[Tex/LaTex] Even page numbers do not show in fancyhdr

fancyhdrpage-numberingroman numerals

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{\headrulewidth}{0pt}
        \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?

Best Answer

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.