Welcome to bytea
当前位置: Home 学习资料 网站制作 Display math formula in Mediawiki using mimetex 今天是...date...

登录bbs

用户名
密码

bytea统计

Members : 43193
Content : 332
Web Links : 69
Display math formula in Mediawiki using mimetex PDF Print E-mail
Sunday, 19 November 2006 08:00
Mediawiki itself has a Math.php file used to generate math formula, but the installation is a little bit complicated:
  1. First of all, we need to install ocaml and LaTex.
  2. And then enter the math directory, make to compile texvc.
  3. Finally modify the LocalSettings.php file, set $wgUseTeX to true;
For the guys do not have their own server (like me), it is difficult to install ocaml and LaTex. So let me introduce my method: using mimetex to display math fomular:

mimetex is a CGI program which generate formula using tex syntax, the installation is much simpler than ocaml and Latex. I would not talk about the installation of mimetex here, since this tutorial focus of mediawiki. I will assume you have a mimetex.cgi file already, and let's start the modification of mediawiki:
  1. First of all, enter the math directory, backup math.php file.
  2. upload our math.php file ( the file is given at the end of this tutorial)
  3. Open the Localsettings.php file, change the setting:
    $wgUseTeX             = true;
    $wgMathPath         = "MIMETEX URL";
  4. The "MIMETEX URL" above is the location of your mimetex.cgi program, for my website, it looks like "http://www.bytea.net/cgi-bin/mimetex.cgi"
Ok now let's have a look at the math.php file:
For the guys using php4.x, the whole math.php looks lie:

<?php
function renderMath( $tex ){
    global $wgMathPath;
    $url = htmlspecialchars( "$wgMathPath?$tex");
    $alt = trim(str_replace("\n", ' ', htmlspecialchars( $tex )));
    return "<img class='tex' src=\"$url\" alt=\"$alt\" />";
}
?>

For the guys using php5.x, the whole math.php looks lie:

<?php
class MathRenderer {
    public static function renderMath( $tex ) {
        global $wgMathPath;
        $url = htmlspecialchars( "$wgMathPath?$tex");
        $alt = trim(str_replace("\n", ' ', htmlspecialchars( $tex )));
        return "<img class='tex' src=\"$url\" alt=\"$alt\" />";
    }
}
?>

Done! Now if you want to write a formula in mediawiki, just use the tag <math>FORMULA</math>.
And the FORMULA above is tex syntax. Besides math formula, mimetex could also display lots of other things, FYI: mimetex's tutorial.

Notice that this tutorial is just for your reference, I am not responsible for any bug and any damage it may cause.
Of course I am appreciate you could tell me any bug or suggestion


Comments (0)Add Comment

Write comment
quote
bold
italicize
underline
strike
url
image
quote
quote
smile
wink
laugh
grin
angry
sad
shocked
cool
tongue
kiss
cry
smaller | bigger

security code
Write the displayed characters


busy
 

支持本站:



Connect with me via QQ:38074 or e-mail:

©2006 bytea.net All Copyrights Reserved.

本站备案编号:保密^_^

RSS:  

开启背景音乐