【问题标题】:Placement of pictures in markdown/bookdown在markdown/bookdown中放置图片
【发布时间】:2019-01-28 10:25:06
【问题描述】:

我正在使用 Rstudio 在 bookdown 中编写文本,并希望在文本中包含这样的图片:

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 imagesbookdown documentation,但似乎都没有记录控制图形位置的方法。

【问题讨论】:

标签: r knitr bookdown


【解决方案1】:

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.

【讨论】:

    猜你喜欢
    • 2020-12-19
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-07-27
    相关资源
    最近更新 更多