chasemc
chasemc

Reputation: 869

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")
```

Upvotes: 4

Views: 1156

Answers (1)

chasemc
chasemc

Reputation: 869

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"

Upvotes: 5

Related Questions