# Color Box Theorem Headtitle only

I want to put a colored box in every theorem, example etc. Only the headtile and not it's contents. I've found an answer here which works for simple tetx. But is does not work for theorems, examples etc. I get an error "Use of \simpletitleshade doesn't match its definition T". Here's my code

\documentclass{article}

\usepackage{amsthm}
\usepackage{thmtools}
\usepackage{tikz}

\def\simpletitleshade[#1]#2{\tikz[overlay]\node[fill=cyan,inner sep=2pt, anchor=text, rectangle, rounded corners=1mm,#1] {#2};\phantom{#2}}%

\begin{document}

\begin{example}
Test
\end{example}
\end{document}


tcolorbox includes a library for theorems and similar environments. An example with color boxed title could be declared with:

\documentclass{article}

\usepackage{amsthm}
\usepackage{thmtools}
\usepackage{varwidth}
\usepackage[most]{tcolorbox}
\usepackage{lipsum}

\newtcbtheorem{MyExample}{Example}%
{enhanced, tile, left=0pt, right=0pt, colback=white, attach boxed title to top left, boxed title style={colback=blue!30, sharp corners}, varwidth boxed title}{ex}

\begin{document}

\lipsum[1]
\begin{MyExample}{AAA}{a}% First parameter = Title, Second = label
\lipsum[1]
\end{MyExample}

As can be seen in example~\ref{ex:a}

\end{document}


• I get the following errors from your mwe. pgfkeys: I do not know the key '/tcb/attach boxed title to top left' and I am going to ignore it. Perhaps you misspelled it. \begin{MyExample}{AAA}{a} pgfkeys: I do not know the key '/tcb/boxed title style' and I am going to ignore it. Perhaps you misspelled it. \begin{MyExample}{AAA}{a} pgfkeys: I do not know the key '/tcb/varwidth boxed title' and I am going to ignore it. Perhaps you misspelled it. \begin{MyExample}{AAA}{a} – C. Apollon Mar 11 '16 at 20:01
• @C.Apollon please, update tcolorbox package and try again – Ignasi Mar 12 '16 at 14:11