W3C Amaya

previous top next

Editing Mathematics

Amaya allows you to include mathematical expressions in web pages, following the Mathematical Markup Language (MathML) specification. Mathematical expressions are handled as structured components, in the same way as HTML elements. Therefore, you can manipulate math expressions in the same way you manipulate other parts of HTML documents. All editing commands provided by Amaya for handling text are also available for math, and there are some additional controls for entering mathematical constructs.

Creating a Mathematical Expression

The Math palette and the Types/Math menu

To create a mathematical expression in a document, just move the insertion point (the caret) to the position where you want to insert an expression, and then click the Math button (the rightmost button on the button bar), or select the Math entry from the Types menu. The Math button displays a palette that stays on the screen until you click the Done button. The item Math from the Types menu displays a popup menu. Just choose the most convenient tool for you. Both allow you to select the mathematical construct to be inserted.

In the Math palette (or menu) the first item allows you to create a new formula when the caret is in some HTML element (but the caret should not be within a MathML element).

In the Math menu, the next items allow you to create new basic elements (not available in the palette): Plain text (mtext), Identifier (mi), Number (mn), Operator (mo). You can also use these commands to change the type of a single element or a sequence of elements.

These items in the Math menu are followed by the Character (mchar) item. This command allows you to enter a character that is not available on the keyboard. It displays a dialogue box where you have to enter the character name (for instance alpha for the greek character α).

The next items of the Math menu (or palette) allow you to create new constructs within a formula. If the caret is not in a formula, a Math element is created first to accept the new construct. The available constructs are:

The last item of the Math palette ( αβγ ) displays another palette from which you can insert mathematical symbols and greek characters.

Entering constructs from the keyboard

You are not obliged to use a menu or a palette to create and edit mathematical expressions. You can enter mathematical constructs directly from the keyboard, as each item in the Math menu has a keyboard equivalent (all shortcuts are listed in the menu). This allows you to type faster. To type even faster, you may also use the keyboard to move the caret from a construct to another, with the arrow keys.

Entering characters

When you type a character string in a MathML element, Amaya parses that string and generates elements mo (operator), mn (number), mi (identifier), and mtext automatically. For instance, to enter

x = 2 a + b

just type this sequence of 6 characters: x=2a+b, (don't forget to first click on the Math item of the Math menu, if you are not in a mathematical expression) and you will get the following structure (you can check in the Math_Structure view):

<mi>x</mi><mo>=</mo><mn>2</mn><mi>a</mi><mo>+</mo><mi>b</mi>

If the result is not exactly what you want, just select the characters that have been misinterpreted and change their type with one of the commands Plain text (mtext), Identifier (mi), Number (mn), Operator (mo) from the Types/Math menu.

Structure editing

Amaya provides the same method to create and edit matrices as to edit HTML tables. Like for tables there is a specific command (Delete matrix column) to delete a column in a matrix, even if it's not empty. This command is located at the end of submenu Math of menu Types.

You may want to change the structure of an existing expression, e.g. appending a superscript or puting parentheses around an expression. To do that, just select the expression and enter the new construct with the palette, the Math menu or the keyboard. You can also use the Transform command from the Edit menu. Select the expression you want to transform and the Transform command will display a menu with all possible changes.

Math_Structure view

Whenever a document contains some MathML elements, choosing the Show Structure item from the Views menu actually opens two views:

You can edit math expressions either in the main view or in the Math_Structure view. The Math_Structure view is especially helpful to avoid ambiguity. Consider the following example:

x = a + b + 1

When moving the caret after character b, it is not clear whether you want to add something within the square root or after it. Selecting (or checking) in the Math_Structure view avoids any ambiguity. You can also check the status line, at the bottom of the main window.

Links in MathML

You can create and use links in mathematical expressions. These links are represented using a draft version of the XML Linking Language (XLink). Only the simple unidirectional hyperlinks are available, but you can associate a link with any part of a formula. For example, the fraction in the formula below is a link to the W3C home page:

y = 1 x 2 + 1

Double-clicking any character within the fraction fetches the W3C home page. In the XML file, the fraction is represented by:

<mfrac xml:link="simple" href="http://www.w3.org/">...</mfrac>

(You can only find this in the structure view - it is not currently shown in the links view) To create such a link, just select an expression (the fraction in the above example), click on the Link button (or select "createLink" from the Links menu) and click on the desired target. If the target is an expression in a formula, you first have to turn that expression into a target. Just select the expression and select "create Target" from the Links menu. This creates an id attribute for the target expression.

Current limitations

Amaya implements only the Presentation Tags from MathML 2.0, not the Content Markup. All presentation elements and attributes are available, but only some attributes have an impact on the formatted view (fontsize, fontweight, fontstyle, fontfamily, color, numalign, denomalign, beveled, notation). The class, id and style attributes are available, with the same semantics as in HTML: you can associate CSS style with MathML elements (class and style attributes) and a MathML element can be the target of a link (id attribute).

Due to the lack of mathematical fonts, only a limited set of entities representing math symbols are recognized, mainly those available in the Symbol font. The current version supports: Therefore, SuchThat, DownTee, Or, And, Not, Exists, ForAll, Element, NotElement, NotSubset, Subset, SubsetEqual, Superset, SupersetEqual, DoubleLeftArrow, DoubleLeftRightArrow, DoubleRightArrow, LeftArrow, LeftRightArrow, RightArrow, Congruent, GreaterEqual, le, NotEqual, Proportional, VerticalBar, Union, Intersection, PlusMinus, CirclePlus, Sum, Integral, CircleTimes, Product, CenterDot, Diamond, PartialD, DoubleDownArrow, DoubleUpArrow, DownArrow, UpArrow, ApplyFunction, TripleDot.

previous top next