# Background color of the title of a theorem, including its numbering

I am starting with a classical theorem environment from amsthm, it has the numbering I want. What I would like is to color the background of the name of the theorem. I have tried to do a color box in the definition itself, but I only get to color the name, unfortunately without the numbering. Basically, my question is: how to get the numbering to be colored as well?

I am aware of the package thmtools but I am only trying to color the background of the name and numbering, not the whole theorem.

MWE:

\documentclass{article}

\usepackage{amsmath,amsthm}

\usepackage{xcolor}
\usepackage{colortbl}

\definecolor{1}{RGB}{255,200,255}
\newtheorem{prop1}{\colorbox{1}{Proposition}}

\begin{document}

\begin{prop1}
For any information provision policy $A$,
$\rho^*_A = 1.$
\end{prop1}

\end{document}


You could define your own theorem style:

\documentclass{article}

\usepackage{amsmath,amsthm}

\usepackage{xcolor}
\usepackage{colortbl}

\definecolor{1}{RGB}{255,200,255}
\newtheoremstyle{colth}%
{}{}%
{\itshape}{}%
{}{}%
{ }%
{\colorbox{1}{\textbf{\thmname{#1}\thmnumber{ #2}}\thmnote{ (#3)}.}}
\newtheorem{prop}{Proposition}
\theoremstyle{colth}
\newtheorem{prop1}[prop]{Proposition}

\begin{document}
\begin{prop}
An ordinary Proposition
\end{prop}

\begin{prop1}
For any information provision policy $A$,
$\rho^*_A = 1.$
\end{prop1}

\begin{prop}[With a note]
For any information provision policy $A$,
$\rho^*_A = 1.$
\end{prop}

\begin{prop1}[With a note]
For any information provision policy $A$,
$\rho^*_A = 1.$
\end{prop1}

\end{document}


• That's exactly what I was looking for, it works like a charm. I would just add that I used \bf to make the text bold-faced, to be more coherent with the other theorem style. – Olivier Massicot Nov 30 '18 at 15:35
• @OlivierMassicot \bf is deprecated, use \bfseries instead, see here: tex.stackexchange.com/questions/41681/… and see my edit. – CarLaTeX Nov 30 '18 at 15:55
• I see, thank you! However I noticed that the numbering counts the number of prop1 theorems, and obviously not the number of propositions. Is there a way where I can have a prop1 and prop2 defined, such that the numbering is the sum of the numberings, i.e. so that it goes Proposition 1., Proposition 2., etc. irrespective of the colors? Or is there a way to pass the color as an argument, something like \begin{colorprop}[red] ... \end{colorprop}? – Olivier Massicot Nov 30 '18 at 17:16
• @OlivierMassicot See if my renewed answer fits your needs. – CarLaTeX Nov 30 '18 at 18:44
• @OlivierMassicot Thank you for accepting my answer. – CarLaTeX Nov 30 '18 at 19:01