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}
\beginR
and\endR
, butxelatex
complained:! Improper \beginR.
– Stefan Müller Nov 2 '13 at 10:38\TeXXeTstate = 1 \newbox\mybox \everypar{\setbox\mybox\lastbox\beginR\box\mybox}
will make all paragraphs RTL and move the indent correctly. – Joseph Wright♦ Nov 2 '13 at 10:41cjhebrew
package. It doesn't look like there's an Arab equivalent though. – einpoklum Nov 2 '13 at 22:26bidi
with no options means you want to typeset an LR document with some RL text. In LR mode,bidi
does not change document behaviour (e.g. margins, footnotes, etc), but of course it gives you the ability to do so. Every changebidi
does to internal macros of LaTeX and different packages, has a test to check whether you are typesetting in LR or RL mode. For LR, the macro will behave exactly as defined before loadingbidi
. You can also temporarily switch off TeX--XeT feature byTeXXeTOff
(provude bybidi
) and switch it back on byTeXXetOn
in case you have a package clash. – Hasan Zakeri Nov 3 '13 at 20:08