4

I have a strange formatting problem in my table of contents. For some reason, the dots following chapters do not extend as far as those for sections and subsections.

I have included a MWE below

\documentclass[a4paper,12pt]{report}
\usepackage[english]{babel}
\usepackage[T1]{fontenc}
\usepackage[a4paper,top=2.5cm,bottom=3cm,left=3cm,right=3cm]{geometry}

\usepackage{tocloft} 
\setlength{\cftbeforetoctitleskip}{-1em} 

\renewcommand{\cftchapdotsep}{\cftdotsep} 
\setlength{\cftchapnumwidth}{6em}
\renewcommand{\cftchappresnum}{Chapter }

\begin{document}

\tableofcontents

\chapter{Example 1}
\section{Example 2}
\subsection{Example 3}

\end{document}

I have highlighted the place of the missing dot in the image below

enter image description here

2
  • The page number for chapters is in bold, hence is a little bit wider than the non-bold, and leaves narrower space for the dotted filling. Also the dots are filling from left to right, hence it's a coincidence that those dots in different toc lines look aligned. Sep 11 at 11:16
  • @muzimuzhiZ Is there a way to fix this such that the chapters align and are in bold?
    – M B
    Sep 11 at 11:29
1

What I said in this comment is close, and only close to the point. TeX will automatically make the box leaders aligned, as far as the boxes has equal width. See texdoc texbytopic, sec. 9.2.2 "Box Leaders". Here tocloft uses a box leader

\leaders\hbox{$\m@th\mkern #1 mu\hbox{\cftdot}\mkern #1 mu$}\hfill

in which for chapters the \cftdot is in bold, hence makes the box wider and not aligned with that box for sections.

The following example tries to make the box used by leader has equal width.

\documentclass[a4paper,12pt]{report}
\usepackage[english]{babel}
\usepackage[T1]{fontenc}
\usepackage[a4paper,top=2.5cm,bottom=3cm,left=3cm,right=3cm]{geometry}

\usepackage{tocloft} 
\setlength{\cftbeforetoctitleskip}{-1em} 

\renewcommand{\cftchapdotsep}{\cftdotsep} 
\setlength{\cftchapnumwidth}{6em}
\renewcommand{\cftchappresnum}{Chapter }

% make dots in toc aligned
\usepackage{xpatch}

\makeatletter
\xpatchcmd\cftdotfill
  {\hbox{\cftdot}}
  {\hbox to 3pt{\hss\cftdot}}
  {}{\fail}
\makeatother

\cftsetpnumwidth{1em} % initially 1.55em

\begin{document}
\tableofcontents

\chapter{Example 1}
\section{Example 2}
\subsection{Example 3}
\end{document}

enter image description here

1

As you say, the bold dots are slightly wider than the regular dots. You need to change (reduce) the spacing between bold dots to get them to match with the regular dots. The following does this but might need a little adjustment for your particular case.

% tocdotsprob.tex  SE 615007

\documentclass[a4paper,12pt]{report}
\usepackage[english]{babel}
\usepackage[T1]{fontenc}
\usepackage[a4paper,top=2.5cm,bottom=3cm,left=3cm,right=3cm]{geometry}

\usepackage{tocloft} 
\setlength{\cftbeforetoctitleskip}{-1em} 

\renewcommand{\cftchapdotsep}{\cftdotsep} 
%\renewcommand{\cftchapdotsep}{4.4} % the default is 4.5
\renewcommand{\cftchapdotsep}{4.3} %%%% adjust this to suit
\setlength{\cftchapnumwidth}{6em}
\renewcommand{\cftchappresnum}{Chapter }

\begin{document}

\tableofcontents

\chapter{Example 1}
\section{Example 2}
\subsection{Example 3}

\end{document}

enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.