1

I have a document where I want to have theorems formatted using the tcolorbox package, and propositions formatted using the default formatting from the amsthm package.

However, I'd also like to have my theorems and propositions have a shared counter and use a consistent numbering scheme (e.g., if in section 2 I have a theorem and then a proposition, the theorem should be labeled as Theorem 2.1, and the proposition should be labeled as Proposition 2.2).

Normally, I would define the theorem environment and then write

\newtheorem{proposition}[theorem]{Proposition}

but doing this produces an error message: "LaTeX Error: No counter 'theorem' defined."

Since the above does not work, how should I setup my theorem and proposition to make sure they have shared numbering?

An small example for the packages and environments I'm working with is included below:

\documentclass{article}

\usepackage{amsmath}
\usepackage{amsthm}
\usepackage{tcolorbox}
\usepackage{hyperref}
\usepackage{cleveref}

\theoremstyle{definition}
\tcbuselibrary{theorems}
\newtcbtheorem
  [number within=section, Crefname={Theorem}{Theorems}]% init options
  {theorem}% name
  {Theorem}% title
  {colframe=gray!40!black}% options
  {theorem}% prefix
\newtheorem{proposition}{Proposition}
%% Using below command produces "LaTeX Error: No counter 'theorem' defined."
% \newtheorem{proposition}[theorem]{Proposition}

\begin{document}
\section{First Section}
\section{Second Section}

\begin{theorem}{Example Theorem}{referencing}
A major result. 
\end{theorem}

\begin{proposition}
    A minor result.
\end{proposition}

\end{document}

1 Answer 1

1

You can take a peak in your .aux file and find out that the counter used by tcolorbox for your theorem is called tcb@cnt@theorem:

\documentclass{article}

\usepackage{amsmath}
\usepackage{amsthm}
\usepackage{tcolorbox}
\usepackage{hyperref}
\usepackage{cleveref}

\theoremstyle{definition}
\tcbuselibrary{theorems}
\newtcbtheorem
  [number within=section, Crefname={Theorem}{Theorems}]% init options
  {theorem}% name
  {Theorem}% title
  {colframe=gray!40!black}% options
  {theorem}% prefix
\makeatletter
\newtheorem{proposition}[tcb@cnt@theorem]{Proposition}
\makeatother
\begin{document}
\section{First Section}
\section{Second Section}

\begin{theorem}{Example Theorem}{referencing}
A major result. 
\end{theorem}

\begin{proposition}
    A minor result.
\end{proposition}

\end{document}

enter image description here

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .