Using the scrartcl class for a report I am writing, I would like to have only the sections show up in the table of contents. Although I manage to do that, the linespread looks too big in my eyes, and I think this is a consequence of the reduced toc depth:

For this reason, I would like to reduce the linespread locally. I tried to put a {spacing} around my code like this:

\begin{spacing}{0.5}
\setcounter{tocdepth}{1}
\rule{\textwidth}{1pt}
\vspace*{-1cm}
\tableofcontents
\vspace*{-0.5cm}
\rule{\textwidth}{1pt}
\end{spacing}


Which will not work, however. What is the easiest way to decrease the linespread here?

-

You could use the tocstyle package that comes with the KOMA Script bundle. But you will get a warning about the Alpha state of the package so you should use it with caution. At least the below code works as desired.

\documentclass[english]{scrartcl}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{tocstyle}
\usepackage{babel}
\usepackage{blindtext}

\setcounter{tocdepth}{1}
\newtocstyle{compact}{%
\settocfeature[1]{entryhook}{\bfseries}%
\settocfeature[1]{entryvskip}{0pt plus 2pt}%
}
\usetocstyle{compact}

\begin{document}
\tableofcontents

\bigskip
\Blinddocument
\end{document}


And as always, the blindtext package is only for creating dummy text thus not part of the solution.

-
The package generating the alpha warning is named tocstyle. –  lockstep Dec 11 '10 at 21:28
Thanks. Corrected. –  Thorsten Donig Dec 11 '10 at 21:31
That leaves nothing unanswered. Thanks! –  Ingo Dec 12 '10 at 10:26

You may use the etoolbox package to patch the command \l@section which is (beside other things) responsible for setting the vertical space before a section entry in the ToC.

\documentclass{scrartcl}

\usepackage{etoolbox}
\makeatletter
\patchcmd{\l@section}{1.0em}{\z@}{}{}
\makeatother

\setcounter{tocdepth}{1}

\begin{document}

\tableofcontents

\section{bla}

\section{blubb}

\section{foo}

\subsection{bar}

\end{document}

-