Everyday Quarto Reference
The options and patterns I actually reuse
This page is a personal working reference. It focuses on the Quarto options that recur across my research notebooks, reports, teaching material, and websites rather than trying to summarize every Quarto feature.
Render and preview
Run commands from the folder containing the document or _quarto.yml.
# Preview a project and refresh after each saved change
quarto preview
# Render the complete project
quarto render
# Render one document
quarto render report.qmd
# Choose a specific output format
quarto render report.qmd --to html
quarto render report.qmd --to pdf
quarto render report.qmd --to docx
# Check the Quarto installation and its dependencies
quarto checkBefore sharing a report, restart R and render it from a clean session. This exposes missing packages, objects, and file paths that were available only in the interactive environment.
My usual document header
The complete version is available on the template page. These are the defaults I change most often:
toc: true
toc-location: left
toc-title: Contents
number-sections: false
highlight-style: github
format:
html:
theme:
light: flatly
dark: darkly
code-fold: true
code-tools: true
code-link: true
df-print: kable
embed-resources: true
execute:
warning: false
message: falseUseful adjustments:
- Use
code-fold: falsewhen the code should remain visible. - Remove
embed-resources: truefor large reports or website projects. - Add
date: todayfor the render date ordate: last-modifiedfor the file modification date.
My setup cell
#| label: setup
#| include: false
Sys.setlocale("LC_TIME", "C")
options(width = 700, height = 700)
knitr::opts_chunk$set(
out.width = "100%",
fig.showtext = TRUE,
retina = 1
)include: false runs the setup without displaying its code or output.
Cell options I use most
Place cell options immediately below the opening code-cell line:
::: {.cell}
```{.r .cell-code}
summary(data)
```
:::| Option | Effect |
|---|---|
echo: false |
Run the code but hide it |
eval: false |
Display code without running it |
output: false |
Hide printed output |
include: false |
Hide both code and output |
warning: false |
Hide warnings |
message: false |
Hide package messages |
code-fold: true |
Collapse code in HTML output |
fig-width: 7 |
Set figure width in inches |
fig-height: 5 |
Set figure height in inches |
Use short, unique labels containing no spaces.
Figures and tables
Figure labels begin with fig-:
::: {.cell}
```{.r .cell-code}
plot(mtcars$wt, mtcars$mpg)
```
:::Refer to the figure in the text with @fig-mpg-weight.
Table labels begin with tbl-:
::: {#tbl-summary .cell tbl-cap='Descriptive statistics for the analytical sample.'}
```{.r .cell-code}
knitr::kable(summary_table)
```
:::Refer to it with @tbl-summary.
Section references
Add an identifier to a heading:
# Quality control {#sec-qc}Refer to that section with @sec-qc.
Callouts
::: {.callout-note}
Background information that helps interpret the analysis.
:::
::: {.callout-tip}
A practical recommendation or shortcut.
:::
::: {.callout-warning}
Something that can invalidate or change the analysis.
:::
::: {.callout-caution}
Something that requires particular care.
:::
::: {.callout-important}
A detail the reader should not miss.
:::The same callouts appear like this after rendering:
Background information that helps interpret the analysis.
A practical recommendation or shortcut.
Something that can invalidate or change the analysis.
Something that requires particular care.
A detail the reader should not miss.
Relative file paths
Keep paths relative to the project instead of using full computer-specific paths:
# Good
data <- readr::read_csv("data/input.csv")
# Avoid
data <- readr::read_csv("/Users/name/Documents/project/data/input.csv")Store inputs, figures, and helper scripts in clearly named project folders:
project/
├── report.qmd
├── data/
├── figures/
└── scripts/
A small website configuration
For a multi-page project, put shared settings in _quarto.yml:
project:
type: website
output-dir: _site
website:
title: "Project title"
search: true
navbar:
left:
- href: index.qmd
text: Home
- href: analysis.qmd
text: Analysis
format:
html:
theme:
light: flatly
dark: darkly
toc: true
code-copy: trueDocument headers can still override these defaults when one page needs different behavior.