LaTeX support in docstrings - how?

It appears that any docstrings that have LaTeX in them (surrounded by double backticks) need to be preceded by @doc_str. Is that correct? The documentation hints at this, but it’s not very clear.

Also, do backslashes need to be escaped within double backticks or not? The documentation shows examples both ways.

I’ve found that you don’t need to use the macro version, but you do need to escape the dollar sign inline. For displayed math, use a math codeblock and escape backslashes. See here and rendered.

Thanks - this is helpful. What about equations that I’d prefer to be rendered inline?

I’ve always used \$\\cos x ^ 2 + \\sin x ^ 2 = 1\$ and it always worked.

You can also use the doc"..." string macro if you don’t want to escape $ and \, e.g. doc"$\cos x^2$".

4 Likes