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???
Asked
Active
Viewed 3,879 times
7
-
Did you try fig.cap in the code block parameters? – user12256545 Apr 21 '20 at 15:37
-
@user12256545 Yes I tried. `fig.cap` does not do the job. It just takes notes as a caption. What I wanted is the note shown in the figure above. – Yabin Da Apr 21 '20 at 15:51
1 Answers
11
If you are using a format that goes through LaTeX (e.g. 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.

user2554330
- 37,248
- 4
- 43
- 90
-
Hi. I wanted to similar thing but in my case the note is coming above the caption and is center aligned? How can I (1) left align; (2) keep it below caption; and (3) decrease text size of this note? – Dayne Nov 22 '21 at 07:40
-
Hi please ignore (1) and (3) as I was able to do it with required latex code in the latex chunks. (2) is still a problem – Dayne Nov 22 '21 at 07:47
-
@Dayne: you should post a new question showing what you did, and someone will tell you how to fix it. – user2554330 Nov 22 '21 at 10:34
-
thanks for replying. I was thinking I'd putting separately but then tried something and it worked out :). Anyway +1 for this ans – Dayne Nov 23 '21 at 04:00