| |
| |
| |
| |
|
|
| |
| import defineMacro, {_macros} from "./defineMacro"; |
| const macros = _macros; |
| export default macros; |
|
|
| import fontMetricsData from "./fontMetricsData"; |
| import functions from "./functions"; |
| import symbols from "./symbols"; |
| import {makeEm} from "./units"; |
| import ParseError from "./ParseError"; |
|
|
| import type {MacroContextInterface} from "./defineMacro"; |
|
|
| |
| |
|
|
| defineMacro("\\noexpand", function(context) { |
| |
| |
| |
| const t = context.popToken(); |
| if (context.isExpandable(t.text)) { |
| t.noexpand = true; |
| t.treatAsRelax = true; |
| } |
| return {tokens: [t], numArgs: 0}; |
| }); |
|
|
| defineMacro("\\expandafter", function(context) { |
| |
| |
| |
| |
| |
| const t = context.popToken(); |
| context.expandOnce(true); |
| return {tokens: [t], numArgs: 0}; |
| }); |
|
|
| |
| |
| defineMacro("\\@firstoftwo", function(context) { |
| const args = context.consumeArgs(2); |
| return {tokens: args[0], numArgs: 0}; |
| }); |
|
|
| |
| |
| defineMacro("\\@secondoftwo", function(context) { |
| const args = context.consumeArgs(2); |
| return {tokens: args[1], numArgs: 0}; |
| }); |
|
|
| |
| |
| |
| |
| defineMacro("\\@ifnextchar", function(context) { |
| const args = context.consumeArgs(3); |
| context.consumeSpaces(); |
| const nextToken = context.future(); |
| if (args[0].length === 1 && args[0][0].text === nextToken.text) { |
| return {tokens: args[1], numArgs: 0}; |
| } else { |
| return {tokens: args[2], numArgs: 0}; |
| } |
| }); |
|
|
| |
| |
| |
| |
| defineMacro("\\@ifstar", "\\@ifnextchar *{\\@firstoftwo{#1}}"); |
|
|
| |
| defineMacro("\\TextOrMath", function(context) { |
| const args = context.consumeArgs(2); |
| if (context.mode === 'text') { |
| return {tokens: args[0], numArgs: 0}; |
| } else { |
| return {tokens: args[1], numArgs: 0}; |
| } |
| }); |
|
|
| |
| const digitToNumber: Record<string, number> = { |
| "0": 0, "1": 1, "2": 2, "3": 3, "4": 4, "5": 5, "6": 6, "7": 7, "8": 8, |
| "9": 9, "a": 10, "A": 10, "b": 11, "B": 11, "c": 12, "C": 12, |
| "d": 13, "D": 13, "e": 14, "E": 14, "f": 15, "F": 15, |
| }; |
|
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| defineMacro("\\char", function(context) { |
| let token = context.popToken(); |
| let base; |
| let number = 0; |
| if (token.text === "'") { |
| base = 8; |
| token = context.popToken(); |
| } else if (token.text === '"') { |
| base = 16; |
| token = context.popToken(); |
| } else if (token.text === "`") { |
| token = context.popToken(); |
| if (token.text[0] === "\\") { |
| number = token.text.charCodeAt(1); |
| } else if (token.text === "EOF") { |
| throw new ParseError("\\char` missing argument"); |
| } else { |
| number = token.text.charCodeAt(0); |
| } |
| } else { |
| base = 10; |
| } |
| if (base) { |
| |
| number = digitToNumber[token.text]; |
| if (number == null || number >= base) { |
| throw new ParseError(`Invalid base-${base} digit ${token.text}`); |
| } |
| let digit; |
| while ((digit = digitToNumber[context.future().text]) != null && |
| digit < base) { |
| number *= base; |
| number += digit; |
| context.popToken(); |
| } |
| } |
| return `\\@char{${number}}`; |
| }); |
|
|
| |
| |
| |
| const newcommand = ( |
| context: MacroContextInterface, |
| existsOK: boolean, |
| nonexistsOK: boolean, |
| skipIfExists: boolean, |
| ) => { |
| let arg = context.consumeArg().tokens; |
| if (arg.length !== 1) { |
| throw new ParseError( |
| "\\newcommand's first argument must be a macro name"); |
| } |
| const name = arg[0].text; |
|
|
| const exists = context.isDefined(name); |
| if (exists && !existsOK) { |
| throw new ParseError(`\\newcommand{${name}} attempting to redefine ` + |
| `${name}; use \\renewcommand`); |
| } |
| if (!exists && !nonexistsOK) { |
| throw new ParseError(`\\renewcommand{${name}} when command ${name} ` + |
| `does not yet exist; use \\newcommand`); |
| } |
|
|
| let numArgs = 0; |
| arg = context.consumeArg().tokens; |
| if (arg.length === 1 && arg[0].text === "[") { |
| let argText = ''; |
| let token = context.expandNextToken(); |
| while (token.text !== "]" && token.text !== "EOF") { |
| |
| argText += token.text; |
| token = context.expandNextToken(); |
| } |
| if (!argText.match(/^\s*[0-9]+\s*$/)) { |
| throw new ParseError(`Invalid number of arguments: ${argText}`); |
| } |
| numArgs = parseInt(argText); |
| arg = context.consumeArg().tokens; |
| } |
|
|
| if (!(exists && skipIfExists)) { |
| |
| context.macros.set(name, { |
| tokens: arg, |
| numArgs, |
| }); |
| } |
| return ''; |
| }; |
| defineMacro("\\newcommand", |
| (context) => newcommand(context, false, true, false)); |
| defineMacro("\\renewcommand", |
| (context) => newcommand(context, true, false, false)); |
| defineMacro("\\providecommand", |
| (context) => newcommand(context, true, true, true)); |
|
|
| |
| defineMacro("\\message", (context) => { |
| const arg = context.consumeArgs(1)[0]; |
| |
| console.log(arg.reverse().map(token => token.text).join("")); |
| return ''; |
| }); |
| defineMacro("\\errmessage", (context) => { |
| const arg = context.consumeArgs(1)[0]; |
| |
| console.error(arg.reverse().map(token => token.text).join("")); |
| return ''; |
| }); |
| defineMacro("\\show", (context) => { |
| const tok = context.popToken(); |
| const name = tok.text; |
| |
| console.log(tok, context.macros.get(name), functions[name], |
| symbols.math[name], symbols.text[name]); |
| return ''; |
| }); |
|
|
| |
| |
| |
| defineMacro("\\bgroup", "{"); |
| defineMacro("\\egroup", "}"); |
|
|
| |
| |
| |
| |
| |
| |
| defineMacro("~", "\\nobreakspace"); |
| defineMacro("\\lq", "`"); |
| defineMacro("\\rq", "'"); |
| defineMacro("\\aa", "\\r a"); |
| defineMacro("\\AA", "\\r A"); |
|
|
| |
| |
| |
| |
| |
| |
| defineMacro("\\textcopyright", "\\html@mathml{\\textcircled{c}}{\\char`©}"); |
| defineMacro("\\copyright", |
| "\\TextOrMath{\\textcopyright}{\\text{\\textcopyright}}"); |
| defineMacro("\\textregistered", |
| "\\html@mathml{\\textcircled{\\scriptsize R}}{\\char`®}"); |
|
|
| |
| defineMacro("\u212C", "\\mathscr{B}"); |
| defineMacro("\u2130", "\\mathscr{E}"); |
| defineMacro("\u2131", "\\mathscr{F}"); |
| defineMacro("\u210B", "\\mathscr{H}"); |
| defineMacro("\u2110", "\\mathscr{I}"); |
| defineMacro("\u2112", "\\mathscr{L}"); |
| defineMacro("\u2133", "\\mathscr{M}"); |
| defineMacro("\u211B", "\\mathscr{R}"); |
| defineMacro("\u212D", "\\mathfrak{C}"); |
| defineMacro("\u210C", "\\mathfrak{H}"); |
| defineMacro("\u2128", "\\mathfrak{Z}"); |
|
|
| |
| defineMacro("\\Bbbk", "\\Bbb{k}"); |
|
|
| |
| defineMacro("\\llap", "\\mathllap{\\textrm{#1}}"); |
| defineMacro("\\rlap", "\\mathrlap{\\textrm{#1}}"); |
| defineMacro("\\clap", "\\mathclap{\\textrm{#1}}"); |
|
|
| |
| defineMacro("\\mathstrut", "\\vphantom{(}"); |
|
|
| |
| defineMacro("\\underbar", "\\underline{\\text{#1}}"); |
|
|
| |
| |
| |
| |
| |
| defineMacro("\\not", "\\html@mathml{\\mathrel{\\mathrlap\\@not}\\nobreak}" + |
| "{\\char\"338}"); |
|
|
| |
| |
| |
| |
| |
| defineMacro("\\neq", "\\html@mathml{\\mathrel{\\not=}}{\\mathrel{\\char`≠}}"); |
| defineMacro("\\ne", "\\neq"); |
| defineMacro("\u2260", "\\neq"); |
| defineMacro("\\notin", "\\html@mathml{\\mathrel{{\\in}\\mathllap{/\\mskip1mu}}}" |
| + "{\\mathrel{\\char`∉}}"); |
| defineMacro("\u2209", "\\notin"); |
|
|
| |
| defineMacro("\u2258", "\\html@mathml{" + |
| "\\mathrel{=\\kern{-1em}\\raisebox{0.4em}{$\\scriptsize\\frown$}}" + |
| "}{\\mathrel{\\char`\u2258}}"); |
| defineMacro("\u2259", |
| "\\html@mathml{\\stackrel{\\tiny\\wedge}{=}}{\\mathrel{\\char`\u2258}}"); |
| defineMacro("\u225A", |
| "\\html@mathml{\\stackrel{\\tiny\\vee}{=}}{\\mathrel{\\char`\u225A}}"); |
| defineMacro("\u225B", |
| "\\html@mathml{\\stackrel{\\scriptsize\\star}{=}}" + |
| "{\\mathrel{\\char`\u225B}}"); |
| defineMacro("\u225D", |
| "\\html@mathml{\\stackrel{\\tiny\\mathrm{def}}{=}}" + |
| "{\\mathrel{\\char`\u225D}}"); |
| defineMacro("\u225E", |
| "\\html@mathml{\\stackrel{\\tiny\\mathrm{m}}{=}}" + |
| "{\\mathrel{\\char`\u225E}}"); |
| defineMacro("\u225F", |
| "\\html@mathml{\\stackrel{\\tiny?}{=}}{\\mathrel{\\char`\u225F}}"); |
|
|
| |
| defineMacro("\u27C2", "\\perp"); |
| defineMacro("\u203C", "\\mathclose{!\\mkern-0.8mu!}"); |
| defineMacro("\u220C", "\\notni"); |
| defineMacro("\u231C", "\\ulcorner"); |
| defineMacro("\u231D", "\\urcorner"); |
| defineMacro("\u231E", "\\llcorner"); |
| defineMacro("\u231F", "\\lrcorner"); |
| defineMacro("\u00A9", "\\copyright"); |
| defineMacro("\u00AE", "\\textregistered"); |
|
|
| |
| |
| defineMacro("\\ulcorner", "\\html@mathml{\\@ulcorner}{\\mathop{\\char\"231c}}"); |
| defineMacro("\\urcorner", "\\html@mathml{\\@urcorner}{\\mathop{\\char\"231d}}"); |
| defineMacro("\\llcorner", "\\html@mathml{\\@llcorner}{\\mathop{\\char\"231e}}"); |
| defineMacro("\\lrcorner", "\\html@mathml{\\@lrcorner}{\\mathop{\\char\"231f}}"); |
|
|
| |
| |
|
|
| |
| |
| |
| |
| defineMacro("\\vdots", "{\\varvdots\\rule{0pt}{15pt}}"); |
| defineMacro("\u22ee", "\\vdots"); |
|
|
| |
| |
| |
|
|
| |
| |
| defineMacro("\\varGamma", "\\mathit{\\Gamma}"); |
| defineMacro("\\varDelta", "\\mathit{\\Delta}"); |
| defineMacro("\\varTheta", "\\mathit{\\Theta}"); |
| defineMacro("\\varLambda", "\\mathit{\\Lambda}"); |
| defineMacro("\\varXi", "\\mathit{\\Xi}"); |
| defineMacro("\\varPi", "\\mathit{\\Pi}"); |
| defineMacro("\\varSigma", "\\mathit{\\Sigma}"); |
| defineMacro("\\varUpsilon", "\\mathit{\\Upsilon}"); |
| defineMacro("\\varPhi", "\\mathit{\\Phi}"); |
| defineMacro("\\varPsi", "\\mathit{\\Psi}"); |
| defineMacro("\\varOmega", "\\mathit{\\Omega}"); |
|
|
| |
| defineMacro("\\substack", "\\begin{subarray}{c}#1\\end{subarray}"); |
|
|
| |
| |
| defineMacro("\\colon", "\\nobreak\\mskip2mu\\mathpunct{}" + |
| "\\mathchoice{\\mkern-3mu}{\\mkern-3mu}{}{}{:}\\mskip6mu\\relax"); |
|
|
| |
| defineMacro("\\boxed", "\\fbox{$\\displaystyle{#1}$}"); |
|
|
| |
| |
| |
| defineMacro("\\iff", "\\DOTSB\\;\\Longleftrightarrow\\;"); |
| defineMacro("\\implies", "\\DOTSB\\;\\Longrightarrow\\;"); |
| defineMacro("\\impliedby", "\\DOTSB\\;\\Longleftarrow\\;"); |
|
|
| |
| |
| |
| defineMacro("\\dddot", "{\\overset{\\raisebox{-0.1ex}{\\normalsize ...}}{#1}}"); |
| defineMacro("\\ddddot", "{\\overset{\\raisebox{-0.1ex}{\\normalsize ....}}{#1}}"); |
|
|
| |
| const dotsByToken: Record<string, string> = { |
| ',': '\\dotsc', |
| '\\not': '\\dotsb', |
| |
| '+': '\\dotsb', |
| '=': '\\dotsb', |
| '<': '\\dotsb', |
| '>': '\\dotsb', |
| '-': '\\dotsb', |
| '*': '\\dotsb', |
| ':': '\\dotsb', |
| |
| '\\DOTSB': '\\dotsb', |
| '\\coprod': '\\dotsb', |
| '\\bigvee': '\\dotsb', |
| '\\bigwedge': '\\dotsb', |
| '\\biguplus': '\\dotsb', |
| '\\bigcap': '\\dotsb', |
| '\\bigcup': '\\dotsb', |
| '\\prod': '\\dotsb', |
| '\\sum': '\\dotsb', |
| '\\bigotimes': '\\dotsb', |
| '\\bigoplus': '\\dotsb', |
| '\\bigodot': '\\dotsb', |
| '\\bigsqcup': '\\dotsb', |
| '\\And': '\\dotsb', |
| '\\longrightarrow': '\\dotsb', |
| '\\Longrightarrow': '\\dotsb', |
| '\\longleftarrow': '\\dotsb', |
| '\\Longleftarrow': '\\dotsb', |
| '\\longleftrightarrow': '\\dotsb', |
| '\\Longleftrightarrow': '\\dotsb', |
| '\\mapsto': '\\dotsb', |
| '\\longmapsto': '\\dotsb', |
| '\\hookrightarrow': '\\dotsb', |
| '\\doteq': '\\dotsb', |
| |
| '\\mathbin': '\\dotsb', |
| |
| '\\mathrel': '\\dotsb', |
| '\\relbar': '\\dotsb', |
| '\\Relbar': '\\dotsb', |
| '\\xrightarrow': '\\dotsb', |
| '\\xleftarrow': '\\dotsb', |
| |
| '\\DOTSI': '\\dotsi', |
| '\\int': '\\dotsi', |
| '\\oint': '\\dotsi', |
| '\\iint': '\\dotsi', |
| '\\iiint': '\\dotsi', |
| '\\iiiint': '\\dotsi', |
| '\\idotsint': '\\dotsi', |
| |
| '\\DOTSX': '\\dotsx', |
| }; |
|
|
| const dotsbGroups = new Set(['bin', 'rel']); |
|
|
| defineMacro("\\dots", function(context) { |
| |
| |
| |
| |
| |
| let thedots = '\\dotso'; |
| const next = context.expandAfterFuture().text; |
| if (next in dotsByToken) { |
| thedots = dotsByToken[next]; |
| } else if (next.slice(0, 4) === '\\not') { |
| thedots = '\\dotsb'; |
| } else if (next in symbols.math) { |
| if (dotsbGroups.has(symbols.math[next].group)) { |
| thedots = '\\dotsb'; |
| } |
| } |
| return thedots; |
| }); |
|
|
| const spaceAfterDots = { |
| |
| ')': true, |
| ']': true, |
| '\\rbrack': true, |
| '\\}': true, |
| '\\rbrace': true, |
| '\\rangle': true, |
| '\\rceil': true, |
| '\\rfloor': true, |
| '\\rgroup': true, |
| '\\rmoustache': true, |
| '\\right': true, |
| '\\bigr': true, |
| '\\biggr': true, |
| '\\Bigr': true, |
| '\\Biggr': true, |
| |
| '$': true, |
| |
| ';': true, |
| '.': true, |
| ',': true, |
| }; |
|
|
| defineMacro("\\dotso", function(context) { |
| const next = context.future().text; |
| if (next in spaceAfterDots) { |
| return "\\ldots\\,"; |
| } else { |
| return "\\ldots"; |
| } |
| }); |
|
|
| defineMacro("\\dotsc", function(context) { |
| const next = context.future().text; |
| |
| |
| if (next in spaceAfterDots && next !== ',') { |
| return "\\ldots\\,"; |
| } else { |
| return "\\ldots"; |
| } |
| }); |
|
|
| defineMacro("\\cdots", function(context) { |
| const next = context.future().text; |
| if (next in spaceAfterDots) { |
| return "\\@cdots\\,"; |
| } else { |
| return "\\@cdots"; |
| } |
| }); |
|
|
| defineMacro("\\dotsb", "\\cdots"); |
| defineMacro("\\dotsm", "\\cdots"); |
| defineMacro("\\dotsi", "\\!\\cdots"); |
| |
| |
| |
| defineMacro("\\dotsx", "\\ldots\\,"); |
|
|
| |
| |
| |
| defineMacro("\\DOTSI", "\\relax"); |
| defineMacro("\\DOTSB", "\\relax"); |
| defineMacro("\\DOTSX", "\\relax"); |
|
|
| |
| |
| |
| defineMacro("\\tmspace", "\\TextOrMath{\\kern#1#3}{\\mskip#1#2}\\relax"); |
| |
| |
| defineMacro("\\,", "\\tmspace+{3mu}{.1667em}"); |
| |
| defineMacro("\\thinspace", "\\,"); |
| |
| |
| |
| defineMacro("\\>", "\\mskip{4mu}"); |
| defineMacro("\\:", "\\tmspace+{4mu}{.2222em}"); |
| |
| defineMacro("\\medspace", "\\:"); |
| |
| |
| defineMacro("\\;", "\\tmspace+{5mu}{.2777em}"); |
| |
| defineMacro("\\thickspace", "\\;"); |
| |
| |
| defineMacro("\\!", "\\tmspace-{3mu}{.1667em}"); |
| |
| defineMacro("\\negthinspace", "\\!"); |
| |
| |
| defineMacro("\\negmedspace", "\\tmspace-{4mu}{.2222em}"); |
| |
| |
| defineMacro("\\negthickspace", "\\tmspace-{5mu}{.277em}"); |
| |
| defineMacro("\\enspace", "\\kern.5em "); |
| |
| defineMacro("\\enskip", "\\hskip.5em\\relax"); |
| |
| defineMacro("\\quad", "\\hskip1em\\relax"); |
| |
| defineMacro("\\qquad", "\\hskip2em\\relax"); |
|
|
| |
| defineMacro("\\tag", "\\@ifstar\\tag@literal\\tag@paren"); |
| defineMacro("\\tag@paren", "\\tag@literal{({#1})}"); |
| defineMacro("\\tag@literal", (context) => { |
| if (context.macros.get("\\df@tag")) { |
| throw new ParseError("Multiple \\tag"); |
| } |
| return "\\gdef\\df@tag{\\text{#1}}"; |
| }); |
|
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| defineMacro("\\bmod", |
| "\\mathchoice{\\mskip1mu}{\\mskip1mu}{\\mskip5mu}{\\mskip5mu}" + |
| "\\mathbin{\\rm mod}" + |
| "\\mathchoice{\\mskip1mu}{\\mskip1mu}{\\mskip5mu}{\\mskip5mu}"); |
| defineMacro("\\pod", "\\allowbreak" + |
| "\\mathchoice{\\mkern18mu}{\\mkern8mu}{\\mkern8mu}{\\mkern8mu}(#1)"); |
| defineMacro("\\pmod", "\\pod{{\\rm mod}\\mkern6mu#1}"); |
| defineMacro("\\mod", "\\allowbreak" + |
| "\\mathchoice{\\mkern18mu}{\\mkern12mu}{\\mkern12mu}{\\mkern12mu}" + |
| "{\\rm mod}\\,\\,#1"); |
|
|
| |
| |
|
|
| |
| |
| |
| defineMacro("\\newline", "\\\\\\relax"); |
|
|
| |
| |
| |
| |
| defineMacro("\\TeX", "\\textrm{\\html@mathml{" + |
| "T\\kern-.1667em\\raisebox{-.5ex}{E}\\kern-.125emX" + |
| "}{TeX}}"); |
|
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| const latexRaiseA = makeEm(fontMetricsData['Main-Regular']["T".charCodeAt(0)][1] - |
| 0.7 * fontMetricsData['Main-Regular']["A".charCodeAt(0)][1]); |
| defineMacro("\\LaTeX", "\\textrm{\\html@mathml{" + |
| `L\\kern-.36em\\raisebox{${latexRaiseA}}{\\scriptstyle A}` + |
| "\\kern-.15em\\TeX}{LaTeX}}"); |
|
|
| |
| defineMacro("\\KaTeX", "\\textrm{\\html@mathml{" + |
| `K\\kern-.17em\\raisebox{${latexRaiseA}}{\\scriptstyle A}` + |
| "\\kern-.15em\\TeX}{KaTeX}}"); |
|
|
| |
| |
| |
| |
| defineMacro("\\hspace", "\\@ifstar\\@hspacer\\@hspace"); |
| defineMacro("\\@hspace", "\\hskip #1\\relax"); |
| defineMacro("\\@hspacer", "\\rule{0pt}{0pt}\\hskip #1\\relax"); |
|
|
| |
| |
|
|
| |
| defineMacro("\\ordinarycolon", ":"); |
| |
| |
| defineMacro("\\vcentcolon", "\\mathrel{\\mathop\\ordinarycolon}"); |
| |
| defineMacro("\\dblcolon", "\\html@mathml{" + |
| "\\mathrel{\\vcentcolon\\mathrel{\\mkern-.9mu}\\vcentcolon}}" + |
| "{\\mathop{\\char\"2237}}"); |
| |
| defineMacro("\\coloneqq", "\\html@mathml{" + |
| "\\mathrel{\\vcentcolon\\mathrel{\\mkern-1.2mu}=}}" + |
| "{\\mathop{\\char\"2254}}"); |
| |
| defineMacro("\\Coloneqq", "\\html@mathml{" + |
| "\\mathrel{\\dblcolon\\mathrel{\\mkern-1.2mu}=}}" + |
| "{\\mathop{\\char\"2237\\char\"3d}}"); |
| |
| defineMacro("\\coloneq", "\\html@mathml{" + |
| "\\mathrel{\\vcentcolon\\mathrel{\\mkern-1.2mu}\\mathrel{-}}}" + |
| "{\\mathop{\\char\"3a\\char\"2212}}"); |
| |
| defineMacro("\\Coloneq", "\\html@mathml{" + |
| "\\mathrel{\\dblcolon\\mathrel{\\mkern-1.2mu}\\mathrel{-}}}" + |
| "{\\mathop{\\char\"2237\\char\"2212}}"); |
| |
| defineMacro("\\eqqcolon", "\\html@mathml{" + |
| "\\mathrel{=\\mathrel{\\mkern-1.2mu}\\vcentcolon}}" + |
| "{\\mathop{\\char\"2255}}"); |
| |
| defineMacro("\\Eqqcolon", "\\html@mathml{" + |
| "\\mathrel{=\\mathrel{\\mkern-1.2mu}\\dblcolon}}" + |
| "{\\mathop{\\char\"3d\\char\"2237}}"); |
| |
| defineMacro("\\eqcolon", "\\html@mathml{" + |
| "\\mathrel{\\mathrel{-}\\mathrel{\\mkern-1.2mu}\\vcentcolon}}" + |
| "{\\mathop{\\char\"2239}}"); |
| |
| defineMacro("\\Eqcolon", "\\html@mathml{" + |
| "\\mathrel{\\mathrel{-}\\mathrel{\\mkern-1.2mu}\\dblcolon}}" + |
| "{\\mathop{\\char\"2212\\char\"2237}}"); |
| |
| defineMacro("\\colonapprox", "\\html@mathml{" + |
| "\\mathrel{\\vcentcolon\\mathrel{\\mkern-1.2mu}\\approx}}" + |
| "{\\mathop{\\char\"3a\\char\"2248}}"); |
| |
| defineMacro("\\Colonapprox", "\\html@mathml{" + |
| "\\mathrel{\\dblcolon\\mathrel{\\mkern-1.2mu}\\approx}}" + |
| "{\\mathop{\\char\"2237\\char\"2248}}"); |
| |
| defineMacro("\\colonsim", "\\html@mathml{" + |
| "\\mathrel{\\vcentcolon\\mathrel{\\mkern-1.2mu}\\sim}}" + |
| "{\\mathop{\\char\"3a\\char\"223c}}"); |
| |
| defineMacro("\\Colonsim", "\\html@mathml{" + |
| "\\mathrel{\\dblcolon\\mathrel{\\mkern-1.2mu}\\sim}}" + |
| "{\\mathop{\\char\"2237\\char\"223c}}"); |
|
|
| |
| defineMacro("\u2237", "\\dblcolon"); |
| defineMacro("\u2239", "\\eqcolon"); |
| defineMacro("\u2254", "\\coloneqq"); |
| defineMacro("\u2255", "\\eqqcolon"); |
| defineMacro("\u2A74", "\\Coloneqq"); |
|
|
| |
| |
|
|
| |
| defineMacro("\\ratio", "\\vcentcolon"); |
| defineMacro("\\coloncolon", "\\dblcolon"); |
| defineMacro("\\colonequals", "\\coloneqq"); |
| defineMacro("\\coloncolonequals", "\\Coloneqq"); |
| defineMacro("\\equalscolon", "\\eqqcolon"); |
| defineMacro("\\equalscoloncolon", "\\Eqqcolon"); |
| defineMacro("\\colonminus", "\\coloneq"); |
| defineMacro("\\coloncolonminus", "\\Coloneq"); |
| defineMacro("\\minuscolon", "\\eqcolon"); |
| defineMacro("\\minuscoloncolon", "\\Eqcolon"); |
| |
| defineMacro("\\coloncolonapprox", "\\Colonapprox"); |
| |
| defineMacro("\\coloncolonsim", "\\Colonsim"); |
|
|
| |
| defineMacro("\\simcolon", |
| "\\mathrel{\\sim\\mathrel{\\mkern-1.2mu}\\vcentcolon}"); |
| defineMacro("\\simcoloncolon", |
| "\\mathrel{\\sim\\mathrel{\\mkern-1.2mu}\\dblcolon}"); |
| defineMacro("\\approxcolon", |
| "\\mathrel{\\approx\\mathrel{\\mkern-1.2mu}\\vcentcolon}"); |
| defineMacro("\\approxcoloncolon", |
| "\\mathrel{\\approx\\mathrel{\\mkern-1.2mu}\\dblcolon}"); |
|
|
| |
| defineMacro("\\notni", "\\html@mathml{\\not\\ni}{\\mathrel{\\char`\u220C}}"); |
| defineMacro("\\limsup", "\\DOTSB\\operatorname*{lim\\,sup}"); |
| defineMacro("\\liminf", "\\DOTSB\\operatorname*{lim\\,inf}"); |
|
|
| |
| |
| defineMacro("\\injlim", "\\DOTSB\\operatorname*{inj\\,lim}"); |
| defineMacro("\\projlim", "\\DOTSB\\operatorname*{proj\\,lim}"); |
| defineMacro("\\varlimsup", "\\DOTSB\\operatorname*{\\overline{lim}}"); |
| defineMacro("\\varliminf", "\\DOTSB\\operatorname*{\\underline{lim}}"); |
| defineMacro("\\varinjlim", "\\DOTSB\\operatorname*{\\underrightarrow{lim}}"); |
| defineMacro("\\varprojlim", "\\DOTSB\\operatorname*{\\underleftarrow{lim}}"); |
|
|
| |
| |
| defineMacro("\\gvertneqq", "\\html@mathml{\\@gvertneqq}{\u2269}"); |
| defineMacro("\\lvertneqq", "\\html@mathml{\\@lvertneqq}{\u2268}"); |
| defineMacro("\\ngeqq", "\\html@mathml{\\@ngeqq}{\u2271}"); |
| defineMacro("\\ngeqslant", "\\html@mathml{\\@ngeqslant}{\u2271}"); |
| defineMacro("\\nleqq", "\\html@mathml{\\@nleqq}{\u2270}"); |
| defineMacro("\\nleqslant", "\\html@mathml{\\@nleqslant}{\u2270}"); |
| defineMacro("\\nshortmid", "\\html@mathml{\\@nshortmid}{∤}"); |
| defineMacro("\\nshortparallel", "\\html@mathml{\\@nshortparallel}{∦}"); |
| defineMacro("\\nsubseteqq", "\\html@mathml{\\@nsubseteqq}{\u2288}"); |
| defineMacro("\\nsupseteqq", "\\html@mathml{\\@nsupseteqq}{\u2289}"); |
| defineMacro("\\varsubsetneq", "\\html@mathml{\\@varsubsetneq}{⊊}"); |
| defineMacro("\\varsubsetneqq", "\\html@mathml{\\@varsubsetneqq}{⫋}"); |
| defineMacro("\\varsupsetneq", "\\html@mathml{\\@varsupsetneq}{⊋}"); |
| defineMacro("\\varsupsetneqq", "\\html@mathml{\\@varsupsetneqq}{⫌}"); |
| defineMacro("\\imath", "\\html@mathml{\\@imath}{\u0131}"); |
| defineMacro("\\jmath", "\\html@mathml{\\@jmath}{\u0237}"); |
|
|
| |
| |
|
|
| |
| |
|
|
| defineMacro("\\llbracket", "\\html@mathml{" + |
| "\\mathopen{[\\mkern-3.2mu[}}" + |
| "{\\mathopen{\\char`\u27e6}}"); |
| defineMacro("\\rrbracket", "\\html@mathml{" + |
| "\\mathclose{]\\mkern-3.2mu]}}" + |
| "{\\mathclose{\\char`\u27e7}}"); |
|
|
| defineMacro("\u27e6", "\\llbracket"); |
| defineMacro("\u27e7", "\\rrbracket"); |
|
|
| defineMacro("\\lBrace", "\\html@mathml{" + |
| "\\mathopen{\\{\\mkern-3.2mu[}}" + |
| "{\\mathopen{\\char`\u2983}}"); |
| defineMacro("\\rBrace", "\\html@mathml{" + |
| "\\mathclose{]\\mkern-3.2mu\\}}}" + |
| "{\\mathclose{\\char`\u2984}}"); |
|
|
| defineMacro("\u2983", "\\lBrace"); |
| defineMacro("\u2984", "\\rBrace"); |
|
|
| |
| |
|
|
| |
| |
| defineMacro("\\minuso", "\\mathbin{\\html@mathml{" + |
| "{\\mathrlap{\\mathchoice{\\kern{0.145em}}{\\kern{0.145em}}" + |
| "{\\kern{0.1015em}}{\\kern{0.0725em}}\\circ}{-}}}" + |
| "{\\char`⦵}}"); |
| defineMacro("⦵", "\\minuso"); |
|
|
| |
| |
|
|
| |
| |
| |
|
|
| |
|
|
| defineMacro("\\darr", "\\downarrow"); |
| defineMacro("\\dArr", "\\Downarrow"); |
| defineMacro("\\Darr", "\\Downarrow"); |
| defineMacro("\\lang", "\\langle"); |
| defineMacro("\\rang", "\\rangle"); |
| defineMacro("\\uarr", "\\uparrow"); |
| defineMacro("\\uArr", "\\Uparrow"); |
| defineMacro("\\Uarr", "\\Uparrow"); |
| defineMacro("\\N", "\\mathbb{N}"); |
| defineMacro("\\R", "\\mathbb{R}"); |
| defineMacro("\\Z", "\\mathbb{Z}"); |
| defineMacro("\\alef", "\\aleph"); |
| defineMacro("\\alefsym", "\\aleph"); |
| defineMacro("\\Alpha", "\\mathrm{A}"); |
| defineMacro("\\Beta", "\\mathrm{B}"); |
| defineMacro("\\bull", "\\bullet"); |
| defineMacro("\\Chi", "\\mathrm{X}"); |
| defineMacro("\\clubs", "\\clubsuit"); |
| defineMacro("\\cnums", "\\mathbb{C}"); |
| defineMacro("\\Complex", "\\mathbb{C}"); |
| defineMacro("\\Dagger", "\\ddagger"); |
| defineMacro("\\diamonds", "\\diamondsuit"); |
| defineMacro("\\empty", "\\emptyset"); |
| defineMacro("\\Epsilon", "\\mathrm{E}"); |
| defineMacro("\\Eta", "\\mathrm{H}"); |
| defineMacro("\\exist", "\\exists"); |
| defineMacro("\\harr", "\\leftrightarrow"); |
| defineMacro("\\hArr", "\\Leftrightarrow"); |
| defineMacro("\\Harr", "\\Leftrightarrow"); |
| defineMacro("\\hearts", "\\heartsuit"); |
| defineMacro("\\image", "\\Im"); |
| defineMacro("\\infin", "\\infty"); |
| defineMacro("\\Iota", "\\mathrm{I}"); |
| defineMacro("\\isin", "\\in"); |
| defineMacro("\\Kappa", "\\mathrm{K}"); |
| defineMacro("\\larr", "\\leftarrow"); |
| defineMacro("\\lArr", "\\Leftarrow"); |
| defineMacro("\\Larr", "\\Leftarrow"); |
| defineMacro("\\lrarr", "\\leftrightarrow"); |
| defineMacro("\\lrArr", "\\Leftrightarrow"); |
| defineMacro("\\Lrarr", "\\Leftrightarrow"); |
| defineMacro("\\Mu", "\\mathrm{M}"); |
| defineMacro("\\natnums", "\\mathbb{N}"); |
| defineMacro("\\Nu", "\\mathrm{N}"); |
| defineMacro("\\Omicron", "\\mathrm{O}"); |
| defineMacro("\\plusmn", "\\pm"); |
| defineMacro("\\rarr", "\\rightarrow"); |
| defineMacro("\\rArr", "\\Rightarrow"); |
| defineMacro("\\Rarr", "\\Rightarrow"); |
| defineMacro("\\real", "\\Re"); |
| defineMacro("\\reals", "\\mathbb{R}"); |
| defineMacro("\\Reals", "\\mathbb{R}"); |
| defineMacro("\\Rho", "\\mathrm{P}"); |
| defineMacro("\\sdot", "\\cdot"); |
| defineMacro("\\sect", "\\S"); |
| defineMacro("\\spades", "\\spadesuit"); |
| defineMacro("\\sub", "\\subset"); |
| defineMacro("\\sube", "\\subseteq"); |
| defineMacro("\\supe", "\\supseteq"); |
| defineMacro("\\Tau", "\\mathrm{T}"); |
| defineMacro("\\thetasym", "\\vartheta"); |
| |
| defineMacro("\\weierp", "\\wp"); |
| defineMacro("\\Zeta", "\\mathrm{Z}"); |
|
|
| |
| |
| |
|
|
| defineMacro("\\argmin", "\\DOTSB\\operatorname*{arg\\,min}"); |
| defineMacro("\\argmax", "\\DOTSB\\operatorname*{arg\\,max}"); |
| defineMacro("\\plim", "\\DOTSB\\mathop{\\operatorname{plim}}\\limits"); |
|
|
| |
| |
| |
|
|
| defineMacro("\\bra", "\\mathinner{\\langle{#1}|}"); |
| defineMacro("\\ket", "\\mathinner{|{#1}\\rangle}"); |
| defineMacro("\\braket", "\\mathinner{\\langle{#1}\\rangle}"); |
| defineMacro("\\Bra", "\\left\\langle#1\\right|"); |
| defineMacro("\\Ket", "\\left|#1\\right\\rangle"); |
| const braketHelper = (one: boolean) => (context: MacroContextInterface) => { |
| const left = context.consumeArg().tokens; |
| const middle = context.consumeArg().tokens; |
| const middleDouble = context.consumeArg().tokens; |
| const right = context.consumeArg().tokens; |
| const oldMiddle = context.macros.get("|"); |
| const oldMiddleDouble = context.macros.get("\\|"); |
| context.macros.beginGroup(); |
| const midMacro = (double: boolean) => (context: MacroContextInterface) => { |
| if (one) { |
| |
| context.macros.set("|", oldMiddle); |
| if (middleDouble.length) { |
| context.macros.set("\\|", oldMiddleDouble); |
| } |
| } |
| let doubled = double; |
| if (!double && middleDouble.length) { |
| |
| const nextToken = context.future(); |
| if (nextToken.text === "|") { |
| context.popToken(); |
| doubled = true; |
| } |
| } |
| return { |
| tokens: doubled ? middleDouble : middle, |
| numArgs: 0, |
| }; |
| }; |
| context.macros.set("|", midMacro(false)); |
| if (middleDouble.length) { |
| context.macros.set("\\|", midMacro(true)); |
| } |
| const arg = context.consumeArg().tokens; |
| const expanded = context.expandTokens([ |
| ...right, ...arg, ...left, |
| ]); |
| context.macros.endGroup(); |
| return { |
| tokens: expanded.reverse(), |
| numArgs: 0, |
| }; |
| }; |
| defineMacro("\\bra@ket", braketHelper(false)); |
| defineMacro("\\bra@set", braketHelper(true)); |
| defineMacro("\\Braket", "\\bra@ket{\\left\\langle}" + |
| "{\\,\\middle\\vert\\,}{\\,\\middle\\vert\\,}{\\right\\rangle}"); |
| defineMacro("\\Set", "\\bra@set{\\left\\{\\:}" + |
| "{\\;\\middle\\vert\\;}{\\;\\middle\\Vert\\;}{\\:\\right\\}}"); |
| defineMacro("\\set", "\\bra@set{\\{\\,}{\\mid}{}{\\,\\}}"); |
| |
|
|
| |
| |
| defineMacro("\\angln", "{\\angl n}"); |
|
|
| |
| defineMacro("\\blue", "\\textcolor{##6495ed}{#1}"); |
| defineMacro("\\orange", "\\textcolor{##ffa500}{#1}"); |
| defineMacro("\\pink", "\\textcolor{##ff00af}{#1}"); |
| defineMacro("\\red", "\\textcolor{##df0030}{#1}"); |
| defineMacro("\\green", "\\textcolor{##28ae7b}{#1}"); |
| defineMacro("\\gray", "\\textcolor{gray}{#1}"); |
| defineMacro("\\purple", "\\textcolor{##9d38bd}{#1}"); |
| defineMacro("\\blueA", "\\textcolor{##ccfaff}{#1}"); |
| defineMacro("\\blueB", "\\textcolor{##80f6ff}{#1}"); |
| defineMacro("\\blueC", "\\textcolor{##63d9ea}{#1}"); |
| defineMacro("\\blueD", "\\textcolor{##11accd}{#1}"); |
| defineMacro("\\blueE", "\\textcolor{##0c7f99}{#1}"); |
| defineMacro("\\tealA", "\\textcolor{##94fff5}{#1}"); |
| defineMacro("\\tealB", "\\textcolor{##26edd5}{#1}"); |
| defineMacro("\\tealC", "\\textcolor{##01d1c1}{#1}"); |
| defineMacro("\\tealD", "\\textcolor{##01a995}{#1}"); |
| defineMacro("\\tealE", "\\textcolor{##208170}{#1}"); |
| defineMacro("\\greenA", "\\textcolor{##b6ffb0}{#1}"); |
| defineMacro("\\greenB", "\\textcolor{##8af281}{#1}"); |
| defineMacro("\\greenC", "\\textcolor{##74cf70}{#1}"); |
| defineMacro("\\greenD", "\\textcolor{##1fab54}{#1}"); |
| defineMacro("\\greenE", "\\textcolor{##0d923f}{#1}"); |
| defineMacro("\\goldA", "\\textcolor{##ffd0a9}{#1}"); |
| defineMacro("\\goldB", "\\textcolor{##ffbb71}{#1}"); |
| defineMacro("\\goldC", "\\textcolor{##ff9c39}{#1}"); |
| defineMacro("\\goldD", "\\textcolor{##e07d10}{#1}"); |
| defineMacro("\\goldE", "\\textcolor{##a75a05}{#1}"); |
| defineMacro("\\redA", "\\textcolor{##fca9a9}{#1}"); |
| defineMacro("\\redB", "\\textcolor{##ff8482}{#1}"); |
| defineMacro("\\redC", "\\textcolor{##f9685d}{#1}"); |
| defineMacro("\\redD", "\\textcolor{##e84d39}{#1}"); |
| defineMacro("\\redE", "\\textcolor{##bc2612}{#1}"); |
| defineMacro("\\maroonA", "\\textcolor{##ffbde0}{#1}"); |
| defineMacro("\\maroonB", "\\textcolor{##ff92c6}{#1}"); |
| defineMacro("\\maroonC", "\\textcolor{##ed5fa6}{#1}"); |
| defineMacro("\\maroonD", "\\textcolor{##ca337c}{#1}"); |
| defineMacro("\\maroonE", "\\textcolor{##9e034e}{#1}"); |
| defineMacro("\\purpleA", "\\textcolor{##ddd7ff}{#1}"); |
| defineMacro("\\purpleB", "\\textcolor{##c6b9fc}{#1}"); |
| defineMacro("\\purpleC", "\\textcolor{##aa87ff}{#1}"); |
| defineMacro("\\purpleD", "\\textcolor{##7854ab}{#1}"); |
| defineMacro("\\purpleE", "\\textcolor{##543b78}{#1}"); |
| defineMacro("\\mintA", "\\textcolor{##f5f9e8}{#1}"); |
| defineMacro("\\mintB", "\\textcolor{##edf2df}{#1}"); |
| defineMacro("\\mintC", "\\textcolor{##e0e5cc}{#1}"); |
| defineMacro("\\grayA", "\\textcolor{##f6f7f7}{#1}"); |
| defineMacro("\\grayB", "\\textcolor{##f0f1f2}{#1}"); |
| defineMacro("\\grayC", "\\textcolor{##e3e5e6}{#1}"); |
| defineMacro("\\grayD", "\\textcolor{##d6d8da}{#1}"); |
| defineMacro("\\grayE", "\\textcolor{##babec2}{#1}"); |
| defineMacro("\\grayF", "\\textcolor{##888d93}{#1}"); |
| defineMacro("\\grayG", "\\textcolor{##626569}{#1}"); |
| defineMacro("\\grayH", "\\textcolor{##3b3e40}{#1}"); |
| defineMacro("\\grayI", "\\textcolor{##21242c}{#1}"); |
| defineMacro("\\kaBlue", "\\textcolor{##314453}{#1}"); |
| defineMacro("\\kaGreen", "\\textcolor{##71B307}{#1}"); |
|
|