The Mathematica Journal
Volume 9, Issue 2


In This Issue
Tricks of the Trade
In and Out
Trott's Corner
New Products
New Publications
News Bulletins
New Resources

Download This Issue 

About the Journal
Editorial Policy
Back Issues
Contact Information

Tricks of the Trade
Edited by Paul Abbott


The default input and output FormatType is StandardForm. An easy way to define a new format is to use ParentForm. All rules are inherited from the ParentForm and new rules can be added and old rules overridden if desired. Here we extend StandardForm to ExtendedStandardForm.

There are several acts of "registration" needed to add a new FormatType so that it works in input cells in the front end:

1. Define the ParentForm of ExtendedStandardForm in the kernel.

2. Augment $BoxForms in the kernel.

3. Augment the front end's menu of box forms.

The new ExtendedStandardForm format appears under the appropriate categories of the Cell menu.

4. Add a new cell style for ExtendedStandardForm.

Since the ParentForm of ExtendedStandardForm is StandardForm, make a copy of the StandardForm cell style definition, rename it ExtendedStandardForm, and put it in the FormatType Styles section of the notebook's style sheet. I have modified this cell's style definition by coloring it red.

5. Make ExtendedStandardForm your default input and output format via Default Input FormatType and Default Output FormatType under the Cell menu.

Presently StandardForm and ExtendedStandardForm are identical, apart from the coloring of input and output.

6. Add or modify formatting rules in ExtendedStandardForm.

Suppose that you would like to automatically interpret mappings, , as Mathematica functions, f := Function[x, y]. To do this, add a formatting rule to ExtendedStandardForm using the Utilities`Notation` package.

This definition is now part of ExtendedStandardForm. We also add an input alias to simplify entering this notation.

Now, if you type in an input cell you obtain . Using this alias, enter the map , moving between placeholders via the key.

After entering this cell, things work as expected.

If we duplicate the above cell containing the definition of f and then do CellRightTriangleConvert ToRightTriangleStandardForm, we obtain the StandardForm representation of this cell.

Alternatively, if we enter a function using Function notation, say f := Function[x, Sin[x]/x], select the cell, and then do CellRightTriangleConvert ToRightTriangleExtendedStandardForm, we obtain the ExtendedStandardForm representation of this function.

7. Restore the default input and output formats via the Cell menu.

8. Restore the front end box forms using SetOptions.

About Mathematica | Download Mathematica Player
Copyright © Wolfram Media, Inc. All rights reserved.