, LaTeX renderer

Overview

PHPLatex is quick and dirty PHP script that makes TeX rendering easier.
It was initially made for latex.knobs-dials.com.

Does have a few requirements, though you'll likely meet all of those on modern *nix-with-texlive installations.
Aside from the fact it fundamentally is a bit hackish, it seems to work well enough.

At the core it just invokes latex, dvips, and convert.
And stores the resulting image, so that asking for the same TeX will generate once, then read from disk.
This means you can leave the function call in the PHP, which should make both using TeX on a page
and changing it later a low-brainer, and easy on your resources.

External invocation so is always potentially unsafe in an untrusted environment (the utilities will run as your webserver user).
For a safer but rather more restrictive variation, check the ocaml parser that mediawiki (as in wikipedia) uses.

Released under the GPL. Comments, praise, complaints, bugs, fixes and whatnot are encouraged.
Contact address:

Ideas / requests for comments

This thing fulfils my own needs, so I am not actively working on it. Suggestions are welcome, of course.

I am considerering having it always render higher resolutions to have images be sharper in printing,
although I would have to test whether this can be done elegantly and check that nothing reacts weirdly
(browsers, OS settings, etc.).
If anyone has played with something like that, I welcome your notes.

Download

Examples

<? print texify('wh^{e^{e^{e^{e^{e_{e_e}}}}}}'); ?>

Since you write inside PHP strings, backslashes are interpreted, so double them. Also, PHP wants to interpret dollar characters as $variables, so escape those too (though you can get away with $$ as-is). PHP does not seem to allow anything nicer for either of these cases.

TeX text in HTML text

...should work well enough for normal-sized text. PHPLatex 0.4
has some simple logic that adjusts the HTML vertical offset of the image based on obvious ascenders, descenders
(needs more work and is fiddly at best, but seems to work decently so far).

Colors, Resolution

The default dpi is 90. Capped at 300 to be nice to resources, but you can change that.
The default foreground is black, and background is white.
extraprelude is primarily useful for inclusion of extra packages.
trans controls whether the background color will also be transparent - this is a semi-broken experiment at the moment, though

While you can use any coloring TeX you want, the texify() call specifically lets you set
the text and background colors in RGB (uses the color package).