## 7  Tabular Environment or Halign for Tables

The tabular environment is the recommended way to construct tables in LATEX. In plain TEX, although \settabs etc. is supported, the \halign{ ... } command is recommended. (The LATEX tabbing environment is not supported by TTH because it is antithetical to the spirit of HTML document description, and because it is an extremely complicated construct. If you are lucky, TTH will not mess up your tabbing environment too much, but it makes no attempt to interpret it properly.) Considerable effort has been expended to translate the tabular environment, including interpreting the alignment argument of the environment, into as near an equivalent in HTML as reasonably achievable6. However, the limitations of HTML tables impose the following limitations on the translation.

### 7.1  Tabular

• HTML tables have either all cells bordered with rules or none. TTH therefore decides whether to use a bordered table by examining the first character of the alignment argument. If is it |, then the table is bordered, otherwise not.
• HTML tables are not capable of simultaneously aligning part of a cell's contents to the right and part to the left, which is automatically done by LATEX on some occasions when @-strings are used. For example if the alignment argument is |l@{~units}|r|, LATEX will align "units" to the right of the first cell. TTH can't. In some unbordered cases TTH will try for the same effect by putting the closing @-string in the following cell. This won't always give a good result.
• @-strings and *{num} code repetition are not permitted in the alignment argument to \multicolumn, but they are in the main tabular alignment argument.

### 7.2  Halign

• TTH decides whether to use a bordered table in Plain TEX by examining the entire halign template (i.e. the material up to the first \cr of the halign). If it contains the command \vrule TTH makes the table bordered, otherwise not.
• TTH decides on the alignment of the cell contents by looking for \hfill or \hss commands in the cell template. The default is to left-align the cell. If one of these spacing commands is present in the template prior to the # for this cell, then the cell will be right-aligned unless such a command also appears after the #, in which case the cell is centered. Again HTML is not capable of applying different alignments to different parts of a cell. So results may sometimes be different from TEX. However, if most of this paragraph sounds totally obscure to you, don't worry; TTH will probably do the right thing.
• The \multispan command is supported, giving a centered multicolumn cell, and \omit is treated as \multispan1. However, \span is currently not supported.
• In TEX each cell of an halign table resides within its own implied brace group. Because TTH does not implement this implied group, errors can arise. Even HTML table errors that lead to parse errors with XML parsers can arise when the cells have boxes in them. If this happens, the fix is to put an explicit brace group round the offending cell in the template line like this example:
  \halign{#\quad\hfil &{\vbox{\hsize\0.5\hsize #}}\cr
1 & V-box material\cr
}



### 7.3  Longtables

• The longtable environment is supported, but it is always centered. It is converted into a standard tabular inside a table environment because there is no need to accommodate page breaks (the main point of longtable) in HTML.
• The caption (including caption*) command is translated correctly but set as part of the HTML table; so, if the caption is longer than the longest row of the table, it will cause the whole table width to expand, possibly up to 100% of the line-width.
• The commands endhead, endfirsthead, endfoot, endlastfoot, are ignored, but their immediately preceding commands are therefore inserted into the table. That is probably not desirable for the foot commands. Longtable footers are not translated into footers.
• The \kill command is ignored. Its text is spuriously inserted.