Adding LaTeX Support in Ghost

In the previous post we described the process of adding nice syntax highlighting in Ghost blog. We are missing one more important step to make a truly mathematically friendly - the LaTex support.

Thanks to MathJax this task is extremely easy to accomplish. In order to add MathJax to the blog we need to edit the default.hbs file in your template (e.g. Casper) and put following code between <body> and <\body> tags

{{! Mathjax configuration}}
<script type="text/javascript"     src=""></script>

<script type="text/x-mathjax-config">  
        tex2jax: {inlineMath: [['$','$'], ['\\(','\\)']],
                  displayMath: [['$$','$$'], ['\[','\]']]}

Simple. Let's see this in action. This code $$\sum_{n=1}^{\infty} \frac{1}{n^2} = \frac{\pi}{6}$$ will yield

$$\sum_{n=1}^{\infty} \frac{1}{n^2} = \frac{\pi^2}{6}$$

The nice feature is that if you right-click on the equation, you can select to display the equation in TeX or MathML code.

In future posts we will use both syntax higlighting and LaTeX extensively.