Add both a title above and a note below a figure when knitting Rmarkdown to HTML

I am knitting an Rmarkdown document to HTML with bookdown::html_document2 . How can I include both a title above the figure and a note below the figure?

For example, this code lets me produce a figure with a title above the figure. But how can I also include a note below the figure?

To be clear, I do not want to include the note below the ggplot with + labs(caption = "Text") , I want to have the note separate from the plot in the same HTML style as the figure title above the figure (as is common in scientific publications).

---
title: "Reprex"
output: 
  bookdown::html_document2
---

```{r setup, include=FALSE}
knitr::opts_chunk$set(fig.topcaption = TRUE) # Display figure title above the figure
```

Figure \@ref(fig:figure) shows some results.

```{r figure, fig.cap="Figure Title (which I want above the figure)"}
library(tidyverse)
mtcars %>% 
  ggplot() +
  aes(x = wt, y = mpg) +
  geom_point()
```

I fear that this is not yet possible.

Is this what you would like ?

Hi @cderv, thanks for the information, this is exactly what I would like. Fingers crossed that it will be implemented soon!

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.