如何确保将Sphinx文档中的图像文件“自动”复制到LaTeX pdf中

问题描述

在我的Sphinx文档项目中,我正在使用如下图像:

.. image:: /_static/carousel_filling.png
   :width: 300px
   :height: 450px
   :scale: 100 %
   :alt: Image here
   :align: right

在生成的Sphinx HTML文档中,图像完美地显示在html页面中。但是,当我使用make latexpdf生成pdf文档时,出现以下错误:

'LaTeX Warning: File `{carousel_filling}.png' not found on input line ...'

我试图找到与输出图像有关的文档,但是我只想到了这一点:

实例from

latex_additional_files 相对于 配置目录,在构建时复制到构建目录 LaTeX输出。这对于复制Sphinx不复制的文件很有用 自动,例如如果在添加到其中的自定义LaTeX中引用了它们 latex_elements。 在源文件中引用的图像文件(例如 通过.. image::)自动复制。

因此,图像文件应该自动添加到输出pdf文件。但是,这没有发生。在应包含图像的pdf文件中,只能看到空白矩形

有趣的是,我可以看到图像文件已经复制到了文件夹 _build / latex ,因此,这意味着{{1 }}可以访问图像文件!

问题

如何在生成的pdf文件中正确输出Sphinx文档中包含的图像?

编辑1:

在终端中,我可以看到以下警告

pdflatex

编辑2:

代替图像(在pdf文件中输出了矩形轮廓),我可以看到:

LaTeX Warning: File `{carousel_filling}.png' not found on input line 931. ! Package pdftex.def Error: File `"""{carousel_filling}".png' not found: using dra ft setting. See the pdftex.def package documentation for explanation. Type H <return> for immediate help. ... l.931 ...t=450\sphinxpxdimen]{{carousel_filling}.png} ? [21]

解决方法

请勿将图片放在_static下。这是一个专用文件夹,不适用于图像。例如。在您的第一个文件级别创建img/,然后在其中移动图片,然后.. image:: img/my-image.png

相关问答

错误1:Request method ‘DELETE‘ not supported 错误还原:...
错误1:启动docker镜像时报错:Error response from daemon:...
错误1:private field ‘xxx‘ is never assigned 按Alt...
报错如下,通过源不能下载,最后警告pip需升级版本 Requirem...