# Mathematical formula & LaTeX

WonderPen supports embedded mathematical formulas, if you are familiar with LaTeX or related syntax, it will be easy to insert all kinds of formulas in WonderPen.

## Formula blocks

Formula blocks refer to formulas that occupy a single paragraph. They are usually wrapped between `$$`

and `$$`

. E.g:

```
$$x = \frac{-b \pm \sqrt{b^2 - 4ac}}{2a}$$
```

Will be rendered as:

If the formula is complex, you can also wrap lines in the middle, for example:

```
$$
\begin {aligned}
\sin \theta &= \sin(\frac{\pi}{4})(1 - 2\sin^2\alpha) - \cos(\frac{\pi}{4}) \cdot 2\sin \alpha \cos \alpha\\
&=\frac{1}{\sqrt{2}}(1 - 2\cdot(\frac{1}{\sqrt{5}})^2) - \frac{1}{\sqrt{2}} \cdot 2 \cdot \frac{1}{\sqrt{5}} \cdot \frac{2}{\sqrt{5}}\\
&= \frac{3}{5\sqrt{2}} - \frac{4}{5\sqrt{2}}
\end {aligned}
$$
```

Will be rendered as:

## Inline Formulas

You can also embed formulas within sentences within a paragraph. This form is called *inline formulas*. Inline formulas are usually wrapped between `$`

and `$`

.

E.g:

```
This formula will be displayed in-line: $\left( \frac{n^2}{6} \right)$
```

Will be rendered as:

## Rendering Engine

WonderPen supports the following two rendering engines:

- KaTeX
- MathJax

You can choose your preferred rendering engine in **Settings** → **Advanced** → **Additional**. If you are not sure which engine to use, it is recommended to choose the default KaTeX.

## References

The complete LaTeX formula syntax is supported in WonderPen. Learning about LaTeX syntax is a huge topic, and you can refer to related materials. If you don't know much about LaTeX, you can start with the following links: