L3: Quarto Presentations

Bogdan G. Popescu

John Cabot University

Introduction

Quarto supports a variety of formats for creating presentations, including:

The most capable format by far is revealjs which can be presented as HTML slides or can be printed to PDF for easier distribution

Quarto Document Structure

YAML Header

  • The YAML header defines the document metadata, such as title, author, date, and output format.
---
title: "Statistical Analysis Presentation"
author: "Your Name"
date: "2024-11-05"
format: revealjs
---

# Introduction

This is an example.

Creating HTML Output

Basic YAML Configuration

To generate an HTML file, specify format: revealjs in the YAML header.

Use quarto render in R to generate the output.

Creating Slides

You can also divide slide shows into sections with title slides using a level 1 and level 2 header (#). For example:

---
title: "Statistical Analysis Presentation"
author: "Your Name"
date: "2024-11-05"
format: revealjs
---

# Introduction
## Section 1

This is an example.

Incremental Lists

This is how we create increamental lists

---
title: "Statistical Analysis Presentation"
author: "Your Name"
date: "2024-11-05"
format: revealjs
    incremental: true
---

## Section 1

- This is an example
- This is another example.

Incremental Lists

We can obtain the same output in the following way:

---
title: "Statistical Analysis Presentation"
author: "Your Name"
date: "2024-11-05"
format: revealjs
---

## Section 1

::: {.incremental}
- This is an example
- This is another example.
:::

Multiple Columns

To put material in side by side columns, you can use a native div container with class .columns

---
title: "Statistical Analysis Presentation"
author: "Your Name"
date: "2024-11-05"
format: revealjs
---

## Section 1

:::: {.columns}

::: {.column width="40%"}
Left column
:::

::: {.column width="60%"}
Right column
:::

::::

Content Overflow

If you have a slide that has more content than can be displayed on a single frame there are two slide-level classes you can apply to mitigate this:

  1. Using .smaller
## Slide Title (with `.smaller`){.smaller}

- Point 1
- Point 2

Content Overflow

If you have a slide that has more content than can be displayed on a single frame there are two slide-level classes you can apply to mitigate this:

  1. Use the .scrollable class to make off-slide content available by scrolling.
## Slide Title {.scrollable}

- Point 1
- Point 2
- Point 3
- Point 4
- Point 5
- Point 6
- Point 7
- Point 8
- Point 9
- Point 10
- Point 11
- Point 12

Themes

There are 11 built-in themes provided for Reveal presentations (you can also create your own themes).

---
title: "Presentation"
author: "Your Name"
date: "2024-11-05"
format: revealjs
theme: dark
---

Themes

There are 11 built-in themes provided for Reveal presentations (you can also create your own themes).

---
title: "Presentation"
author: "Your Name"
date: "2024-11-05"
format: revealjs
theme: blood
---

Themes

There are 11 built-in themes provided for Reveal presentations (you can also create your own themes).

---
title: "Presentation"
author: "Your Name"
date: "2024-11-05"
format: revealjs
theme: beige
---

Themes

There are 11 built-in themes provided for Reveal presentations (you can also create your own themes).

---
title: "Presentation"
author: "Your Name"
date: "2024-11-05"
format: revealjs
theme: league
---

Themes

Other themes include:

  • beige
  • blood
  • dark
  • default
  • league
  • moon
  • night
  • serif
  • simple
  • sky
  • solarized

Themes

You can also create your own theme if you play around with css

Slide Backgrounds

---
title: "Statistical Analysis Presentation"
author: "Your Name"
date: "2024-11-05"
format: revealjs
---

## Slide Title {background-color="aquamarine"}

Slide Gradient Backgrounds

---
title: "Statistical Analysis Presentation"
author: "Your Name"
date: "2024-11-05"
format: revealjs
---

## Slide Title {background-gradient="radial-gradient(#283b95, #17b2c3)"}

Image Backgrounds

By default, background images are resized to cover the full page.

You need to have slide_background.png inside figures.

---
title: "Statistical Analysis Presentation"
author: "Your Name"
date: "2024-11-05"
format: revealjs
---

## Slide Title {background-image="figures\slide_background.png"}

Video Backgrounds

Occasionally, you may want to have a video in the background. Note that you need to edit the video so that it takes as little space as possible.

---
title: "Statistical Analysis Presentation"
author: "Your Name"
date: "2024-11-05"
format: revealjs
---

#  {background-video="video/izma3.mp4" background-size="1200px" visibility="uncounted"}
::: footer

:::

Website Backgrounds

You can easily have website backgrounds in the following way:

---
title: "Statistical Analysis Presentation"
author: "Your Name"
date: "2024-11-05"
format: revealjs
---

## {background-iframe="https://quarto.org"}

Code Blocks in Python

You may want to highlight specific lines of code output

The following will highlight code 1-4 and 6-11

```{python, filename="Python", echo=TRUE, eval=TRUE}
#| code-line-numbers: "1-4|6-11"
from collections import Counter
import pandas as pd
from pretty_html_table import build_table
from IPython.display import display, HTML

# Input texts
texts = {
    "text_1": "I love playing football.",
    "text_2": "I hate basketball.",
    "text_3": "When I was a kid I was playing football."
}
```
Python
from collections import Counter
import pandas as pd
from pretty_html_table import build_table
from IPython.display import display, HTML

# Input texts
texts = {
    "text_1": "I love playing football.",
    "text_2": "I hate basketball.",
    "text_3": "When I was a kid I was playing football."
}

Code Blocks in R

You may want to highlight specific lines of code output

The following will highlight code 2,3,4

```{r, filename="R", echo=TRUE, eval=TRUE}
#| code-line-numbers: "2|3|4"
# Input texts
text_1 <- "I love playing football."
text_2 <- "I hate basketball."
text_3 <- "When I was a kid I was playing football."
```
R
# Input texts
text_1 <- "I love playing football."
text_2 <- "I hate basketball."
text_3 <- "When I was a kid I was playing football."

Code Blocks in R

As you might guess:

  • echo can have two values
    • TRUE - code is visible
    • FALSE - code is not visible
  • eval has two values:
    • TRUE - code is executed
    • FALSE - code is not executed

Code Blocks in R

Examples

echo=TRUE

You can see the code and the code is executed automatically.

```{r, filename="R", echo=TRUE}
text_1 <- "I love playing football."
print(text_1)
```
R
text_1 <- "I love playing football."
print(text_1)
[1] "I love playing football."

echo=FALSE

You cannot see the code and the code is executed automatically.

```{r, filename="R", echo=FALSE}
text_1 <- "I love playing football."
print(text_1)
```
[1] "I love playing football."

Code Blocks in R

Examples

eval=FALSE

You can see the code and the code is not executed.

```{r, filename="R", echo=TRUE, eval=FALSE}
text_1 <- "I love playing football."
print(text_1)
```
R
text_1 <- "I love playing football."
print(text_1)

eval=TRUE

You can see the code and the code is executed.

```{r, filename="R", echo=TRUE, eval=TRUE}
text_1 <- "I love playing football."
print(text_1)
```
R
text_1 <- "I love playing football."
print(text_1)
[1] "I love playing football."

Code Blocks in R

Examples

echo=TRUE and eval=TRUE

This is most useful when we have graphs

```{r, filename="R", echo=FALSE, eval=TRUE}
library(ggplot2)
ggplot(mtcars, aes(x=wt, y=mpg)) + 
  geom_point()+
  geom_smooth(method=lm)
```

Conclusion

There are a variety of ways to customize your Quarto Presentations

Checkout the Quarto Presentation Guide

Other resources:

There are many examples out there. The world is your oyster!