小编sta*_*der的帖子

使用 :numref 通过图形编号引用 reStructuredText 中的图形:

我目前正在尝试设置一个 reStructuredText 模板。我想包括编号的数字和对这些数字的引用。所以我遵循了 sphinx 文档(http://www.sphinx-doc.org/en/stable/markup/inline.html)中给出的说明。

首先我包括了这条线

numfig = True
Run Code Online (Sandbox Code Playgroud)

在文件“conf.py”中。我在我的文件“rstTemplate.rst”中实现了这个图和对它的引用,如下所示:

.. _my-figure:

.. figure:: images/scen-smartcity.*
    :scale: 50 %
    :alt: smartcity symbol
    :align: center

    This is the caption of the figure (a simple paragraph).

    This is the legend of the figure

Reference to the figure :numref:`(Fig. %s) my-figure`
Run Code Online (Sandbox Code Playgroud)

当我使用构建 html 文件时 make html

Running Sphinx v1.6.1
loading pickled environment... done
building [mo]: targets for 0 po files that are out of date
building [html]: targets for 1 source files …
Run Code Online (Sandbox Code Playgroud)

restructuredtext python-sphinx

4
推荐指数
1
解决办法
2497
查看次数

标签 统计

python-sphinx ×1

restructuredtext ×1