apxproof icon indicating copy to clipboard operation
apxproof copied to clipboard

A redundant proof section appears when the appendix is not inline

Open ericpony opened this issue 3 years ago • 2 comments

Hello, I seemed to bump into a bug. Here is a minimal working example:

\documentclass{article}
\usepackage{apxproof}
\newtheoremrep{theorem}{Theorem}
\newtheoremrep{proposition}{Proposition}
\author{Author}
\begin{document}
\title{Title}
\maketitle
\section{A Section}
\begin{propositionrep}
This is a proposition
\end{propositionrep}
\begin{proof}
This is a proof
\end{proof}
\section{Another Section}
This is a section without proofs
\begin{toappendix}
\section{Appendix Section}
\end{toappendix}
\end{document}

The above code works fine. But if I change \section{Appendix Section} to \include{appendix}, an empty section "B Proofs for Section 2 (Another Section)" will be created in the appendix even though Section 2 has no proofs. Cheers!

ericpony avatar Dec 06 '22 17:12 ericpony

Thanks for your bug report. I am aware of the issue, but this is something that is not easily fixable: the current behavior is as follows:

  • if \nosectionappendix is used, no section is created in the appendix;
  • if there is no appendix material at all within a \section, no section is created in the appendix;
  • if there is a toappendix environment within a \section, apxproof first checks whether the very first command within the toappendix is a \section command; or whether it is an \input of a file whose very first command is a \section command; if such a \section command is found, no section is created in the appendix;
  • otherwise, a section is created in the appendix.

The special \input check already does kind of what you want, but for \input and not \include; I cannot do the exact same thing for \include, as \include has other side effects than simply reading the file (in particular, setting up a new .aux file) that are not easy to simulate. I would have to think whether there is a better way to handle this.

That being said, the following two workarounds should work for you:

  1. If you actually don't need the extra features of \include, use \input (which is usually more versatile anyway).
  2. Otherwise, just put \nosectionappendix after the \section for which no section in appendix should be produced.

Please let me know whether these workarounds are ok for you.

PierreSenellart avatar Dec 06 '22 23:12 PierreSenellart

@PierreSenellart Thanks a lot for the explanations and workarounds! Using \input instead of \include works for me. By the way, I just noticed that newlines before the first \section or \input in the toappendix environment also lead to a redundant section:

\begin{toappendix}

\section{Appendix Section}
\end{toappendix}

Perhaps you can skip newlines when you check the first command? Anyway, thank you again for creating this convenient package :-)

ericpony avatar Dec 07 '22 00:12 ericpony