[XeTeX] XeTeX, Persian, Page Numbers, Footnote Numbers
Bruno Voisin
bvoisin at mac.com
Wed Nov 28 07:13:51 CET 2007
Le 28 nov. 07 à 01:29, mjslouber at berkeley.edu a écrit :
>> Date: Tue, 27 Nov 2007 07:37:38 -0800 (PST)
>> From: Apostolos Syropoulos
>>
>>> Is it possible to produce page numbers in Persian? The same
>>> question exists about >footnote numbers, endnote numbers and heading
>>> numbers.
>>
>> Of course it is. But either you have modify the standard commads or
>> you have to introduce some new commands to take care of this.
>>
>
> I am also interested in using non-arabic numbering in my XeTeX/LEDMAC
> edition, and I am afraid A.S.'s answer is not very helpful. Is it too
> complicated to explain to a beginner how to change these numbering
> commands?
IIRC LaTeX knows only about arabic and roman numbers, and also about
numbering using the roman alphabet and using "old-fashioned" non-
alphanumeric characters (for footnotes) like *, §, ¶, †, ‡, ǁ
and the like.
LaTeX sets up the way counters appear in output by making definitions
(for example in article.cls) equivalent to
\renewcommand{\thesection} {\arabic{section}} % for sections
\renewcommand{\thepart} {\Roman{part}} % for parts
\renewcommand{\thefootnote}{\fnsymbol{footnote}} % for footnotes
\renewcommand{\theenumii} {\alph{enumii}} % for second-order
numbered lists
where section is the section counter and \thesection the way this
counter is displayed, and so forth.
But then the hard work of defining the commands \arabic, \roman and so
forth is done in latex.ltx, with code equivalent to:
\newcommand{\arabic}[1]{\expandafter\@arabic\csname c@#1\endcsname}
\newcommand{\roman}[1]{\expandafter\@roman\csname c@#1\endcsname}
\newcommand{\Roman}[1]{\expandafter\@Roman\csname c@#1\endcsname}
\newcommand{\alph}[1]{\expandafter\@alph\csname c@#1\endcsname}
\newcommand{\Alph}[1]{\expandafter\@Alph\csname c@#1\endcsname}
\newcommand{\fnsymbol}[1]{\expandafter\@fnsymbol\csname c@#1\endcsname}
\newcommand{\@arabic}[1]{\number #1}
\newcommand{\@roman}[1]{\romannumeral #1}
\newcommand{\@Roman}[1]{\expandafter\@slowromancap\romannumeral #1@}
\newcommand{\@slowromancap}[1]{\ifx @#1% then terminate
\else
\if i#1I\else\if v#1V\else\if x#1X\else\if l#1L\else\if
c#1C\else\if d#1D\else \if m#1M\else#1\fi\fi\fi\fi\fi\fi\fi
\expandafter\@slowromancap
\fi}
\newcommand{\@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}
\newcommand{\@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}
\newcommand{\@fnsymbol}[1]{\ensuremath{\ifcase#1\or *\or \dagger\or
\ddagger\or
\mathsection\or \mathparagraph\or \|\or **\or \dagger\dagger
\or \ddagger\ddagger \else\@ctrerr\fi}}
where \number and \romannumeral are TeX primitives (i.e., commands
implemented in the core TeX engine itself).
I don't have time to try to explain these definitions in detail, I
hope they're more-or-less self-explanatory.
I can't say much more not knowing anything about Persian numbers. From
the answer given by Mojca Miklavec and using ConTeXt, it seems Persian
numbers have the same structure as so-called "arabic" numbers (i.e.
base-10, right-to-left ordering of successive powers of 10). So if
that's indeed correct, and if the font BCompset does indeed provide
Persian numbers at the slots normally reserved for arabic numbers,
then I guess the following could do the job, in the preamble of your
LaTeX file:
\usepackage{fontpec}
\newfontfamily\persianfont{BCompset}
\makeatletter
\newcommand{\persian}[1]{\expandafter\@persian\csname c@#1\endcsname}
\newcommand{\@persian}[1]{\bgroup\persianfont\number #1\egroup}
\makeatother
\renewcommand{\thefootnote}{\persian{footnote}}
Three more things:
- The above is untested, incomplete (it's not dealing with page
numbers which are more complicated) and probably won't work as is. I
hope it could provide a starting point for others to come up with
something usable.
- It's likely that there's a LaTeX package out there somewhere
allowing this to be done transparently. But I'm lost personally in the
jungle of innumerable and largely redundant LaTeX packages. Have you
looked at the LaTeX Companion 2nd edition?
- Apart from the Persian font thing, it's more a generic LaTeX
question than a XeTeX-specific one. Accordingly, you could get luckier
by asking it at a generic LaTeX forum like comp.text.tex.
In any case, you see that changing numbering in LaTeX is not
straightforward at all, and yes, it's complicated to explain to a
beginner how to change it.
Hope this helps though,
Bruno Voisin
More information about the XeTeX
mailing list