Jan-Hendrik Ewers Logo

Adding LaTex to Jekyll

September 10, 2021    latex jekyll markdown ☕️ buy me a coffee

I’m about to start my PhD and a logical conclusion from that is that I will be writing a lot on LaTex. If I plan to write any blogs or such about the progress then this LaTex support is needed! Luckily for me iangoodfellow has written a short guide on this already!


Add the following code to _layouts/post.html:

<script src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML" type="text/javascript"></script>

Note: cdn.mathjax.org has been deprecated. Please use cdnjs.cloudflare.com as per https://www.mathjax.org/cdn-shutting-down/

Then you can write normal MathJax expressions such as

    1 & 1 & 1 \\
    2 & 2 & 2
    4 \\
    2 \\

to get

\[\vec{\alpha} = \begin{bmatrix} 1 & 1 & 1 \\ 2 & 2 & 2 \end{bmatrix} \cdot \begin{bmatrix} 4 \\ 2 \\ 0 \end{bmatrix}\]


MathJax only supports the core LaTex functionality which means so ability to add packages with usepackage. Hence, iangoodfellow suggests using boldsymbol rather than bm. Furthermore, he says

“There seem to be a few other rough edges, for example, LaTeX expressions seem to cause extraneous line breaks when used in blog post titles.”

Tips ‘n’ tricks

There’s two resources I result on the regular when using Markdown and/or Latex:

  1. This Markdown cheatsheet by adam-p
  2. This table generator to get plaintext, markdown, latex, etc. tables with formatting and more. Super useful.
  3. This MathJax cheatsheet by MJD