Using Gitlab with mathjax

This page will outline how to get gitlab markdown to render mathjax in a way that is mostly compatable with pandoc.

Configurign the mathjax script

The first thing to do is add a plain text script to the view layout templates. This code should go into the file app/views/layouts/_mathjax.html.haml

  <script type="text/x-mathjax-config">
      tex2jax: {
        inlineMath: [ ['$','$'] ],
        processEscapes: true
  <script type="text/javascript"

Now, configuring the view haml files should be as easy as putting = render 'layouts/mathjax' at the top of all of the following files:


Disabling superscript

By default, gitlab has the (annoying) feature of using carrot as a superscript. This breaks mathjax for ever equation with a superscript, so to turn it off in the file app/helpers/gitlab_markdown_helper.rb. Simply set superscript to false.