28

My LaTeX file compiles fine. However, in reading my .log file, I see many repeated instances of

Package Fancyhdr Warning: \headheight is too small

Looking for it in google, I found some 'fixes', but first I'd like to know what the error is about.

What is fancyhdr? What is \headheight? What does the error mean?

  • Well, you compile your document , so you should know what fancyhdr is meant for, shouldn't you? ;-) headheight is the vertical space left for the page headers at the top of the page. The error just means that the setting is too small, i.e. the page header is squeezed. The geometry package has a nice sketch what headheight means, see page 3 of v5.6 manual, for example, please – user31729 Aug 30 '16 at 23:59
40

First of all, this is just a warning, which is different from an error.

  • fancyhdr is a package that

    pro­vides ex­ten­sive fa­cil­i­ties, both for con­struct­ing head­ers and foot­ers, and for con­trol­ling their use (for ex­am­ple, at times when LATEX would au­to­mat­i­cally change the head­ing style in use).

    (from the fancyhdr README)

  • \headheight is the (vertical) height associated with the header of the page. Where is this located at on the page? Here's a schematic (from the geometry package documentation):

    enter image description here

    The notation in the above image corresponds to the geometry settings, but is similar to the lengths used by fancyhdr.

  • The warning mentions that the space currently allocated for the header is too small and should be enlarged. A more comprehensive view of the message will actually tell you what the suggested minimum height should be.

    You can ignore this warning, but page layouts will be adjusted by fancyhdr automatically and therefore differ from one page to the next. Here's an example that highlights this:

    enter image description here

    \documentclass{article}
    
    \usepackage{fancyhdr,lipsum}
    \pagestyle{fancy}
    \fancyhead[C]{\rule{.5\textwidth}{4\baselineskip}}% Add something BIG in the header
    
    \begin{document}
    
    \lipsum[1-10]
    
    \end{document}
    

    Note how the header rule remains at the same height from one page to the next (the red arrow). However, the first line of text on the page is pushed down immediately following the incorrect \headheight page. fancyhdr adjusted this manually, as noted by the warning text:

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

    Correcting for this we add

    \setlength{\headheight}{52pt}% ...at least 51.60004pt
    

    to the preamble:

    enter image description here

    \documentclass{article}
    
    \usepackage{fancyhdr,lipsum}
    \pagestyle{fancy}
    \fancyhead[C]{\rule{.5\textwidth}{4\baselineskip}}% Add something BIG in the header
    \setlength{\headheight}{52pt}% ...at least 51.60004pt
    
    \begin{document}
    
    \lipsum[1-10]
    
    \end{document}
    

Note, load or place your geometry settings before loading fancyhdr/selecting \pagestyle{fancy}.

  • you do the Oppostite of your note : settings before pagestyle! – qrtLs Jun 24 at 8:35
  • 1
    @qrtLs: I specifically refer to geometry settings, which is not used in my code. – Werner Jun 24 at 15:05

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.