Next / Previous / Contents / Shipman's homepage

12.4. Horizontal (column) spanning in tables

So far we have talked only about tables with a cell at the intersection of each row and column. In the real world, though, we often need to span cells, that is, to combine two or more cells into a larger area that holds a single item.

Here is the procedure for column spanning, where multiple cells of the same row are combined.

  1. To each colspec element, add a colname attribute that specifies a unique name for that column.

  2. Inside the entry element to be spanned, add two attributes. Set the namest attribute value to the name of the column where the spanning is to start. Set the nameend attribute value to the name of the ending column.

Here is a small table that demonstrates spanning. Note that the last two column headings are each centered over two columns:

Table 2. Rising and setting of Venus, 1994

  20° N. Lat. 30° N. Lat.
 RiseSetRiseSet
Jan.16:2117:146:4316:52
 116:3517:316:5617:10

Here's the source for the first part of this table:

      <table xml:id='venus-table'>
        <title>Rising and setting of Venus, 1994</title>
        <tgroup cols='6' align='right'>
          <colspec align='left' colname='month'/>
          <colspec colwidth='4em' colname='day'/>
          <colspec colwidth='3em' colname='rise-20'/>
          <colspec colwidth='5em' colname='set-20'/>
          <colspec colwidth='5em' colname='rise-30'/>
          <colspec colwidth='5em' colname='set-30'/>
          <thead>
            <row>
              <entry namest='month' nameend='day'/>
              <entry namest='rise-20' nameend='set-20' align='center'>
                20° N. Lat.
              </entry>
              <entry namest='rise-30' nameend='set-30' align='center'>
                30° N. Lat.
              </entry>
            </row>
            <row>
              <entry namest='month' nameend='day'/>
              <entry>Rise</entry>
              <entry>Set</entry>
              <entry>Rise</entry>
              <entry>Set</entry>
            </row>
          </thead>
          <tbody>
            <row>
              <entry>Jan.</entry>
              <entry>1</entry>
              <entry>6:21</entry>
              <entry>17:14</entry>
              <entry>6:43</entry>
              <entry>16:52</entry>
            </row>
            ...