5

This is a follow-up question to this answer.

I noticed that the macro proposed returns error if the frame is loaded with the parameter fragile \begin{frame}[fragile]. Note that when issuing manually

\begin{frame}[fragile,allowframebreaks]

it doesn't returns any error (and it's not a question of parameter order). Why ?

\documentclass{beamer}

\let\oldframe\frame
\renewcommand\frame[1][]{\oldframe[allowframebreaks,#1]}

\begin{document}

\begin{frame}[fragile]
\begin{enumerate}
\item    something \item    something \item    something
\item    something \item    something \item    something
\item    something \item    something \item    something
\item    something \item    something \item    something
\item    something \item    something \item    something
\item    something \item    something \item    something
\item    something \item    something \item    something
\end{enumerate}
\end{frame}

\end{document}
Cfun
  • 1,840

1 Answers1

4

Do not try this at home! Not intended for individual, collective, aggregative, national, international, supranational, global, solar, intersystem, intergalactic or universal use for commercial, non-commercial, public, private, semi-private or third sector purposes.

Caveat emptor


The manual has this to say about fragile and environment (pp 60-1):

  • fragile ... tells beamer that the frame contents is “fragile.” This means that the frame contains text that is not “interpreted as usual.” For example, this applies to verbatim text, which is, obviously, interpreted somewhat differently from normal text.

    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).

    In detail, the following happens when this option is given for normal (pdf)LaTeX: The contents of the frame is scanned and then written to a special file named ⟨jobname⟩.vrb or, if a label has been assigned to the frame, ⟨jobname⟩.⟨current frame number⟩.vrb. Then, the frame is started anew and the content of this file is read back. Since, upon reading of a file, the character codes can be modified, this allows you to use both verbatim text and overlays.

    To determine the end of the frame, the following rule is used: The first occurence [sic.] of a single line containing exactly \end{⟨frame environment name⟩} ends the frame. The ⟨environment name⟩ is normally frame, but it can be changed using the environment option. This special rule is needed since the frame contents is, after all, not interpreted when it is gathered.

    ...

  • environment=⟨frame environment name⟩. This option is useful only in conjunction with the fragile option .... The <frame environment name> is used to determine the end of the scanning when gathering the frame contents. Normally, the frame ends when a line reading \end{frame} is reached. However, if you use \begin{frame} inside another environment, you need to use this option ...

    ... [because otherwise] TeX would “miss” the end ... since it does not interpret text while gathering the frame contents.

Modifying the example on 61, you could, therefore, use this to work around the various constraints.

\documentclass{beamer}
% modified from example on p 61
\newenvironment{slide}[1][]
{%
  \begin{frame}[allowframebreaks,#1]%
  }{%
  \end{frame}%
}

\begin{document}

\begin{slide}[fragile,environment=slide]
  \begin{enumerate}
    \item    something \item    something \item    something
    \item    something \item    something \item    something
    \item    something \item    something \item    something
    \item    something \item    something \item    something
    \item    something \item    something \item    something
    \item    something \item    something \item    something
    \item    something \item    something \item    something
  \end{enumerate}
  \begin{verbatim}
    \macro \macro \macro
  \end{verbatim}
\end{slide}

\end{document}

autobreaks with fragile content

cfr
  • 198,882