Wolfram Research

Function Repository Resource:

SetOutputFormCellLabels

Source Notebook

Set up custom cell labels for a formatting function

Contributed by: Wolfram Staff

ResourceFunction["SetOutputFormCellLabels"][f,expr1,expr2,]

use expri in output cell labels for the output form function f.

ResourceFunction["SetOutputFormCellLabels"][f]

restore the default cell labels for f.

Details and Options

In ResourceFunction["SetOutputFormCellLabels"][f,], f must be a member of $OutputForms.
The values of expri replace the default expression head //f in output cell labels.

Examples

Basic Examples

Replace the output form name with a custom string:

In[1]:=
ResourceFunction[
 "SetOutputFormCellLabels"][InputForm, "//", "myInputForm"]
In[2]:=
1 // InputForm
Out[2]=

Restore the default formatting of cell labels:

In[3]:=
ResourceFunction["SetOutputFormCellLabels"][InputForm]
In[4]:=
1 // InputForm
Out[4]=

Use time stamps in labels:

In[5]:=
ResourceFunction["SetOutputFormCellLabels"][InputForm, "(", DateString[], ")"]
In[6]:=
1 // InputForm
Out[6]=
In[7]:=
2 // InputForm
Out[7]=

Restore the default:

In[8]:=
ResourceFunction["SetOutputFormCellLabels"][InputForm]

Scope

Use a custom string in cell labels:

In[9]:=
ResourceFunction["SetOutputFormCellLabels"][InputForm, " my label"]
In[10]:=
1 // InputForm
Out[10]=

Use an output of a function in labels:

In[11]:=
ResourceFunction["SetOutputFormCellLabels"][InputForm, " ", Date[]]
In[12]:=
1 // InputForm
Out[12]=

Restore the default:

In[13]:=
ResourceFunction["SetOutputFormCellLabels"][InputForm]

Applications

Displaying Timings

Create a dummy output form that applies no special formatting:

In[14]:=
TimingForm /:
 MakeBoxes[TimingForm[e_], form_] := MakeBoxes[e, form]
In[15]:=
Unprotect[$OutputForms]; AppendTo[$OutputForms, TimingForm];

Store the absolute time when the evaluation of an input expression started:

In[16]:=
$Pre = Function[x, $start = AbsoluteTime[]; x, HoldFirst];

Let the cell label display the difference between the time when the evaluation started and when the cell label is constructed after the evaluation:

In[17]:=
ResourceFunction["SetOutputFormCellLabels"][TimingForm, " (", AbsoluteTime[] - $start, " sec)"]

The cell label displays the wall-clock timing:

In[18]:=
Pause[.1]; 2 + 2 // TimingForm
Out[18]=

Restore the defaults:

In[19]:=
$Pre =.

Resource History

Related Resources

License Information