3

I am using some code from here which allows me to use ordinal numbers in arabic for the chapter titles.

I also want to change the title spacing. I am only a little familiar with titlesec. The \titlespacing command requires an earlier setting of \titleformat (page 5 of titlesec documentation) but I don't know how to incorporate the patchcmd in the MWE inside the \titleformat format command.

How can I use titlesec as well as my arabic ordinal numbers? The commented-out line in the MWE is the setting I would like for my title spacing.

\documentclass[12pt,oneside]{report}
\usepackage{titlesec}
\usepackage{polyglossia}
\setmainlanguage[numerals=mashriq]{arabic}
\setotherlanguage{english}
\newfontfamily\arabicfont[Script=Arabic]{Times New Roman}

\gappto\captionsarabic{\renewcommand{\chaptername}{الباب}} 
\newcommand\words[1]{\expandafter\xwords\csname c@#1\endcsname}
\def\xwords#1{\ifcase#1\or
الأول\or          
الثاني\or          
الثالث\or 
الرابع\or 
الخامس\or 
    \else
    you need to supply additional numbers \fi}
%next three lines is to make chapter naming use the above wordings (literal numbering in Arabic words)
\makeatletter
\patchcmd{\@makechapterhead}{\thechapter}{\words{chapter}}{}{}
\makeatother

% \titlespacing{\chapter}{0pt}{0ex plus 9ex minus 9ex}{0ex plus 9ex minus 9ex}

\begin{document}
\chapter{ددد}
\end{document}
2
  • What happens if you load titlesec after the patch?
    – cfr
    Commented Oct 11, 2015 at 16:24
  • titlesec must be before polyglossia, and polyglossia must be before the patch. But even apart from this, the \titlespacing command has no effect unless i issue a \titleformat command, which I don't know how to do with the ordinal patch.
    – Tim
    Commented Oct 11, 2015 at 16:41

1 Answer 1

4

Here two solutions, with and without titlesec package

First (titlesec)

\documentclass[12pt,oneside]{report}
\usepackage{titlesec}
\usepackage{polyglossia}
\setmainlanguage[numerals=mashriq]{arabic}
\setotherlanguage{english}
\newfontfamily\arabicfont[Script=Arabic]{Times New Roman}

\gappto\captionsarabic{\renewcommand{\chaptername}{الباب}} 
\def\xwords#1{\ifcase\value{#1}\or
الأول\or          
الثاني\or          
الثالث\or 
الرابع\or 
الخامس\or 
    \else
    you need to supply additional numbers \fi}

\titleformat{\chapter}[display]
{\normalfont\huge\bfseries}{\chaptertitlename\ \xwords{chapter}}{20pt}{\Huge}
\titlespacing{\chapter}{0pt}{0ex plus 9ex minus 9ex}{0ex plus 9ex minus 9ex}

\begin{document}
\chapter{ددد}
\end{document}

second

\documentclass[12pt,oneside]{report}
\usepackage{polyglossia}
\setmainlanguage[numerals=mashriq]{arabic}
\setotherlanguage{english}
\newfontfamily\arabicfont[Script=Arabic]{Times New Roman}

\gappto\captionsarabic{\renewcommand{\chaptername}{الباب}} 
\def\xwords#1{\ifcase\value{#1}\or
الأول\or          
الثاني\or          
الثالث\or 
الرابع\or 
الخامس\or 
    \else
    you need to supply additional numbers \fi}

\makeatletter
\patchcmd{\@makechapterhead}{\thechapter}{\xwords{chapter}}{}{}
\patchcmd{\@makechapterhead}{\vspace*{50\p@}}{\vspace*{0ex plus 9ex minus 9ex}}{}{}
\patchcmd{\@makechapterhead}{\vskip 40\p@}{\vspace*{0ex plus 9ex minus 9ex}}{}{}
\makeatother


\begin{document}
\chapter{ددد}
\end{document}

You must log in to answer this question.

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