Adding MimeTex or MathTex to Dreamhost

Posted: May 31st, 2010 | Author: | Filed under: Dreamhost, Drupal | Tags: , , , , , , , | No Comments »

I use Deamhost for hosting and for 99.9% of the tasks one would face it is great. The only let down is lack of full Latex support as it doesn’t support dvipng.

In the end, I had decided to use Mathtex / Mimetex.
The installation instructions between Mathtex and Mimtex are similiar and straight forward. One thing you have to watch out for is to unzip Mathtex on Dreamhost if you are using a Windows computer. As the C file uses UNIX encoding only, it will give you weird errors like:

mathtex.c:205: error: expected expression before â/â token


mathtex.c: In function âsetpathsâ:
mathtex.c:1697: error: âonvertpathâ undeclared (first use in this function)
mathtex.c:1697: error: (Each undeclared identifier is reported only once
mathtex.c:1697: error: for each function it appears in.)

If you want to fix the above while you are in Windows. Use Notepad++, make sure the encoding is for UNIX, remove the offending key etc setpath and retype it and save. If you have unzip the file on Dreamhost, you shouldnt’ have to go through that step.

In Dreamhost, you have access to latex, dvips and convert. You can use the which command to see where the commands reside.

To compile the file you issue the following (for Dreamhost and it will output PNG files):

cc mathtex.c -DLATEX=\"/usr/bin/latex\" -DDVIPS=\"/usr/bin/dvips\" -DCONVERT=\"/usr/bin/convert\" -DPNG -o mathtex.cgi

Note: \” is the delimiter.

mathtex.cgi will be compiled. You then move it to your cgi-bin directory and change the correct permission. It is ready to be used!

The main difference between mathtex and mimetex is mathtex is quite a bit smaller (240kb vs 980kb) because it requires outside programs. Functionally, they are the same.

Once you have that setup, you can integrate it with Drupal via the Mathematics Filter module. You can then create Latex based math text with the [$ your math expression here $] tag. I find the tag conflicts with HTML Filter and other filters, so it is wise to create a separate Input Format with MathFilter input method and only allow authenticated user to use it.