In my last post we saw how we can add KaTeX to a Hugo blog to automatically render TeX code. Unfortunately, our changes still don’t allow inline math, i.e. we can only render equations in their own line like this: $$\int \frac{1}{x-2}$$ To enable inline math, we can simply open our katex.html partial from the last post and add the following script at the end of the file:

<script>
    document.addEventListener("DOMContentLoaded", function () {
        renderMathInElement(document.body, {
            delimiters: [
                { left: "$$", right: "$$", display: true },
                { left: "$", right: "$", display: false }
            ]
        });
    });
</script>

We can see that the following markdown line

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

outputs $ a^2 + b^2 = c^2$ which shows that inline math is now supported.