Quarto adds research-writing features: figures and tables with captions, cross-references (@fig-bill, @tbl-summary, @eq-ratio), math, inline code that reports numbers from the data, and callouts.
Figures & cross-references
A labeled code cell becomes a numbered, referenceable figure:
```{r}#| label: fig-bill#| fig-cap: "Bill length versus depth, by species."#| fig-alt: >-#| Scatter plot of bill depth against bill#| length for three penguin species,#| forming clusters.#| output-location: columnggplot(penguins, aes(bill_len, bill_dep,color = species)) +geom_point(alpha =0.8) +labs(x ="Bill length (mm)",y ="Bill depth (mm)")```
Figure 1: Bill length versus depth, by species.
Refer to it in prose with @fig-bill → renders as “Figure 1”, a live link. Labels must start with fig- / tbl- / eq- to be cross-referenceable. #| fig-alt is the figure’s alt text (the description screen readers announce). Add it to every figure.
#| output-location: column is slide-only: a revealjs placement, not article layout.
Tables
gt (or knitr::kable) turns a data frame into a table. A #| label: tbl- makes it referenceable.
```{r}#| label: tbl-summary#| tbl-cap: "Mean bill length per species."penguins |>summarise(bill =mean(bill_len), .by = species) |>gt() |>fmt_number(bill, decimals =1)```
Table 1: Mean bill length per species.
species
bill
Adelie
38.8
Gentoo
47.5
Chinstrap
48.8
Then refer to it in prose with @tbl-summary (the same mechanism as figures).
Alt text: add #| fig-alt: to every figure. It is what a screen reader announces.
Color-blind-safe colors: choose a suitable palette. Okabe-Ito is a common choice for discrete scales in science (scale_color_okabe_ito()). Viridis suits continuous scales. Encode by shape or label too, not color alone.
Check contrast: WCAG AA requires a contrast ratio of at least 4.5:1 for normal text. Quarto’s built-in axe runs axe-core on the rendered page:
format:html:axe:output: document # or `axe: true` to log to the browser consolestandard: wcag21aa # the level you are checking against
RStudio, Positron, and VS Code all work. The visual editor (WYSIWYM — what you see is what you mean) is built into the RStudio IDE, and comes to Positron and VS Code through the Quarto extension.
Parameterized reports
quarto render also accepts -P name:value. Use it to override a document parameter and produce one report per sample or species from a single source. (Optional bonus in today’s lab.)
Quarto in Positron
The same quarto preview, from inside the editor: source on the left, live preview on the right. Edit, hit Preview, and it live-reloads.
Your turn
Your turn
Head to the Lab and start at the Authoring Challenge: author a penguins document with a figure, a cross-referenced table, and margin layout, then render it to HTML.
You can now author a figure, a cross-referenced table, and margin layout. After the break we cite it and produce a branded PDF.
Part 2: Citations → Typst
From report to article: cite it, then typeset it.
From report to article
You have a clean HTML document. The lab provides a completed Part-1 report if you need one. To make it a branded article with citations, add two things:
citations: a .bib file and a citation style.
a typeset PDF — via Typst, bundled in Quarto.
Citations
A .bib file holds one entry per source. The entry key is what you cite.
references.bib
@article{gorman2014,author = {Gorman, K. B. and ...},year = {2014}}
Create or export BibTeX entries with Zotero, a DOI lookup, or the journal’s Cite button.
Two header lines point at the file and the style:
bibliography: references.bibcsl: apa.csl
CSL = Citation Style Language. Change csl: to another CSL file to apply that journal’s citation style.
Use brackets to control the citation form:
You write
You get
[@gorman2014]
(Gorman et al., 2014)
@gorman2014
Gorman et al. (2014)
[-@gorman2014]
(2014)
Where the reference list goes
By default the list goes at the end of the document. Put this div where you want it instead:
::: {#refs}:::
Two processors can build that list, and only one of them reads the div:
Pandoc citeproc is the default for HTML. It puts the list in #refs.
Typst builds its own bibliography and always places it last.
For the Typst PDF, add citeproc: true so Pandoc processes the citations:
Return to the Citations Challenge in the Lab. Add citations to my-report.qmd (save authoring-checkpoint.qmd as my-report.qmd if you did not finish Part 1), then render it as a branded Typst PDF.
What you can do now
You can now:
author a .qmd natively with figures, tables, cross-references, math, and callouts.
lay it out with the article grid and margin content.
make it accessible with alt text, color-blind-safe colors, and a built-in axe check.
cite it with a .bib and CSL, and give it a real title block.
render it as a branded Typst PDF.
Next (Day 2): grow one document into a whole project, a website your team can publish.