3

I would like to know if there is a method to generate beamer pdf presentation based on conditions. For example:

-Main Beamer presentation:

Slide 1
Slide 2
Slide 3
Slide 4
Slide 5

-For the first presentation (pdf file):

Slide 1 (hidden)
Slide 2 (hidden)
Slide 3
Slide 4
Slide 5

-For the second presentation (pdf file):

Slide 1
Slide 2 (hidden)
Slide 3
Slide 4 (hidden)
Slide 5 (hidden)

Thank you in advance!

2 Answers2

5

I think that in beamer terminology you mean to omit certain frames (rather than slides). The comments suggest some generic ways to omit sections but beamer has a bult in way to drop certain frames.

\begin{frame}<0>

\end{frame}

will not appear in the output.

This is a special case of a more general conditional processing feature see section 8.4 of the beamer manual.

David Carlisle
  • 757,742
4

Here's a specifically beamerish (not to be confused with Beamish) way to do this. It works by taking advantage of the fact that beamer's modes are not defined from a specified list. Indeed, searching the code then the trans mode is conspicuous by its absence. In reality, trans is simply "not beamer". Similarly handout. So you can define a new mode and the overlay specifications will work matching that mode. The only snag is that the in-frame slide count has a specific match for beamer. This means that a generic specification, say \only<3>{some text} will be viewed as \only<beamer:3>{some text}. So to make the new modes act as beamer and not as trans or article, it's necessary to subvert this test. This means that one needs the Dreaded MakeAtLetter of Bexhill-on-Sea. Moreover, I haven't thoroughly tested this so there may be more situations I haven't considered.

Anyway, here's the code:

\documentclass{beamer}
%\url{http://tex.stackexchange.com/q/66508/86}
\makeatletter
\newcommand{\beamersetmode}[1]{%
  \gdef\beamer@currentmode{#1}%
    \gdef\beamer@@@decodefind##1:##2|{%
      \beamer@ifempty{##2}%
      {\beamer@decodefind #1:##1:}%
      {\beamer@decodefind ##1:##2}}}
\makeatother

\beamersetmode{A}

\begin{document}
\begin{frame}<A:0>
Slide One \only<2>{with overlays}
\end{frame}
\begin{frame}<A:0|B:0>
Slide Two \only<2>{with overlays}
\end{frame}
\begin{frame}
Slide Three \only<2>{with overlays}
\end{frame}
\begin{frame}<B:0>
Slide Four \only<2>{with overlays}
\end{frame}
\begin{frame}<B:0>
Slide Five \only<2>{with overlays}
\end{frame}
\begin{frame}<presentation:0>
Slide Six will never be shown
\end{frame}
\end{document}

And this produces the following. Change the \beamersetmode to \beamersetmode{B} or omit it altogether to get the other versions.

conditional frame inclusion

Note: don't use first and second because second is already used for something to do with having slides on a second screen.

Andrew Stacey
  • 153,724
  • 43
  • 389
  • 751