In attempt to build a function that would work like MatrixForm
but would wrap a matrix with brackets, I tried the following function:
matrixform[mat_] := TraditionalForm[DisplayForm[RowBox[{
StyleBox["[", SpanMaxSize -> \[Infinity]],
GridBox[mat],
StyleBox["]", SpanMaxSize -> \[Infinity]]}]]]
This does what I want on an ordinary matrix, say a={{1,2},{3,4}}
, as well as on 2a
and a+a
. But if I pass in a product such as a.a
it does not work properly. I have tried wrapping the product in Evaluate
, and tried executing a.a
separately and then passing in %
and this has made no difference. Note that a better function Composition[bracketF,Grid]
suggested here lacks these issues. So the question is why can we not pass in a product of matrices into matrixform
? This is my first time working with functions such as StyleBox, GridBox, RowBox
, etc.