MathFlow toolbar definition language

Overview, language constructs

The MathFlow toolbar configuration language is an XML vocabulary for describing the arrangement of templates, symbols, and pull-down palettes. The language is very simple, with just six tags and five attributes. However, there are several hundred keywords for pre-defined palettes, symbols and templates. Note in most cases the toolbar configuration language expects names of characters rather than true entity references, i.e., <btn>alpha</btn> instead of <btn>&alpha;</btn>. The following sections describe the tags, their attributes, and examples of their usage.

Toolbar definition language attributes

tb element

The tb element is the top-level wrapper for a complete toolbar description. Every configuration description consists of a single tb element.

Attributes

namepermitted values
size [s | l | w | ws] (default l)

Specifying size=s indicates that all buttons on the toolbar and pull-down palettes should be the small size, unless otherwise indicated. Similarly, size=l (lowercase L) indicates buttons should be large, size=w should be wide, and size=ws should be wide and small.

Examples

<tb><btn>alpha</btn><incl name='#toolbox'/></tb>

large toolbar with an included sub-toolbar

<tb size='s'><btn>alpha</btn><incl name='#toolbox'/></tb>

small toolbar with an included sub-toolbar

row element

The row element is the top-level wrapper for a toolbar row description. Every row description consists of a single row element, which may be inferred if the toolbar has only 1 row. Each row element is a child only of the tb element.

Attributes

namepermitted values
size[s | l | w | ws] (default l)

Specifying size=s indicates that all buttons on the toolbar and pull-down palettes should be the small size, unless otherwise indicated. Similarly, size=l (lowercase L) indicates buttons should be large, size=w should be wide, and size=ws should be wide and small.

btn element

The btn element is used to place a button on the toolbar. The contents of the element determine the image that will appear on the button and what it does. The contents of a btn element can be:

  1. Any single Unicode character supported by MathFlow, e.g., A, b, 3, etc.
  2. Any single MathML character name supported by MathFlow, e.g., alpha, otimes, infin, etc.
  3. A quote delimited run of Unicode characters supported by MathFlow, e.g. "sin", "Airy", etc.
  4. Any predefined template name.
  5. Any predefined icon name.
  6. A valid MathML string.

Consult the tables of predefined Templates, Palettes, Palette Labels, and MathFlow characters for a complete listing.

When a character or character name is given as the content of the btn element, a button is created displaying that character. When clicked, the button inserts the same character at the current cursor location.

  • When a pre-defined template name is given, a button is created displaying a graphic representation of the template, and clicking inserts the corresponding template at the current cursor location.
  • When an icon name is given, a button is placed on the toolbar displaying the named image. In the case of toolbox icons, the button is associated with the corresponding editor action, i.e., cut, paste, etc. However, when a non-toolbox icon name is given, i.e., "TRIGPALETTE," a button without any default action is created. Normally, one only uses these icons when creating a button to open a pull-down palette using the sub element (see below).
  • When MathML is given, an image of the corresponding typeset mathematical expression is generated and placed on the button. Unless the optional insertas element is used, the same MathML is inserted into the editor.
  • If a button name is not recognized, the toolbar parser will indicate the problem by creating a button displaying a red "X".

When the imagesrc attribute is present, the image indicated will be used for the button face, regardless of the element's content. The action for the button is identical to what it would be without the attribute. The image will be scaled and centered on the button.

Attributes

namepermitted values
type [mi | mn | mo]
cue text string
imagesrc a path relative to the CLASSPATH

When creating a button to insert a character, there is an issue of what MathML code to generate. Some characters can be used as identifiers, numbers or operators, and thus should be tagged with the MI, MN, and MO MathML elements respectively. MathFlow tries to guess according to the following rules:

  • If the character is in the MathFlow operator dictionary, it tags it as an MO.
  • If it is a digit, it tags it as an MN.
  • Otherwise, characters are treated as MI.

By specifying a type attribute on a btn element, you can override this default behavior, and specify which element you would like to have generated.

Similarly, MathFlow displays a default status line message when a reader mouses over a button on the toolbar. For characters, this default message is just the character name. For other icons and templates, the default message varies. By giving a cue attribute, you can specify your own status line message to be displayed when mousing over the button.

Children

namecontents
insertas (optional) MathML string

When using a MathML string for a button, you can differentiate the MathML used to display an image on the button from the MathML that is inserted into the editor. This allows you to "tweak" the MathML to appear correctly depending on where it is displayed. The content of the btn element indicates the MathML to be displayed on the button. The optional child element insertas indicates the MathML to be inserted into the editor.

