# Add dotted lines in TOC without changing spacing

I would like to add dotted lines to the chapters in my TOC. Currently my PDF and code look like this:

\documentclass[12pt,a4paper,twoside]{report} %openright

%Schriftart Arial - ACHTUNG: Compile with XeLaTeX (not PDFLaTeX)!
\usepackage{fontspec}
\defaultfontfeatures{Scale = MatchLowercase}
\setmainfont{Arial}[Scale = 1.0]

%Seitenlayout
\usepackage[top=2.5cm, bottom=2cm, left=2.5cm, right=2.5cm,paper=a4paper]{geometry}

%Zeilenabstand ändern
\usepackage[onehalfspacing]{setspace}

%Graphiken und Bilder
\usepackage{subfig}

%Kopfzeile
\usepackage{fancyhdr}

%Verzeichnisse
\usepackage[notindex, nottoc, numbib]{tocbibind}
%\usepackage[subfigure]{tocloft}
%\renewcommand\cftchapdotsep{\cftdotsep}

%Längenangaben für den Abstand zwischen zwei Absätzen.
\usepackage{parskip}

%Kapitelanzeige und -platzierung im Text
\usepackage[clearempty]{titlesec}
\titleformat{\chapter}{\normalfont\fontsize{16pt}{0}\bfseries}{\thechapter.}{9pt}{}
\titleformat{\section}{\normalfont\fontsize{14pt}{0}\bfseries}{\thesection}{9pt}{}
\titleformat{\subsection}{\normalfont\fontsize{12pt}{0}\bfseries}{\thesubsection}{9pt}{}
\titlespacing*{\chapter}{0pt}{-22pt}{7pt}

% = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =
% Formatierung der Kopfzeile
% = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =

\pagestyle{fancy}
\fancyhf{}
\renewcommand{\chaptermark}[1]{\markboth{#1}{}}

\fancypagestyle{plain}{
\fancyhf{}
}

% = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =
% Anfang von Dokumententext
% = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =
\begin{document}

\pagenumbering{Roman}

% = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =
% Verzeichnisse
% = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =
\tableofcontents

\chapter{Chapter 1}
\section{test section}
\subsection{test section}
\section{test section}
\subsection{test section}

\end{document}


But when I use (comment in):

\usepackage[subfigure]{tocloft}
\renewcommand\cftchapdotsep{\cftdotsep}


then the following code line doesn't work any more and it looks like this:

\titlespacing*{\chapter}{0pt}{-22pt}{7pt}


Does anyone know how to fix this issue? I appreciate every help. Thanks in advance!

Edit 1: Thanks to daleif I have come so far to this:

\usepackage{titletoc}
\contentsmargin{2em}
\dottedcontents{section}[3.9em]{}{2.3em}{9.5pt}
\dottedcontents{subsection}[84pt]{}{3.2em}{9.5pt}
\dottedcontents{chapter}[20pt]{\bfseries}{20pt}{9.5pt}


Please don't mind the nonsense titles, this is just for comparing the spacing. As you can see, the spacing between the lines are still not correct as everything is quite close together... Does anyone know how to adjust that?

Edit 2:

I have now added vertical space between the entries of the chapters, sections and subsections:

\usepackage{titletoc}
\contentsmargin{2em}


But now the space between "Contents" and "1 Chapter 1" is too big. Does anyone know how to adjust just this particular spacing (by now adjusting the vertical space in \dottedcontents{chapter}[21pt]{\addvspace{15pt}\bfseries}{20pt}{9.5pt}, since this is the spacing within the TOC itself)? By this I mean how can I position "1 Chapter 1" and everything following a bit further up? With the positioning of "Contents" I am happy so far.

Edit 3: I have not found a solution for the spacing, but discovered that in my template there is the same specific spacing (seems to be normal, no matter whether you do it in LATEX or Word), so I will not search any further. Thanks everyone for helping! :-)

• tocloft and titlesec are not compatible. If you want to use titlesec then titletoc might be the package you should use. May 30, 2019 at 12:15
• @daleif I see! Can you help me out how to implement it? Is \dottedcontents the command I should use? So far I only get error messages. May 30, 2019 at 12:40
• Not really, I don't use titlesec. I'd perhaps starting from scratch May 30, 2019 at 12:53
• @daleif Thanks so far :-) I am making progress and will update this Question. May 30, 2019 at 13:30

Here is a solution with titletoc:

\documentclass[12pt,a4paper,twoside]{report} %openright

%Schriftart Arial - ACHTUNG: Compile with XeLaTeX (not PDFLaTeX)!
\usepackage{fontspec}
\defaultfontfeatures{Scale = MatchLowercase}
\setmainfont{Arial}[Scale = 1.0]

%Seitenlayout
\usepackage[top=2.5cm, bottom=2cm, left=2.5cm, right=2.5cm,paper=a4paper]{geometry}

%Zeilenabstand ändern
\usepackage[onehalfspacing]{setspace}

%Graphiken und Bilder
\usepackage{subfig}

%Kopfzeile
\usepackage{fancyhdr}

%Verzeichnisse
\usepackage[notindex, nottoc, numbib]{tocbibind}

%Längenangaben für den Abstand zwischen zwei Absätzen.
\usepackage{parskip}

%Kapitelanzeige und -platzierung im Text
\usepackage[clearempty]{titlesec}
\titleformat{\chapter}{\normalfont\fontsize{16pt}{0}\bfseries}{\thechapter.}{9pt}{}
\titleformat{\section}{\normalfont\fontsize{14pt}{0}\bfseries}{\thesection}{9pt}{}
\titleformat{\subsection}{\normalfont\fontsize{12pt}{0}\bfseries}{\thesubsection}{9pt}{}
\titlespacing*{\chapter}{0pt}{-22pt}{7pt}
\usepackage{titletoc}
\dottedcontents{chapter}[1.5em]{}{1.5em}{0.78pc}

% = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =
% Formatierung der Kopfzeile
% = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =

\pagestyle{fancy}
\fancyhf{}
\renewcommand{\chaptermark}[1]{\markboth{#1}{}}

\fancypagestyle{plain}{
\fancyhf{}
}

% = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =
% Anfang von Dokumententext
% = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =
\begin{document}

\pagenumbering{Roman}

% = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =
% Verzeichnisse
% = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =
\tableofcontents

\chapter{Chapter 1}
\section{test section}
\subsection{test section}
\section{test section}
\subsection{test section}

\end{document}


• Thank you very much! I have come so far to "Edit 2" in my original posted Question. Do you have any idea how to adjust the spacing between "Content" and "1 Chapter 1"? May 30, 2019 at 14:29
• You might change the spacing parameters for numberless chapters, with \titlespacing{name=\chapter, numberless}{ ... }. May 30, 2019 at 14:32
• Can I adjust the position of "1 Chapter 1" with this, too? Or is this just for the adjustment of "Contents"? Because I am happy with the positioning of "Contents", just the whole part below ("1 Chapter 1", etc.) should go a bit further up. Sorry for the confusion, I edited my original post to clarify what I mean. May 30, 2019 at 14:51
• To adjust the position of "1 Chapter 1", you can play with the last parameter of \titlespacing, which defines the spacing below Contents. Or you can add vertical spacing in the empty argument of \dottedcontents, which is for abovecode, but it well be applied to every subsequent chapter in the table of contents. Just testand see what's fine for you. May 30, 2019 at 14:57
• Ah I see, thanks a lot! I will try this :-) May 30, 2019 at 14:58

Finally I used this code:

\usepackage{titletoc}
\contentsmargin{2em}