有可能实现这样的事情吗:
\begin{theorm}
foo equal bar
\end{theorem}
\begin{proof}
\extern{lemma-fu}
With this, we will do … % A lot of text
\end{proof}
\begin{lemma}
\label{lemma-fu}
some statement
\end{lemma}
\begin{proof}
proof-of-lemma
\end{proof}
我想使用 imagine 命令\extern
将引理插入到定理证明中。verbdef
我可以反向操作——在定理证明中写出引理的公式,稍后再参考,但这在源代码中的可读性较差。
答案1
这是一个快速解决方案,它将引理保存到文件中。请注意,如果找不到引理,它不会发出任何警告。它需要两次 TeX 运行:
\documentclass[12pt]{minimal}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{amsthm}
\usepackage{environ,etoolbox}
\newtheorem{theorem}{Theorem}
\newtheorem{lemma}{Lemma}
\makeatletter
\NewEnviron{Lemma}[1]{
\protected@write\@mainaux{}{
\csgdef{\detokenize{Lemma@#1}}{\BODY}
}
\begin{lemma}\label{#1}
\BODY
\end{lemma}
}
\newcommand{\extern}[1]{\textbf{Lemma \ref{#1}:} \@nameuse{\detokenize{Lemma@#1}}}
\makeatother
\begin{document}
\begin{theorem}
foo equal bar
\end{theorem}
\begin{proof}
\extern{lemma:fu}
With this, we will do … % A lot of text
\end{proof}
\begin{Lemma}{lemma:fu}
A cool lemma.
\end{Lemma}
\begin{proof}
That is true!
\end{proof}
\end{document}