Math in reStructuredText with LaTeX

Craig Younkins picture Craig Younkins · Aug 31, 2010 · Viewed 33.4k times · Source

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!

Answer

devsnd picture devsnd · Jun 27, 2012

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.


UPDATE:

in newer versions it seems to be necessary to use a double-backslash for the math elements, so it's \\frac and not \frac