--- loncom/cgi/mimeTeX/mimetex.html 2007/10/09 21:41:41 1.3 +++ 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"; + } + ?> + + + @@ -117,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.64 )
+ ( for mimeTeX version + )
Click for:  @@ -125,6 +223,12 @@ Banner across top of page, containing ti LaTeX tutorial
mimeTeX QuickStart
+ + mimeTeX Source Listing
download mimeTeX
@@ -136,11 +240,18 @@ 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-2006, +Copyright © 2002-2012, John Forkosh Associates, Inc.
email: john@forkosh.com


@@ -169,7 +280,8 @@ Table of Contents   (I) Introduction  
a. Quick Start
b. Examples
- c. GPL License
+ c. Scripts&Plugins
+ d. GPL License   (II) Building mimeTeX  
a. Compile
@@ -185,7 +297,8 @@ Table of Contents e. \begin{array}
f. \picture( ){ }
g. Other Commands
- h. Other Exceptions
+ h. Other Exceptions
+ i. Errors and Messages     (IV) Appendices    
a. Fonts
@@ -194,11 +307,31 @@ Table of Contents
  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)

-
+ +
@@ -252,129 +385,47 @@ SECTION I. INTRODUCTION And mimeTeX is an entirely separate little program that doesn't use TeX or its fonts in any way. It's just one cgi that you put in your site's cgi-bin/ directory, with no other dependencies. So mimeTeX - is very easy to install. And it's equally - easy to use. Just place an html <img> tag in your document - wherever you want to see the corresponding LaTeX expression. - For example,

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

immediately - generates the corresponding gif image on-the-fly, displaying - wherever you put that <img> tag. + is very easy to install.
+         + Just download + mimetex.zip and then type
+             + unzip mimetex.zip
+             + cc –DAA mimetex.c gifsave.c + –lm –o mimetex.cgi
+         + Now just mv mimetex.cgi to your cgi-bin/ + directory,
+         + set permissions as necessary, and you're all done.
+
+ And mimeTeX is equally easy to use: +   just place an html <img> tag in your document + wherever you want to see the corresponding LaTeX expression.
+         + For example, the <img> tag
+             + <img  + src="../cgi-bin/mimetex.cgi?f(x)=\int_{-\infty}^xe^{-t^2}dt" >
+         + immediately generates the corresponding gif image on-the-fly,
+             + displaying   + +   wherever you put that tag.
+
MimeTeX doesn't need intermediate dvi-to-gif conversion, and it doesn't create separate gif files for each converted expression. (But you can enable image caching with mimeTeX's   -DCACHEPATH=\"path/\"   - compile option.)

- -

-mimeTeX plugins...

-

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

- -

For example, if you're using - phpBB2, then - Jameson - contributed the following typical one-line mod that lets you just write - [tex] f(x)=\int_{-\infty}^xe^{-t^2}dt [/tex] - to obtain the same image illustrated above:

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

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

- -

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

-
- - - - - - - - - - - - - - - - - - - - -
 Package      Plugin  
- - PmWiki   - mimeTeX plugin
- - Wikimedia   - "mimeTeX alternative"
- MathWiki   "mimeTeX Parser"
- PunBB   - mimeTeX plugin
- - Movable Type   mimeTeX plugin
- WordPress   - - mimeTeX plugin
- -

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

+ compile option.) +   And there's no inherent need to repeatedly write the + cumbersome <img> tag illustrated above. + You can write your own + wrapper scripts, + discussed below, around mimeTeX to simplify the notation.

Alternative solutions...

@@ -388,38 +439,34 @@ Alternative solutions...latexrender which uses LaTeX to create higher quality images than mimeTeX produces. For comparison, - , with arbitrary mean - - and standard deviation - , and at mimeTeX's next larger font size, looks like

+ , + with arbitrary mean + and standard deviation + , + and at mimeTeX's next larger font size, looks like

- + - + - - + +
mimeTeX latexrender latexrender mimeTeX
-     + +

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

+ +

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

+
+ + + + + + + + + + + +
mathtran mimeTeX
unavailable +
  +
