I am trying to write a simple document with a header and a footer on each page. I may decide to change the header/footer later or even use different styles on different pages, so I am looking for a solution that does not require to hardcode the height of the header and footer. I would like that no matter the height of the header and footer, the top and bottom margins (say 1in
) and the separations with the body (say 0.1in
) are respected.
I have tried using the fancyhdr
package for this effect in combination of the geometry
package but I cannot seem to find a neat solution. My idea was to first load \usepackage[margin=1in, include head, includefoot]{geometry}
to have 1in
everywhere and hope that fancyhdr
could adapt the body size to what remains available once the header and footer are placed. However, without further specification, the header spills over the text, or rather, the text starts too high. I have tried using the argument headheight=100pt
which works if I know the exact height of my header (if I overshoot, it adds an undesired buffer), but I would have to hardcode the height of my header. One last problem, the bottom margin is not respected when the footer has multiple lines. In fact, it disappears out of the page if it is too long.
My MWE is the following:
\documentclass{article}[10pt]\usepackage{lipsum}\usepackage[margin=1in, headheight=100pt, includehead, includefoot]{geometry}\usepackage{fancyhdr}\pagestyle{fancy}\fancyhead{}\fancyhead[L]{A multiline footer\\Quite tall\\Whose height I do not want have to mention explicitly\\One more line\\And another one}\fancyfoot{}\fancyfoot[L]{My custom footer\\When it is longer\\It leaves the page\\And that's not what I want\\Definitely\\One more line\\And another one\\And an invisible one}\begin{document}\lipsum[1-10]\end{document}