3

Please see Beamer presentation: List of frames within a section / part. I have copy-pasted Gonzalo Medina's example code below. Uncommenting the [allowframebreaks] or using it in any other frame that is also to be listed in the lbf file results in an error. Is there a way of obtaining the same result WITH the use of [allowframebreaks], assuming the context requires its use ?

\documentclass{beamer}
\usetheme{Berkeley}

\newif\ifframeinlbf
\frameinlbftrue

\makeatletter
\newcommand\listofframes{\vfill\@starttoc{lbf\thesection}}
\makeatother

\addtobeamertemplate{frametitle}{}{%
  \ifframeinlbf
  \addcontentsline{lbf\thesection}{section}{\protect\makebox[2em][l]{%
    \protect\usebeamercolor[fg]{structure}\insertframenumber\hfill}%
  \insertframetitle\vfill}%
  \else\fi%
}

\begin{document}

\section{Test Section One}

\frameinlbffalse
\begin{frame}
\frametitle{List of Frames for Section One}
\listofframes
\end{frame}

\frameinlbftrue
\begin{frame}%[allowframebreaks]
\frametitle{Test Frame One One}
test
\end{frame}

\begin{frame}
\frametitle{Test Frame One Two}
test
\end{frame}

\section{Test Section Two}

\frameinlbffalse
\begin{frame}
\frametitle{List of Frames for Section Two}
\listofframes
\end{frame}

\frameinlbftrue
\begin{frame}
\frametitle{Test Frame Two One}
test
\end{frame}

\begin{frame}
\frametitle{Test Frame Two Two}
test
\end{frame}

\begin{frame}
\frametitle{Test Frame Two Three}
test
\end{frame}

\end{document}
Shrihari
  • 103

2 Answers2

1

MWE

With a more conventional approach, that is, making a subsection for each frame and touching beamer options, it is possible obtain a TOC with only the actual section highlighted and showing only the list of frames (=subsections) of that section.

Is a different display but hopefully make the same function (?) and the simpler code work without problems with allowframebreaks.

\documentclass{beamer}
\usetheme{Berkeley}
%\usetheme[hideothersubsections]{Berkeley}

%macros only to simplify commands in document  
\newcommand\newframeb[1]{%
\subsection[]{#1}\begin{frame}[allowframebreaks]{#1}}

\newcommand\newframe[1]{%
\subsection[]{#1}\begin{frame}{#1}}

\begin{document}

% This make the partial TOCs
\AtBeginSection[]
{\begin{frame}{Contents}
\tableofcontents[currentsection,hideothersubsections]
\end{frame}}

\section{Test Section One}
\newframe{Test Frame One One} Single frame \end{frame}
\newframeb{Test Frame One Two (breaked)}
Break  \vspace{3 cm} \\ frame \vspace{3 cm} \\
Break  \vspace{3 cm} \\ frame \vspace{3 cm} \\
\end{frame}

\section{Test Section Two}
\newframe{Test Frame Two One} test \end{frame}
\newframeb{Test Frame Two Two (breaked)} 
Break  \vspace{3 cm} \\ frame \vspace{3 cm} \\
Break  \vspace{3 cm} \\ frame \vspace{3 cm} \\
\end{frame}
\newframe{Test Frame Two Three} test \end{frame}

\end{document}
Moriambar
  • 11,466
Fran
  • 80,769
1

The problem is caused by the changes beamer makes to \insertframetitle (to add a \space\usebeamertemplate*{frametitle continuation} wrapped in a conditional) when the option allowframebreaks is used.

There are a couple of issues with this:

  1. \usebeamertemplate is not safe in an expansion-only context, as it looks for *s
  2. \usebeamertemplate* executes \usebeamercolor which is expanded at the wrong time

Here's a local fix that goes straight to the result of the *-parsing, and \protects the \usebeamercolor etc:

\documentclass{beamer}
\usetheme{Berkeley}

\usepackage{etoolbox}
\errorcontextlines=\maxdimen

\newif\ifframeinlbf
\frameinlbftrue

\makeatletter
\newcommand\listofframes{\vfill\@starttoc{lbf\thesection}}

\addtobeamertemplate{frametitle}{}{%
  \ifframeinlbf
  \bgroup
  \patchcmd\insertframetitle{\usebeamertemplate*{frametitle continuation}}{{{\protect\usebeamerfont{frametitle continuation}\protect\usebeamercolor[fg]{frametitle continuation}\beamer@usebeamertemplatedo{frametitle continuation}}}}{}{\errmessage{failed to patch}}
  \addcontentsline{lbf\thesection}{section}{\protect\makebox[2em][l]{%
    \protect\usebeamercolor[fg]{structure}\insertframenumber\hfill}%
  \insertframetitle\vfill}%
  \egroup
  \else\fi%
}
\makeatother

\begin{document}

\section{Test Section One}

\frameinlbffalse
\begin{frame}
\frametitle{List of Frames for Section One}
\listofframes
\end{frame}

\frameinlbftrue
\begin{frame}[allowframebreaks]
\frametitle{Test Frame One One}
test
\end{frame}

\begin{frame}
\frametitle{Test Frame One Two}
test
\end{frame}

\section{Test Section Two}

\frameinlbffalse
\begin{frame}
\frametitle{List of Frames for Section Two}
\listofframes
\end{frame}

\frameinlbftrue
\begin{frame}
\frametitle{Test Frame Two One}
test
\end{frame}

\begin{frame}
\frametitle{Test Frame Two Two}
test
\end{frame}

\begin{frame}
\frametitle{Test Frame Two Three}
test
\end{frame}

\end{document}

If you want to remove the continuation counter completely from the list of frames, instead of patching \insertframetitle, one could just do \beamer@autobreakcount=0 in its place (on the same line so again the change remains local).