我正在尝试编写一个宏,通过设置变量将定理证明放入和移出附录。
我知道如何执行以下操作:在下面的示例中,当我将变量 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}
相反,我需要将 proof 移至文档末尾的附录部分。但是,如果我按如下方式添加 toappendix 环境(在 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.
<*>