46

This is a follow up on beamer's fragile frame as default. What are the drawbacks of setting the default frame to be fragile (or passing the optional fragile argument to all frames). The beamer user guide says

If a frame contains fragile text, different internal mechanisms are used to typeset the frame to ensure that inside the frame the character codes can be reset. The price of switching to another internal mechanism is that either you cannot use overlays or an external file needs to be written and read back (which is not always desirable).

Presumably writing and reading a file takes time and so this increases the time it takes to compile, but are there things that do not work in a fragile frame?

As for an MWE:

\documentclass{beamer}
\def\foo{Something that makes the fragile frame fail is: }
\begin{document}
\begin{frame}
    \foo
\end{frame}
\begin{frame}[fragile]
    \foo
\end{frame}
\end{document}

I am trying to understand what \foo would need to be defined as to cause problems.

  • 4
    The only issue that I remember encountering so far is in debugging. If you get an error (e.g. \foo is undefined), then without fragile, you get the line number of the \end{frame} in which the error occurred. On the other hand, with fragile, you just get the line number within the frame (the .vrb file), not of the frame itself. – cyberSingularity Oct 3 '13 at 21:27
  • 1
    It's difficult to define a new command in a fragile frame. – Paul Gaborit Nov 7 '13 at 0:10
  • @PaulGaborit Doing \newcommand{\bar}{bar} inside a fragile frame doesn't work, but \def\bar{}\renewcommand{\bar}{bar} does work. I think \newcommand fails because of the writing a file and reading it back in issue, making this a potential answer. That said, the need to use \newcommand within a frame and the simple work around, means it is not much of a drawback. – StrongBad Nov 7 '13 at 10:56
  • @StrongBad Any verbatim stuff doesn't work inside a non-fragile frame (i.e. source code listings). – Henri Menke Jan 26 '14 at 16:30
  • 1
    See tex.stackexchange.com/questions/159172/… for one case in which the need to use fragile proved problematic and the solution to the problem involved an alternative approach which avoided the need for fragile. – cfr Feb 12 '14 at 1:17
30
+100

there are no important drawbacks. It is also possible to define a new environment with the fragile option:

\documentclass{beamer}

\newenvironment{Foo}[1]
  {\begin{frame}[environment=Foo]{#1}}
  {\end{frame}}

\newenvironment{FooBar}[1]
  {\begin{frame}[fragile,environment=FooBar]{#1}}
  {\end{frame}}
\begin{document}

\begin{Foo}{title} 
\end{Foo}

\begin{FooBar}{title}
\end{FooBar}

\end{document} 

With fragile every contents is written into an external file and read back. Not a big deal but makes compiling slow. However, fragile is needed for verbatim material.

  • 1
    Well, does that mean that the option is useless and it should be activated always directly by the class? That seems strange to me :-/ – yo' Feb 15 '14 at 21:26
  • 13
    no, with fragile every contents is written into an external file and read back. Not a big deal but makes compiling slow. – user2478 Feb 15 '14 at 21:28
5

See this thread. Apparently the fragile option is incompatible with the allowframebreaks option, without some awkward finagling. So that's one drawback, in addition to the much slower compilation mentioned in the comments of the accepted answer.

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.