6

Preface: NOT a duplicate of My footer disappears when I increase headheight - I tried the accepted answer here and still ran into issues.


I am using Overleaf to create some documentation for software, and using fancyhdr to customize the header and footers. My header contains images which makes the header somewhat large, so I get an error from LaTeX to increase headheight to a larger value. When I do increase this to the recommended 67pt, it removes the error, but pushes the footer off the page. At first glance, the question at the link I referenced above is a 1-for-1 mirror image of what I need, but I tried includeheadfoot, setting all to 1in margins through geometry, and the footer still runs off the page. I've looked at the fancyhdr documentation exhaustively and cannot find a solution. Below is a MWE, which pushes the footer off the page:

\documentclass[12pt]{article} 
\usepackage[utf8]{inputenc}
\usepackage{graphicx} 
\usepackage[includeheadfoot, margin=1in]{geometry}
\usepackage{fancyhdr} 
\usepackage{lastpage}
\setlength{\headheight}{67pt}
\pagestyle{fancy}
\fancyhf{} 

\fancyhead[C]{}
\lhead{\includegraphics[width=6cm]{image.PNG} \hfill \includegraphics[width=3cm]{image2.jpg}  \hfill \includegraphics[width=4cm]{image3.png}} 
\renewcommand{\headrulewidth}{0.4pt} 
\fancyfoot[R]{\small ~Page \thepage~of \pageref{LastPage}} 
\lfoot{\small Collections Guide \\ Last Updated: 07/28/2017}
\renewcommand{\footrulewidth}{0.4pt} 

\begin{document}

First line of the document.

Second line of the document.

\end{document}

How do I get rid of the \headheight warning while also keeping a footer which is at a 1 inch margin from the bottom?

Note: I've only been using LaTeX for about 2 years and for really simple reports, so this is one of the more sophisticated projects I've done so far. I appreciate insight on how I can avoid this issue again in the future, and please let me know how I can edit this question to be more concise.

1
  • Welcome to TeX.SE! Please make your code example an MWE (emphasis on minimal, i.e. remove unnecessary packages, options and definitions).
    – schtandard
    Commented Aug 8, 2019 at 13:19

1 Answer 1

10

give geometry the chance to know the headheight you are using by setting it with the geometry options:

\documentclass[12pt]{article}
\usepackage[utf8]{inputenc}
\usepackage{graphicx}
\usepackage[includeheadfoot, margin=1in,headheight=67pt]{geometry}
\usepackage{hyperref}
\usepackage{fancyhdr}
\usepackage{titlesec}
\usepackage{lastpage}
\setcounter{secnumdepth}{0}
\setlength{\parskip}{4pt}
\titlespacing*{\section}{0pt}{2pt}{2pt}
\pagestyle{fancy}
\fancyhf{}

\fancyhead[C]{}
\lhead{\includegraphics[height=62pt]{example-image-duck}}
\renewcommand{\headrulewidth}{0.4pt}
\fancyfoot[R]{\small ~Page \thepage~of \pageref{LastPage}}
\lfoot{\small Collections Guide \\ Last Updated: 07/28/2017}
\renewcommand{\footrulewidth}{0.4pt}

\begin{document}

First line of the document.

Second line of the document.

\end{document}

enter image description here

2
  • 1
    Brilliant! I added the includeheadfoot and moved the headheight to geometry as you suggested, and it worked beautifully. When I included the headheight outside of geometry, was I essentially overwriting the parameters I initially ascribed within the geometry package?
    – GeoMoon
    Commented Aug 8, 2019 at 13:07
  • The overwriting is not the main problem. The values not independant: when you enlarge the headheight you also need to shorten the textheight. geometry is doing this for you, but only if you give it all the values. Commented Aug 8, 2019 at 13:12

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .