附录

附录

我想在附录中证明我的所有定理。为此,我想通过在附录中重印定理来提醒读者定理是什么。

但是,我还没有找到一种方法来做到这一点,而不是直接复制粘贴。复制粘贴的问题是定理数完全不准确。例如:

在此处输入图片描述

有谁知道如何优雅地解决这个问题?

\documentclass{article}
\usepackage[utf8]{inputenc}

\usepackage{amsthm}     
\setlength\parindent{0pt}
\theoremstyle{definition}
\newtheorem{definition}{Definition}[section]

\theoremstyle{thm}
\newtheorem{thm}{Theorem}[section]
\newtheorem{lem}{Lemma}[section]
\newtheorem{prop}{Proposition}[section]
\newtheorem{cor}{Corollary}[section]
\newtheorem{conj}{Conjecture}[section]
\newtheorem{claim}{Claim}[section]

\theoremstyle{remark}
\newtheorem{remark}{Remark}[section]
\newtheorem{example}{Example}[section]

\newcommand{\thmautorefname}{Theorem}
\newcommand{\propautorefname}{Proposition}
\newcommand{\lemautorefname}{Lemma}
\newcommand{\corautorefname}{Corollary}
\newcommand{\conjautorefname}{Conjecture}
\newcommand{\claimautorefname}{Claim}


\begin{document}


\section{Introduction}

\begin{thm}
We'd like to introduce the \bfseries{theorem of the universe}, the theorem says that $1+1 = 2$
\end{thm}
This is a remarkable theorem indeed!

\section{Appendix}
In the Appendix, we will prove theorem

We will reprint the theorem here:

\begin{thm}
We'd like to introduce the \bfseries{theorem of the universe}, the theorem says that $1+1 = 2$
\end{thm}

\begin{proof}
2 - 1 = 1. 
\end{proof}


\bibliographystyle{plain}
\bibliography{references}
\end{document}

答案1

定义thmtools 定理restatable。下面是它的工作原理。顺便说一句,thm定理样式不存在,因为这是由 定义的thmtools。我想你指的是plain样式。此外,我必须注释掉 s autorefname,因为它们已经由 定义thmtools

\documentclass{article}
\usepackage[utf8]{inputenc}

\usepackage{amsthm,thmtools}%
\setlength\parindent{0pt}
\theoremstyle{definition}
\newtheorem{definition}{Definition}[section]

\theoremstyle{plain}
\declaretheorem[name=Theorem, numberwithin=section]{thm}
\declaretheorem[name=Lemma, numberwithin=section]{lem}
\declaretheorem[name=Proposition, numberwithin=section]{prop}
\declaretheorem[name=Corollary, numberwithin=section]{cor}
\declaretheorem[name=Conjecture, numberwithin=section]{conj}
\declaretheorem[name=Claim, numberwithin=section]{claim}

\theoremstyle{remark}
\newtheorem{remark}{Remark}[section]
\newtheorem{example}{Example}[section]

%\newcommand{\thmautorefname}{Theorem}
%\newcommand{\propautorefname}{Proposition}
%\newcommand{\lemautorefname}{Lemma}
%\newcommand{\corautorefname}{Corollary}
%\newcommand{\conjautorefname}{Conjecture}
%\newcommand{\claimautorefname}{Claim}

\begin{document}

\section{Introduction}

\begin{restatable}{thm}{universe}
We'd like to introduce the \bfseries{theorem of the universe}, the theorem says that $1+1 = 2$
\end{restatable}
This is a remarkable theorem indeed!

\section{Appendix}
In the Appendix, we will prove theorem

We will reprint the theorem here:

\universe*

\begin{proof}
$ 2 - 1 = 1 $.
\end{proof}

\bibliographystyle{plain}
\bibliography{references}

\end{document} 

在此处输入图片描述

答案2

你可以\label复制需要的定理,然后在通过以下方式重写它的计数器\ref

