mirror of
https://github.com/Smaug123/KaTeX
synced 2025-10-11 22:18:41 +00:00
Fix \underset (#1277)
* Fix \underset This PR modifies `\underset` and `\overset` to align with LaTeX behavior when a superscript is applied after the `\underset`. Fixes issue #1275. I also changed the spacing from KaTeX `mop` to KaTeX `rmel`. The result seems to be a closer visual match to LaTeX. * Update screenshots
This commit is contained in:
@@ -62,26 +62,26 @@ defineFunction([
|
||||
};
|
||||
});
|
||||
|
||||
// Build a relation by placing one symbol on top of another
|
||||
defineFunction(["\\stackrel"], {
|
||||
// Build a relation or stacked op by placing one symbol on top of another
|
||||
defineFunction(["\\stackrel", "\\overset", "\\underset"], {
|
||||
numArgs: 2,
|
||||
}, function(context, args) {
|
||||
const top = args[0];
|
||||
const bottom = args[1];
|
||||
const mathAxisArg = args[1];
|
||||
const shiftedArg = args[0];
|
||||
|
||||
const bottomop = new ParseNode("op", {
|
||||
const xAxisOp = new ParseNode("op", {
|
||||
type: "op",
|
||||
limits: true,
|
||||
alwaysHandleSupSub: true,
|
||||
symbol: false,
|
||||
value: ordargument(bottom),
|
||||
}, bottom.mode);
|
||||
value: ordargument(mathAxisArg),
|
||||
}, mathAxisArg.mode);
|
||||
|
||||
const supsub = new ParseNode("supsub", {
|
||||
base: bottomop,
|
||||
sup: top,
|
||||
sub: null,
|
||||
}, top.mode);
|
||||
base: xAxisOp,
|
||||
sup: context.funcName === "\\underset" ? null : shiftedArg,
|
||||
sub: context.funcName === "\\underset" ? shiftedArg : null,
|
||||
}, shiftedArg.mode);
|
||||
|
||||
return {
|
||||
type: "mclass",
|
||||
|
@@ -169,10 +169,6 @@ defineMacro("\\varPhi", "\\mathit{\\Phi}");
|
||||
defineMacro("\\varPsi", "\\mathit{\\Psi}");
|
||||
defineMacro("\\varOmega", "\\mathit{\\Omega}");
|
||||
|
||||
// \def\overset#1#2{\binrel@{#2}\binrel@@{\mathop{\kern\z@#2}\limits^{#1}}}
|
||||
defineMacro("\\overset", "\\mathop{#2}\\limits^{#1}");
|
||||
defineMacro("\\underset", "\\mathop{#2}\\limits_{#1}");
|
||||
|
||||
// \newcommand{\boxed}[1]{\fbox{\m@th$\displaystyle#1$}}
|
||||
defineMacro("\\boxed", "\\fbox{\\displaystyle{#1}}");
|
||||
|
||||
|
Reference in New Issue
Block a user