# amsthm environment and colorbox

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


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.

-
The documentation for amsthm is in the file amsthdoc.pdf. It's probably in your distribution. Try "texdoc amsthm" from a command line. –  Matthew Leingang Apr 8 '11 at 3:37
@Matthew -- the user documentation for amsthm is in amsthdoc.pdf. the source documentation is in amsclass.dtx. amsthm is built into the ams document classes, and the .sty file is spun off from that source. since everything is interwoven, it may be a bit obscure to pull out just the amsthm parts, but it's all there. –  barbara beeton Apr 8 '11 at 12:25

\makeatletter
\newtheoremstyle{Coloredtheo}%
{3pt}    %Space above
{3pt}    %Space below
{}   %Body font
{}   %Indent amount
\thmnumber{\@ifnotempty{#1}{ }\@upn{#2}}}%
\thmnote{ {--- \the\thm@notefont#3.}}%
\makeatother
\theoremstyle{Coloredtheo}
\newenvironment{colorthm}
\def\thmbgcolor{blue}%
\begin{genericcolorthm}}
{\end{genericcolorthm}}
\newenvironment{colorlemma}
\def\thmbgcolor{green}%
\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.

-
very nice! Accepted! –  pluton Apr 7 '11 at 23:50

1 - How can I put a colorbox under the name of the environment ... where the blue box should be of the size of the theorem head.

Take a look at the thmtools package. It gives a nice key-val interface to declaring all kinds of beautiful theorem-like environments.

-

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

\begin{theorem}[Schwarz inequality]...


should not be (Schwarz inequality) but Schwarz inequality.

Put this in the preamble:

\newtheorem*{schwarz}{Schwarz Inequality}


Then in the document:

\begin{schwarz}
% I see your Schwarz is as big as mine.'' --- Dark Helmet, Spaceballs
\end{schwarz}


EDIT I think I understand what you want now. If you don't want a one-off environment, you can alter the theorem's head specification to typeset only the theorem note (optional argument) without delimiters, like so:

\documentclass{minimal}
\usepackage{amsthm}

\makeatletter
\newtheoremstyle{namedtheorem}%
{3pt}    %Space above
{3pt}    %Space below
{}   %Body font
{}   %Indent amount
{\thmname{\@ifempty{#3}{#1}\@ifnotempty{#3}{#3}}}
\makeatother

\theoremstyle{namedtheorem}

% first argument here is the environment to be defined
% second argument is the default name of the theorem.
\newtheorem*{namedtheorem}{Theorem}

\begin{document}

\begin{namedtheorem}
One is the loneliest number.
\end{namedtheorem}

\begin{namedtheorem}[Schwarz Inequality]
For $x$ and $y$ in a Hilbert space $H$,
$|(x,y) | \leq \Vert x \Vert \cdot \Vert y \Vert$
\end{namedtheorem}

\end{document}


-
it is not optional anymore –  pluton Apr 7 '11 at 23:35
@pluton: Not sure what that means. What exactly do you want to type and see? –  Matthew Leingang Apr 8 '11 at 2:19
I do not want the optional argument of a math environment to be between brackets in the pdf. The name of the environment should still be something like "theorem" or "definition" or "lemma". –  pluton Apr 8 '11 at 2:28
not exactly :) I want (for instance) "Theorem 1.2 --- Schwarz inequality." instead of "Theorem 1.2 (Schwarz inequality)" (which is by default) –  pluton Apr 8 '11 at 15:16
OK, never mind. I see you have that in your own answer. –  Matthew Leingang Apr 9 '11 at 11:25