[XeTeX] \beginR ...\endR
Jonathan Kew
jonathan_kew at sil.org
Thu Nov 4 21:09:04 CET 2004
On 4 Nov 2004, at 7:11 pm, Michael Gedalin wrote:
> I am typesetting the following:
>
> \documentclass{article}
> \TeXXeTstate=1
> \begin{document}
>
> \beginR
> first
> \endR
>
> \beginR
> second
>
> \endR
>
> \beginR
>
> third
> \endR
> \end{document}
>
> and get
>
> "tsfri" (flushed left)
> "dnoces" (flushed right)
> "third" (flushed left)
>
> log complains about
> \endL or \endR problem (0 missing, 1 extra) for the second and third.
>
> Is this normal or am I doing something wrong ?
> Michael
There should be documentation on the TeX--XeT direction primitives
somewhere among the e-TeX documentation, as this is a standard e-TeX
feature. But to address your example in brief:
The \beginR...\endR (or L) commands need to be properly balanced
*within* each paragraph, with the exception that you omit the final
\endR if the paragraph is to be right-to-left overall. So to explain
your results:
(1) is flush left because the actual paragraph end doesn't happen until
after the \endR. If you remove that, it'll be flush right instead (with
no complaints).
(2) is flush right because the paragraph ends in R mode, but then
complains because of the \endR *after* the paragraph has ended. Again,
you simply don't want that at all.
(3) is flush left because the \beginR is actually in a paragraph all by
itself (because of the following blank line), so there's no \beginR
within the paragraph, just an \endR (which generates the complaint).
If you're wanting to set a series of right-to-left paragraphs, you need
to begin each one with \beginR, and don't use any \endR. \everypar is a
handy way to do this. A common incantation is something like:
\everypar={\setbox0=\lastbox \beginR \box0 }
before a series of paragraphs. (The box manipulation is to deal with
the paragraph indent, which has already been generated before \everypar
is expanded; we need to move it so that it occurs after the \beginR.)
> PS On the same occasion: why not \TeXXeTstate=1 by default ? Does it
> interfere with anything ?
According to the e-TeX code, the additional nodes that it inserts into
TeX's internal lists can potentially have an effect on line-breaking or
hyphenation; I forget the precise details. So it's possible, in obscure
cases, that the layout of a purely unidirectional standard TeX document
could be affected by enabling the feature. But unless you require
absolute document stability when moving documents between TeX and
e-TeX, it probably doesn't matter to you.
HTH,
Jonathan
More information about the XeTeX
mailing list