1

For my document, I like to have all my theorem environments be counted consecutively as definition 1, definition 2, ..., theorem 1, theorem 2, ....

I created a tcb theorem environment that does this, however, whenever I reference a theorem it only gives the section + subsection that theorem is under.

\documentclass[reqno, 11pt]{amsart}
\usepackage[margin=0.75in]{geometry}
\usepackage{tcolorbox}
\usepackage{hyperref}
\usepackage{nameref}
\tcbuselibrary{theorems}

\hypersetup{ colorlinks = true, linkcolor={red!50!black} }

\newtcbtheorem[auto counter]{thm}{Theorem} {theorem style=plain,colframe=red!50!black,colback=red!5!white, coltitle=red!50!black,fonttitle=\upshape\bfseries,fontupper=\itshape,boxrule=0.5pt}{}

\begin{document} \section{First Section} \subsection{Subsection One} \hfill \begin{thm}{Theorem 1 Name}{} \label{thm:1} Theorem here \end{thm} \begin{thm}{Theorem 2 name}{} \label{thm:2} Theorem here \end{thm} By Theorem ~\ref{thm:1}, ... By Theorem ~\ref{thm:2},... \end{document}

In this example, the reference renders the 1.1 for both Theorems 1 and 2. I would like it to render 1 for Theorem 1 and 2 for Theorem 2. I obviously would like this to not reset when going into another section.

Lex_i
  • 215

1 Answers1

2

The second argument in your theorem environment, which you left empty, is actually for a label. You can specify a prefix like thm when you define your theorem environment (the last argument, which you also left empty) so you don't have to repeat it in every label:

\documentclass[reqno, 11pt]{amsart}
\usepackage[margin=0.75in]{geometry}
\usepackage{tcolorbox}
\usepackage{nameref}
\tcbuselibrary{theorems}
\usepackage{hyperref}
\hypersetup{
    colorlinks = true,
    linkcolor={red!50!black}
}

\newtcbtheorem[auto counter]{thm}{Theorem} {theorem style=plain,colframe=red!50!black,colback=red!5!white, coltitle=red!50!black,fonttitle=\upshape\bfseries,fontupper=\itshape,boxrule=0.5pt}{thm}

\begin{document} \section{First Section} \subsection{Subsection One} \hfill \begin{thm}{Theorem 1 Name}{duck} Theorem here \end{thm} \begin{thm}{Theorem 2 name}{bear} Theorem here \end{thm} By Theorem ~\ref{thm:duck}, ... By Theorem ~\ref{thm:bear},... \end{document}