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 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 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,
and create vectors and matrices.
Before trying out the editor, please change the color and font to the
recommendations
given below. Once you've done that, you are ready to start editing equations!
Creating a Basic Expression
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.
As you see, the expression editor has a single visual clue:
a highlighted current expression. Here is a summary of its basic
principles:
- An empty box denotes an
expression to be filled in. Your initial expression is an empty box.
In general, your expression may contain 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 or more leading
alphabetic letters of its name. Use TAB to
complete the word as far as possible. Type any non-alphabetic character, e.g., SPACE, to end the word.
Alternatively, right-click on the characters typed so far
to get a context menu of choices for completions.
Control words like \sum and \int create variable-sized
operators.
- An open-parenthesis creates an empty enclosed expression. Type an
open parenthesis, bracket, or curly brace delimiter to create an empty enclosed expression.
Want to change a delimiter?
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 curly brace
wraps the current expression with matching left-right delimiters.
- Infix operators like % or + create
an empty box for the second operand.
Operator % (or ALT+o) creates a two-dimensional fraction
with an empty box for the denominator.
Simlarly ^, _, and # (alternatively, ALT+p, ALT+s, and ALT+q)
create two-dimensional forms for powers, subscripts, and
square roots (for a general root, type left-arrow to get a box for the exponent).
Operators +, -, =, *, and / create no two-dimensional structure but
give you an empty box for the right operand.
Arrow Keys
The arrow keys move the highlight to a new leaf in the indicated direction.
Adding the CTRL key, lets you navigate the math expression as a tree
structure.
-
Arrow keys move the highlight to a new leaf in the indicated direction.
Type left- and right-arrow to move along the leaves of an expresssion. Type up-arrow to move
the highlight from a denominator to a numerator leaf, from a subscript to a base to a superscript leaf, and so on.
-
CTRL+left- and CTRL+right-arrow move highlight
across sibling structures.
Adding CTRL, the left- and right-arrow keys move the highlight
to the left- or right-sibling of the current expression tree. For example,
CTRL+right will move you across the terms of a product.
-
CTRL+up-arrow means larger structure.
Type CTRL+up arrow to move the highlight to
the parent of the current expression tree. For example, CTRL+up arrow
moves you from a denominator of a fraction to the entire fraction.
-
CTRL+down-arrow means smaller structure.
Type CTRL+down arrow to move the highlight to
a child of the current expression tree. For example, CTRL+down
arrow moves you from a fraction to the numerator of the fraction.
-
CTRL+SHIFT+right/left-arrow means extend.
When CTRL+SHIFT is held down when typing the
right- or left-arrow, the highlight is extended
in the direction of the arrow. For example, CTRL+SHIFT+right-arrow can be used to extend the selection of a leading term of a product to include
one of more terms to the right.
Insertion and Deletion
- New characters are inserted to the right unless preceded by the INSERT key.
The characters you type are inserted to the right of the currently highlighted
expression. If you must insert a character to the left, preceed the character by an INSERT.
- DELETE (or ALT + d) 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 braces, you can move the highlight to either delimiter. You can now type a
new delimiter or hit
DELETE or BACKSPACE to remove both delimiters.
- Left- and right-arrow introduce insertion boxes.
When positioned at the right-end of an expression, successive right-arrows create
an insertion box that moves "up" one level at a time.
Alternatively, left-arrow can be used to introduce an insertion box to the left of the expression.
- ALT+x inserts a 2-by-2 matrix with empty boxes as coefficients.
- ALT+y inserts a vector (a 2-by-1 matrix) with empty boxes as coefficients.
- Use ALT+w or ALT+l to add rows and columns.
- Type ALT+w or ALT+l to insert an empty row or column into the matrix.
- Add the SHIFT key if you want the empty row or column to be inserted before the current one.
- Use TAB and the arrow keys to navigate around the matrix.
- TAB moves the highlight from one coefficient to the next.
- Add the SHIFT key to move in the opposite direction.
- Left- and right-arrow move the highlight across the sibling leaves.
- Up- and down-arrow move the highlight up or down to the nearest leaf.
- Matrices can be viewed structurally as having either rows or columns as children.
- Matrix structures initially have rows as children.
- CTRL+right/left-arrow moves the highlight across the coefficients of a row.
- CTRL+up-arrow highlights the row containing the coefficient.
- ALT+r rotates a row into a column and vice-versa.
- CTRL+right/left-arrow then moves the highlight up and down the rows or columns of the matrix.
- CTRL+up-arrow moves the highlight from a row or column to the entire matrix.
- CTRL+down-arrow moves the highlight from the matrix to the first row or column, from a row or column to its first
coefficient.
- Editing a matrix.
- To delete a row or column of a matrix, use CTRL+arrow keys and
ALT+r to select a row or column to be deleted, then hit DELETE or BACKSPACE to remove it.
- To insert an expression before or after a matrix, hit CTRL+up-arrow repeatedly to select the matrix, then insert as usual.
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.
Visit the official techexplorer home page at
http://www.software.ibm.com/techexplorer/.