I need to customize the appearance of my table of contents according to the requirements of a publisher.

Here is a minimal example of what it looks like right now:

\documentclass{scrbook}

\begin{document}

\frontmatter

\tableofcontents

\chapter{Preface}

\mainmatter

\part{First part}

\chapter{First chapter}
\section{First section}
\subsection{First subsection}
\subsection{Second subsection}
\section{Second section}

\chapter{Second chapter}

\end{document}


This produces something that looks like this:

Now my publisher requested that the chapter titles should have dots between title and page number.

I have found the tocstyle package, but I don't understand its documentation. I am not even sure the package lets me do what I need to do. Can somebody please make suggestions on how to get what I want? Thanks.

Edit: I need to remove the part page numbers as well. I posted this requirement in my original question, but multiple questions per thread were discouraged. However, later it turned out that this can actually make a difference also for the question asked here: If I use tocstyle to suppress page part numbers, this may affect the solutions posted here to get rid of the chapter dots.

• Three questions at once, it would be easier if you split the questions leaving just one detail to answer. – Johannes_B Feb 14 '16 at 15:44
• Thanks for the suggestion. I am asking this as a separate question now. – Philip Leifeld Feb 14 '16 at 15:52
• \KOMAoption{chapterentrydots}{true} %\addtokomafont{chapterentrydots}{\bfseries} Remove % for extra horror. – Johannes_B Feb 14 '16 at 16:29
• I believe this doesn't work if I use tocstyle to customize other aspects of the TOC. Other ideas? – Philip Leifeld Feb 14 '16 at 17:04

Do not use package tocloft (mentioned in your own answer) together with a KOMA-Script class.

There is an KOMA-Script option to fill the space between the chapter title and the pagenumber in TOC with dots:

\KOMAoptions{toc=chapterentrydotfill}


If the page numbers for the chapter headings should not be bold use

\addtokomafont{chapterentrypagenumber}{\mdseries}


It is also possible to remove the page number for the part headings from TOC:

\addtokomafont{partentrypagenumber}{\nullfont}


Code:

\documentclass[toc=chapterentrydotfill]{scrbook}
\begin{document}
\frontmatter
\tableofcontents
\chapter{Preface}
\mainmatter
\part{First part}
\chapter{First chapter}
\section{First section}
\subsection{First subsection}
\subsection{Second subsection}
\section{Second section}
\chapter{Second chapter}
\end{document}


It is also possible to use package tocstyle which is part of the KOMA-Script bundle. To get dots between the headings off all levels and the page numbers in TOC use

\usetocstyle{allwithdot}


as already suggested by @Peter Ebelsberger. To remove the dots and the page numbers for the part headings in TOC add

\settocstylefeature[-1]{leaders}{\hfill}
\settocstylefeature[-1]{pagenumberhook}{\nullfont}


MWE:

\documentclass{scrbook}
\usepackage{tocstyle}
\usetocstyle{allwithdot}
\settocstylefeature[-1]{pagenumberhook}{\nullfont}
\begin{document}
\frontmatter
\tableofcontents
\chapter{Preface}
\mainmatter
\part{First part}
\chapter{First chapter}
\section{First section}
\subsection{First subsection}
\subsection{Second subsection}
\section{Second section}
\chapter{Second chapter}
\end{document}


Run several times to get

• I believe this solution doesn't work if I use tocstyle to customize other aspects of the TOC. In my original question, I mentioned that I also needed to remove page numbers for parts, but Johannes_B said it was good practice to ask only one question per thread, so I removed this second requirement. Anyway, I need to make sure the part page numbers are gone as well, and if I use tocstyle to do that, this solution doesn't work anymore, I think. – Philip Leifeld Feb 14 '16 at 17:19
• See my updated answer. – esdd Feb 14 '16 at 17:23
• Awesome! No need to load any additional packages, and both problems are solved at once! – Philip Leifeld Feb 14 '16 at 17:28
• Do not use package tocloft together with a KOMA-Script class. Why? – Peter Ebelsberger Feb 14 '16 at 17:58
• @PeterEbelsberger tocstyle does the same (partly, but not everything) as KOMA, hence whacking KOMA-functionality to death. In other words, tocloft is good for customizing standard classes, but incompatible with KOMA-script. – Johannes_B Feb 14 '16 at 18:01
\documentclass{scrbook}

\usepackage{tocstyle}
\usetocstyle{allwithdot}
\begin{document}

\frontmatter

\tableofcontents

\chapter{Preface}

\mainmatter

\part{First part}

\chapter{First chapter}
\section{First section}
\subsection{First subsection}
\subsection{Second subsection}
\section{Second section}

\chapter{Second chapter}

\end{document}

• Thanks. But this also adds dots to part titles, right? That's not what I want. – Philip Leifeld Feb 14 '16 at 17:02
• What about Johannes' suggestion above? \KOMAoption{chapterentrydots}{true} – BlackBird Feb 14 '16 at 17:14
• I believe Johannes_B's suggestion doesn't work if I use tocstyle to customize other aspects of the TOC. In my original question, I mentioned that I also needed to remove page numbers for parts, but Johannes_B said it was good practice to ask only one question per thread, so I removed this second requirement. Anyway, I need to make sure the part page numbers are gone as well, and if I use tocstyle to do that, this solution doesn't work anymore, I think. – Philip Leifeld Feb 14 '16 at 17:18
• @SpammerSlammer I thought we already had the question how to get the dos for chapterentries, but nothing really fitted. If so, we could have marked this (single) question as a duplicate. But esdd provided wverything in her answer. – Johannes_B Feb 14 '16 at 18:04

I found this elsewhere:

\RequirePackage{tocloft}
\let\partbackup\l@part  % create a backup copy of the part definition
\renewcommand*\l@part[2]{\partbackup{#1}{}}  % redefine part in order to leave out the page number for part
\renewcommand{\cftchapdotsep}{\cftdotsep}  % add dots for chapter entries

With the new tocloft, it works as follows:
\DeclareTOCStyleEntry[%