I need to typeset RTL text (Arabic, Persian) for linguistics books. I know of the bidi
package. But bidi
is way to powerful for our purposes and it has many side effects (it basically affects everything: title, footnotes, margin notes, …). This results in problems with hyperref
as described here: bidi and hyperref change hyphenation
What I need is just the support for using the script in the main text. So the question is: What do I need for this functionality? Can I use code from the bidi
package? Could there be a package that users like me and bidi
loads? This would be most modular, I guess …
\documentclass{scrbook}
\usepackage{fontspec}
\usepackage{bidi}
\newfontfamily\Parsifont[Script=Arabic]{XB Niloofar}
\usepackage{bidi}
\newcommand{\PRL}[1]{\RL{\Parsifont #1}}
\begin{document}
Some Persian example: \PRL{او مرد را دوست نخواهد داشت.}
\end{document}
Edit:
OK. I now have the following. This works nicely for one line, but breaks for longer text. The problem is that after a linebreak text should start at the right hand site and not in the middle of the page as if it was left to right text ending in the middle of the page.
\documentclass{scrbook}
\usepackage{fontspec}
\newfontfamily\Parsifont[Script=Arabic]{XB Niloofar}
\newcommand{\TeXXeTOn}{\TeXXeTstate=1 }
\newcommand{\TeXXeTOff}{\TeXXeTstate=0 }
\TeXXeTOn
\newcommand{\RL}[1]{\beginR #1\endR}
\newcommand{\PRL}[1]{\RL{\Parsifont #1}}
\begin{document}
Some Persian example: \PRL{او مرد را دوست نخواهد داشت.}
\PRL{او مرد را دوست نخواهد داشت. و مرد را دوست نخواهد داشت. و مرد را دوست نخواهد داشت. و مرد را دوست نخواهد داشت.}
\end{document}
Best Answer
You will be needing two different commands/environments to typeset Persian (or any other RTL language alongside Latin texts. One for small RTL texts along in an LTR paragraph, and one for RTL paragraph.
bidi.tex
is part ofbidi
package for bidirectional typesetting in plain XeTeX, so it is pretty much minimal. It redefines only a handful of commands, and they are essential for correct bidirectional typesetting.