| 1 |
% \iffalse meta-comment |
| 2 |
% |
| 3 |
%% File: latex-lab-table.dtx (C) Copyright 2023-2025 LaTeX Project |
| 4 |
% |
| 5 |
% It may be distributed and/or modified under the conditions of the |
| 6 |
% LaTeX Project Public License (LPPL), either version 1.3c of this |
| 7 |
% license or (at your option) any later version. The latest version |
| 8 |
% of this license is in the file |
| 9 |
% |
| 10 |
% https://www.latex-project.org/lppl.txt |
| 11 |
% |
| 12 |
% |
| 13 |
% The development version of the bundle can be found below |
| 14 |
% |
| 15 |
% https://github.com/latex3/latex2e/required/latex-lab |
| 16 |
% |
| 17 |
% for those people who are interested or want to report an issue. |
| 18 |
% |
| 19 |
\def\ltlabtbldate{2025-08-01} |
| 20 |
\def\ltlabtblversion{0.85s} |
| 21 |
%<*driver> |
| 22 |
\DocumentMetadata{tagging=on,pdfstandard=ua-2} |
| 23 |
\documentclass[kernel]{l3doc} |
| 24 |
\usepackage{latex-lab-testphase-l3doc} |
| 25 |
\EnableCrossrefs |
| 26 |
\CodelineIndex |
| 27 |
\begin{document} |
| 28 |
\DocInput{latex-lab-table.dtx} |
| 29 |
\end{document} |
| 30 |
%</driver> |
| 31 |
% |
| 32 |
% \fi |
| 33 |
% |
| 34 |
% \providecommand\hook[1]{\texttt{#1\DescribeHook[noprint]{#1}}} |
| 35 |
% \providecommand\socket[1]{\texttt{#1\DescribeSocket[noprint]{#1}}} |
| 36 |
% \providecommand\plug[1]{\texttt{#1\DescribePlug[noprint]{#1}}} |
| 37 |
% |
| 38 |
% \NewDocElement[printtype=\textit{socket},idxtype=socket,idxgroup=Sockets]{Socket}{socketdecl} |
| 39 |
% \NewDocElement[printtype=\textit{hook},idxtype=hook,idxgroup=Hooks]{Hook}{hookdecl} |
| 40 |
% \NewDocElement[printtype=\textit{plug},idxtype=plug,idxgroup=Plugs]{Plug}{plugdecl} |
| 41 |
% |
| 42 |
% |
| 43 |
% |
| 44 |
% |
| 45 |
% \title{The \textsf{latex-lab-table} package\\ |
| 46 |
% Changes related to the tagging of tables} |
| 47 |
% \author{Frank \& Ulrike, \LaTeX{} Project\thanks{Initial implementation done by Frank Mittelbach}} |
| 48 |
% \date{v\ltlabtblversion\ \ltlabtbldate} |
| 49 |
% |
| 50 |
% \maketitle |
| 51 |
% |
| 52 |
% \newcommand{\xt}[1]{\textsl{\textsf{#1}}} |
| 53 |
% \newcommand{\TODO}[1]{\textbf{[TODO:} #1\textbf{]}} |
| 54 |
% \newcommand{\docclass}{document class \marginpar{\raggedright document class |
| 55 |
% customizations}} |
| 56 |
% |
| 57 |
% |
| 58 |
% \begin{abstract} |
| 59 |
% The following code implements a first draft for the tagging of |
| 60 |
% tables. It still has a large number of limitations and restrictions! |
| 61 |
% \end{abstract} |
| 62 |
% |
| 63 |
% \tableofcontents |
| 64 |
% |
| 65 |
% \section{Documentation} |
| 66 |
% |
| 67 |
% In \LaTeX{} the word \texttt{table} is used as the name of the float environment that can contain |
| 68 |
% a data table\footnote{But it does not really have to, you can put |
| 69 |
% other material into such environments.} along with a caption and some additional text. The environments for |
| 70 |
% actual data tables have various names like \texttt{tabular}, \texttt{tabular*}, |
| 71 |
% \texttt{tabularx} and \texttt{longtable}---the last should not be used inside a float |
| 72 |
% and supports its own caption command. |
| 73 |
% |
| 74 |
% In this documentation \enquote{table} always means such data tables and not the float |
| 75 |
% environment. |
| 76 |
% |
| 77 |
% Tagging of tables is on one side doesn't look very difficult: one only has to |
| 78 |
% surround rows and cells by TR and TH or TD structures. |
| 79 |
% But there are difficulties: |
| 80 |
% \begin{itemize} |
| 81 |
% \item |
| 82 |
% One is that over the years various packages related to tables have |
| 83 |
% been written that all change some of the internals. Inserting the |
| 84 |
% tagging commands and testing all the variants and various nestings |
| 85 |
% is not trivial. |
| 86 |
% |
| 87 |
% \item |
| 88 |
% The other difficulty is that most of the existing environments to |
| 89 |
% create tables do not know the concept of headers as a semantic |
| 90 |
% structures. |
| 91 |
% |
| 92 |
% \item |
| 93 |
% Headers are only produced through visual formatting, e.g., by |
| 94 |
% making them bold or by underlying some color. But accessible |
| 95 |
% tables need headers (and the PDF/UA standards requires them) and |
| 96 |
% this means that additional syntax to declare headers (when they |
| 97 |
% can't be guessed) must be developed. This is still an area for |
| 98 |
% research. |
| 99 |
% \end{itemize} |
| 100 |
% |
| 101 |
% Right now, this module therefore does implement only some basic |
| 102 |
% support for the tagging of tables. A list of the known limitations |
| 103 |
% is shown below. |
| 104 |
% |
| 105 |
% \subsection{Loading} |
| 106 |
% The module is not loaded automatically (i.e., not yet integrated |
| 107 |
% into any \texttt{phase-XX}) and by itself it doesn't activate |
| 108 |
% tagging. For experimenting with table tagging it is therefore best |
| 109 |
% to load it in combination |
| 110 |
% with phase-III in \cs{DocumentMetadata}, i.e.: |
| 111 |
% |
| 112 |
% \begin{verbatim} |
| 113 |
% \DocumentMetadata{testphase={phase-III,table}} |
| 114 |
% \end{verbatim} |
| 115 |
% |
| 116 |
% It will then automatically tag all table environments it already supports with |
| 117 |
% the exception of tables in the header and footer of the page (where tagging is disabled). |
| 118 |
% Such tables can be nested. |
| 119 |
% |
| 120 |
% Inside cells the automatic tagging of paragraphs is disabled with the exception of |
| 121 |
% p/m/b-type cells. |
| 122 |
% |
| 123 |
% Rows do not need to contain a full number of \&, missing cells are automatically |
| 124 |
% added with an empty TD-structure. |
| 125 |
% |
| 126 |
% You should not insert meaningful text with \verb+!{...}+ or \verb+@{...}+ or \cs{noalign} |
| 127 |
% between the rows or columns of the table. |
| 128 |
% With pdflatex such text will be unmarked, with lualatex it will be marked as artifact. |
| 129 |
% Either case means that it will be currently ignored in the |
| 130 |
% structure.\footnote{While it is theoretically possible |
| 131 |
% to collect such text and move it into a structure it would require manual markup |
| 132 |
% from the author to clarify where this text belongs too.} |
| 133 |
% |
| 134 |
% As mentioned below the \pkg{colortbl} doesn't work fully with the tagging, |
| 135 |
% but when it does, colors inside the table are currently ignored. If such a color |
| 136 |
% has a semantic meaning (like \enquote{important value}) this meaning will be lost. |
| 137 |
% |
| 138 |
% \subsection{Untagged and presentation tables} |
| 139 |
% If a table should not be tagged as table, for example because it is merely used |
| 140 |
% as a layout to ensure that the content is properly aligned |
| 141 |
% or because it is a not yet (fully) supported table structure, |
| 142 |
% the tagging can be disabled with |
| 143 |
% \verb|\tagpdfsetup{table/tagging=false}| or changed with |
| 144 |
% \verb|\tagpdfsetup{table/tagging=presentation}| or \verb|\tagpdfsetup{table/tagging=div}|% |
| 145 |
% \footnote{The key has been renamed. The old name `table-tagging` still works but is |
| 146 |
% deprecated. The value \texttt{presentation} refers to the ARIA role \enquote{presentation}.} |
| 147 |
% The first option disables the table tagging code and the content of the tabular |
| 148 |
% is then treated more or less like running text. This works ok for simple tables using |
| 149 |
% only hmode-cells (l/c/r) with normal text content, but fails if the table uses vmode-cells |
| 150 |
% (p/m/b). In such cases the second option works better: it keeps the tagging code active, |
| 151 |
% but adds an ARIA-role as attribute to indicate that this is a presentation table. |
| 152 |
% When deriving to html this gives the best result |
| 153 |
% as it keeps the layout. |
| 154 |
% The last option changes the tag names and creates simply a number of DIV structures. |
| 155 |
% Both options also |
| 156 |
% (re)set the \texttt{table/header-rows} and \texttt{table/header-columns} keys to empty. |
| 157 |
% |
| 158 |
% To reset to the normal tagging in the current group (e.g. inside a presentation |
| 159 |
% table) one can use \verb|\tagpdfsetup{table/tagging=true}| (and if needed reenable the headers). |
| 160 |
% |
| 161 |
% |
| 162 |
% \subsection{Header rows and columns} |
| 163 |
% There is some basic support\footnote{This is not meant to be the |
| 164 |
% final interface, though.} for headers. With\footnote{The old key name \texttt{table-header-rows} still |
| 165 |
% works but is deprecated.} |
| 166 |
% \begin{quote} |
| 167 |
% \verb|\tagpdfsetup{table/header-rows={|\meta{list of row numbers}\verb|}}|\\ |
| 168 |
% \verb|\tagpdfsetup{table/header-columns={|\meta{list of column numbers}\verb|}}| |
| 169 |
% \end{quote} |
| 170 |
% you can |
| 171 |
% declare which (absolute) row and column numbers should be tagged as header rows and header columns. |
| 172 |
% It applies to all tables until it is changed to a different list of row or |
| 173 |
% columns numbers or undone by setting |
| 174 |
% the keys to \meta{empty}. |
| 175 |
% A row or column number can be |
| 176 |
% negative, then the counting starts from the end of the table. |
| 177 |
% In a \env{longtable} the code will currently use the \cs{endhead} or |
| 178 |
% \cs{endfirsthead} rows as header if one of these commands has been |
| 179 |
% used and in that case the code |
| 180 |
% ignores a \texttt{table/header-rows} setting. |
| 181 |
% |
| 182 |
% \subsection{Spanning of cells} |
| 183 |
% |
| 184 |
% \cs{multicolumn} is supported out of the box and will create a structure with a |
| 185 |
% suitable \texttt{ColSpan} attribute\footnote{The code uses actually an attribute \emph{class}. |
| 186 |
% The validator PAC doesn't handle this correctly currently and complains about a missing attribute.} |
| 187 |
% |
| 188 |
% For cells spanning rows some preliminary support exists\footnote{The interface is bound to change!}: |
| 189 |
% If you add |
| 190 |
% \begin{quote} |
| 191 |
% \verb|\tagpdfsetup{table/multirow={|\meta{number of rows}\verb|}| |
| 192 |
% \end{quote} |
| 193 |
% to a cell the code will add the suitable \texttt{RowSpan} attribute and suppress the tagging of affected |
| 194 |
% cells in the following rows. This will also work if the current cell is a \cs{multicolumn}, then |
| 195 |
% the cell will span both rows and columns. It is the duty of the author to |
| 196 |
% ensure that all cells below and covered by a \texttt{RowSpan} are empty! |
| 197 |
% The code neither checks that nor does |
| 198 |
% it tries to suppress content. |
| 199 |
% |
| 200 |
% Feedback and problems with the code can be reported at |
| 201 |
% \url{https://github.com/latex3/tagging-project} either in form of |
| 202 |
% explicit issues or as a \enquote{discussion topic}, whatever works best. |
| 203 |
% |
| 204 |
% |
| 205 |
% \section{Limitations} |
| 206 |
% |
| 207 |
% \begin{itemize} |
| 208 |
% \item The code loads the \pkg{array} package and so does not work without it (that is |
| 209 |
% not really a limitation, but can affect existing tables). |
| 210 |
% |
| 211 |
% \item It supports only a restricted number of tables types. Currently |
| 212 |
% \env{tabular}, \env{tabular*}, \env{tabularx}, and \env{longtable}. |
| 213 |
% |
| 214 |
% \item the \env{array} environment is assumed to be part of math and tagging as a table is disabled for |
| 215 |
% it. |
| 216 |
% |
| 217 |
% \item Row spans can only be added manually (the \pkg{multirow} package is untested). |
| 218 |
% |
| 219 |
% \item The \pkg{colortbl} package breaks tagging if there are nested tables. |
| 220 |
% |
| 221 |
% \item The \pkg{tabularray} package use a completed different |
| 222 |
% method to create tables and will not be supported by this code. |
| 223 |
% |
| 224 |
% \item The \pkg{nicematrix} package is currently incompatible. |
| 225 |
% |
| 226 |
% \item Most other packages related to tables in \LaTeX{} are not fully tested, |
| 227 |
% that includes packages that change rules like \pkg{booktabs}, \pkg{hhline}, |
| 228 |
% \pkg{arydshln}, \pkg{hvdashln}. Some problems have been resolved, either |
| 229 |
% in the packages or through a firstaid which can be loaded the \verb+testphase=firstaid+. |
| 230 |
% |
| 231 |
% \item \env{longtable} currently only works with lualatex. |
| 232 |
% With other engines it breaks as its output |
| 233 |
% routine clashes with the code which closes open MC-chunks at pagebreaks and |
| 234 |
% if this is resolved there will probably be problems with the head and foot boxes |
| 235 |
% (but this can't be tested currently). |
| 236 |
% |
| 237 |
% \item Not every table should be tagged as a Table structure, often they are |
| 238 |
% only used as layout help, e.g. to align authors in a title pages. In such uses |
| 239 |
% the tagging of the table must be deactivated with \verb|\tagpdfsetup{table/tagging=false}| |
| 240 |
% or changed with \verb|\tagpdfsetup{table/tagging=presentation}| or |
| 241 |
% \verb|\tagpdfsetup{table/tagging=div}|. |
| 242 |
% |
| 243 |
% \item Only simple header rows and columns are currently supported. Complex headers with |
| 244 |
% subheaders will be handled later as that needs some syntax changes. Tables |
| 245 |
% with more than one header row or column are probably not pdf/UA as the headers array in |
| 246 |
% the cells is missing. |
| 247 |
% |
| 248 |
% \item A \pkg{longtable} \cs{caption} is currently simply formatted as a multicolumn and |
| 249 |
% not tagged as a \texttt{Caption} structure. |
| 250 |
% |
| 251 |
% \item The \pkg{caption} package will quite probably break the \pkg{longtable} caption. |
| 252 |
% |
| 253 |
% \item The setup for \pkg{longtable} requires lots of patches to internal \pkg{longtable} |
| 254 |
% commands and so can easily break if other packages try to patch \pkg{longtable} too. |
| 255 |
% |
| 256 |
% \item The \env{longtable} environment supports footnotes in p-type columns, but it hasn't been |
| 257 |
% tested yet if this works also with the tagging code. |
| 258 |
% |
| 259 |
% \item Vertical boxes (\cs{parbox}, \texttt{minipage}, \ldots) inside cells can be problematic. |
| 260 |
% |
| 261 |
% \item The code is quite noisy and fills the log with lots of |
| 262 |
% messages.\footnote{Helpful for us at this stage.} |
| 263 |
% \end{itemize} |
| 264 |
% |
| 265 |
% |
| 266 |
% |
| 267 |
% \section{Introduction} |
| 268 |
% |
| 269 |
% |
| 270 |
% \section{Technical details and problems} |
| 271 |
% |
| 272 |
% The implementation has to take care of various details. |
| 273 |
% |
| 274 |
% \subsection{TODOs} |
| 275 |
% |
| 276 |
% \begin{itemize} |
| 277 |
% \item |
| 278 |
% Test \texttt{array-006-longtable.lvt} and |
| 279 |
% \texttt{array-007-longtable.lvt} have errors with pdftex (para |
| 280 |
% tagging) |
| 281 |
% |
| 282 |
% \item |
| 283 |
% Instead of before/after hooks we should add sockets directly |
| 284 |
% into the code. |
| 285 |
% |
| 286 |
% \item Debugging code and messages must be improved. |
| 287 |
% |
| 288 |
% \item Cells need an \texttt{Headers} array. |
| 289 |
% |
| 290 |
% \item Row spans should be supported (but perhaps need syntax support) |
| 291 |
% |
| 292 |
% \item Longtable captions should be properly supported. |
| 293 |
% |
| 294 |
% |
| 295 |
% \item More packages must be tested. |
| 296 |
% \end{itemize} |
| 297 |
% |
| 298 |
% |
| 299 |
% \section{Implementation} |
| 300 |
% \begin{macrocode} |
| 301 |
%<@@=tbl> |
| 302 |
%<*package> |
| 303 |
% \end{macrocode} |
| 304 |
% \begin{macrocode} |
| 305 |
\ProvidesExplPackage {latex-lab-testphase-table} {\ltlabtbldate} {\ltlabtblversion} |
| 306 |
{Code related to the tagging of tables} |
| 307 |
% \end{macrocode} |
| 308 |
% This builds on \pkg{array} so we load it by default: |
| 309 |
% \begin{macrocode} |
| 310 |
\RequirePackage{array} |
| 311 |
% \end{macrocode} |
| 312 |
% |
| 313 |
% |
| 314 |
% \subsection{Variables} |
| 315 |
% \begin{macro} |
| 316 |
% { |
| 317 |
% \l_@@_celltag_tl |
| 318 |
% \l_@@_pcelltag_tl |
| 319 |
% ,\l_@@_rowtag_tl |
| 320 |
% ,\l_@@_table_tl |
| 321 |
% ,\l_@@_cellattribute_tl |
| 322 |
% ,\l_@@_rowattribute_tl |
| 323 |
% ,\l_@@_tmpa_clist |
| 324 |
% ,\l_@@_tmpa_tl |
| 325 |
% ,\l_@@_tmpa_str |
| 326 |
% } |
| 327 |
% This is for the celltag, e.g. TD or TH: |
| 328 |
% \begin{macrocode} |
| 329 |
\tl_new:N \l_@@_celltag_tl |
| 330 |
\tl_set:Nn \l_@@_celltag_tl {TD} |
| 331 |
\tl_new:N \l_@@_pcelltag_tl |
| 332 |
\tl_set:Nn \l_@@_pcelltag_tl {TD} |
| 333 |
% \end{macrocode} |
| 334 |
% For the rowtag, probably always TR: |
| 335 |
% \begin{macrocode} |
| 336 |
\tl_new:N \l_@@_rowtag_tl |
| 337 |
\tl_set:Nn \l_@@_rowtag_tl {TR} |
| 338 |
% \end{macrocode} |
| 339 |
% For the tabletag, probably always Table: |
| 340 |
% \begin{macrocode} |
| 341 |
\tl_new:N \l_@@_tabletag_tl |
| 342 |
\tl_set:Nn \l_@@_tabletag_tl {Table} |
| 343 |
% \end{macrocode} |
| 344 |
% And here cell and row attributes: |
| 345 |
% \begin{macrocode} |
| 346 |
\tl_new:N \l_@@_cellattribute_tl |
| 347 |
\tl_set:Nn \l_@@_cellattribute_tl {} |
| 348 |
\tl_new:N \l_@@_rowattribute_tl |
| 349 |
\tl_set:Nn \l_@@_rowattribute_tl {} |
| 350 |
% \end{macrocode} |
| 351 |
% Variable to store cell info like which cell must be skipped when tagging multirows. |
| 352 |
% \begin{macrocode} |
| 353 |
\prop_new:N\g_@@_untagged_cells_prop |
| 354 |
\prop_new:N\l_@@_saved_untagged_cells_prop |
| 355 |
% \end{macrocode} |
| 356 |
% Temp variables |
| 357 |
% \begin{macrocode} |
| 358 |
\clist_new:N \l_@@_tmpa_clist |
| 359 |
\tl_new:N \l_@@_tmpa_tl |
| 360 |
\str_new:N \l_@@_tmpa_str |
| 361 |
% \end{macrocode} |
| 362 |
% \end{macro} |
| 363 |
% |
| 364 |
% \subsection{Tagging support sockets} |
| 365 |
% |
| 366 |
% |
| 367 |
% This are the standard plugs for tagging of cells and rows. |
| 368 |
% |
| 369 |
% The following two sockets are defined in lttagging, but we check |
| 370 |
% for their existence until the release 11/2024. |
| 371 |
% \begin{macrocode} |
| 372 |
\socket_if_exist:nF {tagsupport/tbl/init/celldata} |
| 373 |
{ |
| 374 |
\NewTaggingSocket{tbl/init/celldata}{0} |
| 375 |
\NewTaggingSocket{tbl/restore/celldata}{0} |
| 376 |
} |
| 377 |
% \end{macrocode} |
| 378 |
% \begin{plugdecl}{default} |
| 379 |
% This socket is used inside \cs{tbl_init_cell_data_for_table} for the |
| 380 |
% case that this a nested table in a cell. |
| 381 |
% \begin{macrocode} |
| 382 |
\NewTaggingSocketPlug{tbl/init/celldata}{default} |
| 383 |
{ |
| 384 |
\prop_set_eq:NN\l_@@_saved_untagged_cells_prop \g_@@_untagged_cells_prop |
| 385 |
\prop_gclear:N \g_@@_untagged_cells_prop |
| 386 |
} |
| 387 |
\AssignTaggingSocketPlug{tbl/init/celldata}{default} |
| 388 |
% \end{macrocode} |
| 389 |
% \end{plugdecl} |
| 390 |
|
| 391 |
% \begin{plugdecl}{default} |
| 392 |
% This socket is used inside \cs{tbl_restore_outer_cell_data:} and restores |
| 393 |
% values when a nested table is ended. |
| 394 |
% \begin{macrocode} |
| 395 |
\NewTaggingSocketPlug{tbl/restore/celldata}{default} |
| 396 |
{ |
| 397 |
\prop_gset_eq:NN\g_@@_untagged_cells_prop \l_@@_saved_untagged_cells_prop |
| 398 |
} |
| 399 |
\AssignTaggingSocketPlug{tbl/restore/celldata}{default} |
| 400 |
% \end{macrocode} |
| 401 |
% \end{plugdecl} |
| 402 |
% |
| 403 |
% \begin{plugdecl}{TD} |
| 404 |
% \begin{macrocode} |
| 405 |
\NewTaggingSocketPlug{tbl/cell/begin}{TD} |
| 406 |
{ |
| 407 |
% \end{macrocode} |
| 408 |
% Next line was previously outside of the plug, so if we want to execute it |
| 409 |
% always even if the noop plug is in force this needs a different solution. |
| 410 |
% \begin{macrocode} |
| 411 |
\@@_show_curr_cell_data: |
| 412 |
% \end{macrocode} |
| 413 |
% We test if the cell should be tagged at all. |
| 414 |
% \begin{macrocode} |
| 415 |
\@@_if_tag_cell:nnT {\g_@@_row_int } { \g_@@_col_int } |
| 416 |
{ |
| 417 |
% \end{macrocode} |
| 418 |
% this sets row headers |
| 419 |
% \begin{macrocode} |
| 420 |
\clist_if_in:NVT \l_@@_header_columns_clist\g_@@_col_int |
| 421 |
{ |
| 422 |
\tl_set:Nn \l_@@_celltag_tl {TH} |
| 423 |
\tl_set:Ne \l_@@_cellattribute_tl {\l_@@_cellattribute_tl,TH-row} |
| 424 |
} |
| 425 |
% \end{macrocode} |
| 426 |
% Here we handle negative value for row headers: |
| 427 |
% \begin{macrocode} |
| 428 |
\tl_set:Ne \l_@@_tmpa_tl |
| 429 |
{\int_eval:n { \g_@@_col_int - 1 - \g_@@_table_cols_tl }} |
| 430 |
\clist_if_in:NoT \l_@@_header_columns_clist { \l_@@_tmpa_tl } |
| 431 |
{ |
| 432 |
\tl_set:Nn \l_@@_celltag_tl {TH} |
| 433 |
\tl_set:Ne \l_@@_cellattribute_tl {\l_@@_cellattribute_tl,TH-row} |
| 434 |
} |
| 435 |
\tag_struct_begin:n |
| 436 |
{ |
| 437 |
tag =\l_@@_celltag_tl, |
| 438 |
attribute-class ={\l_@@_cellattribute_tl} |
| 439 |
} |
| 440 |
\seq_gput_right:Ne \g_@@_struct_cur_seq { \tag_get:n {struct_num} } |
| 441 |
% \end{macrocode} |
| 442 |
% we store the cells of multicolumns as negative number. This allow to skip them |
| 443 |
% or to use them as needed. |
| 444 |
% \begin{macrocode} |
| 445 |
\int_step_inline:nn { \g_@@_span_tl - 1 } |
| 446 |
{ |
| 447 |
\seq_gput_right:Ne \g_@@_struct_cur_seq { -\tag_get:n {struct_num} } |
| 448 |
} |
| 449 |
\tag_mc_begin:n{} |
| 450 |
} |
| 451 |
} |
| 452 |
% \end{macrocode} |
| 453 |
% \end{plugdecl} |
| 454 |
% |
| 455 |
% \begin{plugdecl}{TD} |
| 456 |
% \begin{macrocode} |
| 457 |
\NewTaggingSocketPlug{tbl/cell/end}{TD} |
| 458 |
{ |
| 459 |
\@@_if_tag_cell:nnT {\g__tbl_row_int } { \g__tbl_col_int } |
| 460 |
{ |
| 461 |
\tag_mc_end: |
| 462 |
\tag_struct_end: |
| 463 |
} |
| 464 |
} |
| 465 |
% \end{macrocode} |
| 466 |
% \end{plugdecl} |
| 467 |
% |
| 468 |
% In p-columns we need a slightly different plug which reactivates the |
| 469 |
% paragraph tagging. |
| 470 |
% \changes{0.85s}{2025-08-01}{fix typo celltag to pcelltag, tagging issue 965} |
| 471 |
% \begin{plugdecl}{TDpbox} |
| 472 |
% \begin{macrocode} |
| 473 |
\NewTaggingSocketPlug{tbl/pcell/begin}{TDpbox} |
| 474 |
{ |
| 475 |
\@@_show_curr_cell_data: |
| 476 |
\@@_if_tag_cell:nnT {\g__tbl_row_int } { \g__tbl_col_int } |
| 477 |
{ |
| 478 |
\clist_if_in:NVT \l_@@_header_columns_clist\g_@@_col_int |
| 479 |
{ |
| 480 |
\tl_set:Nn \l_@@_pcelltag_tl {TH} |
| 481 |
\tl_set:Ne \l_@@_cellattribute_tl {\l_@@_cellattribute_tl,TH-row} |
| 482 |
} |
| 483 |
\tag_struct_begin:n |
| 484 |
{ |
| 485 |
tag =\l_@@_pcelltag_tl, |
| 486 |
attribute-class ={\l_@@_cellattribute_tl} |
| 487 |
} |
| 488 |
\seq_gput_right:Ne \g_@@_struct_cur_seq { \tag_get:n {struct_num} } |
| 489 |
\int_step_inline:nn { \g_@@_span_tl - 1 } |
| 490 |
{ |
| 491 |
\seq_gput_right:Ne \g_@@_struct_cur_seq { -\tag_get:n {struct_num} } |
| 492 |
} |
| 493 |
\tagpdfparaOn |
| 494 |
\tl_set:Nn \l__tag_para_main_tag_tl {Div} |
| 495 |
} |
| 496 |
} |
| 497 |
% \end{macrocode} |
| 498 |
% \end{plugdecl} |
| 499 |
% |
| 500 |
% \begin{plugdecl}{TDpbox} |
| 501 |
% \begin{macrocode} |
| 502 |
\NewTaggingSocketPlug{tbl/pcell/end}{TDpbox} |
| 503 |
{ |
| 504 |
\@@_if_tag_cell:nnT {\g_@@_row_int } { \g_@@_col_int } |
| 505 |
{ |
| 506 |
\tag_struct_end: |
| 507 |
\legacy_if:nT {@endpe}{\par} |
| 508 |
\mode_if_vertical:T{ \tagpdfparaOff } |
| 509 |
} |
| 510 |
} |
| 511 |
% \end{macrocode} |
| 512 |
% \end{plugdecl} |
| 513 |
% |
| 514 |
% \begin{plugdecl}{TR} |
| 515 |
% \begin{macrocode} |
| 516 |
\NewTaggingSocketPlug{tbl/row/begin}{TR} |
| 517 |
{ |
| 518 |
\seq_gclear:N \g_@@_struct_cur_seq |
| 519 |
\tag_struct_begin:n |
| 520 |
{ |
| 521 |
tag =\l_@@_rowtag_tl, |
| 522 |
attribute-class=\l_@@_rowattribute_tl |
| 523 |
} |
| 524 |
\seq_gput_right:Ne \g_@@_struct_rows_seq { \tag_get:n {struct_num} } |
| 525 |
} |
| 526 |
% \end{macrocode} |
| 527 |
% \end{plugdecl} |
| 528 |
% |
| 529 |
% \begin{plugdecl}{TR} |
| 530 |
% \changes{0.85t}{2025-07-02}{Removed unneeded \cs{tag_if_active:T}} |
| 531 |
% \begin{macrocode} |
| 532 |
\NewTaggingSocketPlug{tbl/row/end}{TR} |
| 533 |
{ |
| 534 |
\@@_add_missing_cells: |
| 535 |
\seq_gput_right:Ne \g_@@_struct_cells_seq |
| 536 |
{ |
| 537 |
\seq_use:Nn \g_@@_struct_cur_seq {,} |
| 538 |
} |
| 539 |
\int_compare:nNnTF { \g_@@_row_int } = |
| 540 |
{ \seq_count:N \g_@@_struct_cells_seq } |
| 541 |
{ |
| 542 |
\@@_trace:n |
| 543 |
{==>~ |
| 544 |
structure~stored~for~row~\int_use:N\g_@@_row_int :~ |
| 545 |
\seq_use:Nn \g_@@_struct_cur_seq {,} |
| 546 |
} |
| 547 |
} |
| 548 |
{ \ERRORtbl/row } % should not happen ... |
| 549 |
\tag_struct_end: |
| 550 |
} |
| 551 |
% \end{macrocode} |
| 552 |
% \end{plugdecl} |
| 553 |
% |
| 554 |
% And the plugs for the table as whole. The code can be different for |
| 555 |
% normal tables which can also be used inline and nested and |
| 556 |
% \enquote{vmode} tables like longtable. |
| 557 |
% |
| 558 |
% \begin{macro}{\l__tag_block_flattened_level_int} |
| 559 |
% Count the levels of nested blockenvs starting with the first that |
| 560 |
% is \enquote{flattened}. The counter is defined in lttagging.dtx, |
| 561 |
% but until the next release 11/24 we set it up here too so that we can |
| 562 |
% use it in the following socket |
| 563 |
% \begin{macrocode} |
| 564 |
\int_if_exist:NF \l__tag_block_flattened_level_int |
| 565 |
{ |
| 566 |
\int_new:N \l__tag_block_flattened_level_int |
| 567 |
} |
| 568 |
% \end{macrocode} |
| 569 |
% \end{macro} |
| 570 |
% |
| 571 |
% \begin{plugdecl}{Table} |
| 572 |
% Inside a TD or TR Part is not allowed as child. For structures that restore |
| 573 |
% paragraph settings we therefore need a special plug that adjust the settings. |
| 574 |
% Currently we set the para main tag to Div. This leads to double Div-structures |
| 575 |
% but flattening the paragraph doesn't work, it errors if there is a list inside. |
| 576 |
% \begin{macrocode} |
| 577 |
\NewTaggingSocketPlug{para/restore}{Table} |
| 578 |
{ |
| 579 |
\tl_set:Nn \l__tag_para_main_tag_tl {Div} |
| 580 |
\tl_set_eq:NN \l__tag_para_tag_tl\l__tag_para_tag_default_tl |
| 581 |
\bool_set_true:N \l__tag_para_bool |
| 582 |
\bool_set_false:N \l__tag_para_flattened_bool |
| 583 |
\int_zero:N \l__tag_block_flattened_level_int |
| 584 |
} |
| 585 |
% \end{macrocode} |
| 586 |
% \end{plugdecl} |
| 587 |
% |
| 588 |
% \begin{plugdecl}{Table} |
| 589 |
% Inside a table we currently only disable paratagging. We assume |
| 590 |
% that these sockets are called in a group, so there is no |
| 591 |
% need to reenable paratagging. |
| 592 |
% \begin{macrocode} |
| 593 |
\NewTaggingSocketPlug{tbl/init}{Table} |
| 594 |
{ |
| 595 |
\bool_set_false:N \l__tag_para_bool |
| 596 |
\AssignTaggingSocketPlug{para/restore}{Table} |
| 597 |
% \end{macrocode} |
| 598 |
% We also initialize the structure data variables a this point. |
| 599 |
% \begin{macrocode} |
| 600 |
\@@_init_struct_data: |
| 601 |
} |
| 602 |
% \end{macrocode} |
| 603 |
% \end{plugdecl} |
| 604 |
% |
| 605 |
% |
| 606 |
% \begin{plugdecl}{Table} |
| 607 |
% This plug will fine tune the structure. |
| 608 |
% \begin{macrocode} |
| 609 |
\NewTaggingSocketPlug{tbl/finalize}{Table} |
| 610 |
{ |
| 611 |
\@@_set_header_rows: |
| 612 |
% \end{macrocode} |
| 613 |
% Similarly, we restore the outer values of the structure data when |
| 614 |
% we leave the table. |
| 615 |
% \begin{macrocode} |
| 616 |
\@@_restore_struct_data: |
| 617 |
} |
| 618 |
% \end{macrocode} |
| 619 |
% \end{plugdecl} |
| 620 |
% |
| 621 |
% |
| 622 |
% |
| 623 |
% |
| 624 |
% \begin{plugdecl}{Table} |
| 625 |
% This plug will initialize the structure in longtable. |
| 626 |
% \begin{macrocode} |
| 627 |
\NewTaggingSocketPlug{tbl/longtable/init}{Table} |
| 628 |
{ |
| 629 |
\seq_gclear:N\g_@@_struct_rows_seq |
| 630 |
\seq_gclear:N\g_@@_struct_cells_seq |
| 631 |
\seq_gclear:N\g_@@_struct_cur_seq |
| 632 |
\seq_gclear:N\g_@@_LT@firsthead_rows_seq |
| 633 |
\seq_gclear:N\g_@@_LT@head_rows_seq |
| 634 |
\seq_gclear:N\g_@@_LT@lastfoot_rows_seq |
| 635 |
\seq_gclear:N\g_@@_LT@foot_rows_seq |
| 636 |
} |
| 637 |
% \end{macrocode} |
| 638 |
% \end{plugdecl} |
| 639 |
% |
| 640 |
% |
| 641 |
|
| 642 |
|
| 643 |
% \begin{plugdecl}{Table} |
| 644 |
% This plug will fine tune the structure in longtable. |
| 645 |
% \begin{macrocode} |
| 646 |
\NewTaggingSocketPlug{tbl/longtable/finalize}{Table} |
| 647 |
{ |
| 648 |
% \end{macrocode} |
| 649 |
% If neither \cs{endhead} nor \cs{endfirsthead} has been used |
| 650 |
% we use the standard header command: |
| 651 |
% \begin{macrocode} |
| 652 |
\bool_lazy_and:nnTF |
| 653 |
{ \seq_if_empty_p:N \g_@@_LT@head_rows_seq } |
| 654 |
{ \seq_if_empty_p:N \g_@@_LT@firsthead_rows_seq } |
| 655 |
{ \@@_set_header_rows: } |
| 656 |
% \end{macrocode} |
| 657 |
% Otherwise, if firsthead has not been used we use head. For this |
| 658 |
% we simple retrieve the row numbers and then call the header |
| 659 |
% command. |
| 660 |
% \begin{macrocode} |
| 661 |
{ |
| 662 |
\seq_if_empty:NTF \g_@@_LT@firsthead_rows_seq |
| 663 |
{ |
| 664 |
\clist_set:Ne \l_@@_header_rows_clist |
| 665 |
{\seq_use:Nn \g_@@_LT@head_rows_seq {,}} |
| 666 |
\@@_set_header_rows: |
| 667 |
} |
| 668 |
% \end{macrocode} |
| 669 |
% In the other case we use firsthead. |
| 670 |
% \begin{macrocode} |
| 671 |
{ |
| 672 |
\clist_set:Ne \l_@@_header_rows_clist |
| 673 |
{ \seq_use:Nn \g_@@_LT@firsthead_rows_seq {,} } |
| 674 |
\@@_set_header_rows: |
| 675 |
% \end{macrocode} |
| 676 |
% Additionally we have to remove the head to avoid duplication. The |
| 677 |
% one option here is to remove the rows from the kid sequence of |
| 678 |
% the table (which will lead to orphaned structure elements), the |
| 679 |
% other to make them artifact. For now we use the first option for |
| 680 |
% pdf 1.7 and the second for pdf 2.0. |
| 681 |
% \begin{macrocode} |
| 682 |
\pdf_version_compare:NnTF < {2.0} |
| 683 |
{ |
| 684 |
\seq_map_inline:Nn \g_@@_LT@head_rows_seq |
| 685 |
{ |
| 686 |
\seq_gset_item:cnn |
| 687 |
{g__tag_struct_kids_ \g_@@_struct_table_tl _seq} |
| 688 |
{ ##1 } |
| 689 |
{} |
| 690 |
% \end{macrocode} |
| 691 |
% Not sure if needed, but if needed we can remove also the P tag. |
| 692 |
% This is currently disabled as it produce warnings. TODO: This |
| 693 |
% needs also a tagpdf command which takes care of debug code. |
| 694 |
% \begin{macrocode} |
| 695 |
\tl_set:Ne \l_@@_tmpa_tl |
| 696 |
{ \seq_item:Nn\g_@@_struct_rows_seq {##1} } |
| 697 |
\prop_if_exist:cT |
| 698 |
{ g__tag_struct_ \l_@@_tmpa_tl _prop } |
| 699 |
{ |
| 700 |
%\prop_gremove:cn {g__tag_struct_ \l_@@_tmpa_tl _prop} {P} |
| 701 |
} |
| 702 |
} |
| 703 |
} |
| 704 |
{ |
| 705 |
\seq_map_inline:Nn \g_@@_LT@head_rows_seq |
| 706 |
{ |
| 707 |
\tl_set:Ne \l_@@_tmpa_tl |
| 708 |
{ \seq_item:Nn\g_@@_struct_rows_seq {##1} } |
| 709 |
\prop_if_exist:cT |
| 710 |
{ g__tag_struct_ \l_@@_tmpa_tl _prop } |
| 711 |
{ |
| 712 |
\__tag_struct_prop_gput:onn { \l_@@_tmpa_tl } {S}{/Artifact} |
| 713 |
} |
| 714 |
} |
| 715 |
} |
| 716 |
} |
| 717 |
} |
| 718 |
% \end{macrocode} |
| 719 |
% The foot is handled similar, the difference is |
| 720 |
% that we have to move it to the end one of them |
| 721 |
% is not empty, but do nothing if they aren't there. |
| 722 |
% \begin{macrocode} |
| 723 |
\bool_lazy_and:nnF |
| 724 |
{ \seq_if_empty_p:N \g_@@_LT@foot_rows_seq } |
| 725 |
{ \seq_if_empty_p:N \g_@@_LT@lastfoot_rows_seq } |
| 726 |
{ |
| 727 |
% \end{macrocode} |
| 728 |
% If lastfoot is empty move foot to the end. |
| 729 |
% \begin{macrocode} |
| 730 |
\seq_if_empty:NTF \g_@@_LT@lastfoot_rows_seq |
| 731 |
{ |
| 732 |
\seq_map_inline:Nn \g_@@_LT@foot_rows_seq |
| 733 |
{ |
| 734 |
\tl_set:Ne \l_@@_tmpa_tl |
| 735 |
{ |
| 736 |
\seq_item:cn |
| 737 |
{g__tag_struct_kids_ \g_@@_struct_table_tl _seq} |
| 738 |
{##1} |
| 739 |
} |
| 740 |
\seq_gset_item:cnn |
| 741 |
{g__tag_struct_kids_ \g_@@_struct_table_tl _seq} |
| 742 |
{ ##1 } |
| 743 |
{} |
| 744 |
\seq_gput_right:cV |
| 745 |
{g__tag_struct_kids_ \g_@@_struct_table_tl _seq} |
| 746 |
\l_@@_tmpa_tl |
| 747 |
} |
| 748 |
} |
| 749 |
% \end{macrocode} |
| 750 |
% If lastfoot is not empty we move that. |
| 751 |
% \begin{macrocode} |
| 752 |
{ |
| 753 |
\seq_map_inline:Nn \g_@@_LT@lastfoot_rows_seq |
| 754 |
{ |
| 755 |
\tl_set:Ne \l_@@_tmpa_tl |
| 756 |
{ |
| 757 |
\seq_item:cn |
| 758 |
{g__tag_struct_kids_ \g_@@_struct_table_tl _seq} |
| 759 |
{##1} |
| 760 |
} |
| 761 |
\seq_gset_item:cnn |
| 762 |
{g__tag_struct_kids_ \g_@@_struct_table_tl _seq} |
| 763 |
{ ##1 } |
| 764 |
{} |
| 765 |
\seq_gput_right:cV |
| 766 |
{g__tag_struct_kids_ \g_@@_struct_table_tl _seq} |
| 767 |
\l_@@_tmpa_tl |
| 768 |
} |
| 769 |
% \end{macrocode} |
| 770 |
% and we hide foot |
| 771 |
% \begin{macrocode} |
| 772 |
\pdf_version_compare:NnTF < {2.0} |
| 773 |
{ |
| 774 |
\seq_map_inline:Nn \g_@@_LT@foot_rows_seq |
| 775 |
{ |
| 776 |
\seq_gset_item:cnn |
| 777 |
{g__tag_struct_kids_ \g_@@_struct_table_tl _seq} |
| 778 |
{ ##1 } |
| 779 |
{} |
| 780 |
% \end{macrocode} |
| 781 |
% Not sure if needed, but if needed we can remove also the P tag. |
| 782 |
% This is currently disabled as it produce warnings. |
| 783 |
% TODO: This needs also |
| 784 |
% a tagpdf command which takes care of debug code. |
| 785 |
% \begin{macrocode} |
| 786 |
\tl_set:Ne \l_@@_tmpa_tl |
| 787 |
{ \seq_item:Nn\g_@@_struct_rows_seq {##1} } |
| 788 |
\prop_if_exist:cT |
| 789 |
{ g__tag_struct_ \l_@@_tmpa_tl _prop } |
| 790 |
{ |
| 791 |
%\prop_gremove:cn {g__tag_struct_ \l_@@_tmpa_tl _prop} {P} |
| 792 |
} |
| 793 |
} |
| 794 |
} |
| 795 |
{ |
| 796 |
\seq_map_inline:Nn \g_@@_LT@foot_rows_seq |
| 797 |
{ |
| 798 |
\tl_set:Ne \l_@@_tmpa_tl |
| 799 |
{ \seq_item:Nn\g_@@_struct_rows_seq {##1} } |
| 800 |
\prop_if_exist:cT |
| 801 |
{ g__tag_struct_ \l_@@_tmpa_tl _prop } |
| 802 |
{ |
| 803 |
\__tag_struct_prop_gput:onn {\l_@@_tmpa_tl} {S}{/Artifact} |
| 804 |
} |
| 805 |
} |
| 806 |
} |
| 807 |
} |
| 808 |
} |
| 809 |
} |
| 810 |
% \end{macrocode} |
| 811 |
% \end{plugdecl} |
| 812 |
% |
| 813 |
% |
| 814 |
% |
| 815 |
% \begin{plugdecl}{Table} |
| 816 |
% |
| 817 |
% We must avoid that the reuse of the header foot box leads to duplicated |
| 818 |
% content, thus reset attribute of the box: |
| 819 |
% \begin{macrocode} |
| 820 |
\NewTaggingSocketPlug{tbl/longtable/head}{Table} |
| 821 |
{ |
| 822 |
\tagmcbegin{artifact} |
| 823 |
\tag_mc_reset_box:N\LT@head |
| 824 |
\tagmcend |
| 825 |
} |
| 826 |
% \end{macrocode} |
| 827 |
% \end{plugdecl} |
| 828 |
% |
| 829 |
% \begin{plugdecl}{Table} |
| 830 |
% \begin{macrocode} |
| 831 |
\NewTaggingSocketPlug{tbl/longtable/foot}{Table} |
| 832 |
{ |
| 833 |
\tagmcbegin{artifact} |
| 834 |
\tag_mc_reset_box:N \LT@foot |
| 835 |
\tagmcend |
| 836 |
} |
| 837 |
% \end{macrocode} |
| 838 |
% \end{plugdecl} |
| 839 |
% |
| 840 |
% \begin{plugdecl}{Table} |
| 841 |
% \begin{macrocode} |
| 842 |
\NewTaggingSocketPlug{tbl/hmode/begin}{Table} |
| 843 |
{ |
| 844 |
\tag_mc_end_push: |
| 845 |
% \end{macrocode} |
| 846 |
% Close the P-chunk. This assumes that para-tagging is active. |
| 847 |
% For nested tables that is not necessarily true, so we test for it. |
| 848 |
% \begin{macrocode} |
| 849 |
\bool_lazy_and:nnT |
| 850 |
{ \bool_if_exist_p:N \l__tag_para_bool } { \l__tag_para_bool } |
| 851 |
{ \tag_struct_end:n { text } } |
| 852 |
\tag_struct_begin:n {tag=\l_@@_tabletag_tl} |
| 853 |
\tl_gset:Ne \g_@@_struct_table_tl { \tag_get:n {struct_num} } |
| 854 |
} |
| 855 |
% \end{macrocode} |
| 856 |
% \end{plugdecl} |
| 857 |
% |
| 858 |
% \begin{plugdecl}{LayoutTable} |
| 859 |
% \changes{v0.85p}{2025/01/05}{new plugs for layout tables (tagging/778)} |
| 860 |
% This plug is meant for presentation tables, it sets the ARIA role. |
| 861 |
% \begin{macrocode} |
| 862 |
\NewTaggingSocketPlug{tbl/hmode/begin}{LayoutTable} |
| 863 |
{ |
| 864 |
\tag_mc_end_push: |
| 865 |
% \end{macrocode} |
| 866 |
% Close the P-chunk. This assumes that para-tagging is active. |
| 867 |
% For nested tables that is not necessarily true, so we test for it. |
| 868 |
% \begin{macrocode} |
| 869 |
\bool_lazy_and:nnT |
| 870 |
{ \bool_if_exist_p:N \l__tag_para_bool } { \l__tag_para_bool } |
| 871 |
{ \tag_struct_end:n { text } } |
| 872 |
\tag_struct_begin:n {tag=\l_@@_tabletag_tl,attribute-class=ARIA-role-presentation} |
| 873 |
\tl_gset:Ne \g_@@_struct_table_tl { \tag_get:n {struct_num} } |
| 874 |
} |
| 875 |
% \end{macrocode} |
| 876 |
% \end{plugdecl} |
| 877 |
% |
| 878 |
% \begin{plugdecl}{Table} |
| 879 |
% \begin{macrocode} |
| 880 |
\NewTaggingSocketPlug{tbl/hmode/end}{Table} |
| 881 |
{ |
| 882 |
\tag_struct_end: |
| 883 |
% \end{macrocode} |
| 884 |
% reopen the P-chunk. This assumes that para-tagging is active. |
| 885 |
% For nested tables that is not necessarily true, so we test for it. |
| 886 |
% \begin{macrocode} |
| 887 |
\bool_lazy_and:nnT |
| 888 |
{ \bool_if_exist_p:N \l__tag_para_bool } { \l__tag_para_bool } |
| 889 |
{ \tag_struct_begin:n { tag=\l__tag_para_tag_tl } } |
| 890 |
\tag_mc_begin_pop:n{} |
| 891 |
} |
| 892 |
% \end{macrocode} |
| 893 |
% \end{plugdecl} |
| 894 |
% |
| 895 |
% \begin{plugdecl}{Table} |
| 896 |
% \begin{macrocode} |
| 897 |
\NewTaggingSocketPlug{tbl/vmode/begin}{Table} |
| 898 |
{ |
| 899 |
\tag_struct_begin:n {tag=\l_@@_tabletag_tl} |
| 900 |
\tl_gset:Ne \g_@@_struct_table_tl { \tag_get:n {struct_num} } |
| 901 |
} |
| 902 |
% \end{macrocode} |
| 903 |
% \end{plugdecl} |
| 904 |
% |
| 905 |
% \begin{plugdecl}{Table} |
| 906 |
% \begin{macrocode} |
| 907 |
\NewTaggingSocketPlug{tbl/vmode/begin}{LayoutTable} |
| 908 |
{ |
| 909 |
\tag_struct_begin:n {tag=\l_@@_tabletag_tl,attribute-class=ARIA-role-presentation} |
| 910 |
\tl_gset:Ne \g_@@_struct_table_tl { \tag_get:n {struct_num} } |
| 911 |
} |
| 912 |
% \end{macrocode} |
| 913 |
% \end{plugdecl} |
| 914 |
% |
| 915 |
% |
| 916 |
% \begin{plugdecl}{Table} |
| 917 |
% \begin{macrocode} |
| 918 |
\NewTaggingSocketPlug{tbl/vmode/end}{Table} |
| 919 |
{ |
| 920 |
\tag_struct_end: |
| 921 |
\par |
| 922 |
} |
| 923 |
% \end{macrocode} |
| 924 |
% \end{plugdecl} |
| 925 |
% |
| 926 |
% |
| 927 |
% \begin{plugdecl}{code} |
| 928 |
% This socket takes a number, checks if is larger than one, |
| 929 |
% checks if the colspan attribute already exists (we can't predefine an |
| 930 |
% arbitrary number), and updates \cs{l_@@_cellattribute_tl}. |
| 931 |
% \begin{macrocode} |
| 932 |
\NewTaggingSocketPlug{tbl/colspan}{code} |
| 933 |
{ |
| 934 |
\int_compare:nNnT {#1}>{1} |
| 935 |
{ |
| 936 |
\prop_get:NeNF \g__tag_attr_entries_prop |
| 937 |
{colspan-\int_eval:n{#1}} |
| 938 |
\l_@@_tmpa_tl |
| 939 |
{ |
| 940 |
\__tag_attr_new_entry:ee |
| 941 |
{colspan-\int_eval:n{#1}} |
| 942 |
{/O /Table /ColSpan~\int_eval:n{#1}} |
| 943 |
} |
| 944 |
\tl_set:Ne \l_@@_cellattribute_tl |
| 945 |
{\l_@@_cellattribute_tl,colspan-\int_eval:n{#1}} |
| 946 |
} |
| 947 |
} |
| 948 |
% \end{macrocode} |
| 949 |
% \end{plugdecl} |
| 950 |
% |
| 951 |
% |
| 952 |
% |
| 953 |
% |
| 954 |
% \begin{plugdecl}{code} |
| 955 |
% The sockets will be in lttagging.dtx, but that may only happen in |
| 956 |
% the next main release, so for now we test if they are in the |
| 957 |
% format and if not define them now. |
| 958 |
% \begin{macrocode} |
| 959 |
\str_if_exist:cF { l__socket_tagsupport/tbl/leaders/end_plug_str } |
| 960 |
{ |
| 961 |
\NewTaggingSocket{tbl/leaders/begin}{0} |
| 962 |
\NewTaggingSocket{tbl/leaders/end}{0} |
| 963 |
} |
| 964 |
% \end{macrocode} |
| 965 |
% |
| 966 |
% \begin{macrocode} |
| 967 |
\NewTaggingSocketPlug{tbl/leaders/begin}{code} |
| 968 |
{ \tag_mc_begin:n{artifact} } |
| 969 |
\NewTaggingSocketPlug{tbl/leaders/end}{code} |
| 970 |
{ \tag_mc_end: } |
| 971 |
% \end{macrocode} |
| 972 |
% \end{plugdecl} |
| 973 |
% |
| 974 |
% |
| 975 |
% |
| 976 |
%\subsection{Environments} |
| 977 |
% |
| 978 |
% Currently we support only tabular, tabular*, tabularx and longtable |
| 979 |
% (and possibly environments build directly on top of them). |
| 980 |
% |
| 981 |
% The \env{array} environment is math. So we disable table tagging for now. |
| 982 |
% We use the command hook to catch also cases where \cs{array} is used directly |
| 983 |
% in other environments like matrix environments. |
| 984 |
% Perhaps table tagging should be disable for math generally, but then |
| 985 |
% we have to handle text insertions. |
| 986 |
% \begin{macrocode} |
| 987 |
\AddToHook{cmd/array/before}{\__tag_tbl_disable:} |
| 988 |
% \end{macrocode} |
| 989 |
% |
| 990 |
% |
| 991 |
% \subsection{Interfaces to tagging} |
| 992 |
% |
| 993 |
% \subsubsection{Tagging helper commands} |
| 994 |
|
| 995 |
% \subsubsection{Disabling/enabling} |
| 996 |
% |
| 997 |
% For now we have only the option true/false but this will probably be extended |
| 998 |
% to allow different setups like first row header etc. |
| 999 |
|
| 1000 |
% \begin{macro}{\__tag_tbl_disable:} |
| 1001 |
% |
| 1002 |
% \begin{macrocode} |
| 1003 |
\cs_new_protected:Npn \__tag_tbl_disable: |
| 1004 |
{ |
| 1005 |
\AssignTaggingSocketPlug{tbl/cell/begin}{noop} |
| 1006 |
\AssignTaggingSocketPlug{tbl/cell/end}{noop} |
| 1007 |
\AssignTaggingSocketPlug{tbl/pcell/begin}{noop} |
| 1008 |
\AssignTaggingSocketPlug{tbl/pcell/end}{noop} |
| 1009 |
\AssignTaggingSocketPlug{tbl/row/begin}{noop} |
| 1010 |
\AssignTaggingSocketPlug{tbl/row/end}{noop} |
| 1011 |
\AssignTaggingSocketPlug{tbl/init}{noop} |
| 1012 |
\AssignTaggingSocketPlug{tbl/finalize}{noop} |
| 1013 |
\AssignTaggingSocketPlug{tbl/longtable/init}{noop} |
| 1014 |
\AssignTaggingSocketPlug{tbl/longtable/head}{noop} |
| 1015 |
\AssignTaggingSocketPlug{tbl/longtable/foot}{noop} |
| 1016 |
\AssignTaggingSocketPlug{tbl/longtable/finalize}{noop} |
| 1017 |
\AssignTaggingSocketPlug{tbl/hmode/begin}{noop} |
| 1018 |
\AssignTaggingSocketPlug{tbl/hmode/end}{noop} |
| 1019 |
\AssignTaggingSocketPlug{tbl/vmode/begin}{noop} |
| 1020 |
\AssignTaggingSocketPlug{tbl/vmode/end}{noop} |
| 1021 |
\AssignTaggingSocketPlug{tbl/colspan}{noop} |
| 1022 |
\AssignTaggingSocketPlug{tbl/leaders/begin}{noop} |
| 1023 |
\AssignTaggingSocketPlug{tbl/leaders/end}{noop} |
| 1024 |
} |
| 1025 |
% \end{macrocode} |
| 1026 |
% \end{macro} |
| 1027 |
|
| 1028 |
|
| 1029 |
% \begin{macro}{\__tag_tbl_enable:} |
| 1030 |
% |
| 1031 |
% \begin{macrocode} |
| 1032 |
\cs_new_protected:Npn \__tag_tbl_enable: |
| 1033 |
{ |
| 1034 |
\AssignTaggingSocketPlug{tbl/cell/begin}{TD} |
| 1035 |
\AssignTaggingSocketPlug{tbl/cell/end}{TD} |
| 1036 |
\AssignTaggingSocketPlug{tbl/pcell/begin}{TDpbox} |
| 1037 |
\AssignTaggingSocketPlug{tbl/pcell/end}{TDpbox} |
| 1038 |
\AssignTaggingSocketPlug{tbl/row/begin}{TR} |
| 1039 |
\AssignTaggingSocketPlug{tbl/row/end}{TR} |
| 1040 |
\AssignTaggingSocketPlug{tbl/init}{Table} |
| 1041 |
\AssignTaggingSocketPlug{tbl/finalize}{Table} |
| 1042 |
\AssignTaggingSocketPlug{tbl/longtable/head}{Table} |
| 1043 |
\AssignTaggingSocketPlug{tbl/longtable/foot}{Table} |
| 1044 |
\AssignTaggingSocketPlug{tbl/longtable/init}{Table} |
| 1045 |
\AssignTaggingSocketPlug{tbl/longtable/finalize}{Table} |
| 1046 |
\AssignTaggingSocketPlug{tbl/hmode/begin}{Table} |
| 1047 |
\AssignTaggingSocketPlug{tbl/hmode/end}{Table} |
| 1048 |
\AssignTaggingSocketPlug{tbl/vmode/begin}{Table} |
| 1049 |
\AssignTaggingSocketPlug{tbl/vmode/end}{Table} |
| 1050 |
\AssignTaggingSocketPlug{tbl/colspan}{code} |
| 1051 |
\AssignTaggingSocketPlug{tbl/leaders/begin}{code} |
| 1052 |
\AssignTaggingSocketPlug{tbl/leaders/end}{code} |
| 1053 |
} |
| 1054 |
% \end{macrocode} |
| 1055 |
% \end{macro} |
| 1056 |
% |
| 1057 |
% \begin{macro}{\@@_init_tagnames_default:,\@@_init_tagnames_div:} |
| 1058 |
% These commands are used to switch the tagnames. |
| 1059 |
% \begin{macrocode} |
| 1060 |
\cs_new_protected:Npn\@@_init_tagnames_default: |
| 1061 |
{ |
| 1062 |
\tl_set:Nn\l_@@_rowtag_tl {TR} |
| 1063 |
\tl_set:Nn\l_@@_pcelltag_tl {TD} |
| 1064 |
\tl_set:Nn\l_@@_celltag_tl {TD} |
| 1065 |
\tl_set:Nn\l_@@_tabletag_tl {Table} |
| 1066 |
} |
| 1067 |
|
| 1068 |
\cs_new_protected:Npn\@@_init_tagnames_div: |
| 1069 |
{ |
| 1070 |
\tl_set:Nn\l_@@_rowtag_tl {NonStruct} |
| 1071 |
\tl_set:Nn\l_@@_pcelltag_tl {NonStruct} |
| 1072 |
\tl_set:Nn\l_@@_celltag_tl {text} |
| 1073 |
\tl_set:Nn\l_@@_tabletag_tl {Div} |
| 1074 |
} |
| 1075 |
% \end{macrocode} |
| 1076 |
% \end{macro} |
| 1077 |
|
| 1078 |
% \begin{macrocode} |
| 1079 |
% See tagpdfsetup-keys.md in tagpdf/doc for the naming scheme. |
| 1080 |
\keys_define:nn { __tag / setup } |
| 1081 |
{ |
| 1082 |
table/tagging .choices:nn = { true, on } |
| 1083 |
{ |
| 1084 |
\__tag_tbl_enable: |
| 1085 |
\@@_init_tagnames_default: |
| 1086 |
}, |
| 1087 |
table/tagging .choices:nn = { false, off } |
| 1088 |
{ \__tag_tbl_disable: }, |
| 1089 |
table/tagging .choice:, |
| 1090 |
table/tagging / presentation .code:n = |
| 1091 |
{ |
| 1092 |
\__tag_tbl_enable: |
| 1093 |
\@@_init_tagnames_default: |
| 1094 |
\AssignTaggingSocketPlug{tbl/hmode/begin}{LayoutTable} |
| 1095 |
\AssignTaggingSocketPlug{tbl/vmode/begin}{LayoutTable} |
| 1096 |
\clist_clear:N \l_@@_header_rows_clist |
| 1097 |
\clist_clear:N \l_@@_header_columns_clist |
| 1098 |
}, |
| 1099 |
table/tagging / div .code:n = |
| 1100 |
{ |
| 1101 |
\__tag_tbl_enable: |
| 1102 |
\@@_init_tagnames_div: |
| 1103 |
\AssignTaggingSocketPlug{tbl/hmode/begin}{LayoutTable} |
| 1104 |
\AssignTaggingSocketPlug{tbl/vmode/begin}{LayoutTable} |
| 1105 |
\clist_clear:N \l_@@_header_rows_clist |
| 1106 |
\clist_clear:N \l_@@_header_columns_clist |
| 1107 |
}, |
| 1108 |
table/tagging .default:n = true, |
| 1109 |
table/tagging .initial:n = true |
| 1110 |
} |
| 1111 |
% \end{macrocode} |
| 1112 |
% This are the old key names kept for now for |
| 1113 |
% compatibility. They will got at some time. |
| 1114 |
% \begin{macrocode} |
| 1115 |
\keys_define:nn { __tag / setup } |
| 1116 |
{ |
| 1117 |
table-tagging .meta:n = {table/tagging={#1}} |
| 1118 |
} |
| 1119 |
% \end{macrocode} |
| 1120 |
% |
| 1121 |
% |
| 1122 |
% \subsubsection{Header support} |
| 1123 |
% |
| 1124 |
% Accessible table must have header cells declaring the meaning of the |
| 1125 |
% data in a row or column. To allow a data cell to find it header cell(s) |
| 1126 |
% a number of things must be done: |
| 1127 |
% \begin{itemize} |
| 1128 |
% \item every cell meant as a header should use the tag \texttt{TH}. |
| 1129 |
% |
| 1130 |
% \item header cells should have a \texttt{Scope} attribute with the |
| 1131 |
% value \texttt{Column}, \texttt{Row} or \texttt{Both}. This is not |
| 1132 |
% needed in the first row or column of a table. |
| 1133 |
% |
| 1134 |
% \item For more complex cases both \texttt{TD} and \texttt{TH} cell |
| 1135 |
% can contain a \texttt{Headers} attribute, that is an array of |
| 1136 |
% \texttt{ID}s of \texttt{TH} cell. |
| 1137 |
% \end{itemize} |
| 1138 |
% |
| 1139 |
% For now we support only header rows. |
| 1140 |
% |
| 1141 |
% At first we define attributes for the three standard cases: |
| 1142 |
% \changes{v0.85p}{2025/01/05}{add ARIA-role for presentation (tagging/778)} |
| 1143 |
% \changes{v0.85t}{2025-07-02}{Remove \cs{tag_if_active:}} |
| 1144 |
% \begin{macrocode} |
| 1145 |
\AddToHook{begindocument} |
| 1146 |
{ |
| 1147 |
\tagpdfsetup |
| 1148 |
{ |
| 1149 |
role/new-attribute = |
| 1150 |
{TH-col}{/O /Table /Scope /Column}, |
| 1151 |
role/new-attribute = |
| 1152 |
{TH-row}{/O /Table /Scope /Row}, |
| 1153 |
role/new-attribute = |
| 1154 |
{TH-both}{/O /Table /Scope /Both}, |
| 1155 |
role/new-attribute = |
| 1156 |
{ARIA-role-presentation}{/O /ARIA-1.1/role (presentation)} |
| 1157 |
} |
| 1158 |
% \end{macrocode} |
| 1159 |
% |
| 1160 |
% And we put all three into the class map (perhaps the next tagpdf |
| 1161 |
% should do that directly with role/new-attribute): |
| 1162 |
% |
| 1163 |
% \begin{macrocode} |
| 1164 |
\seq_gput_left:Ne\g__tag_attr_class_used_seq |
| 1165 |
{\pdf_name_from_unicode_e:n{TH-col}} |
| 1166 |
\seq_gput_left:Ne\g__tag_attr_class_used_seq |
| 1167 |
{\pdf_name_from_unicode_e:n{TH-row}} |
| 1168 |
\seq_gput_left:Ne\g__tag_attr_class_used_seq |
| 1169 |
{\pdf_name_from_unicode_e:n{TH-both}} |
| 1170 |
} |
| 1171 |
% \end{macrocode} |
| 1172 |
% |
| 1173 |
% \begin{variable}{\l_@@_header_rows_clist,\l_@@_header_columns_clist} |
| 1174 |
% This holds the numbers of the header rows and columns. Negative numbers are |
| 1175 |
% possible and count from the last column backwards. |
| 1176 |
% \begin{macrocode} |
| 1177 |
\clist_new:N \l_@@_header_rows_clist |
| 1178 |
\clist_new:N \l_@@_header_columns_clist |
| 1179 |
% \end{macrocode} |
| 1180 |
% \end{variable} |
| 1181 |
% |
| 1182 |
% \begin{macro}{\@@_set_header_rows:} |
| 1183 |
% \begin{macrocode} |
| 1184 |
\cs_new_protected:Npn \@@_set_header_rows: |
| 1185 |
{ |
| 1186 |
\clist_map_inline:Nn \l_@@_header_rows_clist |
| 1187 |
{ |
| 1188 |
\clist_set:Ne\l_@@_tmpa_clist |
| 1189 |
{ |
| 1190 |
\seq_item:Nn \g_@@_struct_cells_seq {##1} |
| 1191 |
} |
| 1192 |
\clist_map_inline:Nn \l_@@_tmpa_clist |
| 1193 |
{ |
| 1194 |
% \end{macrocode} |
| 1195 |
% We can have negative numbers in the list from the multicolumn. |
| 1196 |
% \begin{macrocode} |
| 1197 |
\prop_if_exist:cT { g__tag_struct_####1_prop } |
| 1198 |
{ |
| 1199 |
\__tag_struct_prop_gput:nnn{ ####1 }{S}{/TH} |
| 1200 |
% \end{macrocode} |
| 1201 |
% This sets the scope class. If the header has already a row attribute |
| 1202 |
% we replace by TH-both. |
| 1203 |
% \begin{macrocode} |
| 1204 |
\prop_get:cnNTF |
| 1205 |
{ g__tag_struct_####1_prop } |
| 1206 |
{ C } |
| 1207 |
\l_@@_tmpa_tl |
| 1208 |
{ |
| 1209 |
\str_set:Ne \l_@@_tmpa_str {\l_@@_tmpa_tl} |
| 1210 |
\str_remove_once:Nn \l_@@_tmpa_str {[} |
| 1211 |
\str_remove_once:Nn \l_@@_tmpa_str {]} |
| 1212 |
\str_if_in:NnTF\l_@@_tmpa_str{/TH-row} |
| 1213 |
{ |
| 1214 |
\str_replace_once:Nnn \l_@@_tmpa_str {/TH-row}{/TH-both} |
| 1215 |
\__tag_struct_prop_gput:nne{ ####1 }{C}{[\l_@@_tmpa_str]} |
| 1216 |
} |
| 1217 |
{ |
| 1218 |
\__tag_struct_prop_gput:nne{ ####1 }{C}{[/TH-col~\l_@@_tmpa_str]} |
| 1219 |
} |
| 1220 |
} |
| 1221 |
{\__tag_struct_prop_gput:nnn{ ####1 }{C}{/TH-col}} |
| 1222 |
} |
| 1223 |
} |
| 1224 |
} |
| 1225 |
} |
| 1226 |
% \end{macrocode} |
| 1227 |
% \end{macro} |
| 1228 |
% |
| 1229 |
% And some key support: |
| 1230 |
% (See tagpdfsetup-keys.md for the naming scheme.) |
| 1231 |
% \begin{macrocode} |
| 1232 |
\keys_define:nn { __tag / setup } |
| 1233 |
{ |
| 1234 |
table/header-rows .clist_set:N = \l_@@_header_rows_clist, |
| 1235 |
table/header-columns .clist_set:N = \l_@@_header_columns_clist, |
| 1236 |
% \end{macrocode} |
| 1237 |
% obsolete older name: |
| 1238 |
% \begin{macrocode} |
| 1239 |
table-header-rows .meta:n = {table/header-rows={#1}} |
| 1240 |
} |
| 1241 |
% \end{macrocode} |
| 1242 |
% |
| 1243 |
% \subsection{Multirow support} |
| 1244 |
% |
| 1245 |
% \begin{macro}{\@@_multirow:n} |
| 1246 |
% This command makes the current cell into a multirow cell: |
| 1247 |
% it creates, if needed, an RowSpan-attribute, adds it to the attributes |
| 1248 |
% of the cell structure, and marks all following cells spanned by the multirow |
| 1249 |
% as cells that should not be tagged. The argument is the number of spanned row |
| 1250 |
% (including the current row). |
| 1251 |
% \begin{macrocode} |
| 1252 |
\cs_if_exist:NT \__tag_struct_prop_gput:nnn |
| 1253 |
{ |
| 1254 |
\cs_generate_variant:Nn \__tag_struct_prop_gput:nnn {one} |
| 1255 |
} |
| 1256 |
\cs_new_protected:Npn \@@_multirow:n #1 |
| 1257 |
{ |
| 1258 |
% \end{macrocode} |
| 1259 |
% Create an attribute if needed: |
| 1260 |
% \begin{macrocode} |
| 1261 |
\prop_get:NeNF \g__tag_attr_entries_prop |
| 1262 |
{rowspan-\int_eval:n{#1}} |
| 1263 |
\l_@@_tmpa_tl |
| 1264 |
{ |
| 1265 |
\__tag_attr_new_entry:ee |
| 1266 |
{rowspan-\int_eval:n{#1}} |
| 1267 |
{/O /Table /RowSpan~\int_eval:n{#1}} |
| 1268 |
} |
| 1269 |
% \end{macrocode} |
| 1270 |
% ensure that the attribute is marked as used: |
| 1271 |
% \begin{macrocode} |
| 1272 |
\seq_gput_left:Ne\g__tag_attr_class_used_seq |
| 1273 |
{\pdf_name_from_unicode_e:n{rowspan-\int_eval:n{#1}}} |
| 1274 |
% \end{macrocode} |
| 1275 |
% Get the structure number of the current cell |
| 1276 |
% \begin{macrocode} |
| 1277 |
\seq_get_right:NN\g_@@_struct_cur_seq \l_@@_tmpb_tl |
| 1278 |
% \end{macrocode} |
| 1279 |
% If we are in a multicolumn the number can be negative and |
| 1280 |
% this must be changed |
| 1281 |
% \begin{macrocode} |
| 1282 |
\tl_set:Ne \l_@@_tmpb_tl { \int_abs:n{\l_@@_tmpb_tl} } |
| 1283 |
% \end{macrocode} |
| 1284 |
% no we must update an existing attribute. |
| 1285 |
% TODO: simplify this ... (see also colspan handling). |
| 1286 |
% \begin{macrocode} |
| 1287 |
\prop_get:cnNTF |
| 1288 |
{ g__tag_struct_\l_@@_tmpb_tl _prop } |
| 1289 |
{ C } |
| 1290 |
\l_@@_tmpa_tl |
| 1291 |
{ |
| 1292 |
\tl_remove_once:Nn \l_@@_tmpa_tl {[} |
| 1293 |
\tl_remove_once:Nn \l_@@_tmpa_tl {]} |
| 1294 |
\__tag_struct_prop_gput:one{ \l_@@_tmpb_tl } |
| 1295 |
{C} |
| 1296 |
{[/rowspan-\int_eval:n{#1}~\l_@@_tmpa_tl]} |
| 1297 |
} |
| 1298 |
{ |
| 1299 |
\__tag_struct_prop_gput:one{ \l_@@_tmpb_tl } |
| 1300 |
{C} |
| 1301 |
{[/rowspan-\int_eval:n{#1}]} |
| 1302 |
} |
| 1303 |
% \end{macrocode} |
| 1304 |
% Now mark the spanned cells that should be ignored. |
| 1305 |
% \begin{macrocode} |
| 1306 |
\@@_gset_untagged_row_cells:nn {#1-1}{\g_@@_span_tl} |
| 1307 |
} |
| 1308 |
% \end{macrocode} |
| 1309 |
% \end{macro} |
| 1310 |
% |
| 1311 |
% \begin{macrocode} |
| 1312 |
\keys_define:nn{ __tag / setup } |
| 1313 |
{ table/multirow .code:n = {\@@_multirow:n {#1} } |
| 1314 |
,table/multirow .default:n = 1 |
| 1315 |
} |
| 1316 |
% \end{macrocode} |
| 1317 |
% |
| 1318 |
% \begin{macro}{\@@_gset_untagged_row_cells:nn} |
| 1319 |
% This command stores the row and column numbers of the cells in the following row(s) |
| 1320 |
% that should not be tagged as they are a part of a rowspan. |
| 1321 |
% \begin{macrocode} |
| 1322 |
\cs_new_protected:Npn \@@_gset_untagged_row_cells:nn #1 #2 |
| 1323 |
% #1 number of rows, #2 number of columns |
| 1324 |
{ |
| 1325 |
\int_step_inline:nn {#1} |
| 1326 |
{ |
| 1327 |
\int_step_inline:nn {#2} |
| 1328 |
{ |
| 1329 |
\prop_gput:Nee \g_@@_untagged_cells_prop |
| 1330 |
{ |
| 1331 |
\int_eval:n {\g_@@_row_int + ##1}, |
| 1332 |
\int_eval:n{\g_@@_col_int + ####1 -1 } |
| 1333 |
}{} |
| 1334 |
} |
| 1335 |
} |
| 1336 |
} |
| 1337 |
% \end{macrocode} |
| 1338 |
% \end{macro} |
| 1339 |
% |
| 1340 |
% \begin{macro}{\@@_if_tag_cell:nn} |
| 1341 |
% We must be able to detect if a cell should be tagged. For this |
| 1342 |
% we define a conditional --- if more options are needed it can be extended. |
| 1343 |
% \begin{macrocode} |
| 1344 |
\prg_new_protected_conditional:Npnn\@@_if_tag_cell:nn #1 #2 %#1 row, #2 col |
| 1345 |
{ T,TF } |
| 1346 |
{ |
| 1347 |
\prop_get:NeNTF \g_@@_untagged_cells_prop |
| 1348 |
{\int_eval:n{#1},\int_eval:n{#2}}\l__tbl_tmpa_tl |
| 1349 |
{ \prg_return_false:} |
| 1350 |
{ \prg_return_true: } |
| 1351 |
} |
| 1352 |
% \end{macrocode} |
| 1353 |
% \end{macro} |
| 1354 |
% |
| 1355 |
% \subsection{Misc stuff} |
| 1356 |
% |
| 1357 |
% \begin{macro}{\@@_show_curr_cell_data:} |
| 1358 |
% Show the row/column index and span count for current table cell |
| 1359 |
% for debugging. |
| 1360 |
% \begin{macrocode} |
| 1361 |
\cs_new_protected:Npn \@@_show_curr_cell_data: { |
| 1362 |
\@@_trace:n { ==>~ current~cell~data:~ |
| 1363 |
\int_use:N \g_@@_row_int , |
| 1364 |
\int_use:N \g_@@_col_int , |
| 1365 |
\g_@@_span_tl |
| 1366 |
} |
| 1367 |
} |
| 1368 |
% \end{macrocode} |
| 1369 |
% \end{macro} |
| 1370 |
% |
| 1371 |
% |
| 1372 |
% |
| 1373 |
% \begin{macro}{\@@_add_missing_cells:} |
| 1374 |
% The storing and use of the number of missing cells must happen at |
| 1375 |
% different places as the testing happens at the end of the last |
| 1376 |
% cell of a row, but still inside that cell, so we use two |
| 1377 |
% commands. The one adding is used in the row/end socket. |
| 1378 |
% \begin{macrocode} |
| 1379 |
\cs_new:Npn \@@_add_missing_cells: |
| 1380 |
{ |
| 1381 |
% \end{macrocode} |
| 1382 |
% The TD-socket messages are issued after the message about the |
| 1383 |
% end-row socket, but the structure is ok, so better issue a |
| 1384 |
% message for now to avoid confusion: |
| 1385 |
% \begin{macrocode} |
| 1386 |
\int_compare:nNnT \g_@@_missing_cells_int > 0 |
| 1387 |
{ |
| 1388 |
\@@_trace:n {==>~ |
| 1389 |
~Inserting~\int_use:N \g_@@_missing_cells_int \space |
| 1390 |
additional~cell(s)~into~previous~row:} |
| 1391 |
\int_step_inline:nn { \g_@@_missing_cells_int } |
| 1392 |
{ |
| 1393 |
\int_gincr:N\g_@@_col_int |
| 1394 |
\UseTaggingSocket{tbl/cell/begin} |
| 1395 |
\UseTaggingSocket{tbl/cell/end} |
| 1396 |
} |
| 1397 |
} |
| 1398 |
} |
| 1399 |
% \end{macrocode} |
| 1400 |
% \end{macro} |
| 1401 |
% |
| 1402 |
% |
| 1403 |
% |
| 1404 |
% |
| 1405 |
% |
| 1406 |
% |
| 1407 |
% \begin{macro} |
| 1408 |
% { |
| 1409 |
% \g_@@_struct_table_tl, \l_@@_saved_struct_table_tl, |
| 1410 |
% \g_@@_struct_rows_seq,\l_@@_saved_struct_rows_seq, |
| 1411 |
% \g_@@_struct_cells_seq,\l_@@_saved_struct_cells_seq, |
| 1412 |
% \g_@@_struct_cur_seq,\l_@@_saved_struct_cur_seq |
| 1413 |
% } |
| 1414 |
% We need to store the structure numbers for the fine tuning in the |
| 1415 |
% finalize socket. For now we use a rather simple system: A |
| 1416 |
% sequence that hold the numbers for the row structures, and one |
| 1417 |
% that holds comma lists for the cells. |
| 1418 |
% |
| 1419 |
% \cs{g_@@_struct_table_tl} will hold the structure number of the |
| 1420 |
% table, \cs{g_@@_struct_rows_seq} will hold at index i the |
| 1421 |
% structure number of row i, \cs{g_@@_struct_cells_seq} will hold |
| 1422 |
% at index i a comma list of the cell structure numbers of row i. |
| 1423 |
% \cs{g_@@_struct_cur_seq} is used as a temporary store for the |
| 1424 |
% cell structures of the current row. We need also local version |
| 1425 |
% to store and restore the values. |
| 1426 |
% |
| 1427 |
% \begin{macrocode} |
| 1428 |
\tl_new:N \g_@@_struct_table_tl |
| 1429 |
\tl_new:N \l_@@_saved_struct_table_tl |
| 1430 |
\seq_new:N \g_@@_struct_rows_seq |
| 1431 |
\seq_new:N \l_@@_saved_struct_rows_seq |
| 1432 |
\seq_new:N \g_@@_struct_cells_seq |
| 1433 |
\seq_new:N \l_@@_saved_struct_cells_seq |
| 1434 |
\seq_new:N \g_@@_struct_cur_seq |
| 1435 |
\seq_new:N \l_@@_saved_struct_cur_seq |
| 1436 |
% \end{macrocode} |
| 1437 |
% \end{macro} |
| 1438 |
|
| 1439 |
|
| 1440 |
|
| 1441 |
% \begin{macro}{\@@_init_struct_data:} |
| 1442 |
% Save the global structure data variables locally so the we can |
| 1443 |
% restore them when the table ends (important in case of nested |
| 1444 |
% tables). |
| 1445 |
% |
| 1446 |
% This is also the right point to initialize |
| 1447 |
% them. \cs{g_@@_struct_table_tl} is set elsewhere. |
| 1448 |
% \begin{macrocode} |
| 1449 |
\cs_new_protected:Npn \@@_init_struct_data: { |
| 1450 |
\tl_set_eq:NN \l_@@_saved_struct_table_tl \g_@@_struct_table_tl |
| 1451 |
\seq_set_eq:NN \l_@@_saved_struct_rows_seq \g_@@_struct_rows_seq |
| 1452 |
\seq_set_eq:NN \l_@@_saved_struct_cells_seq \g_@@_struct_cells_seq |
| 1453 |
\seq_set_eq:NN \l_@@_saved_struct_cur_seq \g_@@_struct_cur_seq |
| 1454 |
% |
| 1455 |
\seq_gclear:N\g_@@_struct_rows_seq |
| 1456 |
\seq_gclear:N\g_@@_struct_cells_seq |
| 1457 |
\seq_gclear:N\g_@@_struct_cur_seq |
| 1458 |
} |
| 1459 |
% \end{macrocode} |
| 1460 |
% \end{macro} |
| 1461 |
|
| 1462 |
|
| 1463 |
|
| 1464 |
|
| 1465 |
% \begin{macro}{\@@_restore_struct_data:} |
| 1466 |
% |
| 1467 |
% \begin{macrocode} |
| 1468 |
\cs_new_protected:Npn \@@_restore_struct_data: { |
| 1469 |
\tl_gset_eq:NN \g_@@_struct_table_tl \l_@@_saved_struct_table_tl |
| 1470 |
\seq_gset_eq:NN \g_@@_struct_rows_seq \l_@@_saved_struct_rows_seq |
| 1471 |
\seq_gset_eq:NN \g_@@_struct_cells_seq\l_@@_saved_struct_cells_seq |
| 1472 |
\seq_gset_eq:NN \g_@@_struct_cur_seq \l_@@_saved_struct_cur_seq |
| 1473 |
} |
| 1474 |
% \end{macrocode} |
| 1475 |
% \end{macro} |
| 1476 |
|
| 1477 |
|
| 1478 |
% |
| 1479 |
% |
| 1480 |
% \subsection{longtable} |
| 1481 |
% |
| 1482 |
% |
| 1483 |
% |
| 1484 |
% |
| 1485 |
% |
| 1486 |
% \begin{macro}{\@@_patch_\LT@makecaption} |
| 1487 |
% This patch is quite similar to the one for LaTeX's \cs{@makecaption} |
| 1488 |
% we also have to change the parbox sockets. |
| 1489 |
% \begin{macrocode} |
| 1490 |
\def\@@_patch_LT@makecaption#1#2#3{% |
| 1491 |
\LT@mcol\LT@cols c{% |
| 1492 |
% test can go after merge |
| 1493 |
\str_if_exist:cT { l__socket_tagsupport/parbox/before_plug_str } |
| 1494 |
{ |
| 1495 |
\AssignTaggingSocketPlug{parbox/before}{noop} |
| 1496 |
\AssignTaggingSocketPlug{parbox/after}{noop} |
| 1497 |
} |
| 1498 |
\hbox to\z@{\hss\parbox[t]\LTcapwidth{% |
| 1499 |
\reset@font |
| 1500 |
\tag_suspend:n{caption} |
| 1501 |
\sbox\@tempboxa{#1{#2:~}#3}% |
| 1502 |
\tag_resume:n{caption} |
| 1503 |
\ifdim\wd\@tempboxa>\hsize |
| 1504 |
#1{#2:~}#3% |
| 1505 |
\else |
| 1506 |
\hbox to\hsize{\hfil#1{#2:~}#3\hfil}% |
| 1507 |
\fi |
| 1508 |
\endgraf\vskip\baselineskip}% |
| 1509 |
\hss}}} |
| 1510 |
% \end{macrocode} |
| 1511 |
% \end{macro} |
| 1512 |
% |
| 1513 |
% |
| 1514 |
% |
| 1515 |
% Overwrite the longtable definition. That will probably break somewhere as |
| 1516 |
% they are various package which patch too. |
| 1517 |
% \begin{macrocode} |
| 1518 |
\AddToHook{package/longtable/after} |
| 1519 |
{ |
| 1520 |
\cs_set_eq:NN \LT@makecaption\@@_patch_LT@makecaption |
| 1521 |
} |
| 1522 |
% \end{macrocode} |
| 1523 |
|
| 1524 |
|
| 1525 |
% \begin{macrocode} |
| 1526 |
%</package> |
| 1527 |
% \end{macrocode} |
| 1528 |
% |
| 1529 |
% |
| 1530 |
% \begin{macrocode} |
| 1531 |
%<*latex-lab> |
| 1532 |
\ProvidesFile{table-latex-lab-testphase.ltx} |
| 1533 |
[\ltlabtbldate\space v\ltlabtblversion\space latex-lab wrapper table] |
| 1534 |
\RequirePackage{latex-lab-testphase-table} |
| 1535 |
%</latex-lab> |
| 1536 |
% \end{macrocode} |
| 1537 |
|
| 1538 |
% \begin{macrocode} |
| 1539 |
%<*latex-lab-alias> |
| 1540 |
\ProvidesFile{tabular-latex-lab-testphase.ltx} |
| 1541 |
[\ltlabtbldate\space v\ltlabtblversion\space latex-lab wrapper tabular] |
| 1542 |
\RequirePackage{latex-lab-testphase-table} |
| 1543 |
%</latex-lab-alias> |
| 1544 |
% \end{macrocode} |