Skip to content

Instantly share code, notes, and snippets.

@innat
Last active August 16, 2018 17:49
Show Gist options
  • Save innat/67f96da13322640b6c1870ac398a3158 to your computer and use it in GitHub Desktop.
Save innat/67f96da13322640b6c1870ac398a3158 to your computer and use it in GitHub Desktop.
Jekyll is Love

Render Mathematical Equation on GitHub Page

Stack QA

Magic of MathJax.

Procedure

  1. Add following piece of code to jekyll _includes folder, we can name it mathjax.html
<script type="text/x-mathjax-config">
  MathJax.Hub.Config({
    extensions: ["tex2jax.js"],
    jax: ["input/TeX", "output/HTML-CSS"],
    tex2jax: {
      inlineMath: [ ['$','$'], ["\\(","\\)"] ],
      displayMath: [ ['$$','$$'], ["\[","\]"], ["\\[","\\]"] ],
      processEscapes: true
    },
    messageStyle: "none",
    "HTML-CSS": { availableFonts: ["TeX"] }
  });
</script>

<script type="text/javascript"
   src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.4/MathJax.js">
</script>
  1. Then add following inclusion to _layouts/default.html

{% include mathjax.html %}


Test it on Page:

$$
\begin{align}
\sigma_b^2(t) & = \sigma^2(t) - \sigma_w^2(t) = w_0(\mu_0 - \mu_T)^2 + w_1(\mu_1 - \mu_T)^2 \tag{maximum variance} \\ 
&= w_0(t)w_1(t)\left[\mu_0(t) - \mu_1(t)\right]^2
\end{align}
$$

Put it on markdown file. We don't need to put $$...$$ into code formate. Just copy and past only $$...$$. Now, mathematical equation will be available on the page.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment