Макрос для добавления чего-либо в приложение

Макрос для добавления чего-либо в приложение

Я пытаюсь написать макрос для помещения доказательств теорем в приложение и из него путем установки переменной.

Я знаю, как сделать следующее: В следующем примере, когда я устанавливаю переменную appendixenabled на 1, доказательства переносятся в новый раздел (раздел 2). Также, если она установлена ​​на 0, то доказательство встроено.

\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}

Вместо этого мне нужно переместить доказательство в конец документа в раздел приложения. Однако, если я добавлю toappendix environment (в пакете apxproof) следующим образом, я получу ошибку компиляции. Есть идеи?

\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

Ошибка:

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

Связанный контент