[Tex/LaTex] Using regular theorem environments along with tcolorbox theorems

counterstcolorboxtheorems

I am using tcolorbox to draw coloured boxes for my theorems, however for things like a remark, or an example, I would like to have the usual amsthm kind of environment, without any colored boxes.

If I try to combine the two environments as you can see in the MWE below, I can't get the counter right if I make the remark count with respect to the theorem.

What should I put as a counter for the remark to fix this?

enter image description here

\documentclass{article}

\usepackage[theorems]{tcolorbox}
\usepackage{amsmath}

\newtcbtheorem[number within=section]%
{theorem} % \begin..
{Theorem} % Title
{} % Style - default
{theo} % label prefix; cite as ``theo:yourlabel''

\usepackage{amsthm}
\theoremstyle{remark}
\newtheorem{remark}[]{Remark}          % <- This will work
\newtheorem{remark2}[theorem]{Remark2} % <- This won't work

\begin{document}
\section{The section}
\begin{theorem}{The title}{mylabel}
This is a theorem.
\end{theorem}

Counting remarks with respect to the section:
\begin{remark}
Counter is okay
\end{remark}

Counting remarks with respect to the theorem:
\begin{remark2}
\textbf{Problem:} counter is missing and there is
not even a break line.
\end{remark2}

\end{document}

Best Answer

I'm not sure about the counter you want, but tcolorbox creates a \tcbcounter for each box and you can use for later reference.

\documentclass{article}

\usepackage[theorems]{tcolorbox}
\usepackage{amsmath}

\newtcbtheorem[number within=section]%
{theorem} % \begin..
{Theorem} % Title
{} % Style - default
{theo} % label prefix; cite as ``theo:yourlabel''

\usepackage{amsthm}
\theoremstyle{remark}
\newtheorem{remark}[]{Remark}          % <- This will work
\newtheorem{remark2}[\tcbcounter]{Remark2} % <- This won't work

\begin{document}
\section{The section}
\begin{theorem}{The title}{mylabel}
This is a theorem.
\end{theorem}

Counting remarks with respect to the section:
\begin{remark}
Counter is okay
\end{remark}

Counting remarks with respect to the theorem:
\begin{remark2}
\textbf{Problem:} counter is missing and there is
not even a break line.
\end{remark2}

\end{document}

enter image description here

Related Question