02:00
Enhancing scientific publishing through Quarto
Posit
July 8, 2024
Let’s do it together! Follow along…
Create a Quarto project in RStudio and produce HTML.
Convert from .Rmd
to .qmd
?
02:00
Add to the project
reports
..Rmd
exercise file named penguins.Rmd
as is.quarto preview reports/penguins.Rmd
in Terminal.Display the Render button instead of Knit for an Rmd in a Quarto project
Remove output: html_document
from the YAML header and save the file: The Render button should now appear.
.Rmd
to .qmd
.Let’s see what changes!
YAML is still used to provide document-level metadata.
Quarto introduces the “hash pipe” in #|
- this is the preferred syntax, although Quarto is backwards compatible with the old R Markdown syntax.
:::
)Note
Technically, this is constructed as <language-comment-char>|
e.g. #
for R, Python and Julia but //|
for OJS cells as //
is the comment char for Javascript.
Note that YAML for Quarto will follow a “word-word” syntax, with a -
dash and not a .
.
The difference in syntax is due to the fact that Quarto is more closely aligned with Pandoc’s format names and options (hence the use of - as a word separator instead of _
or .
).
05:00
Transform into .qmd
penguins.Rmd
to new-penguins.qmd
.knitr::convert_chunk_header()
on .qmd file
?knitr::convert_chunk_header()
to know how to use it.qmd
file.qmd
formatNew Quarto features
You can test YAML autocompletion and validation in RStudio IDE 🔗
Let’s look at Quarto’s built in features!
R Markdown | Quarto |
---|---|
Custom Blocks of rmarkdown and bookdown to create and style yourself. | Callout Blocks available in all formats and already styled. |
::: {.callout-note}
## About callouts
Note that there are five types of callout:
`note`, `warning`, `important`, `tip`, and `caution`.
:::
About callouts
Note that there are five types of callout: note
, warning
, important
, tip
, and caution
.
R Markdown | Quarto |
---|---|
Available with bookdown in “book” formats (e.g. gitbook() ) or single document variants such as html_document2() |
Cross References available in all formats, for more content and configurable. |
Change of syntax!
fig-
and not fig:
@label
and not \@ref(label)
See @fig-quarto-schematic for Alison Horst's illustration of how Quarto works.
![An illustrated diagram of Quarto](images/quarto-schematics.png){#fig-quarto-schematic}
See Figure 1 for Alison Horst’s illustration of how Quarto works.
Artwork from “Hello, Quarto” keynote by Julia Lowndes and Mine Çetinkaya-Rundel, presented at RStudio Conference 2022. Illustrated by Allison Horst.
R Markdown | Quarto |
---|---|
Available for HTML with distill (Figure layout) ou tufte (Margin content) | Article Layout available for multiple formats and with more flexibility. |
15:00
Add these features!
In your new-penguins.qmd
document:
Note
You can start from your previous document, or download a fresh version from Tutorial’s website
As with R Markdown, different document formats can be produced.
format: html
format: pdf
format: typst
format: docx
format: revealjs
format: pptx
lof
= List Of Figures
Quarto’s HTML is styled with Bootstrap 5 and default values chosen for Quarto.
Quarto’s HTML is styled with Bootstrap 5 and default values chosen for Quarto.
You can also use a theme and customize components with SCSS/SASS.
Quarto guide: https://quarto.org/docs/guide/
Options reference pages for each format: https://quarto.org/docs/reference/
YAML auto-completion: https://quarto.org/docs/tools/rstudio.html#yaml-intelligence
Produce a PDF
.qmd
used to produce HTML.If you want to try…
You’ll need to be set up for LaTeX, but it’s not really suited to the tutorial context.
Produce a PDF with Typst
format: typst
and Render. Look at your shiny new PDF !Quarto 1.5 required
You really need latest Quarto 1.5 for our example to render completely.
10:00
Now let’s take a look at how Quarto can be used to produce more sophisticated content.