1

I am building a large document with xelatex-devanagari. Still, page numbers in the frontmatter defaults to roman numbering. How can I change them to Devanagari custom alphabetic numbering like अ,आ... or क,ख,ग...?

Similar numbering needed for enumerated lists. Presently, first level of enumeration shows Devanagari numerals. What is the best method to achieve Devanagari alphabetic numbering in other levels also?

Sample code -

\documentclass[oneside]{book}
\usepackage{fontspec}
\setmainfont[Script=Devanagari,Mapping=devanagarinumerals]{Sanskrit 2003}

\renewcommand{\chaptername}{अध्यायः}
\renewcommand{\contentsname}{विषयसूची}

\begin{document}

\frontmatter
\tableofcontents
\chapter{भूमिका}

\mainmatter
\chapter{सङ्ग्रहः}
\begin{enumerate}
  \item प्रथमम्
  \begin{enumerate}
    \item द्वितीयम्
    \begin{enumerate}
      \item तृतीयम्
      \begin{enumerate}
        \item चतुर्थम्
      \end{enumerate}
    \end{enumerate}
  \end{enumerate}
\end{enumerate}

\end{document}

enumeration demo

2
  • Thanks for adding the example. It raises new questions: with the default settings, there are multiple series: digits (1, 2, 3…), roman numerals (i, ii, iii…), lowercase letters (a, b, c…), uppercase letters (A, B, C…). The first of these should of course become १, २, ३…. What about the others? Which of them should become अ,आ… or क,ख,ग…? Apr 24 '17 at 1:46
  • As you know, Devanagari does not have that case differences. So, those who use it must differentiate each level. I like the way, * १, २, ३... for 1st level * क, ख, ग... for 2nd level * (१), (२), (३)... for 3rd level and * (क), (ख), (ग)... for 4th level
    – Gaudha
    Apr 24 '17 at 2:39
3

How counters are displayed

In LaTeX, a counter is displayed in one of several “styles”, given by \arabic, \roman, \Roman, \alph, \Alph, and \fnsymbol. (See Chapter 13 Counters in texdoc latex2e, or File m ltcounts.dtx in texdoc source2e, or here/here/here/here.) Of these, \fnsymbol is just symbols used for footnotes (*, ‡, ‡, §, ¶, ∥, **, ††, ‡‡), so it is enough to redefine the others.

For example, by default \Alph is defined via \@Alph which is defined as

\def\@Alph#1{%
 \ifcase#1\or A\or B\or C\or D\or E\or F\or G\or H\or I\or J\or
  K\or L\or M\or N\or O\or P\or Q\or R\or S\or T\or U\or V\or W\or X\or
   Y\or Z\else\@ctrerr\fi}

We can modify this to always use Devanagari consonants क, ख, ग, … everywhere, in place of Roman numerals or letters from the Latin alphabet. (You may also want Devanagari vowels अ, आ, इ, ई, … for one of those; it's your preference.)

How labels in enumerations are displayed

The labels for enumerate at each level are given by \labelenumi, \labelenumii, \labelenumiii, and \labelenumiv. (See section 8.7 enumerate in texdoc latex2e, or 54.6 Itemize and Enumerate in texdoc source2e.)

For example, by default \labelenumii is defined as (\theenumii) where \theenumii is in turn defined as \@alph\c@enumii, which is why at the second level of nesting in lists, you see labels like (a). You can redefine these too, if you (say) want the parentheses or periods in different places.

Putting it together

Here is your sample LaTeX source from the question, with appropriate modifications (the part within \makeatletter to \makeatother is the only change):

\documentclass[oneside]{book}
\usepackage{fontspec}
\setmainfont[Script=Devanagari,Mapping=devanagarinumerals]{Sanskrit 2003}

\makeatletter
% Always use Devanagari consonants for alph/Alph/roman/Roman styles.
\def\devanagari@alph#1{%
 \ifcase#1\or क\or ख\or ग\or घ\or ङ\or च\or छ\or ज\or झ\or ञ\or
  ट\or ठ\or ड\or ढ\or ण\or त\or थ\or द\or ध\or न\or प\or फ\or ब\or भ\or म\or
   य\or र\or ल\or व\or श\or ष\or स\or ह\else\@ctrerr\fi}
% Imitating xgreek.sty and xepersian.sty
\let\@alph\devanagari@alph
\let\@Alph\devanagari@alph
\let\@roman\devanagari@alph
\let\@Roman\devanagari@alph

% Change appearance of enumerate at levels 2, 3, 4.
\renewcommand{\labelenumii}{\theenumii.} % Instead of: (\theenumii)
\renewcommand{\labelenumiii}{(\theenumiii)} % Instead of: \theenumiii.
\renewcommand{\theenumiii}{\@arabic\c@enumiii} % Instead of: \@roman\c@enumiii
\renewcommand{\labelenumiv}{(\theenumiv)} % Instead of: \theenumiv.
\makeatother

\renewcommand{\chaptername}{अध्यायः}
\renewcommand{\contentsname}{विषयसूची}

\begin{document}

\frontmatter
\tableofcontents
\chapter{भूमिका}

\mainmatter
\chapter{सङ्ग्रहः}
\begin{enumerate}
  \item प्रथमम्
  \begin{enumerate}
    \item द्वितीयम्
    \begin{enumerate}
      \item तृतीयम्
      \begin{enumerate}
        \item चतुर्थम्
      \end{enumerate}
    \end{enumerate}
  \end{enumerate}
\end{enumerate}

\end{document}

Running this with xelatex gives Devanagari-consonant page numbers instead of roman numerals (for the front matter), and, for the enumerate, the following: enumerate environment with Devanagari labels

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.