TechniqueMarkdownKaTeXMathematics

Rendering Math in Markdown

2020-11-05Chris Tham

If you are interested in publishing technical or scientific content, you may need to include math formulae in your blog posts. Here is the method I used for this site.

hero

Ever wanted to include a math formula in your blog posts? I studied Pure Mathematics as a major in my BSc degree so I like to use math symbols and notation in some of my posts.

For this site, I enabled the use of math blocks via remark-math and Remark MDX math enhanced plugins.

The plugins use the underlying KaTeX library for math typesetting, which is fast and reliable and created by the Khan Academy.

Here is an example of both inline and block math content generated using the following text in the markdown document:

Lift($L$) can be determined by Lift Coefficient ($C_L$) like the following equation.

$$
L = \frac{1}{2} \rho v^2 S C_L
$$

Lift(LL) can be determined by Lift Coefficient (CLC_L) like the following equation.

L=12ρv2SCLL = \frac{1}{2} \rho v^2 S C_L

Additional examples, taken from the KaTeX website:

1(ϕ5ϕ)e25π=1+e2π1+e4π1+e6π1+e8π1+\displaystyle \frac{1}{\Bigl(\sqrt{\phi \sqrt{5}}-\phi\Bigr) e^{\frac25 \pi}} = 1+\frac{e^{-2\pi}} {1+\frac{e^{-4\pi}} {1+\frac{e^{-6\pi}} {1+\frac{e^{-8\pi}} {1+\cdots} } } }
(k=1nakbk)2(k=1nak2)(k=1nbk2)\displaystyle \left( \sum_{k=1}^n a_k b_k \right)^2 \leq \left( \sum_{k=1}^n a_k^2 \right) \left( \sum_{k=1}^n b_k^2 \right)
1+q2(1q)+q6(1q)(1q2)+=j=01(1q5j+2)(1q5j+3),for q<1.\displaystyle {1 + \frac{q^2}{(1-q)}+\frac{q^6}{(1-q)(1-q^2)}+\cdots }= \prod_{j=0}^{\infty}\frac{1}{(1-q^{5j+2})(1-q^{5j+3})}, \quad\quad \text{for }\lvert q\rvert<1.

Subscribe to get updates to this site!

Like my articles? Enter your details and I will send you an email whenever the site has new content. I will not use your email for any other purpose.

Subscribe