ShowMath Applet

A Java Applet for Displaying Mathematical Equation on HTML Pages

October, 1996.

ShowMath is a Java applet developed by Ariel Shamir for displaying mathematical formulas and equations on HTML pages. The applete receives as input a string in (a subset of) LaTeX style syntax, and converts it to displayed mathematical formula inside the HTML page.

The applet is based on a java lexical analayzer: JavaLex Written by Elliot Berk [edited by A. Appel]:

And on a java based LR-parser: java_cup (Author: Scott Hudson [home page] )


This applet relays heavily on one particular symbol font, which I assumed is common and available on all platforms and operating systems. However, it turns out that Netscape on any platform, and appletviewer on unix, cannot find this font or can find only certain sizes, and not a continous range as required by this applet. This of course, damages the performance of the applet and only simple equations such as shown here are viewable. To appreciate the possibilities of this applet you can use appletviewer (for example on Windows platforms) and try the many exampels included in "examples.html" file in the current directory. I hope to try and overcome this problem sometime later.

Some Examples:


The two parameters for the applet are:


I will describe some of the major problems/drawbacks in this applet, with the hope that some day I will find time to fix them and/or enhance the applet to include more features.
  1. The parser is Very sensitive to syntax errors (especialy since I send "space" as a tokens, i.e. spaces count!, and multiple spaces are sent as one space).
  2. To make things worse, there is no error recovery in the parser so any error just stops the parsing.
  3. The subset of LaTeX was chosen mainly according to what characters the common TrueType Symbol font includes, and hopefully your browser can find this type of symbol font and use it, or else... well, there is no point in math equations without any math symbols is there?
  4. Due to some bug (feature?) a small change in font size (39 instead of 40 etc.) might sometimes improve the overall look, so try playing with that until you get a better result (or until I find out what causes this).
  5. Some more features can be added (which means they are not supported in this version):
  6. Overcome symbol font problems in netscape and support different type of fonts (italic etc.)

WebEQ: a similar applet

Someone has drawn my intension to a similar Java applet for showing math on a HTML page (If only I had known previously...). It is called WebEQ. Some notes regarding this are:
  1. Their syntax is based on an HTML3.0 proposal for math, My syntax is taken from LaTeX.
  2. They build a symbol font by using gif files instead of a real font, this means I am not alone in my difficulty of using symbol fonts.
  3. They use only three predefined sizes of fonts in order to display equations, and I use a whole range and calculate the proportional sizes. Therefore they can not display very nicely a long line of symbol-recursion in equations such as:
    \sqrt{\sqrt{sqrt{3}}} a^{b^{c^{d^{f}}}}
    and, they cannot scale the equation continuously!
NEW! NEW! Another web site for LaTeX math inside HTML is: HotEqn

The Source Files

  1. The main program.
  2. LaTeX.lex: The lexical analayzer definition file.
  3. LaTeX.cup: The parser definition file.