Input mathematics with the expression editor
The expression editor is a Java applet for editing mathematical
expressions that exemplifies the use of the techexplorer Java interface
to the Document Object Model (DOM) API.
With the expression editor you can use the keyboard and mouse to create and edit
mathematical structures that have been created either for the purpose of displaying
mathematics in a document or performing a scientific computation.
The design of the expression editor is distinguished by
three interrelated subcomponents:
- it is based on a hierarchy of mathematical objects that
relates to either or both the graphical rendering of the mathematics on the printed page,
and the interpretation of the formulas by a computational system;
- it provides for WYSIWYG (``what-you-see-is-what-you-get'')
editing of mathematics by use of a single visual cue: a highlighted subexpression; and,
- it correlates these mathematical objects and single visual
cue with keyboard actions for purposes of insertion, deletion, and navigation.
In what follows we introduce the basic use of the expression editor by examining
how to create a basic expression,
use the arrow keys, insert
and delete mathematical expressions, undo and redo,
and and matrix edit commands.
We conclude with recommendations for the use of the
expression editor.
Once you are ready start editing equations!
Creating a Basic Expression
First here is how you create an expression from scratch. The expression
editor first presents you with an empty box. You fill this box with the first character
that you type from the keyboard. As you type in new characters, the highlight moves to the right.
The expression editor has a single visual clue,
a highlighted current expression. Here is a summary of basic
principles:
- An empty box denotes an
expression to be filled in. Your initial expression is an empty box.
In general, your expression may containing any number of empty boxes.
- The current expression
is highlighted. Each new expression you
type becomes the new current expression, i.e. becomes highlighted.
- Variables names have single
alphabetic characters. Thus xy is interpreted as the product of two variables x
and y.
- LaTeX control words are entered
with a backslash. For LaTex control words, type a backslash (\) then one of more leading
alphabetic letters of its name. Use TAB to
complete the word as far as possible, then any non-alphabetic character to accept that completion.
Alternatively, right-click on the characters typed so far
to get a context menu of choices for completions.
- An open-parenthesis creates an empty enclosed expression. Typing an open parenthesis, bracket, or brace, creates an empty enclosed expression.
Want to change them?
Use the right/left-arrow keys to move to the delimiter then type a new one (use a dot "." if you want it invisible).
- A close-parenthesis wraps the highlighted expression in parentheses.
Typing a closed parenthesis, bracket, or brace
wraps the the current expression with identical delimiters.
- Typing the infix operator + gives you
an empty box for the right operand.
Operators + - = and / create no two-dimensional structure but always give you
an empty box for the right operand.
- Type ALT+s (or infix '_') to create a subscript
Typing ALT+s creates an empty box for a subscript.
You can then
rotate this box in the same direction (clockwise) using ALT+r.
Once a script is given, use ALT+a to add an additional script.
Other two-dimensional
structures are created by
ALT+p (or '^') for powers,
ALT+d (or '%') for divisions,
ALT+q for square roots, and
ALT+o for general roots.
Arrow Keys
As is customary with text editors, the arrow keys move you in the direction indicated by the arrow.
Left and right arrow move you systematically across the characters of the math expression. Up and down move from superscript to subscript, numerator to denominator, and so on.
Adding the CTRL key, lets you navigate the math expression as a tree
structure.
-
CTRL+Left and CTRL+Right move
across siblings. Adding CTRL to the left- and right-arrow keys move the highlight
to the left or right sibling of the current expression tree.
-
CTRL+Up means larger.
Type CTRL+up arrow to move the highlight to
the parent of the current expression.
-
CTRL+Down means smaller.
Type CTRL+down arrow to move the highlight to
a child of the current expression.
-
CTRL+SHIFT+Right/Left means extend.
When the CTRL+SHIFT key is held down when typing the
right- or left-arrow, the highlight is extended
in the direction of the arrow.
Insertion and Deletion
- New characters are always inserted to the right unless preceeded by an INSERT..
The characters you type are always inserted to the right of the currently highlighted
expression. If you must insert a character to the left, just precede the character by an INSERT.
- DELETE and BACKSPACE ( or ALT+b ) delete the
current expression.
- The DELETE key deletes the current expression
and moves the highlight to the right.
- The BACKSPACE key deletes the current expression and moves the
highlight to the left.
- DELETE and BACKSPACE delete enclosing
parentheses.
Once you have an expression enclosed in any kind of left-right delimiters:
parentheses, brackets, or curly brackets, typing
DELETE or BACKSPACE replaces the enclosed expresssion by
the expression itself.
- DELETE and BACKSPACE are used to edit control words and numbers.
Numbers are consecutive strings of digits containing an optional decimal point. While creating a number or control word, the
right- and left-arrow keys, DELETE, and BACKSPACE may be used to edit their contents. Thereafter numbers and control words
becomes nodes of the expression tree. To re-edit either, type a down-arrow.
Undo and Redo
The expression editor provides an infinite undo and redo facility.
- UNDO ( CTRL+z ) cancels the last action.
To undo the last keyboard action, issue an UNDO by typing CTRL+Z. A second
UNDO undoes the next-to-last keyboard action. And so on.
- REDO (CTRL+y ) cancels UNDO.
To cancel an UNDO, issue a REDO by typing CTRL+Y. The first REDO cancels
the effect of the last UNDO. A second REDO cancels the next-to-last
UNDO. And so on. A REDO does nothing unless it immediately follows an UNDO or REDO.
- UNDO cancels REDO.
An UNDO immediately following a REDO cancels the effect of the REDO.
The example below illustrates the use of DELETE, UNDO, and REDO to edit the last
expression produced above.

Matrices
- ALT+m creates a 2-by-2 matrix of empty boxes. The 1-1 element becomes its initial current expression.
- Matrices appear without a border. Add whatever you like.
- Use ENTER to insert rows and columns
- Type ENTER to insert an empty row below a highlighted element.
- Add the CTRL key to insert an empty column to the right of the highlighted element.
- Add the SHIFT key to insert a row above or a column to the left of the highlighted element.
- Use the arrow keys and TAB to traverse the elements.
- Use the left/right arrow keys to walk across the characters and elements of the matrix.
- Add the CTRL key to traverse the elements.
- Use the up/down arrow keys to move up/down the columns.
- Type TAB to jump to the next row element.
- Add the CTRL key to jump to the next column element.
- Add the SHIFT key to jump to the previous row or column element.
- Use the arrow keys to move to and traverse rows and columns
- Use CTRL+up arrow to move the highlight from an element to
the row containing the element.
- Use ALT+r ("rotate") to rotate the highlight from a row to a column or
vice-versa.
- Use CTRL+left/right arrows to move highlight along the rows or columns.
- Use another CTRL+up arrow to move the highlight from a row or
column to the entire matrix.
- Use CTRL+down to move the highlight from a matrix to a row/column,
or a row/column to a element.
- DELETE or BACKSPACE work as usual
- Both replace a highlighted element by an empty box, moving the highlight right or left.
- Both delete a highlighted row, moving the highlight down or up.
- Both delete a highlighted column, moving the highlight right or left.
- Both delete a highlighted matrix, moving the highlight right or left.
The matrix example below illustrates many of the above points.

Recomended techexplorer settings
- Colors recommendation: suggest light gray--bottom row, 3rd from right, in table of basic
colors for Selection Background( Options...->Colors from context menu on the Expression
Editor window)
- Font recommendation: Times New Roman 13 for normal and italic math
(Options...-->Fonts from context menu on Expression Editor window).
IBM techexplorer Hypermedia Browser is a trademark of the IBM
Corporation. Send comments and questions to techexpl@us.ibm.com.