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}
\lhead{ Left Header} \rhead{Right Header}
\rfoot{ \textit{Left footer}}
\renewcommand{\headrulewidth}{0pt}
\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}
\lhead{ Left Header \\ 2nd left header \\ 3rd left header \\ 4th left header} \rhead{Right Header \\ 2nd right header \\ \text{ } \\ Skipped 3rd}
\rfoot{ \textit{Left footer}}
\renewcommand{\headrulewidth}{0pt}
\begin{document}
\text{ } \\ \\Testing
\newpage
\text{ } \\ \\ Hi
\end{document}
Best Answer
With the second example, I get the warning
Solution:
(or 46.6pt, I prefer a multiple of
\baselineskip
. The addition ofheightrounded
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 addingwill do, because 18+48+12=78. Of course, the text block will be shifted down.
Complete example:
With
showframe
some hairlines will outline the main blocks, withverbose
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).