Examples

<tb><btn>A</btn><btn>alpha</btn><btn>FRAC</btn><btn>CUT</btn></tb>

Example puts buttons for 2 characters, a template, and an icon on the toolbar.

<tb><btn type='mn'>I</btn><btn type='mn'>V</btn>
    <btn type='mn'>X</btn><btn type='mn'>L</btn><btn type='mn'>C</btn></tb>

Example puts buttons for 5 Roman numerals on the toolbar.

<tb><btn cue='force'>F</btn><btn cue='mass'>m</btn>
    <btn cue='velocity'>v</btn></tb>

Example puts 3 buttons on the toolbar, all of them with tooltips.

<tb>
  <btn cue='Subscript (Ctrl+B)'>
    <math><msub><mi>&template;</mi><mi>&template;</mi></msub></math>
    <insertas>
      <math><msub><template/><template/></msub></math>
    </insertas>
  </btn>
</tb>

Example puts a button on the toolbar for a subscript template. It's defined with MathML, and inserted with different MathML.

sub element

The sub element is used to create a pull-down palette. The sub tags enclose the buttons and sub-palettes which are to be placed on the palette.

The sub element binds the pull-down palette to the button immediately preceding it. Note that if there is no preceding button, the palette created won't be attached to anything and won't be accessible.

Attributes

namepermitted values
size[s | w | ws]
colspositive number

The sub element accepts the same size attribute as the tb element, with the same effect. Giving a value of "s" indicates that all the buttons on the pull-down palette should be small, "w" indicates they should all be wide, and "ws" indicates they should be wide and small.

Small buttons usually work well for symbol palettes, while wide buttons work better for templates. Note that all characters, templates and icons on a toolbar are drawn at a common scale. If you put a wide expression in a small button, the magnification factor will be so small that many of the other buttons images will be too small to read. Thus, it is usually best to try to pick appropriate button sizes for their contents.

The cols attribute specifies how many columns wide the created pull-down palette will be. MathFlow automatically places the buttons left to right and top to bottom on the palette regardless of the number of columns, and fills any empty space in the last row.

Examples

<tb><btn>A</btn><sub><btn>FRAC</btn></sub></tb>

A palette labeled "eh" was added to the toolbar, with a single template inside the pulldown.

<tb><btn>TRIGPALETTE</btn><sub size='w'><btn>COS</btn>
    <btn>SIN</btn><btn>theta</btn></sub></tb>

A named button, TRIG PALETTE, was added to the toolbar, with 3 buttons inside.

<tb><btn>TRIGPALETTE</btn><sub size='w' cols='2'><btn>COS</btn>
    <btn>SIN</btn><btn>theta</btn><btn>pi</btn></sub></tb>

A named button, TRIG PALETTE, was added to the toolbar, with 2 buttons on 2 rows inside the palette.

sep element

The sep element is an empty element which creates a vertical separator on the toolbar or pull-down palette. This is useful for visually grouping similar items on a toolbar or palette.

Attributes

None.

Example

<tb><btn>FRAC</btn><btn>SUP</btn><btn>SQRT</btn><sep/>
    <btn>infin</btn><btn>angle</btn><btn>theta</btn></tb>

6 buttons have been added to the toolbar, with a separator between buttons 3 and 4.

incl Element

The incl element inserts a pre-defined toolbar component at that location in the configuration description. In effect, this element works like a bare-bones macro capability, with a collection of pre-defined macros that expand before processing.

Consult the table of pre-defined Templates and Palettes for a complete listing of pre-defined components. Most of them are complete pre-defined pull-down palettes, such as a trig palette, Greek letter palettes, and so on. Several complete toolbars are also pre-defined.

Pre-defined component names all begin with a "#" character.

Attributes

namepermitted values
namepre-defined label

The incl is an empty element; the pre-defined component to insert is specified by the name attribute. If the value is unrecognized, the include is ignored by MathFlow.

Example

<tb><btn>LCGREEKPALETTE</btn><sub size='s'><incl name='#greek'/></sub><sep/>
    <btn>TOOLBOX</btn><sub cols='3' size='s'><incl name='#toolbox'/></sub></tb>

Two predefined buttons were added to the palette, each of them including a predefined toolbar component.

Complete toolbars

Use these keywords with the incl element to insert pre-defined components in a toolbar. For an explanation of how to use the incl element, see the documentation on the toolbar definition language constructs.

#standard
Toolbar -- standard
#extrasymbols
Toolbar -- extra symbols
#basic
Toolbar -- basic
#websafe
Toolbar -- web safe

