Skip to content

Commit

Permalink
Update various wide math accents to get stretchy=yes; slightly more p…
Browse files Browse the repository at this point in the history
…lausible definitions of \hrulefill, etc; update affected tests
  • Loading branch information
brucemiller committed Dec 12, 2024
1 parent 07608c7 commit 489e0ab
Show file tree
Hide file tree
Showing 7 changed files with 58 additions and 41 deletions.
32 changes: 24 additions & 8 deletions lib/LaTeXML/Engine/TeX_Math.pool.ltxml
Original file line number Diff line number Diff line change
Expand Up @@ -908,18 +908,34 @@ Let('\vcenter', '\vbox');
# \overline c puts a line over the following character or subformula.
# \underline c puts a line under the following character or subformula.

DefMath('\lx@math@overline{}', UTF(0xAF), operator_role => 'OVERACCENT',
name => 'overline', alias => '\overline');
DefMath('\lx@math@overline{}', UTF(0xAF),
operator_role => 'OVERACCENT', scriptpos => 'mid', operator_stretchy => 'true',
name => 'overline', alias => '\overline');
DefConstructor('\lx@text@overline{}',
"<ltx:text framed='overline' _noautoclose='1'>#1</ltx:text>");
DefMath('\lx@math@underline{}', UTF(0xAF), operator_role => 'UNDERACCENT',
name => 'underline', alias => '\underline');
DefMath('\lx@math@underline{}', UTF(0xAF),
operator_role => 'UNDERACCENT', scriptpos => 'mid', operator_stretchy => 'true',
name => 'underline', alias => '\underline');
DefConstructor('\lx@text@underline{}',
"<ltx:text framed='underline' _noautoclose='1'>#1</ltx:text>");
DefMath('\lx@math@overrightarrow{}', "\x{2192}", operator_role => 'OVERACCENT',
name => 'overrightarrow', alias => '\overrightarrow');
DefMath('\lx@math@overleftarrow{}', "\x{2190}", operator_role => 'OVERACCENT',
name => 'overleftarrow', alias => '\overleftarrow');
DefMath('\lx@math@overrightarrow{}', "\x{2192}",
operator_role => 'OVERACCENT', scriptpos => 'mid', operator_stretchy => 'true',
name => 'overrightarrow', alias => '\overrightarrow');
DefMath('\lx@math@overleftarrow{}', "\x{2190}",
operator_role => 'OVERACCENT', scriptpos => 'mid', operator_stretchy => 'true',
name => 'overleftarrow', alias => '\overleftarrow');
DefMath('\lx@math@underrightarrow{}', "\x{2192}",
operator_role => 'UNDERACCENT', scriptpos => 'mid', operator_stretchy => 'true',
name => 'underrightarrow', alias => '\underrightarrow');
DefMath('\lx@math@underleftarrow{}', "\x{2190}",
operator_role => 'UNDERACCENT', scriptpos => 'mid', operator_stretchy => 'true',
name => 'underleftarrow', alias => '\underleftarrow');
DefMath('\lx@math@overbrace{}', "\x{23DE}",
operator_role => 'OVERACCENT', scriptpos => 'mid', operator_stretchy => 'true',
name => 'overbrace', alias => '\overbrace', robust => 1);
DefMath('\lx@math@underbrace{}', "\x{23DF}",
operator_role => 'UNDERACCENT', scriptpos => 'mid', operator_stretchy => 'true',
name => 'underbrace', alias => '\underbrace', robust => 1);

