# How can I single-space text within entries of my table of contents?

I am writing my dissertation. My university requires that the document be double-spaced; I am using the setspace package to do this. However, I must single-space entries of the table of contents that exceed one line in length. What is the best way to do this?

One solution might be to put short titles in the table of contents. However, my university's requirements do not allow this.

Also, from Googling, I have gotten the impression that what I want to do is possible using the tocloft package. However, even after reading the documentation for that package, I'm not sure how.

-

Here's a possible solution using the singlespace environment from setspace for the table of contents and tocloft to redefine the \cftXafterpnum commands to add the necessary space after the ToC entries:

\documentclass{article}
\usepackage[doublespacing]{setspace}
\usepackage{tocloft}

\renewcommand\cftsecafterpnum{\vskip\baselineskip}
\renewcommand\cftsubsecafterpnum{\vskip\baselineskip}
\renewcommand\cftsubsubsecafterpnum{\vskip\baselineskip}

\begin{document}

\begin{singlespace}
\tableofcontents
\end{singlespace}

\section{A section with a very long title that spans several lines - even in the ToC}

\subsection{A subsection}

\subsubsection{A subsection}

\end{document}


-
This works perfectly. Thanks! – Andrew Uzzell Mar 28 '12 at 13:32

An approximate solution is to typeset the ToC as a whole single-spaced -- this may be done by enclosing \tableofcontents in a singlespace environment.

EDIT: To add to the delusion that the ToC is typeset double-spaced, one may fiddle with the definition of internal ToC macros.

\documentclass{article}

\usepackage[doublespacing]{setspace}

\makeatletter

\renewcommand*\l@section[2]{%
\ifnum \c@tocdepth >\z@
\addvspace{2.0em \@plus\p@}% Replaced "1.0em" with "2.0em"
\setlength\@tempdima{1.5em}%
\begingroup
\parindent \z@ \rightskip \@pnumwidth
\parfillskip -\@pnumwidth
\leavevmode \bfseries
\hskip -\leftskip
#1\nobreak\hfil \nobreak\hb@xt@\@pnumwidth{\hss #2}\par
\endgroup
\fi}

\makeatother

\usepackage{lipsum}

\begin{document}

\begin{singlespace}
\tableofcontents
\end{singlespace}

\section{A section with a very long title that spans several lines - even in the ToC}

\subsection{A subsection}

\lipsum[1]

\end{document}


-