Andrew Stacey


About
Andrew Stacey
Information about my research, teaching, and other interests.

By: Andrew Stacey
Contact details


Andrew Stacey


blosxom icon


Fri, 17th Apr 2009 (HowDidIDoThat :: Vanilla)

LaTeX plugin for Vanilla

LaTeX support for Vanilla

This extension allows posters to use LaTeX syntax to include mathematics in their posts. The syntax is converted to pictures in png format using a public latex server. The images are placed in a local cache.


Download

latest version

Installation

In order for Vanilla to recognize an extension, it must be contained within its own directory within the extensions directory. So, once you have downloaded and unzipped the extension files, you can then place the folder containing the default.php file into your installation of Vanilla. The path to this extension's default.php file should look like this:

/path/to/vanilla/extensions/vLaTeX/default.php

Once this is complete, you can enable the extension through the "Manage Extensions" form on the settings tab in Vanilla.

This extension has several configuration options. These can be set via the 'Extension Options' tab under the 'Settings' menu. Most importantly, this plugin requires a cache directory where it can save the images. The plugin will tell you what to do to create this cache. Follow these instructions carefully.

Other plugins need to be told to allow the mathematics to go through. In detail, the code is stored internally within .. tags so other plugins need to be told not to look within these tags. This only works with plugins that can be told to do this; markdown is okay but the default text formatter is not as it escapes all html tags.

  • Markdown: look for the 'clean_tags' variable (currently line 1650). Add 'latex' to the list, e.g.

    var = 'script|math|latex';

  • KSES: add latex to the list of allowed tags in conf.php. e.g.,

    'latex' => array (),

  • HtmlFormater: add latex to the list of Html_Literals (currently line 81). e.g.,

    = array('code', 'samp', 'latex');

Requirements

php with the GD library compiled in.

Usage

The configuration panel gives several options for font size, colours, and so forth. These should be self-explanatory. Note that the background transparency works by setting one colour to be transparent so there can be "edge effects" round the text. It is probably best to set the background to be white or black when using transparency.

To use in posts, surround the mathematics by the appropriate tags and it will be converted into an image. The image is cached so that the server only gets hit once per unique request.

Other Notes

The script actually translates the tags into an "internal standard". This means that changing the input tags later on does not change earlier posts - the mathematics is displayed exactly as it was before. As well as this robustness, this makes it easier for other filters to ignore the mathematics (e.g. markdown can be easily told to ignore tags), and means that if the cache is lost then everything can be easily rebuilt.

[Full link]
Last modified on:
Fri, 17th Apr 2009