0% found this document useful (0 votes)
19 views

Using_MathType_to_Create_TeX_and_MathML

MathType 4.0 is an advanced mathematical equation editing software that facilitates the creation of TEX and MathML equations, providing a user-friendly interface for entering mathematical notation. The software includes a re-architected translation system that allows for easy conversion of MathType equations into various formats, including plain TEX and MathML, making it a valuable tool for both learning and document publishing. Additionally, MathType supports Unicode and offers customizable translator definition files to cater to specific mathematical languages and applications.

Uploaded by

farhanvu
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
19 views

Using_MathType_to_Create_TeX_and_MathML

MathType 4.0 is an advanced mathematical equation editing software that facilitates the creation of TEX and MathML equations, providing a user-friendly interface for entering mathematical notation. The software includes a re-architected translation system that allows for easy conversion of MathType equations into various formats, including plain TEX and MathML, making it a valuable tool for both learning and document publishing. Additionally, MathType supports Unicode and offers customizable translator definition files to cater to specific mathematical languages and applications.

Uploaded by

farhanvu
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 5

Using MathType to Create TEX and MathML Equations

Paul Topping
Design Science, Inc.
4028 Broadway
Long Beach, CA 90803
USA
[email protected]
www.mathtype.com

Abstract
MathType 4.0 is the latest release of Design Science’s interactive mathematical
equation editing software package, the full-featured version of the Equation Editor
applet that comes with Microsoft Word. Its completely re-architected translation
system should be of particular interest to the TEX and MathML communities.
MathType can be used as an aid to learning TEX, as a simpler interface for en-
tering equations into a TEX authoring system, or as part of a document conversion
scheme for journal and book publishers.
After the introduction, a simple translation example is given to show how
its Translator Definition Language (TDL) is used to convert a MathType equa-
tion to TEX. This is followed by an introduction to MathML and MathType’s
MathML translators are discussed. Finally, some of the possibilities for creating
translators for special purposes is mentioned, along with discussion on how Math-
Type’s translation facilities can be used as component of a more comprehensive
document conversion process.

Introduction
MathType is an interactive tool for authoring math-
ematical material. It runs on Microsoft Windows
and Apple Macintosh systems (a Linux implemen-
tation is under consideration). Readers may also
be familiar with MathType’s junior version, Equa-
tion Editor, as it is supplied as part of many personal
computer software products, such as Microsoft Word
and Corel WordPerfect.
Unlike TEX, MathType does not process entire
documents. Rather, it is used in conjunction with
other products, such as word processors, page layout
programs, presentation programs, web/HTML edi-
tors, spreadsheets, graphing software, and virtually
any other kind of application that allows insertion
of a graphical object into its documents. MathType Figure 1: The MathType Window
equations can even be inserted into database fields
with most modern database systems!
MathType has a simple but powerful direct- the numerator and denominator. The contents of
manipulation interface for creating standard math- each slot are filled in by the user by more typing
ematical notation. Instead of entering a computer and inserting of templates. The displayed equation
language, such as TEX, the MathType user combines is reformatted as the user types and spacing is added
simple typing with the insertion of “templates”. For automatically (although spacing may be explicitly
example, inserting a fraction template results in a overridden). Some find this interface to be simpler
fraction bar with empty slots above and below for than direct TEX input as there are no keywords to

184 TUGboat, Volume 20 (1999), No. 3 — Proceedings of the 1999 Annual Meeting
Using MathType to Create TEX and MathML Equations

