Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

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

share|improve this question
4  
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
1  
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
add comment

1 Answer 1

up vote 5 down vote accepted

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

\documentclass{article}
\usepackage{fancyhdr,lipsum}
\pagestyle{fancy}
\rfoot{right}
%\AtBeginDocument{\let\headwidth\textwidth}
\AtBeginDocument{\fancyhfoffset{0pt}} % comment to see the difference
\usepackage[margin=6cm]{geometry}

\begin{document}
\section{blub}
\lipsum

\end{document}
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
add comment

Your Answer

 
discard

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.