Introduction to Quarto — Lab
RaukR 2026 · Day 1
Build one penguins document with the authoring extras, then cite it and render it as a branded Typst PDF. You will use one document for two challenges, with a break between them. The result follows the same path from an analysis to a submission-ready report. Everything runs on base-R datasets::penguins (R ≥ 4.5), so there is no data to download.
Before you start: work through the Setup page if you haven’t. The 00-check-setup.R script is at the top of the exercises download (not inside day1-intro/). It confirms R, Quarto, and the packages this lab uses.
You are working in the day1-intro/ folder from the exercises download. Open that folder in your editor, or make it your working directory in R (see the Setup page). Everything you render is written next to your files. Start with the supplied authoring-starter.qmd. The lab introduces the other files when you need them. The folder README lists them all.
The folder also holds a _brand.yml. Quarto applies it to anything you render there, so your HTML carries the RaukR font and colors from the first render.
You do not need to convert anything to work natively in Quarto. Start with .qmd directly. But if you have an .Rmd you want to bring over:
- it renders as-is (Quarto reads
.Rmdtoo). - cell options move from the chunk header to the
#|“hash-pipe” (one YAML option per line). knitr::convert_chunk_header("doc.Rmd", output = "doc.qmd")does the mechanical part.
The rest of this lab uses native .qmd.
2 Citations Challenge
Goal: cite the report, then render the same document as a branded Typst PDF.
If you finished the Authoring Challenge, continue in my-report.qmd. Otherwise:
- Open
day1-intro/authoring-checkpoint.qmd(the completed Part-1 report). - Save a copy as
my-report.qmdinday1-intro/, next toreferences.bib,apa.csl, and_brand.yml. - Continue in that copy.
The instructions below use my-report.qmd for both routes.
Missing the download? Take the sources directly:
Quarto docs
2.1 Add the bibliography and citation style
Point the document header at the shared bibliography and citation style. Add citeproc: true so Quarto processes the citations and places the reference list in the #refs div you add below. Without it, Typst processes the citations and ignores that div:
bibliography: references.bib
csl: apa.csl
citeproc: true2.2 Cite the two sources
Add [@gorman2014] before the period in the sentence ending “…collected at Palmer Station, Antarctica.” Add [@horst2020] immediately after palmerpenguins in the next sentence. The rest of that sentence describes base R, so keep the citation beside the package name. Do not duplicate either sentence.
2.3 Add the References section
Add a References section where the list should appear:
## References {.unnumbered}
::: {#refs}
:::2.4 Give it a title block
Give it a real title block so the PDF reads as a paper. Replace your document’s author: line (or add one) with:
author:
- name: Your Name
affiliation: Your Lab, Your University2.5 Render to HTML and check the citations
Render to HTML and confirm that both citations resolve as (Gorman et al., 2014) and (Horst et al., 2020), with a reference list holding both entries.
2.6 Render a branded PDF with Typst
Render a branded PDF with Typst. Keep my-report.qmd in day1-intro/ so Quarto can find the supplied _brand.yml. You may see unknown font family warnings on the first render. See Troubleshooting if the final PDF still uses a serif font. Choose one route:
CLI: keep
format: htmlin the header and run:quarto render my-report.qmd --to typstEditor: change the header to
format: typst, then render (RStudio’s Render button, or Quarto: Render Document in Positron and VS Code). The editor renders whateverformat:is declared, so while the header still saysformat: htmlyou get HTML, not a PDF.
The PDF is written next to its source in day1-intro/.
2.7 Keep the Session appendix out of the PDF
Look at the end of the PDF. The Session appendix is printed in full, with the sessionInfo() call and all of its output. <details> is an HTML disclosure widget and Typst has no equivalent, so that block belongs to HTML only. Wrap the whole section (the heading and the <details> block) in a conditional div:
::: {.content-visible when-format="html"}
## Session {.appendix .unnumbered}
<!-- Keep the existing <details> block here. -->
:::Render to Typst again, then to HTML. On the editor route, set format: back to html for that second render. The appendix is gone from the PDF and unchanged in the HTML.
- The
@keyin[@gorman2014]must match a key inreferences.bibexactly. csl:sets the style (here APA). Swap the file to restyle every citation at once.content-visiblehas an inverse,content-hidden.::: {.content-hidden when-format="typst"}says the same thing the other way round.- The first Typst render requires a network connection while Quarto downloads the brand’s Google fonts.
In the YAML header:
bibliography: references.bib
csl: apa.csl
citeproc: trueIn the prose, append each citation to the sentence that credits its source:
… collected at Palmer Station, Antarctica [@gorman2014]. The data are available through the
**palmerpenguins** package [@horst2020] and are now also included in base R's `datasets` package.A References section (the list renders inside the #refs div):
## References {.unnumbered}
::: {#refs}
:::The Session appendix, kept out of the PDF:
::: {.content-visible when-format="html"}
## Session {.appendix .unnumbered}
<!-- Keep the existing <details> block here. -->
:::For the branded PDF (day1-intro/_brand.yml styles it), either force the target from the CLI:
quarto render my-report.qmd --to typstor set format: typst in the header and render from the editor.
solutions/day1/penguins-report.qmd is the complete Day-1 report: the starter with every step of both challenges applied. Try the challenge first, then open it to compare, or take the source:
For a more advanced branded PDF example, render day1-intro/sample-typst.qmd. It also styles its table and plot in R and sets Typst page options. Those additions are outside this exercise.
3 Bonus — one report per species (optional)
Goal: turn a report into a parameterized one: a single source that renders a separate report per species by passing the species at render time. This section is optional. Skip it if time is short.
A parameter is a value declared in the YAML that your code can read as params$…. Change the value at render time and the same document produces a different report. You do not need separate source files.
Open day1-intro/parameters-starter.qmd. It contains the report structure, data, and plot. Your task is to make the species an input to the document. A complete reference is available at solutions/day1/penguins-by-species.qmd.
Missing the download? Take the source directly:
Quarto docs
Replace Species in the heading with inline code so it shows the selected species:
## `{r} params$species` at a glanceTo keep two named reports, render each as a self-contained HTML file:
quarto render parameters-starter.qmd -P species:Adelie --output adelie.html --embed-resources
quarto render parameters-starter.qmd -P species:Chinstrap --output chinstrap.html --embed-resources--output prevents the second render from overwriting the first. --embed-resources puts each plot inside its HTML file, so the reports do not share a figure-support folder.
- Parameters must have defaults:
params$specieshas to resolve when no-Pis passed. -Ptakesname:value(-P species:Adelie). Pass several with repeated-Pflags.- The plot must use the filtered object
one, not the fullpenguinsdata.
The complete, runnable solution is solutions/day1/penguins-by-species.qmd. Open it to compare your work or render it with different -P species: values. You can also take the source:
4 Troubleshooting
Session
Session info
sessionInfo()R version 4.6.1 (2026-06-24 ucrt)
Platform: x86_64-w64-mingw32/x64
Running under: Windows 11 x64 (build 26200)
Matrix products: default
LAPACK version 3.12.1
locale:
[1] C
system code page: 65001
time zone: Europe/Paris
tzcode source: internal
attached base packages:
[1] stats graphics grDevices datasets utils methods base
other attached packages:
[1] ggokabeito_0.1.0 gt_1.3.0 ggplot2_4.0.3 dplyr_1.2.1
loaded via a namespace (and not attached):
[1] vctrs_0.7.3 cli_3.6.6 knitr_1.51 rlang_1.3.0
[5] xfun_0.59 renv_1.2.3 generics_0.1.4 S7_0.2.2
[9] jsonlite_2.0.0 labeling_0.4.3 glue_1.8.1 htmltools_0.5.9
[13] scales_1.4.0 rmarkdown_2.31 grid_4.6.1 evaluate_1.0.5
[17] tibble_3.3.1 fastmap_1.2.0 yaml_2.3.12 lifecycle_1.0.5
[21] compiler_4.6.1 fs_2.1.0 RColorBrewer_1.1-3 htmlwidgets_1.6.4
[25] pkgconfig_2.0.3 farver_2.1.2 digest_0.6.39 R6_2.6.1
[29] tidyselect_1.2.1 pillar_1.11.1 magrittr_2.0.5 withr_3.0.3
[33] tools_4.6.1 gtable_0.3.6 xml2_1.6.0
