LaTeX on a shared host

From MediaWiki.org

Jump to: navigation, search

It is possible to run LaTeX under a shared host. It might not be beautiful, but it works. If you wish to do this, be aware that this is not an official hack.

I am writing this because I had a hard time finding the information. I found it on google's cache of an old forum which did not exist outside google's cache. Therefore I'm writing it here, so that other people might also find it.

  1. Install MediaWiki
  2. Take a backup of your MediaWiki installation.
  3. Find a LaTeX engine:
    1. If you have CGI support on your host install mimeTeX, which can be found at: http://www.forkosh.com/mimetex.html
    2. If you don't have CGI support, use a public mimeTeX server: http://www.forkosh.dreamhost.com/mimetex.cgi or http://www.forkosh.dreamhost.com/mathtex.cgi (for prettier rendering using mathTeX)
  4. Open Math.php in $WikiPath/includes/Math.php and find this function (at the bottom):
public static function renderMath( $tex, $params=array() ) {
    global $wgUser;
    $math = new MathRenderer( $tex, $params );
    $math->setOutputMode( $wgUser->getOption('math'));
    return $math->render();
}

Add this line after the first line:

    return '<img class="tex" src="http://www.example.com/cgi-bin/mimetex.cgi?' . rawurlencode($tex) . '" alt="LaTeX: ' . htmlspecialchars($tex) . '">';

Result:

public static function renderMath( $tex, $params=array() ) {
    return '<img class="tex" src="http://www.example.com/cgi-bin/mimetex.cgi?' . rawurlencode($tex) . '" alt="LaTeX: ' . htmlspecialchars($tex) . '">';
    global $wgUser;
    $math = new MathRenderer( $tex, $params );
    $math->setOutputMode( $wgUser->getOption('math'));
    return $math->render();
}

Where http://www.example.com/cgi-bin/mimetex.cgi? is the URL of your mimeTeX installation or the public one.

Then enable TeX in LocalSettings.php


Remember this is not official, and may not work with some versions. I've tried version 1.5.5.

Also working on version 1.5.6 --80.62.185.50 00:03, 7 February 2006 (UTC)
Work fine on Mediawiki 1.6.3 --82.50.10.47 12:23, 17 April 2006 (UTC)
Commented out all existing lines of renderMath. $math and $wgUser are obviously not used in the patched version. This change has not been tested. See page history for old version. --Archimerged 02:58, 27 May 2006 (UTC)
Tried on MediaWiki 1.12 and it does not work. Do you have a patch?
Works on my 1.12. I used the external mimetex server, cose I have problems with my cgi-bin.
Working on version 1.13.1 with external mathtex server.
Working on version 1.14 with external mathtex server.

[edit] See also