5

I use knitr and RStudio with XeLaTeX to create a presentation with many slides. But sometimes not all of the slides should appear in the final pdf. Is it possible to have a variable that I change depending on if all slides should be included or not?

\documentclass{beamer}

#Here I would like to set parameter allslides=FALSE so that the tomato-slide "disappears" from pdf

\begin{document}

\begin{frame}[fragile]{A Slide about Apples}
Bla bla
\end{frame}

\begin{frame}[fragile]{A Slide about Tomatoes}
Bla bla
\end{frame}

\begin{frame}[fragile]{A Slide about Bananas}
Bla bla
\end{frame}

\end{document}

The slides that should disappear have content that the receiver of the pdf should not get.

I tried using \includeonlyframes but couldn't get it to work (all slides disappeared).

1
  • 2
    You could try the ifthen package and define a new environment that does nothing whenever you want all slides and is \comment when you want to exclude some. You just put this environment around the slides in question.
    – Anke
    May 9, 2013 at 13:55

2 Answers 2

1

The following should do the job, however gives an error about an extra } I can't get rid of. If anyone could fix it I'd be happy to adjust the example.

\documentclass{beamer}
\usepackage{ifthen}
\newboolean{tomatoes}
\setboolean{tomatoes}{true} 


\begin{document}

\begin{frame}[fragile]{A Slide about Apples}
Bla bla
\end{frame}

\ifthenelse{\boolean{tomatoes}}{
\begin{frame}[fragile]{A Slide about Tomatoes}
Bla bla
\end{frame}
}{}

\begin{frame}[fragile]{A Slide about Bananas}
Bla bla
\end{frame}

\end{document}
3

You could use the environ package to define a conditional frame environment that gobbles its contents. For example, the following code:

\documentclass{beamer}

\usepackage{environ}

\newenvironment{tomatoframe}{\begin{frame}}{\end{frame}}
%\NewEnviron{tomatoframe}{}{}

\begin{document}

\begin{frame}{A Slide about Apples}
Bla bla
\end{frame}

\begin{tomatoframe}{A Slide about Tomatoes}
Bla bla
\end{tomatoframe}

\begin{frame}{A Slide about Bananas}
Bla bla
\end{frame}

\end{document}

To get a pdf where the tomato frame is dropped, uncomment the NewEnviron line and comment the newenvironment line.

You must log in to answer this question.

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