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 change the vertical spacing above the section heading that dont have a number (like for instance the table of contents, the list of figures and the bibliograpy) while keeping the spacing of all other chapters the same? (I am using the report class.)

share|improve this question
add comment

1 Answer

This answer was taken mostly verbatim from How to remove top margin above \tableofcontents.

In the standard document classes (like book and report), \tableofcontents (and friends) is set as a \chapter*:

\newcommand\tableofcontents{%
    \if@twocolumn
      \@restonecoltrue\onecolumn
    \else
      \@restonecolfalse
    \fi
    \chapter*{\contentsname
        \@mkboth{%
           \MakeUppercase\contentsname}{\MakeUppercase\contentsname}}%
    \@starttoc{toc}%
    \if@restonecol\twocolumn\fi
    }

So, it would be possible to temporarily modify the chapter heading macro to not insert as much vertical space. Here's a look at the \chapter* heading macro \@makeschapterhead:

\def\@makeschapterhead#1{%
  \vspace*{50\p@}%
  {\parindent \z@ \raggedright
    \normalfont
    \interlinepenalty\@M
    \Huge \bfseries  #1\par\nobreak
    \vskip 40\p@
  }}

Note the insertion of vertical space (\vspace*{50\p@}) before setting the heading. So, we can temporarily redefine this macro to not insert the vertical space (or modify it to whatever you need):

enter image description here

\documentclass{report}
\usepackage{showframe}% http://ctan.org/pkg/showframe
\begin{document}

\begingroup
\makeatletter
% Redefine the \chapter* header macro to remove vertical space
\def\@makeschapterhead#1{%
  %\vspace*{50\p@}% Remove the vertical space
  {\parindent \z@ \raggedright
    \normalfont
    \interlinepenalty\@M
    \Huge \bfseries  #1\par\nobreak
    \vskip 40\p@
  }}
\makeatother

\tableofcontents
\endgroup
\chapter{A chapter}\section{A section}\subsection{A subsection}
\chapter{A chapter}\section{A section}\subsection{A subsection}
\chapter{A chapter}\section{A section}\subsection{A subsection}
\chapter{A chapter}\section{A section}\subsection{A subsection}
\chapter{A chapter}\section{A section}\subsection{A subsection}
\chapter{A chapter}\section{A section}\subsection{A subsection}
\end{document}

The grouping of the redefinition makes it local. Therefore, all modifications are restored after \endgroup. The same idea goes for \listoffigures, \listoftables, etc.

Since the \chapter* header macro only uses \vspace*{..} to insert the gap between the text block and chapter header, you could also redefine \vspace to gobble the two arguments (* and {50\p@}):

\documentclass{book}
\usepackage{showframe}% http://ctan.org/pkg/showframe
\begin{document}
\begingroup
\renewcommand{\vspace}[2]{}% Gobble 2 arguments after \vspace
\tableofcontents
\endgroup
\chapter{A chapter}\section{A section}\subsection{A subsection}
\chapter{A chapter}\section{A section}\subsection{A subsection}
\chapter{A chapter}\section{A section}\subsection{A subsection}
\chapter{A chapter}\section{A section}\subsection{A subsection}
\chapter{A chapter}\section{A section}\subsection{A subsection}
\chapter{A chapter}\section{A section}\subsection{A subsection}
\end{document}

The showframe package highlights the text block boundary (in addition to other elements) and is therefore only used in this example to showcase the vertical alignment of the table of contents. It is not needed in your final document.

Other packages (including titlesec) can also be used to obtain this result.

share|improve this answer
    
Thank you very much for your extensive explanation! –  Jan Jul 4 '12 at 8:50
    
@Jan: If this answered your original question, consider up-voting and accepting it as such. See How do you accept an answer? –  Werner Jul 4 '12 at 10:23
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.