# Structure Editor: keyboard input, fonts, and Insert menu

### Inserting characters

Typing letters, numbers, and symbols from the keyboard inserts them into the current equation at the current cursor position. In addition, special "keyboard shortcuts" can be used to cut, paste, insert templates, and perform other useful functions. Both kinds of keyboard input are described in more detail below.

MathFlow will accept characters from international keyboards.

In MathML equations, all characters are categorized according to type. In the MathFlow Editor, the most important types are text, identifiers, numbers, and operators. These types correspond to the MathML elements <mtext>, <mi>, <mn> and <mo>, respectively. In MathML, these basic character types are called tokens.

As you enter characters from the keyboard, the MathFlow Editor analyzes the input and automatically inserts the characters into the appropriate MathML token element. Ordinarily, this results in the appropriate MathML markup, and makes authoring MathML equations much easier. As with any automatic algorithm there are cases where problems can arise. However, by understanding how the MathFlow Editor chooses token types for characters, you can easily avoid or correct problem situations.

In the General Editing Preferences dialog, there is an option called Recognize Common Functions. How MathFlow handles characters and invisible operators such as the invisible multiplication character depends on whether or not you have selected this option.

If the "Recognize Common Functions" option is not selected and two or more characters of the same type are entered in succession, the MathFlow Editor will place the characters into the same MathML token element. Thus, typing 's', 'i', 'n' will result in a single identifier token containing 'sin'. Similarly, if you place two or more characters of the same token type together by some other means, such as cut and paste, backspacing, etc. the MathFlow Editor will merge them together into a single token.

However, when the "Recognize Common Functions" is selected, MathFlow will look at the characters you type in and try to recognize a common function, such as cosine. If it determines you have typed in a function, the individual characters are combined in a single token. If a function is not found, each character is placed in a separate token. (Note: Custom toolbar shown in screen shot.)

The MathFlow Editor uses the following rules to decide what token type to assign to characters.

1. A run of alphabetic characters is placed in an identifier, or <mi>, token.
2. A run consisting of digits, commas, and/or periods is placed in a number, or <mn>, token.
3. By default, everything else is placed in an operator, or <mo>, token.
4. Whenever you enter a character of a type not matching the preceding characters, the Editor starts a new token for it.

When problems arise, they usually result when a run of characters should be broken into several tokens, or when separate tokens merge as a result of editing. In the following sections, we'll describe the most common issues.

### Text tokens vs. identifiers

Ordinarily, the MathFlow Editor assumes alphabetic characters are identifiers. Sometimes, however, you may want to treat a run of alphabetic characters and spaces as text. In particular, if you are entering a bit of descriptive text in an equation, you will want the space bar to insert spaces, not InvisibleTimes characters. You can tell the MathFlow Editor to treat a run of characters as text by inserting a text template from the toolbar.

When you insert a text template, the Editor assumes subsequent alphabetic characters and spaces should be treated as text, and won't break them into smaller tokens.

To switch out of a text token to an identifier token, either move the cursor to the right until it loses its I-beam shape, or press the Tab key.

### Invisible operators

MathML uses an "invisible multiplication" character to explicitly denote when two variables or expressions are being multiplied. There is also an "invisible apply function" character that differentiates between multiplication and functions. For example, ab might mean "a times b", or the two-letter variable "ab". Similarly a(b + c) might mean "a times b + c" or it might mean, "apply a function a to the argument b + c". By inserting the proper invisible character, either multiplication or apply function, the semantics become clear.

The option "Recognize Common Functions" on the General Editing Preferences dialog dictates how invisible multiplication and apply function are handled by default. Selecting this option changes whether the MathFlow Editor favors using invisible multiplication or apply function characters.

If the "Recognize Common Functions" option is not selected, the MathFlow Editor favors using multiplication characters and its automatic tokenizing behavior helps remind you to code equations properly. If you just type "a" followed by "b", it will group them both into one token and switch the typeface to upright. This is a visual cue what you entered was the two-letter variable "ab". To enter "a times b", you need to put an invisible times between them.

When you hit the spacebar following an identifier, the MathFlow Editor will insert an InvisibleTimes character. By doing so, a and b will each go into an identifier token of its own, with the InvisibleTimes operator token in-between. a and b will remain in the customary italic typeface, giving you a visual cue you have encoded a multiplication.

If you hit the space bar after anything other than an identifier, the MathFlow Editor will insert a space character as usual. You can customize the behavior of the spacebar from the General Editing Preferences dialog if you don't like the default. You can also access the invisible characters palette on the "Standard" toolbar, and explicitly insert InvisibleTimes characters without using the spacebar.

