latextexbeamer

Combine labels and allowframebreaks in beamer class


For my latex beamer presentations, I have used a labeling system with short, long, and both, to quickly switch between short presentations and longer ones.

To do so, I use the code \includeonlyframes{both,short} (for a short presentation, and likewise \includeonlyframes{both,long} for a long one) in the preamble, and put a label to each slide like this:

\begin{frame}[label=both]

This system has served me relatively well in the past, but it has also created some problems. The particular one I am trying to solve is that my references exceed one slide. I tried to use allowframebreaks to solve this, so here is the code for my reference slide:

\begin{frame}[allowframebreaks,label=both]    
\frametitle{References}

\tiny    
    \bibliographystyle{apalike}    
    \bibliography{references}

\end{frame}

What happens now is that the first reference slide is displayed as it's supposed to, but the remaining ones aren't part of the pdf. I guess what is happening is that the label is only applied to the first slide, so due to my \includeonlyframes command in the preamble, the remaining reference slides are produced, but not included in the pdf. Does anyone have an idea how I could get around this problem?

Also, this is my first post here, so please let me know if something is unclear/badly explained etc.

Edit: Here's a minimal working example. I usually use natbib, but that didn't work with the example bibliography I used here. The issue still occurs, so I don't think natbib has anyhting to do with it.

\documentclass{beamer} 
%\usepackage{natbib}
\includeonlyframes{both,short}

\begin{document}

\begin{frame}[label=both] 
\frametitle{Frametitle} 
Some content for both presentations 
\end{frame}

\begin{frame}[label=short] 
\frametitle{Frametitle}
Some content for a short presentation 
\end{frame}

\begin{frame}[label=long] 
\frametitle{Frametitle}
Some content for a long presentation 
\end{frame}

\begin{frame}[label=long] 
\frametitle{Frametitle}
Some more content for a long presentation 
\end{frame}

\begin{frame}[allowframebreaks,label=both] 
\frametitle{References}
 %\tiny 
\nocite{*}
\bibliographystyle{apalike}
%\bibliography{references} \bibliography{xampl}
\end{frame}

\end{document}

Solution

  • You can use a similar approach as in https://tex.stackexchange.com/a/289637 and update it to use the current implementation of \beamer@@@@frame:

    \documentclass{beamer}
    \makeatletter
    \def\beamer@@@@frame<#1>[#2]{%
      \framewidth\textwidth
      \beamer@savemode%
      \gdef\beamer@mode{\mode<all>}%
      \def\beamer@frametemplate{}%
      \def\beamer@againname{}%
      \def\beamer@undolabels{}%
      \def\beamer@cramped{}%
      \def\beamer@displaybreak{}%
      \setbox\beamer@footins=\box\voidb@x%
      \beamer@autobreakcount=0\relax%
      \beamer@autobreaklastheight=16000pt%
      \beamer@zoomcount=0\relax%
      \beamer@noframenumberingfalse%
      \beamer@containsverbatimfalse%
      \beamer@isfragilefalse%
      \beamer@autobreakfalse%
      \beamer@shrinkfalse%
      \beamer@plainframefalse%
      \global\advance\beamer@zoomframecount by1\relax%
      \csname beamer@dosecondmode\beamer@defaultdosecondmode\endcsname%
      \ifbeamer@centered\setkeys{beamerframe}{c}\else\setkeys{beamerframe}{t}\fi%
      \setkeys{beamerframe}{environment=frame}%
      \setkeys{beamerframe}{#2}%
      \beamer@frametemplate%
      \ifbeamer@noframenumbering%
        \ifbeamer@isfragile%Fragile frames will be processed twice
          \stepcounter{framenumber}%
        \fi%
      \else%
        \stepcounter{framenumber}%do not set \label here - it interferes with AtBegin*
      \fi%
      {\let\@elt\beamer@savecounter\beamer@overlaycounterresets}
      \gdef\beamer@framestartpage{}%
      \gdef\beamer@whichframes{#1}%
      \ifx\beamer@framerestriction\@undefined\else% restriction stuff
        \expandafter\beamer@checkifinlist\beamer@framerestriction\relax%
      \fi%
      \ifbeamer@inlecture%
      \else%
        \gdef\beamer@whichframes{all:0}%
      \fi%
      \ifx\beamer@againname\@empty%
        \beamer@slideinframe=0\relax%
        \beamer@anotherslidefalse%
        \beamer@masterdecode{\beamer@whichframes}%
        \ifbeamer@anotherslide%
            \let\beamer@howtotreatframe\beamer@doseveralframes%
          \ifbeamer@containsverbatim%
            \let\beamer@howtotreatframe\beamer@dosingleframe%
          \fi%
          \ifbeamer@autobreak%
            \let\beamer@howtotreatframe\beamer@autobreakframe%
          \fi%
          \ifbeamer@isfragile%
            \let\beamer@howtotreatframe\beamer@doexternalframe%
          \fi%
        \else% no slides in frame
          \let\beamer@howtotreatframe\beamer@donoframe%
        \fi%
      \else% again mode
        \let\beamer@howtotreatframe\beamer@doseveralframes%
        \ifbeamer@isfragile%
          \let\beamer@howtotreatframe\beamer@doexternalframe%
        \fi%
        \ifbeamer@containsverbatim
          \let\beamer@howtotreatframe\beamer@dosingleframe
        \fi
        \beamer@slideinframe=0\relax%
        \beamer@anotherslidefalse%
        {\beamer@masterdecode{\beamer@whichframes}}%
        \message{^^J^^J \beamer@againname:\beamer@whichframes ^^J^^J}
        \ifbeamer@anotherslide%
          \message{^^J^^J \beamer@againname:I am Here ^^J^^J}
          \ifbeamer@autobreak%
            \let\beamer@howtotreatframe\beamer@autobreakframe%
          \fi%
        \fi    
      \fi%
      \beamer@howtotreatframe}
    \makeatother
    
    \includeonlyframes{both,long}
    
    
    \begin{document}
    
    \begin{frame}[allowframebreaks,label=both]   
    \nocite{*} 
    \frametitle{References}
    
    %\tiny    
        \bibliographystyle{apalike}    
        \bibliography{\jobname}
    
    \end{frame}
    
    \begin{frame}[label=long]
    content...
    \end{frame}
    
    \end{document}
    

    enter image description here