From the Sphinx documentation:
Keep in mind that when you put math markup in Python docstrings read by autodoc, you either have to double all backslashes, or use Python raw strings (
r"raw"
).
This is needed so that LaTeX commands, such as \alpha
, are interpreted correctly (\a
and a few other sequences have special meaning in a string literal).
This is the raw version of the docstring in the question, with triple quotes, prepended by r
:
r"""
.. math::
w_k^* = \min_{w_k} \ell_k(w_k) + \lambda\left(\alpha||w_k||_1
+ \frac{1}{2}(1-\alpha) ||w_k||^2\right)
"""