3

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?

  • Why not use handout mode to hide answers and presentation mode to display answers? – Herr K. Aug 6 '15 at 21:56
  • I want to do it three ways: presentation to display answers, handout with all answers, and handout without answers. Handouts with all answers are needed for a study reference. – Todor Milev Aug 6 '15 at 23:08
3

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.

  • that looks nice. I see why you are renaming the class - not to have slides that claim to be "beamer" but actually fail to compile with the beamer documentclass. – Todor Milev Aug 7 '15 at 3:27
  • @user39417 LPPL stuff must be renamed if you adapt the code. Legalities aside, if I don't use a different name, what will happen when I say \LoadClass{beamer}? It will simply load my wrapper class again. So it has to have a different name in order to work, even aside from the fact that the licence requires it. – cfr Aug 7 '15 at 3:31
  • Thanks! Your post appears to be exactly what I wanted, but I am very much scared of jumping head first into maintaining a hackedbeamer class (I am seeing the LoadClass command for the first time). Is there away to achieve the same effect by renewing the \alert, \uncover and \only commands? – Todor Milev Aug 7 '15 at 3:40
  • @user39417 Well you have to define the mode somewhere in order to be able to use it in those commands. To redefine them so that that was not necessary would mean replicating large chunks of the class's code inside the commands. Not only would that be enormously redundant, it would also be much more fragile. (An update to beamer would almost certainly break it.) And you'd never get it to work really seamlessly. At least, maybe you would but I wouldn't. But hang on, there is one other possibility... – cfr Aug 7 '15 at 3:45
  • @user39417 See edit. This produces the same results. Do note that it is doing essentially the same thing. – cfr Aug 7 '15 at 3:55

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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