0

In a similar manner shown in

Change chapter numbers to words in Arabic

How can I write "Part one" instead of "part 1" but in Arabic:

Replace the word "part" with "الجزء" since the word "القسم" Is not appropriate.

I was able to do this replacement using the command:

\gappto\captionsarabic{\renewcommand{\partname}{الجزء}}

HOwever, I do not know how to replace the number with its arabic translation written in letters

Here is an MWE:


\documentclass[a4paper,12pt,twoside]{book}
\usepackage[a4paper,top=2.5cm,bottom=2.5cm,margin=2.5cm,bindingoffset=0.5cm]{geometry} 

\usepackage{hyperref} 

\usepackage{arabluatex}
\setcounter{secnumdepth}{6} 
\setcounter{tocdepth}{6}
    

\usepackage[bidi=basic,layout=lists.tabular]{babel}
\babelprovide[import=ar,mapdigits,main]{arabic}
\babelprovide[import=en,language=Default]{english}

\babelfont{rm}{Latin Modern Roman}
\babelfont[arabic]{rm}{Simplified Arabic}
\babelfont[english]{rm}{Times New Roman}








 %%%%%  END MACRO Litteral Numbering of chapters 
     
    \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
الحادي عشر\or 
الثاني عشر\or 
الثالث عشر\or 
الرابع عشر\or 
الخامس عشر\or 
السادس عشر\or  
السابع عشر\or
الثامن عشر\or 
التاسع عشر\or 
العشرون\or 
    \else
    I need more words أحتاج إلى المزيد من ترقيمات الأبواب بالحروف في ملف arbbook.cls\fi}

     
    %next three lines is to make chapter naming use the above wordings (literal numbering in Arabic words)

% The below commands so that chapter name apear in header as Chapter one instead of chapter1
\usepackage{etoolbox} 
\makeatletter
\pretocmd{\Hy@org@chapter}
  {\begingroup \renewcommand{\thechapter}{{\words{chapter}}}}
  {}
  {}
\patchcmd{\Hy@org@chapter} 
% Controls how chapter namin apear in table of contents
  {\addcontentsline{toc}{chapter}{\protect\numberline{\thechapter}#1}}
  {\addcontentsline{toc}{chapter}{\@chapapp\space\words{chapter}\space#1}}
  {}
  {}
\apptocmd{\Hy@org@chapter}
  {\endgroup}
  {}
  {}
\patchcmd{\@makechapterhead}
  {\thechapter}
  {\words{chapter}}
  {}
  {}
\makeatother
 
 


% The below commands so that part name apear in header as part one instead of part 1
\makeatletter
\pretocmd{\Hy@org@part}
  {\begingroup \renewcommand{\thepart}{{\words{part}}}}
  {}
  {}
\patchcmd{\Hy@org@part} 
% Controls how part namin apear in table of contents
  {\addcontentsline{toc}{part}{\protect\numberline{\thepart}#1}}
  {\addcontentsline{toc}{part}{\partname\space\words{part}\space#1}}
  {}
  {}
\apptocmd{\Hy@org@part}
  {\endgroup}
  {}
  {}
\patchcmd{\@makeparthead}
  {\thepart}
  {\words{part}}
  {}
  {}
\makeatother


% part Naming
\gappto\captionsarabic{\renewcommand{\partname}{الجزء}} %to name the part title   الجزء instead of القسم

% Chapter Naming
\gappto\captionsarabic{\renewcommand{\chaptername}{الباب}}
 
\gappto\captionsarabic{\renewcommand{\appendixname}{الملحق}}






\begin{document}

\part{تمهيد}
\chapter{شكر وتقدير} 
\subsection{سيشسي}
\subsubsection{شسيسشسي}


\end{document}

7
  • You might try with the fmtcount package, which uses .ldf files. As far as I know there's no .ldf file for arabic, but you could make one yourself.
    – Bernard
    Commented Apr 14, 2022 at 9:08
  • @Bernard, the attached link, he managed to do something similar using a different approach
    – Silva
    Commented Apr 14, 2022 at 9:20
  • in what way does the linked answer no answer the question? Commented Apr 15, 2022 at 19:10
  • The \part macro differs from \chapter macro, we might use an analogous approach, able to change the word "part" to "الجزء" by using \gappto\captionsarabic{\renewcommand{\partname}{الجزء}} However, I could not achieve literal numbering of parts and do not know how to set their appearance in the TOC
    – Silva
    Commented Apr 15, 2022 at 19:13
  • you just need to replace "chapter` by "part" so \renewcommand\thepart{\words{part}} with \words as defined there Commented Apr 15, 2022 at 19:54

1 Answer 1

1

Here is the general mechanism provided by babel to set locale dependent counters and redefine strings. There are some simplifications, but note the ‘words’ counter appears in the section number (you may redefine it, however). Requires a relatively recent version.

\documentclass[a4paper,12pt,twoside]{book}
\usepackage[a4paper,top=2.5cm,bottom=2.5cm,
            margin=2.5cm,bindingoffset=0.5cm]
           {geometry} 

\usepackage{hyperref} 

\setcounter{secnumdepth}{6} 
\setcounter{tocdepth}{6}

\usepackage[english, bidi=basic, layout=lists.tabular]{babel}
\babelprovide[
  import,
  mapdigits,
  main, % Space separated list. Use braces in multi-word items:
  counters/words = الأول الثاني الثالث الرابع الخامس السادس السابع
     الثامن التاسع العاشر {الحادي عشر} {الثاني عشر}]{arabic}

\babelfont{rm}{Simplified Arabic} % The main font for the main lang
\babelfont[english]{rm}{Latin Modern Roman} % Secondary font/lang

\renewcommand{\thepart}{\localecounter{words}{part}}
\renewcommand{\thechapter}{\localecounter{words}{chapter}}

\setlocalecaption{arabic}{part}{الجزء}
\setlocalecaption{arabic}{chapter}{الباب}
\setlocalecaption{arabic}{appendix}{الملحق}

\begin{document}

\part{تمهيد}
\chapter{شكر وتقدير} 
\subsection{سيشسي}
\subsubsection{شسيسشسي}

\end{document}

enter image description here

3
  • The words counter appearing in section number is odd, is there a way to set it?
    – Silva
    Commented Apr 16, 2022 at 19:43
  • The commands \setlocalecaption{arabic}{part}{الجزء} \setlocalecaption{arabic}{chapter}{الباب} \setlocalecaption{arabic}{appendix}{الملحق} Are useful, however, the numbering code won't be good enough for use, also will it cause issues in the table of contents?
    – Silva
    Commented Apr 16, 2022 at 20:25
  • \renewcommand{\thesection}{\arabic{chapter}.\arabic{section}}. See, for example, tex.stackexchange.com/questions/278299/… . The best way to redefine the TOC format is with a package: options are titletoc, tocloft and etoc – see ctan.org/topic/toc-etc . Commented Apr 17, 2022 at 6:42

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .