kiat has asked for the wisdom of the Perl Monks concerning the following question:

Hi all,

Is there a perl module that's well-suitable to creating images of fractions (e.g. 2/9, 5/14) on-the-fly? These will be displayed on web pages. Using the html tags superscript (sup) and subscript (sub) doesn't give very good results.

Thanks in advance :)

Replies are listed 'Best First'.
Re: perl module for math representation...
by tachyon (Chancellor) on Apr 15, 2004 at 00:46 UTC

    There is the way cool GPL mimetex.cgi which essentially takes LaTeX format input and converts it to a gif on the fly. It will do simple fractions or entire equations just as easily. You can use if off the command line as well Click Here to see just how powerful it is and a sample query LaTeX query string.

    For what you asked for the only syntax you need to learn is as easy as 1+\frac{2}{2}+\frac{3}{3}=3 :-)

    Try it out in the test widget here

    cheers

    tachyon

      Thanks tachyon!

      That looks promising! I know a little latex syntax and if I can make use of mimetex.cgi to produce mathematical notations, it would be great.

      But the problem is, I downloaded mimetex.zip and saw that I need to compile it - I don't have a compiler. Is mimetex.cgi the only file that's needed. I'm trying to search the Net for one...

Re: perl module for math representation...
by kvale (Monsignor) on Apr 15, 2004 at 00:40 UTC
    I don't know of any perl modules for this specifically. Probably the most portable way is to use tables:
    <div class="math"> <table class="fraction" cellpadding="0" cellspacing="0" > <tr> <td align="center" class="numerator"><i>Aa</i><sub>0</sub><i>qp</i +> </td></tr> <tr> <td align="center" class="divider">--------- </td></tr> <tr> <td align="center" class="denominator"><i>b</i><sup>2</sup> </td></tr> </table> </div>
    which looks like
    Aa0qp
    ---------
    b2

    -Mark