0

I know the restatable environment from the packages thm-restate combined with thmtools, which allows to formulate theorems that can be restated later in the document.

Now I am wondering, if there is a similar solution for equations like equation, align, etc.. I have already tried to just reuse that restatable environment for equations, but as expected I got an error.

I have already found "solutions" that suggestion to copy the content and tag the reference number. However, this seems to be a stopgap.

1 Answers1

2

The code below provides a command \NewSavedEnvironment{<new-envname>}{<orig-envname>} that defines an environment with syntax

\begin{<new-envname>}{customid}
\end{<new-envname>}

whose contents can be restated with \customid*.

\documentclass{article}
\usepackage{thmtools,amsmath}

\newenvironment{donothing}{}{}

\NewDocumentCommand{\NewSavedEnvironment}{m m}{ \NewDocumentEnvironment{#1}{m +b}{% \begin{restatable}{donothing}{##1} \begin{#2} ##2 \end{#2} \end{restatable}% }{\unskip\ignorespacesafterend} }

\NewSavedEnvironment{savedequation}{equation} \NewSavedEnvironment{savedalign}{align}

\begin{document}

\begin{savedequation}{somename} \label{mylab} \sum_i a_i \end{savedequation}

\begin{savedalign}{anothername} f: X &\to Y \ x &\mapsto n\cdot x \end{savedalign}

\somename*

\anothername*

\ref{mylab}

\end{document}

equations

If you want to use this for environments that don't use the equation counter, see this answer.

mbert
  • 4,171