This post covers adding MathJax support to a GitHub Pages Jekyll blog.

Software Versions

$ date -u "+%Y-%m-%d %H:%M:%S +0000"
2016-08-21 23:41:54 +0000
$ uname -vm
FreeBSD 11.0-ALPHA6 #0 r302384: Thu Jul  7 22:40:47 JST 2016     root@mirage.sennue.com:/usr/obj/usr/src/sys/MIRAGE_KERNEL  amd64
$ ruby --version
ruby 2.2.5p319 (2016-04-26 revision 54774) [amd64-freebsd11]
$ jekyll --version
jekyll 3.0.1

Instructions

Add the following code to _includes/mathjax.html.

_includes/mathjax.html.

{% if page.mathjax %}
<script type="text/x-mathjax-config">
  MathJax.Hub.Config({
    tex2jax: {
      inlineMath: [ ['$','$'], ["\\(","\\)"] ],
      processEscapes: true
    }
  });
</script>
<script
  type="text/javascript"
  charset="utf-8"
  src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML"
>
</script>
<script
  type="text/javascript"
  charset="utf-8"
  src="https://vincenttam.github.io/javascripts/MathJaxLocal.js"
>
</script>
{% endif %}

Add the following line to the header in _layouts/post.html or anywhere else you want to use MathJax.

_layouts/post.html partial listing

{% include mathjax.html %}

Add the following line to the YAML front matter of a post to enable MathJax on a post by post basis.

mathjax: true

For example, the front matter of this post looks like this. Note that Disqus comments have been added with the same strategy.

---
layout: post
mathjax: true
comments: true
title:  "Adding MathJax to a GitHub Pages Jekyll Blog"
date:   2016-08-21 23:41:54 +0000
categories: github jekyll
---

If all goes well, you should be able to use MathJax inline and display modes. Note that the MathJax dynamic preview can be useful when formatting complex equations.

In N-dimensional simplex noise, the squared kernel summation radius $r^2$ is $\frac 1 2$
for all values of N. This is because the edge length of the N-simplex $s = \sqrt {\frac {N} {N + 1}}$
divides out of the N-simplex height $h = s \sqrt {\frac {N + 1} {2N}}$.
The kernel summation radius $r$ is equal to the N-simplex height $h$.

$$ r = h = \sqrt{\frac {1} {2}} = \sqrt{\frac {N} {N+1}} \sqrt{\frac {N+1} {2N}} $$

In N-dimensional simplex noise, the squared kernel summation radius $r^2$ is $\frac 1 2$ for all values of N. This is because the edge length of the N-simplex $s = \sqrt {\frac {N} {N + 1}}$ divides out of the N-simplex height $h = s \sqrt {\frac {N + 1} {2N}}$. The kernel summation radius $r$ is equal to the N-simplex height $h$.

\[r = h = \sqrt{\frac {1} {2}} = \sqrt{\frac {N} {N+1}} \sqrt{\frac {N+1} {2N}} \tag{1}\]

Equations

This section collects the 1 display equations of the article in the order they appear, each under its number and reproduced exactly as it stands in the text. A title in bold names an established result, and a title in italics beginning with the word Bespoke names a construction made for this analysis. Of the 1, 1 are established and 0 are bespoke. All lengths are dimensionless and measured in the unit grid of N-dimensional simplex noise, in which the simplex edge length depends on the dimension N.

Equation 1, Kernel Summation Radius of Simplex Noise. The height of a regular N-simplex is its edge length multiplied by $\sqrt{(N+1)/2N}$, so with the simplex noise edge length $\sqrt{N/(N+1)}$ the dimension cancels and the kernel radius is $\sqrt{1/2}$ for every $N$.

\[r = h = \sqrt{\frac {1} {2}} = \sqrt{\frac {N} {N+1}} \sqrt{\frac {N+1} {2N}} \tag{1}\]

Notation

  • $r$, the kernel summation radius of simplex noise
  • $h$, the height of the N-simplex
  • $N$, the number of dimensions

References

Primary Sources, Non-Peer-Reviewed

Commercial Sources

General Sources