1 minute read

In one of my previous blog posts I show you how to set up the Minimal Mistakes theme for your Github page. In this blog post I show how to add Latex support to your Minimal Mistakes jekyll blog and is largely based on this.

Step 1. Set markdown engine to kramdown

In your _config.yml change the engine to kramdown as follows

# Build settings
markdown: kramdown
remote_theme: mmistakes/minimal-mistakes
...

Step 2. Copy over scripts.html

This is where stuff gets a little bit tricky. This blog was set up by forking this repo and then using the original repo as a remote theme. To get Latex support we first have to go to the original Minimal Mistakes repo here and copy over minimal-mistakes/_includes/scripts.html locally to our _includes/scripts.html.

Step 3. Modify scripts.html

We are now going to modify scripts.html and append the following content:

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

<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>

Note that this overrides any other include file in the remote theme. So the contents of the original file in the remote theme will be overwritten. This means that this fix/update is liable to break with new updates. Be mindful of this.

Step 4. That’s it!

If you did everything properly then this should render nicely:

\[e^{i \pi} = -1\]

Subscribe

Comments