【问题标题】:reStructuredText in Sphinx: display number when referencing a sectionSphinx中的reStructuredText:引用部分时显示编号
【发布时间】:2015-06-27 13:54:10
【问题描述】:

要在 Sphinx 中使用 reStructuredText 引用一个部分,我可以这样做:

.. _my-reference-label:

Section to cross-reference
--------------------------

This is the text of the section.

It refers to the section itself, see :ref:`my-reference-label`.

正如here 解释的那样。

这导致该部分被按标题引用,即我得到以下行:

它指的是部分本身,请参阅Section to cross-reference

(其中要交叉引用的部分链接到相应部分的开头)

我想改为:

它指的是部分本身,请参阅2.1

其中 2.1 是节的编号。

有没有办法在 Sphinx 中使用 reStructuredText 来实现这一点?

【问题讨论】:

    标签: python-sphinx restructuredtext


    【解决方案1】:

    numsec Sphinx 扩展可以满足您的需求。源代码在这里:https://github.com/jterrace/sphinxtr/blob/master/extensions/numsec.py

    该扩展是 Stack Overflow 成员 jterrace 开发的“Sphinx Thesis Resource”包的一部分。见https://github.com/jterrace/sphinxtr

    【讨论】:

    • 非常感谢mzjn! numsec 扩展运行良好,而且该软件包还有许多其他非常有趣的东西。
    猜你喜欢
    • 2011-01-28
    • 2014-04-11
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-08-29
    • 1970-01-01
    • 2020-10-17
    • 1970-01-01
    相关资源
    最近更新 更多