7

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.

2
  • 1
    The documentation for amsthm is in the file amsthdoc.pdf. It's probably in your distribution. Try "texdoc amsthm" from a command line. Apr 8, 2011 at 3:37
  • 1
    @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. Apr 8, 2011 at 12:25

3 Answers 3

7
\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.

0
3

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

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
{\bfseries}    %Theorem head font
{.}   %Punctuation after theorem head
{0.25em} %Space after theorem head
{\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}

enter image description here

5
  • it is not optional anymore
    – pluton
    Apr 7, 2011 at 23:35
  • @pluton: Not sure what that means. What exactly do you want to type and see? Apr 8, 2011 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, 2011 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, 2011 at 15:16
  • OK, never mind. I see you have that in your own answer. Apr 9, 2011 at 11:25

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .