Macro para poner cosas en el apéndice.

Macro para poner cosas en el apéndice.

Estoy intentando escribir una macro para incluir pruebas de teoremas dentro y fuera del apéndice estableciendo una variable.

Sé cómo hacer lo siguiente: en el siguiente ejemplo, cuando configuro la variable appendixenabled en 1, las pruebas van a una nueva sección (sección 2). Además, si se establece en 0, entonces la prueba está en línea.

\documentclass{article}[11pt]

\usepackage{amsthm, amsmath}
\usepackage{cleveref}
\usepackage[appendix=append]{apxproof}
\usepackage{thmtools, mathtools, thm-restate}\newtheorem*{theorem*}{Theorem}
\newtheorem{fact}{Fact}[section]
\newtheorem{lemma}{Lemma}[section]
\newtheorem{theorem}[lemma]{Theorem}
\renewenvironment{proof}{\smallskip\noindent{\bf Proof:}}%
        {\hspace*{\fill}\par}


% =========================================================
%                       Appendix stuff
% =========================================================
\newcommand{\myproof}[4]{
% 1: name of the environment
% 2: command 
% 3: label  of the theorem
% 4: proof
    \begin{proof}
        #4  
    \end{proof}
}
\def\appendixenabled{1}
% Switch to 0 to make the proofs inline
\if\appendixenabled1
    \renewcommand{\myproof}[4]{
    The proof is provided in Appendix~\ref{sec:proofof#3}
    \section{Proof of #1~\ref{#3}}
        \label{sec:proofof#3}
        \begin{proof}
            #4  
        \end{proof}
    }
\fi
% =========================================================

\begin{document}
\section{One}

\begin{restatable}{theorem}{aaa}
    \label{thmLabel}
    This is a resettable theorem!
\end{restatable}



\myproof{Theorem}{aaa}{thmLabel}{This is the proof.}
\end{document}

En lugar de eso, necesito mover la prueba al final del documento en una sección del apéndice. Sin embargo, si agrego el entorno del apéndice (en el paquete apxproof) de la siguiente manera, obtendré un error de compilación. ¿Alguna idea?

\if\appendixenabled1
    \renewcommand{\myproof}[4]{
    \begin{toappendix}
        The proof is provided in Appendix~\ref{sec:proofof#3}
        \section{Proof of #1~\ref{#3}}
        \label{sec:proofof#3}
        \begin{proof}
            #4  
        \end{proof}
    \end{toappendix}
    }
\fi

El error:

! FancyVerb Error:
  Extraneous input `The proof is provided in Appendix~\ref {sec:proofofthmLabel} \section {Proof of Theorem~\ref {thmLabel}} \label {sec:proofofthmLabel} \begin {proof} This is the proof. \end {proof} \end {toappendix} \end{document}' between \begin{toappendix}[<key=value>] and line end
.
\FV@Error ...ncyVerb Error:^^J\space \space #1^^J}

l.52 ...hmLabel}{This is the proof.}\end{document}

This input will be discarded. Hit <return> to continue.

)
Runaway argument?
! File ended while scanning use of \FancyVerbGetLine.
<inserted text> 
                \par 
<*> 

I suspect you have forgotten a `}', causing me
to read past where you wanted me to stop.
I'll try to recover; but if the error is serious,
you'd better type `E' or `X' now and fix your file.

! Emergency stop.
<*> 

información relacionada