Editing Mathematics

Amaya enables you to include mathematical expressions in web pages, using 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. In addition, there are some other controls for entering mathematical constructs.

Entering Math Constructs using the Keyboard

You are not required to use the menus or the Math palette to create and edit mathematical expressions. You can enter mathematical constructs directly from the keyboard because each item in the Math menus has a keyboard equivalent. These shortcuts are listed on the menu and in the table below.

You can also use the keyboard arrow keys to move the insertion point from one math construct to another. The right and left arrows move the insertion point according to the structure of the mathematical expression. For example, in a fraction when the insertion point is at the end of a numerator, the right arrow key moves the insertion point to the beginning of the denominator.

Action Shortcut
New formula (math) Ctrl-m Ctrl-m
Plain text (mtext) Ctrl-m Ctrl-x
Identifier (mi) Ctrl-m Ctrl-d
Number (mn) Ctrl-m Ctrl-n
Operator (mo) Ctrl-m Ctrl-g
Space (mspace) Ctrl-m Ctrl-Space
Character (&xxx;) Ctrl-m Ctrl-e
Invisible Times Ctrl-m Ctrl-i
ApplyFunction Ctrl-m Ctrl-a
Root (mroot) Ctrl-m Ctrl-r
Square root (msqrt) Ctrl-m Ctrl-q
Enclose (menclose) Ctrl-m Ctrl-c
Fraction (mfrac) Ctrl-m Ctrl-f
Subscript and superscript (msubsup) Ctrl-m Ctrl-b
Subscript (msub) Ctrl-m Ctrl-v
Superscript (msup) Ctrl-m Ctrl-6
Under and over (munderover) Ctrl-m Ctrl-k
Under (munder) Ctrl-m Ctrl-u
Over (mover) Ctrl-m Ctrl-o
Parentheses (mrow) Ctrl-m Ctrl-p
Multiscripts (mmultiscripts) Ctrl-m Ctrl-s
Matrix (mtable) Ctrl-m Ctrl-t

Creating a New Formula

To create a new mathematical expression in a document, move the mouse cursor to the position where you want to insert an expression, and then click the Math button from the Math palette, or choose New formula from the XML menu.

Math Menus and Palette Commands

The XML/Basic math Elements menu contains elements which are not available from the palette. The first items include: Plain text (mtext), Identifier (mi), Number (mn), Operator (mo). These commands are used to create new elements in a mathematical expression. They can also change the type of a single element or a sequence of elements.

The next command, Space (mspace), allows you to add space in a formula. Changing the value of the width attribute for this element allows you to set the width of the space.

The next item, Character (&xxx;) , enables you to enter a character that is not available on the keyboard. It displays a dialog where you have to enter the character name (for instance alpha for the Greek character α).

Commands InvisibleTimes and ApplyFunction are used to enter the corresponding invisible characters.

The XML/Math Constructions menu or the Math palette enable you to create new constructs within a formula. If the insertion point is not in a formula, Amaya first creates a math element to accept the new construct. The available constructs are:

The XML/Matrices menu allows you to create and edit matrices:

You can create a matrix with the first command of this menu or with the corresponding button from the Math palette. You must then choose the number of lines and columns in the new matrix through a dialog that pops up. You can manipulate a matrix like a HTML table through the commands available from the XML/Matrices menu.

Entering Math Characters

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

For example, to enter the formula x = 2 a + b

  1. If you are not in a mathematical expression, choose XML/New formula (math).

  2. Type this sequence of 6 characters: x=2a+b

Use the Structure or Source view to display the following structure generated by Amaya:

<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, select the characters that were misinterpreted and change their type with one of the commands such as Plain text (mtext), Identifier (mi), Number (mn), Operator (mo) or Space (mspace) from the Basic math elements submenu of the XML menu.

Spacing

Amaya takes care of spacing within math expressions, but in some cases you may need to add some additional space. Move the cursor to the position where you want to insert space and choose Basic math elements/Space (mspace) from the XML menu. This creates a default horizontal space. You can then change its width attribute to adjust its size or you can add other attributes (height, depth, linebreak) to change vertical spacing. Refer to the MathML specification for more details.

Bracket size

When entering brackets as in the following expression:

f ( x ) = 1 x

typing the sequence f(x)= ... would lead to:

f ( x ) = 1 x

Instead, choose Math Constructs/Parentheses from the XML menu or select the Parentheses button on the Maths palette to enter the parentheses properly.

Special Characters

You can use the Character command from the XML/Basic math Elements menu to enter mathematical characters and symbols that are not available on the keyboard. Type in the name of the character, as defined in the MathML specification. You may choose to type the Unicode value of the character instead. For entering this value in decimal, start with a '#'. For entering the value in hexadecimal, start with '#x'. To type faster, you can also enter the hexadecimal value without any leading '#x', but note that this may be ambiguous (like 'af', for instance). In case of ambiguity, the string is interpreted as a character name.

You can also use the Special characters palette. The first two rows of buttons allow you to choose a group of characters, which are then available in the pull down below. Choose a character in the list and insert it in the formula by clicking the insertion button

Changing the Expression Structure

You may want to change the structure of an existing expression, such as appending a superscript, putting parentheses around an expression, or turning an expression into the numerator of a fraction. To do that, select the expression and enter the new construct with the palette, the XML/Math Constructs menu or the keyboard.

You can also use Transform on the Edit menu. Select the expression you want to transform and Transform will display a menu with all possible changes.

Viewing Structure in MathML

MathML structure in a document can be viewed by choosing Show Structure from the Views menu. Choosing this option opens the Structure view, which reveals the main structure of the document, the math elements, and their contents.

Math expressions can be edited in the main view or in the Structure view.

The Structure view is especially helpful to avoid ambiguity. For example, in the equation below, placing the cursor after character b , it is not clear whether you wish to add something within the square root or after it.

x = a + b + 1

Selecting (or checking) in the Structure view avoids any misselections. You can also check the status line at the bottom of the main window.

Linking in MathML

You can create and use links in mathematical expressions. These links are represented using the XML Linking Language (XLink). Only simple unidirectional hyperlinks are available in Amaya, 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 or right-clicking any character within the fraction loads the W3C home page.

To create such a link, select a math expression (the fraction in the above example, for instance by clicking on the fraction bar), click the Link button from the XHTML palette (or choose Create or change link from the Links menu), and click the desired target.

If the target is an expression in a formula, you must first turn the expression into a target. Select the expression and choose Create target from the Links menu to create an id attribute for the target expression.

Known Issues With MathML

The following are known Amaya MathML issues: