MyTetra Share
Делитесь знаниями!
Копия страницы с документацией по MimeTex
Текстовые метки: формулы, mimetex, документация
Раздел: Компьютер - Программирование - Язык C - Библиотека MimeTeX

m i m e T e X   q u i c k s t a r t
( for mimeTeX version 1.64 )
Click for:   complete mimeTeX manual
download mimeTeX


Copyright © 2002-2006, John Forkosh Associates, Inc.

    C o n t e n t s    


    Q u i c k S t a r t   S u m m a r y    

(a) Introduction
(b) QuickStart
(c) Examples
(d) QuickBuild
(e) GPL License

  Related   Pages  
LaTeX Tutorial
mimeTeX changeLog
mimeTeX Manual



Download and then type
    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.



To see the image

just write the tag
    <img src="/cgi-bin/mimetex.cgi?

(a) 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>

immediately generates the corresponding gif image on-the-fly, displaying 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 if you want image caching, see 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 has a mimeTeX plugin that lets you just write {$ f(x)=\int_{-\infty}^xe^{-t^2}dt $} to obtain the same image.   Similarly,






"mimeTeX alternative"



"mimeTeX Parser"



mimeTeX plugin

Movable Type


mimeTeX plugin



"mimeTeX bot"



mimeTeX plugin   (see item 9)

and, as already discussed in the text...



mimeTeX plugin



mimeTeX plugin

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




// Remove our padding from the string..

#--------[before, add]----------------------------------------------

$text = preg_replace('/\[tex\](.*?)\[\/tex\]/ie',

"'<img src=\"/cgi-bin/mimetex.cgi?'.rawurlencode('$1').'\" align=\"middle\" />'",


  (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's benefit over similar math-on-the-web solutions is, as mentioned above, its very easy installation. But if that's not a problem for you, and if your site's server already has a LaTeX distribution installed, and suitable image conversion utilities like ImageMagick, then you may prefer to look at a math rendering script like latexrender which uses LaTeX to create higher quality images than mimeTeX currently produces. For comparison, , with arbitrary mean and standard deviation , and at mimeTeX's next larger font size, looks like




Similar LaTeX-based solutions that you may want to look at are textogif and gladTeX. Additional discussion and several more links are at and in the tex-faq.

(b) QuickStart  

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 (a detailed syntax overview and reference is provided by the complete mimeTeX manual):

  • 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 \normalsize and smaller, and renders them displaystyle     at sizes \large and larger. The LaTeX directives \displaystyle or \textstyle, and \limits or \nolimits, override mimeTeX's default in the usual way.

Now enter your own expression, use the sample provided, or Click any of the Examples. Then press the Submit button, and mimeTeX's rendering should be displayed in the little window immediately below it.

First enter your own LaTeX expression, or Click any example...
\Large f(x)=\int_{-\infty}^x e^{-t^2}dt


Now click Submit to see it rendered below...
&amp;lt;p&amp;gt;iframe's not supported if you see this.&amp;lt;/p&amp;gt;

First enter your own LaTeX expression, or Click any example...
\Large f(x)=\int_{-\infty}^x e^{-t^2}dt


Now click Submit to see it rendered below...
&amp;lt;p&amp;gt;iframe's not supported if you see this.&amp;lt;/p&amp;gt;

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

(c) Examples  

Here are various additional random examples further demonstrating mimeTeX's features and usage. To see how they're done, Click any one of them to place its corresponding expression in the Query Box above. Then press Submit to re-render it, or you can edit the expression first to suit your own purposes. You may also want to look at a sample document prepared using mimeTeX to render equations.




definition of derivative


illustrating \left\{...\right.
and note the accents


\overbrace{}^{} and \underbrace{}_{}
(TeXbook page 181, Exercise 18.41)


\begin{array}'s dashed lines


Block diagonal form using nested \begin{array}'s.
Also, note rows aligned across all three arrays.


using \begin{eqnarray} to align equations


commutative diagram using \begin{array}


mimeTeX \picture(size){pic_elems} "environment", illustrating the image charge - q for a grounded conducting sphere of radius a with a charge q at distance r > a outside it.


\picture "environment" illustrating the surface polarization charge induced by a uniform electric field. Inside the slab of material, the volume polarization charge clearly vanishes.

The little
dipole image is drawn only once, then multiput across two columns, and then that result is further multiput down the rows. MimeTeX \picture's can be used as picture elements in other pictures, nested to any level. The image at left is picture-in-picture-in-picture.

(d) QuickBuild  

Very quickly   ---   download and then type

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

      Now mv mimetex.cgi to your cgi-bin/ directory, and you're all done.      
Read the rest of this section only if you want more information.

mimeTeX's source code is ansi-standard C, and should compile and execute without any change. QuickBuild instructions below are for Unix. Modify them as necessary for your particular situation (note the -DWINDOWS switch if applicable). More detailed instructions comprise Section II of the complete manual.

The steps needed to compile and install mimeTeX are:

  • Download and unzip in any convenient working directory. Your working directory should now contain


    mimeTeX release notes


    GPL license, under which you may use mimeTeX


    mimeTeX source program and all required functions


    header file for mimetex.c (and for gfuntype.c)


    only needed if you want to create new font data for texfonts.h


    output from several gfuntype runs, needed by mimetex.c


    gif library by Sverre H. Huseby


    complete mimeTeX user's manual

  • To compile an executable that emits anti-aliased gif images, just type
            cc -DAA mimetex.c gifsave.c -lm -o mimetex.cgi
  • Windows compile notes:
    • If (and only if) you're compiling a Windows executable then add -DWINDOWS
              gcc -DAA -DWINDOWS mimetex.c gifsave.c -lm -o mimetex.exe
      The above Unix-like syntax works with MinGW and djgpp Windows compilers, but probably not with most others, where it's only intended as a "template".
    • If you'd prefer to install mimeTeX as a Win32 DLL, see the Code Project developed by Shital Shah, and download containing Shital's latest code.

  • Immediately after compiling, test your new executable by typing   ./mimetex.cgi "x^2+y^2"   from the Unix command line (or   mimetex "x^2+y^2"   from the Windows Command Prompt), which should emit two ascii rasters something like the following
  • Ascii dump of bitmap image... Hex dump of colormap indexes...

    ...........**....................**... ..........1**1...................1**1..

    ..........*..*......*...........*..*.. ..........*23*......*............*23*..

    .............*......*..............*.. .............*......*...............*..

    ....****.....*......*.....*..*.....*.. ...1****....2*......*.....2*..*....2*..

    ...*.*.*....*.......*....**..*....*... ...*.*.*...1*.......*.....**..*...1*...

    .....*.....*.*..********..*..*...*.*.. ....1*1...2*.*..********..3*..*..2*.*..

    .....*....****......*.....*..*..****.. ....2*2...****......*......*12*..****..

    ..*.*.*.............*.....*.*......... ..*.*.*.............*......*.*2........

    ...****.............*.....***......... ..1****.............*......***.........

    ....................*.......*......... ....................*........*.........

    .........................*.*.......... ..........................*.*1.........

    .........................**........... ..........................**1..........

    The 5 colormap indexes denote rgb vals...

    .-->255 1-->196 2-->186 3-->177 *-->0

  • Install your compiled executable only after it runs successfully from the command line. Just   mv mimetex.cgi   to your server's cgi-bin/ directory and set permissions as necessary.
  • Now, to quickly test your installed mimetex.cgi, try typing a url into your browser's locator window something like
    which should display     in the upper-left corner of your window, just like clicking this link does, which tests my mimetex.cgi,

Any problems with anything above? Read the more detailed instructions in Section II of the complete manual.

Precompiled Binaries...

Compiling your own mimeTeX executable from source is highly recommended. But if you don't have a compiler, or experience some other difficulty, then the following pre-compiled binaries are available. Each binary is the last file in a zip file named, which also contains all the source files that were current when the binary was compiled. I can't be sure my binary will work on your machine. Unix binaries are usually named mimetex.cgi inside the file, and others (e.g., Windows and VMS) are usually named mimetex.exe. Unzip and rename them as necessary for your own system.

 Operating System 

  Last Updated  


Linux (i386)

FreeBSD (i386)

NetBSD (i386)



After downloading, if you have "shell access", test your downloaded binary from the command line as described in the compile section above, to make sure it's the right binary for your system. If you see the two ascii rasters illustrated above, then your binary's good, so mv it to your server's cgi-bin/ directory and set permissions as necessary. But if your mimetex binary won't display ascii rasters from the command line, then it's not going to emit gifs from the server. Either find a compatible binary from the list above, or you'll have to find a way to compile your own binary from mimetex's source.

Public mimeTeX server...

If you have trouble installing mimeTeX on your own server, a public mimeTeX server is currently available. An <img> tag of the form

<img src="\sqrt{a^2+b^2}"

alt="" border=0 align=middle>

will display wherever you put that <img> tag in your own document. Note that the typical ../cgi-bin/mimetex.cgi? has been replaced by in this <img> tag, using mimeTeX on my server to render your expression for you.

(e) GPL License   "My grandfather once told me there are two kinds of people:
    Those who do the work and those who take the credit.
    He told me to try to be in the first group; there was much less competition.
Indira Gandhi, the late Prime Minister of India

MimeTeX's copyright is registered by me with the US Copyright Office, and I hereby license it to you under the terms and conditions of the GPL. There is no official support of any kind whatsoever, and you use mimeTeX entirely at your own risk, with no guarantee of any kind, in particular with no warranty of merchantability.

By using mimeTeX, you warrant that you have read, understood and agreed to these terms and conditions, and that you possess the legal right and ability to enter into this agreement and to use mimeTeX in accordance with it.

Hopefully, the law and ethics regarding computer programs will evolve to make this kind of obnoxious banter unnecessary. In the meantime, please forgive me my paranoia.

To protect your own intellectual property, I recommend Copyright Basics from The Library of Congress, and similarly, Copyright Basics from The American Bar Association. Very briefly, download Form TX and follow the included instructions. In principle, you automatically own the copyright to anything you write the moment it's on paper. In practice, if the matter comes under dispute, the courts look _very_ favorably on you for demonstrating your intent by registering the copyright.

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. 

Так же в этом разделе:
MyTetra Share v.0.52
Яндекс индекс цитирования