[Tex/LaTex] Why doesn’t frame option allowframebreaks work when using the label option

beamerframe-title

When compiling with the parameter label as in the MWE, allowframebreaks doesn't work. Why not?

Is there any difference between setting a frame title as a frame argument and by using \frametitle?

\documentclass{beamer}
\usetheme{Warsaw}
\usepackage{blindtext}
\begin{document}

\begin{frame}[allowframebreaks,label=frame1]{Title}
%\frametitle{Title}
\framesubtitle{Sub-title}
\blindtext
Text........ Text........ Text........ Text........ Text........
Text........ Text........ Text........ Text........ Text........
Text........ Text........ Text........ Text........ Text........ 
Text........ Text........ Text........ Text........ Text........ 
\end{frame}

\end{document}

Best Answer

There can be a difference between setting the title as an argument to frame and using \frametitle if the next thing TeX finds is a { because this will be interpreted either as the start of the frame's subtitle or as the start of the frame's content.

For example

\documentclass{beamer}
\usetheme{Warsaw}
\usepackage{blindtext}
\begin{document}
\begin{frame}{Title}{\centering A sunny day\par}And a gloomy one.
\end{frame}
\begin{frame}\frametitle{Title}{\centering A sunny day\par}And a gloomy one.
\end{frame}
\end{document}

demonstrates the difference between using the argument to frame

as argument

and using the macro

as macro


In beamerbaseframe.sty, we find

\define@key{beamerframe}{label}{\def\beamer@againname{#1}%
  {\let\@elt\beamer@labelsavecounter\beamer@overlaycounterresets}%
}

beamerbaseframesize.sty shows that allowframebreaks sets the toggle beamer@autobreak to true. Back in beamerbaseframe.sty we find, for example,

\newenvironment{beamer@frameslide}{%
  \ifbeamer@autobreak\else% i.e. unless allowframebreaks is requested ...
    \ifx\beamer@againname\@empty% if label isn't set ...
      {\let\@elt\beamer@restorecounter\beamer@overlaycounterresets}%
    \else% otherwise i.e. we have label=<some label> ...
      {\let\@elt\beamer@labelrestorecounter\beamer@overlaycounterresets}%
    \fi%
  \fi%
  ...

So the mechanism activated by passing the label option to the frame environment is only used at all if allowframebreaks is not set to true.

It is important to appreciate that the label option is not equivalent to saying \label{} at any point. The label option is designed for something significantly more complex. Its main purpose is to support \againframe. For this purpose it names each slide of the current frame. Each slide also gets a label. If label=mylabel, then the slides get labels mylabel<1>, mylabel<2> etc. As a convenience, an additional label is set on the first slide mylabel. So, assuming the frame has n slides, setting this option is equivalent to saying

\label{mylabel}\label{mylabel<1>}% on the first slide
\label{mylabel<2>}% on the second slide
...
\label{mylabel<n>}% on the nth slide

This mechanism serves no purpose if allowframebreaks is set because overlays are disabled in this case.

Of course, you could code the option so that, if allowframebreaks is true, then label issues \label{} on the first frame. However, this would be potentially confusing since it would mean that the label option activated very different mechanisms depending on whether frames were allowed to be broken or not.