jeppeb
jeppeb

Reputation: 103

Giving two plots in the same chunck different captions in RMarkdown/Bookdown

I have a function that produces several plots. When I call it in a chunck, all plots are given the same caption.

The problem boils down to having two plots in the same chunck with different captions. Is that possible in any way?

---
title: "Testing"
output:
  pdf_document: 
    latex_engine: pdflatex
---
```{r setup, include=FALSE}

```

``` {r, fig.cap="Same Caption"}
plot(cars$speed)

plot(cars)

```

Upvotes: 1

Views: 175

Answers (1)

Martin C. Arnold
Martin C. Arnold

Reputation: 9658

Simply pass a vector with two captions to fig.cap:

```{r, fig.cap=c("Caption", "Not the same caption")}
plot(cars$speed)
plot(cars)
```

Upvotes: 2

Related Questions