Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Passing italics through fig.scap (table of figures) or fig.cap (captions) in Rmarkdown

I asked and answered my own question, so I'll post it here in case it helps

If you want a table of figures in Rmarkdown or Bookdown, and you want to use Markdown formatting you cannot put it within the Rmarkdown chunk itself:

```{r chunk1,fig.scap="my *short* caption"}

knitr::include_graphics("some_figure.png")
```
like image 820
chasemc Avatar asked Oct 28 '25 10:10

chasemc


1 Answers

Instead you have to use caption by reference:

---
title: "reprex"
output: bookdown::pdf_book
toc: yes
lof: yes
lot: yes
---

```{r chunk1, echo=FALSE, fig.scap='(ref:short)', fig.cap='(ref:long)'}
plot(1)
```

(ref:short) "This is *a short* caption"

(ref:long) "This is *a long* caption"
like image 75
chasemc Avatar answered Oct 30 '25 00:10

chasemc