\newenvironment{usethmcounterof}[1]{%
  \renewcommand\thethm{\ref{#1}}\thm}{\endthm\addtocounter{thm}{-1}}

一个基本的例子可以这么说:

...
\begin{thm}\label{mythm}
We'd like to introduce the \bfseries{theorem of the universe}, the theorem says that $1+1 = 2$
\end{thm}
...
\begin{usethmcounterof}{mythm}
We'd like to introduce the \bfseries{theorem of the universe}, the theorem says that $1+1 = 2$
\end{usethmcounterof}
...

展示

完整代码

\documentclass{article}
\usepackage[utf8]{inputenc}

\usepackage{amsthm}     
\setlength\parindent{0pt}
\theoremstyle{definition}
\newtheorem{definition}{Definition}[section]

\theoremstyle{thm}
\newtheorem{thm}{Theorem}[section]
\newtheorem{lem}{Lemma}[section]
\newtheorem{prop}{Proposition}[section]
\newtheorem{cor}{Corollary}[section]
\newtheorem{conj}{Conjecture}[section]
\newtheorem{claim}{Claim}[section]

\theoremstyle{remark}
\newtheorem{remark}{Remark}[section]
\newtheorem{example}{Example}[section]

\newcommand{\thmautorefname}{Theorem}
\newcommand{\propautorefname}{Proposition}
\newcommand{\lemautorefname}{Lemma}
\newcommand{\corautorefname}{Corollary}
\newcommand{\conjautorefname}{Conjecture}
\newcommand{\claimautorefname}{Claim}

\newenvironment{usethmcounterof}[1]{%
  \renewcommand\thethm{\ref{#1}}\thm}{\endthm\addtocounter{thm}{-1}}

\begin{document}


\section{Introduction}

\begin{thm}\label{mythm}
We'd like to introduce the \bfseries{theorem of the universe}, the theorem says that $1+1 = 2$
\end{thm}
Theorem \ref{mythm} is a remarkable theorem indeed!

\section{Appendix}
In the Appendix, we will prove theorem

We will reprint the theorem here:

\begin{usethmcounterof}{mythm}
We'd like to introduce the \bfseries{theorem of the universe}, the theorem says that $1+1 = 2$
\end{usethmcounterof}

\begin{proof}
2 - 1 = 1. 
\end{proof}
\end{document}

附录

当您处理多个定理环境时,您可以按如下方式定义修补程序,而不必为每个环境复制和粘贴代码。

\newcommand\MakeReplicatable[1]{%
  \newenvironment{use#1counterof}[1]{%
    \expandafter\renewcommand\csname the#1\endcsname{\ref{##1}}\csname #1\endcsname}{%
      \csname end#1\endcsname\addtocounter{#1}{-1}}}

然后你可以声明

\MakeReplicatable{thm}
\MakeReplicatable{lem}
...

如果您想默认允许此功能,您甚至可以将其带入环境定义过程:

\let\ams@newtheorem\newtheorem
\renewcommand\newtheorem[1]{%
  \MakeReplicatable{#1}\ams@newtheorem{#1}}

那么序言中的顺序就需要

...
\usepackage{amsthm}

\makeatletter
\newcommand\MakeReplicatable[1]{%
  \newenvironment{use#1counterof}[1]{%
    \expandafter\renewcommand\csname the#1\endcsname{\ref{##1}}\csname #1\endcsname}{%
      \csname end#1\endcsname\addtocounter{#1}{-1}}}
\let\ams@newtheorem\newtheorem
\renewcommand\newtheorem[1]{%
  \MakeReplicatable{#1}\ams@newtheorem{#1}}
\makeatother

\theoremstyle{definition}
\newtheorem{definition}{Definition}[section]

\theoremstyle{thm}
\newtheorem{thm}{Theorem}[section]
\newtheorem{lem}{Lemma}[section]
...

然而,更优雅的(在我看来)是以如下方式定义复制环境\begin{usecounterof}{<thm-env>}{<label>}...\end{usecounterof}

\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage{amsthm}
  \theoremstyle{definition}
    \newtheorem{definition}{Definition}[section]
  \theoremstyle{thm}
    \newtheorem{thm}{Theorem}[section]
    \newtheorem{lem}{Lemma}[section]
    \newtheorem{prop}{Proposition}[section]
    \newtheorem{cor}{Corollary}[section]
    \newtheorem{conj}{Conjecture}[section]
    \newtheorem{claim}{Claim}[section]
  \theoremstyle{remark}
    \newtheorem{remark}{Remark}[section]
    \newtheorem{example}{Example}[section]
  \newcommand{\thmautorefname}{Theorem}
  \newcommand{\propautorefname}{Proposition}
  \newcommand{\lemautorefname}{Lemma}
  \newcommand{\corautorefname}{Corollary}
  \newcommand{\conjautorefname}{Conjecture}
  \newcommand{\claimautorefname}{Claim}

\makeatletter
\newenvironment{usecounterof}[2]{%
  \def\@tempb{#1}%
  \expandafter\renewcommand\csname the#1\endcsname{\ref{#2}}\@nameuse\@tempb}{%
    \@nameuse{end\@tempb}\addtocounter\@tempb{-1}}
\makeatother

\setlength\parindent{0pt}

\begin{document}
\section{Introduction}

\begin{thm}\label{mythm}
We'd like to introduce the \bfseries{theorem of the universe}, the theorem says that $1+1 = 2$
\end{thm}
Theorem \ref{mythm} is a remarkable theorem indeed!

\section{Appendix}
In the Appendix, we will prove theorem

We will reprint the theorem here:

\begin{usecounterof}{thm}{mythm}
We'd like to introduce the \bfseries{theorem of the universe}, the theorem says that $1+1 = 2$
\end{usecounterof}

\begin{proof}
2 - 1 = 1. 
\end{proof}
\end{document}

相关内容