我正在使用Rstudio在书本中编写文本,并希望在文本中包含这样的图片:
Some text goes here
```{r, fig.cap="\\label{fig:figs}figlabel"}
knitr::include_graphics("images/image.png")
```
Some other text goes here.
但是,当我使用bookdown :: render_book(“ index.Rmd”)渲染书籍时,插入的图片位于下一页,而不是其在文本中的位置。我希望将其放在两个句子之间,但要放在最后一个句子的下面。
是否有一种方法可以控制图像在文本中的显示位置?我尝试查看chunk options for images和bookdown documentation,但似乎都没有记录控制图形放置的方法。
答案 0 :(得分:0)
LaTeX将尝试找到该图形的最佳位置。您可以使用\FloatBarrier
强制放置浮动图形和表格。请注意,这样做可能会导致页面底部有很多空白。
Some text goes here. See fig. \@ref(fig:my-fig)
```{r my-fig, fig.cap="fig caption"}
knitr::include_graphics("images/image.png")
```
\FloatBarrier
Some other text goes here.