宣言の前にステートメントを言い換える
TLDR
付録に汚いが必要なすべての「見出語/証明」を投げて、本文でそれらを言い換えるにはどうすればよいですか?
何度か試してみましたが、リクエストがおかしいようでした。質問する前に少し説明しておきます。
私は数学の論文を書いています。私は数学の引数を書くことをコードを書くことと見なしています。ステートメントは「関数」であり、証明は肉体です。完全を期すために、必要なだけの証拠を含めたいと思います。ただし、引数の構造は線形ではないため、線形にしないと、読みやすさが大幅に低下します。したがって、付録で汚いものを隠し、メインテキストでdef / thm / proofを引用したいと思います。
理想的には、疑似texコードは次のようになります。
Section 1
#call{main-theorem}
% nothing input here.
#endcall
.
.
Section 10
.
.
Appendix
#theorem[callable]{main-theorem}
2-1=1.
#end-theorem
これを達成するために、@ Bernardはthmtools
[1]で私に指摘しました。本当にやりたいことを実現するためにエラーが発生しましたが、メイントピックではないので、ここで新しい質問をします。
最小限の例
以下は、(ほぼ)機能する最小限の例です。
\documentclass{article}
\usepackage{thmtools, thm-restate}
\declaretheorem{theorem}
\begin{document}
%\firsteuclid*
%%% Uncommenting the above causes an error:
%%% > ! Undefined control sequence.
%%% > l.7 \firsteuclid
\begin{restatable}[Euclid]{theorem}{firsteuclid}
\label{thm:euclid}
$$1+1 = 2.$$
\end{restatable}
\firsteuclid* % This, however, works fine.
\end{document}
正しくコンパイルされます。しかし、私はそれが述べられる前に私が最初に電話をかけることができることを望み\firsteuclid*
ます。試行は失敗します。コメント行のコメントを外すことで、それを複製できます。
もちろん、回避策の1つは、その制限を受け入れ、[2]のようにステートメントを宣言することです。しかし、ダーティコードをすべてソースファイルにグループ化できることも願っています。これにより、将来、次の論文でそれらを使用したいときに、私の生活がはるかに楽になります。繰り返しになりますが、良いコードを書いて、何度も使用するというアナロジーが成り立ちます。
質問
付録に汚いが必要なすべての「コード」を投げて、本文でそれらを言い換えるにはどうすればよいですか?
参照
[3]また関連している..私の別の試みセクションの提示を遅らせる
回答
これが概念実証です。
\documentclass{article}
\usepackage{amsthm}
\ExplSyntaxOn
\NewDocumentCommand{\theoremstatement}{m m}
{% #1 = label, #2 = theorem type
\use:e
{
\exp_not:N \begin{#2}
\prop_item:Nn \g_student_theorems_statements_prop { #1 }
\exp_not:N \end{#2}
}
\prop_gput:Nnx \g_student_theorems_numbers_prop { #1 } { \thethm }
}
\NewDocumentEnvironment{delayedtheorem}{m m +b}
% #1 = label, #2 = theorem type, #3 = theorem statement
{
\cs_set:Npx \thethm { \prop_item:Nn \g_student_theorems_numbers_prop { #1 } }
\begin{#2}#3\end{#2}
\iow_now:Nn \g_student_theorems_statements_iow
{
\studentpropgput { g_student_theorems_statements_prop } { #1 } { #3 }
}
}{}
\cs_new_eq:NN \studentpropgput \prop_gput:cnn
\iow_new:N \g_student_theorems_statements_iow
\prop_new:N \g_student_theorems_statements_prop
\prop_new:N \g_student_theorems_numbers_prop
\AtBeginDocument
{
\file_if_exist_input:n { \c_sys_jobname_str.thm }
\iow_open:Nn \g_student_theorems_statements_iow { \c_sys_jobname_str.thm }
}
\ExplSyntaxOff
\newtheorem{thm}{Theorem}[section]
\newtheorem{lem}[thm]{Lemma}
\begin{document}
\section{First}
\begin{thm}
This is a normal theorem.
\end{thm}
\begin{proof}
Which has a proof.
\end{proof}
\theoremstatement{A}{thm}
\section{Second}
\theoremstatement{B}{lem}
\appendix
\section{Statements and proofs}
\begin{delayedtheorem}{A}{thm}
This is a theorem whose proof is in the appendix.
\end{delayedtheorem}
\begin{proof}
And its proof.
\end{proof}
\begin{delayedtheorem}{B}{lem}[With name]
A boring lemma.
\end{delayedtheorem}
\begin{proof}
Even more boring proof.
\end{proof}
\end{document}
