Markdown documents can include elegant representations of algebraic formulae, using KaTeX.

The CommonMark specification of Markdown does not include scope for representing formulae or equations. Fortunately, there is KaTeX , an excellent typesetting library, which can be embedded in Markdown. KaTeX is supported extensively.

VSCode supports $\KaTeX$ in Markdown, equations are rendered in the VSCode preview pane, Ctrl + K V.

Inline math equations are wrapped in single dollar signs. For example, $x^2$ becomes $x^2$.

$\KaTeX$ blocks begin and end with two dollar signs:

1$$
2x^2
3$$

produces $$ x^2 $$

Here are a few more examples:

Pythagorean Theorem

1$$
2a^2 + b^2 = c^2
3$$

$$ a^2 + b^2 = c^2 $$

Einstein’s Theory of Special Relativity

1$$
2e=mc^2
3$$

$$ e=mc^2 $$

Matrices

 1$$
 2\begin{pmatrix}
 3a & b \cr
 4c & d
 5\end{pmatrix}
 6+
 7\begin{pmatrix}
 8e & f \cr
 9g & h
10\end{pmatrix}
11$$

$$ \begin{pmatrix} a & b \cr c & d \end{pmatrix} + \begin{pmatrix} e & f \cr g & h \end{pmatrix} $$

Special Cases

1$$
2\begin{dcases}
3   a &\text{if } b \cr
4   c &\text{if } d
5\end{dcases}
6$$

$$ \begin{dcases} a &\text{if } b \cr c &\text{if } d \end{dcases} $$

See many more examples at Cheat Sheet: Mathematical Notation in Markdown .