1

I am writing a book in Urdu using polyglossia package. Urdu text goes from right to left but numbers are written from left to right. The number format is correct everywhere except in the section numbering in the table of contents and references. The minimal example that reproduces the error is as follows

\documentclass{book}
\usepackage{fontspec}
\usepackage{polyglossia}
\setmainlanguage{urdu}
\def\urdunumber#1{\protect\farsidigits{\number#1}}
\setotherlanguage{english}
\setmainfont[
    Script=Arabic,
    Extension=.ttf,
    Scale=1.0]{JameelNooriNastaleeq}

\setmonofont{DejaVu Sans Mono}
\let\urdufontt\ttfamily

\author{احمد}

\title{کتاب}

\begin{document}
\sloppy

\frontmatter

\maketitle


\tableofcontents
\pagestyle{empty}
\chapter{دیباچہ}

\mainmatter

\pagestyle{headings}

\chapter{پہلا}
\section{حصہ اول}
\section{حصہ دوم}
\begin{equation}
a+b
\end{equation}
\begin{equation}
\label{test}
    a+c
\end{equation}
دوسری مساوات \ref{test}

\backmatter
\end{document}

The section numbers in the table of content follow the RTL direction. enter image description here

The reference generated by \ref also follows the RTL direction. enter image description here

Any Help would be highly appreciated

1

Seems to be a bug as reported here. Using \setlatin at the beginning, as suggested here, has solved the problem.

\documentclass{book}
\usepackage{fontspec}
\usepackage{amsmath}
\usepackage{polyglossia}
\setmainlanguage{urdu}
\def\urdunumber#1{\protect\farsidigits{\number#1}}
\setotherlanguage{english}
\setmainfont[
    Script=Arabic,
    Extension=.ttf,
    Scale=1.0]{JameelNooriNastaleeq}

\setmonofont{DejaVu Sans Mono}
\let\urdufontt\ttfamily

\setlatin
%fix equation numbering for formulas
\makeatletter
\def\tagform@#1{\maketag@@@{(\ignorespaces#1\unskip)}}
\makeatother

\author{احمد}

\title{کتاب}

\begin{document}
\sloppy

\frontmatter

\maketitle


\tableofcontents
\pagestyle{empty}
\chapter{دیباچہ}

\mainmatter

\pagestyle{headings}

\chapter{پہلا}
\section{حصہ اول}
\section{حصہ دوم}
\begin{equation}
a+b
\end{equation}
\begin{equation}
\label{test}
    a+c
\end{equation}
دوسری مساوات \ref{test}

\backmatter
\end{document}

enter image description here

enter image description here

Edit (amsmath package)

When using amsmath package, the parentheses get reversed with \setlatin; We need to add the following after \setlatin as a way around this

%fix equation numbering for formulas
\makeatletter
\def\tagform@#1{\maketag@@@{(\ignorespaces#1\unskip)}}
\makeatother

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.