References Truncated in Beamer Presentation prepared in Knitr/RMarkdown
Asked Answered
O

3

17

I'm currently preparing a presentation in RStudio (using RMarkdown and Knitr, outputting to a Beamer presentation) that has quite a few references.

I'm using a pretty typical YAML header:

---
title: "Title"
author: "Me"
date: "February 27th, 2016"
output: 
  beamer_presentation
csl: ../../apa.csl
bibliography: ../../RefenceDesk.bib 
---

This presentation compiles and the references appear as they should, but unfortunately they all appear on one slide (and actually run off the page). Is there any way to have the references appear on multiple slides?

Oao answered 28/2, 2016 at 2:3 Comment(0)
D
9

As @David above said in the comments:

For me it didnt work with ## References {.allowframebreaks} but it worked out with # References {.allowframebreaks}.

I would like to point out that, apparently for the reference slide to work you have to create a last slide with the same heading level es set by slide_level: __ at the YAML section.

So, the user should set one of the following:

  • # References {.allowframebreaks}. for those using slide_level: 1, OR
  • ## References {.allowframebreaks}. for those using slide_level: 2, OR
  • ### References {.allowframebreaks}. for those using slide_level: 3 and so on...
Damning answered 20/5, 2018 at 22:31 Comment(3)
It's {.allowframebreaks} not {.allowframebrakes} if anyone is failing because of the spelling..Marinelli
is it possible to set allowframebreaks for all slides (all levels) ?Durward
yes, it is. just append the option {.allowframebreaks} after every slide title. (there might be a way to change in in the yaml options for all slides, but I am not aware of.Damning
C
15

{.allowframebreaks} is the solution for multislides bibliographies in beamer. It works out of the box with regular pandoc templates (see my previous answer). However, knitr has a setting that prevents it, by redefining \widowpenalties in its beamer template. You can verify that if you examine the .tex file with keep_tex: true.

In my opinion, this is a bug. A quick fix would be to reset \widowpenalties to its default value. It can be done in your yaml front matter:

---
title: Title
header-includes:
  - \widowpenalties 1 150
output: 
  beamer_presentation
---

Then, you can indicate the reference section as such:

## References {.allowframebreaks}
Chabazite answered 28/2, 2016 at 10:51 Comment(2)
Interesting! I discovered {.allowframebreaks} last night, but it didn't do anything. I've just tried adding the header-includes - but it doesn't actually seem to change the values in the .tex file. After I compile, if I open the .tex file, it still says \widowpenalties 1 10000.Oao
For me it didnt work with ## References {.allowframebrakes} but it worked out with # References {.allowframebrakes}.Spaniel
D
9

As @David above said in the comments:

For me it didnt work with ## References {.allowframebreaks} but it worked out with # References {.allowframebreaks}.

I would like to point out that, apparently for the reference slide to work you have to create a last slide with the same heading level es set by slide_level: __ at the YAML section.

So, the user should set one of the following:

  • # References {.allowframebreaks}. for those using slide_level: 1, OR
  • ## References {.allowframebreaks}. for those using slide_level: 2, OR
  • ### References {.allowframebreaks}. for those using slide_level: 3 and so on...
Damning answered 20/5, 2018 at 22:31 Comment(3)
It's {.allowframebreaks} not {.allowframebrakes} if anyone is failing because of the spelling..Marinelli
is it possible to set allowframebreaks for all slides (all levels) ?Durward
yes, it is. just append the option {.allowframebreaks} after every slide title. (there might be a way to change in in the yaml options for all slides, but I am not aware of.Damning
O
3

While this goes outside of using the regular pandoc citation template, I have found another approach that can be used to put the references across slides but it relies on the natbib citation package.

In the YAML front matter, I added:

---
title: "Title"
output: 
  beamer_presentation:
    citation_package: natbib
bibliography: ../../RefenceDesk.bib 
biblio-style: "apalike"
---

The reference slide does not get a title and I cannot seem to adjust the font size (by using a \scriptsize at the end of the .Rmd file), but at least they appear coherently.

EDIT: For parsimony, I removed the csl: ../../apa.csl line, since natbib does not require it.

Oao answered 28/2, 2016 at 15:27 Comment(1)
Worked for me! If anyone gets a natbib-caused error ! LaTeX Error: \newblock undefined. then just add this line \newcommand{\newblock}{}Incursive

© 2022 - 2024 — McMap. All rights reserved.