2012-01-12

So up until recently I had been using MoinMoin Latex to render my math formulae but it didn't run very well on tahnok.me and it was dependent on a really old version of tetex or texlive that I don't quite recall how I got working...

Now I have (MathJax)[http://www.mathjax.org/] working! It kinda eats my browser for a little while because pages like Math240 have more formula than is strictly reasonable but oh well.

Here's how I got it running!

Method 1: Using the MathJax CDN

This is the easiest way but it requires a request to an external server.

Step 1 Open up wikiconfig.py or whatever your config file is called and add:

html_head = u"""
        <script type="text/x-mathjax-config">
                 MathJax.Hub.Config({
                    extensions: ["tex2jax.js"],
                    jax: ["input/TeX", "output/HTML-CSS"],
                    tex2jax: {
                      inlineMath: [ ['$','$'] ],
                      displayMath: [ ['$$','$$'] ],
                      processEscapes: true
                    },
                    "HTML-CSS": { availableFonts: ["TeX"] }
                  });
        </script>
        <script type="text/javascript"
          src="https://d3eoax9i5htok0.cloudfront.net/mathjax/latest/MathJax.js">
        </script>"""

Step 2

Restart moinmoin and enjoy!

Method 2: Local installation of MathJax

I had to use this method for my local install of moinmoin and I don't always have laptop but I still want to see equations.

Step 1

Open a terminal to your htdocs/common folder. For me it was in wikidir/MoinMoin/web/static/htdocs/common

Then I ran git clone git://github.com/mathjax/MathJax.git MathJax

Step 2

Add the following to your wikiconfig.py file:

html_head = u"""<script type="text/x-mathjax-config">
 MathJax.Hub.Config({
    extensions: ["tex2jax.js"],
    jax: ["input/TeX", "output/HTML-CSS"],
    tex2jax: {
      inlineMath: [ ['$','$'] ],
      displayMath: [ ['$$','$$'] ],
      processEscapes: true
    },
    "HTML-CSS": { availableFonts: ["TeX"] }
  });
</script>
<script type="text/javascript" src="/moin/static193/common/MathJax/MathJax.js"></script>"""

Step 3

Restart moinmoin and enjoy!

Using MathJax

The current config treats anything between a pair of $'s as an inline formula and a pair of $$' as a formula to display centered in the page. So to get

Beautiful beautiful latex

You'd write $\sum_{v \in V} \deg (v)= 2 e \leq 2(3n-6) \leq 6n -12$

No comments: