[Tex/LaTex] Beamer: how to make theorem-like block (with free title)

beameritalictheorems

I often use CambridgeUS, the only negative part about is that when I put theorems in blocks, it's not see clear where that theorem ends.
So I would like the body of the theorem to be in italic.
However, I also want to be able to choose the title, so instead of "Theorem" I would want "Theorem (Erdos, 1960)".

What is the best way to do this?

Should I make a new type of block environment, or change the theorem environment?

I could of course use ordinary blocks and always make it italic by hand, but that looks like a nasty solution.

Best Answer

You could try the following code, to define your custom block:

\newenvironment<>{proposition}[1][\undefined]{%
\begin{actionenv}#2%
\ifx#1\undefined%
   \def\insertblocktitle{Proposition}%
\else%
   \def\insertblocktitle{Proposition ({\em#1})}%
\fi%
\par%
\mode<presentation>{%
  \setbeamercolor{block title}{fg=white,bg=yellow!50!black}
  \setbeamercolor{block body}{fg=black,bg=yellow!20}
}%
\usebeamertemplate{block begin}\em}
{\par\usebeamertemplate{block end}\end{actionenv}}

which has been adapted from here: Custom beamer blocks for pros and cons?. Note that an \if has been inserted to typeset either Proposition in the title, when no optional title is given, or Proposition (Name of Proposition) if such an optional name is provided.

The main text has been tweaked to be italic, by inserting the \em command after the \usebeamertemplate{block begin}.

Also, colors have been defined (which was my original motivation for implementing a custom definition in beamer, since using the package thmtools is problematic in beamer when a background color is specified).

In this way you can define definition, assumption, proposition, lemma, theorem, corollary, remark blocks, with possibly different colors each. Use them as:

\begin{proposition}
   Main text, no custom name in the title.
\end{proposition}

when you just want the main text, or if you also want to specify a name in italics within parentheses, then use:

\begin{proposition}[optional name, will become italic]
   Main text
\end{proposition}

In case that one prefers the main body text to remain normal (and not in italics), then removing the \em command from after \usebeamertemplate{block begin} will suffice.