# Equations

LaTeX equations support

By default, the inline and block equations are exported to Markdown in a format that can be rendered using MathJax. You can find one MathJax config example below.

ox-hugo indirectly extends from ox-html and so it also inherits a different way of exporting LaTeX equations — by exporting them to images.

## Inline equations #

• Inline equations are wrapped between $$ and $$.
• $ wrapping also works, but it is not preferred as it comes with restrictions like “there should be no whitespace between the equation and the $ delimiters”.

So $a=b$ will not work (it will look like: $a=b$), but $a=b$ will work (it will look like: $$a=b$$).

On the other hand, both $$a=b$$ (it will look like: $$a=b$$) and $$a=b$$ (it will look like: $$a=b$$) will work.

• One-per-line equations are wrapped between $ and $ or $$ delimiters. For example, below in Org: LaTeX formatted equation: $$E = -J \sum_{i=1}^N s_i s_{i+1}$$  will look like this in Hugo rendered HTML (using MathJax): LaTeX formatted equation: $$E = -J \sum_{i=1}^N s_i s_{i+1 }$$ Here’s another example, taken from Org Info: LaTeX fragments: If a^2=b and $$b=2$$, then the solution must be either$$ a=+\sqrt{2}  or $a=-\sqrt{2}$


Above renders to below using Mathjax:

If $$a^2=b$$ and $$b=2$$, then the solution must be either $a=+\sqrt{2}$ or $a=-\sqrt{2}$

Note that the last two equations show up on their own lines because those equations are wrapped in $..$.

## LaTeX Environments #

ox-hugo support LaTeX environments.

So below in Org buffer:

\begin{equation}
\label{eq:1}
C = W\log_{2} (1+\mathrm{SNR})
\end{equation}


will render as below using MathJax:

\begin{equation} \label{eq:1} C = W\log_{2} (1+\mathrm{SNR}) \end{equation}

You can find many more equation examples at tests tagged equations.

### Referencing Equations #

Equation referencing will also work but it requires MathJax. Here is a MathJax configuration that is known to work for this referencing feature. \label{SOMELABEL} labeled equations can be referenced using \ref{SOMELABEL}1. So \ref{eq:1} will render as \ref{eq:1} and link to the equation above.

## MathJax config example #

Here’s how MathJax is configured for this website:

## Exporting LaTeX equations as images #

If you prefer, you can using dvisvgm or dvipng2 to export the equations to SVG or PNG images, and the equations in the Org file will be replaced by links to those images in the exported Markdown files.

The method for exporting the equations to images is the same as that documented for ox-html in Org Info: Math formatting in HTML export:

• To export the equations to SVG, add #+options: tex:dvisvgm to the top of your Org file, or add :EXPORT_OPTIONS: tex:dvisvgm to the post subtree’s property drawer.
• Similarly, to export the equations to PNG, use the tex:dvipng option instead.

Referencing to equations using \ref{..} will not work if equations are exported as images.

1. This same MathJax setup is used on the ox-hugo test site too. ↩︎

2. The dvisvgm and dvipng executables ship with TexLive distributions. ↩︎ 