Creating equations in Sphinx


The syntax for writing equations is LaTeX.

Only brief examples are included here, since LaTeX as a rather steep learning curve, and AMS LaTeX is only concerned with math support.

The following links are useful:


In Sphinx, the rendering (display) of the equations can be done in different ways, that will not be discussed here.

The selected option is to use the sphinx.ext.mathjax extension. This extension uses the JavaScript package MathJax to transform the LaTeX markup to readable math live in the browser.

The disadvantages are the (large) size and load time of the MathJax library.

The mathjax_path in the file indicates where the MathJax library resides. By default, this is the MathJax site, but the path can be changed no cross-site scripting is allowed.

Equation editors or previewers

Given that LaTeX syntax may be daunting, a WYSIWYG math editor can be useful, or at least an interactive previewer:

  • If the objective is simply to preview the result, the online `Interactive LaTeX Editor`_ is very good option and includes numerous equations as examples.

  • LyX_ is a user-friendly LaTeX processor that includes an equation editor.

    In the long run, LyX may be the best choice: it as the same dependencies as EqualX, a larger development and user community, and does not require virtually any LaTeX knowledge.

  • EqualX_ is a LaTeX equation editor (not a document processor as LyX): it can be used to create the equations and then paste the code into the ReST document.

    Like LyX_, EqualX requires a LaTeX distribution (in Linux, the dependencies are automatically installed and TeXLive_ is included in the official repositories of all major distributions; for Windows systems, MiKTeX_ is a possible alternative).


See additional examples at


If :math:`\sigma_{1}` equals :math:`\sigma_{2}` then etc, etc.


If \(\sigma_{1}\) equals \(\sigma_{2}\) then etc, etc.


:math:`\underline{x}=[  x_{1}, ...,  x_{n}]^{T}`


\(\underline{x}=[ x_{1}, ..., x_{n}]^{T}\)


\langle \alpha, \beta  \rangle
\Biggl \lbrace
M,\text{ if }
    l(\underline{x}) =
      \frac { p(\underline{x}|M ) } { p(\underline{x}|U) }
       \frac { p(U) }{ p(M) } }
U, \text{ otherwise }


\[\langle \alpha, \beta \rangle \in \Biggl \lbrace { M,\text{ if } { l(\underline{x}) = \frac { p(\underline{x}|M ) } { p(\underline{x}|U) } \geq \frac { p(U) }{ p(M) } } \atop U, \text{ otherwise } }\]