3.1 Bibliographies and citations
For an overview of including bibliographies in your output document, you may see Section 2.8 of Xie (2016). The basic usage requires us to specify a bibliography file using the
bibliography metadata field in YAML. For example:
where the BibTeX database is a plain-text file with the
*.bib extension that consists of bibliography entries like this:
Items can be cited directly within the documentation using the syntax
key is the citation key in the first line of the entry, e.g.,
@R-base. To put citations in parentheses, use
[@key]. To cite multiple entries, separate the keys by semicolons, e.g.,
[@key-1; @key-2; @key-3].
3.1.1 Changing citation style
By default, Pandoc will use a Chicago author-date format for citations and references. To use another style, you will need to specify a CSL (Citation Style Language) style file in the
csl metadata field, e.g.,
To find your required formats, we recommend using the Zotero website, which makes it easy to search for and download your desired style.
CSL files can be tweaked to meet custom formatting requirements. For example, we can change the number of authors required before “et. al” is used to abbreviate them. This can be simplified through the use of visual editors such as the one available at http://editor.citationstyles.org.
3.1.2 Add an item to bibliography without using it
By default, the bibliography will only display items that are directly referenced in the document. If you want to include items in the bibliography without actually citing them in the body text, you can define a dummy
nocite metadata field and put the citations there.
3.1.3 Add all items to bibliography
If we do not wish to explicitly state all of the items within the bibliography but would still like to show them in our references, we can use the following syntax:
This will force all items to be displayed in the bibliography.
3.1.4 Include appendix after bibliography
By default, the bibliography appears at the very end of the document. However, there can be cases in which we want to place additional text after the references, most typically if we wish to include appendices in the document. We can force the position of the references by using
<div id="refs"></div>, as shown below:
We can improve this further by using the bookdown package, which offers a special header for the appendix as shown with the syntax below:
The numbering style of appendices will be automatically changed in LaTeX/PDF and HTML output (usually in the form A, A.1, A.2, B, B.1, and so on).
Xie, Yihui. 2016. Bookdown: Authoring Books and Technical Documents with R Markdown. Boca Raton, Florida: Chapman; Hall/CRC. https://github.com/rstudio/bookdown.