Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

use RTL to shift \llap content and fix \llap, \rlap extreme wrapping #2475

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions lib/LaTeXML/Engine/plain.pool.ltxml
Original file line number Diff line number Diff line change
Expand Up @@ -536,9 +536,8 @@ 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}');
DefMacro('\llap{}', '\hbox{\@ADDCLASS{ltx_llap}#1}');
DefMacro('\rlap{}', '\hbox{\@ADDCLASS{ltx_rlap}#1}');

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

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

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

/* \llap, \rlap */
.ltx__lap_container {
display:inline-block; vertical-align:bottom; width:0pt; white-space:nowrap; /* width 0pt causes extreme wrapping otherwise */ }
.ltx__lap_container>.ltx_llap { float:right; }
.ltx__lap_container>.ltx_rlap { float:left; }
51 changes: 35 additions & 16 deletions lib/LaTeXML/resources/XSLT/LaTeXML-inline-xhtml.xsl
Original file line number Diff line number Diff line change
Expand Up @@ -33,22 +33,41 @@
<xsl:preserve-space elements="ltx:text"/>
<xsl:template match="ltx:text">
<xsl:param name="context"/>
<xsl:element name="span" namespace="{$html_ns}">
<xsl:variable name="innercontext" select="'inline'"/><!-- override -->
<xsl:call-template name="add_id"/>
<xsl:call-template name="add_attributes">
<xsl:with-param name="extra_classes" select="f:if(@width,'ltx_inline-block','')"/>
</xsl:call-template>
<xsl:apply-templates select="." mode="begin">
<xsl:with-param name="context" select="$innercontext"/>
</xsl:apply-templates>
<xsl:apply-templates>
<xsl:with-param name="context" select="$innercontext"/>
</xsl:apply-templates>
<xsl:apply-templates select="." mode="end">
<xsl:with-param name="context" select="$innercontext"/>
</xsl:apply-templates>
</xsl:element>
<xsl:variable name="content">
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just proof of concept, this would have to be implemented for ltx:inline-block and ltx:p too (the other possible constructors from \hbox).

<xsl:element name="span" namespace="{$html_ns}">
<xsl:variable name="innercontext" select="'inline'"/><!-- override -->
<xsl:call-template name="add_id"/>
<xsl:call-template name="add_attributes">
<xsl:with-param name="extra_classes" select="f:if(@width,'ltx_inline-block','')"/>
</xsl:call-template>
<xsl:apply-templates select="." mode="begin">
<xsl:with-param name="context" select="$innercontext"/>
</xsl:apply-templates>
<xsl:apply-templates>
<xsl:with-param name="context" select="$innercontext"/>
</xsl:apply-templates>
<xsl:apply-templates select="." mode="end">
<xsl:with-param name="context" select="$innercontext"/>
</xsl:apply-templates>
</xsl:element>
</xsl:variable>
<xsl:choose>
<xsl:when test="contains(concat(' ',@class,' '),' ltx_llap ')">
<xsl:element name="span" namespace="{$html_ns}">
<xsl:attribute name="class">ltx__lap_container</xsl:attribute>
<xsl:copy-of select="$content" />
</xsl:element>
</xsl:when>
<xsl:when test="contains(concat(' ',@class,' '),' ltx_rlap ')">
<xsl:element name="span" namespace="{$html_ns}">
<xsl:attribute name="class">ltx__lap_container</xsl:attribute>
<xsl:copy-of select="$content" />
</xsl:element>
</xsl:when>
<xsl:otherwise>
<xsl:copy-of select="$content" />
</xsl:otherwise>
</xsl:choose>
</xsl:template>

<!-- Special case: all OTHER attributes have to be outside the "hidden"
Expand Down
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
Loading