si2*_*19e 8 python documentation latex python-sphinx
我正在使用Sphinx文档包来记录我正在处理的一个小型Python工具包,并且我想通过在Python文档字符串中以LaTeX格式列出它们来描述各种模块实现的数学公式.
使用:math:或.. math::指令reStructuredText 很容易实现这一点,例如:
.. math::
\\displaymath \\sum_{i=1}^{\\infty} x_{i}
Run Code Online (Sandbox Code Playgroud)
但是\\displaymath在Python文档字符串中,该指令只是以红色文本突出显示.当在.rst文件(例如index.rst)中使用时,这按预期工作,并且用于求和的子脚本和超脚本直接在求和符号之下和之上.
这根本不支持docstrings,还是我做错了什么或不做我需要做的事情?
bmu*_*bmu 16
你不需要\displaymath在狮身人面像和没有额外的转义反斜线\sum和\infty.
调用时,以下示例函数在html和latex输出中呈现正常.. autofunction:::
def test_func(x):
"""This function will try to calculate:
.. math::
\sum_{i=1}^{\\infty} x_{i}
good luck!
"""
pass
Run Code Online (Sandbox Code Playgroud)
您必须使用该.. math::指令,因为内联math(:math:)不起作用.