Is there a way to reference a parameter in a Quarto figure or table caption? In the example below, I am able to reference my input parameter txt
in a regular text block, but not in a figure caption. In the figure caption, only the raw text is displayed:
---
title: "example"
format: html
params:
txt: "example"
---
## I can reference it in text
Here I can reference an input parameter: `r params$txt`
```{r}
#| label: fig-example
#| fig-cap: "Example: I cannot reference a parameter using `r params$txt` or params$txt."
plot(1:10, 1:10)
```
CodePudding user response:
Try with !expr
```{r}
#| label: fig-example
#| fig-cap: !expr params$txt
plot(1:10, 1:10)
```
-output
If we need to add some text, either paste
or use glue
#| fig-cap: !expr glue::glue("This should be {params$txt}")