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

more_examples...

Copyright © 2002-2006, 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. 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
    (IV) Appendices    
a. Fonts
b. make_raster()
c. gifsave.c
  Remarks  

- - - - - - 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. And it's equally easy to use. Just place an html <img> tag in your document wherever you want to see the corresponding LaTeX expression. For example,

  <img src="../cgi-bin/mimetex.cgi?f(x)=\int_{-\infty}^xe^{-t^2}dt"
   alt="" border=0 align=middle>

immediately generates the corresponding gif image on-the-fly, displaying wherever you put that <img> 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.)

mimeTeX plugins...

There's no inherent need to repeatedly write the cumbersome <img> tag illustrated above. You can write your own custom tags, or write a wrapper script around mimeTeX to simplify the notation.

For example, if you're using phpBB2, then Jameson contributed the following typical one-line mod that lets you just write [tex] f(x)=\int_{-\infty}^xe^{-t^2}dt [/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
Wikimedia   "mimeTeX alternative"
MathWiki   "mimeTeX Parser"
PunBB   mimeTeX plugin
Movable Type   mimeTeX plugin
WordPress   mimeTeX plugin

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.

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

mimeTeX latexrender
 

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

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.

And the <img> tag to embed this same integral anywhere in your own document is

 <img src="../cgi-bin/mimetex.cgi?\large f(x)=\int_{-\infty}^xe^{-t^2}dt"
  alt="" border=0 align=middle>

The typical mimeTeX <img> tag has the form

 <img src="../cgi-bin/mimetex.cgi?any valid LaTeX/mimeTeX expression"
  alt="" border=0 align=middle>

where ../cgi-bin/mimetex.cgi is the relative path from your html page containing these tags to your compiled mimetex.cgi program, and where any valid LaTeX/mimeTeX expression is pretty much any valid LaTeX math expression:

(Ib) Examples  

Here are various additional random examples further demonstrating 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.


Some font examples ...

Finally, illustrated below are some examples of fonts and symbols available with mimeTeX. 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. And also not shown are various "constructed symbols" like \sqrt, accents, etc. 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

(Ic) 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 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. For example, courts will stop unauthorized use of unregistered material, but monetary damages are awarded _only_ if you register the copyright before infringement occurs.

(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 the LaTeX expression.
      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
---------------------------------------------------------------------
2004-08-07:09:00: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).
-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.
-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 REFERER is defined, mimeTeX performs a case-insensitive test of the environment variable HTTP_REFERER 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 emits an error message image instead of the requested image. You can manually modify invalid_referer_msg, defined in function main(), to personalize the error message for your own site.
      Finally, if HTTP_REFERER is not found as an environment variable, then mimeTeX correctly generates the requested image instead of generating an error.
-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 ).

(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...

For complete information about the characters and math symbols available in mimeTeX, you'll need to browse through the bottom 500-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     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.

I haven't exhaustively checked all the name-number matchings for the hundreds of 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.

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.

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.

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