3

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}

Solely <code>Proposition' is colored, whereas I would like the numbering</code>1.' to be colored as well.

3

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}

enter image description here

  • 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
  • 2
    @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
  • 1
    @OlivierMassicot See if my renewed answer fits your needs. – CarLaTeX Nov 30 '18 at 18:44
  • 1
    @OlivierMassicot Thank you for accepting my answer. – CarLaTeX Nov 30 '18 at 19:01

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.