Search code examples
rpandocquartoreveal.js

Set default output-location with Quarto in Revealjs slides


when I create Revealjs slides with Quarto in R I can use the chunk option output-location to define where and how the result of a code chunk is displayed. The Quarto docs explain the options: https://quarto.org/docs/presentations/revealjs/#output-location

The default is to print the output immediately below the code. However, I prefer to have the output after a click (output-location: fragment).

```{r}
#| output-location: fragment
#| echo: true

library(palmerpenguins)
mean(penguins$body_mass_g, na.rm = TRUE)
```

Is there a way to change the default output-location to fragment? I want to avoid defining it in every single chunk. I did not find a way to do it in the YAML header with execute: or knitr: opts_chunk: but neither way worked.

Thanks!


Solution

  • You can specify it in the YAML header on top, just don't nest it within the execute: key:

    ---
    title: Set Output Location Globally
    format: revealjs
    output-location: fragment
    ---