[Tex/LaTex] Minor bugfixes and adjustments for the TOC of classicthesis

classicthesistable of contents

I am using classicthesis and prepared my document with parts, chapters and sections. This produces the following table of contents.

TOC

There are some details that I would like to fix:

  1. Longer part numbers run into the part name. (highlighted in red)
  2. I would like to manipulate the distance between subsequent chapter entries (highlighted in green). Thus, chapter entries followed by section entries should not be affected. (highlighted in yellow)
  3. Part entries should have a dotted line as sections have.
  4. The font size of the page number for parts, chapters and sections should be adjustable.

Last but not least, here is the MWE to test things out.

\documentclass[oneside, openright, titlepage, dottedtoc, numbers=noenddot, 
headinclude, footinclude=true, cleardoublepage=empty, abstractoff, BCOR=5mm, 
paper=a4, fontsize=11pt, ngerman] {scrreprt}

\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{lmodern}
\usepackage{textcomp}
\usepackage[pdfspacing]{classicthesis}
\usepackage[dvipsnames]{xcolor}
\usepackage{lipsum,kantlipsum}

\hypersetup{
    colorlinks=true,      % false: boxed links; true: colored links.
    linktocpage=true,     % Moves the clickable link to the page numbers.
    linkcolor=OliveGreen  % Color of internal links.
}
\begin{document}
\tableofcontents

\part{Baden-Württemberg} \chapter{Stuttgart} \chapter{Mannheim}
\part{Bayern} \chapter{Muenchen} \chapter{Nuernberg}

\part{Berlin}
\chapter{Berlin}
\section{Charlottenburg-Wilmersdorf}\clearpage
\section{Friedrichshain-Kreuzberg}\clearpage
\section{Lichtenberg}\clearpage
\section{Marzahn-Hellersdorf}\clearpage
\section{Mitte}\clearpage
\section{Neukoelln}\clearpage
\section{Pankow}\clearpage
\section{Reinickendorf}\clearpage
\section{Spandau}\clearpage
\section{Steglitz-Zehlendorf}\clearpage
\section{Tempelhof-Schoeneberg}\clearpage
\section{Treptow-Koepenick}\clearpage

\part{Brandenburg} \chapter{Potsdam} \chapter{Cottbus}
\part{Bremen} \chapter{Bremen}
\part{Hamburg} \chapter{Hamburg}
\part{Hessen} \chapter{Wiesbaden} \chapter{Frankfurt}
\part{Mecklenburg-Vorpommern} \chapter{Schwerin} \chapter{Rostock}
\part{Niedersachsen} \chapter{Hannover} \chapter{Braunschweig}
\part{Nordrhein-Westfalen} \chapter{Duesseldorf} \chapter{Koeln}
\part{Rheinland-Pfalz} \chapter{Mainz} \chapter{Ludwigshafen}
\part{Saarland} \chapter{Saarbruecken}
\part{Sachsen} \chapter{Dresden} \chapter{Leipzig}
\part{Sachsen-Anhalt}\chapter{Magdeburg}\chapter{Halle}
\part{Schleswig-Holstein}\chapter{Kiel}\chapter{Luebeck}
\part{Thüringen} \chapter{Erfurt} \chapter{Jena}

\end{document}

Best Answer

classicthesis internally uses the tocloft package to design the ToC, so you can easily achieve what you want; all you have to do is to play with

  • \cftbeforechapskip to change vertical skip before chapters.
  • \cftpartpagefont to change the font for part page numbers.
  • \cftchappagefont to change the font for chapter page numbers.
  • \cftsecpagefont to change the font for section page numbers.
  • \cftpartdotsep to control the leaders for part entries.
  • \cftpartaftersnumb to add space between part number.

A little example illustrating the use of those lenghts/commands:

\documentclass[oneside, openright, titlepage, dottedtoc, numbers=noenddot, 
headinclude, footinclude=true, cleardoublepage=empty, abstractoff, BCOR=5mm, 
paper=a4, fontsize=11pt, ngerman] {scrreprt}

\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{lmodern}
\usepackage{textcomp}
\usepackage[pdfspacing]{classicthesis}
\usepackage[dvipsnames]{xcolor}
\usepackage{lipsum,kantlipsum}

\hypersetup{
    colorlinks=true,      % false: boxed links; true: colored links.
    linktocpage=true,     % Moves the clickable link to the page numbers.
    linkcolor=OliveGreen  % Color of internal links.
}

\setlength{\cftbeforechapskip}{0.1em} % change vertical skip before chapters
\renewcommand{\cftpartpagefont}{\Large}% change the font for part page numbers
\renewcommand{\cftchappagefont}{\Large}% change the font for chapter page numbers
\renewcommand{\cftsecpagefont}{\Large}% change the font for section page numbers
\renewcommand{\cftpartdotsep}{\cftdotsep}% add leaders for part entries
\renewcommand{\cftpartleader}{\normalfont\normalsize\cftdotfill{\cftpartdotsep}
}% change the font for part leader dots (not boldfaced)
\renewcommand{\cftpartaftersnumb}{\hspace*{0.5em}}% add space between part number and part title

\begin{document}
\tableofcontents

\part{Baden-Württemberg} \chapter{Stuttgart} \chapter{Mannheim}
\part{Bayern} \chapter{Muenchen} \chapter{Nuernberg}

\part{Berlin}
\chapter{Berlin}
\section{Charlottenburg-Wilmersdorf}\clearpage
\section{Friedrichshain-Kreuzberg}\clearpage
\section{Lichtenberg}\clearpage
\section{Marzahn-Hellersdorf}\clearpage
\section{Mitte}\clearpage
\section{Neukoelln}\clearpage
\section{Pankow}\clearpage
\section{Reinickendorf}\clearpage
\section{Spandau}\clearpage
\section{Steglitz-Zehlendorf}\clearpage
\section{Tempelhof-Schoeneberg}\clearpage
\section{Treptow-Koepenick}\clearpage

\part{Brandenburg} \chapter{Potsdam} \chapter{Cottbus}
\part{Bremen} \chapter{Bremen}
\part{Hamburg} \chapter{Hamburg}
\part{Hessen} \chapter{Wiesbaden} \chapter{Frankfurt}
\part{Mecklenburg-Vorpommern} \chapter{Schwerin} \chapter{Rostock}
\part{Niedersachsen} \chapter{Hannover} \chapter{Braunschweig}
\part{Nordrhein-Westfalen} \chapter{Duesseldorf} \chapter{Koeln}
\part{Rheinland-Pfalz} \chapter{Mainz} \chapter{Ludwigshafen}
\part{Saarland} \chapter{Saarbruecken}
\part{Sachsen} \chapter{Dresden} \chapter{Leipzig}
\part{Sachsen-Anhalt}\chapter{Magdeburg}\chapter{Halle}
\part{Schleswig-Holstein}\chapter{Kiel}\chapter{Luebeck}
\part{Thüringen} \chapter{Erfurt} \chapter{Jena}

\end{document}

enter image description here

However, as Sveinung notes in his remark, the author of classicthesis carefully and intentionally designed the package to produce the intended layout, so one has to be careful not to break the overall design.

To prevent a single section entry from appearing in a page (as is the case for "Frankfurt", in the example) one can say

 \addtocontents{toc}{\protect\enlargethispage{\baselineskip}}

for example right after \chapter{Stuttgart}.