[Tex/LaTex] beamer, overlays, and handout: exclude frames from handout

beameroverlays

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.

Best Answer

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