0

I have a document with Persian elements. To get them typeset properly, I am using xepersian. Unfortunately, this results in all subsections being numbered RTL instead of LTR, thus 1.2.3 instead of 3.2.1.

what I get

How can I change this?

Minimal working example:

\documentclass[11pt,a4paper]{article}

% Font and Language Packages \usepackage{fontspec} % For font customization \usepackage{xunicode} % Extra Unicode support \usepackage{polyglossia} % Multilingual support \usepackage{xepersian} % Persian (Farsi) support

% Define the Persian (Farsi) font \newfontfamily\persianfont[Script=Arabic]{Amiri}

% Set Document Languages \setmainlanguage{german} % Main document language \setotherlanguages{persian, english} % Other languages used in the document

\begin{document}

% Table of Contents \tableofcontents

% Sections and Subsections \section{Einleitung} % German section This is the introduction section.

\section{Pahlavi-Zukunftsvisionen} % German section This is the Pahlavi-Zukunftsvisionen section.

\section{Exil-Zukunfts-Vergangenheits-Träumereien} % German section A section containing subsections.

\subsection{QQ Bang Bang} % German subsection This is the QQ Bang Bang subsection.

\subsubsection{Erinnerungen und Nostalgie} % German sub-subsection This is the Erinnerungen und Nostalgie sub-subsection.

\subsection{Another Subsection} % German subsection This is another subsection.

% Persian Text \begin{persian} این یک پاراگراف متن نمونه به زبان فارسی است. % A paragraph of Persian (Farsi) text.

این یک مثال از یک شعر به زبان فارسی است: % An example of a Persian (Farsi) poem. \end{persian}

% English Text \begin{english} This is a paragraph of dummy text in English. % A paragraph of English text. \end{english}

\end{document}

Floris
  • 89
  • 1
    if you have only a few persian elements xepersian is probably not suited. It (and bidi too) changes a lot of things. Consider to use lualatex + babel. – Ulrike Fischer Sep 19 '23 at 12:44

1 Answers1

1

The xepersian package is mostly useful when your main text is going to be in Farsi, otherwise you have to configure a lot of things to use it effectively. Instead, I suggest using the bidi package, assuming you will only have a small number of sentences in Farsi.

Here I defined a new command \persiantext that sets the text direction to right-to-left and uses the correct font for that part. You just need to use this when you have some text in Farsi.

\documentclass[11pt,a4paper]{article}

% Font and Language Packages \usepackage{fontspec} % For font customization \usepackage{xunicode} % Extra Unicode support \usepackage{polyglossia} % Multilingual support \usepackage{bidi} % For RTL support

% Define the Persian (Farsi) font \newfontfamily{\persianfont}[Script=Arabic]{Vazirmatn}

% Set Document Languages \setmainlanguage{german} % Main document language \setotherlanguages{persian,english} % Other languages used in the document

% Command to set the text direction and font for Persian text \newcommand{\persiantext}[1]{\begin{RTL} {\persianfont #1} \end{RTL}}

\begin{document}

% Table of Contents \tableofcontents

% Sections and Subsections \section{Einleitung} % German section This is the introduction section.

\section{Pahlavi-Zukunftsvisionen} % German section This is the Pahlavi-Zukunftsvisionen section.

\section{Exil-Zukunfts-Vergangenheits-Träumereien} % German section A section containing subsections.

\subsection{QQ Bang Bang} % German subsection This is the QQ Bang Bang subsection.

\subsubsection{Erinnerungen und Nostalgie} % German sub-subsection This is the Erinnerungen und Nostalgie sub-subsection.

\subsection{Another Subsection} % German subsection This is another subsection.

% Persian Text \persiantext{ این یک پاراگراف متن نمونه به زبان فارسی است. % A paragraph of Persian (Farsi) text.

این یک مثال از یک شعر به زبان فارسی است: % An example of a Persian (Farsi) poem. }

% English Text \begin{english} This is a paragraph of dummy text in English. % A paragraph of English text. \end{english}

\end{document}

enter image description here

NEO
  • 342
  • Thanks! I also have a longer sections of 2-3 pages in Persian thought, typeset in the verse environment. At the moment, I use polyglossia's \begin{persian} ... \end{persian}. I probably can't replace that with this solution, right? I cannot find proper documentation for bidi's modernpoem environment, otherwise I would happily use that! – Floris Sep 27 '23 at 10:08
  • Having longer text might make things a bit difficult but as long as the whole thing is just a few paragraphs of text with nothing fancy then I think the above solution should work fine. Did you run into any issues?

    Regarding bidi, here is the official documentation: https://mirror.lyrahosting.com/CTAN/macros/xetex/latex/bidi/bidi-doc.pdf

    – NEO Sep 27 '23 at 13:38