# How To Span Table Headings?

What I am doing wrong? I would like to get a header to the table and based on your code I tried this:

hdr = {{"Calculated Coordinates", SpanFromLeft}, {"No", "x", "y"}};
hdr1 = Grid[hdr, Frame -> All];

legendmarkers=Range@Length@data;
legendlabels=Map[Style[AccountingForm[#, 10], FontSize -> 20, FontFamily -> "Calibri"] &, data, {-1}];
styledheaders=Style[#,Bold,FontSize -> 22,FontFamily -> "Calibri"] & /@ {hdr1};
legendGrd = Grid[Prepend[Transpose[Join[{legendmarkers},
BaseStyle -> {FontSize -> 20, FontFamily -> "Calibri"},
FrameStyle -> GrayLevel[.9], Alignment -> {Center, Center},
Background -> {None, {GrayLevel[.5], {GrayLevel[.8]}}}]


The result is:

"Calculated Coordinates" should span all three columns, and "No", "x", and "y" should be the header of the corresponding columns. What must I do to get this? Again, thanks a lot!!

-
Perhaps the question title is not too well suited for those not familiar with the first part - consider rephrasing to help future visitors. –  Yves Klett Sep 3 '12 at 14:50
@Klett: Of course, I can do it. But don't you think, that the link to the first question of this topic will do it? –  Harald Sep 4 '12 at 5:46
Not really - if you browse the questions, a meaningful, self-contained title is important. Having to retrace a question´s history to understand it is not beneficial. This question is about spanning table headings, not about a table in a legend. –  Yves Klett Sep 4 '12 at 6:59
I agree. I changed it and I hope it is now more or less ok –  Harald Sep 4 '12 at 7:32

Another way:

(* The following command imports your data from an image, see
http://meta.mathematica.stackexchange.com/a/633/193 for an explanation *)

ToExpression@Uncompress@FromCharacterCode@Flatten@Import["http://tinyurl.com/cbr4wkf","Data"]


Now the code

sh = Style[#, Bold, FontSize -> 22, FontFamily -> "Calibri"] &;
hdr = {{sh@"Calculated Coordinates", SpanFromLeft, SpanFromLeft}, sh /@ {"No", "x", "y"}};

leglbl = Map[Style[AccountingForm[#, 10]] &, data, {-1}];

legendGrd = Grid[
BaseStyle  -> {FontSize -> 20, FontFamily -> "Calibri"}, Frame -> All,
FrameStyle -> GrayLevel[.9], Alignment -> {Center, Center},
Background -> {None, {GrayLevel[.5], GrayLevel[.5], {GrayLevel[.8]}}}]


-
Verde: Thanks a lot!! –  Harald Sep 3 '12 at 17:02

Here is one way. The trick is making the header part of the data.

hdr = {{"Calculated Coordinates", SpanFromLeft, SpanFromLeft}, {"No",
"x", "y"}};
data = RandomReal[{-1, 1}, {10, 2}];
legendmarkers = Range@Length@data;

legendlabels =
Map[Style[AccountingForm[#, 10], FontSize -> 20,
FontFamily -> "Calibri"] &, data, {-1}];

hdr[[2]] =
Style[#, Bold, FontSize -> 22, FontFamily -> "Calibri"] & /@
hdr[[2]];
hdr[[1, 1]] =
Style[hdr[[1, 1]], Bold, FontSize -> 22, FontFamily -> "Calibri"];
legendGrd =
Grid[hdr~Join~
Transpose[Join[{legendmarkers}, Transpose[legendlabels]]],
Frame -> All,
BaseStyle -> {FontSize -> 20, FontFamily -> "Calibri"},
FrameStyle -> GrayLevel[.9], Alignment -> {Center, Center},
Background -> {None, {GrayLevel[.5],GrayLevel[.5], {GrayLevel[.8]}}}]


-
Ajasja: Thanks a lot!! –  Harald Sep 3 '12 at 17:01