【问题标题】:How to ensure that image files from Sphinx Documentation are copied "Automatically" in LaTeX pdf如何确保 Sphinx 文档中的图像文件在 LaTeX pdf 中“自动”复制
【发布时间】:2020-08-16 08:36:21
【问题描述】:

在我的 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 文件名列表,相对于 配置目录,构建时复制到构建目录 乳胶输出。这对于复制 Sphinx 不复制的文件很有用 自动,例如如果它们在添加的自定义 LaTeX 中被引用 乳胶元素。 源文件中引用的图像文件(例如 via .. image::) 会自动复制。

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

有趣的是,我可以看到图像文件已经复制到文件夹_build/latex,所以这意味着pdflatex 能够访问图像文件!

问题

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

编辑 1:

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

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]

编辑 2:

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

"""{carousel_filling}".png

【问题讨论】:

  • 检查 日志 显示此错误:! Package pdftex.def Error: File """{carousel_filling}".png' not found: using draft setting.

标签: image pdf python-sphinx pdflatex


【解决方案1】:

不要将您的图片放在_static 下。它是一个专用文件夹,不用于图像。例如。在您的第一个文件级别创建img/,将图像移到那里,然后.. image:: img/my-image.png。

【讨论】:

    猜你喜欢
    • 2020-12-06
    • 1970-01-01
    • 2019-05-16
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-09-22
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多