({{, (RefLink[TableForm, paclet:ref/TableForm])[list]
prints with the elements of list arranged in an array of rectangular cells. }})

OpenersNotesSection(Spacer1)Details and Options

The height of each row and the width of each column are determined by the maximum size of an element in the row or column.

(RefLink[TableForm, paclet:ref/TableForm]) prints a single-level list in a column. It prints a two-level list as a two-dimensional table. More deeply nested lists are by default printed with successive dimensions alternating between rows and columns.

Arrays in which all sublists at a particular level are not of the same length display as ragged tables. »

The following options can be given:

(RefLink[TableForm, paclet:ref/TableForm]) acts as a "wrapper", which affects printing, but not evaluation.

OpenersPrimaryExamplesSection(Spacer1)Examples  (24)

OpenersExampleSection0(Spacer1)Basic Examples  (1)

Show vector, matrix and general arrays in tabular form:

TableForm[Array[a,{2}]]

TableForm[Array[a,{2,2}]]

TableForm[Array[a,{2,2,2}]]

OpenersExampleSection1(Spacer1)Scope  (3)

Tables of numbers and formulas:

TableForm[RandomReal[5,{3,4}]]

TableForm[Table[1/(i+j),{i,4},{j,4}]]

TableForm[RotationMatrix[θ,{UnitVector[5,2],UnitVector[5,4]}]]

A table of lists:

Outer[List,Range[4],Range[4]]

TableForm[%,TableDepth->2]

Format a ragged array:

TableForm[Table[Range[i],{i,5}]]

OpenersExampleSection2(Spacer1)Options  (10)

OpenersExampleSubsection0(Spacer1)TableAlignments  (2)

Specify the alignment of columns:

TableForm[Partition[Range[15]!,3],TableAlignments->Center]

Define both horizontal and vertical alignments:

TableForm[Table[Graphics[Rectangle[],ImageSize->(i+j)],{i,{10,25,40}},{j,{10,25,40}}],TableAlignments->{Right,Center}]

OpenersExampleSubsection1(Spacer1)TableDepth  (2)

By default all dimensions are formatted:

TableForm[{{a,b},{c,d},{e,f}}]

Only use tabular formatting for the outermost dimension:

TableForm[{{a,b},{c,d},{e,f}},TableDepth->1]

OpenersExampleSubsection2(Spacer1)TableDirections  (2)

By default the outermost dimension is a column:

TableForm[{{a,b},{c,d},{e,f}}]

Format the first dimension as a row instead:

TableForm[{{a,b},{c,d},{e,f}},TableDirections->Row]

OpenersExampleSubsection3(Spacer1)TableHeadings  (3)

Specify headings for rows:

TableForm[{{a,b},{c,d},{e,f}},TableHeadings->{{"r1","r2","r3"},None}]

Specify headings for columns:

TableForm[{{a,b},{c,d},{e,f}},TableHeadings->{None,{"c1","c2"}}]

Specify headings for rows and columns:

TableForm[{{a,b},{c,d},{e,f}},TableHeadings->{{"r1","r2","r3"},{"c1","c2"}}]

OpenersExampleSubsection4(Spacer1)TableSpacing  (1)

The default automatic spacing:

TableForm[{{a,b},{c,d},{e,f}}]

Explicitly specify the spacing between rows and between columns:

TableForm[{{a,b},{c,d},{e,f}},TableSpacing->{5,2}]

OpenersExampleSection3(Spacer1)Applications  (4)

Display data in a formatted table:

TableForm[{{5,7},{4,2},{10,3}},TableHeadings->{{"Group A","Group B","Group C"},{"y1","y2"}}]

Create a multiplication table:

TableForm[Outer[Times,Range[10],Range[10]],TableHeadings->Automatic]

Multiplication table for the cyclic group (Subscript[C, 5]):

c5={1,"A","B","C","D"};

TableForm[Table[RotateLeft[c5,n],{n,0,4}],TableHeadings->{c5,c5},TableSpacing->{1,2}]

Create a table of graphics:

TableForm@Table[SphericalPlot3D[Evaluate@Abs@SphericalHarmonicY[l,m,θ,ϕ],{θ,0,Pi},{ϕ,0,2Pi},PlotRange->0.6,Mesh->None,Boxed->False,Axes->None,ImageSize->100],{l,0,3},{m,0,l}]

OpenersExampleSection4(Spacer1)Properties & Relations  (5)

(RefLink[TableForm, paclet:ref/TableForm]) formats arrays in a tabular form:

TableForm[{{a,b},{c,d},{e,f}}]

(RefLink[MatrixForm, paclet:ref/MatrixForm]) formats arrays using standard matrix formatting:

MatrixForm[{{a,b},{c,d},{e,f}}]

(RefLink[Grid, paclet:ref/Grid]) formats two-dimensional arrays as a grid:

Grid[{{a,b},{c,d},{e,f}}]

Use (RefLink[MatrixPlot, paclet:ref/MatrixPlot]) to visualize the structure of large arrays:

b[i_]:=Table[Binomial[n,k],{n,0,i},{k,0,i}]

b[5]//TableForm

MatrixPlot[b[99]]

Use (RefLink[ArrayPlot, paclet:ref/ArrayPlot]) to visualize the structure of large discrete arrays:

b[i_]:=CellularAutomaton[30,{{1},0},i]

TableForm[b[5]]

ArrayPlot[b[100]]

Use (RefLink[Style, paclet:ref/Style]) to affect the display of (RefLink[TableForm, paclet:ref/TableForm]):

b[i_]:=Table[Binomial[n,k],{n,0,i},{k,0,i}]

Style[TableForm[b[20]],Tiny]

Style[TableForm[b[3]],{Large,Bold,Orange}]

Use any number form such as (RefLink[ScientificForm, paclet:ref/ScientificForm]) or (RefLink[BaseForm, paclet:ref/BaseForm]) to affect the display of numbers:

ScientificForm[TableForm[RandomReal[10^5,{4,4}]],3]

PaddedForm[BaseForm[TableForm[RandomInteger[{0,127},{4,4}]],2],8,NumberPadding->{"0",""}]

OpenersExampleSection5(Spacer1)Neat Examples  (1)

A Stirling table texture:

Style[TableForm[Table[StirlingS2[n,k],{n,1,28},{k,1,28}]],2,Orange]

({{DocumentationFooterIconsRelatedFunction.png, ({{See Also}, {(RefLink[MatrixForm, paclet:ref/MatrixForm])  ▪  (RefLink[Grid, paclet:ref/Grid])  ▪  (RefLink[TextGrid, paclet:ref/TextGrid])  ▪  (RefLink[GraphicsGrid, paclet:ref/GraphicsGrid])  ▪  (RefLink[ArrayPlot, paclet:ref/ArrayPlot])  ▪  (RefLink[PaddedForm, paclet:ref/PaddedForm])}})}})

({{DocumentationFooterIconsRelatedTutorial.png, ({{Tutorials}, {▪(RefLinkPlain[Making Tables of Values, paclet:tutorial/MakingTablesOfValues])}, {▪(RefLinkPlain[Tables and Matrices, paclet:tutorial/TablesAndMatrices])}, {▪(RefLinkPlain[Formatted Output, paclet:tutorial/FormattedOutput])}})}})