quarto
params
Author

Reddy Lee

Published

March 29, 2024

Modified

April 5, 2024


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.

Code
# Attach packages
library(tidyverse)

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:

  1. First item

  2. Second item

    • Subitem 1
    • Subitem 2

2.4 Blockquotes

We can use > to create blockquotes. For example:

This is a blockquote.

2.6 Images

We can include images using the following syntax:

  • From the web: Quarto logo

  • 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:

Quarto logo

Quarto logo

3.2 Callouts

We can create callouts using the callout directive. For example:

Note

Note that there are five types of callouts, including: note, warning, important, tip, and caution.

Tip with Title

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:

Code
cat("Hello, Quarto!")
Hello, Quarto!
Code
print("Hello, python!")
Hello, python!

4 Embed code from external files

4.1 Embed plot

Figure 1: Scatter plot of body mass and flipper length by species
Source: _penguins.qmd

4.2 Embed table

Table 1: First 5 rows of mtcars
mpg cyl disp hp drat wt qsec vs am gear carb
Mazda RX4 21.0 6 160 110 3.90 2.620 16.46 0 1 4 4
Mazda RX4 Wag 21.0 6 160 110 3.90 2.875 17.02 0 1 4 4
Datsun 710 22.8 4 108 93 3.85 2.320 18.61 1 1 4 1
Hornet 4 Drive 21.4 6 258 110 3.08 3.215 19.44 1 0 3 1
Hornet Sportabout 18.7 8 360 175 3.15 3.440 17.02 0 0 3 2

4.3 Embed video

Get started with Quarto | Mine Çetinkaya-Rundel

Quarto for Academics | Mine Çetinkaya-Rundel

Back to top