# Careful: Use \protect so that it doesn't expand too early in alignments, etc.
# [Really shouldn't use \protect, since this is a TeX primitive and \protect is LaTeX]
Expand Down
17 changes: 9 additions & 8 deletions lib/LaTeXML/Engine/plain.pool.ltxml
Original file line number Diff line number Diff line change
Expand Up @@ -736,9 +736,12 @@ DefConstructor('\@math@baccent {}',

DefMathI('\to', undef, "\x{2192}", role => 'ARROW'); # RIGHTWARDS ARROW??? a bit more explicitly relation-like?

foreach my $op ('\hrulefill', '\dotfill', '\rightarrowfill', '\leftarrowfill',
'\upbracefill', '\downbracefill') {
DefPrimitiveI($op, undef, undef); }
DefMacro('\hrulefill', '\leaders\hrule\hfill');
DefMacro('\dotfill', '\leaders\hbox{.}\hfill'); # Not exactly, but...
DefMath('\leftarrowfill', "\x{2190}", role => 'ARROW', stretchy => 'true');
DefMath('\rightarrowfill', "\x{2192}", role => 'ARROW', stretchy => 'true');
DefMath('\upbracefill', "\x{23DF}", role => 'ARROW', stretchy => 'true'); # for \underbrace
DefMath('\downbracefill', "\x{23DE}", role => 'ARROW', stretchy => 'true'); # for \overbrace

Let('\sp', T_SUPER);
Let('\sb', T_SUB);
Expand Down Expand Up @@ -1218,11 +1221,9 @@ DefMath('\dot Digested', "\x{02D9}", operator_role => 'OVERACCENT'); # DOT
DefMath('\ddot Digested', UTF(0xA8), operator_role => 'OVERACCENT'); # DIAERESIS
DefMath('\widehat Digested', UTF(0x5E), operator_role => 'OVERACCENT'); # CIRCUMFLEX ACCENT [plain? also amsfonts]
DefMath('\widetilde Digested', UTF(0x7E), operator_role => 'OVERACCENT'); # TILDE [plain? also amsfonts]
# These aren't handled as simple accents by TeX, so no Digested
DefMath('\overbrace {}', "\x{23DE}", operator_role => 'OVERACCENT', # TOP CURLY BRACKET
scriptpos => 'mid', robust => 1);
DefMath('\underbrace {}', "\x{23DF}", operator_role => 'UNDERACCENT', # BOTTOM CURLY BRACKET
scriptpos => 'mid', robust => 1);

Let('\overbrace', '\lx@math@overbrace');
Let('\underbrace', '\lx@math@underbrace');

# NOTE that all the above accents REQUIRE math mode
# EXCEPT underline, overrightarrow and overleftarrow!
Expand Down
4 changes: 2 additions & 2 deletions t/ams/mathtools.xml
Original file line number Diff line number Diff line change
Expand Up @@ -1461,7 +1461,7 @@ Then a switch of tag forms.</p>
<XMApp xml:id="S3.Ex22.m1.1">
<XMTok role="SUPERSCRIPTOP" scriptpos="mid1"/>
<XMApp scriptpos="mid">
<XMTok name="overbrace" role="OVERACCENT">⏞</XMTok>
<XMTok name="overbrace" role="OVERACCENT" stretchy="true">⏞</XMTok>
<XMApp>
<XMTok meaning="plus" role="ADDOP">+</XMTok>
<XMApp>
Expand Down Expand Up @@ -1492,7 +1492,7 @@ Then a switch of tag forms.</p>
<XMApp xml:id="S3.Ex22.m1.2">
<XMTok role="SUBSCRIPTOP" scriptpos="mid1"/>
<XMApp scriptpos="mid">
<XMTok name="underbrace" role="UNDERACCENT">⏟</XMTok>
<XMTok name="underbrace" role="UNDERACCENT" stretchy="true">⏟</XMTok>
<XMApp>
<XMTok meaning="plus" role="ADDOP">+</XMTok>
<XMTok meaning="1" role="NUMBER">1</XMTok>
Expand Down
8 changes: 4 additions & 4 deletions t/complex/physics.xml
Original file line number Diff line number Diff line change
Expand Up @@ -661,13 +661,13 @@
<XMHint name="qquad" role="PUNCT" width="20pt"/>
<XMTok font="bold italic" role="ID" xml:id="S1.Ex7.m1.2">a</XMTok>
<XMHint name="qquad" role="PUNCT" width="20pt"/>
<XMApp role="ID" xml:id="S1.Ex7.m1.3">
<XMTok name="overrightarrow" role="OVERACCENT">→</XMTok>
<XMApp role="ID" scriptpos="mid" xml:id="S1.Ex7.m1.3">
<XMTok name="overrightarrow" role="OVERACCENT" stretchy="true">→</XMTok>
<XMTok font="bold" role="UNKNOWN">a</XMTok>
</XMApp>
<XMHint name="qquad" role="PUNCT" width="20pt"/>
<XMApp role="ID" xml:id="S1.Ex7.m1.4">
<XMTok name="overrightarrow" role="OVERACCENT">→</XMTok>
<XMApp role="ID" scriptpos="mid" xml:id="S1.Ex7.m1.4">
<XMTok name="overrightarrow" role="OVERACCENT" stretchy="true">→</XMTok>
<XMTok font="bold italic" role="UNKNOWN">a</XMTok>
</XMApp>
<XMHint name="qquad" role="PUNCT" width="20pt"/>
Expand Down
12 changes: 6 additions & 6 deletions t/fonts/abxtest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4696,7 +4696,7 @@
<td align="left" thead="row"><Math mode="inline" tex="\overbrace{ABC\ldots XYZ}" text="overbrace@(A * B * C * ldots * X * Y * Z)" xml:id="S0.SS0.SSS0.Px29.p2.m5">
<XMath>
<XMApp scriptpos="mid">
<XMTok name="overbrace" role="OVERACCENT">⏞</XMTok>
<XMTok name="overbrace" role="OVERACCENT" stretchy="true">⏞</XMTok>
<XMApp>
<XMTok meaning="times" role="MULOP">⁢</XMTok>
<XMTok font="italic" role="UNKNOWN">A</XMTok>
Expand All @@ -4716,7 +4716,7 @@
<td align="left" thead="row"><Math mode="inline" tex="\underbrace{ABC\ldots XYZ}" text="underbrace@(A * B * C * ldots * X * Y * Z)" xml:id="S0.SS0.SSS0.Px29.p2.m6">
<XMath>
<XMApp scriptpos="mid">
<XMTok name="underbrace" role="UNDERACCENT">⏟</XMTok>
<XMTok name="underbrace" role="UNDERACCENT" stretchy="true">⏟</XMTok>
<XMApp>
<XMTok meaning="times" role="MULOP">⁢</XMTok>
<XMTok font="italic" role="UNKNOWN">A</XMTok>
Expand Down Expand Up @@ -5022,8 +5022,8 @@
<tr>
<td align="left" thead="row"><Math mode="inline" tex="\overrightarrow{ABC\ldots XYZ}" text="overrightarrow@(A * B * C * ldots * X * Y * Z)" xml:id="S0.SS0.SSS0.Px30.p2.m12">
<XMath>
<XMApp>
<XMTok name="overrightarrow" role="OVERACCENT">→</XMTok>
<XMApp scriptpos="mid">
<XMTok name="overrightarrow" role="OVERACCENT" stretchy="true">→</XMTok>
<XMApp>
<XMTok meaning="times" role="MULOP">⁢</XMTok>
<XMTok font="italic" role="UNKNOWN">A</XMTok>
Expand All @@ -5042,8 +5042,8 @@
<tr>
<td align="left" thead="row"><Math mode="inline" tex="\overleftarrow{ABC\ldots XYZ}" text="overleftarrow@(A * B * C * ldots * X * Y * Z)" xml:id="S0.SS0.SSS0.Px30.p2.m13">
<XMath>
<XMApp>
<XMTok name="overleftarrow" role="OVERACCENT">←</XMTok>
<XMApp scriptpos="mid">
<XMTok name="overleftarrow" role="OVERACCENT" stretchy="true">←</XMTok>
<XMApp>
<XMTok meaning="times" role="MULOP">⁢</XMTok>
<XMTok font="italic" role="UNKNOWN">A</XMTok>
Expand Down
22 changes: 11 additions & 11 deletions t/fonts/mathaccents.xml
Original file line number Diff line number Diff line change
Expand Up @@ -639,7 +639,7 @@ dot, ddot, overline, widehat, widetilde)</p>
<XMWrap>
<XMTok role="OPEN" stretchy="false">[</XMTok>
<XMApp scriptpos="mid" xml:id="S0.Ex3.m1.1">
<XMTok name="underbrace" role="UNDERACCENT">⏟</XMTok>
<XMTok name="underbrace" role="UNDERACCENT" stretchy="true">⏟</XMTok>
<XMTok font="italic" role="UNKNOWN">A</XMTok>
</XMApp>
<XMTok role="CLOSE" stretchy="false">]</XMTok>
Expand All @@ -654,7 +654,7 @@ dot, ddot, overline, widehat, widetilde)</p>
<XMWrap>
<XMTok role="OPEN" stretchy="false">[</XMTok>
<XMApp scriptpos="mid" xml:id="S0.Ex3.m1.2">
<XMTok name="underbrace" role="UNDERACCENT">⏟</XMTok>
<XMTok name="underbrace" role="UNDERACCENT" stretchy="true">⏟</XMTok>
<XMTok meaning="absent"/>
</XMApp>
<XMTok role="CLOSE" stretchy="false">]</XMTok>
Expand All @@ -669,7 +669,7 @@ dot, ddot, overline, widehat, widetilde)</p>
<XMWrap>
<XMTok role="OPEN" stretchy="false">[</XMTok>
<XMApp scriptpos="mid" xml:id="S0.Ex3.m1.3">
<XMTok name="underbrace" role="UNDERACCENT">⏟</XMTok>
<XMTok name="underbrace" role="UNDERACCENT" stretchy="true">⏟</XMTok>
<XMTok font="italic" role="UNKNOWN">A</XMTok>
</XMApp>
<XMTok role="CLOSE" stretchy="false">]</XMTok>
Expand All @@ -684,7 +684,7 @@ dot, ddot, overline, widehat, widetilde)</p>
<XMWrap>
<XMTok role="OPEN" stretchy="false">[</XMTok>
<XMApp scriptpos="mid" xml:id="S0.Ex3.m1.4">
<XMTok name="underbrace" role="UNDERACCENT">⏟</XMTok>
<XMTok name="underbrace" role="UNDERACCENT" stretchy="true">⏟</XMTok>
<XMApp>
<XMTok meaning="times" role="MULOP">⁢</XMTok>
<XMTok font="italic" role="UNKNOWN">A</XMTok>
Expand All @@ -704,7 +704,7 @@ dot, ddot, overline, widehat, widetilde)</p>
<XMWrap>
<XMTok role="OPEN" stretchy="false">[</XMTok>
<XMApp scriptpos="mid" xml:id="S0.Ex3.m1.5">
<XMTok name="underbrace" role="UNDERACCENT">⏟</XMTok>
<XMTok name="underbrace" role="UNDERACCENT" stretchy="true">⏟</XMTok>
<XMApp>
<XMTok meaning="times" role="MULOP">⁢</XMTok>
<XMTok font="italic" role="UNKNOWN">A</XMTok>
Expand Down Expand Up @@ -743,7 +743,7 @@ dot, ddot, overline, widehat, widetilde)</p>
<XMApp xml:id="S0.Ex4.m1.1.1">
<XMTok meaning="times" role="MULOP">⁢</XMTok>
<XMApp scriptpos="mid">
<XMTok name="underbrace" role="UNDERACCENT">⏟</XMTok>
<XMTok name="underbrace" role="UNDERACCENT" stretchy="true">⏟</XMTok>
<XMTok meaning="absent"/>
</XMApp>
<XMTok font="italic" role="UNKNOWN">A</XMTok>
Expand All @@ -762,7 +762,7 @@ dot, ddot, overline, widehat, widetilde)</p>
<XMApp xml:id="S0.Ex4.m1.2.1">
<XMTok meaning="times" role="MULOP">⁢</XMTok>
<XMApp scriptpos="mid">
<XMTok name="underbrace" role="UNDERACCENT">⏟</XMTok>
<XMTok name="underbrace" role="UNDERACCENT" stretchy="true">⏟</XMTok>
<XMTok meaning="absent"/>
</XMApp>
<XMTok font="italic" role="UNKNOWN">A</XMTok>
Expand All @@ -781,7 +781,7 @@ dot, ddot, overline, widehat, widetilde)</p>
<XMApp xml:id="S0.Ex4.m1.3.1">
<XMTok meaning="times" role="MULOP">⁢</XMTok>
<XMApp scriptpos="mid">
<XMTok name="underbrace" role="UNDERACCENT">⏟</XMTok>
<XMTok name="underbrace" role="UNDERACCENT" stretchy="true">⏟</XMTok>
<XMTok meaning="absent"/>
</XMApp>
<XMTok font="italic" role="UNKNOWN">A</XMTok>
Expand All @@ -800,7 +800,7 @@ dot, ddot, overline, widehat, widetilde)</p>
<XMApp xml:id="S0.Ex4.m1.4.1">
<XMTok meaning="times" role="MULOP">⁢</XMTok>
<XMApp scriptpos="mid">
<XMTok name="underbrace" role="UNDERACCENT">⏟</XMTok>
<XMTok name="underbrace" role="UNDERACCENT" stretchy="true">⏟</XMTok>
<XMTok meaning="absent"/>
</XMApp>
<XMTok font="italic" role="UNKNOWN">A</XMTok>
Expand All @@ -820,11 +820,11 @@ dot, ddot, overline, widehat, widetilde)</p>
<XMApp>
<XMTok meaning="times" role="MULOP">⁢</XMTok>
<XMApp scriptpos="mid">
<XMTok name="underbrace" role="UNDERACCENT">⏟</XMTok>
<XMTok name="underbrace" role="UNDERACCENT" stretchy="true">⏟</XMTok>
<XMTok meaning="absent"/>
</XMApp>
<XMApp scriptpos="mid">
<XMTok name="underbrace" role="UNDERACCENT">⏟</XMTok>
<XMTok name="underbrace" role="UNDERACCENT" stretchy="true">⏟</XMTok>
<XMTok font="italic" role="UNKNOWN">f</XMTok>
</XMApp>
<XMTok font="italic" role="UNKNOWN">o</XMTok>
Expand Down
4 changes: 2 additions & 2 deletions t/math/sampler.xml
Original file line number Diff line number Diff line change
Expand Up @@ -1239,8 +1239,8 @@ some as accents, and pre-scripts (<text font="typewriter">m:multiscripts</text>,
<XMApp xml:id="S3.E20.m1.3">
<XMTok meaning="times" role="MULOP">⁢</XMTok>
<XMTok font="italic" role="UNKNOWN">a</XMTok>
<XMApp>
<XMTok name="overrightarrow" role="OVERACCENT">→</XMTok>
<XMApp scriptpos="mid">
<XMTok name="overrightarrow" role="OVERACCENT" stretchy="true">→</XMTok>
<XMTok role="UNKNOWN">def</XMTok>
</XMApp>
<XMTok font="italic" role="UNKNOWN">b</XMTok>
Expand Down

0 comments on commit 489e0ab

Please sign in to comment.