TeX - LaTeX Asked by Salim Bou on December 21, 2020
Consedering this example hbox
in RTL context appears on the left isn’t it supposed to appear on the right side with pardir TRT
!?
documentclass{article}
usepackage[showframe]{geometry}
parindent0pt
begin{document}
pagedir TRT pardir TRT textdir TRT bodydir TRT
Text text text text text text text text text text
hbox{Text text text text text text text text text text}
pagedir TLT pardir TLT textdir TLT bodydir TLT
hbox{Text text text text text text text text text text}
end{document}
As Henri Menke said, hbox
does not start a paragraph and therefore pardir
doesn't affect it. Instead you get a horizontal box which not as wide as the enclosing box. In this case, the inner box is aligned based on the directionality of the outer box, which in this case is the vertical box TeX builds out of the main vertical list (whose directionalty is controlled by bodydir
).
Now you might expect that this doesn't make a difference because you set bodydir
too, but there is only one such box on every page, so one value of bodydir
is respected on every page. As you can see here, it is the last one.
This demonstrates that boxes in the main vertical list which do not go over the full hsize
are incompatible with changing the directionality in the middle of a page.
There are multiple ways to avoid this. You can for example enter a paragraph (by adding noindent
) which always goes over the full width or you can wrap your boxes in an inner vbox which can have it's own consistent direction. (Of course, you have to make sure that this box itself has full width, e.g. by adding a hrule height 0pt width textwidthrelax
)
The last option is particularly useful if you can't change some commands which use a direction not normally used in your document: E.g.
documentclass{article}
usepackage[showframe]{geometry}
parindent0pt
begin{document}
pagedir TRT pardir TRT textdir TRT bodydir TRT
Text text text text text text text text text text
hbox{Text text text text text text text text text text}
vbox dir TLT {hrule height 0pt width hsize relax
hbox{Text text text text text text text text text text}
% Everything here is left to right
}
end{document}
But be careful: This vbox
can never break over pages, so you shouldn't place long text in there.
Correct answer by Marcel Krüger on December 21, 2020
Get help from others!
Recent Questions
Recent Answers
© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP