Page Layoutdifferent header for odd and even page of oneside report

Information and discussion about page layout specific issues (e.g. header and footer lines, page formats, page numbers).
Post Reply
spiegboy
Posts: 120
Joined: Thu Dec 06, 2007 9:58 am

different header for odd and even page of oneside report

Post by spiegboy »

Hi, I wonder if there is a way to set different headers for even and odd pages of report class with 'oneside' option. I know fancyhdr can do this but for 'twoside' options.

Many thanks.
Last edited by spiegboy on Sun Jul 18, 2010 3:00 am, edited 1 time in total.

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

User avatar
localghost
Site Moderator
Posts: 9202
Joined: Fri Feb 02, 2007 12:06 pm

different header for odd and even page of oneside report

Post by localghost »

The most obvious solution to me seems to check whether the »page« counter is odd or even and then create a suitable header. This can be done with structures provided by the ifthen package as shown in the code below.

Code: Select all

\documentclass[11pt,a4paper,english]{report}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{babel}
\usepackage{fancyhdr,ifthen}
\usepackage{blindtext}

% Setup for headers and footers (fancyhdr)
\fancyhf{}
\lhead{\ifthenelse{\isodd{\value{page}}}{\rightmark}{\leftmark}}
\rhead{\thepage}
\pagestyle{fancy}

\begin{document}
  \blinddocument
\end{document}
Compare the header content by just replacing the »fancy« page style with the »headings« style.


Thorsten
spiegboy
Posts: 120
Joined: Thu Dec 06, 2007 9:58 am

Re: different header for odd and even page of oneside report

Post by spiegboy »

Absolutely brilliant!

Many thanks.
Post Reply