2

Problem description

When I use two lines in my header, the distance between the bottom line of my fancy header and the title of the first section is different than the distance between the header and the title of all subsequent sections. It seems like the content of all subsequent pages if moved down by a little bit compared to the first page.

Code to replicate problem

\documentclass[a4paper,12pt]{article}
\usepackage[margin=2.5cm]{geometry} %layout
\usepackage{fancyhdr}   
\pagestyle{fancy}
\fancyhf{}
\rhead{Some text \\ some more text}

\begin{document}
\section*{Section 1}
\newpage
\section*{Section 2}
\end{document}
2

In your log file you will find the message

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

which explains the problem as well as the consequences, and how the problem can be solved.

In your case, add headheight=27.05003pt to the options of the geometry package, and the page layout will be consistent for all pages, including the first one. (Without the geometry package, use \setlength\headheight{27.05003pt}.)

\documentclass[a4paper,12pt]{article}
\usepackage[margin=2.5cm,headheight=27.05003pt]{geometry} %layout <<<<<<<<<<<
\usepackage{fancyhdr}   
\pagestyle{fancy}
\fancyhf{}
\rhead{Some text \\ some more text}
\begin{document}
\section*{Section 1}
\newpage
\section*{Section 2}
\end{document}

enter image description here

enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.