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.

How to get devanagari numerals in xetex or latex - especially in enumerate environment?

I can use unicode to write devanagari text but I am unable to get devenagari numerals in section numbers, enumerate environment, etc.

Here is the basic code I am using:

\documentclass{article}

\usepackage{fontspec}
\usepackage{polyglossia}
\setdefaultlanguage{hindi}
\setotherlanguage{english}
\setmainfont[Script=Devanagari]{Nakula}

\begin{document}

\section{Section Heading}

देवनागरी

Same English Text

१ २ ३ ४ ५ ६ ७ ८ ९ ०

\begin{enumerate}
    \item   This is first
    \item   देवनागरी
\end{enumerate}

\end{document}           

Output of the above document compiled with xetex

And I am compiling using xetex (default set-up on Ubuntu 12.04).

share|improve this question

migrated from askubuntu.com Sep 6 '12 at 11:52

This question came from our site for Ubuntu users and developers.

    
Your question was migrated here from another stackexchange site. Please register on this site, too, and make sure that both accounts are associated with each other, otherwise you won't be able to comment on or accept answers or edit your question. –  percusse Sep 6 '12 at 11:56
    
You'll probably need a specific font for that. SIL has some devanagari fonts: sil.org/sil/news/2011/annapurna-font.htm –  ℝaphink Sep 6 '12 at 14:20
    
I can see devanagari numerals and devanagari text (१, २, देवनागरी, etc.) But the numbers in section numbers, enumerate environment are still arabic –  deshmukh Sep 8 '12 at 10:29

2 Answers 2

up vote 8 down vote accepted
+50

There's currently no interface for changing all numerals to Devanagari ones. However you can define your own:

\documentclass{article}

\usepackage{fontspec}
\usepackage{polyglossia}
\setdefaultlanguage{hindi}
\setotherlanguage{english}

\setmainfont[Script=Devanagari]{Nakula}

\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}

\section{\foreignlanguage{english}{Section Heading}}

देवनागरी

\foreignlanguage{english}{Some English Text}

१ २ ३ ४ ५ ६ ७ ८ ९ ०

\begin{enumerate}
    \item   \foreignlanguage{english}{This is first}
    \item   देवनागरी
\end{enumerate}

\end{document}

A more risky approach is to change the meaning of \@arabic (the internal command that represents counter with arabic digits):

\makeatletter
\def\@arabic#1{\expandafter\devanagaridigits\expandafter{\number#1}}
\makeatother

This would spare you from redefining all needed counter representations, but may break packages that rely on \@arabic.

enter image description here

share|improve this answer
    
I tried both the approaches. It produces an error ! Undefined control sequence. \devanagarinumeral #1->\devanagaridigits {\number \csname c@#1\endcsname } l.20 ...foreignlanguage{english}{Section Heading}} What could be wrong here? –  deshmukh Sep 11 '12 at 12:01
    
Add \usepackage{devanagaridigits}; on my machine this package is automatically loaded, perhaps your TeX distribution is older than mine. –  egreg Sep 11 '12 at 12:05
    
This has opened up Pandora's Box! My texlive installation is from Ubuntu repositories. It is a 2009 version. I could not find any devanagaridigits package in the repositories or on ctan.org Should I, therefore, go and install latest tex-live 2012? Can I install and use it where I do not have root access? I know, this should be a separate question. But thought might ask here for a link to these answers. Thanks, @egreg –  deshmukh Sep 12 '12 at 14:06
    
@deshmukh As far as I know TeX Live 2012 is in the Debian "testing" tree, but installing it requires root access anyway. –  egreg Sep 12 '12 at 14:14
    
thanks @egreg. I have accepted your answer and passed on the bounty. Will look up on installing Tex Live 2012 (with/ without root access). :) –  deshmukh Sep 12 '12 at 14:30

There is such a mapping, use Mapping=devanagarinumerals as the font feature. This mapping exists since July 2007, originally distributed with the velthuis package, now it is included in xetex-devanagari.

share|improve this answer
    
Where exactly does one set this mapping up? Will be useful if you can give a MWE/ the exact command. –  deshmukh Feb 11 '13 at 12:48

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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