本文介绍了如何在狮身人面像中启用数学?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在将 sphinx pngmath 扩展名用于记录我的具有很多数学表达式的代码.在*.rst文件中执行此操作就可以了.

I am using sphinx with the pngmath extension to document my code that has a lot of mathematical expressions. Doing that in a *.rst file is working just fine.

a \times b变为:

但是,如果我在*.py文件中尝试相同的操作,例如在模块文档中,例如:

However, if I try the same inside a *.py file for example in a module documentation like so:

"""
a \times b
"""

我最终得到

此外,amsmath功能似乎也不起作用.
要在*.py文档中也包含数学公式,我该怎么做?

Furthermore no amsmath functionality seems to work, either.
What do I need to do, to also have math formulas in my *.py documentations?

推荐答案

尝试在文档字符串前加上小写的"r",如下所示:

Try putting a lower case 'r' before your docstring - like this:

def multiply(a,b):
    r"""
    returns a \times b
    """
    return a*b

我以前从未见过文档字符串的原始文字字符串,但这可以防止\ t被解释为<TAB>字符.

I've never seen a raw literal string for a docstring before, but this will keep your \t from being interpreted as a <TAB> character.

这篇关于如何在狮身人面像中启用数学?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-23 10:32