1

My first section title clashes with my header, but does not for any subsequent section titles. How can I fix this?

First Section Title Clashes

Subsequenty Section Titles Do Not Clash

%Preamble
\documentclass[british]{report}
\usepackage[utf8]{inputenc}
\usepackage[a4paper,left=25mm, right=25mm,top=25mm,bottom=25mm]{geometry} %Formats page
\usepackage{babel}
\usepackage{graphicx} %Allows images
\graphicspath{ {images/} } %Sets image folder location
\usepackage[useregional,showdow]{datetime2} %Allows dynamically updating date
\usepackage{fancyhdr,lastpage} %Headers and Footers
\pagestyle{fancy}
\fancyhead[C]{
    \title{XXX: Xxxx 12 Xxxxxxxxx Xxxxxxxxxxx - Xxxxxxxxx 1}\\ \author{Xxxx Xxxx Xxxxxx Xxxxx}\\
    XXX: 12345678 $\vert$ XXX: 12345678}
\fancyfoot[C]{$\thepage$ of $\pageref{LastPage}$}

\fancypagestyle{empty}{\renewcommand{\headrulewidth}{0pt}\fancyhead{} \fancyfoot[C]{$\thepage$ of $\pageref{LastPage}$}}



%Document Information
\title{XXX: Xxxx 12 Xxxxxxxxx Xxxxxxxxxxx - Xxxxxxxxx 1}
\author{Xxxx Xxxx Xxxxxx Xxxxx}


%Document Content
\begin{document}
\maketitle

\section*{Question 1}
\setcounter{page}{2}


\pagebreak
\section*{Question 2}

\pagebreak
\section*{Question 3}

\pagebreak

\end{document}

1 Answers1

0

The MWE generates the following warning of package fancyhdr:

Package Fancyhdr Warning: \headheight is too small (12.0pt):
 Make it at least 34.43335pt.
 We now make it that large for the rest of the document.
 This may cause the page layout to be inconsistent, however.

The fix is to increase \headheight as needed. This can be done by option headheight of package geometry:

\usepackage[
  a4paper,
  left=25mm,
  right=25mm,
  top=25mm,
  bottom=25mm,
  headheight=34.5pt,
]{geometry}
Heiko Oberdiek
  • 271,626