[Tex/LaTex] amsthm environment and colorbox

amsthmboxescolortheorems

I'd like to customize the amsthm command a little bit but I cannot find the relevant lines in the (undocumented?) .sty.

  1. How can I put a colorbox on the name of the environment

    \newtheoremstyle{Coloredtheo}%
    {3pt}    %Space above
    {3pt}    %Space below
    {}       %Body font
    {}       %Indent amount
    {\bf \colorbox{blue}}    %Theorem head font
    {}       %Punctuation after theorem head
    {0.25em} %Space after theorem head
    {}       %Theorem head spec
    

    where the blue box should be of the size of the theorem head.

  2. how I can remove the brackets of the optional parameter

    \begin{theorem}[Schwarz inequality]... should not be (Schwarz inequality) but Schwarz inequality.

Best Answer

\makeatletter
\newtheoremstyle{Coloredtheo}%
{3pt}    %Space above
{3pt}    %Space below
{}   %Body font
{}   %Indent amount
{\bfseries}    %Theorem head font
{}   %Punctuation after theorem head
{0.25em} %Space after theorem head
{\colorbox{\thmbgcolor}{\color{\thmheadcolor}\thmname{#1}%
  \thmnumber{\@ifnotempty{#1}{ }\@upn{#2}}}%
  \thmnote{ {--- \the\thm@notefont#3.}}%
}   %Theorem head spec
\makeatother
\theoremstyle{Coloredtheo}
\newtheorem{genericcolorthm}{\generichead}
\newenvironment{colorthm}
  {\def\generichead{Theorem}%
   \def\thmbgcolor{blue}%
   \def\thmheadcolor{red}%
   \begin{genericcolorthm}}
  {\end{genericcolorthm}}
\newenvironment{colorlemma}
  {\def\generichead{Lemma}%
   \def\thmbgcolor{green}%
   \def\thmheadcolor{black}%
   \begin{genericcolorthm}}
  {\end{genericcolorthm}}

With two commands in the theorem style definition, you are free to give them a meaning which will be local in the environment.