Fatih Kansoy in Latex 34 minutes

# Latex Equations in Jekyll and Markdown

The standard Markdown does not render $\rm \LaTeX$. That is the reason why sometimes researchers avoid to use Markdown on their writings. Actually is fairly simple. Let me briefly explain how it works.

There is a plugin called MathJax. What MathJax does simply is turning $\rm \LaTeX$ snippets into quality PNG images that we can see as if $\rm \LaTeX$ staff.

This blog is based on Jekyll which runs on kramdown converter that supports MathJax. So, be sure that you have a compatible markdown processing engine. If you use Jekyll that is ok. To jump start running and using equations, here is the code which all we need:

<script type="text/javascript"
src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.0/MathJax.js?config=TeX-AMS_CHTML"></script>


Copy the code and paste after the  <head>  block of your document. For example, you are using Jekyll and you want to see $\rm \LaTeX$ equations in your blog posts, you should put this code in post_html page under the _layouts folder.

# Inline and Displayed Math

Having saved that now we can start typing our equations. Let assume you would like to write an inline equation like this $E = mc^2$ then you need to type \$E = mc^2 \$. On the other hand, you may want to see the equation in the middle independently. In this case, all you need is to change parenthesis from oval one to rectangular one and rest of it are the same. So type  \$E = mc^2 \$ and get: $E = mc^2$

# Equation Numbers

In addition, you can also allocate numbers for each displayed equation. Again we need a very simply code again.

<script type="text/x-mathjax-config">
MathJax.Hub.Config({
TeX: { equationNumbers: { autoNumber: "AMS" } }
});
</script>


Similarly copy this code and paste to the same place where just after the </head> tag. Then type your equation

and get this:

$$e^{\pi i} + 1 = 0$$

Moreover, by using label{abc} and \eqref{abc} you can label and link to the each equation. For instance, type

and get:

$$\int_0^\infty \frac{x^3}{e^x-1}\,dx = \frac{\pi^4}{15} \label{eq:2}$$

So, now you can mention any equation you want. This is the second equation-\eqref{eq:2}.

This is one of simple examples of MathJax and you can find dozens of other here.