Search code examples
mathlatexmarkdownrestructuredtextgedit

Math in reStructuredText with LaTeX


I would like to use a lightweight markup language to take notes in my college classes.

My editor of choice is gedit, and I found reStructuredText Tools for Gedit, which will run the reStructuredText processor and render the HTML in a pane in gedit. This is great, and 80% of the way there.

But for many of my classes I need to include math equations or greek characters in my notes. Although I'm not very familiar with LaTeX, my understanding is that it has these capabilities.

How can I use LaTeX in a reST document? Would the reST document need to be processed into LaTeX, then that rendered into HTML, or is there a better way? Would markdown make this easier? I can modify the gedit plugin if necessary.

Lastly, does anyone do this? Any other suggestions for taking class notes in a plain text editor?

Thanks!


Solution

  • Since version 0.8 it is supported natively: You shouldn't use any workaround anymore. The syntax is also very simple. It is the same as latex math, but without the enclosing $$

    So you can simply write the following for a math block

    .. math::
    
       \frac{ \sum_{t=0}^{N}f(t,k) }{N}
    

    Or if you want to write inline you can use this:

    :math:`\frac{ \sum_{t=0}^{N}f(t,k) }{N}`
    

    notice the delimiting backticks there.


    Note: if you're using latex notation in rst doc-strings, you will need to double escape the backslash using a double-backslash for the math elements, so then it's \\frac and not \frac