Knowledge Base Article

How to get complex math formulas working in MediaWiki

This article explains how to overcome issues with Math formulas not properly displaying in MediaWiki with enabled Math Support.

The problem is mainly caused by the fact that the default Math Support in MediaWiki does not include all desired formulas or mathematical signs. Particularly more complex ones.

If you are getting an error that the formula you are trying to use is not recognize follow these steps.


1. Enable Math Support for your MediaWiki
2. Download this file and place it in the cgi-bin folder for your account with execute permissions.
3. Make sure there is a directory under the cgi-bin folder called mathtex and set its permissions to 755.
4. Open the Math.php file located in the /includes folder of your MediaWiki 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/mathtex.cgi?' . rawurlencode($tex) . '"' . htmlspecialchars($tex) . '">';

The result should look like this:

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


Where http://www.example.com/cgi-bin/mathtex.cgi is the URL of the mathTeX cgi script you have just downloaded and placed on your account.

That's it. All valid mathematical formulas should be loading properly for your MediaWiki installation now.



Rating

Please indicate if this article was helpful for you.

rating :  4.7 from 5
views :  694
votes :  3

Related Articles

Views

Haven't found what you are looking for? Suggest an article HERE.

powered by

Valid XHTML 1.0 Strict Valid CSS!