[Tex/LaTex] Problem with the header/ footer width

fancyhdrgeometryheader-footerincompatibilitymargins

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}

Best Answer

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}
Related Question