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"; } ?>

 $\Large f=b_o+\frac{a_1}{b_1+\frac{a_2} {b_2+\frac{a_3}{b_3+a_4}}}$ m i m e T e X   m a n u a l ( for mimeTeX version $\small\versionnumber$ ) Click for:  LaTeX tutorial mimeTeX QuickStart mimeTeX Source Listing download mimeTeX $\Large\scr{J}^{ij}=\frac12\varepsilon_{ijk} \left[\begin{array}{cc}\sigma_k&0\\0&\sigma_k\end{array}\right]$ 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.)

email: john@forkosh.com

$\normalsize\blue\begin{matrix} \large\today\\\normalsize\today[3]\end{matrix}$

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     $x=\frac{-b\pm\sqrt{b^2-4ac}}{2a}$ just write the tag

# (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.
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 $\hspace{30}$ 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 $\hspace{30}$ mimeTeX unavailable $\large f(x)={\Large\frac1{\sigma\sqrt{2\pi}}} \int_{\small-\infty}^xe^{-\small\frac{(t-\mu)^2}{2\sigma^2}}dt$

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... \Large f(x)=\int_{-\infty}^x e^{-t^2}dt
Now click Submit to see it rendered below...

You should see   $\normalsize f(x)=\int\limits_{-\infty}^x e^{-t^2}dt$   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)     $\red\normalsize\displaystyle e^x=\sum_{n=0}^\infty\frac{x^n}{n!}$     $\green\large\displaystyle e^x=\sum_{n=0}^\infty\frac{x^n}{n!}$     $\blue\Large e^x=\sum_{n=0}^\infty\frac{x^n}{n!}$     $\reverse\opaque \LARGE e^x=\sum_{n=0}^\infty\frac{x^n}{n!}$     $\LARGE e^x=\lim_{n\to\infty} \left(1+\frac xn\right)^n$
(2) $\Large\frac{dv^m}{ds}=-\Gamma^m_{oo}v^{o^2} =-g^{mn}\Gamma_{noo}v^{o^2}=\frac12g^{mn}g_{oo,n}v^{o^2}$
(3) $\Large\varepsilon=\sum_{i=1}^{n-1} \frac1{\Delta x}\int_{x_i}^{x_{i+1}}\left\{\frac1{\Delta x}\big[ (x_{i+1}-x)y_i^\ast+(x-x_i)y_{i+1}^\ast\big]-f(x)\right\}^2dx$
(4)
 $\LARGE x=\frac{-b\pm\sqrt{b^2-4ac}}{2a}$ solution for quadratic $\large f^\prime(x)\ = \lim_{\Delta x\to0}\frac{f(x+\Delta x)-f(x)}{\Delta x}$ definition of derivative
(5) $\LARGE f=b_o+\frac{a_1}{b_1+ \frac{a_2}{b_2+\frac{a_3}{b_3+a_4}}}$ illustrating \frac{}{} for continued fraction
(6) $\LARGE\tilde y=\left\{ {\ddot x\text{ if \vec x odd}\atop\hat{\,\bar x+1}\text{ if even}}\right.$ illustrating \left\{...\right.
and note the accents
(7) $\large\overbrace{a,...,a}^{\text{k a^,s}}, \underbrace{b,...,b}_{\text{l b^,s}}\hspace{10} \normalsize\underbrace{\overbrace{a...a}^{\text{k a^,s}}, \overbrace{b...b}^{\text{l b^,s}}}_{\text{k+l elements}}$ \overbrace{}^{} and \underbrace{}_{}
(TeXbook page 181, Exercise 18.41)
(8)
(9) $\large \left(\large\begin{array}{GC+45} \varepsilon_x\\\varepsilon_y\\\varepsilon_z\\\gamma_{xy}\\ \gamma_{xz}\\\gamma_{yz}\end{array}\right)\ {\large=} \ \left[\begin{array}{CC} \begin{array}\frac1{E_{\fs{+1}x}} &-\frac{\nu_{xy}}{E_{\fs{+1}x}} &-\frac{\nu_{\fs{+1}xz}}{E_{\fs{+1}x}}\\ -\frac{\nu_{yx}}{E_y}&\frac1{E_{y}}&-\frac{\nu_{yz}}{E_y}\\ -\frac{\nu_{\fs{+1}zx}}{E_{\fs{+1}z}}& -\frac{\nu_{zy}}{E_{\fs{+1}z}} &\frac1{E_{\fs{+1}z}}\end{array} & {\LARGE 0} \\ {\LARGE 0} & \begin{array}\frac1{G_{xy}}&&\\ &\frac1{G_{\fs{+1}xz}}&\\&&\frac1{G_{yz}}\end{array} \end{array}\right] \ \left(\large\begin{array} \sigma_x\\\sigma_y\\\sigma_z\\\tau_{xy}\\\tau_{xz}\\\tau_{yz} \end{array}\right)$ Block diagonal form using nested \begin{array}'s.
Also, note rows aligned across all three arrays.
(10) $\large\left.\begin{eqnarray} x+y+z&=&3\\2y&=&x+z\\2x+y&=&z\end{eqnarray}\right\}$ using \begin{eqnarray} to align equations
(11) $\Large\begin{array}{rccclBCB} &f&\longrightarrow[75]^{\alpha:{\normalsize f\rightarrow g}}&g\\ \large\gamma&\longdownarrow[50]&&\longdownarrow[50]&\large\gamma\\ &u&\longrightarrow[75]_\beta&v\end{array}$ commutative diagram using \begin{array}
(12) $\large\hspace{5}\unitlength{1} \picture(175,100){ (50,50){\circle(100)} (1,50){\overbrace{\line(46)}^{3\;\;a}} (52,50){\line(125)} (50,52;115;2){\mid} (52,55){\longleftar[60]} (130,56){\longrightar[35]} (116,58){\small r} (c85,50;80;2){\small\bullet} (c85,36){\small -q} (c165,36){\small q} (42,29){\underbrace{\line(32)}_{\scriptsize a^2/r\;\;\;}} }$ 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) $\small\hspace{10}\unitlength{.75} \picture(120,220){ (60,200){\circle(120,40)} (0,20){\line(0,180)} (5,189;0,-30){\pict(110,20){(c20,10;70;2){ \pict(40,20){(20,10){\circle(40,20)}(c10,10)+(c30,10)-}} } } (119,20){\line(0,180)} (60,20){\circle(120,40;34)}}$ \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 $\small\unitlength{.75} \pict(40,20){(20,10) {\circle(40,20)}(c10,10)+(c30,10)-}$ 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 $\normalsize c=\sqrt{a^2+b^2}$

   <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) {
return true; }
else if (obj.attachEvent) { //For Internet Explorer.
var r = obj.attachEvent("on"+evType, fn);
return r; }
}
// Initialize after entire document is loaded
-->
</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 $$c=\sqrt{a^2+b^2}$$ to obtain the same $\normalsize c=\sqrt{a^2+b^2}$ image illustrated above

   #--------[open]-----------------------------------------------------
