--- loncom/cgi/mimeTeX/mimetex.html 2005/02/28 19:08:11 1.1 +++ loncom/cgi/mimeTeX/mimetex.html 2012/06/09 00:58:11 1.5 @@ -1,10 +1,11 @@ - + - + + + + + 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"; + } + ?> + + + @@ -116,7 +212,10 @@ Banner across top of page, containing ti
m i m e T e X   m a n u a l
- ( for mimeTeX version 1.60 )
+ ( for mimeTeX version + )
Click for:  @@ -124,8 +223,14 @@ Banner across top of page, containing ti LaTeX tutorial
mimeTeX QuickStart
- - + + mimeTeX Source Listing
+ + download mimeTeX
@@ -135,43 +240,54 @@ Banner across top of page, containing ti alt="" border=0 align=middle>
more_examples... + + This page discusses mimeTeX, a program that displays math on the web.
+ (See + Writing Math on the Web + for a more general discussion.) +
-Copyright © 2002-2005, +Copyright © 2002-2012, John Forkosh Associates, Inc.
email: john@forkosh.com -
+

+ -

-
-       C o n t e n t s       -
+
+         C o n t e n t s         +
- + - - - T u t o r i a l - - - + + c. Scripts&Plugins
+ d. GPL License + a. Compile
+ b. Install
+ c. Compile Options
+ d. Command Line + h. Other Exceptions
+ i. Errors and Messages -
- - - - T u t o r i a l - - - -- - - - - - - - - - - - - - R e f e r e n c e - - - - - - - - - - - - - - + - - - - - - - - - - - - - - R e f e r e n c e - - - - - - - - - - - - - - +
  (I) Introduction  
a. Quick Start
b. Examples
- c. GPL License
  (II) Building mimeTeX  
- a. Download
- b. Compile
- c. Install
- d. Compile Options
- e. Command Line
  (III) Syntax Reference  
a. Math & White Space
@@ -181,7 +297,8 @@ Table of Contents e. \begin{array}
f. \picture( ){ }
g. Other Commands
- h. Other Exceptions
    (IV) Appendices    
a. Fonts
@@ -189,7 +306,70 @@ Table of Contents c. gifsave.c
  Remarks  
+ +
+ + +

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

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

+   + + + + + + +

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

+ spend more time learning to use it.

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, instead, + 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 expression, use the sample provided, + 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.

@@ -383,10 +685,9 @@ QUICKSTART
- @@ -396,7 +697,8 @@ QUICKSTART  
- +
+ First enter your own LaTeX expression, + or Click any example...

-
+ + Now click Submit to see it rendered below...
@@ -405,50 +707,113 @@ QUICKSTART

You should see   if you submit the sample expression - already in the box.

- -

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

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

You can see numerous additional examples illustrating html - <img> tags using mimeTeX by viewing this page's source. - The typical mimeTeX <img> tag has the form

