Charlotte Wickham
Built with
by Jadey Ryan
Quarto is an open-source, command line tool, built by Posit, to…
$
quarto
render
corvallis.ipynb
corvallis.html
$ quarto render corvallis.ipynb
--to docx
corvallis.docx
{.border .tight fig-alt=“The
corvallis.ipynb
notebook rendered by Quarto to docx
.}
$ quarto render corvallis.ipynb
--to typst
corvallis.pdf
#|
commentsA way to avoid copy-and-pasting into a Word document
quarto publish slides.qmd github-pages
Start with a notebook that works for one value:
Turn hardcoded value into a variable
Make the variable a parameter
Render with a different parameter value
Automate rendering for all parameter values
corvallis.ipynb
Add the tag parameters
to the code cell:
quarto render climate.ipynb
climate.pdf
quarto render climate.ipynb -P city:Portland
climate.pdf
quarto render climate.ipynb -P city:Portland --output-file portland.pdf
portland.pdf
cities
:
city |
output_file |
---|---|
Portland | portland.pdf |
Cottage Grove | cottage_grove.pdf |
St. Helens | st_helens.pdf |
… | … |
_brand.yml
color:
palette:
white: "#FFFFFF"
forest-green: "#2d5a3d"
charcoal-grey: "#555555"
orange: "#ff6b35"
foreground: charcoal-grey
background: white
primary: forest-green
secondary: orange
typography:
fonts:
- family: Montserrat
source: google
- family: Open Sans
source: google
base:
family: Open Sans
weight: 400
headings:
family: Montserrat
weight: 600
color: forest-green
logo:
medium: logo.png
_brand.yml
More control over logo with options:
Use brand-yml
package to set brand elements in your code:
Typst Docs: https://typst.app/docs/
Example:
Tips: Quarto + Typst
Legislation mandating accessible PDFs:
USA ADA 2024 web rule for State and Local Governments
Neither format: typst
nor format: pdf
currently produce tagged PDFs 😔
Possible solutions:
Use format: docx
then use Word to export to PDF
Don’t use PDF. Use format: html
. Quarto ≥v1.8 websites pass axe-core
checks by default.
Advantages
Manage one notebook
Render to one or many formats
“You do you” automation
Tables, e.g. great_tables
, work great too
Include other .md
files with the {{< include >}}
shortcode
Rearrange content with the {{< contents >}}
shortcode
Show content conditional on format
, e.g. interactive plot for HTML, static plot for PDF
Consider Quarto’s plain text format (*.qmd
)— easier version control, copy-paste examples
Quarto:
Source for examples:
Quarto Q&A:
Ask me at charlotte.wickham@posit.co
Big thanks to Jadey Ryan for the inspiring example and talk
.qmd
*.qmd
Plain text, easier version control, copy-paste examples
No output from cells in file, forced reproducibility
Header and markdown unadorned
Code cells inside {python}
code blocks:
corvallis.qmd
---
format: typst
echo: false
title: Corvallis
jupyter: python3
---
```{python}
import polars as pl
from plotnine import *
from datetime import date
from calendar import month_name, month_abbr
from IPython.display import Markdown
```
```{python}
this_month = date(2025, 5, 1)
highlight_color = "#FF5733"
```
```{python}
tmean_oregon = pl.read_csv("data/tmean-oregon.csv", schema_overrides={"date": pl.Date})
tmean = tmean_oregon.filter(
pl.col("city") == "Corvallis",
)
```
```{python}
#| include: false
tmean.head()
```
```{python}
this = tmean.filter(pl.col("date") == this_month).row(0, named=True)
Markdown(f"{month_name[this['month']]} {this['year']} was {abs(this['tmean_diff']):.1f}°C {this['tmean_direction']} than usual.")
```
```{python}
(
ggplot(tmean, aes(x="month", y="tmean"))
+ geom_line(aes(group="year"), alpha=0.2)
+ geom_line(aes(y = "tmean_normal"))
+ geom_line(data=tmean.filter(pl.col("year") == 2025), color=highlight_color)
+ geom_point(
data=tmean.filter(pl.col("date") == this_month), color=highlight_color
)
+ scale_x_continuous(breaks=list(range(1, 13)), labels=list(month_abbr[1:]))
+ labs(title = "Corvallis, OR", x="", y="Mean Temperature (°C)")
+ theme_bw()
+ theme(figure_size = (8, 4))
)
```
.typ
fileIn document header of climate.ipynb
:
quarto render climate.ipynb
Output:
climate.pdf
: the final PDF resultclimate.typ
: the intermediate Typst file. Useful for examining and debugging.Write Typst code in a raw cell with ```{=typst}
syntax
Typst docs: https://typst.app/docs/
This raw syntax works to inject code into other formats too e.g. =html
and =latex
.
Add the typst-function Quarto extension.