Getting LaTeX Math to work in Pelican

Basically, you can follow this post verbatim.

I’ll just explain how I got to work on my personal setup. First of all, in order to do this you’ll need to edit your template. I have a copy of the “notmyidea” template in my blog directory, so I can make changes to it. You can copy /usr/share/pyshared/pelican/themes/notmyidea to your blog directory, for example if my pelican files live in ~/blog/ I’d copy notmyidea to ~/blog/themes/notmyidea. Now you’ll need to tell Pelican where to look for your theme, you can do this by editing your to include:

THEME = "themes/notmyidea"
CSS_FILE = "main.css"

Now, in blog/themes/notmyidea/templates/base.html you’ll need to add

<!-- Using MathJax, with the delimiters $ -->
<!-- Conflict with pygments for the .mo and .mi -->
<script type="text/x-mathjax-config">
  "HTML-CSS": {
  styles: {
  ".MathJax .mo, .MathJax .mi": {color: "black ! important"}}
  tex2jax: {inlineMath: [['$','$'], ['\\\\(','\\\\)']],processEscapes: true}

<script type="text/javascript" src="//"></script>

in the <head> section.

Now that you have this done, you should be able to start using inline equations using \$a^{\\beta}\$ to get $a^{\\beta}$ (note the double backslash).

I was having problems, however, getting the math directive to work with MathJax. What was happening was that instead of creating a <div class="math"> for the mathblock, RST was parsing the $\LaTeX$ as HTML. In order to fix this, you need to edit your docutils settings, as documented here. I did this by having a docutils.conf in my ~/blog folder with the following contents:

[html4css1 writer]
math_output: MathJax


.. math::


Outputs to: