true, // return web page CURLOPT_HEADER => true); // return headers $ch = curl_init( $url ); //curl_setopt_array( $ch, $options ); curl_setopt( $ch, CURLOPT_RETURNTRANSFER, true ); curl_setopt( $ch, CURLOPT_HEADER, true ); $gif = curl_exec( $ch ); $errno = curl_errno( $ch ); $error = curl_error( $ch ); //$info = curl_getinfo( $ch ); curl_close( $ch ); //echo '
url= ',$url,'
',"\n"; //echo '
gif=
',$gif,'
',"\n"; if ( $errno == 0 ) { $fields = explode("Vertical-Align:",$gif); $vfield = trim($fields[1]); $fldlen = strspn($vfield,"+-0123456789"); $valign = substr($vfield,0,$fldlen); } else { echo 'verticalalign> errno ',$errno,' = ',$error,'

',"\n"; } return $valign; } function mimetextag( $label, $expression ) { global $mimetexurl; $valign = verticalalign($expression); $url = $mimetexurl . $expression; //echo ' valign=',$valign,' ',"\n"; echo ''; echo '',$expression,''; echo '', "\n"; } ?>

The hardware and bandwidth for this mirror is donated by dogado GmbH, the Webhosting and Full Service-Cloud Provider. Check out our Wordpress Tutorial.
If you wish to report a bug, or if you are interested in having us mirror your free-software or open-source project, please feel free to contact us at mirror[@]dogado.de.



m i m e T e X   m a n u a l
( for mimeTeX version )
Click for:  LaTeX tutorial
mimeTeX QuickStart
mimeTeX Source Listing
download mimeTeX

more_examples...
This page discusses mimeTeX, a program that displays math on the web.
(See Writing Math on the Web for a more general discussion.)

Copyright © 2002-2012, John Forkosh Associates, Inc.
email: john@forkosh.com



        C o n t e n t s        
- - - T u t o r i a l - - - - - - - - - - - - - - - - - R e f e r e n c e - - - - - - - - - - - - - -
  (I) Introduction  
a. Quick Start
b. Examples
c. Scripts&Plugins
d. GPL License
  (II) Building mimeTeX  
a. Compile
b. Install
c. Compile Options
d. Command Line
  (III) Syntax Reference  
a. Math & White Space
b. Symbols, Sizes, Modes
c. Delimiters
d. Accents, Arrows, etc.
e. \begin{array}
f. \picture( ){ }
g. Other Commands
h. Other Exceptions
i. Errors and Messages
    (IV) Appendices    
a. Fonts
b. make_raster()
c. gifsave.c
  Remarks  

This page contains more information than you'll probably need to read. If you follow the Installation and Usage Summary below, try installing mimeTeX immediately. Or continue reading until you feel comfortable trying to install mimeTeX. Prerequisites are: some knowledge of your OS's shell, of installing cgi's, of LaTeX.
        "Computers are like Old Testament gods: lots of rules and no mercy."
        –– Joseph Campbell, The Power of Myth   (Doubleday 1988, page 18)

- - - - - - I n s t a l l a t i o n   a n d   U s a g e   S u m m a r y - - - - - -
      Installation:     Download mimetex.zip and then type
    unzip mimetex.zip
    cc -DAA mimetex.c gifsave.c -lm -o mimetex.cgi
Now just mv mimetex.cgi to your cgi-bin/ directory,
set permissions as necessary, and you're all done.
 
Usage:     To see the image
   
just write the tag
    <img src="/cgi-bin/mimetex.cgi?
    x=\frac{-b\pm\sqrt{b^2-4ac}}{2a}">

(I) Introduction  

MimeTeX, licensed under the gpl, lets you easily embed LaTeX math in your html pages. It parses a LaTeX math expression and immediately emits the corresponding gif image, rather than the usual TeX dvi. And mimeTeX is an entirely separate little program that doesn't use TeX or its fonts in any way. It's just one cgi that you put in your site's cgi-bin/ directory, with no other dependencies. So mimeTeX is very easy to install.
        Just download mimetex.zip and then type
            unzip mimetex.zip
            cc –DAA mimetex.c gifsave.c –lm –o mimetex.cgi
        Now just mv mimetex.cgi to your cgi-bin/ directory,
        set permissions as necessary, and you're all done.

And mimeTeX is equally easy to use:   just place an html <img> tag in your document wherever you want to see the corresponding LaTeX expression.
        For example, the <img> tag
            <img  src="../cgi-bin/mimetex.cgi?f(x)=\int_{-\infty}^xe^{-t^2}dt" >
        immediately generates the corresponding gif image on-the-fly,
            displaying     wherever you put that tag.

