Ral*_* B. 6 restructuredtext python-sphinx
我对 sphinx 比较陌生,我刚刚创建了两个文件来测试带有编号的方程交叉引用。
我在conf.py中做了以下配置
numfig = True
math_numfig = True
numfig_secnum_depth = 2
math_eqref_format = "Eq.{number}"
Run Code Online (Sandbox Code Playgroud)
第一个文件是
1. Test File 1 Main
=============
Inline math examples: :math:`\color{blue}{\sigma_{1}}` equals :math:`\colorbox{yellow}{\sigma_{2}}` then etc, etc.
Any text.
.. math::
x^2+y^2=1
:label: eq_a
Math block example with label:
.. math::
e^{i\pi} + 1 = 0
:label: eq_b
1.1 Some Examples
****************
.. math::
\color{red}{x^2}+y^2=3
:label: eq_c
Run Code Online (Sandbox Code Playgroud)
第二个是
2. Test File 2 Main
=============
Refer to :eq:`eq_a`
Refer to :eq:`eq_b`
Refer to :eq:`eq_c`
Run Code Online (Sandbox Code Playgroud)
输出是 HTML。它不适用于编号,所有标签都丢失(但链接很好)。
我错过了什么吗?我也很困惑如何自动对章节编号进行编号。测试中的部分编号是手动添加的。是因为我需要配置节号才能显示方程式编号吗?这样做的正确方法是什么?谢谢!
正如疯狂物理学家所说,答案 3 是错误的。当带有 :label: 的行不是直接位于 '.. math:: 下方时,Sphinx 不会创建新标签,如下所示:
.. math::
:label: eq_a
e^i + 1 = 0
Which can be referenced in the text using :eq:`eq_a` and so on.
Note the blank lines and the back-tics in the reference.
Also, there may not be a space between :eq: and `eq_a` in the reference!
Further, no back-tics around the eq_a at the :label: line!
Run Code Online (Sandbox Code Playgroud)
我发现弄清楚这个问题是一项艰巨的工作。所以我希望它能帮助其他人。
| 归档时间: |
|
| 查看次数: |
2998 次 |
| 最近记录: |