# How to | Put Headings in a Table

*Mathematica *provides great flexibility for displaying and styling headings in a table. You can use Prepend or ArrayFlatten to add headings to rows and columns and then use Grid with any of its styling elements to display them in a table.

*Mathematica* lets you control and customize the display of data in your table. Headings are just like any other element of a table.

In[49]:= |

Out[49]= |

In[50]:= |

Out[50]= |

Display the data, with column headings, using Grid:

In[51]:= |

Out[51]= |

Use MapThread to prepend headings for rows:

In[52]:= |

Out[52]= |

Display the data with headings for rows and columns, using Grid with Frame:

In[53]:= |

Out[53]= |

In[54]:= |

Use GraphicsGrid to display the circles in a grid:

In[55]:= |

Out[55]= |

Create and style column headings:

In[56]:= |

Out[56]= |

Prepend the styled column headings to the circles:

In[57]:= |

View the styled table with GraphicsGrid:

In[58]:= |

Out[58]= |

The following data represents yields for three types of soils and two types of corn seeds:

In[59]:= |

The data can be grouped by soil type by using First with GatherBy to gather the data by the first element of each data point:

In[85]:= |

Out[85]= |

To prepare the data for display in a table, use Flatten at level one, which here makes one list of triples. The symbol specifies the most recent output, which in this case is the grouped data:

In[61]:= |

Out[61]= |

The observation number within each soil type will serve as the corresponding row heading.

Use Length to count the number of observations within each soil type:

In[62]:= |

Out[62]= |

Use Range to generate a list of successive integers beginning with 1 and ending with the number of observations within each soil type:

In[63]:= |

Out[63]= |

Prepare the numbers for use as row headings by using Flatten to compress them into a single list:

In[64]:= |

Out[64]= |

Create column headings for the soil type, seed type, and yield data. You will create a column heading for the observation number in the next step, so you do not need to do so here:

In[65]:= |

Use ArrayFlatten to add the observation numbers, along with the column heading , to the data:

In[87]:= |

Out[87]= |

Use Grid to display the data in a table:

In[88]:= |

Out[88]= |

Use some of the options available in Grid to add styling to the table:

In[89]:= |

Out[89]= |

For more examples of table formatting and styling, see "How to: Format a Table of Data", and "Grids, Rows, and Columns".

You can also create tables and add headings to them using TableForm.

Define a set of data to work with:

In[1]:= |

Create the row and column headings for your data:

In[1]:= |

Create a table with TableForm, and use the TableHeadings option to add your headings:

In[3]:= |

Out[3]//TableForm= | |

While TableForm allows you to create tables, it does not support the extensive styling options that are available to Grid.