Zotero and Better BibTeX
Our Bookdown workflow uses the open-source Zotero bibliography manager, with the Better BibTeX extension, to simplify the process of creating source notes and a bibliography. Rather than typing full references directly into the text, you can insert a short citation key into the book manuscript, and the tools will automatically generate the desired references in your preferred format (we like Chicago-style endnotes), with an alphabetized bibliography of all sources cited at the end.
After you’ve installed the tools, here’s an overview of the workflow:
- Create an entry for each source (book, journal article, document, etc.) in your Zotero library.
- Select and upload your preferred citation style in
- For each source, Better BibTeX generates a unique citation key, similar to
tyackOneBestSystem1974, which you can paste with formatting to create a note in the book manuscript.
- Each time before you build your book inside Bookdown, export your Zotero library or collection in
.bibformat into your Bookdown repository, which supplies the reference data to match your citation keys in the text.
Here are more detailed instructions to install, set up, and use Zotero and Better BibTeX in a Bookdown workflow. Remember that this workflow may not be ideal for novice computer users. But if you have multiple citations, it will save you time in the long run.
Download and install Zotero for Mac, Windows, or Linux. Add connectors to your preferred browsers to automatically upload bibliographic data for your sources.
Install the Better BibTeX extension and follow all of the site’s instructions for initial setup.
At the top of each entry in Zotero, the extension will generate a unique citation code, such as
Copy and paste the citation code into your Markdown text, and add a caret, square brackets, and the at symbol
^[@tyackOneBestSystem1974]. See more options in the Style Guide. Or you can set Zotero preferences > Export > Better BibTeX Quick Copy to use Zotero’s drag-and-drop quick copy feature.
Tip: If you use R Studio’s built-in text editor, see this blog post on how it supports Zotero citations.
Go to the Zotero Style Repository to find your preferred citation style (such as
chicago-fullnote-bibliography.csl). Upload this file to your Bookdown repository, and also add it to your book’s
index.Rmdsettings for both the HTML and PDF editions.
Each time before your build your book in Bookdown, export an updated Zotero bibliography (in
.bibformat) from your Zotero library or collection, and upload into your Bookdown repo, following these steps:
- A. Select Library > Right-click to export the collection
- B. Select format > Better BibLaTeX (IMPORTANT: We use this setting, rather than “Better BibTex,” because “Better BibLaTex” includes full dates in newspaper citations, and URLs). Also, we leave all of the checkboxes blank during the export, and do not select “keep updated.” This means that if your Better BibTex citation codes suddenly change in Zotero because the author, title, or year changed, then you are responsible for running find-and-replace to make these edits in the text of the book.
- C. Save the output in
.bibformat, save into your book repo, and be sure to add the same filename to your settings in
index.Rmd, as shown in these excerpts:
bibliography: ontheline.bib citation-style: chicago-fullnote-bibliography.csl ... output: bookdown::gitbook: ... pandoc_args: [ "--csl", "chicago-fullnote-bibliography.csl" ] ... bookdown::pdf_book: ... citation_package: default pandoc_args: [ "--csl", "chicago-fullnote-bibliography.csl" ]
In our Bookdown workflow, which uses the Chicago full-note bibliography style, this Zotero source type entries appear correctly formatted:
- Book chapter
- Journal article
- Web page
- Blog post – But we avoid this because Zotero Chicago-style entry inserts “(blog)” into citation title. Instead, we prefer to reset the type to Web page.
- Document – Use this all-purpose entry in place of other types: Law case, Presentation, Interview, Video recording, Television broadcast, etc. Insert important details (such as the archival location information) in the Publisher field.
To help other researchers find items cited in this book, include URLs in Zotero entries whenever feasible, even if not required by convention. For example, some print-only books and documents are hard to locate, so include an OCLC WorldCat permalink to make them easier to find (example: http://www.worldcat.org/oclc/20683509). Also, if a print source has been digitized by HathiTrust, Google Books, or the Internet Archive, add one of these URLs to the Zotero entry.
Reminder: Chicago full-note works exactly as it was designed, meaning that the second instance of a citation currently appears as an abbreviated note (author, with title when appropriate).
Demo: Here’s a text-only note, with no Zotero citation.249
To create a note with citations only, separate Zotero/BibTeX citation keys with semi-colons:250
Since notes also may include text and punctuation in Markdown syntax, always insert a caret symbol prior to the brackets to demarcate a note:251
Remember that the
chicago-fullnote-bibliography.csl format is designed to automatically shorten the note after it its first reference.
Customized to restart endnote numbering in each chapter & subchapter
Note that this publication contains customized code in
style.css to restart endnote numbering in each chapter and subchapter (aka section), to match a traditional history book publication. See relevant code on GitHub.
TODO: Fix known issue: Using Bookdown version 0.16 as of January 2020, note numbering with customized code appears differently across editions, and needs to be addressed prior to final PDF publication:
In the Web HTML edition, customized code in
style.cssrenumbers endnotes at the beginning of each chapter (e.g. 2) and subchapter (e.g. 2.1), as desired by the author.
But in the PDF edition, endnote renumbering begins only at each chapter, not subchapter, regardless of the custom CSS code. Probably need to change a Pandoc LaTeX setting.
In the MS Word edition, footnotes (rather than endnotes) are continuously numbered without breaks across the entire document, regardless of the custom CSS code.
Also, avoid placing notes in image captions, since URLs cause an extra } symbol to appear when generating PDF version, which crashes the build. Instead, place dynamic reference in the body text immediately before the image, along with footnote ref.
On The Line © 2021 by Jack Dougherty and contributors is freely shared under a Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International license.