After switching from the report
class to the book
class and starting to use the fancyhdr
package to control headers/footers, the page numbers in my footers are no longer centered.
This is my fancyhdr
setup:
\usepackage{fancyhdr}
\fancypagestyle{plain}{%
\fancyhf{} % clear all header and footer fields
\fancyfoot[C]{\thepage} % except the center
\renewcommand{\headrulewidth}{0pt}
\renewcommand{\footrulewidth}{0pt}}
%activate the style:
\pagestyle{plain}
\usepackage{geometry}
\geometry{a4paper} %paper format
\geometry{left=27.5mm,right=27.5mm,bottom=27.5mm,top=27.5mm} %margins
With this the page numbers are placed off-center. On even pages they are to the right of the center and on odd ones they are to the left of it. What I want is a perfectly centered (with respect to the page) pagenumber in the footer of even and odd pages alike (like it was when I used the report
class and no fancyhdr
s).
Best Answer
The solution is to load
geometry
beforefancyhdr
and apply the settings, then configurefancyhdr
, not the other way round.A working example:
In this example, if
\usepackage{geometry}
and the\geometry
settings are moved below\pagestyle{plain}
, the undesired behavior occurs. I wonder whygeometry
is not even mentioned in thefancyhdr
manual, when I see this dependency.