Extension:Wiki2LaTeX

From MediaWiki.org
Jump to: navigation, search


MediaWiki extensions manual
Crystal Clear action run.png
Wiki2LaTeX

Release status: stable

Implementation Tag, User interface, Data extraction
Description Exports Mediawiki-articles to LaTeX and PDF
Author(s) Hans-Georg Kluge (HaGe-Ktalk)
Latest version r13 2013-02-13 (2013-02-13)
MediaWiki 1.20+ (older MW-versions unknown)
Database changes No
License GPL v2
Download Project page
Download snapshot
Subversion [Help]

Browse source code
View code changes
Note: no localisation updates provided by translatewiki.net.
readme

Hooks used
SkinTemplateContentActions

UnknownAction
BeforePageDisplay
SkinTemplateNavigation
GetPreferences
ParserFirstCallInit

Translate the Wiki2LaTeX extension if it is available at translatewiki.net

Check usage and version matrix; code metrics

The Wiki2LaTeX extension converts MediaWiki syntax into LaTeX, and makes the result available as:

  • LaTeX source, which can be copy-and-pasted
  • LaTeX file, which can be downloaded, and
  • a PDF file, which can be downloaded.

After installation, a new tab will appear next to the edit tab labeled as "LaTeX/PDF". Click on it, choose options and export the article. Screen shots are available at [1]. There is a sample of the pdf output download section on the projectpage.

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 MediaWiki parser. 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[edit | edit source]

Formal documentation is minimal and scattered:

News and support:

Supported Wiki Markup[edit | edit source]

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
  • <nowiki> 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. Wiki2LaTeX requires the Wiki markup to be correct as it does not contain any error correction mechanisms.

Download and Installation[edit | edit source]

Download and installation are straightforward:

  1. Download from Google Code
  2. Unpack file w2l-XXX.zip into the folder "/extensions/w2l".
  3. Copy the config file w2lConfig.sample.php to w2lConfig.php. Make changes if necessary.
  4. 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";

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

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

Installation Problems[edit | edit source]

The template variable ((Title)) is broken, use ((PAGENAME)) instead.

pdflatex path[edit | edit source]

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%';

Wiki2LaTeX and Fedora[edit | edit source]

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]
  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]
  3. There are reports that apache does not have a home directory, preventing pdflatex from working properly [4]

Wiki2LaTeX on Ubuntu 10.04 using Lighttpd[edit | edit source]

Seems like you have to restart the webserver after you login. Otherwise some important LaTeX-files are not available and pdf-creation fails.

Update existing installations[edit | edit source]

  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[edit | edit source]

There are some limitations:

  • pdf-export requires much cpu power.
  • Please be aware that while this extension is considered stable, there might be security issues, performance issues and data-loss bugs.

Development[edit | edit source]

Wiki2LaTeX uses Google Code for Mercurial and Bug-tracking.