我正在尝试使用knitr和pandoc转换为PDF时控制绘图的位置.我的.Rmd文件看起来像这样:
# My report
Some text some text some text some text some text some text some text some text some text
```{r myplot, echo=FALSE, fig.pos="placeHere", results='hide'}
library(ggplot2)
ggplot(mtcars, aes(mpg, drat)) + geom_point()
```
Some text some text some text some text some text some text some text some text some text
\usepackage{graphicx}
\begin{figure}[placeHere]
\centering
\includegraphics[width=0.5\textwidth]{placeHere}
\end{figure}
Some text some text some text some text some text some text some text some text some text
Run Code Online (Sandbox Code Playgroud)
我正在使用此处提供的功能转换为PDF:http://quantifyingmemory.blogspot.co.uk/2013/02/reproducible-research-with-r-knitr.html
如何在第二和第三块文本之间放置图?乳胶代码目前无法正常工作. …
正如标题所述,我的问题是关于 pandocs md 到 pdf 的。
当我像这样转换降价时
# Title
...... text that is about a 3/4 page

Some more text
Run Code Online (Sandbox Code Playgroud)
然后图像“更多文本”之后的文本显示在第一页上,并且图像被推送到第二页,这改变了我的内容的顺序。
我能做的就是
# Title
...... text that is about a 3/4 page
\newpage

Some more text
Run Code Online (Sandbox Code Playgroud)
但这维护起来非常烦人,因为当我想随后在开头添加内容时,我必须检查是否\newpage仍然有必要,是否必须在其他地方添加另一个内容。
有没有真正的解决方案?也许是 YAML 标头中的设置?
我在谷歌上搜索了很多关于这个问题的信息,但没有找到解决方案。
谢谢 :)