设置定理数和旁路计数器

设置定理数和旁路计数器

有时,我想重复一个定理,例如,如果证明放在附录中。在这种情况下,我希望这两个定理具有相同的编号,而不会影响计数器。有没有简单的方法可以实现这一点?

我基本上追求的是这个:

\documentclass[a4paper,11pt]{article}
\newtheorem{thm}{Theorem}
\begin{document}
\section{Main}
\begin{thm}
This is theorem 1
\end{thm}
\section{Appendix}
\subsection{Proof of theorem 1}
To prove this theorem we need another theorem:
\begin{theorem}
This is another theorem
\end{theorem}
\setcounter{thm}{0}
\begin{theorem}
This is theorem 1
\begin{proof}
The proof of this theorem follows theorem 2...
\end{proof}
\end{theorem}
\setcounter{thm}{2}
\end{document}

但无需手动跟踪计数器的移动距离。

答案1

怎么样?我定义了一个环境{repeatthm},它接受一个强制参数,该参数应该是被重复的定理的标签。重复定理标记自身Theorem \ref{#1}.(因此,如果引用未定义,它将显示为Theorem ??.

\documentclass{article}
\usepackage{amsthm}
\newtheorem{thm}{Theorem}

\makeatletter
\newtheorem{repeatthm@}{Theorem}
\newenvironment{repeatthm}[1]{%
    \def\therepeatthm@{\ref{#1}}
    \repeatthm@
}
{\endrepeatthm@}
\makeatother

\begin{document}
\section{Main}
\begin{thm}
This is thm 1
\end{thm}

\begin{thm}
\label{a-thm}
This is theorem 2
\end{thm}
\section{Appendix}
\subsection{Proof of thm 1}
To prove this theorem we need another theorem:
\begin{thm}
This is another theorem.
\end{thm}

\begin{repeatthm}{a-thm}
This is theorem 2 again.
\end{repeatthm}
\begin{proof}
The proof of this theorem follows thm 2...
\end{proof}

\begin{repeatthm}{unknown-thm}
This is a repeated theorem with an incorrect label.
\end{repeatthm}
\end{document} 

相关内容