Jack Henry
Jack Henry

Reputation: 65

How do I add citations using rmarkdown

I am having some trouble getting citations to work in rmarkdown.
I use write_bib() to generate a bibliography file which seems to work.

knitr::write_bib("knitr", "package.bib")
@Manual{R-knitr,
  title = {knitr: A General-Purpose Package for Dynamic Report Generation in R},
  author = {Yihui Xie},
  year = {2020},
  note = {R package version 1.29},
  url = {https://CRAN.R-project.org/package=knitr},
}

However when I try to use this in the document like this.

---
title: "Example"
output: html_document
Bibliography: package.bib
---

[@R-knitr]

I get this

No Citation

I think I am missing something but I cannot work out what it is.
Thanks in advance for any help.

Upvotes: 2

Views: 102

Answers (1)

Giulio Centorame
Giulio Centorame

Reputation: 700

Rmarkdown metadata are formatted in YAML, which is case sensitive. The correct format would be

---
title: "Example"
output: html_document
bibliography: package.bib
---

Upvotes: 3

Related Questions