The Crash Course to DocBook

Chapter 7. Tables

The tags covered in this section are listed below.

table - Table in a document
informaltable - Untitled table
thead - Heading row of a table
tfoot - Footer row of a table
tgroup - Wrapper for part of a table that contains an array along with its formatting information
tbody - Wrapper for the rows of a table or informaltable
row - Row in a tbody, thead, or tfoot
entry - Cell in a table
entrytbl - Subtable appearing as a table cell

Tables are used to organize data into a columnar format with optional titles, headers, and footers. DocBook tables come in two varieties: the table, which requires a title, and the informaltable, which does not have a title. All the other characteristics of these two table types are the same.

A table consists of formatting information and data entries. There are quite a few attributes that can be adjusted to tweak the display of your data. This tutorial will only cover the basic formatting attributes. For more details, you should refer to the DocBook Reference.

Tables begin with the <table> or <informaltable> tag. Next, define a title using the <title> tag if you are using a regular table. Finally, we get to the <tgroup> tag which contains all of the header, footer, and row information. You can have more than one tgroup if you wish to change formatting options for a section of the table. The <tgroup> tag has a number of optional formatting parameters, but the COLS attribute, which specifies the number of columns, is required. The <thead>, <tfoot>, and <tbody> contain the data in your table. Data in the thead appears at the top of the table, tbody appears in the middle, and tfoot appears at the end of the table.

Data in a table is contained in rows and entries, labelled with the <row> and <entry> tags respectively. Use the <row> tag to begin a row, an <entry> tag for each item of data, and a closing <row> tag to end that row. If you want to embed a table within a table, you must use the <entrytbl> tag.

Example 7-1. A table

<title>Mouse Mileage</title>
<tgroup cols="3">
<entry>Feet Traveled</entry>

The above example would look something like this when converted:

Table 7-1. Mouse Mileage

MonthWeekFeet Traveled
Total 1753