[Tex/LaTex] Remove vertical space between several chapters in ToC

spacingtable of contents

I would like to remove the vertical space between several (but not all) chapters in my ToC (namely, the literature, the list of symbols, and the index). The following code works in the preamble to remove the vertical space between all chapters:

\usepackage{tocloft}
\setlength{\cftbeforechapskip}{0cm}

But this doesn't work for individual chapters. The same question has been asked a lot of times in TeX forums, in particular here. But I don't know how to use the code there resp. it does not work.

Best Answer

You can reset the parameter \cftbeforechapskip at the spot, by adding

\addtocontents{toc}{\protect\setlength{\cftbeforechapskip}{0pt}}

in the document, just before the first item where you want this to take effect in the table of contents.

So, if you use \bibliography{filename} for the references,

\addtocontents{toc}{\protect\setlength{\cftbeforechapskip}{0pt}}
\bibliography{filename}

and similarly if you directly use \chapter.