[Tex/LaTex] beamer’s fragile frame as default

beamerverbatim

Is there a way to specify fragile mode as default for all frames? Now I know how to define a fragile frame: \begin{frame}[fragile].

Best Answer

You could define your own frame environment like it is explained in the user manual p.62, e.g.:

\newenvironment{xframe}[2][]
  {\begin{frame}[fragile,environment=xframe,#1]
  \frametitle{#2}}
  {\end{frame}}

The environment option does the trick. It tells beamer that the frame ends with an \end{xframe} now.

Note that the frame has a complex set of optional arguments, including two < > and to optional(!) braced arguments for the frame title and sub-title. Not all of these arguments might be supported by the above code. You might write it better as:

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

which should support both optional title and sub-title arguments. You also can define the frame title using an explicit \frametitle command.

Another, more complex alternative is to use the xparse package to define xframe with the same arguments of frame and pass it along.

Related Question