LaTeX with google chart
From MediaWiki.org
LaTeX on a shared host and Mediawiki and LaTeX on a host with shell access tell you how to use mimeTeX.cgi to get Latex rendered on your wiki, there is another way now - the google chart.
You can use google chart to render latex in two ways:
[edit] Solution 1
(based on the idea of Mediawiki and LaTeX on a host with shell access)
<?php # Place this file in extension directory as Mtag.php # Add the following line to LocalSettings.php: # include './extensions/Mtag.php'; # Mediawiki will render as LaTeX the code within <m> </m> tags. $wgExtensionFunctions[] = "wfMtag"; function wfMtag() { global $wgParser; $wgParser->setHook( "m", "returnMtagged" ); } function returnMtagged( $code, $argv) { $urlencodedcode = urlencode($code); $txt='<img src="http://chart.apis.google.com/chart?cht=tx&chf=bg,s,FFFFFFFF&chco=000000&chl='.$urlencodedcode.'">'; return $txt; } ?>
[edit] Solution 2
(based on the idea of LaTeX on a shared host)
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://chart.apis.google.com/chart?cht=tx&chf=bg,s,FFFFFFFF&chco=000000&chl=' . rawurlencode($tex) . '" alt="LaTeX: ' . htmlspecialchars($tex) . '">';
Result:
public static function renderMath( $tex, $params=array() ) { return '<img class="tex" src="http://chart.apis.google.com/chart?cht=tx&chf=bg,s,FFFFFFFF&chco=000000&chl=' . rawurlencode($tex) . '" alt="LaTeX: ' . htmlspecialchars($tex) . '">'; global $wgUser; $math = new MathRenderer( $tex, $params ); $math->setOutputMode( $wgUser->getOption('math')); return $math->render(); }
Then enable TeX in LocalSettings.php