Palettes

Use these keywords with the incl element to insert pre-defined components in a toolbar. For an explanation of how to use the incl element, see the documentation on the toolbar definition language constructs.

#layout layout #accents accents palette
#combiningCommon common combining marks #combiningOther other combinnig marks
#fences fence templates #matrix matrix templates
#trig trig symbols and templates #calculus calculus palette
#arrows arrow symbols #operators operator palette
#relations relational symbols #settheory set theory symbols
#greek lower case Greek #Greek upper case Greek
#logic logic symbols #dots dots palette
#variants variants #exarr extra arrows
#exrel extra relations #equiv equivalence operators
#exop extra operator symbols #triangles triangles palette
#boxes boxes palette #dashes dashes palette
#basicops basic operators palette #basicrelns basic relations
#mixedsym mixed symbols #mixedops mixed operators
#intcalc integral calculus #diffcalc differential calculus
#veccalc vector calculus #invisiblechars invisible characters
#toolboxtoolbox palette

Palette labels

LAYOUTPALETTE layout
FENCEPALETTE fences
COMMONCOMBININGPALETTE common combining palette
OTHERCOMBININGPALETTE other combining palette
ACCENTPALETTE Accent palette
TRIGPALETTE trig palette
MATRIXPALETTE matrices
CALCPALETTE calculus
DERIVATIVEPALETTE derivatives
INTEGRALPALETTE integrals
VECTORCALCPALETTE vector calculus
LOGICPALETTE logic
RELATIONPALETTE relations
OPERATORPALETTE operators
SYMBOLPALETTE symbols
LCGREEKPALETTE lower case Greek
UCGREEKPALETTE upper case Greek
ARROWPALETTE arrows
SETTHEORYPALETTE set theory
DOTPALETTE dots
VARIANTPALETTE vraiants
EXARRPALETTE extra arrows
EQUIVPALETTE equivalence symbols
EXRELPALETTE extra relational symbols
EXOPPALETTE extra operators
TRIANGLEPALETTE triangles
BOXPALETTE boxes
DASHPALETTE dashes
INVISIBLECHARSPALETTE invisible characters

Templates

FRAC fraction SQRT square root
ROOT enth root SUB subscript
SUP superscript SUBSUP subscript and superscript
PRESUB subscript before the base PRESUP superscript before the base
PRESUBSUP subscript and superscript before the base UNDER underscript
OVER overscript UNDEROVER under/overscript
MAKEMROW insert an mrow MAKEMSTYLE insert an mstyle
MAKEMTEXT insert plain text PARENS parentheses
BRACKETS brackets BRACES braces
ANGLES angle brackets ABSBARS absolute value
CEILS ceiling bars FLOORS floor bars
NORMBARS norm bars BAR overbar (line segment)
RAY ray VEC vector
PRIME prime DOT dot
DDOT double dot TILDE tilde
HAT hat LINE line
CUB curvy upper brace CLB curvy lower brace
UBAR under-bar TBRK top bracket
BBRK bottom bracket SIN sine
COS cosine TAN tangent
SEC secant CSC cosecant
COT cotangent ARCCOS arccos
ARCSIN arcsin ARCTAN arctangent
LOGBASE log base
MATRIX1X2 1 by 2 matrix MATRIX2X1 2 by 1 matrix
MATRIX2X2 2 by 2 matrix MATRIX3X3 3 by 3 matrix
MATRIXNXM N by M matrix DDX d-dx
DELDELX partial d-partial dx INDEFINT indefinite integral
DEFINT definite integral SUM summation with upper and lower limits
LOWSUM summation with condition PROD product with lower and upper limits
LOWPROD product with codition LIMIT limit
DIV divergence GRAD gradient (nabla)
CURL curl THINSPACE thin space
THINNEGSPACE thin negative space INVISIBLETIMES invisible times
APPLYFUNCTION function application CUT cut
COPY copy PASTE paste
UNDO undo BIGGER bigger (zoom in)
SMALLER smaller (zoom out) HELP help
CHECKSYNTAX check syntax TOOLBOX toolbox

Palettes toolbar

The Palettes toolbar comprises the top 2 rows of the MathFlow Structure Editor.

The Palettes toolbar has the following qualities:

  • Allows multiple toolbars with various button sizes, which can be configured with the configuration files.
  • A user can load a custom Palettes toolbar.
  • The Palettes toolbar can be hidden or shown via a View menu.
  • The top level <tb> element contains one or more <row> elements which define each row of the toolbar.
    • Vertical position is defined by the order of <row> elements.
    • If your toolbar has only one row, you can omit the <row> element since it is inferred.

