I want to add a title to a figure and reference the figure number in the document, but I do not want to show a figure caption (because the plot title is sufficient). The following attempt only gives me a figure number if I include fig.cap="This is my title"
in the chunk options.
---
title: "test"
output:
bookdown::html_document2:
toc: true
toc_float: true
toc_depth: 1
code_folding: "show"
theme: default
highlight: tango
fig_captions: no
number_sections: false
---
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
library(tidyverse)
```
```{r myplot, echo=FALSE}
ggplot(mtcars, aes(x=mpg)) +
geom_density() +
ggtitle("This is my title")
```
What I get without setting fig.cap
:
What I want (minus the caption):