|
Cookbook /
MimeTeXSummary: Add markup to display and embed mathematical formulas in wiki pages
Version: 2007-02-16
Prerequisites: pmwiki-2.0.0
Status: Stable
Maintainer: Pm
Categories: Markup
Votes:
Questions answered by this recipe
Solution
DiscussionThe mimeTeX utility from John
Forkosh Associates, Inc., along with the mimetex.php script above, makes
it easy to embed mathematical formulas in wiki pages using the LaTeX
math expression syntax. Once installed, the markup {$ x^2 + y^2 = z^2 $}
produces
More complex formulas can be generated--for example: {$ e^x=\relstack{\rm lim}{n\rightar\infty}\(1+\frac xn\)^ $}
becomes
See the full mimeTeX manual [forkosh.com] for more details. InstallationTo install MimeTeX, perform the following steps: 1. Download and install the mimeTeX package from http://www.forkosh.com/mimetex.html. You can use the installation instructions given in the README file included with the mimeTeX package; on pmichaud.com we simply unzipped the archive into a mimetex/ directory and executed the command cc -DAA mimetex.c gifsave.c -lm -o mimetex.cgi (you can download the compiled version for linux directly on : http://www.forkosh.dreamhost.com/mimetex.exe/linux/mimetex.zip(approve links) ) 2. Place the mimetex-vc.phpΔ script in your cookbook/ subdirectory and rename it mimetex.php) 3. If you want to have PmWiki simply use MimeTeX as an external CGI script and do no caching of its own, you can place the following lines in your local/config.php (change the URL for mimetex.cgi as necessary): $MimetexUrl = '/cgi-bin/mimetex.cgi';
include_once('cookbook/mimetex.php');
4. If you want PmWiki to call MimeTeX directly and cache the resulting images, then create a directory called pub/cache for the images and give the webserver write permissions to this subdirectory. (On Unix systems this is typically done via the command $MimetexCmd = '/filesystem/path/to/mimetex.cgi';
include_once('cookbook/mimetex.php');
That should do it! Whenever mimetex.php encounters the {$ ... $} markup, it automatically generates a call to mimetex.cgi and displays the resulting image. If PmWiki is being used to cache the images, then the images are kept in pub/cache/ to avoid regenerating them on future page accesses. A WikiAdministrator can delete the image files in pub/cache/ at any time and MimeTeX will automatically regenerate them as needed. MimeTeX itself now has an optional built-in cachine mechanism, which is enabled by compiling mimetex.cgi with the 5. If you have a wikifarm installed, you need an extra
--- mimetex.php.orig
+++ mimetex.php
-SDV($ImgCacheDir,"pub/cache");
+SDV($ImgCacheDir,"$FarmD/pub/cache");
Also add include_once('Contributors
MimeTeX Sandbox{$$ f_X(x_1, \dots, x_N) = \frac {1}
{(2\pi)^{N/2} \left|\Sigma\right|^{1/2}}
\exp \left( -\frac{1}{2}
( x - \mu)^\top \Sigma^{-1} (x - \mu)
\right)$$} Feel free to use the space below to test various mimeTeX formula markups.
{$\array{CCC$\Large f=b_\0+\frac{a_\1}{b_\1+\frac{a_2}{b_2+\frac{a_3}{b_3+a_4}}} & \hspace{10} {\small\rm{Notes and\atop mimeTeX Sandbox}} \hspace{10} } \Large \scrJ^{ij}=\frac12\vareps_{ijk}\[\array{cc$\sig_k&0\\0&\sig_k}\] $
This is some text wrapped around
Some examples used from another Wiki:
Some weird examples... probably a bug. Only one of the formulas below should produce
Ben: I found a similar bug. If you insert \. (which does nothing) at the beginning of each of these, then MimeTeX formats the image correctly. I would guess it is a bug with MimeTeX. Typing the following should work:
Comments: When you want to include mathematics on the same line as text, the alignment is rather ugly. You can simplify this by changing line 46
return "<img class='mimetex' src='$ImgCacheUrl/$imgname' alt='". to return "<img ALIGN='absMIDDLE' class='mimetex' src='$ImgCacheUrl/$imgname' alt='". This causes the images to be centered with the center line of the text. It works in IE and Firefox. It still is not perfect at displaying all images, but I think it looks a lot better. Other options for aligning are available (see http://www.w3.org/MarkUp/Test/Img/imgtest.html). I think the absmiddle does the best job.
I'm trying to make this work but I keep getting the error message: Warning: Cannot modify header information - headers already sent by (output started at /home6/jcarter/public_html/pmwiki/cookbook/mimetex.php:4) in /home6/jcarter/public_html/pmwiki/pmwiki.php on line 871. any suggestions??? Try re-downloading the mimetex.phpΔ script. I suspect there may have been extraneous characters at the end of the file. If that doesn't help, try emailing me (pmichaud@pobox.com).
I'm looking for markup that I can use for text that will allow me to place alternative strings directly above and below eachother (without using preformatted text). For example, with preformatted text, the result would be like this:
(ago)
A: (e) ache moyuba
Using frac (and avoiding Q&A): A: (e) Using large and frac: A: (e) Using large and relstack:
Using \\: A: (e) ------
i'm wondering if and how can this plugin works under windows iis.. Folks can't get it to work config.php has $MimetexUrl = '/cgi-bin/mimetex.cgi';
include_once('cookbook/mimetex.php');
"cgi-bin" is a subdirectory in the "pmwiki-2.1.26" directory. mimetex.cgi is there, still it shows only the typed symbols, not the one I want to display. Thanks for suggestion <<<<<<< mw <math>\sqrt{1-e^2}</math>
ltx <math>\sqrt{1-e^2}</math> >>>>>>>
http://meta.wikimedia.org/wiki/Help:Formula
{$S_{new} = S_{old} - \frac{ \left( 5-T \right) ^2} {2}*}
27-Feb-2007 mimetex.phpΔ attachment seems to be corrupted. Can it be restored please ??
Attachement problem24-Jul-2007 18-Nov-2007
User notes +1: If you use, used or reviewed this recipe, you can add your name. The following format is recognized:
* (+) Optional positive comment. Name, date * (-) Optional negative comment. Name, date These statistics appear in the Cookbook listings and will help newcomers browsing through the wiki. |