1

I add "fig_caption: TRUE" to the default R Notebook example:

---
title: "R Notebook"
output: html_notebook
fig_caption: TRUE
---
This is an [R Markdown](http://rmarkdown.rstudio.com) Notebook. When you execute code within the notebook, the results appear beneath the code. 

Try executing this chunk by clicking the *Run* button within the chunk or by placing your cursor inside it and pressing *Ctrl+Shift+Enter*. 

```{r}
plot(cars)
```

I was expecting something like a "Figure 1" caption after the plot, but do not get any. What should I do to get figure captions with an automatic numbering?

user2955884
  • 405
  • 2
  • 11
  • 1
    It's `fig.cap`, not `fig_caption`. See [here](https://bookdown.org/yihui/rmarkdown/tufte-figures.html). And you do actually need to provide the text of the caption. – Limey Oct 13 '22 at 07:23
  • Have you seen this link? https://stackoverflow.com/questions/37116632/r-markdown-html-number-figures – Peter Oct 13 '22 at 07:24
  • You don't need to specify `fig_caption: TRUE` in the yaml. [`fig_caption: TRUE` is set by default in `html_notebook`](https://github.com/rstudio/rmarkdown/blob/898199b9bc3df2da50edd1f7ded472e6c9e46c1b/R/html_notebook.R#L26) – shafee Oct 13 '22 at 07:27
  • 2
    `fig.cap` when running the chunk inline is not supported yet. check these two open issues on the `{rmarkdown}` and `rstudio` github repository. [#1764](https://github.com/rstudio/rmarkdown/issues/1764) and [#11113](https://github.com/rstudio/rstudio/issues/11113) – shafee Oct 13 '22 at 07:50
  • @Limey fig.cap is the chunk option, fig_caption the YAML option see https://bookdown.org/yihui/rmarkdown/html-document.html#figure-options – user2955884 Oct 13 '22 at 10:00
  • @Peter Thanks, but those solutions rather look like workarounds. The only simple one is the 1st one, but requires specifying the caption for each chunk. Should I understand that something like just stating fig_caption: TRUE in the yaml is not sufficient? – user2955884 Oct 13 '22 at 10:11
  • @shafe, then, according to #1764 and #11113, it looks like there is no solution at the moment. Thanks. – user2955884 Oct 13 '22 at 10:17

0 Answers0