# Heading width are wrong if they are defined in a class

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 ?

Thanks

-
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

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

\documentclass{article}
\usepackage{fancyhdr,lipsum}
\pagestyle{fancy}
\rfoot{right}

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