Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

I would like to redefine the block templates for Beamer's theorem-like environments. For example, the example environment creates an exampleblock. I would like to make the definition environment do the same thing.

It's possible to do this locally using the exampleblock environment:

\begin{exampleblock}{Definition}
(Definition here)
\end{exampleblock}

However, I would like a global solution.

I should add that much the same question was asked on Stackoverflow, but no one seems to have figured out a solution.

share|improve this question
    
So you want the definition environment to behave exactly as an exampleblock? –  Gonzalo Medina Sep 12 '12 at 13:14
    
Yes, that's right. –  Andrew Uzzell Sep 12 '12 at 13:16
add comment

1 Answer

up vote 7 down vote accepted

You can set the theorem begin and theorem end templates to use an exampleblock:

\documentclass{beamer}
\usetheme{CambridgeUS}

\makeatletter
\setbeamertemplate{theorem begin}
{%
  \begin{exampleblock}
  {%
%    \inserttheoremheadfont% uncomment if you want amsthm-like formatting
    \inserttheoremname
    \inserttheoremnumber
    \ifx\inserttheoremaddition\@empty\else\ (\inserttheoremaddition)\fi%
    \inserttheorempunctuation
  }%
}
\setbeamertemplate{theorem end}{\end{exampleblock}}
\makeatother

\begin{document}

\begin{frame}
\begin{definition}
Test text.
\end{definition}
\begin{exampleblock}{Definition}
(Definition here)
\end{exampleblock}
\end{frame}

\end{document}

enter image description here

The above solution makes all theorem-like environments inherit the settings for exampleblock; if just the default definition environment must behave like exampleblock, all one has to do is to change the default style used for definition to make it equal to the example style; a simple way to achieve this is to \let both commands \definition and \enddefinition to \relax and then use \newtheorem to define the definition structure using the example style.

An example showing this approach; definition behaves as an exampleblock, but all other theorem-like structures preserve theis default behaviour:

\documentclass{beamer}
\usetheme{CambridgeUS}

\let\definition\relax
\let\enddefinition\relax

\theoremstyle{example}
\newtheorem{definition}[theorem]{\translate{Definition}}

\begin{document}

\begin{frame}
\begin{definition}
Test text.
\end{definition}
\begin{exampleblock}{Definition}
Test text.
\end{exampleblock}
\begin{theorem}
Test text.
\end{theorem}
\end{frame}

\end{document}

enter image description here

share|improve this answer
    
This solution changes all theorem environments. I would like to make definition into an exampleblock, but leave the other theorem environments unchanged. –  Andrew Uzzell Sep 12 '12 at 14:08
    
@AndrewUzzell please see my updated answer. –  Gonzalo Medina Sep 12 '12 at 17:49
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.