StringOriented Output Formats

"text"a string containing arbitrary text

Text strings.

The quotes are not included in standard Wolfram System output form.
In[1]:=
Click for copyable input
Out[1]=
In input form, the quotes are included.

You can put any kind of text into a Wolfram Language string. This includes nonEnglish characters, as well as newlines and other control information. "Strings and Characters" discusses in more detail how strings work.

StringForm["cccc``cccc",x1,x2,]output a string in which successive are replaced by successive
StringForm["cccc`i`cccc",x1,x2,]output a string in which each `i` is replaced by the corresponding

Using format strings.

In many situations, you may want to generate output using a string as a "template", but "splicing" in various Wolfram Language expressions. You can do this using StringForm.

This generates output with each successive replaced by an expression.
In[3]:=
Click for copyable input
Out[3]=
You can use numbers to pick out expressions in any order.
In[4]:=
Click for copyable input
Out[4]=

The string in StringForm acts somewhat like a "format directive" in the formatted output statements of languages such as C and Fortran. You can determine how the expressions in StringForm will be formatted by wrapping them with standard output format functions.

You can specify how the expressions in StringForm are formatted using standard output format functions.
In[5]:=
Click for copyable input
Out[5]=

You should realize that StringForm is only an output format. It does not evaluate in any way. You can use the function ToString to create an ordinary string from a StringForm object.

StringForm generates formatted output in standard Wolfram System output form.
In[6]:=
Click for copyable input
Out[6]=
In input form, you can see the actual StringForm object.
This creates an ordinary string from the StringForm object.

StringForm allows you to specify a "template string", then fill in various expressions. Sometimes all you want to do is to concatenate together the output forms for a sequence of expressions. You can do this using Row.

Row[{expr1,expr2,}]give the output forms of the concatenated together
Row[list, s]insert s between successive elements
Spacer[w]a space of w points that can be used in Row
Invisible[expr]a space determined by the physical dimensions of expr

Output of sequences of expressions.

Row prints as a sequence of expressions concatenated together.
In[9]:=
Click for copyable input
Out[9]=
Row also works with typeset expressions.
In[10]:=
Click for copyable input
Out[10]=
Row can automatically insert any expression between the displayed elements.
In[11]:=
Click for copyable input
Out[11]=
Spacer can be used to control the precise spacing between elements.
In[12]:=
Click for copyable input
Out[12]=
Column[{expr1,expr2,}]a leftaligned column of objects
Column[list,alignment]a column with a specified horizontal alignment (Left, Center, or Right)
Column[list,alignment,s]a column with elements separated by s x-heights

Output of columns of expressions.

This arranges the two expressions in a column.
In[13]:=
Click for copyable input
Out[13]=
Defer[expr]give the output form of expr, with expr maintained unevaluated
Interpretation[e,expr]give an output which displays as e, but evaluates as expr

Output of unevaluated expressions.

Using text strings and functions like Row, you can generate pieces of output that do not necessarily correspond to valid Wolfram Language expressions. Sometimes, however, you want to generate output that corresponds to a valid Wolfram Language expression, but only so long as the expression is not evaluated. The function Defer maintains its argument unevaluated, but allows it to be formatted in the standard Wolfram System output form.

Defer maintains unevaluated.
In[14]:=
Click for copyable input
Out[14]=
The Defer prevents the actual assignment from being done.
In[15]:=
Click for copyable input
Out[15]=

When the output of Defer is evaluated again, which might happen by modifying the output or by using copy and paste, it will evaluate normally.

The following output was copied from the previous output cell into an input cell.
In[16]:=
Click for copyable input
Out[16]=

It is also possible to produce output whose appearance has no direct correlation to how it evaluates by using Interpretation. This method is effectively used by the Wolfram System when formatting some kinds of outputs where the most readable form does not correspond well to the internal representation of the object. For example, Series always generates an Interpretation object in its default output.

Although this output displays as , it will evaluate as .
In[17]:=
Click for copyable input
Out[17]=
Copying and pasting the previous output will reference the value earlier assigned to .
In[18]:=
Click for copyable input
Out[18]=