Section8Tables
¶After sidebyside
, getting tables to lay out consistently between HTML and PDF is probably the second biggest headache that PreTeXt takes care of for us behind the scenes. Lots of effort has been taken in order to fix some of the challenges inherent to working with the tabular
environment in LaTeX, and so if you author in PreTeXt, you should be able to forget the hacks you had to learn to make nice tables in LaTeX.
Tables should only be used to display data that is inherently tabular. Too often in other authoring systems, tables are used as a crutch to facilitate the visual layout of a page. Do not do that when authoring PreTeXt. A good question to ask yourself before using a tabular
is “Do the \(xy\)-coordinates of a cell have semantic meaning in terms of my data?” If the answer is “yes”, then make a table with tabular
. If not, find a more suitable tag. (Perhaps sidebyside
and/or sbsgroup
.) One of the many reasons for this is that screen readers used by individuals with visual impairments read tables in a very specific way that assumes the \(xy\)-coordinates of each cell are contributing to the meaning. Individuals who use screen readers will find a document that uses tables to do something other than present tabular data very confusing and frustrating.
<table> <caption>A simple table</caption> <tabular halign="center"> <row bottom="minor" > <cell><m>x</m></cell> <cell><m>y</m></cell> <cell><m>x\wedge y</m></cell> <cell><m>x\vee y</m></cell> </row> <row> <cell>T</cell> <cell>T</cell> <cell>T</cell> <cell>T</cell> </row> <row> <cell>T</cell> <cell>F</cell> <cell>F</cell> <cell>T</cell> </row> <row> <cell>F</cell> <cell>T</cell> <cell>F</cell> <cell>T</cell> </row> <row> <cell>F</cell> <cell>F</cell> <cell>F</cell> <cell>F</cell> </row> </tabular> </table>
The code in Listing 8.1 produces the following output:
\(x\) | \(y\) | \(x\wedge y\) | \(x\vee y\) |
T | T | T | T |
T | F | F | T |
F | T | F | T |
F | F | F | F |
See the PreTeXt documentation for more information about how to make more complicated tables.