# fancyhdr ignores newgeometry

It seems that fancyhdr ignores the setting of \newgeoemtry. That is, the settings made upon loading the geometry package:

\usepackage[
left=1.0em,
right=1.0em,
top=1.0cm,
bottom=1.0cm,
paperheight=11.0in,
paperwidth=8.5in
]{geometry}

\pagestyle{fancy}
\fancyfoot{}% clear footers
\fancyfoot[RO, LE]{Page \thepage}


work fine with the page number being on the right hand side as required:

But, if the \fancyfoot is set, and then the geometry is modified:

\usepackage[
paperheight=11.0in,
paperwidth=8.5in
]{geometry}

\pagestyle{fancy}
\fancyfoot{}% clear footers
\fancyfoot[RO, LE]{Page \thepage}

\newgeometry{
left=1.0em,
right=1.0em,
top=1.0cm,
bottom=1.0cm,
}
\pagestyle{fancy}
\fancyfoot{}% clear footers
\fancyfoot[RO, LE]{Page \thepage}


the footer does not end up on the right as requested.

## Notes:

• The reason for the two step process is that the \usepacakge and the fancy settings are from a common .sty files that I use. Then for one particular case, I want a different geometry so the cleanest solution is to use \newgometry to modify the settings.
• One solution of course is to set a flag before the packages are loaded and then adjust the settings at \usepackage time. I'd prefer not to do this as then the it seperates the specfic settings from where they are required.

## Code:

\documentclass{book}

%% -------------------------------------------- Standard packages
\usepackage{xcolor}
\usepackage{fancyhdr}
%\usepackage{showframe}
\usepackage{lipsum}

\usepackage[
%% Setting these here work, however I would prefer to do this later via \newgoemetry
%    left=1.0em,
%    right=1.0em,
%    top=1.0cm,
%    bottom=1.0cm,
paperheight=11.0in,
paperwidth=8.5in
]{geometry}

\pagestyle{fancy}
\fancyfoot{}% clear footers
\fancyfoot[RO, LE]{Page \thepage}

%% -------------------------------------------- Cusomizations
\newgeometry{
left=1.0em,
right=1.0em,
top=1.0cm,
bottom=1.0cm,
}
\pagestyle{fancy}
\fancyfoot{}% clear footers
\fancyfoot[RO, LE]{Page \thepage}

\begin{document}
\lipsum[1-12]
\end{document}

• it doesn't ignore geometry, it uses the settings at the time that the page head is set. You could use \AtBeginDocument{....} around the fancyhdr settings so they happen after the geometry settings) Nov 20 '17 at 18:19
• @DavidCarlisle: Applying \AtBeginDocument{} to the initial settings seems to work. But, that also seems to imply that changing geometry mid document wont work with fancyhdr. Is there no way to reset the fancy settings? Nov 20 '17 at 18:25
• the way to change the page head mid document is to define multiple page styles and use \pagestyle{zzz} where you want a change. Nov 20 '17 at 18:28
• @DavidCarlisle: I can't seem to get that to work without removing the initial fancy settings, even with \AtBeginDocument{\pagestyle{mypagestyle}}. Nov 20 '17 at 18:35
• you would need to adjust the geometry before defining the pagestyle (and adjust it back) or poke into the fancyhdr definition and reset its lengths to match the new textwidth Nov 20 '17 at 19:19

If you are using one of the commands \fancyhfoffset, \fancyheadoffset or \fancyfootoffset the \headwidth will be recalculated based on the current parameters even if you use the default value 0pt for the offset.

\documentclass{book}
\usepackage{fancyhdr}
\usepackage{lipsum}

\usepackage[
paperheight=11.0in,
paperwidth=8.5in
]{geometry}

\pagestyle{fancy}
\fancyhf{}
\fancyfoot[RO, LE]{Page \thepage}

\newgeometry{
left=1.0em,
right=1.0em,
top=1.0cm,
bottom=1.0cm,
}