[Tex/LaTex] Page numbering at wrong place

fancyhdrpage-numbering

I am quite new to TeX. I'm writing my thesis and I want to place the page numbers at bottom left for even pages and bottom right for odd pages. I've done this and it works for even pages, but the odd ones have the page number at the center. Any idea what I'm doing wrong?

\documentclass[11pt, twoside]{book}
\usepackage{geometry, amsmath, float, fancyhdr, standalone}
\geometry{a4paper}
\usepackage[parfill]{parskip}
\pagestyle{fancy}
\fancyhf{}
\fancyfoot[LE,RO]{\thepage}

Best Answer

First pages of chapters, table of contents, and other "special" pages are defined to have a plain page style (\thispagestyle{plain} can be found in the definition of \chapter and so in \tableofcontents, etc.).

Even when you apply the fancy page style through the fancyhdr package, these pages continue to have the plain style.

So, if you want these pages to have the fancy style, you have to redefine the plain style to be the same of the fancy one:

\makeatletter
\let\ps@plain\ps@fancy % plain style = fancy style
\makeatother

The same can be achieved with

\fancypagestyle{plain}{}

I also suggest you to add the following line

\renewcommand{\headrulewidth}{0pt} % remove the header rule

to remove the header rule, since you are putting nothing in the header.

Complete example:

\documentclass[11pt, twoside]{book}
\usepackage{geometry, amsmath, float, fancyhdr, standalone}
\geometry{a4paper}
\usepackage[parfill]{parskip}
\pagestyle{fancy}
\fancyhf{}
\renewcommand{\headrulewidth}{0pt} % remove the header rule
\fancyfoot[LE,RO]{\thepage}
\makeatletter
\let\ps@plain\ps@fancy % plain style = fancy style
\makeatother

\usepackage{blindtext} % just for the example

\begin{document}
\blinddocument % just for the example
\end{document} 

Output (first two pages):

enter image description here

EDIT

If you want to keep the header line in all pages but plain ones, forget what I said and simply put the line

\fancypagestyle{plain}{\renewcommand{\headrulewidth}{0pt}}

in the preamble.

In this way you are redefining the plain style to be the same of fancy except for the header rule.

Code:

\documentclass[11pt, twoside]{book}
\usepackage{geometry, amsmath, float, fancyhdr, standalone}
\geometry{a4paper}
\usepackage[parfill]{parskip}
\pagestyle{fancy}
\fancyhf{}
\fancyfoot[LE,RO]{\thepage}

\fancypagestyle{plain}{\renewcommand{\headrulewidth}{0pt}}

\usepackage{blindtext} % just for the example

\begin{document}
\blinddocument % just for the example
\end{document} 

Output:

enter image description here