附录章节编号模仿定理编号?

附录章节编号模仿定理编号?

我有一份包含多个定理的文档(“ \begin{restatable} \label{thmA}...”)。每个定理后都有语句“ see proof in section \ref{sec:thmA:proof}”。

因此,我的附录现在是一系列以通常方式(“ 7.1, 7.2, ...”)编号的长章节。但是,我希望章节编号与定理编号相同,但前缀“ A”除外。

例如,对于定理:

定理 1.1

定理 2.1

定理 2.2

我希望附录看起来像:

A1.1. 定理 1.1 的证明

A2.1. 定理 2.1 的证明

A2.2. 定理 2.2 的证明

这是一个工作示例,它使用该thm-restate包重述附录中的定理,尽管这对于问题来说并不重要:

\documentclass[]{article}

\usepackage{amsmath,amsthm}
\usepackage{thmtools,thm-restate}

\newtheorem{thm}{Theorem}[section]

\begin{document}

\section{A section in the body}

\begin{restatable}{thm}{thmA} \label{thmA}
Statement of the theorem.
\end{restatable}

The proof of theorem \ref{thmA} can be found in the appendix (see section \ref{sec:thmA:proof}).

\newpage
\appendix

The appendix starts here.

\section{Proof of theorem \ref{thmA}} \label{sec:thmA:proof}

\thmA*

\begin{proof}
Here goes the proof.
\end{proof}

\end{document}

在上面的例子中,定理的编号为Theorem 1.1.,附录第一部分的标题为A. Proof of theorem 1.1.。我希望它是A1.1.,其中包括定理编号的信息。

答案1

该解决方案重新定义了thm环境并向proof其中添加了参数,该参数稍后会自动写入附录部分。

它还会将内容写入\section{Proof of Number...}附录,该附录必须包含在\CollectProofs

这是不是此刻可重新声明!

\documentclass{article}%

\usepackage{blindtext}%
\usepackage{amsmath}
\usepackage{amsfonts}
\usepackage{amsthm}

\usepackage{letltxmacro}%
\usepackage{thmtools,thm-restate}

\theoremstyle{plain}% default
\newtheorem{thm}{Theorem}[section]




\newwrite\appendixcontent%

\AtBeginDocument{%
  \immediate\openout\appendixcontent=\jobname.proofs
}%

\AtEndDocument{%
  \immediate\closeout\appendixcontent%
}%


\newcommand{\CollectProofs}{%

\immediate\closeout\appendixcontent%

\renewcommand{\thesection}{A\arabic{thm}}

\IfFileExists{\jobname.proofs}{\input{\jobname.proofs}}{False}%
}%


\LetLtxMacro\StandardTheoremBegin\thm
\let\StandardTheoremEnd\endthm


\makeatletter
\renewenvironment{thm}[1]{%
\thmt@toks{}%
\refstepcounter{thm}%
\immediate\write\appendixcontent{%
  \string\renewcommand{\noexpand\thesection}{A\thethm}%
  \string\section{Proof of \thethm}%
    \string\begin{proof}%
    \string\unexpanded{#1}%
    \string\end{proof}%
}
\addtocounter{thm}{-1}%
\StandardTheoremBegin%
}{%
  \StandardTheoremEnd%
}%



\begin{document}



\section{A section in the body}


\begin{thm}{Nothing}
\blindtext
\end{thm}


\begin{thm}{Already proven}%
  On Brontosaurs -- Part 2\par
\blindtext[2]%
\end{thm}%

\section{Other Brontosaur theories -- by Misses Ann Elk}


\begin{thm}{See excavations}
By Misses Ann Elk\par
Brontosaurs are thin at one end, thick in the middle and thin again at the other end.
\end{thm}


\clearpage

\appendix

\CollectProofs


\end{document}

在此处输入图片描述

答案2

一种可能性是定义一个新命令\proofsection,临时重新定义\thesection

\newcommand{\proofsection}[1]{%
    \let\origsection\thesection
    \def\thesection{\Alph{section}\ref{#1}}
    \section{Proof of theorem \ref{#1}}
    \let\thesection\origsection
}

这可能不是理想的,可能需要进行一些调整,但我认为这可能是解决问题的一个开始。

使用它,你的例子将变成:

\documentclass[]{article}

\usepackage{amsmath,amsthm}
\usepackage{thmtools,thm-restate}

\newtheorem{thm}{Theorem}[section]

\newcommand{\proofsection}[1]{%
    \let\origsection\thesection
    \def\thesection{\Alph{section}\ref{#1}}
    \section{Proof of theorem \ref{#1}}
    \let\thesection\origsection
}

\begin{document}

\section{A section in the body}

\begin{restatable}{thm}{thmA} \label{thmA}
Statement of the theorem.
\end{restatable}

The proof of theorem \ref{thmA} can be found in the appendix (see section \ref{sec:thmA:proof}).

\newpage
\appendix

The appendix starts here.

\proofsection{thmA}\label{sec:thmA:proof}

\thmA*

\begin{proof}
Here goes the proof.
\end{proof}

\section{A non-proof section in the appendix}

\proofsection{thmA}
this would be another proof section, referring to the proof section \ref{sec:thmA:proof}.

\end{document}

相关内容