[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 10:56:31 CET 2022


I don't want to get into an indirect dispute with an unnamed person about perceived shortcomings of my answers.  It's always a good idea when submitting bug reports to be clear and provide complete information along with examples and background information, if any.

I was unaware of any previous correspondence on the subject and since it concerns LaTeX, I will not be looking it up.  If there's a known limitation of etex, then that's not a bug.  If one wants a particular result and the combination of packages doesn't provide it, then one has to adjust things to try to make it work.  I've tried to show how the result may be acheived with etex as it exists.  I'm sorry if that wasn't helpful to you, but it may be to someone else.

> Gesendet: Freitag, 18. November 2022 um 10:29 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: [tex-k] Horizontal positioning of an hbox in a right-to-left bidi document doesn't work as expected
>
> Thanks for your reply, Laurence. I have conveyed your observations to
> the developer of the bidi package, and here is (part of) his reply.
>
> > the issue is not that we can not place an \hbox wherever we like but explicitly the one demonstrated in my code above. Sure, we can place an \hbox wherever we want to place as shown in my two other solutions but he entirely misses the point. I am also a Plain TeX user and do not use LaTeX. All he had to do was to apply the content of the minimal example I provided in right to left in Plain TeX and see the issue for himself.
>
> > Having said that, I was in contact with Peter Breitenlohner, the original author of e-TeX several years ago when he was still alive and we discussed several issues including this one. He agreed back then that this was a limitation of TeX--XeT algorithm in e-TeX and that it could be a feature since \beginL, \endL, \beginR, and \endR are all horizontal primitives. We agreed that this could be fixed and Peter said that he will work on it but sadly he passed away and things were not fixed. In fact, if you look at TeXLive commits, you can see some of the history of our discussions.
>
> On Fri, Nov 18, 2022 at 10:34 AM <Laurence.Finston at gmx.net> wrote:
> >
> > 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.