1.14. Mathematics

In Sphinx you can include inline math \(x\leftarrow y\ x\forall y\ x-y\) (as role :math:`x\leftarrow y\ x\forall y\ x-y`) or display math as directive block which is able to cross-referencing equations:

(1.1)\[W^{3\beta}_{\delta_1 \rho_1 \sigma_2} = U^{3\beta}_{\delta_1 \rho_1} + \frac{1}{8 \pi 2} \int^{\alpha_2}_{\alpha_2} d \alpha^\prime_2 \left[ \frac{ U^{2\beta}_{\delta_1 \rho_1} - \alpha^\prime_2U^{1\beta}_{\rho_1 \sigma_2} }{U^{0\beta}_{\rho_1 \sigma_2}}\right ]\]
.. math::

To include math in your document, just use the .. math:: directive. For more details, see math directive.

The example
1
2
3
4
.. math::

   W^{3\beta}_{\delta_1 \rho_1 \sigma_2}
   \approx U^{3\beta}_{\delta_1 \rho_1}
Which gives
(1.2)\[W^{3\beta}_{\delta_1 \rho_1 \sigma_2} \approx U^{3\beta}_{\delta_1 \rho_1}\]
:math:numref:

The math domain (name math) provides the role :math:numref:`label` which is for cross-referencing equations defined by .. math:: directive via their label. For more details, see math:numref role.

The example
1
2
3
4
5
.. math:: e^{i\pi} + 1 = 0
   :label: euler

Euler's identity, :math:numref:`euler`, was elected one
of the most beautiful mathematical formulas.
Which gives
(1.3)\[e^{i\pi} + 1 = 0\]

Euler’s identity, Equastion 1.3, was elected one of the most beautiful mathematical formulas.

When the equation is only one line of text, it can also be given as a directive argument (as used in Euler’s identity above).

:eq:

The role :eq:`euler` is the same as :math:numref:`euler`. For more details, see eq role.

Recent versions of Sphinx include built-in support for math. There are three flavors:

Additionally, there are special Sphinx extensions provided by matplotlib that has its own math support for writing mathematical expressions and inserting automatically-generated plots:

See also

See Mathematical Plots for more details about the Sphinx matplotlib extensions with examples.