mirror of
https://github.com/Smaug123/KaTeX
synced 2025-10-12 06:28:40 +00:00
feat: \operatornamewithlimits (and clean up \operatorname support) (#2984)
* feat: \operatornamewithlimits (and clean up \operatorname support) Add support for `\operatornamewithlimits` (an alias to `\operatorname*` defined in `amsmath/amsopn.sty`), and use KaTeX's existing `\@ifstar` macro to define `\operatorname` instead of a special lexing rule (simplifying the lexer). * Pick up one comment * Actually fix docs this time Co-authored-by: Ron Kok <ronkok@comcast.net>
This commit is contained in:
@@ -801,6 +801,7 @@ use `\ce` instead|
|
|||||||
|\ominus|$\ominus$||
|
|\ominus|$\ominus$||
|
||||||
|\operatorname|$\operatorname{asin} x$|`\operatorname{asin} x`|
|
|\operatorname|$\operatorname{asin} x$|`\operatorname{asin} x`|
|
||||||
|\operatorname\*|$\operatorname*{asin}\limits_y x$|`\operatorname*{asin}\limits_y x`|
|
|\operatorname\*|$\operatorname*{asin}\limits_y x$|`\operatorname*{asin}\limits_y x`|
|
||||||
|
|\operatornamewithlimits|$\operatornamewithlimits{asin}\limits_y x$|`\operatornamewithlimits{asin}\limits_y x`|
|
||||||
|\oplus|$\oplus$||
|
|\oplus|$\oplus$||
|
||||||
|\or|<span style="color:firebrick;">Not supported</span>||
|
|\or|<span style="color:firebrick;">Not supported</span>||
|
||||||
|\origof|$\origof$||
|
|\origof|$\origof$||
|
||||||
|
@@ -421,10 +421,10 @@ Direct Input: $+ - / * ⋅ ± × ÷ ∓ ∔ ∧ ∨ ∩ ∪ ≀ ⊎ ⊓ ⊔ ⊕
|
|||||||
| $\argmin$ `\argmin` | $\lim$ `\lim` | $\plim$ `\plim` | $\varliminf$ `\varliminf` |
|
| $\argmin$ `\argmin` | $\lim$ `\lim` | $\plim$ `\plim` | $\varliminf$ `\varliminf` |
|
||||||
| $\det$ `\det` | $\liminf$ `\liminf` | $\Pr$ `\Pr` | $\varlimsup$ `\varlimsup` |
|
| $\det$ `\det` | $\liminf$ `\liminf` | $\Pr$ `\Pr` | $\varlimsup$ `\varlimsup` |
|
||||||
| $\gcd$ `\gcd` | $\limsup$ `\limsup` | $\projlim$ `\projlim` | $\varprojlim$ `\varprojlim` |
|
| $\gcd$ `\gcd` | $\limsup$ `\limsup` | $\projlim$ `\projlim` | $\varprojlim$ `\varprojlim` |
|
||||||
| $\inf$ `\inf` | $\max$ `\max` | $\sup$ `\sup` |$\operatorname*{f}$ `\operatorname*{f}`|
|
| $\inf$ `\inf` | $\max$ `\max` | $\sup$ `\sup` ||
|
||||||
|
| $\operatorname*{f}$ `\operatorname*{f}` | $\operatornamewithlimits{f}$ `\operatornamewithlimits{f}` |||
|
||||||
|
|
||||||
|
Functions in the bottom six rows of this table can take `\limits`.
|
||||||
Functions in the bottom five rows of this table can take `\limits`.
|
|
||||||
|
|
||||||
### \sqrt
|
### \sqrt
|
||||||
|
|
||||||
|
@@ -59,7 +59,6 @@ const tokenRegexString = `(${spaceRegexString}+)|` + // whitespace
|
|||||||
`${combiningDiacriticalMarkString}*` + // ...plus accents
|
`${combiningDiacriticalMarkString}*` + // ...plus accents
|
||||||
"|\\\\verb\\*([^]).*?\\4" + // \verb*
|
"|\\\\verb\\*([^]).*?\\4" + // \verb*
|
||||||
"|\\\\verb([^*a-zA-Z]).*?\\5" + // \verb unstarred
|
"|\\\\verb([^*a-zA-Z]).*?\\5" + // \verb unstarred
|
||||||
"|\\\\operatorname\\*" + // \operatorname*
|
|
||||||
`|${controlWordWhitespaceRegexString}` + // \macroName + spaces
|
`|${controlWordWhitespaceRegexString}` + // \macroName + spaces
|
||||||
`|${controlSymbolRegexString})`; // \\, \', etc.
|
`|${controlSymbolRegexString})`; // \\, \', etc.
|
||||||
|
|
||||||
|
@@ -1,5 +1,6 @@
|
|||||||
// @flow
|
// @flow
|
||||||
import defineFunction, {ordargument} from "../defineFunction";
|
import defineFunction, {ordargument} from "../defineFunction";
|
||||||
|
import {defineMacro} from "../macros";
|
||||||
import buildCommon from "../buildCommon";
|
import buildCommon from "../buildCommon";
|
||||||
import mathMLTree from "../mathMLTree";
|
import mathMLTree from "../mathMLTree";
|
||||||
import {SymbolNode} from "../domTree";
|
import {SymbolNode} from "../domTree";
|
||||||
@@ -140,7 +141,7 @@ const mathmlBuilder: MathMLBuilder<"operatorname"> = (group, options) => {
|
|||||||
// amsopn.dtx: \mathop{#1\kern\z@\operator@font#3}\newmcodes@
|
// amsopn.dtx: \mathop{#1\kern\z@\operator@font#3}\newmcodes@
|
||||||
defineFunction({
|
defineFunction({
|
||||||
type: "operatorname",
|
type: "operatorname",
|
||||||
names: ["\\operatorname", "\\operatorname*"],
|
names: ["\\operatorname@", "\\operatornamewithlimits"],
|
||||||
props: {
|
props: {
|
||||||
numArgs: 1,
|
numArgs: 1,
|
||||||
},
|
},
|
||||||
@@ -150,7 +151,7 @@ defineFunction({
|
|||||||
type: "operatorname",
|
type: "operatorname",
|
||||||
mode: parser.mode,
|
mode: parser.mode,
|
||||||
body: ordargument(body),
|
body: ordargument(body),
|
||||||
alwaysHandleSupSub: (funcName === "\\operatorname*"),
|
alwaysHandleSupSub: (funcName === "\\operatornamewithlimits"),
|
||||||
limits: false,
|
limits: false,
|
||||||
parentIsSupSub: false,
|
parentIsSupSub: false,
|
||||||
};
|
};
|
||||||
@@ -159,3 +160,5 @@ defineFunction({
|
|||||||
mathmlBuilder,
|
mathmlBuilder,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
defineMacro("\\operatorname",
|
||||||
|
"\\@ifstar\\operatornamewithlimits\\operatorname@");
|
||||||
|
Reference in New Issue
Block a user