How to add inline code to #| fig-cap: in quarto

Viewed 544

Update:

@harre. I encountered an issue.

It works perfect with mtcars dataset.

But when I try to use a loaded dataframe it says:

Fehler in nrow(df_xxx) : Objekt 'df_xxx' nicht gefunden
Ruft auf: paste -> nrow
Fehler in yaml::yaml.load(meta, eval.expr = TRUE) : 
  Could not evaluate expression: paste(nrow(df_xxx), "blabla")
Ruft auf: .main ... FUN -> parse_block -> partition_chunk -> <Anonymous>
Ausf�hrung angehalten

It seems that quarto looks first #|... in this case df_xxx is not generated. Although it is in the environment we have no access to it. Any idea?

Original question: This is a working quarto exmple:

---
title: "test"
format: revealjs
---

## Quarto example


```{r}
#| label: fig-plot_mtcars
#| fig-cap: nrow(mtcars).

plot(mtcars$mpg, mtcars$disp)
```

output:

enter image description here

How can I add a inline code to fig.cap:: desired output: enter image description here

I have tried with #| fig-cap: paste("bla", nrow(mtcars))

1 Answers
Related