我有一些关于 Sphinx 2.x 的文档。除了 HTML 版本 ( make html
),我还想将其导出为 PDF 版本,最好使用rst2pdf:
我的文件有一些图形图像。这是index.rst
.
.. figure:: ./_images/img01.png
Caption for img01.
.. figure:: ./_images/img02.png
Caption for img02.
我想在每个标题的开头添加“Figure <#>”。有人有想法吗?请注意
- numfig不适用于 rst2pdf。
更新(2020 年 3 月 22 日)。在conf.py
.
numfig = True
numfig_format = {
'figure': 'Figure %s.'
}
numfig_secnum_depth = 1
在 HTML 输出中它可以工作。
在 rst2PDF 版本中,您看不到"Figure #"。
- : counter:指令不适用于 Sphinx;我收到以下错误:
.. figure:: ./_images/img01.png
Figure :counter:`figure`. Caption for img01.
$ sphinx-build -b pdf ./source/ ./build/
Running Sphinx v2.4.4
/home/sarah/sphinx_test/lib/python3.6/importlib/__init__.py:126: RemovedInSphinx30Warning: sphinx.environment.NoUri is deprecated.
Check CHANGES for Sphinx API modifications.
return _bootstrap._gcd_import(name[level:], package, level)
Initiated sphinxcontrib-images backend: `sphinxcontrib_images_lightbox2.lightbox2:LightBox2`
building [mo]: targets for 0 po files that are out of date
building [pdf]: targets for 1 source files that are out of date
updating environment: [new config] 1 added, 0 changed, 0 removed
reading sources... [100%] index
Exception occurred:
File "/home/sarah/sphinx_test/lib/python3.6/site-packages/docutils/nodes.py", line 439, in copy
return self.__class__(reprunicode(self), rawsource=self.rawsource)
AttributeError: 'CounterNode' object has no attribute 'rawsource'
The full traceback has been saved in /tmp/sphinx-err-1bzghsm6.log, if you want to report the issue to the developers.
Please also report this if it was a user error, so that a better error message can be provided next time.
A bug report can be filed in the tracker at <https://github.com/sphinx-doc/sphinx/issues>. Thanks!