A quick way to get high quality math equations displayed on your website is MathTran. They provide a webservice which will render a given LaTeX equation as a PNG for you. All you need to do is place the following line inside the <head> tags of your website:

<script type="text/javascript" src="http://www.mathtran.org/js/mathtran.js"></script>

Once you have done this all <img> tags of the form

<img alt="tex:e^{i\pi} = -1" />

will be replaced by the corresponding LaTeX equation.

MoinMoin macro

If you are using MoinMoin as your wiki here is a basic macro which allows you to insert MathTran rendered equations into your wiki pages. Place the following two lines in a file named MathTran.py in the data/plugin/macro directory of your wiki.

   1 def execute(macro, formula):
   2    return macro.formatter.image(alt=r"tex:"+ formula)

At first sight this appears to allow cross-site scripting attacks, however I believe that formula is automagically escaped by the wiki. See the end of this page for an example.

The MoinMoin MacroMarket page for MathTran is http://moinmo.in/MacroMarket/MathTran

From now on the macro MathTran is available, to use it just type:

[[MathTran(e^{i\pi} = -1)]]

Which will give you tex:e^{i\pi} = -1.

We all recognise the expression of a Taylor series tex:f(x) = \sum_{n=0}^{\infty}\frac{f^{(n)}(0)}{n!}x^n, but it is a bit cramped. Luckily MathTran can also display things display style:

tex:\displaystyle f(x) = \sum_{n=0}^{\infty}\frac{f^{(n)}(0)}{n!}x^n

You might also recognise:

tex:\displaystyle \gamma = \frac{1}{\sqrt{1-\frac{v^2}{c^2}}}

tex:\displaystyle \left(-\frac{\hbar^2}{2m}\nabla^2 + V\left(\vec{r}\right) \right)\Psi\left(\vec{r}, t \right) = i \hbar \frac{\partial}{\partial t}\Psi\left(\vec{r}, t \right)

Feel free to add more examples.

XSS attacks? tex:" /> hello world \displaystyle f(x) = \sum_{n=0}^{\infty}\frac{f^{(n)}(0)}{n!}x^n


CategoryLatex CategoryPython

MathTran (last edited 2011-10-30 12:34:35 by TimHead)