[XeTeX] XeTeX, Persian, Page Numbers, Footnote Numbers

Mostafa Vahedi vahedi58 at yahoo.com
Wed Nov 28 12:33:45 CET 2007


Ali,

For the macros that you look for, I agree with the previous people who replied to your question that it is not easy (in fact very difficult) to do that from scratch. However you can reuse much of the macros of the Arabi package. Specially I recommend using ArabXeTeX + BIDI + some macros from the Arabi package. Note that the Arabi package was written to support Arabic and Persian using LaTeX and Babel.

Arabic digits and Persian digits are different! For the Arabic digits in Unicode we should use U+0660 to U+0669 and for the Persian digits we SHOULD use U+06F0 to U+06F9.

Mostafa

Ali Majdzadeh <ali.majdzadeh at gmail.com> wrote: Bruno,
 By the way, Persian numbers are axactly the same as Arabic.
 
 Regards
 Ali

2007/11/28, Ali Majdzadeh <ali.majdzadeh at gmail.com>: Hello Bruno
 Thanks a lot. I am going to give it a try.
 
 Regards
 Ali

2007/11/28, Bruno Voisin <bvoisin at mac.com>:  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





       
---------------------------------
Be a better sports nut! Let your teams follow you with Yahoo Mobile. Try it now.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://tug.org/pipermail/xetex/attachments/20071128/b8e3ca4e/attachment-0001.html 


More information about the XeTeX mailing list