Anatomy of a Quarto document
Authoring Quarto
Changing formats
.qmd
file format with three components:
YAML: Metadata
Text: Markdown
Code: R, Python, Observable, and Julia
Weave it all together, and you have beautiful, powerful, and useful outputs!
Metadata: YAML
Text: Markdown
my-document.qmd
Text: Markdown
The `nation.csv` dataset records the [**National Inventory of Dams (NID)**](https://nid.sec.usace.army.mil) information.
The nation.csv
dataset records National Inventory of Dams (NID) information.
Text: Markdown
Markdown syntax | Output |
---|---|
|
italics and bold |
|
superscript2 / subscript2 |
|
|
|
verbatim code |
Code
Code
{}
Inline code executes code within Markdown
Results in:
The number of dams is 92428.
Code can include optional chunk options, in YAML style, identified by #|
at the beginning of the line
Code can include optional chunk options, in YAML style, identified by #|
at the beginning of the line
---
title: "The Story of America's Dam Infrastructure"
format: html
---
This is [**National Inventory of Dams (NID)**](https://nid.sec.usace.army.mil) data.
```{python}
#| include: false
#| fig.alt: "A scatterplot with state on the x-axis and dams on the y-axis."
from plotnine import ggplot, aes, geom_bar
(
ggplot(mpg, aes(x = "state", y = "dams"))
+ geom_bar()
)
```
Code can include optional chunk options, in YAML style, identified by #|
at the beginning of the line
Option | Description |
---|---|
eval |
Evaluate the code chunk |
echo |
Include the source code |
warning |
Include warnings |
include |
Include code and results |
Other options: https://quarto.org/docs/computations/execution-options.html
01-exercise-r.qmd
and run the first three code chunks (in order).#| include: false
chunk option to the first cell. Preview the file and note the differences.author
field and add your name. Preview the file.code-fold
to be true
. Preview the file.**
and (2) use inline code instead of hardcoded values for the number of dams:05:00
Anatomy of a Quarto document
Authoring Quarto
Changing formats
Markdown syntax | Output |
---|---|
|
https://quarto.org |
|
Quarto |
|
![]() |
```{markdown}
| Right | Left | Default | Center |
|------:|:-----|---------|:------:|
| 12 | 12 | 12 | 12 |
| 123 | 123 | 123 | 123 |
| 1 | 1 | 1 | 1 |
```
Right | Left | Default | Center |
---|---|---|---|
12 | 12 | 12 | 12 |
123 | 123 | 123 | 123 |
1 | 1 | 1 | 1 |
```{markdown}
| Right | Left | Default | Center |
|------:|:-----|---------|:------:|
| 12 | 12 | 12 | 12 |
| 123 | 123 | 123 | 123 |
| 1 | 1 | 1 | 1 |
: Table Column Widths {tbl-colwidths="[10,30,30,30]"}
```
Right | Left | Default | Center |
---|---|---|---|
12 | 12 | 12 | 12 |
123 | 123 | 123 | 123 |
1 | 1 | 1 | 1 |
\[E = mc^{2}\]
Divs
::: {.border}
This content can be styled with a border
:::
Spans
[This is *some text*]{.class key="val"}
This is some text
Callout blocks
my-document.qmd
Tip
Note that there are five types of callouts, including: note
, tip
, warning
, caution
, and important
.
Multiple columns
my-document.qmd
::: {layout-ncol=2}

Photo by <a href="https://unsplash.com/@dmey503?utm_content=creditCopyText&utm_medium=referral&utm_source=unsplash">Dan Meyers</a> on <a href="https://unsplash.com/photos/aerial-photography-of-body-of-water-w6X7XaolqA0?utm_content=creditCopyText&utm_medium=referral&utm_source=unsplash">Unsplash</a>
:::
Photo by Dan Meyers on Unsplash
Tabsets
my-document.qmd
This is text that is red.
Anatomy of a Quarto document
Authoring Quarto
Changing formats
important
callout box to “Key Findings at a Glance”:format
to revealjs
. Preview the document.format
to pdf
. Preview the document.Note
Removing code-fold
, code-summary
, and embed-resources
is not required because these are html
only features. However, I’d recommend removing them to keep your document tidy.
05:00