Skip to content

Inline code in figure captions #1334

Answered by cderv
Dpananos asked this question in Q&A
Jul 8, 2022 · 2 comments · 3 replies
Discussion options

You must be logged in to vote

As documented, when using R, you need to use the !expr syntax in YAML so that an evaluation happens before YAML parsing
https://quarto.org/docs/computations/r.html#chunk-options

---
self-contained: true
format: html
---

```{r}
nsims <- 1000
x <- rnorm(nsims)
```

The following does not work with knitr/rmarkdown:

```{r}
#| fig-cap: !expr paste(nsims, "draws from a standard normal")
hist(x)
```

Replies: 2 comments 3 replies

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
3 replies
@mcanouil
Comment options

mcanouil Jul 8, 2022
Collaborator

@cderv
Comment options

cderv Jul 8, 2022
Maintainer

@mcanouil
Comment options

mcanouil Jul 8, 2022
Collaborator

Answer selected by mcanouil
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
3 participants