# How to change vertical spacing in TOC between section entry and only the first subsection entry in each section?

I am using article class and tocloft package.

Does anyone know how to put a space (for example of size "22pt") between a ToC section entry and only the first subsection entry in every section.

When I use \setlength\cftbeforesubsecskip{22pt} this puts a space before every subsection entry. I don't want extra space between subsection entires. I only want a space between the section entry and 1st subsection entry (in every section).

What would be useful is a command that changes the space after a section entry, not before. This way I could set the space after a section entry but as far as I know something like \cftAFTERsecskip does not exist.

Does anyone have a suggestion? Thank you!

\documentclass[12pt]{article}
\usepackage{tocloft}

\setlength\cftparskip{0pt}

\setlength\cftbeforesecskip{0pt}

\setlength\cftbeforesubsecskip{22pt}

\setlength\cftaftertoctitleskip{44pt}

\begin{document}
\tableofcontents

\section{Test section one}
\subsection{test section one one}
\subsection{test section one two}
\section{Test section two}
\subsection{test section two one}
\subsection{test section two two}
\clearpage
\section{Test section three}
\subsection{test section three one}
\subsection{test section three two}

\end{document}

-
–  lockstep Apr 24 '12 at 15:23

One option would be to redefine \subsection as implemented in article.cls. In the redefinition you test for the value of the subsection counter; if the value is greater then one, do nothing; if it's equal to one, add the space to the ToC:

\documentclass[12pt]{article}
\usepackage{tocloft}

\setlength\cftparskip{0pt}
\setlength\cftaftertoctitleskip{44pt}

\makeatletter
\renewcommand\subsection{\@startsection{subsection}{2}{\z@}%
{-3.25ex\@plus -1ex \@minus -.2ex}%
{1.5ex \@plus .2ex}%
{\normalfont\large\bfseries%
\makeatother

\begin{document}
\tableofcontents

\section{Test section one}
\subsection{test section one one}
\subsection{test section one two}
\section{Test section two}
\subsection{test section two one}
\subsection{test section two two}
\clearpage
\section{Test section three}
\subsection{test section three one}
\subsection{test section three two}

\end{document}


Patching the \subsection command with the help of \patchcmd from the etoolbox package simplifies the code:

\documentclass[12pt]{article}
\usepackage{tocloft}
\usepackage{etoolbox}

\setlength\cftparskip{0pt}
\setlength\cftaftertoctitleskip{44pt}

\patchcmd{\subsection}{\bfseries}%

\begin{document}
\tableofcontents

\section{Test section one}
\subsection{test section one one}
\subsection{test section one two}
\section{Test section two}
\subsection{test section two one}
\subsection{test section two two}
\clearpage
\section{Test section three}
\subsection{test section three one}
\subsection{test section three two}

\end{document}

-