简体   繁体   中英

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

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"

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM