且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

在r-markdown中无法从URL找到图像文件

更新时间:2023-02-23 19:30:28

LaTeX graphicx 软件包不包含http客户端,因此无法从互联网提取图像.但是,从Markdown到LaTeX的许多转换工作是由pandoc执行的,可以获取此图像.只需通过传递--extract-media选项告诉pandoc将所有图像存储在本地即可.当RMarkdown调用LaTeX时,它可以查找图像.

The LaTeX graphicx package does not include an http client, it is therefore not able to pull the image from the internet. However, a lot of the conversion work from Markdown to LaTeX is performed by pandoc, which can get this image. One just needs to tell pandoc to store all images locally by passing the --extract-media option. This allows LaTeX to find the images when it is invoked by RMarkdown.

---
output:
  pdf_document:
    pandoc_args: ["--extract-media", "."]
---

以上内容将所有图像与Rmd文件存储在同一目录中.这些文件将使用SHA1哈希命名,因此您可能想为这些文件使用单独的目录.

The above will store all images in the same directory as the Rmd file. The files will be named using SHA1 hashes, so you might want to use a separate directory for these files instead.