Tagged tables syntax #1
Replies: 3 comments 5 replies
-
Following @u-fischer's encouragement during the Thurstday Tagged PDF Workshop, I thought I would give this a try as well. IntroductionIn this post, I will go through the example tables at https://www.w3.org/WAI/tutorials/tables/ and I will propose a backwards-compatible way to represent the tables in LaTeX. 1. Tables with One HeaderExample 1.1: Table with header cells in the top row only\begin{tabular}{lll}
\colheaders Date & Event & Venue \\ \hline
12 February & Waltz with Strauss & Main Hall \\
24 March & The Obelisks & West Wing \\
14 April & The What & Main Hall \\
\end{tabular} Here, we use the Example 1.2: Table with header cells in the first column only\begin{tabular}{>{\rowheader}l|ll}
Date & 12 February & 24 March & 14 April \\
Event & Waltz with Strauss & The Obelisks & The What \\
Venue & Main Hall & West Wing & Main Hall \\
\end{tabular} Here, we use the Example 1.3: Table with ambiguous dataSame approach as for Example 1.1. 2. Tables with Two HeadersExample 2.1: Table with header cells in the top row and first column\begin{tabular}{>{\rowheader}l|lllll}
\norowheader \colheaders[2-6] & Monday & Tuesday & Wednesday & Thurstday & Friday \\ \hline
09:00--11:00 & Closed & Open & Open & Closed & Closed \\
11:00--13:00 & Open & Open & Closed & Closed & Closed \\
13:00--15:00 & Open & Open & Open & Closed & Closed \\
15:00--17:00 & Closed & Closed & Closed & Open & Open \\
\end{tabular} Here, we need to indicate that the upperleftmost cell is an exception and not a row or column header. For the row headers, the proposed solution expands to the Example 2.2: Table with an offset column of header cells\begin{tabular}{l|>{\rowheader}l|llllll}
\colheaders ID & Name & July & August & September & October & November & December \\ \hline
215 & Abel & 5 & 2 & 0 & 0 & 0 & 3 \\
231 & Annette & 0 & 5 & 3 & 0 & 0 & 6 \\
173 & Bernard & 2 & 0 & 0 & 5 & 0 & 0 \\
141 & Gerald & 0 & 10 & 0 & 0 & 0 & 8 \\
99 & Michael & 8 & 8 & 8 & 8 & 0 & 4 \\
\end{tabular} 3. Tables with Irregular HeadersExample 3.1: Table with two tier headers\begin{tabular}{>{\rowheader}l|llll}
\norowheader \colheaders[2-5] & \multicolumn{2}{l}{Mars} & \multicolumn{2}{l}{Venus} \\ \cline{2-5}
\norowheader \colheaders[2-5] & Produced & Sold & Produced & Sold \\ \hline
Teddy Bears & 50,000 & 30,000 & 100,000 & 80,000 \\
Board Games & 10,000 & 5,000 & 12,000 & 9,000 \\
\end{tabular} Example 3.2: Table with headers spanning multiple rows or columns\begin{tabular}{>{\rowheader}l|>{\rowheader}l|lll}
\colheaders Poster name & Color & \multicolumn{3}{l}{Sizes available} \\ \hline
\multirow[t]{3}{*}{Zodiac} & Full color & A2 & A3 & A4 \\
& Black and white & A1 & A2 & A3 \\
& Sepia & A3 & A4 & A5 \\ \cline{1-2}
\multirow[t]{3}{*}{Angels} & Black and white & A1 & A3 & A4 \\
& Sepia & A2 & A3 & A5 \\
\end{tabular} Here, we use the 4. Tables with Multi-Level HeadersExample 4.1: Table with multiple column headers in each column\begin{tabular}{>{\rowheader}l|ll}
\norowheader \colheaders[2-3] & Example 1 Ltd & Example 2 Co \\ \hline
Contact & James Phillips & Marie Beauchamp \\
Position & Sales Director & Sales Manager \\
Email & jp@1ltd.example.com & marie@2co.example.com \\ \hline
\norowheader \colheaders[2-3, direction=b] & Example 3 Ltd & Example 4 Inc \\ \hline
Contact & Suzette Jones & Alex Howe \\
Position & Sales Officer & Sales Director \\
Email & Suz@ltd3.example.com & howe@4inc.example.com \\
\end{tabular} Here, we use a Example 4.2: Table with three headers related to each data cell\begin{tabular}{>{\rowheader}l|llll}
\norowheader \colheaders[2-5] & Studio & Apt & Chalet & Villa \\ \hline
\multicolumn{5}{l}{\rowheader[direction=b] Paris} \\ \hline
1 bedroom & 11 & 20 & 25 & 23 \\
2 bedroom & & 43 & 52 & 32 \\
3 bedroom & & 13 & 15 & 40 \\ \hline
\multicolumn{5}{l}{\rowheader[direction=b] Rome} \\ \hline
1 bedroom & 13 & 21 & 22 & 3 \\
2 bedroom & & 23 & 43 & 30 \\
3 bedroom & & 16 & 32 & 40 \\
\end{tabular} Here, we use a Example 4.3: Split up multi-level tablesSame approach as for Example 2.1. ConclusionIn this post, I have converted all the example tables at https://www.w3.org/WAI/tutorials/tables/ to LaTeX. Only three new commands were introduced:
Tables that are too complex to be marked up by these three commands will not be tagged. |
Beta Was this translation helpful? Give feedback.
-
I'd suggest a short switch on a per-cell basis with an mandatory argument for the direction, and an optional, numeric argument for the head "level" (as positiv integer, default The mandatory argument is a letter In the following table, this is examplified by the
In this example, the head "Paris" would count for all the cells in the next three rows of the table, because in the fourth row, contains another |
Beta Was this translation helpful? Give feedback.
-
Here are my considerations for tagging tables:
|
Beta Was this translation helpful? Give feedback.
-
At the Tagging PDF workshop Ulrike and Frank asked for the syntax of tagged tables.
Here is my suggestion. The commands are either table-wide or cell-wide. Example of a table-wide commands
Example of a cell-wide command
headersetup
keyword. There are three of them.firstRow
means that the first row is the column headers (this is the default),firstCol
means that the first column is row headers,none
means that the table has no headers (or all headers are defined by cell-wide commands).firstRow
andfirstCol
may have a numbern
in square brackets. This means that firstn
rows or columns are headers. The deault is 1. ThefirstCol
andfirstRow
keywords may be combined.\header
overrides table-wide commands. It has an argument, zero or more pairs of cell coordinates in the round brackets, separated by a comma, with row number(s) first and column number(s) second. The empty argument\header{}
means that the cell is not a header (possibly overriding the table-wide settings). If the argument is not empty, it specifies a range of cells for which the current cell is header, for example,(3,2-9)
means third row, columns from 2 to 9 are the cells, for which the current cell is a header. The current col or row can be substituted by.
, and all cells in a row or column can be substituted by-
so(., -)
means the current row. There could be several such ranges, which are added. together. Again, this command is only for complicated cases, not covered byheadersetup
Beta Was this translation helpful? Give feedback.
All reactions