remember and, most importantly, no possibility of controlled by a translator definition file, a text file
syntax errors. containing a simple translation rule language that
One common complaint heard from TEX users allows a fragment of the target language to be asso-
upon first seeing MathType’s user interface is that ciated with each of MathType’s many symbols and
one must use the mouse for everything. Whereas templates. Although the chief motivation for its de-
mouse support is an important part of MathType’s velopment was TEX translation, it can also be used
user interface (as with virtually all Windows and to convert MathType equations to other languages,
Mac applications), MathType 4.0 has keyboard meth- such as MathML and those specified by the math
ods for performing all of its commands. Also, users parts of various SGML-based document languages.
may assign keystrokes to commands in any kind of MathType is supplied with translator definition
mnemonic scheme they care to invent. The ability to files for plain TEX, AMS-TEX, LATEX, AMS-LATEX,
assign a keystroke to an arbitrary math expression and four MathML variations. These can be cus-
is analogous to TEX’s macro facility. tomized for specific applications or translators for
Although a thorough examination of MathType other mathematical languages can be written by start-
is beyond the scope of this paper, here are some of ing from scratch. Also, commands are available in
its most important features: Microsoft Word that will allow a Word document
• Any national language characters that the host containing MathType (or Equation Editor) equations
operating system allows may be inserted into to be converted to TEX or any other language sup-
math, including Asian characters. ported by a translator. MathType’s translation fa-
cilities can be used as an aid to learning TEX, as a
• MathType’s internal representation of charac-
simpler interface for entering equations into a TEX
ters is Unicode,1 extended via its Private Use
authoring system, or as part of a document conver-
area to cover more of the characters that ap-
sion scheme for journal and book publishers.
pear in mathematical notation. We call this
MTCode. A user-extendable database of math The MTCode character encoding
font-to-MTCode mappings is used to relate char-
acters entered to knowledge used in line format- Although the designers of Unicode have attempted
ting, as well as translation. to include many mathematical characters, their at-
tempt falls somewhat short. In fairness to them,
• A basic set of mathematical fonts (Roman,
incorporating all the characters of the many natu-
Greek, italics, Fraktur, blackboard bold, and
ral languages in use in the world must have been an
many mathematical symbols) is included. Math-
overwhelming task.
Type can also make use of any PostScript Type 1
There is an attempt by some in the mathemat-
or TrueType font available via the operating
ical community to get the Unicode Consortium to
system.
add the missing mathematical characters to a future
• MathType also includes a translation system for version of Unicode. If and when they are successful,
converting mathematics entered in its editing we will probably adopt it to replace MTCode.
window to virtually any text-based language. MathType uses each character’s MTCode value
This translation system is the chief subject of as a key into a database of character information
this paper. In particular, it includes translators that, for each character, includes a human-readable
for several flavors of TEX and MathML. description, an indicator of its role in mathematical
MathType’s translation facilities notation (e.g. variable, binary operator), and infor-
mation used in the process of choosing an appropri-
MathType has had a TEX translator for many years ate font to render it on screen and printer. Most
that allows the user to copy all or part of an ex- importantly, a character’s MTCode value is an in-
pression onto the clipboard in the TEX language, dex into tables of translation strings in MathType’s
ready to be pasted into a document. However, un- translation system.
til version 4.0, it had two important limitations: it We will use the terms MTCode and Unicode
could only generate plain TEX and the user had no interchangeably in the remainder of this paper.
control over the TEX fragments generated for par-
ticular symbols and templates. MathType 4.0 fea-
tures a complete re-design of the translator mecha-
nism. The translation of a MathType expression is
1 Unicode is a standard for encoding characters. See www.

unicode.org for information.

TUGboat, Volume 20 (1999), No. 3 — Proceedings of the 1999 Annual Meeting 185
Paul Topping

The translation system from a user’s to the user in the Translators dialog (see Fig. 2)
perspective and a longer description which appears in the
dialog once the translator is chosen from the
The basic scenario for using MathType to aid in the
list. The description might include the author’s
creation of a TEX document is to run it simultane-
name and affiliation as well as the version num-
ously with your favorite TEX editor. The process is
ber of the translator.
this:
• a set of matching rules of the form
• whenever an equation is needed, the MathType hthing to matchi = htranslation stringi ;
window is brought to the front;
MathType equations (just like TEX ones) are
• the equation is created in the MathType win- represented internally as a tree. Let’s take the fol-
dow; lowing equation as an example:
• the equation is selected and copied to the clip- a+b
board, a process which invokes the previously y=
c
selected translator; MathType sees this equation as:
• the TEX editor is brought to the front;
eqn (root)
• the TEX code for the equation is pasted into the slot (main)
document. character (y)
Editing to correct mistakes is performed by re- character (=)
versing this process, pasting the TEX code (along template (fraction)
slot (numerator)
with a comment containing a compressed form of
character (a)
MathType’s internal representation) back into a character (+)
MathType window, and then repeating the above character (b)
process once the corrections have been made. slot (denominator)
At the beginning of such a document creation character (c)
and editing session, the user must select one of Math-
Type’s translators. This is done via the Translators The translation process begins by applying the
dialog, which presents a list of all the translators display equation rule,2 to the root of the MathType
present on the user’s system in the MathType trans- expression:
lators directory (Fig. 2). eqn = "\[@n#@n\]@n"; // display equation

