# MoinMoin Latex integration

Attention!

Obviously, I'm no longer use MoinMoin here, so none of this works on my site anymore

## HOWTO install

(mostly courtesy of Bernhard Kast)

Attention!

Beware that when you have many equations on a page, the browser has to make a request to the wiki for each page. This can trigger surge protection so you may need to raise the limits.

Another set of installation instructions can be found at http://wiki.vislab.usyd.edu.au/moin.cgi/moinmoin-LaTeX

### docs

Attention!

Note: Previously, you had to install this as latex2. This is no longer the case, and the code now assumes that it is installed as just latex.

Attention!

See also the extra page about security considerations. We hope to have fixed all the problems by making latex open files only after checking (thus \input{/etc/passwd} and similar don't work any more), and by limiting the running time of the executable (to avoid infinite loops bogging down the server). This has been implemented for unix in the python code directly, but for windows we need an extra wrapper to set the run time limit. It's C code is available from the windows-wrapper page, C code and a binary are also available (built by Alexander Schremmer). Note that you cannot just leave out the wrapper on windows since it also performs the essential function of changing the current working directory. Also note that in some cases you need to specify absolute paths of and to the runlimit.exe (reported to be the case under IIS for instance); to do this edit the parser python file and substitute full paths, be sure to double all backslashes to quote them in the python code. Look for # edit full path here comments.

For more, see the code to this page and the source code (for now).

Because people requested an easier way to enter latex, I've added the possibility to write \$ ... \$ to obtain inline formulas. This is equivalent to writing <<latex(\$ ... \$)>> and has the same single-line limitation (but everything else isn't really useful in formulas anyway). In order to do this, install the inline_latex.py parser add #format inline_latex to your page (alternatively, configure the default parser to be inline_latex). This parser accepts all regular wiki syntax, but additionally the \$ ... \$ syntax. Additionally, the inline_latex formatter supports \$\$....\$\$ style formulas (still limited to a single line though!) which puts the formula into a paragraph on its own.

If you use this parser together with my text/latex formatter, you'll notice that the latest version will simply copy your expressions into the latex. Note however that it will strip any prologue you added, so you'll have to add that manually to the latex the formatter generates.

Instead of using %%end-prologue%% inside the parser or % inside the macro to add things that go into the latex document preamble, you can now add a pragma #pragma latex_preamble PageName and the contents of the page PageName will be included in the preamble. This also works for the latex formatter where the inline preambles are ignored.

Requirements:

• a latex installation so that the latex command is somewhere in \$PATH (or adjust plugin source)
• dvipng also in \$PATH

The code has been tested with Python 2.3.4 on

• Debian Linux with out-of-the-box tetex-bin and dvipng packages installed

### installation

This is just a normal plugin (with the exception that it has external requirements), so installation is just like any plugin. For windows however, you also need to have the runlimit.exe executable in %PATH% (or, better, put the full path to it into the parser python code).

You'll also need to enable attachments on the wiki, because the generated images are stored and served as attachments.

### error handling

I've just updated the code to include error handling. If you write something with a latex error, like this

```  #!latex
\error

then you'll get a complete error report instead of the missing image, like this:
```
```error! exitcode was 1 (signal 0), transscript follows:

This is TeXk, Version 3.14159 (Web2C 7.4.5)
%&-line parsing enabled.
(./latex_9ef631490b429d8368539334faf5c6b5452e91a4_p.tex
LaTeX2e <2001/06/01>
Babel <v3.7h> and hyphenation patterns for american, french, german, ngerman, n
(/usr/share/texmf/tex/latex/base/article.cls
Document Class: article 2001/04/21 v1.4e Standard LaTeX document class
(/usr/share/texmf/tex/latex/base/size12.clo))
No file latex_9ef631490b429d8368539334faf5c6b5452e91a4_p.aux.
! Undefined control sequence.
l.6 \error

?
! Emergency stop.
l.6 \error

No pages of output.
Transcript written on latex_9ef631490b429d8368539334faf5c6b5452e91a4_p.log.
```

## Notes

• It appears that IE (even 7) can't handle png transparency. If you rely on IE then remove the "-bgTransparent" from the dvipng arguments.