Elevating R Markdown for Advanced Publishing
Christophe Dervieux
Posit PBC
July 9, 2024
An open-source, scientific and technical publishing system
Quarto is the next generation of R Markdown
it unifies and improves the R Markdown ecosystem
it extends it for people who don’t know R Markdown
Artwork from “Hello, Quarto” keynote by Julia Lowndes and Mine Çetinkaya-Rundel, presented at RStudio Conference 2022. Illustrated by Allison Horst.
D. Krishnamurthy, “Writing technical papers with Markdown and Pandoc,” Dec. 20, 2015. https://kdheepak.com/blog/writing-papers-with-markdown
Quarto is a command line interface (CLI) that renders plain text formats (.qmd
, .rmd
, .md
) OR mixed formats (.ipynb
/Jupyter notebook) into static PDF/Word/HTML reports, books, websites, presentations and more.
$ quarto --help
Usage: quarto
Version: 1.5.53
Description:
Quarto CLI
Options:
-h, --help - Show this help.
-V, --version - Show the version number for this program.
Commands:
render [input] [args...] - Render files or projects to various document types.
preview [file] [args...] - Render and preview a document or website project.
serve [input] - Serve a Shiny interactive document.
create [type] [commands...] - Create a Quarto project or extension
use <type> [target] - Automate document or project setup tasks.
add <extension> - Add an extension to this folder or project
update [target...] - Updates an extension or global dependency.
remove [target...] - Removes an extension.
convert <input> - Convert documents to alternate representations.
pandoc [args...] - Run the version of Pandoc embedded within Quarto.
typst [args...] - Run the version of Typst embedded within Quarto.
run [script] [args...] - Run a TypeScript, R, Python, or Lua script.
install [target...] - Installs a global dependency (TinyTex or Chromium).
uninstall [tool] - Removes an extension.
tools - Display the status of Quarto installed dependencies
publish [provider] [path] - Publish a document or project to a provider.
check [target] - Verify correct functioning of Quarto installation.
help [command] - Show this help or the help of a sub-command.
Quarto integrates with other tools.
From R Markdown…
---
title: Hello penguins!
output:
html_document:
toc: true
---
Some **Markdown** content based on _Pandoc_'s markdown
```{r species, fig.width=5, fig.cap="About penguins"}
ggplot(penguins) + aes(x = bill_length_mm, y = bill_depth_mm, color = species) +
geom_point() + labs(x = "Bill length (mm)", y = "Bill depth (mm)")
```
… to Quarto
---
title: Hello penguins!
format: html
toc: true
---
Some **Markdown** content based on _Pandoc_'s markdown
```{r}
#| label: species
#| fig-width: 5
#| fig-cap: About penguins
ggplot(penguins) + aes(x = bill_length_mm, y = bill_depth_mm, color = species) +
geom_point() + labs(x = "Bill length (mm)", y = "Bill depth (mm)")
```
Multiple fresh polished formats, built-in, with consistent syntax and features.
Feature | Quarto | R Markdown |
---|---|---|
Basic Formats |
typst_document |
|
Beamer | beamer | beamer_presentation |
PowerPoint | pptx | powerpoint_presentation |
HTML Slides | revealjs |
Multiple fresh polished formats, built-in, with consistent syntax and features.
Feature | Quarto | R Markdown |
---|---|---|
Cross References | Quarto Crossrefs | |
Advanced Layout | Quarto Article Layout | |
Websites & Blogs | ||
Books | Quarto Books | bookdown |
Interactivity | Quarto Interactive Documents | Shiny Documents |
Dashboards | Quarto Dashboards | flexdashboard |
Quarto theme files are based on SCSS for all HTML output formats (shared by HTML and RevealJS slides, extendable to work with anything).
For boostrap document, based on core variables defined by bslib (so fully compatible with Shiny, Flexdashboard, & R Markdown themes).
New PDF rendering through Typst (https://typst.app)
This is the quickest way to do PDF with already nice features !
# Producing a HTML Table with CSS styles
library(gt)
temps <- data.frame(
year = c(1920:1924),
Jan = c(40.6, 44.2, 37.5, 41.8, 39.3),
Jun = c(58.5, 58.7, 57.8, 52.7, 57.7)
)
nice_col <- scales::col_numeric(
colorspace::diverge_hcl(
n = 9, palette = "Green-Orange"
), domain = c(35, 62)
)
gt(temps) |>
data_color(
columns = c(-year),
fn = nice_col
)
Integrated quarto publish
command that targets a variety of services
> quarto publish --help
Usage: quarto publish [provider] [path]
Version: 1.5.52
Description:
Publish a document or project to a provider.
Available providers include:
- Quarto Pub (quarto-pub)
- GitHub Pages (gh-pages)
- Posit Connect (connect)
- Posit Cloud (posit-cloud)
- Netlify (netlify)
- Confluence (confluence)
- Hugging Face Spaces (huggingface)
Accounts are configured interactively during publishing.
Manage/remove accounts with: quarto publish accounts
Quarto specific syntax to include content: https://quarto.org/docs/authoring/shortcodes.html
placeholder
is one of the built-in shortcodes
Let’s add some sample image !
Shortcodes is among what is extensible using Quarto Extensions
A Quarto Project is a directory that contains a file called _quarto.yml.
Organizing content as a project to gain project’s features and enhanced outputs
Examples of project’s configurations
This presentation aimed to give you a taste of what Quarto can do and a broad overview of its features.
Follow other talks at useR! 2024 to learn more about Quarto, and our resources below.
Getting started: https://quarto.org/docs/get-started/
User guide: https://quarto.org/docs/guide/
Awesome Quarto: https://github.com/mcanouil/awesome-quarto
Follow along at https://cderv.github.io/user2024-quarto-talk/ and https://quarto.org