I describe how I include MathJax using Euler fonts.

Non-Standard Fonts

I follow the instructions in this blog on getting MathJax support in Markdown using Jekyll. However, to better match the Palatino text font, I use the Euler Math font, which MathJax can be configured to use. A nice place to try out the different available fonts is here.

I decided to include the mathjax scripts only on those pages, where it is actually used, so I created a new _include file mathjax.html with the usual MathJax contents:

<script>   window.MathJax = {
tex: {
  inlineMath: [['$', '$'], ['\\(', '\\)']],
  displayMath: [['\\[', '\\]']],
  processEscapes: true,
  // as in MathJax 2: \texttt{..} etc. take their argument verbatim
  // (textmacros would reject e.g. \texttt{node_rank}, after kramdown ate the \_)
  packages: { '[-]': ['textmacros'] }
}   }; </script> <script src="/assets/mathjax/wi-mathjax.js" data-output="chtml"></script> <script defer src="/assets/mathjax/v4/tex-chtml.js"></script>

By starting a new page with {% include mathjax.html %}, MathJax support is enabled—and it works out of the box: $\sqrt x$.

Showing liquid tags.
To show liquid tags literally (i.e. not expanded by jekyll), you can use the raw-tag of liquid.

By default, MathJax uses \(...\) for inline math, but it can also be configured to work with single dollars $\sum_{i=1}^n i^2 = \frac{n(n+1)(2n+1)}{6}$.

Using macros

Using macros with MathJax is possible (in MathJax 2, \newcommand with optional parameters did not work; it does now). In Jekyll, one runs into trouble with opening braces followed by % parts since these are interpreted as liquid tag opening.

However, basic macros do work. One can define a macro in one part and use it later on that page. It is best practice to put definitions in a separate display:none div to not influence the layout.

<div style="display:none">
$
\newcommand\testmacro[2]{\mathbf{F\alpha}(#1)^{#2}}
$
</div>
$ \newcommand\testmacro[2]{\mathbf{F\alpha}(#1)^{#2}} $

Then we can use $\testmacro{17}{\text{hallo}}$ to get $\testmacro{17}{\text{hallo}}$.

Text Fonts

Updated November 2026: the site now uses MathJax 4, served from the site itself rather than a CDN, with its Euler font extension; see _tools/README-mathjax.md in the sources.

In 2016, not all fonts worked as they should with Euler math: \mathrm and \mathit used the Euler letters meant for single-letter variables, and \text did not follow italic surroundings. MathJax has no setting for this, so a small extension now does what LaTeX’s eulervm package does: words are set in the text font, single letters, digits and Greek in Euler.

  • $\mathrm{mathrm}$ and $\mathit{mathit}$: $\mathrm{mathrm}$ and $\mathit{mathit}$
  • operator names, $\log n$, $\max_i a_i$, $\operatorname{rank}(M)$: $\log n$, $\max_i a_i$, $\operatorname{rank}(M)$
  • multi-letter variables, $x+2\cdot\text{slope}$: $x+2\cdot\text{slope}$, and in italic text, $\text{math}$ follows suit.
  • variables stay Euler: in $\mathrm{d}x$ only the d is Pagella, and $\Gamma(x) + \mathcal{O}(n)$ is all Euler.

Further Resources