Notes to Future-Me


Using MathJax with Jekyll and kramdown

Posted: 2024-01-23
Tags: Jekyll, kramdown, MathJax

Simply put all equations inside of $$ ... $$ and kramdown will automatically convert them to \( ... \) for inline or \[ ... \] for display mode as appropriate.

Then, as long as the MathJax script is included on the page, the equations will be automatically rendered appropriately with no further configuration.

For example, the following renders correctly using only double dollar-signs:

This is a sentence and $$ \int^{1}_{-1} f(x) dx $$ is math in the sentence.  However, this:

$$ \int^{1}_{-1} f(x) dx $$ 

is math in its own block.

This is a sentence and \(\int^{1}_{-1} f(x) dx\) is math in the sentence. However, this:

\[\int^{1}_{-1} f(x) dx\]

is math in its own block.


This is a feature of kramdown, as noted here:

Using inline math is also easy: just surround your math content with two dollar signs, like with a math block.