Lab 12: Bibliography
Why are we here?
Citations and references are an important backbone of academic and scientific writing. Regardless of what field of study, or what type of work you do, you will always be building on the work of others that came before you. When you do, it’s important to use references in your writing to 1) give credit where credit is due, and 2) allow others to follow the progress and development of ideas over time. What’s more, properly referencing the work of others is important for giving your own work credibility; by referencing the foundations of your own arguments and claims, readers will be able to know if the premise of your work is reasonable. At a practical level, references are important for avoiding plagiarism, where you pass off the words and ideas of other people as your own.
An important feature of your citations will be providing enough information for your reader to find the original source you are referencing, so that they may be able to verify the claim your are making, or just learn more about the topic. With an ever-expanding collection of articles, books, manuscripts and websites in the information landscape, citations need to provide fine-grained detail about exactly where the original source can be located. While it is true that no software is required to manage and format your citations, doing so without the use of software is a tedious, repetitive and error prone process—just the type of problem software is most helpful in solving. So in today’s lab, we will focus on learning how to use the BibTeX citation management system to (mostly) painlessly add citations to your Quarto documents, and bring you one step closer to scientific publishing.
The purpose of this lab is to add in-text references to your Quarto documents, and create a bibliography section in your rendered Quarto document that provides all the publication details of your references.
After completing this lab, you should be able to add in-text references to your Quarto documents, and create a bibliography section in your rendered Quarto document. You will know that you are done when you have created a rendered file where the results match the examples in this HTML file.
The following are good additional resources for the material covered in this lab:
Lab instructions
Setting up
First, download the First, download the Lab 12 template.
Before you open the template, use your computer’s file explorer to move the template file you just downloaded out of your Downloads folder and into your SDS 100 folder.
Then, open RStudio, and make sure you’re working in the SDS 100 project. If the
Project
pane in the top right of your RStudio window doesn’t show “SDS 100”, go toOpen Project
as shown below and navigate to your project.Finally, open the template file in RStudio. The easiest way to do this is to go to the Files pane in RStudio, find the lab_12_bibliographies.qmd file from the list, and click on it.
If you don’t see a file named lab_12_bibliographies.qmd in the list, make sure you did steps 2 and 3 correctly. If you’ve double-checked your steps, and still don’t see it, ask your instructor for help.
What is a citation?
A citation has two components: 1) a brief in-text reference, which links to; 2) a detailed description in a bibliography section at the end of your document. The in-text reference should contain just enough information to uniquely identify the source you are referencing, and allow the reader to find the entry for this source in your bibliography. In the bibliography section (i.e., the full list of all works you cited in your writing), you should have all the detailed information your readers need to track down the original source and read it for themselves.
Adding in-text references to a Quarto file
Adding in-text references to your Quarto file has 3 steps to it:
- Collecting information about your references into a citation database, called a BibTeX file
- Connecting the BibTeX file to the Quarto document
- Referencing citations in your BibTeX file using the labels you’ve given to them
Creating a BibTeX file
As you know from your reading, a BibTeX file is a plain-text file that stores information about the sources you are referencing in a key/value format. So, before you reference a source in the text of your document, you must first collect information about those sources into a properly formatted BibTeX file. Luckily, creating a properly formatted BibTeX file usually isn’t too difficult, since nearly every search engine or publisher website where you find academic writings will allow you export a citation in BibTeX format.
Let’s create our very fist BibTeX file, so we can proceed to learning how to use it within Quarto documents. To make our first experience with BibTeX a bit simpler, we’ll create a BibTeX file that holds information about a single publication.
Search for “Lum and Isaac To Predict and Serve”
Click the small “Cite” button at the bottom of the first search result
In the pop-up window, click on the link at the bottom that says “BibTeX”
This should open a page of plain text, where the first line begins with
@article
Copy this text, and paste it into a plain text file
- You can open an empty plain text file by clicking on the green + sign icon and choosing “Text File”
Save this file in the same directory as your Quarto document.
- It’s a good idea to name this file something simple and easy to remember, like
refs.bib
. The.bib
file extension is important, because it signals to other people (and other computer programs!) that this file contains reference information formatted in the BibTeX style.
- It’s a good idea to name this file something simple and easy to remember, like
Connect your BibTeX file to your Quarto document
To make RStudio aware of your BibTeX file, you need to add a bibliography
entry in your Quarto document’s YAML header. Scroll up to the very top of your Quarto document until your find the header section. You’ll know you’ve found the header when you see a list of fields like title:
and format:
all stored between a set of three dashes on the top and three dashes on the bottom. There, add a new line before the three dashes on the bottom with the option bibliography: refs.bib
. This tells RStudio it can find all the information for your bibliography inside the file named refs.bib
that is in the same folder as your Quarto document.
If you named your BibTeX file something other than refs.bib
, make sure you change the value you give for the bibliograhy:
option to match it. Using bibliography: refs.bib
will only work if you named your BibTeX file refs.bib
when you saved it.
Adding references in text
In-text citations generally come in two different styles, parenthetical citations and narrative citations. Narrative citation integrate the reference information into a sentence, while parenthetical citations place the reference information inside a parenthetical clause at the end of a sentence. Examples of each style are shown in Table 1.
Narrative Style | Parenthetical Style | |
---|---|---|
Output: | According to Lum & Isaac (2016), algorithmic bias occurs in the Oakland police department. | Algorithmic bias occurs in the Oakland police department (Lum & Isaac, 2016). |
text in .qmd: | According to @lum2016predict, algorithmic bias occurs in the Oakland police department. | Algorithmic bias occurs in the Oakland police department [@lum2016predict]. |
The narrative style works well when you only want to cite one or two sources, and wish to give them an active voice in your writing. The parenthetical style works better when you need to cite a long list of sources, or adopt a more passive writing style.
To add either style of citation to your document, you need to know the citekey for your citation. You can always find the citekey for your source by looking for the text right after the {
on the very first line of the entry for your citation in your BibTeX file.
To add a narrative style citation to a sentence, write the citekey where you want the citation to appear in your sentence, directly preceded by an @
symbol. Be sure to write the citekey exactly as it appears in the BibTeX file (i.e., don’t add any spaces or dashes or capital letters), and don’t add any space between the @
symbol and the citekey. It’s a bit like mentioning someone on Twitter (or so I’m told…).
Question
Reproduce the narrative style citation shown in Table 1 in your own Quarto document. Make sure you render your Quarto document, and check that the in-text and bibliography citation formatting are correct.
To add a parenthetical style citation at the end of a sentence, write the citekey at the end of your sentence (but before the period!), directly preceded by an @
symbol. Then, surround the citation with square brackets: place the [
character before the @
symbol, and the ]
character at the very end of the citekey.
Question
Reproduce the parenthetical style citation shown in Table 1 in your own Quarto document. Make sure you render your Quarto document, and check that the in-text and bibliography citation formatting are correct.
Adding information to a BibTeX entry
Google Scholar can do almost all the work for you, but it doesn’t always contain every piece of information about a reference that you need. And, information the exported citation can occasionally be wrong, and it’s your responsibility to correct it if need be.
One field that is always missing from citations exported from Google Scholar (but is almost always required by academic journals and scholars) are URLs and DOIs that link back to the original document on the internet. Ideally, every citation should have either a DOI or a URL, with DOIs preferred. Include a URL only if you can’t find a DOI.
To add a DOI link to your BibTeX entry for the Lum and Isaac paper, return to the Google Scholar search entry you used previously to export the citation, and this time click on the main link to visit the primary source (at Significance magazine).
DOI’s are a long string of letters and numbers used to uniquely identify a published work. These numbers always begin with the sequence 10.
. To find the DOI for the Lum and Isaac article, look for a link towards to the top of the page that contains 10.1
in it.
Then, open your BibTeX file, and add a new field to the entry for the Lum and Isaac article to store this DOI information, using the screenshot below as a guide:
After adding the DOI information, render your Quarto document again, and take note of what has changed in the bibliography at the end of your document.
Changing the Citation style
By default, your citations and bibliography will use the Chicago style formatting. But, you may find yourself in a situation where another citation style is required. For example, an instructor may request you use MLA style citations for your research paper, or a publisher may require APA style citations for all submissions.
By using BibTeX as your reference manager, you won’t have to manually edit or re-type all your references if you need to change to another citation style. All you need to do is provide RStudio with a Citation Style Language file that describes how you want your citations to be formatted, and it does the rest.
Citation Style Language files (better known as CSL files) already exist for every major journal and citation format out there – the only time you’d ever need to write one yourself is if you’re inventing a new style of citation! Instead, all you need to know is where to find the CSL file for your style of choice, and how to connect it to your Quarto document.
Finding CSL files
A great place to find CSL files is the Zotero Style Repository, which allows you to search for CSL files for a specific format. Let’s use it to find the CSL file for the 7th Edition of the APA manual, and use that to change our citation style to APA style. Write “American Psychological Association” in the seach box, and find the entry in the search results that says “American Psychological Association 7th edition” (as shown in the screenshot below).
Then, click on this file to download it. Once it finishes downloading, move it into the same folder as your Quarto document and your BibTeX file.
Changing the Citation Style
The last thing to do is add a csl:
option to the header of your Quarto document, and point it towards the apa.csl
file your just downloaded and moved. This process will be just like when you added the bibliography
option to your document’s header: Add a new line before the three dashes on the bottom of your header, and write the option csl: apa.csl
. This tells RStudio it can find all the information on how to format and style your citations inside the file named apa.csl
that is in the same folder as your Quarto document. The screenshot below shows what your header should look like when you are finished.
Now when you render your Quarto document, all your citations will be formatted in APA style instead of Chicago style.
Citing a Web Page
Not everything you’ll need to cite appears in Google Scholar. In this class, sources are often in the form of web pages. You can create a simple BibTeX citation based on a few pieces of information about the web page: the title, the author, the year published (if available), the URL, and the date you’re accessing the page.
Here is an example citation for the FiveThirtyEight article that uses the avengers data we worked with in Lab 7.
@misc{avengers,
title={Joining The Avengers Is As Deadly As Jumping Off A Four-Story Buiding},
author={Hickey, Walt},
date={2015},
url={https://fivethirtyeight.com/features/avengers-death-comics-age-of-ultron/},
urldate={2024-01-14}}
Note avengers
on the first line - this is a citekey, the unique label given to your source within the BibTeX file you created. When creating your own citation like this, you’ll have to come up with your own citekey.
Question
Using the citation above as a template, create a citation for this article: Some People Are Too Superstitious To Have A Baby On Friday The 13th. Be sure to use an appropriate citekey.
There are many other types of sources you can cite using BibTeX. If you need to cite a different type of source, refer to this web page to see what information you need to collect and how to format it.
Next Steps
Step 1: Complete the Moodle Quiz
Complete the Moodle quiz for this lab.
Step 2: Final Project Phase 5
During this week, you will complete Phase 5 of the final project. See the project page for details about what is expected during this phase of the project.