Skip to content
This repository has been archived by the owner on Jul 17, 2018. It is now read-only.

LaTeX mathematics support with MathJax

Adam Prescott edited this page Apr 22, 2014 · 4 revisions

Serif uses the kramdown library for Markdown rendering, which supports both block and inline mathematics:

# Post content

My opening paragraph.

$$
\begin{...}
  ...
\end{...}
$$

And from this we find that $$f(x) = ...$$ so the theorem holds.

Note that unlike the default MathJax configuration, both inline and block level LaTeX sections use $$.

Enabling MathJax

As per the MathJax.org website, add the relevant <script> to your layout.

For example, in _layouts/default.html:

<script src="https://c328740.ssl.cf1.rackcdn.com/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML"></script>

And then create js/admin/admin.js with the following (using the same URL as your layout), so that admin pages get the same preview functionality as generated posts:

(function() {
  var mathjax = document.createElement('script');
  mathjax.src = "https://c328740.ssl.cf1.rackcdn.com/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML";
  var s = document.getElementsByTagName('script')[0];
  s.parentNode.insertBefore(mathjax, s);
})();

$(function() {
  $("#entry").on("markdown-previewed", function() {
    MathJax.Hub.Queue(["Typeset",MathJax.Hub]);
  });
});
Clone this wiki locally