I\'m writing some mathematical code in Python and using Sphinx to produce the documentation. I know that Sphinx can handle LaTeX code in Python docstrings; see https://www.s
If you're using the pngmath extension, you can put that in the preamble by inserting this into the conf.py script:
pngmath_latex_preamble = r"\newcommand{\cG}{\mathcal{G}}"