我是这个社区的新手,不熟悉高级乳胶使用(例如创建包,自定义构建脚本,后处理脚本),所以如果我的问题看起来不寻常或过于简单,我深表歉意。
如何在文档的其他地方重述所有定理、定义、推论等?下图说明了这一目标。
\listoftheorems
我认为我的问题与命令(包)的普通用法不同,thmtools
它生成一个将定理、定义等与它们所在的页面联系起来的内容页面。
最小工作示例(MWE)
我在 Overleaf 中提供了 MWE:https://www.overleaf.com/read/vtjwpszsrnnz
此链接将带您进入 Overleaf,并为您提供编辑源代码以及直接在浏览器中进行编译的方法。
对于首选的包类型没有限制,但如果讨论可以考虑更常用的包(例如,thmtools
系列ams___
),那就更好了。
如果您更喜欢在 Overleaf 云之外编辑或编译 MWE,您可以使用以下与 Overleaf 链接中包含的相同的 LateX 源代码。
\documentclass{article}
\usepackage{amsmath, amsthm, amssymb}
\usepackage{thmtools}
% Define the theorem environments
\newtheorem{theorem}{Theorem}[section] % Theorems are numbered within sections
\newtheorem{lemma}[theorem]{Lemma} % Lemmas share numbering with theorems
\newtheorem{corollary}[theorem]{Corollary}
\newtheorem{definition}[theorem]{Definition}
\newtheorem{proposition}[theorem]{Proposition}
% Create a list of theorems, lemmas, corollaries, and definitions
\declaretheorem[name=Theorem,numberwithin=section]{thm}
\declaretheorem[name=Lemma,sibling=thm]{lem}
\declaretheorem[name=Corollary,sibling=thm]{cor}
\declaretheorem[name=Definition,sibling=thm]{defn}
\declaretheorem[name=Proposition,sibling=thm]{prop}
% Blindtext:
\newcommand{\loremipsum}{Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Etiam lobortis facilisis sem. Nullam nec mi et neque pharetra sollicitudin.}
\begin{document}
\section{Introduction}
\begin{definition}[Sequence]
A sequence refers to a $\mathbb{R}$ function $f$ defined on the set of natural numbers $\mathbb{N}$ where $f(n) = x_n \forall n \in \mathbb{N}$. It is customary to denote the sequence by the symbol ${x_n}$
\end{definition}
\loremipsum
\begin{theorem}[Bolzano-Weierstrass Theorem]
A bounded sequence $(x_n)$ in $\mathbb{R}^k$ (or $\mathbb{C}^k$) has a subsequence $(x_{n_k})$ that converges to some limit $L$ in $\mathbb{R}^k$ (or $\mathbb{C}^k$).
\end{theorem}
\loremipsum
\begin{corollary}[Squeeze Theorem]
Let $f$, $g$, $h$ be functions from $A \subseteq \mathbb{R}$ to $\mathbb{R}$ and let $c$ be a limit point of $A$. If
\\
$$f(x) \leq g(x) \leq h(x)$$
\\
for all $x \in A$ and
\\
$$\lim_{x \rightarrow c} f(x) = L = \lim_{x \rightarrow c} h(x) $$
\\
then
\\
$$\lim_{x \rightarrow c} g(x) = L$$
\end{corollary}
\section{More Stuff}
\begin{proposition}[Continuity limit laws]
Let $f : A \rightarrow \mathbb{R}$ and $g : A \rightarrow \mathbb{R}$ be continuous at $c \in A$. Then,
\\
(i) $k \cdot f(x)$ is continuous at $c$, $\forall k \in \mathbb{R}$;
\\
(ii) $f(x) + g(x)$ is continuous at $c$;
\\
(iii) $f(x) \cdot g(x)$ is continuous at $c$;
\end{proposition}
\loremipsum
\begin{theorem}[Continuous image of a compact set is compact]
Suppose $f : A \rightarrow \mathbb{R}$ is continuous. If $A \subseteq \mathbb{R}$ is compact, then $f(A)$ is compact.
\end{theorem}
\loremipsum
\begin{theorem}[Arzela-Ascoli Theorem]
If $(f_k)$ is uniformly bounded and equicontinuous on $A$, then $(f_k)$ contains a uniformly convergent subsequence.
\end{theorem}
\loremipsum
\section{List of Results}
Need help for this.
% List of theorems, lemmas, corollaries, and definitions
% \listoftheorems[ignoreall,show={thm,lem,cor,defn}]
\end{document}
答案1
这是一个幼稚的尝试。我们定义了\declaretheoremx
which ,\declaretheorem
但也定义了一个新的环境saved<thmname>
,它只是restatable
环境的一个包装器,将其内容存储在 csname 中thm-<savedthmcount>
。如果不使用此环境,则定理将不会打印在最后的定理列表中,该列表由 调用\printsavedtheorems
。
\documentclass{article}
\usepackage{kantlipsum,amsthm,thmtools,pgffor}
\newcounter{savedthmcount}
\newcommand{\declaretheoremx}[2][]{
\declaretheorem[#1]{#2}
\NewDocumentEnvironment{saved#2}{O{}+b}{%
\stepcounter{savedthmcount}%
\edef\temp{%
\noexpand\begin{restatable}[##1]{#2}{thm-\thesavedthmcount}%
}%
\temp
##2
\end{restatable}
}{}
}
\newcommand{\printsavedtheorems}{%
\section*{List of Saved Theorems}
\foreach \NUM in {1,...,\thesavedthmcount}{\UseName{thm-\NUM}*}%
}
\declaretheoremx{theorem}
\declaretheoremx[numbered=no]{lemma}
\begin{document}
\begin{savedtheorem}
\kant[1][1]
\end{savedtheorem}
\begin{theorem}
\kant[2][1]
\end{theorem}
\begin{savedtheorem}
\kant[3][1]
\end{savedtheorem}
\begin{savedlemma}
\kant[4][1]
\end{savedlemma}
\printsavedtheorems
\end{document}
注意\edef
诡计是必要的,否则所有重述的定理都指向最后提到的定理(见我的问题对这个)。
显然的标题\printsavedtheorems
可以定制为章节,添加到目录中等等。
顺便说一句,可重设环境添加的额外空间是 thmtools 的一个错误;请参阅此github 问题。那里提供了一个临时修复。