Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

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

  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"
share|improve this question
    
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
add comment

marked as duplicate by Heiko Oberdiek, Thorsten, lockstep, cgnieder, Kurt Nov 17 '12 at 18:13

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

1 Answer

up vote 1 down vote accepted

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}

See also http://tex.stackexchange.com/a/70903/4427

enter image description here

share|improve this answer
    
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
add comment

Not the answer you're looking for? Browse other questions tagged or ask your own question.