LaTeX with Google chart
Appearance
(Redirected from LaTeX with google chart)
This page is obsolete. It is being retained for archival purposes. It may document extensions or features that are obsolete and/or no longer supported. Do not rely on the information here being up-to-date. |
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 Tools to render latex in two ways:
Solution 1
[edit](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;
}
?>
Solution 2
[edit](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
See also
[edit]- Extension:SimpleMathJax a quicker and easier way to provide support for rendering mathematical formulas on-wiki, without texvc or LaTeX.