Tabbed toolbar (Structure Editor only)

The Palettes toolbar comprises the row of buttons beneath the palettes toolbar on the MathFlow Structure Editor.

The Tabbed toolbar has the following qualities:

  • A user can select an expression and drag onto the current tabbed toolbar to add a new custom button. To delete a button, you can choose Delete from the contextual menu, or edit the toolbar configuration file.
  • To insert the button content at the insertion point, either click the button or right-click and choose Insert.
  • In order to save a toolbar on which you've added custom expressions, choose: Toolbar > Tabbed Toolbar > Save Current Toolbar As.
  • A user can save a Tabbed toolbar under a different name.
  • A user can load a custom Tabbed toolbar.
  • To return to factory default settings, choose Toolbar > Tabbed Toolbar > Standard.
  • To save a separate copy of the Standard toolbar, save a new copy of it: Toolbar > Tabbed Toolbar > Save Current Toolbar As.
  • The Tabbed toolbar can be hidden or shown via the View menu.
  • The toolbar Configuration Language has been extended to allow the definition of multiple tabs for the tabbed toolbar:
    • The top level element <tb> contains one or more <tab> elements.
    • Horizontal position is defined by the order of <tab> elements.
  • There are 7 pre-defined tabs and 2 undefined tabs, all of which can be customized:
    • Algebra
    • Derivs
    • Statistics
    • Matrices
    • Sets
    • Trig
    • Geometry
    • Tab8
    • Tab9
  • To change the tab names, first save the toolbar, then edit the toolbar configuration file.

Mini toolbar

Mini toolbar

The mini toolbar is combined on the same line as the MathML ancestry. Included on the mini toolbar are:

  • Style selector. Choose between MathFlow's 12 pre-defined logical styles, such as sans-serif and script. If you're using Structure Editor and have defined a custom style, you may choose this style from the style selector as well. Default is inherited, which inherits the style from the parent node on the expression tree.
  • Nine "utility" command buttons. Included are:
    • Configure Styles (Structure Editor only)
    • Undo
    • Cut
    • Copy
    • Paste
    • Verify (check syntax)
    • Magnify (zoom in)
    • Shrink (zoom out)
    • Help

Here's an extended example showing a toolbar customized for calculus…

MathFlow editor with custom toolbar customized for calculus.

Here's the configuration string for the toolbar:

<tb>
   <btn>LAYOUTPALETTE</btn>
   <sub>
      <btn>FRAC</btn>
      <btn>SUP</btn>
      <btn>SQRT</btn>
      <btn>ROOT</btn><btn>PARENS</btn><btn>ABSBARS</btn>
      <btn>NORMBARS</btn><btn>BAR</btn>
   </sub>
   <btn>SYMBOLPALETTE</btn>
   <sub><incl name="#mixedsym"/></sub>
   <btn>OPERATORPALETTE</btn>
   <sub cols=3>
      <btn>plus</btn><btn>minus</btn><btn>times</btn><btn>divide</btn>
      <btn>plusmn</btn><btn>lt</btn><btn>gt</btn><btn>leq</btn>
      <btn>geq</btn><btn>cup</btn><btn>cap</btn><btn>in</btn>
      <btn>rarr</btn><btn>subset</btn><btn>compfn</btn>
   </sub>
   <sep/>
   <btn>DERIVATIVEPALETTE</btn>
   <sub cols=3>
      <btn>DDX</btn><btn>DELDELX</btn><btn>LIMIT</btn>
      <btn>PRIME</btn><btn>DOT</btn><btn>DDOT</btn>
   </sub>
   <btn>INTEGRALPALETTE</btn>
   <sub cols="3">
      <btn>INDEFINT</btn><btn>DEFINT</btn><btn>SUM</btn>
      <btn>LOWSUM</btn><btn>PROD</btn><btn>LOWPROD</btn>
   </sub>
   <btn>VECTORCALCPALETTE</btn>
   <sub cols="3">
      <btn>VEC</btn><btn>times</btn><btn>middot</btn>
      <btn>DIV</btn><btn>GRAD</btn><btn>CURL</btn>
   </sub>
   <sep/>
   <btn>CUT</btn><btn>COPY</btn><btn>PASTE</btn>
   <btn>UNDO</btn><btn>BIGGER</btn><btn>SMALLER</btn>
   <sep/>
   <btn>HELP</btn>
</tb>