[Tex/LaTex] Chapter-specific headers using fancyhdr

fancyhdrheader-footer

I would like to use the fancyhdr package to format the headers for my dissertation, and I'm running into some problems.

For the introduction, I would like the even pages to have the page number and the word Introduction on the left-hand side, and for the odd pages, I would like to have the same thing (but the order transposed) on the right-hand side.

However, the remaining chapters have sections, so I would like to format them differently. I want the page number followed by Chapter name on the left-hand side of every even page, and the Section name followed by the page number on the right-hand side of every odd page.

This is a minimal example:

\documentclass[twoside]{report}
\usepackage{fancyhdr}
...
\fancyhead[LE]{\thepage\qquad Introduction}
\fancyhead[RO]{Introduction\qquad\thepage}
\fancyfoot[CE,CO]{}
\renewcommand{\footrulewidth}{0pt}
\renewcommand{\headrulewidth}{0pt}
\chapter{Introduction}
\pagestyle{fancy}
...
\renewcommand{\chaptermark}[1]{\markboth{#1}{}}
\renewcommand{\sectionmark}[1]{\markright{#1}{}}
\fancyhead[LE]{\thepage\qquad\thechapter .~\leftmark}
\fancyhead[RO]{\thesection~\rightmark\qquad\thepage}
\fancyfoot[CE,CO]{}
\renewcommand{\footrulewidth}{0pt}
\renewcommand{\headrulewidth}{0pt}
\chapter{Background}
\pagestyle{fancy}
...

However, the last page of the Introduction has a header that corresponds to what the header for the next chapter should be.

Any suggestions would be appreciated…thanks!!

Best Answer

The style is applied to the current page. So you need to clear the page first. This is done by \clearpage (end current page) or \cleardoublepage(clear current page and optionally add a blank page so that the next page with content is an odd page), depending on whether your chapters can start on any page or always start on an odd page.