Is there a way to ensure that every time I perform an operation such as RowReduce, Linear Solve, Null Space, Inverse, Eigenvectors, etc. that the matrix is displaying in MatrixForm instead of applying the postfix form of MatrixForm every time (//MatrixForm)? For example, is there a variable in the Option Inspector to set the default form of an array? I checked but couldn't find anything of the sort. If not, I am going to make a feature request for a future release of Mathematica.
3 Answers
$\begingroup$
$\endgroup$
1
You can use $PrePrint
:
$PrePrint = If[MatrixQ @ #, MatrixForm @ #, #] &;
Array[x, {4, 5}]
{{a, b}, {x, y}}
SeedRandom[1];
rm = RandomInteger[10, {5, 5}]
N @ Eigenvectors[rm]
-
1$\begingroup$ How do create a global matrix preprint setting? It reverts back after I close the kernel. $\endgroup$ Commented Dec 1, 2021 at 1:20
$\begingroup$
$\endgroup$
3
An alternative is to teach StandardForm
about your desired formatting:
Unprotect[StandardForm];
StandardForm /: MakeBoxes[l_List, StandardForm] /; MatrixQ @ Unevaluated @ l := MakeBoxes[MatrixForm[l]]
Protected[StandardForm];
-
$\begingroup$ Is this to be applied in a notebook or init.m? $\endgroup$ Commented Dec 6, 2021 at 20:14
-
-
$\begingroup$ My init.m changes are undone after I restart. How do I make permanent modifications? $\endgroup$ Commented Dec 6, 2021 at 20:27
$\begingroup$
$\endgroup$
2
Here's how to automatically view two-dimensional arrays in matrix form using the Option Inspector to change from StandardForm to TraditionalForm.
- Launch Mathematica.
- On the Mathematica main menu, select Mathematica > Settings...
- Click on the Advanced tab.
- Click on the Open Option Inspector button.
- In the Options column, open Cell Options > New Cell Defaults > CommonDefaultFormatTypes.
- Within the CommonDefaultFormatTypes folder, find the word "Output." Click to the far left of the word "Output" (near the left edge of the dialog box in the Set column).
- To the right of the word "Output", double-click on the words StandardForm and replace them with the words TraditionalForm
- Press the enter key.
- Close all open dialog boxes. This change should now be permanent in future sessions for the current user.
This procedure worked for me with Mathematica 13.1 and is a very slightly updated version of the following link.
-
$\begingroup$ Please include the detailed procedure in your answer rather than relying on the link, which eventually will break. $\endgroup$– MarcoBCommented Mar 17 at 11:23
-
$\begingroup$ Thanks. Made the change you requested. $\endgroup$ Commented Mar 18 at 19:11