Skip to content

Commit

Permalink
use RTL to shift \llap content and fix \llap, \rlap extreme wrapping
Browse files Browse the repository at this point in the history
  • Loading branch information
xworld21 committed Jan 3, 2025
1 parent f82b733 commit 9704dbf
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 8 deletions.
7 changes: 4 additions & 3 deletions lib/LaTeXML/Engine/plain.pool.ltxml
Original file line number Diff line number Diff line change
Expand Up @@ -536,9 +536,10 @@ DefConstructor('\ltx@centerline{}', sub {
alias => '\centerline',
bounded => 1);

# These should be 0 width, but perhaps also shifted?
DefMacro('\llap{}', '\hbox to 0pt{\hss#1}');
DefMacro('\rlap{}', '\hbox to 0pt{#1\hss}');
# rely on RTL trickery to shift the \llap content over the previous text (see CSS)
# the zero-width space prevents merging the two boxes in a single ltx:text
DefMacro('\llap{}', '\hbox to 0pt{\@ADDCLASS{ltx_llap}' . "\x{200B}" . '\hbox{\@ADDCLASS{ltx_llap_content}#1}}');
DefMacro('\rlap{}', '\hbox to 0pt{\@ADDCLASS{ltx_rlap}#1}');

DefMacroI('\m@th', undef, '\mathsurround=0pt ');

Expand Down
12 changes: 12 additions & 0 deletions lib/LaTeXML/resources/CSS/LaTeXML.css
Original file line number Diff line number Diff line change
Expand Up @@ -510,3 +510,15 @@ cite { font-style: normal; }

.ltx_overlay {position:relative; }
.ltx_overlay > span:nth-child(2) {position:absolute; left:0; }

/* \llap, \rlap */
.ltx_llap, .ltx_rlap {
white-space: nowrap; /* width 0pt causes extreme wrapping otherwise */ }

/* shift \llap over the previous text by shifting text direction */
.ltx_llap {
direction: rtl; }

/* restore LTR inside \llap */
.ltx_llap_content {
direction: ltr; }
2 changes: 1 addition & 1 deletion t/alignment/halignatt.xml
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
<td border="l t" class="ltx_nopad_l ltx_nopad_r"/>
<td align="right" border="r t">6</td>
<td align="center" border="r t">51–59</td>
<td align="right" border="r t">.95<text width="0.0pt">*</text></td>
<td align="right" border="r t">.95<text class="ltx_rlap" width="0.0pt">*</text></td>
</tr>
<tr>
<td align="left" border="t" class="ltx_nopad_l ltx_nopad_r" colspan="4">* (first quarter only)</td>
Expand Down
6 changes: 3 additions & 3 deletions t/ams/mathtools.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7120,7 +7120,7 @@ Then a switch of tag forms.</p>
<title><tag close=" ">11</tag>Stepped lines</title>
<para xml:id="S11.p1">
<equation xml:id="S11.Ex81">
<Math class="ltx_math_unparsed" mode="display" tex="\begin{gathered}x=1,\quad x+1=2\\&#10;y=2\end{gathered}" text="[1∗  ]@x@=@1@,@quad@x@+@1@=@2@[ over]@[2∗  ]@y@=@2@[ over]" xml:id="S11.Ex81.m1">
<Math class="ltx_math_unparsed" mode="display" tex="\begin{gathered}x=1,\quad x+1=2\\&#10;y=2\end{gathered}" text="[1∗  ]@x@=@1@,@quad@x@+@1@=@2@[ over]@[2∗  ]@y@=@2@[ over]" xml:id="S11.Ex81.m1">
<XMath>
<XMDual>
<XMWrap rule="Anything,">
Expand Down Expand Up @@ -7150,7 +7150,7 @@ Then a switch of tag forms.</p>
<XMTok meaning="equals" role="RELOP" xml:id="S11.Ex81.m1.3">=</XMTok>
<XMApp>
<XMTok meaning="times" role="MULOP">⁢</XMTok>
<XMText xml:id="S11.Ex81.m1.1"><text width="0.0pt">1</text><Math mode="inline" tex="*" text="*" xml:id="S11.Ex81.m1.m1">
<XMText xml:id="S11.Ex81.m1.1"><text class="ltx_llap" width="0.0pt">​<text class="ltx_llap_content">1</text></text><Math mode="inline" tex="*" text="*" xml:id="S11.Ex81.m1.m1">
<XMath>
<XMTok meaning="times" role="MULOP">∗</XMTok>
</XMath>
Expand Down Expand Up @@ -7182,7 +7182,7 @@ Then a switch of tag forms.</p>
<XMTok meaning="equals" role="RELOP" xml:id="S11.Ex81.m1.14">=</XMTok>
<XMApp>
<XMTok meaning="times" role="MULOP">⁢</XMTok>
<XMText xml:id="S11.Ex81.m1.12"><text width="0.0pt">2</text><Math mode="inline" tex="*" text="*" xml:id="S11.Ex81.m1.m2">
<XMText xml:id="S11.Ex81.m1.12"><text class="ltx_llap" width="0.0pt">​<text class="ltx_llap_content">2</text></text><Math mode="inline" tex="*" text="*" xml:id="S11.Ex81.m1.m2">
<XMath>
<XMTok meaning="times" role="MULOP">∗</XMTok>
</XMath>
Expand Down
2 changes: 1 addition & 1 deletion t/structure/plainsample.xml
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ finish the remaining cases.</p>
<XMTok role="CLOSE" stretchy="false">)</XMTok>
</XMWrap>
</XMDual>
<XMText width="0.0pt">Draft</XMText>
<XMText class="ltx_rlap" width="0.0pt">Draft</XMText>
</XMApp>
</XMath>
</Math></tag>
Expand Down

0 comments on commit 9704dbf

Please sign in to comment.