开发者

How do I change the block template for specific theorem environments (LaTeX beamer)

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 re开发者_运维技巧gistry. This approach would be a bit higher-level and wouldn't involve any commands with @ in them; however, YAGNI comes to mind.


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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