0

I am typesetting the Quran in LaTeX with English on the left side and Arabic on the right side. I use XeLaTeX and arabxetex to do this. I use the tocloft package to customize the Table of Contents and the titlesec package to cusomize title pages. What I want to do is put the Arabic Surah name on the right side and the English Surah name on the left side for both the title pages and the Table of Contents. I managed to do the title page part with the help of someone on another question I posted here.

The part I am having trouble with is the Table of Contents. I want to have the section number and the English chapter name in English with the page number in English just before the middle of the text width, the section number in Arabic on the right (you can get an Arabic number with the command textarab{1} for example) and the section name next to it. This is the code I have so far:

\documentclass{book}

\usepackage{unicode-math}
\defaultfontfeatures{Scale=MatchLowercase}
\defaultfontfeatures[\rmfamily]{Ligatures=TeX,Scale=1}

\usepackage[paperwidth = 6 in,paperheight = 9 in,margin = 0.75 in,bindingoffset = 0.125 in]{geometry}

% Use the Quran version of the Amiri font
\newfontfamily\arabicfont[Script=Arabic]{Amiri Quran}

% Use "Surah" instead of "Chapter"
\renewcommand\chaptername{Surah}

% English on the left, Arabic on the right
\usepackage[explicit]{titlesec}
\usepackage[fullvoc]{arabxetex}
\titleformat{\chapter}[display]
   {\normalfont\huge\bfseries}
   {\chaptertitlename\ \thechapter \hfill \textarab{سورة \surahnum}}
   {0pt}
   {\Huge  #1\hfill\textarab{\archapter}}
\titlespacing*{\chapter}{0pt}{-20pt}{40pt}

\newcommand\archapter{\textarab{فهرس}}

\usepackage[titles]{tocloft}
\renewcommand{\cftchapleader}{\hfill} % Content between chaptertion title and page number
\renewcommand{\cftchapafterpnum}{\bfseries\hspace{1em}\textarab{\thepage}\hfill\textarab{\archapter}} % Content after chaptertion page number

\title{}
\author{}
\date{}

\begin{document}
\maketitle

\tableofcontents

\newcommand\surahnum{1}
\renewcommand\archapter{الفاتحة}
\chapter{Al-Faatiha}

\end{document}

This is what it looks like:

There are a few problems with the result:

  1. The Arabic page number is not the actual page number for the section: it should be 5, not 3. The Arabic number shown in the screenshot is 3 because that is the page that the Table of Contents starts in, but it should be the page for that chapter instead.
  2. The Arabic chapter name is not the name of the Surah (chapter), it is the Arabic word for "Table of Contents" or "Index". This is because it is not taking the Arabic chapter name from the chapter in that line, but the chapter it is currently on (the Table of Contents).
  3. The page numbers are slightly too much in the right. They should be dead centre.
1

2 Answers 2

0

Well you can push the definitions also into the table of contents. But it feels a bit too much handmade, and one probably should avoid to store the page number like this, but it would need more time to check the code of titletoc more carefully.

\documentclass{book}

\usepackage{unicode-math}
\defaultfontfeatures{Scale=MatchLowercase}
\defaultfontfeatures[\rmfamily]{Ligatures=TeX,Scale=1}

\usepackage[paperwidth = 6 in,paperheight = 9 in,margin = 0.75 in,bindingoffset = 0.125 in]{geometry}

% Use the Quran version of the Amiri font
\newfontfamily\arabicfont[Script=Arabic]{Amiri Quran}

% Use "Surah" instead of "Chapter"
\renewcommand\chaptername{Surah}

% English on the left, Arabic on the right
\usepackage[explicit]{titlesec}
\usepackage[fullvoc]{arabxetex}
\titleformat{\chapter}[display]
   {\normalfont\huge\bfseries}
   {\chaptertitlename\ \thechapter \hfill \textarab{سورة \surahnum}}
   {0pt}
   {\Huge  #1\hfill\textarab{\archapter}}
\titlespacing*{\chapter}{0pt}{-20pt}{40pt}

\newcommand\archapter{\textarab{فهرس}}

\usepackage[titles]{tocloft}
\renewcommand{\cftchapleader}{\hfill} % Content between chaptertion title and page number
\renewcommand{\cftchapafterpnum}{\bfseries\hspace{1em}\textarab{\arpage}\hfill\textarab{\archapter}} % Content after chaptertion page number

\title{}
\author{}
\date{}
\newcommand\arpage{1}
\begin{document}
\maketitle

\tableofcontents


\cleardoublepage% important
\newcommand\surahnum{1}
\renewcommand\archapter{الفاتحة}
\addtocontents{toc}{% 
 \protect\renewcommand\protect\arpage{\thepage}%
 \protect\renewcommand\protect\archapter{الفاتحة}}
\chapter{Al-Faatiha}

\end{document}
0

Based on this post, I came up with a working solution:

\documentclass{book}

\usepackage{etoolbox}
\usepackage{parcolumns}
\usepackage{calc}

\makeatletter

\patchcmd{\pc@placeboxes}{\vrule}{{\VRULE}}{}{}
\newcommand\VRULE{\color{SOME_COLOR}\vrule width 0.2mm}

\newcounter{storetocdepth}

\let\latex@@chapter\chapter
\RenewDocumentCommand{\chapter}{somos}{%
  \IfBooleanTF{#1}{%
    \latex@@chapter*{#3}%
  }{%
    \IfBooleanTF{#5}{%
      \setcounter{storetocdepth}{\value{tocdepth}}
      \addtocontents{toc}{\protect\setcounter{tocdepth}{-4}}
      % The #2 is of no use here, except of page headings /chapter mark
      \IfValueTF{#2}{%
        \latex@@chapter[#2]{#3}%
      }{%
        \latex@@chapter{#3}%
      }%
      \addtocontents{toc}{\protect\setcounter{tocdepth}{\number\value{storetocdepth}}}
      \addtocontents{toc}{\protect\contentsline{chapter}{\protect\phantom{#3}}{}}% Provide an empty fake entry
    }{%
      \IfValueTF{#2}{%
        \latex@@chapter[#2]{#3}%
      }{%
        \latex@@chapter{#3}%
      }%
    }%
    \IfValueTF{#4}{%
      \addcontentsline{ftoc}{chapter}{\protect\numberline{\csname thechapter\endcsname}#4}
    }{%
      \addtocontents{ftoc}{\protect\contentsline{chapter}{\protect\phantom{#2}}{}}% Provide an empty fake entry
    }%
  }%
}

\renewcommand\tableofcontents[1][toc]{%
  \@starttoc{#1}%
}

\makeatother

\usepackage{unicode-math}
\defaultfontfeatures{Scale=MatchLowercase}
\defaultfontfeatures[\rmfamily]{Ligatures=TeX,Scale=1}

\usepackage[paperwidth = 6 in,paperheight = 9 in,margin = 0.75 in,bindingoffset = 0.125 in]{geometry}

% Use the Quran version of the Amiri font
\newfontfamily\arabicfont[Script=Arabic]{Amiri Quran}

% Use "Surah" instead of "Chapter"
\renewcommand\chaptername{Surah}

% English on the left, Arabic on the right
\usepackage[explicit]{titlesec}
\usepackage[fullvoc]{arabxetex}
\titleformat{\chapter}[display]
   {\normalfont\huge\bfseries}
   {\chaptertitlename\ \thechapter \hfill \textarab{سورة \surahnum}}
   {0pt}
   {\Huge  #1\hfill\textarab{\archapter}}
\titlespacing*{\chapter}{0pt}{-20pt}{40pt}

\newcommand\archapter{\textarab{فهرس}}

\title{}
\author{}
\date{}

\begin{document}
\maketitle

\chapter*{Contents}

\newlength\distance
\addtolength\distance{\columnsep * 2}

\begin{parcolumns}[distance = \distance]{2}
    \colchunk{

            \tableofcontents
    }
    \colchunk{

        \tableofcontents[ftoc]
    }
\end{parcolumns}

\newcommand\surahnum{1}
\renewcommand\archapter{الفاتحة}
\chapter{Al-Faatiha}[Arabic test]

\end{document}

You must log in to answer this question.

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