Using LaTeX codes on Drupal is a much talked about topic among mathematicians, statisticians and many other branches of science. DruTeX is a module that is freely available to serve this purpose. However, DruTeX needs latex to be installed on your server, which is rarely the scenario in most cases. Shared hosting providers do not allow you to install LaTeX. In this article, I've discussed my experience about the available solutions to put LaTeX equations on Drupal.
If you want to put mathematical equations on your website but you do not have latex, dvipng, imagemagic installed on your shared hosting server, you will probably search Google with the following questions:
The purpose of this talk is to share my experience with the Internet community (webmaster, managers, forum moderators/admins) who are in search of a way to enabling their users to add mathematical equations in their posts typeset in LaTeX. This talk is not about how to typeset in LaTeX, though. If you are looking for typesetting (i.e., typing) in LaTeX, please search Google and you will find lots of good references. (I find this one to be the most comprehensive yet short guide to LaTeX2E).
What I've found lately:
There are basically four different ways one can put mathematical equations typeset in LaTeX on websites or blogs. These are:
When I wrote this article sometime in 2008, DruTeX was not available for Drupal 6.x. Now it is available. It is an excellent module (probably the best solution available). However, it requires LaTeX, dvipng and ImageMagic or other latex renderer installed on the server, which you won't usually have on a shared hosting account. I've tried JsMath, CodeCogs equation editor and lately Mathfilter based MimeTeX solutions. I will share my experience about each of those.
The beauty of JsMath is describe on the project webpage
It overcomes a number of the shortcomings of the traditional method of using images to represent mathematics: jsMath uses native fonts, so they resize when you change the size of the text in your browser, they print at the full resolution of your printer, and you don't have to wait for dozens of images to be downloaded in order to see the mathematics in a web page
However, I did not find JsMath very effective or efficient for my site. First of all, it took unusually big amount of space on my server (about 30MB). The font installer that comes with the software iteself is 7MB. Also it is really very slow to render the fonts when you visit the page containing equations. I would say that is really very inefficient.
CodeCogs solutions are by far the best among these. They produce really good images of the equations and you dont have to worry about linking those images from your page. All images will be hosted on CodeCogss server. All you need is to go to CodeCogs Web Equation Editor and paste your LaTeX equation in the appropriate box. Then click "Render Equation". If what you typed is correct, it will show you the equation as-it-will-show on your webpage. All necessary html code will also be generated at the botton of that equation editor window. You can copy and past it on your website. But the possible limitation of this method is that you are basically depending on somebody else's server and if, in future, they discontinue this service, you have no way to recover those equation images.
Lastly, Mimetex based solution is very easy one. First, install MimeTex. Download mimetex.zip and then type
unzip mimetex.zip
cc -DAA mimetex.c gifsave.c -lm -o mimetex.cgi
mv mimetex.cgi to your cgi-bin/ directory.
To test before installing drupal module, run http://www.yourdomain.com/cgi-bin/mimetex.cgi?x^2+y^2
If you see
, then mimetex is installed successfully. Please see more details here. MimiTex works nicely with Mathfilter. But Mathfiler has bug in it and please see the discussion at http://drupal.org/node/205994. The solution I got is to remove the argument from line 16 of the mathfilter.module file.
I just removed
may_cache from the following line (line 16 in the mathfilter.module) and that seems to be working for me.
function mathfilter_menu(
may_cache) {
Later a solution has been posted to work around with this and can be found at http://drupal.org/node/205994#comment-1482984
Software that I use:
Both TinyMCE and FCKEditor causes some problem with LaTeX. This may be because I could not set the input filters properly. So, I resorted to BUEditor. If you are using FCKEditor, CodeCogs has a plugin for FCKEditor which enables you to add a button on the menu to launch the equation editor from the editing window.
Results:
This following equation has been created using the web-equation editor provided by CodeCogs. Following is a Box-Cox transformation equation that is widely used to transform nonnormal data into normality by choosing an appropriate
In my opinion, CodeCogs solution produces better quality images than that by the mimetex based solution.
References:
Update:(January 22, 2010)
I've installed Drutex, the latex+dvipng-based solution for putting mathematical equations on Drupal. See the outcome below.
![]() |