TransWikia.com

What does this warning mean? (fancyhdr and headheight)

TeX - LaTeX Asked by josinalvo on November 30, 2020

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?

One Answer

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{.5textwidth}{4baselineskip}}% 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{.5textwidth}{4baselineskip}}% 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}.

Correct answer by Werner on November 30, 2020

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP