2

I need to put some horizontal space between a title (of chapter, section, subsection, etc.) and the dotted leader, as it is marked in the given figure by red rectangles. The space should be independent of the distance between dots. Moreover, I would rather not to apply a trivial solution, which consists in adding the space at the end of every title. Could anybody tell me, how to modify the tocloft commands in order to obtain the considered effect? I would very appreciate for any reply. enter image description here

  • 1
    Welcome! Please provide us with a Minimal Working Example - code for a small document which we can copy, paste and compile to reproduce your current results. (Not all of it, of course - we just need enough to see the problem.) The format of the ToC is highly dependent on your class and, if relevant, the use of other packages which modify it (e..g. titletoc, etoc etc.). Right now, we'd just be guessing and so our answers would as likely be useless to you as not. – cfr Apr 7 '16 at 2:09
1

You can put the space in \cftXleaders before the actual leaders:

\documentclass{book}
\usepackage[titles]{tocloft}

\renewcommand{\cftchapdotsep}{\cftdotsep} % leaders for chapters
\renewcommand{\cftchapleader}{\hspace{1em}\cftdotfill{\cftsecdotsep}}
\renewcommand{\cftsecleader}{\hspace{2em}\cftdotfill{\cftsecdotsep}}
\renewcommand{\cftsubsecleader}{\hspace{3em}\cftdotfill{\cftsubsecdotsep}}

\begin{document}

\tableofcontents

\chapter{Title}

\section{First}

\section{The Next}
\subsection{A test}

\end{document}

Here, just by way of example, I used three different values for the added space.

enter image description here

  • Touche! I never made it to p.18 of the documentation. – Steven B. Segletes Apr 7 '16 at 12:10
  • Thank you very much, this is it! You really helped me a lot. – Adam Apr 8 '16 at 0:35
0

For the tocloft package (tagged by the OP's question), after turning dots on with \cftsecdotsep, the gap between section title and the dot leader can be adjusted by redefining \cftsecfillnum to add a \hspace at the very beginning.

\documentclass{article}
\usepackage{tocloft}
\renewcommand\cftsecdotsep{\cftdotsep}
\makeatletter
\renewcommand{\cftsecfillnum}[1]{\hspace{30pt}% H<--- HERE IS WHAT TO ADD
 {\cftsecleader}\nobreak
 \makebox[\@pnumwidth][\cftpnumalign]{\cftsecpagefont #1}\cftsecafterpnum\par
 }
\makeatother
\begin{document}
\tableofcontents

\section{First}
\section{The Next}
\end{document}

enter image description here

Of course, this change is just for section leaders. It will have to be repeated for other sectioning units, as desired. I looked in the style file itself, in order to determine the extant definition for \cftsecfillnum.

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.