# How to control spacing in toc for different sections?

I need to have a TOC that has double space between Chapter titles but single space between sections and subsections. I know there are several related questions on this matter, but the difference is that when using some of the suggested solutions like \setlength{\cftbeforesecskip}{-2pt} or \renewcommand\cftchapafterpnum{\vspace{}} that changes the spacing before or after the section or subsection, and if the title in question is one-line long is fine, but if its a long three lines title of a section then, it gives very irregular spacing, with the desired space above the section title, and then what looks like one half spacing and again single spaced after the page number.
Another solution I have tried is within the actual text use something like \section[\singlespacing{\noindent Long title}]{Long title}but then although I get single spaced lines in the TOC, I also get some undesired vertical space between the section number and the beginning of the section title. Is there any way of uniformly changing the spacing in the TOC by hierarchical sections, or avoid the extra vertical space in my second approach? Also, it is worth mentioning that I am loading the setspacepackage and using \onehalfspacing on the preamble of my document, since the main body of it should be one-half spaced. Thanks a lot, Here is how it looks what I have:

\documentclass[12pt,reqno]{report}
\usepackage[titles]{tocloft}
\setlength{\cftbeforesecskip}{-2.5pt}
\setlength{\cftbeforesubsecskip}{-2.5pt}
\usepackage{setspace}
\onehalfspacing
\usepackage{blindtext}
\begin{document}
\tableofcontents
\newpage
\chapter{this is a really really long title that someone else wrote for all the penguins in the world}
\section{this is a really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really long title having more than three lines of text to appear on the toc.}
\subsection{this is a really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really long title having more than three lines of text to appear on the toc.}
\blinddocument
\blinddocument
\blinddocument
\blinddocument
\end{document}


On this MWE I show one of the options I tried. I hope someone can comment on this. Thanks.

• You are aware that the ToC entries are not intended to be really long? That's why the \section[short title]{long title} - way was introduced/designed – user31729 Apr 30 '15 at 19:00
• Not really. The problem anyway is that my university requires the whole title of the section to appear on the TOC for my written dissertation. Thanks for the comment, anyway. – jealopez Apr 30 '15 at 19:20
• Well, in this case, you should show us an example of your file in order to get some clue -- without a document, it's just guessing around – user31729 Apr 30 '15 at 19:21
• Thanks. I posted an edited version, trying to summarize the parts of the document that are involved. – jealopez Apr 30 '15 at 19:46
• @jealopez I extended the MWE to work, but reading the question , i really don't know where which spacing shall be? You are talking about double- and singlespacing, but there is non in your example. – Johannes_B Apr 30 '15 at 20:12

You can hook into \cftchapafterpnum for adding some vertical space after a chapter title in the table of contents.

\documentclass[12pt,reqno]{report}
\usepackage[titles]{tocloft}
\usepackage{blindtext}

\renewcommand{\cftchapafterpnum}{\vspace{\cftbeforechapskip}}

\begin{document}
\tableofcontents
\newpage
\chapter{this is a really really long title that someone else wrote for all the penguins in the world}
\section{this is a really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really long title having more than three lines of text to appear on the toc.}
\subsection{this is a really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really long title having more than three lines of text to appear on the toc.}
\blinddocument
\blinddocument
\blinddocument
\blinddocument
\end{document}


However, long titles have nothing to do with the problem; you seem to be loading setspace with \onehalfspacing, probably to comply with silly requirements by your institution (if not, just use standard spacing, you'll leave happier).

Just issue \singlespacing when doing the table of contents.

\documentclass[12pt,reqno]{report}
\usepackage[titles]{tocloft}
\usepackage{setspace}
\usepackage{blindtext}

\renewcommand{\cftchapafterpnum}{\vspace{\cftbeforechapskip}}

\onehalfspacing

\begin{document}

\begingroup\singlespacing
\tableofcontents
\endgroup

\chapter{this is a really really long title that someone else wrote
for all the penguins in the world}
\section{this is a really really really really really really really
really really long title having more than three lines of text to appear on the toc.}
\subsection{this is a really really really really really really really
really really really long title having more than three lines of text to appear on the toc.}

\blinddocument

\end{document}


• I have done that, and that adds the space after the chapter title, it works well just as you showed it here. What I cannot achieve is to get the sections, subsections altogether to be single-spaced, they look more like one half spaced, and I am being requested to make sure they are single spaced. I have used \cftbeforesecskip but that won't change the spacing within all the sections sub-sections but only for the lines before each of them. From your example, what I need is to have all the spacing from 1.1 to the end of 1.1.1 to be reduced to "look" single spaced. Hope I explained myself. – jealopez May 1 '15 at 15:13
• @jealopez Sorry, but I can't see any “one half spaced” part in the picture. Are you perhaps loading the setspace package and using \onehalfspace or similar things? – egreg May 1 '15 at 15:16
• Yes, you are right!! that might be the problem, the thing is that all the document (actual chapters, sections and subsections) should be one-half space, and I am indeed loading setspace and using \onehalfspace, is there a way of keeping that and still getting on the TOC the single space in section and subsection titles? Thanks. – jealopez May 1 '15 at 16:10
• @jealopez Just set \singlespacing for the TOC, a version with it is online. – egreg May 1 '15 at 16:18