# Excluding whole frames with ifthen does not work (any more…)

I have a large slide deck (a multi-day training course) from which I want to generate different training courses (different lengths and combinations of subjects) by including/excluding certain slides. I used to do this with ifthen, but all of a sudden (new computer) it fails. Here is a minimal example:

\documentclass[utf8]{beamer}

\RequirePackage{ifthen}
\newif\ifdetails
\newcommand{\details}[1]{\ifdetails#1\fi}
\detailstrue

\begin{document}

\begin{frame}[fragile]{No Problems Here}
\details{Works fine, really.}
\end{frame}

\details{
\begin{frame}[fragile]{But Issues Here}
Why??!?
\end{frame}
}

\begin{frame}[fragile]{Again, All Good}
\details{Works fine, again.}
\end{frame}

\end{document}


This works fine when \detailstrue is not set, but otherwise fails with

(./demo1.vrb
! Extra }, or forgotten \endgroup.
\endframe ->\egroup
\begingroup \def \@currenvir {frame}
l.2 Why??!? \end {frame}
\fi


(As you can see, it only fails for the \details{} command that is wrapped around a frame. The ones used inside a frame are perfectly fine.)

From googling I learned that I should rather use etoolbox, so I replaced the \details definition by:

\usepackage{etoolbox}
\newbool{details}
\newcommand{\details}[1]{\ifbool{details}{#1}{}}
\booltrue{details}


This also works well when \newbool{details} is not present, but again fails otherwise:

(./demo2.vrb
! Extra }, or forgotten \endgroup.
\endframe ->\egroup
\begingroup \def \@currenvir {frame}
l.2 Why??!? \end {frame}


I finally tried to leverage Beamer's own mechanism for hiding frames and defined my own environment for this:

\newenvironment{frameOn}[2]{\ifbool{#1}{\begin{frame}[fragile]{#2}}{\begin{frame}<0>[noframenumbering]{}}}{\end{frame}}

...

\begin{frameOn}{details}{But Issues Here}
Why??!?
\end{frameOn}


Again, all is well when the boolean flag is not set, but the same failure occurs otherwise:

(./demo3.vrb
! Extra }, or forgotten \endgroup.
\endframe ->\egroup
\begingroup \def \@currenvir {frame}
l.3 \end{frameOn}


Am I missing something obvious here? How can I exclude full slides programmatically? Thanks for any insights :-)

• Works without the [fragile], so has something to do with that. – Torbjørn T. Nov 27 '17 at 12:28
• Why do you want all frames to be fragile? You should only use that with verbatim content. – TeXnician Nov 27 '17 at 12:44
• You can't do this with fragile frames. You can try \ifdetails ... \fi instead but imho you should better implement such a switch with mode specifications. Btw: Your command doesn't use the ifthen package, that's a low-level \if. – Ulrike Fischer Nov 27 '17 at 13:12
• @TeXnician: I actually use lstlisting a lot (these are programming trainings). So I usually need [fragile]. – Nicole Nov 27 '17 at 15:04
• @UlrikeFischer: "You can't do this with fragile frames." -- The weird thing is: This worked 6 weeks ago (as I said, I have a large slide deck and I extracted a subset from it in October, using the initial definition of \details I gave above). I'm a bit dumbfounded on what happened to LaTeX that made it not work any more... – Nicole Nov 27 '17 at 15:06

Here is an alternative way to turn off a frame.

\documentclass[utf8]{beamer}

%\RequirePackage{ifthen}
\newif\ifdetails
\newcommand{\details}[1]{\ifdetails#1\fi}
\detailstrue

\begin{document}

\begin{frame}[fragile]{No Problems Here}
\details{Works fine, really.}
\end{frame}

\begin{frame}<\ifdetails1-\else0\fi>[fragile]{But Issues Here}
Why??!?
\end{frame}

\begin{frame}[fragile]{Again, All Good}
\details{Works fine, again.}
\end{frame}

\end{document}

• Yes, that's what Ulrike hinted at -- thank you for elaborating! – Nicole Nov 27 '17 at 17:21
• Is that a mode specification? I thought I was specifying overlays. – John Kormylo Nov 28 '17 at 14:47