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!
Page Layout ⇒ odd and even chapter headings
NEW: TikZ book now 40% off at Amazon.com for a short time.
- localghost
- Site Moderator
- Posts: 9202
- Joined: Fri Feb 02, 2007 12:06 pm
odd and even chapter headings
A often underestimated package concerning page styles is titlesec. With this packages headers according your ideas are very easy. Consider the following example.
Adapt the page styles to your needs. The manual will show you how to do that.
Best regards
Thorsten¹
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}
Best regards
Thorsten¹
How to make a "Minimal Example"
Board Rules
Avoidable Mistakes
¹ System: TeX Live 2025 (vanilla), TeXworks 0.6.10
Board Rules
Avoidable Mistakes
¹ System: TeX Live 2025 (vanilla), TeXworks 0.6.10