[Tex/LaTex] Headers on appendix

appendicesheader-footer

I can't find the solution to this problem. I did google it and nothing came out. My project has 3 chapters and the appendix, but as far as I used \chapter*{Ap\'endice} and so, the appendix page headers are the same as third's chapter (I assume this is why).

I want to have something like "Number (space) Apéndice" on even pages and "Apéndice (space) Number" on odd pages.

I already tried the afterpage package. \afterpage{\lhead{Ap\'endice} or \afterpage{\rhead{Ap\'endice}} modifies every page after that and since this is the book class with different even and odd pages headers, \lhead on even pages replaces the page number and the same with \rhead on odd pages. Is there any way to solve this out?

I would really appreciate your help.

I'm using fancyhdr package, I'm sorry I didn't made that clear before. Here's my code. As you would see when compile, page 4 (Appendix) header is Capítulo 1 instead of Ap\'endice.

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

\fancyhf{}
\renewcommand{\chaptermark}[1]{\markboth{#1}{}}
\renewcommand{\sectionmark}[1]{\markright{#1}}
\fancyhead[LE,RO]{\bfseries\thepage}
\fancyhead[LO]{\bfseries\rightmark}
\fancyhead[RE]{\bfseries\leftmark}
\fancypagestyle{plain}{\fancyhead{}\renewcommand{\headrulewidth}{0pt}}

\begin{document}

\chapter{Cap\'itulo 1}
\lipsum[1]
\chapter*{Ap\'endice}
\addcontentsline{toc}{chapter}{Ap\'endice: Teor\'ia de Grupos}
\addtocontents{toc}{\protect\setcounter{tocdepth}{0}}
\lipsum[2]. \newpage
\lipsum[3]
\end{document}

Best Answer

You can use the fancyhdr package and the command \fancyhead

\chapter*{Ap\'endice}
\fancyhead[LE,RO]{\thepage}
\fancyhead[RE]{Ap\'endice}
\fancyhead[LO]{Ap\'endice}

Edit: To clarify, you have to set a propper page style for this to work. Add

\pagestyle{fancy}

to the beginning of your document.

Alternatively, you can simply declare the chapter to be an appendix by stating

\appendix
\chapter{Name of the appendix}

Note that here I have used the standard \chapter command, not the \chapter* command. This will produce slightly different results, however, it might be a more robust (and in my opinion better) solution.

Related Question