# LinuxTex

Note: The recipes here are for PmWiki versions 0.6 and 1.0 only. For PmWiki 2.0 recipes, see Cookbook.

tarta.

### Goal

i did not the like the quality of the images MimeTeX produces, so I tried to write my own script that uses an existing latex installation. this is the first time i used the php scripting language ... so the entire script propably isn't implemented very smart ... suggestions welcome.

### Solution

as mentioned above you need a complete latex installation and the tool dvipng (or convert that comes with imagemagik, if you slightly adjust the script in line 131).

### Discussion

the script assumes that you have a /pub/img/latex/ directory the webserver user has write permissions to.

•  {$latex formula$} , for inline equations, like $$a+b$$ in latex
•  {% label, latex formula %} , for \begin{math} like equations, EQ(label) can be used anywhere on the page as an anchor to the equation

put useful settings for these tags in your local.css or another appropriate place

• span.mathRef for the anchor to the equation
• img.formulaMath for equations with label, put a dotted line arround them or something
• img.inlineMath, gues what, for inline equations
• span.eqCount, for the little number behind labeled equations

### History

• 11/22/04 first "release"
• 01/25/05 security enhancements by Nils Knappmeier

bugs:

• where do the spaces in the name attribute of the anchor for the formulas come from, i had to remove the "" to make it work, not very nice
• the whole ref() is implemented pretty bad i guess ... suggestions welcome
• this definetly does not produce valid html
• this propably isn't very safe

Security modifications by Nils Knappmeier:

• I noticed that you could just read any file on the disk by doing a "{/etc/passwd }" for instance. The code I inserted modifies the tex-source, such that:
• "/" is replaced by "\slash{}"
• "$" is replaced by "\$"
• Every command with parameters is as in \command{something} is replaced by \command{\nothing{}something} where \nothing{} does in fact do nothing (but it will scramble filenames)
• The problem is that you can never be sure to know all commands that open files somehow. But this way, all filenames in a function should be rendered useless, while all math formulars should still work.

### Contributors

• JanSchumacher