Using Mathtype to Create TEX and Mathml Equations
Total Page:16
File Type:pdf, Size:1020Kb
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 MathType of a graphical object into its documents. Figure 1:TheMathType 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 TEXusers 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 MathType Equation Editor • Any national language characters that the host containing (or ) equations operating system allows may be inserted into to be converted to TEX or any other language sup- MathType math, including Asian characters. ported by a translator. ’s translation fa- cilities can be used as an aid to learning T X, as a • MathType’s internal representation of charac- E 1 simpler interface for entering equations into a T X ters is Unicode, extended via its Private Use E 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 T X document is to run it simultane- E name and affiliation as well as the version num- ously with your favorite T X editor. The process is E ber of the translator. this: • a set of matching rules of the form • MathType whenever an equation is needed, the hthing to matchi = htranslation stringi ; window is brought to the front; MathType equations (just like T X ones) are • MathType E the equation is created in the 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 y + board, a process which invokes the previously = c selected translator; MathType sees this equation as: • the T X editor is brought to the front; E 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 (=) template (fraction) versing this process, pasting the TEX code (along with a comment containing a compressed form of slot (numerator) character (a) MathType’s internal representation) back into a MathType character (+) 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.