【问题标题】:How to refer to an equation in Sphinx如何在 Sphinx 中引用方程
【发布时间】:2021-06-06 05:53:24
【问题描述】:

我有一个方程写在第一个文件中:

.. math::
   F=\begin{bmatrix} \lambda_1 & 0 & 0\\0 & \lambda_2 & 0\\0 & 0 & \lambda_3\end{bmatrix}
  :label: eq:6

完美显示为:

现在我想在同一个 rst 文件中引用这个等式。我试过类似的东西:

I need to refer to this :ref:`Link title < eq:6>`

但是它不起作用。如何链接(例如引用)这个等式?

【问题讨论】:

    标签: python-sphinx cross-reference


    【解决方案1】:

    您的math 角色缩进不匹配,label 而不是name 的角色选项不正确,角色及其内容的顺序不正确,以及链接参考中&lt; 之后的多余空格。

    以下对我有用。

    .. math::
        :name: eq:6
    
        F=\begin{bmatrix} \lambda_1 & 0 & 0\\0 & \lambda_2 & 0\\0 & 0 & \lambda_3\end{bmatrix}
    
    I need to refer to this :ref:`Link title <eq:6>`
    

    还有另一个对:math:numref: 的引用,但我认为这不是您想要的。还有ref 的使用,可以使用标签作为ref 的目标。

    【讨论】:

    • 感谢您的解决方案。像魅力一样工作!
    猜你喜欢
    • 1970-01-01
    • 2010-12-11
    • 1970-01-01
    • 2015-01-04
    • 2020-09-25
    • 1970-01-01
    • 1970-01-01
    • 2011-04-18
    • 2021-07-13
    相关资源
    最近更新 更多