简体   繁体   中英

How to create a figure note below the figure caption in r markdown and bookdown

I am struggling to create a figure note below the figure caption in r markdown and bookdown . The figure note I want looks like below. This figure is from (Greenstone and Hanna 2014) . My figure actually is a r plot. The note should be the same length as the figure width and automatically break the line. Any ideas???

在此处输入图像描述

If you are using a format that goes through LaTeX (eg pdf_book or pdf_document ), this is possible. I don't know if there's a way to do it with HTML output. (But does that move figures around? Maybe plain text below the figure is enough). The idea is to enter the LaTeX code to start and end the figure yourself, and include the note within that block. Here's an example, based on the standard pdf_document example.

---
title: "Untitled"
output: 
  pdf_document
---

```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
```

## Including Plots

You can also embed plots, for example:  Figure \ref{fig:pressure}.
```{=latex}
\begin{figure}[t]
```
```{r pressure, echo=FALSE}
plot(pressure)
```
```{=latex}
\caption{Air quality monitors across India. \label{fig:pressure}}
\textit{Notes:} Dots denote cities with monitoring stations
under India's National Ambient Air Monitoring Programme
(NAAMP).  Geographical data are drawn from MIT's Geodata
Repository.
\end{figure}
```

Note that the `echo = FALSE` parameter was added to the code chunk to prevent printing of the R code that generated the plot.

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