Math

To use mathematical expressions, you can use LaTeX expressions under the following directives:

  1. :math:`<expression>`

    Since Pythagoras, we know that \(a^2 + b^2 = c^2\).

    Code:

    Since Pythagoras, we know that :math:`a^2 + b^2 = c^2`.
    
  2. .. math:: directive

    \[(\prod \limits_{i=1}^n (x_i+1))^{1/n}-1 = \sqrt[n]{(x_1+1)(x_2+1) \cdots (x_n+1)} -1\]

    Code:

    .. math::
    
       (\prod \limits_{i=1}^n (x_i+1))^{1/n}-1 = \sqrt[n]{(x_1+1)(x_2+1) \cdots (x_n+1)} -1
    

In Sphinx, math directives can include an optional label which can be used to reference a formula (in the same document) using the :eq: role.

.. math:: e^{i\pi} + 1 = 0
   :label: euler

Euler's identity equation :eq:`euler`,
as elected one of the most
beautiful mathematical formulas.
(1)\[e^{i\pi} + 1 = 0\]

Euler’s identity equation (1), as elected one of the most beautiful mathematical formulas.

Syntax

Math code in Sphinx uses LaTeX syntax.

Symbols

Leters

\(\alpha\)

\alpha

\(\beta\)

\beta

\(\gamma\)

\gamma

\(\Gamma\)

\Gamma

\(\delta\)

\delta

\(\Delta\)

\Delta

\(\epsilon\)

\epsilon

\(\varepsilon\)

\varepsilon

\(\theta\)

\theta

\(\Theta\)

\Theta

\(\eta\)

\eta

\(\kappa\)

\kappa

\(\lambda\)

\lambda

\(\Lambda\)

\Lambda

\(\mu\)

\mu

\(\nu\)

\nu

\(\xi\)

\xi

\(\pi\)

\pi

\(\rho\)

\rho

\(\sigma\)

\sigma

\(\phi\)

\phi

\(\Phi\)

\Phi

\(\psi\)

\psi

\(\Psi\)

\Psi

\(\omega\)

\omega

\(\Omega\)

\Omega

\(\varphi\)

\varphi

\(\hbar\)

\hbar

Operators

\(\ne\)

\ne

\(\pm\)

\pm

\(\sim\)

\sim

\(\approx\)

\approx

\(\equiv\)

\equiv

\(\simeq\)

\simeq

\(\leq\)

\leq

\(\geq\)

\geq

\(\mid\)

\mid

\(\parallel\)

\parallel

\(\|\)

\|

\(\perp\)

\perp

\(\lim\)

\lim

\(\Pr\)

\Pr

\(\neg\)

\neg

\(A^\intercal\)

\intercal

Decorators

\(\hat{a}\)

\hat{a}

\(\tilde{a}\)

\tilde{a}

\(\bar{a}\)

\bar{a}

\(\vec{a}\)

\vec{a}

\(\overline{abc}\)

\overline{abc}

\(\overrightarrow{abc}\)

\overrightarrow{abc}

\(\widehat{abc}\)

\widehat{abc}

\(\dot{a}\)

\dot{a}

Set symbols

\(\in\)

\in

\(\notin\)

\notin

\(\emptyset\)

\emptyset

\(\varnothing\)

\varnothing

\(\cap\)

\cap

\(\cup\)

\cup

Other symbols

\(\cdot\)

\cdot

\(\cdots\)

\cdots

\(\ldots\)

\ldots

\(\vdots\)

\vdots

\(\ddots\)

\ddots

\(\times\)

\times

\(\rfloor\)

\rfloor

\(\lrcorner\)

\lrcorner

\(\infty\)

\infty

\(\prime\)

\prime

Fonts

\(\mathcal{A}\)

\mathcal{A}

\(\mathbb{A}\)

\mathbb{A}

\(\mathbf{A}\)

\mathbf{A} 1

\(\boldsymbol{\alpha}\)

\boldsymbol{\alpha}

Functions

\(\min\)

\min

\(\max\)

\max

\(\lim\)

\lim

\(\sin\)

\sin

\(\cos\)

\cos

\(\tan\)

\tan

\(\exp\)

\exp

\(\log\)

\log

\(\ln\)

\ln

\(\arg\)

\arg

\(\sum\)

\sum

\(\int\)

\int

Styling equations

Align equations to the left with align

.. math::

   \begin{align}
   &S = {A,B,C} \\
   &P(3, 2) = 6; \quad \{AB, AC, BA, BC, CA, CB\} \\
   \end{align}
\[\begin{split}\begin{align} &S = {A,B,C} \\ &P(3, 2) = 6; \quad \{AB, AC, BA, BC, CA, CB\} \\ \end{align}\end{split}\]

Control the size of brackets and parentheses with: \big, \Big, \bigg, \Bigg

\(\big(\)

\big(

\(\Big]\)

\Big]

\(\bigg\{\)

\bigg\{

\(\Bigg \rangle\)

\Bigg \rangle

Create a function with different steps using cases:

.. math::

   \kappa = \begin{cases}
   0 & \text{if censored} \\
   1 & \text{if not censored}
   \end{cases}
\[\begin{split} \kappa = \begin{cases} 0 & \text{if censored} \\ 1 & \text{if not censored} \end{cases}\end{split}\]

Matrix

Matrix can be including in LaTeX with array:

.. math::

   M=
   \left[ {\begin{array}{cc}
   1 & 2 \\
   3 & 4 \\
   \end{array} } \right]
\[\begin{split}M= \left[ {\begin{array}{cc} 1 & 2 \\ 3 & 4 \\ \end{array} } \right]\end{split}\]

https://en.wikipedia.org/wiki/Wikipedia:LaTeX_symbols

https://tex.stackexchange.com/questions/145657/align-equation-left

https://www.overleaf.com/learn/latex/Brackets_and_Parentheses


1

\mathbf{A} does not work with other LaTeX symbols