Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

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

share|improve this question
    
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
add comment

2 Answers

up vote 3 down vote accepted

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
share|improve this answer
add comment

You can do this easily with the tocloft package:

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

will do what you want.

share|improve this answer
    
Not only did that work, it also solved a problem I had with styles! Thx! –  Hugo S Ferreira Mar 14 '11 at 21:34
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.