This is documentation for Mathematica 6, which was
based on an earlier version of the Wolfram Language.
View current documentation (Version 11.2)


Grid[{{expr11, expr12, ...}, {expr21, expr22, ...}, ...}]
is an object that formats with the exprij arranged in a two-dimensional grid.
  • In a notebook, you can enter expressions in a two-dimensional layout by using Ctrl+, to add columns and Ctrl+Enter to add rows. By default, this layout evaluates to a nested list. You can make a Grid that preserves the layout by using Grid[layout].
  • You can use Tab to move to the next placeholder in a Grid. Ctrl+Space moves out of the whole Grid.
  • First[grid] extracts the list of lists that make up a grid.
  • The exprij can be expressions of any kind, including graphics and controls.
  • You can enter text in an element of a Grid by giving it as a string. You can use Text["string"] or Style["string", "style"] to specify a particular style.
  • The listi in Grid[{list1, list2, ...}] do not all need to be the same length; there will be empty space in the grid at the ends of shorter rows.
  • The following specify that a particular position should be spanned:
SpanFromLeftspan from left
SpanFromAbovespan from above
SpanFromBothspan from both left and above
  • In a notebook, you can combine selected elements in a grid to make a single spanning element using the Make Spanning menu item.
  • The following options can be given:
Alignment{Center,Baseline}horizontal and vertical alignment of items
BackgroundNonewhat background colors to use
BaselinePositionAutomaticwhat to align with a surrounding text baseline
BaseStyle{}base style specifications for the grid
DefaultElement""what element to insert in an empty item
DividersNonewhere to draw divider lines in the grid
FrameNonewhere to draw frames in the grid
FrameStyleAutomaticstyle to use for frames
ItemSizeAutomaticwidth and height of each item
ItemStyleNonestyles for columns and rows
SpacingsAutomatichorizontal and vertical spacings
  • Common settings for Frame include:
Noneno frame
Trueframe around the whole grid
Allframe around every item in the grid
Centerdraw interior frames only
{All,False}put a frame at every horizontal position (column lines)
{False,All}put a frame at every vertical position (row lines)
specapply spec to all items
{specx}apply specx at successive horizontal positions
{specx,specy}apply speck at successive horizontal and vertical positions
{spec_(x),spec_(y),rules}also allow explicit rules for individual i,j elements
  • The speck can have the following forms:
{s1,s2,...,sn}use s_1 through s_n; then use defaults
{{c}}use c in all cases
{{c1,c2}}alternate between c_1 and c_2
{{c1,c2,...}}cycle through all c_i
{s,{c}}use s, then repeatedly use c
{s1,{c},sn}use s_1, then repeatedly use c, but use s_n at the end
{s1,s2,...,{c1, c2, ... }, sm, ... , sn}
use the first sequence of s_i at the beginning, then cyclically use the c_i, then use the last sequence of s_i at the end
{s1,s2,...,{},sm,...,sn}use the first sequence of s_i at the beginning and the last sequence at the end
{i1->v1,i2->v2,...}specify what to use at positions i_k
{spec,rules}use rules to override specifications in spec
  • With settings of the form {s_1,s_2,…,{…},s_m,…,s_n}, if there are more s_i specified than items across the grid, s_i from the beginning are used for the first items, and ones from the end are used for the last items.
  • With the default setting ItemSize->Automatic, Grid will break elements across multiple lines if necessary.
  • Grid will not change the size of graphics or other objects that have explicit ImageSize settings.
  • For a grid with n items in a particular direction, Dividers and Spacings can specify settings for the n+1 gaps between elements, starting before the first element, and ending after the last element.
specapply spec to all gaps between items
{specx,specy}apply speci to successive horizontal and vertical gaps
  • The speci can have the same forms as for Alignment, Background and other item-oriented options.
Axisaxis of the middle row in the grid (default)
Baselinebaseline of the middle row in the grid
Bottombottom of the whole grid
Centerhalfway from top to bottom
Toptop of the whole grid
{{i,j},pos}position pos in element i,j
  • The settings for BaseStyle are appended to the default style typically given by the "Grid" style in the current stylesheet.
New in 6