# Making the TableForm output into two columns

I have a program that calculates Christoffel symbols for a given metric, and the output I'm getting now is such that I have every calculated symbol in one column like this:

I'd like that I could have that in two columns:

1. \Gamma^1_2,3=... \Gamma^2_1,3= ...
2. \Gamma^1_3,2=... \Gamma^3_1,3= ...
3. \Gamma^2_2,2=... \Gamma^3_1,2= ...
4. ...

I looked at the documentation, and I tried something with that, but all I could do is to widen the spacing between \Gamma and the results -.-"

Here's thee code:

Clear[coord, metric, inversemetric, affine, τ, r, θ, \
φ]

n := 4

coord := {τ, r, θ, φ}

metric :=
2 G J Ω[θ]^2*{{-(1 + (1 - Λ[\
θ]^2)), 0, 0, 2 r Λ[θ]^2}, {0, 1/(
1 + r^2), 0, 0}, {0, 0, 1, 0}, {2 r Λ[θ]^2,
0, 0, Λ[θ]^2}}

inversemetric := Simplify[Inverse[metric]]

affine :=
affine = Simplify[
Table[(1/2) Sum[
inversemetric[[μ, ρ]] (D[metric[[ρ, ν]],
coord[[λ]]] +
D[metric[[ρ, λ]], coord[[ν]]] -
D[metric[[ν, λ]], coord[[μ]]]), {ρ, 1,
n}], {ν, 1, n}, {λ, 1, n}, {μ, 1, n}]]

listaffine :=
Table[If[UnsameQ[affine[[ν, λ, μ]],
0], {Style[
Subsuperscript[Γ,
Row[{coord[[ν]], coord[[λ]]}], coord[[μ]]],
18], "=",
Style[affine[[ν, λ, μ]], 14]}], {λ, 1,
n}, {ν, 1, n}, {μ, 1, n}] // FullSimplify

TableForm[
Partition[DeleteCases[Flatten[listaffine], Null],
3]] // FullSimplify

-

Ok, here is the code. Made small changes at the very end. I am sure there is a more elegant way to do it. But I simply added the counter column at the left using Insert[] and added the "=" using a Map. That is pretty much it.

Changes:

1. changed your listaffine line to remove "=" that you had there.
2. Partition it to 4 column now.
3. use Map to format it with "="
4. insert the counters column

i.e. 1 line changed. 2 new lines. that is it (you can use online diff website to see the difference also)

 (*... every thing from top to here was not changed... *)
listaffine :=
Table[If[UnsameQ[affine[[ν, λ, μ]],
0], {Style[
Subsuperscript[Γ,
Row[{coord[[ν]], coord[[λ]]}], coord[[μ]]],
18], Style[affine[[ν, λ, μ]],
14]}], {λ, 1, n}, {ν, 1, n}, {μ, 1, n}] //
FullSimplify;

data = {#[[1]], "=", #[[2]], #[[3]], "=", #[[4]]} & /@
Partition[DeleteCases[Flatten[listaffine], Null], 4];

data = Insert[data[[#]], #, 1] & /@ Range[Length[data]];
TableForm[data] (*or Grid[data] or anything else you like *)


-
Yes!!!! Like that :D How did you do that? :D –  dingo_d Dec 15 '12 at 12:54