Markdown and Mathjax

I came across an unexpected problem when using Mathjax in a Markdown document (to be used with the Hugo site generator).

Usually, when writing long equations in LaTeX, I like to put the equality sign on a line by itself, like so:

\[
left hand side
= 
right hand side
\]

But this doesn’t work, because the Markdown processor (which runs before Mathjax sees the generated HTML) interprets the equality sign, on a line by itself, as headline indicator. (Markdown has two ways of indicating a top-level headline: a hash-mark # at the beginning of a line, or any number of equality signs, by themselves, following the line with the headline text.)

The solution is simple enough: combine the equality sign with either of the two halves of the equation.

\[
left hand side
= right hand side
\]

I don’t think I have seen this “gotcha” being pointed out before. Thankfully, it is much easier to resolve than the well-known problems involving underscores!

The Mathjax documentation discusses the preparation of inputs for Mathjax, and also mentions some of the typical issues when using Markdown as input format.