How to Write Math Equations in Markdown (LaTeX)


There’s no native support for LaTeX in Markdown, but there are two nice solutions to write math equations in Markdown.

Using HTML Entities and Symbols

We can use HTML entities and UTF-8 Mathematical Operators in Markdown to write math equations without any external dependencies.

hθ(x) = θo x + θ1x

However, this approach is fairly limited and can be quite complicated just to get a simple math equation on the page.

Using LaTeX in CodeCogs

This equation editor called CodeCogs is quite amazing.

It’s a very friendly interface to write out equations in LaTeX markup.

Once we’ve typed in an equation, we can do the following:

  1. Click Export
  2. Select svg and HTML
  3. Paste the img tag into our Markdown.
<img
  src="https://latex.codecogs.com/svg.image?\frac{0.1*25,000}{0.85*min(1.5,1)*10}(1.5*10)"
  title="\frac{0.1*25,000}{0.85*min(1.5,1)*10}(1.5*10)"
/>

This equation is from a previous article: Should I Participate in an Employee Stock Purchase Plan (ESPP)?