I have left Harvard as of July 1, 2008 to take a position at NYU. This website has been cached and left static. Feel free to browse my new website, aka "What the heck is a Clinical Associate Professor?"

05.08.07

Math on the web without TeX?

Posted in LaTeX, PHP, Web at 2:53 pm by leingang

I just found PhpMathPublisher on the web and it looks kind of interesting. The name pretty much describes it: a PHP package that parses a kind of math input and produces image-based output.

Most packages (such as LaTeXRender) along these lines serve as a front end to TeX or LaTeX, then serve up a generated image file. There are some drawbacks to this:

  • TeX and LaTeX are complicated programs with huge distributions, and may not be available to all web programmers
  • because these programs can include files, there’s a potential security leak in allowing all web users to effectively execute TeX code on the server.

PhpMathPublisher has a tex-like syntax but seems to parse the input on its own and use GD to assemble a formula. Here’s the markup:


<m>delim{|}{{1/N} sum{n=1}{N}{gamma(u_n)} - 1/{2 pi} int{0}{2 pi}{gamma(t) dt}}{|} <= epsilon/3</m>

In LaTeX we would write

\left|\frac{1}{N}\sum_{n=1}^n \gamma(u_n) - \frac{1}{2\pi}\int_0^{2\pi} \gamma(t)\,dt\right| \leq \frac{\varepsilon}{3}

to get

\displaystyle\left|\frac{1}{N}\sum_{n=1}^n \gamma(u_n) - \frac{1}{2\pi}\int_0^{2\pi} \gamma(t)\,dt\right| \leq \frac{\varepsilon}{3}

It does get the job done, and the finished product is not so bad.

Blogged with Flock

Comments are closed.