# How to modify the space between the numbers and text of sectioning titles in the table of contents?

I'm preparing a document using the book class. In the table of contents, the space between the subsection number and title is too wide. How to reduce it?

-
Some feedback would be really nice. –  Marco Daniel Nov 10 '11 at 8:14

Without any packages:

In the standard documentclass without the influence of a package like titletoc you have to redefine the command \l@subsection. In the file book.cls you find the following settings:

\newcommand*\l@section{\@dottedtocline{1}{1.5em}{2.3em}}
\newcommand*\l@subsection{\@dottedtocline{2}{3.8em}{3.2em}}
\newcommand*\l@subsubsection{\@dottedtocline{3}{7.0em}{4.1em}}
\newcommand*\l@paragraph{\@dottedtocline{4}{10em}{5em}}
\newcommand*\l@subparagraph{\@dottedtocline{5}{12em}{6em}}


The command \@dottedtocline expects the following parameters:

\renewcommand{\l@<typ>}{\@dottedtocline{<level>}%
{<indentation>}%
{<numwidth>}}


To reduce the indentation of subsection you can do:

\makeatletter
\renewcommand*\l@subsection{\@dottedtocline{2}{1.8em}{3.2em}}
\makeatother


Example:

\documentclass{book}
\makeatletter
\renewcommand*\l@subsection{\@dottedtocline{2}{1.8em}{3.2 em}}
\makeatother
\begin{document}
\tableofcontents
\chapter{foo}
\section{bar}
\subsection{foobar}
\end{document}


The method is equal for floating environments. The standard class book.cls provides \l@figure and and \l@table with the following settings:

\newcommand*\l@figure{\@dottedtocline{1}{1.5em}{2.3em}}
\let\l@table\l@figure


Package titletoc

By using the package titletoc you can set the indentation using \dottedcontents:

\dottedcontents{<section>}[<left>]{<above-code>}


Example

\documentclass{book}
\usepackage{titletoc}
\dottedcontents{subsection}[5.5em]{}{3.2em}{1pc}

\begin{document}
\tableofcontents
\chapter{foo}
\section{bar}
\subsection{foobar}
\end{document}


The argument <section> can be somewhat irritating. The argument allows the name without a leading backslash so that figure and table are allowed, too.

Package tocloft

The package tocloft offers more than the following setting. The indentation is set by the length \cftXindent. The X stands for:

• part for \part titles
• chap for \chapter titles
• sec for \section titles
• subsec for \subsection titles
• subsubsec for \subsubsection titles
• para for \paragraph titles
• fig for figure \caption title
• tab for table \caption titles

Example:

\documentclass{book}
\usepackage{tocloft}
\setlength{\cftsubsecindent}{2em}

\begin{document}

\tableofcontents
\chapter{foo}
\section{bar}
\subsection{foobar}
\end{document}


KOMA-Script

When using a class of the KOMA bundle the settings of \@dottedtocline won't work. KOMA provides the command \bprot@dottedtocline. In the file scrbook.cls you find the settings:

\newcommand*{\l@chapteratlist}{\l@chapter}
\newcommand*\l@section{\bprot@dottedtocline{1}{1.5em}{2.3em}}
\newcommand*\l@subsection{\bprot@dottedtocline{2}{3.8em}{3.2em}}
\newcommand*\l@subsubsection{\bprot@dottedtocline{3}{7.0em}{4.1em}}
\newcommand*\l@paragraph{\bprot@dottedtocline{4}{10em}{5em}}
\newcommand*\l@subparagraph{\bprot@dottedtocline{5}{12em}{6em}}


The syntax of \bprot@dottedtocline is equivalent to \@dottedtocline (see above)

Example:

\documentclass{scrbook}
\makeatletter
\renewcommand*\l@subsection{\bprot@dottedtocline{2}{1.8em}{3.2em}}
\makeatother
\begin{document}

\tableofcontents
\chapter{foo}
\section{bar}
\subsection{foobar}
\end{document}


The modification of figure and table is equal to the standard class and defined as follow:

\newcommand*\l@figure{\@dottedtocline{1}{1.5em}{2.3em}}
\let\l@table\l@figure


To manipulate the toc (or other list of ...) in combination with a class of the KOMA bundle you should use the package tocsyle. The package is part of the KOMA bundle but with a separate documentation. The influence of the indentation is given indirectly by entryhook which can be set by \settocfeature

One of the benefits oftocstyle is the automatic calculation of the needed indentation.

Example:

\documentclass{scrbook}

\usepackage{tocstyle}
\usetocstyle{KOMAlike}
\settocfeature[toc][2]{entryhook}{\protect\hspace*{-1.5em}\nobreakspace}
\begin{document}

\tableofcontents
\chapter{foo}
\section{bar}
\subsection{foobar}
\end{document}

-
tocstyle without option tocindentmanual calculates the needed indention itself, so to much indent shouldn't be. And the depth of subsection is AFAIK 2, so the second optional argument of \settocfeature should be 2 not 9. BTW: If the space after the number is to large you may change the feature spaceafternumber. –  Schweinebacke Nov 6 '11 at 15:48
@Schweinebacke: Welcome on stack exchange. I toke the wrong number ;-). Thanks. The spaceafternumber influence the space between the number and the title. I want to reduce the intention in front of the section number. –  Marco Daniel Nov 6 '11 at 15:56
If added the information about spaceafternumber only, because I'm not sure if the OP wanted to change the indentation before the number or the indentation of the text, because there's a hanging indent after the number. It shouldn't be a critic to your excellent answer only an addendum. –  Schweinebacke Nov 6 '11 at 16:05
@Schweinebacke: I doesn't sound like critic ;-). But adding this information to my answer I must change also the other sections. (regards mechanicus -- mrunix :-) ) –  Marco Daniel Nov 6 '11 at 16:32
OK. BTW: <distance "number <-> text" > sounds like space between number and text, but its the hanging indent of the text aka the width reserved for number and space between number and text. –  Schweinebacke Nov 6 '11 at 16:59