I have a 2D matrix, such as:
d=2;
M=Array[a, {d^2,d^2}];
and I would like to print it in a way which emphasizes its dxd block matrix structure. If MatrixForm had a Dividers option like Grid, then this is what I would use. But it doesn't. The first thing I tried was:
With[
{div={False, Join[Table[False, {n, d - 1}], {Dashed}], False}},
{{Grid[M,Dividers->{div,div}]}}//MatrixForm
]
where the {{stuff}}//MatrixForm is simply to get the parentheses.
The problem with this is that if your matrix is big (d>2) and certain entries of your matrix are big expressions, then they do an ugly line wrap thing. To counter this, I call {{TableForm[#]}}& on each element of the matrix first:
With[
{div = {False,Join[Table[False, {n, d - 1}], {Dashed}],False}},
{{
Grid[Map[TableForm[{{#}}] &, M, {2}],Dividers -> {div, div}]
}} // MatrixForm
]
but this is a hack. So I suppose my questions are:
What Form do TableForm and MatrixForm use on each of their elements, and can I use this here? I've tried StandardForm but that's not it.
Next, is there in general some better way to do what I am trying to do?
Edit: As requested, here is an example that illustrates the "ugly line wrap thing":
d = 3;
M = Table[Expand[(a + b)^RandomInteger[4]], {i, d^2}, {j, d^2}];