[Tex/LaTex] Beamer class creating 3 modes: presentation, handout, and custom

beamer

Currently, the beamer class has two modes: presentation and handout. I want to create a third mode for the beamer class, i.e., to have presentation, handout, and a new mode – the exercise handout mode. I want the exercise handout mode is to function in the same as the handout mode except that it will not have all elements from the handout mode.

An example of what I have right now:

\documentclass
%[handout]
{beamer}
\begin{document}
\begin{frame}
\[
1+1=\uncover<handout:1|2->{\alert<handout:0|2>{2}}
\]
\end{frame}
\end{document}

Now, the presentation mode shows the computation of 1+1 gradually. The handout mode shows the computation in a single slide. Now, I need a third mode in which I have the slide without the answer. I am imagining something like:

1+1=\uncover<handout:1|exerciseHandout:0|2->{\alert<handout:0|2>{2}}

Now when I compile in "exerciseHandout" mode, I want to get the same as the handout mode but without the answer 2. I want to have all three versions of my slides (presentation for showing to students, handout for reference, and exerciseHandout for handing out to students to exercise themselves “fill-in-the-blanks'' style).

How would you do this?

Best Answer

Do note that this is extremely poorly tested. As in, hardly at all. The MWE works for me right now on this machine today. That is all.

Caveat emptor...


This creates a new class hackedbeamer.cls which is essentially a wrapper around beamer.cls. It is not possible to mimic exactly what the class does because it uses \DeclareOptionBeamer{}{} to define the mode options passed to the class. I can't use that here because I need to define the option before the class is loaded and \DeclareOptionBeamer{}{} defined. So I'm using a regular \DeclareOption{}{} and hoping that the worst doesn't turn out too badly.

This makes no attempt to adjust for themes which handle modes differently. This includes the default outer theme.

Anyway, for what it is worth:

\begin{filecontents}{hackedbeamer.cls}
\NeedsTeXFormat{LaTeX2e}% LaTeX 2.09 can't be used (nor non-LaTeX)
[1994/12/01]% LaTeX date must December 1994 or later
\ProvidesClass{hackedbeamer}
\newif\ifhacked@beamer@exhandout\hacked@beamer@exhandoutfalse
\DeclareOption{exhandout}{\hacked@beamer@exhandouttrue}
\DeclareOption*{\PassOptionsToClass{\CurrentOption}{beamer}}
\ProcessOptions*
\LoadClass{beamer}
\ifhacked@beamer@exhandout
  \AtEndOfClass{%
    \gdef\beamer@currentmode{exhandout}%
    \def\animate<#1>{\transduration<#1| handout:0| exhandout:0| trans:0>{0}}%
  }
\fi
\endinput
\end{filecontents}
\documentclass
[exhandout]
{hackedbeamer}
\begin{document}
\begin{frame}
  \[
    1+1=\uncover<2-| handout:1| exhandout:0>{\alert<2| handout:0>{2}}
  \]
\end{frame}
\end{document}

As written, the code produces a single slide:

new mode

Switching to handout produces a single slide which differs from the one above:

standard handout

Switching to default mode produces two sides:

default

EDIT

I think the above method is cleaner but, if you don't want to use a parasitic class like hackedbeamer.cls, you can avoid it as follows:

\documentclass
[handout]
{beamer}
% \makeatletter
%     \gdef\beamer@currentmode{exhandout}%
%     \def\animate<#1>{\transduration<#1| handout:0| exhandout:0| trans:0>{0}}%
% \makeatother
\begin{document}
\begin{frame}
  \[
    1+1=\uncover<2-| handout:1| exhandout:0>{\alert<2| handout:0>{2}}
  \]
\end{frame}
\end{document}

When you want to enable exhandout mode, uncomment the commented lines. When you want handout, comment those lines and specify the class option. When you want default mode, comment those lines and comment the class option.

This is doing the same as the parasitic class does. It is just doing it in your preamble.

Either method seems a bit mysterious but this one feels like positive sleight of hand. Notice that the code above works despite exhandout mode never being defined even thought the overlay specification uses it. I assume Beamer's parser must just discard any mode specification not relevant to the currently active mode.