# Create a dummy dataset
<- data.frame(species = rep('Mycteroperca microlepis', 10),
dat gear = rep(c('HL','LL','SP','UA'),5),
age = 1:20,
size = seq(1,100,5))
write.csv(dat, file = 'dat_colval.csv',row.names = F)
Cross-references, bibliography and citations in Quarto files
- Insert citations and a bibliography into a Quarto document
- Customize citation and bibliography styles
- Add cross-referencing for tables, figures, and sections to direct your readers through your document
- Make dynamic captions for tables and figures
Today’s Carpentries Tutorials
During these workshops, we will be using the Carpentries Incubator Reproducible Publications with RStudio set of tutorials from UCSB (https://carpentries-incubator.github.io/reproducible-publications-quarto/) for most of our content. While we will be walking everyone through the tutorials, it may be helpful for you to look through the tutorials prior to attending. This will give you a feel for what we will be covering during each session, and will highlight some areas where you may need some additional work or assistance.
For this session, we will be covering the following topic:
We will again be relying on the forked repository from previous sessions. If you have not yet set up your forked repository in RStudio, follow the instructions here: https://nmfs-opensci.github.io/Quarto-Workshop-2024/tutorials/tutorial-2.html#instructions-for-forking-the-carpentries-example-repository
Zotero and Quarto: a Powerful Pairing
Zotero is a free, open-source reference manager that integrates directly into RStudio and Quarto. Reference managers make life easier by providing a central location to store, access, and organize your reference collection. Zotero takes this to the next level by allowing you to directly add references from your library into your Quarto document. Zotero stores its references in a flat text-based BibTex file, rather than a proprietary file format only readable by a single application. This makes sharing reference libraries across teams much easier and more open than with other, paid reference management software.
Import into Zotero from EndNote or Mendeley
If you currently use a different reference manager, you can import your library into Zotero. The steps are a bit different depending which reference manager you currently use:
To import from EndNote, you will first need to export your EndNote references as an XML file, which you can then import into Zotero. This link provides instructions for doing this: https://www.zotero.org/support/kb/endnote_import
Unfortunately, if you rely on EndNote Groups for organizing your references, this method will not preserve group structure. Zotero does have its own organizing feature, called Collections. If you wish to retain the group structure from EndNote as a set of Zotero Collections, you will either need to export groups into individual XML files and import groups individually, or export your full library as one file and re-organize your references into collections after import.Importing from Mendeley is a bit easier. Zotero can connect directly to a Mendeley online library: https://www.zotero.org/support/kb/mendeley_import
Connect Zotero and RStudio
Once your Zotero library is set up, you will need to connect it to RStudio. If you’re using RStudio and Zotero on your local machine, navigate to RStudio, click on the Tools menu in the top menu bar, and click on Global Options. In the dialogue box that pops up, click on R Markdown on the left side, and then Citations in the top menu:
Select the Local option in the Zotero Library dropdown menu. Click the Browse button and navigate to the folder where your Zotero library data is stored. If you have multiple Zotero libraries, select the one you would like to use. Check the box for Use Better BibTeX for citation keys and BibTeX export; this option gives you many more fields and reference types to choose from when adding references.
You can also connect Zotero if you are using RStudio on a machine that does not have access to a local Zotero installation or in the cloud (our JupyterHub, for example). Zotero provides a web-based service that will synchronize your library between your local installation and an online account. You will need to create a Zotero account, which you will then need to link with a local Zotero install to synchronize your library (Edit -> Settings -> Sync).
Once your Zotero library is synced to Zotero Web, create a Zotero API key to access your library from RStudio. Give your key a name (like RStudio or JupyterHub), and give the key Read Only access to your personal library and groups:
Click Save Key, then copy the resulting string to your clipboard. Back in your RStudio Citations options, select the Web dropdown item next to Zotero Library, and paste your Web API Key copied from Zotero into the appropriate space:
You can verify that the key was created and copied over correctly by clicking the Verify Key button. Once you’ve verified that the key works, click OK, exit out RStudio, and re-open. If using JupyterHub, you may need to restart your JupyterHub instance. Next time you open a Quarto document in RStudio, you will be able to insert a citation directly from your Zotero library using the @ symbol.