5  Citations and bibliographies

In this chapter, you will
  • learn how to add citations and a bibliography to a quarto document if the style you want

Quarto can add citations and a bibliography to a document. Use the bibliography field in the YAML to point to the bibliography file.

title: "My Manuscript"
output: html_document
bibliography: reproducibility.bib

The bibliography file can be in one of several formats, including bibTeX (*.bib). Any reference manager should be able to export to a bibTeX file.

5.1 Citations

Use the citation keys from the bibliography to cite the reference in the text. So to cite the reference with the citation key “Cooper2017” we would use.

Reproducible code [@Cooper2017] ...
@Cooper2017 discuss ...

The output depends on the csl file (see below). Using the default author-date style gives

Reproducible code (Cooper and Hsing 2017)
Cooper and Hsing (2017) discuss …

In the visual editor, type @ to get suggestions from the bibliography. This is not so useful if you have many references. Alternatively, summon the import anything tool by typing ctrl + / and opening the citation menu, which lets you search for references in the bibliography or add new ones.


Add a citation to Töpper et al (2018) to the introduction to your quarto document as an example of climate change impacts on terrestrial ecosystems.

5.2 Citation style

If you don’t like the default citation style, or you want to submit a manuscript to a journal with an overly pedantic editor, you can change the citation style by specifying a csl file in the YAML.

title: "My Manuscript"
output: html_document
bibliography: reproducibility.bib
csl: plos.csl

The csl (Citation Style Language) file defines the citation style. There are thousands of citation style available from http://zotero.org/styles (there are specific formats for publishers and many journals).


Change the csl file from nordic-journal-of-botany.csl to plos.cls. Render the document to see how the citations change in the text and in the bibliography.

5.3 Citation problems

Unfortunately, there can be problems with the bibliography and citation. Most can be solved by googling the error message. A few common problems are addressed here.

5.3.1 Incorrect capitalisation

Many CLS styles convert the title to title case (i.e. only first letter of the first word is capitalised). This can be annoying as names (people, countries, species) can be given in the wrong case.

A paper with the title

Population ecology of polar bears at Svalbard, Norway.

may appear as

Population ecology of polar bears at svalbard, norway.

This can be fixed by editing the bibtex file, putting braces around the word with capitals that need to be kept.

Population ecology of polar bears at {Svalbard}, {Norway}.

5.3.2 Accents and other special characters

The tool-chain that processes quarto files can sometimes fall over with accented characters or other diacritic marks in the references. The error message will look something like this

! Package inputenc Error: Unicode character ́ (U+0301)
(inputenc)                not set up for use with LaTeX.

One solution is to edit the bibtex file to replace the accented character with an escaped code. For example, the “í” in “Martínez” could be replaced by “\’{i}”.

5.4 Bibliography placement

By default, the bibliography is placed at the end of the document. It will be given the header “References”. If you want a different header, end the document with it.

# Conclusions

Quarto is cool.

# Bibliography {-}

The {-} stops quarto from numbering the reference section header.

If you want to move the bibliography, for example because you need to finish with an appendix, you need to use this bit of magic.

# Conclusions

Quarto is very cool.

# References {-}

::: {#refs}

# Appendix A
Cooper, Natalle, and Pen-Yuan Hsing. 2017. A Guide to Reproducible Code in Ecology and Evolution. British Ecological Society. http://www.britishecologicalsociety.org/wp-content/uploads/2017/12/guide-to-reproducible-code.pdf.