Bibliography Management in R Markdown with CiteDrive and RStudio

6 min readJun 23, 2022

This short guide explains how to use CiteDrive to manage references and bibliographies for your R Markdown project and integrate it with RStudio.

CiteDrive + RStudio

With CiteDrive, we offer a cloud-based and fully collaborative BibTeX-based platform for collecting, organizing, and managing references and bibliographies used by hundreds of data-driven researchers.
You can automatically export references to a BibTeX file in your R Markdown project. Each time you add, update or remove a reference, the application will update the BibTeX file in the RStudio project folder.

Guide: Project preparation and connecting both Apps

Please note that a small workaround is required if you use {rticles}. We will explain this at the end. Until then, you can follow along by reading this guide.

Step 1: Create a new Project at CiteDrive

First, let’s look at CiteDrive and create an R Markdown project. Click on the big R Markdown button + to create a new project. After that, enter the name of your choice.

You will notice that your project is empty when you open it for the first time. Let us populate your new project with some references.

The easiest way will be using our free and easy-to-use browser extension, the CiteDrive companion, available on the Chrome Web Store. Alternatively, you can use the Microsoft Edge or Firefox add-on if you prefer.

Be sure to pin the extension in the browser for easy access.


Step 2: Adding a reference

With the help of the browser extension, we can easily add articles to our project from the browser window. For our project, we use Google Scholar (or a similar search engine) to search for articles, such as R Markdown.

Google Scholar with the search term R Markdown.
Google Scholar with the first result under the search term R Markdown.

When we open one of the links, we usually see a preview of the article, and to save it in CiteDrive, we click on the button of our extension.

The following clip illustrates the whole process. In this example, we click on the first article that appears in the search results. Note that you get a BibTeX preview to check if everything is correct or if you want to make changes.

Adding References from Google Scholar with CiteDrive — via YouTube

After we have added the paper, the reference should appear in our project when you open the project in CiteDrive:

CiteDrive project view

We can add as many as we want, but I should mention here that there are many convenient ways to add references to CiteDrive — it is also possible to import BibTeX files. In this example, however, this one reference is sufficient, and we refer you to our guides:

Now that we have created the project at CiteDrive and added a reference, we can prepare our project in R Markdown.

Step 3: Create a new R Markdown template at RStudio

To create a new R Markdown template in RStudio, do the following:

File >New File > R Markdown.

Creating a new R Markdown project in RStudio

We set the title to Project Title in this example but keep all the default settings.

R Markdown settings for a new document

Step 4: Synchronize your references

Now that we have created the template in RStudio, we go back to CiteDrive, load the project and open our dynamic BiBTeX file. We click on .bib and see that the file opens in a new window. We copy the URL from that window, and in YAML, after the bibliography, we specify our previously created file at RMarkdown. We demonstrate the whole process in this clip:

Export your references to RMarkdown from your CiteDrive project.

As illustrated in the clip, once we have defined our bibliography at R Markdown, we can copy the citation keys directly from the CiteDrive project and specify them in the text.

That’s it! And this is how you can utilize CiteDrive to conveniently share your references for RStudio and your R Markdown projects.

Workarorand when using {rticles}

As mentioned earlier, there is one to be aware of when using {rticles}, as specifying the URL in YAML is impossible when using this package.

But the workaround requires just a few more lines:

Workarorand when using {rticles} with download.fil(“url”,file)

As shown in the figure, you can insert the R function download.file("URL","filename.bib")directly after YAML. In the YAML, set the path to the bibliography file with the same name you used in the download.file function, in the case of the figure bibliography.bib.

Apart from this slight detour, everything remains the same. Every time you change your bibliographic data, the function will download the latest state as soon as you knit the R Markdown document.

Additional Information

1. About R Markdown and the Citation engine

R Markdown is a great tool that embeds R code directly into Markdown-based documents to create dynamic papers, books, or reports. So you can make most of your research pipeline in RStudio, from data analysis to publication-ready PDFs or web pages.

R Markdown is based on Pandoc and comes with Citeproc, a processor that allows you to format your bibliography (e.g., a *.bib file following the BibTeX format) with an XML-based style for formatting a specific citation style (like APA or Vancouver). Citation Style Language provides these as CSL styles, and most reference managers such as Zotero and Mendeley use them. There are currently over 10,000 styles available.

2. Bibliography

With RMarkdown, you define your bibliography and style in the YAML front matter:

---bibliography: bibliography.bib
csl: american-chemical-society.csl

With bibliography, the path to your literature database (for example, bibliography.bib), and with csl, the XML file (American-chemical-society.csl) that defines the citation style is specified. There are few options for storing your bibliographic data in your RStudio project, like CSL, RIS, and BibTeX. CiteDrive is BibTeX first and is the most popular for R Markdown projects.

3. BibTeX and CitationKeys

In our example, your bibliography.bib will contain so-called BibTeX-entries. We can best explain the structure of a BibTeX entry with an example:

title = "Title of the book",
author = "Gareth Doe and Josh Doe",
year = "1988"

So each entry is declared according to the scheme @type{…} where @type is the type of the reference. In BibTeX, 14 types are supported, such as @book, @article, and @techreport. REFERENCE_ID is the so-called citation key of the reference. You can refer to the source in the text by the citation key. In the Pandoc-based system, like R Markdown or Quarto, it is done like this:

Lorem ipsum dolor sit amet, consectetur adipiscing elit. [@CITATIONKEY]

To bundle references via in-text citations, simply separate them with a comma:

Lorem ipsum dolor sit amet, consectetur adipiscing elit. [@CITATIONKEY1, @CITATIONKEY2]

Each citation key must be unique in the same database (.bib file). Often it consists of the first author’s last name, publication year, and the first non-stopper word. Here in this example, the citation key could be Doe1988Title. You can specify attributes with BibTeX fields, like title, year, or author. Additional authors are separated by and.

4. Changing styles

As noted above, you can choose one of the thousands of styles to suit your needs. Citation Style Language provides them in their official GitHub repository:

You can download any of these styles, add them to your RStudio project folder and define the path:

csl: american-chemical-society.csl

If no packages/settings conflict, it is possible to specify them by providing a URL.

As an example of american-chemical-society.csl from the GitHub repo (be sure to click on raw), the specification would be as follows:


5. Other CiteDriveIntegrations




CiteDrive: Cloud-based BibTeX manager. Enables easy collaboration, auto-syncing, and multi-format imports/exports. Research-focused, distraction-free.