BaseMappings.ts 26 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760
  1. /*************************************************************
  2. *
  3. * Copyright (c) 2017-2022 The MathJax Consortium
  4. *
  5. * Licensed under the Apache License, Version 2.0 (the "License");
  6. * you may not use this file except in compliance with the License.
  7. * You may obtain a copy of the License at
  8. *
  9. * http://www.apache.org/licenses/LICENSE-2.0
  10. *
  11. * Unless required by applicable law or agreed to in writing, software
  12. * distributed under the License is distributed on an "AS IS" BASIS,
  13. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  14. * See the License for the specific language governing permissions and
  15. * limitations under the License.
  16. */
  17. /**
  18. * @fileoverview Base mappings for TeX Parsing.
  19. *
  20. * @author v.sorge@mathjax.org (Volker Sorge)
  21. */
  22. import * as sm from '../SymbolMap.js';
  23. import {TexConstant} from '../TexConstants.js';
  24. import BaseMethods from './BaseMethods.js';
  25. import ParseMethods from '../ParseMethods.js';
  26. import ParseUtil from '../ParseUtil.js';
  27. import {TEXCLASS} from '../../../core/MmlTree/MmlNode.js';
  28. import {MATHSPACE, em} from '../../../util/lengths.js';
  29. /**
  30. * Letter pattern for parsing identifiers and operators.
  31. */
  32. new sm.RegExpMap('letter', ParseMethods.variable, /[a-z]/i);
  33. /**
  34. * Digit pattern for parsing numbers.
  35. */
  36. new sm.RegExpMap('digit', ParseMethods.digit, /[0-9.,]/);
  37. /**
  38. * Pattern for spotting start of commands.
  39. */
  40. new sm.RegExpMap('command', ParseMethods.controlSequence, /^\\/ );
  41. /**
  42. * Treatment of special characters in LaTeX.
  43. */
  44. new sm.MacroMap('special', {
  45. // This is now handled with a RegExp!
  46. // '\\': 'ControlSequence',
  47. '{': 'Open',
  48. '}': 'Close',
  49. '~': 'Tilde',
  50. '^': 'Superscript',
  51. '_': 'Subscript',
  52. ' ': 'Space',
  53. '\t': 'Space',
  54. '\r': 'Space',
  55. '\n': 'Space',
  56. '\'': 'Prime',
  57. '%': 'Comment',
  58. '&': 'Entry',
  59. '#': 'Hash',
  60. '\u00A0': 'Space',
  61. '\u2019': 'Prime'
  62. }, BaseMethods);
  63. /**
  64. * Macros for identifiers.
  65. */
  66. new sm.CharacterMap('mathchar0mi', ParseMethods.mathchar0mi, {
  67. // Lower-case greek
  68. alpha: '\u03B1',
  69. beta: '\u03B2',
  70. gamma: '\u03B3',
  71. delta: '\u03B4',
  72. epsilon: '\u03F5',
  73. zeta: '\u03B6',
  74. eta: '\u03B7',
  75. theta: '\u03B8',
  76. iota: '\u03B9',
  77. kappa: '\u03BA',
  78. lambda: '\u03BB',
  79. mu: '\u03BC',
  80. nu: '\u03BD',
  81. xi: '\u03BE',
  82. omicron: '\u03BF', // added for completeness
  83. pi: '\u03C0',
  84. rho: '\u03C1',
  85. sigma: '\u03C3',
  86. tau: '\u03C4',
  87. upsilon: '\u03C5',
  88. phi: '\u03D5',
  89. chi: '\u03C7',
  90. psi: '\u03C8',
  91. omega: '\u03C9',
  92. varepsilon: '\u03B5',
  93. vartheta: '\u03D1',
  94. varpi: '\u03D6',
  95. varrho: '\u03F1',
  96. varsigma: '\u03C2',
  97. varphi: '\u03C6',
  98. // Ord symbols
  99. S: ['\u00A7', {mathvariant: TexConstant.Variant.NORMAL}],
  100. aleph: ['\u2135', {mathvariant: TexConstant.Variant.NORMAL}],
  101. hbar: ['\u210F', {variantForm: true}],
  102. imath: '\u0131',
  103. jmath: '\u0237',
  104. ell: '\u2113',
  105. wp: ['\u2118', {mathvariant: TexConstant.Variant.NORMAL}],
  106. Re: ['\u211C', {mathvariant: TexConstant.Variant.NORMAL}],
  107. Im: ['\u2111', {mathvariant: TexConstant.Variant.NORMAL}],
  108. partial: ['\u2202', {mathvariant: TexConstant.Variant.ITALIC}],
  109. infty: ['\u221E', {mathvariant: TexConstant.Variant.NORMAL}],
  110. prime: ['\u2032', {variantForm: true}],
  111. emptyset: ['\u2205', {mathvariant: TexConstant.Variant.NORMAL}],
  112. nabla: ['\u2207', {mathvariant: TexConstant.Variant.NORMAL}],
  113. top: ['\u22A4', {mathvariant: TexConstant.Variant.NORMAL}],
  114. bot: ['\u22A5', {mathvariant: TexConstant.Variant.NORMAL}],
  115. angle: ['\u2220', {mathvariant: TexConstant.Variant.NORMAL}],
  116. triangle: ['\u25B3', {mathvariant: TexConstant.Variant.NORMAL}],
  117. backslash: ['\u2216', {mathvariant: TexConstant.Variant.NORMAL}],
  118. forall: ['\u2200', {mathvariant: TexConstant.Variant.NORMAL}],
  119. exists: ['\u2203', {mathvariant: TexConstant.Variant.NORMAL}],
  120. neg: ['\u00AC', {mathvariant: TexConstant.Variant.NORMAL}],
  121. lnot: ['\u00AC', {mathvariant: TexConstant.Variant.NORMAL}],
  122. flat: ['\u266D', {mathvariant: TexConstant.Variant.NORMAL}],
  123. natural: ['\u266E', {mathvariant: TexConstant.Variant.NORMAL}],
  124. sharp: ['\u266F', {mathvariant: TexConstant.Variant.NORMAL}],
  125. clubsuit: ['\u2663', {mathvariant: TexConstant.Variant.NORMAL}],
  126. diamondsuit: ['\u2662', {mathvariant: TexConstant.Variant.NORMAL}],
  127. heartsuit: ['\u2661', {mathvariant: TexConstant.Variant.NORMAL}],
  128. spadesuit: ['\u2660', {mathvariant: TexConstant.Variant.NORMAL}]
  129. });
  130. /**
  131. * Macros for operators.
  132. */
  133. new sm.CharacterMap('mathchar0mo', ParseMethods.mathchar0mo, {
  134. surd: '\u221A',
  135. // big ops
  136. coprod: ['\u2210', {texClass: TEXCLASS.OP,
  137. movesupsub: true}],
  138. bigvee: ['\u22C1', {texClass: TEXCLASS.OP,
  139. movesupsub: true}],
  140. bigwedge: ['\u22C0', {texClass: TEXCLASS.OP,
  141. movesupsub: true}],
  142. biguplus: ['\u2A04', {texClass: TEXCLASS.OP,
  143. movesupsub: true}],
  144. bigcap: ['\u22C2', {texClass: TEXCLASS.OP,
  145. movesupsub: true}],
  146. bigcup: ['\u22C3', {texClass: TEXCLASS.OP,
  147. movesupsub: true}],
  148. 'int': ['\u222B', {texClass: TEXCLASS.OP}],
  149. intop: ['\u222B', {texClass: TEXCLASS.OP,
  150. movesupsub: true, movablelimits: true}],
  151. iint: ['\u222C', {texClass: TEXCLASS.OP}],
  152. iiint: ['\u222D', {texClass: TEXCLASS.OP}],
  153. prod: ['\u220F', {texClass: TEXCLASS.OP,
  154. movesupsub: true}],
  155. sum: ['\u2211', {texClass: TEXCLASS.OP,
  156. movesupsub: true}],
  157. bigotimes: ['\u2A02', {texClass: TEXCLASS.OP,
  158. movesupsub: true}],
  159. bigoplus: ['\u2A01', {texClass: TEXCLASS.OP,
  160. movesupsub: true}],
  161. bigodot: ['\u2A00', {texClass: TEXCLASS.OP,
  162. movesupsub: true}],
  163. oint: ['\u222E', {texClass: TEXCLASS.OP}],
  164. bigsqcup: ['\u2A06', {texClass: TEXCLASS.OP,
  165. movesupsub: true}],
  166. smallint: ['\u222B', {largeop: false}],
  167. // binary operations
  168. triangleleft: '\u25C3',
  169. triangleright: '\u25B9',
  170. bigtriangleup: '\u25B3',
  171. bigtriangledown: '\u25BD',
  172. wedge: '\u2227',
  173. land: '\u2227',
  174. vee: '\u2228',
  175. lor: '\u2228',
  176. cap: '\u2229',
  177. cup: '\u222A',
  178. ddagger: '\u2021',
  179. dagger: '\u2020',
  180. sqcap: '\u2293',
  181. sqcup: '\u2294',
  182. uplus: '\u228E',
  183. amalg: '\u2A3F',
  184. diamond: '\u22C4',
  185. bullet: '\u2219',
  186. wr: '\u2240',
  187. div: '\u00F7',
  188. divsymbol: '\u00F7',
  189. odot: ['\u2299', {largeop: false}],
  190. oslash: ['\u2298', {largeop: false}],
  191. otimes: ['\u2297', {largeop: false}],
  192. ominus: ['\u2296', {largeop: false}],
  193. oplus: ['\u2295', {largeop: false}],
  194. mp: '\u2213',
  195. pm: '\u00B1',
  196. circ: '\u2218',
  197. bigcirc: '\u25EF',
  198. setminus: '\u2216',
  199. cdot: '\u22C5',
  200. ast: '\u2217',
  201. times: '\u00D7',
  202. star: '\u22C6',
  203. // Relations
  204. propto: '\u221D',
  205. sqsubseteq: '\u2291',
  206. sqsupseteq: '\u2292',
  207. parallel: '\u2225',
  208. mid: '\u2223',
  209. dashv: '\u22A3',
  210. vdash: '\u22A2',
  211. leq: '\u2264',
  212. le: '\u2264',
  213. geq: '\u2265',
  214. ge: '\u2265',
  215. lt: '\u003C',
  216. gt: '\u003E',
  217. succ: '\u227B',
  218. prec: '\u227A',
  219. approx: '\u2248',
  220. succeq: '\u2AB0', // or '227C',
  221. preceq: '\u2AAF', // or '227D',
  222. supset: '\u2283',
  223. subset: '\u2282',
  224. supseteq: '\u2287',
  225. subseteq: '\u2286',
  226. 'in': '\u2208',
  227. ni: '\u220B',
  228. notin: '\u2209',
  229. owns: '\u220B',
  230. gg: '\u226B',
  231. ll: '\u226A',
  232. sim: '\u223C',
  233. simeq: '\u2243',
  234. perp: '\u22A5',
  235. equiv: '\u2261',
  236. asymp: '\u224D',
  237. smile: '\u2323',
  238. frown: '\u2322',
  239. ne: '\u2260',
  240. neq: '\u2260',
  241. cong: '\u2245',
  242. doteq: '\u2250',
  243. bowtie: '\u22C8',
  244. models: '\u22A8',
  245. notChar: '\u29F8',
  246. // Arrows
  247. Leftrightarrow: '\u21D4',
  248. Leftarrow: '\u21D0',
  249. Rightarrow: '\u21D2',
  250. leftrightarrow: '\u2194',
  251. leftarrow: '\u2190',
  252. gets: '\u2190',
  253. rightarrow: '\u2192',
  254. to: ['\u2192', {accent: false}],
  255. mapsto: '\u21A6',
  256. leftharpoonup: '\u21BC',
  257. leftharpoondown: '\u21BD',
  258. rightharpoonup: '\u21C0',
  259. rightharpoondown: '\u21C1',
  260. nearrow: '\u2197',
  261. searrow: '\u2198',
  262. nwarrow: '\u2196',
  263. swarrow: '\u2199',
  264. rightleftharpoons: '\u21CC',
  265. hookrightarrow: '\u21AA',
  266. hookleftarrow: '\u21A9',
  267. longleftarrow: '\u27F5',
  268. Longleftarrow: '\u27F8',
  269. longrightarrow: '\u27F6',
  270. Longrightarrow: '\u27F9',
  271. Longleftrightarrow: '\u27FA',
  272. longleftrightarrow: '\u27F7',
  273. longmapsto: '\u27FC',
  274. // Misc.
  275. ldots: '\u2026',
  276. cdots: '\u22EF',
  277. vdots: '\u22EE',
  278. ddots: '\u22F1',
  279. dotsc: '\u2026', // dots with commas
  280. dotsb: '\u22EF', // dots with binary ops and relations
  281. dotsm: '\u22EF', // dots with multiplication
  282. dotsi: '\u22EF', // dots with integrals
  283. dotso: '\u2026', // other dots
  284. ldotp: ['\u002E', {texClass: TEXCLASS.PUNCT}],
  285. cdotp: ['\u22C5', {texClass: TEXCLASS.PUNCT}],
  286. colon: ['\u003A', {texClass: TEXCLASS.PUNCT}]
  287. });
  288. /**
  289. * Macros for special characters and identifiers.
  290. */
  291. new sm.CharacterMap('mathchar7', ParseMethods.mathchar7, {
  292. Gamma: '\u0393',
  293. Delta: '\u0394',
  294. Theta: '\u0398',
  295. Lambda: '\u039B',
  296. Xi: '\u039E',
  297. Pi: '\u03A0',
  298. Sigma: '\u03A3',
  299. Upsilon: '\u03A5',
  300. Phi: '\u03A6',
  301. Psi: '\u03A8',
  302. Omega: '\u03A9',
  303. '_': '\u005F',
  304. '#': '\u0023',
  305. '$': '\u0024',
  306. '%': '\u0025',
  307. '&': '\u0026',
  308. And: '\u0026'
  309. });
  310. /**
  311. * Macros for delimiters.
  312. */
  313. new sm.DelimiterMap('delimiter', ParseMethods.delimiter, {
  314. '(': '(',
  315. ')': ')',
  316. '[': '[',
  317. ']': ']',
  318. '<': '\u27E8',
  319. '>': '\u27E9',
  320. '\\lt': '\u27E8',
  321. '\\gt': '\u27E9',
  322. '/': '/',
  323. '|': ['|', {texClass: TEXCLASS.ORD}],
  324. '.': '',
  325. '\\\\': '\\',
  326. '\\lmoustache': '\u23B0', // non-standard
  327. '\\rmoustache': '\u23B1', // non-standard
  328. '\\lgroup': '\u27EE', // non-standard
  329. '\\rgroup': '\u27EF', // non-standard
  330. '\\arrowvert': '\u23D0',
  331. '\\Arrowvert': '\u2016',
  332. '\\bracevert': '\u23AA', // non-standard
  333. '\\Vert': ['\u2016', {texClass: TEXCLASS.ORD}],
  334. '\\|': ['\u2016', {texClass: TEXCLASS.ORD}],
  335. '\\vert': ['|', {texClass: TEXCLASS.ORD}],
  336. '\\uparrow': '\u2191',
  337. '\\downarrow': '\u2193',
  338. '\\updownarrow': '\u2195',
  339. '\\Uparrow': '\u21D1',
  340. '\\Downarrow': '\u21D3',
  341. '\\Updownarrow': '\u21D5',
  342. '\\backslash': '\\',
  343. '\\rangle': '\u27E9',
  344. '\\langle': '\u27E8',
  345. '\\rbrace': '}',
  346. '\\lbrace': '{',
  347. '\\}': '}',
  348. '\\{': '{',
  349. '\\rceil': '\u2309',
  350. '\\lceil': '\u2308',
  351. '\\rfloor': '\u230B',
  352. '\\lfloor': '\u230A',
  353. '\\lbrack': '[',
  354. '\\rbrack': ']'
  355. });
  356. /**
  357. * Macros for LaTeX commands.
  358. */
  359. new sm.CommandMap('macros', {
  360. displaystyle: ['SetStyle', 'D', true, 0],
  361. textstyle: ['SetStyle', 'T', false, 0],
  362. scriptstyle: ['SetStyle', 'S', false, 1],
  363. scriptscriptstyle: ['SetStyle', 'SS', false, 2],
  364. rm: ['SetFont', TexConstant.Variant.NORMAL],
  365. mit: ['SetFont', TexConstant.Variant.ITALIC],
  366. oldstyle: ['SetFont', TexConstant.Variant.OLDSTYLE],
  367. cal: ['SetFont', TexConstant.Variant.CALLIGRAPHIC],
  368. it: ['SetFont', TexConstant.Variant.MATHITALIC], // needs special handling
  369. bf: ['SetFont', TexConstant.Variant.BOLD],
  370. bbFont: ['SetFont', TexConstant.Variant.DOUBLESTRUCK],
  371. scr: ['SetFont', TexConstant.Variant.SCRIPT],
  372. frak: ['SetFont', TexConstant.Variant.FRAKTUR],
  373. sf: ['SetFont', TexConstant.Variant.SANSSERIF],
  374. tt: ['SetFont', TexConstant.Variant.MONOSPACE],
  375. mathrm: ['MathFont', TexConstant.Variant.NORMAL],
  376. mathup: ['MathFont', TexConstant.Variant.NORMAL],
  377. mathnormal: ['MathFont', ''],
  378. mathbf: ['MathFont', TexConstant.Variant.BOLD],
  379. mathbfup: ['MathFont', TexConstant.Variant.BOLD],
  380. mathit: ['MathFont', TexConstant.Variant.MATHITALIC],
  381. mathbfit: ['MathFont', TexConstant.Variant.BOLDITALIC],
  382. mathbb: ['MathFont', TexConstant.Variant.DOUBLESTRUCK],
  383. Bbb: ['MathFont', TexConstant.Variant.DOUBLESTRUCK],
  384. mathfrak: ['MathFont', TexConstant.Variant.FRAKTUR],
  385. mathbffrak: ['MathFont', TexConstant.Variant.BOLDFRAKTUR],
  386. mathscr: ['MathFont', TexConstant.Variant.SCRIPT],
  387. mathbfscr: ['MathFont', TexConstant.Variant.BOLDSCRIPT],
  388. mathsf: ['MathFont', TexConstant.Variant.SANSSERIF],
  389. mathsfup: ['MathFont', TexConstant.Variant.SANSSERIF],
  390. mathbfsf: ['MathFont', TexConstant.Variant.BOLDSANSSERIF],
  391. mathbfsfup: ['MathFont', TexConstant.Variant.BOLDSANSSERIF],
  392. mathsfit: ['MathFont', TexConstant.Variant.SANSSERIFITALIC],
  393. mathbfsfit: ['MathFont', TexConstant.Variant.SANSSERIFBOLDITALIC],
  394. mathtt: ['MathFont', TexConstant.Variant.MONOSPACE],
  395. mathcal: ['MathFont', TexConstant.Variant.CALLIGRAPHIC],
  396. mathbfcal: ['MathFont', TexConstant.Variant.BOLDCALLIGRAPHIC],
  397. symrm: ['MathFont', TexConstant.Variant.NORMAL],
  398. symup: ['MathFont', TexConstant.Variant.NORMAL],
  399. symnormal: ['MathFont', ''],
  400. symbf: ['MathFont', TexConstant.Variant.BOLD],
  401. symbfup: ['MathFont', TexConstant.Variant.BOLD],
  402. symit: ['MathFont', TexConstant.Variant.ITALIC],
  403. symbfit: ['MathFont', TexConstant.Variant.BOLDITALIC],
  404. symbb: ['MathFont', TexConstant.Variant.DOUBLESTRUCK],
  405. symfrak: ['MathFont', TexConstant.Variant.FRAKTUR],
  406. symbffrak: ['MathFont', TexConstant.Variant.BOLDFRAKTUR],
  407. symscr: ['MathFont', TexConstant.Variant.SCRIPT],
  408. symbfscr: ['MathFont', TexConstant.Variant.BOLDSCRIPT],
  409. symsf: ['MathFont', TexConstant.Variant.SANSSERIF],
  410. symsfup: ['MathFont', TexConstant.Variant.SANSSERIF],
  411. symbfsf: ['MathFont', TexConstant.Variant.BOLDSANSSERIF],
  412. symbfsfup: ['MathFont', TexConstant.Variant.BOLDSANSSERIF],
  413. symsfit: ['MathFont', TexConstant.Variant.SANSSERIFITALIC],
  414. symbfsfit: ['MathFont', TexConstant.Variant.SANSSERIFBOLDITALIC],
  415. symtt: ['MathFont', TexConstant.Variant.MONOSPACE],
  416. symcal: ['MathFont', TexConstant.Variant.CALLIGRAPHIC],
  417. symbfcal: ['MathFont', TexConstant.Variant.BOLDCALLIGRAPHIC],
  418. textrm: ['HBox', null, TexConstant.Variant.NORMAL],
  419. textup: ['HBox', null, TexConstant.Variant.NORMAL],
  420. textnormal: ['HBox'],
  421. textit: ['HBox', null, TexConstant.Variant.ITALIC],
  422. textbf: ['HBox', null, TexConstant.Variant.BOLD],
  423. textsf: ['HBox', null, TexConstant.Variant.SANSSERIF],
  424. texttt: ['HBox', null, TexConstant.Variant.MONOSPACE],
  425. tiny: ['SetSize', 0.5],
  426. Tiny: ['SetSize', 0.6], // non-standard
  427. scriptsize: ['SetSize', 0.7],
  428. small: ['SetSize', 0.85],
  429. normalsize: ['SetSize', 1.0],
  430. large: ['SetSize', 1.2],
  431. Large: ['SetSize', 1.44],
  432. LARGE: ['SetSize', 1.73],
  433. huge: ['SetSize', 2.07],
  434. Huge: ['SetSize', 2.49],
  435. arcsin: 'NamedFn',
  436. arccos: 'NamedFn',
  437. arctan: 'NamedFn',
  438. arg: 'NamedFn',
  439. cos: 'NamedFn',
  440. cosh: 'NamedFn',
  441. cot: 'NamedFn',
  442. coth: 'NamedFn',
  443. csc: 'NamedFn',
  444. deg: 'NamedFn',
  445. det: 'NamedOp',
  446. dim: 'NamedFn',
  447. exp: 'NamedFn',
  448. gcd: 'NamedOp',
  449. hom: 'NamedFn',
  450. inf: 'NamedOp',
  451. ker: 'NamedFn',
  452. lg: 'NamedFn',
  453. lim: 'NamedOp',
  454. liminf: ['NamedOp', 'lim&thinsp;inf'],
  455. limsup: ['NamedOp', 'lim&thinsp;sup'],
  456. ln: 'NamedFn',
  457. log: 'NamedFn',
  458. max: 'NamedOp',
  459. min: 'NamedOp',
  460. Pr: 'NamedOp',
  461. sec: 'NamedFn',
  462. sin: 'NamedFn',
  463. sinh: 'NamedFn',
  464. sup: 'NamedOp',
  465. tan: 'NamedFn',
  466. tanh: 'NamedFn',
  467. limits: ['Limits', 1],
  468. nolimits: ['Limits', 0],
  469. overline: ['UnderOver', '2015'],
  470. underline: ['UnderOver', '2015'],
  471. overbrace: ['UnderOver', '23DE', 1],
  472. underbrace: ['UnderOver', '23DF', 1],
  473. overparen: ['UnderOver', '23DC'],
  474. underparen: ['UnderOver', '23DD'],
  475. overrightarrow: ['UnderOver', '2192'],
  476. underrightarrow: ['UnderOver', '2192'],
  477. overleftarrow: ['UnderOver', '2190'],
  478. underleftarrow: ['UnderOver', '2190'],
  479. overleftrightarrow: ['UnderOver', '2194'],
  480. underleftrightarrow: ['UnderOver', '2194'],
  481. overset: 'Overset',
  482. underset: 'Underset',
  483. overunderset: 'Overunderset',
  484. stackrel: ['Macro', '\\mathrel{\\mathop{#2}\\limits^{#1}}', 2],
  485. stackbin: ['Macro', '\\mathbin{\\mathop{#2}\\limits^{#1}}', 2],
  486. over: 'Over',
  487. overwithdelims: 'Over',
  488. atop: 'Over',
  489. atopwithdelims: 'Over',
  490. above: 'Over',
  491. abovewithdelims: 'Over',
  492. brace: ['Over', '{', '}'],
  493. brack: ['Over', '[', ']'],
  494. choose: ['Over', '(', ')'],
  495. frac: 'Frac',
  496. sqrt: 'Sqrt',
  497. root: 'Root',
  498. uproot: ['MoveRoot', 'upRoot'],
  499. leftroot: ['MoveRoot', 'leftRoot'],
  500. left: 'LeftRight',
  501. right: 'LeftRight',
  502. middle: 'LeftRight',
  503. llap: 'Lap',
  504. rlap: 'Lap',
  505. raise: 'RaiseLower',
  506. lower: 'RaiseLower',
  507. moveleft: 'MoveLeftRight',
  508. moveright: 'MoveLeftRight',
  509. ',': ['Spacer', MATHSPACE.thinmathspace],
  510. ':': ['Spacer', MATHSPACE.mediummathspace],
  511. '>': ['Spacer', MATHSPACE.mediummathspace],
  512. ';': ['Spacer', MATHSPACE.thickmathspace],
  513. '!': ['Spacer', MATHSPACE.negativethinmathspace],
  514. enspace: ['Spacer', .5],
  515. quad: ['Spacer', 1],
  516. qquad: ['Spacer', 2],
  517. thinspace: ['Spacer', MATHSPACE.thinmathspace],
  518. negthinspace: ['Spacer', MATHSPACE.negativethinmathspace],
  519. hskip: 'Hskip',
  520. hspace: 'Hskip',
  521. kern: 'Hskip',
  522. mskip: 'Hskip',
  523. mspace: 'Hskip',
  524. mkern: 'Hskip',
  525. rule: 'rule',
  526. Rule: ['Rule'],
  527. Space: ['Rule', 'blank'],
  528. nonscript: 'Nonscript',
  529. big: ['MakeBig', TEXCLASS.ORD, 0.85],
  530. Big: ['MakeBig', TEXCLASS.ORD, 1.15],
  531. bigg: ['MakeBig', TEXCLASS.ORD, 1.45],
  532. Bigg: ['MakeBig', TEXCLASS.ORD, 1.75],
  533. bigl: ['MakeBig', TEXCLASS.OPEN, 0.85],
  534. Bigl: ['MakeBig', TEXCLASS.OPEN, 1.15],
  535. biggl: ['MakeBig', TEXCLASS.OPEN, 1.45],
  536. Biggl: ['MakeBig', TEXCLASS.OPEN, 1.75],
  537. bigr: ['MakeBig', TEXCLASS.CLOSE, 0.85],
  538. Bigr: ['MakeBig', TEXCLASS.CLOSE, 1.15],
  539. biggr: ['MakeBig', TEXCLASS.CLOSE, 1.45],
  540. Biggr: ['MakeBig', TEXCLASS.CLOSE, 1.75],
  541. bigm: ['MakeBig', TEXCLASS.REL, 0.85],
  542. Bigm: ['MakeBig', TEXCLASS.REL, 1.15],
  543. biggm: ['MakeBig', TEXCLASS.REL, 1.45],
  544. Biggm: ['MakeBig', TEXCLASS.REL, 1.75],
  545. mathord: ['TeXAtom', TEXCLASS.ORD],
  546. mathop: ['TeXAtom', TEXCLASS.OP],
  547. mathopen: ['TeXAtom', TEXCLASS.OPEN],
  548. mathclose: ['TeXAtom', TEXCLASS.CLOSE],
  549. mathbin: ['TeXAtom', TEXCLASS.BIN],
  550. mathrel: ['TeXAtom', TEXCLASS.REL],
  551. mathpunct: ['TeXAtom', TEXCLASS.PUNCT],
  552. mathinner: ['TeXAtom', TEXCLASS.INNER],
  553. vcenter: ['TeXAtom', TEXCLASS.VCENTER],
  554. buildrel: 'BuildRel',
  555. hbox: ['HBox', 0],
  556. text: 'HBox',
  557. mbox: ['HBox', 0],
  558. fbox: 'FBox',
  559. boxed: ['Macro', '\\fbox{$\\displaystyle{#1}$}', 1],
  560. framebox: 'FrameBox',
  561. strut: 'Strut',
  562. mathstrut: ['Macro', '\\vphantom{(}'],
  563. phantom: 'Phantom',
  564. vphantom: ['Phantom', 1, 0],
  565. hphantom: ['Phantom', 0, 1],
  566. smash: 'Smash',
  567. acute: ['Accent', '00B4'], // or 0301 or 02CA
  568. grave: ['Accent', '0060'], // or 0300 or 02CB
  569. ddot: ['Accent', '00A8'], // or 0308
  570. tilde: ['Accent', '007E'], // or 0303 or 02DC
  571. bar: ['Accent', '00AF'], // or 0304 or 02C9
  572. breve: ['Accent', '02D8'], // or 0306
  573. check: ['Accent', '02C7'], // or 030C
  574. hat: ['Accent', '005E'], // or 0302 or 02C6
  575. vec: ['Accent', '2192'], // or 20D7
  576. dot: ['Accent', '02D9'], // or 0307
  577. widetilde: ['Accent', '007E', 1], // or 0303 or 02DC
  578. widehat: ['Accent', '005E', 1], // or 0302 or 02C6
  579. matrix: 'Matrix',
  580. array: 'Matrix',
  581. pmatrix: ['Matrix', '(', ')'],
  582. cases: ['Matrix', '{', '', 'left left', null, '.1em', null,
  583. true],
  584. eqalign: ['Matrix', null, null, 'right left',
  585. em(MATHSPACE.thickmathspace), '.5em', 'D'],
  586. displaylines: ['Matrix', null, null, 'center', null, '.5em', 'D'],
  587. cr: 'Cr',
  588. '\\': 'CrLaTeX',
  589. newline: ['CrLaTeX', true],
  590. hline: ['HLine', 'solid'],
  591. hdashline: ['HLine', 'dashed'],
  592. // noalign: 'HandleNoAlign',
  593. eqalignno: ['Matrix', null, null, 'right left',
  594. em(MATHSPACE.thickmathspace), '.5em', 'D', null,
  595. 'right'],
  596. leqalignno: ['Matrix', null, null, 'right left',
  597. em(MATHSPACE.thickmathspace), '.5em', 'D', null,
  598. 'left'],
  599. hfill: 'HFill',
  600. hfil: 'HFill', // \hfil treated as \hfill for now
  601. hfilll: 'HFill', // \hfilll treated as \hfill for now
  602. // TeX substitution macros
  603. bmod: ['Macro', '\\mmlToken{mo}[lspace="thickmathspace"' +
  604. ' rspace="thickmathspace"]{mod}'],
  605. pmod: ['Macro', '\\pod{\\mmlToken{mi}{mod}\\kern 6mu #1}', 1],
  606. mod: ['Macro', '\\mathchoice{\\kern18mu}{\\kern12mu}' +
  607. '{\\kern12mu}{\\kern12mu}\\mmlToken{mi}{mod}\\,\\,#1',
  608. 1],
  609. pod: ['Macro', '\\mathchoice{\\kern18mu}{\\kern8mu}' +
  610. '{\\kern8mu}{\\kern8mu}(#1)', 1],
  611. iff: ['Macro', '\\;\\Longleftrightarrow\\;'],
  612. skew: ['Macro', '{{#2{#3\\mkern#1mu}\\mkern-#1mu}{}}', 3],
  613. pmb: ['Macro', '\\rlap{#1}\\kern1px{#1}', 1],
  614. TeX: ['Macro', 'T\\kern-.14em\\lower.5ex{E}\\kern-.115em X'],
  615. LaTeX: ['Macro', 'L\\kern-.325em\\raise.21em' +
  616. '{\\scriptstyle{A}}\\kern-.17em\\TeX'],
  617. ' ': ['Macro', '\\text{ }'],
  618. // Specially handled
  619. not: 'Not',
  620. dots: 'Dots',
  621. space: 'Tilde',
  622. '\u00A0': 'Tilde',
  623. // LaTeX
  624. begin: 'BeginEnd',
  625. end: 'BeginEnd',
  626. label: 'HandleLabel',
  627. ref: 'HandleRef',
  628. nonumber: 'HandleNoTag',
  629. // Internal use:
  630. mathchoice: 'MathChoice',
  631. mmlToken: 'MmlToken'
  632. }, BaseMethods);
  633. /**
  634. * Macros for LaTeX environments.
  635. */
  636. new sm.EnvironmentMap('environment', ParseMethods.environment, {
  637. array: ['AlignedArray'],
  638. equation: ['Equation', null, true],
  639. eqnarray: ['EqnArray', null, true, true, 'rcl',
  640. ParseUtil.cols(0, MATHSPACE.thickmathspace), '.5em']
  641. }, BaseMethods);
  642. /**
  643. * Mapping for negated operators.
  644. */
  645. new sm.CharacterMap('not_remap', null, {
  646. '\u2190': '\u219A',
  647. '\u2192': '\u219B',
  648. '\u2194': '\u21AE',
  649. '\u21D0': '\u21CD',
  650. '\u21D2': '\u21CF',
  651. '\u21D4': '\u21CE',
  652. '\u2208': '\u2209',
  653. '\u220B': '\u220C',
  654. '\u2223': '\u2224',
  655. '\u2225': '\u2226',
  656. '\u223C': '\u2241',
  657. '\u007E': '\u2241',
  658. '\u2243': '\u2244',
  659. '\u2245': '\u2247',
  660. '\u2248': '\u2249',
  661. '\u224D': '\u226D',
  662. '\u003D': '\u2260',
  663. '\u2261': '\u2262',
  664. '\u003C': '\u226E',
  665. '\u003E': '\u226F',
  666. '\u2264': '\u2270',
  667. '\u2265': '\u2271',
  668. '\u2272': '\u2274',
  669. '\u2273': '\u2275',
  670. '\u2276': '\u2278',
  671. '\u2277': '\u2279',
  672. '\u227A': '\u2280',
  673. '\u227B': '\u2281',
  674. '\u2282': '\u2284',
  675. '\u2283': '\u2285',
  676. '\u2286': '\u2288',
  677. '\u2287': '\u2289',
  678. '\u22A2': '\u22AC',
  679. '\u22A8': '\u22AD',
  680. '\u22A9': '\u22AE',
  681. '\u22AB': '\u22AF',
  682. '\u227C': '\u22E0',
  683. '\u227D': '\u22E1',
  684. '\u2291': '\u22E2',
  685. '\u2292': '\u22E3',
  686. '\u22B2': '\u22EA',
  687. '\u22B3': '\u22EB',
  688. '\u22B4': '\u22EC',
  689. '\u22B5': '\u22ED',
  690. '\u2203': '\u2204'
  691. });