Beamer: Strange spacing in references with biblatex apa-style

I stumbled upon these two spacing errors (marked with red numbers):
enter image description here

I guess the first space is not really an error, but simply English spacing (\nonfrenchspacing). Can it be turned off (without changing the language)? \frenchspacing does not seem to have an effect on the references.

But I don’t understand where the second spacing error is coming from. Has anyone got a clue?

Here is the code:


\usepackage[style=apa, backend=biber,doi,url]{biblatex}

@article {Thomas1975,
  author = {Thomas, Ewart and Weaver, Wanda},
  title = {Cognitive processing and time perception},
  journal = {Attention, Perception, \& Psychophysics},
  issn = {1943-3921},
  pages = {363--367},
  volume = {17},
  doi = {10.3758/BF03199347},
  year = {1975}




Without beamer (\documentclass{article}) everything looks fine:

enter image description here

Solutions Collecting From Web of "Beamer: Strange spacing in references with biblatex apa-style"

The spacing and punctuation issues are associated with patches beamer applies to biblatex bibliography macros for changing colours within bibliography items. These can be found in beamerbaselocalstructure.sty.

Extra whitespace in the first problem is associated with \usebeamercolor. This can be resolved by issuing biblatex‘s \unspace.

To solve the second problem we can set punctuation before changing the colour. This will suppress any spurious punctuation generated by \newunit or \setunit in the existing drivers and bibliography macros.

Here are some revised patches demonstrating these ideas. A new patch for the labeltitle bibliography macro handles the case where author-year styles use label or labeltitle as a fallback for labelname.

        \usebeamercolor[fg]{bibliography entry author}}{}{}
       {\ifboolexpr{ test {\ifcsundef{abx@field@label}}
          and test {\ifcsundef{abx@field@labeltitle}} }{}{\let\bbx@tempa\labelnamepunct}}{}{}
        \bbx@tempa\newblock\unspace\usebeamercolor[fg]{bibliography entry title}}{}{}
        \newblock\unspace\usebeamercolor[fg]{bibliography entry note}}{}{}}

Instead of editing the beamer style file, you can modify the existing patches just after \begin{document}.


  {\ifboolexpr{ test {\ifcsundef{abx@field@label}}
     and test {\ifcsundef{abx@field@labeltitle}} }{}{\let\bbx@tempa\labelnamepunct}}{}{}
  {\newblock\usebeamercolor[fg]{bibliography entry title}}
  {\bbx@tempa\newblock\unspace\usebeamercolor[fg]{bibliography entry title}}{}{}
  {\newblock\usebeamercolor[fg]{bibliography entry note}}
  {\newblock\unspace\usebeamercolor[fg]{bibliography entry note}}{}{}

Here’s your entry printed with some different bibliography margins.

enter image description here

The patches appear to give the desired effect for standard biblatex styles, but thorough testing is needed. The solution doesn’t resolve issues for a few (hopefully edge) cases in biblatex-apa. These include entries that don’t have any data to form a label (i.e. labelname, label, labeltitle and labelyear all missing) and biblatex-apa‘s overriding of useeditor and friends per-entry option settings (e.g. britannica in the above document).

Unresolved issues are probably worse for some other contributed styles. Surely beamer can’t account for all of them. Perhaps the best approach is to have style authors tailor the patches as needed.

The problem here is one that I suspected could occur: adding beamer colours to bibliographies is something of a hack, and is more risky with biblatex than with traditional BibTeX styles.

When adding to biblatex styles, we have to target the drivers ‘during’ the formatting: with traditional BibTeX, it’s essentially done ‘after’ the formatting. That’s an issue because the formatting produced by biblatex depends on the output, but the colour-control inserts affect that. For example, the standard biblatex set up is

    test {\iffieldundef{title}}
    test {\iffieldundef{subtitle}}

whereas for the apa style it’s


The important line here is \setunit{\addspace}: it will insert a space ‘after’ the current material. Unfortunately, the colour code is seen as ‘output’ by biblatex (there is a whatsit in the output stream, which prevents biblatex ‘seeing’ what is going on).

Now, the question is what to do about this. I’m not sure there is a general fix, as the appropriate place to insert the colour code depends on the biblatex driver in use. So perhaps the best thing that can be done is to offer an option not to add in any colours.