3

As shown in my MWE I'm using tocloft to add dots next to my chapters in the TOC. It works, but for a reason I don't know, the headings of the TOC, LOF, LOT are not on the same height as the regular chaptertitles anymore. MWE:

\documentclass[pdftex, 12pt, oneside]{book}
\usepackage[english]{babel}
\usepackage{tocloft}
 \renewcommand\cftchapaftersnum{.}
 \renewcommand{\cftchapleader}{\cftdotfill{\cftdotsep}}
\usepackage{titlesec}
 \titleformat{\chapter}{\huge\bfseries}{\thechapter}{20pt}{\huge}
 \titlespacing*{\chapter}{0pt}{10pt}{30pt}
\usepackage[paper = a4paper, margin = 1in]{geometry}

\begin{document}
 \frontmatter
  \tableofcontents
 \mainmatter
  \chapter*{Chapter without number}
   \addcontentsline{toc}{chapter}{Chapter without number}
    Hello world!
  \chapter{Chapter with number}
    Hello world, again!
\end{document}

Does anyone has an idea why that's so and has a solution for my problem?

3

The tocloft package, by default, discards customization made by other packages to how chapter titles are typeset, for what concerns the table of contents and the list of figures or tables.

In order to avoid this behavior, you have to load it with the titles option:

\usepackage[titles]{tocloft}

Some comments about your code.

I would add \hspace{\cftchapnumwidth} to the unnumbered chapter entry.

\documentclass[12pt, oneside]{book}
\usepackage[paper = a4paper, margin = 1in]{geometry}
\usepackage[english]{babel}

\usepackage[titles]{tocloft}
\usepackage{titlesec}

\renewcommand\cftchapaftersnum{.}
\renewcommand{\cftchapleader}{\cftdotfill{\cftdotsep}}

\titleformat{\chapter}{\huge\bfseries}{\thechapter}{20pt}{\huge}
\titlespacing*{\chapter}{0pt}{10pt}{30pt}

\begin{document}
\frontmatter

\tableofcontents

\mainmatter

\chapter*{Chapter without number}
  \addcontentsline{toc}{chapter}{\protect\hspace{\cftchapnumwidth}Chapter without number}

Hello world!

\chapter{Chapter with number}

Hello world, again!

\end{document}

You might want to avoid \chapter* and the clumsy \addcontentsline command with

\newcommand{\uchapter}[1]{%
  \chapter*{#1}%
  \addcontentsline{toc}{chapter}{\protect\hspace{\cftchapnumwidth}#1}%
}

enter image description here

A more common trick that works without tocloft is typing \protect\numberline{} instead of \protect\hspace{...}; in this case it would add an unwanted period.

3
  • Ahh I maybe have ask my question in a misleading way. I want the actual headings of the TOC, LOF, LOT and the chapters to be on the same height, not the entries in the TOC itself. If you compile the MWE you should see that they are different. The TOC is a bit lower than the chapters. But your suggestions are also really helpful. :) Haven't noticed this yet. – Chris.V Sep 19 '13 at 9:17
  • Awesome, thanks a lot. I must have missed the titles option in the documentation. Is there a way to add the \hspace{\cftchapnumwidth} to the LOF and LOT? That would be great too. – Chris.V Sep 19 '13 at 10:45
  • @Chris.V I guess the correct parameters are \cftfignumwidth and \cfttabnumwidth – egreg Sep 19 '13 at 10:51

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.