Extension:Mimetex alternative

On some web hosting servers, especially shared hosting servers, LaTeX, ImageMagick, or Ghostwriter may not be installed. Using a program called Mimetex.cgi which was created by John Forkosh, a work around has been created.

You can view his site at http://www.forkosh.com/mimetex.html for a complete description of Mimetex.

How to install Mimetex on your own server
To install Mimetex on your own server, and integrate its functionality into Mediawiki you will need Mediawiki installed on a web server and Ftp access. If you have this much, follow the instructions below.

This installation will allow you to use &#60;tex&#62; and &#60;/tex&#62; tags in your edit boxes. If you modify the EditPage.php file as shown below you can use the Math button included in Mediawiki to insert the proper tags.

Save the text below in a file called mimetex.php and install this file into your extensions folder.

setHook( "tex", "render_Mimetex" ); }

/** function render_Mimetex($input, $argv, $parser = null) {
 * Renders $text in Mimetex

if (!$parser) $parser =& $GLOBALS['wgParser']; // $img_url is the url the mimetex will be sent to. // IMPORTANT!! The URL below should be the link to YOUR mimetex.cgi if possible $img_url = "http://www.forkosh.dreamhost.com/mimetex.cgi?".$input; // Sets the output of the tex tag using the url from above, and the input as // the Alt text. It's important to note that there is no error output added yet. $output = "";

return $output; } ?>

and add the line:

require("extensions/mimetex.php");

to the end of your localsettings.php file in your root directory of your MediaWiki site.

You also change the Math button in your editor to give you &#60;tex&#62; and &#60;/tex&#62; tags. You can customize the Edit Toolbar quite easily.

In the ...wiki/includes/ directory you will find a file called editpage.php. Don't forget to make a copy before changing it, just in case (cp editpage.php editpage.php~).

Search for the following lines: array(	'image'	=>'button_math.png',	'open'	=>	"",	'close'	=>	"",	'sample'=>	wfMsg('math_sample'),	'tip'	=>	wfMsg('math_tip'),	'key'	=>	'C' Replace with: array(	'image'	=>'button_math.png', 'open'	=>	"\\", 'close'	=>	"\\", 'sample'=>	wfMsg('math_sample'), 'tip'	=>	wfMsg('math_tip'), 'key'	=>	'C'

You should make sure your files have the correct permissions (read and execute, but not write). Also note that there is no error encoding included in this installation, but fortunately Mimetex.cgi will do that for you (if the code entered is not a LaTeX equation, a blank image will be presented).

To install Mimetex, either follow the instructions at www.forkosh.com/mimetex.html or download the appropriate Mimetex.cgi precompiled file from: http://www.forkosh.dreamhost.com/mimetex.exe/

Your version of Mimetex.cgi needs to be placed in the ../cgi-bin folder on your website, and needs to have the file permissions be 755 (everyone can read and execute the file and the user can write to it).

This extension was created by examining a module in Drupal called Drutex (which was originally authored by Daniel Gutekunst), although very little of the original code is the same. It also uses the sample code provided by Mediawiki for the purposes of creating extensions. It is meant to be covered under the GNU General Public License. The author of this extension is David Wees, July 1st, 2006.