Quarto Cheatsheet

Quarto Cheatsheet (LLM‑friendly)

Version: Quarto 1.7 (Updated 2025‑07)

This cheatsheet converts the human‑oriented Quarto PDF into a compact, copy‑pastable guide for LLM prompts and automation. Citations point back to the official PDF.

For comprehensive coverage (journals, books, interactive docs, execution control), see skills/quarto-skill.md.


1) Core ideas

  • Source: .qmd (or Jupyter notebook). Output: HTML/PDF/Word/Presentations/Websites/Books. [PDF p.1 header, p.1 “Write…/Generate…”]
  • Render pipeline: (1) Run code with knitr (for {r}) or Jupyter (for others), then (2) Pandoc converts Markdown to the requested format. [PDF p.1 “Behind the scenes”]
  • Editors: RStudio, VS Code (+ Quarto ext), Positron, or any text editor. [PDF p.1]
  • Projects: A dir of .qmd + _quarto.yml. Create from CLI or IDE. [PDF p.1]
  • Publish: quarto publish {venue}; venues include quarto-pub, connect, gh-pages, netlify, confluence. [PDF p.1]

2) CLI commands

# Render (all formats defined in YAML)
quarto render path/to/file.qmd

# Render a specific format
quarto render path/to/file.qmd --to pdf

# Live preview while editing
quarto preview path/to/file.qmd

# Create a project (types: default, website, blog, book, confluence, manuscript)
quarto create project {type}

# Publish (venues: quarto-pub, connect, gh-pages, netlify, confluence)
quarto publish {venue} path/to/file.qmd

[PDF p.1: render/preview/publish; project types/venues]

3) Minimal document

---
title: "My Document"
format: html
---

# Hello
Some prose.

[PDF p.1 examples]

4) Multi‑format document (HTML + PDF) with global + per‑format options

---
title: "My Document"
toc: true                   # global applies to all formats
format:
  html:
    code-fold: true
  pdf: default
---

[PDF p.2 “Set Format and Options / Multiple Formats”]

5) Code cells & execution

  • Cell fences: start with {language} … and end with ```
  • Options are added via #| comments in the cell or globally in YAML under execute:
  • Common execution options (default → effect):
    • echo: truefalse hides code
    • eval: truefalse skips running
    • include: truefalse omits code/results
    • output: truefalse omits results
    • asis: falsetrue treats results as raw Markdown
    • warning: truefalse hides warnings
    • error: falsetrue keeps going after errors and shows them
  • Global:
---
execute:
  echo: false
---
  • Per‑cell:
#| label: load-data
#| echo: false
import pandas as pd

[PDF p.2 “CODE CELLS”, “EXECUTION OPTIONS”]

6) Figures

Figure 1: Scatter of X vs Y
#| label: fig-scatter
#| fig-cap: "Scatter of X vs Y"
#| fig-alt: "Dots showing relation between X and Y"
# (plot code here)

Key figure options: fig-cap, fig-alt, fig-width, fig-height, fig-align, fig-format. [PDF p.2 figures/options table]

7) Tables

R (Markdown table via knitr):

#| label: tbl-cars
#| tbl-cap: "Head of cars"
knitr::kable(head(cars))

Python (Markdown via pandas → Markdown()):

#| label: tbl-small
#| tbl-cap: "A small table"
import pandas as pd
from IPython.display import Markdown
df = pd.DataFrame({"A":[1,2],"B":[1,2]})
Markdown(df.to_markdown(index=False))

Also see R packages: gt, flextable, kableExtra. [PDF p.2 “TABLES”]

8) Cross‑references

  • Prefixes: fig- (Figure), tbl- (Table), eq- (Equation), sec- (Section)
  • Label a code cell with label: prefix-id or a Markdown element with {#prefix-id}
  • Reference with @prefix-id in text.
    Example: “As shown in Figure 1…” [PDF p.2 “CROSS REFERENCES”]

9) Citations

---
bibliography: references.bib
---

In text: [@key] or @key. Build .bib from Zotero, DOI, Crossref, DataCite, PubMed. [PDF p.2 “CITATIONS”]

10) Common document options (by format)

10.a) Self‑contained HTML with embed-resources

What it does: Packages CSS, JS, images, and other assets directly into the HTML file (via data: URIs) so the page works offline and has no external dependencies.

When to use: Emailing a single file, attaching to tickets, archiving reproducible outputs, or publishing where asset hosting is unreliable.

YAML (document-level):

format:
  html:
    embed-resources: true

YAML (project-level _quarto.yml):

format:
  html:
    embed-resources: true

Notes: Increases file size; some complex JS modules were fixed in recent Quarto releases—keep Quarto current; supported for HTML formats including revealjs.

(Put under format:html: / pdf: / docx: unless marked “all”)

  • All formats: toc, toc-depth, highlight-style, keep-md, fig-width, fig-height, fig-format, code-overflow, code-tools, code-fold
  • HTML / revealjs: theme, css, anchor-sections, embed-resources
  • docx / pptx: reference-doc
  • PDF / beamer: documentclass, pdf-engine, mainfont/monofont
  • Citations: cite-method

Examples:

format:
  html:
    theme: cosmo        # Bootswatch
    code-tools: true    # add show/hide + download
  pdf:
    pdf-engine: xelatex
    fig-width: 5
    fig-height: 3

[PDF p.2 options matrix]

11) Callouts

::: {.callout-tip}
## Title
Helpful text.
:::

Types: tip, note, caution, warning, important. [PDF p.2 “CALLOUTS”]

12) Shortcodes

{{< include _file.qmd >}}
{{< embed notebook.ipynb#cell-id >}}
{{< video video.mp4 >}}

[PDF p.2 “SHORTCODES”]


Citations back to the official PDF

  • Header, editors, project & publish venues, CLI: Quarto cheatsheet PDF (Posit, Quarto 1.7, updated 2025‑07).
  • Render pipeline (knitr/Jupyter → Pandoc): Quarto cheatsheet PDF.
  • Figures/tables/cross‑refs/citations/execution options/callouts/shortcodes/options matrix: Quarto cheatsheet PDF.

(Primary source: https://rstudio.github.io/cheatsheets/quarto.pdf)