/includes/bbcode.php
#--------[find]-----------------------------------------------------
// Remove our padding from the string..
$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 $${TEXT}$$ 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 $\normalsize f(x)=\int\limits_{-\infty}^xe^{-t^2}dt$ doesn't look as good as the same image $\normalsize f(x)=\int\limits_{-\infty}^xe^{-t^2}dt$ 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  <?phpmimetexurl = "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 $\normalsize\frac12\left(a^2+b^2\right)$ 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.)

"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

 $\hspace{50}$ 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.
$\hspace{150}$

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

 README mimeTeX release notes COPYING GPL license, under which you may use mimeTeX mimetex.c mimeTeX source program and all required functions mimetex.h header file for mimetex.c (and for gfuntype.c) gfuntype.c parses output from gftype -i and writes bitmap data texfonts.h output from several gfuntype runs, needed by mimetex.c gifsave.c gif library by Sverre H. Huseby http://shh.thathost.com mimetex.html this file, the mimeTeX user's manual
Note: all files use Unix line termination, i.e., linefeeds (without carriage returns) signal line endings. Conversion for Windows PC's, Macs, VMS, etc, can usually be accomplished by unzip's -a option, i.e., unzip -a mimetex.zip

• To compile an executable that emits anti-aliased gif images (which is recommended for most uses), just type the following command from the Unix shell
cc -DAA mimetex.c gifsave.c -lm -o mimetex.cgi
• Or, to compile an executable that emit gif images without anti-aliasing
cc -DGIF mimetex.c gifsave.c -lm -o mimetex.cgi
• Alternatively, to compile an executable that emits mime xbitmaps
cc -DXBITMAP mimetex.c -lm -o mimetex.cgi
• Compile Notes:
• If (and only if) you're compiling a Windows executable with the -DAA or -DGIF option (but not -DXBITMAP), then add -DWINDOWS . For example,
gcc -DAA -DWINDOWS mimetex.c gifsave.c -lm -o mimetex.exe
The above Unix-like syntax works with MinGW and djgpp Windows compilers, but probably not with most others, where it's only intended as a "template".
Explanation: mimeTeX writes gif bytes directly to stdout, as usual for cgi's. But Windows treats stdout as a character stream, interpreting any hex 0A byte as an <lf>, and automatically preceding it with a spurious hex 0D   <cr> byte. The -DWINDOWS switch compiles in a non-portable, Windows-specific _setmode() call that sets stdout to binary mode.
• If you're compiling for Windows and would prefer to install mimeTeX as a Win32 DLL, see the Code Project developed by Shital Shah, and download eq2img_all.zip containing Shital's latest code.
• If you install mimeTeX on one server and try to use it from another, you may instead see messages like
$\message{3}$
In this case, compile mimetex.cgi with the -DNOREFCHECK switch, e.g.,
cc -DAA -DNOREFCHECK mimetex.c gifsave.c -lm -o mimetex.cgi
and read the -DREFLEVELS=n discussion under compile options below.

• The gfuntype program is only needed if you plan to change the font information in texfonts.h, as explained in Appendix IVa below. In that case, compile gfuntype with the command
cc gfuntype.c mimetex.c -lm -o gfuntype

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

• mv mimetex.cgi   (or move mimetex.exe)   to your server's cgi-bin/ directory, wherever cgi programs are expected.
• Now you may need to chmod 755 mimetex.cgi   and/or chown it, too, depending on your server's requirements. Contact your system administrator or ISP if you're not already familiar with this information.
• Once mimetex.cgi is moved to your server's cgi-bin/ directory, with permissions and owner set as necessary, you're all done.

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   $\normalsize x^2+y^2$   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   $\normalsize x^2+y^2$   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:

• mv mimetex.html (this file) to your server's htdocs/ directory
• Paths to cgi-bin/ and htdocs/ directories are typically path/www/cgi-bin/ and path/www/htdocs/, so I set up mimtex.html to access mimetex.cgi from the relative path ../cgi-bin/. If your directories are non-conforming, you may have to edit the few dozen occurrences of ../cgi-bin/mimetex.cgi in your mimetex.html page. Sometimes a suitable symlink works; if not, you'll have to edit. Globally changing ../cgi-bin/mimetex.cgi usually works.
• Now visit your page   http://www.yourdomain.com/mimetex.html
• Once your mimetex.html displays properly, you can assume everything is working, and can begin authoring html documents using mimetex.cgi to render your own math.