+ src="../cgi-bin/mimetex.cgi?\normalsize + f(x)=\int\limits_{-\infty}^x e^{-t^2}dt" + alt="" border=0 style="Vertical-Align:-11px">   + 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 demonstrating +

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 @@ -472,27 +837,27 @@ EXAMPLES                 @@ -579,7 +944,7 @@ EXAMPLES illustrating \left\{...\right. @@ -595,7 +960,7 @@ EXAMPLES (8) - + @@ -645,10 +1013,10 @@ EXAMPLES
demonstrating \begin{array}'s dashed lines @@ -711,13 +1079,13 @@ using \longxxxarrow[] and \begin{array} mimeTeX \picture(size){pic_elems} @@ -752,18 +1120,22 @@ using \longxxxarrow[] and \begin{array} The image at left is picture-in-picture-in-picture.
-

+ + + +

(Ic) Scripts & Plugins  

+ +

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

+ +

+mimeTeX plugins...

+ + +

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

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

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

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

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

+ +

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

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

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

+ +

+Vertical alignment...

+

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

+ +

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

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

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

+ +

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

-

(Ic) GPL License  

+

(Id) GPL License  

"My grandfather once told me there are two kinds of people:
@@ -865,19 +1532,25 @@ Indira Gandhi, the late Prime Minister o evolve to make this kind of obnoxious banter unnecessary. In the meantime, please forgive me my paranoia.

-

To protect your own intellectual property, I recommend - Copyright Basics from The Library of Congress, and - similarly, Copyright Basics from The American Bar Association. +

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.

- + on you for demonstrating your intent by registering the copyright. +

+ + + @@ -2306,6 +4014,9 @@ Raise and rotate, Compose, Abb + + + @@ -2348,8 +4059,8 @@ Raise and rotate, Compose, Abb

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 3. In addition, any &...& cell may contain font + {\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.

@@ -2536,7 +4247,7 @@ Raise and rotate, Compose, Abb (50,35){\circle(50,45;34)} %%lower lip%%   }


Have a nice day!
@@ -2564,19 +4275,21 @@ Raise and rotate, Compose, Abb in LaTeX, and won't be discussed further. Short discussions of some other commands follow.

-

\stackrel{ }{ } and -\relstack{ }{ }...

+

\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\stackrel{\rm def}=(x_1\ldots x_n)" + "\vec x\overset{\rm def}=(x_1\ldots x_n)"   produces  

"Conversely" to \stackrel{ }{ }, mimeTeX provides @@ -2586,10 +4299,10 @@ Raise and rotate, Compose, Abb 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,

- "\relstack{\log}{\rm base 2}32=5"   to render   + "\underset{\rm base 2}\log32=5"   to render  

MimeTeX's \limits provides an easier but non-standard @@ -2612,7 +4325,7 @@ Raise and rotate, Compose, Abb the usual \fbox{expression} command, e.g.,

"\fbox{x=\frac12}"   produces  

You can also write \fbox[width]{expression} @@ -2620,6 +4333,58 @@ Raise and rotate, Compose, Abb \fbox[width][height]{expression} to explicitly set both width and height.

+

\today and \calendar...

+ +

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

+ +

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

+ +

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

+
+           +
+ +

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

+

\input{ }...

@@ -2635,6 +4400,14 @@ Raise and rotate, Compose, Abb 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 @@ -2659,6 +4432,14 @@ Raise and rotate, Compose, Abb 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 @@ -2686,7 +4467,7 @@ Raise and rotate, Compose, Abb

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 - 2004-09-20:12:59:33pm <tag>=99 192.168.1.1 http_referer + 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.

@@ -2700,6 +4481,25 @@ Raise and rotate, Compose, Abb unless/until you "touch" and "chmod" counters.txt (and, optionally, counters.log) in your mimetex.cgi directory.

+

\environment +...

+

Submitting the expression   \environment   + to mimeTeX renders

+
+

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

+ +

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

+

(IIIh) Other Exceptions to LaTeX Syntax  

@@ -2716,6 +4516,98 @@ to LaTeX Syntax   e.g., you must write \sqrt{\frac\alpha\beta}, etc.

+

(IIIi) mimeTeX Errors +and Messages  

+ +

mimeTeX Errors...

+ +

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

+ +

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

+ + +

mimeTeX Messages...

+ + +

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

+
+
+

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

+ + @@ -2739,13 +4631,14 @@ SECTION IV. APPENDICES (supplied with your mimeTeX distribution).

The final output from each such sequence of three runs - (metafont > gftype -i > gfuntype) gives mimeTeX the 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 36 such (sequences of) - runs, representing six font families at six sizes each.

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

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 @@ -2762,7 +4655,8 @@ SECTION IV. APPENDICES

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=onetz; mag=magstep(.5); input cmmi10'
+
+ 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).

@@ -2788,39 +4682,54 @@ SECTION IV. APPENDICES 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 36 sequences of runs represented +

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

-
   size=0 (.83gf)   mf '\mode=eighthre; input cmr10'
+  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 five other font families cmmi10, cmsy10, cmex10, - rsfs10, bbold10. All the subsequent gftype and gfuntype runs just - follow the usual format described above.

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

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

    static fontfamily aafonttable[] =
-     { /* -------------------------------------------------------------
-          family   size=0,       1,       2,       3,       4,      5
-       ------------------------------------------------------------- */
-       {  CMR10, {  cmr83,  cmr100,  cmr118,  cmr131,  cmr160,  cmr180 } },
-       { CMMI10, { cmmi83, cmmi100, cmmi118, cmmi131, cmmi160, cmmi180 } },
-       { CMSY10, { cmsy83, cmsy100, cmsy118, cmsy131, cmsy160, cmsy180 } },
-       { CMEX10, { cmex83, cmex100, cmex118, cmex131, cmex160, cmex180 } },
-       { RSFS10, { rsfs83, rsfs100, rsfs118, rsfs131, rsfs160, rsfs180 } },
-       {BBOLD10, {bbold83,bbold100,bbold118,bbold131,bbold160,bbold180 } },
-       {   -999, {   NULL,    NULL,    NULL,    NULL,    NULL,    NULL } }
-     } ; /* --- end-of-fonttable[] --- */

- Note the 36 names cmr83...bbold180 in the table. These must + 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.

+ switch you specified for your   gfuntype   runs.

-

If you want more than six font sizes, first build up texfonts.h +

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.

@@ -2831,6 +4740,51 @@ SECTION IV. APPENDICES 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  

@@ -2855,7 +4809,8 @@ function  

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

@@ -2910,8 +4865,8 @@ function   }

Cut-and-paste as before, compile like
-         cc mimedemo.c mimetex.c gifsave.c - -lm -o mimedemo
+         + 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" @@ -3194,7 +5149,7 @@ Footer across bottom of page



Very quickly   ---   download - - + + mimetex.zip and then type @@ -906,149 +1579,112 @@ SECTION II. BUILDING MIMETEX

I've built and run mimeTeX under Linux and NetBSD using gcc. The source - code is ansi-standard C, and should compile and execute under all - environments without any change whatsoever. Build instructions below + 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).

-

A summary of the steps needed to build mimeTeX is

+

(IIa) Download and Compile  

+ +

The steps needed to download and compile mimeTeX are

  • Download and unzip - - - mimetex.zip in any convenient working directory.
  • + + + mimetex.zip in any convenient working directory. + Your working directory should now contain
    +
