Add Latex Support for Minimal Mistakes

If you are seeing the latex name below, it means latex works for this site:

Mathjax

Set Markdown Engine to Kramdown

Check jekyll documentations for this step’s instructions.

Include Scripts

Check MathJax Documentation for this step’s instructions. Note that you might need config=TeX-MML-AM_CHTML at the end of your src value separated by a question mark in the following form to enable predefined configurations. Add the following into your website, it will load the latest MathJax library.

<script type="text/javascript" async
	src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.5/latest.js?config=TeX-MML-AM_CHTML">
</script>

And usually, if you are using a jekyll theme, this include line should go to a file in the _includes/ folder. In my case, I put it into the scripts.html file. You can also create a file for doing this, a file named custom.html for an example.

Adding configurations to scripts.html

(Thanks to Abhijit S., I forgot to put this part into this blog.)
We have included the MathJax library, and next we need to add some configurations and make it actually work pretty on our website. The goal is that we want the website to be able to recognize all normal Latex symbols for math equations and symbols: $$ and \[\]. To do that, add the following code into scripts.html:

<script type="text/x-mathjax-config">
   MathJax.Hub.Config({
     extensions: ["tex2jax.js"],
     jax: ["input/TeX", "output/HTML-CSS"],
     tex2jax: {
       inlineMath: [ ['$','$'], ["\\(","\\)"] ],
       displayMath: [ ['$$','$$'], ["\\[","\\]"] ],
       processEscapes: true
     },
     "HTML-CSS": { availableFonts: ["TeX"] }
   });
</script>

The meaning of this code is rather straight forward. You can add any symbols you want to enrich the ways MathJax pick up math equations.

Putting Math Equations on Your Webpage

If everything goes fine, you should get a working site with Mathjax. For usages of writing mathematics on page, check MathJax Doc. Use my blog as an example:
Math code:

\[p(\theta) = \mathbf{\prod}_{i,c}p(\mathbf{\theta}^i(c))\]

or

$$ E = mc^2 $$

Will be rendered to:

[ p(\theta) = \mathbf{\prod}_{i,c}p(\mathbf{\theta}^i(c)) ]

and

Note that, in my case, it seems like you better leave blank lines in your markdown file around a Latex Code Block to make it be centered after generated.

Using Katex instead of Mathjax

Katex is faster than Mathjax. To migrate, first check kramdown doc. You need JQuery, Katex and an automatic rendering script. Check Katex on Github and Auto render. After doing these, you should have a working site with Katex.

Updated:

Leave a Comment