That's all there is to installing mimeTeX.

.

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
-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 $\tiny\begin{pmatrix}1&2&1\\2&\,8\,&2\\1&2&1\end{pmatrix}$ 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 $\normalsize\displaystyle\smashmargin{2}{\int\nolimits_a}^b$ at font sizes \normalsize and smaller, and rendered \displaystyle $\large\int_a^b$ 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\"
{ "\\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
$\message{0}$
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 $\normalsize\displaystyle \nosmash\frac12\int_{a+b+c}^{d+e+f}g(x)dx$. MimeTeX tries to remove extra whitespace, rendering the same expression as $\normalsize\displaystyle \smash\frac12\int_{a+b+c}^{d+e+f}{g(x)}dx$ 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 ).

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

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
$\large\advertisement \int_0^xe^{-x^2}dx$     instead of just     $\large \int_0^xe^{-x^2}dx$
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.
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.
$\advertisement x^2+y^2$     instead of just     $x^2+y^2$

## (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   $\large A\hspace{10} {\unitlength{2.5}B\hspace{10}C}\hspace{10}D$

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   $1\backsl\raise{-5}{\rotate{-90}]}$   (i.e., a \ followed by a blank). For example,   (a\/b\,c\:d\;e\  f\quad  g\qquad  h)   renders   $(a\/b\,c\:d\;e\ f\quad g\qquad h)$. 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   $a=b$   whereas   a\!=b   renders   $a\!=b$   and   a\!\!=b   renders   $a\!\!=b$. 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   $ABC\hspace*{-20}-DEF$,   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     $\large{abc\hfill{75}def}\hfill{150}ghi$

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     $\large y=a+b+c+d\\\hspace{50}+e+f+g+h$

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     $\large y=\{a+b+c+d\\ \hspace{50}+e+f+g+h\}$
whereas you probably wanted         $\large y=\big{a+b+c+d\\ \hspace{50}+e+f+g+h\big}$

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 $\large\cyr Khrushchev$. 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.

$\large \begin{array}{|c+57|c|c|c0|c|c|c|c|c| C25 C+15} \hline \large \textrm{a-z} & \small \backslash\textrm{text} & \small \backslash\textrm{mathbb} & & \large \textrm{A-Z} & \small \backslash\textrm{text} & \small \backslash\textrm{mathbb} & \small \backslash\textrm{mathcal} & \small \backslash\textrm{mathscr} \\ \hline a&\text{a}&\mathbb{a}& &A&\text{A}&\mathbb{A}&\mathcal{A}&\mathscr{A}\\ b&\text{b}&\mathbb{b}& &B&\text{B}&\mathbb{B}&\mathcal{B}&\mathscr{B}\\ c&\text{c}&\mathbb{c}& &C&\text{C}&\mathbb{C}&\mathcal{C}&\mathscr{C}\\ d&\text{d}&\mathbb{d}& &D&\text{D}&\mathbb{D}&\mathcal{D}&\mathscr{D}\\ e&\text{e}&\mathbb{e}& &E&\text{E}&\mathbb{E}&\mathcal{E}&\mathscr{E}\\ f&\text{f}&\mathbb{f}& &F&\text{F}&\mathbb{F}&\mathcal{F}&\mathscr{F}\\ g&\text{g}&\mathbb{g}& &G&\text{G}&\mathbb{G}&\mathcal{G}&\mathscr{G}\\ h&\text{h}&\mathbb{h}& &H&\text{H}&\mathbb{H}&\mathcal{H}&\mathscr{H}\\ i&\text{i}&\mathbb{i}& &I&\text{I}&\mathbb{I}&\mathcal{I}&\mathscr{I}\\ j&\text{j}&\mathbb{j}& &J&\text{J}&\mathbb{J}&\mathcal{J}&\mathscr{J}\\ k&\text{k}&\mathbb{k}& &K&\text{K}&\mathbb{K}&\mathcal{K}&\mathscr{K}\\ l&\text{l}&\mathbb{l}& &L&\text{L}&\mathbb{L}&\mathcal{L}&\mathscr{L}\\ m&\text{m}&\mathbb{m}& &M&\text{M}&\mathbb{M}&\mathcal{M}&\mathscr{M}\\ n&\text{n}&\mathbb{n}& &N&\text{N}&\mathbb{N}&\mathcal{N}&\mathscr{N}\\ o&\text{o}&\mathbb{o}& &O&\text{O}&\mathbb{O}&\mathcal{O}&\mathscr{O}\\ p&\text{p}&\mathbb{p}& &P&\text{P}&\mathbb{P}&\mathcal{P}&\mathscr{P}\\ q&\text{q}&\mathbb{q}& &Q&\text{Q}&\mathbb{Q}&\mathcal{Q}&\mathscr{Q}\\ r&\text{r}&\mathbb{r}& &R&\text{R}&\mathbb{R}&\mathcal{R}&\mathscr{R}\\ s&\text{s}&\mathbb{s}& &S&\text{S}&\mathbb{S}&\mathcal{S}&\mathscr{S}\\ t&\text{t}&\mathbb{t}& &T&\text{T}&\mathbb{T}&\mathcal{T}&\mathscr{T}\\ u&\text{u}&\mathbb{u}& &U&\text{U}&\mathbb{U}&\mathcal{U}&\mathscr{U}\\ v&\text{v}&\mathbb{v}& &V&\text{V}&\mathbb{V}&\mathcal{V}&\mathscr{V}\\ w&\text{w}&\mathbb{w}& &W&\text{W}&\mathbb{W}&\mathcal{W}&\mathscr{W}\\ x&\text{x}&\mathbb{x}& &X&\text{X}&\mathbb{X}&\mathcal{X}&\mathscr{X}\\ y&\text{y}&\mathbb{y}& &Y&\text{Y}&\mathbb{Y}&\mathcal{Y}&\mathscr{Y}\\ z&\text{z}&\mathbb{z}& &Z&\text{Z}&\mathbb{Z}&\mathcal{Z}&\mathscr{Z}\\ \hline \end{array}$

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

