For a quarto document with multiple supported output formats, how can I make quarto parameters that are conditional on the active format?
e.g. Suppose I wanted to have one plot background color for HTML output, and a different color for powerpoint? Other applications could be changing character sizes, line weights, etc.
My first thought was ty try placing the params
YAML block within each format specifier, but that doesn't work.
the following params.qmd
document fails rendering with an error "object 'params' not found"
---
title: "format-driven parameters"
format:
html:
params:
plot_bg: "mistyrose"
pptx:
params:
plot_bg: "lightblue"
---
```{r}
#| warning: false
#| message: false
library(ggplot2)
ggplot(mtcars, aes(x=drat, y=mpg)) +
geom_point() +
theme_minimal() +
theme(plot.background = element_rect(fill = params$plot_bg, linetype = "blank"))
```