Next: Previewing LaTeX fragments, Previous: Subscripts and superscripts, Up: Embedded LaTeX [Contents][Index]

Going beyond symbols and sub- and superscripts, a full formula language is
needed. Org mode can contain LaTeX math fragments, and it supports ways
to process these for several export back-ends. When exporting to LaTeX,
the code is obviously left as it is. When exporting to HTML, Org invokes the
MathJax library (see Math formatting in HTML export) to process and display the math^{127}.
Finally, it can also process the mathematical expressions into
images^{128} that can be
displayed in a browser.

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

- Environments of any kind
^{129}. The only requirement is that the`\begin`

and`\end`

statements appear on a new line, at the beginning of the line or after whitespaces only. - Text within the usual LaTeX math delimiters. To avoid conflicts with
currency specifications, single ‘
`$`’ characters are only recognized as math delimiters if the enclosed text contains at most two line breaks, is directly attached to the ‘`$`’ characters with no whitespace in between, and if the closing ‘`$`’ is followed by whitespace, punctuation or a dash. For the other delimiters, there is no such restriction, so when in doubt, use ‘`\(...\)`’ as inline math delimiters.

For example:

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

LaTeX processing can be configured with the variable
`org-export-with-latex`

. The default setting is `t`

which means
`MathJax` for HTML, and no processing for ASCII and LaTeX back-ends.
You can also set this variable on a per-file basis using one of these
lines:

#+OPTIONS: tex:t Do the right thing automatically (MathJax) #+OPTIONS: tex:nil Do not process LaTeX fragments at all #+OPTIONS: tex:verbatim Verbatim export, for jsMath or so

If you plan to use
this regularly or on pages with significant page views, you should install
`MathJax` on your own server in order to limit the load of our server.

For this to work you need to be on a system with a working
LaTeX installation. You also need the `dvipng` program or the
`convert`, respectively available at
http://sourceforge.net/projects/dvipng/ and from the `imagemagick`
suite. The LaTeX header that will be used when processing a fragment can
be configured with the variable `org-format-latex-header`

.

When `MathJax` is used, only the
environments recognized by `MathJax` will be processed. When
`dvipng` program or `imagemagick` suite is used to create images,
any LaTeX environment will be handled.