Page Layout ⇒ odd and even chapter headings
odd and even chapter headings
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!
Learn LaTeX easily with newest books:
The LaTeX Beginner's Guide: 2nd edition and perfect for students writing a thesis
The LaTeX Cookbook: 2nd edition full of practical examples for mathematics, physics, chemistry, and more
LaTeX Graphics with TikZ: the first book about TikZ for perfect drawings in your LaTeX thesis
- localghost
- Site Moderator
- Posts: 9202
- Joined: Fri Feb 02, 2007 12:06 pm
odd and even chapter headings
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¹
Board Rules
Avoidable Mistakes
¹ System: TeX Live 2025 (vanilla), TeXworks 0.6.10