# How to create and reference “Theorem A1”, “Theorem A2”, “Theorem B1”, etc

I want to create two theorem styles of the following form: Theorem A1 [Insert Theorem Here]

Theorem A2 [Insert Theorem Here]

Theorem B1 [Insert Theorem Here]

Theorem B2 [Insert Theorem Here]

and so on. It is fairly straightforward to do this using \newtheorem:

\documentclass[12pt]{extarticle}
\usepackage{amsthm}
\usepackage{hyperref}

\newtheoremstyle{theorem}{4mm}{1mm}{\itshape}{ }{\bfseries}{.}{ }{}
\theoremstyle{theorem}
\newtheorem{theoremA}{Theorem A\ignorespaces}
\newtheorem{theoremB}{Theorem B\ignorespaces}
\begin{document}

\begin{theoremA}\label{thm:A1}
This is a theorem of type A.
\end{theoremA}

\begin{theoremA}\label{thm:A2}
This is another theorem of type A.
\end{theoremA}

\begin{theoremB}\label{thm:B1}
This is a theorem of type B.
\end{theoremB}

\begin{theoremB}\label{thm:B2}
This is another theorem of type B.
\end{theoremB}

\end{document}


This yields:

Theorem A1. This is a theorem of type A.

Theorem A2. This is another theorem of type A.

Theorem B1. This is a theorem of type B.

Theorem B2. This is another theorem of type B.

So the code returns my desired result. A problem, however, occurs when I attempt to cross-reference one of the theorems. For example, if I site Theorem A1 using

Theorem \ref{thm:A1}

returns

Theorem 1

rather than Theorem A1. Does anyone have an idea of how to correctly cross-reference a theorem in this form? Is it possible to give the theorem a name, which is not displayed, so that I can use the command \nameref{thm:A1}? A quick and dirty fix is

Theorem A\ref{thm:A1}

but, using the hyperref package, a red box appears around the number "1" only. I would prefer a red box around the entire expression "Theorem A1".

\newtheorem{theoremA}{Theorem}

• Thanks, that works perfectly. Extending your answer, if one wants a red hyperef box around "Theorem A1" rather than just "A1", the following seems to work: \newtheorem{theoremC}{} \renewcommand{\thetheoremC}{Theorem C\arabic{theoremC}} – Matthew Thirkettle Aug 31 '16 at 13:31
• @MattT I'd not recommend this, as you'll get Theorem also at every \ref – egreg Aug 31 '16 at 13:34
• [Slightly off-topic] @MattT: use \newcommand*{\thmref}[1]{\hyperref[#1]{Theorem~\ref*{#1}}} if you want such behaviour. I hope that's more what you'd also recommend @egreg (at least I use it like this). – Martin Nyolt Aug 31 '16 at 13:36
• @MattT Have a look at the cleveref package. – egreg Aug 31 '16 at 13:40