View on GitHub

GHP-Tutorial

GitHub Pages - Crash Course

Enabling MathJax

This site template has been pre-enabled with MathJax, so if you use this as the base of your project (removing the links to or re-writing the existing pages), you shouldn’t need to do anything special to enable MathJax. Just follow the instructions below.

The most important thing to remember for using MathJax in GitHub Pages is to add a special include to the top of each page in which you will be using it. In this case, that means adding include mathjax.html surrounded by {% %}

This tells the browser to include the script I’ve put in _includes/mathjax.html in the home directory, which enables MathJax:

<!-- <script type="text/javascript"></script> -->
<script type="text/x-mathjax-config">
  MathJax.Hub.Config({
   tex2jax: {inlineMath: [['$','$'], ['\\(','\\)']]}
   });
 </script>
 <script type="text/javascript" src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML">
</script>
 

Once you do this, it’s very simple to use MathJax with GitHub pages with markdown.

Using MathJax with Markdown

Kramdown, the markdown translater this GitHub Pages site is setup to use, has special support for $$ to delimit both inline and block equations.

For example, $$ \frac{1}{n^{2}} $$ is rendered as a block equation here:

It’s the same process for more complex formulae, such as

$$ J(\theta) = \frac{1}{2m}(\sum_{i=1}^m(h_\theta (x^{(i)}) - y^{(i)})^2 + \lambda\sum_{j=1}^n\theta^2_j) $$ 

Rendered as:

You use the same basic syntax to render $$a^2 + b^2 = c^2$$ inline:

You can also use different typesets or math alphabets, such as \mathbf:

Additional Resources