The characters between quotation marks are pro-


cessed from left to right. Most of the characters in
the eqn rule are simply placed in the output trans-
lation stream. The @n sequence outputs a newline.
The @ character, called the escape character, is used
to insert special characters into the output stream.
The default escape character is $, but is redefined
in the TEX translators to @ for convenience.
The # in the eqn rule causes the translator to
look for a rule that will be used to translate the
equation’s main slot. After applying this transla-
tion (we’ll get to that next) and inserting its output
into the translation stream, the rest of the eqn trans-
lation string is output and the translation process is
Figure 2: The Translators dialog
complete.
Let’s go back to see how the # in the eqn rule
Anatomy of a translator is processed. This is done with the rule:
slot/t = "#";
Each translator is defined by a text file written in
a simple language called TDL (Translator Definition This rule works just like the eqn rule but is even
Language). A translator has a simple structure: simpler. The /t option is used to signal that this
• The first line defines the short name for the 2 The translation rules used in our example are simplified

translator which appears in the list presented somewhat for the purpose of this paper.

186 TUGboat, Volume 20 (1999), No. 3 — Proceedings of the 1999 Annual Meeting
Using MathType to Create TEX and MathML Equations

rule is to be used for the top-most slot in the equa- can convert its equations into MathML’s presenta-
tion only. Other slot rules enclose the translation tion markup. For example, translating the following
of their contents in {}, the TEX notation for group- expression into MathML:
ing. Now, each item in the main slot is processed. √
The rules for y and = are also very simple: −b ± b2 − 4ac
char/0x0079 = "y"; // Latin small letter y 2a
char/0x003D = " = "; // Equals sign results in:
<math displaystyle=’true’>
Here is where Unicode comes into play. MathType <mrow>
knows the Unicode value for y is 79 (in hexadecimal <mfrac>
notation). It uses this knowledge to find the char <mrow>
rule that specifies how y is to be translated. <mo>-</mo>
The fraction is handled by a template rule: <mi>b</mi><mo>&PlusMinus;</mo>
frac = "\frac{#1}{#2}"; // fraction <msqrt>
<mrow>
<msup>
The #s in this rule are followed by numerals that
<mi>b</mi>
specify the slot’s index in the template; 1 for the
<mn>2</mn>
numerator, 2 for the denominator. These two slots
</msup>
are processed much like the main slot, except they
<mo>-</mo>
use the more general slot rule:
<mn>4</mn><mi>a</mi><mi>c</mi>
slot = "{#}"; </mrow>
</msqrt>
So, the complete translation of our simple ex- </mrow>
ample is: <mrow>
<mn>2</mn><mi>a</mi>
\[
</mrow>
y = \frac{a+b}{c}
</mfrac>
\]
</mrow>
</math>
MathML
The first reaction of most TEX users is a gasp
The MathML specification was written by the W3C
at how verbose MathML is. Please bear in mind
Math Working Group.3 In April 1998, it was raised
that MathML is not intended to be authored directly
to Recommendation status by the W3C. MathML
by humans but with tools like MathType. MathML
has as its main goals:
inherits its verbosity from XML. This “disadvan-
• encode mathematical material suitable for teach- tage” is far outweighed by the advantages gained
ing and scientific communication at all levels with XML structure with its support in browsers,
• encode both mathematical notation and math- editors, and other tools. In the future, we hope
ematical meaning to see MathML become the language of choice for
MathML is intended to be used to both present math- exchanging mathematics between mathematical ap-
ematical notation and to serve as as a medium of plications. Its eventual integration with browsers
exchange between scientific and mathematical soft- should make it tremendously useful in teaching.
ware. Toward that end, MathML defines a set of Unfortunately, it may be a little while before
XML elements and attributes (together called mark- MathML achieves its promise. Until we are able to
up) that fall into two categories: presentation mark- properly display MathML in the popular browsers,
up and content markup. Presentation markup is in- such as Microsoft’s Internet Explorer and Netscape’s
tended to describe mathematical expressions from a Navigator, we will have to rely on various browser
two-dimensional layout point of view, whereas con- “plug-ins”, such as IBM’s techexplorer.4 and Geome-
tent markup is intended to capture the meaning of try Technologies’ WebEQ.5 These work but are con-
the mathematics. strained by various font issues, sizing problems, and
MathType provides four MathML translators lack baseline alignment for in-line math. The W3C’s
(why there are four will be explained shortly) that 4 For information, see http://www.software.ibm.com/
3 See http://www.w3.org/Math/ for the specification and network/techexplorer/.
other information on MathML. 5 See http://www.webeq.com/.

