Jump to content

Sacred Wiki math tag <math></math>

Recommended Posts



math tag doesn't seem to work. Does one of us manage to insert math formulae ?


This would help me a lot.





PS : As far as I've seen, you need to toggle an option :


"To have math rendered, you have to set $wgUseTeX = true; in LocalSettings.php." taken from mediawiki help

The link

Edited by gogoblender
Link to comment

Oh very cool Nihilith. :drunkards:


That looks very intriguing. Unfortunately enabling it is going to be quite complicated. I added the line to LocalSettings.php and then tried a test example but it didn't work. :)


After doing abit of searching I discovered that there are many more steps that need to be taken as is explained by the following:



The number one barrier is the fact that we won't be allowing uploads which is required by the Math Tag. If I understand correctly tha Math Tag renders much of the Math output as png images which would explain the need for uploading. For your curiousity I'll post the Readme file for Math which was taken from the Math folder of our wiki installation. Maybe you can think of a work around?


In the meantime can you use HTML instead? It appears as though Math does the same thing as html but it looks nicer. Also, can you tell me how you would use the Math code? Maybe it would be possible to create the nice math output from a graphics editor instead?


I'm sorry that this can't be done easily Nihilith but maybe sometime in the future we will make this an option. :)





text/x-generic README

ASCII English text


== About texvc ==


texvc takes LaTeX-compatible equations and produces formatted output in

HTML, MathML, and (via LaTeX/dvipng) rasterized PNG images.

Input data is parsed and scrutinized for safety, and the output includes

an estimate of whether the code is simple enough that HTML rendering will

look acceptable.


The program was written by Tomasz Wegrzanowski for use with MediaWiki;

it's included as part of the MediaWiki package (http://wikipedia.sf.net)

and is under the GPL license.


Please report bugs at: http://bugzilla.wikimedia.org/ (under "MediaWiki")


== Setup ==


=== Requirements ===


OCaml 3.06 or later is required to compile texvc; this can be acquired

from http://caml.inria.fr/ if your system doesn't have it available.


The makefile requires GNU make.


Rasterization is done via LaTeX, dvipng. These need

to be installed and in the PATH: latex, dvipng


AMS* packages for LaTeX also need to be installed. Without AMS* some

equations will render correctly while others won't render.

Most distributions of TeX already contain AMS*.

In Debian/Ubuntu you need to install tetex-extra.


To work properly with rendering non-ASCII Unicode characters, a

supplemental TeX package is needed (cjk-latex in Debian)


=== Installation ===


Run 'make' (or 'gmake' if GNU make is not your default make). This should

produce the texvc executable.


If you're using MediaWiki's install.php and have enabled $wgUseTeX in your

LocalSettings.php, the installer will try to copy texvc into place, in the

'math' subdirectory under where wiki.phtml is installed.



== Usage ==


Normally texvc is called from MediaWiki's Math.php modules and everything

Just Works. It can be run manually for testing or for use in another app.


=== Command-line parameters ===


texvc <temp directory> <output directory> <TeX code> <encoding>


Be sure to properly quote the TeX code!




texvc /home/wiki/tmp /home/wiki/math "y=x+2" iso-8859-1


=== Output format ===


Status codes and HTML/MathML transformations are returned on stdout.

A rasterized PNG file will be written to the output directory, named

for the MD5 hash code.


texvc output format is like this:

+%5 ok, but not html or mathml

c%5%h ok, conservative html, no mathml

m%5%h ok, moderate html, no mathml

l%5%h ok, liberal html, no mathml

C%5%h%m ok, conservative html, with mathml

M%5%h%m ok, moderate html, with mathml

L%5%h%m ok, liberal html, with mathml

X%5%m ok, no html, with mathml

S syntax error

E lexing error

F%s unknown function %s

- other error


- null character

%5 - md5, 32 hex characters

%h - html code, without characters

%m - mathml code, without characters



== Troubleshooting ==


Unforunately, many error conditions with rasterization are not well reported.

texvc will return as though everything is successful, and the only obvious

sign of problems for the user is a big X on a wiki page where an equation

should be.


Try running texvc from the command line to ensure that the software it relies

upon is all set up.


Ensure that the temporary and math directories exist and can be written to by

the user account the web server runs under; if you don't control the server,

you may have to make them world-writable.


If some equations render correctly while others don't, you probably don't have

AMS* packages for LaTeX installed. Most distributions of TeX come with AMS*.

In Debian/Ubuntu AMS* is in tetex-extra package.

To check if that is the problem you can try those two equations:

x + y

x \implies y

The first uses only standard LaTeX, while the second uses symbol \implies from AMS*.

If the first renders, but the second doesn't, you need to install AMS*.


== Hacking ==


Before you start hacking on the math package its good to know the workflow,

which is basically:


1. texvc gets called by includes/Math.php (check out the line begining with "$cmd")

2. texvc does its magic, which is basically to check for invalid latex code.

3. texvc takes the user input if valid and creates a latex file containing it, see

get_preface in texutil.ml

4. dvipng(1) gets called to create a .png file

See render.ml for this process (commenting out the removal of

the temporary file is useful for debugging).

Link to comment

Hi Schot


Well, nevermind. Thank you for going so deep into this problem, I will use another method.

It would just have been so SeXy having complicated formulae in the middle of a guide :evil:


Ok, next step is to find a template for all formulae, so that everybody can easily understand them


Back to work.

Link to comment

lol nihilith


It does look sexy, hahaha. I was looking at the math output on example pages and it looks very nice. :evil:


Oh... Here's something you could do. Create your math on a wiki that has Math enabled. Preview your Math then take a screenshot of it to be placed as an image on our Wiki. That could work well enough I think. :viking:

Link to comment
  • 3 weeks later...

Considering the newly created "Formulae and Calculator" page, it would be nice to have the chance to write formulae with latex. Luckyly our formulae are really easy, so we can write them without LaTeX and have an acceptable result. So there's no problem at all.


But, if sometime in future there should be the possibility to activate the latex code, than keep in mind that you would make no more 1 but 2 (and I say TWO! xD ) people happy :lol:

Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Create New...
Please Sign In or Sign Up