I want to add a caption to a figure in Rmarkdown, and it won't let me. The header of the file looks like this
---
title: "..."
author: "..."
date: '...'
output:
pdf_document:
fig_caption: true
---
and I display the image using
```{r, echo = FALSE, fig.width = 4, fig.cap = "my caption. \\label{my-label}"}
knitr::include_graphics('figure1')
knitr::include_graphics('figure2')
```
because I want to display two figures side-by-side. The figures are showed perfectly, but there's no way the caption will appear. Maybe I have to use two captions since I'm using two figures? I don't know how to do that either.
Best Answer
You can include the figures directly using LaTeX: