![付録に内容を入れるマクロ](https://rvso.com/image/400388/%E4%BB%98%E9%8C%B2%E3%81%AB%E5%86%85%E5%AE%B9%E3%82%92%E5%85%A5%E3%82%8C%E3%82%8B%E3%83%9E%E3%82%AF%E3%83%AD.png)
変数を設定することで定理の証明を付録に出し入れするマクロを書こうとしています。
次の方法を知っている: 次の例では、変数 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 環境 (パッケージ 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.
<*>