【问题标题】:How to use `term` role to reference math equations in glossory in sphinx-doc如何使用 `term` 角色在 sphinx-doc 中的词汇表中引用数学方程
【发布时间】:2021-04-26 16:34:15
【问题描述】:

Sphinx-doc 支持 term roleglossary directive 一起工作。假设在词汇表中,我有一个数学公式作为键,如下所示

:math:`{[n] \choose k}`
  Set of :math:`k`-subsets of :math:`[n]`

我尝试通过使用术语角色来引用它

:term:`{[n] \choose k}`

但是,当我构建文档时,我遇到了以下警告消息

警告:术语不在词汇表中:{[n] 选择 k}

如何在 sphinx-doc 中使用术语角色引用数学公式键?谢谢!

【问题讨论】:

    标签: python-sphinx


    【解决方案1】:

    我的最佳解决方案是为方程式定义一个有意义的替换字符串,然后在词汇表中使用该替换字符串:

    .. |n-choose-k| replace:: :math:`{[n] \choose k}`
    
    .. glossary::
    
       |n-choose-k|
          Set of :math:`k`-subsets of :math:`[n]`
    
    Reference the term above :term:`like this <n-choose-k>`
    

    see output

    您可以为该术语的链接设置任何锚文本,但我认为不可能在其中放置数学公式。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2023-03-31
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-10-06
      • 2014-03-12
      相关资源
      最近更新 更多