# Removing space before Section in Table of Contents when using Article

How can I remove the vertical spacing before each section in the table of contents from a 'article' documentclass?

-
the question's title means chapter, the question's body refers to section. Btw. before sections there's no space, but before chapters there is. –  Stefan Kottwitz Mar 14 '11 at 19:58
Hugo, please also update the title if you want change the spacing of section lines instead of chapter lines. Note that simple changing `\l@section` to `\l@chapter` in Gonzalo's answer might not work. –  Martin Scharrer Mar 14 '11 at 19:59
It actually works... I meant about referring to section, because chapter does not exist in the 'article' documentclass. Yes, I made a lot of mistakes in this question, but the answer's still valid. –  Hugo S Ferreira Mar 14 '11 at 20:15

## 2 Answers

You can redefine `\l@section` as implemented in `article.cls` and suppress (or comment out) the line `\addvspace{1.0em \@plus\p@}%` responsible for the extra space. Simply add these lines to the preamble of your document:

``````\makeatletter
\renewcommand*\l@section[2]{%
\ifnum \c@tocdepth >\z@
\addpenalty\@secpenalty
\setlength\@tempdima{1.5em}%
\begingroup
\parindent \z@ \rightskip \@pnumwidth
\parfillskip -\@pnumwidth
\leavevmode \bfseries
\advance\leftskip\@tempdima
\hskip -\leftskip
#1\nobreak\hfil \nobreak\hb@xt@\@pnumwidth{\hss #2}\par
\endgroup
\fi}
\makeatother
``````
-

You can do this easily with the `tocloft` package:

``````\usepackage{tocloft}
\renewcommand{\cftbeforesecskip}{0pt}
``````

will do what you want.

-
Not only did that work, it also solved a problem I had with styles! Thx! –  Hugo S Ferreira Mar 14 '11 at 21:34