40

I am using LaTeX to write my dissertation, and I have realised that on the table of contents and on every chapter page, LaTeX leaves a lot of empty space.

What I mean is that lets say in the page where chapter 1 begins, from the top of the page until the chapter title there is much more vertical space than on any other page. The same goes with chapter 2 etc... and for contents page as well.

Can anybody help me to remove that space? Is there any mistake in my code or something like that? Is this a default of LaTeX?

the preamble is

\documentclass[12pt,twoside]{report}
\pagestyle{plain}
\usepackage{a4paper}
\usepackage{setspace}
\doublespacing 
\usepackage{amssymb}
\usepackage{amsmath} 

I've tried the methods below, but none of them work properly.

egreg
  • 1,121,712
user1015777
  • 1,153
  • Please provide a minimal example. The spacing really depends on the document class and mabye related packages. – Marco Daniel Jan 04 '12 at 06:41
  • I want to add that this default behaviour of scrreprt is really strange. Usually you don't want so much whitespace before a chapter, at least if you have a limit of totally available space. – TomM Dec 26 '13 at 13:33

4 Answers4

35

Werner answered the questions for the standard classes. If you use scrbook or scrreprt (KOMA-script) the space before and after the chapter title is given by \chapterheadstartvskip and \chapterheadendvskip. These "lengths" are not defined as lengths, but as commands instead. To change the settings you must use renewcommand:

\renewcommand*{\chapterheadstartvskip}{\vspace*{1cm}}
\renewcommand*{\chapterheadendvskip}{\vspace{2cm}}

With KOMA-script version 3.16, a new interface was introduced to change the appearance of sectioning commands, including chapters. You can now do something like this

\RedeclareSectionCommand[beforeskip=0pt,
afterskip=2cm]{chapter}
Johannes_B
  • 24,235
  • 10
  • 93
  • 248
Marco Daniel
  • 95,681
30

This is the default behaviour of for \chapter (and \chapter*) in both book and report document class, so you're doing nothing wrong. This default length is 50pt.

You could use the etoolbox package to remove (or modify) the spacing above the chapter headings. Here's a minimal example that will work with either book or report document class:

enter image description here

\documentclass{book}
\usepackage{showframe}% http://ctan.org/pkg/showframe
\usepackage{etoolbox}% http://ctan.org/pkg/etoolbox
\makeatletter
\patchcmd{\@makechapterhead}{\vspace*{50\p@}}{}{}{}% Removes space above \chapter head
\patchcmd{\@makeschapterhead}{\vspace*{50\p@}}{}{}{}% Removes space above \chapter* head
\makeatother
\begin{document}
\chapter{A chapter}
\chapter*{Another chapter}
\end{document}

\patchcmd searches for \vspace*{50\p@} in both \@makechapterhead and \@makeschapterhead and replaces it with nothing, thereby removing the space. If you want to add a little space, you can insert something different as the replacement text. For example

\patchcmd{\@makechapterhead}{\vspace*{50\p@}}{\vspace*{20pt}}{}{}%
\patchcmd{\@makeschapterhead}{\vspace*{50\p@}}{\vspace*{20pt}}{}{}%

will insert 20pt instead of the default 50pt.

showframe was added to show the frame of the text block and was merely used for illustrative purposes - you can remove this.


An alternative to this would be to use the titlesec package. However, in order to modify the \chapter spacing (via \titlespacing{\chapter}...), you are also required to modify the \chapter format (via \titleformat{\chapter}...). See the titlesec documentation for more information.

Werner
  • 603,163
  • Thank you! After all these years, your solution keeps being useful for people like me! – mathreader Apr 21 '18 at 16:18
  • For anyone using the sectsty package to change the font of the section headings: The solution with etoolbox of this answer has to be inserted after sectsty. – Mouagip Feb 16 '21 at 07:16
19

The default style for LaTeX's book class is quite generous with the whitespace on the page -- there's probably nothing wrong with your code.

One way to change the behavior of headings is to use the titlesec package, which allows you finegrained control over how all the levels of headings are displayed. For example, the following code in the preamble of the document would remove the whitespace above the chapter heading:

\usepackage{titlesec}

\titleformat{\chapter}[display]
    {\normalfont\huge\bfseries}{\chaptertitlename\ \thechapter}{20pt}{\Huge}
\titlespacing*{\chapter}{0pt}{0pt}{40pt}

In the last line, the four measurements are the left, upper and lower spacing around the heading, respectively. The second one is normally 50pt; it was changed here to 0pt to remove the white space above the chapter heading completely.

G-J
  • 191
  • This does nothing in my tex document. Has anything changed? – Ivan Perez Sep 16 '18 at 18:28
  • This doesn't work. Use \usepackage{showframe} and you will see space between the top of the page and the chapter title. Tested in document class book and report. Bug officialised at https://github.com/jbezos/titlesec/issues/53. Workaround: https://tex.stackexchange.com/questions/59389/package-titlesec-adds-extra-space-on-top-of-chapter-despite-commands-to-the-co/59392#59392 – quark67 Mar 06 '23 at 03:27
10

With the report class the space before a chapter title is 50pt. The easiest method for changing it is to patch the two relevant commands:

\documentclass[a4paper,12pt,twoside]{report}
\usepackage{amssymb}
\usepackage{amsmath}

\usepackage{setspace}
\doublespacing 

%\pagestyle{plain} % default for report

\usepackage{etoolbox}
\makeatletter
\patchcmd{\@makechapterhead}{50\p@}{0pt}{}{}
\patchcmd{\@makeschapterhead}{50\p@}{0pt}{}{}
\makeatother

<rest of the preamble>

\begin{document}

<the document>

\end{document}

You can play with the figures: instead of 0pt you can put any dimension you want.

Note that there's no a4paper package; to get page parameters suitable for ISO A4 paper you need to specify a4paper as an option to \documentclass.

egreg
  • 1,121,712
  • This somehow does not work for me with the book class. I want the "Chapter 1" line to appear right at the top. What am I doing wrong? – Ivan Perez Sep 16 '18 at 18:35
  • @IvanPerez What document class are you using? – egreg Sep 16 '18 at 19:00
  • The document class book – Ivan Perez Sep 16 '18 at 19:08
  • @IvanPerez Change 0pt to something like -24pt (it depends on the main font size, though). – egreg Sep 16 '18 at 19:12
  • I changed it to -100pt, and it had no effect. It's like it's not using \@makechapterhead at all. I removed every import but this and left only one chapter to obtain a minimal example, and it still won't make a difference. I'm using Ubuntu 18.04, and installing latex from the default repositories. – Ivan Perez Sep 16 '18 at 19:26
  • @IvanPerez Maybe you're using something like titlesec? – egreg Sep 16 '18 at 19:34
  • I tried that too (and separately), but I removed that usepackage to find a minimal example, and the issue persists. – Ivan Perez Sep 16 '18 at 19:46
  • @IvanPerez Sorry, but the information is insufficient and dealing with this in comments is impossible. Add a fresh question with the details. – egreg Sep 16 '18 at 19:53
  • Finally after several hours looking everywhere I have found something that works just the way I wanted. For all of you noobs like me out there, make sure to copy all the 5 lines (\usepackage{etoolbox} \makeatletter \patchcmd{@makechapterhead}{50\p@}{0pt}{}{} \patchcmd{@makeschapterhead}{50\p@}{0pt}{}{} \makeatother) – miguelpiquet Aug 09 '20 at 07:46