1

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}
\fancyhead{} % clear the headers
\fancyhead[L]{\nouppercase{\leftmark}}
\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.

2

Replace \chaptername by \@chapapp:

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

Example:

\documentclass{report}
\usepackage[toc,page]{appendix}
\usepackage{fancyhdr}
\pagestyle{fancy}
\fancyhead{} % clear the headers
\fancyhead[L]{\nouppercase{\leftmark}}
\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}
| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.