I am trying to take control over the white spacing around chapter headings, more specifically between TOC heading and the top margin. However, I seem to have some spacing I can't control, would anyone be able to point me to which nob I should turn?
With the following code I thought I removed all white space around chapter headings (ie. TOC, Bibliography headings and whatnot):
\documentclass{report}
\usepackage{biblatex}
\usepackage{titlesec}
\usepackage{etoolbox}
\usepackage{showframe}
\usepackage{filecontents}
\begin{filecontents}{refs.bib}
@misc{ref,
title = {A title},
author = {Doe, J.},
year = {2000},
}
\end{filecontents}
\addbibresource{refs.bib}
\nocite{*}
\titleformat{\chapter}{
\sffamily\fontsize{18pt}{18pt}
\bfseries
}{\thechapter}{0pt}{}
\titlespacing{\chapter}{0pt}{0pt}{0pt}
\titlespacing{name=\chapter,numberless}{0pt}{-15pt}{0pt}
\setlength{\parskip}{0pt}
\patchcmd{\chapter}{\if@openright\cleardoublepage\else\clearpage\fi}{}{}{}
\begin{document}
\tableofcontents
\listoffigures
\clearpage
\section{first}
\begin{figure}
Text in figure
\caption{First figure}
\label{fig:Fig1}
\end{figure}
\begin{figure}
Text in figure
\caption{Second figure}
\label{fig:Fig2}
\end{figure}
\section{second}
\section{third}
\clearpage
\printbibliography[heading=bibintoc, title={Bibliography}]
\end{document}
But this is the result I get:
The sections don't seem to have this problem:
I read in this answer that:
For many reasons, titlesec continues to use the default \@makechapterhead macro for typesetting the chapter title when the chapter style is display. ... \@makechapterhead adds a 50pt space above the title and 40pt after it.
But adding the proposed -50pt
to \titlespacing
doesn't seem to do the trick. Adding -15pt
seems to work though, does this mean something has changed in titlesec or is this another case where some other solution would be preferable?
EDIT: However I just noticed a problem with the solution above, when using printing additional "List of ..."s such as figures on the same page (see updated code above), the title of the next list will clip into the TOC as such:
How can I prevent this while still placing the TOCs chapter at the very top of the page?
\vspace*{25pt}
immediately before\listoffigures
?\titleformat
shouldn't be{\thechapter}
; instead, it should probably be either{\thechapter\space}
or{\thechapter\quad}
.\patchcmd{\chapter}{\if@openright\cleardoublepage\else\clearpage\fi}{}{}{}
suppress the automatic switching to a new page at the start of each chapter. You therefore need to provide manual controls for those cases where a chapter-level header, in fact, does not occur at the start of a page.\fontsize{18pt}{18pt}
is asking for trouble if a chapter-level header ever takes up more than 1 line. Something like\fontsize{18pt}{21pt}
is probably more appropriate. If you make this adjustment, you should probably also change\titlespacing{name=\chapter,numberless}{0pt}{-15pt}{0pt}
to\titlespacing{name=\chapter,numberless}{0pt}{-18pt}{0pt}
. Plus, for the sake of consistency, you should probably change\titlespacing{\chapter}{0pt}{0pt}{0pt}
to\titlespacing{\chapter}{0pt}{-18pt}{0pt}
.