My contents page would fit on one side, if LateX wouldn't force an automatic whitespace block on top of the table of contents.
Is there any way to remove this block and have \tableofcontents
start at the top of the page?
spacingtable of contents
My contents page would fit on one side, if LateX wouldn't force an automatic whitespace block on top of the table of contents.
Is there any way to remove this block and have \tableofcontents
start at the top of the page?
Best Answer
In the standard document classes (like
book
andreport
),\tableofcontents
is set as a\chapter*
: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
: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:The grouping of the redefinition makes it local. Therefore, all modifications are restored after
\endgroup
.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@}
):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.Perhaps a cleaner approach would be to use
etoolbox
to patch\@makeschapterhead
. This would also allow you to separate document structure from content (making what resides in thedocument
environment only relate to the content). Add the following to your document preamble:The above does a local search-and-replace within
\@makeschapterhead
(replacing\vspace*{50\p@}
with nothing, before calling the regular table of contents. The redefinition (search-and-replace) is localized within the scope of the group.