For this blog, I am currently using Hugo v0.62.2, and since v0.60 Hugo by default, goldmark is used under the hood to render Markdown to HTML. Moreover, to write math I am now using Katex which is pretty fast compared to other math typesetting libraries!
Today, as I was doing some math on my blog, I realize that inline math was not rendered. At first I thought that this was a conflict between KaTeX and goldmark but actually, I needed to tweak the delimiters
KaTeX option. Fortunately, KaTeX options are well documented and so is the auto-render extension (plus, there is an answer on about this). Without further ado, Below is the partial that I am now using that is added to the head of every page that has math:true
in the YAML front matter. In the code block below I’ve highlighted how I set up the delimiters
option so as to use $$
for math in display mode and $
for inline math.
|
|
For instance $\sum_i^nd_i$
gives $\sum_i^nd_i$ whereas $$\sum_i^nd_i$$
yields the following equation
$$\sum_i^nd_i$$
By the way that \tag
can be used to number the equation and so $$\sum_i=1^n \tag{1}$$
gives
$$\sum_i^nd_i \tag{1}$$
but looks like that so far, \tag
do not handle automated referencing, this may change in the future, we’ll see!
That’s all folks 🎉! Hope this can be helpful!