I have been searching to fix this problem for a while now. When I use the fancyhdr package to create headers and footers, and I run my code, as long as the header does not take up multiple lines, the footer spacing from the bottom of the page is consistent on every page. However, when I add a multiline header, the footer on the first page is always higher than the footer on the subsequent pages. I have not been able to find a solution to this in my online searches.

Example of code WITHOUT a multiline header and consistent footer spacing:

    \documentclass[10pt]{article}

\usepackage{amsmath, amssymb, graphicx}
\usepackage[height=9in,width=7in]{geometry}

\usepackage{fancyhdr}
\pagestyle{fancy}

\rfoot{ \textit{Left footer}}

\begin{document}
Testing
\newpage
Hi

\end{document}


Example of code WITH a multiline header that is more than 2 lines and a footer higher on first page than on subsequent pages:

    \documentclass[10pt]{article}

\usepackage{amsmath, amssymb, graphicx}
\usepackage[height=9in,width=7in]{geometry}

\usepackage{fancyhdr}
\pagestyle{fancy}

\rfoot{ \textit{Left footer}}

\begin{document}
\text{  } \\ \\Testing
\newpage
\text{  } \\ \\ Hi

\end{document}


With the second example, I get the warning

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


Solution:

\usepackage[height=9in,width=7in,headheight=48pt,heightrounded]{geometry}


(or 46.6pt, I prefer a multiple of \baselineskip. The addition of heightrounded is not related to the problem, but it's better to always use it.

When the document class is article (one sided), geometry applies some heuristics for setting the unspecified lengths. Since you just specify the text height to 9in, it will divide the space at the top and bottom according to a 2:3 ratio; thus the space above is 0.8in.

The default value of \headsep is 25pt; it's the distance from the baseline of the header to the top of the text block. With a \headheight of 48pt, it makes 73pt, which is slightly more than 1 inch, so part of the header will disappear above the top of the paper.

Since you need 48pt for the header, you have to adjust also other parameters. Let's say you want 18pt (1/4 in) above the header and also a reduced \headsep, say 12pt. Then adding

top=78in,


will do, because 18+48+12=78. Of course, the text block will be shifted down.

Complete example:

\documentclass{article}
\usepackage[
height=9in,      % height of the text block
width=7in,       % width of the text block
top=78pt,        % distance of the text block from the top of the page
heightrounded,   % ensure an integer number of lines
showframe,       % show the main blocks
verbose,         % show the values of the parameters in the log file
]{geometry}
\usepackage{fancyhdr}
\pagestyle{fancy}
\fancyhf{} % clear all fields

\fancyfoot[C]{\thepage}
\fancyfoot[R]{\textit{Left footer}}

\usepackage{lipsum}

\begin{document}
\lipsum[1-20]
\end{document}


With showframe some hairlines will outline the main blocks, with verbose the computations will be shown in the log file.

The documentation of the geometry package is very extensive. Here is a link, but you can surely find it on your system (texdoc geometry from a command line).

• This solution made my headers move much higher on the page. It did make the footers line up consistently, but created another problem with the header margin being too small. Thanks anyway. – layman Feb 26 '14 at 21:28
• @user46944 You have to change the top spacing as well, then – egreg Feb 26 '14 at 21:29
• I am still a beginner in using LaTeX. My google searches suggest that headheight sets the spacing for the header, though your code seems to suggest it modifies the footer spacing. I don't understand why your solution worked, and how I would modify the code to change the top spacing, as well. – layman Feb 26 '14 at 21:34
• Such a complicated solution for a beginner like me (but your clear explanations helped me make sense of it). Your suggestion worked, and my headers and footers now look great across all pages. Thank you very much for your time and help. I put a green check mark next to your answer -- I assume that is how to vote an answer as best. – layman Feb 26 '14 at 22:09
• @user46944 Thanks for the kind words (and the accept, of course). You want to do complicated things, so a really simple solution is not available. ;-) – egreg Feb 26 '14 at 22:11