Skip to content

Commit 38d0934

Browse files
committed
reimplement \llap, \rlap using CSS float
1 parent f82b733 commit 38d0934

File tree

6 files changed

+48
-24
lines changed

6 files changed

+48
-24
lines changed

lib/LaTeXML/Engine/plain.pool.ltxml

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -536,9 +536,8 @@ DefConstructor('\ltx@centerline{}', sub {
536536
alias => '\centerline',
537537
bounded => 1);
538538

539-
# These should be 0 width, but perhaps also shifted?
540-
DefMacro('\llap{}', '\hbox to 0pt{\hss#1}');
541-
DefMacro('\rlap{}', '\hbox to 0pt{#1\hss}');
539+
DefMacro('\llap{}', '\hbox{\@ADDCLASS{ltx_llap}#1}');
540+
DefMacro('\rlap{}', '\hbox{\@ADDCLASS{ltx_rlap}#1}');
542541

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

lib/LaTeXML/resources/CSS/LaTeXML.css

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -510,3 +510,9 @@ cite { font-style: normal; }
510510

511511
.ltx_overlay {position:relative; }
512512
.ltx_overlay > span:nth-child(2) {position:absolute; left:0; }
513+
514+
/* \llap, \rlap */
515+
.ltx__lap_container {
516+
display:inline-block; vertical-align:bottom; width:0pt; white-space:nowrap; /* width 0pt causes extreme wrapping otherwise */ }
517+
.ltx__lap_container>.ltx_llap { float:right; }
518+
.ltx__lap_container>.ltx_rlap { float:left; }

lib/LaTeXML/resources/XSLT/LaTeXML-inline-xhtml.xsl

Lines changed: 35 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -33,22 +33,41 @@
3333
<xsl:preserve-space elements="ltx:text"/>
3434
<xsl:template match="ltx:text">
3535
<xsl:param name="context"/>
36-
<xsl:element name="span" namespace="{$html_ns}">
37-
<xsl:variable name="innercontext" select="'inline'"/><!-- override -->
38-
<xsl:call-template name="add_id"/>
39-
<xsl:call-template name="add_attributes">
40-
<xsl:with-param name="extra_classes" select="f:if(@width,'ltx_inline-block','')"/>
41-
</xsl:call-template>
42-
<xsl:apply-templates select="." mode="begin">
43-
<xsl:with-param name="context" select="$innercontext"/>
44-
</xsl:apply-templates>
45-
<xsl:apply-templates>
46-
<xsl:with-param name="context" select="$innercontext"/>
47-
</xsl:apply-templates>
48-
<xsl:apply-templates select="." mode="end">
49-
<xsl:with-param name="context" select="$innercontext"/>
50-
</xsl:apply-templates>
51-
</xsl:element>
36+
<xsl:variable name="content">
37+
<xsl:element name="span" namespace="{$html_ns}">
38+
<xsl:variable name="innercontext" select="'inline'"/><!-- override -->
39+
<xsl:call-template name="add_id"/>
40+
<xsl:call-template name="add_attributes">
41+
<xsl:with-param name="extra_classes" select="f:if(@width,'ltx_inline-block','')"/>
42+
</xsl:call-template>
43+
<xsl:apply-templates select="." mode="begin">
44+
<xsl:with-param name="context" select="$innercontext"/>
45+
</xsl:apply-templates>
46+
<xsl:apply-templates>
47+
<xsl:with-param name="context" select="$innercontext"/>
48+
</xsl:apply-templates>
49+
<xsl:apply-templates select="." mode="end">
50+
<xsl:with-param name="context" select="$innercontext"/>
51+
</xsl:apply-templates>
52+
</xsl:element>
53+
</xsl:variable>
54+
<xsl:choose>
55+
<xsl:when test="contains(concat(' ',@class,' '),' ltx_llap ')">
56+
<xsl:element name="span" namespace="{$html_ns}">
57+
<xsl:attribute name="class">ltx__lap_container</xsl:attribute>
58+
<xsl:copy-of select="$content" />
59+
</xsl:element>
60+
</xsl:when>
61+
<xsl:when test="contains(concat(' ',@class,' '),' ltx_rlap ')">
62+
<xsl:element name="span" namespace="{$html_ns}">
63+
<xsl:attribute name="class">ltx__lap_container</xsl:attribute>
64+
<xsl:copy-of select="$content" />
65+
</xsl:element>
66+
</xsl:when>
67+
<xsl:otherwise>
68+
<xsl:copy-of select="$content" />
69+
</xsl:otherwise>
70+
</xsl:choose>
5271
</xsl:template>
5372

5473
<!-- Special case: all OTHER attributes have to be outside the "hidden"

t/alignment/halignatt.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@
5050
<td border="l t" class="ltx_nopad_l ltx_nopad_r"/>
5151
<td align="right" border="r t">6</td>
5252
<td align="center" border="r t">51–59</td>
53-
<td align="right" border="r t">.95<text width="0.0pt">*</text></td>
53+
<td align="right" border="r t">.95<text class="ltx_rlap" width="0.0pt">*</text></td>
5454
</tr>
5555
<tr>
5656
<td align="left" border="t" class="ltx_nopad_l ltx_nopad_r" colspan="4">* (first quarter only)</td>

t/ams/mathtools.xml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7120,7 +7120,7 @@ Then a switch of tag forms.</p>
71207120
<title><tag close=" ">11</tag>Stepped lines</title>
71217121
<para xml:id="S11.p1">
71227122
<equation xml:id="S11.Ex81">
7123-
<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">
7123+
<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">
71247124
<XMath>
71257125
<XMDual>
71267126
<XMWrap rule="Anything,">
@@ -7150,7 +7150,7 @@ Then a switch of tag forms.</p>
71507150
<XMTok meaning="equals" role="RELOP" xml:id="S11.Ex81.m1.3">=</XMTok>
71517151
<XMApp>
71527152
<XMTok meaning="times" role="MULOP">⁢</XMTok>
7153-
<XMText xml:id="S11.Ex81.m1.1"><text width="0.0pt">1</text><Math mode="inline" tex="*" text="*" xml:id="S11.Ex81.m1.m1">
7153+
<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">
71547154
<XMath>
71557155
<XMTok meaning="times" role="MULOP">∗</XMTok>
71567156
</XMath>
@@ -7182,7 +7182,7 @@ Then a switch of tag forms.</p>
71827182
<XMTok meaning="equals" role="RELOP" xml:id="S11.Ex81.m1.14">=</XMTok>
71837183
<XMApp>
71847184
<XMTok meaning="times" role="MULOP">⁢</XMTok>
7185-
<XMText xml:id="S11.Ex81.m1.12"><text width="0.0pt">2</text><Math mode="inline" tex="*" text="*" xml:id="S11.Ex81.m1.m2">
7185+
<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">
71867186
<XMath>
71877187
<XMTok meaning="times" role="MULOP">∗</XMTok>
71887188
</XMath>

t/structure/plainsample.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ finish the remaining cases.</p>
8080
<XMTok role="CLOSE" stretchy="false">)</XMTok>
8181
</XMWrap>
8282
</XMDual>
83-
<XMText width="0.0pt">Draft</XMText>
83+
<XMText class="ltx_rlap" width="0.0pt">Draft</XMText>
8484
</XMApp>
8585
</XMath>
8686
</Math></tag>

0 commit comments

Comments
 (0)