$\large \begin{array}{|l98c28c28|l98c28c28|l98c28c28|} \hline \; \\ \hspace{10}\backslash\textrm{Gamma} & \Gamma & \mathbb{\Gamma} & \hspace{10}\backslash\textrm{Delta} & \Delta & \mathbb{\Delta} & \hspace{10}\backslash\textrm{Theta} & \Theta & \mathbb{\Theta} \\ \hspace{10}\backslash\textrm{Lambda} & \Lambda & \mathbb{\Lambda} & \hspace{10}\backslash\textrm{Xi} & \Xi & \mathbb{\Xi} & \hspace{10}\backslash\textrm{Pi} & \Pi & \mathbb{\Pi} \\ \hspace{10}\backslash\textrm{Sigma} & \Sigma & \mathbb{\Sigma} & \hspace{10}\backslash\textrm{Upsilon} & \Upsilon & \mathbb{\Upsilon}& \hspace{10}\backslash\textrm{Phi} & \Phi & \mathbb{\Phi} \\ \hspace{10}\backslash\textrm{Psi} & \Psi & \mathbb{\Psi} & \hspace{10}\backslash\textrm{Omega} & \Omega & \mathbb{\Omega} \\ \; \\ \hline \; \\ \hspace{10}\backslash\textrm{alpha} & \alpha & \mathbb{\alpha} & \hspace{10}\backslash\textrm{beta} & \beta & \mathbb{\beta} & \hspace{10}\backslash\textrm{gamma} & \gamma & \mathbb{\gamma} \\ \hspace{10}\backslash\textrm{delta} & \delta & \mathbb{\delta} & \hspace{10}\backslash\textrm{epsilon} & \epsilon & \mathbb{\epsilon}& \hspace{10}\backslash\textrm{zeta} & \zeta & \mathbb{\zeta} \\ \hspace{10}\backslash\textrm{eta} & \eta & \mathbb{\eta} & \hspace{10}\backslash\textrm{theta} & \theta & \mathbb{\theta} & \hspace{10}\backslash\textrm{iota} & \iota & \mathbb{\iota} \\ \hspace{10}\backslash\textrm{kappa} & \kappa & \mathbb{\kappa} & \hspace{10}\backslash\textrm{lambda} & \lambda & \mathbb{\lambda} & \hspace{10}\backslash\textrm{mu} & \mu & \mathbb{\mu} \\ \hspace{10}\backslash\textrm{nu} & \nu & \mathbb{\nu} & \hspace{10}\backslash\textrm{xi} & \xi & \mathbb{\xi} & \hspace{10}\backslash\textrm{pi} & \pi & \mathbb{\pi} \\ \hspace{10}\backslash\textrm{rho} & \rho & \mathbb{\rho} & \hspace{10}\backslash\textrm{sigma} & \sigma & \mathbb{\sigma} & \hspace{10}\backslash\textrm{tau} & \tau & \mathbb{\tau} \\ \hspace{10}\backslash\textrm{upsilon} & \upsilon & \mathbb{\upsilon}& \hspace{10}\backslash\textrm{phi} & \phi & \mathbb{\phi} & \hspace{10}\backslash\textrm{chi} & \chi & \mathbb{\chi} \\ \hspace{10}\backslash\textrm{psi} & \psi & \mathbb{\psi} & \hspace{10}\backslash\textrm{omega} & \omega & \mathbb{\omega} \\ \; \\ \hline \; \\ \hspace{10}\backslash\textrm{varepsilon} & \varepsilon & & \hspace{10}\backslash\textrm{vartheta} & \vartheta & & \hspace{10}\backslash\textrm{varpi} & \varpi & \\ \hspace{10}\backslash\textrm{varrho} & \varrho & & \hspace{10}\backslash\textrm{varsigma} & \varsigma & & \hspace{10}\backslash\textrm{varphi} & \varphi & \\ \; \\ \hline \end{array}$

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   $\textstyle f(x)=\int_{-\infty}^x e^{-t^2}dt$   whereas   \displaystyle f(x)=\int_{-\infty}^x e^{-t^2}dt   renders   $\displaystyle f(x)=\int_{-\infty}^x e^{-t^2}dt$

