| 1 |
% \iffalse meta-comment |
| 2 |
% |
| 3 |
% Copyright (C) 2023-2025 |
| 4 |
% The LaTeX Project and any individual authors listed elsewhere |
| 5 |
% in this file. |
| 6 |
% |
| 7 |
% This file is part of the LaTeX base system. |
| 8 |
% ------------------------------------------- |
| 9 |
% |
| 10 |
% It may be distributed and/or modified under the |
| 11 |
% conditions of the LaTeX Project Public License, either version 1.3c |
| 12 |
% of this license or (at your option) any later version. |
| 13 |
% The latest version of this license is in |
| 14 |
% https://www.latex-project.org/lppl.txt |
| 15 |
% and version 1.3c or later is part of all distributions of LaTeX |
| 16 |
% version 2008 or later. |
| 17 |
% |
| 18 |
% This file has the LPPL maintenance status "maintained". |
| 19 |
% |
| 20 |
% The list of all files belonging to the LaTeX base distribution is |
| 21 |
% given in the file `manifest.txt'. See also `legal.txt' for additional |
| 22 |
% information. |
| 23 |
% |
| 24 |
% The list of derived (unpacked) files belonging to the distribution |
| 25 |
% and covered by LPPL is defined by the unpacking scripts (with |
| 26 |
% extension .ins) which are part of the distribution. |
| 27 |
% |
| 28 |
% \fi |
| 29 |
% |
| 30 |
% \iffalse |
| 31 |
%%% From File: lttagging.dtx |
| 32 |
% |
| 33 |
%<*driver> |
| 34 |
% \fi |
| 35 |
\ProvidesFile{lttagging.dtx} |
| 36 |
[2025/10/20 v1.0u LaTeX Kernel (tagging support)] |
| 37 |
% \iffalse |
| 38 |
\documentclass{l3doc} |
| 39 |
\GetFileInfo{lttagging.dtx} |
| 40 |
\title{\filename} |
| 41 |
\date{\filedate} |
| 42 |
\author{\LaTeX{} project} |
| 43 |
|
| 44 |
\begin{document} |
| 45 |
% \MaintainedByLaTeXTeam{latex} % should be added again the moment |
| 46 |
% it is supported by l3doc |
| 47 |
\maketitle |
| 48 |
\DocInput{\filename} |
| 49 |
\end{document} |
| 50 |
%</driver> |
| 51 |
% \fi |
| 52 |
% |
| 53 |
% \providecommand\env[1]{\texttt{#1}} |
| 54 |
% |
| 55 |
% \providecommand\hook[1]{\texttt{#1\DescribeHook[noprint]{#1}}} |
| 56 |
% \providecommand\socket[1]{\texttt{#1\DescribeSocket[noprint]{#1}}} |
| 57 |
% \providecommand\plug[1]{\texttt{#1\DescribePlug[noprint]{#1}}} |
| 58 |
% |
| 59 |
% \ProvideDocElement[printtype=\textit{socket},idxtype=socket,idxgroup=Sockets]{Socket}{socketdecl} |
| 60 |
% \ProvideDocElement[printtype=\textit{hook},idxtype=hook,idxgroup=Hooks]{Hook}{hookdecl} |
| 61 |
% \ProvideDocElement[printtype=\textit{plug},idxtype=plug,idxgroup=Plugs]{Plug}{plugdecl} |
| 62 |
% |
| 63 |
% \ProvideDocElement[printtype=\textit{tag socket},idxtype=tag socket, |
| 64 |
% idxgroup=Tagging sockets]{TaggingSocket}{taggingsocketdecl} |
| 65 |
% \ProvideDocElement[printtype=\textit{tag plug},idxtype=tag plug, |
| 66 |
% idxgroup=Tagging Plugs]{TaggingPlug}{taggingplugdecl} |
| 67 |
% |
| 68 |
% |
| 69 |
% \begin{macrocode} |
| 70 |
%<*2ekernel|latexrelease> |
| 71 |
% \end{macrocode} |
| 72 |
% |
| 73 |
% \begin{macrocode} |
| 74 |
\ExplSyntaxOn |
| 75 |
% \end{macrocode} |
| 76 |
% |
| 77 |
% |
| 78 |
% \section{General support for tagged output} |
| 79 |
% |
| 80 |
% \DescribeMacro\SuspendTagging |
| 81 |
% \DescribeMacro\ResumeTagging |
| 82 |
% \DescribeMacro\tag_suspend:n |
| 83 |
% \DescribeMacro\tag_resume:n |
| 84 |
|
| 85 |
% |
| 86 |
% There are places in code where it is important to stop any tagging |
| 87 |
% activities, e.g., when we are doing trial typesetting that it is |
| 88 |
% done several times. In such a case one must tag only the final |
| 89 |
% version that is actually used, otherwise tagging structures are |
| 90 |
% generated which then do not end up in the PDF and confuse the |
| 91 |
% mechanism. For this we have two commands that can be used in |
| 92 |
% packages: \cs{SuspendTagging} and \cs{ResumeTagging} (with corresponding |
| 93 |
% L3 programming layer commands). They are |
| 94 |
% available as part of the \LaTeX{} kernel, so that they can be |
| 95 |
% safely used in packages whether or not tagging is requested. They |
| 96 |
% all take a string argument that is used for debugging to easily |
| 97 |
% identify why tagging was suspended or restarted, for example, in |
| 98 |
% \pkg{tabularx} you find \verb=\SuspendTagging{tabularx}=. By default |
| 99 |
% these four commands do nothing. |
| 100 |
% |
| 101 |
% The argument is used literally (in \cs{typeout} messages) without any |
| 102 |
% expansion when debugging is turned on and otherwise it is not used at all. |
| 103 |
% This means it is safe to write something like |
| 104 |
% \verb=\SuspendTagging{\foo}= or even \verb=\SuspendTagging\foo= |
| 105 |
% which means \LaTeX{} has to parse only |
| 106 |
% a single token instead of putting a string of characters into the |
| 107 |
% argument. This means a tiny speed improvement but with many such |
| 108 |
% debugging strings\ldots |
| 109 |
% |
| 110 |
% |
| 111 |
% |
| 112 |
% |
| 113 |
% \DescribeMacro\NewTaggingSocket |
| 114 |
% \DescribeMacro\NewTaggingSocketPlug |
| 115 |
% \DescribeMacro\AssignTaggingSocketPlug |
| 116 |
% Tagging sockets are implemented as normal sockets but with a name |
| 117 |
% that starts with \texttt{tagsupport/} and some special conventions |
| 118 |
% how their arguments (if any) are to be interpreted. This means in |
| 119 |
% principle one can use the standard socket commands, which is what |
| 120 |
% we started out with. |
| 121 |
% |
| 122 |
% However, providing dedicated declaration commands is more convenient |
| 123 |
% and helps in keeping the interfaces clearer and simpler, e.g., |
| 124 |
% \cs{NewTaggingSocket} not only declares the socket but also |
| 125 |
% automatially sets up necessary plugs and assigns a suitable default |
| 126 |
% plug when tagging is not enabled. |
| 127 |
% |
| 128 |
% \cs{NewTaggingSocketPlug} and \cs{AssignTaggingSocketPlug} on the |
| 129 |
% other hand are mainly syntactic sugar and do nothing more than |
| 130 |
% adding the \texttt{tagsupport/} to the socket name behind the |
| 131 |
% scenes. |
| 132 |
% |
| 133 |
% |
| 134 |
% |
| 135 |
% |
| 136 |
% \DescribeMacro\UseTaggingSocket |
| 137 |
% \DescribeMacro\tag_socket_use:n |
| 138 |
% \DescribeMacro\tag_socket_use:nn |
| 139 |
% \DescribeMacro\tag_socket_use:nnn |
| 140 |
% Given that we sometimes have to suspend tagging, it would be fairly |
| 141 |
% inefficient to put different plugs into these sockets whenever that |
| 142 |
% happens. We therefore offer \cs{UseTaggingSocket} which is like |
| 143 |
% \cs{UseSocket} except that is expects a socket starting with |
| 144 |
% \texttt{tagsupport/} but the socket name is specified without |
| 145 |
% this prefix, i.e., |
| 146 |
% \begin{quote} |
| 147 |
% \verb=\UseTaggingSocket{foo}= $\to$ |
| 148 |
% \verb=\UseSocket{tagsupport/foo}= |
| 149 |
% \end{quote}. |
| 150 |
% |
| 151 |
% Beside being slightly shorter, the big advantage is that this way |
| 152 |
% we can change \cs{UseTaggingSocket} to do nothing by switching a boolean |
| 153 |
% instead of changing the plugs of the tagging support sockets back and forth. |
| 154 |
% |
| 155 |
% Usually, these sockets have (beside the default plug defined for every socket) |
| 156 |
% one additional plug defined and directly assigned. This plug is used when |
| 157 |
% tagging is active. |
| 158 |
% There may be more plugs, e.g., tagging with special debugging or special behavior |
| 159 |
% depending on the class or PDF version etc., but right now it is usually just on or off. |
| 160 |
% |
| 161 |
% When tagging is suspended they all have the same predefined behavior: |
| 162 |
% The sockets with zero arguments do nothing. The sockets with one argument |
| 163 |
% gobble their argument. The sockets with two arguments |
| 164 |
% will drop their first argument and pass the second unchanged. |
| 165 |
% |
| 166 |
% It is possible to use the tagging support sockets with |
| 167 |
% \cs{UseSocket} directly, but in this case the socket remains active |
| 168 |
% if \cs{SuspendTagging} is in force. There may be reasons for doing |
| 169 |
% that but in general we expect to always use \cs{UseTaggingSocket}. |
| 170 |
% |
| 171 |
% \DescribeMacro\UseExpandableTaggingSocket |
| 172 |
% \DescribeMacro\tag_socket_use_expandable:n |
| 173 |
% For special cases like in some \cs{halign} contexts we need a fully expandable |
| 174 |
% version of the command. For these cases, \cs{UseExpandableTaggingSocket} can be |
| 175 |
% used. To allow being expandable, it does not output any debugging information |
| 176 |
% if \cs{DebugSocketsOn} is in effect and therefore should be avoided whenever possible. |
| 177 |
% |
| 178 |
% The L3 programming layer versions \cs{tag_socket_use_expandable:n}, |
| 179 |
% \cs{tag_socket_use:n}, \cs{tag_socket_use:nn}, and \cs{tag_socket_use:nnn} |
| 180 |
% are slightly more efficient than |
| 181 |
% \cs{UseTaggingSocket} because they do not have to determine how |
| 182 |
% many arguments the socket takes when disabling it. |
| 183 |
% |
| 184 |
% \DescribeMacro\MathCollectTrue |
| 185 |
% \DescribeMacro\MathCollectFalse |
| 186 |
% The tagging of math has to collect/grab the math first. This is not wanted |
| 187 |
% for all uses of \verb+$+. These command allow to control the behavior of the |
| 188 |
% math shift token. Without the math tagging code they do nothing. Their behavior |
| 189 |
% with the math tagging code is documented in latex-lab-math.pdf |
| 190 |
% |
| 191 |
% |
| 192 |
% \DescribeMacro\MathMLintent |
| 193 |
% \DescribeMacro\MathMLarg |
| 194 |
% \changes{v1.0r}{2025/08/23}{MathML intent macros added} |
| 195 |
% These two commands take two arguments. The first argument is the value of the |
| 196 |
% \verb|intent| or \verb|arg| attribute to be added to the MathML generated by |
| 197 |
% the term in the second argument. |
| 198 |
% By default the commands are no-op and discard the first argument and expand to |
| 199 |
% the second. If \pkg{luamml} is loaded via the math tagging code, then these commands |
| 200 |
% are redefined. They could also potentially be used by other \TeX{} to MathML convertors |
| 201 |
% to control the generated MathML. |
| 202 |
% |
| 203 |
% \DescribeMacro\NewStructureName |
| 204 |
% \DescribeMacro\UseStructureName |
| 205 |
% \DescribeMacro\AssignStructureRole |
| 206 |
% Structure elements in a document can use as tag a name from the standard PDF namespaces |
| 207 |
% like \verb|Sect|, \verb|H1| or \verb|Figure| but they can also use new names |
| 208 |
% (which then must be rolemapped to a standard name). The second option is useful for three reasons: |
| 209 |
% \begin{itemize} |
| 210 |
% \item It looks nicer, if, e.g., a bible uses tag names like \texttt{Testament} or |
| 211 |
% \texttt{Chapter} or \texttt{Book} instead of \texttt{Sect}. |
| 212 |
% \item It is possible to formulate additional constraint on such structures in a Schema |
| 213 |
% and thus ensure that there is no \texttt{Testament} inside a \texttt{Book}, |
| 214 |
% something that can not be done if \texttt{Sect} is used everywhere. |
| 215 |
% \item We can provide a uniform LaTeX set of names for tags. |
| 216 |
% \end{itemize} |
| 217 |
% |
| 218 |
% To make it possible to adapt the tag names of a structure in document, the tag name |
| 219 |
% should be stored in a command. These three commands offer an interface to declare, |
| 220 |
% use and reassign such symbolic structure names. \verb+\NewStructureName+ |
| 221 |
% takes one argument and |
| 222 |
% declares the internal command, initially its value is \texttt{NonStruct}. |
| 223 |
% The expandable command \verb+\UseStructureName+ takes one argument and allows to use |
| 224 |
% the stored value. \verb+\AssignStructureRole+ takes two |
| 225 |
% arguments. The first is a symbolic structure names, the second a role which |
| 226 |
% should be a simply string allowed as a tag name. |
| 227 |
% When the tagging code is loaded \verb+\AssignStructureRole+ is redefined |
| 228 |
% to setup the rolemapping, see the description in \texttt{latex-lab-namespace.dtx}. |
| 229 |
% There is also a description of |
| 230 |
% the naming scheme and a list of the already predeclared names. |
| 231 |
% |
| 232 |
% |
| 233 |
% |
| 234 |
% \MaybeStop{} |
| 235 |
% \section{Implementation} |
| 236 |
% |
| 237 |
% |
| 238 |
% |
| 239 |
% \begin{macro}{\tag_suspend:n,\tag_resume:n,\SuspendTagging,\ResumeTagging} |
| 240 |
% |
| 241 |
% In the kernel, these commands get dummy definitions so that |
| 242 |
% they can be used without harm in packages. The real definition is |
| 243 |
% used when tagging gets enabled. |
| 244 |
% \begin{macrocode} |
| 245 |
\cs_new_eq:NN \tag_suspend:n \use_none:n |
| 246 |
\cs_new_eq:NN \tag_resume:n \use_none:n |
| 247 |
\cs_new_protected:Npn \SuspendTagging #1 { \tag_suspend:n {#1} } |
| 248 |
\cs_new_protected:Npn \ResumeTagging #1 { \tag_resume:n {#1} } |
| 249 |
% \end{macrocode} |
| 250 |
% \end{macro} |
| 251 |
% |
| 252 |
% |
| 253 |
% |
| 254 |
% |
| 255 |
% |
| 256 |
% \begin{macro}{\NewTaggingSocket} |
| 257 |
% Initialize a new tagging socket and assign it a suitable plug. |
| 258 |
% \changes{v1.0o}{2025/02/26}{Initialize tagging sockets with 1 or 2 arguments} |
| 259 |
% \begin{macrocode} |
| 260 |
\cs_new_protected:Npn \NewTaggingSocket #1 #2 { |
| 261 |
\socket_new:nn { tagsupport / #1 } { #2 } |
| 262 |
\int_case:nnF |
| 263 |
{ #2 } |
| 264 |
{ |
| 265 |
0 \prg_do_nothing: |
| 266 |
1 { \socket_assign_plug:nn { tagsupport / #1 } { noop } } |
| 267 |
% \end{macrocode} |
| 268 |
% Tagging sockets with two arguments use a special \texttt{transparent} plug that |
| 269 |
% just passes the second argument. Its already assigned so we only |
| 270 |
% have to alter it. |
| 271 |
% \begin{macrocode} |
| 272 |
2 { \socket_new_plug:nnn { tagsupport / #1 } { transparent } |
| 273 |
{ ##2 } |
| 274 |
\socket_assign_plug:nn { tagsupport / #1 } { transparent } } |
| 275 |
} |
| 276 |
% \end{macrocode} |
| 277 |
% |
| 278 |
% \begin{macrocode} |
| 279 |
\ERRORnewtaggingsocket % that should get a proper error message |
| 280 |
} |
| 281 |
% \end{macrocode} |
| 282 |
% \end{macro} |
| 283 |
% |
| 284 |
% |
| 285 |
% \begin{macro}{\NewTaggingSocketPlug,\AssignTaggingSocketPlug} |
| 286 |
% |
| 287 |
% \changes{v1.0o}{2025/02/26}{Macro added} |
| 288 |
% \begin{macrocode} |
| 289 |
\cs_new_protected:Npn \NewTaggingSocketPlug #1 { |
| 290 |
\NewSocketPlug { tagsupport/ #1 } |
| 291 |
} |
| 292 |
\cs_new_protected:Npn \AssignTaggingSocketPlug #1 { |
| 293 |
\AssignSocketPlug { tagsupport/ #1 } |
| 294 |
} |
| 295 |
% \end{macrocode} |
| 296 |
% \end{macro} |
| 297 |
% |
| 298 |
% |
| 299 |
% \begin{macro}{\tag_socket_use:n, |
| 300 |
% \tag_socket_use:nn, |
| 301 |
% \tag_socket_use:nnn, |
| 302 |
% \tag_socket_use_expandable:n, |
| 303 |
% \UseTaggingSocket, |
| 304 |
% \UseExpandableTaggingSocket, |
| 305 |
% } |
| 306 |
% Again this is not the final definition for the kernel; it is just |
| 307 |
% a version to get going while some parts of the kernel support are |
| 308 |
% still missing. |
| 309 |
% \changes{v1.0l}{2024/11/21}{Define \cs{tag_if_active:TF} conditionals here (github/1558)} |
| 310 |
% \begin{macrocode} |
| 311 |
\prg_new_conditional:Npnn \tag_if_active: { p , T , TF, F } |
| 312 |
{ \prg_return_false: } |
| 313 |
% \end{macrocode} |
| 314 |
% Dummy definitions in the kernel. |
| 315 |
% These definitions will get updated in \pkg{tagpdf}. |
| 316 |
% The default in the kernel is simply to get rid of the first argument, while |
| 317 |
% the second argument is preserved if present: |
| 318 |
% \changes{v1.0k}{2024/10/21}{Changed behavior of two argument tagging sockets when disabled.} |
| 319 |
% \changes{v1.0k}{2024/10/21}{Added expandable variants} |
| 320 |
% \begin{macrocode} |
| 321 |
\cs_new:Npn \tag_socket_use_expandable:n #1 { } |
| 322 |
\cs_new_protected:Npn \tag_socket_use:n #1 { } |
| 323 |
\cs_new_protected:Npn \tag_socket_use:nn #1#2 { } |
| 324 |
\cs_new_protected:Npn \tag_socket_use:nnn #1#2#3 { #3 } |
| 325 |
\cs_new_protected:Npn \UseTaggingSocket #1 { |
| 326 |
\int_case:nnF |
| 327 |
{ \int_use:c { c__socket_tagsupport/#1_args_int } } |
| 328 |
{ |
| 329 |
0 \prg_do_nothing: |
| 330 |
1 \use_none:n |
| 331 |
2 \use_ii:nn |
| 332 |
% \end{macrocode} |
| 333 |
% We do not expect tagging sockets with more than one or two |
| 334 |
% arguments, so for now we only provide those. |
| 335 |
% \begin{macrocode} |
| 336 |
} |
| 337 |
\ERRORusetaggingsocket % that should get a proper error message |
| 338 |
} |
| 339 |
% \end{macrocode} |
| 340 |
% The same as an expandable command: |
| 341 |
% \begin{macrocode} |
| 342 |
\cs_new:Npn \UseExpandableTaggingSocket #1 { |
| 343 |
\int_case:nnF |
| 344 |
{ \int_use:c { c__socket_tagsupport/#1_args_int } } |
| 345 |
{ |
| 346 |
0 \prg_do_nothing: |
| 347 |
1 \use_none:n |
| 348 |
2 \use_ii:nn |
| 349 |
} |
| 350 |
\ERRORusetaggingsocket % that should get a proper error message |
| 351 |
} |
| 352 |
% \end{macrocode} |
| 353 |
% |
| 354 |
% \end{macro} |
| 355 |
% |
| 356 |
% \subsection{Math collection} |
| 357 |
% The documentation is in latex-lab-math. |
| 358 |
% |
| 359 |
% \begin{macro}{\MathCollectTrue,\MathCollectFalse} |
| 360 |
% \begin{macrocode} |
| 361 |
\cs_new_protected:Npn\MathCollectTrue{} |
| 362 |
\cs_new_protected:Npn\MathCollectFalse{} |
| 363 |
% \end{macrocode} |
| 364 |
% \end{macro} |
| 365 |
% |
| 366 |
% \subsection{Tagging sockets} |
| 367 |
% This collects tagging sockets that should be generally available |
| 368 |
% so that they can also be used even if the tagging code is not loaded. |
| 369 |
% |
| 370 |
% \subsection{Generic sockets} |
| 371 |
% These sockets are used in various places and should not be reassigned globally. |
| 372 |
% |
| 373 |
% \begin{taggingsocketdecl}{mc} |
| 374 |
% At first a generic socket to surround content with the mc-commands. The first |
| 375 |
% argument can be used to pass options like \texttt{artifact} |
| 376 |
% \begin{macrocode} |
| 377 |
\NewTaggingSocket{mc}{2} |
| 378 |
\NewTaggingSocketPlug{mc}{kernel} |
| 379 |
{ |
| 380 |
\tag_mc_begin:n {#1} |
| 381 |
#2 |
| 382 |
\tag_mc_end: |
| 383 |
} |
| 384 |
\AssignTaggingSocketPlug{mc}{kernel} |
| 385 |
% \end{macrocode} |
| 386 |
% \end{taggingsocketdecl} |
| 387 |
% |
| 388 |
% \begin{taggingsocketdecl}{struct-mc} |
| 389 |
% A socket to surround content with a structure and an mc-command. With the first |
| 390 |
% argument the tag and other options can be set. |
| 391 |
% \begin{macrocode} |
| 392 |
\NewTaggingSocket{struct-mc}{2} |
| 393 |
\NewTaggingSocketPlug{struct-mc}{kernel} |
| 394 |
{ |
| 395 |
\tag_struct_begin:n{#1} |
| 396 |
\tag_mc_begin:n {} |
| 397 |
#2 |
| 398 |
\tag_mc_end: |
| 399 |
\tag_struct_end: |
| 400 |
} |
| 401 |
\AssignTaggingSocketPlug{struct-mc}{kernel} |
| 402 |
% \end{macrocode} |
| 403 |
% \end{taggingsocketdecl} |
| 404 |
% |
| 405 |
% \subsubsection{Tagging support for paragraph setup} |
| 406 |
% |
| 407 |
% Paragraphs are tagged through the code in the para/hooks. This code is sometimes |
| 408 |
% adjusted, e.g. to produce a \enquote{flattened} paragraph or to use a different tag. |
| 409 |
% Sockets related to such code parts are collected here. |
| 410 |
% |
| 411 |
% \begin{macro}{\l__tag_block_flattened_level_int} |
| 412 |
% The block code needs to know if they are nested blockenvs inside |
| 413 |
% a flattened environment. For this it uses a counter. Inside some contexts, |
| 414 |
% e.g. at the begin of a minipage or a footnote this counter must be reset. |
| 415 |
% We therefore define the counter here so that we can use it in the following |
| 416 |
% socket. |
| 417 |
% \begin{macrocode} |
| 418 |
\int_new:N \l__tag_block_flattened_level_int |
| 419 |
% \end{macrocode} |
| 420 |
% \end{macro} |
| 421 |
% |
| 422 |
%\begin{taggingsocketdecl}{para/on,para/off} |
| 423 |
% These sockets allow paragraph tagging to be enabled/disabled. |
| 424 |
% \begin{macrocode} |
| 425 |
\NewTaggingSocket{para/on}{0} |
| 426 |
\NewTaggingSocketPlug{para/on}{kernel}{\bool_set_true:N \l__tag_para_bool} |
| 427 |
\NewTaggingSocket{para/off}{0} |
| 428 |
\NewTaggingSocketPlug{para/off}{kernel}{\bool_set_false:N \l__tag_para_bool} |
| 429 |
\AssignTaggingSocketPlug{para/on}{kernel} |
| 430 |
\AssignTaggingSocketPlug{para/off}{kernel} |
| 431 |
% \end{macrocode} |
| 432 |
%\end{taggingsocketdecl} |
| 433 |
% |
| 434 |
% \begin{taggingsocketdecl}{para/restore} |
| 435 |
% This socket restores the para related settings to their default. It |
| 436 |
% should be used in places where ``normal'' paragraph tagging must be ensured, for example |
| 437 |
% at the begin of a footnote. |
| 438 |
% \begin{macrocode} |
| 439 |
\NewTaggingSocket{para/restore}{0} |
| 440 |
% \end{macrocode} |
| 441 |
% \end{taggingsocketdecl} |
| 442 |
% |
| 443 |
% \begin{taggingplugdecl}{default} |
| 444 |
% \changes{v1.0i}{2024/10/10}{Restore also paratagging (tagging/723)} |
| 445 |
% \changes{v1.0t}{2025/08/21}{Use symbolic name instead of text-unit} |
| 446 |
% \begin{macrocode} |
| 447 |
\NewTaggingSocketPlug{para/restore}{default} |
| 448 |
{ |
| 449 |
\tl_set:Nn \l__tag_para_main_tag_tl {\UseStructureName{para/semantic}} |
| 450 |
\tl_set_eq:NN \l__tag_para_tag_tl\l__tag_para_tag_default_tl |
| 451 |
\bool_set_false:N\l__tag_para_flattened_bool |
| 452 |
\int_zero:N \l__tag_block_flattened_level_int |
| 453 |
\bool_set_true:N \l__tag_para_bool |
| 454 |
} |
| 455 |
\AssignTaggingSocketPlug{para/restore}{default} |
| 456 |
% \end{macrocode} |
| 457 |
% \end{taggingplugdecl} |
| 458 |
% |
| 459 |
% \begin{taggingsocketdecl}{para/begin,para/end} |
| 460 |
% These sockets were previously defined in tagpdf. |
| 461 |
% There are the main sockets to handle the paragraph tagging when it is active |
| 462 |
% (i.e., when para/on or para/restore was executed earlier). |
| 463 |
% \begin{macrocode} |
| 464 |
\NewTaggingSocket{para/begin}{0} |
| 465 |
\NewTaggingSocket{para/end}{0} |
| 466 |
% \end{macrocode} |
| 467 |
% Until tagpdf is updated we need to provide the plain and block plugs |
| 468 |
% \begin{macrocode} |
| 469 |
\NewTaggingSocketPlug{para/begin}{plain}{} |
| 470 |
\NewTaggingSocketPlug{para/end}{plain}{} |
| 471 |
\NewTaggingSocketPlug{para/begin}{block}{} |
| 472 |
\NewTaggingSocketPlug{para/end}{block}{} |
| 473 |
|
| 474 |
% \end{macrocode} |
| 475 |
|
| 476 |
% \end{taggingsocketdecl} |
| 477 |
% |
| 478 |
% \begin{taggingsocketdecl}{para/semantic/begin,para/semantic/end} |
| 479 |
% These sockets handle the \UseStructureName{para/semantic} begin and end structure. |
| 480 |
% These are stored in sockets of their own to be able to disable |
| 481 |
% them globally. |
| 482 |
% |
| 483 |
% \begin{macrocode} |
| 484 |
\NewTaggingSocket{para/semantic/begin}{1} |
| 485 |
\NewTaggingSocket{para/semantic/end}{1} |
| 486 |
% \end{macrocode} |
| 487 |
% \end{taggingsocketdecl} |
| 488 |
% |
| 489 |
% \begin{taggingplugdecl}{kernel (para/semantic/begin)} |
| 490 |
% This tagging socket adds a \UseStructureName{para/semantic} structure. |
| 491 |
% The argument allows to add additional commands like |
| 492 |
% the command that puts the structure number of this command |
| 493 |
% on a stack. |
| 494 |
% \begin{macrocode} |
| 495 |
\tl_new:N \l__tag_para_attr_class_tl |
| 496 |
\NewTaggingSocketPlug{para/semantic/begin}{kernel} |
| 497 |
{ |
| 498 |
\__tag_gincr_para_main_begin_int: |
| 499 |
\tag_struct_begin:n |
| 500 |
{ |
| 501 |
tag=\l__tag_para_main_tag_tl, |
| 502 |
attribute-class=\l__tag_para_main_attr_class_tl, |
| 503 |
} |
| 504 |
#1 |
| 505 |
} |
| 506 |
% \end{macrocode} |
| 507 |
% \end{taggingplugdecl} |
| 508 |
% |
| 509 |
% \begin{taggingplugdecl}{kernel (para/semantic/end)} |
| 510 |
% This socket should be used if a \UseStructureName{para/semantic}-structure is closed. |
| 511 |
% The argument allows e.g. to add debug info. |
| 512 |
% \begin{macrocode} |
| 513 |
\NewTaggingSocketPlug{para/semantic/end}{kernel} |
| 514 |
{ |
| 515 |
#1 |
| 516 |
\__tag_gincr_para_main_end_int: |
| 517 |
\tag_struct_end: |
| 518 |
} |
| 519 |
% \end{macrocode} |
| 520 |
% \end{taggingplugdecl} |
| 521 |
% And now we assign these plugs: |
| 522 |
% \begin{macrocode} |
| 523 |
\AssignTaggingSocketPlug{para/semantic/begin}{kernel} |
| 524 |
\AssignTaggingSocketPlug{para/semantic/end}{kernel} |
| 525 |
% \end{macrocode} |
| 526 |
% |
| 527 |
% \begin{taggingplugdecl}{kernel (para/begin)} |
| 528 |
% This plug is similar to the block socket currently defined |
| 529 |
% in tagpdf and should overwrite it. |
| 530 |
% \begin{macrocode} |
| 531 |
\NewTaggingSocketPlug{para/begin}{kernel} |
| 532 |
{ |
| 533 |
\bool_if:NT \l__tag_para_bool |
| 534 |
{ |
| 535 |
\legacy_if:nF { @inlabel } |
| 536 |
{ |
| 537 |
\__tag_check_typeout_v:n |
| 538 |
{==>~ @endpe = \legacy_if:nTF { @endpe }{true}{false} \on@line } |
| 539 |
\legacy_if:nF { @endpe } |
| 540 |
{ |
| 541 |
\bool_if:NF \l__tag_para_flattened_bool |
| 542 |
{ |
| 543 |
\UseTaggingSocket{para/semantic/begin} |
| 544 |
{ \__tag_para_main_store_struct: } |
| 545 |
} |
| 546 |
} |
| 547 |
\__tag_gincr_para_begin_int: |
| 548 |
\__tag_check_typeout_v:n {==>~increment~ P \on@line } |
| 549 |
\tag_struct_begin:n |
| 550 |
{ |
| 551 |
tag=\l__tag_para_tag_tl |
| 552 |
,attribute-class=\l__tag_para_attr_class_tl |
| 553 |
} |
| 554 |
\__tag_check_para_begin_show:nn {green}{\PARALABEL} |
| 555 |
\tag_mc_begin:n {} |
| 556 |
} |
| 557 |
} |
| 558 |
} |
| 559 |
% \end{macrocode} |
| 560 |
% \end{taggingplugdecl} |
| 561 |
% \begin{taggingplugdecl}{kernel (para/end)} |
| 562 |
% This socket is used at the end of paragraphs. |
| 563 |
% \begin{macrocode} |
| 564 |
\NewTaggingSocketPlug{para/end}{kernel} |
| 565 |
{ |
| 566 |
\bool_if:NT \l__tag_para_bool |
| 567 |
{ |
| 568 |
\__tag_gincr_para_end_int: |
| 569 |
\__tag_check_typeout_v:n {==>~increment~ /P \on@line } |
| 570 |
\tag_mc_end: |
| 571 |
\__tag_check_para_end_show:nn {red}{} |
| 572 |
\tag_struct_end: |
| 573 |
\bool_if:NF \l__tag_para_flattened_bool |
| 574 |
{ |
| 575 |
\UseTaggingSocket{para/semantic/end}{} |
| 576 |
} |
| 577 |
} |
| 578 |
} |
| 579 |
% \end{macrocode} |
| 580 |
% \end{taggingplugdecl} |
| 581 |
% As tagpdf is currently assigning the sockets after the block code we assign |
| 582 |
% if even later (for now): |
| 583 |
% \begin{macrocode} |
| 584 |
\AddToHook{package/latex-lab-testphase-sec/after} |
| 585 |
{ |
| 586 |
\AssignTaggingSocketPlug{para/begin}{kernel} |
| 587 |
\AssignTaggingSocketPlug{para/end}{kernel} |
| 588 |
} |
| 589 |
% \end{macrocode} |
| 590 |
|
| 591 |
% \subsubsection{Tagging socket for targets} |
| 592 |
|
| 593 |
% \begin{taggingsocketdecl}{refstepcounter} |
| 594 |
% When tagging is active we want to track the current structure number |
| 595 |
% when targets are set. This will be mostly used in \cs{refstepcounter} |
| 596 |
% but also if targets are set manually. |
| 597 |
% \begin{macrocode} |
| 598 |
\NewTaggingSocket{recordtarget}{0} |
| 599 |
% \end{macrocode} |
| 600 |
% \end{taggingsocketdecl} |
| 601 |
% |
| 602 |
% \begin{taggingplugdecl}{kernel (recordtarget)} |
| 603 |
% \begin{macrocode} |
| 604 |
% |
| 605 |
\NewTaggingSocketPlug{recordtarget}{kernel} |
| 606 |
{ |
| 607 |
\tl_if_blank:VF \@currentHref |
| 608 |
{ |
| 609 |
\prop_gput:Nee |
| 610 |
\g__tag_struct_dest_num_prop |
| 611 |
{\@currentHref} |
| 612 |
{\tag_get:n{struct_num}} |
| 613 |
} |
| 614 |
} |
| 615 |
\AssignTaggingSocketPlug{recordtarget}{kernel} |
| 616 |
\ExplSyntaxOff |
| 617 |
% \end{macrocode} |
| 618 |
% \end{taggingplugdecl} |
| 619 |
% |
| 620 |
% \subsubsection{Tagging Sockets for lists and blocks} |
| 621 |
% \changes{v1.0s}{2025/08/03}{Add sockets for block code} |
| 622 |
% \begin{taggingsocketdecl}{block/list/label} |
| 623 |
% A tagging socket around the label in a list. |
| 624 |
% \begin{macrocode} |
| 625 |
\NewTaggingSocket{block/list/label}{2} |
| 626 |
% \end{macrocode} |
| 627 |
% \end{taggingsocketdecl} |
| 628 |
% |
| 629 |
% \begin{taggingsocketdecl}{block/recipe} |
| 630 |
% A tagging socket to set the tagging recipe. |
| 631 |
% \begin{macrocode} |
| 632 |
\NewTaggingSocket{block/recipe}{1} |
| 633 |
% \end{macrocode} |
| 634 |
% \end{taggingsocketdecl} |
| 635 |
% |
| 636 |
% \subsubsection{Tagging sockets for headings} |
| 637 |
% \changes{v1.0u}{2025/10/20}{Tagging sockets for headings added} |
| 638 |
% Tagging headings is quite tricky. The sockets (and plugs) |
| 639 |
% used by the kernel definitions often expect specially formatted arguments. |
| 640 |
% For this reason some of them may not be suitable in other classes or packages. |
| 641 |
% In that case additional sockets (or plugs) might be required. |
| 642 |
% |
| 643 |
% \begin{taggingsocketdecl}{sec/begin, sec/end} |
| 644 |
% These two sockets should surround the whole section by a \texttt{Sect} structure. |
| 645 |
% They should be suited also for classes and packages. |
| 646 |
% The begin socket takes two brace groups are argument: the level and key for the structure |
| 647 |
% (typically \verb|tag=somename|), the end socket takes as argument a level. |
| 648 |
% |
| 649 |
% \begin{macrocode} |
| 650 |
\NewTaggingSocket{sec/begin}{1} |
| 651 |
\NewTaggingSocket{sec/end}{1} |
| 652 |
% \end{macrocode} |
| 653 |
% \end{taggingsocketdecl} |
| 654 |
% |
| 655 |
% \begin{taggingsocketdecl}{sec/title/begin, sec/title/end} |
| 656 |
% These two sockets are used around display heading where the number |
| 657 |
% is on a line of its own. |
| 658 |
% The argument of the begin socket consists of two brace groups containing the level and |
| 659 |
% the title. |
| 660 |
% \begin{macrocode} |
| 661 |
\NewTaggingSocket{sec/title/begin}{1} |
| 662 |
\NewTaggingSocket{sec/title/end}{0} |
| 663 |
% \end{macrocode} |
| 664 |
% \end{taggingsocketdecl} |
| 665 |
% |
| 666 |
% \begin{taggingsocketdecl}{sec/title/hang} |
| 667 |
% This socket is used in headings with hanging number. |
| 668 |
% \begin{macrocode} |
| 669 |
\NewTaggingSocket{sec/title/hang}{2} |
| 670 |
% \end{macrocode} |
| 671 |
% \end{taggingsocketdecl} |
| 672 |
% |
| 673 |
% \begin{taggingsocketdecl}{sec/title/init,sec/title/split,sec/title/runin/number} |
| 674 |
% These sockets are used by run-in heading to initialize tagging and to split |
| 675 |
% heading and following text and tag the title. |
| 676 |
% \begin{macrocode} |
| 677 |
\NewTaggingSocket{sec/title/init}{1} |
| 678 |
\NewTaggingSocket{sec/title/split}{0} |
| 679 |
\NewTaggingSocket{sec/title/runin/number}{2} |
| 680 |
% \end{macrocode} |
| 681 |
% \end{taggingsocketdecl} |
| 682 |
% |
| 683 |
% \begin{taggingsocketdecl}{sec/title/number} |
| 684 |
% This is a socket to tag the number. It takes two arguments: the level and |
| 685 |
% the content. |
| 686 |
% \begin{macrocode} |
| 687 |
\NewTaggingSocket{sec/title/number}{2} |
| 688 |
% \end{macrocode} |
| 689 |
% \end{taggingsocketdecl} |
| 690 |
% |
| 691 |
% \subsubsection{Tagging sockets for toc} |
| 692 |
% |
| 693 |
% \begin{taggingsocketdecl}{toc/contentsline/before, |
| 694 |
% toc/contentsline/after} |
| 695 |
% Tagging sockets at the begin and end of contentsline. |
| 696 |
% They receive \emph{all} contentsline arguments as one argument |
| 697 |
% in four brace groups. The socket code should then use the parts it needs. |
| 698 |
% \begin{macrocode} |
| 699 |
\NewTaggingSocket{toc/contentsline/before}{1} |
| 700 |
\NewTaggingSocket{toc/contentsline/after}{1} |
| 701 |
% \end{macrocode} |
| 702 |
% \end{taggingsocketdecl} |
| 703 |
% |
| 704 |
% \begin{taggingsocketdecl}{toc/starttoc/before, |
| 705 |
% toc/starttoc/after} |
| 706 |
% Tagging sockets for the begin and end of start of \cs{@starttoc}. |
| 707 |
% They take one argument, the extension. |
| 708 |
% \begin{macrocode} |
| 709 |
\NewTaggingSocket{toc/starttoc/before}{1} |
| 710 |
\NewTaggingSocket{toc/starttoc/after}{1} |
| 711 |
% \end{macrocode} |
| 712 |
% \end{taggingsocketdecl} |
| 713 |
% |
| 714 |
% \begin{taggingsocketdecl}{toc/leaders/before, |
| 715 |
% toc/leaders/after} |
| 716 |
% Tagging sockets to make the dot leaders an artifact. |
| 717 |
% They do not take an argument. |
| 718 |
% \begin{macrocode} |
| 719 |
\NewTaggingSocket{toc/leaders/before}{0} |
| 720 |
\NewTaggingSocket{toc/leaders/after}{0} |
| 721 |
% \end{macrocode} |
| 722 |
% \end{taggingsocketdecl} |
| 723 |
% |
| 724 |
% \subsubsection{Tagging support for marginpar} |
| 725 |
% |
| 726 |
% \begin{taggingsocketdecl}{marginpar/begin,marginpar/end} |
| 727 |
% \changes{v1.0n}{2025/02/21}{move marginpar sockets} |
| 728 |
% \begin{macrocode} |
| 729 |
\NewTaggingSocket{marginpar/begin}{0} |
| 730 |
\NewTaggingSocket{marginpar/end}{0} |
| 731 |
% \end{macrocode} |
| 732 |
% \end{taggingsocketdecl} |
| 733 |
|
| 734 |
% |
| 735 |
% \subsubsection{Tagging support for table/tabular packages} |
| 736 |
% |
| 737 |
% The code uses a number of sockets to inject the tagging |
| 738 |
% commands. These can be easily set to a noop-plug in case the |
| 739 |
% automated tagging is not wanted. |
| 740 |
% |
| 741 |
% \begin{taggingsocketdecl}{tbl/cell/begin, |
| 742 |
% tbl/cell/end, |
| 743 |
% tbl/pcell/end, |
| 744 |
% tbl/pcell/end, |
| 745 |
% tbl/row/begin, |
| 746 |
% tbl/row/end, |
| 747 |
% } |
| 748 |
% At first sockets for the begin and end of cells and table rows: |
| 749 |
% \begin{macrocode} |
| 750 |
\NewTaggingSocket{tbl/cell/begin}{0} |
| 751 |
\NewTaggingSocket{tbl/cell/end}{0} |
| 752 |
% \end{macrocode} |
| 753 |
% |
| 754 |
% \begin{macrocode} |
| 755 |
\NewTaggingSocket{tbl/row/begin}{0} |
| 756 |
\NewTaggingSocket{tbl/row/end}{0} |
| 757 |
% \end{macrocode} |
| 758 |
% Multi-line cells have their own sockets (as they start out in |
| 759 |
% vertical mode and need different treatment). |
| 760 |
% \begin{macrocode} |
| 761 |
\NewTaggingSocket{tbl/pcell/begin}{0} |
| 762 |
\NewTaggingSocket{tbl/pcell/end}{0} |
| 763 |
% \end{macrocode} |
| 764 |
% \end{taggingsocketdecl} |
| 765 |
% |
| 766 |
% \begin{taggingsocketdecl}{tbl/init} |
| 767 |
% This socket should be at the begin of the table, inside a group. |
| 768 |
% It is used for settings such as disabling para-tagging inside the |
| 769 |
% table. This socket |
| 770 |
% can perhaps be merged later into the begin-sockets. |
| 771 |
% \begin{macrocode} |
| 772 |
\NewTaggingSocket{tbl/init}{0} |
| 773 |
% \end{macrocode} |
| 774 |
% \end{taggingsocketdecl} |
| 775 |
% |
| 776 |
% \begin{taggingsocketdecl}{tbl/init/celldata} |
| 777 |
% This socket is used in \cs{tbl_init_cell_data_for_table}, the command |
| 778 |
% that stores and initialize cell data to handle nested tables. |
| 779 |
% It can be used to restore similar tagging related values |
| 780 |
% \begin{macrocode} |
| 781 |
\NewTaggingSocket{tbl/init/celldata}{0} |
| 782 |
% \end{macrocode} |
| 783 |
% \end{taggingsocketdecl} |
| 784 |
% |
| 785 |
% \begin{taggingsocketdecl}{tbl/finalize} |
| 786 |
% To fine tune the structure (change cells to header cells, remove |
| 787 |
% unwanted structures, move a foot to the end, etc.). We also need a |
| 788 |
% socket that is executed at the end of the table but \emph{before} |
| 789 |
% all the variables are restored to the outer or default values. |
| 790 |
% The code in the socket can make assignments, but probably |
| 791 |
% shouldn't do typesetting and not write whatsits. |
| 792 |
% \begin{macrocode} |
| 793 |
\NewTaggingSocket{tbl/finalize}{0} |
| 794 |
% \end{macrocode} |
| 795 |
% \end{taggingsocketdecl} |
| 796 |
% |
| 797 |
% \begin{taggingsocketdecl}{tbl/restore/celldata} |
| 798 |
% This socket is used in \cs{tbl_restore_outer_cell_data:}, the command |
| 799 |
% that restores cell data when quitting a nested table. It can be used to restore |
| 800 |
% similar tagging related values |
| 801 |
% \begin{macrocode} |
| 802 |
\NewTaggingSocket{tbl/restore/celldata}{0} |
| 803 |
% \end{macrocode} |
| 804 |
% \end{taggingsocketdecl} |
| 805 |
|
| 806 |
% \begin{taggingsocketdecl}{tbl/colspan} |
| 807 |
% This socket is used to manage spanning cells, e.g., a |
| 808 |
% \cs{multicolumn}. It expects one argument (the number of cells |
| 809 |
% spanned) and if tagging is enabled set appropriate tag attributes |
| 810 |
% in the background. We probably need a similar socket for row |
| 811 |
% spans eventually. |
| 812 |
% \begin{macrocode} |
| 813 |
\NewTaggingSocket{tbl/colspan}{1} |
| 814 |
% \end{macrocode} |
| 815 |
% \end{taggingsocketdecl} |
| 816 |
% |
| 817 |
|
| 818 |
|
| 819 |
% \begin{taggingsocketdecl}{tbl/hmode/begin, |
| 820 |
% tbl/hmode/end, |
| 821 |
% tbl/vmode/begin, |
| 822 |
% tbl/vmode/end |
| 823 |
% } |
| 824 |
% |
| 825 |
% These sockets are used in the begin and end code of environments, |
| 826 |
% to allow a fast enabling and disabling of the tagging. We |
| 827 |
% distinguish between tables that can be used inside paragraphs and |
| 828 |
% standalone tables such as \env{longtable} that are always in |
| 829 |
% vertical mode. |
| 830 |
% \begin{macrocode} |
| 831 |
\NewTaggingSocket{tbl/hmode/begin}{0} |
| 832 |
\NewTaggingSocket{tbl/hmode/end}{0} |
| 833 |
\NewTaggingSocket{tbl/vmode/begin}{0} |
| 834 |
\NewTaggingSocket{tbl/vmode/end}{0} |
| 835 |
% \end{macrocode} |
| 836 |
% \end{taggingsocketdecl} |
| 837 |
% |
| 838 |
% |
| 839 |
% |
| 840 |
% \begin{taggingsocketdecl}{tbl/longtable/init, |
| 841 |
% tbl/longtable/finalize} |
| 842 |
% \env{longtable} needs its own sockets to fine tune the structure. |
| 843 |
% Simply switching the plug in the previous socket interferes with |
| 844 |
% enabling/disabling the tagging. |
| 845 |
% \begin{macrocode} |
| 846 |
\NewTaggingSocket{tbl/longtable/init}{0} |
| 847 |
\NewTaggingSocket{tbl/longtable/finalize}{0} |
| 848 |
% \end{macrocode} |
| 849 |
% \end{taggingsocketdecl} |
| 850 |
% |
| 851 |
% \begin{taggingsocketdecl}{tbl/longtable/head, |
| 852 |
% tbl/longtable/foot} |
| 853 |
% Header and footer boxes need special handling because they are repeatedly |
| 854 |
% used. |
| 855 |
% \begin{macrocode} |
| 856 |
\NewTaggingSocket{tbl/longtable/head}{0} |
| 857 |
\NewTaggingSocket{tbl/longtable/foot}{0} |
| 858 |
% \end{macrocode} |
| 859 |
% \end{taggingsocketdecl} |
| 860 |
% |
| 861 |
% |
| 862 |
% \begin{taggingsocketdecl}{tbl/leaders/begin, |
| 863 |
% tbl/leaders/end} |
| 864 |
% Sockets around leaders such as rules or dotted lines, that should |
| 865 |
% be tagged as artifacts, used, for example, in \cs{cline}. |
| 866 |
% \changes{v1.0c}{2024/07/13}{Sockets for \cs{cline} leaders added (tagging/134)} |
| 867 |
% \begin{macrocode} |
| 868 |
\NewTaggingSocket{tbl/leaders/begin}{0} |
| 869 |
\NewTaggingSocket{tbl/leaders/end}{0} |
| 870 |
% \end{macrocode} |
| 871 |
% \end{taggingsocketdecl} |
| 872 |
% |
| 873 |
% \subsubsection{Tagging Support for floats} |
| 874 |
% |
| 875 |
% \begin{taggingsocketdecl}{float/hmode/begin, |
| 876 |
% float/hmode/end} |
| 877 |
% These sockets are used if the float is called in |
| 878 |
% hmode. |
| 879 |
% \changes{v1.0h}{2024/09/13}{Sockets for floats added} |
| 880 |
% \begin{macrocode} |
| 881 |
\NewTaggingSocket{float/hmode/begin}{0} |
| 882 |
\NewTaggingSocket{float/hmode/end}{0} |
| 883 |
% \end{macrocode} |
| 884 |
% \end{taggingsocketdecl} |
| 885 |
% |
| 886 |
% \begin{taggingsocketdecl}{float/begin, |
| 887 |
% float/end} |
| 888 |
% These sockets start and stop the float structure. |
| 889 |
% \begin{macrocode} |
| 890 |
\NewTaggingSocket{float/begin}{0} |
| 891 |
\NewTaggingSocket{float/end}{0} |
| 892 |
% \end{macrocode} |
| 893 |
% \end{taggingsocketdecl} |
| 894 |
% |
| 895 |
% |
| 896 |
% \begin{taggingsocketdecl}{caption/begin, |
| 897 |
% caption/end} |
| 898 |
% These sockets are used in \cs{@makecaption}. |
| 899 |
% They open and close the \texttt{Caption} structure. |
| 900 |
% Their default plugs assume that they are used in |
| 901 |
% vmode. The argument of the begin socket is |
| 902 |
% the structure number of the parent float. If it is |
| 903 |
% empty the current structure number is used. |
| 904 |
% \begin{macrocode} |
| 905 |
\NewTaggingSocket{caption/begin}{1} |
| 906 |
\NewTaggingSocket{caption/end}{0} |
| 907 |
% \end{macrocode} |
| 908 |
% \end{taggingsocketdecl} |
| 909 |
% |
| 910 |
% \begin{taggingsocketdecl}{caption/label/begin, |
| 911 |
% caption/label/end} |
| 912 |
% These sockets are used in \cs{@makecaption} around the |
| 913 |
% label. Their default plugs ensure that |
| 914 |
% the label is outside the paragraph and that |
| 915 |
% the rest of the caption uses flattened para mode. If the |
| 916 |
% caption is not in a hbox, the \texttt{para/begin} |
| 917 |
% socket should follow to properly start the paragraph. |
| 918 |
% \begin{macrocode} |
| 919 |
\NewTaggingSocket{caption/label/begin}{0} |
| 920 |
\NewTaggingSocket{caption/label/end}{0} |
| 921 |
% \end{macrocode} |
| 922 |
% \end{taggingsocketdecl} |
| 923 |
% |
| 924 |
% |
| 925 |
% \subsection{Tagging support for output routines} |
| 926 |
% |
| 927 |
% \changes{v1.0m}{2025/02/14}{Tagging support for output routines added} |
| 928 |
% |
| 929 |
% \begin{taggingsocketdecl}{build/page/header} |
| 930 |
% \changes{v1.0m}{2025/02/14}{Tagging socket added} |
| 931 |
% \begin{taggingsocketdecl}{build/page/footer} |
| 932 |
% \changes{v1.0m}{2025/02/14}{Tagging socket added} |
| 933 |
% These sockets receive the formatted running header/footer in its |
| 934 |
% second argument (the first is not used) following the convention |
| 935 |
% of tagging sockets, i.e., only the second argument is processed |
| 936 |
% if tagging is not active. |
| 937 |
% \begin{macrocode} |
| 938 |
\NewTaggingSocket{build/page/header}{2} |
| 939 |
\NewTaggingSocket{build/page/footer}{2} |
| 940 |
% \end{macrocode} |
| 941 |
% \end{taggingsocketdecl} |
| 942 |
% \end{taggingsocketdecl} |
| 943 |
% |
| 944 |
% |
| 945 |
% |
| 946 |
% \begin{taggingsocketdecl}{build/column/outputbox} |
| 947 |
% \changes{v1.0m}{2025/02/14}{Tagging socket added} |
| 948 |
% This socket is used to add any missing tagging structures to the |
| 949 |
% \cs{@outputbox} box, if necessary. |
| 950 |
% \begin{macrocode} |
| 951 |
\NewTaggingSocket{build/column/outputbox}{0} |
| 952 |
% \end{macrocode} |
| 953 |
% \end{taggingsocketdecl} |
| 954 |
% |
| 955 |
% |
| 956 |
% |
| 957 |
% \begin{taggingsocketdecl}{build/column/footins} |
| 958 |
% \changes{v1.0m}{2025/02/14}{Tagging socket added} |
| 959 |
% This socket is used to add any missing tagging structures to the |
| 960 |
% \cs{footins} box, if necessary. |
| 961 |
% \begin{macrocode} |
| 962 |
\NewTaggingSocket{build/column/footins}{0} |
| 963 |
% \end{macrocode} |
| 964 |
% \end{taggingsocketdecl} |
| 965 |
% |
| 966 |
% |
| 967 |
% |
| 968 |
% |
| 969 |
% |
| 970 |
% |
| 971 |
% \begin{taggingsocketdecl}{page@sofar} |
| 972 |
% |
| 973 |
% This socket is declared and used in the \pkg{multicol} output routines. |
| 974 |
% Only listed for reference. |
| 975 |
% \begin{macrocode} |
| 976 |
%\NewTaggingSocket{page@sofar}{0} |
| 977 |
% \end{macrocode} |
| 978 |
% \end{taggingsocketdecl} |
| 979 |
% |
| 980 |
% \subsection{Tagging support for math} |
| 981 |
% |
| 982 |
% \subsubsection{General sockets} |
| 983 |
% |
| 984 |
% The following sockets are the main math sockets. |
| 985 |
% |
| 986 |
% \changes{v1.0n}{2025/02/19}{Moved math sockets into lttagging} |
| 987 |
% \begin{macrocode} |
| 988 |
\NewTaggingSocket{math/inline/begin}{0} |
| 989 |
\NewTaggingSocket{math/inline/end}{0} |
| 990 |
\NewTaggingSocket{math/inline/formula/begin}{2} |
| 991 |
\NewTaggingSocket{math/inline/formula/end}{0} |
| 992 |
\NewTaggingSocket{math/display/begin}{0} |
| 993 |
\NewTaggingSocket{math/display/end}{0} |
| 994 |
\NewTaggingSocket{math/display/formula/begin}{2} |
| 995 |
\NewTaggingSocket{math/display/formula/end}{0} |
| 996 |
\NewTaggingSocket{math/display/tag/begin}{0} |
| 997 |
\NewTaggingSocket{math/display/tag/end}{0} |
| 998 |
% \end{macrocode} |
| 999 |
% |
| 1000 |
% \subsubsection{Sockets specific for luamml} |
| 1001 |
% \paragraph{Save sockets} |
| 1002 |
% These sockets are wrappers around the \cs{luamml_save:...} commands. |
| 1003 |
% They take an argument which should contain the argument of the save command. |
| 1004 |
% |
| 1005 |
% \begin{taggingsocketdecl}{math/luamml/save/nn} |
| 1006 |
% The argument should contain the two arguments of the command. |
| 1007 |
% \begin{macrocode} |
| 1008 |
\NewTaggingSocket{math/luamml/save/nn}{1} |
| 1009 |
% \end{macrocode} |
| 1010 |
% \end{taggingsocketdecl} |
| 1011 |
% |
| 1012 |
% \begin{taggingsocketdecl}{math/luamml/save/nNn} |
| 1013 |
% The argument should contain the three arguments of the command. |
| 1014 |
% \begin{macrocode} |
| 1015 |
\NewTaggingSocket{math/luamml/save/nNn}{1} |
| 1016 |
% \end{macrocode} |
| 1017 |
% \end{taggingsocketdecl} |
| 1018 |
% |
| 1019 |
% \paragraph{Socket to annotate} |
| 1020 |
% |
| 1021 |
% \begin{taggingsocketdecl}{math/luamml/annotate/false} |
| 1022 |
% These socket can be used for content that should be annotated |
| 1023 |
% with \texttt{core=false} |
| 1024 |
% \begin{macrocode} |
| 1025 |
\NewTaggingSocket{math/luamml/annotate/false}{2} |
| 1026 |
% \end{macrocode} |
| 1027 |
% \end{taggingsocketdecl} |
| 1028 |
% |
| 1029 |
% \paragraph{Array sockets} These sockets will be used in \pkg{array} to |
| 1030 |
% add luamml support to the array environment. |
| 1031 |
% |
| 1032 |
% \begin{taggingsocketdecl}{math/luamml/array/save} |
| 1033 |
% |
| 1034 |
% This socket will be used in \cs{endarray}. The plug is set by luamml. |
| 1035 |
% \begin{macrocode} |
| 1036 |
\NewTaggingSocket{math/luamml/array/save}{0} |
| 1037 |
% \end{macrocode} |
| 1038 |
% \end{taggingsocketdecl} |
| 1039 |
% |
| 1040 |
% \begin{taggingsocketdecl}{math/luamml/array/finalize} |
| 1041 |
% |
| 1042 |
% This socket will be used in \cs{endarray}. The plug is set by luamml. |
| 1043 |
% \begin{macrocode} |
| 1044 |
\NewTaggingSocket{math/luamml/array/finalize}{0} |
| 1045 |
% \end{macrocode} |
| 1046 |
% \end{taggingsocketdecl} |
| 1047 |
% |
| 1048 |
% \begin{taggingsocketdecl}{math/luamml/array/initcol} |
| 1049 |
% This socket will be used in \cs{@classz}. The plug is set by luamml. |
| 1050 |
% \begin{macrocode} |
| 1051 |
\NewTaggingSocket{math/luamml/array/initcol}{0} |
| 1052 |
% \end{macrocode} |
| 1053 |
% \end{taggingsocketdecl} |
| 1054 |
% |
| 1055 |
% |
| 1056 |
% \begin{taggingsocketdecl}{math/luamml/array/finalizecol} |
| 1057 |
% This socket will be used in \cs{@classz}. The plug is set by luamml. |
| 1058 |
% The argument sets the type of the column. |
| 1059 |
% \begin{macrocode} |
| 1060 |
\NewTaggingSocket{math/luamml/array/finalizecol}{1} |
| 1061 |
% \end{macrocode} |
| 1062 |
% \end{taggingsocketdecl} |
| 1063 |
% |
| 1064 |
% \paragraph{Alignment environments} |
| 1065 |
% Multiline environments like \texttt{align}, \texttt{multline} or \texttt{gather} |
| 1066 |
% are tagged as \texttt{mtable}. |
| 1067 |
% |
| 1068 |
% \begin{taggingsocketdecl}{math/luamml/mtable/finalizecol} |
| 1069 |
% This sockets is used at the end of alignment cells and adds them to |
| 1070 |
% the row. The argument passes a type like \texttt{last} or \texttt{box}. |
| 1071 |
% \begin{macrocode} |
| 1072 |
\NewTaggingSocket{math/luamml/mtable/finalizecol}{1} |
| 1073 |
% \end{macrocode} |
| 1074 |
% \end{taggingsocketdecl} |
| 1075 |
% |
| 1076 |
% |
| 1077 |
% \begin{taggingsocketdecl}{math/luamml/mtable/finalize} |
| 1078 |
% This sockets is used at the end of alignment environment to finalize the |
| 1079 |
% mtable code. It should be used normally with \cs{UseExpandableTaggingSocket}. |
| 1080 |
% \begin{macrocode} |
| 1081 |
\NewTaggingSocket{math/luamml/mtable/finalize}{1} |
| 1082 |
% \end{macrocode} |
| 1083 |
% \end{taggingsocketdecl} |
| 1084 |
% |
| 1085 |
% \begin{taggingsocketdecl}{math/luamml/mtable/aligncol} |
| 1086 |
% This sockets is used in multline to add attributes |
| 1087 |
% describing the alignment to the left and right. |
| 1088 |
% It takes an argument, the alignment. |
| 1089 |
% \begin{macrocode} |
| 1090 |
\NewTaggingSocket{math/luamml/mtable/aligncol}{1} |
| 1091 |
% \end{macrocode} |
| 1092 |
% \end{taggingsocketdecl} |
| 1093 |
|
| 1094 |
% |
| 1095 |
% \begin{taggingsocketdecl}{math/luamml/mtable/innertable/save} |
| 1096 |
% This socket is used in \cs{endaligned} to save the table. It takes no argument. |
| 1097 |
% \begin{macrocode} |
| 1098 |
\NewTaggingSocket{math/luamml/mtable/innertable/save}{0} |
| 1099 |
% \end{macrocode} |
| 1100 |
% \end{taggingsocketdecl} |
| 1101 |
% |
| 1102 |
% \begin{taggingsocketdecl}{math/luamml/mtable/smallmatrix/save} |
| 1103 |
% This socket is used in \cs{endsmallmatrix} to save the table. It takes no argument. |
| 1104 |
% TODO: Check if this socket and the innertable socket can/should be merged into a more |
| 1105 |
% generic version. |
| 1106 |
% \begin{macrocode} |
| 1107 |
\NewTaggingSocket{math/luamml/mtable/smallmatrix/save}{0} |
| 1108 |
% \end{macrocode} |
| 1109 |
% \end{taggingsocketdecl} |
| 1110 |
% |
| 1111 |
% \begin{taggingsocketdecl}{math/luamml/mtable/innertable/finalize} |
| 1112 |
% This socket is used e.g. in \cs{endsmallmatrix} and \cs{gathered} to finalize the table. |
| 1113 |
% It takes no argument. |
| 1114 |
% \begin{macrocode} |
| 1115 |
\NewTaggingSocket{math/luamml/mtable/innertable/finalize}{0} |
| 1116 |
% \end{macrocode} |
| 1117 |
% \end{taggingsocketdecl} |
| 1118 |
% |
| 1119 |
% \begin{taggingsocketdecl}{math/luamml/mtable/tag/save} |
| 1120 |
% This socket is used to save a tag for later use. |
| 1121 |
% has been save before. |
| 1122 |
% \begin{macrocode} |
| 1123 |
\NewTaggingSocket{math/luamml/mtable/tag/save}{0} |
| 1124 |
% \end{macrocode} |
| 1125 |
% \end{taggingsocketdecl} |
| 1126 |
|
| 1127 |
% \begin{taggingsocketdecl}{math/luamml/mtable/tag/set} |
| 1128 |
% This socket should be used when a tag is placed. It inserts a tag that |
| 1129 |
% has been save before. |
| 1130 |
% \begin{macrocode} |
| 1131 |
\NewTaggingSocket{math/luamml/mtable/tag/set}{0} |
| 1132 |
% \end{macrocode} |
| 1133 |
% \end{taggingsocketdecl} |
| 1134 |
% |
| 1135 |
% \paragraph{mbox socket} |
| 1136 |
% |
| 1137 |
% \begin{taggingsocketdecl}{math/luamml/hbox} |
| 1138 |
% This socket is used around \cs{hbox} |
| 1139 |
% inside an \cs{mbox}, \cs{makebox} and \cs{text} and annotates |
| 1140 |
% the content if the \cs{hbox} is used inside math. |
| 1141 |
% The real plug is set by luamml but a default plug is defined |
| 1142 |
% here so that the socket can also be used if luamml is not used. |
| 1143 |
% \begin{macrocode} |
| 1144 |
\NewTaggingSocket{math/luamml/hbox}{2} |
| 1145 |
% \end{macrocode} |
| 1146 |
% \end{taggingsocketdecl} |
| 1147 |
% |
| 1148 |
% |
| 1149 |
% \paragraph{math phantom sockets} |
| 1150 |
% \changes{1.0m}{2025-01-27}{add sockets for math phantom commands} |
| 1151 |
% \begin{taggingsocketdecl}{math/luamml/finph@nt} |
| 1152 |
% This socket handles the annotation of \cs{finph@nt} |
| 1153 |
% \begin{macrocode} |
| 1154 |
\NewTaggingSocket{math/luamml/finph@nt}{2} |
| 1155 |
% \end{macrocode} |
| 1156 |
% \end{taggingsocketdecl} |
| 1157 |
% |
| 1158 |
% \begin{taggingsocketdecl}{math/luamml/finph@nt} |
| 1159 |
% This socket handles the annotation of \cs{finsm@sh} |
| 1160 |
% \begin{macrocode} |
| 1161 |
\NewTaggingSocket{math/luamml/finsm@sh}{2} |
| 1162 |
% \end{macrocode} |
| 1163 |
% \end{taggingsocketdecl} |
| 1164 |
% \paragraph{Artifact root sign} |
| 1165 |
% |
| 1166 |
% \begin{taggingsocketdecl}{math/luamml/artifact} |
| 1167 |
% Unicode characters like a root sign should be marked as artifacts |
| 1168 |
% to avoid duplication, e.g., in derivation if mathml |
| 1169 |
% structure elements are used that imply the meaning. |
| 1170 |
% |
| 1171 |
% \begin{macrocode} |
| 1172 |
\NewTaggingSocket{math/luamml/artifact}{0} |
| 1173 |
% \end{macrocode} |
| 1174 |
% \end{taggingsocketdecl} |
| 1175 |
% |
| 1176 |
% \subsection{MathML intent attributes} |
| 1177 |
% \begin{macro}{\MathMLintent,\MathMLarg} |
| 1178 |
% Stub definitions here to allow these commands to be used in packages |
| 1179 |
% whether or not tagging is enabled. |
| 1180 |
% \begin{macrocode} |
| 1181 |
\ExplSyntaxOn |
| 1182 |
\cs_new_protected:Npn\MathMLintent#1#2{#2} |
| 1183 |
\cs_new_protected:Npn\MathMLarg#1#2{#2} |
| 1184 |
\ExplSyntaxOff |
| 1185 |
% \end{macrocode} |
| 1186 |
% \end{macro} |
| 1187 |
% |
| 1188 |
% \subsection{Symbolic structure names} |
| 1189 |
% \begin{macro}{\NewStructureName,\UseStructureName,\AssignStructureRole} |
| 1190 |
% Stub definitions here to allow these commands to be used in packages |
| 1191 |
% whether or not the tagging support code is loaded. |
| 1192 |
% \begin{macrocode} |
| 1193 |
%<@@=tag> |
| 1194 |
\ExplSyntaxOn |
| 1195 |
\cs_new_protected:Npn\NewStructureName#1 |
| 1196 |
{ |
| 1197 |
\tl_new:c {l_@@_name_#1_tl} |
| 1198 |
\tl_set:cn {l_@@_name_#1_tl}{NonStruct} |
| 1199 |
} |
| 1200 |
\cs_new:Npn\UseStructureName#1 |
| 1201 |
{ |
| 1202 |
\cs:w l_@@_name_#1_tl\cs_end: |
| 1203 |
} |
| 1204 |
\cs_new_protected:Npn\AssignStructureRole#1#2 |
| 1205 |
{ |
| 1206 |
\tl_set:cn { l_@@_name_#1_tl }{#2} |
| 1207 |
} |
| 1208 |
\ExplSyntaxOff |
| 1209 |
% \end{macrocode} |
| 1210 |
% \end{macro} |
| 1211 |
% |
| 1212 |
% |
| 1213 |
% \section{For lttab.dtx parked here for now} |
| 1214 |
% |
| 1215 |
% |
| 1216 |
% \begin{macrocode} |
| 1217 |
%<@@=tbl> |
| 1218 |
\ExplSyntaxOn |
| 1219 |
% \end{macrocode} |
| 1220 |
% |
| 1221 |
% |
| 1222 |
% \subsection{Variables for row, column and span counting} |
| 1223 |
% |
| 1224 |
% This part needs a decision on names for various integer registers |
| 1225 |
% as well as a decision if those should be also made available for |
| 1226 |
% \LaTeXe{}-style packages in form of 2e names and or as |
| 1227 |
% non-internals for the L3 programming layer. |
| 1228 |
% |
| 1229 |
% At the moment they are all internal but this probably has to change. |
| 1230 |
% |
| 1231 |
% \begin{macro}{ |
| 1232 |
% \g_@@_col_int, |
| 1233 |
% \g_@@_row_int, |
| 1234 |
% \g_@@_span_tl, |
| 1235 |
% \g_@@_table_cols_tl} |
| 1236 |
% |
| 1237 |
% \cs{g_@@_row_int} holds the current row number in the table. The |
| 1238 |
% value \texttt{0} means we haven't yet processed the table |
| 1239 |
% preamble (or in case of longtable are just in front of the next |
| 1240 |
% chunk to be processed). It is incremented by every \cs{cr} |
| 1241 |
% including the one ending the table preamble. |
| 1242 |
% |
| 1243 |
% TODO: due to the gymnastics needed inside the longtable code the |
| 1244 |
% row counter is directly exposed there rather than hidden by |
| 1245 |
% interfaces. This needs changing when it is decided how to manage |
| 1246 |
% these counters. |
| 1247 |
% |
| 1248 |
% \cs{g_@@_col_int} holds the current column number. The value |
| 1249 |
% \texttt{0} means we have not yet started the table or just finished a table row |
| 1250 |
% (with \verb=\\= typically); any other positive value means we |
| 1251 |
% are currently typesetting a cell in that column in some row |
| 1252 |
% (denoted by the \cs{g_@@_row_int}). |
| 1253 |
% |
| 1254 |
% In a \cs{multicolumn} it holds the column number of the first |
| 1255 |
% spanned column and \cs{g_@@_span_tl} the info how many cells are |
| 1256 |
% spanned. |
| 1257 |
% |
| 1258 |
% \cs{g_@@_span_tl} is normally \texttt{1} except in a |
| 1259 |
% \cs{multicolumn} cell. |
| 1260 |
% \begin{macrocode} |
| 1261 |
\int_new:N \g_@@_col_int |
| 1262 |
\int_new:N \g_@@_row_int |
| 1263 |
\tl_new:N \g_@@_span_tl |
| 1264 |
\tl_new:N \g_@@_table_cols_tl |
| 1265 |
|
| 1266 |
\tl_gset:Nn \g_@@_span_tl {1} |
| 1267 |
\tl_gset:Nn \g_@@_table_cols_tl {0} % indicates outer level |
| 1268 |
% \end{macrocode} |
| 1269 |
% \end{macro} |
| 1270 |
% |
| 1271 |
% |
| 1272 |
% \begin{macro}{\l_@@_saved_col_tl,\l_@@_saved_row_tl, |
| 1273 |
% \l_@@_saved_span_tl,\l_@@_saved_table_cols_tl} |
| 1274 |
% |
| 1275 |
% Saving the outer values if we are nesting tables is necessary (as |
| 1276 |
% the above variables are globally altered). For this we always use |
| 1277 |
% token lists because they don't change and we do not need to blow |
| 1278 |
% additional integer registers. |
| 1279 |
% \begin{macrocode} |
| 1280 |
\tl_new:N \l_@@_saved_col_tl |
| 1281 |
\tl_new:N \l_@@_saved_row_tl |
| 1282 |
\tl_new:N \l_@@_saved_span_tl |
| 1283 |
\tl_new:N \l_@@_saved_table_cols_tl |
| 1284 |
|
| 1285 |
\tl_set:Nn \l_@@_saved_col_tl{0} |
| 1286 |
\tl_set:Nn \l_@@_saved_row_tl{0} |
| 1287 |
\tl_set:Nn \l_@@_saved_span_tl{1} |
| 1288 |
\tl_set:Nn \l_@@_saved_table_cols_tl{0} % indicates outer level |
| 1289 |
% \end{macrocode} |
| 1290 |
% \end{macro} |
| 1291 |
% |
| 1292 |
% \begin{macro}{\g_@@_missingcells_int} |
| 1293 |
% This will contain the number of missing cells in a row: |
| 1294 |
% \begin{macrocode} |
| 1295 |
\int_new:N \g_@@_missing_cells_int |
| 1296 |
% \end{macrocode} |
| 1297 |
% \end{macro} |
| 1298 |
% |
| 1299 |
% |
| 1300 |
% |
| 1301 |
% |
| 1302 |
% |
| 1303 |
% \subsection{Tracing/debugging} |
| 1304 |
% |
| 1305 |
% \begin{macro}{\DebugTablesOn,\DebugTablesOff} |
| 1306 |
% |
| 1307 |
% \begin{macrocode} |
| 1308 |
\def\DebugTablesOn{ |
| 1309 |
\cs_set_eq:NN \@@_trace:n \typeout |
| 1310 |
} |
| 1311 |
\def\DebugTablesOff{ |
| 1312 |
\cs_set_eq:NN \@@_trace:n \use_none:n |
| 1313 |
} |
| 1314 |
% \end{macrocode} |
| 1315 |
% |
| 1316 |
% \begin{macrocode} |
| 1317 |
\cs_new_eq:NN \@@_trace:n \use_none:n |
| 1318 |
% \end{macrocode} |
| 1319 |
% \end{macro} |
| 1320 |
% |
| 1321 |
% |
| 1322 |
% |
| 1323 |
% \subsection{Interface commands} |
| 1324 |
% |
| 1325 |
% All interface commands for the cell number determination have to be |
| 1326 |
% public on some level because they are needed in other packages as |
| 1327 |
% well, e.g., longtable. We may or may not also want to provide 2e |
| 1328 |
% style names for them. |
| 1329 |
% |
| 1330 |
% \begin{macro}{\tbl_update_cell_data:} |
| 1331 |
% Updating cell data in columns after the first means we have to |
| 1332 |
% increment the \cs{g_@@_col_int} by the span count of the previous |
| 1333 |
% cell (in case it was a \cs{multicolumn}) and then reset the |
| 1334 |
% \cs{g_@@_span_tl} to one (as the default). |
| 1335 |
% \begin{macrocode} |
| 1336 |
\cs_new_protected:Npn \tbl_update_cell_data: { |
| 1337 |
\int_gadd:Nn \g_@@_col_int { \g_@@_span_tl } |
| 1338 |
\tl_gset:Nn \g_@@_span_tl {1} |
| 1339 |
} |
| 1340 |
% \end{macrocode} |
| 1341 |
% \end{macro} |
| 1342 |
% |
| 1343 |
% |
| 1344 |
% |
| 1345 |
% \begin{macro}{\tbl_count_table_cols:} |
| 1346 |
% Current implementation of \cs{@mkpream} uses the scratch counter |
| 1347 |
% \cs{count@} to keep track of the number of toks registers it needs |
| 1348 |
% (2 per column), but this can't be used as it counts also |
| 1349 |
% insertions made with \verb+!{}+ and \verb+@{}+. |
| 1350 |
% So similar as does longtable for \cs{LT@cols} we count the |
| 1351 |
% numbers of ampersands instead. |
| 1352 |
% \begin{macrocode} |
| 1353 |
\cs_new:Npn \tbl_count_table_cols: { |
| 1354 |
\seq_set_split:NnV\l_@@_tmpa_seq {&}\@preamble |
| 1355 |
\tl_gset:Ne \g_@@_table_cols_tl { \seq_count:N \l_@@_tmpa_seq } |
| 1356 |
\@@_trace:n { ==>~ Table~ has~ \g_@@_table_cols_tl \space columns } |
| 1357 |
} |
| 1358 |
% \end{macrocode} |
| 1359 |
% \end{macro} |
| 1360 |
% |
| 1361 |
% |
| 1362 |
% \begin{macro}{\l_@@_tmpa_seq} |
| 1363 |
% |
| 1364 |
% \begin{macrocode} |
| 1365 |
\seq_new:N \l_@@_tmpa_seq |
| 1366 |
% \end{macrocode} |
| 1367 |
% \end{macro} |
| 1368 |
% |
| 1369 |
% |
| 1370 |
% |
| 1371 |
% \begin{macro}{\tbl_count_missing_cells:n} |
| 1372 |
% |
| 1373 |
% We might have the situation that some table package has not |
| 1374 |
% implemented the \cs{tbl_count_table_cols:} in which case |
| 1375 |
% \cs{g_@@_table_cols_tl} would always be zero and we would get an |
| 1376 |
% error below when we try to determine the missing cells, so bypass |
| 1377 |
% that calculation if we aren't doing tagging (there the packages |
| 1378 |
% should have the proper code added). Recall that this is code, |
| 1379 |
% that is called by \verb=\\= and an old table package might rely |
| 1380 |
% on whatever the \LaTeX{} kernel offers here. |
| 1381 |
% \begin{macrocode} |
| 1382 |
\cs_new:Npn \tbl_count_missing_cells:n #1 { |
| 1383 |
\tag_if_active:T { |
| 1384 |
\int_compare:nNnT \g_@@_col_int > 0 |
| 1385 |
{ |
| 1386 |
\int_gset:Nn \g_@@_missing_cells_int |
| 1387 |
{ |
| 1388 |
\g_@@_table_cols_tl |
| 1389 |
- \g_@@_col_int |
| 1390 |
- \g_@@_span_tl |
| 1391 |
+ 1 |
| 1392 |
} |
| 1393 |
\int_compare:nNnT \g_@@_missing_cells_int < 0 \ERRORmissingcells % should not happen |
| 1394 |
\@@_trace:n{==>~ |
| 1395 |
(#1)~ |
| 1396 |
This~ row~ needs~ |
| 1397 |
\int_use:N \g_@@_missing_cells_int \space |
| 1398 |
additional~ cell(s) |
| 1399 |
} |
| 1400 |
} |
| 1401 |
} |
| 1402 |
} |
| 1403 |
% \end{macrocode} |
| 1404 |
% \end{macro} |
| 1405 |
% |
| 1406 |
% |
| 1407 |
% |
| 1408 |
% \begin{macro}{\tbl_init_cell_data_for_table:} |
| 1409 |
% |
| 1410 |
% \begin{macrocode} |
| 1411 |
\cs_new_protected:Npn \tbl_init_cell_data_for_table: { |
| 1412 |
\tl_set:No \l_@@_saved_col_tl {\int_use:N \g_@@_col_int } |
| 1413 |
\tl_set:No \l_@@_saved_row_tl {\int_use:N \g_@@_row_int } |
| 1414 |
\tl_set_eq:NN \l_@@_saved_table_cols_tl \g_@@_table_cols_tl |
| 1415 |
\tl_set_eq:NN \l_@@_saved_span_tl \g_@@_span_tl |
| 1416 |
% |
| 1417 |
\@@_trace:n { ==>~ saved~cell~data:~ |
| 1418 |
\l_@@_saved_row_tl, |
| 1419 |
\l_@@_saved_col_tl, |
| 1420 |
\l_@@_saved_span_tl \space |
| 1421 |
( |
| 1422 |
\int_compare:nNnTF \l_@@_saved_table_cols_tl = 0 |
| 1423 |
{ outer~ level } |
| 1424 |
{ max:~ \l_@@_saved_table_cols_tl } |
| 1425 |
) |
| 1426 |
} |
| 1427 |
% \end{macrocode} |
| 1428 |
% Tagging has to initialize cell data too. |
| 1429 |
% \begin{macrocode} |
| 1430 |
\UseTaggingSocket{tbl/init/celldata} |
| 1431 |
% \end{macrocode} |
| 1432 |
% These are the initial values when starting a table: |
| 1433 |
% \begin{macrocode} |
| 1434 |
\int_gzero:N \g_@@_row_int |
| 1435 |
\int_gzero:N \g_@@_col_int |
| 1436 |
\tl_gset:Nn \g_@@_span_tl {1} |
| 1437 |
} |
| 1438 |
% \end{macrocode} |
| 1439 |
% \end{macro} |
| 1440 |
% |
| 1441 |
% |
| 1442 |
% |
| 1443 |
% |
| 1444 |
% \begin{macro}{\tbl_update_cell_data_for_next_row:} |
| 1445 |
% \begin{macrocode} |
| 1446 |
\cs_new_protected:Npn \tbl_update_cell_data_for_next_row: { |
| 1447 |
\int_gincr:N \g_@@_row_int % this row about to start |
| 1448 |
\int_gzero:N \g_@@_col_int % we are before first col |
| 1449 |
} |
| 1450 |
% \end{macrocode} |
| 1451 |
% \end{macro} |
| 1452 |
% |
| 1453 |
% |
| 1454 |
% \begin{macro}{\tbl_init_cell_data_for_row:} |
| 1455 |
% If we start processing a cell in the first column we set |
| 1456 |
% \cs{g_@@_col_int} to \texttt{1} as we are no longer "at" but "in" |
| 1457 |
% the first column. We also set \cs{g_@@_span_tl} to its default |
| 1458 |
% value (not spanning cells). |
| 1459 |
% \begin{macrocode} |
| 1460 |
\cs_new_protected:Npn \tbl_init_cell_data_for_row: { |
| 1461 |
\int_gset:Nn \g_@@_col_int {1} |
| 1462 |
\tl_gset:Nn \g_@@_span_tl {1} |
| 1463 |
} |
| 1464 |
% \end{macrocode} |
| 1465 |
% \end{macro} |
| 1466 |
% |
| 1467 |
% |
| 1468 |
% \begin{macro}{\tbl_if_row_was_started:T, |
| 1469 |
% \tbl_if_row_was_started:TF} |
| 1470 |
% We use \cs{g_@@_col_int} equal zero to indicate that we are just |
| 1471 |
% after a TR (i.e.n between rows or at the very beginning of the |
| 1472 |
% table). Using the row |
| 1473 |
% count is not so good as longtable may split the table in chunks. |
| 1474 |
% |
| 1475 |
% These conditionals have to be expandable (i.e., unprotected) as |
| 1476 |
% they are sometimes executed when \TeX{} is scanning inside a table. |
| 1477 |
% \begin{macrocode} |
| 1478 |
\cs_new:Npn \tbl_if_row_was_started:T { |
| 1479 |
\int_compare:nNnT \g_@@_col_int > 0 |
| 1480 |
} |
| 1481 |
\cs_new:Npn \tbl_if_row_was_started:TF { |
| 1482 |
\int_compare:nNnTF \g_@@_col_int > 0 |
| 1483 |
} |
| 1484 |
% \end{macrocode} |
| 1485 |
% \end{macro} |
| 1486 |
% |
| 1487 |
% |
| 1488 |
% |
| 1489 |
% \begin{macro}{\tbl_gzero_row_count:,\tbl_gincr_row_count:,\tbl_gdecr_row_count:} |
| 1490 |
% This here is basically a temporary interface. What it will be in |
| 1491 |
% the end depends on what we decide concerning exposing row and |
| 1492 |
% column counters, if they stay internal we need something like |
| 1493 |
% this here (perhaps using \texttt{gincr} etc, or perhaps some |
| 1494 |
% other names in the first place). |
| 1495 |
% \begin{macrocode} |
| 1496 |
\cs_new_protected:Npn \tbl_gzero_row_count: { |
| 1497 |
\int_gzero:N \g_@@_row_int |
| 1498 |
} |
| 1499 |
\cs_new_protected:Npn \tbl_gincr_row_count: { |
| 1500 |
\int_gincr:N \g_@@_row_int |
| 1501 |
} |
| 1502 |
\cs_new_protected:Npn \tbl_gdecr_row_count: { |
| 1503 |
\int_gdecr:N \g_@@_row_int |
| 1504 |
} |
| 1505 |
% \end{macrocode} |
| 1506 |
% \end{macro} |
| 1507 |
% |
| 1508 |
% |
| 1509 |
% \begin{macro}{\tbl_inbetween_rows:} |
| 1510 |
% Again name is not really brilliant so far. |
| 1511 |
% \begin{macrocode} |
| 1512 |
\cs_new_protected:Npn \tbl_inbetween_rows: { |
| 1513 |
\int_gzero:N \g_@@_col_int |
| 1514 |
} |
| 1515 |
% \end{macrocode} |
| 1516 |
% \end{macro} |
| 1517 |
% |
| 1518 |
% |
| 1519 |
% |
| 1520 |
% |
| 1521 |
% |
| 1522 |
% |
| 1523 |
% \begin{macro}{\tbl_restore_outer_cell_data:} |
| 1524 |
% |
| 1525 |
% \begin{macrocode} |
| 1526 |
\cs_new_protected:Npn \tbl_restore_outer_cell_data: { |
| 1527 |
\int_gset:Nn \g_@@_col_int { \l_@@_saved_col_tl } |
| 1528 |
\int_gset:Nn \g_@@_row_int { \l_@@_saved_row_tl } |
| 1529 |
\tl_gset_eq:NN \g_@@_span_tl \l_@@_saved_span_tl |
| 1530 |
\tl_gset_eq:NN \g_@@_table_cols_tl \l_@@_saved_table_cols_tl |
| 1531 |
\UseTaggingSocket{tbl/restore/celldata} |
| 1532 |
\@@_trace:n { ==>~ restored~cell~data:~ |
| 1533 |
\int_use:N \g_@@_row_int, |
| 1534 |
\int_use:N \g_@@_col_int, |
| 1535 |
\l_@@_saved_span_tl \space |
| 1536 |
( |
| 1537 |
\int_compare:nNnTF \g_@@_table_cols_tl = 0 |
| 1538 |
{ outer~ level } |
| 1539 |
{ max:~ \g_@@_table_cols_tl } |
| 1540 |
) |
| 1541 |
} |
| 1542 |
} |
| 1543 |
% \end{macrocode} |
| 1544 |
% \end{macro} |
| 1545 |
% |
| 1546 |
% |
| 1547 |
% |
| 1548 |
% \begin{macro}{\tbl_update_multicolumn_cell_data:n} |
| 1549 |
% This macro updates \cs{g_@@_col_int} and \cs{g_@@_span_tl} inside |
| 1550 |
% a \cs{multicolumn} and possibly calls the tagging socket |
| 1551 |
% \texttt{tbl/row/begin}. |
| 1552 |
% \begin{macrocode} |
| 1553 |
\cs_new_protected:Npn \tbl_update_multicolumn_cell_data:n #1 { |
| 1554 |
% \end{macrocode} |
| 1555 |
% We execute socket for tagging only if this \cs{multicolumn} |
| 1556 |
% replaces the preamble of the first column. In that case we also have |
| 1557 |
% to set \cs{g_@@_col_int} to 1 because this is no longer done in the |
| 1558 |
% preamble for the cell either. |
| 1559 |
% \begin{macrocode} |
| 1560 |
\int_compare:nNnTF \g_@@_col_int = 0 |
| 1561 |
{ |
| 1562 |
\UseTaggingSocket{tbl/row/begin} |
| 1563 |
\int_gset:Nn \g_@@_col_int {1} |
| 1564 |
} |
| 1565 |
% \end{macrocode} |
| 1566 |
% If we are in a later column we use \cs{g_@@_span_tl} from the |
| 1567 |
% previous column to update. |
| 1568 |
% \begin{macrocode} |
| 1569 |
{ |
| 1570 |
\int_gadd:Nn \g_@@_col_int { \g_@@_span_tl } |
| 1571 |
} |
| 1572 |
% \end{macrocode} |
| 1573 |
% Then we set the span value so that it can be use in the next column. |
| 1574 |
% \begin{macrocode} |
| 1575 |
\tl_gset:Nn \g_@@_span_tl {#1} |
| 1576 |
} |
| 1577 |
% \end{macrocode} |
| 1578 |
% \end{macro} |
| 1579 |
% |
| 1580 |
% |
| 1581 |
% |
| 1582 |
% \begin{macro}{\tbl_crcr:n} |
| 1583 |
% This macro is used instead of the usual \cs{crcr} at the end of a |
| 1584 |
% table. It is deliberately defined without protection because it |
| 1585 |
% may get expanded by the scanning mechanism of low-level \TeX{} |
| 1586 |
% after a final \cs{cr} (aka \verb=\\=) in the table. In that case |
| 1587 |
% it shouldn't stop the expansion and the conditional inside will |
| 1588 |
% be false, thus it just vanishes without doing anything. If there |
| 1589 |
% are missing cells (in which case we also haven't see \cs{cr} yet) |
| 1590 |
% the macro \cs{tbl_count_missing_cells:n} is executed and |
| 1591 |
% then the row is finished with a final \cs{cr}. |
| 1592 |
% \begin{macrocode} |
| 1593 |
\cs_new:Npn \tbl_crcr:n #1 { |
| 1594 |
\int_compare:nNnT \g_@@_col_int > 0 |
| 1595 |
{ |
| 1596 |
\tbl_count_missing_cells:n {#1} |
| 1597 |
} |
| 1598 |
% \end{macrocode} |
| 1599 |
% Even if we are at the start of a row we my have to do a \cs{cr}, |
| 1600 |
% so we do a \cs{crcr} always at the end. |
| 1601 |
% \changes{v1.0b}{2024/06/10} |
| 1602 |
% {Always issue a \cs{crcr} even if we are at the start of a |
| 1603 |
% row to avoid problems with tabulary and similar code} |
| 1604 |
% \begin{macrocode} |
| 1605 |
\crcr |
| 1606 |
} |
| 1607 |
% \end{macrocode} |
| 1608 |
% \end{macro} |
| 1609 |
% |
| 1610 |
% |
| 1611 |
% |
| 1612 |
% \begin{macrocode} |
| 1613 |
\ExplSyntaxOff |
| 1614 |
%<@@=> |
| 1615 |
% \end{macrocode} |
| 1616 |
% |
| 1617 |
% \changes{v1.0h}{2024/09/20}{moved \cs{@kernel@refstepcounter} into ltxref} |
| 1618 |
% This is needed for \pkg{longtable} because \cs{refstepcounter} is |
| 1619 |
% setting up a target when \pkg{hyperref} is loaded and we don't |
| 1620 |
% want that in \pkg{longtable}.%% |
| 1621 |
% Prevent longtable patching by hyperref until hyperref does so automatically: |
| 1622 |
% \begin{macrocode} |
| 1623 |
\def\hyper@nopatch@longtable{} |
| 1624 |
% \end{macrocode} |
| 1625 |
% |
| 1626 |
% |
| 1627 |
% Should there be a module? |
| 1628 |
% |
| 1629 |
% \begin{macrocode} |
| 1630 |
%<latexrelease>\NewModuleRelease{2024/06/01}{lttagging} |
| 1631 |
%<latexrelease> {Tagging support} |
| 1632 |
% \end{macrocode} |
| 1633 |
% |
| 1634 |
% |
| 1635 |
% |
| 1636 |
% |
| 1637 |
% \begin{macrocode} |
| 1638 |
%<latexrelease>\IncludeInRelease{0000/00/00}{lttagging}% |
| 1639 |
%<latexrelease> {Undo tagging support} |
| 1640 |
%<latexrelease> |
| 1641 |
%<latexrelease> |
| 1642 |
%<latexrelease> |
| 1643 |
%<latexrelease>\EndModuleRelease |
| 1644 |
% \end{macrocode} |
| 1645 |
% |
| 1646 |
% \begin{macrocode} |
| 1647 |
%</2ekernel|latexrelease> |
| 1648 |
% \end{macrocode} |
| 1649 |
% |
| 1650 |
% \Finale |
| 1651 |
% |