# beamer, overlays, and handout: exclude frames from handout

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.

• Interesting, well written and shows research effort => +1 – user36296 Oct 16 '18 at 16:40

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}


• 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 '18 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 '18 at 18:42

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}

• 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. – user36296 Oct 16 '18 at 21:28