# How can I number corollary as a child of theorem where the latter is a child of section using tcolorbox?

I want a result that looks like:

1 Section

Theorem 1.1

Corollary 1.1.1

Proposition 1.2

Corollary 1.2.1

...

This can be achieved easily using amsthm as I used to. However, I want to use tcolorbox for my new notes now but I just cannot find the command that allows me to put three numbers in the title. I searched around and the following is the best I get:

\documentclass{report}
\usepackage[most]{tcolorbox}

\usepackage{chngcntr}\counterwithout{section}{chapter}

\newcounter{theo}
\newtcbtheorem[number within=section]{theorem}{Theorem}{before title={\stepcounter{theo}}}{th}
\newtcbtheorem[number within=theo]{corollary}{Corollary}{}{cor}

\begin{document}
\section{testSection}
\begin{theorem}{testTitle}{}
test theorem
\end{theorem}
\begin{corollary}{testTitle}{}
test corollary
\end{corollary}
\end{document}


Thanks in advance for any help.

• I believe you should add use counter=theo in the optional argument of the Theorem (and you can remove the \stepcounter): \newtcbtheorem[use counter=theo,number within=section]{theorem}{Theorem}{}{th}. Aug 26, 2021 at 15:24
• @campa That works! Thanks a lot! Aug 26, 2021 at 15:44
• @campa Would you post your comment as an answer so I can accept it? Aug 26, 2021 at 16:08
• Rather not. I never used tcolorbox in my life and I cannot really believe that it provides no way to access the real counter. Hopefully some expert will provide an answer. Aug 26, 2021 at 16:10

The inner counter name has prefix tcb@cnt@ (check the example of key /tcb/new/auto counter in tcolorbox's user manual), hence with

\newtcbtheorem[number within=section]{theorem}{Theorem}{<options>}{th}


the theorem environment will use counter tcb@cnt@theorem. Therefore what you need is

\newtcbtheorem[number within=tcb@cnt@theorem]{corollary}{Corollary}{}{cor}


### Full example

\documentclass{report}
\usepackage[most]{tcolorbox}

\usepackage{chngcntr}\counterwithout{section}{chapter}

\newtcbtheorem[number within=section]{theorem}{Theorem}{}{th}
\newtcbtheorem[number within=tcb@cnt@theorem]{corollary}{Corollary}{}{cor}

\begin{document}
\section{testSection}
\begin{theorem}{testTitle}{}
test theorem
\end{theorem}

\begin{corollary}{testTitle}{}
test corollary
\end{corollary}
\end{document}