0

I am trying to add "Chapter" before the chapter number in the ToC.

The code I am using is

\makeatletter
\patchcmd\@chapter
  {\numberline {\thechapter }}
  {\@chapapp~ \numberline {\thechapter }}
  {}{}
\makeatother

However, it causes many conflicts with other parts in the .cls file. For example,

\usepackage{calc}
\newcommand{\t@cfill}{\cleaders\hbox{$\m@th \mkern\@dotsep mu . \mkern\@dotsep mu$}\hfill}
\newcommand{\abbrl@bel}[1]{\makebox[\labelwidth][l]{\textbf{#1}\ \t@cfill}}
\newenvironment{mclistof}[2]{%
   \chapter*{#1}%
   \addcontentsline{toc}{chapter}{#1}
   \begin{list}{}%
   {\renewcommand{\makelabel}{\abbrl@bel}%
    \setlength{\labelwidth}{#2}%
    \setlength{\leftmargin}{\labelwidth+\labelsep}%
    \setlength{\itemsep}{0pt}%
    \markboth{#1}{#1}%
   }}
   {\end{list}\mtcaddchapter}
\newenvironment{alwayssingle}{%
       \@restonecolfalse\if@twocolumn\@restonecoltrue\onecolumn
       \else\newpage\fi}
       {\if@restonecol\twocolumn\else\newpage\fi}
\newcommand{\@acknowledgementstitle}{Acknowledgements}

\newenvironment{acknowledgements}{
\cleardoublepage
\begin{alwayssingle}
% \setsinglecolumn
\chapter*{Acknowledgements}
\thispagestyle{plain}
\pagestyle{plain}
}
{\end{alwayssingle}}

MWE

\documentclass[12pt]{book}
\usepackage{etoolbox}

\makeatletter
\patchcmd\@chapter
  {\numberline {\thechapter }}
  {\@chapapp~ \numberline {\thechapter }}
  {}{}
\makeatother


\usepackage{calc}
\newcommand{\t@cfill}{\cleaders\hbox{$\m@th \mkern\@dotsep mu . \mkern\@dotsep mu$}\hfill}
\newcommand{\abbrl@bel}[1]{\makebox[\labelwidth][l]{\textbf{#1}\ \t@cfill}}
\newenvironment{mclistof}[2]{%
   \chapter*{#1}%
   \addcontentsline{toc}{chapter}{#1}
   \begin{list}{}%
   {\renewcommand{\makelabel}{\abbrl@bel}%
    \setlength{\labelwidth}{#2}%
    \setlength{\leftmargin}{\labelwidth+\labelsep}%
    \setlength{\itemsep}{0pt}%
    \markboth{#1}{#1}%
   }}
   {\end{list}\mtcaddchapter}

\newenvironment{alwayssingle}{%
       \@restonecolfalse\if@twocolumn\@restonecoltrue\onecolumn
       \else\newpage\fi}
       {\if@restonecol\twocolumn\else\newpage\fi}

\newcommand{\@acknowledgementstitle}{Acknowledgements}

\newenvironment{acknowledgements}{
\cleardoublepage
\begin{alwayssingle}
% \setsinglecolumn
\chapter*{Acknowledgements}
\thispagestyle{plain}
\pagestyle{plain}
}
{\end{alwayssingle}}


\usepackage{blindtext}% Dummy text for the example
\begin{document}
\tableofcontents
\blinddocument
\end{document}
6
  • 1
    Did you think of doing that with one of the dedicated packages (etoc, titletoc, tocloft)?
    – Bernard
    Sep 10, 2019 at 10:37
  • @Bernard Thanks. I tried tocloft, but the word "Chaper" is overlapped with the chapter title by using \renewcommand{\cftchappresnum}{Chapter }. Do you know how to deal with it?
    – WZhao
    Sep 10, 2019 at 10:49
  • The are width parameters to change, I guess. Personally, I tend to use titletoc, which comes with package titlesec.
    – Bernard
    Sep 10, 2019 at 10:52
  • @Bernard Could you point me the link of the usage of titletoc which do this work? Thanks a lot.
    – WZhao
    Sep 10, 2019 at 10:57
  • The possibilities are detailed in § 6 of titlesec documentation, (Contents: The titletoc package, pp. 13–19).
    – Bernard
    Sep 10, 2019 at 11:07

1 Answer 1

2

With the tocloft package:

\usepackage{tocloft}
\renewcommand{\cftchappresnum}{Chapter } % put Chapter before the number
% Now make extra space for the word
\newlength{\mylen} % a "scratch" length, choose any name you like
\settowidth{\mylen}{\bfseries\cftchappresnum\cftchapaftersnum} % extra space
\addtolength{\cftchapnumwidth}{\mylen} % add the extra space

Further details are in the package documentation (> texdoc tocloft).

2
  • Thanks. Surprisingly, this has a side effect that the "table of contents" does not starts in the odd pages and also the next. Do you know how to deal with this?
    – WZhao
    Sep 11, 2019 at 4:24
  • I solve it by adding titles option. \usepackage[titles]{tocloft}
    – WZhao
    Sep 11, 2019 at 6:54

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.