# How can I get matrices and text to show up in the same table with MatrixForm?

I'd like to be able to display matrices in the usual written MatrixForm in a table alongside text (or anything that isn't a matrix). Here is an example:

Clear[a, b, c, α, β, γ];
g = {{a^2, a*b*Cos[γ], a*c*Cos[β]}, {b*a*Cos[γ], b^2, b*c*Cos[α]}, {c*a*Cos[β], c*b*Cos[α], c^2}}; MatrixForm[g]
Clear[a, b, c, α, β, γ];
c = b = a; γ = β = α = 90*(Pi/180); g1…cubic = g;
Clear[a, b, c, α, β, γ];
b = a; γ = β = α = 90*(Pi/180); g2…tetragonal = g;
Clear[a, b, c, α, β, γ];
γ = β = α = 90*(Pi/180); g3…orthorhombic = g;
Clear[a, b, c, α, β, γ];
b = a; β = α = 90*(Pi/180); γ = 120*(Pi/180); g4…hexagonal = g;
Clear[a, b, c, α, β, γ];
γ = α = 90*(Pi/180); g5…monoclinic = g;
Clear[a, b, c, α, β, γ];
c = b = a; γ = β = α; g6…rhombohedral = g;
Clear[a, b, c, α, β, γ];
g7…triclinic = g;
crystalsystemnames = {"Cubic", "Tetragonal", "Orthorhombic", "Hexagonal", "Monoclinic", "Rhombohedral", "Triclinic"};
metrictensors = Partition[{g1…cubic, g2…tetragonal, g3…orthorhombic, g4…hexagonal, g5…monoclinic, g6…rhombohedral, g7…triclinic},
1];
MatrixForm[data, TableHeadings -> {None, {"Metric Tensor"}}]


This nearly produces the desired result, but the matrices within the table aren't displayed in Matrix Form:

This sounds like an easy fix, by just using MatrixForm earlier.

MatrixForm[metrictensors]


However, combining these methods doesn't work. This produces a MapThread error:

data = MapThread[Append, {MatrixForm[metrictensors], crystalsystemnames}]


I can display the matrices horizontally after which MapThread no longer computes:

Apply[MatrixForm, metrictensors, {1}]


ref/MatrixForm and ref/TableForm don't seem to have a combination example. Is there a way to do this?

• A simple approach is to use TraditionalForm, e.g., MatrixForm[data, TableHeadings -> {None, {"Metric Tensor"}}] //TraditionalForm Sep 18, 2021 at 0:58

crystalsystemnames = {"Cubic", "Tetragonal", "Orthorhombic",
"Hexagonal", "Monoclinic", "Rhombohedral", "Triclinic"};

metrictensors = Partition[{g1, g2, g3, g4, g5, g6, g7}, 1];

MatrixForm[MapAt[MatrixForm, data, {All, 1}], TableHeadings -> {None, {"Metric Tensor"}}]


Alternatively,

data2 = MapThread[Append[{MatrixForm @ #}, #2] &,
{{g1, g2, g3, g4, g5, g6, g7}, crystalsystemnames}];

MatrixForm[data2, TableHeadings -> {None, {"Metric Tensor"}}]

same picture


Note: I replaced gi...stuff with gi in your code.