Makro zum Einfügen von Inhalten in den Anhang

Makro zum Einfügen von Inhalten in den Anhang

Ich versuche, ein Makro zu schreiben, um Beweise für Theoreme durch Festlegen einer Variablen in den Anhang hinein und wieder hinaus zu setzen.

Ich weiß, wie man Folgendes macht: Im folgenden Beispiel geht der Beweis in einen neuen Abschnitt (Abschnitt 2), wenn ich die Variable appendixenabled auf 1 setze. Wenn sie auf 0 gesetzt ist, ist der Beweis inline.

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

Stattdessen muss ich den Beweis in einen Anhangsabschnitt an das Ende des Dokuments verschieben. Wenn ich jedoch die Umgebung toappendix (im Paket apxproof) wie folgt hinzufüge, erhalte ich einen Kompilierungsfehler. Irgendeine Idee?

\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

Der Fehler:

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

verwandte Informationen