If the "Recognize Common Functions" option is selected, the editor favors using apply function characters over multiplication. Because this option causes the editor to look for common functions, the editor will automatically insert an apply function character when it finds a function it recognizes.

### Cursor movement shortcuts

A collection of keyboard shortcuts facilitates cursor navigation and selection. These shortcuts don't correspond to menu entries, but rather common mouse operations.

Shortcut keyAction
Tab Tab cycles the cursor between the open template blanks in an equation. After all the templates have been visited, hitting Tab moves the cursor to the end of the equation. Continuing to press Tab repeats the cycle.
Enter When the cursor is at a location in the MathML structure where a newline is valid, Enter inserts one.
End Moves the cursor to the end of the current line.
Home Move the cursor to the beginning of the current line.
Ctrl+Home Move the cursor to the beginning of the equation.
Ctrl+End Move the cursor to the end of the equation.
Shift+ Extends the selection to the right.
Shift+ Extends the selection to the left.
Ctrl+Alt Select all.

### Program shortcuts

One set of keyboard shortcuts handles the main Editor functions. These are mostly operations from the File and Edit Menus. Most of them consist of the control key together with a letter.

Shortcut keyAction
Ctrl+N new equation
Ctrl+Q quit
Ctrl+Alt select all
Ctrl+Ctrl copy
Ctrl+V paste
Ctrl+X cut
Ctrl+Z undo
Ctrl+Shift+< shrink
Ctrl+Shift+> magnify

MathFlow possesses a multi-step undo. You can undo the last three editing operations by hitting Ctrl+Z repeatedly.

### Template shortcuts

A second set of keyboard shortcuts handles the insertion of templates. Basically, these are the entries on the Insert Menu (Design view only). These shortcuts all use the control key together with a letter.

Shortcut keyAction
Ctrl+R insert row template (mrow)
Ctrl+Y insert style change template (mstyle)
Ctrl+T insert text template (mtext)
Ctrl+F or Ctrl+/ insert fraction template (mfrac)
Ctrl+L, Ctrl+B or Ctrl+_ insert subscript template (msub)
Ctrl+H, Ctrl+P or Ctrl+^ insert superscript template (msup)
Ctrl+J insert sub and superscript template (msubsup)
Ctrl+Shift+Q insert square root template (msqrt)
Ctrl+Shift+R insert nth root template (mroot)
Ctrl+0, Ctrl+9 or Ctrl+Shift+P insert parenthesized expression template
Ctrl+I insert definite integral template

### Source editor shortcuts

Shortcut keyAction
Ctrl+Q quit
Ctrl+Alt select all
Ctrl+Ctrl copy
Ctrl+V paste
Ctrl+X cut
Ctrl+Z undo
Ctrl+Y redo
Ctrl+F find/replace
Shift+Tab Tabs selected block of text

Keyboard mnemonics (or keyboard indicators) for menus are accessible within the MathFlow Editor. The keyboard mnemonics allow you to access menu commands without using the mouse.

By pressing Alt, you will be able to view the keyboard mnemonics for the main menu. A letter in each menu item is underlined to indicate its respective keyboard mnemonic. For example, to access the File menu from your keyboard, press and hold Alt, then press and release the "F" key and release Alt. Upon pressing "F," the File menu will expand, giving you the option of pressing "N" for a new window and "E" to exit.

Use this dialog to insert a symbol by using its name or numerical code. You can then preview the symbol or insert it into the equation by clicking the "OK" button.

Character Name

Under the Name tab, you may select from any one of the recognized names located in the drop-down list.

Unicode

Under the Unicode tab, you may enter either a Hexadecimal or Decimal number.

This should be the Unicode value for the symbol. Again, a list of the codes of named symbols is on the MathFlow named characters page. However, you are not limited to these named symbols. Any symbol that is represented in the font in use will be displayed.

Note: It's common for the hex value for a Unicode character to be displayed with the leading characters 0x. In fact, the list of MathFlow named characters linked above lists the characters this way. In the Insert Symbol dialog, if you lead the value with 0x, you will get an error. Thus the correct entry for the example above is 2135 as shown, and not 0x2135.

Decimal number

This is the decimal version of the hexadecimal Unicode. If you want to ensure you have entered the reference for the right symbol, press Enter or click the "Preview" button after entering it. You will see a symbol appear in the white area on the right part of the Insert Symbol dialog box. There are several possibilities here:

