(Excerpt from "The MathML Handbook" by Pavi Sandhu)

TtM is a commercial program for converting TeX or LaTeX documents into HTML+MathML documents. It was developed and is maintained by Ian Hutchinson of MIT. TtM is available for Linux and Windows. The Linux version is available for free, while the Windows version sells for $40.

TtM is a modified version of another program, called TtH, which converts LaTeX documents into HTML. The difference between the two is that TtH converts formulas in the original LaTeX document into images, while TtM converts the formulas into MathML. Both TtM and TtH use the Symbol font, available to most browsers, to represent special characters and symbols.

TtM supports many of the complex features of LaTeX, including macros, tables, and bibliographies. Some special types of TeX input that do not have a clear counterpart in HTML are not translated. TtM will generate a warning or error message if it encounters any TeX or LaTeX constructs it does not recognize. These messages are directed to stderr, which typically means they are displayed on the terminal. However, on Unix systems, these messages can also be redirected to a file.

Installing TtM

You can get the source for TtM as a zipped archive from TtM, a TeX to MathML translator. You must extract the files from this archive and then run the installer program to get the executable file. You can then place the executable file in any directory located on your path. Detailed installation instructions are provided with the product.

Running TtM

To convert a given TeX or LaTeX document into HTML, you run the following command:

ttm < test.tex

By default, the output is written to a file with the same name as the input file but with the extension .html. Hence, the above command would produce an output file called test.html. You can explicitly specify a different name for the output file using the redirection operator >, as shown here:

ttm < test.tex > output.html

TtM provides various "switches" or command-line options to customize the output. Some of the important options are:

  • -w*: determines the style of HTML that is produced. If the option is -w0, a title element is not added to the output. If the option is specified as -w1, head and body tags are inserted into the output.
  • -c: adds the prefix head "Content type: text/HTML" for specifying the MIME type of the file.
  • -e*: determines how PostScript figures in the original LaTeX document are handled. If the option is specified as -e1, all figures in the input document are converted to GIF images using the ps2gif utility, which must be present on the user's machine. If the option is specified as -e2, images are converted to inline GIF images. If the option is specified as -e0, the conversion to GIF does not take place and the figures are omitted from the output document.
  • -v: causes warnings and error messages to be produced in a more verbose format, which is useful for debugging.
  • -L filename: identifies the input document as LaTeX and specifies the name of auxiliary files for generating tables of contents and bibliographies.

Unlike TeX4ht and other tools for converting TeX to HTML, such as LaTeX2HTML, TtM does not require a TeX or LaTeX installation to be present on the user's machine. This makes TtM much more self-contained and portable. It is, however, still advisable to run TeX or LaTeX on the input file before the TtM translation so that you can ensure the file is free of syntax errors. If you do not have access to a TeX installation, you can debug the input document using the error messages produced by TtM alone. However, this can be difficult for users who do not have much experience with TeX.

A LaTeX installation is necessary if you are translating a LaTeX document that includes tables of contents or bibliographies. If you want to generate content of this type in LaTeX, the source file has to be processed multiple times. In the first pass, the TeX program generates forward references that are stored in auxiliary files. The information in the auxiliary files is then read by TeX in subsequent passes to generate the final table of contents or bibliography.

TtM can use the auxiliary files generated by LaTeX to generate hypertext versions of a table of contents and bibliography present in the input document. TtM looks for the auxiliary files in the same directory as the input file. By default, TtM expects each auxiliary file to have the same name as the input file but with a different extension. However, you can specify a different name for the auxiliary files by using the command-line option -L filename. You can also use the -L option without a filename to instruct TtM that the input file is in LaTeX format. This enables TtM to interpret LaTeX constructs in the input document even if the document lacks a \documentclass line to identify itself as a LaTeX document.

The following figure shows the HTML+MathML document obtained by processing the document of the following example using TtM when viewed in Amaya. Compare this with the output produced by TeX4ht and LaTeX from the same document, shown in the figures Converting the LaTeX document article.tex into XHTML+MathML using TeX4ht and The DVI file produced by processing article.tex using TeX.

HTML+MathML file produced by translating article.tex using TtM

Figure: The HTML+MathML file produced by translating article.tex using TtM. The resulting file is viewed here in Amaya.

TtM is extremely fast and efficient. Conversion of even large TeX files takes less than a second. As mentioned earlier, TtM is self-contained and does not call TeX or LaTeX when processing a document. Because it is fast and self-contained, you can run TtM on a server via a CGI script to do real-time conversion of LaTeX documents over the Web. You can see examples of such conversion under Try out TtM (see the following figure). This page contains a text area for entering arbitrary LaTeX input. You can then click a button to submit the input to the server, where it is processed using TtM. The output produced by TtM is then displayed on the same Web page. You can try out this Web page for experimenting with different types of TeX and LaTeX input and seeing what types of output TtM generates.

Conversion Web page for translating LaTeX documents using TtM

Figure: A conversion Web page for translating LaTeX documents using TtM.


<< back next >>




Tipp der data2type-Redaktion:
Zum Thema MathML bieten wir auch folgende Schulungen zur Vertiefung und professionellen Fortbildung an:


Copyright © CHARLES RIVER MEDIA, INC., Massachusetts (USA) 2003
Printing of the online version is permitted exclusively for private use. Otherwise this chapter from the book "The MathML Handbook" is subject to the same provisions as those applicable for the hardcover edition: The work including all its components is protected by copyright. All rights reserved, including reproduction, translation, microfilming as well as storage and processing in electronic systems.

CHARLES RIVER MEDIA, INC., 20 Downer Avenue, Suite 3, Hingham, Massachusetts 02043, United States of America