r - rticles 包中的 knitr::include_graphics 不起作用
问题描述
我正在使用 R rticles 包中的 Elsevier 模板在 Rstudio 中生成 pdf 文档。对于论文,我想包含一个 .png 图像。当我加载图像时
![text](images/framework.png)
一切正常,但是当我将其更改为等效的 knitr 命令时(我更喜欢它,因为它更容易设置无花果大小等)。
{r map, fig.cap="text"}
knitr::include_graphics("images/framework.png")
我收到以下错误:
! Paragraph ended before \Gin@iii was complete.
<to be read again>
当我在 rmarkdown 中切换到 pdf 的标准输出设置时,output:pdf_document
knitr 选项确实有效,所以我猜这个问题一定与 rticles 包有关。我在互联网上查看并认为这可能与使用 \graphics 包而不是 \graphicx 乳胶包有关......
https://tex.stackexchange.com/questions/37650/paragraph-ended-before-giniii-was -在插入时完成图像与包含
我尝试在 yaml 中添加以下内容:
header-includes:
- \usepackage{graphicx}
但错误仍然存在。
解决方案
昨天我遇到了同样的问题,使用rticles::elsevier_article
and knitr::include_graphics
。
今天我找到了解决方案:dpi = NA
在include_graphics
函数中使用:
{r map, fig.cap="text"}
knitr::include_graphics("images/framework.png", dpi = NA)
但是,在组合两个图像并 out.width = '50%'
在代码块中使用参数时,我仍然会遇到相同的错误:
{r map, fig.cap="text", out.width = '50%'}
knitr::include_graphics(c("img1", "img2"), dpi = NA)
希望它仍然有用!
推荐阅读
- c++ - istringstream >> 运算符产生意外行为
- shieldui - ShieldUI 网格组件是否支持本地化或 i18n?
- java - JetBrains Java 泛型问题
- java - 如何处理嵌套的 Flux 和 Monos
- python - django:无法将对象保存在数据库中
- java - 使用 `LinkedBlockingQueue` 可能会导致空指针异常
- php - 隐藏 WooCommerce 付款方式功能禁用 WordPress nav-menus.php
- python - 神经网络总是输出接近 0.5 的值
- javascript - Discord.js v12.2.0 | 根据反应添加角色
- serverless-framework - 在无服务器资源名称中使用变量