Sphinx Documentation ツールと 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}
}
?
これらはいくつかの重要な環境変数です:
A. conf.pyで、絶対パスを次のように定義しました。sys.path.insert(0, os.path.abspath('..'))
B. これはディレクトリ ツリーです。
docs/ # (Sphinx) Documentation folder
_build/
_static/
css/
images/
abc.jpg
img_file.jpg <= This image file is in the root ("_static") directory
_templates/
conf.py
index.rst
modules/ <= Folder containing my source (.rst) files
execute/
file_with_image.rst <= I am trying to put the image in this source file
some_other_file.rst
C.画像を含めるために、次を使用しています。
.. image:: /_static/img_file.*
D.前文にグラフィックスを含めました。conf.py
このエラーが発生するのはなぜですか? エラー メッセージに非常に多くの """ 引用符が含まれている原因は何ですか?
編集
*.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}} % ***
を使用するQuick Build
と、エディターは次のようなエラーをスローします。
! パッケージ pdftex.def エラー: ファイル `"""{img_file}".jpg' が見つかりません: ...
ただし、画像ファイル名の中括弧{{img_file}.jpg}
が削除され、次のように変更されると (*** とマークされた行):
\noindent{\hspace*{\fill}\sphinxincludegraphics{img_file.jpg}}
% ***
ドキュメントが正常にコンパイルされ、画像が pdf ファイルで表示されます。
ファイルを保存すると、 _build/latex/フォルダー内.tex
の pdf ファイルに画像が表示されます。