PierreSenellart / apxproof

LaTeX package for automatically putting proof environments in appendix
LaTeX Project Public License v1.3c
23 stars 8 forks source link

Appendix section number if using chapters #42

Closed miguelbper closed 3 years ago

miguelbper commented 3 years ago

Hello,

I would like to use the apxproof package in a document which is sectioned with chapters (and possibly parts).

I would like all appendix sections generated by apxproof to be part of a chapter, let's say chapter "A", and then each section would be named "A.1 Proofs for Section ... ". What I'm obtaining instead is ".1 Proofs for Section ...".

Is there a workaround for this?

Here are pictures of the behaviour I'm obtaining as well as the code I'm using: image image image

\documentclass{report}
\usepackage[utf8]{inputenc}

\usepackage[bibliography=common]{apxproof}

\BeforeBeginEnvironment{appendices}{\edef\TheChapter{\thechapter}}
\AtBeginEnvironment{appendices}{\renewcommand\thesection{\TheChapter.\Alph{section}}}

\renewcommand{\appendixprelim}{
    \clearpage\onecolumn
    \appendix\chapter{Proofs of the theorems in the main text}
    %\section{testsection}
}

\usepackage{amsthm}

\theoremstyle{plain}
    \newtheoremrep{theorem}{Theorem}[chapter]

\usepackage{hyperref}
    \hypersetup{
        bookmarksnumbered=true,
        colorlinks=true,
        linkcolor=blue
    }

\begin{document}

\tableofcontents

\chapter{the first chapter}

\section{the first section}
\begin{toappendix}
    \label{apx:the first section}
\end{toappendix}

\begin{theoremrep}
    This is a theorem.
\end{theoremrep}
\begin{inlineproof}
    See \ref{apx:the first section}.
\end{inlineproof}
\begin{proof}
    This is the actual proof of the theorem, which will show up in the appendix.
\end{proof}

\end{document}
PierreSenellart commented 3 years ago

This is because \appendixprelim is executed before the \appendix command. So there will be two \appendix in a row, and the chapter counter will be reset.

I suggest the following instead, which adds the \chapter command just after the \appendix command, and does not require any change to apxproof:

\renewcommand{\appendixprelim}{\clearpage\onecolumn}
\apptocmd{\appendix}{\chapter{Proofs of the theorems in the main text}}{}{}
miguelbper commented 3 years ago

Thanks! For the answer and the package.