[tex-k] Horizontal positioning of an hbox in a right-to-left bidi document doesn't work as expected

Laurence.Finston at gmx.net Laurence.Finston at gmx.net
Fri Nov 18 09:34:38 CET 2022


I've tested this a little more and discovered that \parindent and \beginR ... \leftR don't work well together.
With the following example, if you set, e.g., \parindent=1cm, you get an overfull box in the second block of text.

Depending on what you want, it may be advisable to put the r-to-l text in a vbox.  In the first block, the last, incomplete line is typeset flush left, not flush right.  In the second block, it is flush right, which is probably the desired behavior.

If one wants indentation, it's best to put explicit glue at the beginning of a paragraph or line in r-to-l mode, i.e., a skip or a kern.
It would seem that r-to-l mode is really designed for short passages within l-to-r text and not for full paragraphs or multiple paragraphs.
It can be used for those things, but it takes a little extra work.

\beginR
The quick brown fox jumps over the lazy dog.  The quick brown fox jumps over the lazy dog.
The quick brown fox jumps over the lazy dog.  The quick brown fox jumps over the lazy dog.
The quick brown fox jumps over the lazy dog.  The quick brown fox jumps over the lazy dog.
\endR

\vskip1cm

\beginR
\vbox{\leavevmode The quick brown fox jumps over the lazy dog.  The quick brown fox jumps over the lazy dog.
The quick brown fox jumps over the lazy dog.  The quick brown fox jumps over the lazy dog.
The quick brown fox jumps over the lazy dog.  The quick brown fox jumps over the lazy dog.
}
\endR

> Gesendet: Freitag, 18. November 2022 um 09:15 Uhr
> Von: Laurence.Finston at gmx.net
> An: "Evan Aad" <oddeveneven at gmail.com>, "tex-ktug.org" <tex-k at tug.org>
> Betreff: Aw: Re: Re: [tex-k] Horizontal positioning of an hbox in a right-to-left bidi document doesn't work as expected
>
> My guess is that the glue for the indentation has a shrink component so that it will shrink in order to prevent an overfull box.  If true, then the indentation is present, it's just doesn't have much if any width.  Somebody familiar with LaTeX would have to give a definitive answer.
>
> For what it's worth, the following code demonstrates that one can put an hbox anywhere one wants with respect to the margins in right-to-left mode using etex (see attachment):
>
> %% ttemp.tex
>
> \special{papersize=297mm, 210mm} %% DIN A4
> \hsize=297mm
> \vsize=210mm
>
> \advance\hoffset by -1in
> \advance\voffset by -1in
>
> \advance\hoffset by 1cm
> \advance\voffset by 1cm
>
> \advance\hsize by -2cm
>
> \parindent=0pt
>
> \TeXXeTstate=1
>
> \beginR
> \vbox{\line{\hskip3em The quick brown fox jumps over the lazy dog.  The quick brown fox jumps over the lazy dog.
> The quick brown fox jumps over the lazy dog.\hss}\vskip.5\baselineskip
> \line{\hskip-3em The quick brown fox jumps over the lazy dog.  The quick brown fox jumps over the lazy dog.
> The quick brown fox jumps over the lazy dog.\hss}\vskip.5\baselineskip
> \line{\hskip10em The quick brown fox jumps over the lazy dog.  The quick brown fox jumps over the lazy dog.
> The quick brown fox jumps over the lazy dog.\hss}\vskip.5\baselineskip
> \line{\hskip-10em The quick brown fox jumps over the lazy dog.  The quick brown fox jumps over the lazy dog.
> The quick brown fox jumps over the lazy dog.\hss}\vskip.5\baselineskip
> \line{\hskip30em The quick brown fox jumps over the lazy dog.  The quick brown fox jumps over the lazy dog.
> The quick brown fox jumps over the lazy dog.\hss}\vskip.5\baselineskip
> \line{\hskip-30em The quick brown fox jumps over the lazy dog.  The quick brown fox jumps over the lazy dog.
> The quick brown fox jumps over the lazy dog.\hss}}
> \endR
>
> \bye
>
>
>
>
> > Gesendet: Freitag, 18. November 2022 um 08:59 Uhr
> > Von: "Evan Aad" <oddeveneven at gmail.com>
> > An: Laurence.Finston at gmx.net
> > Cc: "tex-ktug.org" <tex-k at tug.org>
> > Betreff: Re: Re: [tex-k] Horizontal positioning of an hbox in a right-to-left bidi document doesn't work as expected
> >
> > On Fri, Nov 18, 2022 at 9:40 AM <Laurence.Finston at gmx.net> wrote:
> > > If you would explain exactly what you want to accomplish and provide an example of how it's not working, preferably including the PDF output, I will try to see if I can get it to work with e-tex and plain TeX.
> >
> > Certainly. Please find attached the PDF file resulting from processing
> > my original example with the XeTeX typesetting engine.
> >
> > Here's a commentary on the PDF file:
> >
> > The first line of text is meant to visualize the length of the text
> > area, as well as its start and end points. Beyond this point, to the
> > left and to the right, are the left and right margins, respectively.
> > The second and third lines of text are considerably shorter than the
> > length of the text area. They are properly indented 3cm left of the
> > right margin. These lines are meant to show that as long as a line's
> > length is sufficiently short that the indentation does not cause it to
> > exceed the text area, the indentation works as expected.
> > The fourth line demonstrates the bug. It is as long as the text area
> > itself. Despite the fact that the LaTeX code instructed that it should
> > be indented 3cm like the previous two lines, it remains unindented. If
> > it had been indented, it would exceed the text area, and its left edge
> > would protrude into the left margin, which is the desired behavior. It
> > is also the expected behavior: when the bidi package is not loaded,
> > the last line of text is indented by 3cm, and protrudes beyond the
> > (right) margin.
> >



More information about the tex-k mailing list.