Skip to content

Commit 1c64d74

Browse files
committed
Update font-size macros to correct LaTeX values and make fontsizev3 package for backward compatibility
1 parent 5629a28 commit 1c64d74

File tree

7 files changed

+82
-18
lines changed

7 files changed

+82
-18
lines changed
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
{
2+
"build": {
3+
"id": "[tex]/fontsizev3",
4+
"component": "input/tex/extensions/fontsizev3",
5+
"targets": ["input/tex/fontsizev3"]
6+
},
7+
"webpack": {
8+
"name": "input/tex/extensions/fontsizev3",
9+
"libs": [
10+
"components/src/input/tex-base/lib",
11+
"components/src/core/lib"
12+
]
13+
}
14+
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
import './lib/fontsizev3.js';

components/mjs/source.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ export const source = {
4949
'[tex]/empheq': `${src}/input/tex/extensions/empheq/empheq.js`,
5050
'[tex]/enclose': `${src}/input/tex/extensions/enclose/enclose.js`,
5151
'[tex]/extpfeil': `${src}/input/tex/extensions/extpfeil/extpfeil.js`,
52+
'[tex]/fontsizev3': `${src}/input/tex/extensions/fontsizev3/fontsizev3.js`,
5253
'[tex]/gensymb': `${src}/input/tex/extensions/gensymb/gensymb.js`,
5354
'[tex]/html': `${src}/input/tex/extensions/html/html.js`,
5455
'[tex]/mathtools': `${src}/input/tex/extensions/mathtools/mathtools.js`,

testsuite/tests/input/tex/__snapshots__/Base.test.ts.snap

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7657,53 +7657,53 @@ exports[`Roots Tweaked Root 1`] = `
76577657
76587658
exports[`Setting sizes Empty 1`] = `
76597659
"<math xmlns="http://www.w3.org/1998/Math/MathML" data-latex="\\Huge" display="block">
7660-
<mstyle mathsize="2.49em" data-latex="\\Huge"></mstyle>
7660+
<mstyle mathsize="2.074em" data-latex="\\Huge"></mstyle>
76617661
</math>"
76627662
`;
76637663
76647664
exports[`Setting sizes Huge 1`] = `
76657665
"<math xmlns="http://www.w3.org/1998/Math/MathML" data-latex="\\Huge a" display="block">
7666-
<mstyle mathsize="2.49em" data-latex="\\Huge a">
7666+
<mstyle mathsize="2.074em" data-latex="\\Huge a">
76677667
<mi data-latex="a">a</mi>
76687668
</mstyle>
76697669
</math>"
76707670
`;
76717671
76727672
exports[`Setting sizes LARGE 1`] = `
76737673
"<math xmlns="http://www.w3.org/1998/Math/MathML" data-latex="\\LARGE a" display="block">
7674-
<mstyle mathsize="1.73em" data-latex="\\LARGE a">
7674+
<mstyle mathsize="1.44em" data-latex="\\LARGE a">
76757675
<mi data-latex="a">a</mi>
76767676
</mstyle>
76777677
</math>"
76787678
`;
76797679
76807680
exports[`Setting sizes Large 1`] = `
76817681
"<math xmlns="http://www.w3.org/1998/Math/MathML" data-latex="\\Large a" display="block">
7682-
<mstyle mathsize="1.44em" data-latex="\\Large a">
7682+
<mstyle mathsize="1.2em" data-latex="\\Large a">
76837683
<mi data-latex="a">a</mi>
76847684
</mstyle>
76857685
</math>"
76867686
`;
76877687
76887688
exports[`Setting sizes Tiny 1`] = `
76897689
"<math xmlns="http://www.w3.org/1998/Math/MathML" data-latex="\\Tiny a" display="block">
7690-
<mstyle mathsize="0.6em" data-latex="\\Tiny a">
7690+
<mstyle mathsize="0.5em" data-latex="\\Tiny a">
76917691
<mi data-latex="a">a</mi>
76927692
</mstyle>
76937693
</math>"
76947694
`;
76957695
76967696
exports[`Setting sizes huge 1`] = `
76977697
"<math xmlns="http://www.w3.org/1998/Math/MathML" data-latex="\\huge a" display="block">
7698-
<mstyle mathsize="2.07em" data-latex="\\huge a">
7698+
<mstyle mathsize="1.728em" data-latex="\\huge a">
76997699
<mi data-latex="a">a</mi>
77007700
</mstyle>
77017701
</math>"
77027702
`;
77037703
77047704
exports[`Setting sizes large 1`] = `
77057705
"<math xmlns="http://www.w3.org/1998/Math/MathML" data-latex="\\large a" display="block">
7706-
<mstyle mathsize="1.2em" data-latex="\\large a">
7706+
<mstyle mathsize="1.095em" data-latex="\\large a">
77077707
<mi data-latex="a">a</mi>
77087708
</mstyle>
77097709
</math>"
@@ -7727,15 +7727,15 @@ exports[`Setting sizes scriptsize 1`] = `
77277727
77287728
exports[`Setting sizes small 1`] = `
77297729
"<math xmlns="http://www.w3.org/1998/Math/MathML" data-latex="\\small a" display="block">
7730-
<mstyle mathsize="0.85em" data-latex="\\small a">
7730+
<mstyle mathsize="0.9em" data-latex="\\small a">
77317731
<mi data-latex="a">a</mi>
77327732
</mstyle>
77337733
</math>"
77347734
`;
77357735
77367736
exports[`Setting sizes tiny 1`] = `
77377737
"<math xmlns="http://www.w3.org/1998/Math/MathML" data-latex="\\tiny a" display="block">
7738-
<mstyle mathsize="0.5em" data-latex="\\tiny a">
7738+
<mstyle mathsize="0.6em" data-latex="\\tiny a">
77397739
<mi data-latex="a">a</mi>
77407740
</mstyle>
77417741
</math>"

testsuite/tests/input/tex/__snapshots__/Mathtools.test.ts.snap

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3901,7 +3901,7 @@ exports[`Mathtools Symbols Other 1`] = `
39013901
</mrow>
39023902
<munder data-latex="\\mathop{\\Large\\kern-.1em\\boldsymbol{\\times}\\kern-.1em}_n">
39033903
<mrow data-mjx-texclass="OP" data-latex="\\mathop{\\Large\\kern-.1em\\boldsymbol{\\times}\\kern-.1em}">
3904-
<mstyle mathsize="1.44em" data-latex="\\Large\\kern-.1em\\boldsymbol{\\times}\\kern-.1em">
3904+
<mstyle mathsize="1.2em" data-latex="\\Large\\kern-.1em\\boldsymbol{\\times}\\kern-.1em">
39053905
<mspace width="-.1em" linebreak="nobreak" data-latex="\\kern-.1em"></mspace>
39063906
<mo data-latex="\\boldsymbol{\\times}" mathvariant="bold">&#xD7;</mo>
39073907
<mspace width="-.1em" linebreak="nobreak" data-latex="\\kern-.1em"></mspace>

ts/input/tex/base/BaseMappings.ts

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -452,16 +452,20 @@ new sm.CommandMap('macros', {
452452
textsf: [BaseMethods.HBox, null, VARIANT.SANSSERIF],
453453
texttt: [BaseMethods.HBox, null, VARIANT.MONOSPACE],
454454

455-
tiny: [BaseMethods.SetSize, 0.5],
456-
Tiny: [BaseMethods.SetSize, 0.6], // non-standard
455+
Tiny: [BaseMethods.SetSize, 0.5],
456+
tiny: [BaseMethods.SetSize, 0.6],
457457
scriptsize: [BaseMethods.SetSize, 0.7],
458-
small: [BaseMethods.SetSize, 0.85],
458+
SMALL: [BaseMethods.SetSize, 0.7],
459+
Small: [BaseMethods.SetSize, 0.8],
460+
footnotesize: [BaseMethods.SetSize, 0.8],
461+
small: [BaseMethods.SetSize, 0.9],
459462
normalsize: [BaseMethods.SetSize, 1.0],
460-
large: [BaseMethods.SetSize, 1.2],
461-
Large: [BaseMethods.SetSize, 1.44],
462-
LARGE: [BaseMethods.SetSize, 1.73],
463-
huge: [BaseMethods.SetSize, 2.07],
464-
Huge: [BaseMethods.SetSize, 2.49],
463+
large: [BaseMethods.SetSize, 1.095],
464+
Large: [BaseMethods.SetSize, 1.2],
465+
LARGE: [BaseMethods.SetSize, 1.44],
466+
huge: [BaseMethods.SetSize, 1.728],
467+
Huge: [BaseMethods.SetSize, 2.074],
468+
HUGE: [BaseMethods.SetSize, 2.49],
465469

466470
arcsin: BaseMethods.NamedFn,
467471
arccos: BaseMethods.NamedFn,
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
/*************************************************************
2+
*
3+
* Copyright (c) 2026 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+
/**
19+
* @file Configuration file for the v3-compatible font size macros (\large, etc.)
20+
*
21+
* @author dpvc@mathjax.org (Davide P. Cervone)
22+
*/
23+
24+
import { HandlerType, ConfigurationType } from '../HandlerTypes.js';
25+
import { CommandMap } from '../TokenMap.js';
26+
import { Configuration } from '../Configuration.js';
27+
import BaseMethods from '../base/BaseMethods.js';
28+
29+
new CommandMap('fontsizev3-macros', {
30+
tiny: [BaseMethods.SetSize, 0.5], // // should have been .6
31+
Tiny: [BaseMethods.SetSize, 0.6], // // should have been .5
32+
scriptsize: [BaseMethods.SetSize, 0.7],
33+
small: [BaseMethods.SetSize, 0.85], // // should have been .9
34+
normalsize: [BaseMethods.SetSize, 1.0],
35+
large: [BaseMethods.SetSize, 1.2], // // should have been 1.095
36+
Large: [BaseMethods.SetSize, 1.44], // // should have been 1.2
37+
LARGE: [BaseMethods.SetSize, 1.73], // // should have been 1.44
38+
huge: [BaseMethods.SetSize, 2.07], // // should have been 1.728
39+
Huge: [BaseMethods.SetSize, 2.49], // // should have been 2.074
40+
});
41+
42+
export const FontSizeV3Configuration = Configuration.create('fontsizev3', {
43+
[ConfigurationType.HANDLER]: { [HandlerType.MACRO]: ['fontsizev3-macros'] },
44+
});

0 commit comments

Comments
 (0)