所谓定理的重述,是这样的情况:在文章的某处,我们陈述了一个定理;接下来,我们在文章的其他地方,陈述了一个与之等价但叙述方式不同的定理。此时,如果第一个定理的编号是 Theorem 7,那么第二个的编号就应该是 Theorem 7'。 我们来观察一下这个需求,不难发现有以下特征:
- 原定理的位置不确定;
- 原定理的编号不确定;
- 重述定理的编号和原定理的编号相同,只不过多了一个撇(Prime)。
\newtheorem{thm}{Theorem}
\newenvironment{thmbis}[1]
{\renewcommand{\thethm}{\ref{#1}$'$}%
\addtocounter{thm}{-1}%
\begin{thm}}
{\end{thm}}
这里,我们用 \renewcommand 修改了计数器 thm 的显示方式 \thethm:首先对原定理做引用,然后加上一个撇。随后,在 thm 的当前值上减 1。这是因为,在之后的 \begin{thm} 中会给 thm 计数器自加 1,这里作为「补偿」,需要预先减去 1。
完整的例子可见:
\documentclass[a4paper]{article}
\newtheorem{thm}{Theorem}
\newenvironment{thmbis}[1]
{\renewcommand{\thethm}{\ref{#1}$'$}%
\addtocounter{thm}{-1}%
\begin{thm}}
{\end{thm}}
\begin{document}
\begin{thm}
$1+1=2$
\end{thm}
\begin{thm}\label{comm}
$a+b=b+a$
\end{thm}
\begin{thmbis}{comm}
$x+y=y+x$
\end{thmbis}
\begin{thm}
$0\ne0$
\end{thm}
\end{document}
效果图如下:
选自:http://liam0205.me/2015/09/12/primed-theorems/


发表评论 取消回复