# Even page numbers do not show in fancyhdr

Problems:

1. Even page numbers do not show up using fancyhdr package.
2. Page number are centered, but should be right on odd and left on even.

Minimal Working Example (MWE):

\documentclass{book}
\usepackage[swedish,english]{babel}
\usepackage[utf8]{inputenc}
\usepackage{fancyhdr}
\usepackage{blindtext}

% FRONTMATTER
%
\newcommand{\frontmatterSU}{
\frontmatter
\pagestyle{fancy}{
\fancyhf{}
\renewcommand{\footrulewidth}{0pt}
\fancyfoot[C]{\thepage}
}
}

% ABSTRACT 1
%
\newenvironment{abstract1} {
\let\cleardoublepage\clearpage
\chapter{Abstract 1}
}

% ABSTRACT 2
%
\newenvironment{abstract2} {
\let\cleardoublepage\clearpage
\chapter{Abstract 2}
}

\begin{document}

\frontmatterSU

\setcounter{page}{12}

% Abstract -----------------------------------------------------

\begin{abstract1} % creates the abstract header in 1
\blindtext[10]
\end{abstract1}

\begin{abstract2} % creates the abstract header in 2
\blindtext[10]
\end{abstract2}

\end{document}


Outputs:

Centered roman numbers on odd page numbers, but empty on even page numbers.

Desired output:

Right roman numbers on odd page numbers, left roman numbers on even page numbers.

UPDATE 1:

Page numbers are visible on both odd/even pages in the center and in roman. But for some reason, there is a line in the head that I cannot I tried with \renewcommand{\headrulewidth}{0pt} but does not seem to work. How is the horizontal line removed?

• Shouldn't you use \pagestyle{roman} instead of \pagestyle{empty}? Another 'error' is that chapter start pages use plain style instead of the desired other one. The usage of \newenvironment is wrong as well
– user31729
Apr 12, 2018 at 7:21
• @ChristianHupfer Thanks for the feedback, it's quite helpful. I have removed \pagestyle{empty} from both environments and the page number is visible now on both pages (but even page number are shown top-right now?). However, when I switched to \pagestyle{roman} in the \newcommand I got an error saying Undefined control sequence. Apr 12, 2018 at 9:35
• But your pagestyle asks for centered page numbers! \fancyfoot[C]{\thepage} And you haven't defined a pagestyle called roman. Apr 12, 2018 at 10:27

If you want right numerals on odd pages and left on even ones, tell fancydr: what you are asking for is centered numerals on all pages:

\fancyfoot[C]{\thepage}


And what you want is

\fancyfoot[RO,LE]{\thepage}


Since you have defined the pagestyle as fancy (not roman) that's what you have to use: if you ask for the roman pagestyle you will get an error, because it's not defined. (Note that it is the \frontmatter instruction that is making the numerals roman, not anything in your fancyhdr instruction.)

If you want the first page of the abstract to have the numbers set left, you will need to add \thispagestyle{fancy} to override the plain that would otherwise be selected.

You can't define new environments with two arguments. A new environment needs three arguments:

\newenvironment{name}{start-code}{end-code}


Edited to add: Your headrule problem is because you are calling your fancyheader instruction set inside an environment, and it's not making a global change to the command. Put the \renewcommands outside the environment.

• Excellent and thank you for the educational instructions! Apr 12, 2018 at 11:00
• @kexxcream Edited because I'd forgotten to point out that if you want the first page of a chapter fancy you will need to specify that separately, because otherwise it will be set to plain. Apr 12, 2018 at 11:18