我正在使用rmarkdown输出PDF文档,但是在绘图中添加标题似乎无效。根据文档,我们应该使用fig.cap
指定要传递给Latex的图形标题。这是我的代码块的标题:
```{r Plot bond index returns, include = TRUE, fig.cap = "Bond index cumulative returns"}
我确保在rmarkdown文档的标题中包含以下几行
output:
pdf_document:
fig_caption: true
此设置从生成的PDF中完全消除了整个块的输出
答案 0 :(得分:1)
您能否提供更多细节?我无法重现此错误。准系统.md看起来像这样:
---
output: pdf_document
---
```{r echo = FALSE, fig.cap = "Test figure caption."}
plot(pressure)
```
我得到如下输出:
编辑:
在查看答案to this question之后,以下代码将生成图形,文本中会散布一些图形:
---
output: pdf_document
header-includes:
\usepackage{float}
\floatplacement{figure}{H}
---
```{r global_options, include=FALSE}
knitr::opts_chunk$set(fig.pos = 'h')
```
Here is text number preceding figure 1
```{r echo = FALSE, fig.cap = "Test figure caption."}
plot(pressure)
```
Here is text following figure 1
```{r echo = FALSE, fig.cap = "Second test figure caption."}
plot(cars)
```
Here is some final text following the second figure