घोषणा से पहले बयानों को पुनर्स्थापित करें
TLDR
परिशिष्ट में सभी गंदे लेकिन आवश्यक "लेम्मा / प्रमाण" कैसे फेंकें, और उन्हें मुख्य पाठ में पुनर्स्थापित करें?
मेरे पास कुछ प्रयास थे, और ऐसा लगता था कि मेरे अनुरोध अजीब हैं .. इसलिए मैं सवाल पूछने से पहले थोड़ा समझाता हूं।
मैं गणित का पेपर लिख रहा हूं। मैं गणित के तर्कों को लेखन कोड के रूप में देखता हूं: कथन "कार्य" हैं और सबूत मांस हैं। पूर्णता के लिए, मैं जितना चाहे उतना प्रमाण शामिल करना चाहता हूं। हालाँकि, चूंकि तर्क की संरचना रैखिक नहीं है, इसलिए बड़े पैमाने पर ऐसा करने से पठनीयता घट जाती है। इसलिए, मैं परिशिष्ट में गंदी चीजों को छिपाना चाहता हूं, और अपने मुख्य पाठ में डिफ / thm / प्रूफ को उद्धृत करता हूं।
आदर्श रूप में, एक छद्म टेक्स कोड निम्नानुसार दिखना चाहिए।
Section 1
#call{main-theorem}
% nothing input here.
#endcall
.
.
Section 10
.
.
Appendix
#theorem[callable]{main-theorem}
2-1=1.
#end-theorem
इसे प्राप्त करने के लिए, @ बर्नार्ड ने 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*यह कहा गया है। एक प्रयास विफल। आप टिप्पणी लाइन को अनइंस्टॉल करके इसे दोहरा सकते हैं।
एक काम के आसपास, ज़ाहिर है, इसकी सीमा को स्वीकार करना है, और बयानों को वैसे भी घोषित करना है जैसा कि [2] में है। लेकिन मुझे यह भी उम्मीद है कि गंदे कोड सभी को स्रोत फ़ाइल में एक साथ समूहीकृत किया जा सकता है। यह भविष्य में मेरे जीवन को बहुत आसान बना देगा, जब मैं उन्हें अपने अगले पेपर में उपयोग करना चाहता हूं .. फिर से, सादृश्य रखता है: आप अच्छे कोड लिखते हैं, और उन्हें बार-बार उपयोग करते हैं।
सवाल
परिशिष्ट में सभी गंदे लेकिन आवश्यक "कोड" कैसे फेंकें, और उन्हें मुख्य पाठ में पुनर्स्थापित करें?
संदर्भ
[३] साथ ही संबंधित .. मेरा एक और प्रयास एक खंड प्रस्तुत करने में देरी
जवाब
यहाँ अवधारणा का प्रमाण है।
\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}