Using MathJax with Jekyll and kramdown
Posted: 2024-01-23, Updated:2026-05-14
Tags: Jekyll, kramdown, MathJax
Kramdown will automatically convert equations inside of $$ ... $$ to inline or display mode by replacing $$ ... $$ with \( ... \) or \[ ... \] as appropriate.
If the MathJax script is included on the page equations will be automatically rendered with no further configuration necessary.
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.
Note: Kramdown and MathJax both ignore <code> and <pre> blocks, as demostrated above.
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.