【问题标题】:Add pdf file in Rmarkdown file在 Rmarkdown 文件中添加 pdf 文件
【发布时间】:2015-01-21 17:15:24
【问题描述】:

是否可以在 Rmarkdown 文件中显示 pdf 文件?比如说,以前保存的图像:'myimage.pdf'

我的目标是“\includegraphics[width=0.5]{myimage.pdf}”的一种形式

【问题讨论】:

  • 是的,pdf_output 支持原始乳胶,所以你可以按照你的建议去做。不过,您需要将单位放在宽度上。
  • 我能够按照您说的做并将其包含在 pdf 输出中,谢谢。有没有办法将它包含在 HTML 输出中?
  • 除非您先将其转换为 png 或 jpeg,否则不会。

标签: pdf r-markdown


【解决方案1】:

2017 年底的更新
可以使用knitr::include_graphics() 导入 PDF 图像,例如

{r label, out.width = "85%", fig.cap = "caption"} include_graphics("path-to-your-image.pdf")

【讨论】:

  • knitr::include_graphics("path-to-your-image.pdf") 为我工作,但 include_graphics("path-to-your-image .pdf") 没有。您是否有可能错过在示例中添加 knitr::
  • 当然。我假设你在一开始就加载 knit
  • 很高兴这个排序现在可以工作,但是在 knitr 1.20 中尺寸控制对我没有任何作用
【解决方案2】:

您可以将其直接插入到您的 R Markdown 中。仅当图像未加载时才会显示备用名称。

![Alternate Name](file.pdf){width=500px}

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2022-07-05
    相关资源
    最近更新 更多