Templates and symbols

Equation templates are the building blocks out of which equations are constructed in the MathFlow Editor. Each template represents some common mathematical notational pattern, such as a fraction. Most templates are self-explanatory, and the remaining handful is straightforward once you know what each one does. The less obvious templates are all explained below.

The most common templates usually can be inserted in three ways: from the toolbar, using a keyboard shortcut, or from the Insert Menu. Many of the less common templates must be inserted using the toolbar. However, action templates for interactive equations, and templates for matrices of unusual dimensions can only be inserted by using the Insert Menu. See Keyboard Input: Template Shortcuts for the list of templates you can enter with keyboard shortcuts.

Regardless of the method used to insert a template, it will appear at the current cursor location. By default, the cursor will automatically move to the first empty slot in the newly inserted template. Pressing Tab will cycle the cursor through all the open template slots in the equation.

In many cases, it is convenient to "wrap" a template around an existing expression. For example, perhaps you have already entered x + y when you realize it should be the numerator of a fraction. Rather than cutting x + y to the clipboard, inserting a fraction template, and pasting from the clipboard to the numerator, you can combine this into a single step by "wrapping" the template around x+y.

To do this, just select x + y, then insert the fraction template. The selected expression will automatically be placed in the first open slot in the template. All templates have a "first" slot for the purposes of wrapping. Generally this is the left-most slot, but in cases where some other slot is clearly the dominant slot, the dominant slot is used.

Layouts

There are 8 items you can access through the Layouts flyout of the Insert menu.

You can use the Insert menu to directly insert symbols, the most common equation templates, as well as action templates and templates for matrices of any size.

The standard Layouts you can insert are:

Fraction — inserts a fraction template.

Square Root — inserts a square root template.

Radical — inserts an "nth root" template.

Style Change — inserts a style change template. Style change templates are used to set properties such as font or background color for an entire subexpression. Since the properties are set on the enclosing style change template, they will apply to anything you enter or paste into the template. Similarly, if you cut part of the contents of a style change template and paste it somewhere else, it will no longer reflect the properties set on the style change template. For this reason, properties set using style change templates are sometimes referred to as "non-sticky" properties. See Tutorial: Working with math properties for more details on sticky and non-sticky properties. Ordinarily, style change templates are inserted automatically as needed by Properties dialogs, so you rarely need to insert them by hand.

Text — inserts a text template. Within a text template, the space bar always inserts true spaces and not invisible multiplication markers.

Expression Group — inserts a grouping template. In MathML, this is an <mrow>. An expression group is an invisible template that serves to collect subexpressions together. Characters like parentheses stretch to the height of the group they are in, so it is frequently necessary to insert expression groups when creating parenthesized expressions. A very common mistake is to begin an equation by typing something like f(x) = and then inserting something tall like a fraction to the right of the = symbol. Suddenly the parentheses stretch to the height of the fraction, since they are all contained in a single expression group. Instead, the (x) should be enclosed in an expression group of its own. For this reason, it is generally a good idea to get into the habit of using the parenthesized expression template described below, which automatically inserts the extra expression group.

Parenthesized expression group

Parenthesized Expression — inserts a parenthesized expression template. This is just an expression group with two parentheses pre-entered.

Borders and Strikethroughs — adds borders, strikethroughs, and other bounding objects (radical, long division, etc.) around data. For more information, see Borders and strikethroughs.

Space-like

MSpace — inserts an mspace element. This also brings up a dialog for changing the default attributes of the mspace.

The Insert em space dialog.

The fields in this dialog correspond to attributes of the mspace element. Each field accepts one MathML size value. Note the default value is 0 for all three attributes, so even though a percentage is an admissible value, it will have no effect.

MPhantom — inserts an mphantom template. The mphantom element represents a space of the same dimensions as the expression it wraps. MPhantom has special behaviors when used in the editor:

  1. When the cursor is in the mphantom context, the contents of mphantom show up in light grey. When the cursor is moved out, the mphantom becomes invisible again.
  2. When the mouse is over the mphantom, its contents show up in light grey and the status line says "Please click on the grey text to edit the MPhantom element." When the mouse is out of the mphantom, it becomes invisible again and the statusline message disappears.
  3. When the cursor is inside the mphantom context, it stays visible even if the mouse is moved out of it. It becomes invisible when the mouse is clicked somewhere else.

The contents of an MPhantom element are gray when the mouse pointer is over it.

Scripts

There are 7 script templates available through the Scripts flyout of the Insert menu.

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.

Symbol

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.

You can insert a symbol by its name.

Unicode

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

You can insert a symbol by its Unicode value.

Hexadecimal 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.

Inserting combining diacritical marks

The characters with numerical codes in the blocks 0x0300-0x036F and 0x20D0-0x20FF are combining marks. This means rather than being displayed as characters by themselves they are attached to the previous character and (in most cases) displayed on top of it. For example, a "combining long solidus overlay" (code 0x0338) can be used after an equal sign (=). The result displayed is a negated equal sign; the solidus is superimposed on the =. (Of course there's already a symbol for not equal, but this illustrates a use of combining diacritical marks.)

Inserting a combining diacritical mark over an equal sign with the Insert Symbol dialog.

These characters can be inserted from the Insert Symbol dialog or from a palette present in the default toolbar file, but because of their special nature, MathFlow handles them a little differently than the rest of the characters:

  • Combining characters are only added to the data of an existing token element (an mi, mn, mo or mtext), and only after a regular character that's already in place.
  • Once in place, the pair of normal and following combining characters are treated as a single character: it is impossible to step in between them, or insert new characters between them. The example above looks like this in the MathML code: <mo>=&#x0338;</mo>
  • When trying to delete a combining pair, either from the left (via delete) or from the right (via Backspace) the combining character is deleted first, leaving just the normal character.
  • Only one combining character is allowed per normal character. If you attempt to insert more than one, all the ones after the first one are ignored.

See the Combining diacritical marks and Diacritical marks for symbols tables in the Programmer Documentation section for a list of characters.

Table

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.)

Inserting a 3 by 4 table in MathFlow.

Actions

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.)
    Applying a Toggle Action with MathFlow.
    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.