我正在使用knitr(1.9.5和1.9.17)和rmarkdown(0.5.3.1),并希望在pdf输出中保持数字位置.使用区块选项fig.pos="H"
时,生成的pdf文件工作正常.
但是,当在中设置fig_caption: yes
时,图形位置不会保持不变
我应该如何解决这个问题?谢谢你的建议.
编辑:
在学习了latex 的漂浮环境之后.我将float
个包裹添加到标题中.
\usepackage{float}
但是,生成的tex文件在figure
环境中始终使用htbp
,因为使用了fig.pos
个选项.手动将htbp
更改为H
后,所有图形的位置保持不变.
这是我的rmd文件示例:
---
title: "Untitled"
output:
pdf_document:
fig_caption: yes
includes:
in_header: mystyles.sty
---
# Section 1
Note that the `echo = FALSE` parameter was added to the code chunk to prevent printing of the R code that generated the plot.
Note that the `echo = FALSE` parameter was added to the code chunk to prevent printing of the R code that generated the plot.
Note that the `echo = FALSE` parameter was added to the code chunk to prevent printing of the R code that generated the plot.
Note that the `echo = FALSE` parameter was added to the code chunk to prevent printing of the R code that generated the plot.
```{r fig1, echo=FALSE, fig.height=8.5, fig.pos="H"}
plot(cars)
```
# Section 2
More test
```{r fig2, echo=FALSE, fig.height=8.5, fig.pos="H"}
plot(cars)
```
# Section 3
```{r fig3, echo=FALSE, fig.height=8.5, fig.pos="H"}
plot(cars)
```
More test