+
+ +
  • There are occasional exceptions where I couldn't + program mimeTeX to recognize valid LaTeX syntax. + One particular "gotcha" is that mimeTeX bindings + are pretty much left-to-right. Thus, for example, although + mimeTeX correctly interprets \frac12 as well as + \frac1{x^2}, etc, the legal LaTeX expression + x^\frac12 must be written x^{\frac12}. + Otherwise, mimeTeX interprets it as {x^\frac}12, i.e., + the same way x^\alpha12 would be interpreted, which is + nonsense for \frac. The same "gotcha" also applies to + other combinations of commands, e.g., you must write + \sqrt{\frac\alpha\beta}, or + \frac\alpha{\sqrt\beta}, etc. + The Syntax Reference section + contains much additional information.
  • +
  • And there are various additional syntactic and cosmetic + differences between LaTeX and mimeTeX. For example, + bounding boxes for mimeTeX's character bitmaps don't + accommodate italic corrections. Therefore, an expression + like \int\nolimits_a^b renders + rather than + . + To render the latter image you have to write the somewhat + cumbersome expression {\smashmargin2{\int\nolimits_a}^b} + instead (see smash below).
  • +
  • Besides such exceptions, mimeTeX + also provides various LaTeX extensions (such as font size + directives like \Large permitted within mimeTeX + math mode expressions, as discussed above). + +
  • Now enter your own LaTeX expression, use the sample provided, @@ -570,51 +709,111 @@ QUICKSTART if you submit the sample expression - already in the box.

    - -

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

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

    - The typical mimeTeX <img> tag has the form

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

    + -
  • There are occasional exceptions where I couldn't - program mimeTeX to recognize valid LaTeX syntax. - One particular "gotcha" is that mimeTeX bindings - are pretty much left-to-right. Thus, for example, although - mimeTeX correctly interprets \frac12 as well as - \frac1{x^2}, etc, the legal LaTeX expression - x^\frac12 must be written x^{\frac12}. - Otherwise, mimeTeX interprets it as {x^\frac}12, i.e., - the same way x^\alpha12 would be interpreted, which is - nonsense for \frac. The same "gotcha" also applies to - other combinations of commands, e.g., you must write - \sqrt{\frac\alpha\beta}, or - \frac\alpha{\sqrt\beta}, etc. - The Syntax Reference section - contains much additional information.
  • -
  • Besides such exceptions, mimeTeX - also provides various LaTeX extensions. For example, font size - directives like \Large are permitted within mimeTeX - math mode expressions, but flagged as errors by LaTeX. -
  • + is pretty much any valid LaTeX math expression:

    + + + +

    (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 @@ -761,9 +960,9 @@ EXAMPLES

    @@ -782,7 +981,7 @@ EXAMPLES @@ -880,13 +1079,13 @@ using \longxxxarrow[] and \begin{array} mimeTeX \picture(size){pic_elems} @@ -921,10 +1120,11 @@ 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:
    @@ -1045,10 +1532,10 @@ 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 - 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.

    @@ -1237,14 +1734,15 @@ Ascii dump of bitmap image... http://www.yourdomain.com/cgi-bin/mimetex.cgi?x^2+y^2
    which should display     in the upper-left corner of your window, + style="Vertical-Align:-3px">   + 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 + \normalsize x^2+y^2" alt="" border=0 style="Vertical-Align:-3px">   + image from the yourdomain link, then you've completed a successful mimeTeX installation.

    If you don't see the image, then your installation failed. @@ -1330,13 +1828,22 @@ 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
    @@ -1349,7 +1856,7 @@ Ascii dump of bitmap image... \textstyle at font sizes \normalsize and smaller, and rendered \displaystyle -
    -DNEWCOMMANDS=\"newcommands.h\"
    +
    -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 @@ -1418,6 +1975,21 @@ 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.
    +
    -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 @@ -1464,21 +2036,52 @@ Ascii dump of bitmap image...
    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 @@ -1524,6 +2127,84 @@ Ascii dump of bitmap image... background. This option renders white symbols on a transparent black background instead (or on an opaque black background when combined with -DOPAQUE ).
    + +
    +
    Advertising switches...
    +
    +
    The next three switches + set up a mimeTeX web service that embeds advertising messages + along with rendered images. +

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

    +

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

    + +
    + +

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

    + +
    + +

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

    + +

    +
    +
    +

    Font Sizes...

    MimeTeX currently has eight font sizes, numbered 0-7, with default 3. @@ -2004,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 @@ -2521,7 +3590,7 @@ Raise and rotate, Compose, Abb

    + alt="" border=0 align="bottom">

    \compose{ }{ }...

    @@ -2529,20 +3598,63 @@ 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 and \reflectbox - 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{ }{ }...

    @@ -2572,6 +3684,166 @@ Raise and rotate, Compose, Abb src="../cgi-bin/mimetex.cgi?\frac12xyz\rule[-15]{10}{20}ghi" alt="" border=0 align=middle> +

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

    @@ -2718,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} @@ -3125,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 @@ -3149,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 @@ -3176,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.

    @@ -3190,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  

    @@ -3206,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:

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

    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.

    + + @@ -3340,24 +4742,36 @@ SECTION IV. APPENDICES

    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. You'll need to compile your own version from source. + 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, - or more recent versions. Then   untar   them both, + + 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 two lines very near the top - that   #define maxrow (79)   and similarly for maxcol. - Change both 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.

    +   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
    - Copyright © 2002-2006, + Copyright © 2002-2012, John Forkosh Associates, Inc.
    email: john@forkosh.com