Difference: LaTeXToMathMLPlugin (3 vs. 4)

Revision 42016-02-26 - TWikiAdminUser

Line: 1 to 1

LaTeX to MathML Mathematical Equation Plug-in

   Contributions to this plugin are appreciated. Please update the plugin page at
   http://twiki.org/cgi-bin/view/Plugins/LaTeXToMathMLPlugin or provide feedback at
   If you are a TWiki contributor please update the plugin in the SVN repository.
Display LaTeX-like equations in-line using MathML


This plugin translates embedded LaTeX-like equations into in-line MathML. It requires a MathML enabled browser, such as Mozilla.

See TWiki:Codev.MathMarkup for some Javascript-only client-side alternatives.

Syntax Rules

The syntax rules for embedding equations are identical to those of the TWiki:Plugins.MathModePlugin and are based on LaTeX's own markup for equations. The equations themselves are expressed in a language very, very similar to LaTeX called itex2MML. (Apparently the major differences are in the way equation arrays are handled.)

To put an equation in-line with your text, enclose it with percent signs and the dollar sign,

   $ put your math here $
for example:
   $  \frac{\partial u}{\partial x} = U(x) $
where the opening and closing delimiter must be on the same line.

For equations set on their own line, use the

\[ put your math here \]
notation, for example:
\[  \frac{\partial u}{\partial x} = U(x) \]
and the font will be slightly larger.

For equations written over several lines in the original TWiki document you use the %MATHMODE{ "a=b" }% delimiter. The value in quotes is type set, whether or not it is on a single line. However, unlike the other delimiters, this is also typeset in <pre> environments.


$ \sum_{n=1}^\infty \frac{1}{n} $ is divergent, but $ \lim_{n \to \infty}\sum_{i=1}^n \frac{1}{i} - \ln n $ exists.

This is an $\frac{\partial u}{\partial x} = U(x)$ inline equation.

This equation

\[\frac{\partial u}{\partial x} = \pi \int_a^b F(x) dx\]
should be typset on its own line.

This equation

\[&amp;quot; \frac{\partial u}{\partial x} =            \omega \int_a^b F(x) dx &amp;quot;\]
is broken over several lines of source text.

