Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

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{}
\renewcommand\headrulewidth{0pt}
\fancyhead[C]{%
\ifodd\value{page}
  \small\scshape\authors
\else
  \small\scshape\shorttitle
\fi }

\fancyhead[RO,LE]{\thepage}

\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.

share|improve this question
3  
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

1 Answer 1

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[margin=0.5in,headheight=14.5pt,includehead]{geometry}
\usepackage{fancyhdr}

\journal{}

\pagestyle{fancy}
\newcommand\shorttitle{------------------------------}
\newcommand\authors{--------------------------}
\fancyhf{}
\renewcommand\headrulewidth{0pt}
\fancyhead[C]{%
\ifodd\value{page}
  \small\scshape\authors
\else
  \small\scshape\shorttitle
\fi }

\fancyhead[R]{\thepage\ifodd\value{page}\else\hfill\fi}

\usepackage{lipsum}

\begin{document}
\lipsum[1-20]
\end{document}

enter image description here

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.