2

I am new to this community, and unfamiliar with advanced latex use (e.g. creating packages, custom build scripts, post-processing scripts) so I apologize if my question seems unusual or overly simple.

How may all theorems, definitions, corollaries, etc. be restated elsewhere in the document? The following figure illustrates this goal.

Illustration of restating all theorems, definitions, etc. elsewhere in the document

I believe that my question differs from the vanilla usage of the \listoftheorems command (thmtools package) to generate a content page tying theorems, definitions, etc. to the page they're situated on.

Minimum Working Example (MWE)

I have made available a MWE in Overleaf: https://www.overleaf.com/read/vtjwpszsrnnz

This link will take you to Overleaf and provide you the means to edit the source, as well as compile directly in your browser.

There are no restrictions on the types of packages preferred, but it might be nice if discussions could consider more commonly used packages (e.g., thmtools, ams___ series).

Should you prefer editing or compiling the MWE outside of Overleaf's cloud, you may use the following LateX source code which is identical to that contained in the Overleaf link.

\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}
7
  • 1
    Well, you should not wait. Please post a MWE. Sep 1 at 12:46
  • 1
    Hi José, thank you for the reminder. I have updated this question with a MWE :)
    – davidleejy
    Sep 1 at 15:44
  • The code in this answer should do what you want
    – mbert
    Sep 1 at 20:52
  • 1
    Hi @mbert, not a problem, thanks for responding and sharing the script on stackexchange. And yes, I understand that it can take quite some effort to work a script into compatibility with some package. I'm a stranger to the Expl3 language and was wondering if it'd be not too much of a hassle to ask what the script does? Does it add a hook to the creation of the "theorem" environment so that whenever a theorem environment is instantiated, the contents within are also stored in a variable, and then when \printtheorems is called, this variable is consulted, the elements traversed and printed?
    – davidleejy
    Sep 3 at 7:35
  • 1
    You'll likely get a better answer by commenting on egreg's answer
    – mbert
    Sep 3 at 17:34

1 Answer 1

1

Here is a naive attempt. We define \declaretheoremx which does \declaretheorem but also defines a new environment saved<thmname> which is just a wrapper for the restatable environment that stores its contents in the csname thm-<savedthmcount>. If you don't use this environment, the theorem will not be printed in the list of theorems at the end, which is called with \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}

thms

Note the \edef trick is necessary as otherwise all the restated theorems point to the last called theorem (see my question about this).

Obviously the title of \printsavedtheorems can be customized to be a chapter, add to the TOC, etc.

By the way, the extra space added by the restatable environments is a thmtools bug; see this github issue. A temporary fix is provided there.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .