Page LayoutChange chapter numbers to words in Arabic

Information and discussion about page layout specific issues (e.g. header and footer lines, page formats, page numbers).
Post Reply
ali8
Posts: 2
Joined: Tue May 13, 2014 6:10 pm

Change chapter numbers to words in Arabic

Post by ali8 »

Instead of "Chapter 1" I want "Chapter one", but in Arabic.
one => الأول and so on.

In english, a solution exist:

Code: Select all

\usepackage{fmtcount,etoolbox}
    \makeatletter
    \patchcmd{\@makechapterhead}{\thechapter}{\Numberstring{chapter}}{}{}
    \patchcmd{\chaptermark}{\thechapter}{\NUMBERstring{chapter}}{}{}
    \makeatother
But what about Arabic? MWE:

Code: Select all

\documentclass[12pt,english]{book}
    \usepackage{fancyhdr}
    \usepackage{polyglossia}
    \setmainlanguage[numerals=maghrib]{arabic}
    \setotherlanguage{english}
    \newfontfamily\arabicfont[Script=Arabic,Scale=1.5]{Arabic Typesetting}
    \pagestyle{fancy}
    
    \begin{document}
    \selectlanguage{arabic}
    \chapter{مقدمة}
    
    \end{document}

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

FBellalouna
Posts: 2
Joined: Mon Mar 24, 2014 9:40 am

Re: Change chapter numbers to words in Arabic

Post by FBellalouna »

I have an answer; Are you here ?
User avatar
Johannes_B
Site Moderator
Posts: 4182
Joined: Thu Nov 01, 2012 4:08 pm

Re: Change chapter numbers to words in Arabic

Post by Johannes_B »

Even if not, is might be interesting for others. Please share your solution with us.
The smart way: Calm down and take a deep breath, read posts and provided links attentively, try to understand and ask if necessary.
FBellalouna
Posts: 2
Joined: Mon Mar 24, 2014 9:40 am

Change chapter numbers to words in Arabic

Post by FBellalouna »

You can add this macro in the preamble of your file. This gives the litteral numbering of chapters when you are in arabic environments

Code: Select all

%%%%%%%%%   MACRO Litteral Numbering of chapters in arabic language  %%%%%%%%

\newcommand\words[1]{\expandafter\xwords\csname c@#1\endcsname}
\def\xwords#1{\ifcase#1\or
الأول\or
الثاني\or
الثالث\or
الرابع\or
الخامس\or
السادس\or
السابع\or
الثامن\or
التاسع\or
العاشر\or
\else
I need more words\fi}
%%% You can add by the same if there is more then ten chapters

% \usepackage{etoolbox} %% uncomment if 'etoolbox' isn't already being loaded
\makeatletter
\patchcmd{\@makechapterhead}{\thechapter}{\words{chapter}}{}{}
\makeatother
%%%%%%%%%  END MACRO Litteral Numbering of chapters %%%%%%%%%%
oozypal
Posts: 12
Joined: Fri Dec 21, 2012 8:46 am

Change chapter numbers to words in Arabic

Post by oozypal »

How can we do the same for Book Parts to be

القسم الأول
instead of
القسم I or القسم II

I tried this but it did not work.

Code: Select all

\patchcmd{\@makeparthead}{\thepart}{\words{part}}{}{}
FBellalouna wrote:You can add this macro in the preamble of your file. This gives the litteral numbering of chapters when you are in arabic environments

Code: Select all

%%%%%%%%%   MACRO Litteral Numbering of chapters in arabic language  %%%%%%%%

\newcommand\words[1]{\expandafter\xwords\csname c@#1\endcsname}
\def\xwords#1{\ifcase#1\or
الأول\or
الثاني\or
الثالث\or
الرابع\or
الخامس\or
السادس\or
السابع\or
الثامن\or
التاسع\or
العاشر\or
\else
I need more words\fi}
%%% You can add by the same if there is more then ten chapters

% \usepackage{etoolbox} %% uncomment if 'etoolbox' isn't already being loaded
\makeatletter
\patchcmd{\@makechapterhead}{\thechapter}{\words{chapter}}{}{}
\makeatother
%%%%%%%%%  END MACRO Litteral Numbering of chapters %%%%%%%%%%
Post Reply