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 created a new class based on the book class. In this class I use the package fancyhdr in order to define some heading content.

In my document, I load my new class and then I set the page dimensions with the geometry package. The problem is that the heading do not span all the page width. I did already observed that for example if you defined heading before you load geometry package. But here, as heading are defined in the class I cannot load geometry before. How can I fix this ?


share|improve this question
You could (and probably should) add \Requirepackage{geometry} to your class, and then set the page dimensions in the class. – David Carlisle Jun 26 '12 at 12:56
load geometry first and then fancyhdr in your class. The margins can then be set in your document. – Herbert Jun 26 '12 at 13:02
Yes it works! Thanks – Ger Jun 26 '12 at 14:34
Actually it does not work. Maybe I forgot to remove margins from the cls file when I have tested it. – Ger Jun 28 '12 at 9:34
up vote 5 down vote accepted

Reset \headwidth or let fancyhdr recalculate \headwidth by (re)setting the offsets:

\AtBeginDocument{\fancyhfoffset{0pt}} % comment to see the difference


share|improve this answer
Ok, I just add \AtBeginDocument{\let\headwidth\textwidth} at the end of my class file. – Ger Jun 28 '12 at 9:34

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.