# WebEQ

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

The WebEQ Publisher application provides a convenient way of creating Web pages that contain MathML. This application allows you to use the WebTeX language for authoring mathematical notation. WebTeX is a markup language for describing mathematics that was developed by Design Science. WebTeX markup is simple enough to author directly by hand and can be readily converted into MathML. This makes WebTeX a convenient input method for authoring MathML, especially for users who are already familiar with the LaTeX syntax for mathematical formulas.

For information on how to create an HTML+MathML file starting with a document that contains WebTeX markup, see the description of WebEQ Publisher under Authoring and editing MathML: WebEQ. WebEQ Publisher is a Java application that takes a source file that contains WebTeX equations and produces an HTML file with all the equations automatically converted either to Viewer Control applet tags or to MathML, depending on your preference.

## The WebTeX language

The syntax of WebTeX is almost identical to that of LaTeX. However, there are some differences. For example, in LaTeX the \sqrt command is used to indicate any type of root or radical. Hence, the cube root of x would be indicated as shown below:

$\sqrt[3]{x+1}$

In WebTeX, the same expression would be written as:

$\root{x}{3}$

The WebTeX expression is clearly much easier to translate into MathML since it has the same structure as the MathML mroot element.

Another area in which WebTeX commands differ from those of LaTeX is when you are entering tables and matrices. In WebTeX, as in LaTeX, matrices are entered using the \array command, as shown below:

$\left(\array{1 & 2 \\ 3 & 4}\right$

However, WebTeX provides a set of options that make it easier to control various features of the array. To use these options, you must specify the command \arrayopts{} as the first argument of \array{}. The \arrayopts{} command can have as arguments one or more options, each controlling a specific property of the array.

For example, the options \colalign and \rowalign determine the alignment of columns and rows, respectively. Possible values for \colalign are left, right, and center. Possible values for \rowalign are top, bottom, center, and axis. Here is an example:

\array{\arrayopts{\colalign{left left right}} 1 & x+1 & x^2+1 \\ x^2-1 & x-1 & 1}

The option \equalrows{true} causes all rows in the array to have the same height, while \equalcolumns{true} causes all columns to have the same width. However, if either of these options is set to the default value, false, each row or column is adjusted to fit the entry with the largest height or width. The options \rowlines{} and \collines{} determine if a line is drawn between any two rows or columns, while \frame determines if a frame is drawn around the entire array. The possible values for all these options are solid, dashed, and none.

These array options in WebTeX correspond directly to attributes of the mtable, mtr, and mtd elements in MathML — namely rowalign, columnalign, rowspacing, columnspacing, rowlines, columnlines, and frame. This makes it easy to translate tables in WebTeX syntax into MathML. In contrast, specifying properties of tables in LaTeX requires more complicated commands that do not fit well with the structure of MathML.

WebTeX also includes a few commands that allow for interactivity in equations:

• The command \href{url} {expr} can be used to turn an equation into a hyperlink. The first argument is the URL to be followed, and the second is the expression that should appear as a link.
• The command \statusline{message} {expr} causes the text of message to be displayed in the status line of the browser when the cursor is moved over the expression expr.
• The command \fghighlight{color} {expr} causes the expression expr to be displayed in a different color when the cursor is moved over it. The color is specified in six-digit hexadecimal notation; for example, #ff0000 for red.
• The command \toggle{expr1} {expr2} {prompt1} {prompt2} can be used to toggle between two different expressions. Initially, expr1 is displayed in the Web page and prompt1 appears in the browser status line; however, clicking the expression using the left mouse button causes expr2 to be displayed in the browser window and prompt2 in the status line.

When you translate WebTeX markup into MathML using WebEQ Publisher, these commands get converted into maction elements. They can then be displayed in browsers as WebEQ applets. For details on using maction elements in WebEQ to get interactive behavior, see Creating dynamic math web pages: WebEQ.

WebTeX also allows you to define macros to create shorthand notation for commands that you use frequently. A macro is specified using the command

\define{expr1} {expr2}

where the first argument is the name of the macro and the second argument is the expression that the macro stands for.

The following example shows a simple HTML file that contains WebTeX markup.

Example: An HTML document called calculus.html that contains WebTeX equations.

<html>
<body>
<h1>Fundamental Theorems of Calculus</h1>
<p>The first fundamental theorem of calculus states that, if $f$ is continuous on the closed interval $[a,b]$ and $F$ is the antiderivative (indefinite integral) of $f$ on $[a,b]$, then </p>
<p>$\int _{a}^{b}f(x)\DifferentialD x=F(b)-F(a)$</p>
<p>The second fundamental theorem of calculus holds that if $f$ is a continuous function on an open interval $I$ $a$ any point in $I$, and if $F$ is defined by </p>
<p>$\int _{a}^{b}f(x)\DifferentialD x=F(b)-F(a)$</p>
<p>then $F(x)=f(x)$ at each point in $I$. </p>
<p>The fundamental theorem of calculus along curves states that if $f(z)$ has a continuous antiderivative $F(z)$ in a region $R$ containing a parameterized curve $\gamma: z=z(t)$ for $\alpha \leq t \leq \beta$, then</p>
<p>${{\int }_{\gamma }}f(z)\DifferentialD z=F(z(\beta))-F(z(\alpha))$</p>
</body>
</html>


If you process this file using WebEQ Publisher, you get an output document in which all the WebTeX equations have been translated to MathML. You can also set an option to automatically insert a reference to the Universal MathML stylesheet. The resulting output file can then be viewed in IE.

Note that the output file may not contain well-formed XHTML, so it cannot be viewed in Mozilla. In order to view the file in Mozilla, you may have to first convert the file into XHTML using the free utility TIDY. As discussed under MathML-enabled browsers: Mozilla/Netscape, TIDY is a C program for converting HTML files into XHTML.

The following figure shows the document produced by processing the document calculus.html in WebEQ Publisher. The resulting document contains MathML equations that can be rendered in IE using MathPlayer.

Figure: Viewing the document produced by processing calculus.html in IE.

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