When citation_package: biblatex
is included in the YAML of an .Rmd file, is it possible to specify the citation style? I can't find any information on this in the various R markdown manuals.
This issue was resolved in March 2016. As a lot of the documentation was written before this, it doesn't always show up in the guidance. However, the NEWS file on rmarkdown is always a good place to check for new features.
You can use the biblio-style
argument within the YAML. If you are familiar with latex, this is basically filling in the \usepackage[style= *SELECTED STYLE*]{biblatex}
. Here is an example. It will build a separate .bib
file for you:
---
output:
pdf_document:
citation_package: biblatex
keep_tex: TRUE
bibliography: test.bib
---
```{r}
knitr::write_bib(x = c("knitr", "rmarkdown") , file = "test.bib")
```
Some ref [@R-knitr]
Another ref [@R-rmarkdown]
# References
Adding the biblio-style
argument:
---
output:
pdf_document:
citation_package: biblatex
keep_tex: TRUE
bibliography: test.bib
biblio-style: authoryear
---
```{r}
knitr::write_bib(x = c("knitr", "rmarkdown") , file = "test.bib")
```
Some ref [@R-knitr]
Another ref [@R-rmarkdown]
# References
To find out more about different styles you can use, check here: https://www.sharelatex.com/learn/Biblatex_citation_styles
Taking this further: the YAML only provides a certain amount of control of the biblio-style. For example, you cannot specify
citestyle
directly. if you want to go further with changing the biblatex style, you will need to edit the pandoc template: https://github.com/rstudio/rmarkdown/blob/master/inst/rmd/latex/default-1.15.2.tex . This is a bit more advanced though, so only recommend it if you are comfortable with LaTex: https://rmarkdown.rstudio.com/pdf_document_format.html#custom_templates
© 2022 - 2024 — McMap. All rights reserved.