Page Layoutodd and even chapter headings

Information and discussion about page layout specific issues (e.g. header and footer lines, page formats, page numbers).
Post Reply
ruudvh
Posts: 5
Joined: Thu Feb 19, 2009 8:10 pm

odd and even chapter headings

Post by ruudvh »

Hi,
I'd like to use the fancyhdr package to have chapter info on both my odd and even page headers (using the book class).

I'd like the left page to say just 'Chapter 2' etc, and the right page to give just the name of the chapter, i.e. 'Sesame street'.

The problem is that fancyhdr only appears to allow one \chaptermark, so if i define it correctly for one page, I can't define it for the other page.

Is there any way to work around this?

Thanks!

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

odd and even chapter headings

Post by localghost »

A often underestimated package concerning page styles is titlesec. With this packages headers according your ideas are very easy. Consider the following example.

Code: Select all

\documentclass[11pt,a4paper,english]{book}
\usepackage[T1]{fontenc}
\usepackage[latin1]{inputenc}
\usepackage{babel}
\usepackage[bindingoffset=1cm,includeheadfoot,margin=2cm]{geometry}
\usepackage[pagestyles,raggedright]{titlesec}
\usepackage{blindtext}

\newpagestyle{front}{%
  \headrule
  \sethead[\thepage][][\bfseries\chaptertitle]{\bfseries\chaptertitle}{}{\thepage}
  \setfoot[][][]{}{}{}
}
\newpagestyle{main}{%
  \headrule
  \sethead[\thepage][][\bfseries\chaptername~\thechapter]{\bfseries\chaptertitle}{}{\thepage}
  \setfoot[][][]{}{}{}
}
\newpagestyle{back}{%
  \headrule
  \sethead[\thepage][][\bfseries\chaptertitle]{\bfseries\chaptertitle}{}{\thepage}
  \setfoot[][][]{}{}{}
}

\begin{document}
  \pagestyle{front}
  \tableofcontents
  \newpage
  \pagestyle{main}
  \Blinddocument
  \Blinddocument
  \Blinddocument
  \Blinddocument
  \Blinddocument
  \Blinddocument
  \Blinddocument
  \Blinddocument
  \Blinddocument
\end{document}
Adapt the page styles to your needs. The manual will show you how to do that.


Best regards
Thorsten¹
Post Reply