4

Here's a [not] working example:

\documentclass[11pt,letterpaper]{article} 

\usepackage[titles]{tocloft}

\title{Hello world  \vspace{-0.5cm}} 

\begin{document} 

\maketitle 

\setlength\cftaftertoctitleskip{-100pt}
\tableofcontents

\section{A}

A stuff

\section{B}

B stuff

\end{document} 

When I compile this multiple times, changing the value of \setlength\cftaftertoctitleskip{-100pt} to various other values, I don't see any change in the space after the table of contents title. Is there an obvious error in my script?

zkurtz
  • 415
  • 1
    The \cftaftertoctitleskip feature gets broken by the [titles] option of tocloft. That is because (see Mico's answer at http://tex.stackexchange.com/questions/137299/tocloft-package-interfering-with-toc-page-style) the titles option purposefully bypasses the tocloft mechanisms for setting the toc, lof, lot, etc. – Steven B. Segletes Aug 08 '16 at 18:54
  • I would hasten to add that the obvious solution is to load tocloft without the [titles] option, if you wish to use the \cftaftertoctitleskip mechanism. – Steven B. Segletes Aug 08 '16 at 19:00
  • @StevenB.Segletes that appears to be correct. Consider posting that as a solution. – zkurtz Aug 08 '16 at 19:02

3 Answers3

2

You can keep the titles option, which might be important in case you have to use fancyhdr.

I assume the purpose is to remove the vertical space before the first section title:

\documentclass[11pt,letterpaper]{article}

\usepackage[titles]{tocloft}

\title{Hello world}
\author{Zkurtz}
\date{}

\begin{document}

\maketitle

\addtocontents{toc}{\protect\addvspace{-\cftbeforesecskip}}
\tableofcontents

\section{A}

A stuff

\section{B}

B stuff

\end{document}

enter image description here

egreg
  • 1,121,712
  • Hmm ... maybe so. Actually I think was trying to add space in that position, although I've since iterated too much to reconstruct exactly what I had. I was playing with \setlength\cftbeforesecskip{2pt} and \setlength\cftbeforesubsecskip{-3pt} types of settings when I ended up with too little space between "Contents" and the contents. – zkurtz Aug 08 '16 at 20:09
  • This is a real solution, which does not involve removing the titles option. As a complement, I have added a proposal to specifically pass the value -100pt. – Vincent Krebs Feb 05 '23 at 01:17
1

After some playing around, I discovered the root of the problem was the titles loading-option of tocloft. Remove that option and it worked as expected. Searching the site revealed this question, tocloft package interfering with ToC page style?, and Mico's answer to it.

Specifically, Mico notes this:

The manual of the tocloft package has the following to say about this option:

The titles option causes the titles of the ToC, LoF, and LoT lists to be typeset using the default LATEX methods. This can be useful, for example, when the tocloft and fncychap packages are used together and the 'fancy' chapter styles should be used for the ToC, etc., titles.

This very explicitly points to the problem and the solution as well. The titles option is intended for use, when one wishes to use some of the tocloft features, but not actually set the toc using the tocloft features. The solution? remove the titles option.

\documentclass[11pt,letterpaper]{article} 

\usepackage{tocloft}

\title{Hello world  \vspace{-0.5cm}} 

\begin{document} 

\maketitle 

\setlength\cftaftertoctitleskip{-100pt}
\tableofcontents

\section{A}

A stuff

\section{B}

B stuff

\end{document} 
  • Ironically, the reason I had the titles option there in the first place was because I followed the advice of one solution you cited: http://tex.stackexchange.com/questions/137299/tocloft-package-interfering-with-toc-page-style ... in the end I reverted to the non-titles version of the solution which worked fine. – zkurtz Aug 08 '16 at 19:14
  • @Steven Respectfully, removing the titles option is not a solution. There is a good reason why the OP passed the option to begin with, and the problem is not solved. You do not solve the problem, you simply remove it. – Vincent Krebs Feb 05 '23 at 01:25
0

In order to specify a vertical space after the toc title, simply use:

\renewcommand{\cftaftertoctitle}{\vspace{<whatever value you wish>}}

MWE

\documentclass[11pt,letterpaper]{article}

\usepackage[titles]{tocloft}

\title{Hello world \vspace{-0.5cm}}

\begin{document}

\maketitle

\renewcommand{\cftaftertoctitle}{\vspace{-100pt}} \tableofcontents

\section{A}

A stuff

\section{B}

B stuff

\end{document}

enter image description here