# Using \tag with amsthm environments?

I would like to custom tag theorems, similar to the way \tag lets me custom tag equations in a math environment. How should I go about doing so? The amsthm package documentation is silent on doing something like this..

\documentclass{article}
\usepackage{amsmath}
\usepackage{amsthm}

\begin{document}[article]

$$a + b = c \tag{A1}\label{A1}$$

\begin{theorem}[My important theorem.]
The universe will cease to exist tomorrow.
\end{theorem}

I would like to tag My important theorem as T1'', just like how I tagged \eqref{A1}.

\end{document}


• What kind of interface are you after? Or are you okay with anything? – Werner Feb 12 '15 at 6:35
• @Werner Could you explain what you mean by interface? – user89 Feb 12 '15 at 6:38
• Do you want something like \begin{taggedtheorem}[..] ... \theoremtag{T1} \end{taggedtheorem}, or would the simpler \settheoremtag{T1} \begin{taggedtheorem}[..] ... \end{taggedtheorem} suffice? Or something else altogether...? – Werner Feb 12 '15 at 6:47
• I was thinking the second (simpler) option, because then I can easily extend the solution to tag other environments as well (remarks, definitions, etc.). – user89 Feb 12 '15 at 6:55
• The documentation for amsthm is undergoing revision. Is the form of the output shown in the answers acceptable for the purpose you have in mind? If so, it can be considered as a candidate for the thmtest.tex file that accompanies the documentation. – barbara beeton Feb 12 '15 at 14:46

The following might suffice, although the interface is not as ideal as the regular equation \tag:

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

\newtheorem{theorem}{Theorem}
\makeatletter
\newcommand{\settheoremtag}[1]{% \settheoremtag{<tag>}
\let\oldthetheorem\thetheorem% Store \thetheorem
\renewcommand{\thetheorem}{#1}% Redefine it to a fixed value
\g@addto@macro\endtheorem{% At \end{theorem}, ...
\addtocounter{theorem}{-1}% ...restore theorem counter value and...
\global\let\thetheorem\oldthetheorem}% ...restore \thetheorem
}
\makeatother
\begin{document}

$$a + b = c \tag{A1}\label{A1}$$

\settheoremtag{T4}
\begin{theorem}[My important theorem]\label{thm:importantA}
The universe will cease to exist tomorrow.
\end{theorem}

I would like to tag My important theorem as \ref{thm:importantA},'' just like how I tagged~\eqref{A1}.
Then there is also Theorem~\ref{thm:importantB}.

\begin{theorem}[My important theorem]\label{thm:importantB}
The universe will cease to exist tomorrow.
\end{theorem}

\end{document}


The idea is to set a theorem tag using \settheoremtag{<tag>}, which will then be used to set the numbering for the subsequent theorem environment. At \end{theorem}, the default settings are restored in order to allow for inter-mixing of regularly-numbered theorems together with fixed-tag ones.

• Thanks for explaining your implementation! This is helpful in learning. – user89 Feb 12 '15 at 7:00

Define a special form of theorem and use a new environment with an argument for setting the tag by redefining the \the... command.

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

\usepackage{hyperref} % not mandatory, just to show it works also with it

\newtheorem{theorem}{Theorem}
\newtheorem{taggedtheoremx}{Theorem}
\newenvironment{taggedtheorem}[1]
{\renewcommand\thetaggedtheoremx{#1}\taggedtheoremx}
{\endtaggedtheoremx}

\begin{document}

$$a + b = c \tag{A1}\label{A1}$$

\begin{taggedtheorem}{T4}[My important theorem]\label{thm:importantA}
The universe will cease to exist tomorrow.
\end{taggedtheorem}

I would like to tag My important theorem as \ref{thm:importantA},'' just like how I
tagged~\eqref{A1}. Then there is also Theorem~\ref{thm:importantB}.

\begin{theorem}[My important theorem]\label{thm:importantB}
The universe will cease to exist tomorrow.
\end{theorem}

\end{document}


• Thanks very much for your answer. What's the relationship between a newly created theorem environment, and the \the... – user89 Feb 12 '15 at 15:45
• @user89 When LaTeX finds \label it uses the most recent counter that has been subject to \refstepcounter, in this case taggedtheoremx, using \thetaggedtheoremx that we have suitably redefined. – egreg Feb 12 '15 at 16:38