Next: , Previous: Subscripts and superscripts, Up: Embedded LaTeX


11.3 LaTeX fragments

With symbols, sub- and superscripts, HTML is pretty much at its end when it comes to representing mathematical formulas1. More complex expressions need a dedicated formula processor. To this end, Org mode can contain arbitrary LaTeX fragments. It provides commands to preview the typeset result of these fragments, and upon export to HTML, all fragments will be converted to images and inlined into the HTML document2. For this to work you need to be on a system with a working LaTeX installation. You also need the dvipng program, available at http://sourceforge.net/projects/dvipng/. The LaTeX header that will be used when processing a fragment can be configured with the variable org-format-latex-header.

LaTeX fragments don't need any special marking at all. The following snippets will be identified as LaTeX source code:

For example:

     \begin{equation}                          % arbitrary environments,
     x=\sqrt{b}                                % even tables, figures
     \end{equation}                            % etc
     
     If $a^2=b$ and \( b=2 \), then the solution must be
     either $$ a=+\sqrt{2} $$ or \[ a=-\sqrt{2} \].

If you need any of the delimiter ASCII sequences for other purposes, you can configure the option org-format-latex-options to deselect the ones you do not wish to have interpreted by the LaTeX converter.


Footnotes

[1] Yes, there is MathML, but that is not yet fully supported by many browsers, and there is no decent converter for turning LaTeX or ASCII representations of formulas into MathML. So for the time being, converting formulas into images seems the way to go.

[2] The LaTeX export will not use images for displaying LaTeX fragments but include these fragments directly into the LaTeX code.