• A red square with diagonals — this means you have either entered a name not in MathFlow's list of named characters or you'vce used a non-existent numerical reference.
• A black rectangle — this means you entered a numerical code that is not in the font in use and hence cannot be displayed. You can still insert this code, but will not be able to see it in the formulas.
• A symbol — this is what you will get if you insert it in the formula.

After choosing the correct symbol, click the "OK" button, and it will be inserted into the Editor at the cursor position.

The standard script templates are:

• Subscript
• Superscript
• Subscript and Superscript
• Multiscripts
• Underscript
• Overscript
• Underscript and Overscript

These are all self-explanatory, except for one subtlety concerning under- and overscripts. In MathML, limits are attached to summation and product signs using the under and overscript template. However, to conserve vertical space it is customary in mathematics typesetting to place the limits for summations and products in the sub and superscript positions when an equation appears inline with other text. Thus, when the display style is inline, the under and overscript templates render just like the sub and superscript templates in certain cases. You can manually override this behavior by setting properties on the under and overscript templates.

Choosing the Multiscripts entry opens a dialog box, where you can enter the number of pre- and post-scripts you want. Values of 0 are acceptable (in case you don't want any pre-script, or any post-script.) Note that, per MathML specifications, the subscripts and superscripts should always come in pairs. If you don't want one of them, you would have to enter a space in the corresponding slot.

The Action templates give you a way to add interactivity to equations in some web browsers. The types of interactivity you can choose in response to a click are: toggle between two expressions, status line cue, highlight colors, URL links, mouseover, and combination (nested) actions. These kinds of interactivity are encoded directly in the MathML. Our MathPlayer will render equations with actions interactively in Internet Explorer. If you use MathJax, these are supported in any browser.

• Toggle — Toggles are pairs of templates. Only one of the two toggle expressions shows at a time. When an equation with a toggle template is displayed with MathPlayer or the Viewer Control, clicking on the active toggle expression switches to the other one. This is useful for expanding ellipses, revealing answers, and so on. (Custom toolbar shown in the screen shot.)
When you insert a toggle template, a Toggle Action Properties dialog opens, and two subexpression templates are inserted at the cursor location. They appear vertically stacked and bracketed in the editing pane. Using the buttons on the Toggle Action Properties dialog, you can switch between simultaneous viewing of the two subexpressions, or display of the active expression only, to preview how it will actually look. You can also use the "toggle the active expression" button to simulate a mouse click in the toggle expression. When you mouse over a toggle equation, you can optionally specify a prompt string to appear in the browser status line. You can enter these two cues in the Toggle Action Properties dialog as well. The cue for the active expression is previewed in the status line at the bottom of MathFlow Editor.
• Statusline — inserts a statusline template. By editing the value in the Statusline Action Properties dialog, you can set a prompt string for the browser status line to display when the enclosed expression is moused over.
• Highlight — inserts a highlight template. Enter the names of foreground and background highlight colors to activate on mouseover (i.e., "green," "blue," "red," etc.). You can simulate a mouseover in a published equation by clicking the "Simulate mouseover" button in the Highlight Action Properties dialog.
• Link — inserts a link template. By editing the value in the Link Action Properties dialog, you can set a URL the equation template will link to when clicked in your browser.
• Mouseover — inserts a mouseover template. You can set a foreground highlight color, background highlight color, and a prompt string for the browser status line. The highlighting and status line prompt are activated in the published equation when the reader mouses over the enclosed expression. You can simulate this by clicking the "Simulate Mouseover" button in the Mouseover Action Properties dialog.
• Nested Actions — inserts a special template to combine the mouseover and link actions. You can simulate what will happen on a mouseover by clicking the "Simulate Mouseover" button in the Nested Actions Properties dialog.

The Insert Table option can be used to insert a table of any dimension you wish. Select this option to open a dialog box prompting you for the number of rows and columns. (Custom toolbar shown in the screen shot.)

The Insert Border and Strikethrough box allows you to add borders, strikethroughs and other bounding objects (radical, long division, etc.) around data.

To insert a border or strikethrough, go to the Insert menu, select Layouts, then Borders and Strikethroughs.

To change an existing border or strikethrough, highlight the data you wish to change, then go to the Properties menu and select Border and Strikethrough Properties.

Like other properties dialogs, the Border and Strikethrough properties dialog can also be opened by double-clicking the appropriate tag in the ancestry. In this case, its associated tag is <menclose>.

Note: The Insert Border and Strikethrough and Border and Strikethrough Properties dialogs are exactly the same. Their title depends on context. That's the only difference.