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 have recently started using the geometry package to format the margins of my documents. Although, I've noticed that the width of the header/ footer remains the same. How can I correct this?

Here's a MWE:

\documentclass{article}

\usepackage{geometry}
\usepackage{fancyhdr}
    \pagestyle{fancy}
\usepackage{blindtext}

\lhead{}
\chead{Header}
\rhead{}
\lfoot{}
\cfoot{Footer}
\rfoot{\thepage}
\renewcommand{\headrulewidth}{1pt}
\renewcommand{\footrulewidth}{1pt}

\begin{document}

\newgeometry{margin=0.5in, bottom=1in, top=1in}
\Blinddocument

\end{document}
share|improve this question
add comment

2 Answers

up vote 10 down vote accepted

Loading fancyhdr and tweaking the header/footer content must be done after any margin changes effected by geometry, so that fancyhdr can detect those changes. In your example, \newgeometry after \begin{document} is not needed -- simply specify the margins changes as geometry package options.

\documentclass{article}

\usepackage[margin=0.5in,bottom=1in,top=1in]{geometry}
\usepackage{fancyhdr}
\pagestyle{fancy}
\usepackage{blindtext}

\lhead{}
\chead{Header}
\rhead{}
\lfoot{}
\cfoot{Footer}
\rfoot{\thepage}
\renewcommand{\headrulewidth}{1pt}
\renewcommand{\footrulewidth}{1pt}

\begin{document}

\Blinddocument

\end{document}
share|improve this answer
    
Thank you for your quick reply lockstep. Out of curiosity, do you think there is a way to manually change a header/ footer width? –  mkota Jan 5 '12 at 21:07
    
Maybe @egreg's answer is helpful in that regard. –  lockstep Jan 5 '12 at 21:09
add comment

If you really need to use \newgeometry to change the page shape after \begin{document}, the recent package titleps can be useful:

\documentclass{article}

\usepackage{geometry}
\usepackage{titleps}

\usepackage{blindtext}

\newpagestyle{jay}{%
  \sethead{}{Header}{}%
  \setfoot{}{Footer}{\thepage}%
  \setheadrule{1pt}%
  \setfootrule{1pt}%
}

\pagestyle{jay}

\begin{document}

\Blindtext

\newgeometry{margin=0.5in, bottom=1in, top=1in}

\Blinddocument

\end{document}

But stick to lockstep's recommendation if this change in shape is not required.

share|improve this answer
    
Thank you very much for your response. This package seems promising. –  mkota Jan 5 '12 at 21:19
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.