script to be used together with txt2tags in order to translate formulas to MathML in the generated web pages.
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.

Math Formulas in txt2tags with t2t_math_ml


t2t_math_ml is a PERL script to be used together with txt2tags in order to translate formulas to MathML in the generated web pages.

It takes the xhtml file generated by txt2tags where the formulas are still in LaTeX format, filter them out to translate them using latexmlmath and put them back in the result file.

LaTeXML is used to generate the NIST Digital Library of Mathematical Functions, so it should be powerful enough for small formulas ;-)


Tested with:

  • txt2tags version 2.6
  • perl v5.14.2
  • latexmlmath included in LaTeXML version 0.7.0 (at least on Ubuntu, it can be obtained with: sudo apt-get install latexml)

But it might work with other versions.

Get It


You can get if from GitHub, or download the last pre-packed version:


$ tar -zxvf t2t_math_ml-0.1.tgz

and the script, called t2t_math_ml, is in there.

The Makefile is only needed to compile the test, or to generation the documentation (this file) to other formats ( md or html).

Quick Start

Input file

In the txt2tags input file, the LaTeX formulas can be inline:

like this: ''$x = \sqrt{y+z}$''

Or in a one line block:

''' $$ x = \sqrt{a + b + c} $$

Or in a math block on one or several lines:

|x| = \left\{ \begin{array}{rl}
 -x & \mbox{ if } x<0 \\
  x & \mbox{ otherwise}
       \end{array} \right.

See some examples here ( source, xhtml, pdf ).

Some examples of LaTeX formulas can be found in LaTeX Cookbook.

You might need to add :

    %!postproc(xhtml): "<head>" '<head><meta http-equiv="Content-type" content="application/xhtml+xml;charset=UTF-8"/>'

in your t2t source file to be able to seen the MathML formulas (see in the test file).


    $ txt2tags -t xhtml -o test.xhtml0 test.t2t
    $ ./t2t_math_ml test.xhtml0

creates test.xhtml.

Project Management


The current version is a first try, but should work in simple cases. See GitHub issues for known problems, and please report there for any remark (bug, feature wish, etc).


  • [2015-10-28] t2t_math_ml-02: put it on GitHub: change the doc and the Makefile, add a LICENSE.
  • [2013-09-03] t2t_math_ml-01: first distributed version.