【问题标题】:Numbered reference to figures in Sphinx编号参考狮身人面像中的数字
【发布时间】:2016-03-18 03:47:47
【问题描述】:

使用 sphinx 1.3.6,我找不到对数字进行编号引用的方法。

根据这里的答案和cmets:Referencing figures with numbers in Sphinx and reStructuredTextnumref 内置在 Sphinx 中。

但这根本行不通:

.. _mylabel

.. figure:: img/fig.jpg

   this is the caption

当我在文本中使用:numref:`Figure %s <mylabel>` 时,结果实际上是Figure %s,好像numref 实际上根本没有实现。

我需要在conf.py 或乳胶序言中添加一些内容吗?

【问题讨论】:

标签: python-sphinx


【解决方案1】:

我知道这是一篇旧帖子,但我想我会分享在这种情况下对我有帮助的东西。

以下代码将为您的图片添加一个带有编号标题的编号链接。例如链接Fig. 1 将链接到带有标题的图像:图。 1 系统流程

documentation.rst 文件:

This is some boring documentation text which refers to the illustration in :numref:`my-image`.

.. figure:: images/process_flow.png
    :name: my-image
    :align: center
    :width: 100%

    System Process Flow

conf.py 文件:

将此行添加到您的conf.py 文件中:

numfig = True

您的 Sphinx 文档现在将有一个指向您的编号图的链接。

【讨论】:

    【解决方案2】:

    此外,page.rst 必须包含在某个“目录树”中。

    否则会抛出如下错误:

    警告:没有为图分配编号:

    【讨论】:

      猜你喜欢
      • 2013-02-08
      • 1970-01-01
      • 1970-01-01
      • 2021-10-01
      • 2014-10-03
      • 1970-01-01
      • 2015-06-29
      • 1970-01-01
      • 2012-03-17
      相关资源
      最近更新 更多