Skip to content

Commit

Permalink
Overline fix (brucemiller#2450)
Browse files Browse the repository at this point in the history
* Note that over|under line|arrow should NOT set scriptpos=mid

* Enhance math/sampler test case to catch accent scriptpos

* update other test cases
  • Loading branch information
brucemiller authored Dec 18, 2024
1 parent 3408475 commit 3abc3af
Show file tree
Hide file tree
Showing 6 changed files with 152 additions and 34 deletions.
13 changes: 7 additions & 6 deletions lib/LaTeXML/Engine/TeX_Math.pool.ltxml
Original file line number Diff line number Diff line change
Expand Up @@ -908,27 +908,28 @@ 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.

# Note that (over|under) brace accents act like \limit, but lines, arrows do NOT!
DefMath('\lx@math@overline{}', UTF(0xAF),
operator_role => 'OVERACCENT', scriptpos => 'mid', operator_stretchy => 'true',
operator_role => 'OVERACCENT', 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', scriptpos => 'mid', operator_stretchy => 'true',
operator_role => 'UNDERACCENT', 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', scriptpos => 'mid', operator_stretchy => 'true',
operator_role => 'OVERACCENT', operator_stretchy => 'true',
name => 'overrightarrow', alias => '\overrightarrow');
DefMath('\lx@math@overleftarrow{}', "\x{2190}",
operator_role => 'OVERACCENT', scriptpos => 'mid', operator_stretchy => 'true',
operator_role => 'OVERACCENT', operator_stretchy => 'true',
name => 'overleftarrow', alias => '\overleftarrow');
DefMath('\lx@math@underrightarrow{}', "\x{2192}",
operator_role => 'UNDERACCENT', scriptpos => 'mid', operator_stretchy => 'true',
operator_role => 'UNDERACCENT', operator_stretchy => 'true',
name => 'underrightarrow', alias => '\underrightarrow');
DefMath('\lx@math@underleftarrow{}', "\x{2190}",
operator_role => 'UNDERACCENT', scriptpos => 'mid', operator_stretchy => 'true',
operator_role => 'UNDERACCENT', operator_stretchy => 'true',
name => 'underleftarrow', alias => '\underleftarrow');
DefMath('\lx@math@overbrace{}', "\x{23DE}",
operator_role => 'OVERACCENT', scriptpos => 'mid', operator_stretchy => 'true',
Expand Down
4 changes: 2 additions & 2 deletions t/complex/physics.xml
Original file line number Diff line number Diff line change
Expand Up @@ -661,12 +661,12 @@
<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" scriptpos="mid" xml:id="S1.Ex7.m1.3">
<XMApp role="ID" 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" scriptpos="mid" xml:id="S1.Ex7.m1.4">
<XMApp role="ID" xml:id="S1.Ex7.m1.4">
<XMTok name="overrightarrow" role="OVERACCENT" stretchy="true">→</XMTok>
<XMTok font="bold italic" role="UNKNOWN">a</XMTok>
</XMApp>
Expand Down
4 changes: 2 additions & 2 deletions t/fonts/abxtest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5022,7 +5022,7 @@
<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 scriptpos="mid">
<XMApp>
<XMTok name="overrightarrow" role="OVERACCENT" stretchy="true">→</XMTok>
<XMApp>
<XMTok meaning="times" role="MULOP">⁢</XMTok>
Expand All @@ -5042,7 +5042,7 @@
<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 scriptpos="mid">
<XMApp>
<XMTok name="overleftarrow" role="OVERACCENT" stretchy="true">←</XMTok>
<XMApp>
<XMTok meaning="times" role="MULOP">⁢</XMTok>
Expand Down
Binary file modified t/math/sampler.pdf
Binary file not shown.
9 changes: 9 additions & 0 deletions t/math/sampler.tex
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,15 @@ \section{Script and Limit Schemata}
a \underrightarrow{\mathrm{def}} b
\end{equation}

\begin{equation}
\overline{abc}^s \qquad
\overleftarrow{abc}^s \qquad
\overrightarrow{abc}^s \qquad
\overbrace{abc}^s \qquad
\underline{abc}_s \qquad
\underbrace{abc}_s
\end{equation}

% m:multiscripts, m:prescripts, m:none
\begin{equation}
{}_p F_q,\qquad
Expand Down
156 changes: 132 additions & 24 deletions t/math/sampler.xml
Original file line number Diff line number Diff line change
Expand Up @@ -1239,7 +1239,7 @@ 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 scriptpos="mid">
<XMApp>
<XMTok name="overrightarrow" role="OVERACCENT" stretchy="true">→</XMTok>
<XMTok role="UNKNOWN">def</XMTok>
</XMApp>
Expand Down Expand Up @@ -1267,16 +1267,124 @@ some as accents, and pre-scripts (<text font="typewriter">m:multiscripts</text>,
<tag>(21)</tag>
<tag role="refnum">21</tag>
</tags>
<Math mode="display" tex="{}_{p}F_{q},\qquad\sideset{{}_{a}^{b}}{{}^{c}_{d}}{\sum}" text="list@(_ p F _ q, (_ a ^ b sum ^ c) _ d)" xml:id="S3.E21.m1">
<Math mode="display" tex="\overline{abc}^{s}\qquad\overleftarrow{abc}^{s}\qquad\overrightarrow{abc}^{s}%&#10;\qquad\overbrace{abc}^{s}\qquad\underline{abc}_{s}\qquad\underbrace{abc}_{s}" text="list@((overline@(a * b * c)) ^ s, (overleftarrow@(a * b * c)) ^ s, (overrightarrow@(a * b * c)) ^ s, (overbrace@(a * b * c)) ^ s, (underline@(a * b * c)) _ s, (underbrace@(a * b * c)) _ s)" xml:id="S3.E21.m1">
<XMath>
<XMDual>
<XMApp>
<XMTok meaning="list"/>
<XMRef idref="S3.E21.m1.2"/>
<XMRef idref="S3.E21.m1.1"/>
<XMRef idref="S3.E21.m1.2"/>
<XMRef idref="S3.E21.m1.3"/>
<XMRef idref="S3.E21.m1.4"/>
<XMRef idref="S3.E21.m1.5"/>
<XMRef idref="S3.E21.m1.6"/>
</XMApp>
<XMWrap>
<XMApp xml:id="S3.E21.m1.1">
<XMTok role="SUPERSCRIPTOP" scriptpos="post1"/>
<XMApp>
<XMTok name="overline" role="OVERACCENT" stretchy="true">¯</XMTok>
<XMApp>
<XMTok meaning="times" role="MULOP">⁢</XMTok>
<XMTok font="italic" role="UNKNOWN">a</XMTok>
<XMTok font="italic" role="UNKNOWN">b</XMTok>
<XMTok font="italic" role="UNKNOWN">c</XMTok>
</XMApp>
</XMApp>
<XMTok font="italic" fontsize="70%" role="UNKNOWN">s</XMTok>
</XMApp>
<XMHint name="qquad" role="PUNCT" width="20pt"/>
<XMApp xml:id="S3.E21.m1.2">
<XMTok role="SUPERSCRIPTOP" scriptpos="post1"/>
<XMApp>
<XMTok name="overleftarrow" role="OVERACCENT" stretchy="true">←</XMTok>
<XMApp>
<XMTok meaning="times" role="MULOP">⁢</XMTok>
<XMTok font="italic" role="UNKNOWN">a</XMTok>
<XMTok font="italic" role="UNKNOWN">b</XMTok>
<XMTok font="italic" role="UNKNOWN">c</XMTok>
</XMApp>
</XMApp>
<XMTok font="italic" fontsize="70%" role="UNKNOWN">s</XMTok>
</XMApp>
<XMHint name="qquad" role="PUNCT" width="20pt"/>
<XMApp xml:id="S3.E21.m1.3">
<XMTok role="SUPERSCRIPTOP" scriptpos="post1"/>
<XMApp>
<XMTok name="overrightarrow" role="OVERACCENT" stretchy="true">→</XMTok>
<XMApp>
<XMTok meaning="times" role="MULOP">⁢</XMTok>
<XMTok font="italic" role="UNKNOWN">a</XMTok>
<XMTok font="italic" role="UNKNOWN">b</XMTok>
<XMTok font="italic" role="UNKNOWN">c</XMTok>
</XMApp>
</XMApp>
<XMTok font="italic" fontsize="70%" role="UNKNOWN">s</XMTok>
</XMApp>
<XMHint name="qquad" role="PUNCT" width="20pt"/>
<XMApp xml:id="S3.E21.m1.4">
<XMTok role="SUPERSCRIPTOP" scriptpos="mid1"/>
<XMApp scriptpos="mid">
<XMTok name="overbrace" role="OVERACCENT" stretchy="true">⏞</XMTok>
<XMApp>
<XMTok meaning="times" role="MULOP">⁢</XMTok>
<XMTok font="italic" role="UNKNOWN">a</XMTok>
<XMTok font="italic" role="UNKNOWN">b</XMTok>
<XMTok font="italic" role="UNKNOWN">c</XMTok>
</XMApp>
</XMApp>
<XMTok font="italic" fontsize="70%" role="UNKNOWN">s</XMTok>
</XMApp>
<XMHint name="qquad" role="PUNCT" width="20pt"/>
<XMApp xml:id="S3.E21.m1.5">
<XMTok role="SUBSCRIPTOP" scriptpos="post1"/>
<XMApp>
<XMTok name="underline" role="UNDERACCENT" stretchy="true">¯</XMTok>
<XMApp>
<XMTok meaning="times" role="MULOP">⁢</XMTok>
<XMTok font="italic" role="UNKNOWN">a</XMTok>
<XMTok font="italic" role="UNKNOWN">b</XMTok>
<XMTok font="italic" role="UNKNOWN">c</XMTok>
</XMApp>
</XMApp>
<XMTok font="italic" fontsize="70%" role="UNKNOWN">s</XMTok>
</XMApp>
<XMHint name="qquad" role="PUNCT" width="20pt"/>
<XMApp xml:id="S3.E21.m1.6">
<XMTok role="SUBSCRIPTOP" scriptpos="mid1"/>
<XMApp scriptpos="mid">
<XMTok name="underbrace" role="UNDERACCENT" stretchy="true">⏟</XMTok>
<XMApp>
<XMTok meaning="times" role="MULOP">⁢</XMTok>
<XMTok font="italic" role="UNKNOWN">a</XMTok>
<XMTok font="italic" role="UNKNOWN">b</XMTok>
<XMTok font="italic" role="UNKNOWN">c</XMTok>
</XMApp>
</XMApp>
<XMTok font="italic" fontsize="70%" role="UNKNOWN">s</XMTok>
</XMApp>
</XMWrap>
</XMDual>
</XMath>
</Math>
</equation>
</para>
<para xml:id="S3.p6">
<equation xml:id="S3.E22">
<tags>
<tag>(22)</tag>
<tag role="refnum">22</tag>
</tags>
<Math mode="display" tex="{}_{p}F_{q},\qquad\sideset{{}_{a}^{b}}{{}^{c}_{d}}{\sum}" text="list@(_ p F _ q, (_ a ^ b sum ^ c) _ d)" xml:id="S3.E22.m1">
<XMath>
<XMDual>
<XMApp>
<XMTok meaning="list"/>
<XMRef idref="S3.E22.m1.2"/>
<XMRef idref="S3.E22.m1.1"/>
</XMApp>
<XMWrap>
<XMApp xml:id="S3.E22.m1.2">
<XMTok role="SUBSCRIPTOP" scriptpos="pre1"/>
<XMApp>
<XMTok role="SUBSCRIPTOP" scriptpos="post1"/>
Expand All @@ -1286,7 +1394,7 @@ some as accents, and pre-scripts (<text font="typewriter">m:multiscripts</text>,
<XMTok font="italic" fontsize="70%" role="UNKNOWN">p</XMTok>
</XMApp>
<XMTok role="PUNCT" rpadding="20.0pt">,</XMTok>
<XMApp scriptpos="mid1" xml:id="S3.E21.m1.1">
<XMApp scriptpos="mid1" xml:id="S3.E22.m1.1">
<XMTok role="SUBSCRIPTOP" scriptpos="post3"/>
<XMApp>
<XMTok role="SUPERSCRIPTOP" scriptpos="post3"/>
Expand Down Expand Up @@ -1324,28 +1432,28 @@ many combinations of row and column spacing and spans
are not currently tested.</p>
</para>
<para xml:id="S4.p2">
<equation xml:id="S4.E22">
<equation xml:id="S4.E23">
<tags>
<tag>(22)</tag>
<tag role="refnum">22</tag>
<tag>(23)</tag>
<tag role="refnum">23</tag>
</tags>
<Math mode="display" tex="\begin{matrix}-1&amp;3\\&#10;2&amp;-4\end{matrix},\qquad\begin{matrix}[r]-1&amp;3\\&#10;2&amp;-4\end{matrix},\qquad\begin{Vmatrix}-1&amp;3\\&#10;2&amp;-4\end{Vmatrix},\qquad\begin{Vmatrix}[r]-1&amp;3\\&#10;2&amp;-4\end{Vmatrix}" text="list@(matrix@(Array[[- 1, 3], [2, - 4]]), matrix@(Array[[- 1, 3], [2, - 4]]), norm@(matrix@(Array[[- 1, 3], [2, - 4]])), norm@(matrix@(Array[[- 1, 3], [2, - 4]])))" xml:id="S4.E22.m1">
<Math mode="display" tex="\begin{matrix}-1&amp;3\\&#10;2&amp;-4\end{matrix},\qquad\begin{matrix}[r]-1&amp;3\\&#10;2&amp;-4\end{matrix},\qquad\begin{Vmatrix}-1&amp;3\\&#10;2&amp;-4\end{Vmatrix},\qquad\begin{Vmatrix}[r]-1&amp;3\\&#10;2&amp;-4\end{Vmatrix}" text="list@(matrix@(Array[[- 1, 3], [2, - 4]]), matrix@(Array[[- 1, 3], [2, - 4]]), norm@(matrix@(Array[[- 1, 3], [2, - 4]])), norm@(matrix@(Array[[- 1, 3], [2, - 4]])))" xml:id="S4.E23.m1">
<XMath>
<XMDual>
<XMApp>
<XMTok meaning="list"/>
<XMRef idref="S4.E22.m1.5"/>
<XMRef idref="S4.E22.m1.6"/>
<XMRef idref="S4.E22.m1.7"/>
<XMRef idref="S4.E22.m1.8"/>
<XMRef idref="S4.E23.m1.5"/>
<XMRef idref="S4.E23.m1.6"/>
<XMRef idref="S4.E23.m1.7"/>
<XMRef idref="S4.E23.m1.8"/>
</XMApp>
<XMWrap>
<XMDual xml:id="S4.E22.m1.5">
<XMDual xml:id="S4.E23.m1.5">
<XMApp>
<XMTok meaning="matrix"/>
<XMRef idref="S4.E22.m1.1"/>
<XMRef idref="S4.E23.m1.1"/>
</XMApp>
<XMArray xml:id="S4.E22.m1.1">
<XMArray xml:id="S4.E23.m1.1">
<XMRow>
<XMCell align="center">
<XMApp>
Expand All @@ -1371,12 +1479,12 @@ are not currently tested.</p>
</XMArray>
</XMDual>
<XMTok role="PUNCT" rpadding="20.0pt">,</XMTok>
<XMDual xml:id="S4.E22.m1.6">
<XMDual xml:id="S4.E23.m1.6">
<XMApp>
<XMTok meaning="matrix"/>
<XMRef idref="S4.E22.m1.2"/>
<XMRef idref="S4.E23.m1.2"/>
</XMApp>
<XMArray xml:id="S4.E22.m1.2">
<XMArray xml:id="S4.E23.m1.2">
<XMRow>
<XMCell align="right">
<XMApp>
Expand All @@ -1402,17 +1510,17 @@ are not currently tested.</p>
</XMArray>
</XMDual>
<XMTok role="PUNCT" rpadding="20.0pt">,</XMTok>
<XMDual xml:id="S4.E22.m1.7">
<XMDual xml:id="S4.E23.m1.7">
<XMApp>
<XMTok meaning="norm"/>
<XMApp>
<XMTok meaning="matrix"/>
<XMRef idref="S4.E22.m1.3"/>
<XMRef idref="S4.E23.m1.3"/>
</XMApp>
</XMApp>
<XMWrap>
<XMTok name="||" role="OPEN" stretchy="true">‖</XMTok>
<XMArray xml:id="S4.E22.m1.3">
<XMArray xml:id="S4.E23.m1.3">
<XMRow>
<XMCell align="center">
<XMApp>
Expand Down Expand Up @@ -1440,17 +1548,17 @@ are not currently tested.</p>
</XMWrap>
</XMDual>
<XMTok role="PUNCT" rpadding="20.0pt">,</XMTok>
<XMDual xml:id="S4.E22.m1.8">
<XMDual xml:id="S4.E23.m1.8">
<XMApp>
<XMTok meaning="norm"/>
<XMApp>
<XMTok meaning="matrix"/>
<XMRef idref="S4.E22.m1.4"/>
<XMRef idref="S4.E23.m1.4"/>
</XMApp>
</XMApp>
<XMWrap>
<XMTok name="||" role="OPEN" stretchy="true">‖</XMTok>
<XMArray xml:id="S4.E22.m1.4">
<XMArray xml:id="S4.E23.m1.4">
<XMRow>
<XMCell align="right">
<XMApp>
Expand Down

0 comments on commit 3abc3af

Please sign in to comment.