Next: Section 5
Up: WebEQ 2.5 Documentation

WebTeX: A Markup Language for WebEQ


1. Introduction

WebTeX is an equation markup language for WebEQ. In the style of its syntax, it is similar to LaTeX. However, there are some differences between the two. For one thing, the underlying WebEQ layout engine is based on MathML, the new W3C standard for encoding Math on the Web, and not TeX. The benefit is that WebTeX is better adapted to electronic documents.

WebTeX is a rich mathematical markup language. It has basically the same expressive power as the LaTeX math mode, and it is generally reasonably easy to convert WebTeX math markup into LaTeX markup. A utility program that converts an HTML/WebTeX document into a LaTeX document is under development, and should help meet the needs of authors who need both electronic and traditional paper versions of a technical document.

Work is also under way on utilities to convert LaTeX documents into HTML/MathML documents. However, this is a harder problem, since there are many variants and dialects of TeX. In general, authors should not expect to easily convert existing TeX documents to HTML with embedded WebTeX or MathML.

2. Using WebEQ with WebTeX

It is important to clearly understand the difference between WebEQ and WebTeX. WebEQ is a collection of software tools for creating and displaying scientific Web pages, while WebTeX is a markup language for describing mathematical equations. Generally speaking, WebTeX markup is used as input to the various WebEQ tools. The output can take a number of forms, including images, applets, or the equivalent MathML markup.

The WebEQ tools are internally based on MathML. However, MathML is not really designed as an input language. Therefore, by default, the WebEQ Math Viewer Applet and WebEQ Wizard expect WebTeX equation markup as input. At present, the Equation Editor will only read and write MathML.

The WebEQ Math Viewer Applet is a Java program which runs in a Web browser, and displays interactive math equations. To create an instance of a WebEQ applet, an author puts an applet tag in the HTML source code at the point where the notation should appear. To describe the equation the applet should display, the author must specify some equation markup in an applet parameter. A simple WebEQ applet tag looks like this:

<applet codebase="classes" code="webeq.Main"
           width=500 height=100>
<param name=eq value=" y = x + 1 ">
</applet>
The value of the eq parameter, i.e. y = x + 1, is WebTeX markup describing the equation to display.

This section of the WebEQ documentation describes the WebTeX language, which is used to fill in the value of the parameter eq, along with a few special applet parameters for use with WebTeX.

3. The Wizard

In general, it can be quite tedious to insert applet tags in the document source for each bit of mathematical notation to be displayed. Among other things, in order to properly align the mathematical notation with the surrounding text, one must determine the height and width of the equation.

A great deal of this work is done automatically by a program provided with the WebEQ system called the Wizard. To use the Wizard, an author prepares an HTML document, including the WebTeX markup in the text. The WebTeX markup is surrounded by dollar signs (e.g. $x=2$) for inline equations, and by escaped brackets (e.g. \[ x=2 \]) for displayed equations. This will be familiar to authors accustomed to preparing LaTeX documents.

Once the source document is complete, the author then runs the Wizard program, which goes through the source file, finds the WebTeX markup, computes the equation sizes, and writes out a final HTML file with the proper WebEQ applet tags included. The Wizard has many options that can be set in order to control what applet parameters are set, and how macros are processed, among other things.

One can think of running the Wizard to produce a final HTML file as being analogous to running TeX to produce a DVI file. WebEQ and the web browser work together to display the output of the Wizard, just as a program like xdvi can be used to display the output of TeX. One of the main differences is that the HTML file produced by the Wizard is still a plain text file that one can look at and edit further by hand if necessary, whereas a DVI file is a binary file that is very difficult to work with.

The Wizard is a very useful aid in producing HTML/WebTeX documents. For more information, see the Wizard documentation.

4. Macros

If you are familiar with TeX, you know that the ability to define macros that represent frequently used or complicated expressions greatly simplifies authoring mathematical notation. Both the WebEQ Math Viewer Applet and Wizard support the use of WebTeX macros.

Macros can be defined in any of three ways: they can be defined in an external file, in the header of the HTML document, or in applet parameter tags. Macros can also be processed in a variety of ways by the Applet and Wizard. For details about macro processing, consult the documentation on using macros with the Wizard and WebEQ Math Viewer Applet parameters.

For illustrating the WebTeX syntax for macro definition, we will consider specifying macro definitions using applet parameters. The simplest method is to use the macros parameter. Its syntax is as follows:

<param name=macros value="\define{\plusfifty}{+ 50}">
Here we have used the WebTeX \define{}{} command to define a new keyword, \plusfifty, which can then be used in the equation to signify where the symbols + 50 should be placed. In other words, the new keyword \plusfifty will be replaced by the expression "+ 50". Thus, if the equation markup is
<param name=eq value="y \plusfifty = x \plusfifty ">
the end result is that the applet will display:
y + 50 = x + 50

Macros can also be written using arguments, just as in TeX. WebTeX macros use the symbols #1, #2, #3 and so on to represent the arguments passed to a macro. Thus, the macro definition

<applet codebase="classes" code="webeq.Main"
           width=500 height=100>
<param name=macros value="\define{\plusN}[1]{+ {#1}}">
<param name=eq value="y \plusN{35} = x \plusN{z - w}">
</applet>
produces the output
y + 35 = x + z - w

Note that in the definition of \plusN, the number of arguments is specified in square brackets immediately after the braced expression containing the keyword. When using a macro that accepts arguments, it is generally a good idea to enclose the arguments in curly braces, to prevent unforeseen side effects that might arise when substituting unusual values.

The macrofile parameter is used to specify a file containing macro definitions. The value of the macrofile parameter is actually a URL, so several documents can share the same macro definition file in a central location. For example, if the file "my_macros.def" contains:

\define{\plusfifty}{+ 50}
one could write
<applet codebase="classes" code="webeq.Main"
           width=500 height=100>
<param name=macrofile value="my_macros.def">
<param name=eq value="y \plusfifty = x \plusfifty">
</applet>
in a document living in the same directory as "my_macros.def", while a document on another computer might contain an applet call something like this:
<applet codebase="classes" code="webeq.Main"
           width=500 height=100>
<param name=macrofile
          value="http://www.macros.com/my_macros.def">
<param name=eq value="y \plusfifty = x \plusfifty">
</applet>
The WebEQ Examples include an example of macros.


[HOME] WebEQ 2.5 Documentation Table of Contents

Created: Nov 05 1997 --- Last modified: Sat Mar 04 12:36:24 2000
Copyright © 1997-2000 Design Science, Inc. All rights reserved.