2

Based on etoolbox booleans, I am (un)selecting Beamer slides. When I try to do this with a fragile frame I run into errors. See MWE.

Could you explain why, and would you have a workaround for this? I would prefer to stay with etoolbox's booleans if possible.

Minimal working example (MWE)

\documentclass{beamer}
\usepackage{etoolbox}
\newbool{addcontent}
\booltrue{addcontent}

\begin{document}
  \ifbool{addcontent}{
    \begin{frame}[fragile]
      Fails...
    \end{frame}
  }{}
\end{document}

results in the following error:

File ended while scanning use of \next.

0
4

a fragile frame is like verbatim and can not be in the argument of another command. use the primitive form \ifaddcontent .....\fi not the form using {} arguments

\documentclass{beamer}
\usepackage{etoolbox}
\newbool{addcontent}
\booltrue{addcontent}

\begin{document}
  \ifaddcontent
    \begin{frame}[fragile]
      Fails...
    \end{frame}
 \fi
\end{document}
2
  • 1
    Thanks - extremely helpful! Just, Fails... may be replaced by Works... now ;)
    – matheburg
    Aug 24 at 19:05
  • For the sake of completeness, the inverse case or a switch can be realized via \else, e.g. \ifaddcontent\else.......\fi
    – matheburg
    Aug 25 at 6:09

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.