[Tex/LaTex] Break \printbibliography to multiple frames without [allowframebreaks]

beamerbiblatex

I am using mtheme for my Beamer presentation with XeLaTeX and Biber and I have a quite crowded bibliography. But when I try to add [allowframebreaks] I receive a "TeX capacity exceeded" error. I found out that this is an apparent bug with the theme (https://github.com/matze/mtheme/issues/20).

I want to modify the \printbibliography command so that it inserts a \framebreak after every five entries. How can I achieve this?

Best Answer

I present to you: the sledgehammer method.

Fortunately, biblatex allows us to hook into the very end of a bibliography entry with the bibmacro finentry, by default defined as \newbibmacro*{finentry}{\finentry}.

We define is

\renewbibmacro*{finentry}{\finentry\brf}

Where we define \brf as follows

\newcounter{bibitmctr}
\newcommand{\brf}{%
  \stepcounter{bibitmctr}%
  \ifnum\value{bibitmctr}=5%
    \setcounter{bibitmctr}{0}
    \framebreak
  \fi
}

MWE

\documentclass{beamer}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage[ngerman]{babel}

\usepackage[backend=biber]{biblatex}
\addbibresource{biblatex-examples.bib}

\newcounter{bibitmctr}
\newcommand{\brf}{%
  \stepcounter{bibitmctr}%
  \ifnum\value{bibitmctr}=5%
    \setcounter{bibitmctr}{0}
    \framebreak
  \fi
}

\renewbibmacro*{finentry}{\finentry\brf}
\begin{document}
  \nocite{maron,geer,cicero,wilde,knuth:ct:a,moore,nussbaum,vizedom:related,worman,
          knuth:ct:b,knuth:ct:c,knuth:ct:d,knuth:ct:e,knuth:ct:related,massa}
  \printbibliography
\end{document}

enter image description here

Related Question