MathtoolsMappings.ts 7.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206
  1. /*************************************************************
  2. * Copyright (c) 2020-2022 MathJax Consortium
  3. *
  4. * Licensed under the Apache License, Version 2.0 (the "License");
  5. * you may not use this file except in compliance with the License.
  6. * You may obtain a copy of the License at
  7. *
  8. * http://www.apache.org/licenses/LICENSE-2.0
  9. *
  10. * Unless required by applicable law or agreed to in writing, software
  11. * distributed under the License is distributed on an "AS IS" BASIS,
  12. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. * See the License for the specific language governing permissions and
  14. * limitations under the License.
  15. */
  16. /**
  17. * @fileoverview Macro and environment mappings for the mathtools package.
  18. *
  19. * @author v.sorge@mathjax.org (Volker Sorge)
  20. * @author dpvc@mathjax.org (Davide P. Cervone)
  21. */
  22. import ParseMethods from '../ParseMethods.js';
  23. import {CommandMap, EnvironmentMap, DelimiterMap} from '../SymbolMap.js';
  24. import {TexConstant} from '../TexConstants.js';
  25. import {MathtoolsMethods} from './MathtoolsMethods.js';
  26. //
  27. // Mathtools macros that are not implemented:
  28. //
  29. // \smashoperator[〈pos〉]{〈operator with limits〉}
  30. // \SwapAboveDisplaySkip
  31. // \noeqref{〈label,label,. . . 〉}
  32. // \intertext{〈text 〉}
  33. // \shortintertext{〈text 〉}
  34. // \reDeclarePairedDelimiterInnerWrapper{〈macro name〉}{〈star or nostarnonscaled or nostarscaled〉}{〈code〉}
  35. // \DeclareMathSizes{〈dimen〉}{〈dimen〉}{〈dimen〉}{〈dimen〉}
  36. // \newgathered{〈name〉}{〈pre_line〉}{〈post_line〉}{〈after〉}
  37. // \renewgathered{〈name〉}{〈pre_line〉}{〈post_line〉}{〈after〉}
  38. //
  39. /**
  40. * The macros for this package.
  41. */
  42. new CommandMap('mathtools-macros', {
  43. shoveleft: ['HandleShove', TexConstant.Align.LEFT], // override AMS version
  44. shoveright: ['HandleShove', TexConstant.Align.RIGHT], // override AMS version
  45. xleftrightarrow: ['xArrow', 0x2194, 10, 10],
  46. xLeftarrow: ['xArrow', 0x21D0, 12, 7],
  47. xRightarrow: ['xArrow', 0x21D2, 7, 12],
  48. xLeftrightarrow: ['xArrow', 0x21D4, 12, 12],
  49. xhookleftarrow: ['xArrow', 0x21A9, 10, 5],
  50. xhookrightarrow: ['xArrow', 0x21AA, 5, 10],
  51. xmapsto: ['xArrow', 0x21A6, 10, 10],
  52. xrightharpoondown: ['xArrow', 0x21C1, 5, 10],
  53. xleftharpoondown: ['xArrow', 0x21BD, 10, 5],
  54. xrightleftharpoons: ['xArrow', 0x21CC, 10, 10],
  55. xrightharpoonup: ['xArrow', 0x21C0, 5, 10],
  56. xleftharpoonup: ['xArrow', 0x21BC, 10, 5],
  57. xleftrightharpoons: ['xArrow', 0x21CB, 10, 10],
  58. mathllap: ['MathLap', 'l', false],
  59. mathrlap: ['MathLap', 'r', false],
  60. mathclap: ['MathLap', 'c', false],
  61. clap: ['MtLap', 'c'],
  62. textllap: ['MtLap', 'l'],
  63. textrlap: ['MtLap', 'r'],
  64. textclap: ['MtLap', 'c'],
  65. cramped: 'Cramped',
  66. crampedllap: ['MathLap', 'l', true],
  67. crampedrlap: ['MathLap', 'r', true],
  68. crampedclap: ['MathLap', 'c', true],
  69. crampedsubstack: ['Macro', '\\begin{crampedsubarray}{c}#1\\end{crampedsubarray}', 1],
  70. mathmbox: 'MathMBox',
  71. mathmakebox: 'MathMakeBox',
  72. overbracket: 'UnderOverBracket',
  73. underbracket: 'UnderOverBracket',
  74. refeq: 'HandleRef',
  75. MoveEqLeft: ['Macro', '\\hspace{#1em}&\\hspace{-#1em}', 1, '2'],
  76. Aboxed: 'Aboxed',
  77. ArrowBetweenLines: 'ArrowBetweenLines',
  78. vdotswithin: 'VDotsWithin',
  79. shortvdotswithin: 'ShortVDotsWithin',
  80. MTFlushSpaceAbove: 'FlushSpaceAbove',
  81. MTFlushSpaceBelow: 'FlushSpaceBelow',
  82. DeclarePairedDelimiter: 'DeclarePairedDelimiter',
  83. DeclarePairedDelimiterX: 'DeclarePairedDelimiterX',
  84. DeclarePairedDelimiterXPP: 'DeclarePairedDelimiterXPP',
  85. //
  86. // Typos from initial release -- kept for backward compatibility for now
  87. //
  88. DeclarePairedDelimiters: 'DeclarePairedDelimiter',
  89. DeclarePairedDelimitersX: 'DeclarePairedDelimiterX',
  90. DeclarePairedDelimitersXPP: 'DeclarePairedDelimiterXPP',
  91. centercolon: ['CenterColon', true, true],
  92. ordinarycolon: ['CenterColon', false],
  93. MTThinColon: ['CenterColon', true, true, true],
  94. coloneqq: ['Relation', ':=', '\u2254'],
  95. Coloneqq: ['Relation', '::=', '\u2A74'],
  96. coloneq: ['Relation', ':-'],
  97. Coloneq: ['Relation', '::-'],
  98. eqqcolon: ['Relation', '=:', '\u2255'],
  99. Eqqcolon: ['Relation', '=::'],
  100. eqcolon: ['Relation', '-:', '\u2239'],
  101. Eqcolon: ['Relation', '-::'],
  102. colonapprox: ['Relation', ':\\approx'],
  103. Colonapprox: ['Relation', '::\\approx'],
  104. colonsim: ['Relation', ':\\sim'],
  105. Colonsim: ['Relation', '::\\sim'],
  106. dblcolon: ['Relation', '::', '\u2237'],
  107. nuparrow: ['NArrow', '\u2191', '.06em'],
  108. ndownarrow: ['NArrow', '\u2193', '.25em'],
  109. bigtimes: ['Macro', '\\mathop{\\Large\\kern-.1em\\boldsymbol{\\times}\\kern-.1em}'],
  110. splitfrac: ['SplitFrac', false],
  111. splitdfrac: ['SplitFrac', true],
  112. xmathstrut: 'XMathStrut',
  113. prescript: 'Prescript',
  114. newtagform: ['NewTagForm', false],
  115. renewtagform: ['NewTagForm', true],
  116. usetagform: 'UseTagForm',
  117. adjustlimits: [
  118. 'MacroWithTemplate',
  119. '\\mathop{{#1}\\vphantom{{#3}}}_{{#2}\\vphantom{{#4}}}\\mathop{{#3}\\vphantom{{#1}}}_{{#4}\\vphantom{{#2}}}',
  120. 4, , '_', , '_'
  121. ],
  122. mathtoolsset: 'SetOptions'
  123. }, MathtoolsMethods);
  124. /**
  125. * The environments for this package.
  126. */
  127. new EnvironmentMap('mathtools-environments', ParseMethods.environment, {
  128. dcases: ['Array', null, '\\{', '', 'll', null, '.2em', 'D'],
  129. rcases: ['Array', null, '', '\\}', 'll', null, '.2em'],
  130. drcases: ['Array', null, '', '\\}', 'll', null, '.2em', 'D'],
  131. 'dcases*': ['Cases', null, '{', '', 'D'],
  132. 'rcases*': ['Cases', null, '', '}'],
  133. 'drcases*': ['Cases', null, '', '}', 'D'],
  134. 'cases*': ['Cases', null, '{', ''],
  135. 'matrix*': ['MtMatrix', null, null, null],
  136. 'pmatrix*': ['MtMatrix', null, '(', ')'],
  137. 'bmatrix*': ['MtMatrix', null, '[', ']'],
  138. 'Bmatrix*': ['MtMatrix', null, '\\{', '\\}'],
  139. 'vmatrix*': ['MtMatrix', null, '\\vert', '\\vert'],
  140. 'Vmatrix*': ['MtMatrix', null, '\\Vert', '\\Vert'],
  141. 'smallmatrix*': ['MtSmallMatrix', null, null, null],
  142. psmallmatrix: ['MtSmallMatrix', null, '(', ')', 'c'],
  143. 'psmallmatrix*': ['MtSmallMatrix', null, '(', ')'],
  144. bsmallmatrix: ['MtSmallMatrix', null, '[', ']', 'c'],
  145. 'bsmallmatrix*': ['MtSmallMatrix', null, '[', ']'],
  146. Bsmallmatrix: ['MtSmallMatrix', null, '\\{', '\\}', 'c'],
  147. 'Bsmallmatrix*': ['MtSmallMatrix', null, '\\{', '\\}'],
  148. vsmallmatrix: ['MtSmallMatrix', null, '\\vert', '\\vert', 'c'],
  149. 'vsmallmatrix*': ['MtSmallMatrix', null, '\\vert', '\\vert'],
  150. Vsmallmatrix: ['MtSmallMatrix', null, '\\Vert', '\\Vert', 'c'],
  151. 'Vsmallmatrix*': ['MtSmallMatrix', null, '\\Vert', '\\Vert'],
  152. crampedsubarray: ['Array', null, null, null, null, '0em', '0.1em', 'S\'', 1],
  153. multlined: 'MtMultlined',
  154. spreadlines: ['SpreadLines', true],
  155. lgathered: ['AmsEqnArray', null, null, null, 'l', null, '.5em', 'D'],
  156. rgathered: ['AmsEqnArray', null, null, null, 'r', null, '.5em', 'D'],
  157. }, MathtoolsMethods);
  158. /**
  159. * The delimiters for this package.
  160. */
  161. new DelimiterMap('mathtools-delimiters', ParseMethods.delimiter, {
  162. '\\lparen': '(',
  163. '\\rparen': ')'
  164. });
  165. /**
  166. * The special characters for this package.
  167. */
  168. new CommandMap('mathtools-characters', {
  169. ':' : ['CenterColon', true]
  170. }, MathtoolsMethods);