7

I'm trying to numerate pages depending on even and odd and add chapter name the left part of the header and section name to the right.

here's the code,

\usepackage{fancyhdr}
\pagestyle{fancy}
\fancyhf{}
\fancyhead[RE]{\leftmark}
\fancyhead[LO]{\rightmark}
\fancyfoot[RO,LE]{\thepage}

the output gives me only the chapter name in the left no matter if it is an odd or even page umber, and the numbering in the footer is always in the right.

0

1 Answer 1

9

Use the twoside option for your document class: for example, for report:

\documentclass[twoside]{report} 

Otherwise, the distinction between E and O has no effect.

In a comment it has been requested to have the same position for the page number for the first pages of a chapter; this can be achieved redefining the plain style (by default this style is applied to the first page of a chapter). The following example illustrates this:

\documentclass[twoside]{report}
\usepackage{fancyhdr}
\usepackage{lipsum}

\usepackage{fancyhdr}
\pagestyle{fancy}
\fancyhf{}
\fancyhead[RE]{\leftmark}
\fancyhead[LO]{\rightmark}
\fancyfoot[RO,LE]{\thepage}
\fancypagestyle{plain}{
\renewcommand\headrulewidth{0pt}
\fancyhf{}
\fancyfoot[RO,LE]{\thepage}
}

\begin{document}

\chapter{Cap}
\section{Sec}
\lipsum[1-90]

\end{document}
3
  • Thanks, but now the page numbers in the first page of the chapters stays in the middle
    – SamuelNLP
    Commented Sep 2, 2013 at 5:15
  • @SamuelNLP Of course, you have to redefine the plain style. Commented Sep 2, 2013 at 5:15
  • @SamuelNLP please see my updated answer for an example of such a redefinition. Commented Sep 2, 2013 at 5:18

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .