| 1 |
% \iffalse meta-comment |
| 2 |
% |
| 3 |
%% File: latex-lab-block.dtx (C) Copyright 2021-2025 LaTeX Project |
| 4 |
% |
| 5 |
% It may be distributed and/or modified under the conditions of the |
| 6 |
% LaTeX Project Public License (LPPL), either version 1.3c of this |
| 7 |
% license or (at your option) any later version. The latest version |
| 8 |
% of this license is in the file |
| 9 |
% |
| 10 |
% https://www.latex-project.org/lppl.txt |
| 11 |
% |
| 12 |
\def\ltlabblockdate{2025-07-26} |
| 13 |
\def\ltlabblockversion{0.9k} |
| 14 |
|
| 15 |
%<*driver> |
| 16 |
\DocumentMetadata{tagging=on,pdfstandard=ua-2,lang=en} |
| 17 |
\documentclass[kernel]{l3doc} |
| 18 |
\usepackage{latex-lab-testphase-l3doc} |
| 19 |
\usepackage{amstext} |
| 20 |
\EnableCrossrefs |
| 21 |
\CodelineIndex |
| 22 |
|
| 23 |
\setcounter{secnumdepth}{4} |
| 24 |
\setcounter{tocdepth}{4} |
| 25 |
|
| 26 |
\usepackage{todonotes} |
| 27 |
|
| 28 |
\begin{document} |
| 29 |
\DocInput{latex-lab-block.dtx} |
| 30 |
\end{document} |
| 31 |
%</driver> |
| 32 |
% |
| 33 |
% \fi |
| 34 |
% |
| 35 |
% \providecommand\hook[1]{\texttt{#1\DescribeHook[noprint]{#1}}} |
| 36 |
% \providecommand\socket[1]{\texttt{#1\DescribeSocket[noprint]{#1}}} |
| 37 |
% \providecommand\plug[1]{\texttt{#1\DescribePlug[noprint]{#1}}} |
| 38 |
% |
| 39 |
% \NewDocElement[printtype=\textit{socket},idxtype=socket,idxgroup=Sockets]{Socket}{socketdecl} |
| 40 |
% \NewDocElement[printtype=\textit{hook},idxtype=hook,idxgroup=Hooks]{Hook}{hookdecl} |
| 41 |
% \NewDocElement[printtype=\textit{plug},idxtype=plug,idxgroup=Plugs]{Plug}{plugdecl} |
| 42 |
% |
| 43 |
% |
| 44 |
% \title{Prototype reimplementation of \LaTeXe{}'s block environments using templates} |
| 45 |
% \author{\LaTeX{} Project\thanks{Initial reimplementation of lists done by Bruno |
| 46 |
% Le Floch, generalized second version with tagging support by Frank Mittelbach.}} |
| 47 |
% \date{v\ltlabblockversion\ \ltlabblockdate} |
| 48 |
% |
| 49 |
% \maketitle |
| 50 |
% |
| 51 |
% |
| 52 |
% \newcommand{\xt}[1]{\textsl{\textsf{#1}}} |
| 53 |
% \newcommand{\TODO}[1]{\textbf{[TODO:} #1\textbf{]}} |
| 54 |
% \newcommand{\docclass}{document class \marginpar{\raggedright document class |
| 55 |
% customizations}} |
| 56 |
% |
| 57 |
% \providecommand\hook[1]{\texttt{#1}} |
| 58 |
% \providecommand\struct[1]{\texttt{<#1>}} |
| 59 |
% |
| 60 |
% \NewDocElement[envlike, idxtype=templatetype, idxgroup=template types, |
| 61 |
% printtype=\textit{templatetype}] {TemplateType}{templatetype} |
| 62 |
% |
| 63 |
% \NewDocElement[envlike, idxtype=template, idxgroup=templates, |
| 64 |
% printtype=\textit{templ.}] {Template}{template} |
| 65 |
% |
| 66 |
% \NewDocElement[envlike, idxtype=instance, idxgroup=instances, |
| 67 |
% printtype=\textit{inst.}] {Instance}{instance} |
| 68 |
% |
| 69 |
% |
| 70 |
% \newcommand\key[1]{\texttt{#1}} |
| 71 |
% \newcommand\keyvalue[1]{\texttt{#1}} |
| 72 |
% \newcommand\valuefrom[1]{\textrm{value from }\key{#1}} |
| 73 |
% |
| 74 |
% \newcommand\instname[1]{\texttt{#1}} |
| 75 |
% \newcommand\insttype[1]{\texttt{#1}} |
| 76 |
% |
| 77 |
% \NewDocumentCommand\fmi{sO{}m} |
| 78 |
% {\IfBooleanTF{#1}{\todo[inline,#2]{#3}}^^A |
| 79 |
% {\todo[#2]{#3}}} |
| 80 |
% |
| 81 |
% \NewDocumentCommand\ufi{sO{}m} |
| 82 |
% {\IfBooleanTF{#1}{\todo[inline,#2]{UFi:#3}}^^A |
| 83 |
% {\todo[#2]{UFi:#3}}} |
| 84 |
% \makeatletter |
| 85 |
% \renewenvironment{TemplateInterfaceDescription}[1] |
| 86 |
% { |
| 87 |
% \subsubsection{The~template~type~`#1'} |
| 88 |
% \begingroup |
| 89 |
% \@beginparpenalty\@M |
| 90 |
% \description |
| 91 |
% \def\TemplateArgument##1##2{\item[Arg:~##1]##2\par} |
| 92 |
% \def\TemplateSemantics |
| 93 |
% { |
| 94 |
% \enddescription\endgroup |
| 95 |
% \subsubsection*{Semantics:} |
| 96 |
% } |
| 97 |
% } |
| 98 |
% { |
| 99 |
% \par\bigskip |
| 100 |
% } |
| 101 |
% \renewenvironment{TemplateDescription}[2] |
| 102 |
% {\subsubsection{The \texttt{#1} template `#2'}^^A |
| 103 |
% \paragraph*{Attributes:}^^A |
| 104 |
% \begingroup |
| 105 |
% \@beginparpenalty\@M |
| 106 |
% \description |
| 107 |
% \def\TemplateKey##1##2##3##4{^^A |
| 108 |
% \item[\texttt{##1}~(\textit{\mdseries##2})]##3^^A |
| 109 |
% \ifx\TemplateKey##4\TemplateKey\else |
| 110 |
% \hfill\penalty500\hbox{}\hfill Default:~\keyvalue{##4}^^A |
| 111 |
% \nobreak\hskip-\parfillskip\hskip0pt\relax |
| 112 |
% \fi |
| 113 |
% \par |
| 114 |
% }^^A |
| 115 |
% \def\TemplateSemantics{^^A |
| 116 |
% \enddescription\endgroup |
| 117 |
% \paragraph*{Semantics~\&~Comments:}^^A |
| 118 |
% }^^A |
| 119 |
% } |
| 120 |
% { \par \bigskip } |
| 121 |
% \makeatother |
| 122 |
% |
| 123 |
% |
| 124 |
% \begin{abstract} |
| 125 |
% \end{abstract} |
| 126 |
% |
| 127 |
% |
| 128 |
% \tableofcontents |
| 129 |
% \medskip |
| 130 |
% |
| 131 |
% |
| 132 |
% \begin{documentation} |
| 133 |
% |
| 134 |
% |
| 135 |
% |
| 136 |
% \section{Introduction} |
| 137 |
% |
| 138 |
% The list implementation in \LaTeXe{} serves a dual purpose: it |
| 139 |
% implements real lists such as \env{itemize} or \env{enumerate}, |
| 140 |
% but it is also used as the basis for vertical blocks, i.e., to specify |
| 141 |
% the vertical spacing and paragraph handling after such block, e.g., |
| 142 |
% in environments like \env{center}, \env{quote}, \env{verbatim}, or in |
| 143 |
% the theorem environments. They are all implemented as |
| 144 |
% \enquote{trivial} lists with a single (hidden) item. |
| 145 |
% |
| 146 |
% While this was convenient to get a consistent layout using a single |
| 147 |
% implementation it is not adequate if it comes to interpreting the |
| 148 |
% structure of a document, because environments based on \env{trivlist} |
| 149 |
% should not advertise themselves as being a \enquote{list} --- after all, |
| 150 |
% from a semantic point of view they aren't lists. |
| 151 |
% |
| 152 |
% The approach taking here is therefore to offer separate template |
| 153 |
% types: \insttype{block} (horizontally or vertically oriented data that |
| 154 |
% needs some handling at the start and the end), \insttype{para} (that deals |
| 155 |
% with different paragraph layouts), \insttype{list} (that handles list |
| 156 |
% related parameters, and \insttype{item} (for item layouts and handling). To address |
| 157 |
% the independent aspects we have the template type \insttype{blockenv} |
| 158 |
% that ties them together as necessary. |
| 159 |
% |
| 160 |
% For example, a \env{quote} environment would make use of a (display) |
| 161 |
% \insttype{block} and some \insttype{para} instnce while an standard |
| 162 |
% \env{enumerate} would make use of a display \insttype{block}, a \insttype{list}, |
| 163 |
% and an \insttype{item} and \insttype{para} instance. |
| 164 |
% An inline list (like \env{enumerate*} from the \pkg{enumitem} |
| 165 |
% package) would be using the same \insttype{list} instance but a different |
| 166 |
% (horizontally oriented) \insttype{block} instance build from a |
| 167 |
% different template. |
| 168 |
% |
| 169 |
% |
| 170 |
% |
| 171 |
% \section{Template types and templates for blocks and lists} |
| 172 |
% |
| 173 |
% \subsection{Template types} |
| 174 |
% |
| 175 |
% \begin{TemplateInterfaceDescription}{block} |
| 176 |
% \TemplateArgument{1}{key/value list to alter the default block parameters} |
| 177 |
% \TemplateSemantics |
| 178 |
% Handle the layout aspects of a block of data. In case of a |
| 179 |
% \enquote{display} block (i.e., vertically oriented) the spacing |
| 180 |
% and page breaking as well as the handling if the block starts a |
| 181 |
% paragraph or ends one, that is, if text is immediately following |
| 182 |
% the block without being separated by an empty line, then this |
| 183 |
% text is considered to be in the same paragraph as the block. |
| 184 |
% |
| 185 |
% In case of a horizontally oriented block it covers any special |
| 186 |
% handling at the start and end of the block, e.g, extra spacing, |
| 187 |
% prohibitying or encuraging line breaks, and so forth. |
| 188 |
% \end{TemplateInterfaceDescription} |
| 189 |
% |
| 190 |
% \begin{TemplateInterfaceDescription}{para} |
| 191 |
% \TemplateArgument{1}{key/value list to alter the default item parameters} |
| 192 |
% \TemplateSemantics |
| 193 |
% Sets up paragraph-specific parameters for H\&J, e.g., to |
| 194 |
% implement justification variations, the behavior of \verb=\\= |
| 195 |
% etc. The instances are used in higher-level templates, e.g., in a |
| 196 |
% \insttype{block}. |
| 197 |
% \end{TemplateInterfaceDescription} |
| 198 |
% |
| 199 |
% \begin{TemplateInterfaceDescription}{list} |
| 200 |
% \TemplateArgument{1}{key/value list to alter the default item parameters} |
| 201 |
% \TemplateSemantics |
| 202 |
% Handle the aspects related to list design, e.g., the use and |
| 203 |
% formatting of counters, etc. |
| 204 |
% |
| 205 |
% Note that this does not cover block-related aspects, i.e., a list |
| 206 |
% instance could be used both for a display list or for an inline line. |
| 207 |
% \end{TemplateInterfaceDescription} |
| 208 |
% |
| 209 |
% \begin{TemplateInterfaceDescription}{item} |
| 210 |
% \TemplateArgument{1}{key/value list to alter the default item parameters} |
| 211 |
% \TemplateSemantics |
| 212 |
% A sub-type used as part of \insttype{list} to easily cover alternative layout |
| 213 |
% for list items. |
| 214 |
% \end{TemplateInterfaceDescription} |
| 215 |
% |
| 216 |
% |
| 217 |
% \begin{TemplateInterfaceDescription}{blockenv} |
| 218 |
% \TemplateArgument{1}{key/value list to alter the default parameters of the template |
| 219 |
% instances used by the particular block environment} |
| 220 |
% \TemplateSemantics |
| 221 |
% This template type is used to implement document-level |
| 222 |
% environments. It defines a \insttype{block} instance to handle the |
| 223 |
% layout at the \enquote{edge} of the environment data, possibly |
| 224 |
% some paragraph setup through a \insttype{para} instance, potentially an |
| 225 |
% \enquote{inner} instance for more complicated environments (such |
| 226 |
% as lists), and possibly some additional setup code for certain |
| 227 |
% environments. |
| 228 |
% |
| 229 |
% It also defines how the \insttype{blockenv} behaves with respect to |
| 230 |
% nesting, e.g., does it change when nested and if so how many |
| 231 |
% levels of nesting are supported, etc. |
| 232 |
% |
| 233 |
% Finally, the template type defines how it appears in a tagged PDF |
| 234 |
% document, what tag names are used, how they are rolemapped and |
| 235 |
% whether it adds additional attributes, etc. |
| 236 |
% \end{TemplateInterfaceDescription} |
| 237 |
% |
| 238 |
% |
| 239 |
% |
| 240 |
% \subsection{Templates} |
| 241 |
% |
| 242 |
% |
| 243 |
% \begin{TemplateDescription}{blockenv}{display} |
| 244 |
% |
| 245 |
% \TemplateKey{name}{tokenlist} |
| 246 |
% {Name of the environment used in tracing and error messages.}{} |
| 247 |
% \TemplateKey{tag-name}{tokenlist} |
| 248 |
% {Name of the tag used for the block inside the PDF. If not explicitly given |
| 249 |
% the name is defined by the \key{tagging-recipe}. Note that in case of |
| 250 |
% \key{tagging-recipe}\texttt{=basic} no tag for the block is produced, so any |
| 251 |
% key settings are ignored.}{\meta{empty}} |
| 252 |
% \TemplateKey{tag-attr-class}{tokenlist} |
| 253 |
% {An explicit tag class attribute.}{\meta{empty}} |
| 254 |
% \TemplateKey{tagging-recipe}{tokenlist} |
| 255 |
% {Defines the way tagging is done. Currently the values |
| 256 |
% \keyvalue{basic}, \keyvalue{standard}, and \keyvalue{list} |
| 257 |
% are supported.}{standard} |
| 258 |
% \TemplateKey{increment-level}{boolean}{Does this \insttype{blockenv} |
| 259 |
% increase the block level if it is nested in an outer block?}{true} |
| 260 |
% \TemplateKey{setup-code}{tokenlist} |
| 261 |
% {Initial setup code. This is |
| 262 |
% executed after legacy defaults (from \tn{@listi}, |
| 263 |
% \tn{@listii}, etc.) are used but before the block instance |
| 264 |
% is called.}{\meta{empty}} |
| 265 |
% \TemplateKey{block-instance}{tokenlist}{Part of the name of the |
| 266 |
% \insttype{block} instance that is called. The full name has |
| 267 |
% a \texttt{-}\meta{level} appended.}{displayblock} |
| 268 |
% \TemplateKey{para-instance}{tokenlist}{Paragraph settings to use |
| 269 |
% within the environment. If \meta{empty} then outer values are |
| 270 |
% retained. However, the block template resets some values, which |
| 271 |
% may not be the right thing to do.}{\meta{empty}} |
| 272 |
% \TemplateKey{inner-level-counter}{tokenlist}{Name of an existing (!) counter |
| 273 |
% that is incremented and used to determine final name |
| 274 |
% of the \key{inner-instance} or empty if always the |
| 275 |
% same inner instance should be used.}{} |
| 276 |
% \TemplateKey{max-inner-levels}{tokenlist}{Maximum number of nested |
| 277 |
% environments of this kind. Only relevant if there is a |
| 278 |
% \key{inner-level-counter} specified.}{4} |
| 279 |
% \TemplateKey{inner-instance-type}{tokenlist}{Template type of the |
| 280 |
% inner instance.}{list} |
| 281 |
% \TemplateKey{inner-instance}{tokenlist}{Name of the inner instance |
| 282 |
% (if any). If there is an \key{inner-level-counter} then |
| 283 |
% the instance name gets \texttt{-}\meta{counter value} |
| 284 |
% appended.}{\meta{empty}} |
| 285 |
% \TemplateKey{tagging-suppress-paras}{boolean}{\emph{describe}}{false} |
| 286 |
% \TemplateKey{final-code}{tokenlist}{Final setup code}{\tn{ignorespaces}} |
| 287 |
% |
| 288 |
% \TemplateSemantics |
| 289 |
% |
| 290 |
% This \insttype{blockenv} template supports the legacy list setting that |
| 291 |
% are found in many document classes in the macros \tn{@listi}, |
| 292 |
% \tn{@listii}, up to \tn{@listvi}. It also uses the counter |
| 293 |
% \tn{@listdepth} to track nesting of block, again mainly to |
| 294 |
% support legacy setups (internally it gives it a more appropriate |
| 295 |
% name but it remains accessible through the \LaTeXe{} name). |
| 296 |
% |
| 297 |
% |
| 298 |
% It first checks that nothing is too deeply nested. |
| 299 |
% If the level should increase then the increments the |
| 300 |
% \tn{@listdepth} counter and |
| 301 |
% calls the corresponding \tn{@list...} macro to update the legacy |
| 302 |
% defaults. If \key{increment-level} is set to false this is bypassed. |
| 303 |
% |
| 304 |
% It then sets up the |
| 305 |
% tagging via the \key{tagging-recipe} setting and executes any |
| 306 |
% code in \key{setup-code}. |
| 307 |
% |
| 308 |
% Afterwards it calls the appropriate \insttype{block} instance based on |
| 309 |
% \key{block-instance} and current level, e.g., |
| 310 |
% \texttt{displayblock-1}. Then it sets up paragraph parameters if |
| 311 |
% a \key{para-instance} was specified (otherwise they stay as |
| 312 |
% they are). |
| 313 |
% |
| 314 |
% If a \key{inner-instance} was specified this is called next, |
| 315 |
% or more precisely: if no \key{inner-level-counter} was |
| 316 |
% specified the instance \key{inner-instance} is |
| 317 |
% called. |
| 318 |
% |
| 319 |
% Otherwise, the \key{inner-level-counter} is incremented and the |
| 320 |
% instance with the name |
| 321 |
% \key{inner-instance}\texttt{-}\key{inner-level-counter} is |
| 322 |
% called. |
| 323 |
% |
| 324 |
% Finally, the \key{final-code} is executed (by default |
| 325 |
% \tn{ignorespaces}). |
| 326 |
% |
| 327 |
% |
| 328 |
% \end{TemplateDescription} |
| 329 |
% |
| 330 |
% The maximum number of \insttype{blockenv}s that can be nested into each |
| 331 |
% other is restricted by the \LaTeX{} counter |
| 332 |
% \texttt{maxblocklevels} with a default value of \keyvalue{6}. If this |
| 333 |
% value is increased then it is necessary to provide additional |
| 334 |
% instances, e.g., \texttt{displayblock-7}, etc. Decreasing is, of |
| 335 |
% course, always possible, then some of the instances defined are not |
| 336 |
% used and instead the user gets an error that there is too much |
| 337 |
% nesting going on. |
| 338 |
% |
| 339 |
% If the key \key{increment-level} is set to \keyvalue{false} then such |
| 340 |
% an environment doesn't alter the nesting level and therefore you can |
| 341 |
% nest those environments as often as you like (a typical example |
| 342 |
% would be \env{flushleft} anywhere in the nesting hierarchy, that |
| 343 |
% would have no effect on hitting the boundary). |
| 344 |
% |
| 345 |
% |
| 346 |
% \begin{TemplateDescription}{block}{display} |
| 347 |
% |
| 348 |
% \TemplateKey{begin-vspace}{skip}{}{\tn{topsep}} |
| 349 |
% \TemplateKey{begin-extra-vspace}{skip}{}{\tn{partopsep}} |
| 350 |
% \TemplateKey{para-vspace}{skip}{}{\tn{parsep}} |
| 351 |
% \TemplateKey{end-vspace}{skip}{}{\valuefrom{begin-vspace}} |
| 352 |
% \TemplateKey{end-extra-vspace}{skip}{}{\valuefrom{begin-extra-vspace}} |
| 353 |
% \TemplateKey{item-vspace}{skip}{The space in front of an item if the |
| 354 |
% block is a list; if not the setting has no effect}{\tn{itemsep}} |
| 355 |
% \TemplateKey{begin-penalty}{integer}{}{\tn{@beginparpenalty}} |
| 356 |
% \TemplateKey{end-penalty}{integer}{}{\tn{@endparpenalty}} |
| 357 |
% \TemplateKey{left-margin}{length}{}{\tn{leftmargin}} |
| 358 |
% \TemplateKey{right-margin}{length}{}{\tn{rightmargin}} |
| 359 |
% \TemplateKey{para-indent}{length}{}{0pt} |
| 360 |
% |
| 361 |
% \TemplateSemantics |
| 362 |
% |
| 363 |
% The idea of a \key{heading} key needs some further |
| 364 |
% thoughts and therfore has been removed for now. |
| 365 |
% Maybe instead the template type should accept a second |
| 366 |
% argument and receive input for such a heading from the document |
| 367 |
% level instead. |
| 368 |
% |
| 369 |
% The names of the keys need further thoughts and some |
| 370 |
% decision. Right now it is a mixture of those with hyphens and |
| 371 |
% those that match legacy register names (the way \pkg{enumitem} |
| 372 |
% did its keys). |
| 373 |
% |
| 374 |
% \end{TemplateDescription} |
| 375 |
% |
| 376 |
% |
| 377 |
% \begin{TemplateDescription}{para}{std} |
| 378 |
% |
| 379 |
% \TemplateKey{para-indent}{length}{}{\tn{parindent}} |
| 380 |
% \TemplateKey{begin-hspace}{skip}{}{0pt} |
| 381 |
% \TemplateKey{left-hspace}{skip}{}{0pt} |
| 382 |
% \TemplateKey{right-hspace}{skip}{}{0pt} |
| 383 |
% \TemplateKey{end-hspace}{skip}{}{\tn{@flushglue}} |
| 384 |
% \TemplateKey{fixed-word-spaces}{boolean}{}{false} |
| 385 |
% \TemplateKey{final-hyphen-demerits}{integer}{}{5000} |
| 386 |
% \TemplateKey{newline-cmd}{tokenlist}{}{\tn{@normalcr}} |
| 387 |
% \TemplateKey{para-attr-class}{tokenlist}{}{justify} |
| 388 |
% |
| 389 |
% \TemplateSemantics |
| 390 |
% |
| 391 |
% |
| 392 |
% \end{TemplateDescription} |
| 393 |
% |
| 394 |
% |
| 395 |
% |
| 396 |
% \begin{TemplateDescription}{list}{std} |
| 397 |
% |
| 398 |
% \TemplateKey{counter}{tokenlist} |
| 399 |
% {Counter name to be used in a numbered list or empty, |
| 400 |
% if the list is unnumbered}{} |
| 401 |
% \TemplateKey{item-label}{tokenlist} |
| 402 |
% {Label \enquote{string} for a fixed label or as |
| 403 |
% generated from the current \key{counter} value}{} |
| 404 |
% \TemplateKey{start}{integer} |
| 405 |
% {Start value for the counter if the list is numbered, |
| 406 |
% otherwise irrelevant}{1} |
| 407 |
% \TemplateKey{resume}{boolean} |
| 408 |
% {Should a numbered list be resumed from the last instance?}{false} |
| 409 |
% \TemplateKey{item-instance}{instance} |
| 410 |
% {Instance of type \texttt{item} to be used to format |
| 411 |
% the label string}{basic} |
| 412 |
% \TemplateKey{item-vspace}{skip}{The space in front of an item in the |
| 413 |
% list. If not specified the value specified in the block template instance is used}{} |
| 414 |
% \TemplateKey{item-indent}{length}{Horizontal displacement of the item.}{0pt} |
| 415 |
% \TemplateKey{item-penalty}{integer} |
| 416 |
% {Penalty for breaking before an |
| 417 |
% item (except the first)}{\tn{@itempenalty}} |
| 418 |
% \TemplateKey{label-width}{length} |
| 419 |
% {Width reserved for the formatted item label}{\tn{labelwidth}} |
| 420 |
% \TemplateKey{label-sep}{length} |
| 421 |
% {Horizontal separation between label and following text}{\tn{labelsep}} |
| 422 |
% \TemplateKey{legacy-support}{boolean} |
| 423 |
% {Is formatting the label via \tn{makelabel} supported?}{false} |
| 424 |
% |
| 425 |
% \TemplateSemantics |
| 426 |
% |
| 427 |
% |
| 428 |
% \end{TemplateDescription} |
| 429 |
% |
| 430 |
% |
| 431 |
% \begin{TemplateDescription}{item}{std} |
| 432 |
% |
| 433 |
% \TemplateKey{counter-label}{function{1}}{\emph{unused}}{\tn{arabic}\{\#1\}} |
| 434 |
% \TemplateKey{counter-ref}{function{1}}{\emph{unused}}{\valuefrom{counter-label}} |
| 435 |
% \TemplateKey{label-ref}{function{1}}{\emph{unused}}{\#1} |
| 436 |
% \TemplateKey{label-autoref}{function{1}}{\emph{unused}}{item~\#1} |
| 437 |
% \TemplateKey{label-format}{function{1}} |
| 438 |
% {Formatting of the label, questionable the way it is used}{\#1} |
| 439 |
% \TemplateKey{label-strut}{boolean}{Add a \tn{strut} to the label?}{false} |
| 440 |
% \TemplateKey{label-align}{choice} |
| 441 |
% {Supported values \keyvalue{left},\keyvalue{center}, |
| 442 |
% \keyvalue{right}, and \keyvalue{parleft}. \emph{Only partly implemented}}{right} |
| 443 |
% \TemplateKey{label-boxed}{boolean} |
| 444 |
% {Should the label be boxed?}{true} |
| 445 |
% \TemplateKey{next-line}{boolean}{}{false} |
| 446 |
% \TemplateKey{text-font}{tokenlist}{\emph{unused}}{} |
| 447 |
% \TemplateKey{compatibility}{boolean}{}{true} |
| 448 |
% |
| 449 |
% \TemplateSemantics |
| 450 |
% |
| 451 |
% This template is only rudimentary implemented at the moment. It |
| 452 |
% probably needs other keys and the existing ones need a proper |
| 453 |
% implementation. |
| 454 |
% |
| 455 |
% \end{TemplateDescription} |
| 456 |
% |
| 457 |
% |
| 458 |
% \section{Declaration of standard block environments} |
| 459 |
% |
| 460 |
% |
| 461 |
% \subsection{The \env{center}, \env{flushleft}, and \env{flushright} environments} |
| 462 |
% |
| 463 |
% The \env{center} environment is defined through the |
| 464 |
% \insttype{blockenv} instance \instname{center} which |
| 465 |
% makes use of the \insttype{block} instance |
| 466 |
% \instname{displayblock-\meta{level}} and the |
| 467 |
% \insttype{para} instance \instname{center}. The block |
| 468 |
% nesting level is not incremented. With respect to tagging, text separated |
| 469 |
% by \cs{par} commands (or empty lines) inside the environment is |
| 470 |
% not tagged as separate paragraphs, i.e., the whole environment is |
| 471 |
% considered to be part of an outer paragraph. The default |
| 472 |
% implementation is |
| 473 |
%\begin{verbatim} |
| 474 |
% \DeclareInstance{blockenv}{center}{display} |
| 475 |
% { |
| 476 |
% name = center, |
| 477 |
% tagging-recipe = basic, |
| 478 |
% tagging-suppress-paras = true , |
| 479 |
% increment-level = false, |
| 480 |
% block-instance = displayblock , |
| 481 |
% para-instance = center , |
| 482 |
% } |
| 483 |
%\end{verbatim} |
| 484 |
% The \env{flushleft} and \env{flushright} environments are defined in |
| 485 |
% a similar way. |
| 486 |
% |
| 487 |
% |
| 488 |
% \subsection{The \env{quote} and \env{quotation} environments} |
| 489 |
% |
| 490 |
% The \env{quote} environment is defined through the |
| 491 |
% \insttype{blockenv} instance \instname{quote} which makes |
| 492 |
% use of the \insttype{block} instance |
| 493 |
% \instname{quoteblock-\meta{level}}. The paragraph setup is |
| 494 |
% inherited. The block nesting level is incremented. The default |
| 495 |
% implementation is |
| 496 |
%\begin{verbatim} |
| 497 |
% \DeclareInstance{blockenv}{quote}{display} |
| 498 |
% { |
| 499 |
% name = quote, |
| 500 |
% tag-name = quote, |
| 501 |
% tagging-recipe = standard, |
| 502 |
% increment-level = true, |
| 503 |
% block-instance = quoteblock , |
| 504 |
% } |
| 505 |
%\end{verbatim} |
| 506 |
% The implementation of \env{quotation} is similar but uses |
| 507 |
% \instname{quotationblock-\meta{level}}. |
| 508 |
% |
| 509 |
% |
| 510 |
% |
| 511 |
% \subsection{The \env{verbatim} and \env{verbatim*} environments} |
| 512 |
% |
| 513 |
% Both the \env{verbatim} environment is defined through the |
| 514 |
% \insttype{blockenv} instance \instname{verbatim} which makes use |
| 515 |
% of the \insttype{block} instance |
| 516 |
% \instname{verbatimblock-\meta{level}} and the \insttype{para} |
| 517 |
% instance \instname{justify}. The block nesting level is not |
| 518 |
% incremented. Verbatim processing requires various catcode |
| 519 |
% changes, etc.\ and as a consequence a special parsing routine |
| 520 |
% that grabs the whole environment while these catcodes are in |
| 521 |
% force. This setup is done in the \key{final-code} key and its |
| 522 |
% last action is to initiate the special parsing. The default |
| 523 |
% implementation is |
| 524 |
%\begin{verbatim} |
| 525 |
% \DeclareInstance{blockenv}{verbatim}{display} |
| 526 |
% { |
| 527 |
% name = verbatim, |
| 528 |
% tag-name = verbatim, |
| 529 |
% tagging-recipe = standard, |
| 530 |
% tagging-suppress-paras = true, |
| 531 |
% increment-level = false, |
| 532 |
% block-instance = verbatimblock , |
| 533 |
% para-instance = justify , |
| 534 |
% final-code = \legacyverbatimsetup |
| 535 |
% \@setupverbinvisiblespace \@vobeyspaces |
| 536 |
% \@xverbatim |
| 537 |
% } |
| 538 |
%\end{verbatim} |
| 539 |
% The implementation of \env{verbatim*} is similar using the |
| 540 |
% \insttype{blockenv} instance \instname{verbatim*}. Its |
| 541 |
% \key{final-code} sets up visible spaces and a slightly diffeent |
| 542 |
% parsing that grabs everything up to |
| 543 |
% \verb=\end{verbatim*}=. Otherwise the setup is identical. |
| 544 |
% |
| 545 |
% |
| 546 |
% \subsection{The \env{itemize} environment} |
| 547 |
% |
| 548 |
% The \env{itemize} environment is defined through the |
| 549 |
% \insttype{blockenv} instance \instname{itemize} which makes use |
| 550 |
% of the \insttype{block} instance \instname{list-\meta{level}}, |
| 551 |
% and an inner instance \instname{itemize-\meta{inner-level}} of |
| 552 |
% type \insttype{list}. The paragraph setup is inherited. The |
| 553 |
% \meta{inner-level} is determined through \cs{@itemdepth}. The |
| 554 |
% block nesting level and the inner list nesting level are |
| 555 |
% incremented. The default implementation is |
| 556 |
%\begin{verbatim} |
| 557 |
% \DeclareInstance{blockenv}{itemize}{display} |
| 558 |
% { |
| 559 |
% name = itemize, |
| 560 |
% tag-name = itemize, |
| 561 |
% tag-attr-class = itemize, |
| 562 |
% tagging-recipe = list, |
| 563 |
% inner-level-counter = \@itemdepth, |
| 564 |
% increment-level = true, |
| 565 |
% max-inner-levels = 4, |
| 566 |
% block-instance = listblock , |
| 567 |
% inner-instance = itemize , |
| 568 |
% } |
| 569 |
%\end{verbatim} |
| 570 |
% |
| 571 |
% |
| 572 |
% \subsection{The \env{enumerate} environment} |
| 573 |
% |
| 574 |
% The \env{enumerate} environment is similar to \env{itemize} but |
| 575 |
% uses the \insttype{blockenv} instance \instname{enumerate}, the |
| 576 |
% \insttype{block} instance \instname{list-\meta{level}}, and the |
| 577 |
% inner instance \instname{enumerate-\meta{inner-level}}. The |
| 578 |
% \meta{inner-level} is determined through \cs{@enumdepth}. |
| 579 |
% |
| 580 |
% \subsection{The \env{description} environment} |
| 581 |
% |
| 582 |
% The \env{description} environment uses the \insttype{blockenv} |
| 583 |
% instance \instname{description}, the \insttype{block} instance |
| 584 |
% \instname{list-\meta{level}}, and the inner instance |
| 585 |
% \instname{description} (no dependency on the nesting level), i.e., the |
| 586 |
% environment has the same appearance on all nesting levels. |
| 587 |
% |
| 588 |
% \subsection{The \env{list} environment} |
| 589 |
% |
| 590 |
% The generic \env{list} environment of \LaTeXe{} is modeled with a |
| 591 |
% \insttype{blockenv} instance named \instname{list}, a |
| 592 |
% \insttype{block} instance named \instname{list-\meta{level}}, and |
| 593 |
% an inner instance named \instname{legacy} (with no dependency on |
| 594 |
% the nesting level). This environment has two arguments and |
| 595 |
% customization of the layout is expected to be directly set in the |
| 596 |
% second argument. For this reason this \instname{legacy} instance |
| 597 |
% is something that shouldn't be changed (all that is attempted to |
| 598 |
% provide a way to support legacy setups). |
| 599 |
% |
| 600 |
% To set up the default settings (as they were used in \LaTeXe{}) |
| 601 |
% the \key{setup-code} key gets \cs{legacylistsetupcode} assigned, |
| 602 |
% so the default setup (that should probably not be changed) looks |
| 603 |
% as follows: |
| 604 |
%\begin{verbatim} |
| 605 |
% \DeclareInstance{blockenv}{list}{display} |
| 606 |
% { |
| 607 |
% name = list, |
| 608 |
% tag-name = list, |
| 609 |
% tagging-recipe = list, |
| 610 |
% increment-level = true, |
| 611 |
% setup-code = \legacylistsetupcode , |
| 612 |
% block-instance = listblock , |
| 613 |
% inner-instance = legacy , |
| 614 |
% } |
| 615 |
%\end{verbatim} |
| 616 |
% |
| 617 |
% |
| 618 |
% |
| 619 |
% \subsection{The \env{verse} environment} |
| 620 |
% |
| 621 |
% The \env{verse} environment is currently still implemented as a |
| 622 |
% list without real items (as in \LaTeXe{}. That needs updating.\fmi{fix} |
| 623 |
% |
| 624 |
% |
| 625 |
% \subsection{The \env{trivlist} environment} |
| 626 |
% |
| 627 |
% In \LaTeXe{} \env{trivlist} was used to define various display |
| 628 |
% environments that aren't really lists at all. To support such |
| 629 |
% legacy definitions (even though they shuld be updated to achieve |
| 630 |
% proper tagging) we continue to support and implement it as a |
| 631 |
% \env{list} environment with a few hardwired settings mimicking |
| 632 |
% the original behavior. |
| 633 |
% |
| 634 |
% \subsection{Environments declared through \cs{newtheorem}} |
| 635 |
% |
| 636 |
% \emph{to document} |
| 637 |
% |
| 638 |
% |
| 639 |
% \section{Adjusting the layout of standard block environments} |
| 640 |
% |
| 641 |
% \emph{to document} |
| 642 |
% |
| 643 |
% |
| 644 |
% |
| 645 |
% |
| 646 |
% |
| 647 |
% |
| 648 |
% \section{Tagging support} |
| 649 |
% |
| 650 |
% \subsection{Paragraph tags} |
| 651 |
% |
| 652 |
% Paragraphs in \LaTeX{} can be nested, e.g., you can have a paragraph |
| 653 |
% containing a display quote, which in turn consists of more than one |
| 654 |
% (sub)paragraph, followed by some more text which all belongs to the |
| 655 |
% same outer paragraph. |
| 656 |
% |
| 657 |
% In the PDF model and in the HTML model that is not supported --- a |
| 658 |
% limitation that conflicts with real live, given that such |
| 659 |
% constructs are quite normal in spoken and written language. |
| 660 |
% |
| 661 |
% The approach we take to resolve this is to model such \enquote{big} |
| 662 |
% paragraphs with a structure named \struct{text-unit} and use \struct{text} (rollmapped to \struct{P}) |
| 663 |
% only for (portions of) the actual paragraph text in a way that the |
| 664 |
% \struct{text}s are not nested. As a result we have for a simple |
| 665 |
% paragraph the structures |
| 666 |
% \begin{tabbing} |
| 667 |
% \hspace*{1em}\=\hspace*{1em}\=\hspace*{1em}\=\hspace*{1em}\= \kill |
| 668 |
% \> \struct{text-unit}\\ |
| 669 |
% \>\> \struct{text}\\ |
| 670 |
% \>\>\> The paragraph text \ldots\\ |
| 671 |
% \>\> \struct{/text}\\ |
| 672 |
% \> \struct{/text-unit} |
| 673 |
% \end{tabbing} |
| 674 |
% The \struct{text-unit} structure is rollmapped to \struct{Part} or possibly to |
| 675 |
% \struct{Div} so we get a valid PDF, but processors who care can identify |
| 676 |
% the complete paragraphs by looking for \struct{text-unit} tags. |
| 677 |
% |
| 678 |
% In the case of an element, such as a display quote or a display list |
| 679 |
% inside the paragraph, we then have |
| 680 |
% \begin{tabbing} |
| 681 |
% \hspace*{1em}\=\hspace*{1em}\=\hspace*{1em}\=\hspace*{1em}\= \kill |
| 682 |
% \> \struct{text-unit}\\ |
| 683 |
% \>\> \struct{text}\\ |
| 684 |
% \>\>\> The paragraph text before the display element \ldots\\ |
| 685 |
% \>\> \struct{/text}\\ |
| 686 |
% \>\> \struct{display element structure}\\ |
| 687 |
% \>\>\> Content of the display structure possibly involving inner \struct{text-unit} tags\\ |
| 688 |
% \>\> \struct{/display element structure}\\ |
| 689 |
% \>\> \struct{text}\\ |
| 690 |
% \>\>\> \ldots{} continuing the outer paragraph text\\ |
| 691 |
% \>\> \struct{/text}\\ |
| 692 |
% \> \struct{/text-unit} |
| 693 |
% \end{tabbing} |
| 694 |
% In other words such a display block is always embedded in a |
| 695 |
% \struct{text-unit} structure, possibly preceded by a \struct{text}\ldots\struct{/text} block |
| 696 |
% and possibly followed by one, though both such blocks are optional. |
| 697 |
% |
| 698 |
% Thus an \env{itemize} environment that has some introductory text |
| 699 |
% but no text immediately following the list |
| 700 |
% would be tagged as follows: |
| 701 |
% \begin{tabbing} |
| 702 |
% \hspace*{1em}\=\hspace*{1em}\=\hspace*{1em}\=\hspace*{1em}\=\hspace*{1em}\= \kill |
| 703 |
% \> \struct{text-unit}\\ |
| 704 |
% \>\> \struct{text}\\ |
| 705 |
% \>\>\> The intro text for the \env{itemize} environment \ldots\\ |
| 706 |
% \>\> \struct{/text}\\ |
| 707 |
% \>\> \struct{itemize}\\ |
| 708 |
% \>\>\> \struct{LI}\\ |
| 709 |
% \>\>\>\> \struct{Lbl} label \struct{/Lbl}\\ |
| 710 |
% \>\>\>\> \struct{LBody}\\ |
| 711 |
% \>\>\>\>\> The text of the first item involving \struct{text-unit} as necessary \ldots\\ |
| 712 |
% \>\>\>\> \struct{/LBody}\\ |
| 713 |
% \>\>\> \struct{/LI}\\ |
| 714 |
% \>\>\> \struct{LI}\\ |
| 715 |
% \>\>\>\> The second item \ldots{}\\ |
| 716 |
% \>\>\> \struct{/LI}\\ |
| 717 |
% \>\>\> \ldots{} further items \ldots\\ |
| 718 |
% \>\> \struct{/itemize}\\ |
| 719 |
% \> \struct{/text-unit} |
| 720 |
% \end{tabbing} |
| 721 |
% The \struct{itemize} is rollmapped to \struct{L}. |
| 722 |
% |
| 723 |
% For some display blocks, such as centered text, we use a simpler |
| 724 |
% strategy. Such blocks still ensure that they are inside a \struct{text-unit} |
| 725 |
% structure but their body uses simple \struct{text} blocks and not |
| 726 |
% \struct{text-unit}\struct{text} inside, e.g., the input |
| 727 |
% \begin{verbatim} |
| 728 |
% This is a paragraph with some |
| 729 |
% \begin{center} |
| 730 |
% centered lines |
| 731 |
% |
| 732 |
% with a paragraph break between them |
| 733 |
% \end{center} |
| 734 |
% followed by some more text. |
| 735 |
% \end{verbatim} |
| 736 |
% will be tagged as follows: |
| 737 |
% \begin{tabbing} |
| 738 |
% \hspace*{1em}\=\hspace*{1em}\=\hspace*{1em}\=\hspace*{1em}\=\hspace*{1em}\= \kill |
| 739 |
% \> \struct{text-unit}\\ |
| 740 |
% \>\> \struct{text}\\ |
| 741 |
% \>\>\> This is a paragraph with some\\ |
| 742 |
% \>\> \struct{/text}\\ |
| 743 |
% \>\> \struct{text /O /Layout /TextAlign/Center}\\ |
| 744 |
% \>\>\> centered lines\\ |
| 745 |
% \>\> \struct{/text}\\ |
| 746 |
% \>\> \struct{text /O /Layout /TextAlign/Center}\\ |
| 747 |
% \>\>\> with a paragraph break between them\\ |
| 748 |
% \>\> \struct{/text}\\ |
| 749 |
% \>\> \struct{text}\\ |
| 750 |
% \>\>\> followed by some more text.\\ |
| 751 |
% \> \struct{/text-unit} |
| 752 |
% \end{tabbing} |
| 753 |
% |
| 754 |
% The text-unit structures are added by using the tagging sockets |
| 755 |
% \texttt{para/semantic/begin} and \texttt{para/semantic/end} declared in |
| 756 |
% \texttt{lttagging.dtx}. They can be disabled by assigning these sockets the |
| 757 |
% plug \texttt{noop}. |
| 758 |
% |
| 759 |
% \subsection{Tagging recipes} |
| 760 |
% |
| 761 |
% There are a number of different tagging recipes that implement |
| 762 |
% different tagging approaches. They are selected through the |
| 763 |
% \key{tagging-recipe} of the \insttype{blockenv} template. Currently the |
| 764 |
% following values are implemented: |
| 765 |
% \begin{description} |
| 766 |
% \raggedright |
| 767 |
% \item[\keyvalue{standalone}] |
| 768 |
% This recipe does the following: |
| 769 |
% \begin{itemize} |
| 770 |
% \item |
| 771 |
% Ensure that the \insttype{blockenv} is not inside a \struct{text-unit} |
| 772 |
% structure. If necessary, close the open one (and any open |
| 773 |
% \struct{text} structure). |
| 774 |
% |
| 775 |
% \item |
| 776 |
% Text inside the body of the environment start with |
| 777 |
% \struct{text-unit}\struct{text} unless the key |
| 778 |
% \key{tagging-suppress-paras} is set to \keyvalue{true} |
| 779 |
% (which is most likely the wrong thing to do because we then get just |
| 780 |
% \struct{text} as the structure). |
| 781 |
% |
| 782 |
% \item |
| 783 |
% At the end of the environment close \struct{/text} and possibly an |
| 784 |
% inner \struct{/text-unit} if open. |
| 785 |
% |
| 786 |
% \item |
| 787 |
% Finally, ensure that after the environment a new |
| 788 |
% \struct{text-unit} is started, if appropriate, e.g., if text is following. |
| 789 |
% \end{itemize} |
| 790 |
% |
| 791 |
% \item[\keyvalue{basic}] |
| 792 |
% This recipe does the following: |
| 793 |
% \begin{itemize} |
| 794 |
% \item |
| 795 |
% Ensure that the \insttype{blockenv} is inside a \struct{text-unit} |
| 796 |
% structure, if necessary, start one. |
| 797 |
% \item |
| 798 |
% If inside a \struct{text-unit}\struct{text}, then close the \struct{/text} but |
| 799 |
% leave the \struct{text-unit} open. |
| 800 |
% |
| 801 |
% \item |
| 802 |
% Text inside the body of the environment start with |
| 803 |
% \struct{text-unit}\struct{text} if \key{tagging-suppress-paras} is set to \keyvalue{false}, |
| 804 |
% otherwise just with \struct{text}. |
| 805 |
% |
| 806 |
% \item |
| 807 |
% At the end of the environment close \struct{/text} and possibly an |
| 808 |
% inner \struct{/text-unit} if open. |
| 809 |
% |
| 810 |
% \item |
| 811 |
% Then look if the environment is followed by an empty line |
| 812 |
% (\tn{par}). If so, close the outer \struct{/text-unit} and start any |
| 813 |
% following text with \struct{text-unit}\struct{text}. Otherwise, |
| 814 |
% don't and following text restarts with a just a \struct{text} (and no |
| 815 |
% paragraph indentation) |
| 816 |
% \end{itemize} |
| 817 |
% |
| 818 |
% \item[\keyvalue{standard}] |
| 819 |
% This recipe is like the \keyvalue{basic} one as far as handling |
| 820 |
% \struct{text-unit} and \struct{text} is concerned. In addition |
| 821 |
% \begin{itemize} |
| 822 |
% \item |
| 823 |
% it starts an inner tagging structure (i.e., which is therefore a |
| 824 |
% child of the outer \struct{text-unit}). |
| 825 |
% \item |
| 826 |
% By default this structure is a \struct{Div} unless overwritten |
| 827 |
% by the key \key{tag-name}. If that key is used, a suitable |
| 828 |
% rolemap needs to be provided for the name given. |
| 829 |
% \item |
| 830 |
% At the end of the environment that inner structure is closed |
| 831 |
% again so that we are back on the \struct{text-unit} level from the outside. |
| 832 |
% \item |
| 833 |
% Then the lookahead for an empty line is done as described previously. |
| 834 |
% \end{itemize} |
| 835 |
% |
| 836 |
% |
| 837 |
% |
| 838 |
% \item[\keyvalue{list}] |
| 839 |
% This recipe is like the \keyvalue{standard} one except that |
| 840 |
% \begin{itemize} |
| 841 |
% \item |
| 842 |
% the inner structure is a list (\struct{L}). |
| 843 |
% \item |
| 844 |
% Furthermore everything is set up so that we have list items |
| 845 |
% (\struct{LI}) with suitable substructures (\struct{Lbl} for the item |
| 846 |
% labels and \struct{LBody} for the item bodies). |
| 847 |
% \item |
| 848 |
% If the key \key{tag-name} is specified, this is used as the tag |
| 849 |
% name for the whole list instead of \struct{L}. Of course, it |
| 850 |
% should then have a suitable rollmap. |
| 851 |
% \item |
| 852 |
% If the key \key{tag-attr-class} is specified then this is used as the |
| 853 |
% class attribute. Again, this requires a suitable setup on the outside. |
| 854 |
% \item |
| 855 |
% At the end of the environment the \struct{/LBody}, \struct{/LI}, and |
| 856 |
% \struct{/L} (or the tag name used) are closed. |
| 857 |
% \item |
| 858 |
% Then the lookahead for an empty line is done as described previously. |
| 859 |
% \end{itemize} |
| 860 |
% |
| 861 |
% |
| 862 |
% \end{description} |
| 863 |
% |
| 864 |
% \section{Debugging} |
| 865 |
% |
| 866 |
% \begin{function}{\DebugBlocksOn,\DebugBlocksOff, \block_debug_on:, \block_debug_off:} |
| 867 |
% |
| 868 |
% These commands enable/disable debugging messages. |
| 869 |
% |
| 870 |
% \end{function} |
| 871 |
% |
| 872 |
% \section{New and redefined kernel command} |
| 873 |
% |
| 874 |
% \begin{function}{\@doendpe} |
| 875 |
% The original \LaTeXe{} command is augmented to allow for tagging. |
| 876 |
% \end{function} |
| 877 |
% |
| 878 |
% \begin{function}{\legacyverbatimsetup,\legacylistsetupcode} |
| 879 |
% \emph{to be documented} |
| 880 |
% \end{function} |
| 881 |
% |
| 882 |
% \begin{function}{\@setupverbinvisiblespace} |
| 883 |
% A counterpart definition to the kernel command \tn{@setupverbinvisiblespace}, |
| 884 |
% needed as we need to handle real space chars in verbatim. |
| 885 |
% \end{function} |
| 886 |
% |
| 887 |
% \begin{function}{endblockenv,\g_block_nesting_depth_int} |
| 888 |
% \emph{to be documented} |
| 889 |
% \end{function} |
| 890 |
% |
| 891 |
% \begin{function}{\newtheorem,\@thm,\@begintheorem} |
| 892 |
% Redefined to make theorems tagging aware. |
| 893 |
% \end{function} |
| 894 |
% |
| 895 |
% \begin{function}{\item,\@itemlabel} |
| 896 |
% The \tn{item} is redefined. |
| 897 |
% \end{function} |
| 898 |
% |
| 899 |
% \begin{function}{\c@maxblocklevels} |
| 900 |
% A counter to increase or decrease the number of supported |
| 901 |
% level. If increased, one needs to supply additional level instances. |
| 902 |
% \end{function} |
| 903 |
% |
| 904 |
% \begin{function}{\begin} |
| 905 |
% The \tn{begin} is slightly redefined to handle \tn{@doendpe} better. |
| 906 |
% TODO: move to kernel |
| 907 |
% \end{function} |
| 908 |
% |
| 909 |
% \begin{function}{\para_end:} |
| 910 |
% TODO: consider name, document |
| 911 |
% \end{function} |
| 912 |
% |
| 913 |
% \begin{function}{para/begin} |
| 914 |
% The para/begin hook is enhanced to support list ends |
| 915 |
% \end{function} |
| 916 |
% |
| 917 |
% \end{documentation} |
| 918 |
% |
| 919 |
% \StopEventually{\setlength\IndexMin{200pt} \PrintIndex } |
| 920 |
% |
| 921 |
% |
| 922 |
% |
| 923 |
% \begin{implementation} |
| 924 |
% |
| 925 |
% \section{The Implementation} |
| 926 |
% |
| 927 |
% |
| 928 |
% \begin{macrocode} |
| 929 |
%<*package> |
| 930 |
%<@@=block> |
| 931 |
% \end{macrocode} |
| 932 |
% |
| 933 |
% |
| 934 |
% \begin{macrocode} |
| 935 |
\ProvidesPackage {latex-lab-testphase-block} |
| 936 |
[\ltlabblockdate\space v\ltlabblockversion\space |
| 937 |
blockenv implementation] |
| 938 |
% \end{macrocode} |
| 939 |
% |
| 940 |
% General kernel changes, also loaded by the sec and toc code. |
| 941 |
% \begin{macrocode} |
| 942 |
\RequirePackage{latex-lab-kernel-changes} |
| 943 |
% \end{macrocode} |
| 944 |
% |
| 945 |
% For testing we temporarily load it here (it has to come before |
| 946 |
% the definition of \cs{DebugBlocksOff} below: |
| 947 |
% \begin{macrocode} |
| 948 |
\RequirePackage{latex-lab-testphase-context} |
| 949 |
% \end{macrocode} |
| 950 |
% |
| 951 |
% \begin{macrocode} |
| 952 |
\ExplSyntaxOn |
| 953 |
% \end{macrocode} |
| 954 |
% |
| 955 |
% |
| 956 |
% \subsection{Handling \tn{par} after the end of the list} |
| 957 |
% |
| 958 |
% An empty line (or a \tn{par}) after a list has semantic meaning as |
| 959 |
% it defines whether then following text is logically within the same |
| 960 |
% paragraph as the list (no empty line) or whether it starts a new |
| 961 |
% paragraph and the paragraph containing the list ends at the end of |
| 962 |
% the list (empty line after the list). |
| 963 |
% This is handled by \LaTeX{} using a legacy flag called |
| 964 |
% \texttt{@endpe} and set of commands inside the |
| 965 |
% generic \tn{end} (calling \tn{@doendpe}) and as part of the list |
| 966 |
% environments identifying themselves as \enquote{paragraph ending |
| 967 |
% environments} (by setting this flag). |
| 968 |
% |
| 969 |
% For the reimplementation of the list environments including support |
| 970 |
% of tagging we need to augment that mechanism slightly and add some |
| 971 |
% kernel hook(s) to add the tagging code if needed. |
| 972 |
% |
| 973 |
% |
| 974 |
% |
| 975 |
% |
| 976 |
% \begin{macro}{\@doendpe} |
| 977 |
% The original \LaTeXe{} command is augmented to allow for tagging. |
| 978 |
% TODO: use sockets for this and move to the kernel eventually. |
| 979 |
% \begin{macrocode} |
| 980 |
\def\@doendpe{\@endpetrue |
| 981 |
\def\par |
| 982 |
{ |
| 983 |
% \end{macrocode} |
| 984 |
% If we are processing a \verb=$$= math display and we encounter a real |
| 985 |
% \cs{par} after it, we need to add a \cs{parskip} when tagging is |
| 986 |
% done, because the one |
| 987 |
% added by \TeX{} is always canceled by the processing in |
| 988 |
% \cs{__math_tag_dollardollar_display_end:} in that case. This is |
| 989 |
% signaled by the global legacy switch \texttt{@domathendpe} which is set |
| 990 |
% to true in that case. Once the skip is applied we set it to |
| 991 |
% false. If there is no \cs{par} at all, it will be reset in |
| 992 |
% \cs{everypar} when the next paragraph starts. |
| 993 |
% \changes{v0.8x}{2024/12/01}{Handle \cs{parskip} after \texttt{\$\$} |
| 994 |
% display (tagging/762)} |
| 995 |
% \begin{macrocode} |
| 996 |
\if@domathendpe |
| 997 |
\skip_vertical:n { \tex_parskip:D } |
| 998 |
\@domathendpefalse |
| 999 |
\fi |
| 1000 |
\@restorepar |
| 1001 |
\clubpenalty\@clubpenalty |
| 1002 |
% \end{macrocode} |
| 1003 |
% At this point we add the tagging code that closes an open |
| 1004 |
% \struct{text-unit}, \struct{text} tag combination, |
| 1005 |
% if necessary: |
| 1006 |
% \begin{macrocode} |
| 1007 |
\tag_socket_use:n {@doendpe} |
| 1008 |
% \end{macrocode} |
| 1009 |
% |
| 1010 |
% The standard \tn{par} command (\cs{par_end:}) acts on |
| 1011 |
% \texttt{@endpe} and attempts to close a still open \struct{text-unit}s |
| 1012 |
% and this would be wrong if it was already closed above. So we |
| 1013 |
% have to reset the switch to false first. |
| 1014 |
% \begin{macrocode} |
| 1015 |
\@endpefalse |
| 1016 |
\everypar{} |
| 1017 |
\par |
| 1018 |
} |
| 1019 |
\everypar{{\setbox\z@\lastbox} |
| 1020 |
\everypar{} |
| 1021 |
\@endpefalse |
| 1022 |
% \end{macrocode} |
| 1023 |
% Not sure what is faster: testing for the status of the switch or |
| 1024 |
% setting it unconditionally to false (globally), probably roughly the same, |
| 1025 |
% so we set it always: |
| 1026 |
% \begin{macrocode} |
| 1027 |
% \if@domathendpe |
| 1028 |
\@domathendpefalse |
| 1029 |
% \fi |
| 1030 |
} |
| 1031 |
} |
| 1032 |
% \end{macrocode} |
| 1033 |
% \end{macro} |
| 1034 |
% |
| 1035 |
% \begin{socketdecl}{tagsupport/@doendpe} |
| 1036 |
% The socket used in the \cs{@doendpe} |
| 1037 |
% TODO: if this goes into the kernel, the name should probably be different. |
| 1038 |
% \begin{macrocode} |
| 1039 |
\socket_if_exist:nF{ tagsupport/@doendpe } |
| 1040 |
{ |
| 1041 |
\NewTaggingSocket {@doendpe}{0} |
| 1042 |
} |
| 1043 |
% \end{macrocode} |
| 1044 |
% \end{socketdecl} |
| 1045 |
% |
| 1046 |
% \begin{plugdecl}{default} |
| 1047 |
% If a display block ends and is followed by a blank line we have to end the |
| 1048 |
% enclosing paragraph tagging structure. |
| 1049 |
% \begin{macrocode} |
| 1050 |
\NewTaggingSocketPlug {@doendpe}{default} |
| 1051 |
{ |
| 1052 |
\bool_if:NT \l__tag_para_bool |
| 1053 |
{ |
| 1054 |
% \end{macrocode} |
| 1055 |
% Given that restoring \tn{par} through the legacy \LaTeXe{} method |
| 1056 |
% can take a few iterations (for example, in case of nested lists, |
| 1057 |
% e.g., \verb=...\end{itemize} \item ...\par= it can happen that |
| 1058 |
% the socket code is called while |
| 1059 |
% \texttt{@endpe} is already handled and then we should not attempt |
| 1060 |
% to close a \struct{text-unit} structure). So we need to check for this. |
| 1061 |
% \begin{macrocode} |
| 1062 |
\legacy_if:nT { @endpe } |
| 1063 |
{ |
| 1064 |
% \end{macrocode} |
| 1065 |
% If the display block currently ending was \enquote{flattened} |
| 1066 |
% (i.e., uses simplified paragraphs that are not tagged by a |
| 1067 |
% combination of \struct{text-unit} followed by \struct{text}, but simply |
| 1068 |
% with a \struct{text}), |
| 1069 |
% then we don't have to do anything, because the \struct{text} is already closed. |
| 1070 |
% \begin{macrocode} |
| 1071 |
\@@_debug_typeout:n |
| 1072 |
{ flattened= \bool_if:NTF |
| 1073 |
\l__tag_para_flattened_bool |
| 1074 |
{true}{false} |
| 1075 |
\on@line } |
| 1076 |
\bool_if:NF \l__tag_para_flattened_bool |
| 1077 |
{ |
| 1078 |
% \end{macrocode} |
| 1079 |
% \changes{v0.9k}{2025/07/21}{Use tagging socket for text-unit structure} |
| 1080 |
% \begin{macrocode} |
| 1081 |
\UseTaggingSocket{para/semantic/end} |
| 1082 |
{ |
| 1083 |
\@@_debug_typeout:n{Structure-end~ |
| 1084 |
\l__tag_para_main_tag_tl\space |
| 1085 |
after~ displayblock \on@line } |
| 1086 |
} |
| 1087 |
} |
| 1088 |
} |
| 1089 |
} |
| 1090 |
} |
| 1091 |
\AssignTaggingSocketPlug{@doendpe}{default} |
| 1092 |
% \end{macrocode} |
| 1093 |
% \end{plugdecl} |
| 1094 |
% |
| 1095 |
% |
| 1096 |
% |
| 1097 |
% \begin{macro}[int]{\if@domathendpe,\@domathendpefalse,\@domathendpetrue} |
| 1098 |
% Signal that special paragraph handling after a math display is required. |
| 1099 |
% \changes{v0.8x}{2024/12/01}{Handle \cs{parskip} after \texttt{\$\$} |
| 1100 |
% display (tagging/762)} |
| 1101 |
% \begin{macrocode} |
| 1102 |
\newif\if@domathendpe |
| 1103 |
\def\@domathendpefalse{\global\let\if@domathendpe\iffalse} |
| 1104 |
\def\@domathendpetrue {\global\let\if@domathendpe\iftrue} |
| 1105 |
% \end{macrocode} |
| 1106 |
% \end{macro} |
| 1107 |
% |
| 1108 |
% |
| 1109 |
% |
| 1110 |
% |
| 1111 |
% |
| 1112 |
% \subsection{Template types and template interfaces} |
| 1113 |
% |
| 1114 |
% |
| 1115 |
% \begin{templatetype}{blockenv, block, para, list, item} |
| 1116 |
% All template types expect a single |
| 1117 |
% key--value argument used to tweak template parameters specific to a |
| 1118 |
% given use in the document. This section is devoted to template |
| 1119 |
% interfaces, and the template code is covered later. |
| 1120 |
% \begin{macrocode} |
| 1121 |
\NewTemplateType{blockenv}{1} |
| 1122 |
\NewTemplateType{block}{1} |
| 1123 |
\NewTemplateType{para}{1} |
| 1124 |
\NewTemplateType{list}{1} |
| 1125 |
\NewTemplateType{item}{1} |
| 1126 |
% \end{macrocode} |
| 1127 |
% \end{templatetype} |
| 1128 |
% |
| 1129 |
% |
| 1130 |
% |
| 1131 |
% \begin{template}{blockenv display} |
| 1132 |
% |
| 1133 |
% \begin{macrocode} |
| 1134 |
\DeclareTemplateInterface{blockenv}{display}{1} |
| 1135 |
{ |
| 1136 |
name : tokenlist , |
| 1137 |
% \end{macrocode} |
| 1138 |
% If not explicitly set then \key{tag-name} and |
| 1139 |
% \key{tag-attr-class} are set by the |
| 1140 |
% \key{tagging-recipe}. However, we have to default both to |
| 1141 |
% \meta{empty} so that nested blocks do not inherit from the outer |
| 1142 |
% level. |
| 1143 |
% \changes{v0.9g}{2025/06/30}{ (tagging/925)} |
| 1144 |
% \begin{macrocode} |
| 1145 |
tag-name : tokenlist = , |
| 1146 |
tag-attr-class : tokenlist = , |
| 1147 |
tagging-recipe : tokenlist = standard, |
| 1148 |
increment-level : boolean = true , |
| 1149 |
setup-code : tokenlist = , |
| 1150 |
block-instance : tokenlist = displayblock , |
| 1151 |
% \end{macrocode} |
| 1152 |
% Paragraph instance is normally inherited so no default. |
| 1153 |
% \begin{macrocode} |
| 1154 |
para-instance : tokenlist , |
| 1155 |
inner-level-counter : tokenlist , |
| 1156 |
max-inner-levels : tokenlist = 4, |
| 1157 |
inner-instance-type : tokenlist = list , |
| 1158 |
inner-instance : tokenlist = , |
| 1159 |
tagging-suppress-paras : boolean = false , |
| 1160 |
final-code : tokenlist = \ignorespaces , |
| 1161 |
} |
| 1162 |
% \end{macrocode} |
| 1163 |
% \end{template} |
| 1164 |
% |
| 1165 |
% |
| 1166 |
% \begin{template}{block display} |
| 1167 |
% |
| 1168 |
% \changes{v0.8s}{2024/10/03}{Offer item-vspace key also on block templates} |
| 1169 |
% \begin{macrocode} |
| 1170 |
\DeclareTemplateInterface{block}{display}{1} |
| 1171 |
{ |
| 1172 |
begin-vspace : skip = \topsep , |
| 1173 |
begin-extra-vspace : skip = \partopsep , |
| 1174 |
para-vspace : skip = \parsep , |
| 1175 |
end-vspace : skip = \KeyValue{begin-vspace} , % conflict with name below |
| 1176 |
end-extra-vspace : skip = \KeyValue{begin-extra-vspace} , |
| 1177 |
item-vspace : skip = \itemsep , |
| 1178 |
begin-penalty : integer = \UseName{@beginparpenalty} , |
| 1179 |
end-penalty : integer = \UseName{@endparpenalty} , |
| 1180 |
left-margin : length = \leftmargin , |
| 1181 |
right-margin : length = \rightmargin , |
| 1182 |
para-indent : length = 0pt , |
| 1183 |
% maybe add? (or more general for fonts and color) |
| 1184 |
% font : tokenlist |
| 1185 |
} |
| 1186 |
% \end{macrocode} |
| 1187 |
% \end{template} |
| 1188 |
% |
| 1189 |
% |
| 1190 |
% \begin{template}{para std} |
| 1191 |
% |
| 1192 |
% \begin{macrocode} |
| 1193 |
\DeclareTemplateInterface{para}{std}{1} |
| 1194 |
{ |
| 1195 |
para-attr-class : tokenlist = justify , |
| 1196 |
para-indent : length = \parindent , |
| 1197 |
begin-hspace : skip = 0pt , |
| 1198 |
left-hspace : skip = 0pt , |
| 1199 |
right-hspace : skip = 0pt , |
| 1200 |
end-hspace : skip = \@flushglue , |
| 1201 |
fixed-word-spaces : boolean = false , |
| 1202 |
final-hyphen-demerits : integer = 5000 , |
| 1203 |
newline-cmd : tokenlist = \@normalcr , |
| 1204 |
} |
| 1205 |
% \end{macrocode} |
| 1206 |
% \end{template} |
| 1207 |
% |
| 1208 |
% |
| 1209 |
% \begin{template}{list std} |
| 1210 |
% |
| 1211 |
% \begin{macrocode} |
| 1212 |
\DeclareTemplateInterface{list}{std}{1} |
| 1213 |
{ |
| 1214 |
counter : tokenlist = , |
| 1215 |
item-label : tokenlist = , |
| 1216 |
start : integer = 1 , |
| 1217 |
resume : boolean = false , |
| 1218 |
item-instance : instance{item} = basic , |
| 1219 |
item-vspace : skip = \itemsep , |
| 1220 |
item-penalty : integer = \UseName{@itempenalty} , |
| 1221 |
item-indent : length = \itemindent , |
| 1222 |
label-width : length = \labelwidth , |
| 1223 |
label-sep : length = \labelsep , |
| 1224 |
legacy-support : boolean = false , |
| 1225 |
} |
| 1226 |
% \end{macrocode} |
| 1227 |
% \end{template} |
| 1228 |
% |
| 1229 |
% |
| 1230 |
% \begin{template}{item std} |
| 1231 |
% |
| 1232 |
% \begin{macrocode} |
| 1233 |
\DeclareTemplateInterface{item}{std}{1} |
| 1234 |
{ |
| 1235 |
counter-label : function{1} = \arabic{#1} , |
| 1236 |
counter-ref : function{1} = \KeyValue{counter-label} , |
| 1237 |
label-ref : function{1} = #1 , |
| 1238 |
label-autoref : function{1} = item~#1 , |
| 1239 |
label-format : function{1} = #1 , |
| 1240 |
label-strut : boolean = false , |
| 1241 |
label-align : choice {left,center,right,parleft} = right , |
| 1242 |
label-boxed : boolean = true , |
| 1243 |
next-line : boolean = false , |
| 1244 |
text-font : tokenlist , |
| 1245 |
compatibility : boolean = true , |
| 1246 |
} |
| 1247 |
% \end{macrocode} |
| 1248 |
% \end{template} |
| 1249 |
% |
| 1250 |
% |
| 1251 |
% |
| 1252 |
% |
| 1253 |
% |
| 1254 |
% |
| 1255 |
% \subsection{Useful helper commands} |
| 1256 |
% |
| 1257 |
% This section collects \pkg{expl3} commands that will be useful. |
| 1258 |
% |
| 1259 |
% \begin{macro}{\@@_skip_set_to_last:N,\@@_skip_remove_last:} |
| 1260 |
% Set a skip register to the value of an immediately preceding |
| 1261 |
% skip or zero if there was none. |
| 1262 |
% \begin{macrocode} |
| 1263 |
\cs_new_protected:Npn \@@_skip_set_to_last:N #1 { |
| 1264 |
\skip_set:Nn #1 { \tex_lastskip:D } |
| 1265 |
} |
| 1266 |
% \end{macrocode} |
| 1267 |
% Remove a skip previous skip if it is directly in front (not |
| 1268 |
% allowed in unrestricted vertical mode). |
| 1269 |
% \begin{macrocode} |
| 1270 |
\cs_new_eq:NN \@@_skip_remove_last: \tex_unskip:D |
| 1271 |
% \end{macrocode} |
| 1272 |
% \end{macro} |
| 1273 |
% |
| 1274 |
% \begin{macrocode} |
| 1275 |
\cs_generate_variant:Nn \tl_if_novalue:nTF { o } |
| 1276 |
% \end{macrocode} |
| 1277 |
% |
| 1278 |
% |
| 1279 |
% \subsubsection{Debugging} |
| 1280 |
% |
| 1281 |
% |
| 1282 |
% \begin{variable}{\g_@@_debug_bool} |
| 1283 |
% |
| 1284 |
% \begin{macrocode} |
| 1285 |
\bool_new:N \g_@@_debug_bool |
| 1286 |
% \end{macrocode} |
| 1287 |
% \end{variable} |
| 1288 |
% |
| 1289 |
% |
| 1290 |
% \begin{macro}{\@@_debug:n,\@@_debug_typeout:n} |
| 1291 |
% |
| 1292 |
% \begin{macrocode} |
| 1293 |
\cs_new_eq:NN \@@_debug:n \use_none:n |
| 1294 |
\cs_new_eq:NN \@@_debug_typeout:n \use_none:n |
| 1295 |
% \end{macrocode} |
| 1296 |
% \end{macro} |
| 1297 |
% |
| 1298 |
% \begin{macro}{\block_debug_on:,\block_debug_off:, |
| 1299 |
% \@@_debug_gset:} |
| 1300 |
% \begin{macrocode} |
| 1301 |
\cs_new_protected:Npn \block_debug_on: |
| 1302 |
{ |
| 1303 |
\bool_gset_true:N \g_@@_debug_bool |
| 1304 |
\@@_debug_gset: |
| 1305 |
} |
| 1306 |
% \end{macrocode} |
| 1307 |
% |
| 1308 |
% \begin{macrocode} |
| 1309 |
\cs_new_protected:Npn \block_debug_off: |
| 1310 |
{ |
| 1311 |
\bool_gset_false:N \g_@@_debug_bool |
| 1312 |
\@@_debug_gset: |
| 1313 |
} |
| 1314 |
% \end{macrocode} |
| 1315 |
% |
| 1316 |
% \begin{macrocode} |
| 1317 |
\cs_new_protected:Npn \@@_debug_gset: |
| 1318 |
{ |
| 1319 |
\cs_gset_protected:Npx \@@_debug:n ##1 |
| 1320 |
{ \bool_if:NT \g_@@_debug_bool {##1} } |
| 1321 |
\cs_gset_protected:Npx \@@_debug_typeout:n ##1 |
| 1322 |
{ \bool_if:NT \g_@@_debug_bool { \typeout{[Blocks]~ ==>~ ##1} } } |
| 1323 |
} |
| 1324 |
% \end{macrocode} |
| 1325 |
% \end{macro} |
| 1326 |
% |
| 1327 |
% |
| 1328 |
% \begin{macro}{\DebugBlocksOn,\DebugBlocksOff} |
| 1329 |
% If we are debugging blocks we also want to know about template |
| 1330 |
% instances, so we turn the debugging for templates as well (for now). |
| 1331 |
% \begin{macrocode} |
| 1332 |
\cs_new_protected:Npn \DebugBlocksOn { \block_debug_on: \template_debug_on: } |
| 1333 |
\cs_new_protected:Npn \DebugBlocksOff { \block_debug_off: \template_debug_off: } |
| 1334 |
% \end{macrocode} |
| 1335 |
% |
| 1336 |
% \begin{macrocode} |
| 1337 |
\DebugBlocksOff |
| 1338 |
% \end{macrocode} |
| 1339 |
% \end{macro} |
| 1340 |
% |
| 1341 |
% |
| 1342 |
% |
| 1343 |
% |
| 1344 |
% |
| 1345 |
% \subsection{Implementation of templates} |
| 1346 |
% |
| 1347 |
% |
| 1348 |
% \subsubsection{Implementation of blockenv templates \ldots} |
| 1349 |
% |
| 1350 |
% |
| 1351 |
% |
| 1352 |
% \begin{macro}{\g_block_nesting_depth_int} |
| 1353 |
% \LaTeXe{} already has a counter to record the nesting depth of |
| 1354 |
% blocks, but we want our own name because it isn't really tied to |
| 1355 |
% \enquote{lists} any more. However, \tn{@listdepth} is really part |
| 1356 |
% of the legacy interface (for example \env{minipage} alters it to |
| 1357 |
% point to a different counter) so that we are stuck with using at |
| 1358 |
% least indirectly for now and the following line makes this look |
| 1359 |
% like an L3 integer variable but internally expands to \tn{@listdepth}: |
| 1360 |
% \begin{macrocode} |
| 1361 |
\cs_new:Npn \g_block_nesting_depth_int { \@listdepth } % a fake int |
| 1362 |
% for now |
| 1363 |
% \end{macrocode} |
| 1364 |
% \end{macro} |
| 1365 |
% |
| 1366 |
% |
| 1367 |
% \begin{template}{blockenv display} |
| 1368 |
% |
| 1369 |
% \begin{macrocode} |
| 1370 |
\DeclareTemplateCode{blockenv}{display}{1} |
| 1371 |
{ |
| 1372 |
name = \l_@@_env_name_tl , |
| 1373 |
tag-name = \l_@@_tag_name_tl , |
| 1374 |
tag-attr-class = \l_@@_tag_class_tl , |
| 1375 |
tagging-recipe = \l_@@_tagging_recipe_tl , |
| 1376 |
increment-level = \l_@@_level_incr_bool , |
| 1377 |
setup-code = \l_@@_setup_code_tl , |
| 1378 |
block-instance = \l_@@_block_instance_tl , |
| 1379 |
para-instance = \l_@@_para_instance_tl , |
| 1380 |
tagging-suppress-paras = \l__tag_para_flattened_bool , |
| 1381 |
inner-level-counter = \l_@@_inner_level_counter_tl , |
| 1382 |
max-inner-levels = \l_@@_max_inner_levels_tl , |
| 1383 |
inner-instance-type = \l_@@_inner_instance_type_tl , |
| 1384 |
inner-instance = \l_@@_inner_instance_tl , |
| 1385 |
final-code = \l_@@_final_code_tl , |
| 1386 |
} |
| 1387 |
{ |
| 1388 |
\@@_debug_typeout:n{\l_@@_env_name_tl -env-start} |
| 1389 |
% |
| 1390 |
% \end{macrocode} |
| 1391 |
% We first evaluate the key list passed from the document (if |
| 1392 |
% any). All known keys are used all, the remainder is stored in |
| 1393 |
% \cs{UnusedTemplateKeys} to be passed to any inner instances below. |
| 1394 |
% \begin{macrocode} |
| 1395 |
\SetKnownTemplateKeys{blockenv}{display}{#1} |
| 1396 |
% \end{macrocode} |
| 1397 |
% We need to know later if we have nested blockenvs inside |
| 1398 |
% a flattened environment. Whenever we start a new blockenv we |
| 1399 |
% increment \cs{l__tag_block_flattened_level_int} if it is already |
| 1400 |
% different from zero. If it is zero we increment it if flattening |
| 1401 |
% is requested. |
| 1402 |
% Thus a value of \texttt{0} means no flattening requested so far |
| 1403 |
% and \texttt{1} means this is the first blockenv requesting |
| 1404 |
% flattening. In either case we have to make sure that the blockenv |
| 1405 |
% is surrounded by a \struct{text-unit} tag, while for any value above |
| 1406 |
% \texttt{1} we have to omit the \struct{text-unit}. |
| 1407 |
% \begin{macrocode} |
| 1408 |
\int_compare:nNnTF \l__tag_block_flattened_level_int > 0 |
| 1409 |
{ |
| 1410 |
\int_incr:N \l__tag_block_flattened_level_int |
| 1411 |
} |
| 1412 |
{ |
| 1413 |
\bool_if:NT \l__tag_para_flattened_bool |
| 1414 |
{ |
| 1415 |
\int_incr:N \l__tag_block_flattened_level_int |
| 1416 |
} |
| 1417 |
} |
| 1418 |
% \end{macrocode} |
| 1419 |
% |
| 1420 |
% \begin{macrocode} |
| 1421 |
\tl_if_empty:NF \l_@@_inner_level_counter_tl |
| 1422 |
{ |
| 1423 |
\int_compare:nNnTF \l_@@_inner_level_counter_tl > |
| 1424 |
{ \l_@@_max_inner_levels_tl - 1 } |
| 1425 |
{ \@toodeep } |
| 1426 |
{ \int_incr:N \l_@@_inner_level_counter_tl } % not clean "o"? |
| 1427 |
} |
| 1428 |
% \end{macrocode} |
| 1429 |
% Legacy defaults are only roped in if the list level changes. For |
| 1430 |
% display blocks that remain on the same level the current values |
| 1431 |
% are kept. |
| 1432 |
% \begin{macrocode} |
| 1433 |
\bool_if:NT \l_@@_level_incr_bool |
| 1434 |
{ |
| 1435 |
\int_compare:nNnTF \g_block_nesting_depth_int > |
| 1436 |
{ \c@maxblocklevels - 1 } |
| 1437 |
{ \@toodeep } |
| 1438 |
{ |
| 1439 |
\int_gincr:N \g_block_nesting_depth_int |
| 1440 |
% \end{macrocode} |
| 1441 |
% If there are no legacy defaults for that level then the next line |
| 1442 |
% does nothing, i.e., the current values (from the last level |
| 1443 |
% become the defaults for the next. |
| 1444 |
% \begin{macrocode} |
| 1445 |
\use:c { @list \int_to_roman:n |
| 1446 |
{ \g_block_nesting_depth_int } } |
| 1447 |
} |
| 1448 |
} |
| 1449 |
% \end{macrocode} |
| 1450 |
% If we are doing tagging we load one of the available recipes for |
| 1451 |
% tagging, which alters various kernel hooks to add appropriate |
| 1452 |
% tagging structures. |
| 1453 |
% \changes{v0.9g}{2025-07-01}{use tagging socket for recipe} |
| 1454 |
% \begin{macrocode} |
| 1455 |
\UseTaggingSocket{block/recipe}{\l_@@_tagging_recipe_tl} |
| 1456 |
% \end{macrocode} |
| 1457 |
% The default for \env{list} environments is that they have an |
| 1458 |
% empty label and are not numbered (something that is then |
| 1459 |
% overwritting by the setup of a specific list). We ensure |
| 1460 |
% this here even for non-lists, because we need a defined state |
| 1461 |
% that then can be overwritting by the legacy setup code for |
| 1462 |
% the \env{list} environment in \cs{l_@@_setup_code_tl}. |
| 1463 |
% This is needed in case lists are nested as they otherwise would |
| 1464 |
% inherit outer values (and suddenly an \env{itemize} would start |
| 1465 |
% incrementing an outer \env{enumerate} counter, etc. |
| 1466 |
% \changes{v0.8v}{2024/10/11}{Set the defaults for \tn{@itemlabel}, |
| 1467 |
% \tn{@listctr} and \texttt{@nmbrlist} early in the block code |
| 1468 |
% before the setup code gets executed (tagging/730)} |
| 1469 |
% \begin{macrocode} |
| 1470 |
\tl_clear:N \@itemlabel |
| 1471 |
\tl_clear:N \@listctr |
| 1472 |
\legacy_if_set_false:n { @nmbrlist } |
| 1473 |
% \end{macrocode} |
| 1474 |
% Then run the setup code if any is given in the instance. |
| 1475 |
% \begin{macrocode} |
| 1476 |
\l_@@_setup_code_tl |
| 1477 |
% \end{macrocode} |
| 1478 |
% Next call a block instance at the appropriate level passing it |
| 1479 |
% any remaining key/value from the optional document-level argument |
| 1480 |
% (i.e., those now stored in \cs{UnusedTemplateKeys}). |
| 1481 |
% |
| 1482 |
% |
| 1483 |
% \changes{v0.9j}{2025/07/11}{Expand arguments before passing them to |
| 1484 |
% \cs{Useinstance} to get better error messages} |
| 1485 |
% \begin{macrocode} |
| 1486 |
\exp_args:Nee \UseInstance{block} |
| 1487 |
{ \l_@@_block_instance_tl - \int_use:N |
| 1488 |
\g_block_nesting_depth_int } |
| 1489 |
\UnusedTemplateKeys |
| 1490 |
% \end{macrocode} |
| 1491 |
% After this instance has been processed, any remaining unused keys |
| 1492 |
% are stored in \cs{UnusedTemplateKeys} and we can make use of this |
| 1493 |
% data later as long as we do not call another instance that also |
| 1494 |
% does unused key processing and overwrites it. But this is what |
| 1495 |
% happens below, so we better save its current value for now. |
| 1496 |
% \begin{macrocode} |
| 1497 |
\tl_set_eq:NN \l_@@_unused_blockenv_keys_tl \UnusedTemplateKeys |
| 1498 |
% \end{macrocode} |
| 1499 |
% After the block instance call the para and then inner (list) |
| 1500 |
% instance if either or both are |
| 1501 |
% specified (which may not be the case). |
| 1502 |
% \begin{macrocode} |
| 1503 |
\tl_if_empty:NF \l_@@_para_instance_tl |
| 1504 |
{ |
| 1505 |
% \end{macrocode} |
| 1506 |
% For now we don't offer to alter instance parameters here so we |
| 1507 |
% pass an empty argument. |
| 1508 |
% \changes{v0.9j}{2025/07/11}{Expand arguments before passing them to |
| 1509 |
% \cs{Useinstance} to get better error messages} |
| 1510 |
% \begin{macrocode} |
| 1511 |
\exp_args:Ne \UseInstance{para}{ \l_@@_para_instance_tl } {} |
| 1512 |
} |
| 1513 |
% \end{macrocode} |
| 1514 |
% The inner instance may have its own levels or none depending |
| 1515 |
% on which the instance name differs. Again we pass it the optional |
| 1516 |
% key/value list. |
| 1517 |
% \begin{macrocode} |
| 1518 |
\tl_if_empty:NF \l_@@_inner_instance_tl |
| 1519 |
{ |
| 1520 |
% \end{macrocode} |
| 1521 |
% \changes{v0.9j}{2025/07/11}{Expand arguments before passing them to |
| 1522 |
% \cs{Useinstance} to get better error messages} |
| 1523 |
% \begin{macrocode} |
| 1524 |
\exp_args:Nee |
| 1525 |
\UseInstance{ \l_@@_inner_instance_type_tl } |
| 1526 |
{ \l_@@_inner_instance_tl |
| 1527 |
\tl_if_empty:NF \l_@@_inner_level_counter_tl |
| 1528 |
% not clean use "o"? |
| 1529 |
{ - \int_use:N \l_@@_inner_level_counter_tl } |
| 1530 |
} |
| 1531 |
\l_@@_unused_blockenv_keys_tl |
| 1532 |
% \end{macrocode} |
| 1533 |
% Again the instance may has processed a few keys from the sofar |
| 1534 |
% unused keys, so we update \cs{l_@@_unused_blockenv_keys_tl} to |
| 1535 |
% match the new reality. |
| 1536 |
% \begin{macrocode} |
| 1537 |
\tl_set_eq:NN \l_@@_unused_blockenv_keys_tl \UnusedTemplateKeys |
| 1538 |
} |
| 1539 |
% \end{macrocode} |
| 1540 |
% At this point, the \cs{l_@@_unused_blockenv_keys_tl} token list |
| 1541 |
% should either be empty or it should contain only keys that are suitable for |
| 1542 |
% the item template, but right now there is no code to test that |
| 1543 |
% can test |
| 1544 |
% the latter; it would help probably if we have an interface for |
| 1545 |
% this. |
| 1546 |
% |
| 1547 |
% For now we handle that when the first item is encountered, but |
| 1548 |
% that isn't realy clean.\fmi{fix} |
| 1549 |
% \begin{macrocode} |
| 1550 |
\tl_if_empty:NF \l_@@_unused_blockenv_keys_tl |
| 1551 |
{ |
| 1552 |
% check if only item template keys remain |
| 1553 |
} |
| 1554 |
% \end{macrocode} |
| 1555 |
% We finish off with \cs{l_@@_final_code_tl} which defaults to |
| 1556 |
% \tn{ignorespaces} so that spaces between \verb=\begin{...}= and |
| 1557 |
% the start of the text are ignored. |
| 1558 |
% \begin{macrocode} |
| 1559 |
\l_@@_final_code_tl |
| 1560 |
} |
| 1561 |
% \end{macrocode} |
| 1562 |
% \end{template} |
| 1563 |
% |
| 1564 |
% |
| 1565 |
% \begin{macro}{\l_@@_unused_blockenv_keys_tl} |
| 1566 |
% |
| 1567 |
% \begin{macrocode} |
| 1568 |
\tl_new:N \l_@@_unused_blockenv_keys_tl |
| 1569 |
% \end{macrocode} |
| 1570 |
% \end{macro} |
| 1571 |
% |
| 1572 |
% |
| 1573 |
% \begin{macro}{\l__tag_block_flattened_level_int} |
| 1574 |
% Count the levels of nested blockenvs starting with the first that |
| 1575 |
% is \enquote{flattened}. The counter is defined in lttagging.dtx, |
| 1576 |
% but until the next release 11/24 we set it up here too |
| 1577 |
% \begin{macrocode} |
| 1578 |
\int_if_exist:NF \l__tag_block_flattened_level_int |
| 1579 |
{ |
| 1580 |
\int_new:N \l__tag_block_flattened_level_int |
| 1581 |
} |
| 1582 |
% \end{macrocode} |
| 1583 |
% \end{macro} |
| 1584 |
% |
| 1585 |
% \begin{macro}{\c@maxblocklevels} |
| 1586 |
% A counter to increase or decrease the number of supported |
| 1587 |
% level. If increased, one needs to supply additional level instances. |
| 1588 |
% \begin{macrocode} |
| 1589 |
\newcounter{maxblocklevels} |
| 1590 |
\setcounter{maxblocklevels}{6} |
| 1591 |
% \end{macrocode} |
| 1592 |
% \end{macro} |
| 1593 |
% |
| 1594 |
% \begin{macro}{\endblockenv} |
| 1595 |
% The code executed when a blockenv ends is 99\% the same for all |
| 1596 |
% blockenvs (at least up to now). Small differences exist, though. They |
| 1597 |
% are accounted for first in the conditionals. |
| 1598 |
% |
| 1599 |
% We make this a public command so that new block environments can |
| 1600 |
% be set up without the need to resort to L3 layer |
| 1601 |
% programming.\fmi{name is bad} |
| 1602 |
% \begin{macrocode} |
| 1603 |
\cs_new:Npn \endblockenv { |
| 1604 |
\@@_debug_typeout:n{blockenv~ common~ ending \on@line} |
| 1605 |
% \end{macrocode} |
| 1606 |
% If this block was incrementing the level we have to decrement it |
| 1607 |
% now again: |
| 1608 |
% \begin{macrocode} |
| 1609 |
\bool_if:NT \l_@@_level_incr_bool |
| 1610 |
{ \int_gdecr:N \g_block_nesting_depth_int } |
| 1611 |
% \end{macrocode} |
| 1612 |
% If this block was a list and there are still \tn{item} labels to |
| 1613 |
% be placed we move to horizontal mode to get them typeset. |
| 1614 |
% \begin{macrocode} |
| 1615 |
\legacy_if:nT { @inlabel } |
| 1616 |
{ |
| 1617 |
\mode_leave_vertical: |
| 1618 |
\legacy_if_gset_false:n { @inlabel } |
| 1619 |
} |
| 1620 |
% \end{macrocode} |
| 1621 |
% If we are ending a list environment and we have not seen any |
| 1622 |
% \tn{item}, i.e., \texttt{@newlist} is still true, we raise an |
| 1623 |
% error. In basic a ``displayblock'' scenario \texttt{@newlist} will |
| 1624 |
% always be false, but if such an environment appears inside an outer |
| 1625 |
% list then \tn{noitemerr} could still be triggered and that is undesirable |
| 1626 |
% (as the missing item will be detected at the wrong point and again later, |
| 1627 |
% during the outer list processing). We |
| 1628 |
% therefore run it only if the current environment is a list. |
| 1629 |
% \changes{v0.8q}{2024/09/03}{Raise a \tn{@noitemerr} if appropriate} |
| 1630 |
% \begin{macrocode} |
| 1631 |
\@@_if_list:T { \legacy_if:nT { @newlist } { \@noitemerr } } |
| 1632 |
% \end{macrocode} |
| 1633 |
% \begin{macrocode} |
| 1634 |
\mode_if_horizontal:TF |
| 1635 |
{ \@@_skip_remove_last: \@@_skip_remove_last: \par } |
| 1636 |
{ \@inmatherr{\end{\@currenvir}} } |
| 1637 |
% \end{macrocode} |
| 1638 |
% Once we are back in vertical mode we can add the appropriate |
| 1639 |
% closing tagging structure(s), if we are doing tagging. |
| 1640 |
% \begin{macrocode} |
| 1641 |
\__kernel_displayblock_end: |
| 1642 |
% \end{macrocode} |
| 1643 |
% Resetting the \texttt{@newlist} switch is also only done if the |
| 1644 |
% current enviornment is a list and not unconditionally. |
| 1645 |
% \changes{v0.8q}{2024/09/03}{Setting \texttt{@newlist} to false |
| 1646 |
% moved after tagging code if in a list} |
| 1647 |
% \begin{macrocode} |
| 1648 |
\@@_if_list:T { \legacy_if_gset_false:n { @newlist } } |
| 1649 |
% \end{macrocode} |
| 1650 |
% What to do in terms of vertical spacing in different situations |
| 1651 |
% is still somewhat open to debate, right now this is more or less |
| 1652 |
% implementing what \LaTeXe{} list environment have been |
| 1653 |
% doing.\fmi{some redesign/extensions here?} |
| 1654 |
% \begin{macrocode} |
| 1655 |
% \@@_debug_typeout:n{@noparlist = |
| 1656 |
% \legacy_if:nTF { @noparlist }{true}{false}} |
| 1657 |
\legacy_if:nF { @noparlist } |
| 1658 |
{ |
| 1659 |
\@@_skip_set_to_last:N \l_tmpa_skip |
| 1660 |
\dim_compare:nNnT \l_tmpa_skip > \c_zero_dim |
| 1661 |
{ |
| 1662 |
\skip_vertical:n { - \l_tmpa_skip } |
| 1663 |
\skip_vertical:n { \l_tmpa_skip + \parskip - \@outerparskip } |
| 1664 |
} |
| 1665 |
\addpenalty \@endparpenalty |
| 1666 |
\addvspace \l_@@_topsepadd_skip |
| 1667 |
% \end{macrocode} |
| 1668 |
% \LaTeXe{} triggered the paragraph handling after a list at this |
| 1669 |
% point here, i.e., only if the list didn't start a paragraph. One |
| 1670 |
% can make a case for that, but it can be somewhat surprising to |
| 1671 |
% the user and there is a good argument that even such a list could |
| 1672 |
% be followed explanatory text that is part of the same paragraph |
| 1673 |
% and doesn't start a new one.\fmi{decide which logic we want to |
| 1674 |
% use! If the old logic is used we need to close the text-unit |
| 1675 |
% ourselves in the true branch} |
| 1676 |
% \begin{macrocode} |
| 1677 |
% \legacy_if_gset_true:n { @endpe } |
| 1678 |
} |
| 1679 |
% \end{macrocode} |
| 1680 |
% So this is for now always done. Probably \cs{l_@@_topsepadd_skip} above |
| 1681 |
% should be added only if the paragraph ends here and not if it |
| 1682 |
% continues, so this need some further cleanup.\fmi{decide} |
| 1683 |
% |
| 1684 |
% Finally, we have a socket that handles the \tn{par} handling |
| 1685 |
% after the block. Normally, we use it with the \plug{on} plug (check for a |
| 1686 |
% following \tn{par}) but in the case of standalone environments we |
| 1687 |
% assign it the \plug{off} plug. |
| 1688 |
% |
| 1689 |
% \begin{macrocode} |
| 1690 |
\socket_use:n {block/endpe} |
| 1691 |
} |
| 1692 |
% \end{macrocode} |
| 1693 |
% |
| 1694 |
% \end{macro} |
| 1695 |
% |
| 1696 |
% |
| 1697 |
% \begin{macro}{\@@_if_list:T} |
| 1698 |
% The following code may need some redesigning, as there is no good test for \enquote{is |
| 1699 |
% this environment a \enquote{list} that has \tn{item}s}. For now |
| 1700 |
% this here does the trick well enough.\fmi{revisit and correct} |
| 1701 |
% \changes{v0.8q}{2024/09/03}{Provide a test for: Am I in a list?} |
| 1702 |
% \begin{macrocode} |
| 1703 |
\cs_new:Npn \@@_if_list:T |
| 1704 |
{ \tl_if_eq:NnT \l_@@_block_instance_tl {listblock} } |
| 1705 |
% \end{macrocode} |
| 1706 |
% \end{macro} |
| 1707 |
% |
| 1708 |
% |
| 1709 |
% |
| 1710 |
% \begin{macro}{\__kernel_displayblock_end:} |
| 1711 |
% The kernel hook for tagging at the end of the block. |
| 1712 |
% \begin{macrocode} |
| 1713 |
\cs_new:Npn \__kernel_displayblock_end: { |
| 1714 |
\@@_debug_typeout:n{\detokenize{__kernel_displayblock_end:}} |
| 1715 |
} |
| 1716 |
% \end{macrocode} |
| 1717 |
% \end{macro} |
| 1718 |
% |
| 1719 |
% |
| 1720 |
% |
| 1721 |
% \begin{socketdecl}{block/endpe} |
| 1722 |
% This socket is responsible for the end environment \tn{par} |
| 1723 |
% handling. We define two plugs for it (\plug{on} and \plug{off}). |
| 1724 |
% \begin{macrocode} |
| 1725 |
\socket_new:nn {block/endpe}{0} |
| 1726 |
% \end{macrocode} |
| 1727 |
% \end{socketdecl} |
| 1728 |
% |
| 1729 |
% \begin{plugdecl}{on,off} |
| 1730 |
% The plugs set the legacy \texttt{@endpe} switch. This must always |
| 1731 |
% happen because block environments with different settings can be nested |
| 1732 |
% and should not inherit the setting from the outer environment. |
| 1733 |
% \begin{macrocode} |
| 1734 |
\socket_new_plug:nnn{block/endpe}{on} |
| 1735 |
% \end{macrocode} |
| 1736 |
% We can't use \cs{legacy_if_gset_true:n} because this is now doing |
| 1737 |
% more than setting the legacy switch |
| 1738 |
% \begin{macrocode} |
| 1739 |
{ \@endpetrue } |
| 1740 |
\socket_new_plug:nnn{block/endpe}{off} |
| 1741 |
{ \@endpefalse } |
| 1742 |
% \end{macrocode} |
| 1743 |
% |
| 1744 |
% \begin{macrocode} |
| 1745 |
\socket_assign_plug:nn{block/endpe}{on} |
| 1746 |
% \end{macrocode} |
| 1747 |
% \end{plugdecl} |
| 1748 |
% |
| 1749 |
% |
| 1750 |
% |
| 1751 |
% |
| 1752 |
% |
| 1753 |
% \subsubsection{Implementation of para templates \ldots} |
| 1754 |
% |
| 1755 |
% \begin{template}{para std} |
| 1756 |
% |
| 1757 |
% \begin{macrocode} |
| 1758 |
\DeclareTemplateCode{para}{std}{1} |
| 1759 |
{ |
| 1760 |
para-indent = \parindent , |
| 1761 |
begin-hspace = \l__par_start_skip , % name?? |
| 1762 |
left-hspace = \leftskip , |
| 1763 |
right-hspace = \rightskip , |
| 1764 |
end-hspace = \parfillskip , |
| 1765 |
fixed-word-spaces = \l__par_fixed_word_spaces_bool , % name?? |
| 1766 |
final-hyphen-demerits = \finalhyphendemerits , |
| 1767 |
newline-cmd = \\ , |
| 1768 |
para-attr-class = \l__tag_para_attr_class_tl , |
| 1769 |
} |
| 1770 |
{ |
| 1771 |
\SetTemplateKeys{para}{std}{#1} |
| 1772 |
\skip_set:Nn \@rightskip \rightskip |
| 1773 |
} |
| 1774 |
% \end{macrocode} |
| 1775 |
% \end{template} |
| 1776 |
% |
| 1777 |
% |
| 1778 |
% |
| 1779 |
% |
| 1780 |
% |
| 1781 |
% \subsubsection{Implementation of block templates \ldots} |
| 1782 |
% |
| 1783 |
% |
| 1784 |
% |
| 1785 |
% |
| 1786 |
% |
| 1787 |
% \begin{template}{block display} |
| 1788 |
% |
| 1789 |
% In contrast to the \LaTeXe{} implementation we do not directly |
| 1790 |
% use \tn{listparindent} here but a private register of the |
| 1791 |
% template. The reason is that block template instances are also |
| 1792 |
% used outside of lists. |
| 1793 |
% \changes{v0.8s}{2024/10/03}{Offer item-vspace key also on block templates} |
| 1794 |
% \changes{v0.8w}{2024/11/23}{Use private storage bin for parindent |
| 1795 |
% and not \tn{listparindent} to decouple block and list templates (tagging/767)} |
| 1796 |
% \begin{macrocode} |
| 1797 |
\DeclareTemplateCode{block}{display}{1} |
| 1798 |
{ |
| 1799 |
begin-vspace = \topsep , |
| 1800 |
begin-extra-vspace = \partopsep , |
| 1801 |
para-vspace = \parsep , |
| 1802 |
end-vspace = \l_@@_botsep_skip , |
| 1803 |
end-extra-vspace = \l_@@_parbotsep_skip , |
| 1804 |
item-vspace = \itemsep , |
| 1805 |
begin-penalty = \@beginparpenalty , |
| 1806 |
end-penalty = \@endparpenalty , |
| 1807 |
right-margin = \rightmargin , |
| 1808 |
left-margin = \leftmargin , |
| 1809 |
para-indent = \l_@@_parindent_dim , |
| 1810 |
} |
| 1811 |
{ |
| 1812 |
\SetKnownTemplateKeys{block}{display}{#1} |
| 1813 |
% \end{macrocode} |
| 1814 |
% The code largely follows the logic of \LaTeXe{}'s \env{trivlist} |
| 1815 |
% implementation as far as it applicable for the \enquote{display |
| 1816 |
% block} but coded using the L3 programming layer. However, we keep |
| 1817 |
% all the legacy variables (e.g., \texttt{@noskipsec}) if there is |
| 1818 |
% some chance that they are set in classes or packages. |
| 1819 |
% \begin{macrocode} |
| 1820 |
\legacy_if:nT { @noskipsec } { \mode_leave_vertical: } |
| 1821 |
\skip_set:Nn \l_@@_topsepadd_skip { \topsep } |
| 1822 |
\mode_if_vertical:TF |
| 1823 |
{ |
| 1824 |
\skip_add:Nn \l_@@_topsepadd_skip { \partopsep } |
| 1825 |
% \end{macrocode} |
| 1826 |
% At this point it is safe to add tagging structure(s) so we have |
| 1827 |
% a kernel-owned hook here for tagging. This is used to possibly |
| 1828 |
% start a paragraph structure (to surround the block, for example, |
| 1829 |
% in case of lists) and possibly do some other preparation for |
| 1830 |
% tagging the block. |
| 1831 |
% \begin{macrocode} |
| 1832 |
\__kernel_displayblock_beginpar_vmode: |
| 1833 |
} |
| 1834 |
{ |
| 1835 |
% \end{macrocode} |
| 1836 |
% If we are in horizontal mode then the displayblock has to return |
| 1837 |
% to vertical mode now (after removing any immediately preceding |
| 1838 |
% skip or kern. But before we actually issue the\tn{par} we execute |
| 1839 |
% a kernel hook in which we can add tagging code. This hook is |
| 1840 |
% \enquote{weird} because by default it does nothing, but if |
| 1841 |
% tagging is wanted it takes an argument and grabs the following |
| 1842 |
% \tn{par} in order to put tagging code before and after the \tn{par}. |
| 1843 |
% \begin{macrocode} |
| 1844 |
\@@_skip_remove_last: \@@_skip_remove_last: |
| 1845 |
\__kernel_displayblock_beginpar_hmode:w \par |
| 1846 |
} |
| 1847 |
% \end{macrocode} |
| 1848 |
% Now we are back to legacy list implementation \ldots |
| 1849 |
% \begin{macrocode} |
| 1850 |
\legacy_if:nTF { @inlabel } |
| 1851 |
{ |
| 1852 |
\legacy_if_set_true:n { @noparitem } |
| 1853 |
\legacy_if_set_true:n { @noparlist } |
| 1854 |
} |
| 1855 |
{ |
| 1856 |
\legacy_if:nT { @newlist } { \@noitemerr } |
| 1857 |
\legacy_if_set_false:n { @noparlist } |
| 1858 |
\skip_set_eq:NN \l_@@_effective_top_skip \l_@@_topsepadd_skip |
| 1859 |
} |
| 1860 |
\skip_add:Nn \l_@@_effective_top_skip { \parskip } |
| 1861 |
% \end{macrocode} |
| 1862 |
% Next lines set some paragraph defaults, any of them may get overwritten |
| 1863 |
% if there is a \key{para-instance} specified on the \insttype{blockenv} |
| 1864 |
% instance. |
| 1865 |
% \begin{macrocode} |
| 1866 |
\skip_zero:N \leftskip |
| 1867 |
\skip_set_eq:NN \rightskip \@rightskip |
| 1868 |
\skip_set_eq:NN \parfillskip \@flushglue |
| 1869 |
% \end{macrocode} |
| 1870 |
% The next lines establish a parshape which is retained across |
| 1871 |
% paragraphs be executing \cs{para_end:} within a group and thus |
| 1872 |
% reestablishing the parshape for the next paragraph again. In case |
| 1873 |
% a list got started \tn{par} is ignored until we have seen an |
| 1874 |
% \tn{item} (or we have executed \tn{par} one thousand times. |
| 1875 |
% \begin{macrocode} |
| 1876 |
\int_zero:N \par@deathcycles |
| 1877 |
\@setpar |
| 1878 |
{ |
| 1879 |
\legacy_if:nTF { @newlist } |
| 1880 |
{ |
| 1881 |
\int_incr:N \par@deathcycles |
| 1882 |
\int_compare:nNnTF \par@deathcycles > { 1000 } |
| 1883 |
{ \@noitemerr |
| 1884 |
{ \para_end: } |
| 1885 |
} |
| 1886 |
} |
| 1887 |
{ |
| 1888 |
{ \para_end: } |
| 1889 |
} |
| 1890 |
} |
| 1891 |
\skip_set_eq:NN \@outerparskip \parskip |
| 1892 |
\skip_set_eq:NN \parskip \parsep |
| 1893 |
% \end{macrocode} |
| 1894 |
% \changes{v0.8w}{2024/11/23}{Use private storage bin for parindent |
| 1895 |
% and not \tn{listparindent} to decouple block and list templates (tagging/767)} |
| 1896 |
% \begin{macrocode} |
| 1897 |
\dim_set_eq:NN \parindent \l_@@_parindent_dim |
| 1898 |
\dim_add:Nn \linewidth { - \rightmargin - \leftmargin } |
| 1899 |
\dim_add:Nn \@totalleftmargin { \leftmargin } |
| 1900 |
\tex_parshape:D 1 ~ \@totalleftmargin \linewidth |
| 1901 |
% \end{macrocode} |
| 1902 |
% This is the point where we are ready to add the tagging structure |
| 1903 |
% for the block, e.g., an \verb=<L>=, a \verb=<Figure>= or some |
| 1904 |
% other structure. |
| 1905 |
% \begin{macrocode} |
| 1906 |
\__kernel_displayblock_begin: |
| 1907 |
% \end{macrocode} |
| 1908 |
% Finally, we have to output the vertical separation and penalty at |
| 1909 |
% the start of the block and make corrections for a change in |
| 1910 |
% \tn{parskip} and some other housekeeping, unless this block is inside a list and the list |
| 1911 |
% \tn{item} has not yet placed. In that case the vertical |
| 1912 |
% space and penalty us suppressed. This |
| 1913 |
% is controlled through the legacy switches \texttt{@noparitem}, |
| 1914 |
% \texttt{minipage}, and \texttt{@nobreak}. |
| 1915 |
% \begin{macrocode} |
| 1916 |
\legacy_if:nTF { @noparitem } |
| 1917 |
{ |
| 1918 |
\legacy_if_set_false:n { @noparitem } |
| 1919 |
\hbox_gset:Nn \g_@@_labels_box |
| 1920 |
{ |
| 1921 |
\skip_horizontal:n { - \leftmargin } |
| 1922 |
\hbox_unpack_drop:N \g_@@_labels_box |
| 1923 |
\skip_horizontal:n { \leftmargin } |
| 1924 |
} |
| 1925 |
% \end{macrocode} |
| 1926 |
% \fmi{document 2e logic used here} |
| 1927 |
% \begin{macrocode} |
| 1928 |
\legacy_if:nF { @minipage } % Why this chunk of code? |
| 1929 |
{ |
| 1930 |
\@@_skip_set_to_last:N \l_@@_tmpa_skip |
| 1931 |
\skip_vertical:n { - \l_@@_tmpa_skip } |
| 1932 |
\skip_vertical:n { \l_@@_tmpa_skip + |
| 1933 |
\@outerparskip - \parskip } |
| 1934 |
} |
| 1935 |
} |
| 1936 |
{ |
| 1937 |
\legacy_if:nTF { @nobreak } |
| 1938 |
{ \addvspace{\skip_eval:n{\@outerparskip-\parskip}} } |
| 1939 |
{ |
| 1940 |
\addpenalty \@beginparpenalty |
| 1941 |
\addvspace \l_@@_effective_top_skip |
| 1942 |
\addvspace{-\parskip} |
| 1943 |
} |
| 1944 |
} |
| 1945 |
} |
| 1946 |
% \end{macrocode} |
| 1947 |
% |
| 1948 |
% |
| 1949 |
% Extra keys to support enumitem conventions: |
| 1950 |
% \begin{macrocode} |
| 1951 |
\keys_define:nn { template/block/display } |
| 1952 |
{ |
| 1953 |
,topsep .skip_set:N = \topsep |
| 1954 |
,partopsep .skip_set:N = \partopsep |
| 1955 |
,listparindent .skip_set:N = \listparindent |
| 1956 |
} |
| 1957 |
% \end{macrocode} |
| 1958 |
% \end{template} |
| 1959 |
% |
| 1960 |
% |
| 1961 |
% \begin{macro}{\__kernel_displayblock_begin:, |
| 1962 |
% \__kernel_displayblock_beginpar_hmode:w, |
| 1963 |
% \__kernel_displayblock_beginpar_vmode:} |
| 1964 |
% The internal kernel hooks for tagging. |
| 1965 |
% \begin{macrocode} |
| 1966 |
\cs_new:Npn \__kernel_displayblock_begin: { |
| 1967 |
\@@_debug_typeout:n |
| 1968 |
{\detokenize{__kernel_displayblock_begin:}} |
| 1969 |
} |
| 1970 |
% \end{macrocode} |
| 1971 |
% |
| 1972 |
% \begin{macrocode} |
| 1973 |
\cs_new:Npn \__kernel_displayblock_beginpar_hmode:w { |
| 1974 |
\@@_debug_typeout:n |
| 1975 |
{\detokenize{__kernel_displayblock_beginpar_hmode:w}} |
| 1976 |
} |
| 1977 |
% \end{macrocode} |
| 1978 |
% |
| 1979 |
% \begin{macrocode} |
| 1980 |
\cs_new:Npn \__kernel_displayblock_beginpar_vmode: { |
| 1981 |
\@@_debug_typeout:n |
| 1982 |
{\detokenize{__kernel_displayblock_beginpar_vmode:}} |
| 1983 |
} |
| 1984 |
% \end{macrocode} |
| 1985 |
% \end{macro} |
| 1986 |
% |
| 1987 |
% |
| 1988 |
% |
| 1989 |
% |
| 1990 |
% \subsubsection{Implementation of list templates \ldots} |
| 1991 |
% |
| 1992 |
% |
| 1993 |
% |
| 1994 |
% \begin{macro}{\@itemlabel,\@listctr} |
| 1995 |
% Both \tn{@itemlabel} and \tn{@listctr} from the \LaTeXe{} list |
| 1996 |
% implementation are used (or set) by various packages. We |
| 1997 |
% therefore use them too, so that these packages have a fighting |
| 1998 |
% chance to work with the new tagging-aware implementation for |
| 1999 |
% \env{list}. |
| 2000 |
% \begin{macrocode} |
| 2001 |
\tl_new:N \@itemlabel % should have a top-level definition |
| 2002 |
\tl_new:N \@listctr % should have a top-level definition |
| 2003 |
% \end{macrocode} |
| 2004 |
% \end{macro} |
| 2005 |
% |
| 2006 |
% |
| 2007 |
% |
| 2008 |
% \begin{macro}{\@@_evaluate_saved_user_keys:nn} |
| 2009 |
% Keys set on individual list environments may be intended to alter |
| 2010 |
% the behavior of the template instance that defines the \tn{item} |
| 2011 |
% command. If meant to alter only a single \tn{item} command one |
| 2012 |
% would specify them in the optional argument of the \tn{item}, but |
| 2013 |
% if they should alter all items the right place would be the list |
| 2014 |
% environment. For this reason we need to store the values and then |
| 2015 |
% set them inside the \tn{item} template code using |
| 2016 |
% \tn{SetKnownTemplateKeys} in the appropriate context (template type |
| 2017 |
% and template name). This is done in |
| 2018 |
% \cs{@@_evaluate_saved_user_keys:nn}. The context is provided in |
| 2019 |
% the two arguments (because different list environments may use |
| 2020 |
% different \tn{item} instances based on different templates. By |
| 2021 |
% default the command does |
| 2022 |
% nothing because most environments do not have user key settings. |
| 2023 |
% \changes{v0.8s}{2024/10/03}{Pass user keys on list to \tn{item} for |
| 2024 |
% evaluation} |
| 2025 |
% \begin{macrocode} |
| 2026 |
\cs_new_eq:NN \@@_evaluate_saved_user_keys:nn \use_none:nn |
| 2027 |
% \end{macrocode} |
| 2028 |
% Maybe something like this should become a public function, but |
| 2029 |
% for now this is a one-off for the \tn{item} command and therefore |
| 2030 |
% coded inline and internal to the block code. |
| 2031 |
% \begin{macrocode} |
| 2032 |
%\cs_new:Npn \@@_save_user_keys:n #1 { |
| 2033 |
% \tl_if_empty:nTF {#1} |
| 2034 |
% { \cs_set_eq:NN \@@_evaluate_saved_user_keys:nn \use_none:nn } |
| 2035 |
% { \cs_set:Npe \@@_evaluate_saved_user_keys:nn ##1##2 |
| 2036 |
% { \SetKnownTemplateKeys{##1}{##2}{ \exp_not:n{#1} } } |
| 2037 |
%} |
| 2038 |
% \end{macrocode} |
| 2039 |
% \end{macro} |
| 2040 |
% |
| 2041 |
% |
| 2042 |
% \begin{template}{list std} |
| 2043 |
% |
| 2044 |
% This template implements numbered and unnumbered lists and can |
| 2045 |
% be combined with display blocks or with inline blocks. |
| 2046 |
% \begin{macrocode} |
| 2047 |
\DeclareTemplateCode{list}{std}{1} |
| 2048 |
{ |
| 2049 |
counter = \l_@@_counter_tl, |
| 2050 |
item-label = \l_@@_item_label_tl, |
| 2051 |
start = \l_@@_counter_start_int , |
| 2052 |
resume = \l_@@_resume_bool , |
| 2053 |
item-instance = \@@_item_instance:n , |
| 2054 |
item-vspace = \itemsep , |
| 2055 |
% item-para-vspace = \parsep , |
| 2056 |
item-penalty = \@itempenalty , |
| 2057 |
item-indent = \itemindent , |
| 2058 |
label-width = \labelwidth , |
| 2059 |
label-sep = \labelsep , |
| 2060 |
legacy-support = \l_@@_legacy_support_bool , % FMi questionable |
| 2061 |
} |
| 2062 |
{ |
| 2063 |
\@@_debug_typeout:n{template:list:std} |
| 2064 |
% |
| 2065 |
% \end{macrocode} |
| 2066 |
% We start by looking at the user supplied keys in \texttt{\#1}. If |
| 2067 |
% there aren't any we reset \cs{@@_evaluate_saved_user_keys:nn} to |
| 2068 |
% do nothing. Otherwise we evaluate and set the keys in the context |
| 2069 |
% of the current list template. In addition we prepare |
| 2070 |
% \cs{@@_evaluate_saved_user_keys:nn} for execution in the |
| 2071 |
% template for \tn{item}. |
| 2072 |
% \changes{v0.8s}{2024/10/03}{Prepare \cs{@@_evaluate_saved_user_keys:nn} |
| 2073 |
% for use in \tn{item}} |
| 2074 |
% \begin{macrocode} |
| 2075 |
\tl_if_empty:oTF {#1} |
| 2076 |
{ \cs_set_eq:NN \@@_evaluate_saved_user_keys:nn \use_none:nn } |
| 2077 |
{ |
| 2078 |
\SetKnownTemplateKeys{list}{std}{#1} |
| 2079 |
% \end{macrocode} |
| 2080 |
% The setup for \cs{@@_evaluate_saved_user_keys:nn} is a bit tricky |
| 2081 |
% and has to be done with \cs{cs_set:Npe} even though we don't want |
| 2082 |
% to expand anything and therefore use \cs{exp_not:n} inside. All |
| 2083 |
% this does is that any \texttt{\#} passed in via \texttt{\#1} is |
| 2084 |
% doubled (e.g., from \verb/label-format=\fbox{#1}/ which is |
| 2085 |
% represented as \verb/...\fbox{##1}/). Otherwise, we would end up |
| 2086 |
% with a replacement text like |
| 2087 |
%\begin{verbatim} |
| 2088 |
% \SetTemplateKeys {#1}{#2}{label-format=\fbox {#1}} |
| 2089 |
%\end{verbatim} |
| 2090 |
% instead of |
| 2091 |
%\begin{verbatim} |
| 2092 |
% \SetTemplateKeys {#1}{#2}{label-format=\fbox {##1}} |
| 2093 |
%\end{verbatim} |
| 2094 |
% resulting in very odd and puzzling behavior later on. |
| 2095 |
% \begin{macrocode} |
| 2096 |
\cs_set:Npe \@@_evaluate_saved_user_keys:nn ##1##2 |
| 2097 |
{ \SetKnownTemplateKeys{##1}{##2}{ |
| 2098 |
\exp_not:o { \UnusedTemplateKeys } |
| 2099 |
} |
| 2100 |
% \end{macrocode} |
| 2101 |
% |
| 2102 |
% \begin{macrocode} |
| 2103 |
\exp_not:n { |
| 2104 |
\tl_if_empty:NF \UnusedTemplateKeys |
| 2105 |
{ |
| 2106 |
\msg_error:nnee { block } { unknown-keys } |
| 2107 |
{ \l_@@_env_name_tl \space environment} |
| 2108 |
\UnusedTemplateKeys |
| 2109 |
} |
| 2110 |
} |
| 2111 |
} |
| 2112 |
} |
| 2113 |
% \end{macrocode} |
| 2114 |
% Has this list a counter name defined in the instance? |
| 2115 |
% \begin{macrocode} |
| 2116 |
\tl_if_empty:NTF \l_@@_counter_tl |
| 2117 |
{ |
| 2118 |
% \end{macrocode} |
| 2119 |
% If no counter name has been specified as part of the instance |
| 2120 |
% setup the list might still be numbered if it is a legacy list |
| 2121 |
% that uses \cs{usecounter} in the second argument of the legacy |
| 2122 |
% \env{list} environment. However, in that case we don't have to do |
| 2123 |
% much because \cs{usecounter} sets up \cs{@listctr} and sets |
| 2124 |
% it to zero so that the first item is numbered 1. |
| 2125 |
% |
| 2126 |
% So all we do is to check if there was a \key{start} value given |
| 2127 |
% that differs from 1 and if so we change the counter value to |
| 2128 |
% match that. This makes it possible to define a legacy \env{list} |
| 2129 |
% in which the counter doesn't start with 1 by explicitly setting |
| 2130 |
% the counter value in the second argument of the \env{list} |
| 2131 |
% environment but also overwriting that through a \key{start} key |
| 2132 |
% setting on invocation. |
| 2133 |
% \changes{v0.8v}{2024/10/11}{Correct logic for setting up the list |
| 2134 |
% counter (tagging/730)} |
| 2135 |
% \changes{v0.9f}{2025/06/21}{Correct logic for setting up the list |
| 2136 |
% counter further (tagging/893)} |
| 2137 |
% \begin{macrocode} |
| 2138 |
\int_compare:nNnF \l_@@_counter_start_int = 1 |
| 2139 |
{ |
| 2140 |
\int_gset:cn{ c@ \@listctr } |
| 2141 |
{ \l_@@_counter_start_int - 1 } |
| 2142 |
} |
| 2143 |
} |
| 2144 |
% \end{macrocode} |
| 2145 |
% In that case we only check if we should resume a previous list |
| 2146 |
% (\tn{@listctr} should be set in that case through the legacy |
| 2147 |
% method as well so we should be able to use it). |
| 2148 |
% \begin{macrocode} |
| 2149 |
% \end{macrocode} |
| 2150 |
% If a counter is set in the list instance we use that |
| 2151 |
% one. This should be the name of a \LaTeX{} counter that is |
| 2152 |
% already allocated externally---no runtime check is made for this: |
| 2153 |
% if it is not declared one will get \enquote{no such counter} |
| 2154 |
% error when the list is used. |
| 2155 |
% \begin{macrocode} |
| 2156 |
{ |
| 2157 |
\@nmbrlisttrue |
| 2158 |
\tl_set_eq:NN \@listctr \l_@@_counter_tl |
| 2159 |
\bool_if:NF \l_@@_resume_bool |
| 2160 |
{ |
| 2161 |
\int_gset:cn{ c@ \@listctr } |
| 2162 |
{ \l_@@_counter_start_int - 1 } |
| 2163 |
} |
| 2164 |
} |
| 2165 |
% \end{macrocode} |
| 2166 |
% Does the current instance has an item label representation? This |
| 2167 |
% would be possible whether or not we have a numbered list. If yes, |
| 2168 |
% then we use this for \tn{@itemlabel}, otherwise we expect that |
| 2169 |
% \tn{@itemlabel} is provided from the outside, e.g., as part of |
| 2170 |
% the \env{list} environment argument. |
| 2171 |
% \begin{macrocode} |
| 2172 |
\tl_if_empty:NF \l_@@_item_label_tl |
| 2173 |
{ |
| 2174 |
\tl_set_eq:NN \@itemlabel \l_@@_item_label_tl |
| 2175 |
} |
| 2176 |
% \end{macrocode} |
| 2177 |
% Finally, we signal that we are at the start of a new list (which |
| 2178 |
% affects how the first \tn{item} is handled and how \tn{par} |
| 2179 |
% commands are interpreted. |
| 2180 |
% \begin{macrocode} |
| 2181 |
\legacy_if_gset_true:n { @newlist } |
| 2182 |
% \end{macrocode} |
| 2183 |
% If we encounter horizontal material before the first \tn{item} we |
| 2184 |
% do want a \tn{@noitemerr} straight away, because afterwards we |
| 2185 |
% end up with tagging structure faults whose cause is the |
| 2186 |
% missing \tn{item}. So we setup up \cs{@@_item_everypar:} to test |
| 2187 |
% for this; when the first \tn{item} is encountered this will get |
| 2188 |
% reset. This is only relevant for vertical lists, when dealing with |
| 2189 |
% inline lists one would need to test for something else to |
| 2190 |
% identify that there is horizontal material between the start of the list and |
| 2191 |
% the first \tn{item} (maybe some \tn{spacefactor} trick could be |
| 2192 |
% used then, or the material is boxed first and the width is |
| 2193 |
% inspected as suggested by Joseph).\fmi{Think about a better |
| 2194 |
% implementation at some point.} |
| 2195 |
% \changes{v0.8q}{2024/09/02}{} |
| 2196 |
% \begin{macrocode} |
| 2197 |
\cs_set_eq:NN \@@_item_everypar: \@@_item_everypar_first: |
| 2198 |
% \end{macrocode} |
| 2199 |
% |
| 2200 |
% \begin{macrocode} |
| 2201 |
\@@_debug_typeout:n{template:list:std~end} |
| 2202 |
} |
| 2203 |
% \end{macrocode} |
| 2204 |
% |
| 2205 |
% The message that is used above when we are left with keys that |
| 2206 |
% are unknown: |
| 2207 |
% \begin{macrocode} |
| 2208 |
\msg_new:nnnn { block } { unknown-keys } |
| 2209 |
{ Some~ keys~ specified~ on~ the~ #1~ are~ unknown. } |
| 2210 |
{ |
| 2211 |
The~ following~ keys~ are~ unknown~ and~ their~ |
| 2212 |
values~ are~ ignored:\\ |
| 2213 |
\space\space #2\\ |
| 2214 |
Perhaps~ a~ misspelling~ or~ the~ current~ template~ |
| 2215 |
instance~ uses~ special~ keys. |
| 2216 |
} |
| 2217 |
% \end{macrocode} |
| 2218 |
% |
| 2219 |
% |
| 2220 |
% Extra keys to support enumitem conventions: |
| 2221 |
% \begin{macrocode} |
| 2222 |
\keys_define:nn { template/list/std } |
| 2223 |
{ |
| 2224 |
,nosep .code:n = |
| 2225 |
\dim_zero:N \itemsep |
| 2226 |
\dim_zero:N \parsep |
| 2227 |
\dim_zero:N \topsep |
| 2228 |
\dim_zero:N \l_@@_botsep_skip |
| 2229 |
\dim_zero:N \l_@@_parbotsep_skip |
| 2230 |
,midsep .skip_set:N = \topsep |
| 2231 |
} |
| 2232 |
% \end{macrocode} |
| 2233 |
% |
| 2234 |
% \end{template} |
| 2235 |
% |
| 2236 |
% |
| 2237 |
% \subsubsection{Implementation of \tn{item} template(s)} |
| 2238 |
% |
| 2239 |
% |
| 2240 |
% |
| 2241 |
% \begin{template}{item std} |
| 2242 |
% The item template has one hidden key \key{label} which is not available on the |
| 2243 |
% template for setting because it is only used to receive any |
| 2244 |
% optional data passed to the \tn{item} command. We therefore |
| 2245 |
% declare it with \cs{keys_define:nn} and ensure that the optional |
| 2246 |
% argument data to \tn{item} (if it is not a key/value list |
| 2247 |
% already) is passed to this \key{label} key. |
| 2248 |
% \begin{macrocode} |
| 2249 |
\keys_define:nn { template/item/std } |
| 2250 |
{ label .tl_set:N = \l_@@_label_given_tl } |
| 2251 |
% \end{macrocode} |
| 2252 |
% |
| 2253 |
% \fmi{alignment is mostly wrong (test short medium and multiline |
| 2254 |
% labels)} |
| 2255 |
% \begin{macrocode} |
| 2256 |
\DeclareTemplateCode{item}{std}{1} |
| 2257 |
{ |
| 2258 |
counter-label = \@@_counter_label:n , |
| 2259 |
counter-ref = \@@_counter_ref:n , |
| 2260 |
% \end{macrocode} |
| 2261 |
% \fmi{next set of key not yet used} |
| 2262 |
% \begin{macrocode} |
| 2263 |
label-ref = \@@_label_ref:n , |
| 2264 |
label-autoref = \@@_label_autoref:n , |
| 2265 |
label-format = \@@_label_format:n , |
| 2266 |
label-strut = \l_@@_label_strut_bool , |
| 2267 |
label-boxed = \l_@@_label_boxed_bool , |
| 2268 |
next-line = \l_@@_next_line_bool , |
| 2269 |
text-font = \l_@@_text_font_tl , |
| 2270 |
compatibility = \l_@@_item_compatibility_bool , |
| 2271 |
% \end{macrocode} |
| 2272 |
% This probably needs a different implementation (and needs completing)\fmi{complete} |
| 2273 |
% \begin{macrocode} |
| 2274 |
label-align = { |
| 2275 |
left = \tl_set:Nn \l_@@_item_align_tl { \relax \hss } , |
| 2276 |
center = \tl_set:Nn \l_@@_item_align_tl { \hss \hss } , |
| 2277 |
right = \tl_set:Nn \l_@@_item_align_tl { \hss \relax } , |
| 2278 |
parleft = \NOT_IMPLEMENTED , |
| 2279 |
} , |
| 2280 |
} |
| 2281 |
% \end{macrocode} |
| 2282 |
% Then typeset the label at its natural width by applying |
| 2283 |
% \cs{@@_make_label_box:n} to the label given or to a label constructed |
| 2284 |
% from the counter. If it is boxed and reasonably short, add padding to |
| 2285 |
% make it at least of size \tn{labelwidth}, then add another layer of |
| 2286 |
% box. This way, when we unpack it in \cs{g_@@_labels_box} it correctly |
| 2287 |
% remains boxed in those cases. Afterwards, in the \keyvalue{nextline} |
| 2288 |
% case add \tn{newline} if the label did not fit in the allotted space. |
| 2289 |
% \begin{macrocode} |
| 2290 |
{ |
| 2291 |
\@@_debug_typeout:n{template:item:std} |
| 2292 |
% \end{macrocode} |
| 2293 |
% |
| 2294 |
% First deal with the key--value input, which in particular may |
| 2295 |
% provide a value for the label (the usual optional argument of |
| 2296 |
% \tn{item}). For this we set \cs{l_@@_label_given_tl} to |
| 2297 |
% \cs{c_novalue_tl} so that we can identify if an optional argument |
| 2298 |
% was given. |
| 2299 |
% \begin{macrocode} |
| 2300 |
\tl_set_eq:NN \l_@@_label_given_tl \c_novalue_tl |
| 2301 |
% \end{macrocode} |
| 2302 |
% First we evaluate and set any keys specified on the list |
| 2303 |
% environment by calling |
| 2304 |
% \cs{@@_evaluate_saved_user_keys:nn}. Then we do the same |
| 2305 |
% with all keys specified on this \tn{item} command (which may |
| 2306 |
% overwrite one or the other setting just made). |
| 2307 |
% \changes{v0.8s}{2024/10/03}{Use \cs{@@_evaluate_saved_user_keys:nn} |
| 2308 |
% to make use of user keys on the list level} |
| 2309 |
% \begin{macrocode} |
| 2310 |
\@@_evaluate_saved_user_keys:nn {item}{std} |
| 2311 |
% \end{macrocode} |
| 2312 |
% We don't care whether all of the user keys from the list level have |
| 2313 |
% been applied, but those explicitly set on the \cs{item} command |
| 2314 |
% should be aplicable, so we generate an error if that isn't the case: |
| 2315 |
% \begin{macrocode} |
| 2316 |
\SetKnownTemplateKeys{item}{std}{#1} |
| 2317 |
\tl_if_empty:NF \UnusedTemplateKeys |
| 2318 |
{ |
| 2319 |
\msg_error:nnee { block } { unknown-keys } |
| 2320 |
{ \noexpand\item command } |
| 2321 |
\UnusedTemplateKeys |
| 2322 |
} |
| 2323 |
% \end{macrocode} |
| 2324 |
% |
| 2325 |
% If no optional argument was given then \cs{l_@@_label_given_tl} |
| 2326 |
% is still equal to \cs{c_novalue_tl} and so we can distinuish |
| 2327 |
% that from \verb=\item[]=. |
| 2328 |
% |
| 2329 |
% \begin{macrocode} |
| 2330 |
\tl_if_novalue:oTF \l_@@_label_given_tl |
| 2331 |
{ |
| 2332 |
% \end{macrocode} |
| 2333 |
% The rest of the code for this template needs work and is both |
| 2334 |
% incomplete and partly wrong.\fmi{fix} |
| 2335 |
% \begin{macrocode} |
| 2336 |
\tl_if_blank:oF \@listctr { \@kernel@refstepcounter \@listctr } |
| 2337 |
\bool_if:NTF \l_@@_item_compatibility_bool % not sure that |
| 2338 |
% conditional |
| 2339 |
% makes sense |
| 2340 |
{ \@@_make_label_box:n { \MakeLinkTarget[\@listctr]{}% |
| 2341 |
\@itemlabel } } % TODO ? |
| 2342 |
{ \@@_make_label_box:n { \MakeLinkTarget[\@listctr]{}% |
| 2343 |
\@@_counter_label:n { \@listctr } } } |
| 2344 |
} |
| 2345 |
% \end{macrocode} |
| 2346 |
% \changes{v0.9c}{2025/05/17}{Add \cs{MakeLinkTarget}, tagging issue \#840} |
| 2347 |
% \begin{macrocode} |
| 2348 |
{ |
| 2349 |
\@@_debug_typeout:n{item~ with~ optional} |
| 2350 |
\@@_make_label_box:n {\MakeLinkTarget[\l_@@_env_name_tl]{}\l_@@_label_given_tl } } |
| 2351 |
\bool_if:nT |
| 2352 |
{ |
| 2353 |
\l_@@_label_boxed_bool |
| 2354 |
% TODO: is \linewidth correct? |
| 2355 |
&& \dim_compare_p:n |
| 2356 |
{ \box_wd:N \l_@@_one_label_box <= \linewidth } |
| 2357 |
} |
| 2358 |
{ |
| 2359 |
\dim_compare:nNnT |
| 2360 |
{ \box_wd:N \l_@@_one_label_box } < \labelwidth |
| 2361 |
{ |
| 2362 |
\hbox_set_to_wd:Nnn \l_@@_one_label_box { \labelwidth } |
| 2363 |
{ |
| 2364 |
\exp_after:wN \use_i:nn \l_@@_item_align_tl |
| 2365 |
% \end{macrocode} |
| 2366 |
% FMi: \LaTeXe{} keeps the label boxed inside (not unboxed). This |
| 2367 |
% means that the content stays rigid and does not vary based on |
| 2368 |
% glue setting in the line with the label. |
| 2369 |
% There are cases where we do want the unboxed version (I think |
| 2370 |
% enumitem offers that in some cases too) but it should probably |
| 2371 |
% not the default. |
| 2372 |
% \begin{macrocode} |
| 2373 |
% TODO: customize? |
| 2374 |
% \hbox_unpack_drop:N \l_@@_one_label_box |
| 2375 |
\box_use_drop:N \l_@@_one_label_box |
| 2376 |
% \end{macrocode} |
| 2377 |
% |
| 2378 |
% \begin{macrocode} |
| 2379 |
\exp_after:wN \use_ii:nn \l_@@_item_align_tl |
| 2380 |
} |
| 2381 |
} |
| 2382 |
% \end{macrocode} |
| 2383 |
% Add another box level to the label box: |
| 2384 |
% \begin{macrocode} |
| 2385 |
\hbox_set:Nn \l_@@_one_label_box |
| 2386 |
{ \box_use_drop:N \l_@@_one_label_box } |
| 2387 |
} |
| 2388 |
\dim_compare:nNnTF { \box_wd:N \l_@@_one_label_box } > \labelwidth |
| 2389 |
{ \bool_set_true:N \l_@@_long_label_bool } |
| 2390 |
{ \bool_set_false:N \l_@@_long_label_bool } |
| 2391 |
\hbox_gset:Nn \g_@@_labels_box |
| 2392 |
{ |
| 2393 |
\hbox_unpack_drop:N \g_@@_labels_box |
| 2394 |
\skip_horizontal:n { \itemindent - \labelsep - \labelwidth } |
| 2395 |
\hbox_unpack_drop:N \l_@@_one_label_box |
| 2396 |
\skip_horizontal:n { \labelsep } |
| 2397 |
\bool_if:NT \l_@@_next_line_bool |
| 2398 |
{ \bool_if:NT \l_@@_long_label_bool { \nobreak \hfil \break } } |
| 2399 |
% version of \newline inside an hbox that will be unpacked |
| 2400 |
} |
| 2401 |
% TODO??? FMi what's that? |
| 2402 |
% \skip_set_eq:NN \parsep \l_@@_item_parsep_skip |
| 2403 |
% \end{macrocode} |
| 2404 |
% The next setting is for compatibility: The list template sets |
| 2405 |
% \tn{listparindent} to zero and otherwise doesn't use it any |
| 2406 |
% more. However, in the second argument of a legacy \env{list} |
| 2407 |
% envrironment the user may have set it explicitly to some other |
| 2408 |
% value and whatever value it had was then used for \tn{parindent} |
| 2409 |
% within the list. Now we use its value only if it differs from |
| 2410 |
% zero but otherwise use whatever the template instances |
| 2411 |
% specify. This gives 99.9\% compatibility for legacy |
| 2412 |
% documents. 100\% for definitions using the \env{list} environment |
| 2413 |
% and a setting inside, but if the user used \tn{listparindent} |
| 2414 |
% within the document, e.g., inside a \env{verse} environment there |
| 2415 |
% there is one case in which the setting is ignored, i.e., when it |
| 2416 |
% was set back to zero. That's a rather unlikely scenario, but it |
| 2417 |
% is not impossible. However, I couldn't think of an approach that |
| 2418 |
% circumvents such boundary cases. |
| 2419 |
% |
| 2420 |
% \changes{v0.8w}{2024/11/24}{Only use \tn{listparindent} if it was changed |
| 2421 |
% from its default (tagging/767)} |
| 2422 |
% \begin{macrocode} |
| 2423 |
\dim_compare:nNnF \listparindent = {0pt} |
| 2424 |
{ \dim_set_eq:NN \parindent \listparindent } |
| 2425 |
% \end{macrocode} |
| 2426 |
% Placing the list label(s) is done when the paragraph for the |
| 2427 |
% \tn{item} is started, which executes \cs{@@_item_everypar:} |
| 2428 |
% inside \hook{para/begin}. By default this command does nothing, now we |
| 2429 |
% change it to attach the pending label or labels. |
| 2430 |
% \begin{macrocode} |
| 2431 |
\cs_set_eq:NN \@@_item_everypar: \@@_item_everypar_std: |
| 2432 |
} |
| 2433 |
% \end{macrocode} |
| 2434 |
% \end{template} |
| 2435 |
% |
| 2436 |
% |
| 2437 |
% |
| 2438 |
% \begin{macro}{\l_@@_item_align_tl} |
| 2439 |
% |
| 2440 |
% \begin{macrocode} |
| 2441 |
\tl_new:N \l_@@_item_align_tl |
| 2442 |
% \end{macrocode} |
| 2443 |
% \end{macro} |
| 2444 |
% |
| 2445 |
% \begin{variable}{\l_@@_one_label_box, \g_@@_labels_box} |
| 2446 |
% Each label is typeset in \cs{l_@@_one_label_box} to be measured. |
| 2447 |
% Once this is ready, it is put (boxed or unboxed) in |
| 2448 |
% \cs{g_@@_labels_box}, together with any pending labels (for the case |
| 2449 |
% where a list begins just after \tn{item}). This is an analogue of |
| 2450 |
% \LaTeXe{}'s \tn{@labels}, but it is always unboxed before use, to |
| 2451 |
% support both boxed and unboxed labels. |
| 2452 |
% \begin{macrocode} |
| 2453 |
\box_new:N \l_@@_one_label_box |
| 2454 |
\box_new:N \g_@@_labels_box |
| 2455 |
% \end{macrocode} |
| 2456 |
% \end{variable} |
| 2457 |
% |
| 2458 |
% \begin{variable}{\l_@@_long_label_bool} |
| 2459 |
% Track whether the \cs{l_@@_one_label_box} is larger than |
| 2460 |
% \tn{labelwidth}. |
| 2461 |
% \begin{macrocode} |
| 2462 |
\bool_new:N \l_@@_long_label_bool |
| 2463 |
% \end{macrocode} |
| 2464 |
% \end{variable} |
| 2465 |
% |
| 2466 |
% \begin{macro}{\@@_make_label_box:n, \@@_label_format:e} |
| 2467 |
% Make one label, wrapped in \cs{@@_label_format:n}, with an |
| 2468 |
% appropriate \tn{strut} and possibly \tn{makelabel} in compatibility |
| 2469 |
% mode (used for the \env{list} environment). |
| 2470 |
% \begin{macrocode} |
| 2471 |
\cs_new_protected:Npn \@@_make_label_box:n #1 |
| 2472 |
{ |
| 2473 |
\hbox_set:Nn \l_@@_one_label_box |
| 2474 |
{ |
| 2475 |
% \end{macrocode} |
| 2476 |
% If we do tagging then the contents of this box may need to be |
| 2477 |
% wrapped into a structure, e.g., \verb=<Lbl>=. |
| 2478 |
% \begin{macrocode} |
| 2479 |
\tag_socket_use:nnn {block/list/label}{} |
| 2480 |
{ |
| 2481 |
% \end{macrocode} |
| 2482 |
% |
| 2483 |
% \begin{macrocode} |
| 2484 |
\@@_label_format:n |
| 2485 |
{ |
| 2486 |
\bool_if:NT \l_@@_label_strut_bool { \strut } |
| 2487 |
\bool_if:NTF \l_@@_legacy_support_bool |
| 2488 |
\makelabel |
| 2489 |
\use:n |
| 2490 |
{#1} |
| 2491 |
} |
| 2492 |
% \end{macrocode} |
| 2493 |
% And what gets opened also needs closing: |
| 2494 |
% \begin{macrocode} |
| 2495 |
} |
| 2496 |
} |
| 2497 |
} |
| 2498 |
% \end{macrocode} |
| 2499 |
% \end{macro} |
| 2500 |
% |
| 2501 |
% \begin{socketdecl}{block/list/label} |
| 2502 |
% A tagging socket to tag the label. It takes two arguments so that it can transparently |
| 2503 |
% pass the label content. |
| 2504 |
% \changes{v0.9k}{2025/07/21}{Removed fallback declaration here} |
| 2505 |
% Declaration is in lttagging. |
| 2506 |
% \end{socketdecl} |
| 2507 |
% \begin{plugdecl}{default} |
| 2508 |
% \begin{macrocode} |
| 2509 |
\def\LBody{LBody} |
| 2510 |
\NewTaggingSocketPlug{block/list/label}{default} |
| 2511 |
{ |
| 2512 |
% |
| 2513 |
% FMi: this needs a different logic to decide when to make the label |
| 2514 |
% an artifact (after cleaning up the \item code ), therefore |
| 2515 |
% disabled for now |
| 2516 |
% \tl_if_empty:oTF \@itemlabel |
| 2517 |
% { |
| 2518 |
% \tag_mc_begin:n {artifact} |
| 2519 |
% } |
| 2520 |
% { |
| 2521 |
\tagstructbegin{tag=Lbl} |
| 2522 |
\tagmcbegin{tag=Lbl} |
| 2523 |
% } |
| 2524 |
#2 |
| 2525 |
\tagmcend % end mc-Lbl or artifact |
| 2526 |
% FMi: unconditionally for now |
| 2527 |
% \tl_if_empty:oF \@itemlabel |
| 2528 |
\tagstructend % end Lbl |
| 2529 |
\tagstructbegin{tag=\LBody} |
| 2530 |
} |
| 2531 |
\AssignTaggingSocketPlug{block/list/label}{default} |
| 2532 |
% \end{macrocode} |
| 2533 |
% \end{plugdecl} |
| 2534 |
% |
| 2535 |
% |
| 2536 |
% |
| 2537 |
% \begin{macro}{\@@_item_everypar:, \@@_item_everypar_std:, \@@_item_everypar_first:} |
| 2538 |
% The \cs{@@_item_everypar:} command is executed as part of \hook{para/begin} |
| 2539 |
% but most of the time does nothing, i.e., it has the following |
| 2540 |
% default definition outside of lists (and most of the time within lists). |
| 2541 |
% \begin{macrocode} |
| 2542 |
\cs_new_eq:NN \@@_item_everypar: \prg_do_nothing: |
| 2543 |
% \end{macrocode} |
| 2544 |
% |
| 2545 |
% \begin{macrocode} |
| 2546 |
\AddToHook{para/begin}[items]{\@@_item_everypar:} |
| 2547 |
% \end{macrocode} |
| 2548 |
% |
| 2549 |
% Note that we have to make sure that the above code is executed |
| 2550 |
% after the hook chunk from \pkg{tagpdf} because the latter uses |
| 2551 |
% \texttt{@inlabel} to make a decision. |
| 2552 |
% |
| 2553 |
% By the end of the day both should probably move into the kernel |
| 2554 |
% hook instead or, better, into sockets. |
| 2555 |
% \begin{macrocode} |
| 2556 |
\DeclareHookRule{para/begin}{items}{after}{tagpdf} |
| 2557 |
% \end{macrocode} |
| 2558 |
% |
| 2559 |
% |
| 2560 |
% What follows is the version that resets various legacy booleans and puts |
| 2561 |
% the label box in the right place and finally resets itself to do |
| 2562 |
% nothing next time. \cs{@@_item_everypar:} is set to this by the |
| 2563 |
% item template so that the next paragraph start runs the code below. |
| 2564 |
% \begin{macrocode} |
| 2565 |
\cs_new_protected:Npn \@@_item_everypar_std: { |
| 2566 |
\@@_debug_typeout:n{item~ everypar \on@line } |
| 2567 |
\legacy_if_set_false:n { @minipage } |
| 2568 |
\legacy_if_gset_false:n { @newlist } |
| 2569 |
\legacy_if:nT { @inlabel } |
| 2570 |
{ |
| 2571 |
\legacy_if_gset_false:n { @inlabel } |
| 2572 |
% \end{macrocode} |
| 2573 |
% |
| 2574 |
% \begin{macrocode} |
| 2575 |
\box_if_empty:NT \g_para_indent_box { \kern - \itemindent } |
| 2576 |
\para_omit_indent: |
| 2577 |
% \end{macrocode} |
| 2578 |
% |
| 2579 |
% \begin{macrocode} |
| 2580 |
\box_use_drop:N \g_@@_labels_box |
| 2581 |
% \end{macrocode} |
| 2582 |
% After the labels are placed we start a paragraph structure (if |
| 2583 |
% appropriate). This is handled in the following kernel hook: |
| 2584 |
% \begin{macrocode} |
| 2585 |
\__kernel_list_label_after: |
| 2586 |
% \end{macrocode} |
| 2587 |
% |
| 2588 |
% \begin{macrocode} |
| 2589 |
\penalty \c_zero_int |
| 2590 |
} |
| 2591 |
\legacy_if:nTF { @nobreak } |
| 2592 |
{ |
| 2593 |
\legacy_if_gset_false:n { @nobreak } |
| 2594 |
\int_set:Nn \clubpenalty { 10000 } |
| 2595 |
} |
| 2596 |
{ |
| 2597 |
\int_set_eq:NN \clubpenalty \@clubpenalty |
| 2598 |
% \end{macrocode} |
| 2599 |
% Once the label(s) are typeset and we are past any special |
| 2600 |
% \texttt{@nobreak} handling we reset \cs{@@_item_everypar:} to do |
| 2601 |
% nothing. |
| 2602 |
% \begin{macrocode} |
| 2603 |
\cs_set_eq:NN \@@_item_everypar: \prg_do_nothing: |
| 2604 |
} |
| 2605 |
} |
| 2606 |
% \end{macrocode} |
| 2607 |
% |
| 2608 |
% This is the definition of \cs{@@_item_everypar:} before the first |
| 2609 |
% \tn{item} is encountered. |
| 2610 |
% \changes{v0.8q}{2024/09/02}{Call \tn{@noitemerr} if hmode is |
| 2611 |
% started before the first item} |
| 2612 |
% \begin{macrocode} |
| 2613 |
\cs_new:Npn \@@_item_everypar_first: { |
| 2614 |
\legacy_if:nT { @newlist } { \@noitemerr } |
| 2615 |
} |
| 2616 |
% \end{macrocode} |
| 2617 |
% |
| 2618 |
% \end{macro} |
| 2619 |
% |
| 2620 |
% |
| 2621 |
% \begin{variable}{\l_@@_tmpa_skip} |
| 2622 |
% \begin{macrocode} |
| 2623 |
\skip_new:N \l_@@_tmpa_skip |
| 2624 |
% \end{macrocode} |
| 2625 |
% \end{variable} |
| 2626 |
% |
| 2627 |
% |
| 2628 |
% |
| 2629 |
% |
| 2630 |
% |
| 2631 |
% |
| 2632 |
% |
| 2633 |
% \begin{variable}{\l_@@_topsepadd_skip, \l_@@_effective_top_skip} |
| 2634 |
% Variables equivalent to \LaTeXe{}'s \tn{@topsepadd} and \tn{@topsep}. |
| 2635 |
% Roughly equal to a mixture of \texttt{topsep}, \texttt{partopsep}, |
| 2636 |
% and various \texttt{parskip} at different nesting levels in lists. |
| 2637 |
% The code is really elaborate when \texttt{@inlabel} is true. |
| 2638 |
% \begin{macrocode} |
| 2639 |
\skip_new:N \l_@@_topsepadd_skip |
| 2640 |
\skip_new:N \l_@@_effective_top_skip |
| 2641 |
% \end{macrocode} |
| 2642 |
% \end{variable} |
| 2643 |
% |
| 2644 |
% |
| 2645 |
% |
| 2646 |
% |
| 2647 |
% |
| 2648 |
% |
| 2649 |
% |
| 2650 |
% |
| 2651 |
% |
| 2652 |
% |
| 2653 |
% |
| 2654 |
% \begin{macro}{\item} |
| 2655 |
% Here we already have all the building blocks. Complain in math |
| 2656 |
% mode. Distinguish between first item (do necessary tagging) and |
| 2657 |
% later items \cs{@@_inter_item:} to |
| 2658 |
% cleanly close what's before, then call \cs{@@_item_instance:n} (which |
| 2659 |
% calls \tn{UseInstance}\{item\}\marg{instance}) to prepare the |
| 2660 |
% upcoming item: it will be actually inserted only once some later |
| 2661 |
% material triggers \tn{everypar}. |
| 2662 |
% \begin{macrocode} |
| 2663 |
\AddToHook{begindocument/before}{ |
| 2664 |
\RenewDocumentCommand{\item}{ ={label}o } |
| 2665 |
{ |
| 2666 |
\@inmatherr \item |
| 2667 |
% \end{macrocode} |
| 2668 |
% TODO: Check if test for being outside of a list is sensible |
| 2669 |
% \begin{macrocode} |
| 2670 |
\cs_if_free:NTF \@@_item_instance:n |
| 2671 |
{ |
| 2672 |
\@latex@error{Lonely~\string\item--perhaps~a~missing~ |
| 2673 |
list~environment}\@ehc |
| 2674 |
} |
| 2675 |
{ |
| 2676 |
\legacy_if:nTF { @newlist } |
| 2677 |
{ |
| 2678 |
\__kernel_list_item_begin: |
| 2679 |
% \end{macrocode} |
| 2680 |
% The first item of a list also has to change the \texttt{@newlist} switch. |
| 2681 |
% \changes{v0.8q}{2024/09/02}{Set \texttt{@newlist} to false after |
| 2682 |
% the first \tn{item}} |
| 2683 |
% \begin{macrocode} |
| 2684 |
\legacy_if_gset_false:n { @newlist } |
| 2685 |
} |
| 2686 |
{ \@@_inter_item: } |
| 2687 |
% \end{macrocode} |
| 2688 |
% To avoid unnecessary key/val processing we make a quick check if |
| 2689 |
% there was an optional argument. |
| 2690 |
% \begin{macrocode} |
| 2691 |
\tl_if_novalue:nTF {#1} % avoids reparsing label={} |
| 2692 |
{ \@@_item_instance:n { } } |
| 2693 |
{ \@@_item_instance:n {#1} } |
| 2694 |
% \end{macrocode} |
| 2695 |
% Set the legacy switch that signals that we have a pending item label: |
| 2696 |
% \begin{macrocode} |
| 2697 |
\legacy_if_gset_true:n { @inlabel } |
| 2698 |
\ignorespaces |
| 2699 |
} |
| 2700 |
} |
| 2701 |
} |
| 2702 |
% \end{macrocode} |
| 2703 |
% \end{macro} |
| 2704 |
% |
| 2705 |
% |
| 2706 |
% \begin{macro}{\@@_inter_item:} |
| 2707 |
% Between items. If the previous item had no content then we need to |
| 2708 |
% trigger \tn{everypar}. Otherwise we simply close the previous item |
| 2709 |
% with \tn{par} after removing some horizontal space. Between items, |
| 2710 |
% there is a penalty and some space. |
| 2711 |
% \begin{macrocode} |
| 2712 |
\cs_new_protected:Npn \@@_inter_item: { |
| 2713 |
\legacy_if:nT { @inlabel } |
| 2714 |
{ \indent \par } % case of \item\item |
| 2715 |
% \end{macrocode} |
| 2716 |
% \tn{par} may have a strange definition and may not get us back to |
| 2717 |
% vertical mode in one go, so we better do not treat the next line |
| 2718 |
% as an else case to the above conditional (for now). |
| 2719 |
% \begin{macrocode} |
| 2720 |
\mode_if_horizontal:T { \@@_skip_remove_last: |
| 2721 |
\@@_skip_remove_last: \par } |
| 2722 |
% \end{macrocode} |
| 2723 |
% End any LI-tag, then start the next LI-tag (if doing tagging): |
| 2724 |
% \begin{macrocode} |
| 2725 |
\__kernel_list_item_end: |
| 2726 |
\__kernel_list_item_begin: |
| 2727 |
% \end{macrocode} |
| 2728 |
% |
| 2729 |
% \begin{macrocode} |
| 2730 |
\addpenalty \@itempenalty |
| 2731 |
\addvspace \itemsep |
| 2732 |
} |
| 2733 |
% \end{macrocode} |
| 2734 |
% \end{macro} |
| 2735 |
% |
| 2736 |
% |
| 2737 |
% \begin{macro}{\__kernel_list_item_begin:, |
| 2738 |
% \__kernel_list_item_end:} |
| 2739 |
% |
| 2740 |
% \begin{macrocode} |
| 2741 |
\cs_new_eq:NN \__kernel_list_item_begin: \prg_do_nothing: |
| 2742 |
\cs_new_eq:NN \__kernel_list_item_end: \prg_do_nothing: |
| 2743 |
% \end{macrocode} |
| 2744 |
% \end{macro} |
| 2745 |
% |
| 2746 |
% |
| 2747 |
% |
| 2748 |
% |
| 2749 |
% |
| 2750 |
% |
| 2751 |
% \subsection{Tagging support commands} |
| 2752 |
% |
| 2753 |
% In this section we provide code to the various kernel hooks to support |
| 2754 |
% the tagging of different displayblock environments. |
| 2755 |
% |
| 2756 |
% \changes{v0.9g}{2025-07-01}{Define the following command |
| 2757 |
% even if tagging is not active, to allow to activate tagging later} |
| 2758 |
% \changes{v0.9g}{2025-07-01}{Removed para-hook code, it is in tagpdf currently} |
| 2759 |
% |
| 2760 |
% |
| 2761 |
% \begin{macro}{\@@_beginpar_vmode:} |
| 2762 |
% When a block starts out in vertical mode, i.e., is not yet part of |
| 2763 |
% a paragraph, we have to start a paragraph |
| 2764 |
% structure. However, this is not the case if we are already |
| 2765 |
% flattening paragraphs, thus in this case we do nothing. |
| 2766 |
% We also do nothing if \texttt{@endpe} is currently true, because |
| 2767 |
% that means we are right now just after the end of a |
| 2768 |
% \texttt{blockenv} and in the process of looking if we have to end |
| 2769 |
% the current \struct{text-unit}, i.e., it is already open. |
| 2770 |
% |
| 2771 |
% The command is mapped to \cs{__kernel_displayblock_beginpar_vmode} in various |
| 2772 |
% tagging recipes. It is also used in the math code! |
| 2773 |
% \begin{macrocode} |
| 2774 |
\cs_set:Npn \@@_beginpar_vmode: { |
| 2775 |
\@@_debug_typeout:n |
| 2776 |
{ @endpe = \legacy_if:nTF { @endpe }{true}{false} \on@line } |
| 2777 |
\legacy_if:nTF { @endpe } |
| 2778 |
{ |
| 2779 |
\legacy_if_gset_false:n { @endpe } |
| 2780 |
} |
| 2781 |
% \end{macrocode} |
| 2782 |
% We test for \texttt{<2} because the first flattened environment |
| 2783 |
% has to surround itself with a \struct{text-unit}. Only any inner ones |
| 2784 |
% then have to avoid adding another \struct{text-unit}. |
| 2785 |
% \begin{macrocode} |
| 2786 |
{ |
| 2787 |
\int_compare:nNnT \l__tag_block_flattened_level_int < 2 |
| 2788 |
{ |
| 2789 |
% \end{macrocode} |
| 2790 |
% \changes{v0.9k}{2025/07/21}{Use tagging socket for text-unit structure} |
| 2791 |
% \begin{macrocode} |
| 2792 |
\UseTaggingSocket{para/semantic/begin} |
| 2793 |
{ \__tag_para_main_store_struct: } |
| 2794 |
} |
| 2795 |
} |
| 2796 |
} |
| 2797 |
% \end{macrocode} |
| 2798 |
% \end{macro} |
| 2799 |
% |
| 2800 |
% \begin{macro}{\@@_beginpar_hmode:N} |
| 2801 |
% If the block is already part of a part of a paragraph, i.e., when it has |
| 2802 |
% some text directly in front, then the first thing to |
| 2803 |
% do is to return to vertical mode. However, that should be done |
| 2804 |
% without inserting a paragraph end tag, so before calling \tn{par} |
| 2805 |
% to do its normal work, we disable paragraph tagging and |
| 2806 |
% restarting afterwards again. The argument to this config point |
| 2807 |
% simply gobbles the \tn{par} following it in the code above (which |
| 2808 |
% is used when there is no tagging going on. |
| 2809 |
% |
| 2810 |
% The command is mapped to \cs{__kernel_displayblock_beginpar_hmode:w} in various |
| 2811 |
% tagging recipes. |
| 2812 |
% \begin{macrocode} |
| 2813 |
\cs_set:Npn \@@_beginpar_hmode:N #1 |
| 2814 |
{ |
| 2815 |
\tag_mc_end: |
| 2816 |
\__tag_gincr_para_end_int: |
| 2817 |
\@@_debug_typeout:n{increment~ /P \on@line } |
| 2818 |
\bool_if:NT \l__tag_para_show_bool |
| 2819 |
{ \tag_mc_begin:n{artifact} |
| 2820 |
\rlap{\color_select:n{red}\tiny\ \int_use:N\g__tag_para_end_int} |
| 2821 |
\tag_mc_end: |
| 2822 |
} |
| 2823 |
\tag_struct_end: |
| 2824 |
\tagpdfparaOff \par \tagpdfparaOn |
| 2825 |
} |
| 2826 |
% \end{macrocode} |
| 2827 |
% \end{macro} |
| 2828 |
% |
| 2829 |
% Paragraph tagging is mainly done using the paragraph hooks. |
| 2830 |
% The code is in lttagging. |
| 2831 |
% |
| 2832 |
% \begin{socketdecl}{tagsupport/block/startpara/direct} |
| 2833 |
% A tagging socket to start a paragraph structure. It takes an argument (which is only |
| 2834 |
% used in debugging) that should be gobbled if tagging is not active. |
| 2835 |
% Not yet in lttagging (name and function should be reviewed). |
| 2836 |
% |
| 2837 |
% This is a similar code to the one used in the para/begin hook |
| 2838 |
% but without testing \texttt{@endpe}. This is not |
| 2839 |
% needed in the standalone case and wrong inside lists. |
| 2840 |
% |
| 2841 |
% This code is used in various places and should be a dummy if tagging is not |
| 2842 |
% active. |
| 2843 |
|
| 2844 |
% \begin{macrocode} |
| 2845 |
\socket_if_exist:nF {tagsupport/block/startpara/direct} |
| 2846 |
{ |
| 2847 |
\NewTaggingSocket {block/startpara/direct}{1} |
| 2848 |
} |
| 2849 |
% \end{macrocode} |
| 2850 |
% \end{socketdecl} |
| 2851 |
% \begin{plugdecl}{default} |
| 2852 |
% \begin{macrocode} |
| 2853 |
\NewTaggingSocketPlug{block/startpara/direct}{default} |
| 2854 |
{ |
| 2855 |
\bool_if:NF \l__tag_para_flattened_bool |
| 2856 |
{ |
| 2857 |
% \end{macrocode} |
| 2858 |
% \changes{v0.9k}{2025/07/21}{Use tagging socket for text-unit structure} |
| 2859 |
% \begin{macrocode} |
| 2860 |
\UseTaggingSocket{para/semantic/begin} |
| 2861 |
{ \__tag_para_main_store_struct: } |
| 2862 |
} |
| 2863 |
\__tag_gincr_para_begin_int: |
| 2864 |
\@@_debug_typeout:n{increment~ P \on@line } |
| 2865 |
\tag_struct_begin:n |
| 2866 |
{ |
| 2867 |
tag=\l__tag_para_tag_tl |
| 2868 |
,attribute-class=\l__tag_para_attr_class_tl |
| 2869 |
} |
| 2870 |
\__tag_check_para_begin_show:nn {green}{#1} |
| 2871 |
\tag_mc_begin:n {} |
| 2872 |
} |
| 2873 |
\AssignTaggingSocketPlug{block/startpara/direct}{default} |
| 2874 |
% \end{macrocode} |
| 2875 |
% \end{plugdecl} |
| 2876 |
% |
| 2877 |
% The para/end hook code is in lttagging. |
| 2878 |
% Currently we still need to remove the tagpdf chunk |
| 2879 |
% to avoid that the socket is added twice. |
| 2880 |
% We add empty chunks to avoid warning messages from code parts trying to remove |
| 2881 |
% the chunks. |
| 2882 |
% \begin{macrocode} |
| 2883 |
\AddToHook{para/end}[tagpdf]{} |
| 2884 |
\RemoveFromHook{para/end}[tagpdf] |
| 2885 |
\AddToHook{para/end}{} |
| 2886 |
% \end{macrocode} |
| 2887 |
% |
| 2888 |
% \begin{macrocode} |
| 2889 |
\def\PARALABEL{NP-} |
| 2890 |
% \end{macrocode} |
| 2891 |
% |
| 2892 |
% |
| 2893 |
% \begin{socketdecl}{tagsupport/kernel/endpe/vmode} |
| 2894 |
% A tagging socket which ends a structure. Used in \cs{begin} |
| 2895 |
% and \cs{para_end:} |
| 2896 |
% Not yet in lttagging (name and function should be reviewed). |
| 2897 |
% \begin{macrocode} |
| 2898 |
\socket_if_exist:nF {tagsupport/kernel/endpe/vmode} |
| 2899 |
{ |
| 2900 |
\NewTaggingSocket {kernel/endpe/vmode}{0} |
| 2901 |
} |
| 2902 |
% \end{macrocode} |
| 2903 |
% \end{socketdecl} |
| 2904 |
% \begin{plugdecl}{default} |
| 2905 |
% \begin{macrocode} |
| 2906 |
\NewTaggingSocketPlug{kernel/endpe/vmode}{default} |
| 2907 |
{ |
| 2908 |
\if@endpe \ifvmode |
| 2909 |
\bool_if:NT \l__tag_para_bool |
| 2910 |
{ |
| 2911 |
\bool_if:NF \l__tag_para_flattened_bool |
| 2912 |
{ |
| 2913 |
% \end{macrocode} |
| 2914 |
% \changes{v0.9k}{2025/07/21}{Use tagging socket for text-unit structure} |
| 2915 |
% \begin{macrocode} |
| 2916 |
\UseTaggingSocket{para/semantic/end}{} |
| 2917 |
} |
| 2918 |
% \end{macrocode} |
| 2919 |
% \cs{@endpefalse} is needed by \cs{para_end:}, see test tagging-0097. |
| 2920 |
% \begin{macrocode} |
| 2921 |
\@endpefalse |
| 2922 |
} |
| 2923 |
\fi \fi |
| 2924 |
} |
| 2925 |
\AssignTaggingSocketPlug{kernel/endpe/vmode}{default} |
| 2926 |
% \end{macrocode} |
| 2927 |
% \end{plugdecl} |
| 2928 |
% |
| 2929 |
% \begin{macro}{\para_end:} |
| 2930 |
% If we see a \tn{par} in vmode and a \struct{text-unit} is still open |
| 2931 |
% we need to close that. For this we check if a request for |
| 2932 |
% \text{@endpe} was made (but the \tn{par} redefinition got lost |
| 2933 |
% due to (bad?) coding). |
| 2934 |
% \begin{macrocode} |
| 2935 |
\cs_set_protected:Npn \para_end: { |
| 2936 |
\scan_stop: |
| 2937 |
\mode_if_horizontal:TF { |
| 2938 |
\mode_if_inner:F { |
| 2939 |
\tex_unskip:D |
| 2940 |
\hook_use:n{para/end} |
| 2941 |
\@kernel@after@para@end |
| 2942 |
\mode_if_horizontal:TF { |
| 2943 |
\if_int_compare:w 11 = \tex_lastnodetype:D |
| 2944 |
\tex_hskip:D \c_zero_dim |
| 2945 |
\fi: |
| 2946 |
\tex_par:D |
| 2947 |
\hook_use:n{para/after} |
| 2948 |
\@kernel@after@para@after |
| 2949 |
} |
| 2950 |
{ \msg_error:nnnn { hooks }{ para-mode }{end}{horizontal} } |
| 2951 |
} |
| 2952 |
} |
| 2953 |
{ |
| 2954 |
% \end{macrocode} |
| 2955 |
% TODO 2025-07-01. This is not exactly as before, this doesn't insert an \cs{\@endpefalse} |
| 2956 |
% when tagging is active. Check if this a problem. |
| 2957 |
% \begin{macrocode} |
| 2958 |
\UseTaggingSocket{kernel/endpe/vmode}% |
| 2959 |
\tex_par:D |
| 2960 |
} |
| 2961 |
} |
| 2962 |
% \end{macrocode} |
| 2963 |
% Now reset \LaTeXe{} functions to use the changed \cs{para_end:} |
| 2964 |
% \changes{v0.9j}{2025/07/19}{Use \texttt{@@@@} to obtain 2; found by |
| 2965 |
% explcheck analysis} |
| 2966 |
% \TODO{Need to check if \cs{@@@@par} is ever used in a way that the |
| 2967 |
% vmodetagging hook is needed.} |
| 2968 |
% \begin{macrocode} |
| 2969 |
\cs_set_eq:NN \par \para_end: |
| 2970 |
\cs_set_eq:NN \@@@@par \para_end: |
| 2971 |
\cs_set_eq:NN \endgraf \para_end: |
| 2972 |
% \end{macrocode} |
| 2973 |
% |
| 2974 |
% \end{macro} |
| 2975 |
% |
| 2976 |
% |
| 2977 |
% \begin{macro}{\begin} |
| 2978 |
% We need to do a little more than canceling \texttt{@endpe} now. |
| 2979 |
% \begin{macrocode} |
| 2980 |
\protected\def\begin#1{% |
| 2981 |
\UseHook{env/#1/before}% |
| 2982 |
\@ifundefined{#1}% |
| 2983 |
{\def\reserved@a{\@latex@error{Environment~#1~undefined}\@eha}}% |
| 2984 |
{\def\reserved@a{\def\@currenvir{#1}% |
| 2985 |
\edef\@currenvline{\on@line}% |
| 2986 |
\@execute@begin@hook{#1}% |
| 2987 |
\csname #1\endcsname}}% |
| 2988 |
\@ignorefalse |
| 2989 |
\begingroup |
| 2990 |
\UseTaggingSocket{kernel/endpe/vmode}% |
| 2991 |
\reserved@a} |
| 2992 |
% \end{macrocode} |
| 2993 |
% \end{macro} |
| 2994 |
% |
| 2995 |
% |
| 2996 |
|
| 2997 |
% |
| 2998 |
% \begin{macro}{\__kernel_list_label_after:} |
| 2999 |
% If starting the text-unit/text tags got delayed because of a pending label we |
| 3000 |
% have to do it after the label got typeset. |
| 3001 |
% TODO: it should do nothing without tagging that's why there is a test, |
| 3002 |
% this should be better hidden in a tagging socket, but it is not quite clear |
| 3003 |
% how to do this. |
| 3004 |
% \begin{macrocode} |
| 3005 |
\cs_new:Npn \__kernel_list_label_after: { |
| 3006 |
\bool_lazy_and:nnT { \tag_if_active_p: } {\l__tag_para_bool } |
| 3007 |
{ |
| 3008 |
\tag_socket_use:nn {block/startpara/direct} { LI- } |
| 3009 |
} |
| 3010 |
} |
| 3011 |
% \end{macrocode} |
| 3012 |
% \end{macro} |
| 3013 |
% |
| 3014 |
% |
| 3015 |
% \begin{macro}{\@@_inner_begin:} |
| 3016 |
% Start a block that has an inner structure if it isn't also a list. |
| 3017 |
% This command is tagging specific, it is mapped to \cs{__kernel_displayblock_begin:} |
| 3018 |
% in some tagging recipes. |
| 3019 |
% \begin{macrocode} |
| 3020 |
\cs_new:Npn \@@_inner_begin: { |
| 3021 |
\tagstructbegin{tag=\l_@@_tag_inner_tag_tl} |
| 3022 |
} |
| 3023 |
% \end{macrocode} |
| 3024 |
% \end{macro} |
| 3025 |
% |
| 3026 |
% |
| 3027 |
% \begin{macro}{\@@_inner_end:} |
| 3028 |
% End a block (which isn't also a list). |
| 3029 |
% This command is tagging specific, it is mapped to \cs{__kernel_displayblock_end:} |
| 3030 |
% in some tagging recipes. |
| 3031 |
% \begin{macrocode} |
| 3032 |
\cs_new:Npn \@@_inner_end: { |
| 3033 |
\@@_debug_typeout:n{block-end \on@line} |
| 3034 |
\legacy_if:nT { @endpe } |
| 3035 |
{ |
| 3036 |
\UseTaggingSocket{para/semantic/end} |
| 3037 |
{ \@@_debug_typeout:n{close~ /text-unit \on@line}} |
| 3038 |
} |
| 3039 |
\tagstructend % end inner structure |
| 3040 |
} |
| 3041 |
% \end{macrocode} |
| 3042 |
% \end{macro} |
| 3043 |
% |
| 3044 |
% |
| 3045 |
% |
| 3046 |
% |
| 3047 |
% |
| 3048 |
% |
| 3049 |
% \subsubsection{List tags} |
| 3050 |
% |
| 3051 |
% |
| 3052 |
% \begin{macrocode} |
| 3053 |
\tl_new:N \l__tag_L_tag_tl |
| 3054 |
\tl_set:Nn \l__tag_L_tag_tl {L} |
| 3055 |
|
| 3056 |
\tl_new:N\l__tag_L_attr_class_tl |
| 3057 |
\tl_set:Nn \l__tag_L_attr_class_tl {list} |
| 3058 |
% \end{macrocode} |
| 3059 |
% |
| 3060 |
% \begin{macrocode} |
| 3061 |
\tagpdfsetup |
| 3062 |
{ |
| 3063 |
role/new-attribute = {itemize} |
| 3064 |
{/O /List /ListNumbering/Unordered}, |
| 3065 |
role/new-attribute = {enumerate} |
| 3066 |
{/O /List /ListNumbering/Ordered}, |
| 3067 |
role/new-attribute = {description} |
| 3068 |
{/O /List /ListNumbering/Description}, |
| 3069 |
% \end{macrocode} |
| 3070 |
% Initially, we had \texttt{/None} for the basic \env{list} |
| 3071 |
% environment, but that is not allowed in PDF/UA-2 if the list |
| 3072 |
% contains any Lbl tags. So now we default to |
| 3073 |
% \texttt{Unordered}. |
| 3074 |
% \begin{macrocode} |
| 3075 |
role/new-attribute = {list}{/O /List /ListNumbering/Unordered}, |
| 3076 |
} |
| 3077 |
% \end{macrocode} |
| 3078 |
% |
| 3079 |
% \begin{macrocode} |
| 3080 |
\def\LItag{LI} |
| 3081 |
% \end{macrocode} |
| 3082 |
% |
| 3083 |
% \begin{macro}{\@@_list_begin:} |
| 3084 |
% Start a list \ldots |
| 3085 |
% This command is tagging specific, it is mapped to \cs{__kernel_displayblock_begin:} |
| 3086 |
% in a tagging recipe. |
| 3087 |
% \begin{macrocode} |
| 3088 |
\cs_set:Npn \@@_list_begin: { |
| 3089 |
\tagstructbegin |
| 3090 |
{ |
| 3091 |
tag=\l__tag_L_tag_tl |
| 3092 |
,attribute-class=\l__tag_L_attr_class_tl |
| 3093 |
} |
| 3094 |
} |
| 3095 |
% \end{macrocode} |
| 3096 |
% \end{macro} |
| 3097 |
% |
| 3098 |
% \begin{macro}{\@@_list_item_begin:} |
| 3099 |
% Start tagging a list item. |
| 3100 |
% This command is tagging specific, it is mapped to \cs{__kernel_list_item_begin:} |
| 3101 |
% in a tagging recipe. |
| 3102 |
% \begin{macrocode} |
| 3103 |
\cs_set:Npn \@@_list_item_begin: { \tagstructbegin{tag=\LItag} } |
| 3104 |
% \end{macrocode} |
| 3105 |
% \end{macro} |
| 3106 |
% |
| 3107 |
% |
| 3108 |
% |
| 3109 |
% |
| 3110 |
% |
| 3111 |
% \begin{macro}{\@@_list_item_end:} |
| 3112 |
% When a list item ends we have to close \struct{LBody} and |
| 3113 |
% \struct{LI} but also a \struct{text} in the special case that the |
| 3114 |
% item material ends in a list (identifiable via \texttt{@endpe}). |
| 3115 |
% This command is tagging specific. |
| 3116 |
% This command is copied to \cs{__kernel_list_item_end:} in the list recipe. |
| 3117 |
% \begin{macrocode} |
| 3118 |
\cs_set:Npn \@@_list_item_end: { |
| 3119 |
\legacy_if:nT { @endpe } |
| 3120 |
{ |
| 3121 |
% \end{macrocode} |
| 3122 |
% \changes{v0.9k}{2025/07/21}{Use tagging socket for text-unit structure} |
| 3123 |
% \begin{macrocode} |
| 3124 |
\UseTaggingSocket{para/semantic/end}{} |
| 3125 |
% \@@_debug_typeout:n{Structure-end~ P~ at~ item-end \on@line } |
| 3126 |
} |
| 3127 |
\tagstructend \tagstructend % end LBody, LI |
| 3128 |
} |
| 3129 |
% \end{macrocode} |
| 3130 |
% \end{macro} |
| 3131 |
% |
| 3132 |
% |
| 3133 |
% |
| 3134 |
% \begin{macro}{\@@_list_end:} |
| 3135 |
% Finally, at the list end we have to close the open |
| 3136 |
% \struct{LBody}, \struct{LI}, \struct{L}, and possibly a |
| 3137 |
% \struct{text} if the last item ends with a list. |
| 3138 |
% However, if the user forgot to add an \tn{item} then there will be no |
| 3139 |
% \struct{LI} and \struct{LBody} open, so we check for the status |
| 3140 |
% of \texttt{@newlist}. The corresponding no-item error was |
| 3141 |
% generated earlier outside the tagging code. |
| 3142 |
% |
| 3143 |
% One could argue that it doesn't matter if the tagging is wrong |
| 3144 |
% after a \tn{@noitemerr} was issued. However, there is one case |
| 3145 |
% where it isn't an error: In the \env{thebibliography} |
| 3146 |
% environment (which is internally a list) it is often the case |
| 3147 |
% that documents start out with an empty environment, not |
| 3148 |
% containing any \tn{bibitem}s. For that reason \tn{@noitemerr} is |
| 3149 |
% redefined inside that environment to only produce a warning; |
| 3150 |
% hence we have to produce correct tag structures in that case. |
| 3151 |
% \changes{v0.8q}{2024/09/02}{Do not close LI and LBody if they |
| 3152 |
% never were opened.} |
| 3153 |
% This command is tagging specific. |
| 3154 |
% This command is copied to \cs{__kernel_displayblock_end:} in the list recipe. |
| 3155 |
% \begin{macrocode} |
| 3156 |
\cs_new:Npn \@@_list_end: { |
| 3157 |
% \end{macrocode} |
| 3158 |
% If \texttt{@newlist} is true (i.e., when we have an error or warning |
| 3159 |
% situation) there is not much to close. |
| 3160 |
% \begin{macrocode} |
| 3161 |
\legacy_if:nF { @newlist } |
| 3162 |
{ |
| 3163 |
\legacy_if:nT { @endpe } |
| 3164 |
{ |
| 3165 |
% \end{macrocode} |
| 3166 |
% \changes{v0.9k}{2025/07/21}{Use tagging socket for text-unit structure} |
| 3167 |
% \begin{macrocode} |
| 3168 |
\UseTaggingSocket{para/semantic/end} |
| 3169 |
{\@@_debug_typeout:n{Structure-end~ text-unit~ at~ list-end \on@line }} |
| 3170 |
} |
| 3171 |
\tagstructend\tagstructend % end LBody, LI |
| 3172 |
} |
| 3173 |
\tagstructend % end L |
| 3174 |
} |
| 3175 |
% \end{macrocode} |
| 3176 |
% \end{macro} |
| 3177 |
% End of tagging related declarations. |
| 3178 |
% |
| 3179 |
% |
| 3180 |
% \subsection{Tagging recipes} |
| 3181 |
% \changes{v0.9g}{2025-07-01}{a tagging socket for recipe} |
| 3182 |
% \begin{socketdecl}{tagsupport/block/recipe} |
| 3183 |
% A tagging socket to call the tagging recipe. |
| 3184 |
% Declared in lttagging. |
| 3185 |
% \begin{macrocode} |
| 3186 |
\socket_if_exist:nF {tagsupport/block/recipe} |
| 3187 |
{ |
| 3188 |
\NewTaggingSocket{block/recipe}{1} |
| 3189 |
} |
| 3190 |
% \end{macrocode} |
| 3191 |
% \end{socketdecl} |
| 3192 |
% \begin{plugdecl}{default} |
| 3193 |
% \begin{macrocode} |
| 3194 |
\NewTaggingSocketPlug{block/recipe}{default} |
| 3195 |
{ |
| 3196 |
\use:c { @@_recipe_#1: } |
| 3197 |
} |
| 3198 |
\AssignTaggingSocketPlug{block/recipe}{default} |
| 3199 |
% \end{macrocode} |
| 3200 |
% \end{plugdecl} |
| 3201 |
% |
| 3202 |
% \begin{macro}{\@@_recipe_basic:} |
| 3203 |
% The \keyvalue{basic} recipe simply ensures that the block is inside |
| 3204 |
% a \struct{text-unit} structure and if necessary starts one. When the |
| 3205 |
% block ends and is followed by a blank line the \struct{text-unit} |
| 3206 |
% structure is closed too, otherwise it remains open and further |
| 3207 |
% text starts with just a \struct{text} structure. |
| 3208 |
% |
| 3209 |
% There is otherwise no inner structure so |
| 3210 |
% \cs{__kernel_displayblock_begin:} and |
| 3211 |
% \cs{__kernel_displayblock_end:} do nothing---blockenvs with inner |
| 3212 |
% structure use the \keyvalue{standard} or \keyvalue{list} recipe instead. |
| 3213 |
% \begin{macrocode} |
| 3214 |
\cs_new:Npn \@@_recipe_basic: { |
| 3215 |
\cs_set_eq:NN \__kernel_displayblock_beginpar_hmode:w |
| 3216 |
\@@_beginpar_hmode:N |
| 3217 |
\cs_set_eq:NN \__kernel_displayblock_beginpar_vmode: |
| 3218 |
\@@_beginpar_vmode: |
| 3219 |
\let \__kernel_displayblock_begin: \prg_do_nothing: |
| 3220 |
\let \__kernel_displayblock_end: \prg_do_nothing: |
| 3221 |
% \end{macrocode} |
| 3222 |
% End environment \tn{par} handling: |
| 3223 |
% \begin{macrocode} |
| 3224 |
\socket_assign_plug:nn{block/endpe}{on} |
| 3225 |
} |
| 3226 |
% \end{macrocode} |
| 3227 |
% \end{macro} |
| 3228 |
% |
| 3229 |
% \begin{macro}{\@@_recipe_standalone:} |
| 3230 |
% |
| 3231 |
% The \keyvalue{standalone} recipe produces a block that ensures that |
| 3232 |
% a previous \struct{text-unit} ends and that after the block a new |
| 3233 |
% \struct{text-unit} starts. |
| 3234 |
% \begin{macrocode} |
| 3235 |
\cs_new:Npn \@@_recipe_standalone: { |
| 3236 |
\cs_set_eq:NN \__kernel_displayblock_beginpar_hmode:w |
| 3237 |
\prg_do_nothing: |
| 3238 |
\cs_set_eq:NN \__kernel_displayblock_beginpar_vmode: |
| 3239 |
\prg_do_nothing: |
| 3240 |
\cs_set_eq:NN \__kernel_displayblock_begin: \@@_inner_begin: |
| 3241 |
\cs_set_eq:NN \__kernel_displayblock_end: \@@_inner_end: |
| 3242 |
% \end{macrocode} |
| 3243 |
% End environment \tn{par} handling: |
| 3244 |
% \begin{macrocode} |
| 3245 |
\socket_assign_plug:nn{block/endpe}{off} |
| 3246 |
% \end{macrocode} |
| 3247 |
% |
| 3248 |
% \begin{macrocode} |
| 3249 |
\tl_if_empty:NTF \l_@@_tag_name_tl |
| 3250 |
{ \tl_set:Nn \l_@@_tag_inner_tag_tl {Sect} } |
| 3251 |
{ \tl_set_eq:NN \l_@@_tag_inner_tag_tl \l_@@_tag_name_tl } |
| 3252 |
} |
| 3253 |
% \end{macrocode} |
| 3254 |
% \end{macro} |
| 3255 |
% |
| 3256 |
% \begin{macro}{\@@_recipe_standard:} |
| 3257 |
% The \keyvalue{standard} recipe does the following: |
| 3258 |
% \begin{itemize} |
| 3259 |
% \item surround the block with a \struct{text-unit} structure if not already in a |
| 3260 |
% a \struct{text-unit}. In the latter case end the |
| 3261 |
% MC and the \struct{text} but leave the \struct{text-unit} open. |
| 3262 |
% |
| 3263 |
% If we are producing flattened paragraphs, just close any |
| 3264 |
% \struct{text} but do not open a \struct{text-unit}. |
| 3265 |
% |
| 3266 |
% \item Then open an new (inner) structure (by default |
| 3267 |
% \struct{Div} but typically the one specified on the instance). |
| 3268 |
% \item At the end of the block close the inner structure |
| 3269 |
% (\struct{Div} or explicit one) |
| 3270 |
% but leave the \struct{text-unit} open to be either continued or closed due to a |
| 3271 |
% following \tn{par}. |
| 3272 |
% \end{itemize} |
| 3273 |
% \begin{macrocode} |
| 3274 |
\cs_new:Npn \@@_recipe_standard: |
| 3275 |
{ |
| 3276 |
\cs_set_eq:NN \__kernel_displayblock_beginpar_hmode:w |
| 3277 |
\@@_beginpar_hmode:N |
| 3278 |
\cs_set_eq:NN \__kernel_displayblock_beginpar_vmode: |
| 3279 |
\@@_beginpar_vmode: |
| 3280 |
\cs_set_eq:NN \__kernel_displayblock_begin: \@@_inner_begin: |
| 3281 |
\cs_set_eq:NN \__kernel_displayblock_end: \@@_inner_end: |
| 3282 |
% \end{macrocode} |
| 3283 |
% End environment \tn{par} handling: |
| 3284 |
% \begin{macrocode} |
| 3285 |
\socket_assign_plug:nn{block/endpe}{on} |
| 3286 |
% \end{macrocode} |
| 3287 |
% |
| 3288 |
% \changes{v0.9g}{2025/06/30}{ (tagging/925)} |
| 3289 |
% \begin{macrocode} |
| 3290 |
\tl_if_empty:NTF \l_@@_tag_name_tl |
| 3291 |
{ \tl_set:Nn \l_@@_tag_inner_tag_tl {Div} } |
| 3292 |
{ \tl_set_eq:NN \l_@@_tag_inner_tag_tl \l_@@_tag_name_tl } |
| 3293 |
} |
| 3294 |
% \end{macrocode} |
| 3295 |
% \end{macro} |
| 3296 |
% |
| 3297 |
% |
| 3298 |
% |
| 3299 |
% \begin{macro}{\l_@@_tag_inner_tag_tl} |
| 3300 |
% The tag name that is used if the block has an inner structure. |
| 3301 |
% \begin{macrocode} |
| 3302 |
\tl_new:N \l_@@_tag_inner_tag_tl |
| 3303 |
% \end{macrocode} |
| 3304 |
% \end{macro} |
| 3305 |
% |
| 3306 |
% |
| 3307 |
% |
| 3308 |
% \begin{macro}{\@@_recipe_list:} |
| 3309 |
% The \keyvalue{list} recipe does the following. |
| 3310 |
% \begin{itemize} |
| 3311 |
% \item It opens a \struct{text-unit}-structure or keeps the current one open (only |
| 3312 |
% closing the MC). |
| 3313 |
% \item It then starts a new structure rolemapped to L-structure |
| 3314 |
% and arranges for handling list items, e.g., Li, Lbl and LBody |
| 3315 |
% structures. |
| 3316 |
% \item At the end it closes open list structures as needed but |
| 3317 |
% keeps the \struct{text-unit}-structure open to continue the paragraph after the |
| 3318 |
% list, if necessary. |
| 3319 |
% \end{itemize} |
| 3320 |
% \begin{macrocode} |
| 3321 |
\cs_new:Npn \@@_recipe_list: |
| 3322 |
{ |
| 3323 |
\cs_set_eq:NN \__kernel_displayblock_beginpar_hmode:w |
| 3324 |
\@@_beginpar_hmode:N |
| 3325 |
\cs_set_eq:NN \__kernel_displayblock_beginpar_vmode: |
| 3326 |
\@@_beginpar_vmode: |
| 3327 |
\cs_set_eq:NN \__kernel_displayblock_begin: \@@_list_begin: |
| 3328 |
\cs_set_eq:NN \__kernel_displayblock_end: \@@_list_end: |
| 3329 |
% \end{macrocode} |
| 3330 |
% The next two lines could be done globally, because they are only |
| 3331 |
% called if we do have \tn{item}s, i.e., if we are in a list. It is |
| 3332 |
% therefore also not necessary to reset them in other recipes |
| 3333 |
% (right now---this may change if we get more templates (like |
| 3334 |
% inline lists)). |
| 3335 |
% \begin{macrocode} |
| 3336 |
\cs_set_eq:NN \__kernel_list_item_begin: \@@_list_item_begin: |
| 3337 |
\cs_set_eq:NN \__kernel_list_item_end: \@@_list_item_end: |
| 3338 |
% \end{macrocode} |
| 3339 |
% End environment \tn{par} handling: |
| 3340 |
% \begin{macrocode} |
| 3341 |
\socket_assign_plug:nn{block/endpe}{on} |
| 3342 |
% \end{macrocode} |
| 3343 |
% |
| 3344 |
% Handle the tag name and attribute classes using the key values |
| 3345 |
% from the current list instance. |
| 3346 |
% \begin{macrocode} |
| 3347 |
\tl_if_empty:NTF \l_@@_tag_name_tl |
| 3348 |
{ \tl_set:Nn \l__tag_L_tag_tl {L} } |
| 3349 |
{ \tl_set_eq:NN \l__tag_L_tag_tl \l_@@_tag_name_tl } |
| 3350 |
\tl_if_empty:NTF \l_@@_tag_class_tl |
| 3351 |
{ \tl_set:Nn \l__tag_L_attr_class_tl {} } |
| 3352 |
{ \tl_set_eq:NN \l__tag_L_attr_class_tl \l_@@_tag_class_tl } |
| 3353 |
} |
| 3354 |
% \end{macrocode} |
| 3355 |
% \end{macro} |
| 3356 |
% |
| 3357 |
% |
| 3358 |
% |
| 3359 |
% |
| 3360 |
% \section[Implementation of document-level block environments] |
| 3361 |
% {Implementation of document-level block\\ environments} |
| 3362 |
% |
| 3363 |
% Most such environments are pretty simple: they take an optional |
| 3364 |
% argument and call a \texttt{blockenv} instance to do the work. At |
| 3365 |
% the end of environment we call \tn{endblockenv} to finish. |
| 3366 |
% |
| 3367 |
% |
| 3368 |
% \subsection{Displayblock environments} |
| 3369 |
% |
| 3370 |
% |
| 3371 |
% There are two basic block environment which are similar to |
| 3372 |
% \LaTeXe{}'s \env{trivlist} except that there aren't degenerated |
| 3373 |
% lists and thus have no hidden \tn{item} inside. |
| 3374 |
% |
| 3375 |
% |
| 3376 |
% \begin{environment}{displayblock} |
| 3377 |
% |
| 3378 |
% \begin{macrocode} |
| 3379 |
\NewDocumentEnvironment{displayblock}{ !O{} } |
| 3380 |
{ \UseInstance{blockenv}{displayblock} {#1} } |
| 3381 |
{ \endblockenv } |
| 3382 |
% \end{macrocode} |
| 3383 |
% \end{environment} |
| 3384 |
% |
| 3385 |
% |
| 3386 |
% \begin{environment}{displayblockflattened} |
| 3387 |
% |
| 3388 |
% \begin{macrocode} |
| 3389 |
\NewDocumentEnvironment{displayblockflattened}{ !O{} } |
| 3390 |
{ \UseInstance{blockenv}{displayblockflattened} {#1} } |
| 3391 |
{ \endblockenv } |
| 3392 |
% \end{macrocode} |
| 3393 |
% \end{environment} |
| 3394 |
% |
| 3395 |
% |
| 3396 |
% |
| 3397 |
% |
| 3398 |
% \subsection{The \env{center}, \env{flushleft}, and \env{flushright} environments} |
| 3399 |
% |
| 3400 |
% |
| 3401 |
% For now we redeclare various document environments as late as |
| 3402 |
% possible in order to make tagging work, even if classes have changed |
| 3403 |
% the definitions. Of course this means that such changes get lost. |
| 3404 |
% \begin{macrocode} |
| 3405 |
\AddToHook{begindocument/before}{ |
| 3406 |
% \end{macrocode} |
| 3407 |
% |
| 3408 |
% \begin{environment}{center,flushleft,flushright} |
| 3409 |
% |
| 3410 |
% \begin{macrocode} |
| 3411 |
\RenewDocumentEnvironment{center} { !O{} } |
| 3412 |
{ \UseInstance{blockenv}{center}{#1} } |
| 3413 |
{ \endblockenv } |
| 3414 |
% \end{macrocode} |
| 3415 |
% |
| 3416 |
% \begin{macrocode} |
| 3417 |
\RenewDocumentEnvironment{flushright} { !O{} } |
| 3418 |
{ \UseInstance{blockenv}{flushright}{#1} } |
| 3419 |
{ \endblockenv } |
| 3420 |
% \end{macrocode} |
| 3421 |
% |
| 3422 |
% \begin{macrocode} |
| 3423 |
\RenewDocumentEnvironment{flushleft} { !O{} } |
| 3424 |
{ \UseInstance{blockenv}{flushleft}{#1} } |
| 3425 |
{ \endblockenv } |
| 3426 |
} |
| 3427 |
% \end{macrocode} |
| 3428 |
% \end{environment} |
| 3429 |
% |
| 3430 |
% |
| 3431 |
% |
| 3432 |
% \subsection{Display quote environments} |
| 3433 |
% |
| 3434 |
% |
| 3435 |
% \begin{environment}{quote,quotation} |
| 3436 |
% |
| 3437 |
% \begin{macrocode} |
| 3438 |
\AddToHook{begindocument/before}{ |
| 3439 |
\RenewDocumentEnvironment{quote}{ !O{} } |
| 3440 |
{ \UseInstance{blockenv}{quote} {#1} } |
| 3441 |
{ \endblockenv } |
| 3442 |
% \end{macrocode} |
| 3443 |
% |
| 3444 |
% \begin{macrocode} |
| 3445 |
\RenewDocumentEnvironment{quotation}{ !O{} } |
| 3446 |
{ \UseInstance{blockenv}{quotation} {#1} } |
| 3447 |
{ \endblockenv } |
| 3448 |
} |
| 3449 |
% \end{macrocode} |
| 3450 |
% \end{environment} |
| 3451 |
% |
| 3452 |
% |
| 3453 |
% |
| 3454 |
% |
| 3455 |
% |
| 3456 |
% |
| 3457 |
% \subsection{Verbatim environments} |
| 3458 |
% |
| 3459 |
% |
| 3460 |
% \begin{environment}{verbatim,verbatim*} |
| 3461 |
% |
| 3462 |
% \changes{v0.9f}{2025/06/21}{Move special verbatim code into a key} |
| 3463 |
% \begin{macrocode} |
| 3464 |
\AddToHook{begindocument/before}{ |
| 3465 |
\RenewDocumentEnvironment{verbatim}{ !O{} } |
| 3466 |
{ \UseInstance{blockenv}{verbatim} {#1} } |
| 3467 |
{ \endblockenv } |
| 3468 |
% \end{macrocode} |
| 3469 |
% |
| 3470 |
% \changes{v0.9f}{2025/06/21}{Use separate blockenv instances for |
| 3471 |
% verbatim and verbatim*} |
| 3472 |
% \begin{macrocode} |
| 3473 |
\RenewDocumentEnvironment{verbatim*}{ !O{} } |
| 3474 |
{ \UseInstance{blockenv}{verbatim*} {#1} } |
| 3475 |
{ \endblockenv } |
| 3476 |
} |
| 3477 |
% \end{macrocode} |
| 3478 |
% \end{environment} |
| 3479 |
% |
| 3480 |
% |
| 3481 |
% |
| 3482 |
% \subsubsection{Helper commands for verbatim} |
| 3483 |
% |
| 3484 |
% |
| 3485 |
% \begin{macro}{\legacyverbatimsetup} |
| 3486 |
% |
| 3487 |
% This code resembles the \LaTeXe{} verbatim implementation with a |
| 3488 |
% slight twist: in \LaTeXe{} each code line was a paragraph using |
| 3489 |
% \tn{leftskip}=\tn{@totalleftmargin}. This was possible because |
| 3490 |
% the whole environment was implemented as a trivlist. As this is |
| 3491 |
% no longer the case setting \tn{leftskip} would alter the layout |
| 3492 |
% of a surrounding list. So instead we need to make sure that the |
| 3493 |
% paragraph end is executed in a group so that any parshape setup |
| 3494 |
% is preserved. |
| 3495 |
% \changes{v0.8x}{2025/01/12}{flattened para inside verbatim using codeline tag} |
| 3496 |
% \begin{macrocode} |
| 3497 |
%<@@=> |
| 3498 |
\def\legacyverbatimsetup{% |
| 3499 |
\language\l@nohyphenation |
| 3500 |
\@tempswafalse |
| 3501 |
\def\par{% |
| 3502 |
\if@tempswa |
| 3503 |
\leavevmode \null {\@@par}\penalty\interlinepenalty |
| 3504 |
\else |
| 3505 |
\@tempswatrue |
| 3506 |
\ifhmode{\@@par}\penalty\interlinepenalty\fi |
| 3507 |
\fi}% |
| 3508 |
\let\do\@makeother \dospecials |
| 3509 |
\obeylines \verbatim@font \@noligs |
| 3510 |
\everypar \expandafter{\the\everypar \unpenalty}% |
| 3511 |
% \end{macrocode} |
| 3512 |
% |
| 3513 |
% \begin{macrocode} |
| 3514 |
\frenchspacing |
| 3515 |
% \end{macrocode} |
| 3516 |
% \fmi{next should be a socket} |
| 3517 |
% \begin{macrocode} |
| 3518 |
\tl_set:Nn \l__tag_para_tag_tl {codeline} |
| 3519 |
} |
| 3520 |
%<@@=block> |
| 3521 |
% \end{macrocode} |
| 3522 |
% \end{macro} |
| 3523 |
% |
| 3524 |
% |
| 3525 |
% \begin{macro}{\@setupverbinvisiblespace} |
| 3526 |
% In the \pdfTeX{} engine we need to use \tn{pdffakespace} chars |
| 3527 |
% for the invisible spaces. In luatex we do not want this as it would lead to |
| 3528 |
% doubling the number of real space chars. In dvi-mode we do not want that either: |
| 3529 |
% with pdftex it would error, with xetex it does nothing. |
| 3530 |
% \changes{v0.9g}{2025-07-01}{changed logic} |
| 3531 |
% \begin{macrocode} |
| 3532 |
\newcommand\@setupverbinvisiblespace{} |
| 3533 |
\bool_lazy_or:nnF |
| 3534 |
{ \sys_if_engine_luatex_p: } |
| 3535 |
{ \sys_if_output_dvi_p: } |
| 3536 |
{ |
| 3537 |
\renewcommand\@setupverbinvisiblespace |
| 3538 |
{\def\@xobeysp{\nobreakspace\pdffakespace}} |
| 3539 |
} |
| 3540 |
% \end{macrocode} |
| 3541 |
% \end{macro} |
| 3542 |
% |
| 3543 |
% |
| 3544 |
% \subsection{Standard list environments} |
| 3545 |
% |
| 3546 |
% |
| 3547 |
% \begin{environment}{itemize,enumerate,description} |
| 3548 |
% |
| 3549 |
% For the standard lists everything is managed by the blockenv instance. |
| 3550 |
% \begin{macrocode} |
| 3551 |
\AddToHook{begindocument/before}{ |
| 3552 |
\RenewDocumentEnvironment{itemize}{!O{}} |
| 3553 |
{ \UseInstance{blockenv}{itemize} {#1} } |
| 3554 |
{ \endblockenv } |
| 3555 |
% \end{macrocode} |
| 3556 |
% |
| 3557 |
% \begin{macrocode} |
| 3558 |
\RenewDocumentEnvironment{enumerate}{!O{}} |
| 3559 |
{ \UseInstance{blockenv}{enumerate} {#1} } |
| 3560 |
{ \endblockenv } |
| 3561 |
% \end{macrocode} |
| 3562 |
% |
| 3563 |
% \begin{macrocode} |
| 3564 |
\RenewDocumentEnvironment{description}{!O{}} |
| 3565 |
{ \UseInstance{blockenv}{description} {#1} } |
| 3566 |
{ \endblockenv } |
| 3567 |
} |
| 3568 |
% \end{macrocode} |
| 3569 |
% \end{environment} |
| 3570 |
% |
| 3571 |
% |
| 3572 |
% \subsection{verse environment} |
| 3573 |
% |
| 3574 |
% \begin{environment}{verse} |
| 3575 |
% The verse environment has not special tagging currently. It is |
| 3576 |
% defined as a simple standard list and takes the tagging from there. |
| 3577 |
% But it must be redefined so that \tn{itemindent} is correctly set. |
| 3578 |
% \begin{macrocode} |
| 3579 |
\AddToHook{begindocument/before}{ |
| 3580 |
\RenewDocumentEnvironment{verse}{ !O{} } |
| 3581 |
{ |
| 3582 |
\let\\\@centercr |
| 3583 |
\UseInstance{blockenv}{list} |
| 3584 |
{ |
| 3585 |
item-indent=-1.5em, |
| 3586 |
para-indent=-1.5em, |
| 3587 |
item-vspace=0pt, |
| 3588 |
right-margin = \leftmargin, |
| 3589 |
left-margin = \leftmargin+1.5em, |
| 3590 |
#1 |
| 3591 |
} |
| 3592 |
\item\relax |
| 3593 |
} |
| 3594 |
{ \endblockenv } |
| 3595 |
} |
| 3596 |
% \end{macrocode} |
| 3597 |
% \end{environment} |
| 3598 |
% |
| 3599 |
% |
| 3600 |
% \begin{environment}{list} |
| 3601 |
% |
| 3602 |
% The legacy 2e list environment is more complicated as we have to get the |
| 3603 |
% extra arguments accounted for. |
| 3604 |
% \begin{macrocode} |
| 3605 |
\AddToHook{begindocument/before}{ |
| 3606 |
\RenewDocumentEnvironment{list}{O{} m m } |
| 3607 |
{ |
| 3608 |
% \end{macrocode} |
| 3609 |
% We do this by storing them away and then call the list |
| 3610 |
% instance. Inside this instance the \key{setup-code} key |
| 3611 |
% contains \tn{legacylistsetupcode}, which makes use of the stored values. |
| 3612 |
% \changes{v0.8v}{2024/10/11}{Update \tn{@itemlabel} in |
| 3613 |
% \cs{l_@@_legacy_env_params_tl} and not at the start of the |
| 3614 |
% environment (tagging/730)} |
| 3615 |
% \begin{macrocode} |
| 3616 |
\tl_set:Nn \l_@@_legacy_env_params_tl |
| 3617 |
{ |
| 3618 |
\tl_set:Nn \@itemlabel {#2} |
| 3619 |
#3 |
| 3620 |
} |
| 3621 |
% \end{macrocode} |
| 3622 |
% |
| 3623 |
% \begin{macrocode} |
| 3624 |
\UseInstance{blockenv}{list} {#1} |
| 3625 |
} |
| 3626 |
{ \endblockenv } |
| 3627 |
} |
| 3628 |
% \end{macrocode} |
| 3629 |
% |
| 3630 |
% \end{environment} |
| 3631 |
% |
| 3632 |
% |
| 3633 |
% |
| 3634 |
% \begin{macro}{\legacylistsetupcode} |
| 3635 |
% |
| 3636 |
% And here is the extra code for use in the list instance setup |
| 3637 |
% inside the key \key{setup-code}. |
| 3638 |
% \begin{macrocode} |
| 3639 |
\cs_new:Npn \legacylistsetupcode { |
| 3640 |
% \end{macrocode} |
| 3641 |
% Reset values to defaults: |
| 3642 |
% \begin{macrocode} |
| 3643 |
\dim_zero:N \listparindent |
| 3644 |
\dim_zero:N \rightmargin |
| 3645 |
\dim_zero:N \itemindent |
| 3646 |
% \end{macrocode} |
| 3647 |
% |
| 3648 |
% By default a \env{list} environment is not numbered, but this |
| 3649 |
% happens already in the block template. |
| 3650 |
% \changes{v0.8v}{2024/10/11}{Set the defaults for \tn{@itemlabel}, |
| 3651 |
% \tn{@listctr} and \texttt{@nmbrlist} early in the block code |
| 3652 |
% before the setup code gets executed (tagging/730)} |
| 3653 |
% \begin{macrocode} |
| 3654 |
% \tl_set:Nn \@listctr {} |
| 3655 |
% \legacy_if_set_false:n { @nmbrlist } % needed if lists are nested |
| 3656 |
% \end{macrocode} |
| 3657 |
% By default there is a simple definition for \tn{makelabel}. It can be |
| 3658 |
% overwritten in the second mandatory argument to the list |
| 3659 |
% environment (stored in \cs{l_@@_legacy_env_params_tl}) and |
| 3660 |
% is used if the instance sets the compatibility key to true. |
| 3661 |
% \begin{macrocode} |
| 3662 |
\let\makelabel\@mklab % TODO: customize |
| 3663 |
% \end{macrocode} |
| 3664 |
% Now we use the argument with parameter settings to update some or |
| 3665 |
% all of the above defaults: |
| 3666 |
% \begin{macrocode} |
| 3667 |
\l_@@_legacy_env_params_tl |
| 3668 |
% \end{macrocode} |
| 3669 |
% As we don't know much about this list we can only make a guess about |
| 3670 |
% the nature of the list and the setting of the tag name (default |
| 3671 |
% \keyvalue{list} rolemapped to \struct{L}) and any tag attributes |
| 3672 |
% may have to be overwritten in the optional key/value argument. |
| 3673 |
% But we do have some hints to play with. |
| 3674 |
% \begin{macrocode} |
| 3675 |
\legacy_if:nTF { @nmbrlist } |
| 3676 |
{ \tl_set:Nn \l__tag_L_attr_class_tl {enumerate} } % numbered list |
| 3677 |
{ \tl_if_empty:NTF \@itemlabel |
| 3678 |
{ \tl_set:Nn \l__tag_L_attr_class_tl {list} } % no label |
| 3679 |
{ \tl_set:Nn \l__tag_L_attr_class_tl {itemize} } % unnumbered, |
| 3680 |
% unordered |
| 3681 |
} |
| 3682 |
} |
| 3683 |
% \end{macrocode} |
| 3684 |
% \end{macro} |
| 3685 |
% |
| 3686 |
% |
| 3687 |
% \begin{macro}{\l_@@_legacy_env_params_tl} |
| 3688 |
% |
| 3689 |
% \begin{macrocode} |
| 3690 |
\tl_new:N\l_@@_legacy_env_params_tl |
| 3691 |
% \end{macrocode} |
| 3692 |
% \end{macro} |
| 3693 |
% |
| 3694 |
% |
| 3695 |
% |
| 3696 |
% \begin{environment}{trivlist} |
| 3697 |
% \fmi{Replace with code not using \tn{list}} |
| 3698 |
% \begin{macrocode} |
| 3699 |
\AddToHook{begindocument/before}{ |
| 3700 |
\RenewDocumentEnvironment{trivlist}{ !O{} } |
| 3701 |
{ \list[#1]{} |
| 3702 |
{ |
| 3703 |
\dim_zero:N \leftmargin |
| 3704 |
\dim_zero:N \labelwidth |
| 3705 |
\cs_set_eq:NN \makelabel \use:n |
| 3706 |
} |
| 3707 |
} |
| 3708 |
{ \endblockenv } |
| 3709 |
} |
| 3710 |
% \end{macrocode} |
| 3711 |
% \end{environment} |
| 3712 |
% |
| 3713 |
% |
| 3714 |
% \subsection{Theorem-like environments} |
| 3715 |
% |
| 3716 |
% Theorem-like environments are defined in \LaTeX{} with the help of |
| 3717 |
% \tn{newtheorem} declarations. Internally they used a list with a |
| 3718 |
% single item. Using lists was convenient back then, but in a tagged |
| 3719 |
% document you end up with a strange structure. We therefore alter the |
| 3720 |
% mechanism. |
| 3721 |
% |
| 3722 |
% |
| 3723 |
% \begin{macro}[no-user-doc]{\newtheorem} |
| 3724 |
% This is a slightly streamlined version of \tn{newtheorem}, but it |
| 3725 |
% still uses a lot of the 2e code for now. Eventually this will change. |
| 3726 |
% \begin{macrocode} |
| 3727 |
\RenewDocumentCommand \newtheorem { m O{#1} m o } |
| 3728 |
{ |
| 3729 |
\expandafter\@ifdefinable\csname #1\endcsname |
| 3730 |
{ |
| 3731 |
\str_if_eq:nnTF{#1}{#2} |
| 3732 |
{ |
| 3733 |
\@definecounter {#2} |
| 3734 |
\IfNoValueTF {#4} |
| 3735 |
{ % @ynthm |
| 3736 |
\tl_gset:ce { the #2 } |
| 3737 |
{ |
| 3738 |
\@thmcounter{#2} |
| 3739 |
} |
| 3740 |
} |
| 3741 |
{ % @xnthm |
| 3742 |
\@newctr{#1}[#4] |
| 3743 |
\tl_gset:ce { the #2 } |
| 3744 |
{ |
| 3745 |
\expandafter\noexpand\csname the#4\endcsname |
| 3746 |
\@thmcountersep |
| 3747 |
\@thmcounter{#2} |
| 3748 |
} |
| 3749 |
} |
| 3750 |
} |
| 3751 |
{ % @othm |
| 3752 |
\@ifundefined{c@#2} |
| 3753 |
{ \@nocounterr{#2} } |
| 3754 |
{ |
| 3755 |
\tl_gset:cn { the #1 } |
| 3756 |
{ \UseName { the #2 } } |
| 3757 |
} |
| 3758 |
} |
| 3759 |
\global\@namedef{#1} { \@thm{#2}{#3} } |
| 3760 |
\global\@namedef{end#1}{ \@endtheorem } |
| 3761 |
} |
| 3762 |
} |
| 3763 |
% \end{macrocode} |
| 3764 |
% \end{macro} |
| 3765 |
% |
| 3766 |
% \begin{macro}[no-user-doc]{\@thm} |
| 3767 |
% \tn{@thm} executes \tn{refstepcounter} too early for hyperref |
| 3768 |
% and structure destinations: the generated target is outside the structure |
| 3769 |
% and can be separated from the theorem by a page break. We therefore move |
| 3770 |
% the anchor setting into \tn{@begintheorem}. \tn{@begintheorem} doesn't |
| 3771 |
% currently get the name of the counter as argument, so we store it in variable |
| 3772 |
% for now, to be able to pass it along. |
| 3773 |
% \begin{macrocode} |
| 3774 |
\tl_new:N \l_@@_thm_current_counter_tl |
| 3775 |
\def\@thm#1#2{% |
| 3776 |
\@kernel@refstepcounter{#1} |
| 3777 |
\tl_set:Nn \l_@@_thm_current_counter_tl{#1} |
| 3778 |
\@ifnextchar[{\@ythm{#1}{#2}}{\@xthm{#1}{#2}}} |
| 3779 |
% \end{macrocode} |
| 3780 |
% \end{macro} |
| 3781 |
% |
| 3782 |
% \begin{macro}[no-user-doc]{\@begintheorem,\@opargbegintheorem} |
| 3783 |
% |
| 3784 |
% The \tn{@thm} command expands to either \tn{@beginthorem} or |
| 3785 |
% \tn{@opargbegintheorem}. For the moment we stick with this as it |
| 3786 |
% will help with the transition. But instead of using a |
| 3787 |
% \env{trivlist} we use a blockenv and some tagging for the title |
| 3788 |
% (as a Caption). |
| 3789 |
% We do not want potential tagging from \tn{textbf} here, |
| 3790 |
% so we use \tn{bfseries} to set the font. The commands set also the link targets |
| 3791 |
% which should be inside the main structure. |
| 3792 |
% \begin{macrocode} |
| 3793 |
\NewTaggingSocket{block/theorem/caption}{2} |
| 3794 |
\NewTaggingSocketPlug{block/theorem/caption}{kernel} |
| 3795 |
{ |
| 3796 |
\tag_struct_begin:n{tag=Caption} |
| 3797 |
#2 |
| 3798 |
\tag_struct_end: |
| 3799 |
} |
| 3800 |
\AssignTaggingSocketPlug{block/theorem/caption}{kernel} |
| 3801 |
|
| 3802 |
\def\@begintheorem#1#2{ |
| 3803 |
\UseInstance{blockenv}{theorem}{} |
| 3804 |
\tag_socket_use:n {para/off} |
| 3805 |
% \end{macrocode} |
| 3806 |
% |
| 3807 |
% \changes{v0.8w}{2024/11/23}{\LaTeXe{} theorems always start out |
| 3808 |
% without indentation (tagging/767)} |
| 3809 |
% \changes{v0.9k}{2025-07-26}{Use tagging sockets} |
| 3810 |
% \begin{macrocode} |
| 3811 |
\noindent |
| 3812 |
\MakeLinkTarget{\l_@@_thm_current_counter_tl} |
| 3813 |
\group_begin: |
| 3814 |
\bfseries |
| 3815 |
\tag_socket_use:nnn {block/theorem/caption} {} |
| 3816 |
{ |
| 3817 |
\tag_socket_use:nnn {mc} {} {#1\ } |
| 3818 |
\tag_socket_use:nnn {struct-mc} {tag=Lbl} {#2} |
| 3819 |
} |
| 3820 |
\group_end: |
| 3821 |
\tag_socket_use:n {para/on} |
| 3822 |
% \end{macrocode} |
| 3823 |
% |
| 3824 |
% \begin{macrocode} |
| 3825 |
\tag_socket_use:nn { block/startpara/direct } { \PARALABEL } |
| 3826 |
% \end{macrocode} |
| 3827 |
% |
| 3828 |
% \begin{macrocode} |
| 3829 |
\itshape |
| 3830 |
\hskip\labelsep |
| 3831 |
\ignorespaces |
| 3832 |
} |
| 3833 |
\def\@opargbegintheorem#1#2#3{ |
| 3834 |
\UseInstance{blockenv}{theorem}{} |
| 3835 |
\tag_socket_use:n {para/off} |
| 3836 |
% \end{macrocode} |
| 3837 |
% |
| 3838 |
% \changes{v0.8w}{2024/11/23}{\LaTeXe{} theorems always start out |
| 3839 |
% without indentation (tagging/767)} |
| 3840 |
% \changes{v0.9k}{2025-07-26}{Use tagging sockets} |
| 3841 |
% \begin{macrocode} |
| 3842 |
\noindent |
| 3843 |
\MakeLinkTarget{\l_@@_thm_current_counter_tl} |
| 3844 |
\group_begin: |
| 3845 |
\bfseries |
| 3846 |
\tag_socket_use:nnn {block/theorem/caption}{} |
| 3847 |
{ |
| 3848 |
\tag_socket_use:nnn {mc} {} {#1\ } |
| 3849 |
\tag_socket_use:nnn {struct-mc} {tag=Lbl} {#2} |
| 3850 |
\tag_socket_use:nnn {mc} {} {\ (#3)} |
| 3851 |
} |
| 3852 |
\group_end: |
| 3853 |
\tag_socket_use:n {para/on} |
| 3854 |
% \end{macrocode} |
| 3855 |
% |
| 3856 |
% \begin{macrocode} |
| 3857 |
\tag_socket_use:nn { block/startpara/direct} { \PARALABEL } |
| 3858 |
% \end{macrocode} |
| 3859 |
% |
| 3860 |
% \begin{macrocode} |
| 3861 |
\itshape |
| 3862 |
\hskip\labelsep |
| 3863 |
\ignorespaces |
| 3864 |
} |
| 3865 |
% \end{macrocode} |
| 3866 |
% |
| 3867 |
% \begin{macrocode} |
| 3868 |
\def\@endtheorem{\endblockenv} |
| 3869 |
% \end{macrocode} |
| 3870 |
% \end{macro} |
| 3871 |
% |
| 3872 |
% |
| 3873 |
% |
| 3874 |
% \section{Instance declarations for environments} |
| 3875 |
% |
| 3876 |
% \subsection{Blockenv instances} |
| 3877 |
% |
| 3878 |
% The blockenv instances handle overall setup for the document-level |
| 3879 |
% environments, i.e., |
| 3880 |
% \begin{itemize} |
| 3881 |
% \raggedright |
| 3882 |
% \item name of the environment for debugging purposes (\key{name}) |
| 3883 |
% \item how tagging should be performed (\key{tagging-recipe}, |
| 3884 |
% \key{tag-name}, \key{tag-attr-class}) |
| 3885 |
% \item does this environment changes the block level if nested |
| 3886 |
% (\key{increment-level}) |
| 3887 |
% \item any special setup code; normally not used (\key{setup-code}) |
| 3888 |
% \item what kind of block instance should be used (\key{block-instance}) |
| 3889 |
% \item what kind of para instance should be used; empty means |
| 3890 |
% inherit from the outside (\key{para-instance})\fmi{Note that |
| 3891 |
% block does set some values --- check if this is right!} |
| 3892 |
% \item are inner paragraphs real paragraphs (default) or are they |
| 3893 |
% just \struct{text} structures and part of an outer |
| 3894 |
% paragraph (\key{tagging-suppress-paras}) |
| 3895 |
% \item what kind of inner instance should be used, if any |
| 3896 |
% (\key{inner-instance}, \key{inner-instance-type}) |
| 3897 |
% \item the counter name of the inner level, if any (\key{inner-level-counter}) |
| 3898 |
% \item supported nesting depth of the inner level, if relevant |
| 3899 |
% (\key{max-inner-levels}) |
| 3900 |
% \item extra code executed at the end, by default \tn{ignorespaces} |
| 3901 |
% (\key{final-code}) |
| 3902 |
% \end{itemize} |
| 3903 |
% The blockenv displayblock instance below shows the full set with |
| 3904 |
% those using default values being commented out. |
| 3905 |
% |
| 3906 |
% \subsubsection{Basic instances} |
| 3907 |
% |
| 3908 |
% |
| 3909 |
% \begin{instance}{blockenv displayblock} |
| 3910 |
% This is like \LaTeXe{}'s \env{trivlist}, i.e., it produces a |
| 3911 |
% vertical block with default setting, but doesn't put a list |
| 3912 |
% inside but uses a \struct{Div} structure. |
| 3913 |
% \begin{macrocode} |
| 3914 |
\DeclareInstance{blockenv}{displayblock}{display} |
| 3915 |
{ |
| 3916 |
name = displayblock, |
| 3917 |
% tagging-recipe = standard, |
| 3918 |
% tag-name = , |
| 3919 |
% tag-attr-class = , |
| 3920 |
increment-level = false, |
| 3921 |
% setup-code = , |
| 3922 |
% block-instance = displayblock , |
| 3923 |
% para-instance = , |
| 3924 |
% tagging-suppress-paras = false , |
| 3925 |
% inner-instance = , |
| 3926 |
% inner-instance-type = list , % not relevant as there is no inner instance |
| 3927 |
% inner-level-counter = , % not relevant as there is no inner instance |
| 3928 |
% max-inner-levels = 4, % not relevant as there is no inner instance |
| 3929 |
% final-code = \ignorespaces , |
| 3930 |
} |
| 3931 |
% \end{macrocode} |
| 3932 |
% \end{instance} |
| 3933 |
% |
| 3934 |
% |
| 3935 |
% |
| 3936 |
% |
| 3937 |
% \begin{instance}{blockenv displayblockflattened} |
| 3938 |
% This flattens inner paragraphs without any surrounding tag |
| 3939 |
% structure by using the \keyvalue{basic} tagging recipe. |
| 3940 |
% \begin{macrocode} |
| 3941 |
\DeclareInstance{blockenv}{displayblockflattened}{display} |
| 3942 |
{ |
| 3943 |
name = displayblockflattened, |
| 3944 |
tag-name = , |
| 3945 |
tag-attr-class = , |
| 3946 |
tagging-recipe = basic, |
| 3947 |
tagging-suppress-paras = true , |
| 3948 |
inner-level-counter = , |
| 3949 |
increment-level = false, |
| 3950 |
setup-code = , |
| 3951 |
block-instance = displayblock , |
| 3952 |
inner-instance = , |
| 3953 |
} |
| 3954 |
% \end{macrocode} |
| 3955 |
% \end{instance} |
| 3956 |
% |
| 3957 |
% |
| 3958 |
% |
| 3959 |
% |
| 3960 |
% |
| 3961 |
% \subsubsection{Center, flushleft, and flushright instances} |
| 3962 |
% |
| 3963 |
% All three environments use the \texttt{displayblock} instance as |
| 3964 |
% block instance. They only differ in the choice of para instance. |
| 3965 |
% |
| 3966 |
% \begin{instance}{blockenv center} |
| 3967 |
% The \env{center} environment without using a list internally. |
| 3968 |
% \begin{macrocode} |
| 3969 |
\DeclareInstance{blockenv}{center}{display} |
| 3970 |
{ |
| 3971 |
name = center, |
| 3972 |
tag-name = , |
| 3973 |
tag-attr-class = , |
| 3974 |
tagging-recipe = basic, |
| 3975 |
tagging-suppress-paras = true , |
| 3976 |
inner-level-counter = , |
| 3977 |
increment-level = false, |
| 3978 |
setup-code = , |
| 3979 |
block-instance = displayblock , |
| 3980 |
para-instance = center , |
| 3981 |
inner-instance = , |
| 3982 |
} |
| 3983 |
% \end{macrocode} |
| 3984 |
% \end{instance} |
| 3985 |
% |
| 3986 |
% |
| 3987 |
% \begin{instance}{blockenv flushleft} |
| 3988 |
% The \env{flushleft} environment without using a list internally. |
| 3989 |
% \begin{macrocode} |
| 3990 |
\DeclareInstance{blockenv}{flushleft}{display} |
| 3991 |
{ |
| 3992 |
name = flushleft, |
| 3993 |
tag-name = , |
| 3994 |
tag-attr-class = , |
| 3995 |
tagging-recipe = basic, |
| 3996 |
tagging-suppress-paras = true , |
| 3997 |
inner-level-counter = , |
| 3998 |
increment-level = false, |
| 3999 |
setup-code = , |
| 4000 |
block-instance = displayblock , |
| 4001 |
para-instance = raggedright , |
| 4002 |
inner-instance = , |
| 4003 |
} |
| 4004 |
% \end{macrocode} |
| 4005 |
% \end{instance} |
| 4006 |
% |
| 4007 |
% |
| 4008 |
% |
| 4009 |
% \begin{instance}{blockenv flushright} |
| 4010 |
% |
| 4011 |
% The \env{flushright} environment without using a list internally. |
| 4012 |
% \begin{macrocode} |
| 4013 |
\DeclareInstance{blockenv}{flushright}{display} |
| 4014 |
{ |
| 4015 |
name = flushleft, |
| 4016 |
tag-name = , |
| 4017 |
tag-attr-class = , |
| 4018 |
tagging-recipe = basic, |
| 4019 |
tagging-suppress-paras = true , |
| 4020 |
inner-level-counter = , |
| 4021 |
increment-level = false, |
| 4022 |
setup-code = , |
| 4023 |
block-instance = displayblock , |
| 4024 |
para-instance = raggedleft , |
| 4025 |
inner-instance = , |
| 4026 |
} |
| 4027 |
% \end{macrocode} |
| 4028 |
% \end{instance} |
| 4029 |
% |
| 4030 |
% |
| 4031 |
% |
| 4032 |
% |
| 4033 |
% \subsubsection{Blockquote instances} |
| 4034 |
% |
| 4035 |
|
| 4036 |
% \LaTeXe{} has two environments for quoting: \env{quote} and |
| 4037 |
% \env{quoation}. By default they differ only in indentation of inner |
| 4038 |
% paragraphs. This is handled by using separate block instances. |
| 4039 |
% |
| 4040 |
% The tag names are both roll-mapped to \struct{BlockQuote}. |
| 4041 |
% |
| 4042 |
% \begin{instance}{blockenv quotation} |
| 4043 |
% For the \env{quotation} environment: |
| 4044 |
% \begin{macrocode} |
| 4045 |
\DeclareInstance{blockenv}{quotation}{display} |
| 4046 |
{ |
| 4047 |
name = quotation, |
| 4048 |
tag-name = quotation, |
| 4049 |
tag-attr-class = , |
| 4050 |
tagging-recipe = standard, |
| 4051 |
inner-level-counter = , |
| 4052 |
increment-level = true, |
| 4053 |
setup-code = , |
| 4054 |
block-instance = quotationblock , |
| 4055 |
inner-instance = , |
| 4056 |
} |
| 4057 |
% \end{macrocode} |
| 4058 |
% \end{instance} |
| 4059 |
% |
| 4060 |
% |
| 4061 |
% |
| 4062 |
% \begin{instance}{blockenv quote} |
| 4063 |
% For the \env{quote} environment: |
| 4064 |
% \begin{macrocode} |
| 4065 |
\DeclareInstance{blockenv}{quote}{display} |
| 4066 |
{ |
| 4067 |
name = quote, |
| 4068 |
tag-name = quote, |
| 4069 |
tag-attr-class = , |
| 4070 |
tagging-recipe = standard, |
| 4071 |
inner-level-counter = , |
| 4072 |
increment-level = true, |
| 4073 |
setup-code = , |
| 4074 |
block-instance = quoteblock , |
| 4075 |
inner-instance = , |
| 4076 |
} |
| 4077 |
% \end{macrocode} |
| 4078 |
% \end{instance} |
| 4079 |
% |
| 4080 |
% |
| 4081 |
% |
| 4082 |
% \subsubsection{The theorem instance} |
| 4083 |
% |
| 4084 |
% \begin{instance}{blockenv theorem} |
| 4085 |
% |
| 4086 |
% We use \struct{theorem-like} as the structure name and rolemap it |
| 4087 |
% to a \struct{Sect} because that can hold a \struct{Caption}. |
| 4088 |
% |
| 4089 |
% |
| 4090 |
% \changes{v0.8w}{2024/11/23}{Theorems use their own block-instance |
| 4091 |
% and not displayblock to allow for customization (tagging/767)} |
| 4092 |
% \begin{macrocode} |
| 4093 |
\DeclareInstance{blockenv}{theorem}{display} |
| 4094 |
{ |
| 4095 |
name = theorem-like, |
| 4096 |
tag-name = theorem-like, |
| 4097 |
tag-attr-class = , |
| 4098 |
tagging-recipe = standalone, |
| 4099 |
inner-level-counter = , |
| 4100 |
increment-level = false, |
| 4101 |
setup-code = , |
| 4102 |
block-instance = theoremblock , |
| 4103 |
} |
| 4104 |
% \end{macrocode} |
| 4105 |
% \end{instance} |
| 4106 |
% |
| 4107 |
% |
| 4108 |
% |
| 4109 |
% \subsubsection{The \instname{verbatim} and \instname{verbatim*} instances} |
| 4110 |
% |
| 4111 |
% The rolemapping is \struct{verbatim} to \struct{Code} and |
| 4112 |
% \struct{codeline} to \struct{Sub} (which is role mapped |
| 4113 |
% to \struct{Span} in pdf 1.7). Sub inside Code is allowed according |
| 4114 |
% the errata of ISO 32005. The paragraphs inside verbatim are flattened. |
| 4115 |
% Line numbers should be inside the \struct{codeline} structure |
| 4116 |
% and be tagged either as \struct{Lbl} or \struct{Artifact}\struct{Lbl}. |
| 4117 |
% |
| 4118 |
% \begin{instance}{blockenv verbatim} |
| 4119 |
% |
| 4120 |
% \changes{v0.8x}{2025/01/12}{Use flattened para inside verbatim} |
| 4121 |
% \begin{macrocode} |
| 4122 |
\DeclareInstance{blockenv}{verbatim}{display} |
| 4123 |
{ |
| 4124 |
name = verbatim, |
| 4125 |
tag-name = verbatim, |
| 4126 |
tag-attr-class = , |
| 4127 |
tagging-recipe = standard, |
| 4128 |
tagging-suppress-paras = true, |
| 4129 |
inner-level-counter = , |
| 4130 |
increment-level = false, |
| 4131 |
setup-code = , |
| 4132 |
block-instance = verbatimblock , |
| 4133 |
inner-instance = , |
| 4134 |
para-instance = justify , |
| 4135 |
final-code = \legacyverbatimsetup |
| 4136 |
% \end{macrocode} |
| 4137 |
% Here is where \env{verbatim} and \env{verbatim*} technically |
| 4138 |
% differ: in the former we set up spaces to become nobreakable |
| 4139 |
% spaces (if necessary followed by a \tn{pdffakespace} in the |
| 4140 |
% pdf\TeX{} engine) |
| 4141 |
% and in \env{verbatim*} we set it up to generate visible space chars. |
| 4142 |
% \changes{v0.9f}{2025/06/21}{Move special verbatim code into a key} |
| 4143 |
% \begin{macrocode} |
| 4144 |
\@setupverbinvisiblespace \@vobeyspaces |
| 4145 |
% \end{macrocode} |
| 4146 |
% Then we start the special scanning process to look for |
| 4147 |
% \verb=\end{verbatim}= with special catcodes and grab everything |
| 4148 |
% inbetween. For \env{verbatim*} we use \cs{@sxverbatim} to look |
| 4149 |
% for \verb=\end{verbatim*}= instead.\footnote{Perhaps there should |
| 4150 |
% be some other command names for this?} |
| 4151 |
% \begin{macrocode} |
| 4152 |
\@xverbatim |
| 4153 |
} |
| 4154 |
% \end{macrocode} |
| 4155 |
% \end{instance} |
| 4156 |
% |
| 4157 |
% \begin{instance}{blockenv verbatim*} |
| 4158 |
% |
| 4159 |
% \changes{v0.9f}{2025/06/21}{Use separate blockenv instances for |
| 4160 |
% verbatim and verbatim*} |
| 4161 |
% \begin{macrocode} |
| 4162 |
\DeclareInstance{blockenv}{verbatim*}{display} |
| 4163 |
{ |
| 4164 |
name = verbatim, |
| 4165 |
tag-name = verbatim, |
| 4166 |
tag-attr-class = , |
| 4167 |
tagging-recipe = standard, |
| 4168 |
tagging-suppress-paras = true, |
| 4169 |
inner-level-counter = , |
| 4170 |
increment-level = false, |
| 4171 |
setup-code = , |
| 4172 |
block-instance = verbatimblock , |
| 4173 |
inner-instance = , |
| 4174 |
para-instance = justify , |
| 4175 |
final-code = \legacyverbatimsetup |
| 4176 |
\@setupverbvisiblespace \@vobeyspaces |
| 4177 |
\@sxverbatim |
| 4178 |
} |
| 4179 |
% \end{macrocode} |
| 4180 |
% \end{instance} |
| 4181 |
% |
| 4182 |
% |
| 4183 |
% \subsubsection{Standard list instances} |
| 4184 |
% |
| 4185 |
% \begin{instance}{blockenv itemize} |
| 4186 |
% For the \env{itemize} environment: |
| 4187 |
% \begin{macrocode} |
| 4188 |
\DeclareInstance{blockenv}{itemize}{display} |
| 4189 |
{ |
| 4190 |
name = itemize, |
| 4191 |
tag-name = itemize, |
| 4192 |
tag-attr-class = itemize, |
| 4193 |
tagging-recipe = list, |
| 4194 |
inner-level-counter = \@itemdepth, |
| 4195 |
increment-level = true, |
| 4196 |
max-inner-levels = 4, |
| 4197 |
setup-code = , |
| 4198 |
block-instance = listblock , |
| 4199 |
inner-instance = itemize , |
| 4200 |
} |
| 4201 |
% \end{macrocode} |
| 4202 |
% \end{instance} |
| 4203 |
% |
| 4204 |
% |
| 4205 |
% \begin{instance}{blockenv enumerate} |
| 4206 |
% |
| 4207 |
% For the \env{enumerate} environment: |
| 4208 |
% \begin{macrocode} |
| 4209 |
\DeclareInstance{blockenv}{enumerate}{display} |
| 4210 |
{ |
| 4211 |
name = enumerate, |
| 4212 |
tag-name = enumerate, |
| 4213 |
tag-attr-class = enumerate, |
| 4214 |
tagging-recipe = list, |
| 4215 |
increment-level = true, |
| 4216 |
max-inner-levels = 4, |
| 4217 |
setup-code = , |
| 4218 |
block-instance = listblock , |
| 4219 |
inner-level-counter = \@enumdepth, |
| 4220 |
inner-instance = enum , |
| 4221 |
} |
| 4222 |
% \end{macrocode} |
| 4223 |
% \end{instance} |
| 4224 |
% |
| 4225 |
% |
| 4226 |
% \begin{instance}{blockenv description} |
| 4227 |
% |
| 4228 |
% For the \env{description} environment: |
| 4229 |
% \begin{macrocode} |
| 4230 |
|
| 4231 |
\DeclareInstance{blockenv}{description}{display} |
| 4232 |
{ |
| 4233 |
name = description, |
| 4234 |
tag-name = description, |
| 4235 |
tag-attr-class = description, |
| 4236 |
tagging-recipe = list, |
| 4237 |
inner-level-counter = , |
| 4238 |
increment-level = true, |
| 4239 |
setup-code = , |
| 4240 |
block-instance = listblock , |
| 4241 |
inner-instance = description , |
| 4242 |
} |
| 4243 |
% \end{macrocode} |
| 4244 |
% \end{instance} |
| 4245 |
% |
| 4246 |
% |
| 4247 |
% \begin{instance}{blockenv list} |
| 4248 |
% The general (legacy) \env{list} environment does some of its |
| 4249 |
% setup in the \key{setup-code} key. |
| 4250 |
% \begin{macrocode} |
| 4251 |
\DeclareInstance{blockenv}{list}{display} |
| 4252 |
{ |
| 4253 |
name = list, |
| 4254 |
tag-name = list, |
| 4255 |
tag-attr-class = , |
| 4256 |
tagging-recipe = list, |
| 4257 |
increment-level = true, |
| 4258 |
setup-code = \legacylistsetupcode , |
| 4259 |
block-instance = listblock , |
| 4260 |
inner-level-counter = , |
| 4261 |
inner-instance = legacy , |
| 4262 |
} |
| 4263 |
% \end{macrocode} |
| 4264 |
% \end{instance} |
| 4265 |
% |
| 4266 |
% |
| 4267 |
% |
| 4268 |
% |
| 4269 |
% \subsection{Block instances} |
| 4270 |
% |
| 4271 |
% Below, we declare the different block instances for the |
| 4272 |
% document-level environments. Some, such as the displayblock ones |
| 4273 |
% are shared between different environments (as long as one doesn't |
| 4274 |
% need to adjust individual values), other environments have their |
| 4275 |
% own instances (for precisely that reason). |
| 4276 |
% |
| 4277 |
% \subsubsection{Displayblock instances} |
| 4278 |
% |
| 4279 |
% We provide 6 nesting levels (as in \LaTeXe{}). If you want to |
| 4280 |
% provide more you need to change the \texttt{maxblocklevels} |
| 4281 |
% counter, offer further \texttt{displayblock-xx} instances but |
| 4282 |
% also define further (legacy) \tn{list\meta{romannumeral}} commands |
| 4283 |
% for the defaults. If not, then the settings from the previous |
| 4284 |
% level are reused automatically---which may or may not be good enough). |
| 4285 |
% \begin{macrocode} |
| 4286 |
\setcounter{maxblocklevels}{6} |
| 4287 |
% \end{macrocode} |
| 4288 |
% |
| 4289 |
% \begin{instance}{block displayblock-0, |
| 4290 |
% block displayblock-1, |
| 4291 |
% block displayblock-2, |
| 4292 |
% block displayblock-3, |
| 4293 |
% block displayblock-4, |
| 4294 |
% block displayblock-5, |
| 4295 |
% block displayblock-6 } |
| 4296 |
% |
| 4297 |
% Here we need level zero as well in case a flattened displayblock |
| 4298 |
% (like the center env) it is used on top-level. |
| 4299 |
% |
| 4300 |
% We show all keys here for reference, with those using their |
| 4301 |
% default values commented out: |
| 4302 |
% \begin{macrocode} |
| 4303 |
\DeclareInstance{block}{displayblock-0}{display} |
| 4304 |
{ |
| 4305 |
% begin-vspace = \topsep , |
| 4306 |
% begin-extra-vspace = \partopsep , |
| 4307 |
% para-vspace = \parsep , |
| 4308 |
% end-vspace = \KeyValue{begin-vspace} , |
| 4309 |
% end-extra-vspace = \KeyValue{begin-extra-vspace} , |
| 4310 |
% item-vspace = \itemsep , |
| 4311 |
% begin-penalty = \UseName{@beginparpenalty} , |
| 4312 |
% end-penalty = \UseName{@endparpenalty} , |
| 4313 |
left-margin = 0pt , |
| 4314 |
% right-margin = \rightmargin , |
| 4315 |
% para-indent = 0pt , |
| 4316 |
} |
| 4317 |
% \end{macrocode} |
| 4318 |
% |
| 4319 |
% \begin{macrocode} |
| 4320 |
\DeclareInstanceCopy{block}{displayblock-1}{displayblock-0} |
| 4321 |
\DeclareInstanceCopy{block}{displayblock-2}{displayblock-0} |
| 4322 |
\DeclareInstanceCopy{block}{displayblock-3}{displayblock-0} |
| 4323 |
\DeclareInstanceCopy{block}{displayblock-4}{displayblock-0} |
| 4324 |
\DeclareInstanceCopy{block}{displayblock-5}{displayblock-0} |
| 4325 |
\DeclareInstanceCopy{block}{displayblock-6}{displayblock-0} |
| 4326 |
% \end{macrocode} |
| 4327 |
% \end{instance} |
| 4328 |
% |
| 4329 |
% |
| 4330 |
% |
| 4331 |
% \subsubsection{Verbatim instances} |
| 4332 |
% |
| 4333 |
% Verbatim instances have there own levels so that one can specify |
| 4334 |
% specific indentations or vertical separations between line. |
| 4335 |
% |
| 4336 |
% \begin{instance}{block verbatimblock-0, |
| 4337 |
% block verbatimblock-1, |
| 4338 |
% block verbatimblock-2, |
| 4339 |
% block verbatimblock-3, |
| 4340 |
% block verbatimblock-4, |
| 4341 |
% block verbatimblock-5, |
| 4342 |
% block verbatimblock-6 } |
| 4343 |
% |
| 4344 |
% \begin{macrocode} |
| 4345 |
\DeclareInstance{block}{verbatimblock-0}{display} |
| 4346 |
{ |
| 4347 |
left-margin = 0pt , |
| 4348 |
para-vspace = 0pt , |
| 4349 |
} |
| 4350 |
% \end{macrocode} |
| 4351 |
% |
| 4352 |
% \begin{macrocode} |
| 4353 |
\DeclareInstanceCopy{block}{verbatimblock-1}{verbatimblock-0} |
| 4354 |
\DeclareInstanceCopy{block}{verbatimblock-2}{verbatimblock-0} |
| 4355 |
\DeclareInstanceCopy{block}{verbatimblock-3}{verbatimblock-0} |
| 4356 |
\DeclareInstanceCopy{block}{verbatimblock-4}{verbatimblock-0} |
| 4357 |
\DeclareInstanceCopy{block}{verbatimblock-5}{verbatimblock-0} |
| 4358 |
\DeclareInstanceCopy{block}{verbatimblock-6}{verbatimblock-0} |
| 4359 |
% \end{macrocode} |
| 4360 |
% \end{instance} |
| 4361 |
% |
| 4362 |
% |
| 4363 |
% |
| 4364 |
% |
| 4365 |
% \subsubsection{Quote/quotationblock instances} |
| 4366 |
% |
| 4367 |
% Quote and quotation are not flattened, i.e., they change levels, |
| 4368 |
% thus they start with level 1 not 0. |
| 4369 |
% |
| 4370 |
% \begin{instance}{block quoteblock-1, |
| 4371 |
% block quoteblock-2, |
| 4372 |
% block quoteblock-3, |
| 4373 |
% block quoteblock-4, |
| 4374 |
% block quoteblock-5, |
| 4375 |
% block quoteblock-6 } |
| 4376 |
% Default layout is to indent equally from both sides. |
| 4377 |
% \begin{macrocode} |
| 4378 |
\DeclareInstance{block}{quoteblock-1}{display} |
| 4379 |
{ right-margin = \KeyValue{left-margin} } |
| 4380 |
% \end{macrocode} |
| 4381 |
% |
| 4382 |
% \begin{macrocode} |
| 4383 |
\DeclareInstanceCopy{block}{quoteblock-2}{quoteblock-1} |
| 4384 |
\DeclareInstanceCopy{block}{quoteblock-3}{quoteblock-1} |
| 4385 |
\DeclareInstanceCopy{block}{quoteblock-4}{quoteblock-1} |
| 4386 |
\DeclareInstanceCopy{block}{quoteblock-5}{quoteblock-1} |
| 4387 |
\DeclareInstanceCopy{block}{quoteblock-6}{quoteblock-1} |
| 4388 |
% \end{macrocode} |
| 4389 |
% \end{instance} |
| 4390 |
% |
| 4391 |
% |
| 4392 |
% |
| 4393 |
% \begin{instance}{block quotationblock-1, |
| 4394 |
% block quotationblock-2, |
| 4395 |
% block quotationblock-3, |
| 4396 |
% block quotationblock-4, |
| 4397 |
% block quotationblock-5, |
| 4398 |
% block quotationblock-6 } |
| 4399 |
% Quotation additionally changes the para-indent. |
| 4400 |
% \begin{macrocode} |
| 4401 |
\DeclareInstance{block}{quotationblock-1}{display} |
| 4402 |
{ para-indent = 1.5em , right-margin = \KeyValue{left-margin} } |
| 4403 |
% \end{macrocode} |
| 4404 |
% |
| 4405 |
% \begin{macrocode} |
| 4406 |
\DeclareInstanceCopy{block}{quotationblock-2}{quotationblock-1} |
| 4407 |
\DeclareInstanceCopy{block}{quotationblock-3}{quotationblock-1} |
| 4408 |
\DeclareInstanceCopy{block}{quotationblock-4}{quotationblock-1} |
| 4409 |
\DeclareInstanceCopy{block}{quotationblock-5}{quotationblock-1} |
| 4410 |
\DeclareInstanceCopy{block}{quotationblock-6}{quotationblock-1} |
| 4411 |
% \end{macrocode} |
| 4412 |
% \end{instance} |
| 4413 |
% |
| 4414 |
% |
| 4415 |
% \subsubsection{Block instances for the theorems} |
| 4416 |
% |
| 4417 |
% |
| 4418 |
% \begin{instance}{block theoremblock-0} |
| 4419 |
% Theorems do not support nesting, so we have only one to set up. |
| 4420 |
% The \LaTeX{} default reused the general value of \tn{parindent} |
| 4421 |
% and \tn{parskip} and, of course, they start at the outer margin. |
| 4422 |
% \changes{v0.8w}{2024/11/23}{Add block instance for theorems} |
| 4423 |
% \begin{macrocode} |
| 4424 |
\DeclareInstance{block}{theoremblock-0}{display} |
| 4425 |
{ |
| 4426 |
left-margin = 0pt , |
| 4427 |
para-indent = \parindent , |
| 4428 |
para-vspace = \parskip , |
| 4429 |
} |
| 4430 |
% \end{macrocode} |
| 4431 |
% There are, however, documents that put theorem-like environments |
| 4432 |
% inside of lists. While that is in most case somewhat dubious, it |
| 4433 |
% can make sense, for example, in \env{description} lists. So we |
| 4434 |
% support it somewhat by also providing theoremblock instances for |
| 4435 |
% level 1 and 2. If somebody really nests them further down, then |
| 4436 |
% more such instances need to be declared. |
| 4437 |
% \begin{macrocode} |
| 4438 |
\DeclareInstanceCopy{block}{theoremblock-1}{theoremblock-0} |
| 4439 |
\DeclareInstanceCopy{block}{theoremblock-2}{theoremblock-0} |
| 4440 |
% \end{macrocode} |
| 4441 |
% \end{instance} |
| 4442 |
% |
| 4443 |
% |
| 4444 |
% |
| 4445 |
% \subsubsection{Block instances for the standard lists} |
| 4446 |
% |
| 4447 |
% \begin{instance}{block listblock-1, |
| 4448 |
% block listblock-2, |
| 4449 |
% block listblock-3, |
| 4450 |
% block listblock-4, |
| 4451 |
% block listblock-5, |
| 4452 |
% block listblock-6 } |
| 4453 |
% The block instances for the various list environments use the |
| 4454 |
% same underlying instance (well, by default) and nothing |
| 4455 |
% needs to be set up specifically (because that is already done in |
| 4456 |
% the legacy \tn{list\meta{romannumeral}} unless a |
| 4457 |
% different layout is wanted. |
| 4458 |
% \begin{macrocode} |
| 4459 |
\DeclareInstance{block}{listblock-1}{display}{ |
| 4460 |
% begin-vspace = \topsep , |
| 4461 |
% begin-extra-vspace = \partopsep , |
| 4462 |
% para-vspace = \parsep , |
| 4463 |
% end-vspace = \KeyValue{begin-vspace} , |
| 4464 |
% end-extra-vspace = \KeyValue{begin-extra-vspace} , |
| 4465 |
% item-vspace = \itemsep , |
| 4466 |
% begin-penalty = \UseName{@beginparpenalty} , |
| 4467 |
% end-penalty = \UseName{@endparpenalty} , |
| 4468 |
% left-margin = \leftmargin , |
| 4469 |
% right-margin = \rightmargin , |
| 4470 |
% para-indent = 0pt , |
| 4471 |
} |
| 4472 |
\DeclareInstance{block}{listblock-2}{display}{} |
| 4473 |
\DeclareInstance{block}{listblock-3}{display}{} |
| 4474 |
\DeclareInstance{block}{listblock-4}{display}{} |
| 4475 |
\DeclareInstance{block}{listblock-5}{display}{} |
| 4476 |
\DeclareInstance{block}{listblock-6}{display}{} |
| 4477 |
% \end{macrocode} |
| 4478 |
% \end{instance} |
| 4479 |
% |
| 4480 |
% |
| 4481 |
% |
| 4482 |
% \subsection{List instances for the standard lists} |
| 4483 |
% |
| 4484 |
% For all list instances we have to say what kind of label we want |
| 4485 |
% (\key{item-label}) and how it should be formatted. |
| 4486 |
% |
| 4487 |
% \begin{instance}{list itemize-1, |
| 4488 |
% list itemize-2, |
| 4489 |
% list itemize-3, |
| 4490 |
% list itemize-4} |
| 4491 |
% For \env{itemize} environments this is all we need to do and we |
| 4492 |
% refer back to the external definitions rather than defining the |
| 4493 |
% \key{item-label} code in the instance to ensure that old |
| 4494 |
% documents still work. |
| 4495 |
% |
| 4496 |
% \begin{macrocode} |
| 4497 |
\DeclareInstance{list}{itemize-1}{std}{ item-label = \labelitemi } |
| 4498 |
\DeclareInstance{list}{itemize-2}{std}{ item-label = \labelitemii } |
| 4499 |
\DeclareInstance{list}{itemize-3}{std}{ item-label = \labelitemiii } |
| 4500 |
\DeclareInstance{list}{itemize-4}{std}{ item-label = \labelitemiv } |
| 4501 |
% \end{macrocode} |
| 4502 |
% \end{instance} |
| 4503 |
% |
| 4504 |
% |
| 4505 |
% |
| 4506 |
% \begin{instance}{list enumerate-1, |
| 4507 |
% list enumerate-2, |
| 4508 |
% list enumerate-3, |
| 4509 |
% list enumerate-4} |
| 4510 |
% \env{enumerate} environments are similar, except that we also |
| 4511 |
% have to say which counter to use on each level. |
| 4512 |
% \begin{macrocode} |
| 4513 |
\DeclareInstance{list}{enum-1}{std} |
| 4514 |
{ item-label = \labelenumi , counter = enumi } |
| 4515 |
\DeclareInstance{list}{enum-2}{std} |
| 4516 |
{ item-label = \labelenumii , counter = enumii } |
| 4517 |
\DeclareInstance{list}{enum-3}{std} |
| 4518 |
{ item-label = \labelenumiii , counter = enumiii } |
| 4519 |
\DeclareInstance{list}{enum-4}{std} |
| 4520 |
{ item-label = \labelenumiv , counter = enumiv } |
| 4521 |
% \end{macrocode} |
| 4522 |
% \end{instance} |
| 4523 |
% |
| 4524 |
% |
| 4525 |
% |
| 4526 |
% \begin{instance}{list legacy} |
| 4527 |
% For the legacy \env{list} environment there is only one instance |
| 4528 |
% which is reused on all levels. This is done this way because |
| 4529 |
% the legacy \env{list} environment sets all its |
| 4530 |
% parameters through its arguments. So this instances shouldn't |
| 4531 |
% really be touched. It sets the \key{legacy-support} key to |
| 4532 |
% true, which means that the list code uses \tn{makelabel} for |
| 4533 |
% formatting the label. |
| 4534 |
% \begin{macrocode} |
| 4535 |
\DeclareInstance{list}{legacy}{std} { |
| 4536 |
item-instance = basic , |
| 4537 |
legacy-support = true , |
| 4538 |
} |
| 4539 |
% \end{macrocode} |
| 4540 |
% \end{instance} |
| 4541 |
% |
| 4542 |
% |
| 4543 |
% \begin{instance}{list description} |
| 4544 |
% The \env{description} lists also use only a single list instance |
| 4545 |
% with only one key not using the default: |
| 4546 |
% \begin{macrocode} |
| 4547 |
\DeclareInstance{list}{description}{std} { item-instance = description } |
| 4548 |
% \end{macrocode} |
| 4549 |
% \end{instance} |
| 4550 |
% |
| 4551 |
% |
| 4552 |
% \subsection{Item instances} |
| 4553 |
% |
| 4554 |
% |
| 4555 |
% \begin{instance}{item basic, item description} |
| 4556 |
% There two item instances set up: \keyvalue{description} for use |
| 4557 |
% with the \env{description} environment and \keyvalue{basic} for use |
| 4558 |
% with all other lists (up to now). |
| 4559 |
% \begin{macrocode} |
| 4560 |
\DeclareInstance{item}{basic}{std} |
| 4561 |
{ label-align = right } |
| 4562 |
% \end{macrocode} |
| 4563 |
% |
| 4564 |
% \begin{macrocode} |
| 4565 |
\DeclareInstance{item}{description}{std} |
| 4566 |
{ |
| 4567 |
label-format = \normalfont\bfseries #1 , |
| 4568 |
label-align = left |
| 4569 |
} |
| 4570 |
% \end{macrocode} |
| 4571 |
% \end{instance} |
| 4572 |
% |
| 4573 |
% |
| 4574 |
% |
| 4575 |
% \subsection{Para instances} |
| 4576 |
% |
| 4577 |
% \begin{macrocode} |
| 4578 |
\tagpdfsetup |
| 4579 |
{ |
| 4580 |
role/new-attribute = {justify} {/O /Layout /TextAlign/Justify}, |
| 4581 |
role/new-attribute = {center} {/O /Layout /TextAlign/Center}, |
| 4582 |
role/new-attribute = {raggedright}{/O /Layout /TextAlign/Start}, |
| 4583 |
role/new-attribute = {raggedleft} {/O /Layout /TextAlign/End}, |
| 4584 |
} |
| 4585 |
% \end{macrocode} |
| 4586 |
% |
| 4587 |
% \begin{instance}{para center} |
| 4588 |
% \begin{macrocode} |
| 4589 |
\DeclareInstance{para}{center}{std} |
| 4590 |
{ |
| 4591 |
para-attr-class = center , |
| 4592 |
para-indent = 0pt , |
| 4593 |
% begin-hspace = 0pt , |
| 4594 |
left-hspace = \@flushglue , |
| 4595 |
right-hspace = \@flushglue , |
| 4596 |
end-hspace = \z@skip , |
| 4597 |
final-hyphen-demerits = 0 , |
| 4598 |
newline-cmd = \@centercr , |
| 4599 |
} |
| 4600 |
% \end{macrocode} |
| 4601 |
% \end{instance} |
| 4602 |
% |
| 4603 |
% \begin{instance}{para raggedright} |
| 4604 |
% \begin{macrocode} |
| 4605 |
\DeclareInstance{para}{raggedright}{std} |
| 4606 |
{ |
| 4607 |
para-attr-class = raggedright , |
| 4608 |
para-indent = 0pt , |
| 4609 |
% begin-hspace = 0pt , |
| 4610 |
left-hspace = \z@skip , |
| 4611 |
right-hspace = \@flushglue , |
| 4612 |
end-hspace = \z@skip , |
| 4613 |
final-hyphen-demerits = 0 , |
| 4614 |
newline-cmd = \@centercr , |
| 4615 |
} |
| 4616 |
% \end{macrocode} |
| 4617 |
% \end{instance} |
| 4618 |
% |
| 4619 |
% \begin{instance}{para raggedleft} |
| 4620 |
% \begin{macrocode} |
| 4621 |
\DeclareInstance{para}{raggedleft}{std} |
| 4622 |
{ |
| 4623 |
para-attr-class = raggedleft , |
| 4624 |
para-indent = 0pt , |
| 4625 |
% begin-hspace = 0pt , |
| 4626 |
left-hspace = \@flushglue , |
| 4627 |
right-hspace = \z@skip , |
| 4628 |
end-hspace = \z@skip , |
| 4629 |
final-hyphen-demerits = 0 , |
| 4630 |
newline-cmd = \@centercr , |
| 4631 |
} |
| 4632 |
% \end{macrocode} |
| 4633 |
% \end{instance} |
| 4634 |
% |
| 4635 |
% \begin{instance}{para justify} |
| 4636 |
% Justifying is exactly what the default values do, so the instance |
| 4637 |
% hasn't any special setup. |
| 4638 |
% \begin{macrocode} |
| 4639 |
\DeclareInstance{para}{justify}{std} |
| 4640 |
{ |
| 4641 |
% para-attr-class = justify , |
| 4642 |
% para-indent = \parindent , |
| 4643 |
% begin-hspace = 0pt , |
| 4644 |
% left-hspace = \z@skip , |
| 4645 |
% right-hspace = \z@skip , |
| 4646 |
% end-hspace = \@flushglue , |
| 4647 |
% final-hyphen-demerits = 5000 , |
| 4648 |
% newline-cmd = \@normalcr , |
| 4649 |
} |
| 4650 |
% \end{macrocode} |
| 4651 |
% \end{instance} |
| 4652 |
% |
| 4653 |
% |
| 4654 |
% |
| 4655 |
% |
| 4656 |
% \begin{macro}[no-user-doc]{\centering,\raggedleft,\raggedright,\justifying} |
| 4657 |
% |
| 4658 |
% \begin{macrocode} |
| 4659 |
\DeclareRobustCommand\centering {\UseInstance{para}{center}{}} |
| 4660 |
\DeclareRobustCommand\raggedleft {\UseInstance{para}{raggedleft}{}} |
| 4661 |
\DeclareRobustCommand\raggedright{\UseInstance{para}{raggedright}{}} |
| 4662 |
\DeclareRobustCommand\justifying {\UseInstance{para}{justify}{}} |
| 4663 |
% \end{macrocode} |
| 4664 |
% |
| 4665 |
% \begin{macrocode} |
| 4666 |
\justifying |
| 4667 |
% \end{macrocode} |
| 4668 |
% \end{macro} |
| 4669 |
% |
| 4670 |
% |
| 4671 |
% |
| 4672 |
% |
| 4673 |
% \begin{macrocode} |
| 4674 |
%</package> |
| 4675 |
% \end{macrocode} |
| 4676 |
% |
| 4677 |
% |
| 4678 |
% |
| 4679 |
% \begin{macrocode} |
| 4680 |
%<*latex-lab> |
| 4681 |
\ProvidesFile{block-latex-lab-testphase.ltx} |
| 4682 |
[\ltlabblockdate\space v\ltlabblockversion\space |
| 4683 |
blockenv implementation] |
| 4684 |
\RequirePackage{latex-lab-testphase-block} |
| 4685 |
%</latex-lab> |
| 4686 |
% \end{macrocode} |
| 4687 |
% |
| 4688 |
% \end{implementation} |
| 4689 |
% |
| 4690 |
% \appendix |
| 4691 |
% |
| 4692 |
% \section{Documentation from first prototype implementations} |
| 4693 |
% |
| 4694 |
% |
| 4695 |
% \subsection{Open questions} |
| 4696 |
% \begin{itemize} |
| 4697 |
% \item Existing questions --- moved to issues --- |
| 4698 |
% \end{itemize} |
| 4699 |
% |
| 4700 |
% \subsection{Code cleanup} |
| 4701 |
% \begin{itemize} |
| 4702 |
% \raggedright |
| 4703 |
% \item Actually implement what's announced. |
| 4704 |
% |
| 4705 |
% \item Encapsulate most uses of \cs[no-index]{legacy_if\dots} into |
| 4706 |
% commands with \pkg{expl3} syntax: we cannot rename these booleans |
| 4707 |
% for compatibility reasons but we can make the code cleaner |
| 4708 |
% nevertheless. --- made issue --- |
| 4709 |
% |
| 4710 |
% \item The \tn{topsep} and \tn{partopsep} business is tricky to |
| 4711 |
% reproduce exactly (see \tn{@topsepadd} and \tn{@topsep}) because of |
| 4712 |
% how it accumulates when lists are nested immediately. |
| 4713 |
% |
| 4714 |
% \end{itemize} |
| 4715 |
% |
| 4716 |
% |
| 4717 |
% |
| 4718 |
% \subsection{Tasks} |
| 4719 |
% \begin{itemize} |
| 4720 |
% |
| 4721 |
% \item Change author to LaTeX Team once it's nice enough to deserve |
| 4722 |
% that label. |
| 4723 |
% |
| 4724 |
% \item Reproducing exactly the standard layouts and examples in the |
| 4725 |
% \pkg{enumitem} documentation. |
| 4726 |
% |
| 4727 |
% \item Hooks, but do not duplicate those that already exist as |
| 4728 |
% environment hooks. Hence, mostly around items. |
| 4729 |
% |
| 4730 |
% \item Customization and interaction with LDB: |
| 4731 |
% \begin{itemize} |
| 4732 |
% \item Allow arbitrary nesting depth with automatically defined |
| 4733 |
% styles for labels, counters etc. |
| 4734 |
% \item Adapt everything to font size! (e.g. footnotes). |
| 4735 |
% \item How to model the inheritance from trivlist to list to |
| 4736 |
% enumerate? |
| 4737 |
% \end{itemize} |
| 4738 |
% |
| 4739 |
% \item Add key--value settings mimicking \pkg{enumitem}'s ability to |
| 4740 |
% set any four of five horizontal parameters and deduce the fifth by |
| 4741 |
% $\tn{leftmargin} + \tn{itemindent} = \tn{labelindent} + |
| 4742 |
% \tn{labelwidth} + \tn{labelsep}$. |
| 4743 |
% |
| 4744 |
% \item Provide good ways to customize how overlong labels are dealt with. |
| 4745 |
% |
| 4746 |
% \item Use the \texttt{.aux} file. |
| 4747 |
% \begin{itemize} |
| 4748 |
% \item Implement the \tn{ref} styles that \pkg{enumitem} provides. |
| 4749 |
% \item Reverse enumerations, important in publication lists and the |
| 4750 |
% like. Somehow avoid needing 3 compilations for references to |
| 4751 |
% reverse enumerations to settle? |
| 4752 |
% \item Ability to calculate \tn{labelwidth} from the label contents. |
| 4753 |
% Share calculated parameters between multiple environments (cf.\ |
| 4754 |
% \texttt{resume} option). |
| 4755 |
% \end{itemize} |
| 4756 |
% |
| 4757 |
% \item Related to grabbing the whole list environment, and input syntax |
| 4758 |
% variations: |
| 4759 |
% \begin{itemize} |
| 4760 |
% \item Other layouts: tabular (see \pkg{listliketab} vs |
| 4761 |
% \pkg{typed-checklist}), multicolumn and horizontally numbered (see |
| 4762 |
% \pkg{tasks}), inline lists, runin lists in the easy case where |
| 4763 |
% there is no intervening \tn{par}. |
| 4764 |
% \item Formatting the item text in a |
| 4765 |
% box or similar (requires grabbing the whole list). |
| 4766 |
% \item Filtering which items to show: hide certain items according to |
| 4767 |
% criteria (useful together with list reuse), see |
| 4768 |
% \pkg{typed-checklist}. |
| 4769 |
% \item Shorthands \tn{iitem} for automatic nested lists, or \cs{1}, |
| 4770 |
% \cs{2} etc from \pkg{outlines}. |
| 4771 |
% \item Support markdown input like \pkg{asciilist}. |
| 4772 |
% \end{itemize} |
| 4773 |
% |
| 4774 |
% \item Check interaction with \texttt{babel} options such as |
| 4775 |
% \texttt{french} or \texttt{accadian} (see FrenchItemizeSpacing) |
| 4776 |
% |
| 4777 |
% \item RTL and vertical typesetting. |
| 4778 |
% \end{itemize} |
| 4779 |
% |
| 4780 |
% \section{Plan of attack of first prototype} |
| 4781 |
% |
| 4782 |
% Typesetting list environments involves a rather large number of |
| 4783 |
% parameters. They can be affected by the context such as the total |
| 4784 |
% list nesting level, the nesting level of the given type of list, and |
| 4785 |
% the font size. An environment like \texttt{enumerate} has two main |
| 4786 |
% aspects. |
| 4787 |
% \begin{itemize} |
| 4788 |
% \item It has a certain layout in the page, with vertical and |
| 4789 |
% horizontal spacing around it. This type of layout is shared with |
| 4790 |
% environments such as \texttt{quote}, \texttt{flushright}, or |
| 4791 |
% \texttt{tabbing}. This common layout is implemented in \LaTeXe{} |
| 4792 |
% through \tn{trivlist} (or \tn{list}). |
| 4793 |
% \item It defines how each \tn{item} should be typeset: how to |
| 4794 |
% construct the label, in particular the \texttt{counter} name, and |
| 4795 |
% how to format the content of the item. |
| 4796 |
% \end{itemize} |
| 4797 |
% |
| 4798 |
% This suggests defining two template types, \xt{block} and \xt{item} |
| 4799 |
% covering these two aspects.\footnote{Possibly also \xt{endblock} to |
| 4800 |
% deal with decorations at the end?} While the \xt{item} type will |
| 4801 |
% perhaps have a single template, one could typeset a \xt{block} template |
| 4802 |
% in several ways, for instance the standard \LaTeXe{} way or a fancy |
| 4803 |
% colored box. |
| 4804 |
% |
| 4805 |
% The \xt{general} \xt{block} template should receive the following |
| 4806 |
% parameters. The \xt{plain} \xt{block} template is a restricted |
| 4807 |
% template that freezes all item-related parameters to dummy values |
| 4808 |
% (\texttt{counter}, \texttt{start}, \texttt{resume}, |
| 4809 |
% \texttt{label-width}, \texttt{label-sep} and all \texttt{item-*}). |
| 4810 |
% The \xt{list} \xt{block} template is a restricted template\footnote{A |
| 4811 |
% better approach could be to have a notion of inheritance for template |
| 4812 |
% types, so that we end up with two different \emph{template types}. Then |
| 4813 |
% we can implement other template for the list template type: \xt{table} |
| 4814 |
% for lists typeset as rows/columns of a table, \xt{inline} for lists |
| 4815 |
% typeset in horizontal mode within a paragraph, and \xt{runin} for |
| 4816 |
% run-in lists.} that omits the \texttt{heading} parameter and whose |
| 4817 |
% default for \texttt{item-instance} is non-empty. |
| 4818 |
% \begin{itemize} |
| 4819 |
% \raggedright |
| 4820 |
% \item Structural parameters: the \texttt{heading} to place before, |
| 4821 |
% \texttt{counter} name, \texttt{start} value, whether to |
| 4822 |
% \texttt{resume} a previous list, and the \texttt{item-instance} (an |
| 4823 |
% \xt{item} instance) to use when typesetting items. |
| 4824 |
% \item Vertical spacing and penalties: \texttt{begin-penalty}, |
| 4825 |
% \texttt{begin-vspace}, \texttt{begin-extra-vspace}, \texttt{item-penalty}, |
| 4826 |
% \texttt{item-vspace}, \texttt{item-par-skip}, \texttt{end-penalty}, |
| 4827 |
% \texttt{end-vspace}, \texttt{end-extra-vspace}. |
| 4828 |
% \item Horizontal spacing: \texttt{right-margin}, \texttt{left-margin}, |
| 4829 |
% \texttt{para-indent}, \texttt{item-indent}, \texttt{label-width}, |
| 4830 |
% \texttt{label-sep}. |
| 4831 |
% \end{itemize} |
| 4832 |
% A \docclass should edit these templates (or define restricted |
| 4833 |
% templates) to set up default values that depend on \tn{g_block_nesting_depth_int}, |
| 4834 |
% namely how many lists are nested overall.\footnote{Does |
| 4835 |
% \pkg{xtemplate} provide a way to specify default values that are only |
| 4836 |
% evaluated once an instance is used?} The document class should then |
| 4837 |
% set up an instance of these templates for each environment, with |
| 4838 |
% appropriate settings such as a \texttt{heading}, a suitable |
| 4839 |
% \texttt{item-instance}, or making \texttt{margin-right} equal to |
| 4840 |
% \texttt{margin-left} in a \texttt{quote} environment. |
| 4841 |
% |
| 4842 |
% The \xt{inline-list} \xt{block} template receives many fewer |
| 4843 |
% parameters. Note that \texttt{begin-vspace}, \texttt{item-vspace}, |
| 4844 |
% \texttt{end-vspace} are now \emph{horizontal} skips.\fmi{Text wrong |
| 4845 |
% and or concept with vspace and hspace questionable!} |
| 4846 |
% \begin{itemize} |
| 4847 |
% \item Structural parameters: \texttt{counter}, \texttt{start}, |
| 4848 |
% \texttt{resume}, \texttt{item-instance}. |
| 4849 |
% \item Spacing and penalties: \texttt{begin-penalty}, |
| 4850 |
% \texttt{begin-vspace}, \texttt{item-penalty}, \texttt{item-vspace}, |
| 4851 |
% \texttt{end-penalty}, \texttt{end-vspace}.\fmi{revisit!} |
| 4852 |
% \item Horizontal spacing: \texttt{label-width}, \texttt{label-sep}.\fmi{check!} |
| 4853 |
% \end{itemize} |
| 4854 |
% |
| 4855 |
% The \xt{std} \xt{item} template should receive the following |
| 4856 |
% parameters. They depend on the type of list and its nesting level |
| 4857 |
% among lists of such type, but typically not on the total nesting |
| 4858 |
% level. |
| 4859 |
% \begin{itemize} |
| 4860 |
% \item Counter name (\texttt{counter}), shared with the parent |
| 4861 |
% \xt{list} \xt{block} template, but needed for incrementing. |
| 4862 |
% \item Label construction: a function \texttt{counter-label} that |
| 4863 |
% produces the label from the counter name, used if \tn{item} is given |
| 4864 |
% without argument. |
| 4865 |
% \item References: a function \texttt{counter-ref} for how the label |
| 4866 |
% should be referred to when it is constructed from the counter, |
| 4867 |
% \texttt{label-ref} and \texttt{label-autoref} used when \tn{item} |
| 4868 |
% has an optional argument. |
| 4869 |
% \item Label formatting: \texttt{label-format} function, |
| 4870 |
% \texttt{label-strut} boolean. |
| 4871 |
% \item Label alignment (\texttt{label-align}, \texttt{label-boxed}, |
| 4872 |
% \texttt{next-line}). |
| 4873 |
% \item Content parameters: \key{text-font}. |
| 4874 |
% \item A \texttt{compatibility} boolean that controls for instance |
| 4875 |
% whether \tn{makelabel} is used. |
| 4876 |
% \end{itemize} |
| 4877 |
% The \docclass should set up an instance such as \xt{enumiii} for each |
| 4878 |
% environment and nesting level.\footnote{This should be made easily |
| 4879 |
% extendible to deeper levels.} |
| 4880 |
% |
| 4881 |
% A given environment will adjust some nesting levels, then call the |
| 4882 |
% \xt{block} instance appropriate to the environment type, passing it |
| 4883 |
% the \xt{item} instance appropriate to the environment and depth. |
| 4884 |
% Additional context-dependence could be provided by \pkg{l3ldb}, but |
| 4885 |
% the main context-dependence should not rely on it for simplicity |
| 4886 |
% reasons and incidentally because \pkg{l3ldb} is not yet available. |
| 4887 |
% |
| 4888 |
% |
| 4889 |
% \Finale |
| 4890 |
% |
| 4891 |
|
| 4892 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 4893 |
\endinput |