Is there any reasonable, generic way (i.e. not only Arabic, or only Farsi) to write RTL LaTeX documents (or even bidi) and compile them with pdfTeX or LuaTex?

In ConTeXt, we can use \righttoleft{my inline content}, \startalignment[righttoleft] my paragraph content \stopalignment and finally \setupalign[righttoleft] for the base direction of the document.

When using the bidi package (which only works for XeLaTeX as far as I know), they are \RL, setRL and \usepackage[RTLdocument]{bidi} respectively.

So is there a way, and if so what are the three equivalent commands for pdf/LuaLaTex? The reason I'm asking is that we're debating what pandoc should generate for LaTeX output.

  • As far as I know, XeLaTeX is the best choice for documents needing sophisticated multilingual support. Is there a reason pandoc needs to generate code for one of the less linguistically-advanced engines? (It is true that XeTeX is not, as I understand it, being actively developed now. Maybe LuaTeX will catch up. But my understanding is that it is not there yet.)
    – cfr
    Aug 23 '15 at 20:34
  • 1
    LuaTeX has also support for text directions, see \luatexpardir and \luatextextdir. this is much lower level than what is provided by bidi package. there is also luabidi, but I don't know what is it's status
    – michal.h21
    Aug 23 '15 at 20:51
  • For pdflatex there is arabi package with babel, which provide \textRL, \selectlanguage{arabic}, and environment to write right to left text.
    – Salim Bou
    Aug 24 '15 at 6:12
  • 4
    @cfr XeTeX is being actively developed. Aug 25 '15 at 3:25
  • 1
    @mb21 There is a luabidi, albeit very rudimentary, they has bidi's basic commands. Aug 25 '15 at 3:28

From the comments above, I managed to define a few commands that should serve as basic fallbacks for those people that resist XeTeX.


\newcommand{\RL}[1]{\bgroup\luatextextdir TRT#1\egroup}
\newcommand{\LR}[1]{\bgroup\luatextextdir TLT#1\egroup}
\newenvironment{RTL}{\luatextextdir TRT\luatexpardir TRT\luatexbodydir TRT}{}
\newenvironment{LTR}{\luatextextdir TLT\luatexpardir TLT\luatexbodydir TLT}{}


\newcommand{\RL}[1]{\beginR #1\endR}
\newcommand{\LR}[1]{\beginL #1\endL}

But how to set the base direction to rtl? (i.e. if most/all the text is right-to-left, it should start flowing from the right edge.) Do I really need to wrap the whole document in a giant \begin{RTL}...\end{RTL}?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.