$\large\textstyle \begin{array}{|l98c28c28|l98c28c28|l98c28c28|} \hline \; \\ \hspace{10}\backslash\textrm{cdot} & \cdot & & \hspace{10}\backslash\textrm{times} & \times & & \hspace{10}\backslash\textrm{ast} & \ast & \\ \hspace{10}\backslash\textrm{div} & \div & & \hspace{10}\backslash\textrm{diamond} & \diamond & & \hspace{10}\backslash\textrm{pm} & \pm & \\ \hspace{10}\backslash\textrm{mp} & \mp & & \hspace{10}\backslash\textrm{oplus} & \oplus & \Bigoplus & \hspace{10}\backslash\textrm{ominus} & \ominus & \\ \hspace{10}\backslash\textrm{otimes} & \otimes & \Bigotimes & \hspace{10}\backslash\textrm{oslash} & \oslash & & \hspace{10}\backslash\textrm{odot} & \odot & \Bigodot \\ \hspace{10}\backslash\textrm{bigcirc} & \bigcirc & & \hspace{10}\backslash\textrm{circ} & \circ & & \hspace{10}\backslash\textrm{bullet} & \bullet & \\ \hspace{10}\backslash\textrm{asymp} & \asymp & & \hspace{10}\backslash\textrm{equiv} & \equiv & & \hspace{10}\backslash\textrm{subseteq} & \subseteq & \\ \hspace{10}\backslash\textrm{supseteq} & \supseteq & & \hspace{10}\backslash\textrm{leq} & \leq & & \hspace{10}\backslash\textrm{geq} & \geq & \\ \hspace{10}\backslash\textrm{preceq} & \preceq & & \hspace{10}\backslash\textrm{succeq} & \succeq & & \hspace{10}\backslash\textrm{sim} & \sim & \\ \hspace{10}\backslash\textrm{approx} & \approx & & \hspace{10}\backslash\textrm{subset} & \subset & & \hspace{10}\backslash\textrm{supset} & \supset & \\ \hspace{10}\backslash\textrm{ll} & \ll & & \hspace{10}\backslash\textrm{gg} & \gg & & \hspace{10}\backslash\textrm{prec} & \prec & \\ \hspace{10}\backslash\textrm{succ} & \succ & & \hspace{10}\normalsize\backslash\textrm{leftarrow} & \leftarrow & & \hspace{10}\normalsize\backslash\textrm{rightarrow} & \rightarrow & \\ \hspace{10}\normalsize\backslash\textrm{uparrow} & \uparrow & & \hspace{10}\normalsize\backslash\textrm{downarrow} & \downarrow & & \hspace{10}\normalsize\backslash\textrm{leftrightarrow}&&\leftrightarrow\\ \hspace{10}\backslash\textrm{nearrow} & \nearrow & & \hspace{10}\backslash\textrm{searrow} & \searrow & & \hspace{10}\backslash\textrm{simeq} & \simeq & \\ \hspace{10}\normalsize\backslash\textrm{Leftarrow} & \Leftarrow & & \hspace{10}\normalsize\backslash\textrm{Rightarrow} & \Rightarrow & & \hspace{10}\normalsize\backslash\textrm{Uparrow} & \Uparrow & \\ \hspace{10}\normalsize\backslash\textrm{Downarrow} & \Downarrow & & \hspace{10}\normalsize\backslash\textrm{Leftrightarrow}&&\Leftrightarrow& \hspace{10}\backslash\textrm{nwarrow} & \nwarrow & \\ \hspace{10}\backslash\textrm{swarrow} & \swarrow & & \hspace{10}\backslash\textrm{propto} & \propto & & \hspace{10}\backslash\textrm{prime} & \prime & \\ \hspace{10}\backslash\textrm{infty} & \infty & & \hspace{10}\backslash\textrm{in} & \in & & \hspace{10}\backslash\textrm{ni} & \ni & \\ \hspace{10}\backslash\textrm{triangle} & \triangle & & \hspace{10}\normalsize\backslash\textrm{bigtriangledown}&&\bigtriangledown& \hspace{10}\backslash^\prime & \' & \\ \hspace{10}\textrm{/} & / & & \hspace{10}\backslash\textrm{forall} & \forall & & \hspace{10}\backslash\textrm{exists} & \exists & \\ \hspace{10}\backslash\textrm{neg} & \neg & & \hspace{10}\backslash\textrm{emptyset} & \emptyset & & \hspace{10}\backslash\textrm{Re} & \Re & \\ \hspace{10}\backslash\textrm{Im} & \Im & & \hspace{10}\backslash\textrm{top} & \top & & \hspace{10}\backslash\textrm{bot} & \bot & \\ \hspace{10}\backslash\textrm{aleph} & \aleph & & \hspace{10}\normalsize\backslash\textrm{mathcal\lbrace A\rbrace}&\;\mathcal{A}&....& .... \normalsize\backslash\textrm{mathcal\lbrace Z\rbrace}&\;\mathcal{Z}&\\ \; \\ \hline \end{array}$
$\large\textstyle \begin{array}{|l98c28c28|l98c28c28|l98c28c28|} \hline \; \\ \hspace{10}\backslash\textrm{cup} & \cup & \Bigcup & \hspace{10}\backslash\textrm{cap} & \cap & \Bigcap & \hspace{10}\backslash\textrm{uplus} & \uplus & \Biguplus \\ \hspace{10}\backslash\textrm{wedge} & \wedge & \Bigwedge & \hspace{10}\backslash\textrm{vee} & \vee & \Bigvee & \hspace{10}\backslash\textrm{vdash} & \vdash & \\ \hspace{10}\backslash\textrm{dashv} & \dashv & & \hspace{10}\backslash\textrm{lfloor} & \lfloor & & \hspace{10}\backslash\textrm{rfloor} & \rfloor & \\ \hspace{10}\backslash\textrm{lceil} & \lceil & & \hspace{10}\backslash\textrm{rceil} & \rceil & & \hspace{10}\backslash\textrm{lbrace} & \lbrace & \\ \hspace{10}\backslash\textrm{rbrace} & \rbrace & & \hspace{10}\backslash\textrm{langle} & \langle & & \hspace{10}\backslash\textrm{rangle} & \rangle & \\ \hspace{10}\backslash\textrm{mid} & \mid & & \hspace{10}\backslash\textrm{parallel} & \parallel & & \hspace{10}\normalsize\backslash\textrm{updownarrow}& & \updownarrow \\ \hspace{10}\normalsize\backslash\textrm{Updownarrow}& & \Updownarrow & \hspace{10}\backslash\textrm{setminus} & \setminus & & \hspace{10}\backslash\textrm{wr} & \wr & \\ \hspace{10}\backslash\textrm{surd} & \raisebox{15}\surd & & \hspace{10}\backslash\textrm{amalg} & \amalg & & \hspace{10}\backslash\textrm{nabla} & \nabla & \\ \hspace{10}\backslash\textrm{int} & \int & \Bigint & \hspace{10}\backslash\textrm{sqcup} & \sqcup & \Bigsqcup & \hspace{10}\backslash\textrm{sqcap} & \sqcap & \\ \hspace{10}\normalsize\backslash\textrm{sqsubseteq} & \sqsubseteq & & \hspace{10}\normalsize\backslash\textrm{sqsupseteq} & \sqsupseteq & & \hspace{10}\backslash\textrm{S} & \S & \\ \hspace{10}\backslash\textrm{dag} & \dag & & \hspace{10}\backslash\textrm{ddag} & \ddag & & \hspace{10}\backslash\textrm{P} & \P & \\ \hspace{10}\backslash\textrm{clubsuit} & \clubsuit & & \hspace{10}\backslash\textrm{Diamond} & \Diamond & & \hspace{10}\backslash\textrm{Heart} & \Heart & \\ \hspace{10}\backslash\textrm{spadesuit} & \spadesuit & \\ \; \\ \hline \end{array}$
$\large\textstyle \begin{array}{|l98c28c28|l98c28c28|l98c28c28|} \hline \; \\ \hspace{10}\backslash\textrm{oint} & \oint & \Bigoint & \hspace{10}\backslash\textrm{sum} & \sum & \Bigsum & \hspace{10}\backslash\textrm{prod} & \prod & \Bigprod \\ \hspace{10}\backslash\textrm{coprod} & \coprod & \Bigcoprod \\ \; \\ \hline \; \\ \hspace{10}\normalsize\backslash\textrm{leftharpoonup} &&\leftharpoonup& \normalsize\backslash\textrm{leftharpoondown} &&\;\leftharpoondown& \hspace{10}\normalsize\backslash\textrm{rightharpoonup}&&\rightharpoonup\\ \normalsize\backslash\textrm{rightharpoondown}&&\;\rightharpoondown& \hspace{10}\normalsize\backslash\textrm{triangleright} &&\triangleright& \hspace{10}\normalsize\backslash\textrm{triangleleft} &&\triangleleft\\ \normalsize\backslash\textrm{rightleftharpoons}&&\;\rightleftharpoons& \hspace{10}\backslash\textrm{star} & \LARGE{\star} & & \hspace{10}\backslash\textrm{partial} & \partial & \\ \hspace{10}\backslash\textrm{flat} & \flat & & \hspace{10}\backslash\textrm{natural} & \natural & & \hspace{10}\backslash\textrm{sharp} & \sharp & \\ \hspace{10}\backslash\textrm{smile} & \smile & & \hspace{10}\backslash\textrm{frown} & \frown & & \hspace{10}\backslash\textrm{ell} & \ell & \\ \hspace{10}\backslash\textrm{imath} & \imath & & \hspace{10}\backslash\textrm{jmath} & \jmath & & \hspace{10}\backslash\textrm{wp} & \wp & \\ \; \\ \hline \; \\ \hspace{10}\backslash\textrm{ss} & \ss & & \hspace{10}\backslash\textrm{ae} & \ae & & \hspace{10}\backslash\textrm{oe} & \oe & \\ \hspace{10}\backslash\textrm{AE} & \AE & & \hspace{10}\backslash\textrm{OE} & \OE & \\ \; \\ \hline \; \\ \hspace{10}\backslash\textrm{AA} & \AA & & \hspace{10}\backslash\textrm{aa} & \aa & & \hspace{10}\backslash\textrm{hbar} & \hbar & \\ \hspace{10}\backslash\textrm{ldots} & \ldots & & \hspace{10}\backslash\textrm{cdots} & \cdots & & \hspace{10}\backslash\textrm{vdots} & \vdots & \\ \hspace{10}\backslash\textrm{ddots} & \ddots & & \hspace{10}\backslash\textrm{angle} & \angle & & \hspace{10}\backslash\textrm{iint} & \iint & \Bigiint \\ \; \\ \hline \end{array}$

