Why are we here?
In scientific writing, figures and tables are always references by number in your text. The location and number of these figures and tables are likely to change as your articles are edited and revised. This means that Hard coding the numbers of the tables and figures into your writing is an exercise in frustration, since you have to then go back and change all of the references to that table.
Instead, we use cross-references to automatically refer to figures and tables by number, and avoid the error-prone process of manually numbering each one. Once you learn how to references tables and figures automatically, you will never go back to referencing them manually again!
The purpose of this lab is to learn how to integrate figures and tables into the narrative of the document using references.
After completing this lab, you should be able to create figures from images you embed or from data graphics that you create, and reference them by number automatically in the text. Similarly, you should be able to create formatted tables from data frames and reference them automatically.
Lab instructions
Setting up
There is no Quarto template for this week’s lab. Instead, you should begin by creating a new Quarto document, and saving it in your SDS 100 project folder. If you’re unsure about how to do this, look back the Setting Up section of the “Formatting in Quarto” lab.
Cross-referencing images
In Lab 8, you learned how to embed an image in a Quarto document using Markdown. Images, such as this image of the Smith SDS logo, can be embedded with Markdown syntax like this
![](https://pbs.twimg.com/profile_images/1048189234904010753/RUL5NyvY_400x400.jpg)
To turn this image into something that can be cross-referenced, you need to add:
- A caption by writing text inside the
[]
square brackets that are currently empty.
- Adding a label for the image. You can add an identifier by adding
{}
brackets immediately after the closing parenthesis, and writing a name that starts with #fig-
For example, here’s how you could cross-reference the image of the Smith SDS logo You can also cross-references images you embed in a similar fashion.
@fig-sds displays the Smith SDS logo
![Behold, the beautiful Smith SDS Logo](https://pbs.twimg.com/profile_images/1048189234904010753/RUL5NyvY_400x400.jpg){#fig-sds}
Next Steps
Step 1: Compare solutions
Double check that your Quarto document has all the necessary content and formatting elements by comparing your rendered output against our example solutions.
Step 2: Complete the required reading
Lab 11 has a set of pre-readings to complete to facilitate a fruitful discussion surrounding ethical codes for data science. To lighten the workload, we will divide up the readings among your final project group as follows:
Everyone reads the following two (very short) readings:
The following 3 readings should be divided among your group. Each person will do 1 of the following readings, and present the key points during class.
Step 3: Complete the Moodle Quiz
Complete the Moodle quiz for this lab.
Step 4: Final Project Phase 3
During this week, you will complete Phase 3 of the group project. See the project page for details about what is expected during this phase of the project.