TUGboat, Volume 20 (1999), No. 3 — Proceedings of the 1999 Annual Meeting 187
Paul Topping

Math Working Group has made browser integration • with the development of custom translators, it
one of its highest priorities. can be used to generate virtually any text-based
In order to work with the various MathML math language
browser plug-ins, we have had to create several ver- It is our hope that TEX users will want to add it to
sions of our MathML translator, one for each. They their arsenal of useful tools.
differ only in the “wrapper” code they place around
the generated MathML in order to invoke the
plug-in and pass the MathML code to it. When true
browser integration is possible, we will only need a
single MathML translator.
Experimenting with MathType’s translators
Because of their simple and open structure, Math-
Type’s translators can be easily modified or new ones
written from scratch. Some possibilities include:
• creating a new translator for the mathematics
portion of an SGML document standard (DTD) TEX musings
• changing an existing TEX translator to make Musings from the Bard
use of some macro package or the author’s own
preferred macros Oh, what a tangled web is TEX,
• using the Unicode capability of MathType’s or so it seems at the outset;
translators to take advantage of the various TEX for highest quality, the best to look,
adaptations for non-Ennglish languages Oh why did I choose to typeset my own book!
...
Document conversion For Macintosh users the skies are quite blue,
with Barry to help you and Ben Salzburg too.
MathType’s translation facilities can also be incor-
With Art, Ross, and Uwe ready to assist,
porated into the process of converting entire docu-
just send a short email to Gary Gray’s (Textures)
ments to TEX or any other language supported by
list.
one of its translators. MathType has a programmatic
...
interface beside its more familiar graphical user in-
If shareware type software is more to your taste,
terface. This interface is via functions in a Windows
your super-fast Power-Mac need not go to waste.
DLL (Dynamically Linked Library). As MathType is
There’s CMac- and Direct-TEX to lessen the sorrow,
often used with Microsoft Word, we have provided
and that great program OzTEX, by Andrew Trevor-
functionality that can be accessed using commands
row.
on a “MathType” menu within the Word application
...
itself. One of these is a Convert Equations command
For Unix-like platforms the software’s all free,
that can be used to convert all the MathType and
with a teTEX installation from the TEX-Live CD,
Equation Editor equations in a document to any one
which collects all the pieces and orders all parts,
of the languages for which a MathType translator is
Thanks to Thomas Esser, Kaja, and Sebastian Rahtz.
available. Although this does not result in a fully
...
translated Word document, the most difficult part,
Leslie Lamport created LATEX nearly fifteen years
converting equations, has been achieved.
ago.
MathType’s Word support is written in that
It evolved into 2-epsilon by a process rather slow.
product’s Visual Basic language. The source code is
Improvements are numerous; results you can see.
accessible and may be used as the basis for your own
Thanks to Carlisle, Mittelbach and Rowley,
conversion scheme.
It’ll be even better with release LATEX3.
Conclusions ...
For PostScript Type1 fonts exquisitely drawn,
MathType 4.0, with its new translation features, can The expert is Berthold, whose surname is Horn.
be used in a variety of ways: Where the yin meets the yang in the great cosmic
• as an interactive front-end to TEX authoring goo,
• as an aid to learning TEX Don’t get this name mixed-up with Louis Vosloo.
• to experiment with the new MathML standard —Ross Moore

188 TUGboat, Volume 20 (1999), No. 3 — Proceedings of the 1999 Annual Meeting

You might also like