Mailing List Archive

math support in Mediawiki 1.2.6
Hi,

I have installed Mediawiki 1.2.6 on my website and wish to make use of the math support. However, when I type in mathematical expressions, or copy-and-paste expressions from other wikis where the math support is working, the code simply shows up in the page without being interpreted. I have contacted the webhosting company I use, and they say that the server is running Red Hat Linux, and that Imagemagick, TeTex and Ghostscript are installed.

I haven't been able to find any documentation about what it is necessary to do to get the math support up and running. I read the readme files and googled some likely keywords. If such documentation exists, I would appreciate being pointed to it.

The wiki seems to be working properly otherwise. I have made an example page for mathematical expressions here: http://www.strangeattractor.ca/wiki126/index.php?title=Sandbox

I would appreciate advice or suggestions.

Thanks,

Ellen
Re: math support in Mediawiki 1.2.6 [ In reply to ]
eckayech@engmail.uwaterloo.ca wrote:
> I have installed Mediawiki 1.2.6 on my website and wish to make use
> of the math support. However, when I type in mathematical
> expressions, or copy-and-paste expressions from other wikis where the
> math support is working, the code simply shows up in the page without
> being interpreted. I have contacted the webhosting company I use,
> and they say that the server is running Red Hat Linux, and that
> Imagemagick, TeTex and Ghostscript are installed.

First, it looks like you haven't enabled TeX processing. In your
LocalSettings.php there should be these lines:

## If you have the appropriate support software installed
## you can enable inline LaTeX equations:
# $wgUseTeX = true;
$wgMathPath = "{$wgUploadPath}/math";
$wgMathDirectory = "{$wgUploadDirectory}/math";
$wgTmpDirectory = "{$wgUploadDirectory}/tmp";

Uncomment that $wgUseTeX line.


Second, this won't work unless you've compiled or installed the texvc
helper program. The source is in the 'math' subdirectory; it requires
ocaml 3.04 or later iirc.

There's a precompiled binary for Linux/x86 available for download:
http://prdownloads.sourceforge.net/wikipedia/texvc-linux-x86-20040107.tar.gz?download

Drop 'texvc' into the math subdirectory and make sure it has the
executable bit set.


Third, it will want to put temporary files and generated image files
into subdirectories under the 'images' directory. Make sure that this
directory is writable by the web server.


Unfortunately it can be a bit tricky to diagnose problems in the chain
of events that is texvc, but once you've checked all these it should
either be working or give some kind of error message. :)

-- brion vibber (brion @ pobox.com)
Re: math support in Mediawiki 1.2.6 [ In reply to ]
>
>Unfortunately it can be a bit tricky to diagnose problems in the chain of events that is texvc, but once you've checked all these it should either be working or give some kind of error message. :)
>
>-- brion vibber (brion @ pobox.com)

Thank you. I have uncommented the line to enable TeX processing, put texvc into the math subdirectory, and changed the permissions on texvc and the images subdirectory. It doesn't work yet, but I am now getting an error message:

"Failed to parse (PNG conversion failed; check for correct installation of latex, dvips, gs, and convert): \sin x + \ln y \alpha a^2"

( the URL is http://www.strangeattractor.ca/wiki126/index.php?title=Sandbox )

What do you suggest I do next?

Ellen
Re: math support in Mediawiki 1.2.6 [ In reply to ]
Hi,

Could someone please give me some guidance as to what to check, based on the error message? I don't know what specifically to look for, to see that the installation of the modules is correct. Also, I don't have shell access to the server, so I would have to ask the webhosting company to check for me, and I would like to know what specific steps to ask them to do. The webhosting company tells me that the modules are installed.

Are there some settings within the MediaWiki software that tells the software where the modules are installed? If so, where are they? Maybe they are set incorrectly.

I checked the permissions on the images/math and images/tmp directories and set them to allow reading, writing and executing by everyone. Also, I noticed that in the images/tmp directory, there are a bunch of files with .tex extensions and that there is nothing in the images/math directory.

If there is some documentation that answers my questions, please refer me to it.

Thanks,

Ellen


At 00:04 31/08/2004 -0400, you wrote:

>>
>>Unfortunately it can be a bit tricky to diagnose problems in the chain of events that is texvc, but once you've checked all these it should either be working or give some kind of error message. :)
>>
>>-- brion vibber (brion @ pobox.com)
>
>Thank you. I have uncommented the line to enable TeX processing, put texvc into the math subdirectory, and changed the permissions on texvc and the images subdirectory. It doesn't work yet, but I am now getting an error message:
>
>"Failed to parse (PNG conversion failed; check for correct installation of latex, dvips, gs, and convert): \sin x + \ln y \alpha a^2"
>
>( the URL is http://www.strangeattractor.ca/wiki126/index.php?title=Sandbox )
>
>What do you suggest I do next?
>
>Ellen
>
>_______________________________________________
>MediaWiki-l mailing list
>MediaWiki-l@Wikimedia.org
>http://mail.wikipedia.org/mailman/listinfo/mediawiki-l
Re: math support in Mediawiki 1.2.6 [ In reply to ]
eckayech@engmail.uwaterloo.ca wrote:
> Could someone please give me some guidance as to what to check, based
> on the error message? I don't know what specifically to look for, to
> see that the installation of the modules is correct. Also, I don't
> have shell access to the server, so I would have to ask the
> webhosting company to check for me, and I would like to know what
> specific steps to ask them to do. The webhosting company tells me
> that the modules are installed.
>
> Are there some settings within the MediaWiki software that tells the
> software where the modules are installed? If so, where are they?
> Maybe they are set incorrectly.

The following commands must be available in the default execution path
(PATH environment variable):

latex
dvips
convert
gs

and anything else that they depend on that I might not know about. In
particular ask that dvips is installed, since you didn't mention that
earlier.

You can write a quickie PHP script to look around, like this:

<?php
header("Content-type: text/plain");
echo "dvips is at: ";
system("which dvips");
?>

It should come back with a pathname like "/usr/bin/dvips". If it says
nothing, then it may be missing.

> I checked the permissions on the images/math and images/tmp
> directories and set them to allow reading, writing and executing by
> everyone. Also, I noticed that in the images/tmp directory, there
> are a bunch of files with .tex extensions and that there is nothing
> in the images/math directory.

Also ask your provider for access to the Apache and PHP error logs (or
at least to look to see if anything relevant is showing).

-- brion vibber (brion @ pobox.com)
Re: math support in Mediawiki 1.2.6 [ In reply to ]
Brion-
> The following commands must be available in the default execution path
> (PATH environment variable):

> latex
> dvips
> convert
> gs

> and anything else that they depend on that I might not know about. In
> particular ask that dvips is installed, since you didn't mention that
> earlier.

And as I just found out through two hours of pain, GhostScript in certain
versions doesn't work with ImageMagick at all. See this bug report:
http://ghostscript.com/pipermail/bug-gs/2002-July/001451.html
I used an older version (8.0 something) and it still didn't work. Only
going back to 7.05 did the trick.

One thing that helps in debugging is to edit render.ml in math/, remove
the "/dev/null" redirections, recompile and test on the commandline
according to the README. Then you should see exactly what goes wrong
where.

texvc is really quite terrible when it comes to error messages.

Regards,

Erik
Re: math support in Mediawiki 1.2.6 [ In reply to ]
Erik-

> http://ghostscript.com/pipermail/bug-gs/2002-July/001451.html
> I used an older version (8.0 something) and it still didn't work. Only
^^^^^^^^
Er, I mean I used a newer version than the one in the bug report.

Regards,

Erik
Re: math support in Mediawiki 1.2.6 -- AMSFonts the culprit? [ In reply to ]
On what OS are you running your Wiki?

I have a wiki installation on FreeBSD, and just found that while many
expressions work ok, some do not. It looks like texvc is dependent on
having a package called "amsfonts" (http://www.ams.org) installed, but
FreeBSD (4.10) does not install nor provide this package. I'm trying to
manually install the tarball from ams.org on my server, but so far, with
no luck.

Maybe you're hitting a similar problem? (I found this by manually
running texvc from the cmd-line, and looking at the .log output file)

cheers,
-Nick

Erik Moeller wrote:

>Brion-
>
>
>>The following commands must be available in the default execution path
>>(PATH environment variable):
>>
>>
>
>
>
>> latex
>> dvips
>> convert
>> gs
>>
>>
>
>
>
>>and anything else that they depend on that I might not know about. In
>>particular ask that dvips is installed, since you didn't mention that
>>earlier.
>>
>>
>
>And as I just found out through two hours of pain, GhostScript in certain
>versions doesn't work with ImageMagick at all. See this bug report:
>http://ghostscript.com/pipermail/bug-gs/2002-July/001451.html
>I used an older version (8.0 something) and it still didn't work. Only
>going back to 7.05 did the trick.
>
>One thing that helps in debugging is to edit render.ml in math/, remove
>the "/dev/null" redirections, recompile and test on the commandline
>according to the README. Then you should see exactly what goes wrong
>where.
>
>texvc is really quite terrible when it comes to error messages.
>
>Regards,
>
>Erik
>_______________________________________________
>MediaWiki-l mailing list
>MediaWiki-l@Wikimedia.org
>http://mail.wikipedia.org/mailman/listinfo/mediawiki-l
>
>
Re: math support in Mediawiki 1.2.6 -- AMSFonts the culprit? [ In reply to ]
On Sep 5, 2004, at 9:45 AM, Nick Triantos wrote:

> I have a wiki installation on FreeBSD, and just found that while many
> expressions work ok, some do not. It looks like texvc is dependent on
> having a package called "amsfonts" (http://www.ams.org) installed, but
> FreeBSD (4.10) does not install nor provide this package. I'm trying
> to manually install the tarball from ams.org on my server, but so far,
> with no luck.

Which TeX port are you installing in FreeBSD? If you install the
latex2e port, I can imagine you wouldn't get the AMS fonts. Unless
you're very strapped for space, try installing the teTeX port (it's the
de-facto standard TeX system), which has a lot of add-on packages.
Re: math support in Mediawiki 1.2.6 -- AMSFonts the culprit? [ In reply to ]
Great, thanks a lot, Luis, that fixed the issue I was seeing. I'm not
up on the TeX world, so I didn't know which to install.

cheers,
-Nick

Luis Casillas wrote:

>
> On Sep 5, 2004, at 9:45 AM, Nick Triantos wrote:
>
>> I have a wiki installation on FreeBSD, and just found that while many
>> expressions work ok, some do not. It looks like texvc is dependent
>> on having a package called "amsfonts" (http://www.ams.org) installed,
>> but FreeBSD (4.10) does not install nor provide this package. I'm
>> trying to manually install the tarball from ams.org on my server, but
>> so far, with no luck.
>
>
> Which TeX port are you installing in FreeBSD? If you install the
> latex2e port, I can imagine you wouldn't get the AMS fonts. Unless
> you're very strapped for space, try installing the teTeX port (it's
> the de-facto standard TeX system), which has a lot of add-on packages.
>
> _______________________________________________
> MediaWiki-l mailing list
> MediaWiki-l@Wikimedia.org
> http://mail.wikipedia.org/mailman/listinfo/mediawiki-l
Re: math support in Mediawiki 1.2.6 [ In reply to ]
Thanks everyone for the help. I have finally got the math support on my wiki working.

I have written a summary of what I have learned. I think it would be useful to post it on the MediaWiki documentation pages, but I'm not sure where to create the page for it. Could someone who is more familiar with the structure of the documentation pages please create it, or suggest where to put it?

Here is my summary. I don't claim to understand everything perfectly, but it's got to be better than the meager documentation which currently exists. In particular, I'm not sure of exactly what modules are required at each step in the process, but I guessed.

==Math Support in MediaWiki==

These instructions assume that the wiki is otherwise operational. See other instructions for installing the wiki. For examples of mathematical expressions and the syntax for writing them within a wiki see http://meta.wikimedia.org/wiki/Help:Formula

The math support for MediaWiki requires several modules to be installed, and tex processing to be enabled. It is designed to be run on Linux, and may not run on other operating systems.

==How Math Support Works==

Here is an outline of how the math support works - several steps are involved, and a problem could arise if any one of the steps is broken or missing.

Step 1: recognize that the <math></math> tags are special

requires: Tex processing enabled in LocalSettings.php file

Step 2: convert expressions between <math></math> tags to .tex files

requires: texvc

Step 3: convert .tex files to .dvi files

requires: texvc, latex

Step 4: convert .dvi files to .ps files

requires: texvc, dvips

Step 5: convert .ps files to .png files

requires: texvc, ghostscript, convert, ImageMagick

Step 6: display png files on page

requires: texvc

--

Alternatively, texvc can output mathematical expressions as HTML or MathML instead of as PNG images.


==Installation==

Steps that must be done:


1) Enable Tex proccessing in LocalSettings.php file:

In the LocalSettings.php file there should be these lines:

## If you have the appropriate support software installed
## you can enable inline LaTeX equations:
# $wgUseTeX = true;
$wgMathPath = "{$wgUploadPath}/math";
$wgMathDirectory = "{$wgUploadDirectory}/math";
$wgTmpDirectory = "{$wgUploadDirectory}/tmp";

Uncomment that $wgUseTeX line.


2) Install texvc

The texvc source code is included with the MediaWiki software, in the math subdirectory. It requires OCaml 3.06 or later in order to compile. There are two options for installing it:

i) compile it yourself, and leave it in the math subdirectory

OR

ii) download the precompiled binary and put it in the math subdirectory

A precompiled binary for Linux/x86 is available for download at:
http://prdownloads.sourceforge.net/wikipedia/texvc-linux-x86-20040107.tar.gz?download

The file is "texvc" without a file extension. Make sure it has the executable bit set. (That is, the permissions are set to allow it to execute.)


3) Install any further modules that are required, and that are not already installed. This includes TeTeX, Ghostscript, ImageMagick, and AMS fonts.

TeTex http://www.tug.org/teTeX/

Ghostscript http://www.ghostscript.com/

ImageMagick http://www.imagemagick.org/

AMS fonts http://www.ams.org


==TroubleShooting==

Troubleshooting mostly consists of checking to see if the correct things are installed. Here are some things to try.

1) if you do not have command line access, you can check the availability of commands by uploading a PHP file with this code to your wiki directory. The commands 'latex', 'dvips', 'gs' and 'convert' must be installed and in the PATH. The path for each command should appear when you view the PHP file in your browser. If it is missing, then chances are the module is not installed correctly.

<?php
header("Content-type: text/plain");

echo "latex is at: ";
system("which latex");

echo "dvips is at: ";
system("which dvips");

echo "convert is at: ";
system("which convert");

echo "gs is at: ";
system("which gs");

?>


2) check the subdirectories 'math' and 'tmp' in the upload subdirectory (usually 'images') to see if they contain any files. Sometimes if the conversion process halts at a certain step, files of that type will remain in the 'tmp' directory. PNG files for mathematical expressions are stored in the 'math' directory, once they have been created.

3) check to see if the version of Ghostscript you're using has a conflict with ImageMagick. Versions of Ghostscript later than 7.05 may have problems. See this bug report: http://ghostscript.com/pipermail/bug-gs/2002-July/001451.html


Ellen