# How to put page number on very left on even pages and on very right on odd pages using fancyhdr

I am using \fancyhead[EL,OR]to put page number on very left on even pages and on very right on odd pages using fancyhdr but it does not work.

\documentclass[10pt,openany,oneside]{book}
\usepackage{geometry}
\geometry{paperheight=9.8125in,paperwidth=8in, left=.5in,
right=.5in,top=.75in,bottom=.4375in }
\usepackage{fancyhdr}
\pagestyle{plain}
\renewcommand{\rmdefault}{pag}
\usepackage[utf8]{inputenc}
\usepackage[hyphens]{url}
\usepackage[authoryear,round]{natbib}
\begin{document}
\newcommand{\titlefontarash}{\usefont{OT1}{pag}{b}{n}\fontsize{25}
{\baselineskip} \selectfont}
\newcommand{\basefontarash}{\usefont{OT1}{pag}{b}{n}\fontsize{18}
{\baselineskip} \selectfont}
\title{\titlefontarash  Helping each other}
\author{\basefontarash Good boy}
\maketitle
\frontmatter
\vspace*{\fill}
\begin{center}
\basefontarash To good...
\basefontarash To those good..
\end{center}
\vspace*{\fill}
\tableofcontents
\newgeometry{ left=2.75in, right=.5in }
\mainmatter
\pagestyle{plain}
\chapter{Introduction}
\section{Introducing the fish}
\section{fox}
referring to \citet{Fish(1979)}.
A \textbf{fish}  (or \textbf{cat}) jungle sky.
\section{river}
\newgeometry{ left=.5in, right=.5in}
\pagestyle{plain}

\begin{thebibliography}{9}
\bibitem[Fish(1979)]{Fish(1979)} Fish, Y(1979) \textit{orange HHH} New York:
hot.
\end{thebibliography}
\end{document}


do u know how to make it work?

When you compile your example, you should notice many warnings like:

Package Fancyhdr Warning: \fancyhead's E' option without twoside option is useless
on input line 29.


So you can make your example work like what you want by using twoside instead of oneside in your options for the book class. Actually 10pt and twoside are the default for book class, so it is enough to have:

\documentclass[openany]{book}

• David: thanks for your comment but this adds a blank page with a wrong page number after the title. do you know how to get rid of blank page? – Aria May 2 '19 at 21:10
• @ArashRashidi, this is because \frontmatter includes \cleardoublepage. For a double sided document this is needed, as \frontmatter` restarts the page numbering also. And without the extra blank page, you get page i on the left hand side instead of right hand side. This is wrong. However, I'll have a guess at what you'd like and include a full example in my answer. – David Purton May 4 '19 at 8:24
• @ArashRashidi Actually, you can't do it without a blank page. Your front matter has 3 pages (i–iii). The next page is therefore a left side page which is normally even. But then your main matter suggests page numbering again with one, which needs a right hand page. So either you need a blank page after your title, or a blank page after your contents. Or number everything from 1, rather than using roman numbering at the for your front matter. – David Purton May 4 '19 at 9:17
• Thanks David for your help. – Aria May 4 '19 at 15:36