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 (2) 

Replace the output form name with a custom string:

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

Restore the default formatting of cell labels:

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

Use time stamps in labels:

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

Restore the default:

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

Scope (2) 

Use a custom string in cell labels:

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

Use an output of a function in labels:

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

Restore the default:

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

Applications (5) 

Displaying Timings (5) 

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

Restore the defaults:

In[19]:=
$Pre =.
In[20]:=
DeleteCases[$OutputForms, TimingForm]; Protect[$OutputForms];

Version History

  • 1.0.0 – 23 September 2019

Related Resources

License Information