# Fancyhdr for books

I get confused with fancyhdr. Let's consider this minimal example:

\documentclass{book}
\usepackage{fancyhdr}
\usepackage{lipsum}

\pagestyle{fancy}

\begin{document}
\frontmatter
\title{A dummy document}
\author{John Doe}
\maketitle
\tableofcontents
\section{Abstract}
\lipsum{2}
\mainmatter
\chapter{Foo}
\section{Neo}
\lipsum{8-12}
\section{Trinity}
\lipsum{13-20}
\chapter{Bar}
\section{Morpheus}
\lipsum{21-25}
\backmatter
\section{Appendix}
\lipsum{26}
\end{document}


I can note different header/footer styles:

1. Empty (title page)
2. No headers + header line + page number in roman (after title page)
3. No headers + page number in roman (page with tableofcontents)
4. Headers + page number in roman (other pages in frontmatter)
5. No headers + page number in arabic (chapter pages)
6. Headers + page numbers in arabic (other pages in mainmatter)

I don't really understand (2) and (3). How can I configure all these different configurations?

If I add the following it doesn't affect the titlepage, the chapter pages and the numbering type:

\fancyhead{}


How can I configure fancyhdr to:

• Remove headers/footers on empty pages?
• Configure header/footers on chapter pages?
• Configure header/footers on other pages?
• Well, (2) is a "normal" page but since there hasn't been any \chapter yet the headers are empty. (3) is a normal plain page like (5). But I haven't used fancyhdr in eons so I can't really write an answer... But as far as the first question goes, there is the emptypage package. Aug 3, 2020 at 8:41

## Remove headers and footers on empty pages

The first question is not about fancyhdr is the behavior of \cleardoblepage. In order to remove headers and footers on empty pages I use the following code in the preamble:

\makeatletter
\def\cleardoublepage{\clearpage\if@twoside \ifodd\c@page\else
\vspace*{\fill}
\thispagestyle{empty}
\newpage
\if@twocolumn\hbox{}\newpage\fi\fi\fi}
\makeatother


## Configure headers and footers on chapter pages

\chapter resets the page style to plain by default. If you want to change the style of this page, try:

\chapter{Foo}
\thispagestyle{fancy}


## Headers and footers in other pages

An example on how to modify headers and footer on other pages:

\pagestyle{fancy}

for this part you need to read a little more, because is difficult to make an example to illustrate every aspect of fancyhdr. Try something basic or the manual.