# New theorem environment with manual theorem number

I am wondering how to create a new theorem environment / style which allows me to insert the theorem number manually. That is, I am imagining something like

 \begin{newtheorem}{2.3'}[title]
This is a theorem.
\end{newtheorem}


to translate into

Theorem 2.3' (title). This is a theorem.

As a second example,

 \begin{newtheorem}{A}[title]
This is a theorem.
\end{newtheorem}


should give

Theorem A (title). This is a theorem.

How would one be able to define such a theorem environment with argument which is (apart from the manual insertion of the "number") identical to the usual theorem environment?

Note, if I add a \label to a theorem of this type, I would like the corresponding \ref command to print the theorem number defined in the argument. That is, in the above example \ref should print 2.3'.

I would be grateful for any help with this! Many thanks in advance!

Quite easy! ;-) 1

\documentclass{article}
\usepackage{amsthm}

\newtheorem{manualtheoreminner}{Theorem}
\newenvironment{manualtheorem}[1]{%
\renewcommand\themanualtheoreminner{#1}%
\manualtheoreminner
}{\endmanualtheoreminner}

\begin{document}

\begin{manualtheorem}{2.3'}[title]\label{foo}
This is a theorem.
\end{manualtheorem}

\begin{manualtheorem}{A}[title]\label{baz}
This is a theorem.
\end{manualtheorem}

Here is \ref{foo} and \ref{baz}.

\end{document}


1 Been there, done that.

• Pronto, prontissimo... mamma mia! :) – Ruben Sep 14 '17 at 22:06
• @Ruben Son come il fulmine :-D – egreg Sep 14 '17 at 22:08
• prime would be better than apostrophe. (just being pedantic.) – barbara beeton Sep 15 '17 at 2:56
• @barbarabeeton That's left to the OP to decide. – egreg Sep 15 '17 at 8:06
• Note: does not work with cleveref out of the box. – Bach Dec 15 '19 at 4:01

First of all, you can't define a theorem-like environment newtheorem as there is alredy the \newtheorem macro that defines those environments simply due to the name clash. Assume we have an environment theorem. Then you can locally change \thetheorem:

\documentclass{article}
\usepackage{amsmath,amsthm}
\newtheorem{theorem}{Theorem}

\begin{document}
\begingroup
\renewcommand\thetheorem{2.3'}
\begin{theorem}[title]
This is a theorem.
\end{theorem}
\endgroup
\end{document}


When wrapping this into an own environment you don't need to group explicitly as the \begin and \end definitions take care of this:

\newenvironment{Apollo13theorem}[1]{%
\renewcommand\thetheorem{#1}
\theorem
}{\endtheorem}


The custom environment would then be used as requested by the OP:

\begin{Apollo13theorem}{A}[title]
This is a theorem.
\end{Apollo13theorem}