[XeTeX] Multi directional paragraphs

Vafa Khalighi vafakhlgh at gmail.com
Tue Feb 15 14:17:53 CET 2011


The same kind of isssue existed with the margins in the bibliography
environment and they can be avoided by using LTRitems and RTLitems
environments. To fix lists bidirectionallly, bidi redefines \list as follow:

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\def\list#1#2{%
  \ifnum \@listdepth >5\relax
    \@toodeep
  \else
    \global\advance\@listdepth\@ne
  \fi
  \rightmargin\z@
  \listparindent\z@
  \itemindent\z@
  \csname @list\romannumeral\the\@listdepth\endcsname
  \def\@itemlabel{#1}%
  \let\makelabel\@mklab
  \@nmbrlistfalse
  #2\relax
  \@trivlist
  \parskip\parsep
  \parindent\listparindent
  \advance\linewidth -\rightmargin
  \advance\linewidth -\leftmargin
  \if at RTL
    \advance\@totalleftmargin \rightmargin
  \else
    \advance\@totalleftmargin \leftmargin
  \fi
  \parshape \@ne \@totalleftmargin \linewidth
  \ignorespaces}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

The most important part of this redefinition is:

  \if at RTL
    \advance\@totalleftmargin \rightmargin
  \else
    \advance\@totalleftmargin \leftmargin
  \fi

So if your direction is RTL, you add \rightmargin otherwise \leftmargin to
\@totalleftmargin. Itemize, enumerate and so verse uses lists. Now imagin
you have something like this:

\begin{verse}
some text

\setRTL
some text
\end{verse}

Once you start the verse environment, then you already have started the list
environment and since your directional is LTR first, you add \leftmargin to
\@totalleftmargin but then you make text RTL, and so what should it do? do
you get the idea? This is the kind of bidirectionality that gets complicated
and it needs more, so that is why I have implemented RTLitems and LTRitems
in bidi for itemize, enumerate, description and thebibliography environment.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://tug.org/pipermail/xetex/attachments/20110216/428820b0/attachment.html>


More information about the XeTeX mailing list