### 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:     produces... $\tiny f(x)=x^2$ 1:   $\fs1 f(x)=x^2$ 2:   $\normalsize f(x)=x^2$ 3:   $f(x)=x^2$ 4:   $\Large f(x)=x^2$ 5:   $\fs5f(x)=x^2$ 6:   $\huge f(x)=x^2$ 7:   $\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   $\Large y=e^{x^2}$

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   $\Large y=e^{\normalsize x^{\tiny2}}$

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 $\large\text{abc{\fs{-2}def}ghi}$, 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   $\Large y=e^{\fs{-1}x^2}$

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 $\array{r 2\rm~size~4:~&4A&4B&4C&4D,&4a&4b&4c&4d\\ 2\rm~3:~&3E&3F&3G&3H&3I&3J&3K&3L,&3e&3f&3g&3h&3i&3j&3k&3l\\ 2\rm~2:~&2M&2N&2O&2P&2Q&2R&2S&2T&2U&2V&2W&2X&2Y&2Z,& 2m&2n&2o&2p&2q&2r&2s&2t&2u&2v&2w&2x&2y&2z}$ calligraphic, and rsfs (\cal{A}, \scr{B}, etc) $\array{r 2\rm~size~4:~&4\calA&4\calB&4\calC&4\calD&4\calE&4\calF&4\calG,& 4\scrA&4\scrB&4\scrC&4\scrD&4\scrE&4\scrF&4\scrG\\ 2\rm~3:~&3\calH&3\calI&3\calJ&3\calK&3\calL&3\calM&3\calN&3\calO& 3\calP,& 3\scrH&3\scrI&3\scrJ&3\scrK&3\scrL&3\scrM&3\scrN&3\scrO&3\scrP\\ 2\rm~2:~&2\calQ&2\calR&2\calS&2\calT&2\calU& 2\calV&2\calW&2\calX&2\calY&2\calZ,& 2\scrQ&2\scrR&2\scrS&2\scrT&2\scrU&2\scrV&2\scrW& 2\scrX&2\scrY&2\scrZ}$ cmmi greek uppercase, and \var lowercase $\array{r 2\rm~size~4:~&4\Gamma&4\Delta&4\Theta&4\Lambda&4\Xi&4\Pi&4\Sigma& 4\Upsilon&4\Phi&4\Psi&4\Omega,&4\rm~~&4\varepsilon&4\vartheta&4\varpi& 4\varrho&4\varsigma&4\varphi\\ 2\rm~3:~&3\Gamma&3\Delta&3\Theta&3\Lambda&3\Xi&3\Pi&3\Sigma& 3\Upsilon&3\Phi&3\Psi&3\Omega,&~&3\varepsilon&3\vartheta&3\varpi& 3\varrho&3\varsigma&3\varphi\\ 2\rm~2:~&2\Gamma&2\Delta&2\Theta&2\Lambda&2\Xi&2\Pi&2\Sigma& 2\Upsilon&2\Phi&2\Psi&2\Omega,&~&2\varepsilon&2\vartheta&2\varpi& 2\varrho&2\varsigma&2\varphi}$ cmmi greek lowercase $\array{r 2\rm~size~4:~&4\alpha&4\beta&4\gamma&4\delta&4\epsilon&4\zeta& 4\eta&4\theta&4\iota&4\kappa&4\lambda&4\mu&4\nu&4\xi&4%%\omicron%%& 4\pi&4\rho&4\sigma&4\tau&4\upsilon&4\phi&4\chi&4\psi&4\omega\\ 2\rm~3:~&3\alpha&3\beta&3\gamma&3\delta&3\epsilon&3\zeta& 3\eta&3\theta&3\iota&3\kappa&3\lambda&3\mu&3\nu&3\xi&3%%\omicron%%& 3\pi&3\rho&3\sigma&3\tau&3\upsilon&3\phi&3\chi&3\psi&3\omega\\ 2\rm~2:~&2\alpha&2\beta&2\gamma&2\delta&2\epsilon&2\zeta& 2\eta&2\theta&2\iota&2\kappa&2\lambda&2\mu&2\nu&2\xi&2%%\omicron%%& 2\pi&2\rho&2\sigma&2\tau&2\upsilon&2\phi&2\chi&2\psi&2\omega}$ cmsy symbols at mimeTeX font size 3 (operators shown large are automatically "promoted" to the larger size in \displaystyle mode) $\array{3,r1\rm~chars~\\ 1\rm~0-15:~&-&\cdot&\times&\ast&\div&\diamond&\pm&\mp& \oplus&\ominus&\otimes&\oslash&\odot&\bigcirc&\circ&\bullet\\ 1\rm~16-31:~&\asymp&\equiv&\subseteq&\supseteq&\leq&\geq&\preceq&\succeq& \sim&\approx&\subset&\supset&\ll&\gg&\prec&\succ\\ 1\rm~32-47:~&\leftar&\rightar&\uparr&\downar&\leftrightar&\near&\sear& \simeq&\Leftar&\Rightar&\Upar&\Downar&\Leftrightar&\nwar&\swar&\propto\\ 1\rm~48-63:~&\prime&\infty&\in&\ni&\triangle&\bigtriangledo&/&\'& \forall&\exists&\neg&\emptyset&\Re&\Im&\top&\bot\\ 1\rm~64-100:~&\aleph&&\calA&4.\,.\,.&\calZ&&\cup&\cap& \uplus&\wedge&\vee&\vdash&\dashv&\lfloor&\rfloor&\lceil\\ 1\rm~101-116:~&\rceil&\lbrace&\rbrace&\langle&\rangle&\mid&\parallel& \updownar&\Updownar&\setminus&\wr&\surd&\amalg&\nabla&\int&\sqcup\\ 1\rm~117-127:~&\sqcap&\sqsubseteq&\sqsupseteq&\S&\dag&\ddag&\P&\clubsuit& \Diamond&\Heart&\spadesuit}$ a few other cmmi, cmr, stmary and wncyr symbols at mimeTeX font size 4 $\array{4,r 1\rm~cmmi:~&\leftharpoonup&\leftharpoondo&\rightharpoonup&\rightharpoondo& \triangleright&\triangleleft&\star&\partial& \flat&\natural&\sharp&\smile&\frown&\ell&\imath&\jmath&\wp&\vec\\ 1\rm~cmr:~&\ss&\ae&\oe&\AE&\OE \\ 1\rm~stmary:~&\moo&\Lbag&\Rbag&\lightning&\llbracket&\rrbracket& \subsetpluseq&\supsetpluseq&\Yup&\Ydown\\ 1\rm~wncyr:~&\cyr A&\cyr a&\cyr B&\cyr b&\cyr V&\cyr v&\cyr G&\cyr g& \cyr D&\cyr d&\cyr Dj&\cyr dj&\cyr\=E&\cyr\=e&\cyr Zh&\cyr zh}$

### 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 $\normalsize\int_a^b$ at font sizes \normalsize and smaller, and rendered \displaystyle $\large\int_a^b$ 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     $\normalsize\sum_{i=1}^ni=\frac{n(n+1)}2$,   whereas
\displaystyle \normalsize \sum_{i=1}^ni=\frac{n(n+1)}2  produces  $\normalsize\displaystyle\sum_{i=1}^ni=\frac{n(n+1)}2$,

and

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

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   $\large\sum\nolimits_{i=1}^ni=\frac{n(n+1)}2$

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   $\normalsize\sum\limits_{i=1}^ni=\frac{n(n+1)}2$

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

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

Likewise, for subexpressions,

\widehat{xyz}\limits^a   produces   $\large\widehat{xyz}\limits^a$

This side effect may occasionally be useful. For example,

x\rightarrow\limits^gy   produces   $\large x\rightarrow\limits^gy$

(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   $\normalsize\sum_1^n {\displaystyle\sum_1^k\sum_1^lx_i^j}\sum_1^m$

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   $\normalsize anything at all$     whereas

\text{anything at all}   produces   $\normalsize\text{anything at all}$     and

\textit{anything at all}   produces   $\normalsize\textit{anything at all}$     instead.


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

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
$\large\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}$

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   $\small\array{C\gamma&\Large\downarr}$   and for   $\small\array{C\Large\downarr&\beta}$) 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).
$\hspace{35}$ 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.
$\hspace{35}$ 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.
$\hspace{35}$ Click one of the following examples to see illustrations of the above discussion:

