# LaTeX in Markdown (New Technology)

_Published: 2023-08-22 · Author: Finn_

## LaTeX in Markdown

Since May 2022, it has been possible to render math expressions in Markdown on GitHub using LaTeX.

[Writing mathematical expressions](https://docs.github.com/en/get-started/writing-on-github/working-with-advanced-formatting/writing-mathematical-expressions)

## LaTeX and Markdown for students in high school

If students, and especially visually impaired students, should learn a simple, yet powerful tool for writing their
homework, this might be the best solution to date.

[Pratique des mathématiques en situation de handicap visuel](https://culturemath.ens.fr/thematiques/lycee/pratique-des-mathematiques-en-situation-de-handicap-visuel)

## Examples of Math in Markdown

### High School Math

```LaTeX
$$
x = \sqrt{x}^2 =\sqrt{x^2} = (x^2)^{\frac{1}{2}}
$$

$$
16 = 4^2
$$

$$
4 = \sqrt{16} = 16^{\frac{1}{2}}
$$
```

$$
x = \sqrt{x}^2 =\sqrt{x^2} = (x^2)^{\frac{1}{2}}
$$

$$
16 = 4^2
$$

$$
4 = \sqrt{16} = 16^{\frac{1}{2}}
$$

### LaTeX

```LaTeX
$$ \LaTeX $$
```

$$ \LARGE{\LaTeX} $$

### Integral

```LaTeX
\int_{-\infty}^{+\infty}\mathrm e^{-\alpha\, x^2}\mathrm d x=\sqrt{\frac{\pi}{\alpha}} 
```

$$
\LARGE{\int_{-\infty}^{+\infty}\mathrm e^{-\alpha\, x^2}\mathrm d x=\sqrt{\frac{\pi}{\alpha}}}
$$

### Special case

If a delimiter on only one side of an expression is required, then an invisible delimiter on the other side may be denoted using a period (.).

```LaTeX
$$
\left.\frac{x^3}{3}\right|_0^1
$$
```

$$
\LARGE{\left.\frac{x^3}{3}\right|_0^1}
$$

### Matrix

```LaTeX
$$
\begin{bmatrix}
    a1 & a2 \\
    a3 & a4 \\
\end{bmatrix}
$$
```

$$
\LARGE{
\begin{bmatrix}
    a1 & a2 \\
    a3 & a4 \\
\end{bmatrix}
}
$$

## Cédric Villani

In his book *Théorème vivant*, Cédric Villani gives an example of an email that he sends to his co-writer Clement Mouhot. In the email, he writes native LaTeX, thereby giving us an example of two people reading native LaTeX without the need to format it.

```LaTeX
N_{k-i+1}/(k-i+1)! devrait donner N_k/k!
et pas N_k/(k+1)!
```

$$
\frac{N_{k-i+1}}{(k-i+1)!}
$$

devrait donner

$$
\frac{N_k}{k!}
$$

et pas

$$
\frac{N_k}{(k+1)!}
$$

In the book, he also tells the story of Donald Knuth and gives the example of

### Formule de Faà di Bruno (Arbogast 1800, Faà de Brune 1855)

```LaTeX
$$
(f\circ H)^{(n)}] = \sum_{\sum_{j=1}^n j\,m_j = n}\frac{n!}{m_1!\ldots m_n!}\, \bigl(f^{(m_1 + \ldots + m_n)}\circ H\bigr)\, \prod_{j=1}^n\left(\frac{H^{(j)}}{j!}\right)^{m_j}
$$
```

$$
(f\circ H)^{(n)} =
    \sum_{\sum_{j=1}^n j\,m_j = n}\frac{n!}{m_1!\ldots m_n!}\, \bigl(f^{(m_1 + \ldots + m_n)}\circ H\bigr)\,
    \prod_{j=1}^n\left(\frac{H^{(j)}}{j!}\right)^{m_j}
$$

### Water

Water is represented as

```LaTeX
$$
\text{H}_2\text{O}
$$
```

$$
\text{H}_2\text{O}
$$

## Sources of information and inspiration

If you want to learn how to do this here are some good sources.

### Good overview of all commands

- [Markdown and LaTeX introduction](https://ashki23.github.io/markdown-latex.html)

- [LaTeX/Mathematics](https://en.wikibooks.org/wiki/LaTeX/Mathematics)

- [KaTeX](https://katex.org/docs/supported.html) GitHub uses this.

### Examples

- [Examples](https://github.com/damienbod/math-docs) in English.

- [Examples](https://dalissier.perso.math.cnrs.fr/pdf/latex/chapitre4.pdf) in French.

## Visual Studio Code Extensions

- [Markdown All in One](https://marketplace.visualstudio.com/items?itemName=yzhang.markdown-all-in-one#math)

- [Markdown+Math](https://marketplace.visualstudio.com/items?itemName=goessner.mdmath)

---

[View the normal web page](https://www.finnpedersenfrance.com/technology/2023/08/22/latex-in-markdown.html)