MimeTeX doesn't need intermediate dvi-to-gif conversion, and it doesn't create separate gif files for each converted expression. (But you can enable image caching with mimeTeX's   -DCACHEPATH=\"path/\"   compile option.)   And there's no inherent need to repeatedly write the cumbersome <img> tag illustrated above. You can write your own wrapper scripts, discussed below, around mimeTeX to simplify the notation.

Alternative solutions...

MimeTeX's benefit over similar math-on-the-web solutions is, as mentioned above, its easy installation. But if that's not a problem for you, and if your site's server already has a LaTeX distribution installed, and suitable image conversion utilities like ImageMagick, then you may prefer to look at a math rendering script like latexrender which uses LaTeX to create higher quality images than mimeTeX produces. For comparison, , with arbitrary mean and standard deviation , and at mimeTeX's next larger font size, looks like

latexrender mimeTeX
 

Similar LaTeX-based solutions that you may want to look at are mathtran, textogif and gladTeX. Additional discussion and several more links are at www.tug.org/interest.html and in the tex-faq.

For example, mathtran is a public LaTeX web service that's particularly easy to use by following these simple instructions. In the <head> of your html page, place the tag
    <script type="text/javascript"
        src="http://www.mathtran.org/js/mathtran_img.js"></script>
and in the <body>, wherever you want to see latex images, place tags like
    <img alt="tex:any latex math expression">
For comparison,
    <img alt="tex: f(x) = \frac1{\sigma\sqrt{2\pi}}
    \int_{-\infty}^x e^{-\frac{(t-\mu)^2}{2\sigma^2}}dt">
looks like

mathtran mimeTeX
unavailable
 

You may now want to browse the additional Examples below before proceeding, to make sure mimeTeX suits your needs before you spend more time learning to use it.

(Ia) Quick Start  

MimeTeX is as TeX-like as possible (though not 100% compliant), and you must already be familiar with LaTeX math markup to use it. If you're not, many online LaTeX turorials are readily available. You may also want to browse Andrew Roberts' Latex Math I and Latex Math II, or my own LaTeX math tutorial. Then, instead of continuing to read this page, you can just Submit any LaTeX math expression you like in the Query Box below. I've started you out with a little example already in the box, or you can Click any of the Examples below to place that corresponding expression in the Query Box.

Meanwhile, here are just a few quickstart tips for Submitting your own mimeTeX expressions in the Query Box below:

Now enter your own LaTeX expression, use the sample provided, or Click any of the Examples. Then press the Submit button, and mimeTeX's rendering should be displayed in the little window immediately below it.

First enter your own LaTeX expression, or Click any example...

     
Now click Submit to see it rendered below...

You should see     if you submit the sample expression already in the box. Or see error messages whenever an unexpected image is displayed instead.   And (as discussed above) the <img> tag to embed this same integral anywhere in your own document is
            <img  src="../cgi-bin/mimetex.cgi?f(x)=\int_{-\infty}^xe^{-t^2}dt" >

(Ib) Examples  

Here are various additional random examples further illustrating mimeTeX's features and usage. To see how they're done, Click any one of them to place its corresponding expression in the Query Box above. Then press Submit to re-render it, or you can edit the expression first to suit your own purposes.

(1)                    
(2)
(3)
(4)
solution for quadratic

definition of derivative
(5) illustrating \frac{}{} for continued fraction
(6) illustrating \left\{...\right.
and note the accents
(7) \overbrace{}^{} and \underbrace{}_{}
(TeXbook page 181, Exercise 18.41)
(8)

demonstrating \begin{array}'s dashed lines
(9) Block diagonal form using nested \begin{array}'s.
Also, note rows aligned across all three arrays.
(10) using \begin{eqnarray} to align equations
(11) commutative diagram using \begin{array}
(12) mimeTeX \picture(size){pic_elems} "environment", illustrating the image charge - q for a grounded conducting sphere of radius a with a charge q at distance r > a outside it.
(13) \picture "environment" illustrating the surface polarization charge induced by a uniform electric field. Inside the slab of material, the volume polarization charge clearly vanishes.

The little dipole image is drawn only once, then multiput across two columns, and then that result is further multiput down the rows. MimeTeX \picture's can be used as picture elements in other pictures, nested to any level. The image at left is picture-in-picture-in-picture.

(Ic) Scripts & Plugins  

Some useful scripts that automatically construct mimeTeX <img> tags for you are illustrated below. And you can also write your own scripts to simplify the HTML notation required to incorporate mimeTeX math images in your pages.

mimeTeX plugins...

The following javascript snippet (based on mathtran's mathtran_img.js) lets you just write   <img alt="mimetex:c=\sqrt{a^2+b^2}">   wherever you want to see  

   <script type="text/javascript">
   <!--
   // Create a namespace to hold variables and functions
   mimetex = new Object();
   // Change this to use your server
   mimetex.imgSrc = "http://www.yourdomain.com/cgi-bin/mimetex.cgi?";
   // Transform the whole document: add src to each img with
   // alt text starting with "mimetex:", unless img already has a src.
   mimetex.init = function () {
       if (! document.getElementsByTagName) return;
       var objs = document.getElementsByTagName("img");
       var len  = objs.length;
       for (i=0; i<len; i++) {
          var img = objs[i];
          if (img.alt.substring(0,8) == 'mimetex:')
             if (!img.src) {
                var tex_src = img.alt.substring(8);
                img.src = mimetex.imgSrc + encodeURIComponent(tex_src);
                // Append TEX to the class of the IMG.
                img.className +=' tex'; }
          }
       mimetex.hideElementById("mimetex.error"); }
   // Utility function
   mimetex.hideElementById = function (id) {
       var obj = document.getElementById(id);
       if (obj) obj.style.display = 'none'; }
   // resolve a cross-browser issue (see CBS events)
   mimetex.addEvent = function (obj, evType, fn, useCapture) {
       if (obj.addEventListener) { //For Mozilla.
           obj.addEventListener(evType, fn, useCapture);
           return true; }
       else if (obj.attachEvent) { //For Internet Explorer.
           var r = obj.attachEvent("on"+evType, fn);
           return r; }
       }
   // Initialize after entire document is loaded
   mimetex.addEvent(window, 'load', mimetex.init, false);
   -->
   </script>

Bulletin boards, wikis, etc, can also incorporate mimeTeX images with short scripts. For example, if you're using phpBB2, then Jameson contributed the following typical one-line mod that lets you write [tex] c=\sqrt{a^2+b^2} [/tex] to obtain the same  image illustrated above 

   #--------[open]-----------------------------------------------------
     /includes/bbcode.php
   #--------[find]-----------------------------------------------------
     // Remove our padding from the string..
   #--------[before, add]----------------------------------------------
     $text = preg_replace('/\[tex\](.*?)\[\/tex\]/ie',
     "'<img src=\"/cgi-bin/mimetex.cgi?'.rawurlencode('$1').'\" align=\"middle\" />'",
     $text);

If you're using phpBB3, then no mod is even needed. Just click Postings from the Administrator Control Panel, and add the custom BBCode [tex]{TEXT}[/tex]   with the HTML replacement <img src="/cgi-bin/mimetex.cgi?{TEXT}" align=middle>

Similarly, PmWiki also has a mimeTeX plugin that lets you just write {$ f(x)=\int_{-\infty}^xe^{-t^2}dt $} to obtain that same image.   Several other packages also have similar mimeTeX plugins:

 Package      Plugin  
PmWiki   mimeTeX plugin
MediaWiki   "mimeTeX alternative"
PunBB   mimeTeX plugin
Movable Type   mimeTeX plugin
WordPress   mimeTeX plugin
Joomla   mimeTeX plugin
Mambo   "mimeTeX bot"

Please note: If you're writing your own plugin for mimeTeX, please don't write php code using system( ), or any other shell escape mechanism, just to cache images. Use mimeTeX's   -DCACHEPATH=\"path/\"   compile option instead. system( ) raises security issues, either real ones if used carelessly, or just in the minds of system administrators. Either way, I've received many emails from people unable to use mimeTeX because of unnecessary system( ) calls prohibited by security-conscious sysadmins. MimeTeX itself poses minimal risk when used as illustrated above, but you're responsible for any plugin/wrapper script you write around it.

Vertical alignment...

An image like doesn't look as good as the same image that's vertically aligned with your surrounding text. Along with several standard HTTP header fields, mimeTeX also emits a special   Vertical-Align: –nn   header, where nn is the number of pixels (usually negative as illustrated) needed for a   style="Vertical-Align: –nn px"   attribute in the <img> tag used to render your expression. This Vertical-Align: header is obtained by placing the directive  \depth  anywhere in your expression.

But mimeTeX's special Vertical-Align: header is unrecognized and ignored by your browser. You have to get the header, interpret it, and write the corresponding <img> tag. The only feasible way to do all this is using a scripting language, as illustrated by the following, rather naive, php code

   <?php
   $mimetexurl = "http://www.yourdomain.com/cgi-bin/mimetex.cgi?";
   function verticalalign( $expression ) {
      global $mimetexurl;
      // note: curl_init() stops at the first whitespace char in $url argument
      $expression = ereg_replace(" ","~",$expression); // so remove whitespace
      $url     = $mimetexurl . "\depth~" . $expression;
      $valign  = "0";
      $ch      = curl_init( $url );
      curl_setopt( $ch, CURLOPT_RETURNTRANSFER, true );
      curl_setopt( $ch, CURLOPT_HEADER, true );
      $gif     = curl_exec( $ch );
      $errno   = curl_errno( $ch );
      curl_close( $ch );
      if ( $errno == 0 ) {
        $fields = explode("Vertical-Align:",$gif);
        $vfield = trim($fields[1]);
        $fldlen = strspn($vfield,"+-0123456789");
        $valign = substr($vfield,0,$fldlen); }
      return $valign;
      }
   function mimetextag( $expression ) {
      global $mimetexurl;
      $valign = verticalalign($expression);
      $url    = $mimetexurl . "\depth~" . $expression;
      echo ' <img src="',$url,'" ';
      echo ' style="Vertical-Align:',$valign,'px" ';
      echo ' alt="" border=0>', "\n";
      }
   ?>

Now you can write   <?php mimetextag('\frac12\left(a^2+b^2\right)'); ?> wherever you want to see correctly aligned. Note that the php code automatically prepends  \depth  to your expression for you. (Also note that this code calls mimeTeX twice to render each expression, once to get the Vertical-Align: header and build an <img> tag, and then again to render that tag. If you're a good php programmer and write better code, please email me a copy.)

If you're using mimeTeX's   -DCACHEPATH=\"path/\"   compile option, you can request that all images be cached with Vertical-Align: headers, whether or not they contain the \depth directive. Prefix your path/ with a leading % and write   -DCACHEPATH=\"%path/\"   instead. That leading % won't become part of your cache directory's path/, but it will signal mimeTeX to cache headers along with each image. (In this case, the directive  \nodepth  suppresses mimeTeX's header caching for that image.)

(Id) GPL License  

"My grandfather once told me there are two kinds of people:
    Those who do the work and those who take the credit.
    He told me to try to be in the first group; there was much less competition.
"
Indira Gandhi, the late Prime Minister of India

MimeTeX's copyright is registered by me with the US Copyright Office, and I hereby license it to you under the terms and conditions of the GPL. There is no official support of any kind whatsoever, and you use mimeTeX entirely at your own risk, with no guarantee of any kind, in particular with no warranty of merchantability.

By using mimeTeX, you warrant that you have read, understood and agreed to these terms and conditions, and that you possess the legal right and ability to enter into this agreement and to use mimeTeX in accordance with it.

Hopefully, the law and ethics regarding computer programs will evolve to make this kind of obnoxious banter unnecessary. In the meantime, please forgive me my paranoia.

To protect your own intellectual property, I recommend (both are pdf) Copyright Basics from The Library of Congress, in particular Circular 61, Copyright Registration for Computer Programs. Very briefly, download Form TX and follow the included instructions. In principle, you automatically own the copyright to anything you write the moment it's on paper. In practice, if the matter comes under dispute, the courts look _very_ favorably on you for demonstrating your intent by registering the copyright.

(II) Building mimeTeX  


Very quickly   ---   download mimetex.zip and then type
unzip mimetex.zip
cc -DAA mimetex.c gifsave.c -lm -o mimetex.cgi
      Now mv mimetex.cgi to your cgi-bin/ directory, and you're all done.      
Read the rest of this section for more detailed information.

I've built and run mimeTeX under Linux and NetBSD using gcc. The source code is ansi-standard C, and should compile and run under all environments without change. Instructions below are for Unix. Modify them as necessary for your particular situation (note the -DWINDOWS switch if applicable).

(IIa) Download and Compile  

The steps needed to download and compile mimeTeX are

That's all there is to compiling mimeTeX. Several other optional compile-line options available for mimetex.c are discussed below.

Immediately after compiling mimeTeX, test your new executable by typing   ./mimetex.cgi "x^2+y^2"   from the Unix shell (or   mimetex "x^2+y^2"   from the Windows Command Prompt), which should emit two "ascii rasters" something like the following

Ascii dump of bitmap image...           Hex dump of colormap indexes...
...........**....................**...  ..........1**1...................1**1..
..........*..*......*...........*..*..  ..........*23*......*............*23*..
.............*......*..............*..  .............*......*...............*..
....****.....*......*.....*..*.....*..  ...1****....2*......*.....2*..*....2*..
...*.*.*....*.......*....**..*....*...  ...*.*.*...1*.......*.....**..*...1*...
.....*.....*.*..********..*..*...*.*..  ....1*1...2*.*..********..3*..*..2*.*..
.....*....****......*.....*..*..****..  ....2*2...****......*......*12*..****..
..*.*.*.............*.....*.*.........  ..*.*.*.............*......*.*2........
...****.............*.....***.........  ..1****.............*......***.........
....................*.......*.........  ....................*........*.........
.........................*.*..........  ..........................*.*1.........
.........................**...........  ..........................**1..........
                                        The 5 colormap indexes denote rgb vals...
                                        .-->255  1-->196  2-->186  3-->177  *-->0

(The right-hand illustration shows asterisks in the same positions as the left-hand one, along with anti-aliased grayscale colormap indexes assigned to neighboring pixels, and with the rgb value for each index.) Just typing ./mimetex.cgi without an argument should produce ascii rasters for the default expression f(x)=x^2. If you see these two ascii rasters then your binary's good. Otherwise, you must find and fix the problem before proceeding.

(IIb) Install  

Once you've successfully tested mimetex.cgi from the Unix shell (or mimetex.exe from the Windows Command Prompt), the steps needed to install mimeTeX are

Immediately after installing mimeTeX, test your new mimetex.cgi by typing a url into your browser's locator window something like
        http://www.yourdomain.com/cgi-bin/mimetex.cgi?x^2+y^2
which should display     in the upper-left corner of your window, just like clicking this link does, which tests my mimetex.cgi,
        http://www.forkosh.com/cgi-bin/mimetex.cgi?x^2+y^2
If you see the same     image from the yourdomain link, then you've completed a successful mimeTeX installation.

If you don't see the image, then your installation failed. If your earlier post-compilation "ascii raster" test succeeeded, then the problem is probably some server-specific installation requirement. First make sure you installed mimetex.cgi in the correct cgi-bin/ directory, set the correct chmod permissions, and typed the correct url into your browser's locator window. Then contact your system administrator or ISP, and ask how to install cgi programs on your server.

After you've successfully installed mimeTeX, and both preceeding tests have succeeded, you can optionally "regression test" all mimeTeX features as follows:

That's all there is to installing mimeTeX.

.

(IIc) Additional Compile-Line Options  

In addition to -DAA or -DGIF or -DXBITMAP (along with -DWINDOWS when necessary) on the mimetex.c compile line, as discussed above, you may also optionally include the following -D switches, whose functionality is discussed below.

-DAA
As already discussed, -DAA turns on anti-aliasing. It also sets default values for individual anti-aliasing parameters discussed below. If you specify -DAA then you needn't specify the individual parameters unless you want to override the defaults.
      Anti-aliasing can't be applied to mime xbitmaps, so don't specify -DAA if you also specify -DXBITMAP.
      And mimeTeX's anti-aliasing only works well on white (or light gray) backgrounds. Your html file probably contains a <body> tag of the form <body bgcolor="#ffffff" text="#000000"> which specifies black text on a pure white background. The background can be grayed down to maybe bgcolor="#e7e7e7", but much darker will begin to show white rings around mimeTeX's anti-aliased characters. This page is displayed using bgcolor="#ffffff".
-DCENTERWT=n
-DADJACENTWT=j
-DCORNERWT=k
MimeTeX currently provides a lowpass filtering algorithm for anti-aliasing, which is applied to the existing set of bitmap fonts. This lowpass filter applies weights to neighboring pixels. The defaults weights are CENTERWT=8, ADJACENTWT=2 and CORNERWT=1, which you can adjust to control anti-aliasing.
-DCACHEPATH=\"path/\"
This option saves each rendered image to a file in directory path/, which mimeTeX reads rather than re-rendering the same image every time it's given the same LaTeX expression. Sometimes mimeTeX disables caching, e.g., expressions containing \input{ } are re-rendered since the contents of the inputted file may have changed. If compiled without -DCACHEPATH=\"path/\" mimeTeX always re-renders expressions. This usually isn't too cpu intensive, but if you have unusually high hit rates then image caching may be helpful. The path/ is relative to mimetex.cgi, and must be writable by it. Files created under path/ are named filename.gif, where filename is the 32-character MD5 hash of your LaTeX expression.
      If you're also using mimeTeX's Vertical-Align: feature, prefix your path/ with a leading % and write   -DCACHEPATH=\"%path/\"   instead. That leading % won't become part of your cache directory's path/, but it will signal mimeTeX to cache headers along with each image. Otherwise, the Vertical-Align: information is lost, and attempts to align cached images will fail.
      When caching a new image, mimeTeX also updates the file path/mimetex.log containing a timestamp, filename and LaTeX expression for each new file created. A sample entry looks like
---------------------------------------------------------------------
2008-09-07:11:29:53am            f8ccc8dd93c8eeb1d9c40b353ef781e0.gif
\LARGE x=\frac{-b\pm\sqrt{b^2-4ac}}{2a}
---------------------------------------------------------------------
-DDEFAULTSIZE=n
MimeTeX currently has eight font sizes numbered 0-7, and always starts out in DEFAULTSIZE, whose default value is 3. Specify -DDEFAULTSIZE=2 on the compile line if you prefer mimeTeX to start in default size 2, etc.
-DDISPLAYSIZE=n
By default, operator limits like \int_a^b are rendered \textstyle at font sizes \normalsize and smaller, and rendered \displaystyle at font sizes \large and larger. This default corresponds to -DDISPLAYSIZE=3, which you can adjust; e.g., -DDISPLAYSIZE=0 always defaults to \displaystyle, and 99 (or any large number) always defaults to \textstyle. Note that explicit \textstyle, \displaystyle, \limits or \nolimits directives in an expression always override the DISPLAYSIZE default.
-DGAMMA=gammacorrection
Applies gammacorrection to antialiased gif images. Default is 1.25 (rather than the standard 2.2). Specify 0.0 to turn off gamma correction (1.0 makes no gamma correction but doesn't actually turn it off).
-DINPUTOK
To enhance mimeTeX's security, the \input{ } command is disabled by default when you compile mimeTeX. Note that the \counter and \environment commands are also disabled by default, and -DINPUTOK enables all three commands simultaneously. (Compile mimeTeX with -DCOUNTEROK to enable only \counter, or with -DENVIRONOK to enable only \environment.)
      Compiling mimeTeX with the -DINPUTOK switch enables \input{ } for all users, subject only to your -DPATHPREFIX restrictions, discussed below. And the following two switches give you additional control over \input{ }'s usage...
-DINPUTPATH=\"path\"       -or-
-DINPUTPATH=\"path1,path2,etc\"
Permits \input{filename} for specific filename's, even when the \input{ } command is otherwise disabled (for security).
      If INPUTPATH is defined, mimeTeX performs a case-insensitive test of \input{ }'s filename argument, to verify that it contains the authorized 'path' as a substring.
      If given several 'path's (second form) then filename must contain either 'path1' or 'path2', or etc, as a (case-insensitive) substring.
      If filename doesn't contain a substring matching any of these path(s), then mimeTeX emits an error message image instead of reading filename.
-DINPUTREFERER=\"domain\"       -or-
-DINPUTREFERER=\"domain1,domain2,etc\"
Permits \input{ } for users from specific domain's, even when the \input{ } command is otherwise disabled (for security).
      If INPUTREFERER is defined but INPUTOK is not defined, then mimeTeX performs a case-insensitive test of the user's HTTP_REFERER environment variable, to verify that it contains the authorized 'domain' as a substring.
      If given several 'domain's (second form) then HTTP_REFERER must contain either 'domain1' or 'domain2', or etc, as a (case-insensitive) substring.
      If HTTP_REFERER doesn't contain a substring matching any of these domain(s), then mimeTeX renders an error message image instead of reading filename.
      Finally, if HTTP_REFERER is not found as an environment variable, then mimeTeX renders the same error message image.
-DNEWCOMMANDS=\"newcommands.h\"
LaTeX-like \newcommand's are available in mimeTeX, via the following facility to help you define your own "new commands" during compilation. Edit a file named newcommands.h (or any filename you specify between \"...\"'s with the -DNEWCOMMANDS=\"filename\" switch). For newcommands _without_ arguments, your file should contain one or more lines like the following examples:
{ "\\iint",  NULL, "{\\int\\int}" },
{ "\\rightleftharpoons",NULL,"{\\rightharpoonup\\atop\\leftharpoondown}" },
{ "\\ldots", NULL, "{\\Large.\\hspace1.\\hspace1.}" },
{ "\\cr",    NULL, "\\\\" },
{ "\\neq",   NULL, "{\\not=}" },
For newcommands _without_ arguments, as illustrated above, the general form of each line in your file should be   { "\\command", NULL, "{replacement}" },     Don't forget a comma at the end of every line, and write a double backslash \\ between quotes "...\\..." wherever you actually want a single backslash \. The only effect of the above examples (without arguments) is simple string substitution, i.e., every occurrence of \command is replaced by {replacement}. Note that the { }'s surrounding replacement aren't required, but are usually a good idea (the case of \cr illustrated above is one exception, where { }'s would defeat the purpose).
    To define newcommands _with_ arguments, change the NULL after the \\command to define your command's arguments as illustrated by the following example:
{ "\\lvec", "2n", "#2_1,\\cdots,#2_{#1}" },
In this case the NULL has been replaced by "2n" (note the mandatory surrounding quotes "..."). This example corresponds to the similar one discussed in TLC2 on page 845. The first character inside the "..."s is   2   indicating the number of arguments, which may be 1 thru 9. If there are no subsequent characters followng this one, then all arguments are mandatory, enclosed in { }'s as usual. Otherwise, any subsequent characters signal that the first argument is optional, enclosed in [ ]'s if given. And these subsequent characters comprise the first argument's default value if it's not explicitly given. The illustrated example's first argument is optional with default value   n   as shown. In this case that's just a single character, but you can write any length default you like.
    To see many additional examples, search for the uppercase string NEWCOMMANDS in mimetex.c, and look below that. All the above examples are already there.
-DNOREFMAXLEN=n
The environment variable HTTP_REFERER identifies the domain a request originates from. If HTTP_REFERER is not defined, then NOREFMAXLEN is the maximum length query string permitted from unidentified domains. It defaults to 9999, i.e., any query string is permitted, since mail and various other legitimate programs often don't supply an HTTP_REFERER. See -DREFERER and -DREFLEVELS below for further discussion, and also see -DNOREFSAFELEN immediately below.
-DNOREFSAFELEN=n
If you compile mimeTeX with either the -DREFERER or -DREFLEVELS switch (discussed below), then the default NOREFMAXLEN value 9999 is replaced by the (usually much shorter) NOREFSAFELEN value whose default is 24.
-DOPAQUE
By default, mimeTeX renders gif images with black symbols on a transparent white background. Defining OPAQUE renders images on an opaque background instead.
-DPATHPREFIX=\"path/\"
The \input{ } and \counter{ } commands discussed below require filename arguments which, by default, point to files residing in the same cgi-bin/ directory as your mimetex.cgi. Moreover, for security, absolute paths with leading /'s or \'s, and paths with ../'s or ..\'s, are not permitted. Instead, compile mimetex with PATHPREFIX defined as path/ if you want input files in some other directory. And make sure your path/ ends with / (or with \ for Windows).
-DPLUSBLANK       -or-
-DPLUSNOTBLANK
mimeTeX receives your LaTeX math expression as a url query string, in which blank spaces are often encoded as %20 or as plus signs +, and where actual plus signs are often encoded as %2B. But these conventions aren't always respected, and even when they are blank spaces may be either %20 or +. The only ambiguity for mimeTeX is whether or not to translate plus signs + back to blank spaces.
      If you know how your applications behave, then define PLUSBLANK to always translate plus signs + to blank spaces, or define PLUSNOTBLANK to never translate.
      Otherwise, if you define neither, mimeTeX applies some common-sense rules to decide whether or not to translate. These usually work, but can't be guaranteed. If your query string contains actual blank spaces or blanks encoded as %20, then plus signs + aren't translated. Otherwise, if your query string contains %2B, then plus signs + are translated. If neither %20 nor %2B, or both %20 and %2B, occur in your query string, then the situation is ambiguous. In this case, if mimeTeX finds two or more plus signs ++ with no intervening space, then they're translated; otherwise they're not.
-DREFERER=\"domain\"       -or-
-DREFERER=\"domain1,domain2,etc\"
Blocks mimeTeX requests from unauthorized domains that are using your mimetex.cgi (hence your server's resources) without permission.
      If compiled with -DREFERER, then mimeTeX performs a case-insensitive test of the environment variable HTTP_REFERER to verify that it contains the authorized 'domain' as a substring. For example, if -DREFERER=\"\",
      If given several 'domain's (second form) then HTTP_REFERER must contain either 'domain1' or 'domain2', or etc, as a (case-insensitive) substring.
      If HTTP_REFERER doesn't contain a substring matching any of these domain(s), then mimeTeX emits the error message image

instead of the requested image. You can manually modify this invalid_referer_msg, which is msgtable[0] defined immediately above function main(), to personalize the error message displayed for your own site.
      Finally, if you specify -DREFERER (or -DREFLEVELS discussed immediately below) but HTTP_REFERER is not found as an environment variable, then mimeTeX correctly generates images whose QUERY_STRING's contain 24 or fewer characters. For 25 or more characters, mimeTeX generates an error. See -DNOREFMAXLEN and -DNOREFSAFELEN above to change the 24 limit.
-DREFLEVELS=n       -or-
-DNOREFCHECK
Besides -DREFERER discussed immediately above, mimeTeX can block requests from HTTP_REFERER's that don't match your HTTP_HOST, i.e., from pages on different servers than your mimetex.cgi image.
      The default value of REFLEVELS is 3, meaning the topmost three levels of HTTP_REFERER and HTTP_HOST must match. For example, phy.cam.ac.uk matches math.cam.ac.uk because they share the same topmost three levels cam.ac.uk. So a page installed at the physics department can use a mimetex.cgi installed at the math department. If you always want a complete match, compile mimeTeX with -DREFLEVELS=99 or any large number. If HTTP_REFERER is not found, then the same 24 character limit discussed immediately above remains in effect.
      To completely disable the REFLEVELS check, compile mimeTeX with -DNOREFCHECK (or with -DREFLEVELS=0). Or, if you supply a specific -DREFERER list of authorized domains, as discussed immediately above, then the REFLEVELS check is automatically disabled.
-DSECURITY=n
This is essentially a "paranoid" setting that defaults to a high value 999, which inhibits some optional logging activity. -DCACHEPATH=path/ isn't affected, since you're explicitly supplying a path/ you want files written to. But, for example, you must set -DSECURITY=5 (or less) to permit the \counter command to create a new counter file. A malicious user could conceivably flood your file system by submitting zillions of \counter{filename} commands to mimeTeX, each with a different filename.
-DSMASHMARGIN=n       -or-
-DNOSMASH
TeX typically renders an expression like \frac12\int_{a+b+c}^{d+e+f}g(x)dx as . MimeTeX tries to remove extra whitespace, rendering the same expression as instead. Compile with -DNOSMASH if you prefer the typical TeX behavior as mimeTeX's default. Or, to adjust the minimum number of pixels between smashed symbols (default is 3), compile with -DSMASHMARGIN=n. See Smash for further discussion.
-DWARNINGS=n       -or-
-DNOWARNINGS
If an expression submitted to mimeTeX contains an unrecognzied escape sequence, e.g., "y=x+\abc+1", then mimeTeX generates a gif image containing an embedded warning in the form "y=x+[\abc?]+1". Or, if an expression contains an unrecognized character, i.e., one for which mimeTeX has no corresponding bitmap, then the embedded warning is [?]. If you want these warnings suppressed, either -DWARNINGS=0 or -DNOWARNINGS on the compile line tells mimeTeX to treat unrecognized/undisplayable input as white space.
-DWHITE
MimeTeX usually renders black symbols on a white background. This option renders white symbols on a transparent black background instead (or on an opaque black background when combined with -DOPAQUE ).

Advertising switches...

The next three switches set up a mimeTeX web service that embeds advertising messages along with rendered images.

–DADFREQUENCY=0
If ADFREQUENCY is defined as a positive number n, then one request out of every n submitted to mimeTeX is randomly selected to be displayed along with a pre-defined "advertisement". For example, if your expression is   \large\int_0^xe^{-x^2}dx,   then the default advertisement displays
          instead of just    
See the –DADVERTISEMENT switch below for instructions to define your own advertisement replacing my default.
–DHOST_SHOWAD=\"\\000\"
Advertisement messages are usually displayed randomly, in one request to mimeTeX out of every n, as defined by the –DADFREQUENCY switch above. But if a HOST_SHOWAD string is also defined, then advertisements are only displayed when mimeTeX is running on a host whose HTTP_HOST (or SERVER_NAME) environment variable contains that string. For example, –DHOST_SHOWAD=\"mathsite\" displays advertisements on www.mathsite.com but never on www.mathhouse.com . The default HOST_SHOWAD value is an empty string, which displays advertisements on any host.
–DADVERTISEMENT=\"filename\"
To define your own advertisement, replacing my default illustrated immediately above, edit a file containing lines of the form
      "\\begin{gather}{\\small\\text"
        "{\\fbox{\\begin{gather}"
        "mime\\TeX rendering courtesy of\\\\"
        "http://www.forkosh.com/mimetex.html \\end{gather}}}\\\\"
        " %%expression%%"
      "\\end{gather}"
Every line in your file must be enclosed in "quotes", and all backslashes written as double-backslashes \\. Note \\\\ at the end of the third and fourth lines, which LaTeX sees as \\. The entire example shows how my default advertisement is defined.
      Your advertisement may consist of any valid mimeTeX commands you like. But it must somewhere contain the line
      " %%expression%% "
which is replaced by the user's expression.
      Once mimeTeX is compiled with your advertisement, test it by submitting an expression like   \advertisement x^2+y^2   containing the special mimeTeX   \advertisement directive,   which forces that expression to be rendered with your advertisement. In this case (and with my default advertisement message) we see
          instead of just    
regardless of your ADFREQUENCY value.

(IId) Command Line Features  

MimeTeX usually runs from a browser, obtaining its input expression from a query_string. But you can also run mimeTeX from your Unix shell, supplying all input from the command line. This was briefly illustrated above, where you were advised to test your newly-compiled mimeTeX executable from the command line before installing it.

In addition to such simple testing, mimeTeX also provides some possibly useful functionality from the command line. In particular, you can store a gif (or xbitmap) image of any expression to a file. No syntax checking is applied to command-line arguments, so enter them carefully. (Likewise, plus signs + are never translated to blank spaces, nor is any other %xx url decoding performed on command-line arguments.)

The complete command-line syntax for mimeTeX is

     ./mimetex [ -d ]            dump gif image on stdout,
               [ -e export_file ]  or write gif image to export_file
               [ expression      expression, e.g., "x^2+y^2",
               | -f input_file ]   or read expression from input_file
               [ -g1 -d ]        dump .pbm-formatted image on stdout
               [ -g1 -e export_file ]  or write .pbm image to export_file
               [ -g2 -d ]        dump anti-aliased .pgm image on stdout
               [ -g2 -e export_file ]  or write .pgm image to export_file
               [ -m msglevel ]   verbosity of debugging output
               [ -o ]            render image with opaque background
               [ -s fontsize ]   default fontsize, 0-5

     -d   Rather than printing ascii debugging output, mimeTeX
          dumps the actual gif (or xbitmap) to stdout, e.g.,
               ./mimetex  -d  "x^2+y^2"  >  expression.gif
          creates expression.gif containing an image of x^2+y^2

     -e export_file   Like -d but writes the actual gif
          (or xbitmap) directly to export_file, e.g.,
               ./mimetex  -e expression.gif  "x^2+y^2"
          creates file expression.gif containing an image of x^2+y^2

     expression   Place LaTeX expression directly on command
          line, with no -switch preceding it, as in the example
          immediately above, or.....

     -f input_file   .....read expression from input_file
          (and automatically assume -d switch).  The input_file
          may contain the expression on one line or spread out
          over many lines.  MimeTeX will concatanate all lines
          from input_file to construct one long expression.
          Blanks, tabs, and newlines are just ignored.

     -g1 -d   dumps a .pbm-formatted portable bitmap image to stdout.
          Note that this is the bitmap image _before_ anti-aliasing.

     -g1 -e export_file   Like -g1 -d but writes the .pbm-formatted
          portable bitmap directly to export_file, e.g.,
               ./mimetex  -g1 -e expression.pbm  "x^2+y^2"
          creates file expression.pbm containing a bitmap image
          of x^2+y^2 before anti-aliasing.

     -g2 -d   dumps a .pgm-formatted portable graphic image to stdout.
          Note that this is the bytemap image _after_ anti-aliasing.

     -g2 -e export_file   Like -g2 -d but writes the .pgm-formatted
          portable graphic image directly to export_file, e.g.,
               ./mimetex  -g3 -e expression.pgm  "x^2+y^2"
          creates file expression.pgm containing a bytemap image
          of x^2+y^2 after anti-aliasing.

     -m msglevel   0-99, controls verbosity/message level for
          debugging output (usually used only while testing code).

     -o   Rather than the default transparent gif background,
          the rendered image will contain black symbols on an
          opaque white background (or vice versa if compiled
          with -DWHITE).  For example, if you have ImageMagick's
          display utility,
               ./mimetex  -o -d  "x^2+y^2" | display &
          opens a small window containing the rendered expression.
          (Note: if you already compiled mimeTeX with -DOPAQUE
          then  -o  renders images on a transparent background.)

     -s fontsize   0-7, font size.  Font size can also be specified
          within the expression by a directive, e.g., \Large f(x)=x^2
          displays f(x)=x^2 at font size 4, overriding -s.
          Default font size is 3.
     

(III) Syntax Reference  

Since mimeTeX's syntax is as TeX-like as possible, we'll mostly discuss the occasional differences. This section contains short paragraphs that each discuss some aspect of mimeTeX where your LaTeX experience might not be precisely duplicated.

Anything not discussed here that still doesn't behave like you expect is probably just not implemented. That includes (La)TeX packages (though a few ams commands like \begin{gather} and \begin{pmatrix} are recognized), non-standard fonts, etc. You can try out any questionable syntax by Submitting a query to quickly see whether or not it works. And you might want to occasionally re-browse the Examples above, which may better illustrate implemented features.

(IIIa) \unitlength{ }, Math Spaces and Whitespace  

\unitlength...

Lengths in mimeTeX are all ultimately expressed in number of pixels. Various commands discussed below require length arguments, including

(the \longxxxarrow [ ]-arguments are optional mimeTeX extensions to LaTeX)   MimeTeX's length-type arguments never take units, e.g., {10pt} and {1cm} are both invalid. Lengths always refer to number of pixels, optionally scaled by a user-specified \unitlength.

MimeTeX's \unitlength{ } command lets you specify the number of pixels per "length unit", e.g., \unitlength{10} \hspace{2.5} renders a 25-pixel space. Both \unitlength{ } and \hspace{ }'s length arguments may be integers or may contain decimal points. Ditto for all other mimeTeX commands that take length arguments. The default \unitlength is, you guessed it, 1.

A specified \unitlength applies to all subsequent terms, i.e., everything to its right. And several \unitlength's may be specified in the same expression, each one overriding those to its left. But if one or more \unitlength's appear within a { }-enclosed subexpression, then terms following its closing right } revert to the \unitlength in effect before its opening left {. For example,

A\hspace{10} {\unitlength{2.5}B\hspace{10}C} \hspace{10}D   produces  

which has a 10-pixel space between A and B, then 25 pixels between B and C, and finally another 10 pixels between C and D.

Math Spaces...

Except inside text boxes, unescaped blanks, tildes (a ~), and all other usual whitespace characters are completely ignored by mimeTeX, just like they are in LaTeX math mode. As usual, you must explicitly write one of the recognized math spaces to put extra visible space in your rendered expressions.

MimeTeX recognizes math spaces \/ \, \: \; as well as \quad and \qquad , and also a backslashed blank     (i.e., a \ followed by a blank). For example,   (a\/b\,c\:d\;e\  f\quad  g\qquad  h)   renders   . In mimeTeX, you may also write   \hspace{10}   to insert a 10-pixel (or any other number) space, scaled by any preceding \unitlength, as illustrated just above.

For negative spaces,   \!   produces a small (two pixel) negative space, e.g.,   a=b   renders     whereas   a\!=b   renders     and   a\!\!=b   renders   . For large negative space,   \hspace{-10}   permits a negative argument. But it stops at the first pixel to its left rather than "erasing" pixels. If you don't want to stop, use   \hspace*{-10}   instead. For example,   ABC\hspace*{-20}-DEF   renders   ,   erasing all of the C and the right half of the B.

MimeTeX also supports \hfill{textwidth}, where textwidth is roughly equivalent to LaTeX's \textwidth, i.e., it's the total number of pixels, scaled by \unitlength, that your entire rendered expression will span. However, if \hfill{ } appears within a { }-enclosed subexpression, then it applies only to that subexpression. For example,

{abc \hfill{75} def} \hfill{150} ghi     produces    

The first/inner \hfill{75} inserts exactly enough whitespace so that subexpression "abc  def" spans 75 pixels. Then the second/outer \hfill{150} inserts exactly enough whitespace so that the entire expression spans 150 pixels. Without explicit { }-nesting, mimeTeX evaluates expressions left-to-right (sinistrally), e.g., ...\hfill{150}...\hfill{75}... is exactly equivalent to ...\hfill{150}{...\hfill{75}...}. Notice that, this time, the second/right textwidth argument is necessarily smaller than the first/left.

Finally, mimeTeX begins a new line whenever you write \\ . And you may optionally write \\[10] to put a 10-pixel (or any other number) vertical space, scaled by \unitlength, between lines. \begin{eqnarray} also splits long equations over several lines, as illustrated by Example 10 above. But when that's not the best solution, you can also write, for example,

y=a+b+c+d\\\hspace{50}+e+f+g+h     to produce    

However, mimeTeX can't correctly handle automatically-sized delimiters across linebreaks, e.g.,

y=\left\{a+b+c+d\\\hspace{50}+e+f+g+h\right\}     produces    
whereas you probably wanted        

which I produced using \big{...\\...\big} instead of \left\{...\\...\right\}. Expressions of the form \left...\right \\ \left...\right should all be rendered properly. It's only \left...\\...\right that will look odd.

Whitespace, Comments, and some other characters...

Some browsers occasionally misinterpret typed blank spaces inside html query_string's. In that case, you can write tildes (a ~) wherever blanks are required or desired, e.g., \alpha~w instead of \alpha w, or \frac~xy or \sqrt~z, etc. MimeTeX correctly interprets both blanks and ~'s, and all other usual whitespace characters. So use whatever's convenient as long as it's correctly interpreted inside query_string's by your browser.

Similarly, some browsers occasionally misinterpret linebreaks/newlines inside the middle of long html query_string's. For example,

<img src="../cgi-bin/mimetex.cgi?f(x)=\frac1{\sigma\sqrt{2\pi}}
 \int\limits_{-\infty}^xe^{-\frac{(t-\mu)^2}{2\sig^2}}dt"
 alt="" border=0 align=middle> 

breaks a long query_string over two lines. If your browser interprets this correctly, then mimeTeX will render it correctly, too. Otherwise, you'll have to enter long expressions on one big long line.

If you can break long query_string's over several lines, then you may find mimeTeX's %%comments%% feature useful, too. Note that comments must be preceded and followed by two %'s rather than LaTeX's usual one. The above example could be written

<img src="../cgi-bin/mimetex.cgi?f(x)=\frac1{\sigma\sqrt{2\pi}} %%normalization%%
 \int\limits_{-\infty}^xe^{-\frac{(t-\mu)^2}{2\sig^2}}dt        %%integral%%"
 alt="" border=0 align=middle> 

Besides whitespace, browsers may misinterpret embedded apostrophes, and especially quotes, within query strings. The a's and b's in Example 7 above actually use superscripted commas for apostrophes, i.e., a^,s and b^,s, and you can also use LaTeX \prime's, as in a^\prime s. For quotes, you can use ^{,,} since " almost certainly won't work. To help make things easier, in addition to the usual LaTeX \prime, mimeTeX also recognizes \apostrophe and \quote and \percent, all with the obvious meanings.

(IIIb) Math Symbols, Sizes, and Modes  

Character Sets...

The Comprehensive LaTeX Symbol List illustrates some 6,000 symbols supported by LaTeX. For complete information about the subset of these characters and math symbols available in mimeTeX, you'll need to browse through the bottom 1500-or-so lines of mimetex.h. And several additional symbols like \ldots and \AA and \hbar are defined by the mimeTeX preprocessor, function mimeprep( ) in mimetex.c
        I haven't exhaustively checked all the name-number matchings for the thousand-or-so symbols in mimetex.h. You can eaily correct any minor mistake you find in what I hope is an obvious manner. The fonts Appendix IVa below provides additional information.

Generally speaking, I've tried to encode the cmr10, cmmi10, cmmib10, cmsy10, cmex10, bbold10, rsfs10, stmary10 and wncyr10 families with "names", e.g., \alpha \beta \forall \sqcup, etc, identical to your LaTeX expectations. For example, the calligraphic symbols in cmsy10 are accessed by writing \mathcal{A} \mathcal{B} \mathcal{XYZ}. Similarly, write \mathbf{A} for the cmmib fonts, write \mathscr{A} for rsfs10, write \mathbb{R} for bbold10, and write {\cyr Khrushchev} or \cyr{Khrushchev} to see . Most LaTeX distributions supply stmaryrd.dvi and stmaryrd.sty that both document the names of the stmary10 symbols. Similarly, amsfndoc.dvi documents the names of the wncyr10 cyrillic symbols and ligatures.

In addition to extra LaTeX symbols like \ldots, \AA and \hbar, mentioned above, the mimeTeX preprocessor mimeprep( ) also recognizes various html special characters like &lt;, &gt;, &nbsp;, &quot;, &amp;, etc. Some web tools apparently translate characters like, e.g., > to &gt;, even inside quoted query_string's, so mimeTeX's preprocessor translates them back to LaTeX symbols for you. Moreover, html misinterprets quotes  "  inside a quoted query string as the end of the query string. So, for example, the cyrillic ligature \"E has to be written in the even more cumbersome form \&quot;E inside a query string.

Illustrated below are some of the character sets and math symbols supported by mimeTeX, starting with several roman character fonts. The blackboard bold font contains many characters besides   a-z,A-Z.   Calligraphic and script fonts contain uppercase   A-Z   only.

Characters from the Greek alphabet supported by mimeTeX, along with   \mathbb{ }   versions, are illustrated next. For example,   \mathbb{\lambda}   renders   .

Finally, some of the math symbols supported by mimeTeX are illustrated below. Operators shown in two sizes are automatically "promoted" to the larger size in   \displaystyle   mode. For example,   f(x)=\int_{-\infty}^x e^{-t^2}dt   renders     whereas   \displaystyle f(x)=\int_{-\infty}^x e^{-t^2}dt   renders  



Font Sizes...

MimeTeX currently has eight font sizes, numbered 0-7, with default 3. This font size numbering corresponds to the usual LaTeX directives   \tiny,   \small,   \normalsize,   \large (default),   \Large,   \LARGE,   \huge and \Huge. These directives can be placed anywhere in a mimeTeX expression, and they change font size from that point forwards. However, as usual, a font size change inside a { }-subexpression remains in effect only within that subexpression.

In mimeTeX you may also write \fontsize{0}...\fontsize{7} or the shorter \fs{0},...,\fs{7} for \tiny,...,\Huge. And since these arguments are all single digits, the even shorter form \fs0,...,\fs7 works equally well. For example,

0:   <img src="../cgi-bin/mimetex.cgi?\tiny f(x)=x^2">   produces...
1:   <img src="../cgi-bin/mimetex.cgi?\fs1 f(x)=x^2">
2:   <img src="../cgi-bin/mimetex.cgi?\normalsize f(x)=x^2">
3:   <img src="../cgi-bin/mimetex.cgi?f(x)=x^2">
4:   <img src="../cgi-bin/mimetex.cgi?\Large f(x)=x^2">
5:   <img src="../cgi-bin/mimetex.cgi?\fs5 f(x)=x^2">
6:   <img src="../cgi-bin/mimetex.cgi?\huge f(x)=x^2">
7:   <img src="../cgi-bin/mimetex.cgi?\fs7 f(x)=x^2">

rendering f(x)=x^2 in mimeTeX font sizes   0 (\tiny or \fs0),   1 (\small or \fs1),   2 (\normalsize or \fs2),   3 (default \large),   4 (\Large or \fs4),   5 (\LARGE or \fs5),   6 (\huge or \fs6)   and   7 (\Huge or \fs7).

You'll soon notice that exponents and \frac's and \atop's are automatically rendered one size smaller than their base expressions. For example,

\Large y=e^{x^2}   produces  

rendering the "y=e" in font size 4 (\Large), the "x" in font size 3 (\large), and the "2" in font size 2 (\normalsize). If you get below font size 0, the font size remains 0.

Explicit size declarations override mimeTeX's default sizing behavior. You can rewrite the preceding example as, say,

\Large y=e^{\normalsize x^{\tiny2}}   which now produces  

rendering the "y=e" in font size 4 (\Large unchanged), the "x" in font size 2 (\normalsize), and the "2" in font size 0 (\tiny).

Preceding an \fs{ } size argument with + or - specifies "relative" sizing. For example, \large\text{abc{\fs{-2}def}ghi} produces , rendering the "def" in font size 1 (two sizes smaller than \large). Note that \fs{-2} affects only the subexpression in which it appears, and that its braces are no longer optional since -2 contains two characters. For exponents (or any other size-changing commands like \frac),

\Large y=e^{\fs{-1}x^2}   produces  

rendering the "y=e" in font size 4 (\Large), as usual. The "x" would usually be rendered one size smaller, in font size 3, and your \fs{-1} is applied to that, resulting in font size 2. And the final "2" is rendered, by the usual rules, one size smaller than the "x", in font size 1.

Finally, illustrated below are some examples of fonts and symbols at several mimeTeX sizes. All symbols and sizes from cmr, cmmi, cmmib (use \mathbf{ }), cmsy, cmex, bbold (use \mathbb{ }), rsfs (use \mathscr{ }), stmary and cyrillic wncyr (use {\cyr  } or \cyr{ }) should be available, but they're not all shown. The illustrated font sizes are numbered 4=\Large, 3=\large and 2=\normalsize (not shown are 7=\Huge, 6=\huge, 5=\LARGE, 1=\small and 0=\tiny).

cmmi latin uppercase, and lowercase
calligraphic, and rsfs (\cal{A}, \scr{B}, etc)
cmmi greek uppercase, and \var lowercase
cmmi greek lowercase
cmsy symbols at mimeTeX font size 3
(operators shown large are automatically "promoted"
to the larger size in \displaystyle mode)

a few other cmmi, cmr, stmary and wncyr symbols at mimeTeX font size 4

Modes...

MimeTeX is always in a math-like mode, so you needn't surround expressions with $...$'s for \textstyle, or $$...$$'s for \displaystyle. By default, operator limits like \int_a^b are rendered \textstyle at font sizes \normalsize and smaller, and rendered \displaystyle at font sizes \large and larger (see the -DDISPLAYSIZE compile option to change this default). And when \displaystyle is invoked (either implicitly at font size \large or larger, or if you explicitly write \displaystyle at any font size), then operators \int, \sum, \prod, etc, are automatically promoted to larger sizes. For example,

\normalsize \sum_{i=1}^ni=\frac{n(n+1)}2     produces     ,   whereas
\displaystyle \normalsize \sum_{i=1}^ni=\frac{n(n+1)}2  produces  ,

and

\large \sum_{i=1}^ni=\frac{n(n+1)}2   produces   ,   whereas
\textstyle \large \sum_{i=1}^ni=\frac{n(n+1)}2     produces     .

As usual, \nolimits turns displaystyle off (or textstyle on) for the operator immediately preceding it. For example,

\large \sum\nolimits_{i=1}^ni=\frac{n(n+1)}2   produces  

and likewise, \limits turns displaystyle on for the operator immediately preceding it. For example,

\normalsize \sum\limits_{i=1}^ni=\frac{n(n+1)}2   produces  

By the way, \limits affects _any_ character or subexpression immediately preceding it. For example,

A^i_j   produces       as usual, whereas
A\limits^i_j   produces     instead.

Likewise, for subexpressions,

\widehat{xyz}\limits^a   produces  

This side effect may occasionally be useful. For example,

x\rightarrow\limits^gy   produces  

(mimeTeX automatically centers super/subscripts above/below the long and Long arrow forms)

The \displaystyle command turns on displaystyle math mode for the entire expression (or { }-enclosed subexpression), affecting _all_ super/subscripts to the right of the \displaystyle, except for character classes Ordinary and Variable (TeXbook page 154). Similarly, \textstyle turns off displaystyle math mode. For example,

\sum_1^n {\displaystyle\sum_1^k\sum_1^lx_i^j} \sum_1^m   produces  

Note that \sum's within the subexpression are all affected by the beginning \displaystyle, but not the Variable x_i^j. An explicit x\limits_i^j always affects any preceding term.

text boxes...

Finally, mimeTeX also has a text-like/roman mode entered by writing either \text{anything at all} or the equivalent LaTeX-2.09-like command {\rm anything at all}, both of which render anything at all in roman (font family cmr10). \mbox{ } and several similar LaTeX commands are recognized by mimeTeX as synonyms for \text{ }. For italic, write \textit{anything at all} or {\it anything at all}, both of which render anything at all in italic (font family cmmi10). All four forms respect spaces between words, except that the first/required space after {\rm etc} and {\it etc} is still ignored. For example,

anything at all   just produces       whereas

\text{anything at all}   produces       and

\textit{anything at all}   produces       instead.

You don't usually surround mimeTeX expressions with $'s, but that works in the usual way for \text{ } and \mbox{ }, rendering the $...$-enclosed subexpression in mathmode. For example,

n=\left\{m/2\text{    if $m$ even} \\(m+1)/2\text{  if $m$ odd}\right.   produces  

(IIIc) Delimiters  

Parentheses and Braces (delimiters)...

LaTeX's \left( ... \right) and the other 21 standard LaTeX delimiters are also recognized by mimeTeX. And mimeTeX also recognizes an etex-like \middle.   Several of the most common automatically sized delimiters are illustrated below...

Delimiter example... ...renders
\left( ... \right) \left( \frac1{1-x^2} \right)^2
\left[ ... \right] \left[ \frac1{\sqrt2}x - y \right]^n
\left\{ ... \right\} \left\{ 1^2,2^2,3^2,\ldots \right\}
\left\langle   ...
        ...  \right\rangle
\left\langle \varphi \middle| \hat H
        \middle| \phi \right\rangle
\left| ... \right| \left| \begin{matrix} a_1 & a_2 \\
      a_3 & a_4 \end{matrix} \right|
\left\| ... \right\| \left\|x^2-y^2\right\|
\left\{ ...  \right. y=\left\{ \text{this\\that} \right.
\left.  ... \right\} \left. \text{this\\that} \right\}=y

Notes... 

  1. Size declarations inside any of the above delimiter pairs affect only the enclosed subexpression, e.g., \Large w=\left(\small x+y\right)+z produces
  2. An expression may contain as many etex-like \middle's as you like, and in mimeTeX the surrounding \left...\right isn't required. When omitted, the scope of \middle is either the entire expression or the   { }-enclosed subexpression in which the \middle's occur. For example,   \frac{a+1}b \middle/ \middle(\frac{c+1}d \middle/ \frac{e+1}f\middle)   renders   .
  3. In the last two examples, note that mimeTeX recognizes the   \\   in   \text{this\\that}   as a linebreak. For example, x=1\\y=2\\z=3 renders  

Besides the \left...\right delimiters discussed above, mimeTeX also supports constructions like \left\int_a^b...\right. , which automatically sizes the \left\int to accommodate everything between it and its matching \right.   delimiter. The \right delimiter needn't necessarily be the \right.   illustrated, e.g., \left\int_a^b x^2dx =\frac{x^3}3\right|_a^b produces . You can also write \left\sum, \left\prod, \left\cup, etc, for many of the symbols in CMEX10 and STMARY10. And any symbol that works with \left will also work with \right .

Unescaped ( )'s and [ ]'s and | |'s and < >'s don't need to be balanced since mimeTeX just displays them like ordinary characters without any special significance. Ditto for the usual four \big( and \Big( and \bigg( and \Bigg(, and for their four right ) counterparts, which just display (...)'s at fixed larger sizes, and also have no special significance. All four big [ ]'s and < >'s and { }'s are also available as ordinary characters.

As usual, unescaped {...}'s aren't displayed at all, must be balanced, and have the usual special LaTeX significance. MimeTeX interprets escaped \{...\}'s as abbreviations for \left\{...\right\} and therefore always sizes them to fit. If you need displayed but unsized {...}'s, write \lbrace...\rbrace or any of the four \big{...\big}'s.

(IIId) Accents, Functions, Arrows, Raise and rotate, Compose, Abbreviations, etc.  

Accents...

\vec{ } \hat{ } \bar{ } \tilde{ } \dot{ } \ddot{ }   and   \acute{ } \grave{ } \breve{ } \check{ } are the only accents currently supported. The first four are all "wide". For example, you can write \widehat{ } if you like, but there's absolutely no difference either way (and \bar{ } and \overline{ } are identical). The last four accents only take a single character argument.

Other accent-like directives available in mimeTeX are   \underline{ } \cancel{ } \sout{ },   as well as   \overset{ }{ }   \underset{ }{ }   and the more ususal   \overbrace{ }^{ }   \underbrace{ }_{ }.   And \not also works on the single character immediately following it. Some of these directives are discussed in more detail below.

Function names...

All 32 usual LaTeX function names \arccos,...,\tanh are recognized by mimeTeX and treated in the usual way. MimeTeX also recognizes \tr for the trace, and also \bmod and \pmod. And those functions that normally take "limits" also behave as expected, e.g.,

\lim_{n\to\infty}S_n=S   produces  

long Arrows...

All mimeTeX \long and \Long arrows take an optional [width] argument that explicitly sets the arrow's width in pixels, scaled by \unitlength. For example, \longrightarrow[50] draws a 50-pixel wide arrow , whereas just \longrightarrow calculates a default width , as usual. And, in addition to the usual right, left and leftright arrows, there are also \long (and \Long) up, down and updown arrows that take an optional [height] argument, also scaled by any preceding \unitlength.

In the event that you actually want to place an []-enclosed expression immediately following an "unsized" long arrow, just place a ~ or any white space after the arrow, e.g., f:x\longrightarrow~[0,1] produces . Without any intervening white space, mimeTeX would have "eaten" the [0,1].

Super/subscripts immediately following all long/Long left/right arrows are displayed the same way \limits displays them, e.g.,

x\longrightarrow^gy   produces  
x\longrightarrow[50]^gy   produces  

Subscripted long arrows can occasionally be useful, too, as in Example 11 above, e.g.,

u\longrightarrow[50]_\beta v   produces  

To defeat this default behavior, e.g., \longrightarrow\nolimits^g displays super/subscripts in the usual way.

Super/subscripts immediately following all long/Long up/down arrows are treated correspondingly, i.e., superscripts are vertically centered to the arrow's left, and subscripts to its right. For example,

\longuparrow[30]^\gamma   produces  
\longdownarrow[30]_\gamma   produces      

whose occasional usefulness is also illustrated by Example 11. And as before, to defeat this default behavior, e.g., \longuparrow\nolimits^\gamma displays super/subscripts in the usual way.

\raisebox{ }{ } and \rotatebox{ }{ } and \reflectbox[ ]{ } ...

The \raisebox{height}{expression} and \rotatebox{angle}{expression} and \reflectbox[axis]{expression} commands help you fine-tune and manipulate mimeTeX renderings:

For example, mimeTeX's preprocessor defines the LaTeX ?` symbol, an upside-down question mark, like

abc\raisebox{-2}{\rotatebox{180}?}def   produces  

Using \reflectbox[2]{ } instead of \rotatebox{180}{ } would result in the slightly different

abc\raisebox{-2}{\reflectbox[2]?}def   produces  

\compose{ }{ }...

\compose[offset]{base}{overlay} superimposes the overlay expression on top of the base expression, displaying the result. The superimposed overlay is centered, both horizontally and vertically, on the base image, with the composite image baseline completely ignored. That means the base remains positioned in your expression just as if it had been rendered alone, while the overlay is moved around, vertically as well as horizontally, to accommodate it. For example,

\compose{\LARGE O}{\normalsize c}   renders  

Optionally, the overlay is horizontally offset by the specified number of pixels (positive offsets to the right, negative to the left). For example,

\compose[-4]{\LARGE O}{\normalsize c}   renders  

Vertical offset can be obtained using a \raisebox in either the base or overlay expression, or in both. (Although, note that \compose{\raisebox{10}{base}}{overlay} renders identically to \raisebox{10}{\compose{base}{overlay}}, so applying \raisebox to the base expression is typically unnecessary.) Vertical overlay offset is relative to the centered image, as discussed immediately above, i.e., \compose{base}{\raisebox{0}{overlay}} has no effect at all, and the overlay image remains centered on the base. For example,

abc\compose{\LARGE O}{\raisebox{5}{\normalsize c}}def   renders   , and
abc\compose{\raisebox{10}{\LARGE O}}{\raisebox{-20}{\normalsize c}}def   renders  

Separately or in some judicious combination, \compose and \raisebox and \rotatebox and \reflectbox, discussed above, perhaps along with \rule and \eval discussed immediately below, may help you construct special symbols not "natively" available with mimeTeX's limited set of built-in font families. This can be especially useful in conjunction with the –DNEWCOMMANDS compile-time option discussed above.

\rule{ }{ }...

\rule{width}{height} behaves in the usual way, rendering a black rectangle width pixels wide and height pixels high, with its base on the established baseline. For example,

\frac12xyz\rule{10}{20}ghi   produces  

The mimeTeX version of \rule has an optional [lift] argument, so that its full form is \rule[lift]{width}{height}. lift moves the rule's baseline by the specified number of pixels, up if positive or down if negative. For example,

\frac12xyz\rule[5]{10}{20}ghi   produces     and
\frac12xyz\rule[-15]{10}{20}ghi   produces  

\eval{ }...

mimeTeX can evaluate arithmetic expressions, which is a feature intended primarily for use in \newcommand's discussed above. Expressions can be built up from the following elements

All optional [ ] and mandatory { } numeric arguments for   \rule[lift]{width}{height},   \compose[offset]{ }{ },   \raisebox{height}{ },   \rotatebox{angle}{ },   and   \longarrow[width]   can be expressions as described above, rather than just numeric constants. By using the fs variable, you can construct \newcommand expressions that properly scale with font size. For example, the \mapsto symbol is not explicitly provided in any mimeTeX font, but is instead constructed by the embedded \newcommand
      { "\\mapsto", NULL, "{\\rule[fs/2]{1}{5+fs}\\hspace{-99}\\to}" },
where \rule's [lift]=fs/2 and {height}=5+fs are scaled by font size to render symbols
 
whose rendering automatically varies appropriately with font size. This kind of \newcommand construction is the primary use intended for mimeTeX's expression evaluation feature.

But mimeTeX also provides the \eval{expression} command to make the expression evaluation feature render "visible" results. It's not particularly useful, but an expression like   1+2+3+4+5=\eval{1+2+3+4+5}   renders   .

Finally, one little "gotcha" is mimeTeX's order of evaluation when interpreting expressions. Parentheses are respected as you'd expect. But within   (...)   parentheses, or in an unparenthesized expression, mimeTeX finds the first (reading from the left) operator, then iteratively evaluates the separate subexpressions to that operator's left and to its right, and then finally combines those two separate results. So an expression like 2*3+4 renders 14, and you need to write (2*3)+4 to get 10.

\magstep{ }   and   \magbox{ }{ }...

 \magstep{magnification}, placed anywhere within an expression, magnifies the entire expression by an integer factor 1<=magnification<=10 in both width and height. Each single pixel thus becomes a square box, e.g., for magnification=2 each single pixel becomes a four-pixel square box with dimensions 2-by-2. This compromises mimeTeX's anti-aliasing algorithm, and the resulting image is both hazy/blurry and jagged/staircased compared to an unmagnified image of the same expression. For example, at \LARGE size,
        f(x)=x^2   renders     and
        \magstep{2} f(x)=x^2   renders    ,   whereas
at mimeTeX's largest "native" font size,
        \Huge f(x)=x^2   renders    .
Nevertheless, if you still want to render images larger than mimeTeX's \Huge size, then \magstep{magnification} may render almost-acceptable results.

To magnify just part of an expression, you can use \magbox{magnification}{expression}, which only magnifies each pixel within the enclosed {expression}, again by an integer factor 1<=magnification<=10 in both width and height, and also adjusts the baseline accordingly. But \magbox is applied directly to mimeTeX's black-and-white bitmap  before anti-aliasing . At the present time, this virtually completely defeats mimeTeX's anti-aliasing algorithm, and the resulting image exhibits even more pronounced jagged-line/staircase effects. For example,
        \LARGE f(x)={\magbox{2}{x}}^2   renders   .

Abbreviations...

\ga displays \gamma, but just \g displays \gg (>>). That is, mimeTeX selects the shortest symbol or command which begins with whatever you type. This feature can help shorten an otherwise very long line, but it may be a bit dangerous.

The mimeTeX preprocessor, briefly mentioned above, is responsible for recognizing several LaTeX symbols like \ldots and several commands like \atop . These symbols and commands cannot be abbreviated. The special html characters like &nbsp; are also recognized by the preprocessor and cannot be abbreviated.

Colors...

Rudimentary color commands are provided by mimeTeX. You can write \color{red} or \color{green} or\color{blue} (which may be abbreviated \red or \green or \blue) anywhere in an expression to render the entire expression in the specified color. That is, abc{\red def}ghi renders the entire expression red, not just the def part. Also, note that mimeTeX's "green" is actually color #00FF00, which the html standard more accurately calls "lime". For example,

\blue e^x=\sum_{n=0}^\infty\frac{x^n}{n!}   produces  

"Smash"...

TeX represents characters by boxes, with no idea how ink will be distributed inside. So an expression like \frac12\int_{a+b+c}^{d+e+f}g(x)dx is typically rendered as   . But mimeTeX knows the character shapes of its fonts, and therefore tries to remove extra whitespace, rendering the same expression as     instead.

Precede any expression with the mimeTeX directive \nosmash to render it without "smashing". Or compile mimetex.c with the -DNOSMASH option if you prefer the typical TeX behavior as mimeTeX's default. In this case, precede any expression with \smash to render it "smashed". And note that explicit space like \hspace{10} or \; , etc, is never smashed.

The scope of \smash and \nosmash is the { }-enclosed subexpression in which the directive occurs. For example, if you want the g(x) part of the preceding example smashed, but not the 1/2 part, then the expression \nosmash\frac12{\smash\int_{a+b+c}^{d+e+f}g(x)dx} renders as   .

For finer-grained control, note that \smash is shorthand for the default \smashmargin{+3} (and \nosmash is shorthand for \smashmargin{0}). \smashmargin's value is the minimum number of pixels between smashed symbols. The leading + is optional. If present, the font size (\tiny=0,...,\Huge=7) is added to the specified minimum. Compile mimetex.c with the -DSMASHMARGIN=n option to change the default from 3 to n. Compare the preceding example with the over-smashed \smashmargin{1}     instead.

Smashing is in "beta testing" and some expressions still don't look quite right when smashed, e.g., 1^2,2^2,3^2,\ldots renders as . Just compile with -DNOSMASH if you come across numerous annoying situations.

\not and \cancel and \sout...

The usual LaTeX   \not   "slashes" the single symbol following it, e.g.,   i\not\partial\equiv i\not\nabla   produces .

For arbitrary expressions, mimeTeX provides   \cancel   which draws a line from the upper-right to lower-left corner of its argument, e.g.,   a\cancel{x^2}=bx^{\not3}   produces   .

Finally, similar to the ulem.sty package,   \sout   draws a horizontal strikeout line through its argument, e.g.,   \sout{abcdefg}   produces . MimeTeX's \sout also takes an optional argument that adjusts the vertical position of its strikeout line by the specified number of pixels, e.g.,   \sout[+2]{abcdefg} produces   and   \sout[-2]{abcdefg} produces .

(IIIe) \begin{array}{lcr}...\end{array} Environment  

Rendering vectors and matrices, aligning equations, etc, is all done using the customary LaTeX environment   \begin{array}{lcr} a&b&c\\d&e&f\\etc \end{array}   which you can write in exactly that form. MimeTeX also recognizes the following array-like environments

\begin{array}{lcr} a&b&c \\ d&e&f \\ etc \end{array}
\begin{matrix} a&b&c \\ d&e&f \\ etc \end{matrix}
\begin{tabular} a&b&c \\ d&e&f \\ etc \end{tabular}
\begin{pmatrix} a&b&c \\ d&e&f \\ etc \end{pmatrix}
\begin{bmatrix} a&b&c \\ d&e&f \\ etc \end{bmatrix}
\begin{Bmatrix} a&b&c \\ d&e&f \\ etc \end{Bmatrix}
\begin{vmatrix} a&b&c \\ d&e&f \\ etc \end{vmatrix}
\begin{Vmatrix} a&b&c \\ d&e&f \\ etc \end{Vmatrix}
\begin{eqnarray} a&=&b \\ c&=&d \\ etc \end{eqnarray}
\begin{align} a&=b \\ c&=d \\ etc \end{align}
\begin{cases} a&b \\ c&d \\ etc \end{cases}
\begin{gather} a \\ b \\ etc \end{gather}

There's a built-in maximum of 64 columns and 64 rows. Nested array environments, e.g., \begin{pmatrix}a&\begin{matrix}1&2\\3&4\end{matrix}\\c&d\end{pmatrix}, are permitted.

MimeTeX also provides the abbreviation   \array{lcr$a&b&c\\d&e&f\\etc}   which has exactly the same effect as   \begin{array}{lcr} a&b&c\\d&e&f\\etc \end{array}. And the lcr$ "preamble" in \array{lcr$etc} is optional. In that case,   \array{a&b&c\\d&e&f\\etc}   has exactly the same effect as   \begin{matrix} a&b&c\\d&e&f\\etc \end{matrix}. You can also write \(\array{etc}\) to "manually abbreviate" the pmatrix environment, or \array{rcl$etc} to abbreviate eqnarray, but mimeTeX has no explicit abbreviations for these other environments. For example,

\begin{matrix}a_1&a_2&a_3\\b_1&b_2&b_3\\c_1&c_2&c_3\end{matrix}   produces  

Solid \hline's (but not \cline's) and vertical l|c|r bars are available, as usual. For dashed lines and bars, \begin{array} provides the additional features \hdash and l.c.r . \hline and \hdash may not be abbreviated. For example,

\begin{array}{c.c|c} a_1&a_2&a_3 \\\hdash b_1&b_2&b_3
\\\hline c_1&c_2&c_3 \end{array}
  produces

The default font size is unchanged by \array{ }, but you can explicitly control it in the usual way, e.g., {\Large\begin{matrix}...\end{matrix}} renders the entire array in font size 4. In addition, any &...& cell may contain font size declarations which are always local to that cell, e.g., &\fs{-1}...& renders that one cell one font size smaller than current.

The {lcr} in \begin{array}{lcr} sets left,center,right "horizontal justification" down columns of an array, as usual. And "vertical justification" across rows defaults to what we'll call baseline, i.e., aligned equations, as in Example 10 above, display properly. But the down arrows (for     and for   ) in Example 11 require "vertical centering" across the middle row of that array. So, in addition to lowercase lcr, mimeTeX's {lcr} in \begin{array}{lcr} may also contain uppercase BC to set "B"aseline or "C"enter vertical justification across the corresponding rows. For example, \begin{array}{rccclBCB} sets baseline justification for the first and third rows, and center justification for the second row. Without any BC's, all rows default to the usual B baseline justification.

MimeTeX has no \arraycolsep or \arraystretch parameters. Instead, \begin{array}{lc25rB35C} sets the absolute width of the second column to 25 pixels, and the absolute height of the first row to 35 pixels, as illustrated by Example 9. Any number following an lcrBC specification sets the width of that one column (for lcr), or the height of that one row (for BC).
You can optionally precede the number with a + sign, which "propagates" that value forward to all subsequent columns for lcr, or all subsequent rows for BC. For example, \begin{array}{lc+25rB+35C} sets the absolute width of column 2 and all subsequent columns to 25 pixels, and the absolute height of row 1 and all subsequent rows to 35 pixels. After absolute sizing has been set, the special value 0 reverts to automatic sizing for that one row or column, and +0 reverts to automatic sizing for all subsequent rows or columns. For example, \begin{array}{c+25ccc+35ccc+0} sets the absolute widths of columns 1-3 to 25 pixels, columns 4-6 to 35 pixels, and then reverts to automatic sizing for columns 7 and all subsequent columns.
The "propagation" introduced by + is local to the \begin{array} in which it occurs. So you have to repeat the same specifications if you want rows aligned across several arrays on the same line (or columns aligned on several lines separated by \\). Instead, a lowercase g globally copies your column specifications to all subsequent arrays, and an uppercase G globally copies your row specifications. And gG copies both column and row specifications. For example, \begin{array}{GC+25} sets the height of all rows in this array to 25 pixels, and ditto for all subsequent arrays to its right. Explicit specifications in subsequent arrays override previous global values.
Click one of the following examples to see illustrations of the above discussion:


See Examples 8-11 above for several additional \begin{array}{lcr} applications.

(IIIf) \picture( ){ } "Environment", including \line( ){ } and \circle( )  

Besides \begin{array}{lcr}, mimeTeX also tries to emulate the familiar LaTeX picture environment with the somewhat similar
          \picture(width[,height])  { (loc1){pic_elem1} (loc2){pic_elem2} ... }
as illustrated by Examples 12-13 above. Arguments surrounded by [ ]'s are optional. If the optional [,height] is omitted, then height=width is assumed. Locations (loc1) and (loc2) ... each denote either a \put(loc) or a \multiput(loc), and each location is of the form ([c]x,y[;xinc,yinc[;num]]).

A \put(loc) is denoted by a location of the form ([c]x,y) where x,y denotes the coordinate where the lower-left corner of the subsequent picture_element will be placed, unless the letter c precedes the x-number, in which case cx,y denotes the center point instead. The very lower-left corner of the entire picture is always 0,0, and the upper-right corner is width-1,height-1. Note, for example, that you'd never want to specify location c0,0 since the picture_element would be mostly out-of-bounds (only its upper-right quadrant would be in-bounds).

A \multiput(loc) starts like a \put(loc), but location [c]x,y is followed by ;xinc,yinc[;num] indicating the x,y-increments applied to each of num repetitions of picture_element. If ;num is omitted, repetitions continue until the picture_element goes out-of-bounds of the specified width[,height]. Note that x,y are always positive or zero, but xinc,yinc may be postive, zero or negative.

The \picture(,){...} parameters width, height, x, y, xinc, yinc may be either integer or may contain a decimal point, and they're all scaled by \unitlength. The num parameter must be integer.

Picture_element's {pic_elem1} and {pic_elem2} ... may be any expressions recognized by mimeTeX, even including other \picture's nested to any level.

\line( ){ } and \circle( )...

To help draw useful picture_element's, mimeTeX provides several drawing commands, \line(xinc,yinc)[{xlen}] and \circle(xdiam[,ydiam][;arc]). Although primarily intended for use in \picture's, you can use them in any mimeTeX expression, e.g.,   abc\circle(20)def   produces   .

Without its optional {xlen} parameter, the expression (x,y){\line(xinc,yinc)} draws a straight line from point x,y to point x+xinc,y+yinc. The inc's can be positive, zero or negative. Don't prefix location x,y with a leading c for \line's; the intended "corner" is determined by the signs of xinc and yinc. If given, the optional {xlen} parameter rescales the length of the line so its x-projection is xlen and its slope is unchanged.

Without optional ,ydiam and ;arc, the expression (x,y){\circle(xdiam)} draws a circle of diameter xdiam centered at x,y. Don't prefix location x,y with a leading c for \circle's; centering is assumed. If ,ydiam is also given, then (x,y){\circle(xdiam,ydiam)} draws the ellipse inscribed in a rectangle of width xdiam and height ydiam centered at x,y.
      Finally, ;arc specifies the arc to be drawn, in one of two ways. An ;arc argument given in the form ;1234 interprets each digit as a quadrant to be drawn, with 1 the upper-right quadrant and then proceeding counterclockwise, e.g., \circle(12;34) specifies the lower half of a circle whose diameter is twelve.
      Alternatively, an ;arc argument given in the form 45,180 or -60,120 specifies the endpoints of the desired arc in degrees, with 0 the positive x-axis and then proceeding counterclockwise. The first number must always be smaller than the second (negative numbers are allowed), and the arc is drawn counterclockwise starting from the smaller number.

Besides Examples 12-13 above, it's hard to resist illustrating
      \unitlength{.6}   \picture(100) {
          (50,50){\circle(99)} %%head%%
          (20,55;50,0;2){\fs{+1}\hat\bullet} %%eyes%%
          (50,40){\bullet} %%nose%%
          (50,35){\circle(50,25;34)} %%upper lip%%
          (50,35){\circle(50,45;34)} %%lower lip%%   }


Have a nice day!

(IIIg) Other mimeTeX Commands  

Various and sundry other LaTeX-like commands are also provided by mimeTeX. In addition to features explicitly discussed below, mimeTeX supports the usual sub_scripts and super^scripts, and most of the typical LaTeX commands, many already discussed above, including

All these typical commands should behave as they usually do in LaTeX, and won't be discussed further. Short discussions of some other commands follow.

\overset{ }{ } or \stackrel{ }{ }   and   \underset{ }{ } or \relstack{ }{ } ...

\stackrel{ }{ } behaves as usual in LaTeX, rendering its first argument one font size smaller and centered above its second. And the amsmath-style \overset{ }{ } is identical. For example,

"\vec x\overset{\rm def}=(x_1\ldots x_n)"   produces  

"Conversely" to \stackrel{ }{ }, mimeTeX provides \relstack{ }{ }, which renders its second argument one font size smaller and centered below its first. And the amsmath-style \underset{ }{ } renders its first argument one font size smaller and centered below its second. For example, the \log function name doesn't treat limits like \lim_, but you can write, for example,

"\underset{\rm base 2}\log32=5"   to render  

MimeTeX's \limits provides an easier but non-standard alternative to achieve the same effect. For example,

"\vec x =\limits^{\rm def} (x_1\ldots x_n)"   produces  

and   "\log\limits_{\rm base 2}32=5"   produces  

\fbox{ }...

In case html border attributes aren't suitable, mimeTeX provides the usual \fbox{expression} command, e.g.,

"\fbox{x=\frac12}"   produces  

You can also write \fbox[width]{expression} to explicitly set the box's width, or you can write \fbox[width][height]{expression} to explicitly set both width and height.

\today and \calendar...

\today   renders     in the usual LaTeX text mode way. That's \today's default format#1. MimeTeX has an optional format argument so that, for example,   \blue\today[2]   renders   ,   showing both date and time. And   \red\today[3]   renders   ,   showing time only.

To accommodate time zones, you may also write, for example,   \small\blue\today[2,+3],   which renders   ,   adding three hours to format#2. The arguments may be in either order. The time zone increment must always be preceded by either + or -, and must be in the range -23 to +23.

\calendar   renders a calendar for the current month, as illustrated by the left-hand image below. For a different month, the optional argument   \small\blue\calendar[2001,9]   renders the right-hand image, for the requested year and month. Years must be 1973...2099 and months must be 1...12.

         

The default calendar emphasizes the current day of the current month, while any other month emphasizes no day. Day emphasis is controlled by an optional third argument.   \calendar[0,0,1]   emphasizes the first day of the current month, and   \calendar[2001,9,11]   emphasizes the eleventh day of that month.   \calendar[0,0,99]   renders the current month with no day emphasized.

\input{ }...

\input{filename} behaves just like the corresponding LaTeX command, reading the entire contents of filename into your expression at the point where the \input command occurs. By default, filename resides in the same directory as mimetex.cgi. Moreover, for security, absolute paths with leading /'s or \'s, and paths with ../'s or ..\'s, are not permitted. See the -DPATHPREFIX compile option, discussed above, if you want \input files in some other directory. In any case, if filename isn't found, then \input tries to read filename.tex instead.

And for further security, \input{ } is disabled by default unless mimeTeX is compiled with either the -DINPUTOK or -DINPUTPATH or -DINPUTREFERER compile option discussed above. When it's disabled, the command \input{filename} renders the error message [\input{filename} not permitted] .

MimeTeX also supports the optional form \input{filename:tag}. In this case, filename is read as before, but only those characters between <tag>...</tag> are placed into your expression. This permits you to have one file containing many different <tag>'s, e.g., one file containing all the questions and/or answers to a homework assignment or a quiz, etc.

\counter[ ]{ } ...

The bottom-right corner of this page contains a page hit counter that's maintained using mimeTeX's \counter[logfile]{counterfile:tag} command. As with \input, described immediately above, both the required counterfile and the optional logfile are the names of files that reside in the same directory as your mimetex.cgi executable, unless you compiled mimetex with the -DPATHPREFIX compile option. Before using the \counter command, Unix "touch" and "chmod" those files so they're mimeTeX readable and writable.

Also as with \input, for security \counter is disabled by default unless mimeTeX is compiled with either the -DINPUTOK or the -DCOUNTEROK compile option (notice that -DINPUTOK also enables \counter). If you've compiled mimeTeX with \counter enabled, then it behaves as follows...

If counterfile isn't readable and writable, then the \counter command always displays 1st. Otherwise, it maintains a line in counterfile of the form <tagvalue </tag> where value is initialized as 1_ if the specified <tag> line doesn't already exist, and then incremented on each subsequent call. That trailing underscore on the value in the file, e.g., 99_, tells mimeTeX to display 99th with an ordinal suffix. Edit the value in the file and remove the underscore if you don't want the ordinal suffix displayed. Finally, mimeTeX makes no effort to lock files or records (tags), so be careful using \counter if your hit rates are high enough so that frequent collisions are likely.

The same counterfile can contain as many different <tag> lines as you like, so counters for all the pages on your site can be maintained in one file. MimeTeX also maintains a special <timestamp> tag in counterfile that logs the the date/time and name of the most recently updated tag.

Somewhat more detailed log information can be accumulated in the optional logfile. If you provide that filename, mimeTeX writes a line to it of the form 2008-09-07:12:59:33pm <tag>=99 192.168.1.1 http_referer containing a timestamp, the counter tag and its current value, and the user's IP address and http_referer page if they're available.

The page hit counter displayed at the bottom-right corner of this page is maintained by the command \counter[counters.log]{counters.txt:mimetex.html}. After compiling and installing your own mimetex.cgi and your own copy of this page, that counter will continually show 1st's unless/until you "touch" and "chmod" counters.txt (and, optionally, counters.log) in your mimetex.cgi directory.

\environment ...

Submitting the expression   \environment   to mimeTeX renders

displaying the http environment variables known to mimeTeX. This is primarily a programming aid, showing information available to mimeTeX that might facilitate future enhancements.

As with \input and \counter above, for security \environment is disabled by default unless mimeTeX is compiled with either the -DINPUTOK or the -DENVIRONOK compile option (notice that -DINPUTOK also enables \environment).

(IIIh) Other Exceptions to LaTeX Syntax  

Binding Exceptions...

MimeTeX's bindings are pretty much left-to-right. For example, although mimeTeX correctly interprets \frac12 as well as \frac{1}{2}, etc, the legal LaTeX expression x^\frac12 must be written x^{\frac12}. Otherwise, mimeTeX interprets it as {x^\frac}12, i.e., the same way x^\alpha12 would be interpreted, which is entirely wrong for \frac. The same requirement also applies to other combinations of commands, e.g., you must write \sqrt{\frac\alpha\beta}, etc.

(IIIi) mimeTeX Errors and Messages  

mimeTeX Errors...

Any (La)TeX error is typically also a mimeTeX error. However, mimeTeX has no command line interface or .log file for reporting errors. Its only communication with you is through the mimeTeX image rendered by your browser. So error messages are embedded in that image whenever feasible. For example, suppose you want to see , but you mistakenly type   \alpha\bethe\gamma\delta   instead. Then the image rendered is , indicating the unrecognized [\bethe?] where you wanted to type   \beta   and hoped to see . If your expression contains some unprintable character (meaning any character mimeTeX has no bitmap for), then just     is displayed in the corresponding position.

The preceding example illustrates a pretty trivial error. Any non-trivial errors in your expression are likely to go unrecognized and unreported by mimeTeX, and to render unexpected images. While checking your input expression for syntax errors, keep in mind the following points about mimeTeX's behavior:

mimeTeX Messages...

The latest release of mimeTeX is version which was last revised . The special mimeTeX directive   \version   displays that same information,

To check that your own release of mimeTeX is current, type a url into your browser's locator window something like
        http://www.yourdomain.com/cgi-bin/mimetex.cgi?\version
which will display the version and revision date of mimeTeX installed on your server.

(IV) Appendices  

Programming information to help you modify mimeTeX's behavior, and to use its functionality in your own programs, is provided by these appendices. The currently available appendices discuss (a)how to modify or extend mimeTeX's fonts, (b)how to use mimeTeX's principal function, make_raster(), and (c)how to use Sverre Huseby's gifsave.c library.

(IVa)   mimeTeX Fonts  

The font information mimeTeX uses to render characters is derived from .gf font files (usually generated by metafont running against .mf files), which are then run through gftype -i and finally through my gfuntype program (supplied with your mimeTeX distribution).

The final output from each such sequence of three runs (metafont > gftype -i > gfuntype) gives mimeTeX the bitmap information it needs to render one particular font family at one particular size. The file texfonts.h supplied with your mimeTeX distribution collects the output from 72 such (sequences of) runs, representing nine font families at eight sizes each.

This collection of information in   texfonts.h   is "wired" into mimeTeX through tables maintained in mimetex.h. To change mimeTeX's fonts, you'll have to first modify (or totally replace) texfonts.h using your own gfuntype output, and then change mimetex.h to reflect your texfonts.h modifications.

This appendix provides a brief description of the above process, though you'll probably need at least some previous C programming experience to confidently accomplish it. Your motivation might be to add more fonts to mimeTeX, to change the font sizes I chose, or to add more font sizes, etc. MimeTeX's design permits all this to be easily done once you understand the process.

Running metafont to generate a .gf file from .mf source will usually be your very first step. A typical such run might be

mf '\mode=preview; mag=magstep(-16.393225); input cmmi10'

which in this case generates output file cmmi10.131gf (which is mimeTeX's font size 3 for the cmmi family).

Given the cmmi10.131gf file from this metafont run (or substitute any other .gf file you like), next run

gftype -i cmmi10.131gf > typeout

where typeout can be any temporary filename you like.

Finally, run gfuntype against the typeout file you just generated with the command

gfuntype -n cmmi131 typeout cmmi131.h

to generate the final output file cmmi131.h (or any filename you supply as the last arg). This contains the cmmi data in an array whose name is taken from the -n arg you supplied to gfuntype.

The above sequence of three runs resulted in output file cmmi131.h, containing the font information mimeTeX needs for one font family (cmmi) at one font size (3). Repeat this sequence of three runs for each font size and each font family. Then pull all the output files into one big texfonts.h file (or write a small texfonts.h which just #include's them all).

For your information, the 72 sequences of runs represented in the texfonts.h file supplied with your mimeTeX distribution correspond to the following eight inital metafont runs for cmr10

   size=0 (.83gf)   mf '\mode=eighthre; input cmr10'
        1 (.100gf)  mf '\mode=preview; mag=magstep(-17.874274); input cmr10'
        2 (.118gf)  mf '\mode=preview; mag=magstep(-16.966458); input cmr10'
        3 (.131gf)  mf '\mode=preview; mag=magstep(-16.393225); input cmr10'
        4 (.160gf)  mf '\mode=preview; mag=magstep(-15.296391); input cmr10'
        5 (.180gf)  mf '\mode=preview; mag=magstep(-14.650373); input cmr10'
        6 (.210gf)  mf '\mode=preview; mag=magstep(-13.804885); input cmr10'
        7 (.250gf)  mf '\mode=preview; mag=magstep(-12.848589); input cmr10'

Then ditto for the eight other font families cmmi10, cmmib10, cmsy10, cmex10, bbold10, rsfs10, stmary10 and wncyr10. And to generate other .dpigf font sizes, calculate magsteps   .   All the subsequent gftype and gfuntype runs just follow the standard format described above.

To incorporate all this font information you just generated into mimeTeX, edit your mimetex.h file and find the table that looks something like

static fontfamily aafonttable[] = {
 /* ----------------------------------------------------------------------------------------
    family    size=0,        1,        2,        3,        4,        5,        6,        7
 ----------------------------------------------------------------------------------------- */
 {   CMR10,{   cmr83,   cmr100,   cmr118,   cmr131,   cmr160,   cmr180,   cmr210,   cmr250}},
 {  CMMI10,{  cmmi83,  cmmi100,  cmmi118,  cmmi131,  cmmi160,  cmmi180,  cmmi210,  cmmi250}},
 { CMMIB10,{ cmmib83, cmmib100, cmmib118, cmmib131, cmmib160, cmmib180, cmmib210, cmmib250}},
 {  CMSY10,{  cmsy83,  cmsy100,  cmsy118,  cmsy131,  cmsy160,  cmsy180,  cmsy210,  cmsy250}},
 {  CMEX10,{  cmex83,  cmex100,  cmex118,  cmex131,  cmex160,  cmex180,  cmex210,  cmex250}},
 {  RSFS10,{  rsfs83,  rsfs100,  rsfs118,  rsfs131,  rsfs160,  rsfs180,  rsfs210,  rsfs250}},
 { BBOLD10,{ bbold83, bbold100, bbold118, bbold131, bbold160, bbold180, bbold210, bbold250}},
 {STMARY10,{stmary83,stmary100,stmary118,stmary131,stmary160,stmary180,stmary210,stmary250}},
 {   CYR10,{ wncyr83, wncyr100, wncyr118, wncyr131, wncyr160, wncyr180, wncyr210, wncyr250}},
 {    -999,{    NULL,     NULL,     NULL,     NULL,     NULL,     NULL,     NULL,     NULL}}
} ; /* --- end-of-fonttable[] --- */

Note the 72 names cmr83...wncyr250 in the table. These must correspond to (or must be changed to) the names following the -n switch you specified for your   gfuntype   runs.

If you want more than eight font sizes, first build up texfonts.h with all the necessary information. Then change LARGESTSIZE (and probably NORMALSIZE) in mimetex.h, and finally edit the above aafonttable[] by extending the columns in each row up to your largest size.

You can also add new rows by #define'ing a new family, and then adding a whole lot of character definitions at the bottom of mimetex.h, all in the obvious way (i.e., it should become obvious after reviewing mimetex.h). A new row would be required, for example, to make another font available in mimeTeX.

One small problem with the above procedure is that the default   gftype   program supplied with most TeX distributions can't emit the long lines needed to display mimeTeX's larger font sizes. gftype.zip contains a statically linked linux executable modified to emit the necessary long lines. It may or may not run on your intel linux machine. If not, you'll need to compile your own version from source. The following instructions are for Unix/Linux:
        First, download both web-7.5.3.tar.gz and web2c-7.5.3.tar.gz (note: these files are no longer explicitly archived by ctan, having been superceded by texlive sources, so the preceding two links point to copies kept on my site, www.forkosh.com). Then   untar   both gzipped tar files,   cd web2c-7.5.3/   and run   ./configure   and   make   in the usual way (make may fail before completion if you don't have all needed fonts installed, but it will create and compile gftype.c before failing). Now edit   texk/web2c/gftype.c  and notice three lines very near the top that   #define maxrow (79)   and similarly for maxcol and linelength. Change all three 79's to 1024, and then re-run make. The new   texk/web2c/gftype   executable image can emit the long lines needed for mimeTeX's larger font sizes.

Finally, the Unix/Linux bash shell script texfonts.sh generates file   texfonts.h   containing the information for all 72 mimeTeX fonts discussed above (and, optionally, an extra 1200dpi cmr font used to test mimeTeX's supersampling algorithm). You'll need to understand and edit this script to use it meaningfully. But it helps automate mimeTeX's font generation procedure in case you want to experiment with different fonts. (Note that metafont emits a complaint while generating the 83dpi rsfs font. Just press <CR> and it completes successfully.)

(IVb) mimeTeX's make_raster() function  

MimeTeX converts an input LaTeX math expression to a corresponding GIF image in two steps. First, it converts the input LaTeX expression to a corresponding bitmap raster. Then Sverre Huseby's gifsave library, discussed below, converts that bitmap to the emitted gif. Though you never explicitly see that bitmap, it's mimeTeX's principal result. MimeTeX is written so any program can easily use its expression-to-bitmap conversion capability with just a single line of code. The following complete program demonstrates the simplest such use.

 #include <stdio.h>
 #include "mimetex.h"
 int main ( int argc, char *argv[] )
 {
 raster    *rp = make_raster(argv[1],NORMALSIZE);
 type_raster(rp,stdout);  /* display ascii image of raster */
 }

Cut-and-paste the above sample code from this file to, say, mimedemo.c (and fix the brackets around stdio.h). Then compile
        cc -DTEXFONTS mimedemo.c mimetex.c -lm -o mimedemo
and run it from your unix shell command line like
        ./mimedemo   "x^2+y^2"

MimeTeX's expression-to-bitmap conversion is accomplished by the make_raster() call, whose first argument is just a pointer to a (null-terminated) string containing any mimeTeX-compliant LaTeX expression, and whose second argument is the mimeTeX font size to use (overridden if your expression contains a preamble). The ascii display of the bitmap raster returned by make_raster() results from the subsequent call to type_raster(). That's all this program does, but you could use make_raster()'s returned bitmap for any other purpose you have in mind.

MimeTeX's primary purpose is to emit either xbitmaps or gif images rather than ascii displays. And mimeTeX has anti-aliasing and various other options that further complicate its main() function compared to the simple example above. The example below demonstrates mimeTeX usage in the slightly more realistic situation where an input expression is converted to a gif, without anti-aliasing, and emitted on stdout.

 #include <stdio.h>
 #include <stdlib.h>
 #include "mimetex.h"

 /* --- global needed by callback function, below, for gifsave.c --- */
 static  raster *rp = NULL;              /* 0/1 bitmap raster image */

 /* ---  callback function to return pixel value at col x, row y --- */
 int     GetPixel ( int x, int y )       /* pixel value will be 0 or 1 */
 { return (int)getpixel(rp,y,x); }       /* just use getpixel() macro */

 /* --- main() entry point --- */
 int     main ( int argc, char *argv[] )
 {
 /* --- get LaTeX expression from either browser query or command-line --- */
 char    *query = getenv("QUERY_STRING"),        /* check for query string */
         *expression = (query!=NULL? query :     /* input either from query */
            (argc>1? argv[1] : "f(x)=x^2"));     /* or from command line */
 /* ---- mimeTeX converts expression to bitmap raster ---- */
 rp = make_raster(expression,NORMALSIZE); /* mimeTeX rasterizes expression */
 /* ---- convert returned bitmap raster to gif, and emit it on stdout ---- */
 if ( query != NULL )                    /* Content-type line for browser */
   fprintf( stdout, "Content-type: image/gif\n\n" );
 /* --- initialize gifsave library and colors, and set transparent bg --- */
 GIF_Create(NULL, rp->width, rp->height, 2, 8); /* init for black/white */
 GIF_SetColor(0, 255, 255, 255);         /* always set background white */
 GIF_SetColor(1,   0,   0,   0);         /* and foreground black */
 GIF_SetTransparent(0);                  /* and set transparent background */
 /* --- finally, emit compressed gif image (to stdout) --- */
 GIF_CompressImage(0, 0, -1, -1, GetPixel);
 GIF_Close();
 }

Cut-and-paste as before, compile like
        cc -DTEXFONTS mimedemo.c mimetex.c gifsave.c -lm -o mimedemo
and run it like the first example, but this time you may want to redirect stdout
        ./mimedemo   "x^2+y^2"   >   mimedemo.gif
since output is now a gif image consisting of mostly unprintable bytes. Input is typically from the command line as illustrated, but this example checks for a browser query string too. That means you could actually replace mimetex.cgi with this executable, though anti-aliasing wouldn't be available.

Of course, this example's intent isn't to replace the mimetex.cgi executable, but rather to illustrate GIFSAVE library usage, documented in detail below. And this example also illustrates usage of several mimeTeX raster structure elements, like rp->width and rp->height. So you'll probably also want to refer to mimetex.h, which contains those raster structures and other relevant definitions. For instance, the example's GetPixel() callback function illustrates usage of the getpixel() macro in mimetex.h, to retrieve individual pixels by their x,y-coordinates. And there's a similar setpixel() macro in mimetex.h to store pixels. After completing all this reading, you'll be prepared to begin using mimeTeX functions in your own code.

(IVc) Sverre Huseby's gifsave.c library  

The information below is taken from the README file accompanying Sverre Huseby's distribution of GIFSAVE. I've made a few small editorial modifications, including descriptions of the several minor changes necessary to support mimeTeX. And the mimeTeX example program immediately above uses GIFSAVE in a very straightforward way that should help clarify any questions which may remain after reading the documentation below.

                             INTRODUCTION
                             ============

 The GIFSAVE functions make it possible to save GIF images from
 your own C programs.

 GIFSAVE creates simple GIF files following the GIF87a standard.
 Interlaced images cannot be created.  There should only be
 one image per file.

 GIFSAVE consists of five functions, all returning type int,
 and no separate header file is required.

 The functions should be called in the order listed below
 for each GIF-file. One file must be closed before a new one
 can be created.

     GIF_Create() creates new GIF-files. It takes parameters
         specifying filename, screen size, number of colors,
         and color resolution.

     GIF_SetColor() sets up red, green, blue color components.
         It should be called once for each possible color.

     GIF_SetTransparent() is optional.  If called, it sets the
         color number of the color that should be transparent,
         i.e., the background color shows through this one.

     GIF_CompressImage() performs the compression of the image.
         It accepts parameters describing the position and size
         of the image on screen, and a user defined callback
         function that is supposed to fetch the pixel values.

     GIF_Close() terminates and closes the file.

 To use these functions, you must also write a callback
 function that returns the pixel values for each point
 in the image.


                             THE FUNCTIONS
                             =============

 GIF_Create()
 ------------
         Function  Creates a new GIF-file, and stores info on
                   the screen.

           Syntax  int GIF_Create(
                           char *filename,
                           int width, int height,
                           int numcolors, int colorres
                       );

          Remarks  Creates a new (or overwrites an existing)
                   GIF-file with the given filename. No
                   .GIF-extension is added.

                   If filename is passed as a NULL pointer,
                   output is directed to stdout.

                   The width- and height- parameters specify
                   the size of the image in pixels.

                   numcolors is the number of colors used in
                   the image.

                   colorres is number of bits used to encode a
                   primary color (red, green or blue).
                   In GIF-files, colors are built by combining
                   given amounts of each primary color.
                   On VGA-cards, each color is built by
                   combining red, green and blue values in
                   the range [0, 63]. Encoding the number 63
                   would require 6 bits, so colorres would be
                   set to 6.

     Return value  GIF_OK        - OK
                   GIF_ERRCREATE - Error creating file
                   GIF_ERRWRITE  - Error writing to file
                   GIF_OUTMEM    - Out of memory


 GIF_SetColor()
 --------------
         Function  Specifies the primary color component of a
                   color used in the image.

           Syntax  void GIF_SetColor(
                            int colornum,
                            int red, int green, int blue
                        );

          Remarks  This function updates the colortable-values
                   for color number colornum in the image.

                   Should be called for each color in the range
                   [0, numcolors]

                   with red, green and blue components in the
                   range  [0, (2^colorres)-1]

                   colorres and colornum are values previousely
                   given to the function GIF_Create().

     Return value  None


 GIF_SetTransparent()
 --------------------
         Function  Specifies the color number of the color
                   that should be considered transparent.

           Syntax  void GIF_SetTransparent(
                            int colornum
                        );

          Remarks  Need not be called at all.  But if called,
                   should be called only once with colornum in
                   the range  [0, numcolors]  i.e., colornum
                   must be one of the values previously
                   given to GIF_SetColor().

     Return value  None


 GIF_CompressImage()
 -------------------
         Function  Compresses an image and stores it in the
                   current file.

           Syntax  int GIF_CompressImage(
                           int left, int top,
                           int width, int height,
                           int (*getpixel)(int x, int y)
                       );

          Remarks  The left- and top- parameters indicate the
                   image offset from the upper left corner of
                   the screen.  They also give the start values
                   for calls to the userdefined callback
                   function.

                   width and height give the size of the image.
                   A value of -1 indicates the equivalent screen
                   size given in the call to GIF_Create().

                   If the image is supposed to cover the entire
                   screen, values 0, 0, -1, -1 should be given.

                   GIF_CompressImage() obtains the pixel values
                   by calling a user specified function. This
                   function is passed in the parameter getpixel.
                   See "callback()" further down for a
                   description of this function.

     Return value  GIF_OK        - OK
                   GIF_ERRWRITE  - Error writing to file
                   GIF_OUTMEM    - Out of memory


 GIF_Close()
 -----------
         Function  Closes the GIF-file.

           Syntax  int GIF_Close(void);

          Remarks  This function writes a terminating descriptor
                   to the file, and then closes it. Also frees
                   memory used by the other functions of GIFSAVE.

     Return value  GIF_OK        - OK
                   GIF_ERRWRITE  - Error writing to file


                         THE CALLBACK FUNCTION
                         =====================

 callback()
 ----------
         Function  Obtains pixel-values for the
                   GIF_CompressImage() -function.

           Syntax  int callback(int x, int y);

          Remarks  This function must be written by the
                   programmer.  It should accept two integer
                   parameters specifying a point in the image,
                   and return the pixel value at this point.

                   The ranges for these parameters are as
                   follows
                       x : [img_left, img_left + img_width - 1]
                       y : [img_top, img_top + img_height - 1]

                   where img_left, img_top, img_width and
                   img_height are the values left, top, width
                   and height passed to GIF_CompressImage().

                   An example; if the screen has width 640 and
                   height 350, and the image covers the entire
                   screen, x will be in the range  [0, 639]
                   and y in the range  [0, 349].

                   callback() need not get its values from the
                   screen. The values can be fetched from a
                   memory array, they can be calculated for
                   each point requested, etc.

                   The function is passed as a parameter to
                   GIF_CompressImage(), and can thus have any
                   name, not only callback().

     Return value  Pixel value at the point requested. Should
                   be in the range  [0, numcolors-1]  where
                   numcolors is as specified to GIF_Create().

Concluding Remarks  

I hope you find mimeTeX useful. If so, a contribution to your country's TeX Users Group, or to the GNU project, is suggested, especially if you're a company that's currently profitable.


Copyright © 2002-2012, John Forkosh Associates, Inc.
email: john@forkosh.com

These binaries (installable software) and packages are in development.
They may not be fully stable and should be used with caution. We make no claims about them.
Health stats visible at Monitor.