[Tex/LaTex] Remove or Change heading on certain Chapters

fancyhdrheader-footer

I have headings in all my chapters (on the top corner stating which chapter you are reading), however at the end of my document I have a chapter which is not numbered as my appendix and glossary. For these chapters the heading is the same as the last chapter numbered.

\chapter{Chapter 1}
\chapter*{Chapter 1}

For the first command the heading changes, however for the second command (chapters which are not numbered) it does not change. How can I change the heading for those chapters also?

My heading commands are:

\usepackage{fancyhdr}
\fancyhead[R]{
   \itshape
   \ifnum\value{chapter}>0 \fi \nouppercase
   \leftmark}
\fancyhead[L]{}
\fancyfoot[C]{\thepage}{}
\renewcommand{\headrulewidth}{0pt}

I have added

\chaptermark{...}

under the chapter which are unnumbered. This adds the name of the chapter to the header but I would like to remove the number.

Assuming that Ch 6 is my last chapter, Right now my header reads :

*Chapter 6. Title of chapter 6

Chapter 6. Glossary

Chapter 6. Appendix*

However, I would like to have :

*Chapter 6. Title of chapter 6 (Last chapter)

Glossary

Appendix*

Best Answer

You can emulate what the book class does by the command \backmatter, with some modifications.

\documentclass{report}
\usepackage{fancyhdr}

\newif\ifmainmatter
\mainmattertrue

\makeatletter
\newcommand{\backmatter}{%
  \mainmatterfalse
  \let\@makechapterhead\@makeschapterhead
  \renewcommand{\thechapter}{}%
}
\makeatother

\pagestyle{fancy}
\fancyhf{}
\fancyhead[R]{%
   \itshape
   \ifnum\value{chapter}>0 \ifmainmatter
     \chaptername\ \thechapter.\ 
   \fi \fi
   \nouppercase\leftmark
}
\fancyfoot[C]{\thepage}
\renewcommand{\headrulewidth}{0pt}
\renewcommand{\chaptermark}[1]{\markboth{#1}{}}

\begin{document}

\tableofcontents

\chapter{Introduction}

Something\newpage else

\chapter{First}

Something\newpage else

\backmatter

\chapter{Glossary}

Something\newpage else

\chapter{Appendix}

Something\newpage else

\end{document}
Related Question