Texvc PHP Alternative/pt-br


 * Ver também: Este projeto GSoC para portar o texvc para python

Visão geral
Mediawiki uses an additional program, Texvc, to render math into nice images for page display. Unfortunately texvc needs to be compiled and is written in OCaml which can pose a problem on most public hosts even if all the other requirements are met (ghostscript, latex, etc). This work around replaces the Math rendering code with an in suite PHP version, performing all the image manipulations, renderings, etc that Texvc would normally do.

Limitações
This "hack" is not a workaround to get out of using "latex", "dvips", and "convert" (these three image processing unix commands are required) but it does workaround having to get access to installing ocaml and compiling texvc. While this hack does retain image caching, most of the other features available to math rendering have been lost and some slight differences do occur between the final output image. One notable difference is that only images are produced, the MyMCAT project didn't care for MathML or text outputs of formulas, thus these options were cut.

Como funciona
Basically, in Math.php, the rendering function has been striped of its calls to texvc and instead PHP makes all the calls to the necessary functions directly.

Como instalar
Below is a copy of the source from Math.php. You will need to ensure you have a working directory and the shell commands work correctly for this to work. If you have tried to install texvc formerly, you should replace the Math.php in includes/Math.php. If it doesn't exist yet, you should probably create it with the contents below.

The render function still passes arguments, but they are no longer read. If anyone wants to update this script with some more fancy features, please email me, I would love to hear about it.

Bugs conhecidos
Beyond the fact that parameters can't be passed to this renderer and the output sometimes looks slightly different than other latex renderings there are some other minor issues: - Sometimes PHP warnings get posted to the page when you render some math. I believe I am getting this because I do my file handling in /usr/temp which isn't the best place. This warning never shows up again the next time you go to the page and the image is still rendered just fine. - If you manually delete all the images in the cache folder you get warnings the first time Math.php needs to rerender them but again it renders fine and the warnings never show up again.

Pacote necessário para o Texlive
Para quem não sabe como funciona o tex, se você usar texlive para fazer o LaTex funcionar, você também terá que instalar alguns pacotes:
 * "graphics"
 * "pst-plot"
 * "xkeyval"
 * "PSTricks",
 * "multido"

E talvez outros, dependendo de como você instalou o texlive.

Working Example
This work was done for MyMCAT. You can specifically see an example of the math rendered at The Railgun Passage.

Acknowledgments
This hack was based off of the linux journal article http://www.linuxjournal.com/article/7870 by Titus Barik.