简体   繁体   English

如何在 r markdown 和 bookdown 中的图形标题下方创建图形注释

[英]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 .我正在努力在r markdownbookdown的图形标题下方创建图形注释。 The figure note I want looks like below.我想要的图注如下所示。 This figure is from (Greenstone and Hanna 2014) .这个数字来自(Greenstone and Hanna 2014) My figure actually is a r plot.我的图实际上是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.如果您使用的是通过 LaTeX 的格式(例如pdf_bookpdf_document ),这是可能的。 I don't know if there's a way to do it with HTML output.我不知道有没有办法用 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.这个想法是输入 LaTeX 代码来自己开始和结束图,并在该块中包含注释。 Here's an example, based on the standard pdf_document example.这是一个基于标准pdf_document示例的示例。

---
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.

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM