Tabs

LaTeX support

There are multiple alternative tools that can be integrated into ILIAS for enabling LaTeX support, MathJax (since ILIAS 4.3), \blah{TeX} and mimetex.

LaTeX support using MathJax (ILIAS 4.3.0+)

MathJax is configured in the ILIAS administration of each client. You have two options to use MathJax:
  1. Using an external MathJax server that is accessible for you (e.g. the MathJax at cdn.mathjax.org)
  2. Creating your local MathJax installation and link to it. Visit mathjax.org to get documentation on how you make your local installation.

LaTeX support using \blah{TeX}

System prerequisites:
  • Linux with gcc 4.0.2+ OR Mac OS 10.4.5 with gcc 4.0.1+
  • To generate PNGs, you will need LaTeX (teTeX-latex 3.0x recommended) and the dvipng utility, which is included in many LaTeX distributions. Blahtex assumes that the following LaTeX packages are available: color, fontenc, inputenc, amsmath, amsfonts, amssymb. All of these packages are included in teTeX, one of the most popular TeX distributions for UNIX systems.
    Additionally, to handle non-ASCII characters, the ucs package must be installed.
  • The blahtex command line utility. You can download the source files at the blahtex home page. Installation instructions can be found at this page too.
  • To run the blahtex command line tool as a CGI script, you may use the following PHP script. Be sure that the file paths for $cmd_dvipng and $cmd_blahtex (line 4 and 5) are correct for your system. Change it when necessary.
    This version of the script also contains a caching mechanism for recently used formulas. If the directory in the variable $dir_blahtex_cache exists and has sufficient write permissions, blahtex will speed up a lot.

    The blahtex CGI script is called with it's script name, followed by a question mark and the LaTeX code (see Formula example). To ensure that the latex code is interpreted correctly, the script parameters must be encoded with an URL encoding (see RFC 2396).
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    <?php
    $dir_blahtex_cache = "/opt/ilias/data/blahtex";
     
    function processBlahTex($tex, $tempdir)
    {
    $cmd_dvipng = "/usr/bin/dvipng";
    $cmd_blahtex = "/usr/local/bin/blahtex";
     
    $descriptorspec =
    array(
    0 => array( "pipe", "r" ),
    1 => array( "pipe", "w" )
    );
    $options .= " --png --texvc-compatible-commands --use-ucs-package --temp-directory $tempdir --png-directory $tempdir --shell-dvipng " . $cmd_dvipng;
    $process = proc_open($cmd_blahtex . " " . $options, $descriptorspec, $pipes);
    if ( !$process )
    {
    return array(
    false,
    "math_unknown_error #1"
    );
    }
    fwrite( $pipes[0], "displaystyle" );
    fwrite( $pipes[0], $tex );
    fclose( $pipes[0] );
     
    $contents = '';
    while ( !feof($pipes[1] ) ) {
    $contents .= fgets( $pipes[1], 4096 );
    }
    fclose( $pipes[1] );
    if ( proc_close( $process ) != 0 ) {
    // exit code of blahtex is not zero; this shouldn't happen
    return array(
    false,
    "math_unknown_error #2"
    );
    }
    return array( true, $contents );
    }
     
    // SCRIPT STARTS HERE
    $filename = $dir_blahtex_cache . "/" . md5($_SERVER["QUERY_STRING"]) . ".png";
    if (file_exists($filename))
    {
    header("Content-Type: image/png");
    header('Content-Length: '.filesize($filename));
    readfile($filename);
    }
    else
    {
    $tempdir = dirname(tempnam("",""));
    $result = processBlahTex(" " . urldecode($_SERVER["QUERY_STRING"]), $tempdir);
    if ($result[0] == TRUE)
    {
    if (preg_match("/<md5>(.*?)</md5>/is", $result[1], $matches))
    {
    $result = @rename("$tempdir/" . $matches[1] . ".png", $filename);
    if (!$result)
    {
    $filename = "$tempdir/" . $matches[1] . ".png";
    }
    header("Content-Type: image/png");
    header('Content-Length: '.filesize($filename));
    readfile($filename);
    }
    else
    {
    // error, no png file found
    }
    }
    else
    {
    // error, blahtex call failed
    }
    }
    ?>
    Sample blahtex script
  • The URL of the blahtex CGI script (or any other script working in the same way) must be entered during the ILIAS setup. A public available blahtex CGI script can be found at http://aurealis.de/blahtex.php (test it here)
If you have any questions regarding LaTeX integration with blahtex, please send a mail to Helmut Schottmüller (helmut.schottmueller_AT_mac_DOT_com)

LaTeX support using mimetex

The second alternative is to use mimetex: http://www.forkosh.com/mimetex.html. Follow the installation instructions and put the mimetex cgi script to your cgi directory, e.g. "/cgi-bin/mimetex.cgi". Enter the ILIAS setup, hit Paths in the main menu and provide the URL of the cgi script in the field URL to LaTeX CGI script, e.g. "http:///cgi-bin/mimetex.cgi".


No comment has been posted yet.