What I am trying to accomplish is a fancyhdr that places Appendix or Bibliography in the header with one single definition. So if I am in the bibliography it should display Bibliography, but should display Appendix otherwise.
\documentclass{report}
\usepackage{fancyhdr}
\usepackage{etoolbox}
\newcommand{\backmatter}{
\fancyhdr[C]{\ifstrequal{\leftmark}{\MakeUppercase{\bibname}}
{\bibname}{\appendixname\ \thechapter}}
\begin{document}
\backmatter
\bibliography{my.bib}
\appendix
\chapter{Appendix}
\end{document}
The ifstrequal always evaluates as false and so always produces Appendix in the header. Thank you in advance for your help.
EDIT: My new solution is as follows
\documentclass{report}
\usepackage{fancyhdr}
\usepackage{etoolbox}
\preptocmd{\bibliography}{\fancyhead[C]{\bibname}}{}{}
\preptocmd{\appendix}{\fancyhead[C]{\appendixname\ \thechapter}}{}{}
\begin{document}
\bibliography{my.bib}
\appendix
\chapter{Appendix}
\end{document}
However, when my bibliography hits the third page it displays Appendix again.
Edit 2: The following works
\documentclass{report}
\usepackage{fancyhdr}
\usepackage{etoolbox}
\preptocmd{\bibliography}{\cleardoublepage \fancyhead[C]{\bibname}}{}{}
\preptocmd{\appendix}{\cleardoublepage \fancyhead[C]{\appendixname\ \thechapter}}{}{}
\begin{document}
\bibliography{my.bib}
\appendix
\chapter{Appendix}
\end{document}
\preptocmdshould be\pretocmdI think (2x)... – Matthias May 6 '12 at 11:11