[1] 4
Dynamic documents and rendering websites
March 19, 2025
Quarto is “an open-source scientific and thechnical publishing system”.
Allows you to write a document containing both
Then render these document into a variety of output formats.
Where does the name come from?
Some of the output formats Quarto can render to include:
If you are familar with R, you have likely heard of the Rmarkdown
package.
Rmarkdown allows writing R code + markdown in the same file, and compiling documents.
Quarto is the successor to Rmarkdown.
Each Quarto Document (file extension “.qmd”) has two sections:
YAML (yet another markup language) controls the settings.
Here is a basic YAML that sets the
YAMLs are always declared at the top of the document, between two sets of ---
Quarto uses markdown for text content.
If we want to include code in our document, we use a code cell:
The triple backticks ``` are used to demark a code chunk.
The {r} tells Quarto this is an R code cell.
A code cell without the “{r}” is just a code chunk.
These are simply formatted as code, but not executed.
```
x <- 2 + 2
print(x)
```
x <- 2 + 2
print(x)
For now, we will just use Quarto to combine markdown + R code
But you can instead use Quarto with
You can only use one coding engine in a single document—no mixing languages.
Python:
Julia:
We will be talking about Python and Julia, and once we have those languages installed, we can use them with Quarto.
Code cells have a variety of settings,
Code cells have a variety of settings, for instance,
Code cells have a variety of settings, for instance,
Code cells have a variety of settings, for instance,
Instead, you can set the code cell settings for all cells in the YAML.
All of your code cells run in order, in the same R session.
This means you can use variables and packages from prior code cells.
Code cells can output figures.
Use fig-cap
to set a caption (title).
Use fig-width
and fig-height
to control the figure size.
You can write inline math between two dollar signs: $ $
Rendering \sum_{i=0}^{\infty}x^i as math \(\sum_{i=0}^{\infty}x^i\) that is inline.
Instead, you can use “display math” with $$ $$
to make a block of math:
$$
\sum_{i=0}^{\infty}x^i
\\
\max_{a} \int_0^1 U(a)
$$
\[ \sum_{i=0}^{\infty}x^i \\ \max_{a} \int_0^1 U(a) \]
Change the format:
yaml setting to “pdf”.
Quarto will
You will need to first have LaTeX installed on your computer.
If you don’t, after installing quarto, run quarto install tinytex
in the terminal (PDF Engines Doc).
There are a couple of options for making presentation slides:
format: beamer
format: revealjs
Individual slides are created with a level-2 header.
Some text on my slide
Some more text.
Projects are useful when working
Quarto has a some proejct types and templates that you can choose from:
In VS Code, you can also create a Quarto project from the Command Palette.
Is a YAML file of settings.
Declares this a Quarto Project.
For a website,
A Quarto website is a collection of Quarto documents that are all rendered to HTML.
Quarto builds your website using Bootstrap and a bunch of default theming options.
Here’s an example website project yaml, with a navbar and a theme.
Create a Quarto project (a website)
Edit and render the website
Look at the quarto-academic-website template
Since I don’t assume you all have Quarto installed yet…
Go to https://quarto.org