# The appendix word disappears from the table of contents when using \include

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:

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

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

## 2 Answers

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.

• It would not be nice use it like that. – user Oct 20 '19 at 20:58
• @user Why not? It seems simpler than your solution and is generally applicable to cases other than yours. – Peter Wilson Oct 21 '19 at 17:06
• Because instead of typing it only one time, I would have to type the same thing every include. – user Oct 21 '19 at 17:24

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}