3

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

3

The letter should be part of the counter's representation. Do like

\newtheorem{theoremA}{Theorem}
\renewcommand{\thetheoremA}{A\arabic{theoremA}}
\newtheorem{theoremB}{Theorem}
\renewcommand{\thetheoremB}{B\arabic{theoremB}}
  • 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
  • 2
    @MattT Have a look at the cleveref package. – egreg Aug 31 '16 at 13:40

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.