2

I want to produce pages numbered in literal way in arabic book environment, in the Frontmatter of a document instead of roman numbering in the usual way. The order of the arabic letters counter for the computers is not the numbers order but it's another one. Note that the number of arabic letters is 28. I give the way of literal numbering in arabic for computers, and the values coresponding to each arabic letter. This correspondence is given in the following tabulars:

enter image description here

This means for example, that the number 23 is not represented by the lettre number 23, which is the arabic letter ث , but of the "letters" كج, because the computer reads this command as 23=20+3 and replaces the number 20 by its corresponding letter ك and the number 3 by its corresponding letter ج.

To obtain the good literal representation of the numbers, I increase the counter 'page' by 9 at every new page , until the page number 20; after increase this counter by 99 until we arrive to the page number 28, the number of arabic letters.

I try to do this, using the following commands and packages...

\usepackage{ifthen}
\usepackage{everypage}

\AddEverypageHook{\ifthenelse{\value{page}<11}
                {}
                {
                \ifthenelse{\value{page}<101}
                {\addtocounter{page}{9}} 
                {
                \ifthenelse{\value{page}<999}
                {\addtocounter{page}{99}}
                {}
                }
                }
                }

This gives a good way for the first steps of my purpose...but I have several problems about this:

  1. The first problem is that I use the package 'changepage' to check even/odd pages, to background the odd pages with an image. Now this manipulation transforms all the pages in even pages. How can I do for changing only the pagemark but not the pagenumber ?

  2. We can use this method when the number of paqes is lesser than 28. What about for the number of pages greater than 28.. I want a counter which reinitializes to 1 for the letter 29 and adds the first letter before the counter..something like aa, ab, ac... ax, ay,az.

  3. The command \thepage refers to the label of the page before adding 9 (or 99). How to refer good for the command \thepage ?

  4. What's the command that makes the command '\frontmatter' adopt the roman numberimg for pages ? How can we make the default style be this style of numbering (call it \arabicliteral) for pages in the preamble of the book in arabic environment..? (I think about a possible macro to introduce it in arabic packages...)

Update

I give the tex file which produced the 3 tabulars attached here, for clearness and after demand. I think that the arabic font "Simplified font" is used here because I think that it's available in almost all systems. If not I'll search about a fonte like this.

\documentclass[12pt]{book} 

\usepackage{polyglossia}
\setmainlanguage[numerals=maghrib]{arabic}
\setotherlanguage{english}
\newfontfamily\arabicfont[Script=Arabic,Scale=1.2]{Simplified Arabic}
\newfontfamily\englishfont[Scale=1]{Times New Roman}

\begin{document}
\pagestyle{empty}

\begin{center}
\LR{
\begin{tabular}{|c|c|c|c|c|c|c|c|c|}
\hline
1&  2&  3   &4& 5&  6   &7  &8  &9\\
\hline
 ا  &ب& ج&  د   &ه& و&  ز   &ح& ط   \\ 
\hline
\end{tabular}
}
\vspace*{14pt}

\LR{
\begin{tabular}{|c|c|c|c|c|c|c|c|c|}
\hline
10& 20& 30  &40&    50  &60 &70 &80 &90\\
\hline
    ي&  ك&  ل&  م   &ن  &س& ع   &ف  &ص  \\ 
\hline
\end{tabular}
\vspace*{14pt}
}

\LR{
\begin{tabular}{|c|c|c|c|c|c|c|c|c|c|}
\hline
100 &200&   300 &400&   500 &600&   700 &800&   900 &1000   \\
\hline
ق   &ر  &ش  &ت& ث   &خ  &ذ  &ض  &ظ  &   غ   
\\ 
\hline
\end{tabular}
}
\end{center}
 \end{document}

Update 2 based on the solution given Here is the solution given by @HeikoOberdiek, completed with the arabic font. This is the tex file

\documentclass{article}

    \usepackage{polyglossia}
    \setmainlanguage[numerals=maghrib]{arabic}
    \setotherlanguage{english}
    \newfontfamily\arabicfont[Script=Arabic,Scale=1.2]{Simplified Arabic}
    \newfontfamily\englishfont[Scale=1]{Times New Roman}

    \usepackage{alphalph}

