April 1, 2019 · math software diy

Easily Add LaTex Math to a Ghost Blog

This is a guide to get LaTex math to work on a Ghost Blog. I chose a fast JavaScript Library developed by Khan Academy called KaTex. To see it in action, check my previous blog post on P-NP. Here are the steps to get it working:

  1. Login to the Ghost Administration Panel, and click the "Code Injection" tab on the sidebar.

  2. Paste in the following code block into the "Blog Header" section and Save:

    <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/katex@0.10.1/dist/katex.css" crossorigin="anonymous">
    <script defer src="https://cdn.jsdelivr.net/npm/katex@0.10.1/dist/katex.js" crossorigin="anonymous"></script>
    <script defer src="https://cdn.jsdelivr.net/npm/katex@0.10.1/dist/contrib/auto-render.min.js" crossorigin="anonymous" onload="renderMathInElement(document.body);"></script>
  3. In the blog post editor, to add an inline expression, surround the LaTex math with backslashes and parentheses: \\( LaTex_HERE \\). Example: \(\sum_{i=1}^{n}{n} = \frac{n(n-1)}{2}\). Otherwise, to get a large and beautiful expression, surround the LaTex math with backslashes and square brackets: \\[ LaTex_HERE \\]. Example: \[\sum_{i=1}^{n}{n} = \frac{n(n-1)}{2}\]