This describes how to use RStudio, R Markdown, Firefox, Zotero, and Amazon to author documents so that referencing is straightforward and correct.

The following files may serve as guides:

1 Install the machinery

1.1 Install the RStudio IDE

Get the RStudio IDE and install it.

1.2 Install Firefox

Get Firefox and install it.

1.3 Install Zotero for Firefox

Install Zotero for Firefox by following these Zotero Installation Instructions.

1.4 Install zotero-better-bibtex for Firefox

Install zotero-better-bibtex for Firefox by following the instructions in this Zotero/Pandoc Integration recipe. (I used the zotero-better-bibtex option. I haven’t tried the zotxt option, which may be just as good.)

2 Create and populate a Zotero collection of references

Create a Zotero references collection for a topic of interest (e.g. ‘Authoring’). The Zotero quick start guide shows how to do this.

Add references to the collection using the Zotero window opened by clicking the Zotero (‘Z’) icon now available in the Firefox task bar.

An easy way to add a book is to find it at Amazon.com then add its details (author, title, date, publisher, …) to the collection by clicking the ‘Save to Zotero’ icon next to the Zotero icon in the Firefox task bar.

3 Create your document (essay, article, book, …) as an R Markdown document

Use RStudio to create the document that needs a bibliography. This introduction to R Markdown documents shows how to get started. The authoring quick tour is instructive as well.

4 Integrate references from Zotero

  • Click on the ‘Z’ icon in the Firefox task bar to open the Zotero window in Firefox.

  • Right click on the collection folder (e.g. ‘Authoring’) which contains your references.

  • Choose “Export Collection…”

  • Choose “Better CSL YAML” as the format and click ‘OK’.

  • Choose a name and location for the resulting YAML document (e.g. ‘Authoring.yaml’) then click ‘Save’. (It is simplest to save the YAML document in the same directory as the document that needs a bibliography.)

  • Link the YAML document to your R Markdown document by adding this line to the header:

bibliography: Authoring.yaml

5 Add citations to your document

Add citations to your document. E.g.

Smith said that Jones had been disingenuous [@smith_pontification_2014 26]. Jones then resorted to an _ad hominem_ attack, saying "Smith is a wally." [@jones_refutation_2015 1]

Citation IDs (e.g. jones_refutation_2015) are visible in Zotero as the ‘Citation Key’ or in the generated YAML document as the ‘id’.

6 Generate your output

Press the ‘Knit’ button in RStudio to produce an HTML, Word, or PDF document incorporating the references you have cited. If all has gone well then the citations and bibliography will be automatically generated. To illustrate, the following results from the example citation snippet given above:

Smith said that Jones had been disingenuous (Smith 2014, 26). Jones then resorted to an ad hominem attack, saying “Smith is a wally.” (Jones 2015, 1)

The generated bibliography will be placed at the end of the document. References will only be generated for citations included in the document. A heading can be constructed with a bare section line. E.g.

# References

References

Jones, B. 2015. “A Refutation.” Pointless 25 (4).

Smith, A. 2014. “Pontification on Various Topics.” Aimless 16 (2).