我的第一节标题与页眉冲突,但后续节标题均不冲突。我该如何修复此问题?
%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
MWE 生成以下包警告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.
解决方法是\headheight
根据需要增加。这可以通过headheight
包选项来完成geometry
:
\usepackage[
a4paper,
left=25mm,
right=25mm,
top=25mm,
bottom=25mm,
headheight=34.5pt,
]{geometry}