18

I wanted to put the title of the chapter on even header and the title of the section of the chapter to the odd pages.

My headers are now are using this code:

 \begin{document}

\frontmatter % Use roman page numbering style (i, ii, iii, iv...) for the pre-content pages

\setstretch{1.3} % Line spacing of 1.3

% Define the page headers using the FancyHdr package and set up for one-sided printing
\fancyhead{} % Clears all page headers and footers
\rhead{\thepage} % Sets the right side header to show the page number
\lhead{} % Clears the left side page header

\pagestyle{fancy} % Finally, use the "fancy" page style to implement the FancyHdr headers

Moreover, chapters are in separate files and called in a main file.

1 Answer 1

18

You can simply use the selectors E and O for even and odd pages. Here is a MWE:

\documentclass{book}
\usepackage{lipsum}
\usepackage{fancyhdr}

\fancyfoot{}
\fancyhead[RO,LE]{\thepage}
\fancyhead[LO]{\leftmark}
\fancyhead[RE]{\rightmark}

\begin{document}

\pagestyle{fancy}

\chapter{Chapter}
\section{section}

\lipsum
\lipsum

\end{document}

Here is the output: enter image description here

You can modify the way chapter and section are displayed by redefining \chaptermark and \sectionmark.

4
  • I used it but nothing happen.
    – ali amidi
    Jan 12, 2013 at 16:53
  • 1
    This works for me, but only for some pages... Jun 13, 2015 at 22:25
  • This only worked for me if i set \documentclass[twoside]. Oct 20, 2019 at 2:17
  • @Corentin Is there a way to have this headline with lowercase? I am trying to avoid the Uppercase in the headline it does not work. In fact, my titles in the text are not in uppercases.
    – Guy Fsone
    Nov 22, 2019 at 0:57

You must log in to answer this question.

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