Resources for MathML

  • Mozilla's MathML Project contains information on how to get started with MathML in Mozilla. A default installation from a major Linux distribution ought to be complete enough to use this plug-in. It is available for free. See notes below.
  • The itex2MML program is a FLEX/LEX parser which this plug-in uses to do the actual translation of the LaTeX equations into MathML.
  • Use the MathML Torture Test to see if your browser supports MathML.
  • At the W3C Math Home Page you can find the DTD for MathML along with authoring information. You can even read the 1993 proposal neglected for so many years. Advocates of the commercialization of the web: please note the delay and feel shame.
  • If your organisation does not allow Mozilla then there is a plug-in available at Design Science which may do the trick. (I haven't tried this one.)

LaTeXToMathMLPlugin Global Settings

Plugin settings are stored as preferences variables. To reference a plugin setting write %<plugin>_<setting>%, i.e. %LATEXTOMATHMLPLUGIN_SHORTDESCRIPTION%

  • One line description, is shown in the TextFormattingRules topic:
    • Set SHORTDESCRIPTION = Display LaTeX-like equations in-line using MathML

  • Debug plugin: (See output in data/debug.txt)
    • Set DEBUG = 0

Plugin Installation Instructions

Note: You do not need to install anything on the browser to use this plugin (although your browser must be capable of displaying MathML). The following instructions are for the administrator who installs the plugin on the TWiki server.

  • Install the program itex2MML on your system. The location must be somewhere that your web server can access.

  • Alter the main twiki.pattern.tmpl template in the TWiki installation, in the ./templates directory, or in the sub-directory of any Web that will use this plugin. The line
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    must be changed to support the MathML DTD. Replace it with:
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1 plus MathML 2.0//EN"
    <literal>    "http://www.w3.org/Math/DTD/mathml2/xhtml-math11-f.dtd" [
        <!ENTITY mathml "http://www.w3.org/1998/Math/MathML">

<--   * Alter the lib/TWiki.pm file so that the content type is emitted not
      as text/html but rather application/xhtml+xml .  This is a rather
      dire change.  If you have done anything on your pages that is not
      legal XHTML then your browser may complain mightily.

The change is in sub writeHeader about line 505, where the statement
 writeHeaderFull( $query, 'basic', 'text/html', 0);
needs to become
 writeHeaderFull( $query, 'basic', 'application/xhtml+xml', 0);

  • Download the ZIP file from the Plugin web (see below)

  • Unzip LaTeXToMathMLPlugin.zip in your twiki installation directory. Content:

    File: Description:
    data/TWiki/LaTeXToMathMLPlugin.txt Plugin topic
    pub/TWiki/LaTeXToMathMLPlugin/xhtml-math11-f.dtd XML DTD for XHTML 1.1 and MathML
    lib/TWiki/Plugins/LaTeXToMathMLPlugin.pm Plugin Perl module

  • Visit configure in your TWiki installation, and enable the plugin in the {Plugins} section.

  • If your system does not have itex2MML on the default path, edit the line of LaTeXToMathMLPlugin.pm that reads:
     my $itex2MML = 'itex2MML'; 
    to contain the whole path to the executable. For example:
     my $itex2MML = '/usr/local/bin/itex2MML';

  • Test if the installation was successful: the examples above should be rendered as equations, not text.


  1. This plug-in conflicts with the TWiki:Plugins.MathModePlugin which will need to be disabled. If you re-enable it later, you may need to re-edit pages to update any graphics of math that it would have otherwise generated. You may wish to clean-up the graphics left by TWiki:Plugins.MathModePlugin in the pub/ directories.
  2. Note that documents must be served to Mozilla as application/xhtml+xml for the MathML portion to be rendered correctly. This can pose some challenges for existing TWiki installations with less than tidy XHTML.
  3. Mozilla on Linux has a problem with Xft, the FreeType renderer for fonts. This in turn causes problems with xfs, the X11 font server that uses Xft. For Mozilla versions before 1.4 (assuming this gets fixed in 1.4) you have to set the environment variable
      setenv GDK_USE_XFT 0 
    to enable the correct rendering of the TeX Computer Modern fonts. You may also need to install those fonts, as noted on the MathML project fonts page.

Plugin Info

Plugin Author: TWiki:Main.SimonClift
Copyright: © 2003 TWiki:Main.SimonClift
© 2008-2011 TWiki:TWiki.TWikiContributor
License: GPL (GNU General Public License)
Plugin Version: 2011-03-17
Change History:
<-- versions below in reverse order -->
2011-03-15: TWikibug:Item6638: Doc fixes; code fixes & cleanup (page content was shown twice); changing TWIKIWEB to SYSTEMWEB -- TWiki:Main.PeterThoeny
2003-04-15: Initial version
CPAN Dependencies: none
Other Dependencies: itex2MML
Perl Version: 5.005
Plugin Home: http://TWiki.org/cgi-bin/view/Plugins/LaTeXToMathMLPlugin
Feedback: http://TWiki.org/cgi-bin/view/Plugins/LaTeXToMathMLPluginDev

Related Topics: TWikiPreferences, TWikiPlugins, TWiki:Plugins/MathModePlugin

META FILEATTACHMENT attachment="xhtml-math11-f.dtd" attr="" comment="Saved by install script" date="1300428706" name="xhtml-math11-f.dtd" size="390297" user="BaseUserMapping_333" version="1"
META FILEATTACHMENT attachment="latexcc76c7ca5d25c10287fd5ef611d87a65.png" attr="h" comment="" date="1456505481" name="latexcc76c7ca5d25c10287fd5ef611d87a65.png" user="BaseUserMapping_333" version="1"
META FILEATTACHMENT attachment="latexec0d4d8fbbe6018e4b98d16abd7ba147.png" attr="h" comment="" date="1456505481" name="latexec0d4d8fbbe6018e4b98d16abd7ba147.png" user="BaseUserMapping_333" version="1"
META FILEATTACHMENT attachment="latexdb32087324b6945a9c5c7955c3361933.png" attr="h" comment="" date="1456505481" name="latexdb32087324b6945a9c5c7955c3361933.png" user="BaseUserMapping_333" version="1"
META FILEATTACHMENT attachment="latexb5b5b3ee1285c4e0ce6ef0fc9bb6ad35.png" attr="h" comment="" date="1456505482" name="latexb5b5b3ee1285c4e0ce6ef0fc9bb6ad35.png" user="BaseUserMapping_333" version="1"
META FILEATTACHMENT attachment="latex6dc20f004511f84496d54e3b7b2de89a.png" attr="h" comment="" date="1456505482" name="latex6dc20f004511f84496d54e3b7b2de89a.png" user="BaseUserMapping_333" version="1"
META FILEATTACHMENT attachment="latexf4ace628e261efde9f35b60438964ef1.png" attr="h" comment="" date="1456505482" name="latexf4ace628e261efde9f35b60438964ef1.png" user="BaseUserMapping_333" version="1"
META FILEATTACHMENT attachment="latex4ae340add79300faf8539770b1a6669c.png" attr="h" comment="" date="1456505482" name="latex4ae340add79300faf8539770b1a6669c.png" user="BaseUserMapping_333" version="1"
META FILEATTACHMENT attachment="latexbc290fc607c76783e20ca63d4055bbd8.png" attr="h" comment="" date="1456505482" name="latexbc290fc607c76783e20ca63d4055bbd8.png" user="BaseUserMapping_333" version="1"
META FILEATTACHMENT attachment="latex8f381c036bff57f202d619c6fa5ae7ce.png" attr="h" comment="" date="1456505482" name="latex8f381c036bff57f202d619c6fa5ae7ce.png" user="BaseUserMapping_333" version="1"
This site is powered by the TWiki collaboration platform Powered by PerlCopyright © 1999-2024 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding TWiki? Send feedback
Note: Please contribute updates to this topic on TWiki.org at TWiki:TWiki.LaTeXToMathMLPlugin.