Extension:Wiki2LaTeX

This extension converts Mediawiki syntax into LaTeX-code, and makes the result available as: After installation, a new tab will appear next to the edit tab labeled as "LaTeX/PDF". Click on it, choose some options and export the article. Some screen shots are available at. There is a sample of the pdf output download section on the projectpage.
 * LaTeX source, which can be copy-and-pasted
 * LaTeX file, which can be downloaded, and
 * a PDF file, created using pdflatex, which can be downloaded.

Requirements The LaTeX-only outputs have no additional installation requirements. PDF output requires pdflatex to be installed on the server.

The extension is written in php and uses its own parser, which is based on the original one of Mediawiki. Since the parser supports Parser Extension Tags, this extension enables Mediawiki to be used as a tool to create nicely printable documents. The parser also uses Mediawiki's Hook-system, so you can hook in functions, which change the default behavior of Wiki2LaTeX.

Documentation, News and Support
Formal documentation is minimal and scattered:
 * The documentation page is just getting started.
 * This page's talk page has some helpful comments.
 * There is a little bit of documentation in the distribution zip file.

News and support as well as additional documentation:
 * Please have look at the wiki on the project site, where you can find some documentation.
 * There is also a Google Group, which is open now to any user. There you can discuss and ask anything about Wiki2LaTeX. I am also reading the two Mediawiki Newsgroups Mediawiki-l and Wikitech-l, so you can get answers there, too.
 * To find out anything new about Wiki2LaTeX you can check out the Wiki2LaTeX-Weblog.

Supported Wiki Markup
Wiki2LaTeX supports a many, although not all, wiki markup:


 * Italic and bold font-styles are supported.
 * Lists, including nested ones
 * Internal and external links
 * Special characters are masked to LaTeX-commands
 * Some HTML-entities are parsed into their LaTeX-equivalents
 * tag
 * Mediawikis Template-system can be used (with named and unnamed template parameters).
 * Tables
 * ParserFunctions are supported (tested for 'if' and 'switch' only!)
 * ParserExtension-tags are supported.

Please note, that even though it is supported, it can't be guaranteed, that everything works flawlessly. Not every possible case has been tested, so please report errors, in case something went wrong.

Download and Installation
Download and installation are straightforward:

The second line, which creates the LaTeX namespace is optional, and allows customizing LaTeX-Templates and PDF-Creation. Note that if you already have a custom namespace, that 100 may need to be changed to an available even number 102, 104, etc.; see custom namespace
 * 1) Download from
 * 2) Unpack the archive into the folder '/extensions/w2l'.
 * 3) Unzip the file w2l-0.10rc.zip inside the w2l directory
 * 4)  Copy the config file w2lConfig.sample.php to w2lConfig.php.  Optionally, have a look at the file w2lDefaultConfig.php, as some settings might need changes.
 * 5) Add the following lines to LocalSettings.php, near the end of the file, but before the end PHP-tag ?> (if it exists):
 * require_once($IP."/extensions/w2l/wiki2latex.php");
 * $wgExtraNamespaces[100] = "LaTeX";

A "latex/pdf" tab should now appear at the top of pages, if you are logged in.

Installation Problems
Bugs in 0.10RC According to Issue 52 at Google Code, the current distribution (including 0.10rc) has bugs due to recent versions of PHP and/or MediaWiki becoming more strict.
 * edit w2lHelper.php, line 121 to read:
 * public function UnknownAction($action, $article) { (that is, delete the &)
 * Similarly, contrib/math.php, line 21
 * w2lTags.php, 10 places (lines 69, 75, 91, 98, 113, 122, 134, 158, 173, 181)
 * "There are probably other similar errors" (although perhaps not critical)

Also in 0.10RC, the template variable ((Title)) appears to be broken, meaning that if you have ((Title)) in a template, you get "((Title))" instead of the actual title. After line 325 in w2lCore.php, add the second line:
 * $template_vars['WikiContent'] =& $parsed; // Old, for compatibility
 * $template_vars['Title'] = $title;

pdflatex path If pdflatex is not in the path, you may provide an explicit path in w2lConfig.php by editing to read:
 * $w2lConfig['ltx_command'] = ' /path/to/your/pdflatex -interaction=batchmode %file%';

Fedora Wiki2LaTeX is not guaranteed to work on Fedora, and there seem to be various problems when pdflatex is called on recent versions (Fedora Cora 12)
 * 1) selinux may prevent pdflatex from being called
 * 2) cat /selinux/enforce gives 0/1 to indicate disabled/enabled selinux.  echo 0 > /selinux/enforce to turn off, echo 1 > /selinux/enforce to turn on
 * 3) There are reports that apache does not have a home directory, preventing pdflatex from working properly

Update existing installations

 * 1) Read Release Notes as config changes might be required.
 * 2) Backup all files
 * 3) Remove all files except w2lConfig.php
 * 4) Unpack all new files into that folder

Limitations
There are some limitations:


 * pdf-export requires much cpu power. So it can't be recommended to allow users to personally export an article to pdf.
 * All parts are tested on Ubuntu 8.04 and 8.10 only.

Please be aware that this extension is still in its beta phase. There might be security issues, performance issues and any thinkable issue could come up. So this extension is not (yet) intended to be used on a public wiki, though it works as expected for quite a time now on my personal server to create documents for university and letters.

Development and Planned features
Wiki2LaTeX uses Google Code for SVN and Bug-tracking.


 * Fix some issues regarding templates
 * Support interwiki links
 * Support custom Magicword-variables
 * Add the ability to edit the latex-code before compiling it
 * Support special classes on div and span tags