MathModePlugin

Add math formulas to TWiki topics using LaTeX markup language

Description

This plugin allows you to include mathematics in a TWiki page, with a format very similar to LaTeX. The external program latex2html is used to generate gif (or png) images from the math markup, and the image is then included in the page. The first time a particular expression is rendered, you will notice a lag as latex2html is being run on the server. Once rendered, the image is saved as an attached file for the page, so subsequent viewings will not require re-renders. When you remove a math expression from a page, its image is deleted.

Note that this plugin is called MathModePlugin, not LaTeXPlugin, because the only piece of LaTeX implemented is rendering of images of mathematics.

Syntax Rules

<latex [attr="value"]* > formula </latex>

generates an image from the contained formula. In addition attribute-value pairs may be specified that are passed to the resulting img html tag. The only exeptions are the following attributes which take effect in the latex rendering pipeline:

  • size: the latex font size; possible values are tiny, scriptsize, footnotesize, small, normalsize, large, Large, LARGE, huge or Huge; defaults to %LATEXFONTSIZE%
  • color: the foreground color of the formula; defaults to %LATEXFGCOLOR%
  • bgcolor: the background color; defaults to %LATEXBGCOLOR%

The formula will be displayed using a math latex environment by default. If the formula contains a latex linebreak (\\) then a multline environment of amsmath is used instead. If the formula contains an alignment sequence (& = &) then an eqnarray environment is used.

Note that the old notation using %$formula$% and %\[formula\]% is still supported but are deprecated.

If you might want to recompute the images cached for the current page then append ?refresh=on to its url, e.g. click here to refresh the formulas in the examples below.

Examples

The following will only display correctly if this plugin is installed and configured correctly.

<latex title="this is an example">
  \int_{-\infty}^\infty e^{-\alpha x^2} dx = \sqrt{\frac{\pi}{\alpha}}
</latex>

<latex>
  {\cal P} & = & \{f_1, f_2, \ldots, f_m\} \\
  {\cal C} & = & \{c_1, c_2, \ldots, c_m\} \\
  {\cal N} & = & \{n_1, n_2, \ldots, n_m\}
</latex>

<latex title="Calligraphics" color="orange">
  \cal
  A, B, C, D, E, F, G, H, I, J, K, L, M, \\
  \cal
  N, O, P, Q, R, S, T, U, V, W, X, Y, Z
</latex>

<latex>
  \sum_{i_1, i_2, \ldots, i_n} \pi * i + \sigma
</latex>

This is new inline test.

Greek letters
\alpha \theta
\beta \iota
\gamma \kappa
\delta \lambda
\epsilon \mu
\zeta \nu
\eta \xi

Plugin Author: TWiki:Main.GraemeLufkin, TWiki:Main.MichaelDaum
Copyright: © 2002 Graeme Lufkin gwl@u.washington.edu;
© 2006-2007 Michael Daum http://wikiring.de;
© 2007-2011 TWiki:TWiki.TWikiContributor
License: GPL (GNU General Public License)
Plugin Version: 2.98
Change History:  
2011-10-17 TWikibug:Item6799: Add troubleshoot info -- TWiki:Main.MatthiasRella
2010-04-25 TWikibug:Item6433: Doc improvements -- TWiki:Main.PeterThoeny
07 Dec 2007: replaced templfile with mktemp in the latex2img helper script
13 Nov 2007: fixed plugin on 4.2
18 Dec 2006: only use one bgcolor
02 Oct 2006: don't fail on hierarchical webs; backwards compatible tempfile cleanup
31 Aug 2006: added NO_PREFS_IN_TOPIC; using xcolor instead of color latex package now to be able to specify colors in html typical codes; default preamble uses latexsym now
07 Aug 2006: switched from latex2html to latex+dvipng+convert; added size, color, bgcolor to <latex> tag; rendering pngs by default now; reworked plugin settings; added a latex2img shell script; returning full latex error report
04 Aug 2006: major rewrite; fixed security issues by using TWiki's sandbox feature and creating tempfiles properly; added new <latex>...</latex> tag to support multiline formulas; better configurability; better error reporting; fixed issues where images have not been cleaned up regularly; speedup don't clean orphaned images during view but during save; speedup by adding lazy compilation and initialization; implemented a postRenderingHandler for TWiki V4; prevent auto-generated images stored in pub from being auto-attached using TWiki V4
03 Apr 2002: Initial version
CPAN Dependencies: none
Other Dependencies: LaTeX, dvipng, ImageMagick
Perl Version: 5.8
TWiki:Plugins/Benchmark: GoodStyle nn%, FormattedSearch nn%, MathModePlugin nn%
Plugin Home: TWiki:Plugins/MathModePlugin
Feedback: TWiki:Plugins/MathModePluginDev
Appraisal: TWiki:Plugins/MathModePluginAppraisal
-->
Topic attachments
I Attachment Action Size Date Who Comment
Latex2imgEXT latex2img manage 1.2 K 2011-10-17 - 18:36 TWikiAdminUser Saved by install script
 
Copyright 2013 The Board of Trustees
of the University of Illinois.webmaster@cs.uic.edu
WISEST
Helping Women Faculty Advance
Funded by NSF