Sphinx 中的 reStructuredText:引用部分时显示编号
reStructuredText in Sphinx: display number when referencing a section
要在 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。
这导致该部分被标题引用,也就是说我得到了行:
It refers to the section itself, see Section to cross-reference.
(其中 到 cross-reference 的部分 链接到相应部分的开头)
我想换成:
It refers to the section itself, see 2.1.
其中 2.1 是该部分的编号。
有没有办法在 Sphinx 中使用 reStructuredText 来完成此操作?
numsec
Sphinx 扩展可以满足您的需求。源代码在这里:https://github.com/jterrace/sphinxtr/blob/master/extensions/numsec.py.
该扩展是 Stack Overflow 成员 jterrace. See https://github.com/jterrace/sphinxtr 开发的 "Sphinx Thesis Resource" 包的一部分。
要在 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。
这导致该部分被标题引用,也就是说我得到了行:
It refers to the section itself, see Section to cross-reference.
(其中 到 cross-reference 的部分 链接到相应部分的开头)
我想换成:
It refers to the section itself, see 2.1.
其中 2.1 是该部分的编号。
有没有办法在 Sphinx 中使用 reStructuredText 来完成此操作?
numsec
Sphinx 扩展可以满足您的需求。源代码在这里:https://github.com/jterrace/sphinxtr/blob/master/extensions/numsec.py.
该扩展是 Stack Overflow 成员 jterrace. See https://github.com/jterrace/sphinxtr 开发的 "Sphinx Thesis Resource" 包的一部分。