Python sphinx 如何在Sphinx+;Latex Pdf文件

Python sphinx 如何在Sphinx+;Latex Pdf文件,python-sphinx,pdflatex,pdftex,Python Sphinx,Pdflatex,Pdftex,我正在使用Sphinx文档工具和LaTeX生成pdf文件 在尝试将图像包含在pdf文件中时,我在编译过程中遇到以下错误: LaTeX Warning: File `{img_file}.jpg' not found on input line 920. ! Package pdftex.def Error: File `"""{img_file}".jpg' not found: using dra ft setting. See the pdfte

我正在使用Sphinx文档工具和LaTeX生成pdf文件

在尝试将图像包含在pdf文件中时,我在编译过程中遇到以下错误:

LaTeX Warning: File `{img_file}.jpg' not found on input line 920.


! Package pdftex.def Error: File `"""{img_file}".jpg' not found: using dra
ft setting.

See the pdftex.def package documentation for explanation.
Type  H <return>  for immediate help.
 ...                                              
                                                  
l.920 ...phinxincludegraphics{{img_file}.jpg}
                                                  }
? 
C.为了包含我正在使用的图像,我使用了以下内容。

。。图像::/\u静态/img\u文件。*

D.我在
conf.py
序言中加入了graphix

为什么我会出现这个错误?错误消息中这么多“引号”的来源是什么?

编辑 在tex编辑器中打开
*.tex
文件时,图像插入部分的代码片段显示如下内容:

\subsection{Add Image}
\label{\detokenize{modules/aud_execution/add_image_with_image_directive:add-image}}\label{\detokenize{modules/aud_execution/add_image_with_image_directive::doc}}
\sphinxstylestrong{Adding an image}

Example of image usage using “image” directive:

\noindent{\hspace*{\fill}\sphinxincludegraphics{{img_file}.jpg}} % ***
使用
快速构建
,编辑器抛出错误,如下所示:

!Package pdftex.def错误:文件“`”{img_File}”.jpg'不是 发现:

但是,当图像文件名中的花括号,
{{img_file}.jpg}
被删除并更改为(标有***的行):

\noindent{\hspace*{\fill}\sphinxincludegraphics{img_file.jpg}
%***

文档成功编译,图像可以在pdf文件中看到

如果保存了
.tex
文件,则\u build/latex/文件夹中的pdf文件将显示图像


那么,为什么在从终端制作latexpdf的过程中要插入额外的括号呢?不要将图像放在
\u static
下。它是专用文件夹,不是用于图像的。例如,创建
模块/execute/img/
,将图像移动到那里,以及
。图像::img/my image.png
。我发现了一些东西。这是我的专利深度。除了Sphinx文档之外,您是否尝试过搜索或?我无法重现,但我可以说
sys.path.insert(…)
对图像没有影响。该设置仅在使用autodoc时适用。@StevePiercy-已经检查了您指出的部分,但是文档本身显示的是源文件中引用的图像文件(例如通过..图像::)自动复制。而且,正如文档所说,引用的图像文件正在被复制到
\u build/latex
文件夹,这(我认为)意味着latex正在使用\u image.rst.PS访问文件
文件中引用的图像文件。我已经检查了(其他)源代码,但没有提出任何与此问题相关的内容。发布于。@mzjn-没错。我使用了
sys.path.append(os.path.abspath(“..//docs”)
,结果是一样的。@StevePiercy-我创建了一个新的(Sphinx)项目,以查看是否像我之前所做的那样将其从我的Django应用程序中分离,将改变这种情况。即使这样,它也无法访问图像文件。我在某个地方读到(on,可能是)在conf.py中调用
\usepackage
的顺序也可能有一定的影响。但即使将
graphicx
作为最后一个调用的顺序也没有帮助。有什么想法吗?\u静态文件夹用于图像,但要复制到输出的文件需要您的回复。但是,使用
。image::img/my image.png
raises error
警告:找不到适合html生成器的图像:img/my image.png
。使用
。image::modules/execute/img/my image.png
正确编译html文档并显示图像。但是,与以前一样,使用这两种方法,生成的pdf文件根本无法显示图像。PS我不知何故无法获得您的许可证静态文件夹用于图像,但要复制到输出的文件。如果您能澄清,我的错误。应该是“\u静态文件夹不用于图像”。警告“找不到适合html生成器的图像”“这很奇怪。LaTeX builder支持PDF、PNG和JPG格式的图像。请参阅但当我使用
时。。image::modules/execute/img/my image.png
(标记图像的目录路径)没有警告,图像按预期显示。我是不是遗漏了什么?
\subsection{Add Image}
\label{\detokenize{modules/aud_execution/add_image_with_image_directive:add-image}}\label{\detokenize{modules/aud_execution/add_image_with_image_directive::doc}}
\sphinxstylestrong{Adding an image}

Example of image usage using “image” directive:

\noindent{\hspace*{\fill}\sphinxincludegraphics{{img_file}.jpg}} % ***