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}{९}
}
% \usepackage[bookmarksnumbered,urlcolor=??cyan,linkcolor=blue]{hyperref}
\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
- 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".
- If I uncomment the the commented line which has hyperref, xelatex would not compile and shows the message "! Undefined control sequence \arabictodevnag"

hyperrefare caused by the non-expandable definition of\thepage. Packagedevanagaridigitssolves 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