GeneralTable of Contents Line Spacing

LaTeX specific issues not fitting into one of the other forums of this category.
Post Reply
lee mac
Posts: 3
Joined: Fri Feb 12, 2010 1:13 am

Table of Contents Line Spacing

Post by lee mac »

I would really like to keep my contents page to just one page long, and have tried changing the spacing between listed items using:

Code: Select all

\usepackage{setspace}

\begin{document}

\begin{spacing}{0.01}
  \tableofcontents
\end{spacing}
However, no matter how small I make the spacing figure, the spacing does not change.

Could anyone offer a suggestion as to how I can change the spacing between successive items in my contents?

Many thanks in advance,

Lee

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

User avatar
gmedina
Posts: 2313
Joined: Wed Jul 11, 2007 11:45 pm

Table of Contents Line Spacing

Post by gmedina »

Hi,

you could use some of the features provided by the tocloft package. Take a look at the following simple example:

Code: Select all

\documentclass{book}
\usepackage{tocloft}

\setlength\cftparskip{-2pt}
\setlength\cftbeforechapskip{0pt}

\begin{document}
\tableofcontents
\clearpage

\chapter{Test chapter one}
\section{test section one one}
\section{test section one two}
\chapter{Test chapter two}
\section{test section two one}
\section{test section two two}

\end{document}
Please refer to the package documentation for further information.
1,1,2,3,5,8,13,21,34,55,89,144,233,...
lee mac
Posts: 3
Joined: Fri Feb 12, 2010 1:13 am

Re: Table of Contents Line Spacing

Post by lee mac »

Many thanks for your reply.

I looked into the tocloft package, and was trying to use \cftafterZtitleskip and \cftbeforeZtitleskip to no avail.

However, your suggestion of \setlength\cftparskip{-2pt} with a slightly higher pt setting seems to work. May I ask, if the above is used to space the titles, what are the two macros that I tried used for?

I am using the article documentclass, so the \cftbeforechapskip is not recognised.

Many thanks for your time.

Lee
php1ic
Posts: 192
Joined: Wed Jan 28, 2009 8:17 pm

Re: Table of Contents Line Spacing

Post by php1ic »

Try using a bigger value in \begin{spacing}{x}. The default value for x is 1.0, so to compress the lines by so much (x=0.01 corresponds to 100 times) may not be a valid argument for the environment.

Doing a few quick tests, the minimum value seem to be 0.5, at which poins the lines start to overlap.
User avatar
gmedina
Posts: 2313
Joined: Wed Jul 11, 2007 11:45 pm

Table of Contents Line Spacing

Post by gmedina »

lee mac wrote:...I looked into the tocloft package, and was trying to use \cftafterZtitleskip and \cftbeforeZtitleskip to no avail.

...May I ask, if the above is used to space the titles, what are the two macros that I tried used for?..
With Z replaced with toc (for the \tableofcontents title) or lof (for the \listoffigures title) or lot (for the \listoftables title), those commands control the vertical spacing after and before, respectively, the corresponding title (they have no effect on the spacing between entries of the list).

For example, you can change the vertical spacing between the title "Table of Contents" and the first entry, by changing the length \cftaftertoctitleskip


Here's a modified version of my previous code, using article as the document class and additionally changing \cftaftertoctitleskip:

Code: Select all

\documentclass{article}
\usepackage{tocloft}

\setlength\cftparskip{-2pt}
\setlength\cftbeforesecskip{1pt}
\setlength\cftaftertoctitleskip{2pt}

\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}

\end{document}
1,1,2,3,5,8,13,21,34,55,89,144,233,...
lee mac
Posts: 3
Joined: Fri Feb 12, 2010 1:13 am

Table of Contents Line Spacing

Post by lee mac »

gmedina wrote:
lee mac wrote:...I looked into the tocloft package, and was trying to use \cftafterZtitleskip and \cftbeforeZtitleskip to no avail.

...May I ask, if the above is used to space the titles, what are the two macros that I tried used for?..
With Z replaced with toc (for the \tableofcontents title) or lof (for the \listoffigures title) or lot (for the \listoftables title), those commands control the vertical spacing after and before, respectively, the corresponding title (they have no effect on the spacing between entries of the list).

For example, you can change the vertical spacing between the title "Table of Contents" and the first entry, by changing the length \cftaftertoctitleskip


Here's a modified version of my previous code, using article as the document class and additionally changing \cftaftertoctitleskip:

Code: Select all

\documentclass{article}
\usepackage{tocloft}

\setlength\cftparskip{-2pt}
\setlength\cftbeforesecskip{1pt}
\setlength\cftaftertoctitleskip{2pt}

\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}

\end{document}
Superb!

Many thanks for your answer - I have learnt a lot from your post :D

Thanks!

Lee
Post Reply