|
SOLUTIONS
|
BUILT-IN MATHEMATICA SYMBOL
Grid[{{expr11, expr12, ...}, {expr21, expr22, ...}, ...}]
is an object that formats with the
arranged in a two-dimensional grid.
Details and OptionsDetails and Options
- 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.
- Grid[...] formats as a grid in StandardForm and TraditionalForm.
- In InputForm, Grid[...] formats literally as Grid[...].
- First[grid] extracts the list of lists that make up a grid.
- The
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
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. - You can specify that an element e should span multiple positions in a grid using, for example, Grid[{{e, SpanFromLeft, SpanFromLeft}, ...}].
- The following specify that a particular position should be spanned:
-
SpanFromLeft span from left SpanFromAbove span from above SpanFromBoth span from both left and above - A particular element can span both multiple rows and multiple columns, by having a rectangular section of the array with the form {{e, SpanFromLeft, SpanFromLeft, ...}, {SpanFromAbove, SpanFromBoth, SpanFromBoth, ...}, ...}.
- 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 AllowedDimensions Automatic restrictions on number of rows or columns AutoDelete False whether to remove the grid structure if only one item remains Background None what background colors to use BaselinePosition Automatic what to align with a surrounding text baseline BaseStyle {} base style specifications for the grid DefaultElement "
"what element to insert in an empty item Dividers None where to draw divider lines in the grid Frame None where to draw frames in the grid FrameStyle Automatic style to use for frames ItemSize Automatic width and height of each item ItemStyle None styles for columns and rows Spacings Automatic horizontal and vertical spacings - Common settings for Frame include:
-
None no frame True frame around the whole grid All frame around every item in the grid Center draw 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) - Settings for the options Alignment, Background, Frame, ItemSize, and ItemStyle can be given as follows to apply separately to different items:
-
spec apply spec to all items {specx} apply
at successive horizontal positions{specx,specy} apply
at successive horizontal and vertical positions{specx,specy,rules} also allow explicit rules for individual
elements - The
can have the following forms: -
{s1,s2,...,sn} use
through
, then use defaults {{c}} use c in all cases {{c1,c2}} alternate between
and
{{c1,c2,...}} cycle through all 
{s,{c}} use s, then repeatedly use c {s1,{c},sn} use
, then repeatedly use c, but use
at the end {s1,s2,...,{c1, c2, ... }, sm, ... , sn}use the first sequence of
at the beginning, then cyclically use the
, then use the last sequence of
at the end {s1,s2,...,{},sm,...,sn} use the first sequence of
at the beginning and the last sequence at the end{i1->v1,i2->v2,...} specify what to use at positions 
{spec,rules} use rules to override specifications in spec - With settings of the form
, if there are more
specified than items across the grid,
from the beginning are used for the first items, and ones from the end are used for the last items. - Settings such as Alignment, Background, and Frame can effectively be specified for individual items in the grid using Item.
- 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.
- Settings for Dividers and Spacings can have the following forms:
-
spec apply spec to all gaps between items {specx,specy} apply
,
to successive horizontal and vertical gaps - The
can have the same forms as for Alignment, Background, and other item-oriented options. - The following settings can be used for BaselinePosition:
-
Axis axis of the middle row in the grid Baseline baseline of the middle row in the grid Bottom bottom of the whole grid Center halfway from top to bottom Top top of the whole grid {{i,j},pos} position pos in element 
pos->ref baseline offset to make pos be aligned with ref - The BaselinePosition is by default taken to be Center->Axis.
- The settings for BaseStyle are appended to the default style typically given by the
style in the current stylesheet.
New in 6 | Last modified in 9
Mathematica 9 is now available!
New to Mathematica?
Find your learning path »
Have a question?
Ask support »
