0

fancyhdr provides an easy way to customize headers and footers and hence is used by many people. An issue I just found is that it doesn't handle font sizes other than 10pt well on the first page. From the second page on, everything seems to be alright. It looks like there's a general offset on the first page, affecting header, body, and footer of the page. Here is some code to test this:

\documentclass[12pt,%
               %11pt,%
               %10pt,%
               ]{article}
\usepackage{fancyhdr}
\pagestyle{fancy}

\usepackage{showframe}

\begin{document}
%\vspace*{\dimexpr 2.5pt-\baselineskip\relax} % correct first baseline in body positiong for 12pt
%\vspace*{\dimexpr 1.6pt-\baselineskip\relax} % correct first baseline in body positiong for 11pt
Test line 1st page
\newpage

Test line 2nd page
\end{document}

produces the following (cropped images of first line of text and footer): gif animation

edit: A less flashy picture with colored body-text and overlay instead of animation: result

Is this a feature or a bug? Am I missing something?

1

The standard classes set the \headheight to 12pt, independent of the chosen font size, which is too small for 11pt and 12pt. fancyhdr detects this, writes a warning to the log and corrects it for the rest of the document. This leads to the inconsistency between the first and the following pages. In your case the warning is

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

Adhering to it by adding

\setlength{\headheight}{14.5pt}

to the preamble will solve the problem.

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.