% https://en.wikipedia.org/wiki/Abjad_numerals
\makeatletter
\newcommand*{\@arabicliteral@symbol}[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 غ%
  \else
    \@ctrerr
  \fi
}
\newalphalph\@arabicliteral{\@arabicliteral@symbol}{28}
\newcommand*{\arabicliteral}[1]{\@arabicliteral{\value{#1}}}
\makeatother

\newcounter{test}
\renewcommand*{\thetest}{\arabicliteral{test}}
\newcommand*{\printtest}{\thetest~(\the\value{test})}

\begin{document}

\setcounter{test}{1}\printtest,

\stepcounter{test}\printtest,

\stepcounter{test}\printtest, \dots,

\addtocounter{test}{22}\printtest,

\stepcounter{test}\printtest,

\stepcounter{test}\printtest,

\stepcounter{test}\printtest,

\stepcounter{test}\printtest,

\stepcounter{test}\printtest,

\stepcounter{test}\printtest,

\stepcounter{test}\printtest, \dots,

\addtocounter{test}{24}\printtest,

\stepcounter{test}\printtest,

\stepcounter{test}\printtest,

\stepcounter{test}\printtest,

\end{document} 

It's compilation is given, (one letter per line and read it in RighttoLeft mode, as arabic !)

enter image description here

  • to answer just (4): in the definition of \frontmatter, page numbering is set up to be \pagenumbering{roman}. so for a book in arabic, that should be replaced by something more appropriate. this definition is in book.cls and equivalent document classes, and should be amenable to modification using one of the "patch" techniques. – barbara beeton May 28 '15 at 14:30
  • Thanks... This command would be replaced by \pagenumbering{literalarabic}, where 'literalarabic' will be the name of this kind of counting letters... – Faouzi Bellalouna May 28 '15 at 15:14
  • @FaouziBellalouna I don’t understand how the examples at the bottom at your question relate to the table you give at the top. According to your table, 25 should be written as كه (not ظ), then 25 as كو, (not ظ) etc. Are you sure Heiko’s code does what you want? – Arthur Reutenauer May 28 '15 at 18:56
  • @ArthurReutenauer Yes The Heiko's code does exactly what I want. I think that you make some confusion between letters... The arabic letter number 25 is the letter ذ not the letter ظ... There's 28 letters in arabic alphabet not 26. You can see in my update (the list one letter per line) that there's the letter number 25 in the list and it's the good letter...ذ – Faouzi Bellalouna May 28 '15 at 20:26
  • @FaouziBellalouna Yes, I got the single letters wrong, but whatever. In any case the beginning of your question is irrelevant to what you actually want to do. I think you should remove it. – Arthur Reutenauer May 28 '15 at 20:42
2

Issue 2: Package alphalph provides formatting commands for counters, which uses a limited set of symbols. There are different methods for extending the allowed range of values. The default method is the method of the question and shown in the example below.

Issue 1: If the counter formatting command of the previous paragraph is used, then the counter values are still the normal values, increased by 1 for each \stepcounter. Therefore the odd and even detection should work as normal using the value of the counter (\value{<counter>}).

Issue 3: With the redefinition of \thepage, the arabic literal appearance is also used in references.

Issue 4: \pagenumbering automatically redefines \thepage with the specified counter formatting command and resets the page counter to 1.

Example which uses the symbols A to Z, *, + instead of the Arabic glyphs:

\documentclass{article}

\usepackage{alphalph}

% https://en.wikipedia.org/wiki/Abjad_numerals
\makeatletter
\newcommand*{\@arabicliteral@symbol}[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\or *\or +%
  \else
    \@ctrerr
  \fi
}
\newalphalph\@arabicliteral{\@arabicliteral@symbol}{28}
\newcommand*{\arabicliteral}[1]{\@arabicliteral{\value{#1}}}
\makeatother

\newcounter{test}
\renewcommand*{\thetest}{\arabicliteral{test}}
\newcommand*{\printtest}{\thetest~(\the\value{test})}

\begin{document}
\setcounter{test}{1}\printtest,
\stepcounter{test}\printtest,
\stepcounter{test}\printtest, \dots,
\addtocounter{test}{22}\printtest,
\stepcounter{test}\printtest,
\stepcounter{test}\printtest,
\stepcounter{test}\printtest,
\stepcounter{test}\printtest,
\stepcounter{test}\printtest,
\end{document} 

Result

Extended example

I assume, that the Arabic literal digits should not combine, if the numbers exceed 28. The following example achieves this by putting the digit into \mbox. Also the example shows, that page references work as usual. And \pagenumbering enables the "Arabic literal" page numbers.

\documentclass{article}

\usepackage{polyglossia}
\setmainlanguage[numerals=maghrib]{arabic}
\setotherlanguage{english}
%\newfontfamily\arabicfont[Script=Arabic,Scale=1.2]{Simplified Arabic}
\newfontfamily\arabicfont[Script=Arabic,Scale=1.2]{FreeSerif.otf}
%\newfontfamily\englishfont[Scale=1]{Times New Roman}
\newfontfamily\englishfont[Scale=1]{lmroman10-regular.otf}

\usepackage{alphalph}

% https://en.wikipedia.org/wiki/Abjad_numerals
\makeatletter
\newcommand*{\@arabicliteral@symbol}[1]{%
  \mbox{%
    \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 غ%
    \else
      \@ctrerr
    \fi
  }%
}
\newalphalph\@arabicliteral{\@arabicliteral@symbol}{28}
\newcommand*{\arabicliteral}[1]{\@arabicliteral{\value{#1}}}
\makeatother


\newcommand*{\test}{%
  \begin{otherlanguage}{english}
    This is page \the\value{page} or \foreignlanguage{arabic}{\thepage}.
  \end{otherlanguage}
  \label{page\the\value{page}}
  \newpage
}

\begin{document}
\pagenumbering{arabicliteral}

\begin{otherlanguage}{english}
List of page references:
\end{otherlanguage}

\pageref{page1}, \pageref{page2}, \pageref{page3}, \dots,
\pageref{page25}, \pageref{page26}, \pageref{page27}, \pageref{page28},
\pageref{page29}, \pageref{page30}, \pageref{page31}, \dots,
\pageref{page56}, \pageref{page57}, \pageref{page58}, \pageref{page59}
\medskip

\test\test\test

\addtocounter{page}{21}% omitting some pages

\test\test\test\test\test\test\test

\addtocounter{page}{24}% omitting some pages

\test\test\test\test

\end{document}

As result, the list of page references is shown:

Result

  • I think that you are in the good direction. would you see my update where you can find the tex file which produced the tabulars in my post. Note that the arabic font "Simplified font" is used here because I think that it's available in almost all systems. If not I'll search about a fonte like this. – Faouzi Bellalouna May 28 '15 at 16:20
  • Would you please give another solution, using the arabic font, which can be based on the second update of my post. This will be I think the definitive answer. Many thanks for this brilliant answer – Faouzi Bellalouna May 28 '15 at 17:03
  • I just saw your update. It's exactly my purpose. Thanks – Faouzi Bellalouna May 28 '15 at 21:49
  • I just saw that you are the author of this package. Congratulations for this very useful one. I think that I'll use it too for an arabic-english glossary or dictionnary. Thanks – Faouzi Bellalouna May 29 '15 at 5:36

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.