TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm creating three documents with three different headers, containing images or large banners. Is there a way to determine the head height automatically or even better a way to change the head height automatically with reference to the content?

I know LaTeX is telling me the head height is too small and I should change it to xx pt, but I would like to not have to do it manually.

A little excerpt of the beginning of one of my documents:



\usepackage[paper = a4paper, tmargin = 2cm, bmargin = 2cm, lmargin = 2.5cm, rmargin = 2cm]{geometry}

share|improve this question
Could you please add a minimal example? – egreg Jun 5 '13 at 20:27
@egreg Added a little excerpt. – Chris.V Jun 5 '13 at 20:33
up vote 11 down vote accepted

I do not think, it makes much sense to use an overlarge height of the titlepage's header for the whole document. Nonetheless the question is interesting in general.

Package fancyhdr already updates \headheight or \footskip, if the header or footer is too small. The following example stores the latest values of these dimension registers at the end of the document in an auxiliary file \jobname.heights. If the file exists, it is read in the preamble, before package geometry is loaded that might use the updated values for its calculations. Therefore the .aux file cannot be used for this purpose, because it is read a little too late (in \begin{document}).


  \if@filesw % respect \nofiles
      % same write register as environment `filecontents` uses
      \chardef\reserved@c=15 %



\chead{\Huge Header}
\cfoot{\Huge \begin{tabular}{c}Footer\\\thepage\end{tabular}}

Hello World

First run

Package fancyhdr warns:

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

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

And the contents of the page is displaced:

First run

Second run

The previously written \jobname.heights is used:


There are no warnings and the page is:

Second run

share|improve this answer
Thanks for your fast reply. Oh fancyhdr updates it already if it's too large? Nice to know. This looks really nifty and I'll try it at home right after work. The only problem left and which I probably forgot to mention is that my headers contain data in all three sections of fancyhead. Is that a problem or does your solution always choose the right \headheight? – Chris.V Jun 6 '13 at 6:02
@Chris.V: It does not matter, how many sections of \headheight are used. – Heiko Oberdiek Jun 6 '13 at 7:45
Yeah no that was my mistake. :) Hadn't thought the whole thing to the end. ^^ Thanks for your answer, it exactly does what I searched for. – Chris.V Jun 6 '13 at 18:35

Package fancyhdr already updates \headheight or \footskip

Not entirely true: for accentuated letters, fancyhdr ignore the accents and sets the heights to that of the selected fontsize.


\documentclass[a4paper, 12pt, twoside]{report}
  \fancyhead[RO, LE] {}
  \chapter{nothing, just setting a weird title: l\`ik\'e s\^o}

In this example, fancyhdr puts \headheight to the size of 12pt's \Large for the title of the chapter in the head. However, a title with accents is bigger than without, and LaTeX adjusts the head height at the first title with such accents, leaving the first chapters with a different head height.

This should be fancyhdr default setting, depending on language. Instead, one can correct fancyhdr's oversight, if there are chapters with accentuated letters, using calc's heightof. For french language, worst case scenario is circumflex accent, thus:

\setlength{\headheight}{\heightof{{\Large \^{E}}}}

fixes the headheight.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.