Skip to content

Commit 259d2c7

Browse files
committed
use RTL to shift \llap content and fix \llap, \rlap extreme wrapping
1 parent f82b733 commit 259d2c7

File tree

2 files changed

+16
-3
lines changed

2 files changed

+16
-3
lines changed

lib/LaTeXML/Engine/plain.pool.ltxml

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -536,9 +536,10 @@ 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+
# rely on RTL trickery to shift the \llap content over the previous text (see CSS)
540+
# the zero-width space prevents merging the two boxes in a single ltx:text
541+
DefMacro('\llap{}', '\hbox to 0pt{\@ADDCLASS{ltx_llap}' . "\x{200B}" . '\hbox{\@ADDCLASS{ltx_llap_content}#1}}');
542+
DefMacro('\rlap{}', '\hbox to 0pt{\@ADDCLASS{ltx_rlap}#1}');
542543

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

lib/LaTeXML/resources/CSS/LaTeXML.css

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -510,3 +510,15 @@ 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_llap, .ltx_rlap {
516+
white-space: nowrap; /* width 0pt causes extreme wrapping otherwise */ }
517+
518+
/* shift \llap over the previous text by shifting text direction */
519+
.ltx_llap {
520+
direction: rtl; }
521+
522+
/* restore LTR inside \llap */
523+
.ltx_llap_content {
524+
direction: ltr; }

0 commit comments

Comments
 (0)