How to include math in the sphinx?

I use sphinx with pngmath to document my code that contains a lot of math expressions. Doing this in the *.rst file works fine.

a \times b becomes:


works


However, if I try to do the same inside the *.py file, for example, in the module documentation, for example:

 """ a \times b """ 

The end result


does not work


In addition, the amsmath function does not work.
What do I need to do to also have math formulas in my *.py documents?

+6
source share
1 answer

Try putting the lowercase "r" in front of your docstring - like this:

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

I have never seen the original literal string for docstring before, but this will not allow your \ t to be interpreted as the <TAB> character.

+7
source

Source: https://habr.com/ru/post/903104/


All Articles