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

email: john@forkosh.com

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

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

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

# (I) Introduction

MimeTeX, licensed under the gpl, lets you easily embed LaTeX math in your html pages. It parses a LaTeX math expression and immediately emits the corresponding gif image, rather than the usual TeX dvi. And mimeTeX is an entirely separate little program that doesn't use TeX or its fonts in any way. It's just one cgi that you put in your site's cgi-bin/ directory, with no other dependencies. So mimeTeX is very easy to install. 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="./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 $\normalsize f(x)=\int\limits_{-\infty}^xe^{-t^2}dt$ wherever you put that <img> tag. MimeTeX doesn't need intermediate dvi-to-gif conversion, and it doesn't create separate gif files for each converted expression. (But you can enable image caching with mimeTeX's   -DCACHEPATH=\"path/\"   compile option.)

### mimeTeX plugins...

There's no inherent need to repeatedly write the cumbersome <img> tag illustrated above. You can write your own custom tags, or write a wrapper script around mimeTeX to simplify the notation. For example, PmWiki already has a mimeTeX plugin that lets you just write {$f(x)=\int_{-\infty}^xe^{-t^2}dt$} to obtain the same image.   Similarly,

 Package Plugin Wikimedia "mimeTeX alternative" MathWiki "mimeTeX Parser" PunBB mimeTeX plugin Movable Type mimeTeX plugin Mambo "mimeTeX bot" WordPress mimeTeX plugin   (see item 9) and, as already discussed in the text... PmWiki mimeTeX plugin phpBB mimeTeX plugin

Or, if you're using phpBB, then Jameson contributed the following one-line mod that lets you just write $$...$$ to obtain mimeTeX images:

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

