From 794dc7a21332c9d33210c573debb580f859c0006 Mon Sep 17 00:00:00 2001 From: Ron Kok Date: Mon, 17 Aug 2020 13:28:42 -0700 Subject: [PATCH] feat: support AMS log-like symbols (#2429) * Support AMS log-like symbols * Update documentation * Update \limits info in documentation --- docs/support_table.md | 12 ++++++------ docs/supported.md | 31 +++++++++++++++++-------------- src/macros.js | 9 +++++++++ test/katex-spec.js | 10 ++++++++++ 4 files changed, 42 insertions(+), 20 deletions(-) diff --git a/docs/support_table.md b/docs/support_table.md index b5636b31..9fd07dd1 100644 --- a/docs/support_table.md +++ b/docs/support_table.md @@ -500,7 +500,7 @@ use `\ce` instead| |\inf|$\inf$|| |\infin|$\infin$|| |\infty|$\infty$|| -|\injlim|Not supported|| +|\injlim|$\injlim$|`\injlim`| |\int|$\int$|| |\intercal|$\intercal$|| |\intop|$\intop$|| @@ -843,7 +843,7 @@ use `\ce` instead| |\precsim|$\precsim$|| |\prime|$\prime$|| |\prod|$\prod$|| -|\projlim|Not supported|| +|\projlim|$\projlim$|`\projlim`| |\propto|$\propto$|| |\providecommand|$\providecommand\greet{\text{Hello}} \greet$|`\providecommand\greet{\text{Hello}} \greet`| |\psi|$\psi$|| @@ -1141,18 +1141,18 @@ use `\ce` instead| |\varDelta|$\varDelta$|| |\varepsilon|$\varepsilon$|| |\varGamma|$\varGamma$|| -|\varinjlim|Not supported|| +|\varinjlim|$\varinjlim$|`\varinjlim`| |\varkappa|$\varkappa$|| |\varLambda|$\varLambda$|| -|\varliminf|Not supported|| -|\varlimsup|Not supported|| +|\varliminf|$\varliminf$|`\varliminf`| +|\varlimsup|$\varlimsup$|`\varlimsup`| |\varnothing|$\varnothing$|| |\varOmega|$\varOmega$|| |\varPhi|$\varPhi$|| |\varphi|$\varphi$|| |\varPi|$\varPi$|| |\varpi|$\varpi$|| -|\varprojlim|Not supported|| +|\varprojlim|$\varprojlim$|`\varprojlim`| |\varpropto|$\varpropto$|| |\varPsi|$\varPsi$|| |\varPsi|$\varPsi$|| diff --git a/docs/supported.md b/docs/supported.md index 79420aef..8c725fee 100644 --- a/docs/supported.md +++ b/docs/supported.md @@ -381,21 +381,24 @@ Direct Input: $+ - / * ⋅ ± × ÷ ∓ ∔ ∧ ∨ ∩ ∪ ≀ ⊎ ⊓ ⊔ ⊕ ### Math Operators ||||| -|-----------|---------|-----------------|-----------| -| $\arcsin$ `\arcsin` | $\cotg$ `\cotg` | $\ln$ `\ln` | $\det$ `\det` | -| $\arccos$ `\arccos` | $\coth$ `\coth` | $\log$ `\log` | $\gcd$ `\gcd` | -| $\arctan$ `\arctan` | $\csc$ `\csc` | $\sec$ `\sec` | $\inf$ `\inf` | -| $\arctg$ `\arctg` | $\ctg$ `\ctg` | $\sin$ `\sin` | $\lim$ `\lim` | -| $\arcctg$ `\arcctg` | $\cth$ `\cth` | $\sinh$ `\sinh`| $\liminf$ `\liminf` | -| $\arg$ `\arg` | $\deg$ `\deg` | $\sh$ `\sh` | $\limsup$ `\limsup` | -| $\ch$ `\ch` | $\dim$ `\dim` | $\tan$ `\tan` | $\max$ `\max` | -| $\cos$ `\cos` | $\exp$ `\exp` | $\tanh$ `\tanh`| $\min$ `\min` | -| $\cosec$ `\cosec` | $\hom$ `\hom` | $\tg$ `\tg` | $\Pr$ `\Pr` | -| $\cosh$ `\cosh`| $\ker$ `\ker` | $\th$ `\th` | $\sup$ `\sup` | -| $\cot$ `\cot` | $\lg$ `\lg`| $\argmax$ `\argmax` | $\argmin$ `\argmin` | -| $\plim$ `\plim` | $\operatorname{f}$ `\operatorname{f}`| $\operatorname*{f}$ `\operatorname*{f}`| | +|:--------------------|:--------------------|:----------------|:--------------| +| $\arcsin$ `\arcsin` | $\cosec$ `\cosec` | $\deg$ `\deg` | $\sec$ `\sec` | +| $\arccos$ `\arccos` | $\cosh$ `\cosh` | $\dim$ `\dim` | $\sin$ `\sin` | +| $\arctan$ `\arctan` | $\cot$ `\cot` | $\exp$ `\exp` | $\sinh$ `\sinh` | +| $\arctg$ `\arctg` | $\cotg$ `\cotg` | $\hom$ `\hom` | $\sh$ `\sh` | +| $\arcctg$ `\arcctg` | $\coth$ `\coth` | $\ker$ `\ker` | $\tan$ `\tan` | +| $\arg$ `\arg` | $\csc$ `\csc` | $\lg$ `\lg` | $\tanh$ `\tanh` | +| $\ch$ `\ch` | $\ctg$ `\ctg` | $\ln$ `\ln` | $\tg$ `\tg` | +| $\cos$ `\cos` | $\cth$ `\cth` | $\log$ `\log` | $\th$ `\th` | +| $\operatorname{f}$ `\operatorname{f}` | ||| +| $\argmax$ `\argmax` | $\injlim$ `\injlim` | $\min$ `\min` | $\varinjlim$ `\varinjlim` | +| $\argmin$ `\argmin` | $\lim$ `\lim` | $\plim$ `\plim` | $\varliminf$ `\varliminf` | +| $\det$ `\det` | $\liminf$ `\liminf` | $\Pr$ `\Pr` | $\varlimsup$ `\varlimsup` | +| $\gcd$ `\gcd` | $\limsup$ `\limsup` | $\projlim$ `\projlim` | $\varprojlim$ `\varprojlim` | +| $\inf$ `\inf` | $\max$ `\max` | $\sup$ `\sup` |$\operatorname*{f}$ `\operatorname*{f}`| -Functions on the right column of this table can take `\limits`. + +Functions in the bottom five rows of this table can take `\limits`. ### \sqrt diff --git a/src/macros.js b/src/macros.js index 392842f9..7927842b 100644 --- a/src/macros.js +++ b/src/macros.js @@ -842,6 +842,15 @@ defineMacro("\\notni", "\\html@mathml{\\not\\ni}{\\mathrel{\\char`\u220C}}"); defineMacro("\\limsup", "\\DOTSB\\operatorname*{lim\\,sup}"); defineMacro("\\liminf", "\\DOTSB\\operatorname*{lim\\,inf}"); +////////////////////////////////////////////////////////////////////// +// From amsopn.sty +defineMacro("\\injlim", "\\DOTSB\\operatorname*{int\\,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}}"); + ////////////////////////////////////////////////////////////////////// // MathML alternates for KaTeX glyphs in the Unicode private area defineMacro("\\gvertneqq", "\\html@mathml{\\@gvertneqq}{\u2269}"); diff --git a/test/katex-spec.js b/test/katex-spec.js index 1ad8ac21..bae8f3f5 100644 --- a/test/katex-spec.js +++ b/test/katex-spec.js @@ -3439,6 +3439,16 @@ describe("A macro expander", function() { expect`\liminf`.toParseLike`\operatorname*{lim\,inf}`; }); + it("should expand AMS log-like symbols as expected", () => { + expect`\injlim`.toParseLike`\operatorname*{int\,lim}`; + expect`\projlim`.toParseLike`\operatorname*{proj\,lim}`; + expect`\varlimsup`.toParseLike`\operatorname*{\overline{lim}}`; + expect`\varliminf`.toParseLike`\operatorname*{\underline{lim}}`; + expect`\varinjlim`.toParseLike`\operatorname*{\underrightarrow{lim}}`; + expect`\varinjlim`.toParseLike`\operatorname*{\underrightarrow{lim}}`; + expect`\varprojlim`.toParseLike`\operatorname*{\underleftarrow{lim}}`; + }); + it("should expand \\plim as expected", () => { expect`\plim`.toParseLike`\mathop{\operatorname{plim}}\limits`; });