[Tex/LaTex] Using \tag with amsthm environments

amsthmnumberingtheorems

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]

\begin{equation}
    a + b = c \tag{A1}\label{A1}
\end{equation}

\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}

enter image description here

Best Answer

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

enter image description here

\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}

\begin{equation}
    a + b = c \tag{A1}\label{A1}
\end{equation}

\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.