0

I have the following:

\newcommand{\thmbox}[2]{
    \begin{tcolorbox}[colback=blue!5!white,colframe=blue!75!black,title={#1}]
        {#2}    
        \begin{theorem}
            uhhh
        \end{theorem}
    \end{tcolorbox}
}
\thmbox{contents}{
    how to cite thm in title
}

So far it is mostly working, but for the title, I would like to have it be "Theorem X.XX" for the theorem number. I'm just not sure how to keep track of the theorem number in the title.

enter image description here

1 Answer 1

1

The tcolorbox package has a library for theorem. See section 18 of the manual. The library has the command \NewTcbTheorem[⟨init options⟩]{⟨name⟩}{⟨display name⟩}{⟨options⟩}{⟨prefix⟩} that define a theorem like environment.

  • name : is the name of your environment
  • display name : how would the name appear
  • options : as usual
  • prefix : a prefix that will be add to the label.

Your environment will have two mandatory arguments. The first one is the title of the theorem. The second one is the label.

So here is one way to do what you want

\documentclass{article}

\usepackage{tcolorbox}
    \tcbuselibrary{theorems}

\NewTcbTheorem[number within=section]{mytheorem}{My Theorem}%
{colback=blue!5!white,colframe=blue!75!black}{th}

\usepackage{hyperref}    % for the command \nameref{}

\begin{document}

\section{Test}

\begin{mytheorem}{This is my title}{theoexample}
This is the text of the theorem. The counter is automatically assigned and,
in this example, prefixed with the section number. This theorem is numbered with
\ref{th:theoexample}, it is given on page~\pageref{th:theoexample},
and it is titled : \nameref{th:theoexample}.
\end{mytheorem}

\end{document}
2
  • exactly what I needed! thank you
    – stone327
    Commented Jul 10 at 13:32
  • @stone327 If this answer your question, you can accept it with the green check mark. This is how we keep track of answered/unanswered question. And glad I could help Commented Jul 11 at 0:18

You must log in to answer this question.

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