When using amsthm
, I want to be able to continue a particular theorem-like environment (in my case, an example) later. The continued environment should have the same number as the one it continues from earlier; and after the continued environment is finished, normal theorem numbering should resume.
The following accomplishes what I want. Is there a simpler or otherwise better way -- without having to stray below LaTeX into pure TeX?
% continue-thm.try
\documentclass[12pt]{article}
\usepackage{amsthm}
\newtheorem{theorem}{Theorem}[section]
\newtheorem{proposition}[theorem]{Proposition}
\theoremstyle{definition}
\newtheorem{example}[theorem]{Example}
\newcounter{savedthmcounter}
\newcounter{tobecontinuedthmcounter}
% Invoke \tobecontinued immediately AFTER theorem to be continued
\newcommand{\tobecontinued}{%
\setcounter{tobecontinuedthmcounter}{\value{theorem}}%
\addtocounter{tobecontinuedthmcounter}{-1}}
% Invoke \continue immediately BEFORE continuing theorem that was to be continued
\newcommand{\continue}{%
\setcounter{savedthmcounter}{\value{theorem}}%
\setcounter{theorem}{\value{tobecontinuedthmcounter}}}
% Invoke immediately AFTER done with the continued theorem
\newcommand{\resume}{\setcounter{theorem}{\value{savedthmcounter}}}
\begin{document}
\begin{theorem}% 1
Theorem 1.
\end{theorem}
\begin{example}% 2
\label{ex:ex2}
An example.
\end{example}
%
\tobecontinued
\begin{theorem}% 3
Theorem 3.
\end{theorem}
\begin{theorem}%4
Theorem 4.
\end{theorem}
\begin{proposition}
A proposition.
\end{proposition}
\continue
%
\begin{example}[continued]% 2 again
Example \ref{ex:ex2}, continued.
\end{example}
\resume
\begin{theorem}% 5
Theorem 5.
\end{theorem}
\end{document}
Added
The preceding method works not just for amsthm
with article
, etc., but also when I use thmtools
and then \declaretheoremstyle
and \declaretheorem
(and, as it happens, with the memoir
class that I'm using).
How do I invoke the thmtools
package's \declaretheoremstyle
and \declaretheorem
(with memoir
) so as to adapt the proposed answers -- and most especially egreg's answer?
Update: If the theorem-like environment to be continued already has a note (i.e., from something like \begin{example}[some text]
), then a method different from the above and from the accepted answer, below, seems to be required. One such method is shown in https://tex.stackexchange.com/a/702575/13492.