tags:

views:

556

answers:

1

The amsthm theorem environments (theorem,example,proof,solution,...) make blocks on beamer slides. The default is that example environments use a different template (block example) than theorem or solution or proof (block).

How do I make solution use a different template like "block solution" that I can define?

Edit: Thanks to those who answered. I haven't implemented a workaround yet but it seems like there are two ideas:

  • Redefine the \th@foo command for a theorem-like environment named foo. The new command should redefine \inserttheoremblockenv to be the desired block environment. See beamerbasetheorems.sty (around line 63) for how this is done specifically for example.

  • Redefine the theorem begin and theorem end template to look up the correct theorem block environment based on the global variable \inserttheoremname (see beamerinnerthemedefault.sty). The lookup table could be kept in a pgfkeys registry. This approach would be a bit higher-level and wouldn't involve any commands with @ in them; however, YAGNI comes to mind.

+1  A: 

As seen in beamerbasetheorems.sty:

\documentclass[notheorems]{beamer}

\theoremstyle{plain}
\newtheorem{theorem}{\translate{Theorem}}
\newtheorem{example}[theorem]{\translate{Example}}

% or

\theoremstyle{definition}
\newtheorem{theorem}{\translate{Theorem}}
\newtheorem{example}[theorem]{\translate{Example}}

% or

\theoremstyle{example}
\newtheorem{theorem}{\translate{Theorem}}
\newtheorem{example}[theorem]{\translate{Example}}

Whatever style you like. You can also change the appearance of the [alert|example]block:

\setbeamercolor{block body}{fg=blue,bg=white}
\setbeamercolor{block body alerted}{fg=blue,bg=white}
\setbeamercolor{block body example}{fg=blue,bg=white}

(Not tried it, just looked into the beamer sources)

EDIT: Still not sure want you want to do, but you can define your own theorem styles:

\makeatletter
\def\th@something{%
  \normalfont % body font
  \def\inserttheoremblockenv{alertblock}  
}
\theoremstyle{something}
\newtheorem{warn}[theorem]{WARNING}
\makeatother

\begin{warn}[Attention please]
This is dangerous
\end{warn}

(This works, I tested it)

You have 3 predefined blocks which you can customize using \defbeamertemplate. Look into the sources and the documentation on how to do this. If you need more block environments, see basebeamerlocalstructure.sty:

  \newenvironment<>{alertblock}[1]{%
    \begin{actionenv}#2%
      \def\insertblocktitle{#1}%
      \par%
      \mode<presentation>{%\usebeamerfont{block}%
        \setbeamercolor{local structure}{parent=alerted text}}%
      \usebeamertemplate{block alerted begin}}
    {\par%
      \usebeamertemplate{block alerted end}%
    \end{actionenv}}

Hope that helps

Meinersbur
What I really want to do is create a new alternative to theorem/example/alert blocks.beamerbasetheorems.sty overrides one of amsthm's internals so as to use a "theorem begin" template when a theorem-like enviroment is begin. That template starts a block environment named '\insertblockenv'. This macro is defined in beamerbasetheorems.sty to be "block", and only in an override of an internal '\th@example' is the '\insertblockenv' macro redefined to "exampleblock". So those are your choices: exampleblock if the theoremstyle is example, block o/w.Maybe the template can be adapted?
Matthew Leingang
Do you want to change an existing block environment or define a new block environment?
Meinersbur
I want to change an existing block environment. I don't want "theorem" and "solution" (for instance) to be in the same beamercolorbox. I won't have a chance to get back to this for another day or two, but I think something can be accomplished using PGF's key registry within the `theorem begin` template.
Matthew Leingang
Or, maybe just hack \th@solution to change \insertblockenv like beamerbasetheorems.sty does with \th@example.
Matthew Leingang
Is what you are trying to accomplish in my edit? Do you need more block environments or help to create new ones?
Meinersbur