anf*_*fho 6 python python-sphinx
我是 Sphinx 的新手,想在两个不同的*.rst
文件中显示相同的图形。
第一个 *.rst 文件"lower.rst"
与“figures”文件夹位于同一级别,我在其中包含一个图形,如下所示:
.. figure:: figures/figure1.png
Run Code Online (Sandbox Code Playgroud)
第二个 *.rst 文件"higher.rst
“,比lower.rst 高几个级别。实际上,我将lower.rst 包含在higher.rst 中,如下所示:
.. include:: relative/path/to/lower.rst.
Run Code Online (Sandbox Code Playgroud)
不幸的是,在 中higher.rst
,lower.rst 中的数字没有显示:
"image file not readable" error.
Run Code Online (Sandbox Code Playgroud)
higher.rst
在当前目录中查找图形,而不是指向原始的下层目录。
这个问题有点在这里解决:Sphinx 可以链接到不在根文档下面的目录中的文档吗?,但我仍然不明白如何使用那里提供的信息解决我的问题。
将您的数字放在根级别的目录中,并更改您的标记以使用前导/
.
.. figure:: /_static/figure1.png
Run Code Online (Sandbox Code Playgroud)
现在从更高级别的文件中,您应该能够包含较低级别的文件,并且两个文件都应该显示图像。