n=\left\{m/2\text{    if $m$ even} \m+1)/2\text{ if m odd}\right. produces $n=\left\{m/2\text{ if m even}\\(m+1)/2\text{ if m odd}\right.$ ## (IIIc) Delimiters ### Parentheses and Braces (delimiters)... LaTeX's \left( ... \right) and the other 21 standard LaTeX delimiters are also recognized by mimeTeX. And mimeTeX also recognizes an etex-like \middle. Several of the most common automatically sized delimiters are illustrated below...  Delimiter example... ...renders \left( ... \right) \left( \frac1{1-x^2} \right)^2 $\Large\left(\frac1{1-x^2}\right)^2$ \left[ ... \right] \left[ \frac1{\sqrt2}x - y \right]^n $\Large \left[ \frac1{\sqrt2}x - y \right]^n$ \left\{ ... \right\} \left\{ 1^2,2^2,3^2,\ldots \right\} $\large\left\{1^2,2^2,3^2,\ldots\right\}$ \left\langle ... ... \right\rangle \left\langle \varphi \middle| \hat H \middle| \phi \right\rangle $\Large \left\langle\varphi\middle|\hat H\middle|\phi\right\rangle$ \left| ... \right| \left| \begin{matrix} a_1 & a_2 \\ a_3 & a_4 \end{matrix} \right| $\large \left|\begin{matrix}a_1&a_2\\a_3&a_4\end{matrix}\right|$ \left\| ... \right\| \left\|x^2-y^2\right\| $\large\left\|x^2-y^2\right\|$ \left\{ ... \right. y=\left\{ \text{this\\that} \right. $\large y=\left\{\text{this\\that}\right.$ \left. ... \right\} \left. \text{this\\that} \right\}=y $\large\left.\text{this\\that}\right\}=y$ Notes... 1. Size declarations inside any of the above delimiter pairs affect only the enclosed subexpression, e.g., \Large w=\left(\small x+y\right)+z produces $\Large w=\left(\small x+y\right)+z$ 2. An expression may contain as many etex-like \middle's as you like, and in mimeTeX the surrounding \left...\right isn't required. When omitted, the scope of \middle is either the entire expression or the { }-enclosed subexpression in which the \middle's occur. For example, \frac{a+1}b \middle/ \middle(\frac{c+1}d \middle/ \frac{e+1}f\middle) renders $\large \frac{a+1}b\middle/\middle(\frac{c+1}d\middle/\frac{e+1}f\middle)$. 3. In the last two examples, note that mimeTeX recognizes the \\ in \text{this\\that} as a linebreak. For example, x=1\\y=2\\z=3 renders $\small x=1\\y=2\\z=3$ Besides the \left...\right delimiters discussed above, mimeTeX also supports constructions like \left\int_a^b...\right. , which automatically sizes the \left\int to accommodate everything between it and its matching \right. delimiter. The \right delimiter needn't necessarily be the \right. illustrated, e.g., \left\int_a^b x^2dx =\frac{x^3}3\right|_a^b produces $\large \left\int_a^bx^2dx=\frac{x^3}3\right|_a^b$. You can also write \left\sum, \left\prod, \left\cup, etc, for many of the symbols in CMEX10 and STMARY10. And any symbol that works with \left will also work with \right . Unescaped ( )'s and [ ]'s and | |'s and < >'s don't need to be balanced since mimeTeX just displays them like ordinary characters without any special significance. Ditto for the usual four \big( and \Big( and \bigg( and \Bigg(, and for their four right ) counterparts, which just display (...)'s at fixed larger sizes, and also have no special significance. All four big [ ]'s and < >'s and { }'s are also available as ordinary characters. As usual, unescaped {...}'s aren't displayed at all, must be balanced, and have the usual special LaTeX significance. MimeTeX interprets escaped \{...\}'s as abbreviations for \left\{...\right\} and therefore always sizes them to fit. If you need displayed but unsized {...}'s, write \lbrace...\rbrace or any of the four \big{...\big}'s. ## (IIId) Accents, Functions, Arrows, Raise and rotate, Compose, Abbreviations, etc. ### Accents... \vec{ } \hat{ } \bar{ } \tilde{ } \dot{ } \ddot{ } and \acute{ } \grave{ } \breve{ } \check{ } are the only accents currently supported. The first four are all "wide". For example, you can write \widehat{ } if you like, but there's absolutely no difference either way (and \bar{ } and \overline{ } are identical). The last four accents only take a single character argument. Other accent-like directives available in mimeTeX are \underline{ } \cancel{ } \sout{ }, as well as \overset{ }{ } \underset{ }{ } and the more ususal \overbrace{ }^{ } \underbrace{ }_{ }. And \not also works on the single character immediately following it. Some of these directives are discussed in more detail below. ### Function names... All 32 usual LaTeX function names \arccos,...,\tanh are recognized by mimeTeX and treated in the usual way. MimeTeX also recognizes \tr for the trace, and also \bmod and \pmod. And those functions that normally take "limits" also behave as expected, e.g., \lim_{n\to\infty}S_n=S produces $\large\lim_{n\to\infty}S_n=S$ ### long Arrows... All mimeTeX \long and \Long arrows take an optional [width] argument that explicitly sets the arrow's width in pixels, scaled by \unitlength. For example, \longrightarrow[50] draws a 50-pixel wide arrow $\longrightarrow[50]$, whereas just \longrightarrow calculates a default width $\longrightarrow$, as usual. And, in addition to the usual right, left and leftright arrows, there are also \long (and \Long) up, down and updown arrows that take an optional [height] argument, also scaled by any preceding \unitlength. In the event that you actually want to place an []-enclosed expression immediately following an "unsized" long arrow, just place a ~ or any white space after the arrow, e.g., f:x\longrightarrow~[0,1] produces $\normalsize f:x\longrightarrow~[0,1]$. Without any intervening white space, mimeTeX would have "eaten" the [0,1]. Super/subscripts immediately following all long/Long left/right arrows are displayed the same way \limits displays them, e.g., x\longrightarrow^gy produces $\large x\longrightarrow^gy$ x\longrightarrow[50]^gy produces $\large x\longrightarrow[50]^gy$ Subscripted long arrows can occasionally be useful, too, as in Example 11 above, e.g., u\longrightarrow[50]_\beta v produces $\large u\longrightarrow[50]_\beta^{\,}v$ To defeat this default behavior, e.g., \longrightarrow\nolimits^g displays super/subscripts in the usual way. Super/subscripts immediately following all long/Long up/down arrows are treated correspondingly, i.e., superscripts are vertically centered to the arrow's left, and subscripts to its right. For example, \longuparrow[30]^\gamma produces $\large\longuparrow[30]^\gamma$ \longdownarrow[30]_\gamma produces $\large\longdownarrow[30]_\gamma$ whose occasional usefulness is also illustrated by Example 11. And as before, to defeat this default behavior, e.g., \longuparrow\nolimits^\gamma displays super/subscripts in the usual way. ### \raisebox{ }{ } and \rotatebox{ }{ } and \reflectbox[ ]{ } ... The \raisebox{height}{expression} and \rotatebox{angle}{expression} and \reflectbox[axis]{expression} commands help you fine-tune and manipulate mimeTeX renderings: • \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 $\large\rm abc\raiseb{-2}{\rotateb{180}{\LARGE?}}def$ Using \reflectbox[2]{ } instead of \rotatebox{180}{ } would result in the slightly different abc\raisebox{-2}{\reflectbox[2]?}def produces $\large\rm abc\raiseb{-2}{\reflectb[2]{\LARGE?}}def$ ### \compose{ }{ }... \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 $\compose{\LARGE O}{\normalsize c}$ 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 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 $\frac12xyz\rule{10}{20}ghi$ 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 $\frac12xyz\rule[5]{10}{20}ghi$ and \frac12xyz\rule[-15]{10}{20}ghi produces $\frac12xyz\rule[-15]{10}{20}ghi$ ### Abbreviations... \ga displays \gamma, but just \g displays \gg (>>). That is, mimeTeX selects the shortest symbol or command which begins with whatever you type. This feature can help shorten an otherwise very long line, but it may be a bit dangerous. The mimeTeX preprocessor, briefly mentioned above, is responsible for recognizing several LaTeX symbols like \ldots and several commands like \atop . These symbols and commands cannot be abbreviated. The special html characters like &nbsp; are also recognized by the preprocessor and cannot be abbreviated. ### Colors... Rudimentary color commands are provided by mimeTeX. You can write \color{red} or \color{green} or\color{blue} (which may be abbreviated \red or \green or \blue) anywhere in an expression to render the entire expression in the specified color. That is, abc{\red def}ghi renders the entire expression red, not just the def part. Also, note that mimeTeX's "green" is actually color #00FF00, which the html standard more accurately calls "lime". For example, \blue e^x=\sum_{n=0}^\infty\frac{x^n}{n!} produces $\Large\color{blue} e^x=\sum_{n=0}^\infty\frac{x^n}{n!}$ ### "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 $\normalsize\displaystyle \nosmash\frac12\int_{a+b+c}^{d+e+f}{g(x)dx}$. But mimeTeX knows the character shapes of its fonts, and therefore tries to remove extra whitespace, rendering the same expression as $\normalsize\displaystyle \smash\frac12\int_{a+b+c}^{d+e+f}{g(x)}dx$ instead. Precede any expression with the mimeTeX directive \nosmash to render it without "smashing". Or compile mimetex.c with the -DNOSMASH option if you prefer the typical TeX behavior as mimeTeX's default. In this case, precede any expression with \smash to render it "smashed". And note that explicit space like \hspace{10} or \; , etc, is never smashed. The scope of \smash and \nosmash is the { }-enclosed subexpression in which the directive occurs. For example, if you want the g(x) part of the preceding example smashed, but not the 1/2 part, then the expression \nosmash\frac12{\smash\int_{a+b+c}^{d+e+f}g(x)dx} renders as $\normalsize\displaystyle \nosmash\frac12{\smash\int_{a+b+c}^{d+e+f}{g(x)dx}}$. For finer-grained control, note that \smash is shorthand for the default \smashmargin{+3} (and \nosmash is shorthand for \smashmargin{0}). \smashmargin's value is the minimum number of pixels between smashed symbols. The leading + is optional. If present, the font size (\tiny=0,...,\Huge=7) is added to the specified minimum. Compile mimetex.c with the -DSMASHMARGIN=n option to change the default from 3 to n. Compare the preceding example with the over-smashed \smashmargin{1} $\normalsize\displaystyle \smashmargin1\frac12\int_{a+b+c}^{d+e+f}{g(x)}dx$ instead. Smashing is in "beta testing" and some expressions still don't look quite right when smashed, e.g., 1^2,2^2,3^2,\ldots renders as $\Large1^2,2^2,3^2,\ldots$. Just compile with -DNOSMASH if you come across numerous annoying situations. ### \not and \cancel and \sout... The usual LaTeX \not "slashes" the single symbol following it, e.g., i\not\partial\equiv i\not\nabla produces $\normalsize i\not\partial\equiv i\not\nabla$. For arbitrary expressions, mimeTeX provides \cancel which draws a line from the upper-right to lower-left corner of its argument, e.g., a\cancel{x^2}=bx^{\not3} produces $\large a\cancel{x^2}=bx^{\not3}$. Finally, similar to the ulem.sty package, \sout draws a horizontal strikeout line through its argument, e.g., \sout{abcdefg} produces $\normalsize\sout{abcdefg}$. 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 $\normalsize\sout[+2]{abcdefg}$ and \sout[-2]{abcdefg} produces $\normalsize\sout[-2]{abcdefg}$. ## (IIIe) \begin{array}{lcr}...\end{array} Environment Rendering vectors and matrices, aligning equations, etc, is all done using the customary LaTeX environment \begin{array}{lcr} a&b&c\\d&e&f\\etc \end{array} which you can write in exactly that form. MimeTeX also recognizes the following array-like environments  \begin{array}{lcr} a&b&c \\ d&e&f \\ etc \end{array} \begin{matrix} a&b&c \\ d&e&f \\ etc \end{matrix} \begin{pmatrix} a&b&c \\ d&e&f \\ etc \end{pmatrix} \begin{bmatrix} a&b&c \\ d&e&f \\ etc \end{bmatrix} \begin{Bmatrix} a&b&c \\ d&e&f \\ etc \end{Bmatrix} \begin{vmatrix} a&b&c \\ d&e&f \\ etc \end{vmatrix} \begin{Vmatrix} a&b&c \\ d&e&f \\ etc \end{Vmatrix} \begin{eqnarray} a&=&b \\ c&=&d \\ etc \end{eqnarray} \begin{align} a&=b \\ c&=d \\ etc \end{align} \begin{cases} a&b \\ c&d \\ etc \end{cases} \begin{gather} a \\ b \\ etc \end{gather} There's a built-in maximum of 64 columns and 64 rows. Nested array environments, e.g., \begin{pmatrix}a&\begin{matrix}1&2\\3&4\end{matrix}\\c&d\end{pmatrix}, are permitted. MimeTeX also provides the abbreviation \array{lcra&b&c\\d&e&f\\etc} which has exactly the same effect as \begin{array}{lcr} a&b&c\\d&e&f\\etc \end{array}. And the lcr "preamble" in \array{lcretc} is optional. In that case, \array{a&b&c\\d&e&f\\etc} has exactly the same effect as \begin{matrix} a&b&c\\d&e&f\\etc \end{matrix}. You can also write \(\array{etc} to "manually abbreviate" the pmatrix environment, or \array{rcl\$etc} to abbreviate eqnarray, but mimeTeX has no explicit abbreviations for these other environments. For example,

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

$\normalsize\unitlength{.6}\picture(100){ (50,50){\circle(99)} (20,55;50,0;2){\fs{+1}\hat\bullet} (50,40){\bullet} (50,35){\circle(50,25;34)} (50,35){\circle(50,45;34)}}$
Have a nice day!

## (IIIg) Other mimeTeX Commands

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

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

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

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

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

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

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

"\underset{\rm base 2}\log32=5"   to render   $\Large\underset{\small\rm base 2}\log32\,=\,5$

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

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

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

### \fbox{ }...

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

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

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

### \today and \calendar...

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

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

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

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

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

### \input{ }...

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

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

### \counter[ ]{ } ...

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

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

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

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

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

## (IIIh) Other Exceptions to LaTeX Syntax

### Binding Exceptions...

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

# (IV) Appendices

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

## (IVa)   mimeTeX Fonts

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

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

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

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

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

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

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

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

gftype -i cmmi10.131gf > typeout

where typeout can be any temporary filename you like.

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

gfuntype -n cmmi131 typeout cmmi131.h

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

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

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

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

Then ditto for the eight other font families cmmi10, cmmib10, cmsy10, cmex10, bbold10, rsfs10, stmary10 and wncyr10. And to generate other .dpigf font sizes, calculate magsteps   $\normalsize\frac{\log(dpi/2602)}{\log1.2}$.   All the subsequent gftype and gfuntype runs just follow the standard format described above.

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

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

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

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

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

One small problem with the above procedure is that the default   gftype   program supplied with most TeX distributions can't emit the long lines needed to display mimeTeX's larger font sizes. 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,   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.

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

## (IVb) mimeTeX's make_raster() function

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

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

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

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

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

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

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

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

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

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

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

## (IVc)Sverre Huseby's gifsave.c library

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

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

The GIFSAVE functions make it possible to save GIF images from

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

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

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

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

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

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

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

GIF_Close() terminates and closes the file.

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

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

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

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

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

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

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

numcolors is the number of colors used in
the image.

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

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

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

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

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

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

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

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

Return value  None

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

Syntax  void GIF_SetTransparent(
int colornum
);

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

Return value  None

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

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

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

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

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

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

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

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

Syntax  int GIF_Close(void);

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

Return value  GIF_OK        - OK
GIF_ERRWRITE  - Error writing to file

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

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

Syntax  int callback(int x, int y);

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

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

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

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

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

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

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

# Concluding Remarks

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

 Copyright © 2002-2006, John Forkosh Associates, Inc. email: john@forkosh.com $\hspace{100}$ $\blue{\small\rm You're the } \Large\counter[counters.log]{counters.txt:mimetex.html}\\[0] {\small\rm visitor to this page.$