# Wrong page numbers in TOC and hyperref problems [duplicate]

Possible Duplicate:
How to get devanagari numerals in latex or xetex

This is a follow up to the discussion under XeLaTeX - Devanagari page numbers in \tableofcontents, as suggested by David Carlisle. I am using XeLaTeX (XeTeX, Version 3.1415926-2.4-0.9998 on TeX Live 2012/W32TeX). This is my minimal working example with a custom Indic page numbering style.

\documentclass[14pt]{article}
\usepackage{polyglossia}
\usepackage{fontspec}
\usepackage{lipsum}
\setmainfont[Script=Devanagari]{Arial Unicode MS}
\usepackage{xstring}
\renewcommand\thepage{\Devnag{page}}
\DeclareRobustCommand\Devnag[1]{\expandafter\arabictodevnag\expandafter{\the\csname c@#1\endcsname}}
\newcommand{\arabictodevnag}[1]
{
\StrSubstitute{#1}{0}{०}[\num]
\StrSubstitute{\num}{1}{१}[\num]
\StrSubstitute{\num}{2}{२}[\num]
\StrSubstitute{\num}{3}{३}[\num]
\StrSubstitute{\num}{4}{४}[\num]
\StrSubstitute{\num}{5}{५}[\num]
\StrSubstitute{\num}{6}{६}[\num]
\StrSubstitute{\num}{7}{७}[\num]
\StrSubstitute{\num}{8}{८}[\num]
\StrSubstitute{\num}{9}{९}
}
\begin{document}
\tableofcontents
\pagebreak
\section{One}
\lipsum[1-8]
\pagebreak
\section{Two}
\lipsum[1-8]
\pagebreak
\end{document}


There are two problems with the above

1. The page numbers are fine on the pages, but wrong in the TOC. All page numbers in the TOC are "1", whereas the sections begin on page numbers "2" and "4".
2. If I uncomment the the commented line which has hyperref, xelatex would not compile and shows the message "! Undefined control sequence \arabictodevnag"
-

## marked as duplicate by Heiko Oberdiek, Thorsten, lockstep, clemens, KurtNov 17 '12 at 18:13

The problems with the table of contents and hyperref are caused by the non-expandable definition of \thepage. Package devanagaridigits solves this in an expandable and even more efficient way. See this question and its answer. Therefore this question can be closed as duplicate. –  Heiko Oberdiek Nov 17 '12 at 17:53

You have to choose a language, not only loading polyglossia. Here's a working example:

\documentclass{article}
\usepackage{polyglossia}
\setmainlanguage[numerals=Devanagari]{hindi}
\usepackage{fontspec}
\usepackage{lipsum}
\setmainfont[Script=Devanagari]{FreeSerif} % I don't have Arial Unicode MS

\usepackage{hyperref,bookmark}

\newcommand{\devanagarinumeral}[1]{%
\devanagaridigits{\number\csname c@#1\endcsname}}

% renew all representation of counters
\renewcommand{\thesection}{\devanagarinumeral{section}}
\renewcommand{\thepage}{\devanagarinumeral{page}}
\renewcommand{\theenumi}{\devanagarinumeral{enumi}}

\begin{document}
\tableofcontents
\pagebreak
\section{One}
\lipsum[1-8]
\pagebreak
\section{Two}
\lipsum[1-8]
\pagebreak
\end{document}


-
Works, no need to define my own macro as well! Thanks, I am new to XeLaTeX and polyglossia and did not know of this feature. –  user22209 Nov 17 '12 at 17:11