I recently discovered reST/Sphinx and tried to use it to document a python class I had written some time before.
After some experimentation I found out I needed to write :math:`K_\\alpha`
to get the greek letter in the subscript while using the make latexpdf
target. With a single \
there were errors. Strangely enough every other greek letter only needed a single \
to produce the desired output.
What is happening?
Thank you so much for asking this. It finally helped me solve my related problem.
For me, \alpha and \beta both fail. They both fail even without the subscript part coming into play. But if I use the curly braces it works:
:math:`\alpha`
does not compile
:math:`{\alpha}`
gives me the symbol I want
:math:`{\\alpha}`
gives me the word 'alpha' written as adjacent math variables a, l, p, h, a.
To get a K
followed by a subscripted α
in inline text, use
:math:`K_{\alpha}`
Note curly braces and backticks. It works fine and is what you would expect based on these references:
In math markup used in Python docstrings, you need two backslashes (or use "raw" strings):
:math:`K_{\\alpha}`
Edit: I was wrong about the curly braces. It turns out that these two samples give the same result in the PDF output:
:math:`K_{\alpha}`
and
:math:`K_\alpha`
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With