Mathematica Stack Exchange is a question and answer site for users of Mathematica. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Suppose that I use Grid to display a table tab. I did the following, which frames all cells:

tab = {{"a", "b"}, {"1", SpanFromLeft}, {"2", SpanFromLeft}, {"3", SpanFromLeft}};
Grid[tab, Frame -> All]

and gives this output:


But, how do I programatically generate a table in which only the header cells are framed?


(I created the above by erasing cell dividers manually, using Paint, but for larger tables, I would like to do this programatically.) Thanks.

share|improve this question
up vote 5 down vote accepted

You can explicitly frame only those elements and not frame the rest. For example:

Grid[tab, Frame -> {None, None, {{1, 1} -> True, {1, 2} -> True}}]

enter image description here

To extend this to grids with $n$ columns in the header, you could replace the last element of the RHS of the Frame option with

Table[{1, i} -> True, {i, n}]

where n is an integer.

share|improve this answer

A slight variation:

Grid[MapAt[Item[#, Frame -> True] &, tab, {{1, 1}, {1, 2}}]]
share|improve this answer

A slight variation of a slight variation:

frRow = Item[#, Frame -> 1] & /@ # &;

MapAt[frRow, tab, 1] // Grid

Mathematica graphics

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.