drupal modules for displaying math on web page

in

There are several modules in drupal that allow you displaying math equations on a web page.

DruTeX: Display mathematics written in LaTeX as images inline with other text, or separately as a downloadable pdf. It appears to be the most complete solution, but you do need to install LaTeX on your server. This becomes an issue for most sites sitting on shared-hosting server.

JsMath for displaying mathematics with TeX
enables the jsMath script for displaying mathematical expressions.
TeX is rendered on the user's browser, this module does not require the installation of any TeX executables on your server.

Mathematics Filter
uses MimeTeX to convert TeX to images directly that are then included in the webpage. This requires you to install the mimeTeX executables on your server. Faster, subset of LaTeX.

TeXfilter : dead?

Since latex program is not available on my hosting server, I skipped DruTeX.

jsMath is very attractive as it uses JavaScript to render TeX which takes the load off server. For busy website, this can be very beneficial. Furthermore, as mentioned by its creator

"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"

Installation was a snap. I just followed the instruction upzipping the module, JsMath package,and fonts, then enable the module and leave all the default settings unchanged. To test it, I entered

x=\frac{-b\pm\sqrt{b^2-4ac}}{2a} with delimiter [math], which is customizable on the setting page. The output is:

[math]x=\frac{-b\pm\sqrt{b^2-4ac}}{2a}[/math]

Looks great! Although there's a noticable delay due to rendering.

The second module I tried is Mathfilter. Installation is also very easy.

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 x^2+y^2, then mimetex is installed successfully.

Now install mathfilter module. The current version seems to be buggy, I changed the code following http://drupal.org/node/188744#comment-619393

Then enable mathfilter for both filtered html and full html under "input format". Now for the same equation, mathfilter (mimetex)'s output is:

x=\frac{-b\pm\sqrt{b^2-4ac}}{2a}.

On mathfilter setting page, there's option for caching the image instead of running mimetex.cgi every time. It's a very nice feature, unfortunately, it might not be functioning properly. A quick look at the source code shows that the module puts the image file in "files/mathfilter" directory. However, I didn't see any image files after I created a test page. "mathfilter" directory was not even created. I manually created that directory, still no effect.

In any case, this is a nice module to have. In my opinion, it  has an advantage over the JsMath module as it is provided as a filter that gives you the flexibility to disable it for certain content types.


Comments

Post new comment

The content of this field is kept private and will not be shown publicly.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Allowed HTML tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd>
  • Lines and paragraphs break automatically.

More information about formatting options

CAPTCHA
This question is for testing whether you are a human visitor and to prevent automated spam submissions.
Image CAPTCHA
Copy the characters (respecting upper/lower case) from the image.

Back to top