9

Overfull hbox in ToC after chapter numbers changed to Roman; see MWE below. With the tocloft package \setlength\cftchapternumwidth{3em} solves the problem.

But: Is there any solution to the problem NOT using tocloft but titletoc?

\documentclass{book}

\usepackage{titletoc}

\begin{document}
\renewcommand{\thechapter}{\Roman{chapter}}
\setcounter{chapter}{7}
\tableofcontents
\chapter{Lipsum}
\section{Introduction}
\subsection{Introduction to introduction}
\subsubsection{Introduction to introduction to introduction}
\end{document}

PS: I have specified certain things in the ToC using titletoc and would be glad not to have to do everything again with tocloft. That's why I want to avoid the tocloft solution!

2 Answers 2

5

Here's an adaption of Philippe Goudet's anwer where the horizontal alignment of the various ToC entries resembles that of the standard classes:

\documentclass{book}

\usepackage{titletoc}
\titlecontents{chapter}[3em]{\addvspace{10pt}\bfseries}
    {\contentslabel{2.5em}}{\hspace{-2.5em}}{\hfill\contentspage}
\dottedcontents{section}[6.3em]{}{3.3em}{0.7pc}
\dottedcontents{subsection}[10.5em]{}{4.2em}{0.7pc}

\renewcommand{\thechapter}{\Roman{chapter}}

\begin{document}
\tableofcontents
\chapter*{Introduction}
\addcontentsline{toc}{chapter}{Introduction}
\setcounter{chapter}{7}
\chapter{Lipsum}
\section{Introduction}
\subsection{Introduction to introduction}
\subsubsection{Introduction to introduction to introduction}
\end{document}

enter image description here

2
  • Thanks to you both! That's what I was looking for. What's your personal/subjective opinion: In Philippe Goudet's solution the horizontal alignment is somewhat irritating. In lockstep's solution this is better but my impression is that things get too much "stretched". So I cannot decide which solutions looks more professional. Or should I perhaps better stick to the arabic numbers which avoids both of the before mentioned problems? A personal recommendation would be highly appreciated!!
    – lpdbw
    Commented Aug 8, 2012 at 11:46
  • 1
    In my opinion, a large indentation of subsections is less irritating than non-aligned entries. Personally, I'd either use arabic numbering or exclude subsections from the ToC (\setcounter{tocdepth}{1}).
    – lockstep
    Commented Aug 8, 2012 at 11:53
9

You can fully personalize the entries with titletoc by using \titlecontents. For each section level, you need to change the left indent and the \contentslabel by choosing an appropriate value:

\documentclass{book}

\usepackage{titletoc}

\renewcommand{\thechapter}{\Roman{chapter}}

\titlecontents{chapter}%
  [3em]% left indent
  {\addvspace{1em plus 0pt}\bfseries}% stuff before
  {\contentslabel{3em}}% before if there's a number
  {\hspace{-3em}}% before if there's no number
  {\hfill\contentspage}% dots and page number
  [\addvspace{0pt}]% stuff after

\dottedcontents{section}%
  [5em]% left indent
  {\addvspace{0pt}}% stuff before
  {3.5em}% spacing of \contentslabel
  {0.75em}% space between the dots
  [\addvspace{0pt}]% stuff after

\dottedcontents{subsection}%
  [7.5em]% left indent
  {\addvspace{0pt}}% stuff before
  {4.25em}% spacing of \contentslabel
  {0.75em}% space between the dots
  [\addvspace{0pt}]% stuff after

\begin{document}

\tableofcontents

\chapter*{Introduction}
\addcontentsline{toc}{chapter}{Introduction}

\setcounter{chapter}{7}
\chapter{Lipsum}
\section{Introduction}
\subsection{Introduction to introduction}
\subsubsection{Introduction to introduction to introduction}

\end{document}

You must log in to answer this question.

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