This article is a demo of Story’s ability to typeset mathematical equations, both inline and in block form.

Story uses the KaTeX library to typeset mathematical formulae in \( \LaTeX \) notation. KaTeX is similar to MathJax, but simpler and faster. It provides most of the features needed for typesetting equations, both inline and in block form.

Story provides a `math`

Hugo shortcode to help avoid problems that result from
Markdown processing. Here’s an example of using the shortcode for inline math:

`The quadratic equation is {{< math >}}x = \frac{-b \pm \sqrt{b^2 - 4ac}}{2a}{{< /math >}}.`

The quadratic equation is \( x = \frac{-b \pm \sqrt{b^2 - 4ac}}{2a} \).

And in equation mode,

```
{{< math >}}
x = \frac{-b \pm \sqrt{b^2 - 4ac}}{2a}
{{< /math >}}
```

You don’t have to use the shortcode, but it saves you from needing to backslash-escape special characters, and fixes problems like backslashes and spaces at the end of the line, which Hugo’s Markdown processor will otherwise mangle. This enables frustration-free typesetting of more advanced equations such as the following:

Math typesetting is controlled with the `feature-[no]math`

flag.

Read next: Story’s music notation.