This tutorial introduces R Markdown and Quarto as tools for combining code, output, and narrative text in a single, dynamic, and fully reproducible document. Whether you are writing a corpus analysis report, a phonetics study, or a data science notebook, these tools allow you to weave together your R code, its output, and your prose explanation into a polished, shareable document.
The tutorial is aimed at beginners and intermediate R users in the humanities and social sciences. It covers the full workflow: understanding what R Markdown and Quarto are and how they differ, learning Markdown syntax, configuring YAML headers, controlling code chunk behaviour, producing multiple output formats, and using Quarto’s advanced features such as callout blocks, cross-references, citations, and project-level configuration.
By the end of this tutorial you will be able to:
Create a reproducible R Markdown or Quarto document from scratch
Write well-structured Markdown prose with headings, lists, tables, and figures
Control how code chunks are displayed and executed
Export your work as HTML, PDF, Word, or a presentation
Use Quarto-specific features: callouts, cross-references, freeze, and _quarto.yml
Manage citations and bibliographies with BibTeX
Prerequisite Knowledge
Before working through this tutorial, you should be familiar with:
Martin Schweinberger. 2026. R Markdown and Quarto: Creating Reproducible Documents. The Language Technology and Data Analysis Laboratory (LADAL), The University of Queensland, Australia. url: https://ladal.edu.au/tutorials/notebooks/notebooks.html (Version 3.1.1). doi: 10.5281/zenodo.19332919.
Setup
Installing Packages
Code
# Run once — comment out after installationinstall.packages("rmarkdown")install.packages("knitr")install.packages("tidyverse")install.packages("flextable")install.packages("kableExtra")install.packages("bookdown") # for cross-references in R Markdown# Quarto is installed separately from https://quarto.org/docs/get-started/
What you will learn: What R Markdown and Quarto are; why reproducible documents matter; and how these tools fit into a modern research workflow
The Problem They Solve
A typical research workflow involves several disconnected steps: running R code in a script, copying results into a Word document, inserting figures manually, and then updating everything again when the data changes. This workflow is fragile — a change in the data means re-running the code, re-copying the numbers, and re-inserting the figures, with every step introducing the risk of inconsistency.
R Markdown and Quarto solve this by integrating code, output, and prose in a single source document. When you render the document, the code runs, the output is inserted automatically, and the prose and results are always in sync. The document is reproducible: anyone with the source file and data can re-render it and obtain exactly the same output.
R Markdown
R Markdown was introduced by the knitr package (Xie 2017) and formalised in the rmarkdown package (Allaire et al. 2023). An R Markdown document (.Rmd) combines:
A YAML header specifying document metadata and output format
Markdown prose for narrative text
R code chunks that are executed when the document is rendered
R Markdown documents are rendered by knitr (which executes the R code and weaves the output into the document) followed by Pandoc (which converts the resulting Markdown into the target output format — HTML, PDF, Word, etc.).
Quarto
Quarto is the next-generation publishing system developed by Posit (formerly RStudio). A Quarto document (.qmd) uses the same Markdown + code chunk approach as R Markdown, but with several important advances:
Language-agnostic: supports R, Python, Julia, and Observable JS in the same document
Unified syntax: chunk options use #| comments rather than chunk header parameters
Richer output features: built-in callout blocks, cross-references, layouts, and theming
Project system:_quarto.yml configures entire websites, books, or presentations
Better defaults: produces cleaner HTML and PDF output out of the box
For new projects, Quarto is recommended. R Markdown remains fully supported and is still widely used. This tutorial covers both.
R Markdown vs. Quarto
Section Overview
What you will learn: How R Markdown and Quarto differ in syntax, features, and workflow; and when to use each
`` `r .QuartoInlineRender(expr)` `` or `` `r expr` ``
Freeze / caching
Via `knitr` cache
`freeze: auto` in `_quarto.yml`
Maintained by
Posit / community
Posit
When to use
Existing `.Rmd` projects; R-only workflows
New projects; multi-language; websites; books
Which Should I Use?
Use R Markdown if you are working on an existing .Rmd project, or if you need a package that is R Markdown-specific (e.g. blogdown, bookdown)
Use Quarto for all new projects — it is more powerful, better maintained, and handles multi-language workflows elegantly
Both render to the same output formats via Pandoc, so skills transfer directly between them
Creating Your First Document
Section Overview
What you will learn: How to create a new R Markdown or Quarto document in RStudio; what the basic structure looks like; and how to render it
In RStudio
R Markdown: Go to File → New File → R Markdown. Choose the output format (HTML is the default) and click OK. RStudio creates a template .Rmd file with a YAML header, some sample text, and a few code chunks.
Quarto: Go to File → New File → Quarto Document. Again choose your output format and click Create. RStudio creates a template .qmd file.
Basic Structure
Both document types share the same three-part structure:
---YAML header---Markdown prose` ``{r}# R code chunk` ``
Rendering
R Markdown: Click the Knit button in RStudio (or run rmarkdown::render("file.Rmd") in the console).
Quarto: Click the Render button in RStudio (or run quarto render file.qmd in the terminal).
Both processes: execute all code chunks → weave output into the document → convert to the target format via Pandoc.
Keyboard Shortcut
Ctrl+Shift+K (Windows/Linux) or Cmd+Shift+K (Mac) renders the current document in RStudio — for both R Markdown and Quarto.
YAML Headers
Section Overview
What you will learn: What YAML is; the most important YAML fields for R Markdown and Quarto; how to configure output formats, themes, and table of contents; and how Quarto’s YAML extends R Markdown’s
What Is YAML?
YAML (Yet Another Markup Language) is a human-readable data serialisation format used to store configuration. In R Markdown and Quarto, the YAML header sits between two sets of --- at the top of the document and controls metadata (title, author, date) and rendering options (output format, theme, table of contents).
YAML is indentation-sensitive — use spaces, not tabs, and be consistent with nesting.
title:"Corpus Frequency Analysis"author:"Martin Schweinberger"date:"YYYY-MM-DD # use Sys.Date() in practice"output:html_document:toc:truetoc_depth:3toc_float:truenumber_sections:truetheme: cosmohighlight: tangocode_folding: showdf_print: pagedbibliography: references.bibcsl: unified-style-linguistics.csl
How data frames are printed (`default`, `kable`, `tibble`, `paged`)
`bibliography`
Path to `.bib` bibliography file
`csl`
Citation style language file for reference formatting
`params`
Parameterised report inputs — see Parameterised Reports section
Quarto YAML
Quarto’s YAML uses nested format: keys rather than output:, and adds many new fields:
title:"Corpus Frequency Analysis"author:-name:"Martin Schweinberger"affiliation:"The University of Queensland"email:"m.schweinberger@uq.edu.au"date: last-modifieddate-format:"DD MMMM YYYY"format:html:toc:truetoc-depth:4toc-title:"Contents"toc-location: leftnumber-sections:truenumber-depth:3code-fold: showcode-tools:truecode-line-numbers:truetheme: cosmohighlight-style: tangoembed-resources:truesmooth-scroll:truecitations-hover:truefootnotes-hover:truepdf:documentclass: articlegeometry: margin=2.5cmtoc:truedocx:reference-doc: template.docxexecute:echo:truewarning:falsemessage:falsecache:falsebibliography: references.bibcsl: unified-style-linguistics.csllang: en-GB
Field
Description
`title`
Document title
`author`
Can be a list with `name`, `affiliation`, `email`, `orcid`
`date: last-modified`
Automatically set to the file's last-modified date
`date-format`
Date display format using `dayjs` tokens
`format: html:`
HTML output options — nested under `format: html:`
`toc-location`
Position of ToC: `left`, `right`, `body`
`code-fold`
Code folding: `show`, `hide`, `true`, `false`
`code-tools`
Show a toolbar to copy code or view source
`code-line-numbers`
Add line numbers to code blocks
`embed-resources`
Bundle all dependencies into a single self-contained HTML file
`smooth-scroll`
Enable smooth scrolling between sections
`citations-hover`
Show citation details on hover
`execute:`
Global chunk execution defaults — applies to all chunks
`execute: cache`
Cache all chunk outputs to speed up re-rendering
`lang`
Document language for hyphenation and accessibility
`bibliography`
Path to `.bib` file
`csl`
Citation style language file
Code Chunks
Section Overview
What you will learn: How to insert and label code chunks; how to control their execution, display, and output with chunk options; and how R Markdown and Quarto chunk syntax differ
Inserting a Code Chunk
Keyboard shortcut:Ctrl+Alt+I (Windows/Linux) or Cmd+Option+I (Mac) inserts a new code chunk in RStudio.
R Markdown syntax — options go in the chunk header:
Both syntaxes are valid in Quarto, but the #| style is preferred because it is language-agnostic (the same syntax works for Python, Julia, etc.) and keeps chunk options inside the chunk where they are easier to see.
Chunk Option Reference
Option
R Markdown
Quarto
Effect
`label`
`label`
`label`
Unique chunk identifier (required for cross-refs and caching)
`echo`
`echo`
`echo`
`true` show code; `false` hide code; `fenced` show with delimiters
`eval`
`eval`
`eval`
`true` run the chunk; `false` skip execution entirely
`include`
`include`
`include`
`false` run but suppress ALL output including code, results, messages
format:html:fig-height:5fig-width:7fig-align: center
Inline Code
Inline code embeds a computed value directly in prose without a separate code chunk:
R Markdown: write a backtick followed immediately by r, then a space, your expression, and a closing backtick — directly in prose. When rendered, the expression is replaced by its computed value — e.g. The corpus contains 4,572 tokens.
Quarto: the equivalent syntax is a backtick followed by {r}, a space, your expression, and a closing backtick — placed in prose. The older R Markdown syntax also works in Quarto.
Inline code is rendered inline — the expression is replaced with its value in the output. This ensures numbers in your prose always match your data.
Markdown Syntax Reference
Section Overview
What you will learn: The full Markdown syntax supported by R Markdown and Quarto, from basic formatting to advanced features like footnotes, math, diagrams, and HTML
Monophthong: A vowel with a single, stable tongue position during production.Diphthong: A vowel that involves a glide from one tongue position to another.Formant: A resonant frequency band produced by the vocal tract shape.
Monophthong
A vowel with a single, stable tongue position during production.
Diphthong
A vowel that involves a glide from one tongue position to another.
Formant
A resonant frequency band produced by the vocal tract shape.
Links
[LADAL](https://ladal.edu.au) # external link[Introduction](#intro) # internal anchor link[Schweinberger 2026](references.html#ref-sch26) # link to reference<m.schweinberger@uq.edu.au> # auto-linked email
| Left | Centre | Right ||:---------|:--------:|---------:|| text | text | 1,234 || text | text | 5,678 |
Left
Centre
Right
text
text
1,234
text
text
5,678
For production tables — sortable columns, striped rows, captions, cross-references — use flextable() or knitr::kable() in a code chunk rather than raw Markdown tables.
Footnotes
Formants are resonant frequencies of the vocal tract.[^1][^1]: For a thorough introduction to formant analysis see Johnson (2003).
Formants are resonant frequencies of the vocal tract.1
Inline footnotes (Quarto/Pandoc):
Formants are resonant frequencies of the vocal tract.^[For a thorough introduction see Johnson (2003).]
Quarto supports Mermaid diagrams natively with no extra packages:
```{mermaid}graph TD A[Raw audio] --> B[Praat formant extraction] B --> C[Tab-delimited .txt file] C --> D[Load in R] D --> E[Normalisation] E --> F[Vowel chart]```
graph TD
A[Raw audio] --> B[Praat formant extraction]
B --> C[Tab-delimited .txt file]
C --> D[Load in R]
D --> E[Normalisation]
E --> F[Vowel chart]
Other diagram types: flowchart, sequenceDiagram, gantt, classDiagram, stateDiagram, erDiagram, pie.
HTML Elements
Raw HTML passes through directly in both R Markdown and Quarto HTML output.
Expandable section:
<details> <summary>Click to expand: full model output</summary> Content hidden until expanded. Useful for supplementary material.</details>
Click to expand: full model output
Content hidden until expanded. Useful for supplementary material.
Press <kbd>Ctrl</kbd>+<kbd>Shift</kbd>+<kbd>K</kbd> to render.
Press Ctrl+Shift+K to render.
Escaping Special Characters
Backslash escapes Markdown special characters:
\*not italic\*\`not code\`\# not a heading \[not a link\]
*not italic* · `not code` · # not a heading · [not a link]
Horizontal Rules
---***___
All three produce a horizontal rule:
Emojis
:smile: :+1: :sparkles: :books: :bar_chart:
:smile: :+1: :sparkles: :books: :bar_chart:
(Requires emoji extension or appropriate Pandoc version — works in Quarto HTML by default.)
Output Formats
Section Overview
What you will learn: How to render R Markdown and Quarto documents to HTML, PDF, Word, and presentation formats; what options are available for each; and how to choose the right format for your audience
HTML
HTML is the richest output format — it supports interactive widgets, floating tables of contents, collapsible code, hover citations, and smooth scrolling. It is the recommended format for sharing analysis online or via email.
format:html:toc:truetoc-location: lefttheme: cosmocode-fold: showembed-resources:true # self-contained single file
embed-resources: true
By default, Quarto HTML output references external libraries (Bootstrap, highlight.js, etc.) via relative paths. Setting embed-resources: true bundles everything into a single .html file — ideal for sharing by email or uploading to a repository without worrying about broken relative paths.
PDF
PDF output requires a LaTeX distribution. The recommended option is TinyTeX, which can be installed from R:
If your document contains IPA symbols, non-Latin scripts, or special characters, use latex_engine: xelatex (R Markdown) or latex-engine: xelatex (Quarto). The default pdflatex engine does not support Unicode. Also ensure your fonts support the required character ranges.
Word (.docx)
Word output is useful when collaborators need to add track-changes comments or when a journal requires .docx submission.
To create a Word template: render a document to .docx, open it in Word, modify the Heading 1, Body Text, Code, and Caption styles to match your requirements, save it, and point reference_docx/reference-doc at it.
Presentations
Quarto Reveal.js (HTML Slides)
Reveal.js is Quarto’s primary presentation format — fully interactive, browser-based slides:
format:revealjs:theme: simple # default, simple, sky, moon, serif, solarizedslide-number:truechalkboard:true # interactive drawing on slidesincremental:true # bullet points appear one at a timefooter:"LADAL — ladal.edu.au"logo: /images/uq1.jpgtransition: slide # none, fade, slide, convex, concave, zoombackground-transition: fade
In a Reveal.js document, each ## heading starts a new slide, and --- creates a slide without a heading. Columns are created with:
output:ioslides_presentation:widescreen:truesmaller:trueslidy_presentation:footer:"LADAL"beamer_presentation:theme: Madrid
Format
Best for
R Markdown
Quarto
HTML (`html_document`/`html`)
Online sharing; interactive outputs; most feature-rich
✓
✓
PDF (`pdf_document`/`pdf`)
Print; journal submission; formal reports
✓
✓
Word (`word_document`/`docx`)
Collaboration with track changes; journal .docx submission
✓
✓
Reveal.js (`revealjs`)
Interactive HTML presentations with code output
—
✓
Beamer (`beamer`)
PDF presentations; conference talks with LaTeX typesetting
✓
✓
PowerPoint (`pptx`)
PowerPoint-compatible presentations for non-R users
✓
✓
ioslides / Slidy
Simple HTML presentations (R Markdown only)
✓
—
Quarto-Specific Features
Section Overview
What you will learn: Quarto’s built-in callout blocks; multi-column and panel layouts; tabsets; the freeze execution option; and the _quarto.yml project configuration file
Callout Blocks
Callout blocks draw attention to notes, tips, warnings, and important information. They are a Quarto native feature — no extra packages or CSS required.
::: {.callout-note}## Note titleThis is a note callout — used for supplementary information.:::::: {.callout-tip}## Tip titleThis is a tip callout — used for best practices and shortcuts.:::::: {.callout-warning}## Warning titleThis is a warning callout — used for common mistakes and pitfalls.:::::: {.callout-important}## Important titleThis is an important callout — used for critical information.:::::: {.callout-caution}## Caution titleThis is a caution callout — used for potential issues requiring care.:::
Rendered:
Note title
This is a note callout — used for supplementary information.
Tip title
This is a tip callout — used for best practices and shortcuts.
Warning title
This is a warning callout — used for common mistakes and pitfalls.
Important title
This is an important callout — used for critical information.
Caution title
This is a caution callout — used for potential issues requiring care.
Callouts can be collapsed by default:
::: {.callout-note collapse="true"}## Expandable noteThis content is hidden until the reader clicks the heading.:::
Expandable note
This content is hidden until the reader clicks the heading.
Callouts without a title:
::: {.callout-tip appearance="simple"}A quick tip with no header.:::
A quick tip with no header.
Multi-Column Layouts
Two-Column Body Text
:::: {.columns}::: {.column width="60%"}**Main analysis**The vowel chart reveals that the learner's /iː/ is more centralisedthan the RP target, with F2 approximately 200 Hz lower than expected.:::::: {.column width="40%"}**Key finding**- /iː/ centralised- /ɔː/ raised- /æ/ raised and backed:::::::
Main analysis
The vowel chart reveals that the learner’s /iː/ is more centralised than the RP target, with F2 approximately 200 Hz lower than expected.
Key finding
/iː/ centralised
/ɔː/ raised
/æ/ raised and backed
Figure Layouts
Place two figures side by side with independent captions and cross-reference labels:
::: {#fig-comparison layout-ncol=2}{#fig-raw}{#fig-lob}Vowel space before (left) and after (right) Lobanov normalisation.:::See @fig-comparison for the comparison, or specifically @fig-raw for raw Hz values.
Layout options: layout-ncol, layout-nrow, or a custom layout matrix:
Tabsets allow multiple versions of content in the same space — useful for showing results under different conditions, or code in multiple languages:
::: {.panel-tabset}## Raw HzContent for the raw Hz tab.## LobanovContent for the Lobanov normalisation tab.## NeareyContent for the Nearey normalisation tab.:::
Rendering a Quarto document re-executes all code chunks. For documents with long-running computations (large models, web scraping), this is expensive. The freeze option caches executed output so that chunks are only re-run when their code changes.
In _quarto.yml (applies to all documents in the project):
execute:freeze: auto # re-execute only when source code changes
In an individual document’s YAML:
execute:freeze:true # never re-execute — always use cached output
Cached output is stored in the _freeze/ directory. Commit this directory to version control so collaborators can render the document without re-running expensive computations.
The _quarto.yml Project File
A _quarto.yml file in the root of a project configures all documents simultaneously. This is the key advantage of the Quarto project system over R Markdown.
Any format: settings in _quarto.yml apply to all documents and can be overridden in individual documents:
format:html:theme: cosmotoc:truecode-fold: showfig-height:5fig-width:7execute:echo:truemessage:falsewarning:falsecache:falsefreeze: auto
Cross-References
Section Overview
What you will learn: How to label and reference figures, tables, sections, and equations in both R Markdown (via bookdown) and Quarto (natively)
In Quarto
Quarto has built-in cross-references. Every referenceable element needs a label with the appropriate prefix.
Figures
Label a figure chunk with #| label: fig-something and reference it with @fig-something:
` ``{r}#| label: fig-vowel-chart#| fig-cap: "Vowel space of the L1-German learner vs. RP native speakers"#| fig-height: 6plot(vowel_chart)` ``The results are shown in @fig-vowel-chart.
For Markdown images:
{#fig-vowel-chart}As shown in @fig-vowel-chart, the learner's vowels are displaced.
Tables
` ``{r}#| label: tbl-freq#| tbl-cap: "Top 20 words by frequency"freq_table |> flextable()` ``@tbl-freq shows the 20 most frequent words.
Sections
## Results {#sec-results}See @sec-results for the full discussion.
Equations
$$F_{\text{Lobanov}} = \frac{F - \bar{F}}{SD_F}$$ {#eq-lobanov}As shown in @eq-lobanov, Lobanov normalisation is a z-score transformation.
Reference Formatting
Quarto formats cross-references automatically: @fig-vowel-chart becomes “Figure 1”, @tbl-freq becomes “Table 1”, @sec-results becomes “Section 3”, and @eq-lobanov becomes “Equation 1”. The prefix text can be customised in _quarto.yml:
See Figure \@ref(fig:vowel-chart) and Table \@ref(tab:freq-table).(ref:vowel-chart-cap) Vowel space of the L1-German learner vs. RP native speakers.` ``{r vowel-chart, fig.cap="(ref:vowel-chart-cap)"}plot(vowel_chart)` ``
Citations and Bibliographies
Section Overview
What you will learn: How to manage references with BibTeX; how to cite sources in Markdown; how to specify citation styles with CSL files; and how Quarto’s visual editor simplifies citation management
BibTeX Reference Files
Both R Markdown and Quarto use BibTeX (.bib) files for bibliographies. A .bib file contains entries like:
@book{johnson2003acoustic,author = {Johnson, Keith},title = {Acoustic and Auditory Phonetics},year = {2003},publisher = {Blackwell},address = {Oxford}}@article{lobanov1971classification,author = {Lobanov, B. M.},title = {Classification of Russian vowels spoken by different speakers},journal = {Journal of the Acoustical Society of America},year = {1971},volume = {49},number = {2},pages = {606--608}}@manual{schweinberger2026notebooks,author = {Schweinberger, Martin},title = {R Markdown and Quarto: Creating Reproducible Documents},note = {https://ladal.edu.au/tutorials/notebooks/notebooks.html},year = {2026},organization = {The Language Technology and Data Analysis Laboratory (LADAL)},address = {Brisbane},edition = {2026.03.10}}
Point your document at the .bib file:
bibliography: references.bib
Citation Syntax
[@johnson2003acoustic] # (Johnson 2003)[@johnson2003acoustic, p. 45] # (Johnson 2003, p. 45)[@johnson2003acoustic; @lobanov1971] # (Johnson 2003; Lobanov 1971)@johnson2003acoustic # Johnson (2003) — narrative citation[-@johnson2003acoustic] # (2003) — suppress author name
Rendered examples:
Parenthetical: formants are described in detail in (Johnson 2003)
Narrative: Johnson (2003) provides a thorough introduction to formant analysis
The default citation style is Chicago author-date. To use a different style, download a CSL file from the Zotero Style Repository and point your document at it:
Pandoc automatically inserts the formatted reference list at the end of the document. In Quarto, add a # References {-} heading at the bottom; in R Markdown, the list appears after the last section or after # References.
To place the reference list somewhere other than the end of the document, use a div:
::: {#refs}:::
Quarto Visual Editor and Zotero Integration
Quarto’s Visual Editor (switch via the Source/Visual toggle in RStudio) provides a GUI for inserting citations. It integrates with:
Zotero (via the Zotero connector) — search your Zotero library and insert citations by clicking
DOI lookup — paste a DOI and Quarto fetches the bibliographic data automatically
CrossRef search — search published literature by title or author
The visual editor automatically adds new entries to your .bib file and inserts the citation key in the document.
Parameterised Reports
Section Overview
What you will learn: How to use YAML parameters to create one document template that generates multiple outputs — for example, one report per speaker, corpus, or time period
Defining Parameters
Parameters are defined in the YAML header and accessed in R code via params$name:
R Markdown:
title:"Vowel Chart Report: MY_SPEAKER" # use params$speaker here in practiceparams:speaker:"ms"variety:"RP"max_formant:5500
In both cases, access the parameters in code chunks with params$speaker, params$variety, etc.
Using Parameters in Code
Code
# Filter data to the speaker specified in paramsspeaker_data <- voweldata |> dplyr::filter(subject == params$speaker)# Use the variety name in a plot titleggplot(speaker_data, aes(x = F2, y = F1)) +geom_text(aes(label = ipa)) +labs(title =paste("Vowel space —", params$variety, "variety"))
Rendering Multiple Reports
To generate one report per speaker programmatically:
What you will learn: Concrete practices for making your R Markdown and Quarto documents maximally reproducible — for yourself, your collaborators, and your readers
Always Include sessionInfo()
R package versions change. A script that works with ggplot2 3.4.0 may behave differently with 3.5.0. Always include sessionInfo() at the end of your document so readers can see exactly which package versions were used:
Code
sessionInfo()
Set a Random Seed
Any analysis involving random numbers (simulation, bootstrapping, random train/test splits, k-means clustering) must set a seed for reproducibility:
Code
set.seed(2026)
Place set.seed() at the top of your setup chunk or immediately before the relevant analysis.
Use here::here() for File Paths
Absolute file paths (e.g. C:/Users/martin/Documents/project/data.csv) break when the project is moved or shared. Use here::here() to construct paths relative to the project root:
The renv package creates a project-specific library with pinned package versions, so the project can be restored exactly on any machine:
Code
# Initialise renv in your projectrenv::init()# After installing/updating packages, snapshot the libraryrenv::snapshot()# Collaborator restores exact package versionsrenv::restore()
Avoid Absolute Dates
Use date: last-modified (Quarto) or date: "YYYY-MM-DD" set via Sys.Date() as an inline R expression (R Markdown) rather than a hardcoded date string — the document date always reflects when it was last rendered.
Use Version Control
Store your .Rmd/.qmd, .bib, data files, and renv.lock in a Git repository. This makes every change traceable and enables collaboration via GitHub or GitLab.
Practice
Why
Include `sessionInfo()`
Records exact package versions used
Set `set.seed()`
Ensures random results are reproducible
Use `here::here()` paths
File paths work on any machine
Use `renv` for package management
Pins package versions for exact reproducibility
Use version control (Git)
Tracks changes; enables collaboration
Use `freeze: auto` in Quarto
Avoids re-running unchanged code on project rebuild
Cache expensive chunks with `cache: true`
Speeds up rendering for expensive computations
Use `embed-resources: true` for HTML
Self-contained file — no broken relative links
Write `echo: true` for analytical chunks
Readers can verify and reproduce the analysis
Document all data sources
Provenance of data is clear and traceable
Common Problems and Solutions
Section Overview
What you will learn: The most common errors encountered when rendering R Markdown and Quarto documents, and how to fix them
Problem
Cause
Solution
Document fails to render with a LaTeX error
Missing LaTeX package or TinyTeX not installed
Run `tinytex::install_tinytex()` or `tinytex::tlmgr_install('pkg')`
Unicode/IPA symbols appear as boxes or ? in PDF
`pdflatex` engine does not support Unicode
Set `latex_engine: xelatex` (R Markdown) or `latex-engine: xelatex` (Quarto)
Figures not showing in PDF
File path is wrong or figure is not generated
Check path with `file.exists()`; use `here::here()`
`object 'x' not found` error
Chunk that creates the object ran after the chunk that uses it
Reorder chunks so objects are created before they are used
Package not found error during render
Package installed in global library but not in `renv` library
Run `renv::restore()` or `renv::install('pkg')`
YAML parsing error
Incorrect indentation or special characters in YAML values
Wrap values containing colons or special chars in quotes; use spaces not tabs
Cross-reference not resolving (`@fig-X` shows literally)
Chunk label missing the `fig-` prefix or wrong syntax
Ensure label starts with `fig-` and `#|` syntax is used
Cache not updating after data change
Cache key is based on code only — data changes are not detected
Add `dependson` option pointing to the data-loading chunk
HTML output has broken images
Path is absolute or relative to wrong directory
Use `here::here()` or set `embed-resources: true` in Quarto
Chunk option has no effect
Option spelled incorrectly or wrong syntax (`.` vs `-`)
Check spelling: R Markdown uses `.` (e.g. `fig.height`); Quarto uses `-` (e.g. `fig-height`)
Citation and Session Info
Citation
Martin Schweinberger. 2026. R Markdown and Quarto: Creating Reproducible Documents. The Language Technology and Data Analysis Laboratory (LADAL), The University of Queensland, Australia. url: https://ladal.edu.au/tutorials/notebooks/notebooks.html (Version 3.1.1). doi: 10.5281/zenodo.19332919.
@manual{martinschweinberger2026r,
author = {Martin Schweinberger},
title = {R Markdown and Quarto: Creating Reproducible Documents},
year = {2026},
note = {https://ladal.edu.au/tutorials/notebooks/notebooks.html},
organization = {The Language Technology and Data Analysis Laboratory (LADAL), The University of Queensland, Australia},
edition = {2026.03.28}
doi = {}
}
This tutorial was re-developed with the assistance of Claude (claude.ai), a large language model created by Anthropic. Claude was used to help revise the tutorial text, structure the instructional content, generate the R code examples, and write the checkdown quiz questions and feedback strings. All content was reviewed, edited, and approved by the author (Martin Schweinberger), who takes full responsibility for the accuracy and pedagogical appropriateness of the material. The use of AI assistance is disclosed here in the interest of transparency and in accordance with emerging best practices for AI-assisted academic content creation.
Allaire, JJ, Yihui Xie, Jonathan McPherson, Javier Luraschi, Kevin Ushey, Aron Atkins, Hadley Wickham, Joe Cheng, Winston Chang, and Richard Iannone. 2023. “Rmarkdown: Dynamic Documents for r, 2021.”R Package Version 2: 69.