3

I have a large Beamer file with many frames. Based on the presentation purpose, I want to include/exclude certain slides from the presentation. Is there a way to define the frames at the end of the document and call them up when wanted? Something like the following:

\documentclass{beamer}
\begin{document}

% including the frames
\include{F1}
\include{F2}
% \include{F3}
\include{F4}


% frame definitions
\begin{frame}[F1]
1
\end{frame}
\begin{frame}[F2]
2
\end{frame}
\begin{frame}[F3]
3
\end{frame}
\begin{frame}[F4]
4
\end{frame}
\end{document}

I know that I can go frame by frame and add <beamer:0> to exclude that frame, but since the presentation is too long it would be great if I had the possibility to do as above.

Angelica
  • 33
  • 1
  • 3

2 Answers2

2

This is exactly what the \includeonlyframes command is made for:

\documentclass{beamer}

\includeonlyframes{%
F1,%
F2,%
%F3,%
F4,%
}


\begin{document}

\begin{frame}[label=F1]
1
\end{frame}
\begin{frame}[label=F2]
2
\end{frame}
\begin{frame}[label=F3]
3
\end{frame}
\begin{frame}[label=F4]
4
\end{frame}

\end{document}
1

I don't really consider the following very pretty, but you could define a \newcommand unique for each frame, where the command simply translates to a single value, 0 (excluded) or 1 (included). E.g.

\newcommand{\includeFrameA}{0} % exclude frame
\newcommand{\includeFrameB}{1} % include frame

Then, using a help command

\newcommand{\includeFrame}[1]{beamer:#1}

you can define your frames with the addition of <\includeFrame{\includeFrameX}> to the frame environment signature; in so including/excluding the frame depending on the value of \includeFrameX as specified in the header of your document.

The following example excludes frames "A" and "C", and the produced presentation includes only two pages, containing "B" and "D", respectively.

\documentclass{beamer}

\newcommand{\includeFrame}[1]{beamer:#1}

% one command per frame, 0/1 : exclude/include
\newcommand{\includeFrameA}{0}
\newcommand{\includeFrameB}{1}
\newcommand{\includeFrameC}{0}
\newcommand{\includeFrameD}{1}

\begin{document}

% frame definitions
\begin{frame}<\includeFrame{\includeFrameA}>
A
\end{frame}

\begin{frame}<\includeFrame{\includeFrameB}>
B
\end{frame}

\begin{frame}<\includeFrame{\includeFrameC}>
C
\end{frame}

\begin{frame}<\includeFrame{\includeFrameD}>
D
\end{frame}

\end{document}
dfrib
  • 70,367
  • 12
  • 127
  • 192