This is documentation for Mathematica 8, which was
based on an earlier version of the Wolfram Language.
View current documentation (Version 11.2)

Defining Output Formats

Just as Mathematica allows you to define how expressions should be evaluated, so also it allows you to define how expressions should be formatted for output. The basic idea is that whenever Mathematica is given an expression to format for output, it first calls Format[expr] to find out whether any special rules for formatting the expression have been defined. By assigning a value to Format[expr] you can therefore tell Mathematica that you want a particular kind of expression to be output in a special way.
This tells Mathematica to format objects in a special way.
Click for copyable input
Now objects are output to look like binomial coefficients.
Click for copyable input
Internally, however, objects are still exactly the same.
Click for copyable input
Format[expr1]:=expr2define to be formatted like
Format[expr1,form]:=expr2give a definition only for a particular output form

Defining your own rules for formatting.

By making definitions for Format, you can tell Mathematica to format a particular expression so as to look like another expression. You can also tell Mathematica to run a program to determine how a particular expression should be formatted.
This specifies that Mathematica should run a simple program to determine how objects should be formatted.
Click for copyable input
The strings are created when each is formatted.
Click for copyable input
Internally, however, the expression still contains objects.
Click for copyable input
Prefix[f[x],h]prefix form
Postfix[f[x],h]postfix form
Infix[f[x,y,...],h]infix form
Prefix[f[x]]standard prefix form
Postfix[f[x]]standard postfix form
Infix[f[x,y,...]]standard infix form
PrecedenceForm[expr,n]an object to be parenthesized with a precedence level n

Output forms for operators.

This prints with represented by the "prefix operator" .
Click for copyable input
Here is output with the "infix operator" .
Click for copyable input
By default, the "infix operator" is assumed to have "higher precedence" than , so no parentheses are inserted.
Click for copyable input
When you have an output form involving operators, the question arises of whether the arguments of some of them should be parenthesized. As discussed in "Special Ways to Input Expressions", this depends on the "precedence" of the operators. When you set up output forms involving operators, you can use PrecedenceForm to specify the precedence to assign to each operator. Mathematica uses integers from 1 to 1000 to represent "precedence levels". The higher the precedence level for an operator, the less it needs to be parenthesized.
Here is treated as an operator with precedence . This precedence turns out to be low enough that parentheses are inserted.
Click for copyable input
When you make an assignment for Format[expr], you are defining the output format for expr in all standard types of Mathematica output. By making definitions for Format, you can specify formats to be used in specific output forms.
This specifies the TeXForm for the symbol .
Click for copyable input
The output format for that you specified is now used whenever the TeX form is needed.
Click for copyable input