« Wordpress plugins you should install | Google Treasure Hunt puzzle 3 »

Latex on wordpress blog

Some time back I came to know that wordpress blogs hosted at wordpress.com supports latex. But no such default functionality for self hosted wordpress blogs. But there are plugins (latexrender, wp-latex) which can facilitate similar things.
But for these to work you will need to install latex on your hosting account. (I have intalled latex on my hostmonster account some time back.).

For installing latexrender wordpress plugin you can find guidelines here
One more thing to remember while setting $latexrender_path_http in latex.php give full http path to latexrender folder like $latexrender_path_http = "http://your blog addr/latexrender";
Now you are set to go. To include \LaTeX in your posting, use the following:

[tex] your latex code here [/tex]

For example:

[tex] (a+b)^3 = (a+b)^2(a+b) [/tex]

produces :

(a+b)^3 = (a+b)^2(a+b)

But after setting up latexrender plugin, the png image was still not generated. Error that I got was:

I can’t find the format file ‘latex.fmt’!

But when I tried similar command (latex sample.tex) from shell prompt, It was working fine.
So I thought that problem is in calling latex from php file using exec. So when I copied the latex.fmt file to directory containing .tex file it started working fine. May be some problem in setting environment variable.
You can look for latex.fmt file using :

find -name latex.fmt

For latexrender you can copy latex.fmt file to latexrender/tmp/ folder inside your wordpress installation.
I’m still working on how to set environment variable in php so that I don’t have to copy latex.fmt again and again.
But for now I gave got working latex on my blog :) . Now I can write math equations in my blog posts.
You can try latex formulas in comment too.

And if you want to publish LaTeX equation in WordPress blog without installing any software, try jsTeXrender: http://yourequations.com/. Thanks Doug for the tip.

Related Posts:
Latex Beamer
Installing latex on hostmonster

Comments

5 Responses to “Latex on wordpress blog”

  1. burad on May 25th, 2008 9:19 am

    It works in comments too :
     \int_{0}^{1}\frac{x^{4}\left(1-x\right)^{4}}{1+x^{2}}dx 
 =\frac{22}{7}-\pi

  2. Amit Aggarwal on May 26th, 2008 2:00 am

    nice tip ajit, .. will definitely give it try this week

  3. Abhishek Ojha on May 26th, 2008 1:11 pm

    Really nice tip, is there something similar on blogger?

  4. burad on May 26th, 2008 5:21 pm

    For blogger you can try http://wolverinex02.googlepages.com/emoticonsforblogger2
    Its actually great. For that you will need to install greasemonkey extension in firefox. It uses latex renderer here http://www.forkosh.com/mimetex.html

  5. burad on May 28th, 2008 11:37 am

    Also for blogger, or for any other site you can try CodeCogs Equation editor

Leave a Reply