Debian Codegraph @

texmf-dist/source/latex-dev/base/lttagging.dtx

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