$\large \left( \begin{array}{GC+30} \cos\frac\theta2 & i\,\sin\frac\theta2\\ i\,\sin\frac\theta2 & \cos\frac\theta2 \end{array} \right) \left( \begin{array} z & x_{\tiny-} \\ x_{\tiny+} & -z \end{array} \right) \hfill{300}\text{\normalsize Example 1}$
$\large \left( \begin{array}{GC+30gc+40} \cos\frac\theta2 & i\,\sin\frac\theta2 \\ i\,\sin\frac\theta2 & \cos\frac\theta2 \end{array} \right) \left( \begin{array} z & x_{\tiny-} \\ x_{\tiny+} & -z \end{array} \right) \hfill{300}\text{\normalsize Example 2}$

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   $\large abc\circle(20)def$.

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) {
(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%%   }

$\normalsize\unitlength{.6}\picture(100){ (50,50){\circle(99)} (20,55;50,0;2){\fs{+1}\hat\bullet} (50,40){\bullet} (50,35){\circle(50,25;34)} (50,35){\circle(50,45;34)}}$
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

• \frac{ }{ } and { \over }
• { \atop } and { \choose }
• \sqrt{ }
• \lim_{ } and all the usual LaTeX function names
• \hat{ } and \widehat{ } and many of the usual LaTeX accents
• \overbrace{ }^{ } and \underbrace{ }_{ }
• \overline{ } and \underline{ }

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   $\Large\vec x\,\overset{\small\rm def}= \,(x_1\ldots x_n)$

"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   $\Large\underset{\small\rm base 2}\log32\,=\,5$

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   $\Large\vec x\,=\limits^{\small\rm def} \,(x_1\ldots x_n)$

and   "\log\limits_{\rm base 2}32=5"   produces   $\Large\log\limits_{\small\rm base 2}32\,=\,5$

### \fbox{ }...

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

"\fbox{x=\frac12}"   produces   $\Large\fbox{x=\frac12}$

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   $\normalsize\today$   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   $\normalsize\blue\today[2]$,   showing both date and time. And   \red\today[3]   renders   $\normalsize\red\today[3]$,   showing time only.

To accommodate time zones, you may also write, for example,   \small\blue\today[2,+3],   which renders   $\small\blue\today[2,+3]$,   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.

$\normalsize\calendar$           $\small\blue\calendar[2001,9]$

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

$\nocaching\environment$

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 $\normalsize\alpha\beta\gamma\delta$, but you mistakenly type   \alpha\bethe\gamma\delta   instead. Then the image rendered is $\normalsize\alpha\bethe\gamma\delta$, indicating the unrecognized [\bethe?] where you wanted to type   \beta   and hoped to see $\normalsize\bf\beta$. If your expression contains some unprintable character (meaning any character mimeTeX has no bitmap for), then just   $\small\bf[?]$   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:

• An unmatched left brace   {   is matched by mimeTeX with a "phantom" right brace   }   that's imagined to be at the end of your expression.
• Likewise, an unmatched   \left(,   or \left\{   or \left\anything,   is matched by mimeTeX with a "phantom"   \right.   at the end of your expression.
• On the other hand, an unmatched right brace   }   is displayed in place, as if you had typed \rbrace.
• But an unmatched   \right\anything   is interpreted as an abbreviation for \rightarrow followed by \anything. For example,   \leff( abc \right) def   renders   $\small\leff(abc\right)def$.

### mimeTeX Messages...

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

$\version$

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   $\normalsize\frac{\log(dpi/2602)}{\log1.2}$.   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

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

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 $\hspace{100}$ $\blue{\small\rm You're the } \Large\counter[counters.log]{counters.txt:mimetex.html}\\[0] {\small\rm visitor to this page.$