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 259d2c7
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 3 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; }

0 comments on commit 259d2c7

Please sign in to comment.