如何重复定理编号?

如何重复定理编号?

在我的论文中,我经常在引言中提到一些定理,这些定理会在后面的部分中得到更详细的介绍和证明。

我想两次包含这些定理的陈述,每次都进行编号,因为该定理会自然地出现在其后面的部分中。

我当前的解决方案(使用 amsthm)是,例如

%(in the introduction)
\newtheorem*{thm:associativity}{Theorem \ref{thm:associativity}}
\begin{thm:associativity}
Lorem ipsum ...
\end{thm:associativity}

%(in a later section)
\begin{thm}
\label{thm:associativity}
Lorem ipsum ...
\end{thm}

有人能想到一个更清洁的解决方案吗?

答案1

如果您想让自己在两次出现之间改变文本,这里有一个替代方法:

\documentclass{article}

\usepackage{amsthm}

\makeatletter
\newtheorem*{rep@theorem}{\rep@title}
\newcommand{\newreptheorem}[2]{%
\newenvironment{rep#1}[1]{%
 \def\rep@title{#2 \ref{##1}}%
 \begin{rep@theorem}}%
 {\end{rep@theorem}}}
\makeatother


\newtheorem{theorem}{Theorem}
\newreptheorem{theorem}{Theorem}
\newtheorem{lemma}{Lemma}
\newreptheorem{lemma}{Lemma}

\begin{document}

\begin{reptheorem}{myAmazingTheorem}
That theorem again
\end{reptheorem}

\begin{theorem}
\label{myAmazingTheorem}
A theorem
\end{theorem}
\begin{lemma}
\label{anInsignificantLemma}
A lemma
\end{lemma}

\begin{replemma}{anInsignificantLemma}
That theorem again
\end{replemma}


\end{document}

可能需要稍微调整一下以适应不同的定理风格等等。

答案2

那么 thmtools 套件怎么样?请查看第 6 页导游:有一个“可重述”的环境。

答案3

这是一个我喜欢的解决方案,尽管它不是很聪明。你只需暂时重新定义\thetheorem(或者在你的情况下为\thethm):

% in the introduction
{
\renewcommand{\thetheorem}{\ref{thm:associativity}}
\begin{theorem}
  Lorem ipsum ...
\end{theorem}
\addtocounter{theorem}{-1}
} % note: these braces are here to take advantage of LaTeX scoping ... 
  % \thetheorem is returned to its rightful definition outside of this group

% elsewhere
\begin{theorem} \label{thm:associativity}
  Lorem ipsum ...
\end{theorem}

你也可以按照同样的原则定义环境

% repeat theorems, with amsthm 
% args = type,counter,reference
\newenvironment{repthm}[3] 
{ 
  \bgroup 
  \addtocounter{#2}{-1} 
  \expandafter\def\csname the#2\endcsname{\ref{#3}} 
  \def\foo{\end{#1}} 
  \begin{#1} 
} 
{ 
  \foo 
  \egroup 
} 

答案4

一个有点“粗略”的解决方案:Ulrich Diez 有一个名为 theomac.sty 的软件包,它在网上流传,但不在 CTAN 上,我以前用过一次。我知道的最新版本包含字符串“2007/06/18 v1.00beta4 Define macros from theorems”,可以在讨论中找到这里或者这里(或旧版本Google 群组在哪里可以下载它)。 你可以按如下方式使用它:

\usepackage{theomac} %To repeat theorems
\newtheoremWithMacro{rtheorem}[theorem]{Theorem}

...

\begin{rtheorem}[\foo]
  $1 + 1 = 2$ 
\end{rtheorem}

(或者用任何名称代替rtheorem。)然后,您可以\foo在任何希望定理出现的地方书写,而不必重复主体。

相关内容