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}
8
  • 1
    Most likely frame does not see the correct \endframe code anymore
    – user31729
    Jul 2, 2016 at 10:33
  • 1
    That's one of the many reasons you should neither have allowframebreaks nor fragile as default options. Jul 2, 2016 at 11:25
  • Redefining \frame is a very bad idea. It's a rather complicated command and your naive redefinitionis too naive.
    – egreg
    Jul 2, 2016 at 20:00
  • @samcarter Yes. Though the OP is not setting fragile as default.
    – cfr
    Jul 2, 2016 at 20:04
  • @egreg It is David's redefinition, isn't it?
    – cfr
    Jul 2, 2016 at 20:05

1 Answer 1

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

4
  • thank you for your time and explanation cfr i am sure it wasn't not an easy thing to understand.
    – Cfun
    Jul 3, 2016 at 2:11
  • This way of handling fragile content crops up reasonably often. It is not specific to Beamer.
    – cfr
    Jul 3, 2016 at 2:40
  • 3
    You forgot warnings about usage in parallel universe and extra-dimensions :) Jul 3, 2016 at 9:53
  • How can I have the title in this slide env? Aug 17, 2020 at 2:38

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .