Computational Science and Data Science

Hans Fangohr

Setting up Pelican - how to make equations work?

Seeing that I have solved this problem twice (forgetting the solution after having done it once), I will write down the essential steps.

To be able to use equations in the static Pelican Blog generator, the key is to include a code snippet like

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

<script type="text/javascript" src="http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS_HTML"></script>
</head>

in the template/base.html theme file (just before the <body> section.)

This has been copied from Amic Frouvelle.

Once activated, this source:

.. math::

  \alpha = 10^2

renders nicely into

α = 102

Inline mathematical expressions can be surrounded by \$ just as in LaTeX. However, we need to use a double backslash instead of a single backslash. For example \$\\alpha = 10^2\$ would be rendered as $\alpha = 10^2$ in the line.


Update: February 2014. Have now found this pelican plugin.

https://github.com/barrysteyn/pelican_plugin-latex

Testing $\alpha=0.3$ and $10^2$.

This seems easier as it does not require changing the template/base.html file.

Comments