+ + + + + + + + +
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 how the page you're viewing is displayed)
    -   cc -DAA mimetex.c gifsave.c -lm -o mimetex.cgi
  • -
  • or, to emit gif images without anti-aliasing
    -   cc -DGIF mimetex.c gifsave.c -lm -o mimetex.cgi
  • + (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
  • +         + 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,
      -         cc -DAA -DWINDOWS - mimetex.c gifsave.c -lm -o mimetex.cgi
      +         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".
    • + 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
      +
      + 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.
    • -
  • - -

    And a summary of the steps needed to install mimeTeX is

    -
      -
    • Just   mv mimetex.cgi   to your server's cgi-bin/ - directory, set permissions as necessary, and you're all done.
    • -
    • Now, to quickly test your mimetex.cgi, try typing a url into - your browser's locator window something like   - http://www.yourdomain.com/cgi-bin/mimetex.cgi?x^2+y^2 -   which should display   -   in the upper-left corner of your window.
    • -
    • After the preceding test succeeds, you can optionally - "regression test" all mimeTeX features as follows:
        -
      • mv mimetex.html (this file) to your server's htdocs/ - directory
      • -
      • If the relative path from htdocs to cgi-bin isn't - ../cgi-bin then edit mimetex.html and change the - few dozen occurrences as necessary (globally changing - ../cgi-bin/mimetex.cgi should work).
      • -
      • Now visit your page   - http://www.yourdomain.com/mimetex.html
      • -
      • Once mimetex.html displays properly, you can assume - everything is working, and can begin authoring html documents - using mimetex.cgi to render your own math.
      +

    +
  • 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
  • -

    Any problems with the above? - Read the more detailed instructions below.

    - - -

    (IIa) Download  

    - -

    Download - - - mimetex.zip and unzip it in any convenient working directory. - Your working directory should now contain

    - - - - - - - - - -
    README mimeTeX release notes
    LICENSE 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, mimeTeX tutorial and - 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

    - - -

    (IIb) Compile  

    - -

    To compile a mimeTeX executable that emits anti-aliased gif images - (which is recommended for most uses) issue the command

    -
    cc -DAA mimetex.c gifsave.c -lm -o mimetex.cgi -
    - -

    Or, for an executable that emits gif images without anti-aliasing, - issue the command

    -
    cc -DGIF mimetex.c gifsave.c -lm -o mimetex.cgi -
    - -

    Alternatively, to compile a mimeTeX executable that emits - mime xbitmaps, just issue the command

    -
    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,
      -         cc -DAA -DWINDOWS - mimetex.c gifsave.c -lm -o mimetex.cgi
      - 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.
    • -
    - -

    Several other optional compile-line options +

    That's all there is to compiling mimeTeX. + Several other optional compile-line options available for mimetex.c are discussed 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 building mimeTeX. You can now test your - mimetex.cgi executable from the Unix command line by typing, e.g., - ./mimetex.cgi "x^2+y^2" which should emit two ascii - rasters something like the following

    + 

    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*..
    @@ -1069,32 +1705,81 @@ Ascii dump of bitmap image...
         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 the two ascii rasters then your
    -    binary's good, so mv it to your server's cgi-bin/ directory and
    -    set permissions as necessary. 

    - -

    (IIc) Install  

    - -

    Once mimetex.cgi is working, mv it to your server's cgi-bin/ - directory (wherever cgi programs are expected), and chmod/chown it - if necessary. Then mv mimetex.html to your server's htdocs/ - directory. Now point your browser to www.yourdomain.com/mimetex.html , - and you should see a page identical to this one.

    - -

    Note: the two directories are typically of the form - somewhere/www/cgi-bin/ and somewhere/www/htdocs/ , so I set up - mimtex.html to get 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 mimetex.html . - Sometimes a suitable symlink works; if not, you'll have to edit. - Globally changing ../cgi-bin/mimetex.cgi often works.

    - -

    Either way, once mimetex.html displays properly, you can assume - everything is working, and can begin authoring html documents using - mimetex.cgi to render your own math.

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

    -

    (IId) Additional Compile-Line Options  

    +

    (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   +   + in the upper-left corner of your window, + just like clicking this link does, which tests my mimetex.cgi,
    +         + http://www.forkosh.com/cgi-bin/mimetex.cgi?x^2+y^2
    + If you see the same     + image from the yourdomain link, then you've completed + a successful mimeTeX installation.

    + +

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

    + +

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

    +
      +
    • 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.

    . + + +

    (IIc) Additional Compile-Line Options  

    In addition to -DAA or -DGIF or -DXBITMAP (along with -DWINDOWS when necessary) on the mimetex.c compile line, as discussed above, @@ -1125,9 +1810,9 @@ Ascii dump of bitmap image... algorithm for anti-aliasing, which is applied to the existing set of bitmap fonts. This lowpass filter applies weights to neighboring pixels. The defaults - weights are CENTERWT=32, ADJACENTWT=3 and CORNERWT=1, + 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 @@ -1143,20 +1828,35 @@ Ascii dump of bitmap image... is relative to mimetex.cgi, and must be writable by it. Files created under path/ are named filename.gif, where filename - is the 32-character MD5 hash of the LaTeX expression.
    -       When caching a new image, mimeTeX also + 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
    ---------------------------------------------------------------------
    -2004-08-07:09:00:53am            f8ccc8dd93c8eeb1d9c40b353ef781e0.gif
    +2008-09-07:11:29:53am            f8ccc8dd93c8eeb1d9c40b353ef781e0.gif
     \LARGE x=\frac{-b\pm\sqrt{b^2-4ac}}{2a}
     ---------------------------------------------------------------------
    +
    -DDEFAULTSIZE=n
    +
    MimeTeX currently has eight font sizes numbered 0-7, + and always starts out in DEFAULTSIZE, whose default value is 3. + Specify -DDEFAULTSIZE=2 on the compile line if you prefer + mimeTeX to start in default size 2, etc.
    -DDISPLAYSIZE=n
    By default, operator limits like \int_a^b are rendered \textstyle at font sizes \normalsize and smaller, and rendered \displaystyle \textstyle, \displaystyle, \limits or \nolimits directives in an expression always override the DISPLAYSIZE default.
    -
    -DNEWCOMMANDS=newcommands.h
    +
    -DGAMMA=gammacorrection
    +
    Applies gammacorrection to antialiased + gif images. Default is 1.25 (rather than the standard 2.2). + Specify 0.0 to turn off gamma correction (1.0 makes no + gamma correction but doesn't actually turn it off).
    +
    -DINPUTOK
    +
    To enhance mimeTeX's security, the + \input{ } command is disabled + by default when you compile mimeTeX. Note that the + \counter and + \environment commands are + also disabled by default, and -DINPUTOK enables + all three commands simultaneously. (Compile mimeTeX with + -DCOUNTEROK to enable only \counter, or with + -DENVIRONOK to enable only \environment.)
    +       Compiling mimeTeX with the + -DINPUTOK switch enables \input{ } for all users, + subject only to your -DPATHPREFIX restrictions, + discussed below. And the following two switches give you + additional control over \input{ }'s usage...
    +
    -DINPUTPATH=\"path\"       -or-
    + -DINPUTPATH=\"path1,path2,etc\"
    +
    Permits \input{filename} for specific + filename's, even when the \input{ } command + is otherwise disabled (for security).
    +       If INPUTPATH is defined, mimeTeX + performs a case-insensitive test of \input{ }'s + filename argument, to verify that it contains + the authorized 'path' as a substring.
    +       If given several 'path's (second form) + then filename must contain either 'path1' or + 'path2', or etc, as a (case-insensitive) substring.
    +       If filename doesn't contain + a substring matching any of these path(s), then mimeTeX emits + an error message image instead of reading filename.
    +
    -DINPUTREFERER=\"domain\"       -or-
    + -DINPUTREFERER=\"domain1,domain2,etc\"
    +
    Permits \input{ } for users from specific + domain's, even when the \input{ } command + is otherwise disabled (for security).
    +       If INPUTREFERER is defined + but INPUTOK is not defined, then mimeTeX + performs a case-insensitive test of the user's + HTTP_REFERER environment variable, to verify that it contains + the authorized 'domain' as a substring.
    +       If given several 'domain's (second form) + then HTTP_REFERER must contain either 'domain1' or + 'domain2', or etc, as a (case-insensitive) substring.
    +       If HTTP_REFERER doesn't contain + a substring matching any of these domain(s), then mimeTeX renders + an error message image instead of reading filename.
    +       Finally, if HTTP_REFERER is not found as + an environment variable, then mimeTeX renders the + same error message image.
    +
    -DNEWCOMMANDS=\"newcommands.h\" +
    LaTeX-like \newcommand's are available in mimeTeX, via the following facility to help you define your own "new commands" during compilation. Edit a file named - newcommands.h (or any filename you specify with the - -DNEWCOMMANDS switch). For newcommands _without_ + newcommands.h (or any filename you specify between + \"...\"'s with the -DNEWCOMMANDS=\"filename\" + switch). For newcommands _without_ arguments, your file should contain one or more lines like the following examples:
    { "\\iint",  NULL, "{\\int\\int}" },
    @@ -1219,11 +1975,25 @@ Ascii dump of bitmap image...
                
        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.
    -
    -DNORMALSIZE=n
    -
    MimeTeX currently has six font sizes numbered 0-5, - and always starts out in NORMALSIZE, whose default value is 2. - Specify -DNORMALSIZE=3 on the compile line if you prefer - mimeTeX to start in default size 3, etc.
    +
    -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 @@ -1235,26 +2005,83 @@ Ascii dump of bitmap image... defined as path/ if you want input files in some other directory. And make sure your path/ ends with / (or with \ for Windows).
    -
    -DREFERER=\"domain\" or
    +
    -DPLUSBLANK       -or-
    + -DPLUSNOTBLANK
    +
    mimeTeX receives your LaTeX math expression as a url + query string, in which blank spaces are often encoded + as %20 or as plus signs +, and + where actual plus signs are often encoded as %2B. + But these conventions aren't always respected, + and even when they are blank spaces may be either + %20 or +. The only ambiguity for + mimeTeX is whether or not to translate plus signs + + back to blank spaces.
    +       If you know how your applications behave, + then define PLUSBLANK to always translate plus signs + + to blank spaces, or define PLUSNOTBLANK to never translate.
    +       Otherwise, if you define neither, + mimeTeX applies some common-sense rules to decide whether or + not to translate. These usually work, but can't be guaranteed. + If your query string contains actual blank spaces or + blanks encoded as %20, then plus signs + + aren't translated. Otherwise, if your query string + contains %2B, then plus signs + are + translated. If neither %20 nor %2B, or both + %20 and %2B, occur in your query string, + then the situation is ambiguous. In this case, if mimeTeX + finds two or more plus signs ++ with no intervening + space, then they're translated; otherwise they're not.
    +
    -DREFERER=\"domain\"       -or-
    -DREFERER=\"domain1,domain2,etc\"
    Blocks mimeTeX requests from unauthorized domains that are using your mimetex.cgi (hence your server's resources) without permission.
    -       If REFERER is defined, mimeTeX +       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.
    + 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 an error - message image instead of the requested image. You can manually - modify invalid_referer_msg, defined in function main(), - to personalize the error message for your own site.
    -       Finally, if HTTP_REFERER is not found as - an environment variable, then mimeTeX correctly generates the - requested image instead of generating an error.
    + matching any of these domain(s), then mimeTeX emits the error + message image
    +
    + instead of the requested image. You can manually + modify this invalid_referer_msg, which is msgtable[0] + defined immediately above function main(), + to personalize the error message displayed for your own site.
    +       Finally, if you specify -DREFERER + (or -DREFLEVELS discussed immediately below) but HTTP_REFERER + is not found as an environment variable, then + mimeTeX correctly generates images whose QUERY_STRING's + contain 24 or fewer characters. For 25 or more + characters, mimeTeX generates an error. + See -DNOREFMAXLEN and -DNOREFSAFELEN above to change + the 24 limit. +
    -DREFLEVELS=n       -or-
    + -DNOREFCHECK
    +
    Besides -DREFERER discussed immediately above, + mimeTeX can block requests from HTTP_REFERER's that + don't match your HTTP_HOST, i.e., from pages on + different servers than your mimetex.cgi image.
    +       The default value of REFLEVELS is 3, + meaning the topmost three levels of HTTP_REFERER and + HTTP_HOST must match. For example, phy.cam.ac.uk matches + math.cam.ac.uk because they share the same topmost three + levels cam.ac.uk. So a page installed at the physics + department can use a mimetex.cgi installed at the math + department. If you always want a complete match, compile + mimeTeX with -DREFLEVELS=99 or any large number. + If HTTP_REFERER is not found, then the same 24 + character limit discussed immediately above remains in effect.
    +       To completely disable the REFLEVELS check, + compile mimeTeX with -DNOREFCHECK (or with + -DREFLEVELS=0). Or, if you supply a specific + -DREFERER list of authorized domains, as discussed + immediately above, then the REFLEVELS check is automatically + disabled.
    -DSECURITY=n
    This is essentially a "paranoid" setting that defaults to a high value 999, which inhibits some optional logging @@ -1266,25 +2093,25 @@ Ascii dump of bitmap image... could conceivably flood your file system by submitting zillions of \counter{filename} commands to mimeTeX, each with a different filename.
    -
    -DSQUASHMARGIN=n or
    - -DNOSQUASH
    +
    -DSMASHMARGIN=n       -or-
    + -DNOSMASH
    TeX typically renders an expression like \frac12\int_{a+b+c}^{d+e+f}g(x)dx as - . MimeTeX tries to remove extra whitespace, rendering the same expression as - instead. - Compile with -DNOSQUASH if you prefer the typical TeX + Compile with -DNOSMASH if you prefer the typical TeX behavior as mimeTeX's default. Or, to adjust the minimum - number of pixels between squashed symbols (default is 3), - compile with -DSQUASHMARGIN=n. - See Squash for further discussion.
    -
    -DWARNINGS=n or
    + 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 @@ -1298,11 +2125,90 @@ Ascii dump of bitmap image...
    -DWHITE
    MimeTeX usually renders black symbols on a white background. This option renders white symbols on - a black background instead.
    + a transparent black background instead (or on an opaque + black background when combined with -DOPAQUE ). + +
    +
    Advertising switches...
    +
    +
    The next three switches + set up a mimeTeX web service that embeds advertising messages + along with rendered images. +

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

    (IIe) Command Line Features  

    +

    (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 @@ -1314,7 +2220,9 @@ Ascii dump of bitmap image... 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.

    + 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

    @@ -1322,6 +2230,10 @@ Ascii dump of bitmap image...
                    [ -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
    @@ -1331,24 +2243,42 @@ Ascii dump of bitmap image...
                    ./mimetex  -d  "x^2+y^2"  >  expression.gif
               creates expression.gif containing an image of x^2+y^2
     
    -     -e   Like -d but writes the actual gif (or xbitmap) directly
    -          to export_file, e.g.,
    +     -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"
    -          also creates expression.gif containing an image of 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...
    +          immediately above, or.....
     
    -     -f   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.
    +     -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   0-99, controls verbosity level for debugging output
    -          (usually used only while testing code).
    +     -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
    @@ -1357,11 +2287,13 @@ Ascii dump of bitmap image...
               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   0-5, font size.  As usual, the 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 3,
    -          overriding -s.  Default font size is 2.
    +     -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.
          
    @@ -1372,10 +2304,12 @@ SECTION III. SYNTAX REFERENCE

    (III) Syntax Reference  

    Since mimeTeX's syntax is as TeX-like as possible, we'll mostly discuss - the occasional exceptions (which exist only to simplify my programming - task, not to impose any syntactic aesthetics of mine on you). This - section contains short paragraphs that each discuss some aspect of - mimeTeX where your LaTeX experience might not be precisely relevant.

    + 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 @@ -1442,17 +2376,46 @@ SECTION III. SYNTAX REFERENCE 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 - \/ and \quad and \qquad . 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. There are no negative spaces.

    +

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

    + +

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

    +

    MimeTeX also supports \hfill{textwidth}, where textwidth is roughly equivalent to LaTeX's @@ -1461,18 +2424,18 @@ SECTION III. SYNTAX REFERENCE expression will span. However, if \hfill{ } appears within a { }-enclosed subexpression, then it applies only to that subexpression. For example,

    - {abc \hfill{50} def} \hfill{100} ghi + {abc \hfill{75} def} \hfill{150} ghi     produces    

    - The first/inner \hfill{50} inserts exactly enough whitespace so - that subexpression "abc  def" spans 50 pixels. - Then the second/outer \hfill{100} inserts exactly enough - whitespace so that the entire expression spans 100 pixels. + 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{100}...\hfill{50}... - is exactly equivalent to ...\hfill{100}{...\hfill{50}...}. + 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.

    @@ -1488,7 +2451,7 @@ SECTION III. SYNTAX REFERENCE y=a+b+c+d\\\hspace{50}+e+f+g+h     to produce    

    However, mimeTeX can't correctly handle automatically-sized delimiters @@ -1496,12 +2459,13 @@ SECTION III. SYNTAX REFERENCE y=\left\{a+b+c+d\\\hspace{50}+e+f+g+h\right\}     produces    
    + src="../cgi-bin/mimetex.cgi?\large y=\{a+b+c+d\\ + \hspace{50}+e+f+g+h\}" alt="" border=0 align=middle>
    whereas you probably wanted        

    + src="../cgi-bin/mimetex.cgi?\large y=\big{a+b+c+d\\ + \hspace{50}+e+f+g+h\big}" alt="" border=0 align=middle> +

    which I produced using \big{...\\...\big} instead of \left\{...\\...\right\}. Expressions of the form \left...\right \\ \left...\right should all be @@ -1554,19 +2518,39 @@ and some other characters..

    Character Sets...

    -

    For complete information about the characters and math symbols +

    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 - 500-or-so lines of mimetex.h. And several additional + 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     Generally speaking, I've tried - to encode the cmmi10, cmsy10, cmr10, cmex10, rsfs10 and bbold10 - 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 - \mathscr{A} for the rsfs10 fonts, and write \mathbb{R} - for bbold10.

    + in mimetex.c
    +         + I haven't exhaustively checked all the name-number matchings for + the thousand-or-so symbols in mimetex.h. You can eaily correct + any minor mistake you find in what I hope is an obvious manner. + The fonts Appendix IVa below provides + additional information.

    + +

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

    + -

    I haven't exhaustively checked all the name-number matchings for - the hundreds of symbols in mimetex.h. You can eaily correct - any minor mistake you find in what I hope is an obvious manner. - The fonts Appendix IVa below provides - additional information.

    +

    In addition to extra LaTeX symbols like \ldots, \AA and \hbar, mentioned above, the mimeTeX preprocessor @@ -1590,49 +2570,366 @@ and some other characters.. &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.

    + translates them back to LaTeX symbols for you. Moreover, html + misinterprets quotes  "  inside a quoted + query string as the end of the query string. So, for example, + the cyrillic ligature \"E has to be written in the + even more cumbersome form \&quot;E inside a query + string.

    + +

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

    + +
    + +

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

    + +
    + +

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

    + +

    +
    +

    Font Sizes...

    -

    MimeTeX currently has six font sizes, numbered 0-5, with default 2. - This font size numbering corresponds to the usual LaTeX declarations -   \tiny,   \small,   \normalsize - (default),   \large,   \Large and \LARGE. - These declarations can be placed anywhere in a mimeTeX expression, +

    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{5} or - the shorter \fs{0},...,\fs{5} for \tiny,...,\LARGE. +

    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,...,\fs5 works equally well. For example,

    + form \fs0,...,\fs7 works equally well. For example,

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

    - rendering f(x)=x^2 in mimeTeX font sizes   2 - (default \normalsize),   3 (\large or \fs3), and -   4 (\fs4 or \Large).

    + 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 @@ -1677,6 +2974,105 @@ and some other characters.. by the usual rules, one size smaller than the "x", in font size 1.

    +

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

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

    Modes...

    MimeTeX is always in a math-like mode, so you needn't surround @@ -1709,16 +3105,19 @@ and some other characters.. For example,

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

    and

    @@ -1735,7 +3134,7 @@ and some other characters..

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

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

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

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

    A^i_j   produces       as usual, whereas
    A\limits^i_j   produces   .. 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,

    + {\it etc} is still ignored. For example,

    anything at all   just produces       whereas

    \text{anything at all}   produces       and

    \textit{anything at all}   produces       instead.
    + src="../cgi-bin/mimetex.cgi?\normalsize\textit{anything at all}" + alt="" border=0 align=middle>     instead.
    + +

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

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

    (IIIc) Delimiters  

    @@ -1821,7 +3236,10 @@ and some other characters..

    Parentheses and Braces (delimiters)...

    -

    LaTeX's \left( and \right) may be written exactly +

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

    - - + + + - + - - + + - + - - + + - + - - - + + + - - - + + +
    LaTeX or
    mimeTeX
    or mimeTeX
    abbreviation
    Delimiter example... ...renders
    \left( ... \right) \( ... \) \left( \frac1{1-x^2} \right)^2 ..
    \left[ ... \right] \[ ... \] \left[ 1+\frac xn \right]^n \left[ \frac1{\sqrt2}x - y \right]^n
    \left\{ ... \right\} \{ ... \} \left\{ 1^2,2^2,3^2,\ldots \right\}
    \left| ... \right| \| ... \| \det \left| \begin{array}{cc} 1&2\\
    -         3&4 \end{array} \right|
    \left| \begin{matrix} a_1 & a_2 \\
    +       a_3 & a_4 \end{matrix} \right|
    \left\| ... \right\| \= ... \= \left\|x^2-y^2\right\|
    \left\{ ... \right. \{ ... \. y=\left\{ \text{this\atop that} \right. \left\{ ...  + \right. y=\left\{ \text{this\\that} + \right.
    \left. ... \right\} \. ... \} \left. \text{this\atop that} \right\}=y \left. +  ... \right\} \left. + \text{this\\that} \right\}=y

    Notes... 

      -
    1. The other LaTeX delimiters, i.e., floor's, ceil's, - arrows, etc, can't yet be sized to fit.
    2. +
    3. Size declarations inside any of the above delimiter pairs affect only the enclosed subexpression, e.g., \Large w=\left(\small x+y\right)+z produces
    4. -
    5. An abbreviated left delimiter must be paired with the same +
    6. An expression may contain as many etex-like \middle's as + you like, and in mimeTeX the surrounding \left...\right + isn't required. When omitted, the scope of \middle is + either the entire expression or the   { }-enclosed + subexpression in which the \middle's occur. For example,   + \frac{a+1}b \middle/ \middle(\frac{c+1}d \middle/ \frac{e+1}f\middle) +   renders   + .
    7. +
    8. In the last two examples, note that mimeTeX recognizes the +   \\   in   \text{this\\that}   + as a linebreak. For example, x=1\\y=2\\z=3 renders   +
    9. + + + + + +

    Besides the \left...\right delimiters discussed above, @@ -1976,22 +3418,22 @@ and some other characters.. and its matching \right.   delimiter. The \right delimiter needn't necessarily be the \right.   illustrated, e.g., - \left\int_a^b x^2dx =\frac{x^3}3\right|\nolimits_a^b + \left\int_a^b x^2dx =\frac{x^3}3\right|_a^b produces . Except for Opening (TeX class 4) and + \left\int_a^bx^2dx=\frac{x^3}3\right|_a^b" border=0 alt="" + align=middle>. You can also write \left\sum, \left\prod, - \left\cup, etc, for many of the symbols in CMEX10. + \left\cup, etc, for many of the symbols in CMEX10 and STMARY10. And any symbol that works with \left will also work - with \right . But mimeTeX abbreviations like   + with \right .

    Unescaped ( )'s and [ ]'s and | |'s and < >'s don't need to be balanced since mimeTeX just @@ -2017,11 +3459,24 @@ Raise and rotate, Compose, Abb

    Accents...

    - \vec{ } \hat{ } \bar{ } \tilde{ } \dot{ } - and \ddot{ } are the only accents currently supported, - and they're all "wide". You can write \widehat{ } if you - like, but there's absolutely no difference either way. - \bar{ } and \overline{ } are identical.

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

    + +

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

    Function names...

    @@ -2032,7 +3487,7 @@ Raise and rotate, Compose, Abb also behave as expected, e.g.,

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

    long Arrows...

    @@ -2057,7 +3512,7 @@ Raise and rotate, Compose, Abb any white space after the arrow, e.g., f:x\longrightarrow~[0,1] produces . Without any intervening white space, mimeTeX would have "eaten" the [0,1].

    @@ -2099,17 +3554,28 @@ Raise and rotate, Compose, Abb displays super/subscripts in the usual way.

    \raisebox{ }{ } and -\rotatebox{ }{ }...

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

    The \raisebox{height}{expression} and \rotatebox{angle}{expression} - commands help you fine-tune and manipulate mimeTeX renderings. - The height argument is number of pixels, scaled by - \unitlength, and can be positive - or negative. The angle argument is number of degrees, - and can also be positive (for clockwise) or negative, but must be a - multiple of 90. Finally, the expression can be any - valid LaTeX/mimeTeX expression. For example, mimeTeX's preprocessor + and \reflectbox[axis]{expression} + commands help you fine-tune and manipulate mimeTeX renderings:

    +
      +
    • \raisebox's height argument is number + of pixels, scaled by \unitlength, + and can be positive or negative.
    • +
    • \rotatebox's angle argument is number + of degrees, and can also be positive (for clockwise) or + negative, but must be a multiple of 90.
    • +
    • \reflectbox's optional axis argument + defaults to 1 if not given, which reflects horizontally + (the usual LaTeX behavior), or reflects vertically if + specified as 2.
    • +
    • For all three commands, the expression + can be any valid LaTeX/mimeTeX expression.
    • +
    +

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

    abc\raisebox{-2}{\rotatebox{180}?}def   produces   @@ -2117,6 +3583,14 @@ Raise and rotate, Compose, Abb src="../cgi-bin/mimetex.cgi? \large\rm abc\raiseb{-2}{\rotateb{180}{\LARGE?}}def" alt="" border=0 align=middle>
    +

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

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

    \compose{ }{ }...

    @@ -2124,21 +3598,252 @@ Raise and rotate, Compose, Abb \compose[offset]{base}{overlay} superimposes the overlay expression on top of the base expression, displaying the result. - Optionally, the overlay is horizontally offset - by the specified number of pixels (positive offsets to the right, - negative to the left). For example,

    - \compose{\LARGE O}{\normalsize c}   produces   + The superimposed overlay is centered, both + horizontally and vertically, on the base image, + with the composite image baseline + + completely ignored. + That means the base remains positioned in your expression + just as if it had been rendered alone, while the overlay + is moved around, vertically as well as horizontally, to accommodate it. + For example,

    + \compose{\LARGE O}{\normalsize c}   renders  
    + alt="" border=0 align="bottom">
    + +

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

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

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

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

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

    +

    \rule{ }{ }...

    + +

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

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

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

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

    \eval{ }...

    + +

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

    +
      +
    • digits   0-9 +   and numbers composed of uninterrupted (no whitespace) + sequences of digits,
    • +
    • binary operators   + +-*/% +   (+ and - can be unary, preceding + the first number in an expression, and % is + the modulo operator),
    • +
    • balanced   ( ... ) +   parentheses nested to any level (see below),
    • +
    • whitespace anywhere + (except between digits comprising a number),
    • +
    • One additional construction interpreted by \eval{ } + is similar to (but not identical to) the + ?: conditional, as follows. + The expression (i?v0:v1:v2:etc), usually + parenthesized as illustrated, evaluates to v0 + if i evaluates to 0, or evaluates to v1 + if i evaluates to 1, etc. If i < 0 + then v0 is used, and if i is too large, the last + v is used. All components, i and all v's, + can themselves be expressions, even another + (i?v0:v1:v2:etc), which in this case must be + parenthesized. The only situation where parentheses aren't + required is when i?v0:v1:v2:etc comprises + your entire expression. + For example,
            + \eval{1+2?10:11:12:13:14:15} renders +
    • +
    • and  most importantly,  + the built-in variables
      +       fs for current fontsize and
      +       unitlength for unitlength
      + which provide the capability for useful constructions, + as follows...
    • +
    + +

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

    + +

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

    + +

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

    + + +

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

    + +

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

    + +

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

    +

    Abbreviations...

    @@ -2172,101 +3877,101 @@ Raise and rotate, Compose, Abb \Large\color{blue} e^x=\sum_{n=0}^\infty\frac{x^n}{n!}" alt="" border=0 align=middle>

    -

    "Squash"...

    +

    "Smash"...

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

    -

    Precede any expression with the mimeTeX directive \nosquash - to render it without "squashing". Or compile mimetex.c with the - -DNOSQUASH option if you prefer +

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

    + or \; , etc, is never smashed.

    -

    The scope of \squash and \nosquash is the +

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

    -

    For finer-grained control, note that \squash is shorthand - for the default \squashmargin{+3} (and \nosquash is - shorthand for \squashmargin{0}). \squashmargin's value - is the minimum number of pixels between squashed symbols. The leading - + is optional. If present, the font size (\tiny=0,...,\LARGE=5) +

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

    -

    Squashing is in "alpha testing" and some expressions still don't look - quite right when squashed, e.g., 1^2,2^2,3^2,\ldots renders as - Smashing is in "beta testing" and some expressions still don't look + quite right when smashed, e.g., 1^2,2^2,3^2,\ldots renders as + . Just compile with -DNOSQUASH + alt="" border=0 align=middle>. Just compile with -DNOSMASH if you come across numerous annoying situations.

    -

    \not and \Not and \sout...

    +

    \not and \cancel and \sout...

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

    -

    For arbitrary expressions, mimeTeX provides   \Not   +

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

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

    @@ -2285,6 +3990,9 @@ Raise and rotate, Compose, Abb
    \begin{matrix} a&b&c \\ d&e&f \\ etc \end{matrix}
    \begin{tabular} a&b&c \\ d&e&f \\ etc \end{tabular}
    \begin{pmatrix} a&b&c \\ d&e&f \\ etc \end{pmatrix}
    \begin{align} a&=b \\ c&=d \\ etc \end{align}
    \begin{cases} a&b \\ c&d \\ etc \end{cases}
    \begin{gather} a \\ b \\ etc \end{gather}
    - Copyright © 2002-2005, + Copyright © 2002-2012, John Forkosh Associates, Inc.
    email: john@forkosh.com