# Issues

Issue #16 resolved

# Make bibliography code biblatex-aware

Joseph Wright
created an issue

beamer automatically picks up bibliographies from the standard styles and alters the formatting to look better in a presentation. The biblatex package makes bibliographies in a very different way, and so requires an alternative approach to the changes.

Bump!

I have written some code that integrates biblatex into beamer. Feel free to include and adapt it in a future release.

\AtBeginBibliography{\renewcommand*{\makelabel}[1]{\hss\structure{#1}}\let\small\relax}
% use beamer icons for bibliography
\renewenvironment*{thebibliography}
{\list
{\ifthenelse{\equal{\thefield{entrytype}}{book}%
\or\equal{\thefield{entrytype}}{booklet}%
\or\equal{\thefield{entrytype}}{collection}%
\or\equal{\thefield{entrytype}}{manual}%
\or\equal{\thefield{entrytype}}{periodical}%
\or\equal{\thefield{entrytype}}{proceedings}%
\or\equal{\thefield{entrytype}}{thesis}}%
{\setbeamertemplate{bibliography item}[book]}%
{\setbeamertemplate{bibliography item}[article]}%
\usebeamertemplate{bibliography item}}
{\settowidth{\labelwidth}{\usebeamertemplate{bibliography item}}%
\setlength{\leftmargin}{\labelwidth}%
\setlength{\labelsep}{\biblabelsep}%
\setlength{\itemsep}{\bibitemsep}%
\setlength{\parsep}{\bibparsep}}%
\renewcommand*{\makelabel}[1]{\hss##1}}
{\endlist}
\makeatletter
\pretocmd{\abx@macro@author}{\usebeamercolor[fg]{bibliography entry author}}{}{}
\pretocmd{\abx@macro@editor}{\usebeamercolor[fg]{bibliography entry author}}{}{}
\pretocmd{\abx@macro@title}{\printtext{\strut}\newblock\usebeamercolor[fg]{bibliography entry title}}{}{}
\apptocmd{\abx@macro@title}{\printtext{\strut}\newblock\usebeamercolor[fg]{bibliography entry note}}{}{}
\makeatother



It uses the ifthen and etoolbox packages. The code is of a "works for me" quality, but could use some testing and improvement. IIRC there are sometimes issues with spacing, due to the "\printtext{\strut}\newblock" construct that I used to make biblatex flush its punctuation buffer before the color changes.

I don't know how you handle package dependencies in beamer, I would use something like

\RequirePackage{scrlfile}
\AfterPackage{biblatex}{%
%% code
}

1. reporter

I'm on holiday for a few days: will take a look next week at this properly :-)

2. reporter

I've taken a look at the the suggested code and used it as the basis for some biblatex support. At the present time this is relatively basic, but it does work: see 06980b083c2f . One of the issues is that biblatex works very differently to the standard BibTeX styles, and a lot of the stuff that is currently in beamer is very much tided to those. (Indeed, I suspect you'll l get odd results even with other BibTeX styles even if they don't use natbib or biblatex.)

I'd appreciate some thoughts on what is and is not needed and I'll see what can be done. I suspect doing an item by item uncover will be very challenging as it means messing about with the biblatex method for producing lists. Varying icons might work better, but I'm yet to find a nice method.

What is probably needed is a bit of testing. Please try things out and see what breaks! I'm leaving the bug open for the moment pending feedback, as this is not a simple 'yes it is fixed' item.

3. Hi,

I'm relatively new to biblatex, but I think the proper way to integrate it with beamer is to write a style-file that mimicks beamer's behaviour. In biblatex jargon, this could be done either by rewriting the "driver" for each bib type, or by modifying the "formatting directives" for each field. However, both solutions aren't perfect, require to duplicate a lot of biblatex code, and only integrate with beamer to a certain extent.

I chose the first because it is closer to the way beamer prints the bibliography and looks more natural for a bbx file. The code is a rewrite of the drivers found in standard.bbx and looks like this:

\DeclareBibliographyDriver{article}{%
\usebeamercolor[fg]{bibliography entry author}%
\usebeamerfont{bibliography entry author}%
\usebibmacro{bibindex}%
\usebibmacro{begentry}%
\usebibmacro{author/translator+others}%
\setunit{\labelnamepunct}\newblock
\usebeamercolor[fg]{bibliography entry title}%
\usebeamerfont{bibliography entry title}%
\usebibmacro{title}%
\newunit
\printlist{language}%
\newunit\newblock
\usebeamercolor[fg]{bibliography entry location}%
\usebeamerfont{bibliography entry location}%
\usebibmacro{byauthor}%
\newunit\newblock
\usebibmacro{bytranslator+others}%
\newunit\newblock
\printfield{version}%
\newunit\newblock
\usebibmacro{in:}%
\usebibmacro{journal+issuetitle}%
\newunit\newblock
\usebibmacro{byeditor+others}%
\newunit\newblock
\usebeamercolor[fg]{bibliography entry note}%
\usebeamerfont{bibliography entry note}%
\usebibmacro{note+pages}%
\newunit\newblock
\iftoggle{bbx:isbn}
{\printfield{issn}}
{}%
\newunit\newblock
\usebibmacro{doi+eprint+url}%
\newunit\newblock
\newunit\newblock
\usebibmacro{pageref}%
\usebibmacro{finentry}}


I simply inserted the \usebeamercolor and \usebeamerfont macros at the right spots. I didn't integrate the \usebeamertemplate macro because biblatex's \newblockpunct macro and block option are much better for this. But if more compatibility with beamer is wanted, one could as well issue a

\renewcommand{\newblockpunct}{\usebeamertemplate{bibliography entry xxx}}


at the right spot in the driver.

I attach the full .bbx and .cbx files, they work reasonably well for me. They are based on top of the authoryear style, which looks the most reasonable to be used in a presentation. Here's an example code that separates the bibliography in a book section and an article section.

\documentclass{beamer}

\usepackage[style=beamer]{biblatex}
\bibliography{bibfile}

\begin{document}

...

\begin{frame}[allowframebreaks]
\frametitle{References}

\defbibfilter{books}{\type{book} \or \type{booklet} \or \type{thesis}
\or \type{report} \or \type{collection} \or \type{manual}
\or \type{periodical} \or \type{proceedings}}
\defbibfilter{articles}{\not $$\type{book} \or \type{booklet} \or \type{thesis} \or \type{report} \or \type{collection} \or \type{manual} \or \type{periodical} \or \type{proceedings}$$}

\beamertemplatebookbibitems
\printbibliography[filter=books]
\framebreak
\beamertemplatearticlebibitems
\printbibliography[filter=articles]
\end{frame}

\end{document}

4. reporter

While this is a valid approach, it would need to be done for each biblatex style separately. The current beamer approach for the standard styles applies 'across the board', and so the same should really apply with biblatex.

At the moment, I think I'm calling this 'fixed', but will be quite happy to look again.