0

If you compile the following minimal example which uses the abntex2 class, which is just a wrapper around memoir class:

\documentclass[
12pt,
]{abntex2}

\begin{filecontents*}{beauty.tex}
\chapter{Some first}
Content.
\end{filecontents*}

\begin{filecontents*}{appendix.tex}
\chapter{Other second}
Stuff.
\end{filecontents*}

\begin{document}
    \tableofcontents
    \include{beauty}
    % \chapter{Fixer}

    \begin{apendicesenv}
        \include{appendix}
    \end{apendicesenv}
\end{document}

You get this:

enter image description here

But if you uncomment the line % \chapter{Fixer}, then, the document is generated correctly, i.e., with the Appendix word on the right place:

enter image description here

How can I fix this behavior and keep the Appendix word always showing up in the table of contents regardless the contents of my file?


Related questions

  1. Keep "Appendix #" in the appendix title, but remove the appendix from the table of contents
  2. Word "Appendix" in ToC with memoir class
user
  • 4,745

2 Answers2

3

The apendicesenv environment should be within the include:

\begin{filecontents}{appendix.tex}
  \begin{apendicesenv}
    \chapter{Other second}
    Stuff
  \end{apendicesenv}
\end{filecontents}

I came across this kind of problem when developing the appendix package. I gave the solution in section 2.1 of the documentation but used a different description of the problem to that exhibited in the MWE.

Peter Wilson
  • 28,066
0

I managed to fix this by repopulating the appendix name variable:

\makeatletter
\@ifclassloaded{abntex2}{
  \renewcommand*{\cftappendixname}{\apendicename\space\space}
}{}
\makeatother

Full example:

\documentclass[
12pt,
]{abntex2}

\begin{filecontents*}{beauty.tex}
\chapter{Some first}
Content.
\end{filecontents*}

\begin{filecontents*}{appendix.tex}
\chapter{Other second}
Stuff.
\end{filecontents*}

\makeatletter
\@ifclassloaded{abntex2}{
  \renewcommand*{\cftappendixname}{\apendicename\space\space}
}{}
\makeatother

\begin{document}
    \tableofcontents
    \include{beauty}

    \begin{apendicesenv}
        \include{appendix}
    \end{apendicesenv}
\end{document}

enter image description here

user
  • 4,745