9

I use XePersian to typeset Persian, but I don't want my section number mirrored! For example, section 3-1 is written as section 1-3, which is embaressing! So, I want my numbers back :-)

This issue is not limited to sections, but also affects subsections, figure and table numbers; So I need a solution to fix them all.

I want this:

1-1
1-2
1-3
1-4
...

And certainly not:

1-1
2-1
3-1
4-1
...

This is a minimal working example:

\documentclass{book}

\usepackage{xepersian}
\settextfont[Scale=1]{Arial}
\setlatintextfont[Scale=1]{Arial}
\setdigitfont[Scale=1]{Arial}

\SepMark{-}

\begin{document}
\tableofcontents
\chapter{فصل}
\section{اول}
\section{دوم}
\section{سوم}
\section{چهارم}
\end{document}
  • 2
    If you're writing a document in Persian I suppose you know this, but for the sake of others it's worth saying: xepersian is doing it the right way, and you are trying to do it the wrong way. – adam.baker Sep 27 '15 at 9:08
  • 1
    @adam.baker Are you sure? This is the standard defined in most thesis templates in Persian, and besides, it doesn't make sense to mirror a sequence of numbers. – Ho1 Sep 27 '15 at 9:18
  • That is what educated people have told me. Also, the creator of XePersian seems to be a native speaker of Persian, and also someone who knows quite a bit about Persian typography. (If there's a specific stylesheet guideline, then of course defer to that.) – adam.baker Sep 28 '15 at 5:17
  • @adam.baker I double checked the MS Word style, which my university provided, and it was as I said before. And, yes. Dr. Khalighi is a knowledgeable TeXpert who speaks Persian, but I should provide what I asked to. Anyway, thanks for mentioning this issue. – Ho1 Sep 28 '15 at 5:40
  • I have the exact same problem but the suggested solution does not work for me which is quite sad. Please note that I get what people are referring to as the right or the wrong way (seeing the section number as a number), but I agree with the OP that the standard is different from what is defined in xepersian. – Gigili Aug 30 '16 at 5:44
11

Using the solution from Fix nested section numbers in RTL languages with polyglossia (and no, I haven't gotten down to why this works yet):

\documentclass{book}    
\usepackage{polyglossia}
\setmainlanguage[numerals=western]{farsi}
\newfontfamily\arabicfont{Arial}
\makeatletter
\renewcommand{\SepMark}[1]{\def\@SepMark{#1}}
\makeatother
\SepMark{-}

\begin{document}
\tableofcontents
\chapter{فصل}
\section{اول}
\section{دوم}
\section{سوم}
\section{چهارم}
\end{document}

enter image description here

For reference, without the \renewcommand above, the definition of \SepMark from the bidi package is:

\def\SepMark#1{\gdef\@SepMark{\if@RTL\fi#1\if@RTL\fi}}

And using your original document with the Farsi numbering, the redefinition of \SepMark works, too. I'm just using polyglossia for compactness.

  • Thanks, it worked fine! I suggest to remove [numerals=western], because users usually want localized numbers, and not western numebers. – Ho1 Sep 27 '15 at 6:19
  • Right. Wasn't sure given your examples, plus it's difficult for me to read the localized numbers (I already spent an embarrassing amount of time changing things while looking at the body text instead of the ToC page). – Mike Renfro Sep 27 '15 at 13:04
6

The above answer is correct. I am adding this answer for the reference. One should add this lines to the MWE provided in the question:

\makeatletter
\def\SepMark#1{\gdef\@SepMark{\if@RTL\fi#1\if@RTL\fi}}
\makeatother

So, this will work as intented:

\documentclass{book}

\usepackage{xepersian}
\settextfont[Scale=1]{Arial}
\setlatintextfont[Scale=1]{Arial}
\setdigitfont[Scale=1]{Arial}

\makeatletter
\def\SepMark#1{\gdef\@SepMark{\if@RTL\fi#1\if@RTL\fi}}
\makeatother
\SepMark{-}

\begin{document}
\tableofcontents
\chapter{فصل}
\section{اول}
\section{دوم}
\section{سوم}
\section{چهارم}
\end{document}

Fixing chapter number issues in XePersian

It fixes all the issues with chapter numbers, and also number for formulas, figures and tables.

4

As others stated, what you are asking is wrong and indeed weird; xepersian have been around since 2008 and this is the first time I hear such thing. Say that you are using the book document class and the third equation in the fifth chapter is numbered as 3.5; this is no longer a number. Since you are writing from right to left, the first number is your chapter number and the last one is your equation number. This is numbered in MS Word as 5.3 only because MS Word applies unicode bidi algorithm automatically but it does not mean that it is correct; I would suggest contacting your university and asking about it. The behavior you see in xepersian is done certainly on purpose and there is good reason for it.

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.