2

The header of my appendix is writing "appendix 6" instead of "appendix M"enter image description here

All other appendix headings are writing letters (A-L), so I don't understand why it has suddenly changed. enter image description here

Even the toc says the appendix is called "M" - so why does the heading say "appendix 6"? enter image description here

When I try to create a minimal working example to put in this question, the problem does not arise. So I am really confused. Does anyone have any idea what I am doing wrong?

Here is a MWE. The Main document:

\documentclass[11pt,a4paper,openright,twoside]{report}

    \usepackage{amsmath}                            
    \usepackage{amssymb}                                  
    \usepackage{booktabs}
    \usepackage[toc,page]{appendix}
    \usepackage{pdfpages}
    \usepackage{array}
    \usepackage{fancyhdr}                               
    \pagestyle{fancy} 

    \def\layout{2}  
    \ifnum\layout=2 
        \fancyhf{}      
        \renewcommand{\headrulewidth}{0pt}
        \renewcommand{\chaptermark}[1]{\markboth{#1}{}}
        \fancyhead[LE]{\nouppercase{{\color{gray}\chaptername~ \thechapter}~ |~ \leftmark}}
        \fancyhead[RO]{\nouppercase{ \rightmark}}
        \fancyfoot[RO,LE]{\thepage}
        \fancyfoot[LO]{\includegraphics[width=5cm]{figure/auxiliary/DTUbioengineering.png}}
        \fancypagestyle{plain}{         
        \fancyhf{}
        \fancyfoot[R]{\thepage}}
     \else          
        \renewcommand{\headrulewidth}{0pt}
        \fancyhf{}                  
        \fancyhead[C]{\nouppercase{ \leftmark}}
        \fancyfoot[C]{\thepage}
    \fi


    \begin{document} 

    \tableofcontents

    \renewcommand\chaptername{Appendix}
    \input{Appendices.tex}

    \end{document}

And the appendices:

\begin{appendices}
\addtocontents{toc}{\protect\setcounter{tocdepth}{1}}
\makeatletter
\addtocontents{toc}{%
  \begingroup
  \let\protect\l@chapter\protect\l@section
  \let\protect\l@section\protect\l@subsection
}
\makeatother

\chapter{The first appendix}

\chapter{The second appendix}

\blindtext

\blindtext

\blindtext

\blindtext

\blindtext
\blindtext

\addtocontents{toc}{\endgroup}
\end{appendices}
  • 2
    It's quite hard to say what is going on here with just a few pictures of the output. We would need to see the code that produced this. I realise that it is going to be quite time consuming to come up with an MWE in this case, but it is your best shot at getting a useful answer. You can copy your current document to a new folder and delete stuff until the issue disappears, then you add as much code as necessary to get the issue to resurface. That should make it possible to produce a minimal example. – moewe Aug 20 '18 at 10:41
  • 1
    (1) Welcome, (2) Without code, not really. are you messing with \thechapter anywhere? – daleif Aug 20 '18 at 10:41
  • 1
    Okay. I'll try that. – Camilla Aarup Kristensen Aug 20 '18 at 11:14
  • 1
    Feel free to wrap everything up needed to build this into a ZIP file and send it to daleif@math.au.dk, then I'll have a look at it off site. BTW like on FB or twitter, if you use @<name> then they'll get an notification that you answered them – daleif Aug 20 '18 at 11:29
  • 2
    Oh, please try to reproduce this in a minimal example. This really should not happen. If this is a bug it can be helpful for other people if we manage to identify and report it. – moewe Aug 20 '18 at 12:07
2

appendix's appendices environment restores the previous chapter number at \end{appendices}. That means that the chapter number might be wrong for the header.

The issue can be reproduced in

\documentclass[11pt,a4paper,twoside]{report}
\usepackage{appendix}
\usepackage{fancyhdr}

\pagestyle{fancy}
\fancyhead{\thechapter}

\usepackage{kantlipsum}

\begin{document} 

\tableofcontents

\begin{appendices}
\chapter{The first appendix}
Lorem

\chapter{The second appendix}
\kant[1-8]
\end{appendices}
\end{document}

A work-around would be to add \clearpage or maybe even \cleardoublepage just before \end{appendices}

\begin{appendices}
\chapter{The first appendix}
Lorem

\chapter{The second appendix}
\kant[1-8]
\cleardoublepage
\end{appendices}

But maybe you can just get away with using \appendix instead of \begin{appendices}...\end{appendices}.

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.