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
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.

  • 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
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

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.