Wolfram Function Repository
Instant-use add-on functions for the Wolfram Language
Function Repository Resource:
Change the output style for any kind of expression
| ResourceFunction["SetDisplayStyle"][patt,opts] causes future output that matches pattern patt to be styled with options opts. | |
| ResourceFunction["SetDisplayStyle"][patt,xform,opts] causes future xform output that matches pattern patt to be styled with options opts. | 
Make all negative numbers format in red:
| In[1]:= | ![ResourceFunction["SetDisplayStyle"][x_ /; x < 0, FontColor -> Red]](https://www.wolframcloud.com/obj/resourcesystem/images/6d4/6d411b13-88f5-4b37-94a8-9e98f90773b2/432ea2501364a70a.png) | 
| In[2]:= | ![RandomReal[{-1, 1}, 20]](https://www.wolframcloud.com/obj/resourcesystem/images/6d4/6d411b13-88f5-4b37-94a8-9e98f90773b2/58e3493ab3c9145e.png) | 
| Out[2]= |  | 
Set a specific symbol display at a specific size and in italic:
| In[3]:= | ![ResourceFunction["SetDisplayStyle"][y, FontSize -> 30, FontSlant -> Italic]](https://www.wolframcloud.com/obj/resourcesystem/images/6d4/6d411b13-88f5-4b37-94a8-9e98f90773b2/71ff12de835b3293.png) | 
| In[4]:= |  | 
| Out[4]= |  | 
Cause lists of length 2 and length 3 to have different background colors:
| In[5]:= | ![ResourceFunction["SetDisplayStyle"][{_, _}, Background -> LightBlue];](https://www.wolframcloud.com/obj/resourcesystem/images/6d4/6d411b13-88f5-4b37-94a8-9e98f90773b2/205c494146715cfd.png) | 
| In[6]:= | ![ResourceFunction["SetDisplayStyle"][{_, _, _}, Background -> LightYellow];](https://www.wolframcloud.com/obj/resourcesystem/images/6d4/6d411b13-88f5-4b37-94a8-9e98f90773b2/7b4ad82e6469ed5d.png) | 
| In[7]:= |  | 
| Out[7]= |  | 
You can unset styles by using SetDisplayStyle again with no style options:
| In[8]:= | ![ResourceFunction["SetDisplayStyle"][y]](https://www.wolframcloud.com/obj/resourcesystem/images/6d4/6d411b13-88f5-4b37-94a8-9e98f90773b2/676045c6d7163bce.png) | 
| In[9]:= |  | 
| Out[9]= |  | 
Only StandardForm output is affected by default:
| In[10]:= | ![ResourceFunction["SetDisplayStyle"][x_ /; x < 0, FontColor -> Red]](https://www.wolframcloud.com/obj/resourcesystem/images/6d4/6d411b13-88f5-4b37-94a8-9e98f90773b2/2af9747ad55f6f93.png) | 
| In[11]:= | ![data = RandomReal[{-1, 1}, {4, 4}]](https://www.wolframcloud.com/obj/resourcesystem/images/6d4/6d411b13-88f5-4b37-94a8-9e98f90773b2/0c4f7235d2a907e9.png) | 
| Out[11]= |  | 
| In[12]:= | ![TraditionalForm[data]](https://www.wolframcloud.com/obj/resourcesystem/images/6d4/6d411b13-88f5-4b37-94a8-9e98f90773b2/63c1b327ee62faa5.png) | 
| Out[12]= |  | 
You can set display styles for TraditionalForm by using TraditionalForm as the second argument of the three-argument form:
| In[13]:= | ![ResourceFunction["SetDisplayStyle"][x_ /; x < 0, TraditionalForm, FontColor -> Red]](https://www.wolframcloud.com/obj/resourcesystem/images/6d4/6d411b13-88f5-4b37-94a8-9e98f90773b2/5fd9ea129bd5f69a.png) | 
| In[14]:= | ![TraditionalForm[data]](https://www.wolframcloud.com/obj/resourcesystem/images/6d4/6d411b13-88f5-4b37-94a8-9e98f90773b2/6ccb821a29015686.png) | 
| Out[14]= |  | 
This work is licensed under a Creative Commons Attribution 4.0 International License