5

In a frame I include a graphic that has many overlays, say in two slides. In that very frame, I only want to show a subset of the included graphic, say frame 1.

For the standard presentation, I can easily write \begin{frame}<1> to show only the first slide and therefore also only the first frame of the included graphic.

The handout option, however, always prints the last frame, no matter which ones are included in the actual presentation. In the example it shows the fully developed graphic, until 1. I know about the option |handout:1 that can be added, but this seems useless in my scenario.

MMW Example:

\documentclass[handout]{beamer} % remove "handout" to see normal slides
\usepackage{filecontents,tikz}

\begin{filecontents}{fancyFig.tikz}
\begin{tikzpicture}
  \node[draw] (n1) {some node};
  \only<2>{ % "+(1)" would mean the same than "2"
    \node[below of=n1,draw] (n2) {an even more awesome node!};
  }
\end{tikzpicture}
\end{filecontents}

\begin{document}

% only show the first slide of the following frame,
% i.e., also only show the first pic
\begin{frame}<1>{boring frame title}

Awesome pic:\\[1em]
\input{fancyFig.tikz}

\end{frame}

\end{document}

In this example, the handout also shows the node (n2) and I am clueless how to change this. Please note that using \only<2| handout:0>{ in the figure is not an option, because the figure gets included from several slides (in some of which the node (n2) has to be included in the handout). Thus, I need to find an option/command that I can use just within the frame, not within the imported figure.

Just as a note: my question is highly related to this one about excluding a frame from the handout altogether and even much more to this one about excuding certain overlays from the handout, but even the latter does not work here, because I am including a single graphic, of which handout takes the last slide, no matter which ones are shown in the actual presentation.

1

4 Answers 4

7

I think the awesome trick from https://tex.stackexchange.com/a/356907/36296 is also applicable to your problem:

\documentclass[handout]{beamer} % remove "handout" to see normal slides
\usepackage{filecontents,tikz}
\usetikzlibrary{overlay-beamer-styles}

\makeatletter
\newif\ifOnBeamerModeTransition
\newcommand{\slideselection}{1-}%
\newenvironment{handoutframeselect}[1][1-]{%
  \begingroup%
  \mode<handout>{%
    \gdef\beamer@currentmode{beamer}%
    \OnBeamerModeTransitiontrue%
    \renewcommand{\slideselection}{#1}}%
}{%
  \ifOnBeamerModeTransition%
    \OnBeamerModeTransitionfalse%
    \gdef\beamer@currentmode{handout}%
  \fi%
  \endgroup%
}
\makeatother

\begin{filecontents}{fancyFig.tikz}
\begin{tikzpicture}
  \node[draw] (n1) {some node};
  \node<2>[below of=n1,draw] (n2) {an even more awesome node!};
\end{tikzpicture}
\end{filecontents}

\begin{document}


\begin{handoutframeselect}[1]
\begin{frame}<1>{boring frame title}
Awesome pic:\\[1em]
\input{fancyFig.tikz}
\end{frame}
\end{handoutframeselect}

\end{document}

enter image description here

2
  • Thank you very much! That answer is amazingly good. :) However, you might want consider to change your example code slightly, because it's not fully functional. Let's say my frame included <1-2> instead of just <1>, then your solution would not work with selecting [2] in the new environment. For this to work, the frame must use "<\slideselection>" instead of of its actual number -- only then it works perfectly. Please note that this is not a restriction since the original number can be put into a new/additional \only<> command that spans over the whole slide.
    – Prof.Chaos
    Oct 16, 2018 at 18:18
  • Darn, I was wrong: Just using only<n-m> spanning over the entire slide is not equivalent to using <n-m> (instead of <\slideselection>) for the frame. Using only still generates all frames, but all but n-m are empty. So solve this issue, the addition code of the preamble needs to be refined. I give the fully functional solution in another post (here).
    – Prof.Chaos
    Oct 16, 2018 at 18:42
7

This is a refinement of the anwser given by samcarter, which again builds upon another one. Please, vote for both if you like this one.

In this answer here, \slideselection takes an additional argument, which specifies the slides that should be inlcuded in presentation mode. If all slides should be shown "1-" should be given as argument, otherwise any desired subset works. (Note that this command must be given, as otherwise the handoutframeselect environment does not work correctly.)

\documentclass[handout]{beamer} % remove "handout" to see normal slides
\usepackage{filecontents,tikz}
\usetikzlibrary{overlay-beamer-styles}

\makeatletter
\newif\ifOnBeamerModeTransition
\newcommand{\slideselection}[1]{#1}%
\newenvironment{handoutframeselect}[1][1-]{%
  \begingroup%
  \mode<handout>{%
    \gdef\beamer@currentmode{beamer}%
    \OnBeamerModeTransitiontrue%
    \renewcommand{\slideselection}[1]{#1}}%
}{%
  \ifOnBeamerModeTransition%
    \OnBeamerModeTransitionfalse%
    \gdef\beamer@currentmode{handout}%
  \fi%
  \endgroup%
}
\makeatother

\begin{filecontents}{fancyFig.tikz}
\begin{tikzpicture}
  \node[draw] (n1) {some node};
  \node<2>[below of=n1,draw] (n2) {an even more awesome node!};
\end{tikzpicture}
\end{filecontents}

\begin{document}


\begin{handoutframeselect}[1]
\begin{frame}<\slideselection{1}>{boring frame title}
Awesome pic:\\[1em]
\input{fancyFig.tikz}
\end{frame}
\end{handoutframeselect}

\end{document}
1
  • Oh, then I misunderstood your question. I thought that you'd also want only the first overlay in the beamer version and show the second overlay in a later frame. But good to see you could fix this problem. Please mark you own answer as the accepted one. Oct 16, 2018 at 21:28
0

Further to Prof.Chaos's answer, a slight modification to manage article mode too. The handoutframeselect environment will act in both handout and article mode, and will take care of restoring the correct mode.

\newenvironment{handoutframeselect}[1][1-]{%
  \begingroup%
  \mode<handout|article>{%
    \xdef\beamer@actualcurrentmode{\beamer@currentmode}
    \gdef\beamer@currentmode{beamer}%
    \OnBeamerModeTransitiontrue%
    \renewcommand{\slideselection}[1]{#1}}%
}{%
  \ifOnBeamerModeTransition%
    \OnBeamerModeTransitionfalse%
    \xdef\beamer@currentmode{\beamer@actualcurrentmode}%
  \fi%
  \endgroup%
}
0

The idea behind the answers here is excellent -- thank you!

However, I find a slightly different interface more flexible and easier to use. This is based on a wrapper to \againframe:

\makeatletter
\newcommand\handoutframe[1][handout]{%
  \@ifnextchar<%
    {\handoutframe@[#1]}%
    {\handoutframe@[#1]<1->}%
}
\def\handoutframe@[#1]<#2>#3{%
  \mode<#1>{%
%    \edef\save@currentmode{\beamer@currentmode}
    \begingroup
    \def\beamer@currentmode{beamer}%
    \againframe<#2>{#3}%
    \endgroup
%    \edef\beamer@currentmode{\save@currentmode}%
  }%
}
\makeatother

An example use:

\begin{frame}<2-3|handout:0|trans:0>[label=complexframe]
  complex slide with 
  \only<1>{overwritten}\onslide<2->{replaced}
  \onslide<3->{material}
\end{frame}
\handoutframe<1,3>{complexframe}
\handoutframe[handout|trans]<2>{complexframe}

This version allows the presentation mode overlay spec to appear with the frame as usual, and the default handout (and other mode) rendering to be suppressed if desired using (e.g.) handout:0.

Specific overlays can then be selected for rendering in handouts by using the overlay spec to \handoutframe. If the spec is omitted then every overlay step is rendered.

The same command works for other modes using the optional argument (but I still use the name \handoutframe for the macro, as "handout" is both the default and my most common use). It's possible to use forms like\handoutframe[handout|trans]<spec>{framename}. I find that the grouping is enough to restrict the mode switch to the single \againframe call, but if this breaks under some circumstances, the mode can be saved and restored explicitly by uncommenting the lines with \save@currentmode.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .