Professional Documents
Culture Documents
Contents
---Tutorial--- --------------Reference--------------
(I) Introduction (II) Building (III) Syntax (IV) Appendices
a. Quick Start mimeTeX Reference a. Fonts
b. Examples a. Compile a. Math & White b. make_raster()
c. GPL License b. Install Space c. gifsave.c
c. Compile Options b. Symbols, Sizes, Remarks
d. Command Line Modes
c. Delimiters
d. Accents, Arrows,
etc.
e. \begin{array}
f. \picture( ){ }
g. Other Commands
h. Other Exceptions
(I) Introduction
MimeTeX, licensed under the gpl, lets you easily embed LaTeX math in your
html pages. It parses a LaTeX math expression and immediately emits the
corresponding gif image, rather than the usual TeX dvi. And mimeTeX is an
entirely separate little program that doesn't use TeX or its fonts in any way. It's
just one cgi that you put in your site's cgi-bin/ directory, with no other
dependencies. So mimeTeX is very easy to install. And it's equally easy to use.
Just place an html <img> tag in your document wherever you want to see the
corresponding LaTeX expression. For example,
<img src="../cgi-bin/mimetex.cgi?f(x)=\int_{-
\infty}^xe^{-t^2}dt"
alt="" border=0 align=middle>
m i m e Te X p l u g i n s . . .
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 [tex] ... [/tex] to obtain mimeTeX images:
#--------
[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);
(Please note: Please don't write php code using system( ), or any other shell
escape mechanism, just to cache images. Use mimeTeX's -DCACHEPATH=
\"path/\" compile option instead. system( ) raises security issues, either real
ones if used carelessly, or just in the minds of system administrators. Either way,
I've received many emails from people unable to use mimeTeX because of
unnecessary system( ) calls prohibited by security-conscious sysadmins.
MimeTeX itself poses minimal risk when used as illustrated above, but you're
responsible for any plugin/wrapper script you write around it.)
Alternative solutions...
mimeTeX latexrender
Similar LaTeX-based solutions that you may want to look at are textogif and
gladTeX. Additional discussion and several more links are at
www.tug.org/interest.html and in the tex-faq.
You may now want to browse the additional Examples below before proceeding,
to make sure mimeTeX suits your needs before you spend more time learning to
use it.
(Ia) Quick Start
MimeTeX is as TeX-like as possible (though not 100% compliant), and you must
already be familiar with LaTeX math markup to use it. If you're not, many online
LaTeX turorials are readily available. You may also want to browse Andrew
Roberts' Latex Math I and Latex Math II, or my own LaTeX math tutorial. Then,
instead of continuing to read this page, you can just Submit any LaTeX math
expression you like in the Query Box below. I've started you out with a little
example already in the box, or you can Click any of the Examples below to place
that corresponding expression in the Query Box.
Meanwhile, here are just a few quickstart tips for Submitting your own
mimeTeX expressions in the Query Box below:
MimeTeX currently has eight font sizes selected by one of the usual
directives \tiny or \small or \normalsize , or \large (default) or \Large or
\LARGE , or \huge or \Huge . Unlike standard LaTeX, font size
directives may appear within math mode expressions. They affect
everything to their right, except that their scope will be limited to any { }-
enclosed subexpression in which they occur. For example, "a+\small b+c"
renders , whereas "\small a+{\Large b+}c" renders
.
By default, mimeTeX renders limits textstyle at sizes
Now enter your own LaTeX expression, use the sample provided, or Click any
of the Examples. Then press the Submit button, and mimeTeX's rendering should
be displayed in the little window immediately below it.
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>
where ../cgi-bin/mimetex.cgi is the relative path from your html page containing
these tags to your compiled mimetex.cgi program, and where
any valid LaTeX/mimeTeX expression is pretty much any valid LaTeX math
expression:
(Ib) Examples
(1)
(2)
(3)
illustrating \left\{...\right.
(6)
and note the accents
\overbrace{}^{} and
\underbrace{}_{}
(7)
(TeXbook page 181,
Exercise 18.41)
(8)
demonstrating \begin{array}'s dashed
lines
Block diagonal
form using nested
\begin{array}'s.
(9)
Also, note rows
aligned across all
three arrays.
using \begin{eqnarray} to
(10)
align equations
commutative diagram
(11)
using \begin{array}
mimeTeX
\picture(size){pic_elems}
"environment", illustrating
the image charge - q for a
(12)
grounded conducting
sphere of radius a with a
charge q at distance r > a
outside it.
\picture "environment"
illustrating the surface
polarization charge
induced by a uniform
electric field. Inside the
slab of material, the
volume polarization charge
clearly vanishes.
Finally, illustrated below are some examples of fonts and symbols available with
mimeTeX. All symbols and sizes from cmr, cmmi, cmmib (use \mathbf{ }),
cmsy, cmex, bbold (use \mathbb{ }), rsfs (use \mathscr{ }), stmary and cyrillic
wncyr (use {\cyr } or \cyr{ }) should be available, but they're not all shown. And
also not shown are various "constructed symbols" like \sqrt, accents, etc. The
illustrated font sizes are numbered 4=\Large, 3=\large and 2=\normalsize (not
shown are 7=\Huge, 6=\huge, 5=\LARGE, 1=\small and 0=\tiny).
c m s y s y m b o l s a t m i m e Te X f o n t s i z e 3
(operators shown large are automatically "promoted"
to the larger size in \displaystyle mode)
a f e w o t h e r c m m i , c m r, s t m a r y a n d w n c y r s y m b o l s a t
m i m e Te X f o n t s i z e 4
(Ic) GPL License
By using mimeTeX, you warrant that you have read, understood and agreed to
these terms and conditions, and that you possess the legal right and ability to
enter into this agreement and to use mimeTeX in accordance with it.
Hopefully, the law and ethics regarding computer programs will evolve to make
this kind of obnoxious banter unnecessary. In the meantime, please forgive me
my paranoia.
( I I ) B u i l d i n g m i m e Te X
I've built and run mimeTeX under Linux and NetBSD using gcc. The source
code is ansi-standard C, and should compile and run under all environments
without change. Instructions below are for Unix. Modify them as necessary for
your particular situation (note the -DWINDOWS switch if applicable).
The gfuntype program is only needed if you plan to change the font
information in texfonts.h, as explained in Appendix IVa below. In that case,
compile gfuntype with the command
cc gfuntype.c mimetex.c -lm -o gfuntype
(The right-hand illustration shows asterisks in the same positions as the left-hand
one, along with anti-aliased grayscale colormap indexes assigned to neighboring
pixels, and with the rgb value for each index.) Just typing ./mimetex.cgi without
an argument should produce ascii rasters for the default expression f(x)=x^2. If
you see these two ascii rasters then your binary's good. Otherwise, you must find
and fix the problem before proceeding.
(IIb) Install
Once you've successfully tested mimetex.cgi from the Unix shell (or
mimetex.exe from the Windows Command Prompt), the steps needed to install
mimeTeX are
If you don't see the image, then your installation failed. If your earlier post-
compilation "ascii raster" test succeeeded, then the problem is probably some
server-specific installation requirement. First make sure you installed
mimetex.cgi in the correct cgi-bin/ directory, set the correct chmod permissions,
and typed the correct url into your browser's locator window. Then contact your
system administrator or ISP, and ask how to install cgi programs on your server.
After you've successfully installed mimeTeX, and both preceeding tests have
succeeded, you can optionally "regression test" all mimeTeX features as follows:
-DAA
As already discussed, -DAA turns on anti-aliasing. It also sets default
values for individual anti-aliasing parameters discussed below. If you
specify -DAA then you needn't specify the individual parameters unless you
want to override the defaults.
Anti-aliasing can't be applied to mime xbitmaps, so don't specify -DAA
if you also specify -DXBITMAP.
And mimeTeX's anti-aliasing only works well on white (or light gray)
backgrounds. Your html file probably contains a <body> tag of the form
<body bgcolor="#ffffff" text="#000000"> which specifies black text on a
pure white background. The background can be grayed down to maybe
bgcolor="#e7e7e7", but much darker will begin to show white rings around
mimeTeX's anti-aliased characters. This page is displayed using
bgcolor="#ffffff".
-DCENTERWT=n
-DADJACENTWT=j
-DCORNERWT=k
MimeTeX currently provides a lowpass filtering algorithm for anti-aliasing,
which is applied to the existing set of bitmap fonts. This lowpass filter
applies weights to neighboring pixels. The defaults weights are
CENTERWT=8, ADJACENTWT=2 and CORNERWT=1, which you can
adjust to control anti-aliasing.
-DCACHEPATH=\"path/\"
This option saves each rendered image to a file in directory path/, which
mimeTeX reads rather than re-rendering the same image every time it's
given the same LaTeX expression. Sometimes mimeTeX disables caching,
e.g., expressions containing \input{ } are re-rendered since the contents of
the inputted file may have changed. If compiled without
-DCACHEPATH=\"path/\" mimeTeX always re-renders expressions. This
usually isn't too cpu intensive, but if you have unusually high hit rates then
image caching may be helpful. The path/ is relative to mimetex.cgi, and
must be writable by it. Files created under path/ are named filename.gif,
where filename is the 32-character MD5 hash of the LaTeX expression.
When caching a new image, mimeTeX also updates the file
path/mimetex.log containing a timestamp, filename and LaTeX expression
for each new file created. A sample entry looks like
---------------------------------------------
------------------------
2004-08-07:09:00:53am
f8ccc8dd93c8eeb1d9c40b353ef781e0.gif
\LARGE x=\frac{-b\pm\sqrt{b^2-4ac}}{2a}
---------------------------------------------
------------------------
-DDEFAULTSIZE=n
MimeTeX currently has eight font sizes numbered 0-7, and always starts
out in DEFAULTSIZE, whose default value is 3. Specify
-DDEFAULTSIZE=2 on the compile line if you prefer mimeTeX to start in
default size 2, etc.
-DDISPLAYSIZE=n
MimeTeX usually runs from a browser, obtaining its input expression from a
query_string. But you can also run mimeTeX from your Unix shell, supplying all
input from the command line. This was briefly illustrated above, where you were
advised to test your newly-compiled mimeTeX executable from the command
line before installing it.
In addition to such simple testing, mimeTeX also provides some possibly useful
functionality from the command line. In particular, you can store a gif (or
xbitmap) image of any expression to a file. No syntax checking is applied to
command-line arguments, so enter them carefully. (Likewise, plus signs + are
never translated to blank spaces, nor is any other %xx url decoding performed
on command-line arguments.)
The complete command-line syntax for mimeTeX is
Anything not discussed here that still doesn't behave like you expect is probably
just not implemented. That includes (La)TeX packages (though a few ams
commands like \begin{gather} and \begin{pmatrix} are recognized), non-
standard fonts, etc. You can try out any questionable syntax by Submitting a
query to quickly see whether or not it works. And you might want to
occasionally re-browse the Examples above, which may better illustrate
implemented features.
\unitlength...
\hspace{ }
\hfill{ }
\raisebox{ }{ }
\line( , ) and \circle( , )
\longrightarrow[ ]
MimeTeX's \unitlength{ } command lets you specify the number of pixels per
"length unit", e.g., \unitlength{10} \hspace{2.5} renders a 25-pixel space. Both
\unitlength{ } and \hspace{ }'s length arguments may be integers or may contain
decimal points. Ditto for all other mimeTeX commands that take length
arguments. The default \unitlength is, you guessed it, 1.
which has a 10-pixel space between A and B, then 25 pixels between B and C,
and finally another 10 pixels between C and D.
Math Spaces...
Except inside text boxes, unescaped blanks, tildes (a ~), and all other usual
whitespace characters are completely ignored by mimeTeX, just like they are in
LaTeX math mode. As usual, you must explicitly write one of the recognized
math spaces to put extra visible space in your rendered expressions.
For negative spaces, \! produces a small (two pixel) negative space, e.g., a=b
renders whereas a\!=b renders and a\!\!=b renders
. For large negative space, \hspace{-10} permits a negative argument. But it
stops at the first pixel to its left rather than "erasing" pixels. If you don't want to
stop, use \hspace*{-10} instead. For example, ABC\hspace*{-20}-DEF
renders , erasing all of the C and the right half of the B.
Finally, mimeTeX begins a new line whenever you write \\ . And you may
optionally write \\[10] to put a 10-pixel (or any other number) vertical space,
scaled by \unitlength, between lines. \begin{eqnarray} also splits long equations
over several lines, as illustrated by Example 10 above. But when that's not the
best solution, you can also write, for example,
y=a+b+c+d\\\hspace{50}+e+f+g+h to produce
y=\left\{a+b+c+d\\\hspace{50}+e+f+g+h\right\} produces
<img src="../cgi-
bin/mimetex.cgi?f(x)=\frac1{\sigma\sqrt{2\pi}}
\int\limits_{-\infty}^xe^{-\frac{(t-
\mu)^2}{2\sig^2}}dt"
alt="" border=0 align=middle>
breaks a long query_string over two lines. If your browser interprets this
correctly, then mimeTeX will render it correctly, too. Otherwise, you'll have to
enter long expressions on one big long line.
If you can break long query_string's over several lines, then you may find
mimeTeX's %%comments%% feature useful, too. Note that comments must
be preceded and followed by two %'s rather than LaTeX's usual one. The above
example could be written
<img src="../cgi-
bin/mimetex.cgi?f(x)=\frac1{\sigma\sqrt{2\pi}}
%%normalization%%
\int\limits_{-\infty}^xe^{-\frac{(t-
\mu)^2}{2\sig^2}}dt %%integral%%"
alt="" border=0 align=middle>
Character Sets...
For complete information about the characters and math symbols available in
mimeTeX, you'll need to browse through the bottom 500-or-so lines of
mimetex.h. And several additional symbols like \ldots and \AA and \hbar are
defined by the mimeTeX preprocessor, function mimeprep( ) in mimetex.c
Generally speaking, I've tried to encode the cmr10, cmmi10, cmmib10, cmsy10,
cmex10, bbold10, rsfs10, stmary10 and wncyr10 families with "names", e.g.,
\alpha \beta \forall \sqcup, etc, identical to your LaTeX expectations. For
example, the calligraphic symbols in cmsy10 are accessed by writing
\mathcal{A} \mathcal{B} \mathcal{XYZ}. Similarly, write \mathbf{A} for the
cmmib fonts, write \mathscr{A} for rsfs10, write \mathbb{R} for bbold10, and
write {\cyr Khrushchev} or \cyr{Khrushchev} to see . Most LaTeX
distributions supply stmaryrd.dvi and stmaryrd.sty that both document the names
of the stmary10 symbols. Similarly, amsfndoc.dvi documents the names of the
wncyr10 cyrillic symbols and ligatures.
I haven't exhaustively checked all the name-number matchings for the hundreds
of symbols in mimetex.h. You can eaily correct any minor mistake you find in
what I hope is an obvious manner. The fonts Appendix IVa below provides
additional information.
In addition to extra LaTeX symbols like \ldots, \AA and \hbar, mentioned
above, the mimeTeX preprocessor mimeprep( ) also recognizes various html
special characters like <, >, , ", &, etc. Some web
tools apparently translate characters like, e.g., > to >, even inside quoted
query_string's, so mimeTeX's preprocessor translates them back to LaTeX
symbols for you. Moreover, html misinterprets quotes " inside a quoted query
string as the end of the query string. So, for example, the cyrillic ligature \"E has
to be written in the even more cumbersome form \"E inside a query string.
Font Sizes...
MimeTeX currently has eight font sizes, numbered 0-7, with default 3. This font
size numbering corresponds to the usual LaTeX directives \tiny, \small,
\normalsize, \large (default), \Large, \LARGE, \huge and \Huge. These
directives can be placed anywhere in a mimeTeX expression, and they change
font size from that point forwards. However, as usual, a font size change inside a
{ }-subexpression remains in effect only within that subexpression.
You'll soon notice that exponents and \frac's and \atop's are automatically
rendered one size smaller than their base expressions. For example,
rendering the "y=e" in font size 4 (\Large), the "x" in font size 3 (\large), and
the "2" in font size 2 (\normalsize). If you get below font size 0, the font size
remains 0.
Explicit size declarations override mimeTeX's default sizing behavior. You can
rewrite the preceding example as, say,
rendering the "y=e" in font size 4 (\Large unchanged), the "x" in font size 2
(\normalsize), and the "2" in font size 0 (\tiny).
rendering the "y=e" in font size 4 (\Large), as usual. The "x" would usually be
rendered one size smaller, in font size 3, and your \fs{-1} is applied to that,
resulting in font size 2. And the final "2" is rendered, by the usual rules, one size
smaller than the "x", in font size 1.
Modes...
and
As usual, \nolimits turns displaystyle off (or textstyle on) for the operator
immediately preceding it. For example,
\widehat{xyz}\limits^a produces
This side effect may occasionally be useful. For example,
x\rightarrow\limits^gy produces
The \displaystyle command turns on displaystyle math mode for the entire
expression (or { }-enclosed subexpression), affecting _all_ super/subscripts to
the right of the \displaystyle, except for character classes Ordinary and Variable
(TeXbook page 154). Similarly, \textstyle turns off displaystyle math mode. For
example,
Note that \sum's within the subexpression are all affected by the beginning
\displaystyle, but not the Variable x_i^j. An explicit x\limits_i^j always affects
any preceding term.
text boxes...
You don't usually surround mimeTeX expressions with $'s, but that works in the
usual way for \text{ } and \mbox{ }, rendering the $...$-enclosed subexpression
in mathmode. For example,
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...
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
renders .
3. In the last two examples, note that mimeTeX recognizes the \\ in
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.
Accents...
Function names...
\lim_{n\to\infty}S_n=S produces
long Arrows...
All mimeTeX \long and \Long arrows take an optional [width] argument that
explicitly sets the arrow's width in pixels, scaled by \unitlength. For example,
\longrightarrow[50] draws a 50-pixel wide arrow , whereas just
\longrightarrow calculates a default width , 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.
x\longrightarrow^gy produces
x\longrightarrow[50]^gy produces
u\longrightarrow[50]_\beta v produces
\longuparrow[30]^\gamma produces
\longdownarrow[30]_\gamma produces
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.
abc\raisebox{-2}{\rotatebox{180}?}def produces
abc\raisebox{-2}{\reflectbox[2]?}def produces
\compose{ }{ }...
\rule{ }{ }...
\rule{width}{height} behaves in the usual way, rendering a black rectangle
width pixels wide and height pixels high, with its base on the established
baseline. For example,
\frac12xyz\rule{10}{20}ghi produces
The mimeTeX version of \rule has an optional [lift] argument, so that its full
form is \rule[lift]{width}{height}. lift moves the rule's baseline by the specified
number of pixels, up if positive or down if negative. For example,
\frac12xyz\rule[-15]{10}{20}ghi produces
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.
Colors...
"Smash"...
TeX represents characters by boxes, with no idea how ink will be distributed
inside. So an expression like \frac12\int_{a+b+c}^{d+e+f}g(x)dx is typically
rendered as . But mimeTeX knows the character shapes of its
fonts, and therefore tries to remove extra whitespace, rendering the same
expression as instead.
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
Smashing is in "beta testing" and some expressions still don't look quite right
when smashed, e.g., 1^2,2^2,3^2,\ldots renders as . Just
compile with -DNOSMASH if you come across numerous annoying situations.
The usual LaTeX \not "slashes" the single symbol following it, e.g.,
i\not\partial\equiv i\not\nabla produces .
For arbitrary expressions, mimeTeX provides \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 .
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
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,
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.
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).
( I I I g ) O t h e r m i m e Te X C o m m a n d s
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
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.
\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,
\fbox{ }...
In case html border attributes aren't suitable, mimeTeX provides the usual
\fbox{expression} command, e.g.,
"\fbox{x=\frac12}" produces
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.
\ t o d a y a n d \ c a l e n d a r. . .
\calendar renders a calendar for the current month, as illustrated by the left-
hand image below. For a different month, the optional argument
\small\blue\calendar[2001,9] renders the right-hand image, for the requested
year and month. Years must be 1973...2099 and months must be 1...12.
The default calendar emphasizes the current day of the current month, while any
other month emphasizes no day. Day emphasis is controlled by an optional third
argument. \calendar[0,0,1] emphasizes the first day of the current month, and
\calendar[2001,9,11] emphasizes the eleventh day of that month.
\calendar[0,0,99] renders the current month with no day emphasized.
\input{ }...
\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
<tag> value </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.
( I I I h ) O t h e r E x c e p t i o n s t o L a Te X S y n t a x
Binding Exceptions...
(IV) Appendices
( I Va ) m i m e Te X F o n t s
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
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
Finally, run gfuntype against the typeout file you just generated with the
command
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
Then ditto for the eight other font families cmmi10, cmmib10, cmsy10, cmex10,
bbold10, rsfs10, stmary10 and wncyr10. And to generate other .dpigf font sizes,
To incorporate all this font information you just generated into mimeTeX, edit
your mimetex.h file and find the table that looks something like
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.)
( I V b ) m i m e Te X ' s m a k e _ r a s t e r ( ) f u n c t i o n
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 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"
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.
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 FUNCTIONS
=============
GIF_Create()
------------
Function Creates a new GIF-file, and stores
info on
the screen.
GIF_SetTransparent()
--------------------
Function Specifies the color number of the
color
that should be considered
transparent.
GIF_CompressImage()
-------------------
Function Compresses an image and stores it
in the
current file.
GIF_Close()
-----------
Function Closes the GIF-file.
callback()
----------
Function Obtains pixel-values for the
GIF_CompressImage() -function.
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.