References Truncated in Beamer Presentation prepared in Knitr/RMarkdown

♀尐吖头ヾ 提交于 2019-12-18 02:57:11

问题


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?


回答1:


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...



回答2:


{.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}



回答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.



来源:https://stackoverflow.com/questions/35677857/references-truncated-in-beamer-presentation-prepared-in-knitr-rmarkdown

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!