# fancyhdr with the appendix package

When writing reports, I like to use the fancyhdr package for headers and the appendix package for appendices, but I have run into a small issue with compatibility. Consider the following:

\documentclass{report}
\usepackage[toc,page]{appendix}
\usepackage{fancyhdr}
\pagestyle{fancy}
\renewcommand{\chaptermark}[1]{\markboth{\chaptername\ \thechapter\ -- #1}{}}

\begin{document}
\chapter{The first chapter}
The main body text.
\newpage
This second page has a header.

\begin{appendices}

\chapter{The first appendix}
Appendix text.
\newpage
This second page has a header.

\end{appendices}

\end{document}


If one were to typeset the above, one would find that the second page of the appendix has a header that says "Chapter A - The first appendix".

How could one change the above code, so that it would say "Appendix A - The first appendix" instead (the headers in the main body remaining the same)?

Many thanks.

Replace \chaptername by \@chapapp:

\makeatletter
\renewcommand{\chaptermark}[1]{\markboth{\@chapapp\ \thechapter\ -- #1}{}}
\makeatother


Example:

\documentclass{report}
\usepackage[toc,page]{appendix}
\usepackage{fancyhdr}
\pagestyle{fancy}
\makeatletter
\renewcommand{\chaptermark}[1]{\markboth{\@chapapp\ \thechapter\ -- #1}{}}
\makeatother

\begin{document}
\chapter{The first chapter}
The main body text.
\newpage
This second page has a header.

\begin{appendices}
\chapter{The first appendix}
Appendix text.
\newpage
This second page has a header.
\end{appendices}
\end{document}