Quarto basics
This document demonstrates the basic features of Quarto. You can find the source code of this document from upper right corner of this page by clicking “Code > View Source”.
1 Setup
If we label a code chunk as setup
, it will be executed automatically when you first run a code chunk. We can also set message: false
to suppress the output of the code chunk. For example, the following code chunk loads the tidyverse
package and suppresses the output message.
2 Text styles
2.1 Headings
We can use #
to create headings. The number of #
indicates the level of the heading. For example, # Heading 1
, ## Heading 2
, ### Heading 3
, and all the way up to ###### Heading 6
.
If we set number-sections: true
in the YAML front matter, Quarto will automatically number the headings.
2.2 Emphasis
We can use *
or _
to emphasize text. For example, italic, bold, and bold italic.
2.3 Lists
We can create ordered and unordered lists. For example:
First item
-
Second item
- Subitem 1
- Subitem 2
2.4 Blockquotes
We can use >
to create blockquotes
. For example:
This is a blockquote.
2.5 Links
We can create links using the following syntax:
2.6 Images
We can include images using the following syntax:
From the web:
From the local file:
2.7 Colors
We can use HTML color names or hexadecimal color codes to set text and background colors. For example:
Blue text
Purple text
2.8 Equations
We can include equations using LaTeX syntax. For example:
Inline equation: \(E=mc^2\)
-
Block equation: \[\int_{-\infty}^{\infty} e^{-x^2} dx = \sqrt{\pi}\]
\[\pi \in \mathbb {R}\]
Basic Functions: \[\sin x, \ \log_2{x}, \hspace{0.5cm} \sqrt[3]{x^2 +1}\]
-
Fractions:
\[\$5 \over{x + y}\]\[ \left[\frac{1}{2} \hspace{0.5cm} \frac{x^2}{x^3}\right\}\]
\[\left(\frac{\partial f}{\partial x}\right)\]
-
Changing faces:
\[\mathbb{R}, \ \mathbb{N}, \ \mathbb{Z}, \ \mathbb{Q}\]\[\mathcal{L}, \ \mathcal{F}, \ \mathcal{G}\]
Text in equations: \[ \frac{\text{ordinary stuff}}{\text{extraordinary stuff}}\]
-
Aligned equation:
\[ \begin{aligned} (x + y)^2 &= x^2 + 2xy + y^2 \\ \\ &\ne x^2 + y^2 \end{aligned} \]
Numbered equation: \[ \frac{\partial \mathrm C}{ \partial \mathrm t } + \frac{1}{2}\sigma^{2} \mathrm S^{2} \frac{\partial^{2} \mathrm C}{\partial \mathrm C^2} + \mathrm r \mathrm S \frac{\partial \mathrm C}{\partial \mathrm S}\ = \mathrm r \mathrm C \tag{1}\]
Black-Scholes (Equation 1) is a mathematical model that seeks to explain the behavior of financial derivatives, most commonly options.
-
Matrices:
\[ \begin{bmatrix} 1 & 2 & 3 \\ 4 & 5 & 6 \\ 7 & 8 & 9 \end{bmatrix} \]
3 Layout
3.1 Columns
We can create columns using the columns
directive. For example:
3.2 Callouts
We can create callouts using the callout
directive. For example:
Note that there are five types of callouts, including: note
, warning
, important
, tip
, and caution
.
This is an example of a callout with a title.
This is an example of a ‘folded’ caution callout that can be expanded by the user. You can use collapse="true"
to collapse it by default or collapse="false"
to make a collapsible callout that is expanded by default.
3.3 Tabsets
We can create tabsets using the tabset
directive. For example:
4 Embed code from external files
4.1 Embed plot
4.2 Embed table
4.3 Embed video
Get started with Quarto | Mine Çetinkaya-Rundel
Quarto for Academics | Mine Çetinkaya-Rundel