# Fix nested section numbers in RTL languages with polyglossia.

The third subsection in the second subsection of the first section should be numbered 1.2.3. This holds also for RTL languages, since numbers, including Dewey numbering is still LTR even in an RTL language. Babel seems to have this right, but polyglossia is confused. How do you fix that?

Here is an example:

\documentclass{article}
\usepackage{polyglossia}
\setmainlanguage{hebrew}
\setotherlanguage{english}
\newfontfamily\hebrewfont[Script=Hebrew]{Ezra SIL}% or{SBL Hebrew}

\begin{document}
\section{1st Sect. Should be \#1}
\subsection{1st Subsect. Should be \#1.1}
\subsubsection{1st Subsubsect. Should be \#1.1.1}
\subsubsection{2nd Subsubsect. Should be \#1.1.2}
\subsection{2nd Subsect. Should be Numbered 1.2}
\section{2nd Sect. Should be \#2}
\subsection{1st Subsect. Should be \#2.1}
\subsubsection{1st Subsubsect. Should be \#2.1.1}
\subsubsection{2nd Subsubsect. Should be \#2.1.2}
\subsubsection{3rd Subsubsect. Should be \#2.1.3}
\subsection{2nd Subsect. Should be \#2.2}
\subsubsection{1st Subsubsect. Should be \#2.2.1}
\subsubsection{2nd Subsubsect. Should be \#2.2.2}
\end{document}

-
No, babel is confused. This is the correct format. It is true that in RTL, numbers should be typeset LTR but not in this case. because when it is 3.2.1, 1 stands for section, 2 stands for subsection and 3 stands for subsubsection. This is not a number that should be typeset LTR anymore. –  IRAN Feb 8 '11 at 14:11
I second Vafa on this, I find that a feature not a bug. –  Khaled Hosny Feb 8 '11 at 14:49
Do not know about Farsi or Arabic, but I am 100% certain that Hebrew does not work this way at all. Take a look at e.g., official government regulations: molsa.gov.il/MisradHarevacha/HomePageMenu/Regulations/… . (Use Google translate if you cannot read Hebrew( –  Yossi Gil Feb 8 '11 at 19:06
Yossi Gil: See my answer however as I mentioned this is incorrect. –  IRAN Feb 9 '11 at 3:51
Vafa: I respect your judgment, but, alas, Hebrew simply does not abide by it. Section 1, subsection 2, must be written LTR in Hebrew, which is "1.2". –  Yossi Gil Feb 9 '11 at 5:01
show 1 more comment

Put this in the preamble of your document and it will give your desired results, however I do not think this is the right thing to do:

\makeatletter
\renewcommand{\SepMark}[1]{\def\@SepMark{#1}}
\makeatother
\SepMark{.}

-
Neat solution. Should be added to Hebrew options. –  Yossi Gil Feb 9 '11 at 5:13
Ok, then you should contact the author of polyglossia with good documentation about why it should be done this way for Hebrew. –  IRAN Feb 9 '11 at 6:02
I just did. I hope he will make the change. –  Yossi Gil Feb 11 '11 at 8:50
Why does this work? –  einpoklum Apr 20 '13 at 14:23

I don't know if all RTL languages respect this convention. But you can easily change the numbers in your preamble:

\makeatletter
\renewcommand{\thesection}{\LR{\thechapter\@SepMark\arabic{section}}} % if using book class
\renewcommand{\thesubsection}{\LR{\thesection\@SepMark\arabic{subsection}}}
\renewcommand{\thesubsubsection}{\LR{\thesubsection\@SepMark\arabic{subsubsection}}}
\makeatother

-
Thanks. Great help here. IMHO, this should go in the hebrew.ldf file. There needs to be a way for adapting this to a book rather than an article class. One perhaps could use \let to save the previous definition and redefine it wrapping it with \LR. –  Yossi Gil Feb 8 '11 at 19:08
@Yossi all of the section counters are basically the same, so it's not hard to redefine them too in the same way. I've added code to the example for the book class to redefine \thesection in the same way. –  Alan Munn Feb 9 '11 at 2:53
This does not work as expected in the upcoming version of bidi. Get bidi from bitbucket and test if this actually works. –  IRAN Feb 9 '11 at 3:36
@Vafa Surely I can only be expected to test code with existing versions of a package, unless I'm supposed to be clairvoyant :-). It works with the current version, which is all I have. But your solution is certainly simpler, and seems to work with both the existing and (I assume) upcoming version. –  Alan Munn Feb 9 '11 at 4:13
@Alan Munn: My apologies. What I meant was that it would not work with the new version of bidi since bidi changes some of its old definitions. –  IRAN Feb 9 '11 at 6:06