7
\documentclass[12pt]{arabbook}
%%%%%%%%%%% packages
\usepackage{fancyhdr}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage[english, arabic]{babel}
\usepackage{t1enc}
\usepackage{float}
 \usepackage{arabtex} 
 \usepackage{amssymb}
\usepackage{graphicx}% ajouter des photos
\pagestyle{fancy}
\addto\captionsarabic{\renewcommand{\chaptername}{الفصل}}
\makeatletter
\newcommand{\arabic@words}[1]{% substitute the relevant Arabic numbers here
\ifcase#1\or الأوّل
\or الثاني\or الثالث\or الرابع\else\@ctrerr\fi}
\newcommand*\arabicwords[1]{\expandafter\arabic@words\csname c@#1\endcsname}
\renewcommand\thechapter{\arabicwords{chapter}}
\makeatother
\setcounter{page}{1}
\begin{document}
\tableofcontents
\chapter{أهلا}
\section{مرحبا}
\begin{arabtext}
mr.hbn bkm
\end{arabtext}
\end{document}

I want to get

الفصل الاول

instead of

الفصل ١

and in section headings مرحبا 1.1 instead of ١.١ مرحبا

I edited the files, thanks to @Alan Munn but the problem go to the table of contents: enter image description here

Alan Munn
  • 218,180
Poline Sandra
  • 463
  • 4
  • 11

1 Answers1

4

Edit If for some reason one need to use arabtex, here is another solution with pdflatex (arabi and arabtex):

Note i think one need to add this

\renewcommand*\l@section{\@dottedtocline{1}{1em}{1.5em}}

to correctly set table of contents

\documentclass[12pt]{arabbook}
%---------------------------------------------                
\usepackage[LAE,T1]{fontenc}
\usepackage[utf8]{inputenc} 
\usepackage[english, arabic]{babel}
\usepackage{arabtex} 
%---------------------------------------------
\usepackage{amsmath,amssymb}
\usepackage{graphicx}  
\usepackage{float}
\usepackage{fancyhdr}
\pagestyle{fancy}
\usepackage{etoolbox}
%---------------------------------------------
\addto\captionsarabic{\renewcommand{\chaptername}{الفصل}}
\makeatletter
\newcommand{\arabic@words}[1]{% substitute the relevant Arabic numbers here
\ifcase#1\or الأوّل
\or الثاني\or الثالث\or الرابع\else\@ctrerr\fi}
\newcommand*\arabicwords[1]{\expandafter\arabic@words\csname c@#1\endcsname}
\patchcmd{\@makechapterhead}{\thechapter}{\arabicwords{chapter}}{}{}
\makeatother
\renewcommand \thechapter {\textLR{\arabic{chapter}}}
\renewcommand \thesection {\thechapter.\textLR{\arabic{section}}}
\renewcommand \thesubsection {\thesection.\textLR{\arabic{subsection}}}

%---------------------------------------------
\begin{document}
\tableofcontents
\chapter{أهلا}
\section{مرحبا}
\begin{arabtext}
mr.hbn bkm
\end{arabtext}
\end{document}

Here is a solution. The idea is to redefine \@makechapterhead command and replace \thechapter with \arabicwords{chapter}. For that, we can use \patchcmd from etoolbox package:

\patchcmd{\@makechapterhead}{\thechapter}{\arabicwords{chapter}}{}{}.

Here is a MWE with xelatex :

\documentclass[12pt]{book}  
%---------------------------------------------                
\usepackage{fontspec}
\setmainfont{Times New Roman}
\setsansfont{Arial}
\setmonofont{Courier New}
\newfontfamily{\arabicfont}[Script=Arabic,Scale=1.2]{Amiri}
%\newfontfamily{\arabicfont}[Script=Arabic]{Amiri}
%---------------------------------------------
\usepackage{etoolbox}
\usepackage{amsmath,amssymb}
\usepackage{graphicx}  
\usepackage{float}
\usepackage{fancyhdr}
\pagestyle{fancy}
%---------------------------------------------
\usepackage{polyglossia}
\setdefaultlanguage[locale=algeria]{arabic}
\setotherlanguage{english}
%---------------------------------------------
\addto\captionsarabic{\renewcommand{\chaptername}{الفصل}}
\makeatletter
\newcommand{\arabic@words}[1]{% substitute the relevant Arabic numbers here
\ifcase#1\or الأوّل
\or الثاني\or الثالث\or الرابع\else\@ctrerr\fi}
\newcommand*\arabicwords[1]{\expandafter\arabic@words\csname c@#1\endcsname}
\patchcmd{\@makechapterhead}{\thechapter}{\arabicwords{chapter}}{}{}
\makeatother
%---------------------------------------------
\begin{document}
\tableofcontents
\chapter{أهلا}
\section{مرحبا}
مرحباً بكم
\textenglish{hello}
اللغة العربية

\begin{english}
welcome to TeX.se 
\textarabic{مرحباً}
This is an entire paragraph in english.
\end{english}


\end{document}
touhami
  • 19,520