When preparing technical documents for the World-Wide Web, there's frequently a need to include equations in the text. Since HTML doesn't provide direct support for mathematical typesetting, equations must be included as inline images. If you use TeX or LaTeX to write conventional documents, you already know how to format equations in those languages. Wouldn't it be nice to painlessly use TeX equations in your Web documents?
If you want to convert an entire LaTeX document into HTML, use LaTeX2HTML, by Nikos Drakos. But if you just want to typeset some equations for a new Web document, it's cumbersome to first write your document in LaTeX, convert it into HTML, then add links and additional functionality in the HTML text. Also, it's nice to be able to control the size of an equation image and the resolution with which it's rendered equation-by-equation; this isn't possible with a bulk document translator such as LaTeX2HTML.
Textogif is a simple Perl program which uses the same software tools employed by LaTeX2HTML to compile individual equations in short LaTeX files into images suitable for embedding in Web documents.
To use textogif, write your equation (or anything else you can typeset with LaTeX) in a file like:
\documentclass[12pt]{article} \pagestyle{empty} \begin{document} \begin{displaymath} \int H(x,x')\psi(x')dx' = -\frac{\hbar^2}{2m}\frac{d^2}{dx^2} \psi(x)+V(x)\psi(x) \end{displaymath} \end{document} |
The "\pagestyle{empty}" is required to avoid generating a huge image with a page number at the bottom. Then (assuming you have all the software prerequisites installed properly), you can simply say:
textogif filenameto compile filename.tex to filename.gif, an interlaced, transparent background GIF file ready to use an an inline image. You can specify the base name, for example, "schrod", rather than the full name of the TeX file ("schrod.tex"), and use wild cards to process multiple files. TeX requires, however, that all files have an extension of ".tex". A sample <img> tag, including the image width and height is printed on standard error, for example:
<img src="schrod.gif" width="508" height="56">Here's what you'll see when you include the image for the equation:
GIF and PNG files created by textogif are interlaced to permit incremental display by browsers which provide that capability, and have a transparent background so they'll look good regardless of the background on which they're placed.
Smaller values for "-res" produce greater smoothing, but at the cost of increased memory and disc space requirements as the image is being generated. If your system's resources are insufficient to create an image, increase the value of "-res" until it can be successfully processed. Larger values of "-res" reduce the antialiasing and yield rougher contours in the text. A value of 1.0 disables antialiasing entirely. Here is the same equation processed with different "-res" settings.
-res 0.25 -res 0.5 -res 1.0
Once you'be downloaded the archive, extract the textogif Perl program from it and place the program somewhere on your program search path. If Perl is installed on your system in a location other than the more or less standard /usr/bin/perl, you'll need to change the first line of textogif accordingly.
- textogif-1.1.gz: Release 1.1 (November 2003)
- textogif-1.0.gz: Release 1.0 (May 1995)
Perl 5.8.0 (4.036 or above should work) TeX 3.14159 (Web2C 7.3.1) LaTeX2e <2000/06/01> (Included with most TeX distributions) dvips dvipsk 5.86 (Included with most TeX distributions) Ghostscript 6.52 (2001-10-20) Netpbm 9.24