Quarto offers a powerful and flexible way to create documents that combine both code and narrative text seamlessly. Understanding how to effectively use narrative elements—such as hyperlinks, citations, footnotes, and other formatting tools—can greatly enhance the readability and professional look of your documents. In this chapter, we’ll explore how to work with these narrative features in Quarto.
1 Hyperlinks
Insert a hyperlink into your text, simply highlight the text and then use the insert pull down menu, select link and add the URL that you’d like the text to link to. Couldn’t be easier:
You can also create a link to a specific section of the document. When you click on the link option, instead of inserting a URL, select the Heading option and the select a heading from the menu that appears. This link will take you to the Referencing Figures section.
2 Referencing Figures
To reference a figure, you need to include the label
chunk option and preface your label with fig-
like this:
You’ll notice too that we’ve included fig.cap:
to give the figure a caption at the bottom (this is optional). to make reference to the figure in your narrative text like this Figure 1 all you need to do is include “@fig-chickweight” into your text like this:
Clicking on the link will take a person to the figure and hovering over the link will provide a preview of the figure.
3 Footnotes
Adding footnote is easy. Simply use the insert pull-down menu and add your footnote like this
You’ll then be prompted to include the text that you want in the footnote so that you get something like this 1
4 Citations
Including citations is, once again, as easy at using the insert pull-down menu and selecting citation like this:
This will bring up a box that let’s you select where it is that the citation should be pull from. You can do a search of databases like PubMed directly through R Studio:
Once you do this, a few things will happen, a line will automatically appear in your document YAML that tells Quarto that you’re using citations, and the citation itself will be create in the text itself. When the document renders, a reference section will be created at the end of the document with the full citation.
A file all also automatically be created that stores your citation information. This file will be called references.bib
- you can create this yourself if you want to. So for example, if you want to export references from EndNote as a BibTex file you’ll need to save it in your working directory as references.bib.
You can open the references.bib file and edit the content of your references easily.
Here are a few citations to get the ball rolling (Jenkin 2023; James 2023; Martin 2023)
5 Calculated Values in Text
You might not want to interrupt your text with a chunk of code but instead might want to make reference to a data within the text of your document itself. For example, I might want to say that the average height of starwars
characters is 1.75 meters. Here is a screenshot of how I inserted code into my text. Remember that the highlighted text below has back-ticks ` ` wrapped around it.
6 Multiple Columns
To add multiple columns in Quarto you’ll need to move from the “visual” editor over to the “source” editor. The three :::
indicate in the source that we want to create a Div
(which is a section of text that has a specific style). The {}
add attributes, in this case .columns
.
You can adjust the width of the columns and even increase the space between columns if needed. I’ve added some padding to the columns so that they don’t render too close to each other.
Here is a screenshot of the source code that was used to create the columns above. Note that you can also insert a Div
and include attributes using the insert pull-down menu.
7 Text in the Margins
You can also add content into the margin by using a Div
and the attribute `{.margin}.
In this case however, I want to illustrate how you can get there without using the source. Insert a Div using from the Insert pull-down menu. click on the three dots at the top of the box and add .column-margin to the classes box as seen in the screenshot
8 Using Callouts
There are a number of callouts that you can use in quarto. The easiest way to insert them is to simply use the insert pull down menu and then click the callout option.
This is a note callout
This is a tip
This is important
This is a caution
And this is a warning
9 Horizontal lines
A horizontal line can be inserted from the Insert drop-down menu.
10 What’s next?
You’re now ready to delve into the more nuanced style and layout editing that is done using CCS code. Don’t worry, it’s easier than you think. We’ll go through it step by step and before you know it you’ll be create absolutely beautiful rendered documents.
11 Bibliography
Footnotes
This is my first footnote. Neat hey?↩︎