# Page numbering different side of heading for odd and even page

Hello I am using a fancyhdr package and I want that the page number appear in the right side of the heading for odd pages and in the left side of the heading for the left side. I alredy used the command \fancyhead[RO,LE]{\thepage} but it does not work. Here is my code:

\documentclass[twoside,12pt]{elsarticle}%
\usepackage{amscd}
\usepackage{thmdefs}
\usepackage{amsmath}
\usepackage{amsfonts}
\usepackage{amssymb}
\usepackage{fancyhdr}
\usepackage[margin=0.5in]{geometry}
\setcounter{MaxMatrixCols}{30}
\providecommand{\U}[1]{\protect\rule{.1in}{.1in}}
\numberwithin{equation}{section}
\newenvironment{proof}[1][Proof]{\noindent\textbf{#1.} }{\ \rule{0.5em}{0.5em}}
\newtheorem{condition}[theorem]{Condition}

\journal{}

\pagestyle{fancy}
\newcommand\shorttitle{------------------------------}
\newcommand\authors{--------------------------}
\fancyhf{}
\ifodd\value{page}
\small\scshape\authors
\else
\small\scshape\shorttitle
\fi }

\begin{document}
HELLO!!!!
\end{document}


I think it is something related to the class elsarticle, because if I change to another the class everything works well.

-
If you're submitting an article to an Elsevier journal, they will override such settings before it is published. If you're not, why not use another document class? – Christoph B. Apr 19 '13 at 19:12
Welcome to TeX.sx! – mafp Apr 19 '13 at 19:19

The elsarticle class doesn't use twoside, so there's no way for fancyhdr to distinguish between the two cases.

Use a trick similar to the one you're using for alternating title and author: if the page number is even, push the page number all the way to the left with \hfill.

On the other hand, if you're submitting the paper to Elsevier, such changes shouldn't be made.

\documentclass[twoside,12pt]{elsarticle}%
\usepackage{fancyhdr}

\journal{}

\pagestyle{fancy}
\newcommand\shorttitle{------------------------------}
\newcommand\authors{--------------------------}
\fancyhf{}
\ifodd\value{page}
\small\scshape\authors
\else
\small\scshape\shorttitle
\fi }