| 1 |
% \iffalse meta-comment |
| 2 |
% |
| 3 |
%% File: latex-lab-block.dtx (C) Copyright 2021-2026 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{2026-05-08} |
| 13 |
\def\ltlabblockversion{0.9w} |
| 14 |
|
| 15 |
%<*driver> |
| 16 |
\DocumentMetadata{tagging=on,pdfstandard=ua-2,lang=en} |
| 17 |
\documentclass[kernel]{l3in2edoc} |
| 18 |
|
| 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 |
% |
| 36 |
% |
| 37 |
% \title{Prototype reimplementation of \LaTeXe{}'s block environments using templates} |
| 38 |
% \author{\LaTeX{} Project\thanks{Initial reimplementation of lists done by Bruno |
| 39 |
% Le Floch, generalized second version with tagging support by Frank Mittelbach.}} |
| 40 |
% \date{v\ltlabblockversion\ \ltlabblockdate} |
| 41 |
% |
| 42 |
% \maketitle |
| 43 |
% |
| 44 |
% |
| 45 |
% \newcommand{\xt}[1]{\textsl{\textsf{#1}}} |
| 46 |
% \newcommand{\TODO}[1]{\textbf{[TODO:} #1\textbf{]}} |
| 47 |
% \newcommand{\docclass}{document class \marginpar{\raggedright document class |
| 48 |
% customizations}} |
| 49 |
% |
| 50 |
% \providecommand\struct[1]{\texttt{<#1>}} |
| 51 |
% |
| 52 |
% \newcommand\key[1]{\texttt{#1}} |
| 53 |
% \newcommand\keyvalue[1]{\texttt{#1}} |
| 54 |
% \newcommand\valuefrom[1]{\textrm{value from }\key{#1}} |
| 55 |
% |
| 56 |
% \newcommand\instname[1]{\texttt{#1}} |
| 57 |
% \newcommand\insttype[1]{\texttt{#1}} |
| 58 |
% |
| 59 |
% \NewDocumentCommand\fmi{sO{}m} |
| 60 |
% {\IfBooleanTF{#1}{\todo[inline,#2]{#3}}^^A |
| 61 |
% {\todo[#2]{#3}}} |
| 62 |
% |
| 63 |
% \NewDocumentCommand\ufi{sO{}m} |
| 64 |
% {\IfBooleanTF{#1}{\todo[inline,#2]{UFi:#3}}^^A |
| 65 |
% {\todo[#2]{UFi:#3}}} |
| 66 |
% |
| 67 |
% |
| 68 |
% \begin{abstract} |
| 69 |
% \end{abstract} |
| 70 |
% |
| 71 |
% |
| 72 |
% \tableofcontents |
| 73 |
% \medskip |
| 74 |
% |
| 75 |
% |
| 76 |
% \begin{documentation} |
| 77 |
% |
| 78 |
% \changes{v0.9p}{2026-03-12}{Switch from \texttt{x}- to \texttt{e}-type |
| 79 |
% expansion in expl3 code} |
| 80 |
% |
| 81 |
% \section{Introduction} |
| 82 |
% |
| 83 |
% The list implementation in \LaTeXe{} serves a dual purpose: it |
| 84 |
% implements real lists such as \env{itemize} or \env{enumerate}, |
| 85 |
% but it is also used as the basis for vertical blocks, i.e., to specify |
| 86 |
% the vertical spacing and paragraph handling after such block, e.g., |
| 87 |
% in environments like \env{center}, \env{quote}, \env{verbatim}, or in |
| 88 |
% the theorem environments. They are all implemented as |
| 89 |
% \enquote{trivial} lists with a single (hidden) item. |
| 90 |
% |
| 91 |
% While this was convenient to get a consistent layout using a single |
| 92 |
% implementation it is not adequate if it comes to interpreting the |
| 93 |
% structure of a document, because environments based on \env{trivlist} |
| 94 |
% should not advertise themselves as being a \enquote{list} --- after all, |
| 95 |
% from a semantic point of view they aren't lists. |
| 96 |
% |
| 97 |
% The approach taking here is therefore to offer separate template |
| 98 |
% types: \insttype{block} (horizontally or vertically oriented data that |
| 99 |
% needs some handling at the start and the end), \insttype{para} (that deals |
| 100 |
% with different paragraph layouts), \insttype{list} (that handles list |
| 101 |
% related parameters, and \insttype{item} (for item layouts and handling). |
| 102 |
% |
| 103 |
% To address the independent aspects we have the template type |
| 104 |
% \insttype{blockenv} that ties them together as necessary when we |
| 105 |
% build document level environments. |
| 106 |
% |
| 107 |
% For example, a \env{quote} environment would make use of a (display) |
| 108 |
% \insttype{block} and some \insttype{para} instance while a standard |
| 109 |
% \env{enumerate} would make use of a display \insttype{block}, a \insttype{list}, |
| 110 |
% and an \insttype{item} and a \insttype{para} instance. |
| 111 |
% An inline list (like \env{enumerate*} from the \pkg{enumitem} |
| 112 |
% package) would be using the same \insttype{list} instance but a different |
| 113 |
% (horizontally oriented) \insttype{block} instance build from a |
| 114 |
% different template. |
| 115 |
% |
| 116 |
% Instead of a \insttype{list} instance to handle the inner structure |
| 117 |
% of the environment one can use an instance of the type |
| 118 |
% \insttype{captionedtext} to produce a display environment with an |
| 119 |
% associated heading/caption, such as a theorem-like environment or a |
| 120 |
% proof environment. Further possibilities (not yet implemented) are |
| 121 |
% templates for producing boxed text or formal quotes like those |
| 122 |
% produced by the \pkg{csquotes} package. |
| 123 |
% |
| 124 |
% |
| 125 |
% \section{Template types and templates for blocks and lists} |
| 126 |
% |
| 127 |
% \subsection{Template types} |
| 128 |
% |
| 129 |
% |
| 130 |
% \begin{TemplateInterfaceDescription}{blockenv} |
| 131 |
% \TemplateArgument{1}{key/value list to alter the default parameters of the template |
| 132 |
% instances used by the particular blockenv environment} |
| 133 |
% \TemplateArgument{2}{Boolean to suppress a number in case this |
| 134 |
% environment normally produces a numbered caption} |
| 135 |
% \TemplateArgument{3}{Caption/heading text in case this environment |
| 136 |
% supports a caption (most don't), otherwise \cs{NoValue}} |
| 137 |
% \TemplateArgument{4}{Sub-caption/heading text in case this environment |
| 138 |
% supports a caption (most don't), otherwise \cs{NoValue}} |
| 139 |
% \TemplateSemantics |
| 140 |
% This template type is used to implement document-level |
| 141 |
% environments. It defines a \insttype{block} instance to handle the |
| 142 |
% layout at the \enquote{edge} of the environment data, possibly |
| 143 |
% some paragraph setup through a \insttype{para} instance, potentially an |
| 144 |
% \enquote{inner} instance for more complicated environments (such |
| 145 |
% as lists), and possibly some additional setup code for certain |
| 146 |
% environments. |
| 147 |
% |
| 148 |
% Arguments 2--4 are passed to the instance handling the inner |
| 149 |
% structure, e.g., \insttype{list} or \insttype{captionedtext} |
| 150 |
% which may or may not make use of it. |
| 151 |
% |
| 152 |
% It also defines how the \insttype{blockenv} behaves with respect to |
| 153 |
% nesting, e.g., does it change when nested and if so how many |
| 154 |
% levels of nesting are supported, etc. |
| 155 |
% |
| 156 |
% Finally, the template type defines how it appears in a tagged PDF |
| 157 |
% document, what tag names are used, how they are role-mapped and |
| 158 |
% whether it adds additional attributes, etc. |
| 159 |
% \end{TemplateInterfaceDescription} |
| 160 |
% |
| 161 |
% \begin{TemplateInterfaceDescription}{block} |
| 162 |
% \TemplateArgument{1}{key/value list to alter the default block parameters} |
| 163 |
% \TemplateSemantics |
| 164 |
% Handle the layout aspects of a block of data. In case of a |
| 165 |
% \enquote{display} block (i.e., vertically oriented) the spacing |
| 166 |
% and page breaking as well as the handling if the block starts a |
| 167 |
% paragraph or ends one, that is, if text is immediately following |
| 168 |
% the block without being separated by an empty line, then this |
| 169 |
% text is considered to be in the same paragraph as the block. |
| 170 |
% |
| 171 |
% In case of a horizontally oriented block it covers any special |
| 172 |
% handling at the start and end of the block, e.g, extra spacing, |
| 173 |
% prohibiting or encouraging line breaks, and so forth. |
| 174 |
% \end{TemplateInterfaceDescription} |
| 175 |
% |
| 176 |
% \begin{TemplateInterfaceDescription}{para} |
| 177 |
% \TemplateArgument{1}{key/value list to alter the default paragraph parameters} |
| 178 |
% \TemplateSemantics |
| 179 |
% Sets up paragraph-specific parameters for H\&J, e.g., to |
| 180 |
% implement justification variations, the behavior of \verb=\\= |
| 181 |
% etc. The instances are used in higher-level templates, e.g., in a |
| 182 |
% \insttype{block}. |
| 183 |
% \end{TemplateInterfaceDescription} |
| 184 |
% |
| 185 |
% \begin{TemplateInterfaceDescription}{list} |
| 186 |
% \TemplateArgument{1}{key/value list to alter the default list parameters} |
| 187 |
% \TemplateArgument{2}{Boolean to suppress a number in case this |
| 188 |
% list environment also produces a numbered heading/caption} |
| 189 |
% \TemplateArgument{3}{Caption/heading text in case this environment |
| 190 |
% supports a caption (lists normally don't), otherwise \cs{NoValue}} |
| 191 |
% \TemplateArgument{4}{Sub-caption/heading text in case this environment |
| 192 |
% supports a caption, otherwise \cs{NoValue}} |
| 193 |
% \TemplateSemantics |
| 194 |
% Handle the aspects related to list design, e.g., the use and |
| 195 |
% formatting of counters, etc. |
| 196 |
% |
| 197 |
% Standard \LaTeXe{} lists have no heading/caption, so arguments |
| 198 |
% 2--4 are ignored in the standard \insttype{list} template. But |
| 199 |
% special lists, such as a list of ingredients for a cookbook, |
| 200 |
% might so there might be other templates that make use of them in |
| 201 |
% the future. |
| 202 |
% |
| 203 |
% Note that this template type does not cover block-related |
| 204 |
% aspects, i.e., a list instance could be used both for a display |
| 205 |
% list or for an inline list. |
| 206 |
% \end{TemplateInterfaceDescription} |
| 207 |
% |
| 208 |
% \begin{TemplateInterfaceDescription}{captionedtext} |
| 209 |
% \TemplateArgument{1}{key/value list to alter the default captiontext parameters} |
| 210 |
% \TemplateArgument{2}{Boolean to suppress a number in case this |
| 211 |
% environment also produces a numbered heading/caption} |
| 212 |
% \TemplateArgument{3}{Caption/heading text for this text block; if |
| 213 |
% not given then \cs{NoValue}} |
| 214 |
% \TemplateArgument{4}{Sub-caption/heading text in case this environment |
| 215 |
% supports a caption, otherwise \cs{NoValue}} |
| 216 |
% \TemplateSemantics |
| 217 |
% Produces a text block with an associated caption/heading, e.g., a |
| 218 |
% theorem-like environment. There may not be a user-supplied |
| 219 |
% caption text---the caption may consist of a fixed text only like ``Lemma''. |
| 220 |
% |
| 221 |
% Handles the aspects related to the caption design and typically |
| 222 |
% supports keys for adjusting the layout of the body text, |
| 223 |
% e.g., its font, etc. |
| 224 |
% |
| 225 |
% Note that this template type does not cover block-related |
| 226 |
% aspects, e.g., the dimensions of the display block are handled there. |
| 227 |
% \end{TemplateInterfaceDescription} |
| 228 |
% |
| 229 |
% \begin{TemplateInterfaceDescription}{item} |
| 230 |
% \TemplateArgument{1}{key/value list to alter the default item parameters} |
| 231 |
% \TemplateSemantics |
| 232 |
% A sub-type used as part of \insttype{list} to easily cover alternative layout |
| 233 |
% for list items. |
| 234 |
% \end{TemplateInterfaceDescription} |
| 235 |
% |
| 236 |
% \begin{TemplateInterfaceDescription}{thmstyle} |
| 237 |
% \TemplateArgument{1}{key/value list to alter the default thmstyle parameters} |
| 238 |
% \TemplateArgument{2}{Boolean to suppress a number in case this |
| 239 |
% environment also produces a numbered heading/caption} |
| 240 |
% \TemplateArgument{3}{Caption/heading text for this text block; if |
| 241 |
% not given then \cs{NoValue}} |
| 242 |
% \TemplateArgument{4}{Sub-caption/heading text in case this environment |
| 243 |
% supports a caption, otherwise \cs{NoValue}} |
| 244 |
% \TemplateSemantics |
| 245 |
% A sub-type used as part of \insttype{captionedtext} when |
| 246 |
% producing theorem-like environments. It does the bulk of the work |
| 247 |
% and sets up most of the formatting. It has been separated out |
| 248 |
% because many theorem-like environments use the same theorem |
| 249 |
% layout and only differ in the fixed caption text they |
| 250 |
% generate. |
| 251 |
% |
| 252 |
% Not all templates of type \insttype{captionedtext} use |
| 253 |
% \insttype{thmstyle} as an inner instance, e.g., proofs are |
| 254 |
% implemented with a template that does everything necessary |
| 255 |
% directly. |
| 256 |
% \end{TemplateInterfaceDescription} |
| 257 |
% |
| 258 |
% |
| 259 |
% |
| 260 |
% \subsection{Templates} |
| 261 |
% |
| 262 |
% |
| 263 |
% \begin{TemplateDescription}{blockenv}{std} |
| 264 |
% |
| 265 |
% \TemplateKey{name}{tokenlist} |
| 266 |
% {Name of the environment used in tracing and error messages.}{} |
| 267 |
% \TemplateKey{tag-name}{tokenlist} |
| 268 |
% {Name of the tag used for the block inside the PDF. If not explicitly given |
| 269 |
% the name is defined by the \key{tagging-recipe}. Note that in case of |
| 270 |
% \key{tagging-recipe}\texttt{=basic} no tag for the block is produced, so any |
| 271 |
% key settings are ignored.}{\meta{empty}} |
| 272 |
% \TemplateKey{tag-attr-class}{tokenlist} |
| 273 |
% {An explicit tag class attribute.}{\meta{empty}} |
| 274 |
% \TemplateKey{tagging-recipe}{tokenlist} |
| 275 |
% {Defines the way tagging is done. Currently the values |
| 276 |
% \keyvalue{basic}, \keyvalue{standard}, and \keyvalue{list} |
| 277 |
% are supported.}{standard} |
| 278 |
% \TemplateKey{transparent-level}{boolean}{Is this \insttype{blockenv} |
| 279 |
% transparent for any blocks nested inside?}{false} |
| 280 |
% \TemplateKey{legacy-code}{tokenlist} |
| 281 |
% {Legacy setup code. This is |
| 282 |
% executed after legacy defaults (from \tn{@listi}, |
| 283 |
% \tn{@listii}, etc.) are used but before the block instance |
| 284 |
% is called.}{\meta{empty}} |
| 285 |
% \TemplateKey{block-instance}{tokenlist}{Part of the name of the |
| 286 |
% \insttype{block} instance that is called. The full name has |
| 287 |
% a \texttt{-}\meta{level} appended.}{std-display} |
| 288 |
% \TemplateKey{para-instance}{tokenlist}{Paragraph settings to use |
| 289 |
% within the environment. If \meta{empty} then the |
| 290 |
% current (outer) values are |
| 291 |
% retained. However, the \key{inner-instance} template |
| 292 |
% might reset/overwrite some of the \instname{para} |
| 293 |
% values, e.g., \instname{list} makes used of |
| 294 |
% \cs{listparindent} to explicitly set the paragraph indentation |
| 295 |
% for compatibility.}{\meta{empty}} |
| 296 |
% \TemplateKey{inner-level-counter}{tokenlist}{Name of an existing (!) counter |
| 297 |
% that is incremented and used to determine final name |
| 298 |
% of the \key{inner-instance} or empty if always the |
| 299 |
% same inner instance should be used.}{} |
| 300 |
% \TemplateKey{max-inner-levels}{tokenlist}{Maximum number of nested |
| 301 |
% environments of this kind. Only relevant if there is a |
| 302 |
% \key{inner-level-counter} specified.}{4} |
| 303 |
% \TemplateKey{inner-instance-type}{tokenlist}{Template type of the |
| 304 |
% inner instance. Currently supported types are |
| 305 |
% \insttype{list} and \insttype{captionedtext}.}{\meta{empty}} |
| 306 |
% \TemplateKey{inner-instance}{tokenlist}{Name of the inner instance |
| 307 |
% (if any). If there is an \key{inner-level-counter} then |
| 308 |
% the instance name gets \texttt{-}\meta{counter value} |
| 309 |
% appended.}{\meta{empty}} |
| 310 |
% \TemplateKey{tagging-suppress-paras}{boolean}{\emph{describe}}{false} |
| 311 |
% \TemplateKey{final-code}{tokenlist}{Final setup code}{\tn{ignorespaces}} |
| 312 |
% |
| 313 |
% \TemplateSemantics |
| 314 |
% |
| 315 |
% The \insttype{blockenv} type handles the overall setup for the |
| 316 |
% document-level environments. |
| 317 |
% |
| 318 |
% This \insttype{blockenv} template supports the legacy list setting that |
| 319 |
% are found in many document classes in the macros \tn{@listi}, |
| 320 |
% \tn{@listii}, up to \tn{@listvi}. It also uses the counter |
| 321 |
% \tn{@listdepth} to track nesting of block, again mainly to |
| 322 |
% support legacy setups (internally it gives it a more appropriate |
| 323 |
% name but it remains accessible through the \LaTeXe{} name). |
| 324 |
% |
| 325 |
% |
| 326 |
% The internal block nesting level is stored (for historical |
| 327 |
% reasons) in the \tn{@listdepth} counter and incremented by each |
| 328 |
% block by one. The starting value at top-level (outside any block) |
| 329 |
% is zero. A block environment with |
| 330 |
% \key{transparent-level}\texttt{=true} also increments the level |
| 331 |
% before it evaluates and sets its parameters but then decrements |
| 332 |
% it again, just before it starts processing its body. |
| 333 |
% |
| 334 |
% The template first checks that the block is not too deeply nested. |
| 335 |
% |
| 336 |
% After the level was increased then corresponding \tn{@list...} macro |
| 337 |
% to update the legacy defaults is called. |
| 338 |
% |
| 339 |
% It then sets up the |
| 340 |
% tagging via the \key{tagging-recipe} setting and executes any |
| 341 |
% code in \key{legacy-code}. |
| 342 |
% |
| 343 |
% Afterwards it calls the appropriate \insttype{block} instance |
| 344 |
% based on \key{block-instance} and current level, e.g., |
| 345 |
% \texttt{std-display-1}. |
| 346 |
% |
| 347 |
% Then it sets up paragraph parameters if |
| 348 |
% a \key{para-instance} was specified (otherwise they stay as |
| 349 |
% they are). |
| 350 |
% |
| 351 |
% If a \key{inner-instance} was specified this is called next, |
| 352 |
% or more precisely: if no \key{inner-level-counter} was |
| 353 |
% specified the instance \key{inner-instance} is |
| 354 |
% called. |
| 355 |
% |
| 356 |
% Otherwise, the \key{inner-level-counter} is incremented and the |
| 357 |
% instance with the name |
| 358 |
% \key{inner-instance}\texttt{-}\key{inner-level-counter} is |
| 359 |
% called. |
| 360 |
% |
| 361 |
% Finally, the \key{final-code} is executed (by default |
| 362 |
% \tn{ignorespaces}). |
| 363 |
% |
| 364 |
% |
| 365 |
% \end{TemplateDescription} |
| 366 |
% |
| 367 |
% The maximum number of \insttype{blockenv}s that can be nested into each |
| 368 |
% other is restricted by the \LaTeX{} counter |
| 369 |
% \texttt{maxblocklevels} with a default value of \keyvalue{6}. If this |
| 370 |
% value is increased then it is necessary to provide additional |
| 371 |
% instances, e.g., \texttt{std-display-7}, etc. Decreasing is, of |
| 372 |
% course, always possible, then some of the instances defined are not |
| 373 |
% used and instead the user gets an error that there is too much |
| 374 |
% nesting going on. |
| 375 |
% |
| 376 |
% If the key \key{transparent-level} is set to \keyvalue{true} then |
| 377 |
% such an environment alters the nesting level only temporarily (while |
| 378 |
% processing the \insttype{blockenv} template) and you can therefore |
| 379 |
% nest those environments as often as you like (a typical example |
| 380 |
% would be \env{flushleft} anywhere in the nesting hierarchy) as long |
| 381 |
% as the level isn't already at \texttt{maxblocklevels}). |
| 382 |
% |
| 383 |
% |
| 384 |
% \changes{v0.9l}{2025/11/04}{Fix default for para-vspace, should be the outer \cs{parskip}} |
| 385 |
% |
| 386 |
% \begin{TemplateDescription}{block}{std} |
| 387 |
% |
| 388 |
% \TemplateKey{begin-vspace}{skip}{Vertical space before the block.}{\tn{topsep}} |
| 389 |
% \TemplateKey{begin-extra-vspace}{skip}{Extra vertical space before |
| 390 |
% the block if the block forms its own paragraph.}{\tn{partopsep}} |
| 391 |
% \TemplateKey{begin-unchained-vspace}{skip}{Vertical space before |
| 392 |
% the block to use if this is a nested block, both blocks have |
| 393 |
% items or captions, and these should not be chained; see |
| 394 |
% description below.}{.5\tn{topsep}} |
| 395 |
% \TemplateKey{para-vspace}{skip}{The default for ordinary blocks is to use the |
| 396 |
% \cs{parskip} from the outer galley. In lists and some other special blocks |
| 397 |
% this is then changed.}{\tn{parskip}} |
| 398 |
% \TemplateKey{end-vspace}{skip}{Vertical space after the |
| 399 |
% block.}{\valuefrom{begin-vspace}} |
| 400 |
% \TemplateKey{end-extra-vspace}{skip}{Extra vertical space after the |
| 401 |
% block if the block forms its own paragraph.}{\valuefrom{begin-extra-vspace}} |
| 402 |
% \TemplateKey{item-vspace}{skip}{The space in front of an item if the |
| 403 |
% block is a list; if not, the setting has no effect.}{\tn{itemsep}} |
| 404 |
% \TemplateKey{begin-penalty}{integer}{Penalty for breaking before |
| 405 |
% the block.}{\tn{@beginparpenalty}} |
| 406 |
% \TemplateKey{end-penalty}{integer}{Penalty for breaking after |
| 407 |
% the block.}{\tn{@endparpenalty}} |
| 408 |
% \TemplateKey{item-penalty}{integer}{Penalty for breaking before |
| 409 |
% an item in the list (except the first).}{\tn{@itempenalty}} |
| 410 |
% \TemplateKey{left-margin}{length}{Space on the left of the block.}{\tn{leftmargin}} |
| 411 |
% \TemplateKey{right-margin}{length}{Space on the right of the block.}{\tn{rightmargin}} |
| 412 |
% \TemplateKey{para-indent}{length}{Paragraph indention for |
| 413 |
% paragraphs within the block.}{0pt} |
| 414 |
% |
| 415 |
% \TemplateSemantics |
| 416 |
% Sets up the main block parameters, e.g. its spacing before and |
| 417 |
% after and the indentation on either side. |
| 418 |
% |
| 419 |
% It also sets up some parameter defaults for the inner level, |
| 420 |
% e.g., \texttt{item-penalty}, \texttt{item-vspace} and |
| 421 |
% \texttt{para-indent}, which may get overwritten by inner |
| 422 |
% instances that are called. |
| 423 |
% |
| 424 |
% The vertical spacing before the block covers four different use |
| 425 |
% cases: If there is a caption or an item waiting to be placed, and |
| 426 |
% this item allows for \enquote{chaining}, and the new block also wants |
| 427 |
% to place an item then no space is added (spacing was already |
| 428 |
% added by the outer block). Instead, the items are chained and |
| 429 |
% placed that the start of the block, i.e., producing a layout like the |
| 430 |
% two nested \env{itemize} environments here: |
| 431 |
% \begin{itemize} |
| 432 |
% \item \begin{itemize} |
| 433 |
% \item A second-level item |
| 434 |
% \item Another \ldots |
| 435 |
% \end{itemize} |
| 436 |
% More text for the first-level item |
| 437 |
% \item Another first-level item |
| 438 |
% \end{itemize} |
| 439 |
% In that case there is also no vertical space after the block. |
| 440 |
% If the items should not be chained (as specified by the setup of |
| 441 |
% the outer block), then one gets a result like this one (using |
| 442 |
% \env{itemize} environments inside \env{description} with |
| 443 |
% different treatment of individual description \cs{item}s): |
| 444 |
% \begin{description} |
| 445 |
% \item[label={An normal label},label-placement=chained] |
| 446 |
% \begin{itemize} |
| 447 |
% \item A second-level item |
| 448 |
% \item Another \ldots |
| 449 |
% \end{itemize} |
| 450 |
% More text for the first-level item |
| 451 |
% \item[label={An unchained label},label-placement=unchained] |
| 452 |
% \begin{itemize} |
| 453 |
% \item A second-level item |
| 454 |
% \item Another \ldots |
| 455 |
% \end{itemize} |
| 456 |
% More text for the first-level item |
| 457 |
% \item[A normal label] Another first-level item |
| 458 |
% \end{description} |
| 459 |
% If \enquote{unchaining} happens, as in the second item, then |
| 460 |
% vertical spacing with the value of \key{begin-unchained-vspace} |
| 461 |
% is used and at the end you get \key{end-vertical-space}. |
| 462 |
% |
| 463 |
% Otherwise, if there is no item or caption waiting to be placed |
| 464 |
% you get a vertical space of \key{begin-vspace} before the block |
| 465 |
% and if the block is its own paragraph you additionally get |
| 466 |
% \key{begin-extra-vspace} added to this. |
| 467 |
% |
| 468 |
% Note that \LaTeXe{} always chained the list items, so the ability |
| 469 |
% to prohibit this is a new functionality. |
| 470 |
% \end{TemplateDescription} |
| 471 |
% |
| 472 |
% |
| 473 |
% \begin{TemplateDescription}{para}{std} |
| 474 |
% |
| 475 |
% \TemplateKey{para-indent}{length}{}{\tn{parindent}} |
| 476 |
% \TemplateKey{begin-hspace}{skip}{Horizontal skip added just in |
| 477 |
% front of the indentation box if non-zero}{0pt} |
| 478 |
% \TemplateKey{left-hspace}{skip}{}{0pt} |
| 479 |
% \TemplateKey{right-hspace}{skip}{}{0pt} |
| 480 |
% \TemplateKey{end-hspace}{skip}{}{\tn{@flushglue}} |
| 481 |
% \TemplateKey{fixed-word-spaces}{boolean}{}{false} |
| 482 |
% \TemplateKey{final-hyphen-demerits}{integer}{}{5000} |
| 483 |
% \TemplateKey{newline-cmd}{function(0)}{This defines the meaning of |
| 484 |
% \cs{\bslash}}{\tn{@normalcr}} |
| 485 |
% \TemplateKey{para-attr-class}{tokenlist}{}{justify} |
| 486 |
% |
| 487 |
% \TemplateSemantics |
| 488 |
% |
| 489 |
% The \key{begin-hspace} (normally \texttt{0pt}) is the counterpart |
| 490 |
% of \key{end-hspace} (which is normally \texttt{0pt plus 1fil}). |
| 491 |
% It can be useful in special paragraph shapes. The skip is only |
| 492 |
% inserted into the paragraph if it is non-zero. If it is made |
| 493 |
% non-zero then paragraphs are always at least one line including a |
| 494 |
% construct like \verb=\noindent\par=! |
| 495 |
% |
| 496 |
% The \key{para-attr-class} takes one of the attributes \texttt{justify}, |
| 497 |
% \texttt{center}, \texttt{raggedright}, \texttt{raggedleft}. They are declared |
| 498 |
% in latex-lab-namespace. |
| 499 |
% |
| 500 |
% TODO: to be further documented |
| 501 |
% |
| 502 |
% \end{TemplateDescription} |
| 503 |
% |
| 504 |
% |
| 505 |
% |
| 506 |
% \begin{TemplateDescription}{list}{std} |
| 507 |
% |
| 508 |
% \TemplateKey{counter}{tokenlist} |
| 509 |
% {Counter name to be used in a numbered list or empty, |
| 510 |
% if the list is unnumbered.}{\meta{empty}} |
| 511 |
% \TemplateKey{item-label}{tokenlist} |
| 512 |
% {Label \enquote{string} for a fixed label or as |
| 513 |
% generated from the current \key{counter} value.}{\meta{empty}} |
| 514 |
% \TemplateKey{start}{integer} |
| 515 |
% {Start value for the counter if the list is numbered, |
| 516 |
% otherwise irrelevant.}{1} |
| 517 |
% \TemplateKey{resume}{boolean} |
| 518 |
% {Should a numbered list be resumed from the last instance? |
| 519 |
% If true value of \key{start} is ignored.}{false} |
| 520 |
% \TemplateKey{item-instance}{instance} |
| 521 |
% {Instance of type \texttt{item} to be used to format |
| 522 |
% the label string.}{basic} |
| 523 |
% \TemplateKey{item-vspace}{skip}{The space in front of an item in the |
| 524 |
% list. If not specified the value specified in the |
| 525 |
% block template instance is used.}{} |
| 526 |
% \TemplateKey{item-penalty}{integer} |
| 527 |
% {Penalty for breaking before an item (except the |
| 528 |
% first). If not specified the value specified in the |
| 529 |
% block template instance is used.}{} |
| 530 |
% \TemplateKey{item-indent}{length}{Horizontal displacement of the item.}{0pt} |
| 531 |
% \TemplateKey{label-width}{length} |
| 532 |
% {Width reserved for the formatted item label.}{\tn{labelwidth}} |
| 533 |
% \TemplateKey{label-sep}{length} |
| 534 |
% {Horizontal separation between label and following text.}{\tn{labelsep}} |
| 535 |
% \TemplateKey{legacy-support}{boolean} |
| 536 |
% {Is formatting the label via \tn{makelabel} supported?}{false} |
| 537 |
% |
| 538 |
% \TemplateSemantics |
| 539 |
% Sets up handling of list material, e.g., numbering (if any), |
| 540 |
% layout of items and list elements, and tagging, if requested. |
| 541 |
% |
| 542 |
% \end{TemplateDescription} |
| 543 |
% |
| 544 |
% |
| 545 |
% \begin{TemplateDescription}{item}{std} |
| 546 |
% |
| 547 |
% \TemplateKey{counter-label}{function{1}}{\emph{unused}.}{\tn{arabic}\{\#1\}} |
| 548 |
% \TemplateKey{counter-ref}{function{1}}{\emph{unused}.}{\valuefrom{counter-label}} |
| 549 |
% \TemplateKey{label-ref}{function{1}}{\emph{unused}.}{\#1} |
| 550 |
% \TemplateKey{label-autoref}{function{1}}{\emph{unused}.}{item~\#1} |
| 551 |
% \TemplateKey{label-format}{function{1}} |
| 552 |
% {Formatting of the label, questionable the way it is used.}{\#1} |
| 553 |
% \TemplateKey{label-strut}{boolean}{Add a \tn{strut} to the label?}{false} |
| 554 |
% \TemplateKey{label-align}{choice} |
| 555 |
% {Supported values \keyvalue{left},\keyvalue{center}, |
| 556 |
% \keyvalue{right}, and \keyvalue{parleft}. \emph{Only partly implemented}.}{right} |
| 557 |
% \TemplateKey{label-placement}{choice} |
| 558 |
% {Placement of the label in relation to a directly following label |
| 559 |
% (of a following inner list). Supported values |
| 560 |
% are \keyvalue{chained}, \keyvalue{unchained}, and |
| 561 |
% \keyvalue{standalone}.}{chained} |
| 562 |
% \TemplateKey{label-boxed}{boolean} |
| 563 |
% {Should the label be boxed?}{true} |
| 564 |
% \TemplateKey{next-line}{boolean}{}{false} |
| 565 |
% \TemplateKey{text-font}{tokenlist}{\emph{unused}.}{} |
| 566 |
% \TemplateKey{compatibility}{boolean}{}{true} |
| 567 |
% |
| 568 |
% \TemplateSemantics |
| 569 |
% |
| 570 |
% This template is only rudimentary implemented at the moment. It |
| 571 |
% probably needs other keys and the existing ones need a proper |
| 572 |
% implementation!\fmi{fix} |
| 573 |
% |
| 574 |
% \end{TemplateDescription} |
| 575 |
% |
| 576 |
% |
| 577 |
% |
| 578 |
% \begin{TemplateDescription}{captionedtext}{thmlike} |
| 579 |
% |
| 580 |
% \TemplateKey{counter}{tokenlist} |
| 581 |
% {Counter name to be used if the caption is numbered, |
| 582 |
% otherwise empty.}{\meta{empty}} |
| 583 |
% \TemplateKey{title}{tokenlist} |
| 584 |
% {Fixed part of the caption, e.g., a theorem-like |
| 585 |
% environment may want to specify \enquote{Lemma} here.}{\meta{empty}} |
| 586 |
% \TemplateKey{style}{instance} |
| 587 |
% {Instance of type \insttype{thmstyle} that actually |
| 588 |
% implements the theorem-like environment.}{plain} |
| 589 |
% \TemplateSemantics |
| 590 |
% |
| 591 |
% The template combines the fixed \key{title} and a number (if |
| 592 |
% present) with the caption text as specified on the document |
| 593 |
% element, if one is given, e.g., \enquote{Theorem 1. (Fermat)}. |
| 594 |
% See also the \texttt{proof} template, which handles this |
| 595 |
% differently. |
| 596 |
% |
| 597 |
% The bulk of the work is then outsourced to an instance of |
| 598 |
% type \insttype{thmstyle}. As many such theorem-like |
| 599 |
% environments share the same layout and only differ in the first |
| 600 |
% caption string they use, there is this split for convenience. |
| 601 |
% \end{TemplateDescription} |
| 602 |
% |
| 603 |
% |
| 604 |
% \begin{TemplateDescription}{captionedtext}{proof} |
| 605 |
% |
| 606 |
% \TemplateKey{title}{tokenlist} |
| 607 |
% {Heading for the environment unless overwritten on |
| 608 |
% document level. The default value, i.e., |
| 609 |
% \cs{proofname} resolves to \enquote{Proof} |
| 610 |
% unless changed}{\cs{proofname}} |
| 611 |
% \TemplateKey{punct}{tokenlist} |
| 612 |
% {Punctuation following the heading.}{.} |
| 613 |
% \TemplateKey{caption-placement}{choice} |
| 614 |
% {Supported values |
| 615 |
% \keyvalue{chained},\keyvalue{unchained}, and |
| 616 |
% \keyvalue{standalone}}{unchained} |
| 617 |
% \TemplateKey{caption-unbreakable}{boolean} |
| 618 |
% {Can this caption have (implicit or explicit) line breaks?}{false} |
| 619 |
% \TemplateKey{before-hspace}{skip} |
| 620 |
% {Horizontal displacement of the heading.}{0pt} |
| 621 |
% \TemplateKey{after-hspace}{skip} |
| 622 |
% {Space following the heading, only relevant if text |
| 623 |
% follows on the same line.}{5pt} |
| 624 |
% \TemplateKey{caption-decls}{tokenlist} |
| 625 |
% {Declarations that are applied to the whole caption, |
| 626 |
% e.g., some font settings.}{\meta{empty}} |
| 627 |
% \TemplateKey{title-decls}{tokenlist} |
| 628 |
% {Declarations that are applied only to the caption |
| 629 |
% title.}{\meta{empty}} |
| 630 |
% \TemplateKey{punct-decls}{tokenlist} |
| 631 |
% {Declarations that are applied only to the caption |
| 632 |
% punctuation.}{\meta{empty}} |
| 633 |
% \TemplateKey{title-format}{function{1}} |
| 634 |
% {Formatting applied to the \key{title} value.}{\#1} |
| 635 |
% \TemplateKey{punct-format}{function{1}} |
| 636 |
% {Formatting applied to the \key{punct} value.}{\#1} |
| 637 |
% \TemplateKey{body-decls}{tokenlist} |
| 638 |
% {Declarations that are applied to body of the |
| 639 |
% environment, e.g., font settings.}{\meta{empty}} |
| 640 |
% \TemplateSemantics |
| 641 |
% |
| 642 |
% The \enquote{unnumbered?} argument (\texttt{\#2}) is ignored, as |
| 643 |
% proofs aren't numbered. The template makes use of the caption |
| 644 |
% argument (\texttt{\#3}) but in contrast to theorem-like |
| 645 |
% environments this template replaces the \key{title} key value with the content of |
| 646 |
% this argument (if not \cs{NoValue}). |
| 647 |
% |
| 648 |
% Typically there is only one layout for proofs so that there is no |
| 649 |
% need to split the formatting over two templates as done for |
| 650 |
% theorem-like environment. That's the reason why the template has |
| 651 |
% several layout customization parameters. |
| 652 |
% \end{TemplateDescription} |
| 653 |
% |
| 654 |
% |
| 655 |
% \begin{TemplateDescription}{thmstyle}{std} |
| 656 |
% |
| 657 |
% \TemplateKey{numbered}{boolean} |
| 658 |
% {Is this kind of environment numbered?}{true} |
| 659 |
% \TemplateKey{separator}{tokenlist} |
| 660 |
% {Separation to be applied between elements of the |
| 661 |
% heading, typically a space command of some |
| 662 |
% sort.}{\textbackslash\textvisiblespace } |
| 663 |
% \TemplateKey{punct}{tokenlist} |
| 664 |
% {Punctuation following the heading.}{.} |
| 665 |
% \TemplateKey{caption-placement}{choice} |
| 666 |
% {Supported values |
| 667 |
% \keyvalue{chained},\keyvalue{unchained}, and |
| 668 |
% \keyvalue{standalone}}{unchained} |
| 669 |
% \TemplateKey{caption-unbreakable}{boolean} |
| 670 |
% {Can this caption have (implicit or explicit) line breaks?}{false} |
| 671 |
% \TemplateKey{before-hspace}{skip} |
| 672 |
% {Horizontal displacement of the heading.}{0pt} |
| 673 |
% \TemplateKey{after-hspace}{skip} |
| 674 |
% {Space following the heading, only relevant if text |
| 675 |
% follows on the same line.}{5pt} |
| 676 |
% \TemplateKey{order}{commalist} |
| 677 |
% {Order of elements in the environment |
| 678 |
% caption/heading. Supported values are \texttt{title}, |
| 679 |
% \texttt{number}, \texttt{punct}, \texttt{separator}, and |
| 680 |
% \texttt{note}.}{title,separator,number,separator,note,punct} |
| 681 |
% \TemplateKey{title-decls}{tokenlist} |
| 682 |
% {Declarations that are applied only to the caption |
| 683 |
% title.}{\meta{empty}} |
| 684 |
% \TemplateKey{number-decls}{tokenlist} |
| 685 |
% {Declarations that are applied only to the caption |
| 686 |
% number.}{\meta{empty}} |
| 687 |
% \TemplateKey{punct-decls}{tokenlist} |
| 688 |
% {Declarations that are applied only to the caption |
| 689 |
% punctuation.}{\meta{empty}} |
| 690 |
% \TemplateKey{note-decls}{tokenlist} |
| 691 |
% {Declarations that are applied only to the caption |
| 692 |
% note.}{\meta{empty}} |
| 693 |
% \TemplateKey{title-format}{function{1}} |
| 694 |
% {Formatting applied to the \key{title} value.}{\#1} |
| 695 |
% \TemplateKey{number-format}{function{1}} |
| 696 |
% {Formatting applied to the \key{number} value.}{\#1} |
| 697 |
% \TemplateKey{punct-format}{tokenlist} |
| 698 |
% {Formatting applied to the \key{punct} value.}{\#1} |
| 699 |
% \TemplateKey{note-format}{function{1}} |
| 700 |
% {Formatting applied to the \key{note} value.}{(\#1)} |
| 701 |
% \TemplateKey{body-decls}{tokenlist} |
| 702 |
% {Declarations that are applied to body of the |
| 703 |
% environment, e.g., font settings.}{\meta{empty}} |
| 704 |
% |
| 705 |
% \TemplateSemantics |
| 706 |
% |
| 707 |
% Numbering of the environment is suppressed unconditionally if the |
| 708 |
% \key{numbered} is set to \keyvalue{false}. Otherwise the |
| 709 |
% environment is numbered except when \texttt{\#2} is |
| 710 |
% \cs{BooleanTrue}, i.e., if the star form of the environment was |
| 711 |
% used. |
| 712 |
% |
| 713 |
% The caption of the environment can consist of a title, a number, |
| 714 |
% a punctuation, some separators (typically spaces) and a note. Their order is defined by |
| 715 |
% the key \key{order}. If a component is specified but has no |
| 716 |
% value, e.g., no note or the numbering suppressed on an individual |
| 717 |
% environment, then the component and any preceding separators are |
| 718 |
% ignored. |
| 719 |
% |
| 720 |
% Spaces between elements are uniform (as one can only specify a |
| 721 |
% \texttt{separator} in the \key{order} key), but it is possible to |
| 722 |
% use this several times in a row and adjust the \key{separator} key |
| 723 |
% accordingly. |
| 724 |
% |
| 725 |
% Alternatively, one can omit using \texttt{separator} in the |
| 726 |
% \key{order} key and instead put all necessary spacing into the |
| 727 |
% individual \key{...-format} keys. This approach is used, for example, if a |
| 728 |
% theorem style is set up with \cs{newtheoremstyle} and its ninth |
| 729 |
% argument contains a declaration such as |
| 730 |
%\begin{verbatim} |
| 731 |
% \thmname{#1}\thmnumber{ #2}\thmnote{ (#3)} |
| 732 |
%\end{verbatim} |
| 733 |
% This is then translated to |
| 734 |
%\begin{verbatim} |
| 735 |
% order = {title,number,punct,note} , |
| 736 |
% title-format = {#1} , |
| 737 |
% number-format = { #2} , |
| 738 |
% note-format = { (#3)} , |
| 739 |
%\end{verbatim} |
| 740 |
% when \cs{newtheoremstyle} sets up a new instance. |
| 741 |
% The downside of this approach is that \cs{swapnumbers} would not |
| 742 |
% work with such styles (because it would be necessary to transfer the |
| 743 |
% space inside value for the \key{number-format} key to the value |
| 744 |
% of \key{title-format}). |
| 745 |
% |
| 746 |
% If you look closely you also see that in the \key{order} key a |
| 747 |
% \texttt{punct} was added in the list even though it was not present |
| 748 |
% originally. This is the way \cs{newtheoremstyle} worked and so |
| 749 |
% we mimic that. |
| 750 |
% \end{TemplateDescription} |
| 751 |
% |
| 752 |
% |
| 753 |
% |
| 754 |
% |
| 755 |
% \section{Declaring standard display block environments and their instances} |
| 756 |
% |
| 757 |
% Historically the \LaTeX{} kernel has defined a number of block |
| 758 |
% environments directly, e.g., \env{center} or lists like |
| 759 |
% \env{itemize}, but left others to be set up by document |
| 760 |
% classes. For now we declare all of them here, but in the future, |
| 761 |
% some (or even all) might get moved to new class files. |
| 762 |
% |
| 763 |
% \noindent |
| 764 |
% \DescribeMacro\SimpleBlockEnv |
| 765 |
% Most of the standard block environments have no need for a caption, |
| 766 |
% so to simplify the setup we have added the command |
| 767 |
% \cs{SimpleBlockEnv} that hides the arguments 2--4 required by a |
| 768 |
% \insttype{blockenv} instance and gives them suitable values, i.e., |
| 769 |
% \cs{BooleanFalse}\cs{NoValue}\cs{Novalue}. This way, a document |
| 770 |
% level definition for the \env{center} environment will look like this: |
| 771 |
% \begin{verbatim} |
| 772 |
% \NewDocumentEnvironment{center} { !O{} } |
| 773 |
% { \SimpleBlockEnv{center}{#1} } { \BlockEnvEnd } |
| 774 |
% \end{verbatim} |
| 775 |
% instead of the more verbose |
| 776 |
% \begin{verbatim} |
| 777 |
% \NewDocumentEnvironment{center} { !O{} } |
| 778 |
% { \UseInstance{blockenv}{center}{#1} \BooleanFalse \NoValue \NoValue } |
| 779 |
% { \BlockEnvEnd } |
| 780 |
% \end{verbatim} |
| 781 |
% |
| 782 |
% We use \verb=!O{}= for the optional argument so that it is only |
| 783 |
% recognized if it immediately follows \verb=\begin{center}= without |
| 784 |
% any spaces to avoid that a \texttt{[} at the start of the body text |
| 785 |
% is misinterpreted as the opening bracket of the optional |
| 786 |
% argument. This is only done for environments where this could be a |
| 787 |
% problem. |
| 788 |
% |
| 789 |
% This will then call the \texttt{center} instance of type |
| 790 |
% \insttype{blockenv} that handles the rest. |
| 791 |
% |
| 792 |
% \noindent |
| 793 |
% \DescribeMacro\BlockEnv |
| 794 |
% \DescribeMacro\BlockEnvEnd |
| 795 |
% For the environments that make use of the other arguments, we |
| 796 |
% offer \cs{BlockEnv} as syntactic sugar so that most environment |
| 797 |
% declarations look similar. And we use \cs{BlockEnvEnd} in both |
| 798 |
% cases to finish off. |
| 799 |
% \begin{macrocode} |
| 800 |
%<*class-code> |
| 801 |
% \end{macrocode} |
| 802 |
% |
| 803 |
% In the following sections we provide for all block environments |
| 804 |
% the top-level definition and all instances that are used by |
| 805 |
% it. Instances of type \insttype{block} are often reused across |
| 806 |
% the environments, in which case we just provide |
| 807 |
% cross-references. Note that this is a design decision, different |
| 808 |
% classes may want to have adjusted settings for individual |
| 809 |
% environments, in which case they would provide special |
| 810 |
% \insttype{block} instances instead of reusing, say, the |
| 811 |
% \instname{std-display-\meta{level}} instances. |
| 812 |
% |
| 813 |
% |
| 814 |
% \subsection{The \env{display} and \env{displayflattened} environments} |
| 815 |
% |
| 816 |
% |
| 817 |
% \begin{environment}{displayblock,displayblockflattened} |
| 818 |
% There are two basic block environments (\env{displayblock} and |
| 819 |
% \env{displayblockflattened}) which are similar to \LaTeXe{}'s |
| 820 |
% \env{trivlist} except that they aren't degenerated lists and |
| 821 |
% thus have no hidden \tn{item} inside. |
| 822 |
% |
| 823 |
% \begin{macrocode} |
| 824 |
\NewDocumentEnvironment{displayblock}{ !O{} } |
| 825 |
{ \SimpleBlockEnv{displayblock} {#1} } { \BlockEnvEnd } |
| 826 |
% \end{macrocode} |
| 827 |
% |
| 828 |
% \begin{macrocode} |
| 829 |
\NewDocumentEnvironment{displayblockflattened}{ !O{} } |
| 830 |
{ \SimpleBlockEnv{displayblockflattened} {#1} } { \BlockEnvEnd } |
| 831 |
% \end{macrocode} |
| 832 |
% \end{environment} |
| 833 |
% |
| 834 |
% \subsubsection{Their \insttype{blockenv} instances} |
| 835 |
% |
| 836 |
% \begin{instance}{blockenv displayblock} |
| 837 |
% This is like \LaTeXe{}'s \env{trivlist}, i.e., it produces a |
| 838 |
% vertical block with default setting, but doesn't put a list |
| 839 |
% inside but uses a \struct{Div} structure. |
| 840 |
% |
| 841 |
% We list all keys, those with default values, commented out. |
| 842 |
% \begin{macrocode} |
| 843 |
\DeclareInstance{blockenv}{displayblock}{std} |
| 844 |
{ |
| 845 |
name = displayblock |
| 846 |
% ,tagging-recipe = standard |
| 847 |
% ,tag-name = |
| 848 |
% ,tag-attr-class = |
| 849 |
,transparent-level = true |
| 850 |
% ,legacy-code = |
| 851 |
% ,block-instance = std-display |
| 852 |
% ,para-instance = |
| 853 |
% ,tagging-suppress-paras = false |
| 854 |
% ,inner-instance = |
| 855 |
% ,inner-instance-type = % not relevant as there is no inner instance |
| 856 |
% ,inner-level-counter = % not relevant as there is no inner instance |
| 857 |
% ,max-inner-levels = 4 % not relevant as there is no inner instance |
| 858 |
% ,final-code = \ignorespaces |
| 859 |
} |
| 860 |
% \end{macrocode} |
| 861 |
% |
| 862 |
% The \insttype{block} uses the instance \instname{std-display} |
| 863 |
% which is shown below. |
| 864 |
% \end{instance} |
| 865 |
% |
| 866 |
% |
| 867 |
% |
| 868 |
% \begin{instance}{blockenv displayblockflattened} |
| 869 |
% This flattens inner paragraphs without any surrounding tag |
| 870 |
% structure by using the \keyvalue{basic} tagging recipe. |
| 871 |
% \begin{macrocode} |
| 872 |
\DeclareInstance{blockenv}{displayblockflattened}{std} |
| 873 |
{ |
| 874 |
name = displayblockflattened |
| 875 |
,tagging-recipe = basic |
| 876 |
,tagging-suppress-paras = true |
| 877 |
,transparent-level = true |
| 878 |
} |
| 879 |
% \end{macrocode} |
| 880 |
% \end{instance} |
| 881 |
% |
| 882 |
% |
| 883 |
% |
| 884 |
% \subsubsection{Their \insttype{block} instances} |
| 885 |
% \label{sec:std-display} |
| 886 |
% |
| 887 |
% We provide 6 nesting levels (as in \LaTeXe{}). If you want to |
| 888 |
% provide more you need to change the \texttt{maxblocklevels} |
| 889 |
% counter, offer further \texttt{std-display-\meta{level}} instances but |
| 890 |
% also define further (legacy) \tn{list\meta{romannumeral}} commands |
| 891 |
% for the defaults. If not, then the settings from the previous |
| 892 |
% level are reused automatically---which may or may not be good enough). |
| 893 |
% \begin{macrocode} |
| 894 |
\setcounter{maxblocklevels}{6} |
| 895 |
% \end{macrocode} |
| 896 |
% |
| 897 |
% \begin{instance}{block std-display-1, |
| 898 |
% block std-display-2, |
| 899 |
% block std-display-3, |
| 900 |
% block std-display-4, |
| 901 |
% block std-display-5, |
| 902 |
% block std-display-6 } |
| 903 |
% ^^A |
| 904 |
% We show all keys here for reference, with those using their |
| 905 |
% default values commented out: |
| 906 |
% \begin{macrocode} |
| 907 |
\DeclareInstance{block}{std-display-1}{std} |
| 908 |
{ |
| 909 |
% ,begin-vspace = \topsep |
| 910 |
% ,begin-extra-vspace = \partopsep |
| 911 |
% ,para-vspace = \parskip |
| 912 |
% ,end-vspace = \KeyValue{begin-vspace} |
| 913 |
% ,end-extra-vspace = \KeyValue{begin-extra-vspace} |
| 914 |
% ,item-vspace = \itemsep |
| 915 |
% ,begin-penalty = \UseName{@beginparpenalty} |
| 916 |
% ,end-penalty = \UseName{@endparpenalty} |
| 917 |
,left-margin = 0pt |
| 918 |
% ,right-margin = \rightmargin |
| 919 |
% ,para-indent = 0pt |
| 920 |
} |
| 921 |
% \end{macrocode} |
| 922 |
% |
| 923 |
% \begin{macrocode} |
| 924 |
\DeclareInstanceCopy{block}{std-display-2}{std-display-1} |
| 925 |
\DeclareInstanceCopy{block}{std-display-3}{std-display-1} |
| 926 |
\DeclareInstanceCopy{block}{std-display-4}{std-display-1} |
| 927 |
\DeclareInstanceCopy{block}{std-display-5}{std-display-1} |
| 928 |
\DeclareInstanceCopy{block}{std-display-6}{std-display-1} |
| 929 |
% \end{macrocode} |
| 930 |
% \end{instance} |
| 931 |
% |
| 932 |
% |
| 933 |
% |
| 934 |
% |
| 935 |
% |
| 936 |
% |
| 937 |
% |
| 938 |
% \subsection{The \env{center}, \env{flushleft}, and \env{flushright} environments} |
| 939 |
% |
| 940 |
% All three environments use the \instname{std-display} instance as |
| 941 |
% block instance. They only differ in the choice of para instance. |
| 942 |
% |
| 943 |
% \begin{environment}{center,flushleft,flushright} |
| 944 |
% For now we redeclare various document environments as late as |
| 945 |
% possible in order to make tagging work, even if classes have changed |
| 946 |
% the definitions. Of course, this means that such changes get lost. |
| 947 |
% \begin{macrocode} |
| 948 |
\AddToHook{begindocument/before}[./legacy-core]{ |
| 949 |
% \end{macrocode} |
| 950 |
% |
| 951 |
% \begin{macrocode} |
| 952 |
\RenewDocumentEnvironment{center} { !O{} } |
| 953 |
{ \SimpleBlockEnv{center}{#1} } { \BlockEnvEnd } |
| 954 |
% \end{macrocode} |
| 955 |
% |
| 956 |
% \begin{macrocode} |
| 957 |
\RenewDocumentEnvironment{flushright} { !O{} } |
| 958 |
{ \SimpleBlockEnv{flushright}{#1} } { \BlockEnvEnd } |
| 959 |
% \end{macrocode} |
| 960 |
% |
| 961 |
% \begin{macrocode} |
| 962 |
\RenewDocumentEnvironment{flushleft} { !O{} } |
| 963 |
{ \SimpleBlockEnv{flushleft}{#1} } { \BlockEnvEnd } |
| 964 |
} |
| 965 |
% \end{macrocode} |
| 966 |
% \end{environment} |
| 967 |
% |
| 968 |
% |
| 969 |
% \subsubsection{Their \insttype{blockenv} instances} |
| 970 |
% |
| 971 |
% \begin{instance}{blockenv center} |
| 972 |
% The \env{center} environment is defined through the |
| 973 |
% \insttype{blockenv} instance \instname{center} which makes use of |
| 974 |
% the \insttype{block} instance \instname{std-display-\meta{level}} |
| 975 |
% and the \insttype{para} instance \instname{center}. The block |
| 976 |
% nesting level is not incremented. With respect to tagging, text |
| 977 |
% separated by \cs{par} commands (or empty lines) inside the |
| 978 |
% environment is not tagged as separate paragraphs, i.e., the whole |
| 979 |
% environment is considered to be part of an outer paragraph. |
| 980 |
% \begin{macrocode} |
| 981 |
\DeclareInstance{blockenv}{center}{std} |
| 982 |
{ |
| 983 |
name = center |
| 984 |
,tag-name = |
| 985 |
,tag-attr-class = |
| 986 |
,tagging-recipe = basic |
| 987 |
,tagging-suppress-paras = true |
| 988 |
,inner-level-counter = |
| 989 |
,transparent-level = true |
| 990 |
,legacy-code = |
| 991 |
,block-instance = std-display |
| 992 |
,para-instance = center |
| 993 |
,inner-instance = |
| 994 |
} |
| 995 |
% \end{macrocode} |
| 996 |
% \end{instance} |
| 997 |
% |
| 998 |
% \begin{instance}{blockenv flushleft} |
| 999 |
% Same as \instname{center} except that we use the |
| 1000 |
% \insttype{para} instance \instname{raggedright}. |
| 1001 |
% \begin{macrocode} |
| 1002 |
%\DeclareInstance{blockenv}{flushleft}{std} |
| 1003 |
%{ |
| 1004 |
% name = flushleft |
| 1005 |
% ,tag-name = |
| 1006 |
% ,tag-attr-class = |
| 1007 |
% ,tagging-recipe = basic |
| 1008 |
% ,tagging-suppress-paras = true |
| 1009 |
% ,inner-level-counter = |
| 1010 |
% ,transparent-level = true |
| 1011 |
% ,legacy-code = |
| 1012 |
% ,block-instance = std-display |
| 1013 |
% ,para-instance = raggedright |
| 1014 |
% ,inner-instance = |
| 1015 |
%} |
| 1016 |
% \end{macrocode} |
| 1017 |
% Or more concise in the source and perhaps even faster in |
| 1018 |
% processing if only few keys are changed: |
| 1019 |
% \begin{macrocode} |
| 1020 |
\DeclareInstanceCopy{blockenv}{flushleft}{center} |
| 1021 |
\EditInstance{blockenv}{flushleft}{ |
| 1022 |
name = flushleft |
| 1023 |
,para-instance = raggedright } |
| 1024 |
% \end{macrocode} |
| 1025 |
% \end{instance} |
| 1026 |
% |
| 1027 |
% |
| 1028 |
% \begin{instance}{blockenv flushright} |
| 1029 |
% Same game for \instname{flushright}. |
| 1030 |
% \begin{macrocode} |
| 1031 |
\DeclareInstanceCopy{blockenv}{flushright}{center} |
| 1032 |
\EditInstance{blockenv}{flushright}{ |
| 1033 |
name = flushright |
| 1034 |
,para-instance = raggedleft } |
| 1035 |
% \end{macrocode} |
| 1036 |
% \end{instance} |
| 1037 |
% |
| 1038 |
% |
| 1039 |
% |
| 1040 |
% \subsubsection{Their \insttype{block} instances} |
| 1041 |
% |
| 1042 |
% They all use the \insttype{block} instances \instname{std} |
| 1043 |
% which have already been set up in section~\ref{sec:std-display}. |
| 1044 |
% |
| 1045 |
% |
| 1046 |
% \subsubsection{Their \insttype{para} instances} |
| 1047 |
% |
| 1048 |
% Formatting of paragraphs is handled through the |
| 1049 |
% \key{para-instance} key which either refers to a |
| 1050 |
% instance of type \insttype{para} or is empty, in which case the |
| 1051 |
% handling of paragraphs is inherited. The predefined instances are |
| 1052 |
% discussed in section~\ref{sec:para-instances}. |
| 1053 |
% |
| 1054 |
% |
| 1055 |
% |
| 1056 |
% \subsection{The \env{quote} and \env{quotation} environments} |
| 1057 |
% |
| 1058 |
% \LaTeXe{} has two environments for quoting: \env{quote} and |
| 1059 |
% \env{quotation}. By default they differ only in indentation of |
| 1060 |
% inner paragraphs. This is handled by using separate block |
| 1061 |
% instances. The paragraph setup is inherited. The block nesting |
| 1062 |
% level is incremented. |
| 1063 |
% |
| 1064 |
% The tag names are both role-mapped to \struct{BlockQuote}. |
| 1065 |
% |
| 1066 |
% \begin{environment}{quote,quotation} |
| 1067 |
% We can't use \cs{RenewDocumentEnvironment} for \env{quote} and |
| 1068 |
% other environments that are class defined, because some classes |
| 1069 |
% aren't implementing them at all. So we use |
| 1070 |
% \cs{DeclareDocumentEnvironment} instead. This problem will vanish |
| 1071 |
% if all such definitions move in new versions of the classes instead. |
| 1072 |
% |
| 1073 |
% \changes{v0.9l}{2025/11/20}{Use \cs{DeclareDocumentEnvironment} for \env{quote}, |
| 1074 |
% \env{quotation}, \env{description}, and \env{verse} (tagging/284)} |
| 1075 |
% \begin{macrocode} |
| 1076 |
\AddToHook{begindocument/before}[./legacy-quotes]{ |
| 1077 |
\DeclareDocumentEnvironment{quote}{ !O{} } |
| 1078 |
{ \SimpleBlockEnv{quote} {#1} } { \BlockEnvEnd } |
| 1079 |
% \end{macrocode} |
| 1080 |
% |
| 1081 |
% \begin{macrocode} |
| 1082 |
\DeclareDocumentEnvironment{quotation}{ !O{} } |
| 1083 |
{ \SimpleBlockEnv{quotation} {#1} } { \BlockEnvEnd } |
| 1084 |
} |
| 1085 |
% \end{macrocode} |
| 1086 |
% \end{environment} |
| 1087 |
% |
| 1088 |
% \subsubsection{Their \insttype{blockenv} instances} |
| 1089 |
% |
| 1090 |
% \begin{instance}{blockenv quotation} |
| 1091 |
% For the \env{quotation} environment: |
| 1092 |
% \begin{macrocode} |
| 1093 |
\DeclareInstance{blockenv}{quotation}{std} |
| 1094 |
{ |
| 1095 |
name = quotation |
| 1096 |
,tag-name = \UseStructureName{block/quotation} |
| 1097 |
,tag-attr-class = |
| 1098 |
,tagging-recipe = standard |
| 1099 |
,inner-level-counter = |
| 1100 |
,transparent-level = false |
| 1101 |
,legacy-code = |
| 1102 |
,block-instance = quotation |
| 1103 |
,inner-instance = |
| 1104 |
} |
| 1105 |
% \end{macrocode} |
| 1106 |
% \end{instance} |
| 1107 |
% |
| 1108 |
% \begin{instance}{blockenv quote} |
| 1109 |
% For the \env{quote} environment: |
| 1110 |
% \begin{macrocode} |
| 1111 |
\DeclareInstance{blockenv}{quote}{std} |
| 1112 |
{ |
| 1113 |
name = quote |
| 1114 |
,tag-name = \UseStructureName{block/quote} |
| 1115 |
,tag-attr-class = |
| 1116 |
,tagging-recipe = standard |
| 1117 |
,inner-level-counter = |
| 1118 |
,transparent-level = false |
| 1119 |
,legacy-code = |
| 1120 |
,block-instance = quote |
| 1121 |
,inner-instance = |
| 1122 |
} |
| 1123 |
% \end{macrocode} |
| 1124 |
% \end{instance} |
| 1125 |
% |
| 1126 |
% |
| 1127 |
% |
| 1128 |
% |
| 1129 |
% \subsubsection{Their \insttype{block} instances} |
| 1130 |
% |
| 1131 |
% \begin{instance}{block quote-1, |
| 1132 |
% block quote-2, |
| 1133 |
% block quote-3, |
| 1134 |
% block quote-4, |
| 1135 |
% block quote-5, |
| 1136 |
% block quote-6 } |
| 1137 |
% Default layout is to indent equally from both sides. |
| 1138 |
% \changes{0.9t}{2026-04-27}{Set para-vspace to \cs{parsep} as that is the default in legacy LaTeX.} |
| 1139 |
% Note that settings here also affect verse as it currently reuses the block instances! |
| 1140 |
% \begin{macrocode} |
| 1141 |
\DeclareInstance{block}{quote-1}{std} |
| 1142 |
{ |
| 1143 |
right-margin = \KeyValue{left-margin} |
| 1144 |
,para-vspace = \parsep |
| 1145 |
} |
| 1146 |
% \end{macrocode} |
| 1147 |
% |
| 1148 |
% \begin{macrocode} |
| 1149 |
\DeclareInstanceCopy{block}{quote-2}{quote-1} |
| 1150 |
\DeclareInstanceCopy{block}{quote-3}{quote-1} |
| 1151 |
\DeclareInstanceCopy{block}{quote-4}{quote-1} |
| 1152 |
\DeclareInstanceCopy{block}{quote-5}{quote-1} |
| 1153 |
\DeclareInstanceCopy{block}{quote-6}{quote-1} |
| 1154 |
% \end{macrocode} |
| 1155 |
% \end{instance} |
| 1156 |
% |
| 1157 |
% |
| 1158 |
% |
| 1159 |
% \begin{instance}{block quotation-1, |
| 1160 |
% block quotation-2, |
| 1161 |
% block quotation-3, |
| 1162 |
% block quotation-4, |
| 1163 |
% block quotation-5, |
| 1164 |
% block quotation-6 } |
| 1165 |
% Quotation additionally changes the \key{para-indent}. |
| 1166 |
% \begin{macrocode} |
| 1167 |
\DeclareInstance{block}{quotation-1}{std} |
| 1168 |
{ para-indent = 1.5em , right-margin = \KeyValue{left-margin} } |
| 1169 |
% \end{macrocode} |
| 1170 |
% |
| 1171 |
% \begin{macrocode} |
| 1172 |
\DeclareInstanceCopy{block}{quotation-2}{quotation-1} |
| 1173 |
\DeclareInstanceCopy{block}{quotation-3}{quotation-1} |
| 1174 |
\DeclareInstanceCopy{block}{quotation-4}{quotation-1} |
| 1175 |
\DeclareInstanceCopy{block}{quotation-5}{quotation-1} |
| 1176 |
\DeclareInstanceCopy{block}{quotation-6}{quotation-1} |
| 1177 |
% \end{macrocode} |
| 1178 |
% \end{instance} |
| 1179 |
% |
| 1180 |
% |
| 1181 |
% |
| 1182 |
% |
| 1183 |
% |
| 1184 |
% |
| 1185 |
% \subsection{The \env{verse} environment} |
| 1186 |
% |
| 1187 |
% The \env{verse} environment of \LaTeX{} is intended for |
| 1188 |
% poetry. Not sure what that should mean with respect to |
| 1189 |
% tagging. |
| 1190 |
% |
| 1191 |
% \begin{environment}{verse} |
| 1192 |
% Implementation is like \env{quote} etc. |
| 1193 |
% \begin{macrocode} |
| 1194 |
\AddToHook{begindocument/before}[./legacy]{ |
| 1195 |
\DeclareDocumentEnvironment{verse}{!O{}} |
| 1196 |
{ \SimpleBlockEnv{verse} {#1} } { \BlockEnvEnd } |
| 1197 |
} |
| 1198 |
% \end{macrocode} |
| 1199 |
% \end{environment} |
| 1200 |
% |
| 1201 |
% \subsubsection{Their \insttype{blockenv} instances} |
| 1202 |
% |
| 1203 |
% \begin{instance}{blockenv verse} |
| 1204 |
% \begin{macrocode} |
| 1205 |
\DeclareInstance{blockenv}{verse}{std} |
| 1206 |
{ |
| 1207 |
name = verse |
| 1208 |
,tag-name = \UseStructureName{block/verse} |
| 1209 |
,tag-attr-class = |
| 1210 |
,tagging-recipe = standard |
| 1211 |
,inner-level-counter = |
| 1212 |
,transparent-level = false |
| 1213 |
,legacy-code = |
| 1214 |
,block-instance = quote % reuse? |
| 1215 |
,para-instance = verse |
| 1216 |
,inner-instance = |
| 1217 |
} |
| 1218 |
% \end{macrocode} |
| 1219 |
% The special indentation on continuation lines (the way \LaTeX{} |
| 1220 |
% handled poetry) is done in the \insttype{para} instance |
| 1221 |
% \instname{verse}, defined later on. |
| 1222 |
% \end{instance} |
| 1223 |
% |
| 1224 |
% |
| 1225 |
% |
| 1226 |
% |
| 1227 |
% |
| 1228 |
% \subsection{The \env{verbatim}, \env{verbatim*} and \env{alltt} environments} |
| 1229 |
% |
| 1230 |
% |
| 1231 |
% \begin{environment}{verbatim,verbatim*} |
| 1232 |
% Here are the definitions for the verbatim environments. They look |
| 1233 |
% somewhat different than others (but this isn't the final |
| 1234 |
% definition). |
| 1235 |
% At the moment we use 2 optional arguments, the second is only |
| 1236 |
% there so that there is yet another scan even if one optional |
| 1237 |
% argument got detected. That then scans away the newline so that |
| 1238 |
% afterwards we can reinsert one via \cs{obeyedline}. A better |
| 1239 |
% solution will be to use a \texttt{c} specifier for grabbing the |
| 1240 |
% body, but that is for another day not Christmas Eve.\fmi{fix} |
| 1241 |
% \changes{v0.9f}{2025/06/21}{Move special verbatim code into a key} |
| 1242 |
% \begin{macrocode} |
| 1243 |
\AddToHook{begindocument/before}[./legacy-verbatims]{ |
| 1244 |
\RenewDocumentEnvironment{verbatim}{ ={legacy-code} !o !o } |
| 1245 |
{ \SimpleBlockEnv{verbatim} {#1} \obeyedline } { \BlockEnvEnd } |
| 1246 |
% \end{macrocode} |
| 1247 |
% |
| 1248 |
% \changes{v0.9f}{2025/06/21}{Use separate blockenv instances for |
| 1249 |
% verbatim and verbatim*} |
| 1250 |
% \begin{macrocode} |
| 1251 |
\RenewDocumentEnvironment{verbatim*}{ ={legacy-code} !o !o } |
| 1252 |
{ \SimpleBlockEnv{verbatim*} {#1} \obeyedline } { \BlockEnvEnd } |
| 1253 |
% \end{macrocode} |
| 1254 |
% \end{environment} |
| 1255 |
% |
| 1256 |
% |
| 1257 |
% \begin{environment}{alltt,alltt*} |
| 1258 |
% The \pkg{alltt} package implements a variation on verbatim |
| 1259 |
% handling where backslash and braces retain their normal |
| 1260 |
% meanings. We also reimplement it using the template approach |
| 1261 |
% The \env{alltt*} variant didn't exist in the package, |
| 1262 |
% but it is trivial to set it up as well.\fmi{The parsing here |
| 1263 |
% should be adjusted as well, eventually.} |
| 1264 |
% \begin{macrocode} |
| 1265 |
\NewDocumentEnvironment{alltt}{ ={legacy-code} !o } |
| 1266 |
{ \SimpleBlockEnv{alltt} {#1} } { \BlockEnvEnd } |
| 1267 |
\NewDocumentEnvironment{alltt*}{ ={legacy-code} !o } |
| 1268 |
{ \SimpleBlockEnv{alltt*} {#1} } { \BlockEnvEnd } |
| 1269 |
} |
| 1270 |
% \end{macrocode} |
| 1271 |
% \end{environment} |
| 1272 |
% |
| 1273 |
% \subsubsection{Their \insttype{blockenv} instances} |
| 1274 |
% |
| 1275 |
% \begin{instance}{blockenv verbatim} |
| 1276 |
% The \env{verbatim} environment is defined through |
| 1277 |
% \insttype{blockenv} instance \instname{verbatim} that makes use |
| 1278 |
% of the \insttype{block} instance |
| 1279 |
% \instname{verbatim-\meta{level}} and the \insttype{para} |
| 1280 |
% instance \instname{justify}. The block nesting level is not |
| 1281 |
% incremented. Verbatim processing requires various \cs{catcode} |
| 1282 |
% changes, etc.\ and as a consequence a special parsing routine |
| 1283 |
% that grabs the whole environment while these catcodes are in |
| 1284 |
% force. This setup is done in the \key{final-code} key and its |
| 1285 |
% last action is to initiate the special parsing. |
| 1286 |
% |
| 1287 |
% \changes{v0.8x}{2025/01/12}{Use flattened para inside verbatim} |
| 1288 |
% \begin{macrocode} |
| 1289 |
\DeclareInstance{blockenv}{verbatim}{std} |
| 1290 |
{ |
| 1291 |
name = verbatim |
| 1292 |
,tag-name = \UseStructureName{block/verbatim} |
| 1293 |
,tag-attr-class = |
| 1294 |
,tagging-recipe = standard |
| 1295 |
,tagging-suppress-paras = true |
| 1296 |
,inner-level-counter = |
| 1297 |
,transparent-level = true |
| 1298 |
,legacy-code = |
| 1299 |
,block-instance = verbatim |
| 1300 |
,inner-instance = |
| 1301 |
,para-instance = justify |
| 1302 |
% \end{macrocode} |
| 1303 |
% Here is where \env{verbatim} and \env{verbatim*} technically |
| 1304 |
% differ: in the former we set up spaces to become nonbreakable |
| 1305 |
% spaces (if necessary followed by a \tn{pdffakespace} in the |
| 1306 |
% pdf\TeX{} engine) |
| 1307 |
% and in \env{verbatim*} we set it up to generate visible space chars. |
| 1308 |
% \changes{v0.9f}{2025/06/21}{Move special verbatim code into a key} |
| 1309 |
% \begin{macrocode} |
| 1310 |
,final-code = \legacyverbatimsetup{invisible} |
| 1311 |
% \end{macrocode} |
| 1312 |
% Then we start the special scanning process to look for |
| 1313 |
% \verb=\end{verbatim}= with special catcodes and grab everything |
| 1314 |
% in between. For \env{verbatim*} we use \cs{@sxverbatim} to look |
| 1315 |
% for \verb=\end{verbatim*}= instead.\footnote{Perhaps there should |
| 1316 |
% be some other command names for this?} |
| 1317 |
% \begin{macrocode} |
| 1318 |
\@xverbatim |
| 1319 |
} |
| 1320 |
% \end{macrocode} |
| 1321 |
% \end{instance} |
| 1322 |
% |
| 1323 |
% The role-mapping is \struct{verbatim} to \struct{Code} and |
| 1324 |
% \struct{codeline} to \struct{Sub} (which is role mapped |
| 1325 |
% to \struct{Span} in pdf 1.7). Sub inside Code is allowed according |
| 1326 |
% the errata of ISO 32005. The paragraphs inside verbatim are flattened. |
| 1327 |
% Line numbers should be inside the \struct{codeline} structure |
| 1328 |
% and be tagged either as \struct{Lbl} or \struct{Artifact}\struct{Lbl}. |
| 1329 |
% |
| 1330 |
% |
| 1331 |
% \begin{instance}{blockenv verbatim*} |
| 1332 |
% The implementation of \env{verbatim*} is similar using the |
| 1333 |
% \insttype{blockenv} instance \instname{verbatim*}. Its |
| 1334 |
% \key{final-code} sets up visible spaces and a slightly different |
| 1335 |
% parsing that grabs everything up to |
| 1336 |
% \verb=\end{verbatim*}=. Otherwise the setup is identical. |
| 1337 |
% |
| 1338 |
% \changes{v0.9f}{2025/06/21}{Use separate blockenv instances for |
| 1339 |
% verbatim and verbatim*} |
| 1340 |
% \begin{macrocode} |
| 1341 |
\DeclareInstance{blockenv}{verbatim*}{std} |
| 1342 |
{ |
| 1343 |
name = verbatim |
| 1344 |
,tag-name = \UseStructureName{block/verbatim} |
| 1345 |
,tag-attr-class = |
| 1346 |
,tagging-recipe = standard |
| 1347 |
,tagging-suppress-paras = true |
| 1348 |
,inner-level-counter = |
| 1349 |
,transparent-level = true |
| 1350 |
,legacy-code = |
| 1351 |
,block-instance = verbatim |
| 1352 |
,inner-instance = |
| 1353 |
,para-instance = justify |
| 1354 |
,final-code = \legacyverbatimsetup{visible} |
| 1355 |
\@sxverbatim |
| 1356 |
} |
| 1357 |
% \end{macrocode} |
| 1358 |
% \end{instance} |
| 1359 |
% |
| 1360 |
% \begin{instance}{blockenv alltt} |
| 1361 |
% The implementation of the \env{alltt} environment from the |
| 1362 |
% \pkg{alltt} is more or less identical as well. |
| 1363 |
% We just need a slightly different final code to keep backslash |
| 1364 |
% and braces functional. |
| 1365 |
% |
| 1366 |
% \begin{macrocode} |
| 1367 |
\DeclareInstance{blockenv}{alltt}{std} |
| 1368 |
{ |
| 1369 |
name = alltt |
| 1370 |
,tag-name = \UseStructureName{block/verbatim} % private tag instead? |
| 1371 |
,tag-attr-class = |
| 1372 |
,tagging-recipe = standard |
| 1373 |
,tagging-suppress-paras = true |
| 1374 |
,inner-level-counter = |
| 1375 |
,transparent-level = true |
| 1376 |
,legacy-code = |
| 1377 |
,block-instance = verbatim |
| 1378 |
,inner-instance = |
| 1379 |
,para-instance = justify |
| 1380 |
% \end{macrocode} |
| 1381 |
% Now set up the special environment settings with most characters |
| 1382 |
% verbatim. |
| 1383 |
% We don't even have to scan ahead for the \verb=\end{alltt}= |
| 1384 |
% because backslash and braces still have their normal meaning. |
| 1385 |
% \begin{macrocode} |
| 1386 |
,final-code = \legacyallttsetup {invisible} |
| 1387 |
} |
| 1388 |
% \end{macrocode} |
| 1389 |
% \end{instance} |
| 1390 |
% |
| 1391 |
% |
| 1392 |
% \begin{instance}{blockenv alltt*} |
| 1393 |
% The \env{alltt*} variant didn't exist in the \pkg{alltt} package, |
| 1394 |
% but it is trivial to set it up as well. |
| 1395 |
% \begin{macrocode} |
| 1396 |
\DeclareInstance{blockenv}{alltt*}{std} |
| 1397 |
{ |
| 1398 |
name = alltt* |
| 1399 |
,tag-name = \UseStructureName{block/verbatim} % private tag instead? |
| 1400 |
,tag-attr-class = |
| 1401 |
,tagging-recipe = standard |
| 1402 |
,tagging-suppress-paras = true |
| 1403 |
,inner-level-counter = |
| 1404 |
,transparent-level = true |
| 1405 |
,legacy-code = |
| 1406 |
,block-instance = verbatim |
| 1407 |
,inner-instance = |
| 1408 |
,para-instance = justify |
| 1409 |
,final-code = \legacyallttsetup {visible} |
| 1410 |
} |
| 1411 |
% \end{macrocode} |
| 1412 |
% \end{instance} |
| 1413 |
% |
| 1414 |
% |
| 1415 |
% |
| 1416 |
% \subsubsection{Their \insttype{block} instances} |
| 1417 |
% |
| 1418 |
% |
| 1419 |
% \begin{instance}{block verbatim-1, |
| 1420 |
% block verbatim-2, |
| 1421 |
% block verbatim-3, |
| 1422 |
% block verbatim-4, |
| 1423 |
% block verbatim-5, |
| 1424 |
% block verbatim-6 } |
| 1425 |
% Verbatim instances have there own levels so that one can specify |
| 1426 |
% specific indentations or vertical separations between lines. |
| 1427 |
% \begin{macrocode} |
| 1428 |
\DeclareInstance{block}{verbatim-1}{std} |
| 1429 |
{ |
| 1430 |
,left-margin = 0pt |
| 1431 |
,para-vspace = 0pt |
| 1432 |
} |
| 1433 |
% \end{macrocode} |
| 1434 |
% |
| 1435 |
% \begin{macrocode} |
| 1436 |
\DeclareInstanceCopy{block}{verbatim-2}{verbatim-1} |
| 1437 |
\DeclareInstanceCopy{block}{verbatim-3}{verbatim-1} |
| 1438 |
\DeclareInstanceCopy{block}{verbatim-4}{verbatim-1} |
| 1439 |
\DeclareInstanceCopy{block}{verbatim-5}{verbatim-1} |
| 1440 |
\DeclareInstanceCopy{block}{verbatim-6}{verbatim-1} |
| 1441 |
% \end{macrocode} |
| 1442 |
% \end{instance} |
| 1443 |
% |
| 1444 |
% |
| 1445 |
% |
| 1446 |
% |
| 1447 |
% |
| 1448 |
% \subsection{The standard lists: \env{itemize}, \env{enumerate}, and \env{description}} |
| 1449 |
% |
| 1450 |
% |
| 1451 |
% \begin{environment}{itemize,enumerate,description} |
| 1452 |
% For the standard lists everything is managed by the blockenv |
| 1453 |
% instances. For the list we do not require that the optional argument |
| 1454 |
% directly follows without spaces as there can be no conflict with |
| 1455 |
% any following text (only \cs{item} or an empty line or the |
| 1456 |
% optional argument would be possible). |
| 1457 |
% \changes{v0.9o}{2026/02/16}{Allow spaces before the optional argument (tagging/1237)} |
| 1458 |
% \begin{macrocode} |
| 1459 |
\AddToHook{begindocument/before}[./legacy-lists]{ |
| 1460 |
\RenewDocumentEnvironment{itemize}{ O{} } |
| 1461 |
{ \SimpleBlockEnv{itemize} {#1} } { \BlockEnvEnd } |
| 1462 |
% \end{macrocode} |
| 1463 |
% |
| 1464 |
% \begin{macrocode} |
| 1465 |
\RenewDocumentEnvironment{enumerate}{ O{} } |
| 1466 |
{ \SimpleBlockEnv{enumerate} {#1} } { \BlockEnvEnd } |
| 1467 |
% \end{macrocode} |
| 1468 |
% |
| 1469 |
% \begin{macrocode} |
| 1470 |
\DeclareDocumentEnvironment{description}{ O{} } |
| 1471 |
{ \SimpleBlockEnv{description} {#1} } { \BlockEnvEnd } |
| 1472 |
} |
| 1473 |
% \end{macrocode} |
| 1474 |
% \end{environment} |
| 1475 |
% |
| 1476 |
% \subsubsection{Their \insttype{blockenv} instances} |
| 1477 |
% |
| 1478 |
% \begin{instance}{blockenv itemize} |
| 1479 |
% The \env{itemize} environment is defined through the |
| 1480 |
% \insttype{blockenv} instance \instname{itemize} which makes use |
| 1481 |
% of the \insttype{block} instance \instname{list-\meta{level}}, |
| 1482 |
% and an inner instance \instname{itemize-\meta{inner-level}} of |
| 1483 |
% type \insttype{list}. The paragraph setup is |
| 1484 |
% inherited.\footnote{In the \LaTeXe{} implementation justified |
| 1485 |
% paragraphs where forced, even if the whole document was set in |
| 1486 |
% ragged text. If this slightly strange behavior is desired then one has to set |
| 1487 |
% the \key{para-instance} key to \keyvalue{justify}.} The |
| 1488 |
% \meta{inner-level} is determined through \cs{@itemdepth}. The |
| 1489 |
% block nesting level and the inner list nesting level are |
| 1490 |
% incremented. |
| 1491 |
% \begin{macrocode} |
| 1492 |
\DeclareInstance{blockenv}{itemize}{std} |
| 1493 |
{ |
| 1494 |
name = itemize |
| 1495 |
,tag-name = \UseStructureName{block/itemize} |
| 1496 |
,tag-attr-class = itemize |
| 1497 |
,tagging-recipe = list |
| 1498 |
,inner-level-counter = \@itemdepth |
| 1499 |
,transparent-level = false |
| 1500 |
,max-inner-levels = 4 |
| 1501 |
,legacy-code = |
| 1502 |
,block-instance = std-list |
| 1503 |
,inner-instance-type = list |
| 1504 |
,inner-instance = itemize |
| 1505 |
,para-instance = |
| 1506 |
} |
| 1507 |
% \end{macrocode} |
| 1508 |
% \end{instance} |
| 1509 |
% |
| 1510 |
% \begin{instance}{blockenv enumerate} |
| 1511 |
%^^A |
| 1512 |
% The \env{enumerate} environment is similar to \env{itemize} but |
| 1513 |
% uses the \insttype{blockenv} instance \instname{enumerate}, the |
| 1514 |
% \insttype{block} instance \instname{list-\meta{level}}, and the |
| 1515 |
% inner instance \instname{enumerate-\meta{inner-level}}. The |
| 1516 |
% \meta{inner-level} is determined through \cs{@enumdepth}. |
| 1517 |
% |
| 1518 |
% \begin{macrocode} |
| 1519 |
\DeclareInstance{blockenv}{enumerate}{std} |
| 1520 |
{ |
| 1521 |
name = enumerate |
| 1522 |
,tag-name = \UseStructureName{block/enumerate} |
| 1523 |
,tag-attr-class = enumerate |
| 1524 |
,tagging-recipe = list |
| 1525 |
,transparent-level = false |
| 1526 |
,max-inner-levels = 4 |
| 1527 |
,legacy-code = |
| 1528 |
,block-instance = std-list |
| 1529 |
,inner-level-counter = \@enumdepth |
| 1530 |
,inner-instance-type = list |
| 1531 |
,inner-instance = enumerate |
| 1532 |
} |
| 1533 |
% \end{macrocode} |
| 1534 |
% \end{instance} |
| 1535 |
% |
| 1536 |
% |
| 1537 |
% \begin{instance}{blockenv description} |
| 1538 |
%^^A |
| 1539 |
% The \env{description} environment uses the \insttype{blockenv} |
| 1540 |
% instance \instname{description}, the \insttype{block} instance |
| 1541 |
% \instname{list-\meta{level}}, and the inner instance |
| 1542 |
% \instname{description}. |
| 1543 |
% |
| 1544 |
% In \LaTeXe{} that was no dependency on the nesting level, |
| 1545 |
% i.e., the environment has the same appearance on all nesting |
| 1546 |
% levels, but there is actually no good reason for disallowing |
| 1547 |
% layout adjustments on each level. All we have to do for this is |
| 1548 |
% to provide a value \key{inner-level-counter} and allocate a |
| 1549 |
% counter register for that. |
| 1550 |
% |
| 1551 |
% We allow for 6 levels. |
| 1552 |
% \changes{v0.9r}{2026-04-18}{Support layout customization of |
| 1553 |
% \env{description} on individual nesting levels} |
| 1554 |
% \begin{macrocode} |
| 1555 |
|
| 1556 |
\DeclareInstance{blockenv}{description}{std} |
| 1557 |
{ |
| 1558 |
name = description |
| 1559 |
,tag-name = \UseStructureName{block/description} |
| 1560 |
,tag-attr-class = description |
| 1561 |
,tagging-recipe = list |
| 1562 |
,inner-level-counter = \@descriptiondepth |
| 1563 |
,transparent-level = false |
| 1564 |
,max-inner-levels = 6 |
| 1565 |
,legacy-code = |
| 1566 |
,block-instance = std-list |
| 1567 |
,inner-instance-type = list |
| 1568 |
,inner-instance = description |
| 1569 |
} |
| 1570 |
% \end{macrocode} |
| 1571 |
% \end{instance} |
| 1572 |
% |
| 1573 |
% |
| 1574 |
% \begin{macro}{\@descriptiondepth} |
| 1575 |
% Counting nested \env{description} environments. |
| 1576 |
% \changes{v0.9r}{2026-04-18}{Support layout customization of |
| 1577 |
% \env{description} on individual nesting levels} |
| 1578 |
% \begin{macrocode} |
| 1579 |
\newcount\@descriptiondepth |
| 1580 |
% \end{macrocode} |
| 1581 |
% \end{macro} |
| 1582 |
% |
| 1583 |
% |
| 1584 |
% \subsubsection{Their \insttype{block} instances} |
| 1585 |
% |
| 1586 |
% \begin{instance}{block std-list-1, |
| 1587 |
% block std-list-2, |
| 1588 |
% block std-list-3, |
| 1589 |
% block std-list-4, |
| 1590 |
% block std-list-5, |
| 1591 |
% block std-list-6 } |
| 1592 |
% The block instances for the various list environments use the |
| 1593 |
% same underlying instance (well, by default) and nothing |
| 1594 |
% needs to be set up specifically (because that is already done in |
| 1595 |
% the legacy \tn{list\meta{romannumeral}} unless a |
| 1596 |
% different layout is wanted. |
| 1597 |
% |
| 1598 |
% \begin{macrocode} |
| 1599 |
\DeclareInstance{block}{std-list-1}{std}{ |
| 1600 |
% begin-vspace = \topsep |
| 1601 |
% ,begin-extra-vspace = \partopsep |
| 1602 |
% \end{macrocode} |
| 1603 |
% This is the only one we have to explicitly set for lists if the default |
| 1604 |
% setup is wanted. |
| 1605 |
% \changes{v0.9l}{2025/11/04}{Fix default for para-vspace, should be |
| 1606 |
% \cs{parsep} (only) inside lists} |
| 1607 |
% \begin{macrocode} |
| 1608 |
,para-vspace = \parsep |
| 1609 |
% ,end-vspace = \KeyValue{begin-vspace} |
| 1610 |
% ,end-extra-vspace = \KeyValue{begin-extra-vspace} |
| 1611 |
% ,item-vspace = \itemsep |
| 1612 |
% ,begin-penalty = \UseName{@beginparpenalty} |
| 1613 |
% ,end-penalty = \UseName{@endparpenalty} |
| 1614 |
% ,left-margin = \leftmargin |
| 1615 |
% ,right-margin = \rightmargin |
| 1616 |
% ,para-indent = 0pt |
| 1617 |
} |
| 1618 |
% \end{macrocode} |
| 1619 |
% |
| 1620 |
% \begin{macrocode} |
| 1621 |
\DeclareInstanceCopy{block}{std-list-2}{std-list-1} |
| 1622 |
\DeclareInstanceCopy{block}{std-list-3}{std-list-2} |
| 1623 |
\DeclareInstanceCopy{block}{std-list-4}{std-list-3} |
| 1624 |
\DeclareInstanceCopy{block}{std-list-5}{std-list-4} |
| 1625 |
\DeclareInstanceCopy{block}{std-list-6}{std-list-5} |
| 1626 |
% \end{macrocode} |
| 1627 |
% |
| 1628 |
% If the legacy \tn{list\meta{romannumeral}} is not used in a |
| 1629 |
% modern class then, of course, these instances all need to set up |
| 1630 |
% the different parameters explicitly. The new implementation of |
| 1631 |
% the standard classes (will) show that approach. |
| 1632 |
% \end{instance} |
| 1633 |
% |
| 1634 |
% |
| 1635 |
% |
| 1636 |
% \subsubsection{Their \insttype{list} instances} |
| 1637 |
% |
| 1638 |
% For all list instances we have to say what kind of label we want |
| 1639 |
% (\key{item-label}) and how it should be formatted. |
| 1640 |
% |
| 1641 |
% \begin{instance}{list itemize-1, |
| 1642 |
% list itemize-2, |
| 1643 |
% list itemize-3, |
| 1644 |
% list itemize-4} |
| 1645 |
% For \env{itemize} environments this is all we need to do and we |
| 1646 |
% refer back to the external definitions rather than defining the |
| 1647 |
% \key{item-label} code in the instance to ensure that old |
| 1648 |
% documents still work. |
| 1649 |
% |
| 1650 |
% \begin{macrocode} |
| 1651 |
\DeclareInstance{list}{itemize-1}{std}{ item-label = \labelitemi } |
| 1652 |
\DeclareInstance{list}{itemize-2}{std}{ item-label = \labelitemii } |
| 1653 |
\DeclareInstance{list}{itemize-3}{std}{ item-label = \labelitemiii } |
| 1654 |
\DeclareInstance{list}{itemize-4}{std}{ item-label = \labelitemiv } |
| 1655 |
% \end{macrocode} |
| 1656 |
% \end{instance} |
| 1657 |
% |
| 1658 |
% |
| 1659 |
% |
| 1660 |
% \begin{instance}{list enumerate-1, |
| 1661 |
% list enumerate-2, |
| 1662 |
% list enumerate-3, |
| 1663 |
% list enumerate-4} |
| 1664 |
% \env{enumerate} environments are similar, except that we also |
| 1665 |
% have to say which counter to use on each level. |
| 1666 |
% \begin{macrocode} |
| 1667 |
\DeclareInstance{list}{enumerate-1}{std} |
| 1668 |
{ item-label = \labelenumi , counter = enumi } |
| 1669 |
\DeclareInstance{list}{enumerate-2}{std} |
| 1670 |
{ item-label = \labelenumii , counter = enumii } |
| 1671 |
\DeclareInstance{list}{enumerate-3}{std} |
| 1672 |
{ item-label = \labelenumiii , counter = enumiii } |
| 1673 |
\DeclareInstance{list}{enumerate-4}{std} |
| 1674 |
{ item-label = \labelenumiv , counter = enumiv } |
| 1675 |
% \end{macrocode} |
| 1676 |
% \end{instance} |
| 1677 |
% |
| 1678 |
% |
| 1679 |
% \begin{instance}{list description} |
| 1680 |
% In \LaTeXe{} the \env{description} lists used only a single list |
| 1681 |
% instance with only one key not using the default. But in this |
| 1682 |
% implementation we allow for customization of every level, even |
| 1683 |
% though we aren't making use of it by default. |
| 1684 |
% |
| 1685 |
% Doing that means that you can only use a limited number of nested |
| 1686 |
% environments (while in \LaTeXe{} one could have arbitrary |
| 1687 |
% nestings, so let's hope 6 levels are enough. |
| 1688 |
% |
| 1689 |
% TODO: consider reusing the last level if you run out of |
| 1690 |
% specified levels rather than using \key{max-inner-levels}. |
| 1691 |
% \changes{v0.9r}{2026-04-18}{Support layout customization of |
| 1692 |
% \env{description} on individual nesting levels} |
| 1693 |
% \begin{macrocode} |
| 1694 |
\DeclareInstance{list}{description-1}{std} { item-instance = description } |
| 1695 |
% \end{macrocode} |
| 1696 |
% |
| 1697 |
% \begin{macrocode} |
| 1698 |
\DeclareInstanceCopy{list}{description-2}{description-1} |
| 1699 |
\DeclareInstanceCopy{list}{description-3}{description-1} |
| 1700 |
\DeclareInstanceCopy{list}{description-4}{description-1} |
| 1701 |
\DeclareInstanceCopy{list}{description-5}{description-1} |
| 1702 |
\DeclareInstanceCopy{list}{description-6}{description-1} |
| 1703 |
% \end{macrocode} |
| 1704 |
% \end{instance} |
| 1705 |
% |
| 1706 |
% |
| 1707 |
% \subsubsection{Their \insttype{item} instances} |
| 1708 |
% |
| 1709 |
% \begin{instance}{item basic, item description} |
| 1710 |
% There are two item instances to set up: \keyvalue{description} for use |
| 1711 |
% with the \env{description} environment and \keyvalue{basic} for use |
| 1712 |
% with all other lists (up to now). |
| 1713 |
% \begin{macrocode} |
| 1714 |
\DeclareInstance{item}{basic}{std} |
| 1715 |
{ label-align = right } |
| 1716 |
% \end{macrocode} |
| 1717 |
% |
| 1718 |
% \begin{macrocode} |
| 1719 |
\DeclareInstance{item}{description}{std} |
| 1720 |
{ |
| 1721 |
,label-format = \normalfont\bfseries #1 |
| 1722 |
,label-align = left |
| 1723 |
} |
| 1724 |
% \end{macrocode} |
| 1725 |
% \end{instance} |
| 1726 |
% |
| 1727 |
% |
| 1728 |
% |
| 1729 |
% |
| 1730 |
% \subsection{The legacy \env{list} and \env{trivlist} environments} |
| 1731 |
% |
| 1732 |
% In \LaTeXe{}, \env{trivlist} was used to define various display |
| 1733 |
% environments that aren't really lists at all. To support such |
| 1734 |
% legacy definitions (even though they should be updated to achieve |
| 1735 |
% proper tagging) we continue to support and implement it as a |
| 1736 |
% \env{list} environment with a few hardwired settings mimicking |
| 1737 |
% the original behavior.\fmi{maybe we should simply implement it as |
| 1738 |
% a \instname{displayblock} instance (at least when doing tagging) |
| 1739 |
% - decide} |
| 1740 |
% |
| 1741 |
% |
| 1742 |
% \begin{environment}{list} |
| 1743 |
% The legacy 2e list environment is more complicated as we have to get the |
| 1744 |
% extra arguments accounted for. |
| 1745 |
% \begin{macrocode} |
| 1746 |
\AddToHook{begindocument/before}[./legacy]{ |
| 1747 |
\RenewDocumentEnvironment{list}{ O{} m m } |
| 1748 |
{ |
| 1749 |
% \end{macrocode} |
| 1750 |
% We do this by storing them away and then call the list |
| 1751 |
% instance. Inside this instance the \key{legacy-code} key |
| 1752 |
% contains \tn{legacylistsetup} which makes use of the stored values. |
| 1753 |
% \changes{v0.8v}{2024/10/11}{Update \tn{@itemlabel} in |
| 1754 |
% \cs{l_@@_legacy_env_params_tl} and not at the start of the |
| 1755 |
% environment (tagging/730)} |
| 1756 |
% \begin{macrocode} |
| 1757 |
\tl_set:Nn \l_@@_legacy_env_params_tl |
| 1758 |
{ |
| 1759 |
\tl_set:Nn \@itemlabel {#2} |
| 1760 |
#3 |
| 1761 |
} |
| 1762 |
% \end{macrocode} |
| 1763 |
% The \LaTeXe{} lists don't support captions so we use \cs{SimpleBlockEnv}. |
| 1764 |
% \begin{macrocode} |
| 1765 |
\SimpleBlockEnv{list} {#1} |
| 1766 |
} |
| 1767 |
{ \BlockEnvEnd } |
| 1768 |
} |
| 1769 |
% \end{macrocode} |
| 1770 |
% \end{environment} |
| 1771 |
% |
| 1772 |
% |
| 1773 |
% |
| 1774 |
% \begin{environment}{trivlist} |
| 1775 |
% \LaTeXe{} defined \env{trivlist} as an implementation of |
| 1776 |
% \env{list} (or rather the other way around).\fmi{Replace with |
| 1777 |
% code not using \tn{list}} |
| 1778 |
% \begin{macrocode} |
| 1779 |
\AddToHook{begindocument/before}[./legacy]{ |
| 1780 |
\RenewDocumentEnvironment{trivlist}{ !O{} } |
| 1781 |
{ \list[#1]{} |
| 1782 |
{ |
| 1783 |
\dim_zero:N \leftmargin |
| 1784 |
\dim_zero:N \labelwidth |
| 1785 |
\cs_set_eq:NN \makelabel \use:n |
| 1786 |
} |
| 1787 |
} |
| 1788 |
{ \BlockEnvEnd } |
| 1789 |
} |
| 1790 |
% \end{macrocode} |
| 1791 |
% \end{environment} |
| 1792 |
% |
| 1793 |
% |
| 1794 |
% |
| 1795 |
% \subsubsection{Its \insttype{blockenv} instance} |
| 1796 |
% |
| 1797 |
% \begin{instance}{blockenv list} |
| 1798 |
% The generic \env{list} environment of \LaTeXe{} is modeled with a |
| 1799 |
% \insttype{blockenv} instance named \instname{list}, a |
| 1800 |
% \insttype{block} instance named \instname{std-list-\meta{level}}, and |
| 1801 |
% an inner instance named \instname{legacy} (with no dependency on |
| 1802 |
% the nesting level). This environment has two arguments and |
| 1803 |
% customization of the layout is expected to be directly set in the |
| 1804 |
% second argument. For this reason this \instname{legacy} instance |
| 1805 |
% is something that shouldn't be changed (all that is attempted to |
| 1806 |
% provide a way to support legacy setups). |
| 1807 |
% |
| 1808 |
% To set up the default settings (as they were used in \LaTeXe{}) |
| 1809 |
% the \key{legacy-code} key gets \cs{legacylistsetup} assigned |
| 1810 |
% that contains the necessary code to set up these defaults. |
| 1811 |
% Changing the \insttype{blockenv} is therefore not recommended for |
| 1812 |
% the legacy \env{list} environment. |
| 1813 |
% \begin{macrocode} |
| 1814 |
\DeclareInstance{blockenv}{list}{std} |
| 1815 |
{ |
| 1816 |
name = list |
| 1817 |
,tag-name = \UseStructureName{block/list} |
| 1818 |
,tag-attr-class = |
| 1819 |
,tagging-recipe = list |
| 1820 |
,transparent-level = false |
| 1821 |
,legacy-code = \legacylistsetup |
| 1822 |
,block-instance = std-list |
| 1823 |
,inner-level-counter = |
| 1824 |
,inner-instance-type = list |
| 1825 |
,inner-instance = legacy |
| 1826 |
} |
| 1827 |
% \end{macrocode} |
| 1828 |
% \end{instance} |
| 1829 |
% |
| 1830 |
% |
| 1831 |
% \subsubsection{Its \insttype{list} instance} |
| 1832 |
% |
| 1833 |
% \begin{instance}{list legacy} |
| 1834 |
% For the legacy \env{list} environment there is only one instance |
| 1835 |
% which is reused on all levels. This is done this way because |
| 1836 |
% the legacy \env{list} environment sets all its |
| 1837 |
% parameters through its arguments. So this instances shouldn't |
| 1838 |
% really be touched. It sets the \key{legacy-support} key to |
| 1839 |
% true, which means that the list code uses \tn{makelabel} for |
| 1840 |
% formatting the label. |
| 1841 |
% \begin{macrocode} |
| 1842 |
\DeclareInstance{list}{legacy}{std} { |
| 1843 |
,item-instance = basic |
| 1844 |
,legacy-support = true |
| 1845 |
} |
| 1846 |
% \end{macrocode} |
| 1847 |
% \end{instance} |
| 1848 |
% |
| 1849 |
% |
| 1850 |
% |
| 1851 |
% \subsection{Theorem-like environments declared through \cs{newtheorem}} |
| 1852 |
% |
| 1853 |
% In standard \LaTeX{} theorem-like environments are not defined |
| 1854 |
% directly, but with the help of a \cs{newtheorem} |
| 1855 |
% declaration. That allows specifying the typeset environment title, |
| 1856 |
% e.g., \enquote{Lemma}, and the counter to use to number the |
| 1857 |
% environments, e.g., they could be all numbered individually or one |
| 1858 |
% could number them using the same counter as some other theorem-like |
| 1859 |
% environment. |
| 1860 |
% |
| 1861 |
% This was first augmented by the \pkg{theorem} package which |
| 1862 |
% implemented the idea of a \cs{theoremstyle}; this is now considered |
| 1863 |
% obsolete. Michael Downes from the AMS improved on these early ideas |
| 1864 |
% and wrote the \pkg{amsthm} package, which offered more functionality |
| 1865 |
% including a \cs{newtheoremstyle} declaration and for the document |
| 1866 |
% level a \cs{swapnumbers} and an \env{proof} environment. It also |
| 1867 |
% provided star-forms for \cs{newtheorem} (to define an unnumbered |
| 1868 |
% environment) and allowed to use star-forms of the theorem-like |
| 1869 |
% environments to suppress numbering on an individual instance in the |
| 1870 |
% document. |
| 1871 |
% |
| 1872 |
% This new implementation based on templates, is supposed to cover the |
| 1873 |
% functionality of \pkg{amsthm} including it declarations so that |
| 1874 |
% documents that use \pkg{amsthm} explicitly or implicitly via their |
| 1875 |
% class should continue to work seamlessly. |
| 1876 |
% |
| 1877 |
% For other packages that provide theorem-like environments we have to |
| 1878 |
% see if they could be easily remodeled using the new implementation |
| 1879 |
% or if there is a need for extended templates. |
| 1880 |
% |
| 1881 |
% Assuming declarations such as |
| 1882 |
%\begin{verbatim} |
| 1883 |
% % \swapnumbers % <- commented out |
| 1884 |
% \theoremstyle{definition} |
| 1885 |
% \newtheorem{axiom}[def]{Axiom} |
| 1886 |
%\end{verbatim} |
| 1887 |
% in a document, then the following instances of type \insttype{blockenv} and |
| 1888 |
% \insttype{captionedtext} are declared by \cs{newtheorem}. |
| 1889 |
% |
| 1890 |
% |
| 1891 |
% \subsubsection{The \insttype{blockenv} instances they use} |
| 1892 |
% |
| 1893 |
% Given the above input \cs{newtheorem} defines the following |
| 1894 |
% \insttype{blockenv} instance: |
| 1895 |
%\begin{verbatim} |
| 1896 |
% \DeclareInstance{blockenv}{axiom}{std} |
| 1897 |
% { |
| 1898 |
% name = theorem-like |
| 1899 |
% ,tag-name = \UseStructureName{block/theorem-like} |
| 1900 |
% ,tagging-recipe = standalone |
| 1901 |
% ,transparent-level = true |
| 1902 |
% ,block-instance:e = thm- |
| 1903 |
% \IfInstanceExistsTF{block} |
| 1904 |
% { thm-definition-1 } |
| 1905 |
% { definition } { plain } |
| 1906 |
% ,inner-instance-type = captionedtext |
| 1907 |
% ,inner-instance = axiom |
| 1908 |
% ,para-instance = justify |
| 1909 |
% } |
| 1910 |
%\end{verbatim} |
| 1911 |
% |
| 1912 |
% The setting for \key{block-instance} means that it checks if a |
| 1913 |
% \insttype{block} instance with the name |
| 1914 |
% \instname{thm-definition-1} exists. If so then the value |
| 1915 |
% \keyvalue{thm-definition} is used, otherwise |
| 1916 |
% \keyvalue{thm-plain} is used which is always defined, i.e., |
| 1917 |
% if the theoremstyle does not specify any special vertical spacing |
| 1918 |
% the \insttype{block} instance from the \texttt{plain} style is |
| 1919 |
% reused. |
| 1920 |
% |
| 1921 |
% What varies from \insttype{blockenv} instance to instance are the |
| 1922 |
% values for \key{block-instance} and \key{inner-instance}. |
| 1923 |
% |
| 1924 |
% We use \struct{\UseStructureName{block/theorem-like}} as the |
| 1925 |
% structure name and role-map it to a \struct{Sect} because that |
| 1926 |
% can hold a \struct{Caption}. |
| 1927 |
% |
| 1928 |
% |
| 1929 |
% |
| 1930 |
% \subsubsection{The \insttype{captionedtext} instances they use} |
| 1931 |
% |
| 1932 |
% The instance of type \insttype{captionedtext} is also defined by |
| 1933 |
% \cs{newtheorem} and in this case it looks like this: |
| 1934 |
%\begin{verbatim} |
| 1935 |
% \DeclareInstance{captionedtext}{axiom}{thmlike} |
| 1936 |
% { |
| 1937 |
% ,counter = def |
| 1938 |
% ,title = Axiom % <-- that the title provided to \newtheorem |
| 1939 |
% ,style = definition % <-- that's the used \theoremstyle |
| 1940 |
% } |
| 1941 |
%\end{verbatim} |
| 1942 |
% |
| 1943 |
% If we uncomment the \cs{swapnumbers} line in the example above then we get |
| 1944 |
%\begin{verbatim} |
| 1945 |
% ,style = definition-swap |
| 1946 |
%\end{verbatim} |
| 1947 |
% in the \insttype{captionedtext} instance instead. |
| 1948 |
% |
| 1949 |
% |
| 1950 |
% |
| 1951 |
% |
| 1952 |
% |
| 1953 |
% |
| 1954 |
% \subsubsection{The \insttype{thmstyle} instances they use} |
| 1955 |
% |
| 1956 |
% New theorem styles can be declared with \cs{newtheoremstyle} |
| 1957 |
% which then generates an instance of type |
| 1958 |
% \insttype{thmstyle}. Alternatively, it is, of course, possible to |
| 1959 |
% declare the instances directly (which gives you a bit more |
| 1960 |
% flexibility). A few such styles are predeclared, matching what |
| 1961 |
% is offered by \pkg{amsthm}. These are shown below. |
| 1962 |
% |
| 1963 |
% \begin{instance}{thmstyle plain} |
| 1964 |
% The main style used for many theorem-like environments, i.e., the |
| 1965 |
% one you get if no special \cs{theoremstyle} has been specified. |
| 1966 |
% |
| 1967 |
% \changes{v0.9n}{2026/02/01}{Change order of elements (tagging/1199)} |
| 1968 |
% \changes{v0.9n}{2026/02/01}{Add further decl keys (tagging/1199)} |
| 1969 |
% \begin{macrocode} |
| 1970 |
\DeclareInstance{thmstyle}{plain}{std} |
| 1971 |
{ |
| 1972 |
,caption-placement = unchained |
| 1973 |
,numbered = true |
| 1974 |
,separator = \ |
| 1975 |
,punct = . |
| 1976 |
,before-hspace = 0pt |
| 1977 |
,after-hspace = 5pt plus 1pt minus 1pt |
| 1978 |
,order = {title, separator, number, separator, note, punct} |
| 1979 |
,caption-decls = \bfseries |
| 1980 |
,title-decls = |
| 1981 |
,number-decls = \upshape |
| 1982 |
,punct-decls = |
| 1983 |
,note-decls = \upshape\mdseries |
| 1984 |
,title-format = #1 |
| 1985 |
,number-format = #1 |
| 1986 |
,punct-format = #1 |
| 1987 |
,note-format = (#1) |
| 1988 |
,body-decls = \itshape |
| 1989 |
} |
| 1990 |
% \end{macrocode} |
| 1991 |
% |
| 1992 |
% \end{instance} |
| 1993 |
% |
| 1994 |
% \begin{instance}{thmstyle remark} |
| 1995 |
% The \instname{remark} is like \instname{plain} with two changes: |
| 1996 |
% \begin{macrocode} |
| 1997 |
\DeclareInstanceCopy{thmstyle}{remark}{plain} |
| 1998 |
\EditInstance{thmstyle}{remark} |
| 1999 |
{ |
| 2000 |
,caption-decls = \itshape |
| 2001 |
,body-decls = \normalfont |
| 2002 |
} |
| 2003 |
% \end{macrocode} |
| 2004 |
% \end{instance} |
| 2005 |
% |
| 2006 |
% |
| 2007 |
% |
| 2008 |
% \begin{instance}{thmstyle definition} |
| 2009 |
% The \instname{definition} is like \instname{plain} with only a |
| 2010 |
% difference in the font used for the body: |
| 2011 |
% \begin{macrocode} |
| 2012 |
\DeclareInstanceCopy{thmstyle}{definition}{plain} |
| 2013 |
\EditInstance{thmstyle}{definition} |
| 2014 |
{ |
| 2015 |
,body-decls = \normalfont |
| 2016 |
} |
| 2017 |
% \end{macrocode} |
| 2018 |
% |
| 2019 |
% \end{instance} |
| 2020 |
% |
| 2021 |
% |
| 2022 |
% \begin{instance}{thmstyle legacy2e} |
| 2023 |
% Vanilla \LaTeXe{} (without \pkg{amsthm} loaded) had a slightly |
| 2024 |
% different default. We provide this under the name |
| 2025 |
% \instname{legacy2e}. It doesn't use a punctuation after the |
| 2026 |
% number and it has slightly different vertical spacing (defined by |
| 2027 |
% \instname{thm-legacy2e-1} below). |
| 2028 |
% |
| 2029 |
% Thus, to reprocess an old document for tagging that uses |
| 2030 |
% \cs{newtheorem} without loading \pkg{amsthm} one has to set |
| 2031 |
% \verb=\theoremstyle{legacy2e}= to avoid layout changes. How |
| 2032 |
% such a compatibility setting is automated is not yet decided. |
| 2033 |
% \begin{macrocode} |
| 2034 |
\DeclareInstanceCopy{thmstyle}{legacy2e}{plain} |
| 2035 |
\EditInstance{thmstyle}{legacy2e}{ punct = } |
| 2036 |
% \end{macrocode} |
| 2037 |
% |
| 2038 |
% \end{instance} |
| 2039 |
% |
| 2040 |
% |
| 2041 |
% |
| 2042 |
% |
| 2043 |
% \subsubsection{The \insttype{block} instances they use} |
| 2044 |
% |
| 2045 |
% |
| 2046 |
% \begin{instance}{block thm-plain-1, |
| 2047 |
% block thm-plain-2} |
| 2048 |
% Theorems do not support nesting, so in theory we have only one to set up. |
| 2049 |
% There are, however, documents that put theorem-like environments |
| 2050 |
% inside of lists or other block environments. |
| 2051 |
% While that is in most case somewhat dubious, it |
| 2052 |
% can make sense, for example, in \env{description} lists. So we |
| 2053 |
% support it by providing \instname{thm-plain} instances for |
| 2054 |
% levels 1 and 2. If somebody really nests them further down, then |
| 2055 |
% more such instances need to be declared. |
| 2056 |
% |
| 2057 |
% The \LaTeX{} default reused the general value of \tn{parindent} |
| 2058 |
% and \tn{parskip} and, of course, they start at the outer margin. |
| 2059 |
% \changes{v0.8w}{2024/11/23}{Add block instance for theorems} |
| 2060 |
% \begin{macrocode} |
| 2061 |
\DeclareInstance{block}{thm-plain-1}{std} |
| 2062 |
{ |
| 2063 |
,begin-extra-vspace = 0pt |
| 2064 |
,left-margin = 0pt |
| 2065 |
,para-indent = \parindent |
| 2066 |
,para-vspace = \parskip |
| 2067 |
} |
| 2068 |
% \end{macrocode} |
| 2069 |
% \begin{macrocode} |
| 2070 |
\DeclareInstanceCopy{block}{thm-plain-2}{thm-plain-1} |
| 2071 |
% \end{macrocode} |
| 2072 |
% \end{instance} |
| 2073 |
% |
| 2074 |
% \begin{instance}{block thm-remark-1, |
| 2075 |
% block thm-remark-2} |
| 2076 |
% The \cs{thmstyle} for \enquote{remarks} is defined by |
| 2077 |
% \pkg{amsthm} to use less vertical spacing. It therefore needs its |
| 2078 |
% own \insttype{block} instance. |
| 2079 |
% \begin{macrocode} |
| 2080 |
\DeclareInstance{block}{thm-remark-1}{std} |
| 2081 |
{ |
| 2082 |
,begin-vspace = 0.5\topsep |
| 2083 |
,begin-extra-vspace = 0pt |
| 2084 |
,left-margin = 0pt |
| 2085 |
,para-indent = \parindent |
| 2086 |
,para-vspace = \parskip |
| 2087 |
} |
| 2088 |
% \end{macrocode} |
| 2089 |
% |
| 2090 |
% \begin{macrocode} |
| 2091 |
\DeclareInstanceCopy{block}{thm-remark-2}{thm-remark-1} |
| 2092 |
% \end{macrocode} |
| 2093 |
% \end{instance} |
| 2094 |
% |
| 2095 |
% |
| 2096 |
% \begin{instance}{block thm-legacy2e-1, |
| 2097 |
% block thm-legacy2e-2} |
| 2098 |
% These are like the \texttt{plain} ones but without resetting |
| 2099 |
% \key{begin-extra-vspace} to zero. |
| 2100 |
% \begin{macrocode} |
| 2101 |
\DeclareInstance{block}{thm-legacy2e-1}{std} |
| 2102 |
{ |
| 2103 |
,left-margin = 0pt |
| 2104 |
,para-indent = \parindent |
| 2105 |
,para-vspace = \parskip |
| 2106 |
} |
| 2107 |
% \end{macrocode} |
| 2108 |
% \begin{macrocode} |
| 2109 |
\DeclareInstanceCopy{block}{thm-legacy2e-2}{thm-legacy2e-1} |
| 2110 |
% \end{macrocode} |
| 2111 |
% \end{instance} |
| 2112 |
% |
| 2113 |
% |
| 2114 |
% |
| 2115 |
% \subsection{The \env{proof} environment (from \pkg{amsthm})} |
| 2116 |
% |
| 2117 |
% |
| 2118 |
% |
| 2119 |
% \begin{environment}{proof} |
| 2120 |
% The \env{proof} environment expects one optional argument holding |
| 2121 |
% an alternative title for the proof. We parse this optional |
| 2122 |
% argument as an implicit key/value argument, so that it is |
| 2123 |
% possible to interpret it either as the value for the key |
| 2124 |
% \key{note} or as a key/value list that holds special key settings |
| 2125 |
% for this particular environment instance. The result is analyzed |
| 2126 |
% by \cs{ParseLaTeXeTheoremlike} which then calls a \insttype{blockenv} |
| 2127 |
% instance with the name \instname{proof}. |
| 2128 |
% |
| 2129 |
% In addition we have to set up handling of QED symbols using |
| 2130 |
% \cs{pushQED} and \cs{popQED} using the logic already defined in |
| 2131 |
% \pkg{amsthm}. Details on all this is given in the code section of |
| 2132 |
% this module but normally this top-level declaration doesn't |
| 2133 |
% require any changes. |
| 2134 |
% |
| 2135 |
% Conceptually, it would be better to disallow spaces before the |
| 2136 |
% optional argument here. But \pkg{amsthm} never did this, so for |
| 2137 |
% compatibility we aren't doing this either. |
| 2138 |
% \changes{v0.9o}{2026/02/16}{Allow spaces before the optional argument (tagging/1237)} |
| 2139 |
% \begin{macrocode} |
| 2140 |
\NewDocumentEnvironment{proof}{ ={note}o } |
| 2141 |
{ \pushQED{\qed}% |
| 2142 |
\ParseLaTeXeTheoremlike {proof} \BooleanTrue {#1} } |
| 2143 |
{ \popQED \BlockEnvEnd } |
| 2144 |
% \end{macrocode} |
| 2145 |
% \end{environment} |
| 2146 |
|
| 2147 |
|
| 2148 |
% |
| 2149 |
% \begin{instance}{blockenv proof} |
| 2150 |
% A proof uses its own \instname{proofblock} instance of type |
| 2151 |
% \insttype{block} for vertical spacing. As the proof has a heading |
| 2152 |
% we use a \insttype{captionedtext} instance with name |
| 2153 |
% \instname{proof} as the inner instance and the paragraphs of the |
| 2154 |
% proof are justified. |
| 2155 |
% \begin{macrocode} |
| 2156 |
\DeclareInstance{blockenv}{proof}{std} |
| 2157 |
{ |
| 2158 |
name = proof |
| 2159 |
,tag-name = \UseStructureName{block/proof} |
| 2160 |
,tag-attr-class = |
| 2161 |
,tagging-recipe = standalone |
| 2162 |
,inner-level-counter = |
| 2163 |
,transparent-level = true |
| 2164 |
,legacy-code = |
| 2165 |
,block-instance = proof |
| 2166 |
,inner-instance-type = captionedtext |
| 2167 |
,inner-instance = proof |
| 2168 |
,para-instance = justify |
| 2169 |
} |
| 2170 |
% \end{macrocode} |
| 2171 |
% \end{instance} |
| 2172 |
% |
| 2173 |
% |
| 2174 |
% |
| 2175 |
% \begin{instance}{captionedtext proof} |
| 2176 |
% We use a special \insttype{captionedtext} template to set up the |
| 2177 |
% proof because proofs are not numbered and the argument to a proof |
| 2178 |
% environment has a somewhat different semantic meaning than that |
| 2179 |
% of theorem-like environments. |
| 2180 |
% |
| 2181 |
% \begin{macrocode} |
| 2182 |
\DeclareInstance{captionedtext}{proof}{proof} |
| 2183 |
{ |
| 2184 |
,title = \proofname % default value |
| 2185 |
,punct = . |
| 2186 |
,before-hspace = 0pt |
| 2187 |
,after-hspace = 5pt plus 1pt minus 1pt |
| 2188 |
,caption-decls = \itshape |
| 2189 |
,title-format = #1 |
| 2190 |
,punct-format = #1 |
| 2191 |
,body-decls = \normalfont |
| 2192 |
} |
| 2193 |
% \end{macrocode} |
| 2194 |
% \end{instance} |
| 2195 |
% |
| 2196 |
% |
| 2197 |
% \subsubsection{Block instances for the proofs} |
| 2198 |
% |
| 2199 |
% |
| 2200 |
% \begin{instance}{block proof-1, |
| 2201 |
% block proof-2} |
| 2202 |
% Blocks for proofs are pretty normal (the values are taken from |
| 2203 |
% the \pkg{amsthm} implementation): |
| 2204 |
% \begin{macrocode} |
| 2205 |
\DeclareInstance{block}{proof-1}{std} |
| 2206 |
{ |
| 2207 |
,begin-vspace = 6pt plus 6pt |
| 2208 |
,left-margin = 0pt |
| 2209 |
,para-indent = \parindent |
| 2210 |
,para-vspace = \parskip |
| 2211 |
} |
| 2212 |
\DeclareInstanceCopy{block}{proof-2}{proof-1} |
| 2213 |
% \end{macrocode} |
| 2214 |
% |
| 2215 |
% \end{instance} |
| 2216 |
% |
| 2217 |
% |
| 2218 |
% \section{Declaring \insttype{para} instances}\label{sec:para-instances} |
| 2219 |
% |
| 2220 |
% Display block environments often require special paragraph |
| 2221 |
% settings and therefore have a \key{para-instance} key to specify |
| 2222 |
% and appropriate instance. Here are the standard instances that |
| 2223 |
% are predefined for this purpose. |
| 2224 |
% |
| 2225 |
% \begin{instance}{para justify} |
| 2226 |
% Justifying is exactly what the default values do, so the instance |
| 2227 |
% hasn't any special setup. |
| 2228 |
% \begin{macrocode} |
| 2229 |
\DeclareInstance{para}{justify}{std} |
| 2230 |
{ |
| 2231 |
% ,para-attr-class = justify |
| 2232 |
% ,para-indent = \parindent |
| 2233 |
% ,begin-hspace = 0pt |
| 2234 |
% ,left-hspace = \z@skip |
| 2235 |
% ,right-hspace = \z@skip |
| 2236 |
% ,end-hspace = \@flushglue |
| 2237 |
% ,final-hyphen-demerits = 5000 |
| 2238 |
% ,newline-cmd = \@normalcr |
| 2239 |
} |
| 2240 |
% \end{macrocode} |
| 2241 |
% \end{instance} |
| 2242 |
% |
| 2243 |
% |
| 2244 |
% \begin{instance}{para center} |
| 2245 |
% Centering a paragraph means putting stretchable glue on both sides. |
| 2246 |
% \begin{macrocode} |
| 2247 |
\DeclareInstance{para}{center}{std} |
| 2248 |
{ |
| 2249 |
,para-attr-class = center |
| 2250 |
,para-indent = 0pt |
| 2251 |
% ,begin-hspace = 0pt |
| 2252 |
,left-hspace = \@flushglue |
| 2253 |
,right-hspace = \@flushglue |
| 2254 |
,end-hspace = \z@skip |
| 2255 |
,final-hyphen-demerits = 0 |
| 2256 |
,newline-cmd = \@centercr |
| 2257 |
} |
| 2258 |
% \end{macrocode} |
| 2259 |
% \end{instance} |
| 2260 |
% |
| 2261 |
% \begin{instance}{para raggedright} |
| 2262 |
% This is the plain \TeX{} version of ragged right, which basically |
| 2263 |
% means no hyphenation unless a word is truly longer than a |
| 2264 |
% line. This implements \env{flushleft}. |
| 2265 |
% \begin{macrocode} |
| 2266 |
\DeclareInstance{para}{raggedright}{std} |
| 2267 |
{ |
| 2268 |
,para-attr-class = raggedright |
| 2269 |
,para-indent = 0pt |
| 2270 |
% ,begin-hspace = 0pt |
| 2271 |
,left-hspace = \z@skip |
| 2272 |
,right-hspace = \@flushglue |
| 2273 |
,end-hspace = \z@skip |
| 2274 |
,final-hyphen-demerits = 0 |
| 2275 |
,newline-cmd = \@centercr |
| 2276 |
} |
| 2277 |
% \end{macrocode} |
| 2278 |
% \end{instance} |
| 2279 |
% |
| 2280 |
% \begin{instance}{para raggedleft} |
| 2281 |
% This here is for \env{flushright}. |
| 2282 |
% \begin{macrocode} |
| 2283 |
\DeclareInstance{para}{raggedleft}{std} |
| 2284 |
{ |
| 2285 |
,para-attr-class = raggedleft |
| 2286 |
,para-indent = 0pt |
| 2287 |
% ,begin-hspace = 0pt |
| 2288 |
,left-hspace = \@flushglue |
| 2289 |
,right-hspace = \z@skip |
| 2290 |
,end-hspace = \z@skip |
| 2291 |
,final-hyphen-demerits = 0 |
| 2292 |
,newline-cmd = \@centercr |
| 2293 |
} |
| 2294 |
% \end{macrocode} |
| 2295 |
% \end{instance} |
| 2296 |
% |
| 2297 |
% \begin{macro}[no-user-doc]{\centering,\raggedleft,\raggedright,\justifying} |
| 2298 |
% These instances are also used to implement declarations for |
| 2299 |
% direct use in documents or in user definitions. |
| 2300 |
% \begin{macrocode} |
| 2301 |
\DeclareRobustCommand\centering {\UseInstance{para}{center}{}} |
| 2302 |
\DeclareRobustCommand\raggedleft {\UseInstance{para}{raggedleft}{}} |
| 2303 |
\DeclareRobustCommand\raggedright{\UseInstance{para}{raggedright}{}} |
| 2304 |
\DeclareRobustCommand\justifying {\UseInstance{para}{justify}{}} |
| 2305 |
% \end{macrocode} |
| 2306 |
% \LaTeX{}'s default is to typeset paragraphs justified. |
| 2307 |
% \begin{macrocode} |
| 2308 |
\justifying |
| 2309 |
% \end{macrocode} |
| 2310 |
% \end{macro} |
| 2311 |
% |
| 2312 |
% \begin{instance}{para verse} |
| 2313 |
% For the \env{verse} environment we use a special para |
| 2314 |
% instance. If the right hand side should be ragged then a |
| 2315 |
% different \key{right-hspace} is needed. |
| 2316 |
% \begin{macrocode} |
| 2317 |
\DeclareInstance{para}{verse}{std} |
| 2318 |
{ |
| 2319 |
para-attr-class = justify , |
| 2320 |
para-indent = 0pt , |
| 2321 |
begin-hspace = -1.5em , |
| 2322 |
left-hspace = 1.5em , |
| 2323 |
right-hspace = 0pt , |
| 2324 |
end-hspace = \@flushglue , |
| 2325 |
final-hyphen-demerits = 0 , |
| 2326 |
newline-cmd = \@centercr , |
| 2327 |
} |
| 2328 |
% \end{macrocode} |
| 2329 |
% \end{instance} |
| 2330 |
% |
| 2331 |
% |
| 2332 |
% \begin{macrocode} |
| 2333 |
%</class-code> |
| 2334 |
% \end{macrocode} |
| 2335 |
% |
| 2336 |
% |
| 2337 |
% |
| 2338 |
% |
| 2339 |
% \section{Advice on adjusting the layout of standard block environments} |
| 2340 |
% |
| 2341 |
% \emph{to document} |
| 2342 |
% |
| 2343 |
% |
| 2344 |
% |
| 2345 |
% |
| 2346 |
% \section{Tagging support} |
| 2347 |
% |
| 2348 |
% \subsection{Paragraph tags} |
| 2349 |
% |
| 2350 |
% Paragraphs in \LaTeX{} can be nested, e.g., you can have a paragraph |
| 2351 |
% containing a display quote, which in turn consists of more than one |
| 2352 |
% (sub)paragraph, followed by some more text which all belongs to the |
| 2353 |
% same outer paragraph. |
| 2354 |
% |
| 2355 |
% In the PDF model and in the HTML model that is not supported --- a |
| 2356 |
% limitation that conflicts with real life, given that such |
| 2357 |
% constructs are quite normal in spoken and written language. |
| 2358 |
% |
| 2359 |
% The approach we take to resolve this is to model such \enquote{big} |
| 2360 |
% paragraphs with a structure named |
| 2361 |
% \struct{\UseStructureName{para/semantic}} |
| 2362 |
% and use \struct{\UseStructureName{para/textblock}} (role-mapped to \struct{P}) |
| 2363 |
% only for (portions of) the actual paragraph text in a way that the |
| 2364 |
% \struct{\UseStructureName{para/textblock}}s are not nested. As a |
| 2365 |
% result we have for a simple paragraph the structures |
| 2366 |
% \begin{tabbing} |
| 2367 |
% \hspace*{1em}\=\hspace*{1em}\=\hspace*{1em}\=\hspace*{1em}\= \kill |
| 2368 |
% \> \struct{\UseStructureName{para/textblock}}\\ |
| 2369 |
% \>\> \struct{\UseStructureName{para/textblock}}\\ |
| 2370 |
% \>\>\> The paragraph text \ldots\\ |
| 2371 |
% \>\> \struct{/\UseStructureName{para/textblock}}\\ |
| 2372 |
% \> \struct{/\UseStructureName{para/textblock}} |
| 2373 |
% \end{tabbing} |
| 2374 |
% The \struct{\UseStructureName{para/semantic}} structure is |
| 2375 |
% role-mapped to \struct{Part} or possibly to \struct{Div} so we get a |
| 2376 |
% valid PDF, but processors who care can identify the complete |
| 2377 |
% paragraphs by looking for \struct{\UseStructureName{para/semantic}} |
| 2378 |
% tags. |
| 2379 |
% |
| 2380 |
% In the case of an element, such as a display quote or a display list |
| 2381 |
% inside the paragraph, we then have |
| 2382 |
% \begin{tabbing} |
| 2383 |
% \hspace*{1em}\=\hspace*{1em}\=\hspace*{1em}\=\hspace*{1em}\= \kill |
| 2384 |
% \> \struct{\UseStructureName{para/semantic}}\\ |
| 2385 |
% \>\> \struct{\UseStructureName{para/textblock}}\\ |
| 2386 |
% \>\>\> The paragraph text before the display element \ldots\\ |
| 2387 |
% \>\> \struct{/\UseStructureName{para/textblock}}\\ |
| 2388 |
% \>\> \struct{display element structure}\\ |
| 2389 |
% \>\>\> Content of the display structure possibly involving inner |
| 2390 |
% \struct{\UseStructureName{para/semantic}} tags\\ |
| 2391 |
% \>\> \struct{/display element structure}\\ |
| 2392 |
% \>\> \struct{\UseStructureName{para/textblock}}\\ |
| 2393 |
% \>\>\> \ldots{} continuing the outer paragraph text\\ |
| 2394 |
% \>\> \struct{/\UseStructureName{para/textblock}}\\ |
| 2395 |
% \> \struct{/\UseStructureName{para/semantic}} |
| 2396 |
% \end{tabbing} |
| 2397 |
% In other words such a display block is always embedded in a |
| 2398 |
% \struct{\UseStructureName{para/semantic}} structure, possibly |
| 2399 |
% preceded by a \struct{\UseStructureName{para/textblock}}\ldots |
| 2400 |
% \struct{/\UseStructureName{para/textblock}} block and possibly |
| 2401 |
% followed by one, though both such blocks are optional. |
| 2402 |
% |
| 2403 |
% Thus an \env{itemize} environment that has some introductory text |
| 2404 |
% but no text immediately following the list would be tagged as |
| 2405 |
% follows: |
| 2406 |
% \begin{tabbing} |
| 2407 |
% \hspace*{1em}\=\hspace*{1em}\=\hspace*{1em}\=\hspace*{1em}\=\hspace*{1em}\= \kill |
| 2408 |
% \> \struct{\UseStructureName{para/semantic}}\\ |
| 2409 |
% \>\> \struct{\UseStructureName{para/textblock}}\\ |
| 2410 |
% \>\>\> The intro text for the \env{itemize} environment \ldots\\ |
| 2411 |
% \>\> \struct{/\UseStructureName{para/textblock}}\\ |
| 2412 |
% \>\> \struct{itemize}\\ |
| 2413 |
% \>\>\> \struct{LI}\\ |
| 2414 |
% \>\>\>\> \struct{\UseStructureName{block/list/label}} label \struct{/\UseStructureName{block/list/label}}\\ |
| 2415 |
% \>\>\>\> \struct{\UseStructureName{block/list/body}}\\ |
| 2416 |
% \>\>\>\>\> The text of the first item involving |
| 2417 |
% \struct{\UseStructureName{para/semantic}} as necessary \ldots\\ |
| 2418 |
% \>\>\>\> \struct{/\UseStructureName{block/list/body}}\\ |
| 2419 |
% \>\>\> \struct{/LI}\\ |
| 2420 |
% \>\>\> \struct{LI}\\ |
| 2421 |
% \>\>\>\> The second item \ldots{}\\ |
| 2422 |
% \>\>\> \struct{/LI}\\ |
| 2423 |
% \>\>\> \ldots{} further items \ldots\\ |
| 2424 |
% \>\> \struct{/itemize}\\ |
| 2425 |
% \> \struct{/\UseStructureName{para/semantic}} |
| 2426 |
% \end{tabbing} |
| 2427 |
% The \struct{itemize} is role-mapped to \struct{L}. |
| 2428 |
% |
| 2429 |
% For some display blocks, such as centered text, we use a simpler |
| 2430 |
% strategy. Such blocks still ensure that they are inside a |
| 2431 |
% \struct{\UseStructureName{para/semantic}} structure but their body |
| 2432 |
% uses simple \struct{\UseStructureName{para/textblock}} blocks and |
| 2433 |
% not |
| 2434 |
% \struct{\UseStructureName{para/semantic}}\struct{\UseStructureName{para/textblock}} |
| 2435 |
% inside, e.g., the input |
| 2436 |
% \begin{verbatim} |
| 2437 |
% This is a paragraph with some |
| 2438 |
% \begin{center} |
| 2439 |
% centered lines |
| 2440 |
% |
| 2441 |
% with a paragraph break between them |
| 2442 |
% \end{center} |
| 2443 |
% followed by some more text. |
| 2444 |
% \end{verbatim} |
| 2445 |
% will be tagged as follows: |
| 2446 |
% \begin{tabbing} |
| 2447 |
% \hspace*{1em}\=\hspace*{1em}\=\hspace*{1em}\=\hspace*{1em}\=\hspace*{1em}\= \kill |
| 2448 |
% \> \struct{\UseStructureName{para/semantic}}\\ |
| 2449 |
% \>\> \struct{\UseStructureName{para/textblock}}\\ |
| 2450 |
% \>\>\> This is a paragraph with some\\ |
| 2451 |
% \>\> \struct{/\UseStructureName{para/textblock}}\\ |
| 2452 |
% \>\> \struct{text /O /Layout /TextAlign/Center}\\ |
| 2453 |
% \>\>\> centered lines\\ |
| 2454 |
% \>\> \struct{/\UseStructureName{para/textblock}}\\ |
| 2455 |
% \>\> \struct{text /O /Layout /TextAlign/Center}\\ |
| 2456 |
% \>\>\> with a paragraph break between them\\ |
| 2457 |
% \>\> \struct{/\UseStructureName{para/textblock}}\\ |
| 2458 |
% \>\> \struct{\UseStructureName{para/textblock}}\\ |
| 2459 |
% \>\>\> followed by some more text.\\ |
| 2460 |
% \> \struct{/\UseStructureName{para/semantic}} |
| 2461 |
% \end{tabbing} |
| 2462 |
% |
| 2463 |
% The text-unit structures are added by using the tagging sockets |
| 2464 |
% \texttt{para/semantic/begin} and \texttt{para/semantic/end} declared in |
| 2465 |
% \texttt{lttagging.dtx}. They can be disabled by assigning these sockets the |
| 2466 |
% plug \texttt{noop}. |
| 2467 |
% |
| 2468 |
% |
| 2469 |
% \subsubsection{Tagging recipes} |
| 2470 |
% |
| 2471 |
% There are a number of different tagging recipes that implement |
| 2472 |
% different tagging approaches. They are selected through the |
| 2473 |
% \key{tagging-recipe} of the \insttype{blockenv} template. Currently |
| 2474 |
% the following values are implemented: |
| 2475 |
% \begin{description} |
| 2476 |
% \raggedright |
| 2477 |
% \item[\keyvalue{standalone}] |
| 2478 |
% This recipe does the following: |
| 2479 |
% \begin{itemize} |
| 2480 |
% \item Ensure that the \insttype{blockenv} is not inside a |
| 2481 |
% \struct{\UseStructureName{para/semantic}} structure. If |
| 2482 |
% necessary, close the open one (and any open |
| 2483 |
% \struct{\UseStructureName{para/textblock}} structure). |
| 2484 |
% |
| 2485 |
% \item Text inside the body of the environment start with |
| 2486 |
% \struct{\UseStructureName{para/semantic}}\struct{\UseStructureName{para/textblock}} |
| 2487 |
% unless the key \key{tagging-suppress-paras} is set to |
| 2488 |
% \keyvalue{true} (which is most likely the wrong thing to do |
| 2489 |
% because we then get just |
| 2490 |
% \struct{\UseStructureName{para/textblock}} as the structure). |
| 2491 |
% |
| 2492 |
% \item At the end of the environment close |
| 2493 |
% \struct{/\UseStructureName{para/textblock}} and possibly an |
| 2494 |
% inner \struct{/\UseStructureName{para/semantic}} if open. |
| 2495 |
% |
| 2496 |
% \item |
| 2497 |
% Finally, ensure that after the environment a new |
| 2498 |
% \struct{\UseStructureName{para/semantic}} is started, if |
| 2499 |
% appropriate, e.g., if text is following. |
| 2500 |
% \end{itemize} |
| 2501 |
% |
| 2502 |
% \item[\keyvalue{basic}] |
| 2503 |
% This recipe does the following: |
| 2504 |
% \begin{itemize} |
| 2505 |
% \item |
| 2506 |
% Ensure that the \insttype{blockenv} is inside a |
| 2507 |
% \struct{\UseStructureName{para/semantic}} |
| 2508 |
% structure, if necessary, start one. |
| 2509 |
% |
| 2510 |
% \item If inside a |
| 2511 |
% \struct{\UseStructureName{para/semantic}}\struct{\UseStructureName{para/textblock}}, |
| 2512 |
% then close the \struct{/\UseStructureName{para/textblock}} but |
| 2513 |
% leave the \struct{\UseStructureName{para/semantic}} open. |
| 2514 |
% |
| 2515 |
% \item Text inside the body of the environment start with |
| 2516 |
% \struct{\UseStructureName{para/semantic}}\struct{\UseStructureName{para/textblock}} |
| 2517 |
% if \key{tagging-suppress-paras} is set to \keyvalue{false}, |
| 2518 |
% otherwise just with \struct{\UseStructureName{para/textblock}}. |
| 2519 |
% |
| 2520 |
% \item At the end of the environment close |
| 2521 |
% \struct{/\UseStructureName{para/textblock}} and possibly an |
| 2522 |
% inner \struct{/\UseStructureName{para/semantic}} if open. |
| 2523 |
% |
| 2524 |
% \item Then look if the environment is followed by an empty line |
| 2525 |
% (\tn{par}). If so, close the outer |
| 2526 |
% \struct{/\UseStructureName{para/semantic}} and start any |
| 2527 |
% following text with |
| 2528 |
% \struct{\UseStructureName{para/semantic}}\struct{\UseStructureName{para/textblock}}. |
| 2529 |
% Otherwise, don't and following text restarts with a just a |
| 2530 |
% \struct{\UseStructureName{para/textblock}} (and no paragraph |
| 2531 |
% indentation) |
| 2532 |
% \end{itemize} |
| 2533 |
% |
| 2534 |
% \item[\keyvalue{standard}] |
| 2535 |
% This recipe is like the \keyvalue{basic} |
| 2536 |
% one as far as handling \struct{\UseStructureName{para/semantic}} |
| 2537 |
% and \struct{\UseStructureName{para/textblock}} is concerned. In |
| 2538 |
% addition |
| 2539 |
% \begin{itemize} |
| 2540 |
% \item |
| 2541 |
% it starts an inner tagging structure (i.e., which is therefore a |
| 2542 |
% child of the outer \struct{\UseStructureName{para/semantic}}). |
| 2543 |
% \item |
| 2544 |
% By default this structure is a \struct{Div} unless overwritten |
| 2545 |
% by the key \key{tag-name}. If that key is used, a suitable |
| 2546 |
% role-map needs to be provided for the name given. |
| 2547 |
% \item |
| 2548 |
% At the end of the environment that inner structure is closed |
| 2549 |
% again so that we are back on the |
| 2550 |
% \struct{\UseStructureName{para/semantic}} level from the |
| 2551 |
% outside. |
| 2552 |
% \item |
| 2553 |
% Then the lookahead for an empty line is done as described previously. |
| 2554 |
% \end{itemize} |
| 2555 |
% |
| 2556 |
% |
| 2557 |
% |
| 2558 |
% \item[\keyvalue{list}] |
| 2559 |
% This recipe is like the \keyvalue{standard} one except that |
| 2560 |
% \begin{itemize} |
| 2561 |
% \item |
| 2562 |
% the inner structure is a list (\struct{L}). |
| 2563 |
% \item |
| 2564 |
% Furthermore everything is set up so that we have list items |
| 2565 |
% (\struct{LI}) with suitable substructures (\struct{\UseStructureName{block/list/label}} for the item |
| 2566 |
% labels and \struct{\UseStructureName{block/list/body}} for the item bodies). |
| 2567 |
% \item |
| 2568 |
% If the key \key{tag-name} is specified, this is used as the tag |
| 2569 |
% name for the whole list instead of \struct{L}. Of course, it |
| 2570 |
% should then have a suitable role-map. |
| 2571 |
% \item |
| 2572 |
% If the key \key{tag-attr-class} is specified then this is used as the |
| 2573 |
% class attribute. Again, this requires a suitable setup on the outside. |
| 2574 |
% \item |
| 2575 |
% At the end of the environment the \struct{/\UseStructureName{block/list/body}}, \struct{/LI}, and |
| 2576 |
% \struct{/L} (or the tag name used) are closed. |
| 2577 |
% \item |
| 2578 |
% Then the lookahead for an empty line is done as described previously. |
| 2579 |
% \end{itemize} |
| 2580 |
% \end{description} |
| 2581 |
% |
| 2582 |
% |
| 2583 |
% |
| 2584 |
% |
| 2585 |
% |
| 2586 |
% \section{Tracing and debugging} |
| 2587 |
% |
| 2588 |
% \begin{function}{\DebugBlocksOn,\DebugBlocksOff, \block_debug_on:, \block_debug_off:} |
| 2589 |
% These commands enable/disable debugging messages for blocks. They also |
| 2590 |
% enable/disable debugging of templates (e.g., call |
| 2591 |
% \cs{DebugTemplatesOn} or \cs{DebugTemplatesOff}). |
| 2592 |
% \end{function} |
| 2593 |
% |
| 2594 |
% The data that is produced is rather verbose and largely guided |
| 2595 |
% (so far) by what seemed helpful while developing the code. This |
| 2596 |
% needs some cleanup at a later stage.\fmi{cleanup} At the moment, |
| 2597 |
% if you have the following simple document |
| 2598 |
% |
| 2599 |
%\begin{footnotesize} |
| 2600 |
%\begin{verbatim}[xleftmargin=-20pt,numbers=left,numbersep=6pt,numberblanklines] |
| 2601 |
% \DocumentMetadata{tagging=on, lang=en} |
| 2602 |
% |
| 2603 |
% \documentclass{article} |
| 2604 |
% |
| 2605 |
% \DebugBlocksOn |
| 2606 |
% |
| 2607 |
% \begin{document} |
| 2608 |
% \begin{itemize}[item-vspace=3pt] |
| 2609 |
% \item A normal item |
| 2610 |
% \item[\textbf{+}] A special item |
| 2611 |
% \end{itemize} |
| 2612 |
% \end{document} |
| 2613 |
%\end{verbatim} |
| 2614 |
%\end{footnotesize} |
| 2615 |
% |
| 2616 |
% \smallskip |
| 2617 |
% \noindent |
| 2618 |
% then you will get the following information on the screen and in |
| 2619 |
% the \texttt{.log} file: |
| 2620 |
% \smallskip |
| 2621 |
% |
| 2622 |
%\begin{footnotesize} |
| 2623 |
%\begin{verbatim}[xleftmargin=-40pt] |
| 2624 |
% [Template] ==> Use 'blockenv' instance: itemize on input line 8 |
| 2625 |
% [Template] ==> template: 'std'; arguments: |item-vspace=3pt|\BooleanFalse |\NoValue |\NoValue | |
| 2626 |
% [Template] ==> Use 'block' instance: std-list-1 on input line 8 |
| 2627 |
% [Template] ==> template: 'std'; argument: |item-vspace={3pt}| |
| 2628 |
% [Blocks] ==> @endpe=false on input line 8 |
| 2629 |
% [Template] ==> Use 'list' instance: itemize-1 on input line 8 |
| 2630 |
% [Template] ==> template: 'std'; arguments: ||\BooleanFalse |\NoValue |\NoValue | |
| 2631 |
% [Blocks] ==> Set first block everypar on input line 8 |
| 2632 |
% [Blocks] ==> template:list:std end |
| 2633 |
% |
| 2634 |
% [Template] ==> Use 'item' instance: basic on input line 9 |
| 2635 |
% [Template] ==> template: 'std'; argument: || |
| 2636 |
% [Blocks] ==> Set item block everypar on input line 9 |
| 2637 |
% [Blocks] ==> ... in item block everypar on input line 9 |
| 2638 |
% [Blocks] ==> increment P on input line 9 |
| 2639 |
% [Blocks] ==> Set noop block everypar on input line 9 |
| 2640 |
% |
| 2641 |
% [Template] ==> Use 'item' instance: basic on input line 10 |
| 2642 |
% [Template] ==> template: 'std'; argument: |label={\textbf {+}}| |
| 2643 |
% [Blocks] ==> item with optional |
| 2644 |
% [Blocks] ==> Set item block everypar on input line 10 |
| 2645 |
% [Blocks] ==> ... in item block everypar on input line 10 |
| 2646 |
% [Blocks] ==> increment P on input line 10 |
| 2647 |
% [Blocks] ==> Set noop block everypar on input line 10 |
| 2648 |
% |
| 2649 |
% [Blocks] ==> blockenv common ending on input line 11 |
| 2650 |
% |
| 2651 |
% [Blocks] ==> flattened=false on input line 12 |
| 2652 |
% [Blocks] ==> Structure-end text-unit after displayblock on input line 12 |
| 2653 |
%\end{verbatim} |
| 2654 |
%\end{footnotesize} |
| 2655 |
% |
| 2656 |
% |
| 2657 |
% |
| 2658 |
% \section{New and redefined kernel command} |
| 2659 |
% |
| 2660 |
% \begin{function}{\SimpleBlockEnv,\BlockEnv,\BlockEnvEnd,\g_block_nesting_depth_int} |
| 2661 |
% \emph{to be documented} |
| 2662 |
% \end{function} |
| 2663 |
% |
| 2664 |
% \begin{function}{\legacyverbatimsetup,\legacyallttsetup,\legacylistsetup} |
| 2665 |
% \emph{to be documented} |
| 2666 |
% \end{function} |
| 2667 |
% |
| 2668 |
% \begin{function}{\@setupverbinvisiblespace} |
| 2669 |
% A counterpart definition to the kernel command \tn{@setupverbinvisiblespace}, |
| 2670 |
% needed as we need to handle real space chars in verbatim. |
| 2671 |
% \end{function} |
| 2672 |
% |
| 2673 |
% \begin{function}{\newtheorem,\newtheoremstyle} |
| 2674 |
% Reimplemented to fit the template approach. \cs{newtheoremstyle} |
| 2675 |
% was defined by \pkg{amsthm}. |
| 2676 |
% \end{function} |
| 2677 |
% |
| 2678 |
% \begin{function}{\@nthm,\@xnthm,\@ynthm, |
| 2679 |
% \@thm,\@xthm,\@ythm,\@othm, |
| 2680 |
% \@begintheorem,\@opargbegintheorem,\@endtheorem} |
| 2681 |
% These are no longer used (to be removed). |
| 2682 |
% \end{function} |
| 2683 |
% |
| 2684 |
% \begin{function}{\item,\@itemlabel} |
| 2685 |
% The \tn{item} is redefined. |
| 2686 |
% \end{function} |
| 2687 |
% |
| 2688 |
% \begin{function}{\c@maxblocklevels} |
| 2689 |
% A counter to increase or decrease the number of supported |
| 2690 |
% level. If increased, one needs to supply additional level instances. |
| 2691 |
% \end{function} |
| 2692 |
% |
| 2693 |
% \begin{function}{\begin} |
| 2694 |
% The \tn{begin} is slightly redefined to handle \tn{@doendpe} better. |
| 2695 |
% TODO: move to kernel |
| 2696 |
% \end{function} |
| 2697 |
% |
| 2698 |
% \begin{function}{\@doendpe} |
| 2699 |
% The original \LaTeXe{} command is augmented to allow for tagging. |
| 2700 |
% \end{function} |
| 2701 |
% |
| 2702 |
% \begin{function}{\para_end:} |
| 2703 |
% TODO: consider name, document |
| 2704 |
% \end{function} |
| 2705 |
% |
| 2706 |
% \begin{function}{para/begin} |
| 2707 |
% The para/begin hook is enhanced to support list ends |
| 2708 |
% \end{function} |
| 2709 |
% |
| 2710 |
% \end{documentation} |
| 2711 |
% |
| 2712 |
% \StopEventually{\setlength\IndexMin{200pt} \PrintIndex } |
| 2713 |
% |
| 2714 |
% |
| 2715 |
% |
| 2716 |
% \begin{implementation} |
| 2717 |
% |
| 2718 |
% \section{The Implementation} |
| 2719 |
% |
| 2720 |
% |
| 2721 |
% \begin{macrocode} |
| 2722 |
%<*package-start> |
| 2723 |
% \end{macrocode} |
| 2724 |
% |
| 2725 |
% \begin{macrocode} |
| 2726 |
%<@@=block> |
| 2727 |
% \end{macrocode} |
| 2728 |
% |
| 2729 |
% |
| 2730 |
% \begin{macrocode} |
| 2731 |
\ProvidesPackage {latex-lab-testphase-block} |
| 2732 |
[\ltlabblockdate\space v\ltlabblockversion\space |
| 2733 |
blockenv implementation] |
| 2734 |
% \end{macrocode} |
| 2735 |
% |
| 2736 |
% |
| 2737 |
% \begin{macrocode} |
| 2738 |
\ExplSyntaxOn |
| 2739 |
% \end{macrocode} |
| 2740 |
% |
| 2741 |
% |
| 2742 |
% \subsubsection{Augmented \cs{SetKnownTemplateKeys}} |
| 2743 |
% |
| 2744 |
% |
| 2745 |
% \begin{macro}{\SetKnownTemplateKeys} |
| 2746 |
% A key/val list passed to \cs{SetKnownTemplateKeys} can either be |
| 2747 |
% empty (in which we do not want to start up the parsing machinery) |
| 2748 |
% or it could be \cs{NoValue} in which we do not want to do that |
| 2749 |
% either. The latter can happen, for example, with \env{verbatim} |
| 2750 |
% where we define the optional argument with |
| 2751 |
% \verb/={legacy-code} !o/ so that people can write |
| 2752 |
% \verb/\begin{verbatim}[\small]/ a syntax promoted by the TUGboat |
| 2753 |
% class. |
| 2754 |
% \begin{macrocode} |
| 2755 |
\cs_set_protected:Npn \SetKnownTemplateKeys #1#2#3 |
| 2756 |
{ |
| 2757 |
% \end{macrocode} |
| 2758 |
% An \enquote{empty} argument (or rather one that is empty after one |
| 2759 |
% expansion) is the most likely case so we test for this first. |
| 2760 |
% \begin{macrocode} |
| 2761 |
\tl_if_empty:oTF {#3} |
| 2762 |
{ |
| 2763 |
\tl_set_eq:NN \UnusedTemplateKeys \c_empty_tl |
| 2764 |
} |
| 2765 |
{ |
| 2766 |
\tl_if_novalue:nTF {#3} |
| 2767 |
{ |
| 2768 |
\tl_set_eq:NN \UnusedTemplateKeys \c_empty_tl |
| 2769 |
} |
| 2770 |
{ |
| 2771 |
\keys_set_known:noN { template / #1 / #2 } {#3} |
| 2772 |
\UnusedTemplateKeys |
| 2773 |
} |
| 2774 |
} |
| 2775 |
} |
| 2776 |
% \end{macrocode} |
| 2777 |
% \end{macro} |
| 2778 |
% |
| 2779 |
% |
| 2780 |
% |
| 2781 |
% \begin{macro}{\SetTemplateKeys} |
| 2782 |
% Same kind of extension for \cs{SetTemplateKeys}: |
| 2783 |
% \begin{macrocode} |
| 2784 |
\cs_set_protected:Npn \SetTemplateKeys #1#2#3 |
| 2785 |
{ |
| 2786 |
\tl_if_empty:oF {#3} |
| 2787 |
{ |
| 2788 |
\tl_if_novalue:nF {#3} |
| 2789 |
{ |
| 2790 |
\keys_set:no { template / #1 / #2 } {#3} |
| 2791 |
} |
| 2792 |
} |
| 2793 |
} |
| 2794 |
% \end{macrocode} |
| 2795 |
% \end{macro} |
| 2796 |
% |
| 2797 |
% \subsubsection{Tracing templates and instances} |
| 2798 |
% |
| 2799 |
% \begin{macro}{\template_debug_typeout:n} |
| 2800 |
% I guess that tracing macro is needed in several modules, so |
| 2801 |
% should become public (or at least kernel). |
| 2802 |
% \begin{macrocode} |
| 2803 |
\cs_new_protected:Npn \template_debug_typeout:n { \__template_debug_typeout:n } |
| 2804 |
% \end{macrocode} |
| 2805 |
% \end{macro} |
| 2806 |
% |
| 2807 |
% |
| 2808 |
% |
| 2809 |
% \subsubsection{Handling \tn{par} after the end of the list} |
| 2810 |
% |
| 2811 |
% An empty line (or a \tn{par}) after a list has semantic meaning as |
| 2812 |
% it defines whether then following text is logically within the same |
| 2813 |
% paragraph as the list (no empty line) or whether it starts a new |
| 2814 |
% paragraph and the paragraph containing the list ends at the end of |
| 2815 |
% the list (empty line after the list). |
| 2816 |
% This is handled by \LaTeX{} using a legacy flag called |
| 2817 |
% \texttt{@endpe} and set of commands inside the |
| 2818 |
% generic \tn{end} (calling \tn{@doendpe}) and as part of the list |
| 2819 |
% environments identifying themselves as \enquote{paragraph ending |
| 2820 |
% environments} (by setting this flag). |
| 2821 |
% |
| 2822 |
% For the reimplementation of the list environments including support |
| 2823 |
% of tagging we need to augment that mechanism slightly and add some |
| 2824 |
% kernel hook(s) to add the tagging code if needed. |
| 2825 |
% |
| 2826 |
% |
| 2827 |
% |
| 2828 |
% |
| 2829 |
% \begin{macro}{\@doendpe} |
| 2830 |
% The original \LaTeXe{} command is augmented to allow for tagging. |
| 2831 |
% TODO: move to the kernel eventually. |
| 2832 |
% \begin{macrocode} |
| 2833 |
\def\@doendpe{\@endpetrue |
| 2834 |
\def\par |
| 2835 |
{ |
| 2836 |
% \end{macrocode} |
| 2837 |
% If we are processing a \verb=$$= math display and we encounter a real |
| 2838 |
% \cs{par} after it, we need to add a \cs{parskip} when tagging is |
| 2839 |
% done, because the one |
| 2840 |
% added by \TeX{} is always canceled by the processing in |
| 2841 |
% \cs{__math_tag_dollardollar_display_end:} in that case. This is |
| 2842 |
% signaled by the global legacy switch \texttt{@domathendpe} which is set |
| 2843 |
% to true in that case. Once the skip is applied we set it to |
| 2844 |
% false. If there is no \cs{par} at all, it will be reset in |
| 2845 |
% \cs{everypar} when the next paragraph starts. |
| 2846 |
% |
| 2847 |
% But we first have to restore \cs{par}, otherwise |
| 2848 |
% \cs{skip_vertical:n} might trigger \cs{par} in horizontal mode |
| 2849 |
% and then loop because it never returns to vertical mode. |
| 2850 |
% \changes{v0.9p}{2026/04/07}{Restore \cs{par} first before |
| 2851 |
% attempting to add a \cs{skip_vertical:n} (tagging/1298)} |
| 2852 |
% \begin{macrocode} |
| 2853 |
\@restorepar |
| 2854 |
\clubpenalty\@clubpenalty |
| 2855 |
% \end{macrocode} |
| 2856 |
% \changes{v0.8x}{2024/12/01}{Handle \cs{parskip} after \texttt{\$\$} |
| 2857 |
% display (tagging/762)} |
| 2858 |
% \begin{macrocode} |
| 2859 |
\if@domathendpe |
| 2860 |
\skip_vertical:n { \tex_parskip:D } |
| 2861 |
\@domathendpefalse |
| 2862 |
\fi |
| 2863 |
% \end{macrocode} |
| 2864 |
% At this point we add the tagging code that closes an open |
| 2865 |
% \struct{\UseStructureName{para/semantic}}, |
| 2866 |
% \struct{\UseStructureName{para/textblock}} tag combination, if |
| 2867 |
% necessary: |
| 2868 |
% \begin{macrocode} |
| 2869 |
\tag_socket_use:n {@doendpe} |
| 2870 |
% \end{macrocode} |
| 2871 |
% |
| 2872 |
% The standard \tn{par} command (\cs{par_end:}) acts on |
| 2873 |
% \texttt{@endpe} and attempts to close a still open |
| 2874 |
% \struct{\UseStructureName{para/semantic}}s and this would be |
| 2875 |
% wrong if it was already closed above. So we have to reset the |
| 2876 |
% switch to false first. |
| 2877 |
% \begin{macrocode} |
| 2878 |
\@endpefalse |
| 2879 |
\everypar{} |
| 2880 |
\par |
| 2881 |
} |
| 2882 |
\everypar{{\setbox\z@\lastbox} |
| 2883 |
\everypar{} |
| 2884 |
\@endpefalse |
| 2885 |
% \end{macrocode} |
| 2886 |
% Not sure what is faster: testing for the status of the switch or |
| 2887 |
% setting it unconditionally to false (globally), probably roughly |
| 2888 |
% the same, so we set it always: |
| 2889 |
% \begin{macrocode} |
| 2890 |
% \if@domathendpe |
| 2891 |
\@domathendpefalse |
| 2892 |
% \fi |
| 2893 |
} |
| 2894 |
} |
| 2895 |
% \end{macrocode} |
| 2896 |
% \end{macro} |
| 2897 |
|
| 2898 |
|
| 2899 |
|
| 2900 |
|
| 2901 |
% \begin{macro}{\@endpefalse,\@endpetrue} |
| 2902 |
% Some extra debugging lines, but commented out for now. |
| 2903 |
% \begin{macrocode} |
| 2904 |
\def\@endpefalse{ |
| 2905 |
% \@@_debug_typeout:n { @endpe~ :=~ \if@endpe true \else false \fi -> false \on@line } |
| 2906 |
\global\let\if@endpe\iffalse |
| 2907 |
} |
| 2908 |
\def\@endpetrue {% |
| 2909 |
% \@@_debug_typeout:n { @endpe~ :=~ \if@endpe true \else false \fi -> true \on@line } |
| 2910 |
\global\let\if@endpe\iftrue |
| 2911 |
\ifnum\currentgrouptype =14 % semi-simple group |
| 2912 |
\aftergroup\propagate@doendpe |
| 2913 |
\else |
| 2914 |
\ifnum\currentgrouptype =\z@ % no group: top-level |
| 2915 |
\else |
| 2916 |
\ifnum\currentgrouptype =\@ne % simple group |
| 2917 |
\aftergroup\propagate@doendpe |
| 2918 |
\fi |
| 2919 |
\fi |
| 2920 |
\fi |
| 2921 |
} |
| 2922 |
|
| 2923 |
% \end{macrocode} |
| 2924 |
% \end{macro} |
| 2925 |
|
| 2926 |
|
| 2927 |
% |
| 2928 |
% \begin{socketdecl}{tagsupport/@doendpe} |
| 2929 |
% The socket is used in the \cs{@doendpe} |
| 2930 |
% TODO: if this goes into the kernel, the name should probably be different. |
| 2931 |
% \begin{macrocode} |
| 2932 |
\socket_if_exist:nF{ tagsupport/@doendpe } |
| 2933 |
{ |
| 2934 |
\NewTaggingSocket {@doendpe}{0} |
| 2935 |
} |
| 2936 |
% \end{macrocode} |
| 2937 |
% \end{socketdecl} |
| 2938 |
% |
| 2939 |
% \begin{plugdecl}{default} |
| 2940 |
% If a display block ends and is followed by a blank line we have to end the |
| 2941 |
% enclosing paragraph tagging structure. |
| 2942 |
% \begin{macrocode} |
| 2943 |
\NewTaggingSocketPlug {@doendpe}{default} |
| 2944 |
{ |
| 2945 |
\bool_if:NT \l__tag_para_bool |
| 2946 |
{ |
| 2947 |
% \end{macrocode} |
| 2948 |
% Given that restoring \tn{par} through the legacy \LaTeXe{} method |
| 2949 |
% can take a few iterations (for example, in case of nested lists, |
| 2950 |
% e.g., \verb=...\end{itemize} \item ...\par= it can happen that |
| 2951 |
% the socket code is called while |
| 2952 |
% \texttt{@endpe} is already handled and then we should not attempt |
| 2953 |
% to close a \struct{\UseStructureName{para/semantic}} structure). |
| 2954 |
% So we need to check for this. |
| 2955 |
% \begin{macrocode} |
| 2956 |
\legacy_if:nTF { @endpe } |
| 2957 |
{ |
| 2958 |
% \typeout{===>~ handle~ @endpe} |
| 2959 |
% \end{macrocode} |
| 2960 |
% If the display block currently ending was \enquote{flattened} |
| 2961 |
% (i.e., uses simplified paragraphs that are not tagged by a |
| 2962 |
% combination of \struct{\UseStructureName{para/semantic}} followed by \struct{\UseStructureName{para/textblock}}, but simply |
| 2963 |
% with a \struct{\UseStructureName{para/textblock}}), |
| 2964 |
% then we don't have to do anything, because the \struct{\UseStructureName{para/textblock}} is already closed. |
| 2965 |
% \begin{macrocode} |
| 2966 |
\@@_debug_typeout:n |
| 2967 |
{ flattened= \bool_if:NTF |
| 2968 |
\l__tag_para_flattened_bool |
| 2969 |
{true}{false} |
| 2970 |
\on@line } |
| 2971 |
\bool_if:NF \l__tag_para_flattened_bool |
| 2972 |
{ |
| 2973 |
% \end{macrocode} |
| 2974 |
% \changes{v0.9k}{2025/07/21}{Use tagging socket for text-unit structure} |
| 2975 |
% \begin{macrocode} |
| 2976 |
\UseTaggingSocket{para/semantic/end} |
| 2977 |
{ |
| 2978 |
\@@_debug_typeout:n{Structure-end~ |
| 2979 |
\l__tag_para_main_tag_tl\space |
| 2980 |
after~ displayblock \on@line } |
| 2981 |
} |
| 2982 |
} |
| 2983 |
} |
| 2984 |
{ |
| 2985 |
% \typeout{===>~ @endpe~ already~ handled} |
| 2986 |
} |
| 2987 |
} |
| 2988 |
} |
| 2989 |
% \end{macrocode} |
| 2990 |
% |
| 2991 |
% \begin{macrocode} |
| 2992 |
\AssignTaggingSocketPlug{@doendpe}{default} |
| 2993 |
% \end{macrocode} |
| 2994 |
% \end{plugdecl} |
| 2995 |
% |
| 2996 |
% |
| 2997 |
% |
| 2998 |
% \begin{macro}[int]{\if@domathendpe,\@domathendpefalse,\@domathendpetrue} |
| 2999 |
% Signal that special paragraph handling after a math display is required. |
| 3000 |
% \changes{v0.8x}{2024/12/01}{Handle \cs{parskip} after \texttt{\$\$} |
| 3001 |
% display (tagging/762)} |
| 3002 |
% \begin{macrocode} |
| 3003 |
\newif\if@domathendpe |
| 3004 |
\def\@domathendpefalse{\global\let\if@domathendpe\iffalse} |
| 3005 |
\def\@domathendpetrue {\global\let\if@domathendpe\iftrue} |
| 3006 |
% \end{macrocode} |
| 3007 |
% \end{macro} |
| 3008 |
% |
| 3009 |
% |
| 3010 |
% There is a general bug in the para handling: when the output routine is |
| 3011 |
% triggered the current setting of \texttt{@endpe} affects what |
| 3012 |
% happens in the OR. But it shouldn't, so we need to reset its value |
| 3013 |
% (which is global) and set it back after the OR has finished. This |
| 3014 |
% is what the following code does (final implementation should |
| 3015 |
% probably not involve a normal hook):\fmi{fix in kernel} |
| 3016 |
% \begin{macrocode} |
| 3017 |
\AddToHook{build/column/before}{% |
| 3018 |
\if@endpe \@endpefalse \aftergroup\@endpetrue \fi |
| 3019 |
} |
| 3020 |
% \end{macrocode} |
| 3021 |
% |
| 3022 |
% |
| 3023 |
% |
| 3024 |
% |
| 3025 |
% |
| 3026 |
% \subsubsection{Other useful \pkg{expl3} commands} |
| 3027 |
% |
| 3028 |
% This section collects \pkg{expl3} commands that will be useful in |
| 3029 |
% the code here and possibly generally. |
| 3030 |
% |
| 3031 |
% \begin{macro}{\@@_skip_set_to_last:N,\@@_skip_remove_last:} |
| 3032 |
% Set a skip register to the value of an immediately preceding |
| 3033 |
% skip or zero if there was none. |
| 3034 |
% \begin{macrocode} |
| 3035 |
\cs_new_protected:Npn \@@_skip_set_to_last:N #1 { |
| 3036 |
\skip_set:Nn #1 { \tex_lastskip:D } |
| 3037 |
} |
| 3038 |
% \end{macrocode} |
| 3039 |
% Remove a skip previous skip if it is directly in front (not |
| 3040 |
% allowed in unrestricted vertical mode). |
| 3041 |
% \begin{macrocode} |
| 3042 |
\cs_new_eq:NN \@@_skip_remove_last: \tex_unskip:D |
| 3043 |
% \end{macrocode} |
| 3044 |
% \end{macro} |
| 3045 |
% |
| 3046 |
% \begin{macro}{\tl_if_novalue:oTF} |
| 3047 |
% Not sure this is still necessary (or even correct) after the move |
| 3048 |
% to \cs{NoValue}. |
| 3049 |
% \fmi{check} |
| 3050 |
% \begin{macrocode} |
| 3051 |
\cs_generate_variant:Nn \tl_if_novalue:nTF { o } |
| 3052 |
% \end{macrocode} |
| 3053 |
% \end{macro} |
| 3054 |
% |
| 3055 |
% |
| 3056 |
% \subsection{Tracing and debugging interfaces} |
| 3057 |
% |
| 3058 |
% This follows the same convention as in other modules, but |
| 3059 |
% eventually that should be given a better |
| 3060 |
% implementation.\fmi{refactor at some stage} |
| 3061 |
% |
| 3062 |
% \begin{variable}{\g_@@_debug_bool} |
| 3063 |
% Boolean to indicate if we want to get debugging info from |
| 3064 |
% commands and templates handling block displays. |
| 3065 |
% \begin{macrocode} |
| 3066 |
\bool_new:N \g_@@_debug_bool |
| 3067 |
% \end{macrocode} |
| 3068 |
% \end{variable} |
| 3069 |
% |
| 3070 |
% |
| 3071 |
% \begin{macro}{\@@_debug:n,\@@_debug_typeout:n} |
| 3072 |
% Put debugging info in the code, displayed or not displayed |
| 3073 |
% depending on the value in \cs{g_@@_debug_bool}. |
| 3074 |
% \begin{macrocode} |
| 3075 |
\cs_new_eq:NN \@@_debug:n \use_none:n |
| 3076 |
\cs_new_eq:NN \@@_debug_typeout:n \use_none:n |
| 3077 |
% \end{macrocode} |
| 3078 |
% \end{macro} |
| 3079 |
% |
| 3080 |
% \begin{macro}{\block_debug_on:,\block_debug_off:, |
| 3081 |
% \@@_debug_gset:} |
| 3082 |
% Changing the debugging status. |
| 3083 |
% \begin{macrocode} |
| 3084 |
\cs_new_protected:Npn \block_debug_on: |
| 3085 |
{ |
| 3086 |
\bool_gset_true:N \g_@@_debug_bool |
| 3087 |
\@@_debug_gset: |
| 3088 |
} |
| 3089 |
% \end{macrocode} |
| 3090 |
% |
| 3091 |
% \begin{macrocode} |
| 3092 |
\cs_new_protected:Npn \block_debug_off: |
| 3093 |
{ |
| 3094 |
\bool_gset_false:N \g_@@_debug_bool |
| 3095 |
\@@_debug_gset: |
| 3096 |
} |
| 3097 |
% \end{macrocode} |
| 3098 |
% |
| 3099 |
% \begin{macrocode} |
| 3100 |
\cs_new_protected:Npn \@@_debug_gset: |
| 3101 |
{ |
| 3102 |
\cs_gset_protected:Npe \@@_debug:n ##1 |
| 3103 |
{ \bool_if:NT \g_@@_debug_bool {##1} } |
| 3104 |
\cs_gset_protected:Npe \@@_debug_typeout:n ##1 |
| 3105 |
{ \bool_if:NT \g_@@_debug_bool |
| 3106 |
{ \iow_term:e { ^^J [Blocks]~ ==>~ ##1} } } |
| 3107 |
} |
| 3108 |
% \end{macrocode} |
| 3109 |
% \end{macro} |
| 3110 |
% |
| 3111 |
% |
| 3112 |
% \begin{macro}{\DebugBlocksOn,\DebugBlocksOff} |
| 3113 |
% \changes{2026-03-19}{v0.9p}{Move template debugging support to kernel} |
| 3114 |
% If we are debugging blocks we also want to know about template |
| 3115 |
% instances, so we turn the debugging for templates as well (for now). |
| 3116 |
% \begin{macrocode} |
| 3117 |
\cs_new_protected:Npn \DebugBlocksOn { \block_debug_on: \DebugTemplatesOn } |
| 3118 |
\cs_new_protected:Npn \DebugBlocksOff { \block_debug_off: \DebugTemplatesOff } |
| 3119 |
% \end{macrocode} |
| 3120 |
% |
| 3121 |
% \begin{macrocode} |
| 3122 |
\DebugBlocksOff |
| 3123 |
% \end{macrocode} |
| 3124 |
% \end{macro} |
| 3125 |
% |
| 3126 |
% |
| 3127 |
% |
| 3128 |
% \begin{macro}{\DebugSwitchesOn,\DebugSwitchesOff} |
| 3129 |
% This debugs the use of legacy switches (so perhaps better |
| 3130 |
% called \cs{DebugLegacySwitchesOn}) but so far it was just a quick |
| 3131 |
% debugging aid while I was trying to understand. It needs some |
| 3132 |
% further thoughts and is probably not necessary at all in the end. |
| 3133 |
% \begin{macrocode} |
| 3134 |
\cs_new_protected:Npn \DebugSwitchesOn { |
| 3135 |
\AddToHookWithArguments{cmd/legacy_if_gset_false:n/before}[debug] |
| 3136 |
{\typeout{[Switch]~==>~ ##1~=~false~(global)}} |
| 3137 |
\AddToHookWithArguments{cmd/legacy_if_gset_true:n/before}[debug] |
| 3138 |
{\typeout{[Switch]~==>~ ##1~=~true~(global)}} |
| 3139 |
\AddToHookWithArguments{cmd/legacy_if_set_false:n/before}[debug] |
| 3140 |
{\typeout{[Switch]~==>~ ##1~=~false}} |
| 3141 |
\AddToHookWithArguments{cmd/legacy_if_set_true:n/before}[debug] |
| 3142 |
{\typeout{[Switch]~==>~ ##1~=~true}} |
| 3143 |
} |
| 3144 |
% \end{macrocode} |
| 3145 |
% |
| 3146 |
% \begin{macrocode} |
| 3147 |
\cs_new_protected:Npn \DebugSwitchesOff { |
| 3148 |
\RemoveFromHook{cmd/legacy_if_gset_false:n/before}[debug] |
| 3149 |
\RemoveFromHook{cmd/legacy_if_gset_true:n/before}[debug] |
| 3150 |
\RemoveFromHook{cmd/legacy_if_set_false:n/before}[debug] |
| 3151 |
\RemoveFromHook{cmd/legacy_if_set_true:n/before}[debug] |
| 3152 |
} |
| 3153 |
% \end{macrocode} |
| 3154 |
% |
| 3155 |
% \begin{macrocode} |
| 3156 |
%\DebugSwitchesOn |
| 3157 |
%\DebugSwitchesOff |
| 3158 |
% \end{macrocode} |
| 3159 |
% \end{macro} |
| 3160 |
% |
| 3161 |
% |
| 3162 |
% |
| 3163 |
% |
| 3164 |
% \subsection{Template types and template interfaces} |
| 3165 |
% |
| 3166 |
% This section is devoted to the template interfaces, and the template |
| 3167 |
% code is covered later. |
| 3168 |
% |
| 3169 |
% \begin{templatetype}{blockenv,list,captionedtext,thmstyle,block,item,para} |
| 3170 |
% ^^A |
| 3171 |
% All template types expect a first key--value argument used to |
| 3172 |
% tweak template parameters at a specific point in the document for |
| 3173 |
% a single environment or command. The template types |
| 3174 |
% \insttype{blockenv}, \insttype{list}, \insttype{captionedtext}, |
| 3175 |
% and \insttype{thmstyle} take three more arguments which are a |
| 3176 |
% boolean for suppressing numbering, a possible caption, and a |
| 3177 |
% possible sub-caption. |
| 3178 |
% |
| 3179 |
% \begin{macrocode} |
| 3180 |
\NewTemplateType{blockenv}{4} |
| 3181 |
\NewTemplateType{list}{4} |
| 3182 |
\NewTemplateType{captionedtext}{4} |
| 3183 |
\NewTemplateType{thmstyle}{4} |
| 3184 |
% \end{macrocode} |
| 3185 |
% |
| 3186 |
% \begin{macrocode} |
| 3187 |
\NewTemplateType{block}{1} |
| 3188 |
\NewTemplateType{item}{1} |
| 3189 |
\NewTemplateType{para}{1} |
| 3190 |
% \end{macrocode} |
| 3191 |
% \end{templatetype} |
| 3192 |
% |
| 3193 |
% |
| 3194 |
% |
| 3195 |
% \begin{template}{blockenv std} |
| 3196 |
% ^^A |
| 3197 |
% \begin{macrocode} |
| 3198 |
\DeclareTemplateInterface{blockenv}{std}{4} |
| 3199 |
{ |
| 3200 |
name : tokenlist , |
| 3201 |
% \end{macrocode} |
| 3202 |
% If not explicitly set then \key{tag-name} and |
| 3203 |
% \key{tag-attr-class} are set by the |
| 3204 |
% \key{tagging-recipe}. However, we have to default both to |
| 3205 |
% \meta{empty} so that nested blocks do not inherit from the outer |
| 3206 |
% level. |
| 3207 |
% \changes{v0.9g}{2025/06/30}{ (tagging/925)} |
| 3208 |
% \begin{macrocode} |
| 3209 |
,tag-name : tokenlist = |
| 3210 |
,tag-attr-class : tokenlist = |
| 3211 |
,tagging-recipe : tokenlist = standard |
| 3212 |
,transparent-level : boolean = false |
| 3213 |
,legacy-code : tokenlist = |
| 3214 |
,block-instance : tokenlist = std-display |
| 3215 |
% \end{macrocode} |
| 3216 |
% Paragraph instance is normally inherited so no default. |
| 3217 |
% \begin{macrocode} |
| 3218 |
,para-instance : tokenlist |
| 3219 |
,inner-level-counter : tokenlist |
| 3220 |
,max-inner-levels : tokenlist = 4 |
| 3221 |
,inner-instance-type : tokenlist = |
| 3222 |
,inner-instance : tokenlist = |
| 3223 |
,tagging-suppress-paras : boolean = false |
| 3224 |
,final-code : tokenlist = \ignorespaces |
| 3225 |
} |
| 3226 |
% \end{macrocode} |
| 3227 |
% \end{template} |
| 3228 |
% |
| 3229 |
% |
| 3230 |
% \begin{template}{block std} |
| 3231 |
% ^^A |
| 3232 |
% \changes{v0.8s}{2024/10/03}{Offer item-vspace key also on block templates} |
| 3233 |
% \changes{v0.9l}{2025/11/04}{Fix default for para-vspace, should be the outer \cs{parskip}} |
| 3234 |
% \begin{macrocode} |
| 3235 |
\DeclareTemplateInterface{block}{std}{1} |
| 3236 |
{ |
| 3237 |
,begin-vspace : skip = \topsep |
| 3238 |
,begin-extra-vspace : skip = \partopsep |
| 3239 |
,begin-unchained-vspace : skip = .5\topsep |
| 3240 |
,para-vspace : skip = \parskip |
| 3241 |
,end-vspace : skip = \KeyValue{begin-vspace} |
| 3242 |
,end-extra-vspace : skip = \KeyValue{begin-extra-vspace} |
| 3243 |
,item-vspace : skip = \itemsep |
| 3244 |
,begin-penalty : integer = \UseName{@beginparpenalty} |
| 3245 |
,end-penalty : integer = \UseName{@endparpenalty} |
| 3246 |
,item-penalty : integer = \UseName{@itempenalty} |
| 3247 |
,left-margin : length = \leftmargin |
| 3248 |
,right-margin : length = \rightmargin |
| 3249 |
,para-indent : length = 0pt |
| 3250 |
} |
| 3251 |
% \end{macrocode} |
| 3252 |
% \end{template} |
| 3253 |
% |
| 3254 |
% |
| 3255 |
% \begin{template}{para std} |
| 3256 |
% ^^A |
| 3257 |
% \begin{macrocode} |
| 3258 |
\DeclareTemplateInterface{para}{std}{1} |
| 3259 |
{ |
| 3260 |
,para-attr-class : tokenlist = justify |
| 3261 |
,para-indent : length = \parindent |
| 3262 |
,begin-hspace : skip = 0pt |
| 3263 |
,left-hspace : skip = 0pt |
| 3264 |
,right-hspace : skip = 0pt |
| 3265 |
,end-hspace : skip = \@flushglue |
| 3266 |
,fixed-word-spaces : boolean = false |
| 3267 |
,final-hyphen-demerits : integer = 5000 |
| 3268 |
,newline-cmd : function(0) = \@normalcr |
| 3269 |
} |
| 3270 |
% \end{macrocode} |
| 3271 |
% \end{template} |
| 3272 |
% |
| 3273 |
% |
| 3274 |
% \begin{template}{list std} |
| 3275 |
% ^^A |
| 3276 |
% \begin{macrocode} |
| 3277 |
\DeclareTemplateInterface{list}{std}{4} |
| 3278 |
{ |
| 3279 |
,counter : tokenlist = |
| 3280 |
,item-label : tokenlist = |
| 3281 |
,start : integer = 1 |
| 3282 |
,resume : boolean = false |
| 3283 |
,item-instance : instance{item} = basic |
| 3284 |
,item-vspace : skip = \itemsep |
| 3285 |
,item-penalty : integer = \UseName{@itempenalty} |
| 3286 |
,item-indent : length = \itemindent |
| 3287 |
,label-width : length = \labelwidth |
| 3288 |
,label-sep : length = \labelsep |
| 3289 |
,legacy-support : boolean = false |
| 3290 |
} |
| 3291 |
% \end{macrocode} |
| 3292 |
% \end{template} |
| 3293 |
% |
| 3294 |
% |
| 3295 |
% \begin{template}{item std} |
| 3296 |
% ^^A |
| 3297 |
% \begin{macrocode} |
| 3298 |
\DeclareTemplateInterface{item}{std}{1} |
| 3299 |
{ |
| 3300 |
,counter-label : function{1} = \arabic{#1} |
| 3301 |
,counter-ref : function{1} = \KeyValue{counter-label} |
| 3302 |
,label-ref : function{1} = #1 |
| 3303 |
,label-autoref : function{1} = item~#1 |
| 3304 |
,label-format : function{1} = #1 |
| 3305 |
,label-strut : boolean = false |
| 3306 |
,label-align : choice {left,center,right,parleft} = right |
| 3307 |
,label-boxed : boolean = true |
| 3308 |
,next-line : boolean = false % <- review viz standalone below |
| 3309 |
,text-font : tokenlist |
| 3310 |
,compatibility : boolean = true |
| 3311 |
,label-placement : choice {chained,unchained,standalone} = chained , |
| 3312 |
} |
| 3313 |
% \end{macrocode} |
| 3314 |
% \end{template} |
| 3315 |
% |
| 3316 |
% |
| 3317 |
% \begin{template}{captionedtext thmlike} |
| 3318 |
% ^^A |
| 3319 |
% The \insttype{captionedtext} \instname{thmlike} template for |
| 3320 |
% theorem-like environments has only three keys because it |
| 3321 |
% delegates most of the work to the \insttype{thmstyle} |
| 3322 |
% template specified in the key \key{style}. |
| 3323 |
% \begin{macrocode} |
| 3324 |
\DeclareTemplateInterface{captionedtext}{thmlike}{4} |
| 3325 |
{ |
| 3326 |
,counter : tokenlist = |
| 3327 |
,title : tokenlist = % <- bad name? |
| 3328 |
,style : instance{thmstyle} = plain |
| 3329 |
} |
| 3330 |
% \end{macrocode} |
| 3331 |
% \end{template} |
| 3332 |
% |
| 3333 |
% |
| 3334 |
% \begin{template}{captionedtext proof} |
| 3335 |
% ^^A |
| 3336 |
% In contrast, the \insttype{captionedtext} \instname{proof} |
| 3337 |
% template implements all of the \env{proof} environment without |
| 3338 |
% any delegation and therefore shows several keys for customizing |
| 3339 |
% the layout (similar to those seen with \insttype{thmstyle} |
| 3340 |
% \instname{std}). |
| 3341 |
% \changes{v0.9n}{2026/02/01}{Add further decl keys (tagging/1199)} |
| 3342 |
% \changes{v0.9n}{2026/02/01}{Add caption-unbreakable key (tagging/1200)} |
| 3343 |
% \changes{v0.9n}{2026/02/02}{Use \cs{proofname} as value for title (tagging/1207)} |
| 3344 |
% \begin{macrocode} |
| 3345 |
\DeclareTemplateInterface{captionedtext}{proof}{4} |
| 3346 |
{ |
| 3347 |
,title : tokenlist = \proofname |
| 3348 |
,punct : tokenlist = . |
| 3349 |
,caption-placement : choice {chained,unchained,standalone} = unchained |
| 3350 |
,caption-unbreakable : boolean = false |
| 3351 |
,before-hspace : skip = 0pt |
| 3352 |
,after-hspace : skip = 5pt |
| 3353 |
,caption-decls : tokenlist = |
| 3354 |
,title-decls : tokenlist = |
| 3355 |
,punct-decls : tokenlist = |
| 3356 |
,title-format : function{1} = #1 |
| 3357 |
,punct-format : function{1} = #1 |
| 3358 |
,body-decls : tokenlist = |
| 3359 |
} |
| 3360 |
% \end{macrocode} |
| 3361 |
% \end{template} |
| 3362 |
% |
| 3363 |
% \begin{macro}{\proofname} |
| 3364 |
% The \pkg{amsthm} package supported redefinition of \cs{proofname} |
| 3365 |
% as a means to alter default caption for proofs. We continue to |
| 3366 |
% support this as long as the instance declaration doesn't |
| 3367 |
% overwrite it. |
| 3368 |
% \changes{v0.9n}{2026/02/02}{Macro \cs{proofname} added (tagging/1207)} |
| 3369 |
% \begin{macrocode} |
| 3370 |
\newcommand\proofname{Proof} |
| 3371 |
% \end{macrocode} |
| 3372 |
% \end{macro} |
| 3373 |
% |
| 3374 |
% |
| 3375 |
% |
| 3376 |
% |
| 3377 |
% \begin{template}{thmstyle std} |
| 3378 |
% |
| 3379 |
% \changes{v0.9n}{2026/02/01}{Add further decl keys (tagging/1199)} |
| 3380 |
% \changes{v0.9n}{2026/02/01}{Add caption-unbreakable key (tagging/1200)} |
| 3381 |
% \begin{macrocode} |
| 3382 |
\DeclareTemplateInterface{thmstyle}{std}{4} |
| 3383 |
{ |
| 3384 |
,numbered : boolean = true |
| 3385 |
,separator : tokenlist = \ |
| 3386 |
,punct : tokenlist = . |
| 3387 |
,caption-placement : choice {chained,unchained,standalone} = unchained |
| 3388 |
,caption-unbreakable : boolean = false |
| 3389 |
,before-hspace : skip = 0pt |
| 3390 |
,after-hspace : skip = 5pt |
| 3391 |
,order : commalist = { title, separator, number, punct, separator, note } |
| 3392 |
,caption-decls : tokenlist = |
| 3393 |
,title-decls : tokenlist = |
| 3394 |
,number-decls : tokenlist = |
| 3395 |
,punct-decls : tokenlist = |
| 3396 |
,note-decls : tokenlist = |
| 3397 |
,title-format : function{1} = #1 |
| 3398 |
,number-format : function{1} = #1 |
| 3399 |
,punct-format : function{1} = #1 |
| 3400 |
,note-format : function{1} = (#1) |
| 3401 |
,body-decls : tokenlist = |
| 3402 |
} |
| 3403 |
% \end{macrocode} |
| 3404 |
% \end{template} |
| 3405 |
% |
| 3406 |
% |
| 3407 |
% |
| 3408 |
% |
| 3409 |
% |
| 3410 |
% \subsection{Implementation of templates} |
| 3411 |
% |
| 3412 |
% |
| 3413 |
% \subsubsection{Some notes on the \LaTeXe{} legacy switches} |
| 3414 |
% |
| 3415 |
% \LaTeXe{} used a number of switches to manage its list environments |
| 3416 |
% and everything that was based on them. |
| 3417 |
% |
| 3418 |
% For the reimplementation I made some notes about the original |
| 3419 |
% usage and how this got changed (while keeping the names for now). |
| 3420 |
% |
| 3421 |
% Some of these switches really need to keep their names, e.g., |
| 3422 |
% \texttt{@nobreak} or \texttt{minipage}, because they are used all |
| 3423 |
% over the place. Others can probably replaced with L3 booleans |
| 3424 |
% which makes things faster and cleaner, but for now I kept them |
| 3425 |
% too. |
| 3426 |
% |
| 3427 |
% \paragraph{Original usage:} |
| 3428 |
% \begin{macrocode} |
| 3429 |
% |
| 3430 |
% @newlist (global): signal that we are at the start of a list |
| 3431 |
% |
| 3432 |
% -> true at the start of a list before the first item when control |
| 3433 |
% is returned to document |
| 3434 |
% -> false in everypar setting the first item |
| 3435 |
% -> false at end of list if still true (after generating an error) |
| 3436 |
% |
| 3437 |
% -> tests: at list start setting @noparitemtrue and @noparlisttrue |
| 3438 |
% |
| 3439 |
% |
| 3440 |
% @inlabel (global): signaling that some item label waits to be typeset |
| 3441 |
% |
| 3442 |
% -> true in \@item |
| 3443 |
% -> false at list end |
| 3444 |
% -> false in everypar after label has been typeset |
| 3445 |
% -> false in \newpage after \leavevmode to typeset item label |
| 3446 |
% (probably not needed) |
| 3447 |
% |
| 3448 |
% -> tests: at list start setting @noparitemtrue and @noparlisttrue |
| 3449 |
% -> tests: at list end to ensure that dangling label is typeset |
| 3450 |
% -> tests: in \@item to output a dangling item label by switching to hmode |
| 3451 |
% -> tests: in \everypar to output a dangling item label |
| 3452 |
% -> tests: in \newpage to output a dangling item label before the page is ended |
| 3453 |
% -> tests: in tagging hook {para/begin}{kernel} |
| 3454 |
% |
| 3455 |
% |
| 3456 |
% @noparlist (local): |
| 3457 |
% |
| 3458 |
% -> true at start of list if already @inlabel=true |
| 3459 |
% -> false at start of list otherwise |
| 3460 |
% |
| 3461 |
% -> tests: in \endtrivlist. If true suppress vertical spacing after the list |
| 3462 |
% |
| 3463 |
% |
| 3464 |
% @noparitem (local): |
| 3465 |
% |
| 3466 |
% -> true at start of list if already @inlabel=true |
| 3467 |
% -> false |
| 3468 |
% |
| 3469 |
% \end{macrocode} |
| 3470 |
% \paragraph{Repurpose:} |
| 3471 |
% \begin{macrocode} |
| 3472 |
% |
| 3473 |
% Interpret legacy switches as follows (keeping the names for now) |
| 3474 |
% |
| 3475 |
% @newlist -> signals that we are at the start of a new block with a caption or |
| 3476 |
% at the start of a list block expecting an item next |
| 3477 |
% |
| 3478 |
% In other words this is now really start of a block |
| 3479 |
% with inner structure. |
| 3480 |
% |
| 3481 |
% @noparlist -> signals that we are on a new block with @inlabel already true, i.e., |
| 3482 |
% and this placement should happen horizontally |
| 3483 |
% |
| 3484 |
% @inlabel -> Signals that we have at least one item or caption waiting to be typeset |
| 3485 |
% inside the label box |
| 3486 |
% |
| 3487 |
% @noparitem -> dropped (handled directly) |
| 3488 |
% |
| 3489 |
% \end{macrocode} |
| 3490 |
% |
| 3491 |
% |
| 3492 |
% |
| 3493 |
% |
| 3494 |
% |
| 3495 |
% \subsubsection{Implementation of \insttype{blockenv} templates} |
| 3496 |
% |
| 3497 |
% So far there is only one, but who knows \ldots\ --- however, the |
| 3498 |
% majority will be vertically oriented blocks, so we make this the \texttt{std}. |
| 3499 |
% |
| 3500 |
% \begin{template}{blockenv std} |
| 3501 |
% ^^A |
| 3502 |
% \begin{macrocode} |
| 3503 |
\DeclareTemplateCode{blockenv}{std}{4} |
| 3504 |
{ |
| 3505 |
name = \l_@@_env_name_tl |
| 3506 |
,tag-name = \l_@@_tag_name_tl |
| 3507 |
,tag-attr-class = \l_@@_tag_class_tl |
| 3508 |
,tagging-recipe = \l_@@_tagging_recipe_tl |
| 3509 |
,transparent-level = \l_@@_transparent_level_bool |
| 3510 |
,legacy-code = \l_@@_legacy_code_tl |
| 3511 |
,block-instance = \l_@@_block_instance_tl |
| 3512 |
,para-instance = \l_@@_para_instance_tl |
| 3513 |
,tagging-suppress-paras = \l__tag_para_flattened_bool |
| 3514 |
,inner-level-counter = \l_@@_inner_level_counter_tl |
| 3515 |
,max-inner-levels = \l_@@_max_inner_levels_tl |
| 3516 |
,inner-instance-type = \l_@@_inner_instance_type_tl |
| 3517 |
,inner-instance = \l_@@_inner_instance_tl |
| 3518 |
,final-code = \l_@@_final_code_tl |
| 3519 |
} |
| 3520 |
{ |
| 3521 |
\template_debug_typeout:n{~\space template:~ 'std;~ |
| 3522 |
arguments:~ \exp_not:n{|#1|#2|#3|#4|}} |
| 3523 |
% \end{macrocode} |
| 3524 |
% For special legacy support we start with a hook that receives the |
| 3525 |
% \key{name} value as its argument (so that it contains code that |
| 3526 |
% is only executed for a specific name). Before calling this hook we also set |
| 3527 |
% \cs{UnusedTemplateKeys} to empty. In the hook code this macro can then |
| 3528 |
% be filled with key/value settings (for example, from \cs{setlist}) |
| 3529 |
% to be fed below into \cs{SetKnownTemplateKeys}. |
| 3530 |
% \begin{macrocode} |
| 3531 |
\tl_set_eq:NN \UnusedTemplateKeys \c_empty_tl |
| 3532 |
\exp_args:Nnno \hook_use:nnw {blockenv} 1 \l_@@_env_name_tl |
| 3533 |
% \end{macrocode} |
| 3534 |
% To the \cs{UnusedTemplateKeys} (empty or filled) we append any |
| 3535 |
% keys specified in the first argument to the template unless |
| 3536 |
% \texttt{\#1} is empty or contains just \cs{NoValue}. This allows |
| 3537 |
% keys set on the document level to overwrite those set by |
| 3538 |
% \cs{setlist} and ultimately also those set in the instance. |
| 3539 |
% \begin{macrocode} |
| 3540 |
\tl_if_empty:oF {#1} |
| 3541 |
{ |
| 3542 |
\tl_if_novalue:nF {#1} |
| 3543 |
{ |
| 3544 |
% \end{macrocode} |
| 3545 |
% We expand \texttt{\#1} once because the keys might be hidden in a |
| 3546 |
% user macro. |
| 3547 |
% \begin{macrocode} |
| 3548 |
\tl_set:Ne \UnusedTemplateKeys |
| 3549 |
{ \exp_not:o \UnusedTemplateKeys \exp_not:o { #1 } } |
| 3550 |
} |
| 3551 |
} |
| 3552 |
% \end{macrocode} |
| 3553 |
% Finally the key list stored in \cs{UnusedTemplateKeys} is then |
| 3554 |
% fed to \cs{SetKnownTemplateKeys} for |
| 3555 |
% evaluation. \cs{SetKnownTemplateKeys} applies all keys that apply |
| 3556 |
% to the \insttype{blockenv} template and saves those that don't |
| 3557 |
% back in \cs{UnusedTemplateKeys} to be applied to inner instances |
| 3558 |
% below. This is why we had to combine all keys and evaluate them |
| 3559 |
% in one go. |
| 3560 |
% \begin{macrocode} |
| 3561 |
\SetKnownTemplateKeys {blockenv} {std} \UnusedTemplateKeys |
| 3562 |
% \end{macrocode} |
| 3563 |
% We need to know later if we have nested \insttype{blockenv}s |
| 3564 |
% inside a flattened environment. Whenever we start a new |
| 3565 |
% \insttype{blockenv} we increment |
| 3566 |
% \cs{l__tag_block_flattened_level_int} if it is already different |
| 3567 |
% from zero. If it is zero we increment it if flattening is |
| 3568 |
% requested. Thus a value of \texttt{0} means no flattening |
| 3569 |
% requested so far and \texttt{1} means this is the first blockenv |
| 3570 |
% requesting flattening. In either case we have to make sure that |
| 3571 |
% the blockenv is surrounded by a |
| 3572 |
% \struct{\UseStructureName{para/semantic}} tag, while for any |
| 3573 |
% value above \texttt{1} we have to omit the |
| 3574 |
% \struct{\UseStructureName{para/semantic}}. |
| 3575 |
% \begin{macrocode} |
| 3576 |
\int_compare:nNnTF \l__tag_block_flattened_level_int > 0 |
| 3577 |
{ |
| 3578 |
\int_incr:N \l__tag_block_flattened_level_int |
| 3579 |
} |
| 3580 |
{ |
| 3581 |
\bool_if:NT \l__tag_para_flattened_bool |
| 3582 |
{ |
| 3583 |
\int_incr:N \l__tag_block_flattened_level_int |
| 3584 |
} |
| 3585 |
} |
| 3586 |
% \end{macrocode} |
| 3587 |
% |
| 3588 |
% \begin{macrocode} |
| 3589 |
\tl_if_empty:NF \l_@@_inner_level_counter_tl |
| 3590 |
{ |
| 3591 |
\int_compare:nNnTF \l_@@_inner_level_counter_tl > |
| 3592 |
{ \l_@@_max_inner_levels_tl - 1 } |
| 3593 |
{ \@toodeep } |
| 3594 |
{ \int_incr:N \l_@@_inner_level_counter_tl } % not clean "o"? |
| 3595 |
} |
| 3596 |
% \end{macrocode} |
| 3597 |
% Legacy defaults are only roped in if the list level changes. For |
| 3598 |
% display blocks that remain on the same level the current values |
| 3599 |
% are kept. |
| 3600 |
% \begin{macrocode} |
| 3601 |
\int_compare:nNnTF \g_block_nesting_depth_int > |
| 3602 |
{ \c@maxblocklevels - 1 } |
| 3603 |
{ \@toodeep } |
| 3604 |
{ |
| 3605 |
\int_gincr:N \g_block_nesting_depth_int |
| 3606 |
% \end{macrocode} |
| 3607 |
% If there are no legacy defaults for that level then the next line |
| 3608 |
% does nothing, i.e., the current values (from the last level) |
| 3609 |
% become the defaults for the next. |
| 3610 |
% |
| 3611 |
% If have a transparent level (e.g., something like a \env{center} |
| 3612 |
% environment) we omit setting the legacy defaults, because that is |
| 3613 |
% the way \LaTeXe{} lists worked as well. |
| 3614 |
% \changes{v0.9m}{2026-01-05}{Don't use legacy \texttt{@listi..} values for |
| 3615 |
% transparent blocks (tagging/1163)} |
| 3616 |
% \begin{macrocode} |
| 3617 |
\bool_if:NF \l__block_transparent_level_bool |
| 3618 |
{ |
| 3619 |
\use:c { @list |
| 3620 |
\int_to_roman:n { \g_block_nesting_depth_int } } |
| 3621 |
} |
| 3622 |
} |
| 3623 |
% \end{macrocode} |
| 3624 |
% If we are doing tagging we load one of the available recipes for |
| 3625 |
% tagging, which alters various kernel hooks to add appropriate |
| 3626 |
% tagging structures. |
| 3627 |
% \changes{v0.9g}{2025-07-01}{use tagging socket for recipe} |
| 3628 |
% \begin{macrocode} |
| 3629 |
\UseTaggingSocket{block/recipe}{\l_@@_tagging_recipe_tl} |
| 3630 |
% \end{macrocode} |
| 3631 |
% The default for \env{list} environments is that they have an |
| 3632 |
% empty label and are not numbered (something that is then |
| 3633 |
% overwritten by the setup of a specific list). We ensure |
| 3634 |
% this here even for non-lists, because we need a defined state |
| 3635 |
% that then can be overwritten by the legacy setup code for |
| 3636 |
% the \env{list} environment in \cs{l_@@_legacy_code_tl}. |
| 3637 |
% This is needed in case lists are nested as they otherwise would |
| 3638 |
% inherit outer values (and suddenly an \env{itemize} would start |
| 3639 |
% incrementing an outer \env{enumerate} counter, etc. |
| 3640 |
% \changes{v0.8v}{2024/10/11}{Set the defaults for \tn{@itemlabel}, |
| 3641 |
% \tn{@listctr} and \texttt{@nmbrlist} early in the block code |
| 3642 |
% before the setup code gets executed (tagging/730)} |
| 3643 |
% \begin{macrocode} |
| 3644 |
\tl_clear:N \@itemlabel |
| 3645 |
\tl_clear:N \@listctr |
| 3646 |
\legacy_if_set_false:n { @nmbrlist } |
| 3647 |
% \end{macrocode} |
| 3648 |
% Then run the legacy setup code if any is given in the instance. |
| 3649 |
% \begin{macrocode} |
| 3650 |
\l_@@_legacy_code_tl |
| 3651 |
% \end{macrocode} |
| 3652 |
% Next call a block instance at the appropriate level passing it |
| 3653 |
% any remaining key/value from the optional document-level argument |
| 3654 |
% (i.e., those now stored in \cs{UnusedTemplateKeys}). |
| 3655 |
% |
| 3656 |
% |
| 3657 |
% \changes{v0.9j}{2025/07/11}{Expand arguments before passing them to |
| 3658 |
% \cs{UseInstance} to get better error messages} |
| 3659 |
% \begin{macrocode} |
| 3660 |
\exp_args:Nee \UseInstance {block} |
| 3661 |
{ \l_@@_block_instance_tl - \int_use:N |
| 3662 |
\g_block_nesting_depth_int } |
| 3663 |
\UnusedTemplateKeys |
| 3664 |
% \end{macrocode} |
| 3665 |
% After this instance has been processed, any remaining unused keys |
| 3666 |
% are stored in \cs{UnusedTemplateKeys} and we can make use of this |
| 3667 |
% data later as long as we do not call another instance that also |
| 3668 |
% does unused key processing and overwrites it. But this is what |
| 3669 |
% happens below, so we better save its current value for now. |
| 3670 |
% \begin{macrocode} |
| 3671 |
\tl_set_eq:NN \l_@@_unused_blockenv_keys_tl \UnusedTemplateKeys |
| 3672 |
% \end{macrocode} |
| 3673 |
% After the block instance call the para and then inner (list) |
| 3674 |
% instance if either or both are |
| 3675 |
% specified (which may not be the case). |
| 3676 |
% \begin{macrocode} |
| 3677 |
\tl_if_empty:NF \l_@@_para_instance_tl |
| 3678 |
{ |
| 3679 |
% \end{macrocode} |
| 3680 |
% For now we don't offer to alter instance parameters here so we |
| 3681 |
% pass an empty argument.^^A |
| 3682 |
% \changes{v0.9j}{2025/07/11}{Expand arguments before passing them to |
| 3683 |
% \cs{UseInstance} to get better error messages} |
| 3684 |
% \begin{macrocode} |
| 3685 |
\exp_args:Nee \UseInstance {para}{ \l_@@_para_instance_tl } {} |
| 3686 |
} |
| 3687 |
% \end{macrocode} |
| 3688 |
% The inner instance may have its own levels or none depending |
| 3689 |
% on which the instance name differs. Again we pass it the optional |
| 3690 |
% key/value list. |
| 3691 |
% \begin{macrocode} |
| 3692 |
\tl_if_empty:NF \l_@@_inner_instance_tl |
| 3693 |
{ |
| 3694 |
% \end{macrocode} |
| 3695 |
% We expand the first two arguments so that we get proper names for |
| 3696 |
% template type and instance, because \cs{UseInstance} is not doing |
| 3697 |
% that for us in the right way. |
| 3698 |
% \changes{v0.9j}{2025/07/11}{Expand arguments before passing them to |
| 3699 |
% \cs{UseInstance} to get better error messages} |
| 3700 |
% \begin{macrocode} |
| 3701 |
\exp_args:Nee |
| 3702 |
\UseInstance{ \l_@@_inner_instance_type_tl } |
| 3703 |
{ \l_@@_inner_instance_tl |
| 3704 |
\tl_if_empty:NF \l_@@_inner_level_counter_tl |
| 3705 |
% not clean use "o"? |
| 3706 |
{ - \int_use:N \l_@@_inner_level_counter_tl } |
| 3707 |
} |
| 3708 |
\l_@@_unused_blockenv_keys_tl |
| 3709 |
#2 % <-- \BooleanTrue or False |
| 3710 |
{ #3 } % <-- \NoValue or content |
| 3711 |
{ #4 } % <-- \NoValue or content |
| 3712 |
% \end{macrocode} |
| 3713 |
% Again the instance may have processed a few keys from the so far |
| 3714 |
% unused keys, so we update \cs{l_@@_unused_blockenv_keys_tl} to |
| 3715 |
% match the new reality. |
| 3716 |
% \begin{macrocode} |
| 3717 |
\tl_set_eq:NN \l_@@_unused_blockenv_keys_tl \UnusedTemplateKeys |
| 3718 |
} |
| 3719 |
% \end{macrocode} |
| 3720 |
% At this point, the \cs{l_@@_unused_blockenv_keys_tl} token list |
| 3721 |
% should either be empty or it should contain only keys that are suitable for |
| 3722 |
% the item template, but right now there is no code to test that |
| 3723 |
% can test |
| 3724 |
% the latter; it would help probably if we have an interface for |
| 3725 |
% this. |
| 3726 |
% |
| 3727 |
% For now we handle that when the first item is encountered, but |
| 3728 |
% that isn't really clean.\fmi{fix} |
| 3729 |
% \begin{macrocode} |
| 3730 |
% \tl_if_empty:NF \l_@@_unused_blockenv_keys_tl |
| 3731 |
% { |
| 3732 |
% % check if only item template keys remain |
| 3733 |
% } |
| 3734 |
% \end{macrocode} |
| 3735 |
% If this is supposed to be a transparent block environment then we |
| 3736 |
% have to decrement the nesting level again so that nested |
| 3737 |
% environments think nothing is there. |
| 3738 |
% \begin{macrocode} |
| 3739 |
\bool_if:NT \l_@@_transparent_level_bool |
| 3740 |
{ \int_gdecr:N \g_block_nesting_depth_int } |
| 3741 |
% \end{macrocode} |
| 3742 |
% We finish off with \cs{l_@@_final_code_tl} which defaults to |
| 3743 |
% \tn{ignorespaces} so that spaces between \verb=\begin{...}= and |
| 3744 |
% the start of the text are ignored. |
| 3745 |
% \begin{macrocode} |
| 3746 |
\l_@@_final_code_tl |
| 3747 |
} |
| 3748 |
% \end{macrocode} |
| 3749 |
% \end{template} |
| 3750 |
% |
| 3751 |
% |
| 3752 |
% \begin{hookdecl}{blockenv} |
| 3753 |
% For legacy support we want a hook with one argument (the name of |
| 3754 |
% the \insttype{blockenv} instance). This way code could be added |
| 3755 |
% that is conditional based on which instance is executed. |
| 3756 |
% \begin{macrocode} |
| 3757 |
\NewHookWithArguments{blockenv}{1} |
| 3758 |
% \end{macrocode} |
| 3759 |
% \end{hookdecl} |
| 3760 |
% |
| 3761 |
% \begin{macro}{\BlockEnv,\SimpleBlockEnv} |
| 3762 |
% To simplify the environment declarations later we provide two |
| 3763 |
% simple commands that invoke a \insttype{blockenv} instance. The |
| 3764 |
% matching counterpart to these commands is \cs{BockEnvEnd} |
| 3765 |
% (defined below) that carries out all necessary action when a |
| 3766 |
% block environment ends. |
| 3767 |
% \begin{macrocode} |
| 3768 |
\cs_new_protected:Npn \BlockEnv % #1#2#3#4 implicit |
| 3769 |
{ \UseInstance{blockenv} } |
| 3770 |
% \end{macrocode} |
| 3771 |
% |
| 3772 |
% This here is the most common one that hides arguments 2--4 when |
| 3773 |
% they aren't needed, e.g., in a \env{center} environment. |
| 3774 |
% \begin{macrocode} |
| 3775 |
\cs_new_protected:Npn \SimpleBlockEnv #1#2 |
| 3776 |
{ \UseInstance{blockenv}{#1}{#2} \BooleanFalse \NoValue \NoValue } |
| 3777 |
% \end{macrocode} |
| 3778 |
% \end{macro} |
| 3779 |
% |
| 3780 |
% |
| 3781 |
% |
| 3782 |
% \begin{macro}{\g_block_nesting_depth_int} |
| 3783 |
% \LaTeXe{} already has a counter to record the nesting depth of |
| 3784 |
% blocks, but we want our own name because it isn't really tied to |
| 3785 |
% \enquote{lists} any more. However, \tn{@listdepth} is really part |
| 3786 |
% of the legacy interface (for example \env{minipage} alters it to |
| 3787 |
% point to a different counter) so that we are stuck with using at |
| 3788 |
% least indirectly for now and the following line makes this look |
| 3789 |
% like an L3 integer variable but internally expands to \tn{@listdepth}: |
| 3790 |
% \begin{macrocode} |
| 3791 |
\cs_new_protected:Npn \g_block_nesting_depth_int { \@listdepth } % a fake int |
| 3792 |
% for now |
| 3793 |
% \end{macrocode} |
| 3794 |
% \end{macro} |
| 3795 |
% |
| 3796 |
% |
| 3797 |
% |
| 3798 |
% \begin{macro}{\l_@@_unused_blockenv_keys_tl} |
| 3799 |
% The token list that holds key values we haven't yet used while |
| 3800 |
% we are processing the instances in a block environment. |
| 3801 |
% \begin{macrocode} |
| 3802 |
\tl_new:N \l_@@_unused_blockenv_keys_tl |
| 3803 |
% \end{macrocode} |
| 3804 |
% \end{macro} |
| 3805 |
% |
| 3806 |
% |
| 3807 |
% \begin{macro}{\l__tag_block_flattened_level_int} |
| 3808 |
% Count the levels of nested \insttype{blockenv}s starting with the first that |
| 3809 |
% is \enquote{flattened}. The counter is defined in lttagging.dtx, |
| 3810 |
% but until the next release 11/24 we set it up here too |
| 3811 |
% \begin{macrocode} |
| 3812 |
\int_if_exist:NF \l__tag_block_flattened_level_int |
| 3813 |
{ |
| 3814 |
\int_new:N \l__tag_block_flattened_level_int |
| 3815 |
} |
| 3816 |
% \end{macrocode} |
| 3817 |
% \end{macro} |
| 3818 |
% |
| 3819 |
% \begin{macro}{\c@maxblocklevels} |
| 3820 |
% A counter to increase or decrease the number of supported |
| 3821 |
% level. If increased, one needs to supply additional level instances. |
| 3822 |
% \begin{macrocode} |
| 3823 |
\newcounter{maxblocklevels} |
| 3824 |
\setcounter{maxblocklevels}{6} |
| 3825 |
% \end{macrocode} |
| 3826 |
% \end{macro} |
| 3827 |
% |
| 3828 |
% \begin{macro}{\BlockEnvEnd} |
| 3829 |
% The code executed when a \insttype{blockenv} ends is 99\% the |
| 3830 |
% same for all \insttype{blockenv}s (at least up to now). Small |
| 3831 |
% differences exist, though. They are accounted for first in the |
| 3832 |
% conditionals. |
| 3833 |
% |
| 3834 |
% \changes{v0.9l}{2025/11/21}{Renamed \cs{endblockenv} to \cs{BlockEnvEnd}} |
| 3835 |
% |
| 3836 |
% We make this a public command so that new block environments can |
| 3837 |
% be set up without the need to resort to L3 layer |
| 3838 |
% programming. |
| 3839 |
% \begin{macrocode} |
| 3840 |
\cs_new_protected:Npn \BlockEnvEnd { |
| 3841 |
\@@_debug_typeout:n{blockenv~ common~ ending \on@line} |
| 3842 |
% \end{macrocode} |
| 3843 |
% If this block is not a transparent one we have to decrement the level |
| 3844 |
% now again, otherwise that had happened earlier: |
| 3845 |
% \begin{macrocode} |
| 3846 |
\bool_if:NF \l_@@_transparent_level_bool |
| 3847 |
{ \int_gdecr:N \g_block_nesting_depth_int } |
| 3848 |
% \end{macrocode} |
| 3849 |
% If the \texttt{@inlabel} switch is true, i.e., if there is a |
| 3850 |
% caption or an item waiting to be placed we move to horizontal |
| 3851 |
% mode to get them typeset. |
| 3852 |
% \begin{macrocode} |
| 3853 |
\legacy_if:nT { @inlabel } |
| 3854 |
{ |
| 3855 |
\mode_leave_vertical: |
| 3856 |
\legacy_if_gset_false:n { @inlabel } |
| 3857 |
} |
| 3858 |
% \end{macrocode} |
| 3859 |
% If we are ending a list environment and we have not seen any |
| 3860 |
% \tn{item}, i.e., \texttt{@newlist} is still true, we raise an |
| 3861 |
% error. In basic a ``displayblock'' scenario \texttt{@newlist} will |
| 3862 |
% always be false, but if such an environment appears inside an outer |
| 3863 |
% list then \tn{noitemerr} could still be triggered and that is undesirable |
| 3864 |
% (as the missing item will be detected at the wrong point and again later, |
| 3865 |
% during the outer list processing). We |
| 3866 |
% therefore run it only if the current environment is a list. |
| 3867 |
% \changes{v0.8q}{2024/09/03}{Raise a \tn{@noitemerr} if appropriate} |
| 3868 |
% \begin{macrocode} |
| 3869 |
\@@_if_list:TF |
| 3870 |
{ \legacy_if:nT { @newlist } { \@noitemerr } } |
| 3871 |
% \end{macrocode} |
| 3872 |
% If we aren't in a list we check if there are still unused keys |
| 3873 |
% and in that case generate an error. In lists that is already done |
| 3874 |
% at each \cs{item} command. |
| 3875 |
% \changes{v0.9s}{2026/04/22}{Generate error when the block ends and |
| 3876 |
% some keys are still unused (tagging/1317)} |
| 3877 |
% \begin{macrocode} |
| 3878 |
{ |
| 3879 |
\tl_if_empty:NF \UnusedTemplateKeys |
| 3880 |
{ |
| 3881 |
\msg_error:nnee { block } { unknown-keys } |
| 3882 |
{ \l_@@_env_name_tl \space environment} |
| 3883 |
\UnusedTemplateKeys |
| 3884 |
} |
| 3885 |
} |
| 3886 |
% \end{macrocode} |
| 3887 |
% \begin{macrocode} |
| 3888 |
\mode_if_horizontal:TF |
| 3889 |
{ \@@_skip_remove_last: \@@_skip_remove_last: \par } |
| 3890 |
{ \@inmatherr{\end{\@currenvir}} } |
| 3891 |
% \end{macrocode} |
| 3892 |
% Once we are back in vertical mode we can add the appropriate |
| 3893 |
% closing tagging structure(s), if we are doing tagging. |
| 3894 |
% \begin{macrocode} |
| 3895 |
\__kernel_displayblock_end: |
| 3896 |
% \end{macrocode} |
| 3897 |
% Resetting the \texttt{@newlist} switch is also only done if the |
| 3898 |
% current environment is a list. |
| 3899 |
% \changes{v0.8q}{2024/09/03}{Setting \texttt{@newlist} to false |
| 3900 |
% moved after tagging code if in a list} |
| 3901 |
% \begin{macrocode} |
| 3902 |
\@@_if_list:T { \legacy_if_gset_false:n { @newlist } } |
| 3903 |
% \end{macrocode} |
| 3904 |
% |
| 3905 |
% There is a possibility that the \texttt{@nobreak} switch is still |
| 3906 |
% true so we set it back just in case. |
| 3907 |
% \begin{macrocode} |
| 3908 |
\legacy_if_gset_false:n { @nobreak } |
| 3909 |
% \end{macrocode} |
| 3910 |
% What to do in terms of vertical spacing in different situations |
| 3911 |
% is still somewhat open to debate, right now this is more or less |
| 3912 |
% implementing what \LaTeXe{} list environments have been |
| 3913 |
% doing.\fmi{some redesign/extensions here?} |
| 3914 |
% \begin{macrocode} |
| 3915 |
% \@@_debug_typeout:n{@noparlist = |
| 3916 |
% \legacy_if:nTF { @noparlist }{true}{false}} |
| 3917 |
\legacy_if:nF { @noparlist } |
| 3918 |
{ |
| 3919 |
\@@_skip_set_to_last:N \l_tmpa_skip |
| 3920 |
\dim_compare:nNnT \l_tmpa_skip > \c_zero_dim |
| 3921 |
{ |
| 3922 |
\skip_vertical:n { - \l_tmpa_skip } |
| 3923 |
\skip_vertical:n { \l_tmpa_skip + \parskip - \@outerparskip } |
| 3924 |
} |
| 3925 |
\addpenalty \@endparpenalty |
| 3926 |
% \end{macrocode} |
| 3927 |
% |
| 3928 |
% \changes{v0.9o}{2026/02/15}{Support \texttt{end-vspace} and |
| 3929 |
% \texttt{end-extra-vspace} keys (tagging/738)} |
| 3930 |
% \begin{macrocode} |
| 3931 |
\addvspace \l_@@_effective_bot_skip |
| 3932 |
% \end{macrocode} |
| 3933 |
% \LaTeXe{} triggered the paragraph handling after a list at this |
| 3934 |
% point here, i.e., only if the list didn't start a paragraph. One |
| 3935 |
% can make a case for that, but it can be somewhat surprising to |
| 3936 |
% the user and there is a good argument that even such a list could |
| 3937 |
% be followed explanatory text that is part of the same paragraph |
| 3938 |
% and doesn't start a new one.\fmi{decide which logic we want to |
| 3939 |
% use! If the old logic is used we need to close the text-unit |
| 3940 |
% ourselves in the true branch} |
| 3941 |
% \begin{macrocode} |
| 3942 |
% \legacy_if_gset_true:n { @endpe } |
| 3943 |
} |
| 3944 |
% \end{macrocode} |
| 3945 |
% So this is for now always done. Probably \cs{l_@@_effective_top_skip} above |
| 3946 |
% should be added only if the paragraph ends here and not if it |
| 3947 |
% continues, so this need some further cleanup.\fmi{decide} |
| 3948 |
% |
| 3949 |
% Finally, we have a socket that handles the \tn{par} handling |
| 3950 |
% after the block. Normally, we use it with the \plug{on} plug (check for a |
| 3951 |
% following \tn{par}) but in the case of standalone environments we |
| 3952 |
% assign it the \plug{off} plug. |
| 3953 |
% |
| 3954 |
% \begin{macrocode} |
| 3955 |
\socket_use:n {block/endpe} |
| 3956 |
} |
| 3957 |
% \end{macrocode} |
| 3958 |
% |
| 3959 |
% \end{macro} |
| 3960 |
% |
| 3961 |
% |
| 3962 |
% \begin{macro}{\@@_if_list:T,\@@_if_list:TF} |
| 3963 |
% The following code may need some redesigning, as there is no good test for \enquote{is |
| 3964 |
% this environment a \enquote{list} that has \tn{item}s}. For now |
| 3965 |
% this here does the trick well enough as \tn{item}s are only |
| 3966 |
% supported if the \key{inner-instance-type} is \keyvalue{list}. |
| 3967 |
% \changes{v0.8q}{2024/09/03}{Provide a test for: Am I in a list?} |
| 3968 |
% \begin{macrocode} |
| 3969 |
\cs_new:Npn \@@_if_list:T |
| 3970 |
{ \tl_if_eq:NnT \l_@@_inner_instance_type_tl {list} } |
| 3971 |
\cs_new:Npn \@@_if_list:TF |
| 3972 |
{ \tl_if_eq:NnTF \l_@@_inner_instance_type_tl {list} } |
| 3973 |
% \end{macrocode} |
| 3974 |
% \end{macro} |
| 3975 |
% |
| 3976 |
% |
| 3977 |
% |
| 3978 |
% \begin{macro}{\__kernel_displayblock_end:} |
| 3979 |
% The kernel hook for tagging at the end of the block. |
| 3980 |
% \changes{v0.9s}{2026-04-18}{If inside a list execute the item/after hook.} |
| 3981 |
% Without tagging it executes the \texttt{item/after} hook if inside a list, |
| 3982 |
% with active tagging it is overwritten by other commands in the recipes. |
| 3983 |
% \begin{macrocode} |
| 3984 |
\cs_new_protected:Npn \__kernel_displayblock_end: { |
| 3985 |
\@@_if_list:T{\hook_use:n{item/after}} |
| 3986 |
\@@_debug_typeout:n{\detokenize{__kernel_displayblock_end:}} |
| 3987 |
} |
| 3988 |
% \end{macrocode} |
| 3989 |
% \end{macro} |
| 3990 |
% |
| 3991 |
% |
| 3992 |
% |
| 3993 |
% \begin{socketdecl}{block/endpe} |
| 3994 |
% This socket is responsible for the end environment \tn{par} |
| 3995 |
% handling. We define two plugs for it (\plug{on} and \plug{off}). |
| 3996 |
% \begin{macrocode} |
| 3997 |
\socket_new:nn {block/endpe} {0} |
| 3998 |
% \end{macrocode} |
| 3999 |
% \end{socketdecl} |
| 4000 |
% |
| 4001 |
% \begin{plugdecl}{on,off} |
| 4002 |
% The plugs set the legacy \texttt{@endpe} switch. This must always |
| 4003 |
% happen because block environments with different settings can be nested |
| 4004 |
% and should not inherit the setting from the outer environment. |
| 4005 |
% |
| 4006 |
% We can't use \cs{legacy_if_gset_true:n} because this is now doing |
| 4007 |
% more than setting the legacy switch: |
| 4008 |
% \begin{macrocode} |
| 4009 |
\socket_new_plug:nnn{block/endpe} {on} { \@endpetrue } |
| 4010 |
\socket_new_plug:nnn{block/endpe} {off} { \@endpefalse } |
| 4011 |
% \end{macrocode} |
| 4012 |
% |
| 4013 |
% \begin{macrocode} |
| 4014 |
\socket_assign_plug:nn{block/endpe}{on} |
| 4015 |
% \end{macrocode} |
| 4016 |
% \end{plugdecl} |
| 4017 |
% |
| 4018 |
% |
| 4019 |
% |
| 4020 |
% |
| 4021 |
% |
| 4022 |
% \subsubsection{Implementation of \insttype{para} templates} |
| 4023 |
% |
| 4024 |
% \begin{template}{para std} |
| 4025 |
% |
| 4026 |
% \begin{macrocode} |
| 4027 |
\DeclareTemplateCode{para}{std}{1} |
| 4028 |
{ |
| 4029 |
,para-indent = \parindent |
| 4030 |
% \end{macrocode} |
| 4031 |
% The next parameter needs integrating in the basic paragraph |
| 4032 |
% handling (not done yet) and it should therefore probably a public |
| 4033 |
% name like the rest.\fmi{integrate/fix} |
| 4034 |
% \begin{macrocode} |
| 4035 |
,begin-hspace = \l_para_begin_skip |
| 4036 |
,left-hspace = \leftskip |
| 4037 |
,right-hspace = \rightskip |
| 4038 |
,end-hspace = \parfillskip |
| 4039 |
% \end{macrocode} |
| 4040 |
% Next isn't yet implemented (and the variable name is wrong).\fmi{fix} |
| 4041 |
% \begin{macrocode} |
| 4042 |
,fixed-word-spaces = \l__par_fixed_word_spaces_bool % name?? |
| 4043 |
,final-hyphen-demerits = \finalhyphendemerits |
| 4044 |
,newline-cmd = \\ |
| 4045 |
,para-attr-class = \l__tag_para_attr_class_tl |
| 4046 |
} |
| 4047 |
{ |
| 4048 |
\template_debug_typeout:n{~\space template:~ 'std';~ |
| 4049 |
argument:~ \exp_not:n{|#1|}} |
| 4050 |
\SetTemplateKeys{para}{std}{#1} |
| 4051 |
% \end{macrocode} |
| 4052 |
% |
| 4053 |
% \begin{macrocode} |
| 4054 |
\skip_set:Nn \@rightskip \rightskip |
| 4055 |
} |
| 4056 |
% \end{macrocode} |
| 4057 |
% \end{template} |
| 4058 |
% |
| 4059 |
% |
| 4060 |
% \begin{macro}{\__para_handle_indent:} |
| 4061 |
% We insert \cs{l_para_begin_skip} directly in front of the |
| 4062 |
% indentation box. This way it is hidden from any special setting |
| 4063 |
% of \cs{everypar} (whether that is used to remove the |
| 4064 |
% indentation box or whether it attempts to do something with the |
| 4065 |
% first token(s) of the paragraph). However, we only insert it if |
| 4066 |
% it differs from 0.0pt to avoid adding |
| 4067 |
% \verb=\penalty 10000 \glue 0.0= all over the place. |
| 4068 |
% \begin{macrocode} |
| 4069 |
\tl_const:Ne \c__zero_skip_tl { \skip_use:N \z@skip } |
| 4070 |
\tl_new:N \l__para_begin_skip_tl |
| 4071 |
% \end{macrocode} |
| 4072 |
% |
| 4073 |
% \begin{macrocode} |
| 4074 |
\cs_set:Npn \__para_handle_indent: { |
| 4075 |
\tl_set:Ne \l__para_begin_skip_tl { \skip_use:N \l_para_begin_skip } |
| 4076 |
\if_meaning:w \l__para_begin_skip_tl |
| 4077 |
\c__zero_skip_tl |
| 4078 |
\else: |
| 4079 |
\nobreak |
| 4080 |
\tex_hskip:D \l_para_begin_skip |
| 4081 |
\fi: |
| 4082 |
\box_use_drop:N \g_para_indent_box |
| 4083 |
} |
| 4084 |
% \end{macrocode} |
| 4085 |
% \end{macro} |
| 4086 |
% |
| 4087 |
% |
| 4088 |
% \begin{macro}{\para_raw_noindent:} |
| 4089 |
% \cs{para_raw_noindent:} doesn't call \cs{__para_handle_indent:} |
| 4090 |
% so we have to manually do the \cs {l_para_begin_skip} handling. |
| 4091 |
% \begin{macrocode} |
| 4092 |
\cs_set:Npn \para_raw_noindent: { |
| 4093 |
\mode_if_vertical:TF |
| 4094 |
{ |
| 4095 |
\tex_everypar:D { |
| 4096 |
\tex_everypar:D { \g__para_standard_everypar_tl } |
| 4097 |
\tl_set:Ne \l__para_begin_skip_tl { \skip_use:N \l_para_begin_skip } |
| 4098 |
\if_meaning:w \l__para_begin_skip_tl |
| 4099 |
\c__zero_skip_tl |
| 4100 |
\else: |
| 4101 |
\nobreak |
| 4102 |
\tex_hskip:D \l_para_begin_skip |
| 4103 |
\fi: |
| 4104 |
\the\everypar } |
| 4105 |
} |
| 4106 |
{ \msg_error:nn { latex2e }{ raw-para } } |
| 4107 |
\tex_noindent:D |
| 4108 |
} |
| 4109 |
% \end{macrocode} |
| 4110 |
% \end{macro} |
| 4111 |
% |
| 4112 |
% |
| 4113 |
% \subsubsection{Implementation of \insttype{block} templates} |
| 4114 |
% |
| 4115 |
% |
| 4116 |
% \begin{template}{block std} |
| 4117 |
% ^^A |
| 4118 |
% In contrast to the \LaTeXe{} implementation we do not directly |
| 4119 |
% use \tn{listparindent} here but a private register of the |
| 4120 |
% template. The reason is that block template instances are also |
| 4121 |
% used outside of lists. |
| 4122 |
% \changes{v0.8s}{2024/10/03}{Offer item-vspace key also on block templates} |
| 4123 |
% \changes{v0.8w}{2024/11/23}{Use private storage bin for parindent |
| 4124 |
% and not \tn{listparindent} to decouple block and list templates (tagging/767)} |
| 4125 |
% \begin{macrocode} |
| 4126 |
\DeclareTemplateCode{block}{std}{1} |
| 4127 |
{ |
| 4128 |
,begin-vspace = \topsep |
| 4129 |
,begin-extra-vspace = \partopsep |
| 4130 |
,begin-unchained-vspace = \l_@@_unchained_skip |
| 4131 |
,para-vspace = \parsep |
| 4132 |
% \end{macrocode} |
| 4133 |
% The bottom skips aren't used yet, even if set instead as before |
| 4134 |
% \cs{topsep} is applied there.\fmi{fix} |
| 4135 |
% \begin{macrocode} |
| 4136 |
,end-vspace = \l_@@_botsep_skip |
| 4137 |
,end-extra-vspace = \l_@@_parbotsep_skip |
| 4138 |
,item-vspace = \itemsep |
| 4139 |
,begin-penalty = \@beginparpenalty |
| 4140 |
,end-penalty = \@endparpenalty |
| 4141 |
,item-penalty = \@itempenalty |
| 4142 |
,right-margin = \rightmargin |
| 4143 |
,left-margin = \leftmargin |
| 4144 |
,para-indent = \l_@@_parindent_dim |
| 4145 |
} |
| 4146 |
{ |
| 4147 |
\template_debug_typeout:n{~\space template:~ 'std';~ |
| 4148 |
argument:~ \exp_not:o{\exp_after:wN |#1|}} |
| 4149 |
\SetKnownTemplateKeys{block}{std}{#1} |
| 4150 |
% \end{macrocode} |
| 4151 |
% One aspect that needs a different handling is the management of |
| 4152 |
% \cs{par} after a block environment. If there is no empty line the |
| 4153 |
% following text is considered to be a continuation of the current |
| 4154 |
% paragraph. To manage this both \cs{par} and \cs{everypar} are |
| 4155 |
% redefined with the latter removing the paragraph indentation from |
| 4156 |
% the next paragraph. But if an empty line was seen after the block |
| 4157 |
% then the redefined \cs{par} would cancel the redefinition of |
| 4158 |
% \cs{everypar} so that the next paragraph again had its |
| 4159 |
% indentation. The other case in which the following indentation |
| 4160 |
% should not get suppressed is when two block environments directly |
| 4161 |
% follow each other. In the original \LaTeXe{} implementation that |
| 4162 |
% simply worked because the \cs{item} command canceled any |
| 4163 |
% \cs{everypar} and all block environments were implemented as |
| 4164 |
% \enquote{lists}, i.e., contained an \cs{item}, even if it was |
| 4165 |
% only there to get the vertical spacing right. With the new block |
| 4166 |
% implementation this is no longer the case, so we have handle the |
| 4167 |
% cancelation ourselves. |
| 4168 |
% |
| 4169 |
% We can't simply use \verb/\mode_if_vertical:T { \par }/ because |
| 4170 |
% that would also end the semantic paragraph. Instead we check is |
| 4171 |
% \texttt{@endpe} handling is requested and if so reset \cs{everypar}. |
| 4172 |
% \changes{v0.9p}{2026/03/29}{Cancel env par env handling on |
| 4173 |
% consecutive block envs (tagging/1279)} |
| 4174 |
% \begin{macrocode} |
| 4175 |
\legacy_if:nT { @endpe } { \everypar{} } |
| 4176 |
% \end{macrocode} |
| 4177 |
% |
| 4178 |
% The remaining code largely follows the logic of \LaTeXe{}'s \env{trivlist} |
| 4179 |
% implementation as far as it applicable for the \enquote{display |
| 4180 |
% block} but coded using the L3 programming layer. However, we keep |
| 4181 |
% most of the legacy variables (e.g., \texttt{@noskipsec}) if there is |
| 4182 |
% some chance that they are set/used in classes or packages. |
| 4183 |
% \begin{macrocode} |
| 4184 |
\legacy_if:nTF { @noskipsec } |
| 4185 |
% \end{macrocode} |
| 4186 |
% A \texttt{@noskipsec} heading is a heading that is placed in the |
| 4187 |
% same line as the following text (using \cs{everypar}) but not if |
| 4188 |
% that text starts with a display block, so we ensure that the |
| 4189 |
% heading gets typeset now.\fmi{This is similar to the standalone case |
| 4190 |
% for block captions so perhaps that can be combined, check} |
| 4191 |
% \begin{macrocode} |
| 4192 |
{ \mode_leave_vertical: } |
| 4193 |
% \end{macrocode} |
| 4194 |
% If no such heading is waiting we might have a block caption |
| 4195 |
% waiting to be typeset and this might be requested to be set |
| 4196 |
% \enquote{unchained}. In that case we also have to ensure |
| 4197 |
% that this gets typeset now. |
| 4198 |
% |
| 4199 |
% The situation is slightly different though, because we want to |
| 4200 |
% end in vertical mode in that case also add |
| 4201 |
% some special vertical space and have to properly deal with |
| 4202 |
% avoiding page breaks. |
| 4203 |
% \begin{macrocode} |
| 4204 |
{ |
| 4205 |
\bool_if:NT \g_@@_label_unchained_bool |
| 4206 |
{ |
| 4207 |
\@@_debug_typeout:n{Set~ captioned~ block~ everypar \on@line } |
| 4208 |
\cs_set_eq:NN \@@_everypar: \@@_captioned_everypar_std: |
| 4209 |
\legacy_if:nT { @inlabel } |
| 4210 |
{ |
| 4211 |
\hbox_unpack_drop:N \g_@@_labels_box |
| 4212 |
\legacy_if_gset_false:n { @inlabel } |
| 4213 |
\par |
| 4214 |
\nobreak |
| 4215 |
\skip_vertical:n { \l_@@_unchained_skip } |
| 4216 |
\legacy_if_gset_true:n { @nobreak } |
| 4217 |
} |
| 4218 |
} |
| 4219 |
} |
| 4220 |
% \end{macrocode} |
| 4221 |
% The variable \cs{l_@@_effective_top_skip} is used for the |
| 4222 |
% vertical skip at the start. It is initialized with |
| 4223 |
% \key{begin-vspace} and below we add \key{begin-extra-vspace} if |
| 4224 |
% the block starts in vmode. |
| 4225 |
% \begin{macrocode} |
| 4226 |
\skip_set:Nn \l_@@_effective_top_skip { \topsep } |
| 4227 |
% \end{macrocode} |
| 4228 |
% For the vertical space at the end we do something similar. |
| 4229 |
% \changes{v0.9o}{2026/02/15}{Support \texttt{end-vspace} and |
| 4230 |
% \texttt{end-extra-vspace} keys (tagging/738)} |
| 4231 |
% \begin{macrocode} |
| 4232 |
\skip_set:Nn \l_@@_effective_bot_skip { \l_@@_botsep_skip } |
| 4233 |
\mode_if_vertical:TF |
| 4234 |
{ |
| 4235 |
\skip_add:Nn \l_@@_effective_top_skip { \partopsep } |
| 4236 |
% \end{macrocode} |
| 4237 |
% |
| 4238 |
% \changes{v0.9o}{2026/02/15}{Support \texttt{end-vspace} and |
| 4239 |
% \texttt{end-extra-vspace} keys (tagging/738)} |
| 4240 |
% \begin{macrocode} |
| 4241 |
\skip_add:Nn \l_@@_effective_bot_skip { \l_@@_parbotsep_skip } |
| 4242 |
% \end{macrocode} |
| 4243 |
% At this point it is safe to add tagging structure(s) so we have |
| 4244 |
% a kernel-owned hook here for tagging. This is used to possibly |
| 4245 |
% start a paragraph structure (to surround the block, for example, |
| 4246 |
% in case of lists) and possibly do some other preparation for |
| 4247 |
% tagging the block. |
| 4248 |
% \begin{macrocode} |
| 4249 |
\__kernel_displayblock_beginpar_vmode: |
| 4250 |
} |
| 4251 |
{ |
| 4252 |
% \end{macrocode} |
| 4253 |
% If we are in horizontal mode then the displayblock has to return |
| 4254 |
% to vertical mode now (after removing any immediately preceding |
| 4255 |
% skip or kern. But before we actually issue the \tn{par} we execute |
| 4256 |
% a kernel hook in which we can add tagging code. This hook is |
| 4257 |
% \enquote{weird} because by default it does nothing, but if |
| 4258 |
% tagging is wanted it takes an argument and grabs the following |
| 4259 |
% \tn{par} in order to put tagging code before and after the \tn{par}. |
| 4260 |
% \begin{macrocode} |
| 4261 |
\@@_skip_remove_last: \@@_skip_remove_last: |
| 4262 |
\__kernel_displayblock_beginpar_hmode:w \par |
| 4263 |
} |
| 4264 |
% \end{macrocode} |
| 4265 |
% Next lines set some paragraph defaults, any of them may get overwritten |
| 4266 |
% if there is a \key{para-instance} specified on the \insttype{blockenv} |
| 4267 |
% instance. |
| 4268 |
% \begin{macrocode} |
| 4269 |
\skip_zero:N \leftskip |
| 4270 |
\skip_set_eq:NN \rightskip \@rightskip |
| 4271 |
\skip_set_eq:NN \parfillskip \@flushglue |
| 4272 |
% \end{macrocode} |
| 4273 |
% The next lines establish a parshape which is retained across |
| 4274 |
% paragraphs be executing \cs{para_end:} within a group and thus |
| 4275 |
% reestablishing the parshape for the next paragraph again. In case |
| 4276 |
% a list got started \tn{par} is ignored until we have seen an |
| 4277 |
% \tn{item} (or we have executed \tn{par} one thousand times. |
| 4278 |
% \begin{macrocode} |
| 4279 |
\int_zero:N \par@deathcycles |
| 4280 |
\@setpar |
| 4281 |
{ |
| 4282 |
\legacy_if:nTF { @newlist } |
| 4283 |
{ |
| 4284 |
\int_incr:N \par@deathcycles |
| 4285 |
\int_compare:nNnTF \par@deathcycles > { 1000 } |
| 4286 |
{ \@noitemerr |
| 4287 |
{ \para_end: } |
| 4288 |
} |
| 4289 |
} |
| 4290 |
{ |
| 4291 |
{ \para_end: } |
| 4292 |
} |
| 4293 |
} |
| 4294 |
% \end{macrocode} |
| 4295 |
% \changes{v0.8w}{2024/11/23}{Use private storage bin for parindent |
| 4296 |
% and not \tn{listparindent} to decouple block and list templates (tagging/767)} |
| 4297 |
% \begin{macrocode} |
| 4298 |
\dim_set_eq:NN \parindent \l_@@_parindent_dim |
| 4299 |
\dim_add:Nn \linewidth { - \rightmargin - \leftmargin } |
| 4300 |
\dim_add:Nn \@totalleftmargin { \leftmargin } |
| 4301 |
\tex_parshape:D 1 ~ \@totalleftmargin \linewidth |
| 4302 |
% \end{macrocode} |
| 4303 |
% This is the point where we are ready to add the tagging structure |
| 4304 |
% for the block, e.g., an \verb=<L>=, a \verb=<Figure>= or some |
| 4305 |
% other structure. |
| 4306 |
% \begin{macrocode} |
| 4307 |
\__kernel_displayblock_begin: |
| 4308 |
% \end{macrocode} |
| 4309 |
% Finally, we have to output the vertical separation and penalty at |
| 4310 |
% the start of the block and make corrections for a change in |
| 4311 |
% \tn{parskip} and some other housekeeping, unless this block is inside a list and the list |
| 4312 |
% \tn{item} has not yet placed. In that case the vertical |
| 4313 |
% space and penalty is suppressed. This |
| 4314 |
% is controlled through the legacy switches \texttt{@inlabel}, |
| 4315 |
% \texttt{minipage}, and \texttt{@nobreak}. |
| 4316 |
% |
| 4317 |
% Now we are back to legacy list implementation \ldots |
| 4318 |
% \begin{macrocode} |
| 4319 |
\skip_set_eq:NN \@outerparskip \parskip |
| 4320 |
\skip_set_eq:NN \parskip \parsep |
| 4321 |
% |
| 4322 |
\legacy_if:nTF { @inlabel } |
| 4323 |
{ |
| 4324 |
\legacy_if_set_true:n { @noparlist } |
| 4325 |
\hbox_gset:Nn \g_@@_labels_box |
| 4326 |
{ |
| 4327 |
\skip_horizontal:n { - \leftmargin } |
| 4328 |
\hbox_unpack_drop:N \g_@@_labels_box |
| 4329 |
\skip_horizontal:n { \leftmargin } |
| 4330 |
} |
| 4331 |
% \end{macrocode} |
| 4332 |
% \fmi{document 2e logic used here} |
| 4333 |
% \begin{macrocode} |
| 4334 |
\legacy_if:nF { @minipage } % Why this chunk of code? |
| 4335 |
{ |
| 4336 |
\@@_skip_set_to_last:N \l_@@_tmpa_skip |
| 4337 |
\skip_vertical:n { - \l_@@_tmpa_skip } |
| 4338 |
\skip_vertical:n { \l_@@_tmpa_skip + |
| 4339 |
\@outerparskip - \parsep } |
| 4340 |
} |
| 4341 |
} |
| 4342 |
{ |
| 4343 |
\legacy_if_set_false:n { @noparlist } |
| 4344 |
\legacy_if:nT { @newlist } { \@noitemerr } |
| 4345 |
\legacy_if:nTF { @nobreak } |
| 4346 |
{ |
| 4347 |
% \end{macrocode} |
| 4348 |
% We are not resetting \texttt{@nobreak} here as it should also |
| 4349 |
% apply to the upcoming item. |
| 4350 |
% \begin{macrocode} |
| 4351 |
\addpenalty{ 10000 } |
| 4352 |
\addvspace{ \skip_eval:n{\@outerparskip-\parsep} } |
| 4353 |
} |
| 4354 |
{ |
| 4355 |
\addpenalty \@beginparpenalty |
| 4356 |
\addvspace { \skip_eval:n { \l_@@_effective_top_skip + |
| 4357 |
\@outerparskip } } |
| 4358 |
\addvspace { - \parsep } |
| 4359 |
} |
| 4360 |
} |
| 4361 |
} |
| 4362 |
% \end{macrocode} |
| 4363 |
% \end{template} |
| 4364 |
% |
| 4365 |
% |
| 4366 |
% |
| 4367 |
% |
| 4368 |
% |
| 4369 |
% \begin{macro}{\@@_captioned_everypar_std:} |
| 4370 |
% The captioned text is typeset at the start of a paragraph using |
| 4371 |
% code triggered in \cs{everypar} (by setting \cs{@@_everypar} to |
| 4372 |
% this code here). |
| 4373 |
% \begin{macrocode} |
| 4374 |
\cs_new_protected:Npn \@@_captioned_everypar_std: { |
| 4375 |
\@@_debug_typeout:n{...~ in~ captioned~ block~ everypar \on@line } |
| 4376 |
% \end{macrocode} |
| 4377 |
% First set some control switches to false: |
| 4378 |
% \begin{macrocode} |
| 4379 |
\legacy_if_set_false:n { @minipage } |
| 4380 |
\legacy_if_gset_false:n { @newlist } |
| 4381 |
% \end{macrocode} |
| 4382 |
% The \texttt{@inlabel} is normally true at this point, but if we |
| 4383 |
% also have \texttt{@nobreak} then the same routine is called again |
| 4384 |
% at the next paragraph to reset \cs{clubpenalty} and at that point |
| 4385 |
% the \cs{g_@@_labels_box} has been typeset and \texttt{@inlabel} |
| 4386 |
% is false. |
| 4387 |
% \begin{macrocode} |
| 4388 |
\legacy_if:nT { @inlabel } |
| 4389 |
{ |
| 4390 |
% \end{macrocode} |
| 4391 |
% Typeset the saved label (aka captioned text): |
| 4392 |
% \begin{macrocode} |
| 4393 |
\legacy_if_gset_false:n { @inlabel } |
| 4394 |
\para_omit_indent: |
| 4395 |
\bool_if:NTF \l_@@_caption_unbreakable_bool |
| 4396 |
\box_use_drop:N |
| 4397 |
\hbox_unpack_drop:N |
| 4398 |
\g_@@_labels_box |
| 4399 |
\__kernel_list_label_after:n { \PARALABEL } % <- change |
| 4400 |
% this name |
| 4401 |
\penalty \c_zero_int |
| 4402 |
} |
| 4403 |
% \end{macrocode} |
| 4404 |
% If \texttt{@nobreak} is true we prevent a break after the first |
| 4405 |
% line by setting \cs{clubpenalty}. |
| 4406 |
% \begin{macrocode} |
| 4407 |
\legacy_if:nTF { @nobreak } |
| 4408 |
{ |
| 4409 |
\legacy_if_gset_false:n { @nobreak } |
| 4410 |
\int_set:Nn \clubpenalty { 10000 } |
| 4411 |
} |
| 4412 |
{ |
| 4413 |
% \end{macrocode} |
| 4414 |
% Otherwise we reset \cs{clubpenalty} and disable \cs{@@_everypar}. |
| 4415 |
% \begin{macrocode} |
| 4416 |
\int_set_eq:NN \clubpenalty \@clubpenalty |
| 4417 |
\@@_debug_typeout:n{Set~ noop~ block~ everypar \on@line } |
| 4418 |
\cs_set_eq:NN \@@_everypar: \prg_do_nothing: |
| 4419 |
} |
| 4420 |
} |
| 4421 |
% \end{macrocode} |
| 4422 |
% \end{macro} |
| 4423 |
% |
| 4424 |
% |
| 4425 |
% |
| 4426 |
% |
| 4427 |
% |
| 4428 |
% |
| 4429 |
% |
| 4430 |
% \begin{macro}{\__kernel_displayblock_begin:, |
| 4431 |
% \__kernel_displayblock_beginpar_hmode:w, |
| 4432 |
% \__kernel_displayblock_beginpar_vmode:} |
| 4433 |
% The internal kernel hooks for tagging. |
| 4434 |
% \begin{macrocode} |
| 4435 |
\cs_new_protected:Npn \__kernel_displayblock_begin: { |
| 4436 |
\@@_debug_typeout:n |
| 4437 |
{\detokenize{__kernel_displayblock_begin:}} |
| 4438 |
} |
| 4439 |
% \end{macrocode} |
| 4440 |
% |
| 4441 |
% \begin{macrocode} |
| 4442 |
\cs_new_protected:Npn \__kernel_displayblock_beginpar_hmode:w { |
| 4443 |
\@@_debug_typeout:n |
| 4444 |
{\detokenize{__kernel_displayblock_beginpar_hmode:w}} |
| 4445 |
} |
| 4446 |
% \end{macrocode} |
| 4447 |
% |
| 4448 |
% \begin{macrocode} |
| 4449 |
\cs_new_protected:Npn \__kernel_displayblock_beginpar_vmode: { |
| 4450 |
\@@_debug_typeout:n |
| 4451 |
{\detokenize{__kernel_displayblock_beginpar_vmode:}} |
| 4452 |
} |
| 4453 |
% \end{macrocode} |
| 4454 |
% \end{macro} |
| 4455 |
% |
| 4456 |
% |
| 4457 |
% |
| 4458 |
% |
| 4459 |
% \subsubsection{Implementation of \insttype{list} templates} |
| 4460 |
% |
| 4461 |
% This \insttype{list} is one of the template types that can be used |
| 4462 |
% as an \key{inner-type} in a \insttype{blockenv}; the other one |
| 4463 |
% currently implemented is \insttype{captionedtext}. |
| 4464 |
% |
| 4465 |
% \begin{macro}{\@itemlabel,\@listctr} |
| 4466 |
% Both \tn{@itemlabel} and \tn{@listctr} from the \LaTeXe{} list |
| 4467 |
% implementation are used (or set) by various packages. We |
| 4468 |
% therefore use them too, so that these packages have a fighting |
| 4469 |
% chance to work with the new tagging-aware implementation for |
| 4470 |
% \env{list}. |
| 4471 |
% \begin{macrocode} |
| 4472 |
\tl_new:N \@itemlabel % should have a top-level definition |
| 4473 |
\tl_new:N \@listctr % should have a top-level definition |
| 4474 |
% \end{macrocode} |
| 4475 |
% \end{macro} |
| 4476 |
% |
| 4477 |
% |
| 4478 |
% |
| 4479 |
% \begin{macro}{\@@_evaluate_saved_user_keys:nn} |
| 4480 |
% Keys set on individual list environments may be intended to alter |
| 4481 |
% the behavior of the template instance that defines the \tn{item} |
| 4482 |
% command. If meant to alter only a single \tn{item} command one |
| 4483 |
% would specify them in the optional argument of the \tn{item}, but |
| 4484 |
% if they should alter all items the right place would be the list |
| 4485 |
% environment. For this reason we need to store the values and then |
| 4486 |
% set them inside the \tn{item} template code using |
| 4487 |
% \tn{SetKnownTemplateKeys} in the appropriate context (template type |
| 4488 |
% and template name). This is done in |
| 4489 |
% \cs{@@_evaluate_saved_user_keys:nn}. The context is provided in |
| 4490 |
% the two arguments (because different list environments may use |
| 4491 |
% different \tn{item} instances based on different templates. By |
| 4492 |
% default the command does |
| 4493 |
% nothing because most environments do not have user key settings. |
| 4494 |
% \changes{v0.8s}{2024/10/03}{Pass user keys on list to \tn{item} for |
| 4495 |
% evaluation} |
| 4496 |
% \begin{macrocode} |
| 4497 |
\cs_new_eq:NN \@@_evaluate_saved_user_keys:nn \use_none:nn |
| 4498 |
% \end{macrocode} |
| 4499 |
% Maybe something like this should become a public function, but |
| 4500 |
% for now this is a one-off for the \tn{item} command and therefore |
| 4501 |
% coded inline and internal to the block code. |
| 4502 |
% \begin{macrocode} |
| 4503 |
%\cs_new:Npn \@@_save_user_keys:n #1 { |
| 4504 |
% \tl_if_empty:nTF {#1} |
| 4505 |
% { \cs_set_eq:NN \@@_evaluate_saved_user_keys:nn \use_none:nn } |
| 4506 |
% { \cs_set:Npe \@@_evaluate_saved_user_keys:nn ##1##2 |
| 4507 |
% { \SetKnownTemplateKeys{##1}{##2}{ \exp_not:n{#1} } } |
| 4508 |
%} |
| 4509 |
% \end{macrocode} |
| 4510 |
% \end{macro} |
| 4511 |
% |
| 4512 |
% |
| 4513 |
% \begin{template}{list std} |
| 4514 |
% |
| 4515 |
% This template implements numbered and unnumbered lists and can |
| 4516 |
% be combined with display blocks or with inline blocks. |
| 4517 |
% \begin{macrocode} |
| 4518 |
\DeclareTemplateCode{list}{std}{4} |
| 4519 |
{ |
| 4520 |
,counter = \l_@@_counter_tl |
| 4521 |
,item-label = \l_@@_item_label_tl |
| 4522 |
,start = \l_@@_counter_start_int |
| 4523 |
,resume = \l_@@_resume_bool |
| 4524 |
,item-instance = \@@_item_instance:n |
| 4525 |
,item-vspace = \itemsep |
| 4526 |
% ,item-para-vspace = \parsep |
| 4527 |
,item-penalty = \@itempenalty |
| 4528 |
,item-indent = \itemindent |
| 4529 |
,label-width = \labelwidth |
| 4530 |
,label-sep = \labelsep |
| 4531 |
,legacy-support = \l_@@_legacy_support_bool % FMi questionable |
| 4532 |
} |
| 4533 |
{ |
| 4534 |
\template_debug_typeout:n{~\space template:~ 'std';~ |
| 4535 |
arguments:~ \exp_not:o{\exp_after:wN |#1|#2|#3|#4|}} |
| 4536 |
% \end{macrocode} |
| 4537 |
% We start by looking at the user supplied keys in \texttt{\#1}. If |
| 4538 |
% there aren't any we reset \cs{@@_evaluate_saved_user_keys:nn} to |
| 4539 |
% do nothing. Otherwise we evaluate and set the keys in the context |
| 4540 |
% of the current list template. In addition we prepare |
| 4541 |
% \cs{@@_evaluate_saved_user_keys:nn} for execution in the |
| 4542 |
% template for \tn{item}. |
| 4543 |
% \changes{v0.8s}{2024/10/03}{Prepare \cs{@@_evaluate_saved_user_keys:nn} |
| 4544 |
% for use in \tn{item}} |
| 4545 |
% \begin{macrocode} |
| 4546 |
\tl_if_empty:oTF {#1} |
| 4547 |
{ \cs_set_eq:NN \@@_evaluate_saved_user_keys:nn \use_none:nn } |
| 4548 |
{ |
| 4549 |
\SetKnownTemplateKeys{list}{std}{#1} |
| 4550 |
% \end{macrocode} |
| 4551 |
% The setup for \cs{@@_evaluate_saved_user_keys:nn} is a bit tricky |
| 4552 |
% and has to be done with \cs{cs_set:Npe} even though we don't want |
| 4553 |
% to expand anything and therefore use \cs{exp_not:n} inside. All |
| 4554 |
% this does is that any \texttt{\#} passed in via \texttt{\#1} is |
| 4555 |
% doubled (e.g., from \verb/label-format=\fbox{#1}/ which is |
| 4556 |
% represented as \verb/...\fbox{##1}/). Otherwise, we would end up |
| 4557 |
% with a replacement text like |
| 4558 |
%\begin{verbatim} |
| 4559 |
% \SetTemplateKeys {#1}{#2}{label-format=\fbox {#1}} |
| 4560 |
%\end{verbatim} |
| 4561 |
% instead of |
| 4562 |
%\begin{verbatim} |
| 4563 |
% \SetTemplateKeys {#1}{#2}{label-format=\fbox {##1}} |
| 4564 |
%\end{verbatim} |
| 4565 |
% resulting in very odd and puzzling behavior later on. |
| 4566 |
% |
| 4567 |
% The definition of \cs{@@_evaluate_saved_user_keys:nn} made here |
| 4568 |
% is later used when an \cs{item} is processed and passes |
| 4569 |
% remaining keys to the item instance. After that nothing should |
| 4570 |
% remain, so we test that and issue an error if not. |
| 4571 |
% \begin{macrocode} |
| 4572 |
\cs_set:Npe \@@_evaluate_saved_user_keys:nn ##1##2 |
| 4573 |
{ \SetKnownTemplateKeys{##1}{##2}{ |
| 4574 |
\exp_not:o { \UnusedTemplateKeys } |
| 4575 |
} |
| 4576 |
\exp_not:n { |
| 4577 |
\tl_if_empty:NF \UnusedTemplateKeys |
| 4578 |
{ |
| 4579 |
\msg_error:nnee { block } { unknown-keys } |
| 4580 |
{ \l_@@_env_name_tl \space environment} |
| 4581 |
\UnusedTemplateKeys |
| 4582 |
} |
| 4583 |
} |
| 4584 |
} |
| 4585 |
} |
| 4586 |
% \end{macrocode} |
| 4587 |
% Has this list a counter name defined in the instance? |
| 4588 |
% \begin{macrocode} |
| 4589 |
\tl_if_empty:NTF \l_@@_counter_tl |
| 4590 |
{ |
| 4591 |
% \end{macrocode} |
| 4592 |
% If no counter name has been specified as part of the instance |
| 4593 |
% setup the list might still be numbered if it is a legacy list |
| 4594 |
% that uses \cs{usecounter} in the second argument of the legacy |
| 4595 |
% \env{list} environment. However, in that case we don't have to do |
| 4596 |
% much because \cs{usecounter} sets up \cs{@listctr} and sets |
| 4597 |
% it to zero so that the first item is numbered 1. |
| 4598 |
% |
| 4599 |
% So all we do is to check if there was a \key{start} value given |
| 4600 |
% that differs from 1 and if so we change the counter value to |
| 4601 |
% match that. This makes it possible to define a legacy \env{list} |
| 4602 |
% in which the counter doesn't start with 1 by explicitly setting |
| 4603 |
% the counter value in the second argument of the \env{list} |
| 4604 |
% environment but also overwriting that through a \key{start} key |
| 4605 |
% setting on invocation. |
| 4606 |
% \changes{v0.8v}{2024/10/11}{Correct logic for setting up the list |
| 4607 |
% counter (tagging/730)} |
| 4608 |
% \changes{v0.9f}{2025/06/21}{Correct logic for setting up the list |
| 4609 |
% counter further (tagging/893)} |
| 4610 |
% \begin{macrocode} |
| 4611 |
\int_compare:nNnF \l_@@_counter_start_int = 1 |
| 4612 |
{ |
| 4613 |
\int_gset:cn{ c@ \@listctr } |
| 4614 |
{ \l_@@_counter_start_int - 1 } |
| 4615 |
} |
| 4616 |
} |
| 4617 |
% \end{macrocode} |
| 4618 |
% In that case we only check if we should resume a previous list |
| 4619 |
% (\tn{@listctr} should be set in that case through the legacy |
| 4620 |
% method as well so we should be able to use it). |
| 4621 |
% \begin{macrocode} |
| 4622 |
% \end{macrocode} |
| 4623 |
% If a counter is set in the list instance we use that |
| 4624 |
% one. This should be the name of a \LaTeX{} counter that is |
| 4625 |
% already allocated externally---no runtime check is made for this: |
| 4626 |
% if it is not declared one will get \enquote{no such counter} |
| 4627 |
% error when the list is used. |
| 4628 |
% \begin{macrocode} |
| 4629 |
{ |
| 4630 |
\@nmbrlisttrue |
| 4631 |
\tl_set_eq:NN \@listctr \l_@@_counter_tl |
| 4632 |
\bool_if:NF \l_@@_resume_bool |
| 4633 |
{ |
| 4634 |
\int_gset:cn{ c@ \@listctr } |
| 4635 |
{ \l_@@_counter_start_int - 1 } |
| 4636 |
} |
| 4637 |
} |
| 4638 |
% \end{macrocode} |
| 4639 |
% Does the current instance have an item label representation? This |
| 4640 |
% would be possible whether or not we have a numbered list. If yes, |
| 4641 |
% then we use this for \tn{@itemlabel}, otherwise we expect that |
| 4642 |
% \tn{@itemlabel} is provided from the outside, e.g., as part of |
| 4643 |
% the \env{list} environment argument. |
| 4644 |
% \begin{macrocode} |
| 4645 |
\tl_if_empty:NF \l_@@_item_label_tl |
| 4646 |
{ |
| 4647 |
\tl_set_eq:NN \@itemlabel \l_@@_item_label_tl |
| 4648 |
} |
| 4649 |
% \end{macrocode} |
| 4650 |
% Finally, we signal that we are at the start of a new list (which |
| 4651 |
% affects how the first \tn{item} is handled and how \tn{par} |
| 4652 |
% commands are interpreted. |
| 4653 |
% \begin{macrocode} |
| 4654 |
\legacy_if_gset_true:n { @newlist } |
| 4655 |
% \end{macrocode} |
| 4656 |
% If we encounter horizontal material before the first \tn{item} we |
| 4657 |
% do want a \tn{@noitemerr} straight away, because afterwards we |
| 4658 |
% end up with tagging structure faults whose cause is the |
| 4659 |
% missing \tn{item}. So we set up \cs{@@_everypar:} to test |
| 4660 |
% for this; when the first \tn{item} is encountered this will get |
| 4661 |
% reset. This is only relevant for vertical lists, when dealing with |
| 4662 |
% inline lists one would need to test for something else to |
| 4663 |
% identify that there is horizontal material between the start of the list and |
| 4664 |
% the first \tn{item} (maybe some \tn{spacefactor} trick could be |
| 4665 |
% used then, or the material is boxed first and the width is |
| 4666 |
% inspected as suggested by Joseph).\fmi{Think about a better |
| 4667 |
% implementation at some point.} |
| 4668 |
% \changes{v0.8q}{2024/09/02}{} |
| 4669 |
% \begin{macrocode} |
| 4670 |
\@@_debug_typeout:n{Set~ first~ block~ everypar \on@line } |
| 4671 |
\cs_set_eq:NN \@@_everypar: \@@_item_everypar_first: |
| 4672 |
% \end{macrocode} |
| 4673 |
% |
| 4674 |
% \begin{macrocode} |
| 4675 |
\@@_debug_typeout:n{template:list:std~end} |
| 4676 |
} |
| 4677 |
% \end{macrocode} |
| 4678 |
% |
| 4679 |
% The message that is used above when we are left with keys that |
| 4680 |
% are unknown: |
| 4681 |
% \begin{macrocode} |
| 4682 |
\msg_new:nnnn { block } { unknown-keys } |
| 4683 |
{ Some~ keys~ specified~ on~ the~ #1~ are~ unknown. } |
| 4684 |
{ |
| 4685 |
The~ following~ keys~ are~ unknown~ and~ their~ |
| 4686 |
values~ are~ ignored:\\ |
| 4687 |
\space\space #2\\ |
| 4688 |
Perhaps~ a~ misspelling~ or~ the~ current~ template~ |
| 4689 |
instance~ uses~ special~ keys. |
| 4690 |
} |
| 4691 |
% \end{macrocode} |
| 4692 |
% \end{template} |
| 4693 |
% |
| 4694 |
% |
| 4695 |
% \subsubsection{Implementation of \insttype{item} templates} |
| 4696 |
% |
| 4697 |
% |
| 4698 |
% |
| 4699 |
% \begin{template}{item std} |
| 4700 |
% The item template has one hidden key \key{label} which is not available on the |
| 4701 |
% template for setting because it is only used to receive any |
| 4702 |
% optional data passed to the \tn{item} command. We therefore |
| 4703 |
% declare it with \cs{keys_define:nn} and ensure that the optional |
| 4704 |
% argument data to \tn{item} (if it is not a key/value list |
| 4705 |
% already) is passed to this \key{label} key. |
| 4706 |
% \begin{macrocode} |
| 4707 |
\keys_define:nn { template/item/std } |
| 4708 |
{ label .tl_set:N = \l_@@_label_given_tl } |
| 4709 |
% \end{macrocode} |
| 4710 |
% |
| 4711 |
% \fmi{alignment is mostly wrong (test short medium and multiline |
| 4712 |
% labels)} |
| 4713 |
% \begin{macrocode} |
| 4714 |
\DeclareTemplateCode{item}{std}{1} |
| 4715 |
{ |
| 4716 |
,counter-label = \@@_counter_label:n |
| 4717 |
,counter-ref = \@@_counter_ref:n |
| 4718 |
% \end{macrocode} |
| 4719 |
% \fmi{next set of key not yet used} |
| 4720 |
% \begin{macrocode} |
| 4721 |
,label-ref = \@@_label_ref:n |
| 4722 |
,label-autoref = \@@_label_autoref:n |
| 4723 |
,label-format = \@@_label_format:n |
| 4724 |
,label-strut = \l_@@_label_strut_bool |
| 4725 |
,label-boxed = \l_@@_label_boxed_bool |
| 4726 |
,next-line = \l_@@_next_line_bool |
| 4727 |
,text-font = \l_@@_text_font_tl |
| 4728 |
,compatibility = \l_@@_item_compatibility_bool |
| 4729 |
% \end{macrocode} |
| 4730 |
% This probably needs a different implementation (and needs completing)\fmi{complete} |
| 4731 |
% \begin{macrocode} |
| 4732 |
,label-align = { |
| 4733 |
left = \tl_set:Nn \l_@@_item_align_tl { \relax \hss } , |
| 4734 |
center = \tl_set:Nn \l_@@_item_align_tl { \hss \hss } , |
| 4735 |
right = \tl_set:Nn \l_@@_item_align_tl { \hss \relax } , |
| 4736 |
parleft = \NOT_IMPLEMENTED , |
| 4737 |
} |
| 4738 |
% \end{macrocode} |
| 4739 |
% The key{label-placement} is implemented using two booleans (at |
| 4740 |
% the moment). |
| 4741 |
% \begin{macrocode} |
| 4742 |
,label-placement = { |
| 4743 |
chained = \bool_gset_false:N \g_@@_label_standalone_bool |
| 4744 |
\bool_gset_false:N \g_@@_label_unchained_bool , |
| 4745 |
unchained = \bool_gset_false:N \g_@@_label_standalone_bool |
| 4746 |
\bool_gset_true:N \g_@@_label_unchained_bool , |
| 4747 |
standalone = \bool_gset_true:N \g_@@_label_standalone_bool |
| 4748 |
\bool_gset_false:N \g_@@_label_unchained_bool , |
| 4749 |
} |
| 4750 |
} |
| 4751 |
% \end{macrocode} |
| 4752 |
% Then typeset the label at its natural width by applying |
| 4753 |
% \cs{@@_make_label_box:n} to the label given or to a label constructed |
| 4754 |
% from the counter. If it is boxed and reasonably short, add padding to |
| 4755 |
% make it at least of size \tn{labelwidth}, then add another layer of |
| 4756 |
% box. This way, when we unpack it in \cs{g_@@_labels_box} it correctly |
| 4757 |
% remains boxed in those cases. Afterwards, in the \keyvalue{nextline} |
| 4758 |
% case add \tn{newline} if the label did not fit in the allotted space. |
| 4759 |
% \begin{macrocode} |
| 4760 |
{ |
| 4761 |
\template_debug_typeout:n{~\space template:~ 'std';~ |
| 4762 |
argument:~ \exp_not:n{|#1|}} |
| 4763 |
% \end{macrocode} |
| 4764 |
% |
| 4765 |
% First deal with the key--value input, which in particular may |
| 4766 |
% provide a value for the label (the usual optional argument of |
| 4767 |
% \tn{item}). For this we set \cs{l_@@_label_given_tl} to |
| 4768 |
% \cs{c_novalue_tl} so that we can identify if an optional argument |
| 4769 |
% was given. |
| 4770 |
% \begin{macrocode} |
| 4771 |
\tl_set_eq:NN \l_@@_label_given_tl \c_novalue_tl |
| 4772 |
% \end{macrocode} |
| 4773 |
% First we evaluate and set any keys specified on the list |
| 4774 |
% environment by calling |
| 4775 |
% \cs{@@_evaluate_saved_user_keys:nn}. This generates an error if |
| 4776 |
% not all key can be used, but it should really do so only on the |
| 4777 |
% first item. |
| 4778 |
% TODO: improve error handling! |
| 4779 |
% |
| 4780 |
% Then we do the same |
| 4781 |
% with all keys specified on this \tn{item} command (which may |
| 4782 |
% overwrite one or the other setting just made). |
| 4783 |
% \changes{v0.8s}{2024/10/03}{Use \cs{@@_evaluate_saved_user_keys:nn} |
| 4784 |
% to make use of user keys on the list level} |
| 4785 |
% \begin{macrocode} |
| 4786 |
\@@_evaluate_saved_user_keys:nn {item}{std} |
| 4787 |
% \end{macrocode} |
| 4788 |
% We don't care whether all of the user keys from the list level have |
| 4789 |
% been applied, but those explicitly set on the \cs{item} command |
| 4790 |
% should be applicable, so we generate an error if that isn't the case: |
| 4791 |
% \begin{macrocode} |
| 4792 |
\SetKnownTemplateKeys{item}{std}{#1} |
| 4793 |
\tl_if_empty:NF \UnusedTemplateKeys |
| 4794 |
{ |
| 4795 |
\msg_error:nnee { block } { unknown-keys } |
| 4796 |
{ \noexpand\item command } |
| 4797 |
\UnusedTemplateKeys |
| 4798 |
} |
| 4799 |
% \end{macrocode} |
| 4800 |
% |
| 4801 |
% If no optional argument was given then \cs{l_@@_label_given_tl} |
| 4802 |
% is still equal to \cs{c_novalue_tl} and so we can distinguish |
| 4803 |
% that from \verb=\item[]=. |
| 4804 |
% |
| 4805 |
% \fmi{next line needs checking after novalue implementation was changed} |
| 4806 |
% \begin{macrocode} |
| 4807 |
\tl_if_novalue:oTF \l_@@_label_given_tl |
| 4808 |
{ |
| 4809 |
% \end{macrocode} |
| 4810 |
% The rest of the code for this template needs work and is both |
| 4811 |
% incomplete and partly wrong.\fmi{fix} |
| 4812 |
% \begin{macrocode} |
| 4813 |
\tl_if_blank:oF \@listctr { \@kernel@refstepcounter \@listctr } |
| 4814 |
\bool_if:NTF \l_@@_item_compatibility_bool % not sure that |
| 4815 |
% conditional |
| 4816 |
% makes sense |
| 4817 |
{ \@@_make_label_box:n { \MakeLinkTarget[\@listctr]{}% |
| 4818 |
\@itemlabel } } % TODO ? |
| 4819 |
{ \@@_make_label_box:n { \MakeLinkTarget[\@listctr]{}% |
| 4820 |
\@@_counter_label:n { \@listctr } } } |
| 4821 |
} |
| 4822 |
% \end{macrocode} |
| 4823 |
% \changes{v0.9c}{2025/05/17}{Add \cs{MakeLinkTarget}, tagging issue \#840} |
| 4824 |
% \begin{macrocode} |
| 4825 |
{ |
| 4826 |
\@@_debug_typeout:n{item~ with~ optional} |
| 4827 |
\@@_make_label_box:n { |
| 4828 |
\MakeLinkTarget [\l_@@_env_name_tl]{} |
| 4829 |
\l_@@_label_given_tl |
| 4830 |
} |
| 4831 |
} |
| 4832 |
\bool_if:nT |
| 4833 |
{ |
| 4834 |
\l_@@_label_boxed_bool |
| 4835 |
% TODO: is \linewidth correct? |
| 4836 |
&& \dim_compare_p:n |
| 4837 |
{ \box_wd:N \l_@@_one_label_box <= \linewidth } |
| 4838 |
} |
| 4839 |
{ |
| 4840 |
\dim_compare:nNnT |
| 4841 |
{ \box_wd:N \l_@@_one_label_box } < \labelwidth |
| 4842 |
{ |
| 4843 |
\hbox_set_to_wd:Nnn \l_@@_one_label_box { \labelwidth } |
| 4844 |
{ |
| 4845 |
\exp_after:wN \use_i:nn \l_@@_item_align_tl |
| 4846 |
% \end{macrocode} |
| 4847 |
% FMi: \LaTeXe{} keeps the label boxed inside (not unboxed). This |
| 4848 |
% means that the content stays rigid and does not vary based on |
| 4849 |
% glue setting in the line with the label. |
| 4850 |
% There are cases where we do want the unboxed version (I think |
| 4851 |
% enumitem offers that in some cases too) but it should probably |
| 4852 |
% not the default. |
| 4853 |
% \begin{macrocode} |
| 4854 |
% TODO: customize? |
| 4855 |
% \hbox_unpack_drop:N \l_@@_one_label_box |
| 4856 |
\box_use_drop:N \l_@@_one_label_box |
| 4857 |
% \end{macrocode} |
| 4858 |
% |
| 4859 |
% \begin{macrocode} |
| 4860 |
\exp_after:wN \use_ii:nn \l_@@_item_align_tl |
| 4861 |
} |
| 4862 |
} |
| 4863 |
% \end{macrocode} |
| 4864 |
% Add another box level to the label box: |
| 4865 |
% \begin{macrocode} |
| 4866 |
\hbox_set:Nn \l_@@_one_label_box |
| 4867 |
{ \box_use_drop:N \l_@@_one_label_box } |
| 4868 |
} |
| 4869 |
\dim_compare:nNnTF { \box_wd:N \l_@@_one_label_box } > \labelwidth |
| 4870 |
{ \bool_set_true:N \l_@@_long_label_bool } |
| 4871 |
{ \bool_set_false:N \l_@@_long_label_bool } |
| 4872 |
\hbox_gset:Nn \g_@@_labels_box |
| 4873 |
{ |
| 4874 |
\hbox_unpack_drop:N \g_@@_labels_box |
| 4875 |
\skip_horizontal:n { \itemindent - \labelsep - \labelwidth } |
| 4876 |
\hbox_unpack_drop:N \l_@@_one_label_box |
| 4877 |
\skip_horizontal:n { \labelsep } |
| 4878 |
\bool_if:NT \l_@@_next_line_bool |
| 4879 |
{ \bool_if:NT \l_@@_long_label_bool { \nobreak \hfil \break } } |
| 4880 |
% version of \newline inside an hbox that will be unpacked |
| 4881 |
} |
| 4882 |
% TODO??? FMi what's that? |
| 4883 |
% \skip_set_eq:NN \parsep \l_@@_item_parsep_skip |
| 4884 |
% \end{macrocode} |
| 4885 |
% The next setting is for compatibility: The list template sets |
| 4886 |
% \tn{listparindent} to zero and otherwise doesn't use it any |
| 4887 |
% more. However, in the second argument of a legacy \env{list} |
| 4888 |
% environment the user may have set it explicitly to some other |
| 4889 |
% value and whatever value it had was then used for \tn{parindent} |
| 4890 |
% within the list. Now we use its value only if it differs from |
| 4891 |
% zero but otherwise use whatever the template instances |
| 4892 |
% specify. This gives 99.9\% compatibility for legacy |
| 4893 |
% documents. 100\% for definitions using the \env{list} environment |
| 4894 |
% and a setting inside, but if the user used \tn{listparindent} |
| 4895 |
% within the document, e.g., inside a \env{verse} environment there |
| 4896 |
% there is one case in which the setting is ignored, i.e., when it |
| 4897 |
% was set back to zero. That's a rather unlikely scenario, but it |
| 4898 |
% is not impossible. However, I couldn't think of an approach that |
| 4899 |
% circumvents such boundary cases. |
| 4900 |
% |
| 4901 |
% \changes{v0.8w}{2024/11/24}{Only use \tn{listparindent} if it was changed |
| 4902 |
% from its default (tagging/767)} |
| 4903 |
% \begin{macrocode} |
| 4904 |
\dim_compare:nNnF \listparindent = {0pt} |
| 4905 |
{ \dim_set_eq:NN \parindent \listparindent } |
| 4906 |
% \end{macrocode} |
| 4907 |
% Placing the list label(s) is done when the paragraph for the |
| 4908 |
% \tn{item} is started, which executes \cs{@@_everypar:} |
| 4909 |
% inside \hook{para/begin}. By default this command does nothing, now we |
| 4910 |
% change it to attach the pending label or labels. |
| 4911 |
% \begin{macrocode} |
| 4912 |
\@@_debug_typeout:n{Set~ item~ block~ everypar \on@line } |
| 4913 |
\cs_set_eq:NN \@@_everypar: \@@_item_everypar_std: |
| 4914 |
} |
| 4915 |
% \end{macrocode} |
| 4916 |
% \end{template} |
| 4917 |
% |
| 4918 |
% |
| 4919 |
% \begin{macro}{g_@@_label_standalone_bool,g_@@_label_unchained_bool} |
| 4920 |
% The two booleans for implementing \key{label-placement} and below |
| 4921 |
% \key{caption-placement}. |
| 4922 |
% \begin{macrocode} |
| 4923 |
\bool_new:N \g_@@_label_standalone_bool % tmp until replaced |
| 4924 |
\bool_new:N \g_@@_label_unchained_bool % tmp until replaced |
| 4925 |
% \end{macrocode} |
| 4926 |
% \end{macro} |
| 4927 |
% |
| 4928 |
% \begin{macro}{\l_@@_item_align_tl} |
| 4929 |
% |
| 4930 |
% \begin{macrocode} |
| 4931 |
\tl_new:N \l_@@_item_align_tl |
| 4932 |
% \end{macrocode} |
| 4933 |
% \end{macro} |
| 4934 |
% |
| 4935 |
% \begin{variable}{\l_@@_one_label_box, \g_@@_labels_box} |
| 4936 |
% Each label is typeset in \cs{l_@@_one_label_box} to be measured. |
| 4937 |
% Once this is ready, it is put (boxed or unboxed) in |
| 4938 |
% \cs{g_@@_labels_box}, together with any pending labels (for the case |
| 4939 |
% where a list begins just after \tn{item}). This is an analogue of |
| 4940 |
% \LaTeXe{}'s \tn{@labels}, but it is always unboxed before use, to |
| 4941 |
% support both boxed and unboxed labels. |
| 4942 |
% \begin{macrocode} |
| 4943 |
\box_new:N \l_@@_one_label_box |
| 4944 |
\box_new:N \g_@@_labels_box |
| 4945 |
% \end{macrocode} |
| 4946 |
% \end{variable} |
| 4947 |
% |
| 4948 |
% \begin{variable}{\l_@@_long_label_bool} |
| 4949 |
% Track whether the \cs{l_@@_one_label_box} is larger than |
| 4950 |
% \tn{labelwidth}. |
| 4951 |
% \begin{macrocode} |
| 4952 |
\bool_new:N \l_@@_long_label_bool |
| 4953 |
% \end{macrocode} |
| 4954 |
% \end{variable} |
| 4955 |
% |
| 4956 |
% \begin{macro}{\@@_make_label_box:n, \@@_label_format:e} |
| 4957 |
% Make one label, wrapped in \cs{@@_label_format:n}, with an |
| 4958 |
% appropriate \tn{strut} and possibly \tn{makelabel} in compatibility |
| 4959 |
% mode (used for the \env{list} environment). |
| 4960 |
% \begin{macrocode} |
| 4961 |
\cs_new_protected:Npn \@@_make_label_box:n #1 |
| 4962 |
{ |
| 4963 |
\hbox_set:Nn \l_@@_one_label_box |
| 4964 |
{ |
| 4965 |
% \end{macrocode} |
| 4966 |
% If we do tagging then the contents of this box may need to be |
| 4967 |
% wrapped into a structure, e.g., \verb=<Lbl>=. |
| 4968 |
% \begin{macrocode} |
| 4969 |
\tag_socket_use:nnn {block/list/label}{} |
| 4970 |
{ |
| 4971 |
% \end{macrocode} |
| 4972 |
% |
| 4973 |
% \begin{macrocode} |
| 4974 |
\@@_label_format:n |
| 4975 |
{ |
| 4976 |
\bool_if:NT \l_@@_label_strut_bool { \strut } |
| 4977 |
\bool_if:NTF \l_@@_legacy_support_bool |
| 4978 |
\makelabel |
| 4979 |
\use:n |
| 4980 |
{#1} |
| 4981 |
} |
| 4982 |
% \end{macrocode} |
| 4983 |
% And what gets opened also needs closing: |
| 4984 |
% \begin{macrocode} |
| 4985 |
} |
| 4986 |
} |
| 4987 |
} |
| 4988 |
% \end{macrocode} |
| 4989 |
% \end{macro} |
| 4990 |
% |
| 4991 |
% \begin{socketdecl}{block/list/label} |
| 4992 |
% A tagging socket to tag the label. It takes two arguments so that it can transparently |
| 4993 |
% pass the label content.\fmi{I think this socket should just be |
| 4994 |
% called list/label} |
| 4995 |
% \changes{v0.9k}{2025/07/21}{Removed fallback declaration here} |
| 4996 |
% Declaration is in \file{lttagging.dtx}. |
| 4997 |
% \end{socketdecl} |
| 4998 |
% \begin{plugdecl}{default} |
| 4999 |
% \begin{macrocode} |
| 5000 |
\NewTaggingSocketPlug{block/list/label}{default} |
| 5001 |
{ |
| 5002 |
% |
| 5003 |
% FMi: this needs a different logic to decide when to make the label |
| 5004 |
% an artifact (after cleaning up the \item code ), therefore |
| 5005 |
% disabled for now |
| 5006 |
% \tl_if_empty:oTF \@itemlabel |
| 5007 |
% { |
| 5008 |
% \tag_mc_begin:n {artifact} |
| 5009 |
% } |
| 5010 |
% { |
| 5011 |
\tagstructbegin{tag=\UseStructureName{block/list/label}} |
| 5012 |
\tagmcbegin{tag=\UseStructureName{block/list/label}} |
| 5013 |
% } |
| 5014 |
#2 |
| 5015 |
\tagmcend % end mc-\UseStructureName{block/list/label} or artifact |
| 5016 |
% FMi: unconditionally for now |
| 5017 |
% \tl_if_empty:oF \@itemlabel |
| 5018 |
\tagstructend % end label |
| 5019 |
\tagstructbegin{tag=\UseStructureName{block/list/body}} |
| 5020 |
} |
| 5021 |
\AssignTaggingSocketPlug{block/list/label}{default} |
| 5022 |
% \end{macrocode} |
| 5023 |
% \end{plugdecl} |
| 5024 |
% |
| 5025 |
% |
| 5026 |
% |
| 5027 |
% \begin{macro}{\@@_everypar:, \@@_item_everypar_std:, \@@_item_everypar_first:} |
| 5028 |
% The \cs{@@_everypar:} command is executed as part of \hook{para/begin} |
| 5029 |
% but most of the time does nothing, i.e., it has the following |
| 5030 |
% default definition outside of lists (and most of the time within lists). |
| 5031 |
% \begin{macrocode} |
| 5032 |
\cs_new_eq:NN \@@_everypar: \prg_do_nothing: |
| 5033 |
% \end{macrocode} |
| 5034 |
% |
| 5035 |
% \begin{macrocode} |
| 5036 |
\AddToHook{para/begin}[items]{\@@_everypar:} |
| 5037 |
% \end{macrocode} |
| 5038 |
% |
| 5039 |
% Note that we have to make sure that the above code is executed |
| 5040 |
% after the hook chunk from \pkg{tagpdf} because the latter uses |
| 5041 |
% \texttt{@inlabel} to make a decision. |
| 5042 |
% |
| 5043 |
% By the end of the day both should probably move into the kernel |
| 5044 |
% hook instead. |
| 5045 |
% \begin{macrocode} |
| 5046 |
\DeclareHookRule{para/begin}{items}{after}{tagpdf} |
| 5047 |
% \end{macrocode} |
| 5048 |
% |
| 5049 |
% |
| 5050 |
% What follows is the version that resets various legacy booleans and puts |
| 5051 |
% the label box in the right place and finally resets itself to do |
| 5052 |
% nothing next time. \cs{@@_everypar:} is set to this by the |
| 5053 |
% item template so that the next paragraph start runs the code below. |
| 5054 |
% \begin{macrocode} |
| 5055 |
\cs_new_protected:Npn \@@_item_everypar_std: { |
| 5056 |
\@@_debug_typeout:n{...~ in~ item~ block~ everypar \on@line } |
| 5057 |
\legacy_if_set_false:n { @minipage } |
| 5058 |
\legacy_if_gset_false:n { @newlist } |
| 5059 |
\legacy_if:nT { @inlabel } |
| 5060 |
{ |
| 5061 |
\legacy_if_gset_false:n { @inlabel } |
| 5062 |
% \end{macrocode} |
| 5063 |
% |
| 5064 |
% \begin{macrocode} |
| 5065 |
\box_if_empty:NT \g_para_indent_box { \kern - \itemindent } |
| 5066 |
\para_omit_indent: |
| 5067 |
% \end{macrocode} |
| 5068 |
% \changes{v0.9w}{2026-05-08}{Unpack the box if next line is active, tagging/1276} |
| 5069 |
% TODO: that boxing/unboxing need to be reevaluated at some point |
| 5070 |
% \begin{macrocode} |
| 5071 |
\bool_if:NTF \l_@@_next_line_bool |
| 5072 |
{ |
| 5073 |
\hbox_unpack_drop:N \g_@@_labels_box |
| 5074 |
} |
| 5075 |
{ |
| 5076 |
\box_use_drop:N \g_@@_labels_box |
| 5077 |
} |
| 5078 |
% \end{macrocode} |
| 5079 |
% After the labels are placed we start a paragraph structure (if |
| 5080 |
% appropriate). This is handled in the following kernel hook: |
| 5081 |
% \begin{macrocode} |
| 5082 |
\__kernel_list_label_after:n {LI-} |
| 5083 |
% \end{macrocode} |
| 5084 |
% |
| 5085 |
% \begin{macrocode} |
| 5086 |
\penalty \c_zero_int |
| 5087 |
} |
| 5088 |
\legacy_if:nTF { @nobreak } |
| 5089 |
{ |
| 5090 |
\legacy_if_gset_false:n { @nobreak } |
| 5091 |
\int_set:Nn \clubpenalty { 10000 } |
| 5092 |
} |
| 5093 |
{ |
| 5094 |
\int_set_eq:NN \clubpenalty \@clubpenalty |
| 5095 |
% \end{macrocode} |
| 5096 |
% Once the label(s) are typeset and we are past any special |
| 5097 |
% \texttt{@nobreak} handling we reset \cs{@@_everypar:} to do |
| 5098 |
% nothing. |
| 5099 |
% \begin{macrocode} |
| 5100 |
\@@_debug_typeout:n{Set~ noop~ block~ everypar \on@line } |
| 5101 |
\cs_set_eq:NN \@@_everypar: \prg_do_nothing: |
| 5102 |
} |
| 5103 |
} |
| 5104 |
% \end{macrocode} |
| 5105 |
% |
| 5106 |
% This is the definition of \cs{@@_everypar:} before the first |
| 5107 |
% \tn{item} is encountered. |
| 5108 |
% \changes{v0.8q}{2024/09/02}{Call \tn{@noitemerr} if hmode is |
| 5109 |
% started before the first item} |
| 5110 |
% \begin{macrocode} |
| 5111 |
\cs_new_protected:Npn \@@_item_everypar_first: { |
| 5112 |
\@@_debug_typeout:n{...~ in~ first~ block~ everypar \on@line } |
| 5113 |
\legacy_if:nT { @newlist } { \@noitemerr } |
| 5114 |
} |
| 5115 |
% \end{macrocode} |
| 5116 |
% |
| 5117 |
% \end{macro} |
| 5118 |
% |
| 5119 |
% |
| 5120 |
% \begin{variable}{\l_@@_tmpa_skip} |
| 5121 |
% \begin{macrocode} |
| 5122 |
\skip_new:N \l_@@_tmpa_skip |
| 5123 |
% \end{macrocode} |
| 5124 |
% \end{variable} |
| 5125 |
% |
| 5126 |
% |
| 5127 |
% |
| 5128 |
% |
| 5129 |
% |
| 5130 |
% |
| 5131 |
% |
| 5132 |
% \begin{variable}{\l_@@_effective_top_skip, \l_@@_effective_bot_skip} |
| 5133 |
% Variables equivalent to \LaTeXe{}'s \tn{@topsepadd} and \tn{@topsep}. |
| 5134 |
% Roughly equal to a mixture of \texttt{topsep}, \texttt{partopsep}, |
| 5135 |
% and various \texttt{parskip} at different nesting levels in lists. |
| 5136 |
% The code is really elaborate when \texttt{@inlabel} is true. |
| 5137 |
% \begin{macrocode} |
| 5138 |
\skip_new:N \l_@@_effective_top_skip |
| 5139 |
\skip_new:N \l_@@_effective_bot_skip |
| 5140 |
% \end{macrocode} |
| 5141 |
% \end{variable} |
| 5142 |
% |
| 5143 |
% |
| 5144 |
% |
| 5145 |
% |
| 5146 |
% |
| 5147 |
% \begin{hookdecl}{item/before,item/after} |
| 5148 |
% We provide hooks at the begin and the end of an item. |
| 5149 |
% The before hook is just after the tagging code opens the LI structure (if tagging is active). |
| 5150 |
% The after hook is just before the tagging code closes the LI structure. |
| 5151 |
% The hooks are executed in vmode. |
| 5152 |
% In the item/before hook no typesetting should be done. |
| 5153 |
% It is possible to add content in the item/after but for correct tagging it must be |
| 5154 |
% wrapped in an \texttt{LBody} structure (e.g., with \verb+tag=\UseStructureName{block/list/body}+). |
| 5155 |
% \begin{macrocode} |
| 5156 |
\NewHook{item/before} |
| 5157 |
\NewHook{item/after} |
| 5158 |
% \end{macrocode} |
| 5159 |
% \end{hookdecl} |
| 5160 |
% |
| 5161 |
% |
| 5162 |
% \begin{macro}{\item} |
| 5163 |
% Here we already have all the building blocks. Complain in math |
| 5164 |
% mode. Distinguish between first item (do necessary tagging) and |
| 5165 |
% later items \cs{@@_inter_item:} to |
| 5166 |
% cleanly close what's before, then call \cs{@@_item_instance:n} (which |
| 5167 |
% calls \tn{UseInstance}\{item\}\marg{instance}) to prepare the |
| 5168 |
% upcoming item: it will be actually inserted only once some later |
| 5169 |
% material triggers \tn{everypar}. |
| 5170 |
% \begin{macrocode} |
| 5171 |
\AddToHook{begindocument/before}[./legacy-lists]{ |
| 5172 |
\RenewDocumentCommand{\item}{ ={label}o } |
| 5173 |
{ |
| 5174 |
\@inmatherr \item |
| 5175 |
% \end{macrocode} |
| 5176 |
% TODO: Check if test for being outside of a list is sensible |
| 5177 |
% \begin{macrocode} |
| 5178 |
\cs_if_free:NTF \@@_item_instance:n |
| 5179 |
{ |
| 5180 |
\@latex@error{Lonely~\string\item--perhaps~a~missing~ |
| 5181 |
list~environment}\@ehc |
| 5182 |
} |
| 5183 |
{ |
| 5184 |
% \end{macrocode} |
| 5185 |
% If the previous \cs{item} ended in an environment requesting |
| 5186 |
% \texttt{@endpe} handling we have to ensure that a \cs{par} is |
| 5187 |
% seen so that the semantic paragraph surrounding that environment |
| 5188 |
% ends (as it can't extend to the next item. |
| 5189 |
% \begin{macrocode} |
| 5190 |
\if@endpe \par \fi |
| 5191 |
% \end{macrocode} |
| 5192 |
% |
| 5193 |
% \begin{macrocode} |
| 5194 |
\legacy_if:nTF { @newlist } |
| 5195 |
{ |
| 5196 |
\__kernel_list_item_begin: |
| 5197 |
\hook_use:n{item/before} |
| 5198 |
% \end{macrocode} |
| 5199 |
% The first item of a list also has to change the \texttt{@newlist} switch. |
| 5200 |
% \changes{v0.8q}{2024/09/02}{Set \texttt{@newlist} to false after |
| 5201 |
% the first \tn{item}} |
| 5202 |
% \begin{macrocode} |
| 5203 |
\legacy_if_gset_false:n { @newlist } |
| 5204 |
} |
| 5205 |
{ \@@_inter_item: } |
| 5206 |
% \end{macrocode} |
| 5207 |
% To avoid unnecessary key/val processing we make a quick check if |
| 5208 |
% there was an optional argument. |
| 5209 |
% \begin{macrocode} |
| 5210 |
\tl_if_novalue:nTF {#1} % avoids reparsing label={} |
| 5211 |
{ \@@_item_instance:n { } } |
| 5212 |
{ \@@_item_instance:n {#1} } |
| 5213 |
% \end{macrocode} |
| 5214 |
% The \insttype{item} instance puts the item label into |
| 5215 |
% \cs{g_@@_label_standalone_bool} ready to be placed later. To make |
| 5216 |
% that happen we need to signal that by setting the legacy switch |
| 5217 |
% \texttt{@inlabel} to true. However, if this is a label that |
| 5218 |
% should be always placed \enquote{standalone} we instead typeset it |
| 5219 |
% immediately and ensure that there is no page break after |
| 5220 |
% it.\fmi{support extra vertical space as well?} |
| 5221 |
% \begin{macrocode} |
| 5222 |
\bool_if:NTF \g_@@_label_standalone_bool |
| 5223 |
{ |
| 5224 |
\bool_gset_false:N \g_@@_label_standalone_bool |
| 5225 |
\leavevmode |
| 5226 |
\box_use_drop:N \g_@@_labels_box |
| 5227 |
\par |
| 5228 |
\legacy_if_gset_true:n { @nobreak } % do not break after |
| 5229 |
% a standalone item |
| 5230 |
} |
| 5231 |
{ |
| 5232 |
\legacy_if_gset_true:n { @inlabel } |
| 5233 |
} |
| 5234 |
\ignorespaces |
| 5235 |
} |
| 5236 |
} |
| 5237 |
} |
| 5238 |
% \end{macrocode} |
| 5239 |
% \end{macro} |
| 5240 |
% |
| 5241 |
% |
| 5242 |
% \begin{macro}{\@@_inter_item:} |
| 5243 |
% Between items. If the previous item had no content then we need to |
| 5244 |
% trigger \tn{everypar}. Otherwise we simply close the previous item |
| 5245 |
% with \tn{par} after removing some horizontal space. Between items, |
| 5246 |
% there is a penalty and some space. |
| 5247 |
% \begin{macrocode} |
| 5248 |
\cs_new_protected:Npn \@@_inter_item: { |
| 5249 |
\legacy_if:nT { @inlabel } |
| 5250 |
{ \indent \par } % case of \item\item |
| 5251 |
% \end{macrocode} |
| 5252 |
% \tn{par} may have a strange definition and may not get us back to |
| 5253 |
% vertical mode in one go, so we better not treat the next line |
| 5254 |
% as an else case to the above conditional (for now). |
| 5255 |
% \begin{macrocode} |
| 5256 |
\mode_if_horizontal:T { \@@_skip_remove_last: |
| 5257 |
\@@_skip_remove_last: \par } |
| 5258 |
% \end{macrocode} |
| 5259 |
% End any LI-tag, then start the next LI-tag (if doing tagging): |
| 5260 |
% \begin{macrocode} |
| 5261 |
\hook_use:n{item/after} |
| 5262 |
\__kernel_list_item_end: |
| 5263 |
\__kernel_list_item_begin: |
| 5264 |
\hook_use:n{item/before} |
| 5265 |
% \end{macrocode} |
| 5266 |
% |
| 5267 |
% \begin{macrocode} |
| 5268 |
\addpenalty \@itempenalty |
| 5269 |
\addvspace \itemsep |
| 5270 |
} |
| 5271 |
% \end{macrocode} |
| 5272 |
% \end{macro} |
| 5273 |
% |
| 5274 |
% |
| 5275 |
% \begin{macro}{\__kernel_list_item_begin:, |
| 5276 |
% \__kernel_list_item_end:} |
| 5277 |
% |
| 5278 |
% \begin{macrocode} |
| 5279 |
\cs_new_eq:NN \__kernel_list_item_begin: \prg_do_nothing: |
| 5280 |
\cs_new_eq:NN \__kernel_list_item_end: \prg_do_nothing: |
| 5281 |
% \end{macrocode} |
| 5282 |
% \end{macro} |
| 5283 |
% |
| 5284 |
% |
| 5285 |
% |
| 5286 |
% |
| 5287 |
% \subsubsection{Implementation of \insttype{captionedtext} |
| 5288 |
% and \insttype{thmstyle} templates} |
| 5289 |
% |
| 5290 |
% |
| 5291 |
% \begin{template}{captionedtext thmlike} |
| 5292 |
% The template for typical theorem-like environments is rather |
| 5293 |
% trivial, just setting keys and then passing used keys and the |
| 5294 |
% arguments to a \insttype{thmstyle} instance to do the real work. |
| 5295 |
% \begin{macrocode} |
| 5296 |
\DeclareTemplateCode{captionedtext}{thmlike}{4} |
| 5297 |
{ |
| 5298 |
,counter = \l_@@_counter_tl |
| 5299 |
,title = \l_@@_title_tl |
| 5300 |
,style = \l_@@_style:nnnn |
| 5301 |
} |
| 5302 |
{ |
| 5303 |
% \end{macrocode} |
| 5304 |
% Some debugging info as usual (showing the arguments that are passed): |
| 5305 |
% \begin{macrocode} |
| 5306 |
\template_debug_typeout:n{~\space template:~ 'thmlike';~ |
| 5307 |
arguments:~ \exp_not:o{\exp_after:wN |#1|#2|#3|#4|}} |
| 5308 |
% \end{macrocode} |
| 5309 |
% Then we check if there are any keys passed to the instance from |
| 5310 |
% the outside. |
| 5311 |
% \begin{macrocode} |
| 5312 |
\SetKnownTemplateKeys{captionedtext}{thmlike}{#1} |
| 5313 |
% \end{macrocode} |
| 5314 |
% Finally, we apply the style which is just an instance of |
| 5315 |
% type \insttype{thmstyle}: |
| 5316 |
% \begin{macrocode} |
| 5317 |
\l_@@_style:nnnn \UnusedTemplateKeys {#2} {#3} {#4} |
| 5318 |
} |
| 5319 |
% \end{macrocode} |
| 5320 |
% \end{template} |
| 5321 |
% |
| 5322 |
% |
| 5323 |
% |
| 5324 |
% \begin{macro}{\theoremstyle,\l_@@_thmstyle_tl} |
| 5325 |
% ^^A |
| 5326 |
% All that the \cs{theoremstyle} declaration does is saving its |
| 5327 |
% argument so that it can be used in \cs{newtheorem}. |
| 5328 |
% \begin{macrocode} |
| 5329 |
\cs_new_protected:Npn \theoremstyle #1{ \tl_set:Nn \l_@@_thmstyle_tl {#1} } |
| 5330 |
% \end{macrocode} |
| 5331 |
% \begin{macrocode} |
| 5332 |
\tl_new:N \l_@@_thmstyle_tl |
| 5333 |
% \end{macrocode} |
| 5334 |
% And the default is \texttt{plain}: |
| 5335 |
% \begin{macrocode} |
| 5336 |
\theoremstyle{plain} |
| 5337 |
% \end{macrocode} |
| 5338 |
% \end{macro} |
| 5339 |
% |
| 5340 |
% |
| 5341 |
% |
| 5342 |
% \begin{template}{thmstyle std} |
| 5343 |
% The \insttype{thmstyle} implements the theorem-like |
| 5344 |
% environment and assumes that the fixed part of the caption is |
| 5345 |
% already stored in \cs{l_@@_title_tl}. The reason for this |
| 5346 |
% separation into two templates is that typically the same design |
| 5347 |
% is used for different theorem-like environments only differing in |
| 5348 |
% this fixed string. |
| 5349 |
% \changes{v0.9n}{2026/02/01}{Add further decl keys (tagging/1199)} |
| 5350 |
% \begin{macrocode} |
| 5351 |
\DeclareTemplateCode{thmstyle}{std}{4} |
| 5352 |
{ |
| 5353 |
,numbered = \l_@@_numbered_bool |
| 5354 |
,separator = \l_@@_separator_tl |
| 5355 |
,punct = \l_@@_punct_tl |
| 5356 |
,caption-placement = { |
| 5357 |
chained = \bool_gset_false:N \g_@@_label_standalone_bool |
| 5358 |
\bool_gset_false:N \g_@@_label_unchained_bool |
| 5359 |
,unchained = \bool_gset_false:N \g_@@_label_standalone_bool |
| 5360 |
\bool_gset_true:N \g_@@_label_unchained_bool |
| 5361 |
,standalone = \bool_gset_true:N \g_@@_label_standalone_bool |
| 5362 |
\bool_gset_false:N \g_@@_label_unchained_bool |
| 5363 |
} |
| 5364 |
,caption-unbreakable = \l_@@_caption_unbreakable_bool |
| 5365 |
,before-hspace = \l_@@_caption_before_skip |
| 5366 |
,after-hspace = \l_@@_caption_after_skip |
| 5367 |
,order = \l_@@_order_clist |
| 5368 |
,caption-decls = \l_@@_caption_decls_tl |
| 5369 |
,title-decls = \l_@@_title_decls_tl |
| 5370 |
,number-decls = \l_@@_number_decls_tl |
| 5371 |
,punct-decls = \l_@@_punct_decls_tl |
| 5372 |
,note-decls = \l_@@_note_decls_tl |
| 5373 |
,title-format = \@@_title_format:n |
| 5374 |
,number-format = \@@_number_format:n |
| 5375 |
,punct-format = \@@_punct_format:n |
| 5376 |
,note-format = \@@_note_format:n |
| 5377 |
,body-decls = \l_@@_body_decls_tl |
| 5378 |
} |
| 5379 |
{ |
| 5380 |
% \end{macrocode} |
| 5381 |
% Some tracing: |
| 5382 |
% \begin{macrocode} |
| 5383 |
\template_debug_typeout:n{~\space template:~ 'std';~ |
| 5384 |
arguments:~ \exp_not:o{\exp_after:wN |#1|#2|#3|#4|}} |
| 5385 |
% \end{macrocode} |
| 5386 |
% Applying any user keys: |
| 5387 |
% \begin{macrocode} |
| 5388 |
\SetKnownTemplateKeys{thmstyle}{std}{#1} |
| 5389 |
% \end{macrocode} |
| 5390 |
% Since this is the last template that gets applied for |
| 5391 |
% theorem-like environments, all keys should make sense, so if |
| 5392 |
% something is left over we better generate an error: |
| 5393 |
% \begin{macrocode} |
| 5394 |
\tl_if_empty:NF \UnusedTemplateKeys |
| 5395 |
{ |
| 5396 |
\msg_error:nnee { block } { unknown-keys } |
| 5397 |
{ \l_@@_env_name_tl \space environment} |
| 5398 |
\UnusedTemplateKeys |
| 5399 |
} |
| 5400 |
% \end{macrocode} |
| 5401 |
% |
| 5402 |
% In case there is a dangling \cs{item} we can either join that |
| 5403 |
% with the caption or we can output the item first. For now we |
| 5404 |
% provide no customization for this, but it could be made |
| 5405 |
% customizable. |
| 5406 |
% \begin{macrocode} |
| 5407 |
% \legacy_if:nT { @inlabel } { \indent \par } |
| 5408 |
% \end{macrocode} |
| 5409 |
% Determine if we do numbering: |
| 5410 |
% \begin{macrocode} |
| 5411 |
\bool_lazy_or:nnT |
| 5412 |
{ \tl_if_empty_p:N \l_@@_counter_tl } |
| 5413 |
{ #2 } |
| 5414 |
{ \bool_set_false:N \l_@@_numbered_bool } |
| 5415 |
% \end{macrocode} |
| 5416 |
% Save any note for later use (\verb=\#3= might contain \cs{NoValue}): |
| 5417 |
% \begin{macrocode} |
| 5418 |
\tl_set:Nn \l_@@_note_tl {#3} |
| 5419 |
% \end{macrocode} |
| 5420 |
% If we use numbering then we need a link target and increment the counter. |
| 5421 |
% \begin{macrocode} |
| 5422 |
\bool_if:NTF \l_@@_numbered_bool |
| 5423 |
{ |
| 5424 |
\@kernel@refstepcounter{ \l_@@_counter_tl } |
| 5425 |
\MakeLinkTarget{ \l_@@_counter_tl } |
| 5426 |
} |
| 5427 |
{ |
| 5428 |
\MakeLinkTarget[theorem-like]{} |
| 5429 |
} |
| 5430 |
% \end{macrocode} |
| 5431 |
% Add the caption into \cs{g_@@_labels_box}: |
| 5432 |
% \begin{macrocode} |
| 5433 |
\hbox_gset:Nn \g_@@_labels_box |
| 5434 |
{ |
| 5435 |
\box_use_drop:N \g__block_labels_box % <- does nothing if |
| 5436 |
% there is no dangling label |
| 5437 |
% \end{macrocode} |
| 5438 |
% Now apply the declarations that are for the whole caption. |
| 5439 |
% \begin{macrocode} |
| 5440 |
\l_@@_caption_decls_tl |
| 5441 |
% \end{macrocode} |
| 5442 |
% Then we apply the tagging socket for the caption to the complete content: |
| 5443 |
% \begin{macrocode} |
| 5444 |
\tag_socket_use:nnn {captionedtext/caption} {} |
| 5445 |
{ |
| 5446 |
\skip_horizontal:n { \l_@@_caption_before_skip } |
| 5447 |
% \end{macrocode} |
| 5448 |
% For flexibility, the inner structure is given as a clist stored |
| 5449 |
% in \cs{l_@@_order_clist}. We loop through it and call a |
| 5450 |
% processing function for each item in this clist. Everything |
| 5451 |
% happens in a group |
| 5452 |
% \begin{macrocode} |
| 5453 |
\clist_map_inline:Nn \l_@@_order_clist |
| 5454 |
{ \group_begin: |
| 5455 |
\use:c { @@_do_##1: } |
| 5456 |
\group_end: |
| 5457 |
} |
| 5458 |
\skip_horizontal:n { \l_@@_caption_after_skip } |
| 5459 |
} |
| 5460 |
} |
| 5461 |
% \end{macrocode} |
| 5462 |
% If the title should be standalone we immediately push it out: |
| 5463 |
% \begin{macrocode} |
| 5464 |
\bool_if:NTF \g_@@_label_standalone_bool |
| 5465 |
{ |
| 5466 |
\bool_gset_true:N \g_@@_label_standalone_bool |
| 5467 |
\para_omit_indent: |
| 5468 |
\box_use_drop:N \g_@@_labels_box |
| 5469 |
\par |
| 5470 |
% \end{macrocode} |
| 5471 |
% \fmi{Do we need a \cs{nobreak} here or is this covered? check} |
| 5472 |
% \begin{macrocode} |
| 5473 |
} |
| 5474 |
% \end{macrocode} |
| 5475 |
% Otherwise we signal that we are at the start and have a label |
| 5476 |
% dangling. The name \texttt{@newlist} is a bit unfortunate, but |
| 5477 |
% for now we keep this name.\fmi{check if @newlist could be |
| 5478 |
% replaced by something more general} |
| 5479 |
% \begin{macrocode} |
| 5480 |
{ |
| 5481 |
\legacy_if_gset_true:n { @newlist } |
| 5482 |
\legacy_if_gset_true:n { @inlabel } |
| 5483 |
} |
| 5484 |
% \end{macrocode} |
| 5485 |
% Do not break after the first line: |
| 5486 |
% \begin{macrocode} |
| 5487 |
\legacy_if_gset_true:n { @nobreak } |
| 5488 |
% \end{macrocode} |
| 5489 |
% Then set up a special everypar to handle the dangling caption: |
| 5490 |
% \begin{macrocode} |
| 5491 |
\@@_debug_typeout:n{Set~ captioned~ block~ everypar \on@line } |
| 5492 |
\cs_set_eq:NN \@@_everypar: \@@_captioned_everypar_std: |
| 5493 |
% \end{macrocode} |
| 5494 |
% Finally, set up any declarations for the body of the environment: |
| 5495 |
% \begin{macrocode} |
| 5496 |
\l_@@_body_decls_tl |
| 5497 |
% \end{macrocode} |
| 5498 |
% |
| 5499 |
% \begin{macrocode} |
| 5500 |
\@@_debug_typeout:n{template:thmstyle:std~end} |
| 5501 |
} |
| 5502 |
% \end{macrocode} |
| 5503 |
% \end{template} |
| 5504 |
% |
| 5505 |
% |
| 5506 |
% |
| 5507 |
% |
| 5508 |
% \begin{socketdecl}{tagsupport/captionedtext/caption} |
| 5509 |
% \begin{macrocode} |
| 5510 |
\NewTaggingSocket{captionedtext/caption}{2} |
| 5511 |
% \end{macrocode} |
| 5512 |
% \end{socketdecl} |
| 5513 |
% |
| 5514 |
% \begin{plugdecl}{kernel} |
| 5515 |
% \fmi{why kernel?} |
| 5516 |
% \begin{macrocode} |
| 5517 |
\NewTaggingSocketPlug{captionedtext/caption}{kernel} |
| 5518 |
{ |
| 5519 |
\tag_struct_begin:n{tag=\UseStructureName{block/theorem-like/caption}} |
| 5520 |
#2 |
| 5521 |
\tag_struct_end: |
| 5522 |
} |
| 5523 |
\AssignTaggingSocketPlug{captionedtext/caption}{kernel} |
| 5524 |
% \end{macrocode} |
| 5525 |
% \end{plugdecl} |
| 5526 |
% |
| 5527 |
% |
| 5528 |
% |
| 5529 |
% Here are the functions that are called when the corresponding name appears |
| 5530 |
% in the caption clist. |
| 5531 |
% |
| 5532 |
% |
| 5533 |
% \begin{macro}{\@@_do_title:} |
| 5534 |
% Handle the title: |
| 5535 |
% \begin{macrocode} |
| 5536 |
\cs_new_protected:Npn \@@_do_title: { |
| 5537 |
% \end{macrocode} |
| 5538 |
% Check if there is a title. |
| 5539 |
% \begin{macrocode} |
| 5540 |
\tl_if_empty:NTF \l_@@_title_tl |
| 5541 |
% \end{macrocode} |
| 5542 |
% If the title is empty we drop accumulated but not yet typeset separators: |
| 5543 |
% \begin{macrocode} |
| 5544 |
{ \@@_drop_separators: } |
| 5545 |
% \end{macrocode} |
| 5546 |
% Otherwise we typeset the title, first inserting separator (or separators) |
| 5547 |
% that have been waiting. |
| 5548 |
% \begin{macrocode} |
| 5549 |
{ \tag_socket_use:nnn {mc} {}{ |
| 5550 |
\@@_insert_separators: |
| 5551 |
% \end{macrocode} |
| 5552 |
% The title may have its own formatting: |
| 5553 |
% \changes{v0.9n}{2026/02/01}{Add decl key (tagging/1199)} |
| 5554 |
% \begin{macrocode} |
| 5555 |
\l_@@_title_decls_tl |
| 5556 |
\@@_title_format:n \l_@@_title_tl } |
| 5557 |
} |
| 5558 |
} |
| 5559 |
% \end{macrocode} |
| 5560 |
% \end{macro} |
| 5561 |
% |
| 5562 |
% |
| 5563 |
% \begin{macro}{\@@_do_note:} |
| 5564 |
% Formatting of a note (if present) uses the same structure. |
| 5565 |
% \changes{v0.9n}{2026/02/01}{Add decl key (tagging/1199)} |
| 5566 |
% \begin{macrocode} |
| 5567 |
\cs_new_protected:Npn \@@_do_note: { |
| 5568 |
\tl_if_novalue:oTF \l_@@_note_tl |
| 5569 |
{ \@@_drop_separators: } |
| 5570 |
{ \tag_socket_use:nnn {mc} {} { |
| 5571 |
\@@_insert_separators: |
| 5572 |
\l_@@_note_decls_tl |
| 5573 |
\@@_note_format:n \l_@@_note_tl } |
| 5574 |
} |
| 5575 |
} |
| 5576 |
% \end{macrocode} |
| 5577 |
% \end{macro} |
| 5578 |
% |
| 5579 |
% |
| 5580 |
% \begin{macro}{\@@_do_number:} |
| 5581 |
% The number (if present) has a similar formatting but it uses an |
| 5582 |
% \UseStructureName{block/theorem-like/label} structure: |
| 5583 |
% \changes{v0.9n}{2026/02/01}{Add decl key (tagging/1199)} |
| 5584 |
% \begin{macrocode} |
| 5585 |
\cs_new_protected:Npn \@@_do_number: { |
| 5586 |
\bool_if:NTF \l_@@_numbered_bool |
| 5587 |
{ \tag_socket_use:nnn {struct-mc} {tag=\UseStructureName{block/theorem-like/label}} |
| 5588 |
{ \@@_insert_separators: |
| 5589 |
\l_@@_number_decls_tl |
| 5590 |
\@@_number_format:n { |
| 5591 |
\use:c{ the \l_@@_counter_tl } } |
| 5592 |
} |
| 5593 |
} |
| 5594 |
{ \@@_drop_separators: } |
| 5595 |
} |
| 5596 |
% \end{macrocode} |
| 5597 |
% \end{macro} |
| 5598 |
% |
| 5599 |
% |
| 5600 |
% \begin{macro}{\@@_do_punct:} |
| 5601 |
% The punctuation is handled slightly differently. It unconditionally drops any |
| 5602 |
% dangling separators whether or not it is empty: |
| 5603 |
% \changes{v0.9n}{2026/02/01}{Add decl key (tagging/1199)} |
| 5604 |
% \begin{macrocode} |
| 5605 |
\cs_new_protected:Npn \@@_do_punct: { |
| 5606 |
\@@_drop_separators: |
| 5607 |
\tl_if_empty:NF \l_@@_punct_tl |
| 5608 |
{ \tag_socket_use:nnn {mc} {}{ |
| 5609 |
\l_@@_punct_decls_tl |
| 5610 |
\@@_punct_format:n \l_@@_punct_tl } |
| 5611 |
} |
| 5612 |
} |
| 5613 |
% \end{macrocode} |
| 5614 |
% \end{macro} |
| 5615 |
% |
| 5616 |
% |
| 5617 |
% \begin{macro}{\@@_do_separator:,\@@_insert_separators:,\@@_drop_separators:, |
| 5618 |
% \g_@@_collected_separators_tl} |
| 5619 |
% ^^A |
| 5620 |
% What's still missing is what \texttt{separator} should do. It simply |
| 5621 |
% adds a \cs{l_@@_separator_tl} to the \cs{g_@@_collected_separators_tl} |
| 5622 |
% tokenlist. This way the clist can contain |
| 5623 |
% \texttt{separator,separator,...} to indicate multiple separators |
| 5624 |
% (mainly useful if they are some amount of space). The storage |
| 5625 |
% tokenlist is global as the functions are executed inside their |
| 5626 |
% own group, but the collected separator is used outside of that group. |
| 5627 |
% \begin{macrocode} |
| 5628 |
\cs_new_protected:Npn \@@_do_separator: { |
| 5629 |
\tl_gput_right:Nn \g_@@_collected_separators_tl \l_@@_separator_tl |
| 5630 |
} |
| 5631 |
% \end{macrocode} |
| 5632 |
% So \cs{@@_insert_separators:} is trivial, all we have to do is to |
| 5633 |
% insert the collected separators and then clear the tokenlist |
| 5634 |
% \begin{macrocode} |
| 5635 |
\cs_new_protected:Npn \@@_insert_separators: { |
| 5636 |
\g_@@_collected_separators_tl |
| 5637 |
\tl_gclear:N \g_@@_collected_separators_tl |
| 5638 |
} |
| 5639 |
% \end{macrocode} |
| 5640 |
% Even simpler is \cs{@@_drop_separators:} |
| 5641 |
% \begin{macrocode} |
| 5642 |
\cs_new_protected:Npn \@@_drop_separators: { |
| 5643 |
\tl_gclear:N \g_@@_collected_separators_tl |
| 5644 |
} |
| 5645 |
% \end{macrocode} |
| 5646 |
% What remains is to declare the tokenlist. |
| 5647 |
% \begin{macrocode} |
| 5648 |
\tl_new:N \g_@@_collected_separators_tl |
| 5649 |
% \end{macrocode} |
| 5650 |
% \end{macro} |
| 5651 |
% |
| 5652 |
% |
| 5653 |
% |
| 5654 |
% |
| 5655 |
% |
| 5656 |
% |
| 5657 |
% |
| 5658 |
% |
| 5659 |
% |
| 5660 |
% |
| 5661 |
% |
| 5662 |
% |
| 5663 |
% |
| 5664 |
% \begin{template}{captionedtext proof} |
| 5665 |
% In case of the templates for proofs we do everything in a single template. |
| 5666 |
% \changes{v0.9n}{2026/02/01}{Add further decl keys (tagging/1199)} |
| 5667 |
% \changes{v0.9n}{2026/02/01}{Add caption-unbreakable key (tagging/1200)} |
| 5668 |
% \begin{macrocode} |
| 5669 |
\DeclareTemplateCode{captionedtext}{proof}{4} |
| 5670 |
{ |
| 5671 |
,title = \l_@@_title_tl |
| 5672 |
,punct = \l_@@_punct_tl |
| 5673 |
,caption-placement = { |
| 5674 |
chained = \bool_gset_false:N \g_@@_label_standalone_bool |
| 5675 |
\bool_gset_false:N \g_@@_label_unchained_bool |
| 5676 |
,unchained = \bool_gset_false:N \g_@@_label_standalone_bool |
| 5677 |
\bool_gset_true:N \g_@@_label_unchained_bool |
| 5678 |
,standalone = \bool_gset_true:N \g_@@_label_standalone_bool |
| 5679 |
\bool_gset_false:N \g_@@_label_unchained_bool |
| 5680 |
} |
| 5681 |
,caption-unbreakable = \l_@@_caption_unbreakable_bool |
| 5682 |
,before-hspace = \l_@@_caption_before_skip |
| 5683 |
,after-hspace = \l_@@_caption_after_skip |
| 5684 |
,caption-decls = \l_@@_caption_decls_tl |
| 5685 |
,title-decls = \l_@@_title_decls_tl |
| 5686 |
,punct-decls = \l_@@_punct_decls_tl |
| 5687 |
,title-format = \@@_title_format:n |
| 5688 |
,punct-format = \@@_punct_format:n |
| 5689 |
,body-decls = \l_@@_body_decls_tl |
| 5690 |
} |
| 5691 |
{ |
| 5692 |
% \end{macrocode} |
| 5693 |
% Display the template's arguments when tracing: |
| 5694 |
% \begin{macrocode} |
| 5695 |
\template_debug_typeout:n{~\space template:~ 'proof';~ |
| 5696 |
arguments:~ \exp_not:o{\exp_after:wN |#1|#2|#3|#4|}} |
| 5697 |
% \end{macrocode} |
| 5698 |
% Evaluate document-level key settings. As all given keys should be |
| 5699 |
% handled we use \cs{SetTemplateKeys} to raise an error if one or |
| 5700 |
% more are not recognized: |
| 5701 |
% \begin{macrocode} |
| 5702 |
\SetTemplateKeys{captionedtext}{proof}{#1} |
| 5703 |
% \end{macrocode} |
| 5704 |
% By default the title is defined by the proof instance, but if the |
| 5705 |
% user provides an optional argument that optional argument |
| 5706 |
% overwrites the title (in contrast to theorem-like environments |
| 5707 |
% that use the optional argument to provide an additional note): |
| 5708 |
% \begin{macrocode} |
| 5709 |
\IfNoValueF {#3} { \tl_set:Nn \l_@@_title_tl {#3} } |
| 5710 |
% \end{macrocode} |
| 5711 |
% Now we prepare typesetting the title by placing it in the \cs{g_@@_labels_box}: |
| 5712 |
% \begin{macrocode} |
| 5713 |
\hbox_gset:Nn \g_@@_labels_box |
| 5714 |
{ |
| 5715 |
\box_use_drop:N \g_@@_labels_box % <- does nothing if there |
| 5716 |
% is no dangling label |
| 5717 |
\l_@@_caption_decls_tl |
| 5718 |
\tag_socket_use:nnn {captionedtext/caption} {} |
| 5719 |
{ |
| 5720 |
\skip_horizontal:n { \l_@@_caption_before_skip } |
| 5721 |
% \end{macrocode} |
| 5722 |
% \cs{@@_do_title:} and \cs{@@_do_punct:} unnecessarily call |
| 5723 |
% \cs{@@_drop_separators:} but otherwise they do well, so \ldots |
| 5724 |
% \begin{macrocode} |
| 5725 |
\group_begin: \@@_do_title: \group_end: |
| 5726 |
\group_begin: \@@_do_punct: \group_end: |
| 5727 |
\skip_horizontal:n { \l_@@_caption_after_skip } |
| 5728 |
} |
| 5729 |
} |
| 5730 |
% \end{macrocode} |
| 5731 |
% The remaining code is identical to the one in \insttype{thmstyle} |
| 5732 |
% \instname{std}; for documentation see there: |
| 5733 |
% \changes{v0.9n}{2026/02/01}{Allow caption to break by default (tagging/1200)} |
| 5734 |
% \begin{macrocode} |
| 5735 |
\bool_if:NTF \g_@@_label_standalone_bool |
| 5736 |
{ |
| 5737 |
\bool_gset_true:N \g_@@_label_standalone_bool |
| 5738 |
\para_omit_indent: |
| 5739 |
\bool_if:NTF \l_@@_caption_unbreakable_bool |
| 5740 |
\box_use_drop:N |
| 5741 |
\hbox_unpack_drop:N |
| 5742 |
\g_@@_labels_box |
| 5743 |
\par |
| 5744 |
} |
| 5745 |
{ |
| 5746 |
\legacy_if_gset_true:n { @newlist } |
| 5747 |
\legacy_if_gset_true:n { @inlabel } |
| 5748 |
} |
| 5749 |
\legacy_if_gset_true:n { @nobreak } |
| 5750 |
\@@_debug_typeout:n{Set~ captioned~ block~ everypar \on@line } |
| 5751 |
\cs_set_eq:NN \@@_everypar: \@@_captioned_everypar_std: |
| 5752 |
\l_@@_body_decls_tl |
| 5753 |
% \end{macrocode} |
| 5754 |
% |
| 5755 |
% \begin{macrocode} |
| 5756 |
\@@_debug_typeout:n{template:captionedtext:proof~end} |
| 5757 |
} |
| 5758 |
% \end{macrocode} |
| 5759 |
% \end{template} |
| 5760 |
% |
| 5761 |
% |
| 5762 |
% |
| 5763 |
% |
| 5764 |
% |
| 5765 |
% |
| 5766 |
% |
| 5767 |
% |
| 5768 |
% |
| 5769 |
% |
| 5770 |
% |
| 5771 |
% |
| 5772 |
% \subsection{Tagging support commands} |
| 5773 |
% |
| 5774 |
% In this section we provide code to the various kernel hooks to support |
| 5775 |
% the tagging of different displayblock environments. |
| 5776 |
% |
| 5777 |
% \changes{v0.9g}{2025-07-01}{Define the following command |
| 5778 |
% even if tagging is not active, to allow to activate tagging later} |
| 5779 |
% \changes{v0.9g}{2025-07-01}{Removed para-hook code, it is in tagpdf currently} |
| 5780 |
% |
| 5781 |
% |
| 5782 |
% \begin{macro}{\@@_beginpar_vmode:} |
| 5783 |
% When a block starts out in vertical mode, i.e., is not yet part |
| 5784 |
% of a paragraph, we have to start a paragraph structure. However, |
| 5785 |
% this is not the case if we are already flattening paragraphs, |
| 5786 |
% thus in this case we do nothing. We also do nothing if |
| 5787 |
% \texttt{@endpe} is currently true, because that means we are |
| 5788 |
% right now just after the end of a \texttt{blockenv} and in the |
| 5789 |
% process of looking if we have to end the current |
| 5790 |
% \struct{\UseStructureName{para/semantic}}, i.e., it is already |
| 5791 |
% open. |
| 5792 |
% |
| 5793 |
% The command is mapped to |
| 5794 |
% \cs{__kernel_displayblock_beginpar_vmode:} in various tagging |
| 5795 |
% recipes. It is also used in the math code! |
| 5796 |
% \begin{macrocode} |
| 5797 |
\cs_set:Npn \@@_beginpar_vmode: { |
| 5798 |
\@@_debug_typeout:n |
| 5799 |
{ @endpe = \legacy_if:nTF { @endpe }{true}{false} \on@line } |
| 5800 |
\legacy_if:nTF { @endpe } |
| 5801 |
{ |
| 5802 |
\legacy_if_gset_false:n { @endpe } |
| 5803 |
} |
| 5804 |
% \end{macrocode} |
| 5805 |
% We test for \texttt{<2} because the first flattened environment |
| 5806 |
% has to surround itself with a |
| 5807 |
% \struct{\UseStructureName{para/semantic}}. Only any inner ones |
| 5808 |
% then have to avoid adding another |
| 5809 |
% \struct{\UseStructureName{para/semantic}}. |
| 5810 |
% \begin{macrocode} |
| 5811 |
{ |
| 5812 |
\int_compare:nNnT \l__tag_block_flattened_level_int < 2 |
| 5813 |
{ |
| 5814 |
% \end{macrocode} |
| 5815 |
% \changes{v0.9k}{2025/07/21}{Use tagging socket for text-unit structure} |
| 5816 |
% \begin{macrocode} |
| 5817 |
% \typeout{===> @@_beginpar_vmode:} |
| 5818 |
% \ShowTagging{struct-stack} |
| 5819 |
\UseTaggingSocket{para/semantic/begin} |
| 5820 |
{ \__tag_para_main_store_struct: } |
| 5821 |
% \ShowTagging{struct-stack} |
| 5822 |
} |
| 5823 |
} |
| 5824 |
} |
| 5825 |
% \end{macrocode} |
| 5826 |
% \end{macro} |
| 5827 |
% |
| 5828 |
% \begin{macro}{\@@_beginpar_hmode:N} |
| 5829 |
% If the block is already part of a part of a paragraph, i.e., when |
| 5830 |
% it has some text directly in front, then the first thing to do is |
| 5831 |
% to return to vertical mode. However, that should be done without |
| 5832 |
% inserting a paragraph end tag, so before calling \tn{par} to do |
| 5833 |
% its normal work, we disable paragraph tagging and restarting |
| 5834 |
% afterwards again. The argument to this config point simply |
| 5835 |
% gobbles the \tn{par} following it in the code above (which is |
| 5836 |
% used when there is no tagging going on. |
| 5837 |
% |
| 5838 |
% The command is mapped to |
| 5839 |
% \cs{__kernel_displayblock_beginpar_hmode:w} in various tagging |
| 5840 |
% recipes. |
| 5841 |
% \begin{macrocode} |
| 5842 |
\cs_set:Npn \@@_beginpar_hmode:N #1 |
| 5843 |
{ |
| 5844 |
\UseTaggingSocket{para/textblock/end} |
| 5845 |
\tagpdfparaOff \par \tagpdfparaOn |
| 5846 |
} |
| 5847 |
% \end{macrocode} |
| 5848 |
% \end{macro} |
| 5849 |
% |
| 5850 |
% Paragraph tagging is mainly done using the paragraph hooks. |
| 5851 |
% The code is in \file{lttagging.dtx}. |
| 5852 |
% |
| 5853 |
% \begin{socketdecl}{tagsupport/block/startpara/direct} |
| 5854 |
% A tagging socket to start a paragraph structure. It takes an |
| 5855 |
% argument (which is only used in debugging) that should be gobbled |
| 5856 |
% if tagging is not active. Not yet in lttagging (name and |
| 5857 |
% function should be reviewed). |
| 5858 |
% |
| 5859 |
% This is a similar code to the one used in the para/begin hook but |
| 5860 |
% without testing \texttt{@endpe}. This is not needed in the |
| 5861 |
% standalone case and wrong inside lists. |
| 5862 |
% |
| 5863 |
% This code is used in various places and should be a dummy if |
| 5864 |
% tagging is not active. |
| 5865 |
% \begin{macrocode} |
| 5866 |
\socket_if_exist:nF {tagsupport/block/startpara/direct} |
| 5867 |
{ |
| 5868 |
\NewTaggingSocket {block/startpara/direct}{1} |
| 5869 |
} |
| 5870 |
% \end{macrocode} |
| 5871 |
% \end{socketdecl} |
| 5872 |
% |
| 5873 |
% \begin{plugdecl}{default} |
| 5874 |
% \begin{macrocode} |
| 5875 |
\NewTaggingSocketPlug{block/startpara/direct}{default} |
| 5876 |
{ |
| 5877 |
\bool_if:NT \l__tag_para_bool |
| 5878 |
{ |
| 5879 |
\bool_if:NF \l__tag_para_flattened_bool |
| 5880 |
{ |
| 5881 |
% \end{macrocode} |
| 5882 |
% \changes{v0.9k}{2025/07/21}{Use tagging socket for text-unit structure} |
| 5883 |
% \begin{macrocode} |
| 5884 |
% \typeout{===> block/startpara/direct} |
| 5885 |
% \ShowTagging{struct-stack} |
| 5886 |
\UseTaggingSocket{para/semantic/begin} |
| 5887 |
{ \__tag_para_main_store_struct: } |
| 5888 |
} |
| 5889 |
\UseTaggingSocket{para/textblock/begin} { #1 } |
| 5890 |
} |
| 5891 |
} |
| 5892 |
\AssignTaggingSocketPlug{block/startpara/direct}{default} |
| 5893 |
% \end{macrocode} |
| 5894 |
% \end{plugdecl} |
| 5895 |
% |
| 5896 |
% The para/end hook code is in lttagging. |
| 5897 |
% Currently we still need to remove the tagpdf chunk |
| 5898 |
% to avoid that the socket is added twice. |
| 5899 |
% We add empty chunks to avoid warning messages from code parts trying to remove |
| 5900 |
% the chunks. |
| 5901 |
% \begin{macrocode} |
| 5902 |
\AddToHook{para/end}[tagpdf]{} |
| 5903 |
\RemoveFromHook{para/end}[tagpdf] |
| 5904 |
\AddToHook{para/end}{} |
| 5905 |
% \end{macrocode} |
| 5906 |
% |
| 5907 |
% \begin{macrocode} |
| 5908 |
\def\PARALABEL{NP-} |
| 5909 |
% \end{macrocode} |
| 5910 |
% |
| 5911 |
% |
| 5912 |
% \begin{socketdecl}{tagsupport/kernel/endpe/vmode} |
| 5913 |
% A tagging socket which ends a structure. Used in \cs{begin} and |
| 5914 |
% \cs{para_end:}. Not yet in lttagging (name and function should be |
| 5915 |
% reviewed). |
| 5916 |
% \begin{macrocode} |
| 5917 |
\socket_if_exist:nF {tagsupport/kernel/endpe/vmode} |
| 5918 |
{ |
| 5919 |
\NewTaggingSocket {kernel/endpe/vmode}{0} |
| 5920 |
} |
| 5921 |
% \end{macrocode} |
| 5922 |
% \end{socketdecl} |
| 5923 |
% \begin{plugdecl}{default} |
| 5924 |
% \begin{macrocode} |
| 5925 |
\NewTaggingSocketPlug{kernel/endpe/vmode}{default} |
| 5926 |
{ |
| 5927 |
\if@endpe \ifvmode |
| 5928 |
\bool_if:NT \l__tag_para_bool |
| 5929 |
{ |
| 5930 |
\bool_if:NF \l__tag_para_flattened_bool |
| 5931 |
{ |
| 5932 |
% \end{macrocode} |
| 5933 |
% \changes{v0.9k}{2025/07/21}{Use tagging socket for text-unit structure} |
| 5934 |
% \begin{macrocode} |
| 5935 |
\UseTaggingSocket{para/semantic/end}{} |
| 5936 |
} |
| 5937 |
% \end{macrocode} |
| 5938 |
% \cs{@endpefalse} is needed by \cs{para_end:}, see test tagging-0097. |
| 5939 |
% \begin{macrocode} |
| 5940 |
\@endpefalse |
| 5941 |
} |
| 5942 |
\fi \fi |
| 5943 |
} |
| 5944 |
\AssignTaggingSocketPlug{kernel/endpe/vmode}{default} |
| 5945 |
% \end{macrocode} |
| 5946 |
% \end{plugdecl} |
| 5947 |
% |
| 5948 |
% \begin{macro}{\para_end:} |
| 5949 |
% If we see a \tn{par} in vmode and a |
| 5950 |
% \struct{\UseStructureName{para/semantic}} is still open we need |
| 5951 |
% to close that. For this we check if a request for \text{@endpe} |
| 5952 |
% was made (but the \tn{par} redefinition got lost due to (bad?) |
| 5953 |
% coding). |
| 5954 |
% \begin{macrocode} |
| 5955 |
\cs_set_protected:Npn \para_end: { |
| 5956 |
\scan_stop: |
| 5957 |
\mode_if_horizontal:TF { |
| 5958 |
\mode_if_inner:F { |
| 5959 |
\tex_unskip:D |
| 5960 |
\hook_use:n{para/end} |
| 5961 |
\@kernel@after@para@end |
| 5962 |
\mode_if_horizontal:TF { |
| 5963 |
\if_int_compare:w 11 = \tex_lastnodetype:D |
| 5964 |
\tex_hskip:D \c_zero_dim |
| 5965 |
\fi: |
| 5966 |
\tex_par:D |
| 5967 |
\hook_use:n{para/after} |
| 5968 |
\@kernel@after@para@after |
| 5969 |
} |
| 5970 |
{ \msg_error:nnnn { hooks }{ para-mode }{end}{horizontal} } |
| 5971 |
} |
| 5972 |
} |
| 5973 |
{ |
| 5974 |
% \end{macrocode} |
| 5975 |
% TODO 2025-07-01. This is not exactly as before, this doesn't insert an \cs{\@endpefalse} |
| 5976 |
% when tagging is active. Check if this a problem. |
| 5977 |
% \begin{macrocode} |
| 5978 |
\UseTaggingSocket{kernel/endpe/vmode}% |
| 5979 |
\tex_par:D |
| 5980 |
} |
| 5981 |
} |
| 5982 |
% \end{macrocode} |
| 5983 |
% Now reset \LaTeXe{} functions to use the changed \cs{para_end:} |
| 5984 |
% \changes{v0.9j}{2025/07/19}{Use \texttt{@@@@} to obtain 2; found by |
| 5985 |
% explcheck analysis} |
| 5986 |
% \TODO{Need to check if \cs{@@@@par} is ever used in a way that the |
| 5987 |
% vmodetagging hook is needed.} |
| 5988 |
% \begin{macrocode} |
| 5989 |
\cs_set_eq:NN \par \para_end: |
| 5990 |
\cs_set_eq:NN \@@@@par \para_end: |
| 5991 |
\cs_set_eq:NN \endgraf \para_end: |
| 5992 |
% \end{macrocode} |
| 5993 |
% |
| 5994 |
% \end{macro} |
| 5995 |
% |
| 5996 |
% |
| 5997 |
% \begin{macro}{\begin} |
| 5998 |
% We need to do a little more than canceling \texttt{@endpe} now. |
| 5999 |
% \begin{macrocode} |
| 6000 |
\protected\def\begin#1{% |
| 6001 |
\UseHook{env/#1/before}% |
| 6002 |
\@ifundefined{#1}% |
| 6003 |
{\def\reserved@a{\@latex@error{Environment~#1~undefined}\@eha}}% |
| 6004 |
{\def\reserved@a{\def\@currenvir{#1}% |
| 6005 |
\edef\@currenvline{\on@line}% |
| 6006 |
\@execute@begin@hook{#1}% |
| 6007 |
\csname #1\endcsname}}% |
| 6008 |
\@ignorefalse |
| 6009 |
\begingroup |
| 6010 |
% \end{macrocode} |
| 6011 |
% The original \LaTeXe{} version did set \cs{@endpefalse} |
| 6012 |
% unconditionally at this point, but this is conceptually wrong |
| 6013 |
% because it prevents the upcoming environment from seeing if |
| 6014 |
% \texttt{@endpe} handling was requested, which matters if tagging |
| 6015 |
% is done. Instead, resetting \texttt{@endpe} should only happen at |
| 6016 |
% the start of block environments after they have evaluate the |
| 6017 |
% current status of this flag. For the same reason it is not |
| 6018 |
% correct to unconditionally end a semantic paragraph here, because |
| 6019 |
% \texttt{@endpe} is \texttt{true} we are in a semantic paragraph |
| 6020 |
% that should continue. |
| 6021 |
% \changes{v0.9q}{2026/04/11}{Do not use \cs{@endpefalse} in |
| 6022 |
% \cs{begin} when tagging} |
| 6023 |
% \begin{macrocode} |
| 6024 |
% \@endpefalse |
| 6025 |
\reserved@a} |
| 6026 |
% \end{macrocode} |
| 6027 |
% \end{macro} |
| 6028 |
% |
| 6029 |
% |
| 6030 |
|
| 6031 |
% |
| 6032 |
% \begin{macro}{\__kernel_list_label_after:n} |
| 6033 |
% If starting the text-unit/text tags got delayed because of a pending label we |
| 6034 |
% have to do it after the label got typeset. |
| 6035 |
% TODO: it should do nothing without tagging that's why there is a test, |
| 6036 |
% this should be better hidden in a tagging socket, but it is not quite clear |
| 6037 |
% how to do this.\fmi{internally this is now a tagging socket, why the outer test then?} |
| 6038 |
% \begin{macrocode} |
| 6039 |
\cs_new_protected:Npn \__kernel_list_label_after:n #1 { |
| 6040 |
\tag_socket_use:nn {block/startpara/direct} { #1 } |
| 6041 |
} |
| 6042 |
% \end{macrocode} |
| 6043 |
% \end{macro} |
| 6044 |
% |
| 6045 |
% |
| 6046 |
% \begin{macro}{\@@_inner_begin:} |
| 6047 |
% Start a block that has an inner structure if it isn't also a list. |
| 6048 |
% This command is tagging specific, it is mapped to \cs{__kernel_displayblock_begin:} |
| 6049 |
% in some tagging recipes. |
| 6050 |
% \begin{macrocode} |
| 6051 |
\cs_new_protected:Npn \@@_inner_begin: { |
| 6052 |
\tagstructbegin{tag=\l_@@_tag_inner_tag_tl} |
| 6053 |
} |
| 6054 |
% \end{macrocode} |
| 6055 |
% \end{macro} |
| 6056 |
% |
| 6057 |
% |
| 6058 |
% \begin{macro}{\@@_inner_end:} |
| 6059 |
% End a block (which isn't also a list). |
| 6060 |
% This command is tagging specific, it is mapped to \cs{__kernel_displayblock_end:} |
| 6061 |
% in some tagging recipes. |
| 6062 |
% \begin{macrocode} |
| 6063 |
\cs_new_protected:Npn \@@_inner_end: { |
| 6064 |
\@@_debug_typeout:n{block-end \on@line} |
| 6065 |
\legacy_if:nT { @endpe } |
| 6066 |
{ |
| 6067 |
\UseTaggingSocket{para/semantic/end} |
| 6068 |
{ \@@_debug_typeout:n{close~ /text-unit \on@line}} |
| 6069 |
} |
| 6070 |
\tagstructend % end inner structure |
| 6071 |
} |
| 6072 |
% \end{macrocode} |
| 6073 |
% \end{macro} |
| 6074 |
% |
| 6075 |
% |
| 6076 |
% |
| 6077 |
% |
| 6078 |
% |
| 6079 |
% |
| 6080 |
% \subsubsection{List tags} |
| 6081 |
% |
| 6082 |
% |
| 6083 |
% \begin{macrocode} |
| 6084 |
\tl_new:N \l__tag_L_tag_tl |
| 6085 |
\tl_set:Nn \l__tag_L_tag_tl {\UseStructureName{block/list}} |
| 6086 |
% \end{macrocode} |
| 6087 |
% \begin{variable}{\l__tag_L_attr_class_tl} |
| 6088 |
% The variable should be set to one of the list attributes \texttt{list}, \texttt{itemize} |
| 6089 |
% \texttt{enumerate} or \texttt{description} declared in latex-lab-namespace. |
| 6090 |
% \begin{macrocode} |
| 6091 |
\tl_new:N\l__tag_L_attr_class_tl |
| 6092 |
\tl_set:Nn \l__tag_L_attr_class_tl {list} |
| 6093 |
% \end{macrocode} |
| 6094 |
% \end{variable} |
| 6095 |
% |
| 6096 |
% |
| 6097 |
% \begin{macro}{\@@_list_begin:} |
| 6098 |
% Start a list \ldots |
| 6099 |
% This command is tagging specific, it is mapped to \cs{__kernel_displayblock_begin:} |
| 6100 |
% in a tagging recipe. |
| 6101 |
% \begin{macrocode} |
| 6102 |
\cs_set:Npn \@@_list_begin: { |
| 6103 |
\tagstructbegin |
| 6104 |
{ |
| 6105 |
tag=\l__tag_L_tag_tl |
| 6106 |
,attribute-class=\l__tag_L_attr_class_tl |
| 6107 |
} |
| 6108 |
} |
| 6109 |
% \end{macrocode} |
| 6110 |
% \end{macro} |
| 6111 |
% |
| 6112 |
% \begin{macro}{\@@_list_item_begin:} |
| 6113 |
% Start tagging a list item. |
| 6114 |
% This command is tagging specific, it is mapped to \cs{__kernel_list_item_begin:} |
| 6115 |
% in a tagging recipe. |
| 6116 |
% \begin{macrocode} |
| 6117 |
\cs_set:Npn \@@_list_item_begin: { |
| 6118 |
\tagstructbegin{tag=\UseStructureName{block/list/item}} |
| 6119 |
} |
| 6120 |
% \end{macrocode} |
| 6121 |
% \end{macro} |
| 6122 |
% |
| 6123 |
% |
| 6124 |
% |
| 6125 |
% |
| 6126 |
% |
| 6127 |
% \begin{macro}{\@@_list_item_end:} |
| 6128 |
% When a list item ends we have to close \struct{\UseStructureName{block/list/body}} and |
| 6129 |
% \struct{LI} but also a \struct{\UseStructureName{para/textblock}} in the special case that the |
| 6130 |
% item material ends in a list (identifiable via \texttt{@endpe}). |
| 6131 |
% This command is tagging specific. |
| 6132 |
% This command is copied to \cs{__kernel_list_item_end:} in the list recipe. |
| 6133 |
% \begin{macrocode} |
| 6134 |
\cs_set:Npn \@@_list_item_end: { |
| 6135 |
\legacy_if:nT { @endpe } |
| 6136 |
{ |
| 6137 |
% \end{macrocode} |
| 6138 |
% \changes{v0.9k}{2025/07/21}{Use tagging socket for text-unit structure} |
| 6139 |
% \begin{macrocode} |
| 6140 |
\UseTaggingSocket{para/semantic/end} |
| 6141 |
{ \@@_debug_typeout:n{Structure-end~ P~ at~ item-end \on@line } } |
| 6142 |
} |
| 6143 |
\tagstructend \tagstructend % end \UseStructureName{block/list/body}, LI |
| 6144 |
} |
| 6145 |
% \end{macrocode} |
| 6146 |
% \end{macro} |
| 6147 |
% |
| 6148 |
% |
| 6149 |
% |
| 6150 |
% \begin{macro}{\@@_list_end:} |
| 6151 |
% Finally, at the list end we have to close the open |
| 6152 |
% \struct{\UseStructureName{block/list/body}}, \struct{LI}, \struct{L}, and possibly a |
| 6153 |
% \struct{\UseStructureName{para/textblock}} if the last item ends with a list. |
| 6154 |
% However, if the user forgot to add an \tn{item} then there will be no |
| 6155 |
% \struct{LI} and \struct{\UseStructureName{block/list/body}} open, so we check for the status |
| 6156 |
% of \texttt{@newlist}. The corresponding no-item error was |
| 6157 |
% generated earlier outside the tagging code. |
| 6158 |
% |
| 6159 |
% One could argue that it doesn't matter if the tagging is wrong |
| 6160 |
% after a \tn{@noitemerr} was issued. However, there is one case |
| 6161 |
% where it isn't an error: In the \env{thebibliography} |
| 6162 |
% environment (which is internally a list) it is often the case |
| 6163 |
% that documents start out with an empty environment, not |
| 6164 |
% containing any \tn{bibitem}s. For that reason \tn{@noitemerr} is |
| 6165 |
% redefined inside that environment to only produce a warning; |
| 6166 |
% hence we have to produce correct tag structures in that case. |
| 6167 |
% \changes{v0.8q}{2024/09/02}{Do not close LI and \UseStructureName{block/list/body} if they |
| 6168 |
% never were opened.} |
| 6169 |
% This command is tagging specific. |
| 6170 |
% This command is copied to \cs{__kernel_displayblock_end:} in the list recipe. |
| 6171 |
% \begin{macrocode} |
| 6172 |
\cs_new_protected:Npn \@@_list_end: { |
| 6173 |
% \end{macrocode} |
| 6174 |
% If \texttt{@newlist} is true (i.e., when we have an error or warning |
| 6175 |
% situation) there is not much to close. |
| 6176 |
% \begin{macrocode} |
| 6177 |
\legacy_if:nF { @newlist } |
| 6178 |
{ |
| 6179 |
\legacy_if:nT { @endpe } |
| 6180 |
{ |
| 6181 |
% \end{macrocode} |
| 6182 |
% \changes{v0.9k}{2025/07/21}{Use tagging socket for text-unit structure} |
| 6183 |
% \begin{macrocode} |
| 6184 |
\UseTaggingSocket{para/semantic/end} |
| 6185 |
{\@@_debug_typeout:n{Structure-end~ text-unit~ at~ list-end \on@line }} |
| 6186 |
} |
| 6187 |
\tagstructend % end \UseStructureName{block/list/body}, |
| 6188 |
\hook_use:n{item/after} |
| 6189 |
\tagstructend % LI |
| 6190 |
} |
| 6191 |
\tagstructend % end L |
| 6192 |
} |
| 6193 |
% \end{macrocode} |
| 6194 |
% \end{macro} |
| 6195 |
% End of tagging related declarations. |
| 6196 |
% |
| 6197 |
% |
| 6198 |
% |
| 6199 |
% \subsubsection{Tagging recipes} |
| 6200 |
% |
| 6201 |
% \changes{v0.9g}{2025-07-01}{a tagging socket for recipe} |
| 6202 |
% \begin{socketdecl}{tagsupport/block/recipe} |
| 6203 |
% A tagging socket to call the tagging recipe. |
| 6204 |
% Declared in lttagging. |
| 6205 |
% \begin{macrocode} |
| 6206 |
\socket_if_exist:nF {tagsupport/block/recipe} |
| 6207 |
{ |
| 6208 |
\NewTaggingSocket{block/recipe}{1} |
| 6209 |
} |
| 6210 |
% \end{macrocode} |
| 6211 |
% \end{socketdecl} |
| 6212 |
% \begin{plugdecl}{default} |
| 6213 |
% \begin{macrocode} |
| 6214 |
\NewTaggingSocketPlug{block/recipe}{default} |
| 6215 |
{ |
| 6216 |
\use:c { @@_recipe_#1: } |
| 6217 |
} |
| 6218 |
\AssignTaggingSocketPlug{block/recipe}{default} |
| 6219 |
% \end{macrocode} |
| 6220 |
% \end{plugdecl} |
| 6221 |
% |
| 6222 |
% \begin{macro}{\@@_recipe_basic:} |
| 6223 |
% The \keyvalue{basic} recipe simply ensures that the block is inside |
| 6224 |
% a \struct{\UseStructureName{para/semantic}} structure and if necessary starts one. When the |
| 6225 |
% block ends and is followed by a blank line the \struct{\UseStructureName{para/semantic}} |
| 6226 |
% structure is closed too, otherwise it remains open and further |
| 6227 |
% text starts with just a \struct{\UseStructureName{para/textblock}} structure. |
| 6228 |
% |
| 6229 |
% There is otherwise no inner structure so |
| 6230 |
% \cs{__kernel_displayblock_begin:} and |
| 6231 |
% \cs{__kernel_displayblock_end:} do nothing---\insttype{blockenv}s with inner |
| 6232 |
% structure use the \keyvalue{standard} or \keyvalue{list} recipe instead. |
| 6233 |
% \begin{macrocode} |
| 6234 |
\cs_new_protected:Npn \@@_recipe_basic: { |
| 6235 |
\cs_set_eq:NN \__kernel_displayblock_beginpar_hmode:w |
| 6236 |
\@@_beginpar_hmode:N |
| 6237 |
\cs_set_eq:NN \__kernel_displayblock_beginpar_vmode: |
| 6238 |
\@@_beginpar_vmode: |
| 6239 |
\let \__kernel_displayblock_begin: \prg_do_nothing: |
| 6240 |
\let \__kernel_displayblock_end: \prg_do_nothing: |
| 6241 |
% \end{macrocode} |
| 6242 |
% End environment \tn{par} handling: |
| 6243 |
% \begin{macrocode} |
| 6244 |
\socket_assign_plug:nn{block/endpe}{on} |
| 6245 |
} |
| 6246 |
% \end{macrocode} |
| 6247 |
% \end{macro} |
| 6248 |
% |
| 6249 |
% \begin{macro}{\@@_recipe_standalone:} |
| 6250 |
% |
| 6251 |
% The \keyvalue{standalone} recipe produces a block that ensures that |
| 6252 |
% a previous \struct{\UseStructureName{para/semantic}} ends and that after the block a new |
| 6253 |
% \struct{\UseStructureName{para/semantic}} starts. |
| 6254 |
% \begin{macrocode} |
| 6255 |
\cs_new_protected:Npn \@@_recipe_standalone: { |
| 6256 |
\cs_set_eq:NN \__kernel_displayblock_beginpar_hmode:w |
| 6257 |
\prg_do_nothing: |
| 6258 |
\cs_set_eq:NN \__kernel_displayblock_beginpar_vmode: |
| 6259 |
\prg_do_nothing: |
| 6260 |
\cs_set_eq:NN \__kernel_displayblock_begin: \@@_inner_begin: |
| 6261 |
\cs_set_eq:NN \__kernel_displayblock_end: \@@_inner_end: |
| 6262 |
% \end{macrocode} |
| 6263 |
% End environment \tn{par} handling: |
| 6264 |
% \changes{v0.9q}{2026/04/11}{Use \cs{@endpefalse} in |
| 6265 |
% \texttt{standalone} recipe} |
| 6266 |
% \begin{macrocode} |
| 6267 |
\@endpefalse |
| 6268 |
\socket_assign_plug:nn{block/endpe}{off} |
| 6269 |
% \end{macrocode} |
| 6270 |
% |
| 6271 |
% \begin{macrocode} |
| 6272 |
\tl_if_empty:NTF \l_@@_tag_name_tl |
| 6273 |
{ \tl_set:Nn \l_@@_tag_inner_tag_tl {Sect} } |
| 6274 |
{ \tl_set_eq:NN \l_@@_tag_inner_tag_tl \l_@@_tag_name_tl } |
| 6275 |
} |
| 6276 |
% \end{macrocode} |
| 6277 |
% \end{macro} |
| 6278 |
% |
| 6279 |
% \begin{macro}{\@@_recipe_standard:} |
| 6280 |
% The \keyvalue{standard} recipe does the following: |
| 6281 |
% \begin{itemize} |
| 6282 |
% \item surround the block with a |
| 6283 |
% \struct{\UseStructureName{para/semantic}} structure if not |
| 6284 |
% already in a \struct{\UseStructureName{para/semantic}}. In |
| 6285 |
% the latter case end the MC and the |
| 6286 |
% \struct{\UseStructureName{para/textblock}} but leave the |
| 6287 |
% \struct{\UseStructureName{para/semantic}} open. |
| 6288 |
% |
| 6289 |
% If we are producing flattened paragraphs, just close any |
| 6290 |
% \struct{\UseStructureName{para/textblock}} but do not open a |
| 6291 |
% \struct{\UseStructureName{para/semantic}}. |
| 6292 |
% |
| 6293 |
% \item Then open an new (inner) structure (by default \struct{Div} |
| 6294 |
% but typically the one specified on the instance). |
| 6295 |
% |
| 6296 |
% \item At the end of the block close the inner structure |
| 6297 |
% (\struct{Div} or explicit one) but leave the |
| 6298 |
% \struct{\UseStructureName{para/semantic}} open to be either |
| 6299 |
% continued or closed due to a following \tn{par}. |
| 6300 |
% \end{itemize} |
| 6301 |
% \begin{macrocode} |
| 6302 |
\cs_new_protected:Npn \@@_recipe_standard: |
| 6303 |
{ |
| 6304 |
\cs_set_eq:NN \__kernel_displayblock_beginpar_hmode:w |
| 6305 |
\@@_beginpar_hmode:N |
| 6306 |
\cs_set_eq:NN \__kernel_displayblock_beginpar_vmode: |
| 6307 |
\@@_beginpar_vmode: |
| 6308 |
\cs_set_eq:NN \__kernel_displayblock_begin: \@@_inner_begin: |
| 6309 |
\cs_set_eq:NN \__kernel_displayblock_end: \@@_inner_end: |
| 6310 |
% \end{macrocode} |
| 6311 |
% End environment \tn{par} handling: |
| 6312 |
% \begin{macrocode} |
| 6313 |
\socket_assign_plug:nn{block/endpe}{on} |
| 6314 |
% \end{macrocode} |
| 6315 |
% |
| 6316 |
% \changes{v0.9g}{2025/06/30}{ (tagging/925)} |
| 6317 |
% \begin{macrocode} |
| 6318 |
\tl_if_empty:NTF \l_@@_tag_name_tl |
| 6319 |
{ \tl_set:Nn \l_@@_tag_inner_tag_tl {\UseStructureName{block/inner}} } |
| 6320 |
{ \tl_set_eq:NN \l_@@_tag_inner_tag_tl \l_@@_tag_name_tl } |
| 6321 |
} |
| 6322 |
% \end{macrocode} |
| 6323 |
% \end{macro} |
| 6324 |
% |
| 6325 |
% |
| 6326 |
% |
| 6327 |
% \begin{macro}{\l_@@_tag_inner_tag_tl} |
| 6328 |
% The tag name that is used if the block has an inner structure. |
| 6329 |
% \begin{macrocode} |
| 6330 |
\tl_new:N \l_@@_tag_inner_tag_tl |
| 6331 |
% \end{macrocode} |
| 6332 |
% \end{macro} |
| 6333 |
% |
| 6334 |
% |
| 6335 |
% |
| 6336 |
% \begin{macro}{\@@_recipe_list:} |
| 6337 |
% The \keyvalue{list} recipe does the following. |
| 6338 |
% \begin{itemize} |
| 6339 |
% \item It opens a |
| 6340 |
% \struct{\UseStructureName{para/semantic}}-structure or keeps |
| 6341 |
% the current one open (only closing the MC). |
| 6342 |
% |
| 6343 |
% \item It then starts a new structure role-mapped to L-structure |
| 6344 |
% and arranges for handling list items, e.g., Li, |
| 6345 |
% \UseStructureName{block/list/label} and |
| 6346 |
% \UseStructureName{block/list/body} structures. |
| 6347 |
% |
| 6348 |
% \item At the end it closes open list structures as needed but |
| 6349 |
% keeps the \struct{\UseStructureName{para/semantic}}-structure |
| 6350 |
% open to continue the paragraph after the list, if necessary. |
| 6351 |
% \end{itemize} |
| 6352 |
% \begin{macrocode} |
| 6353 |
\cs_new_protected:Npn \@@_recipe_list: |
| 6354 |
{ |
| 6355 |
\cs_set_eq:NN \__kernel_displayblock_beginpar_hmode:w |
| 6356 |
\@@_beginpar_hmode:N |
| 6357 |
\cs_set_eq:NN \__kernel_displayblock_beginpar_vmode: |
| 6358 |
\@@_beginpar_vmode: |
| 6359 |
\cs_set_eq:NN \__kernel_displayblock_begin: \@@_list_begin: |
| 6360 |
\cs_set_eq:NN \__kernel_displayblock_end: \@@_list_end: |
| 6361 |
% \end{macrocode} |
| 6362 |
% The next two lines could be done globally, because they are only |
| 6363 |
% called if we do have \tn{item}s, i.e., if we are in a list. It is |
| 6364 |
% therefore also not necessary to reset them in other recipes |
| 6365 |
% (right now---this may change if we get more templates (like |
| 6366 |
% inline lists)). |
| 6367 |
% \begin{macrocode} |
| 6368 |
\cs_set_eq:NN \__kernel_list_item_begin: \@@_list_item_begin: |
| 6369 |
\cs_set_eq:NN \__kernel_list_item_end: \@@_list_item_end: |
| 6370 |
% \end{macrocode} |
| 6371 |
% End environment \tn{par} handling: |
| 6372 |
% \begin{macrocode} |
| 6373 |
\socket_assign_plug:nn{block/endpe}{on} |
| 6374 |
% \end{macrocode} |
| 6375 |
% |
| 6376 |
% Handle the tag name and attribute classes using the key values |
| 6377 |
% from the current list instance. |
| 6378 |
% \begin{macrocode} |
| 6379 |
\tl_if_empty:NTF \l_@@_tag_name_tl |
| 6380 |
{ \tl_set:Ne \l__tag_L_tag_tl {\UseStructureName{block/list}} } |
| 6381 |
{ \tl_set_eq:NN \l__tag_L_tag_tl \l_@@_tag_name_tl } |
| 6382 |
\tl_if_empty:NTF \l_@@_tag_class_tl |
| 6383 |
{ \tl_set:Nn \l__tag_L_attr_class_tl {} } |
| 6384 |
{ \tl_set_eq:NN \l__tag_L_attr_class_tl \l_@@_tag_class_tl } |
| 6385 |
} |
| 6386 |
% \end{macrocode} |
| 6387 |
% \end{macro} |
| 6388 |
% |
| 6389 |
% |
| 6390 |
% |
| 6391 |
% \begin{macrocode} |
| 6392 |
%</package-start> |
| 6393 |
% \end{macrocode} |
| 6394 |
% |
| 6395 |
% |
| 6396 |
% \section[Support code for document-level block environments] |
| 6397 |
% {Support code for document-level block\\ environments} |
| 6398 |
% |
| 6399 |
% |
| 6400 |
% |
| 6401 |
% \subsection{Verbatim-like environments} |
| 6402 |
% |
| 6403 |
% \subsubsection{Helper commands for \env{verbatim} and \env{verbatim*}} |
| 6404 |
% |
| 6405 |
% \begin{macro}{\legacyverbatimsetup} |
| 6406 |
% ^^A |
| 6407 |
% This code is called as part of the \key{final-code} of the |
| 6408 |
% \insttype{blockenv} instance and sets up the special conventions |
| 6409 |
% needed for \env{verbatim} environments. We pass one argument to |
| 6410 |
% differentiate between visible and invisible spaces. |
| 6411 |
% |
| 6412 |
% This code resembles the \LaTeXe{} verbatim implementation with a |
| 6413 |
% slight twist: in \LaTeXe{} each code line was a paragraph using |
| 6414 |
% \tn{leftskip}=\tn{@totalleftmargin}. This was possible because |
| 6415 |
% the whole environment was implemented as a trivlist. As this is |
| 6416 |
% no longer the case setting \tn{leftskip} would alter the layout |
| 6417 |
% of a surrounding list. So instead we need to make sure that the |
| 6418 |
% paragraph end is executed in a group so that any parshape setup |
| 6419 |
% is preserved. |
| 6420 |
% \changes{v0.8x}{2025/01/12}{flattened para inside verbatim using codeline tag} |
| 6421 |
% \begin{macrocode} |
| 6422 |
%<*package-finish> |
| 6423 |
% \end{macrocode} |
| 6424 |
% |
| 6425 |
% \begin{macrocode} |
| 6426 |
%<@@=> |
| 6427 |
\def\legacyverbatimsetup #1 {% |
| 6428 |
\language\l@nohyphenation |
| 6429 |
\@tempswafalse |
| 6430 |
\def\par{% |
| 6431 |
\if@tempswa |
| 6432 |
\leavevmode \null {\@@par}\penalty\interlinepenalty |
| 6433 |
\else |
| 6434 |
\@tempswatrue |
| 6435 |
\ifhmode{\@@par}\penalty\interlinepenalty\fi |
| 6436 |
\fi |
| 6437 |
% \end{macrocode} |
| 6438 |
% Do something at the very beginning of each verbatim line:\fmi{might |
| 6439 |
% also need a hook not just a socket} |
| 6440 |
% \begin{macrocode} |
| 6441 |
\UseSocket{verbatim/startline}% |
| 6442 |
}% |
| 6443 |
\let\do\@makeother \dospecials |
| 6444 |
\obeylines \verbatim@font \@noligs |
| 6445 |
\everypar \expandafter{\the\everypar \unpenalty}% |
| 6446 |
% \end{macrocode} |
| 6447 |
% |
| 6448 |
% \begin{macrocode} |
| 6449 |
\frenchspacing |
| 6450 |
% \end{macrocode} |
| 6451 |
% \fmi{Should next line be hidden in a tagging socket?} |
| 6452 |
% \begin{macrocode} |
| 6453 |
\AssignStructureRole {para/textblock}% |
| 6454 |
{\UseStructureName{block/verbatim/codeline}}% |
| 6455 |
% \end{macrocode} |
| 6456 |
% If the argument is neither \texttt{visible} nor |
| 6457 |
% \texttt{invisible} nothing will happen---tough. |
| 6458 |
% \begin{macrocode} |
| 6459 |
\use:c { @setupverb #1 space } |
| 6460 |
\@vobeyspaces |
| 6461 |
} |
| 6462 |
% \end{macrocode} |
| 6463 |
% \end{macro} |
| 6464 |
% |
| 6465 |
% |
| 6466 |
% \begin{socketdecl}{verbatim/startline} |
| 6467 |
% A socket that is executed at the start of each verbatim line, to |
| 6468 |
% be used, for example, to check for |
| 6469 |
% \verb*=% = when the \pkg{doc} package is |
| 6470 |
% active.\fmi{We might also need a hook for line numbers.} |
| 6471 |
% \begin{macrocode} |
| 6472 |
\NewSocket{verbatim/startline}{0} |
| 6473 |
% \end{macrocode} |
| 6474 |
% \end{socketdecl} |
| 6475 |
% |
| 6476 |
% |
| 6477 |
% |
| 6478 |
% |
| 6479 |
% \begin{macro}{\@setupverbinvisiblespace} |
| 6480 |
% ^^A |
| 6481 |
% In the \pdfTeX{} engine we need to use \tn{pdffakespace} chars |
| 6482 |
% for the invisible spaces. In luatex we do not want this as it |
| 6483 |
% would lead to doubling the number of real space chars. In |
| 6484 |
% dvi-mode we do not want that either: with pdftex it would error, |
| 6485 |
% with xetex it does nothing. \changes{v0.9g}{2025-07-01}{changed |
| 6486 |
% logic} |
| 6487 |
% \begin{macrocode} |
| 6488 |
%<@@=block> |
| 6489 |
\newcommand\@setupverbinvisiblespace{} |
| 6490 |
\bool_lazy_or:nnF |
| 6491 |
{ \sys_if_engine_luatex_p: } |
| 6492 |
{ \sys_if_output_dvi_p: } |
| 6493 |
{ |
| 6494 |
\renewcommand\@setupverbinvisiblespace |
| 6495 |
{\def\@xobeysp{\nobreakspace\pdffakespace}} |
| 6496 |
} |
| 6497 |
% \end{macrocode} |
| 6498 |
% \end{macro} |
| 6499 |
% |
| 6500 |
% The command \cs{@setupverbvisiblespace} is already defined in the kernel. |
| 6501 |
% |
| 6502 |
% |
| 6503 |
% |
| 6504 |
% |
| 6505 |
% \subsubsection{Helper commands for \env{alltt} and \env{alltt*}} |
| 6506 |
% |
| 6507 |
% |
| 6508 |
% \begin{macro}{\legacyallttsetup} |
| 6509 |
% The \env{alltt} environment also needs some special setup. We can |
| 6510 |
% reuse \cs{legacyverbatimsetup} but we have to take out \verb=\=, |
| 6511 |
% \verb={=, and \verb=}= from \cs{dospecials} as they should remain |
| 6512 |
% available with their normal catcodes and adjust \verb='= inside |
| 6513 |
% math. This is lifted straight from the original package code. |
| 6514 |
% \begin{macrocode} |
| 6515 |
%<@@=> |
| 6516 |
\ExplSyntaxOff |
| 6517 |
% \end{macrocode} |
| 6518 |
% |
| 6519 |
% \begin{macrocode} |
| 6520 |
\def\legacyallttsetup #1{% |
| 6521 |
\let\org@prime~% |
| 6522 |
\everymath\expandafter{\the\everymath |
| 6523 |
\catcode`\'=12 \let~\org@prime}% |
| 6524 |
\everydisplay\expandafter{\the\everydisplay |
| 6525 |
\catcode`\'=12 \let~\org@prime}% |
| 6526 |
% \end{macrocode} |
| 6527 |
% This alters \cs{dospecials}: |
| 6528 |
% \begin{macrocode} |
| 6529 |
\let\org@dospecials\dospecials |
| 6530 |
\g@remfrom@specials{\\}% |
| 6531 |
\g@remfrom@specials{\{}% |
| 6532 |
\g@remfrom@specials{\}}% |
| 6533 |
% \end{macrocode} |
| 6534 |
% Then call \cs{legacyverbatimsetup}: |
| 6535 |
% \begin{macrocode} |
| 6536 |
\legacyverbatimsetup {#1}% |
| 6537 |
% \end{macrocode} |
| 6538 |
% And afterwards restore \cs{dospecials:} |
| 6539 |
% \begin{macrocode} |
| 6540 |
\let\dospecials\org@dospecials |
| 6541 |
} |
| 6542 |
% \end{macrocode} |
| 6543 |
% |
| 6544 |
% \begin{macro}{\g@remfrom@specials} |
| 6545 |
% Copied from \pkg{alltt}. |
| 6546 |
% \begin{macrocode} |
| 6547 |
\def\g@remfrom@specials#1{% |
| 6548 |
\def\@new@specials{}% |
| 6549 |
\def\@remove##1{% |
| 6550 |
\ifx##1#1\else |
| 6551 |
\g@addto@macro\@new@specials{\do ##1}\fi}% |
| 6552 |
\let\do\@remove\dospecials |
| 6553 |
\let\dospecials\@new@specials |
| 6554 |
} |
| 6555 |
% \end{macrocode} |
| 6556 |
% |
| 6557 |
% \begin{macrocode} |
| 6558 |
\ExplSyntaxOn |
| 6559 |
%<@@=block> |
| 6560 |
% \end{macrocode} |
| 6561 |
% \end{macro} |
| 6562 |
% \end{macro} |
| 6563 |
% |
| 6564 |
% |
| 6565 |
% |
| 6566 |
% \subsubsection{Helper command for legacy \env{list} environment} |
| 6567 |
% |
| 6568 |
% |
| 6569 |
% \begin{macro}{\legacylistsetup} |
| 6570 |
% ^^A |
| 6571 |
% And here is the extra code for use in the list instance setup |
| 6572 |
% in the key \key{legacy-code}: |
| 6573 |
% \begin{macrocode} |
| 6574 |
\cs_new_protected:Npn \legacylistsetup { |
| 6575 |
% \end{macrocode} |
| 6576 |
% Reset values to defaults: |
| 6577 |
% \begin{macrocode} |
| 6578 |
\dim_zero:N \listparindent |
| 6579 |
\dim_zero:N \rightmargin |
| 6580 |
\dim_zero:N \itemindent |
| 6581 |
% \end{macrocode} |
| 6582 |
% |
| 6583 |
% By default a \env{list} environment is not numbered, but this |
| 6584 |
% happens already in the block template. |
| 6585 |
% \changes{v0.8v}{2024/10/11}{Set the defaults for \tn{@itemlabel}, |
| 6586 |
% \tn{@listctr} and \texttt{@nmbrlist} early in the block code |
| 6587 |
% before the setup code gets executed (tagging/730)} |
| 6588 |
% \begin{macrocode} |
| 6589 |
% \tl_set:Nn \@listctr {} |
| 6590 |
% \legacy_if_set_false:n { @nmbrlist } % needed if lists are nested |
| 6591 |
% \end{macrocode} |
| 6592 |
% By default there is a simple definition for \tn{makelabel}. It can be |
| 6593 |
% overwritten in the second mandatory argument to the list |
| 6594 |
% environment (stored in \cs{l_@@_legacy_env_params_tl}) and |
| 6595 |
% is used if the instance sets the compatibility key to true. |
| 6596 |
% \begin{macrocode} |
| 6597 |
\let\makelabel\@mklab % TODO: customize |
| 6598 |
% \end{macrocode} |
| 6599 |
% Now we use the argument with parameter settings to update some or |
| 6600 |
% all of the above defaults (this holds whatever was put into the |
| 6601 |
% second argument to the \env{list} environment): |
| 6602 |
% \begin{macrocode} |
| 6603 |
\l_@@_legacy_env_params_tl |
| 6604 |
% \end{macrocode} |
| 6605 |
% As we don't know much about this list we can only make a guess about |
| 6606 |
% the nature of the list and the setting of the tag name (default |
| 6607 |
% \keyvalue{list} role-mapped to \struct{L}) and any tag attributes |
| 6608 |
% may have to be overwritten in the optional key/value argument. |
| 6609 |
% But we do have some hints to play with. |
| 6610 |
% \begin{macrocode} |
| 6611 |
\legacy_if:nTF { @nmbrlist } |
| 6612 |
{ \tl_set:Nn \l__tag_L_attr_class_tl {enumerate} } % numbered list |
| 6613 |
{ \tl_if_empty:NTF \@itemlabel |
| 6614 |
{ \tl_set:Nn \l__tag_L_attr_class_tl {list} } % no label |
| 6615 |
{ \tl_set:Nn \l__tag_L_attr_class_tl {itemize} } % unnumbered, |
| 6616 |
% unordered |
| 6617 |
} |
| 6618 |
} |
| 6619 |
% \end{macrocode} |
| 6620 |
% \end{macro} |
| 6621 |
% |
| 6622 |
% |
| 6623 |
% \begin{macro}{\l_@@_legacy_env_params_tl} |
| 6624 |
% The token list in which the declarations from the second argument |
| 6625 |
% of \env{list} are temporarily stored. This is then used in |
| 6626 |
% \cs{legacylistsetup}. |
| 6627 |
% \begin{macrocode} |
| 6628 |
\tl_new:N\l_@@_legacy_env_params_tl |
| 6629 |
% \end{macrocode} |
| 6630 |
% \end{macro} |
| 6631 |
% |
| 6632 |
% |
| 6633 |
% \subsection{Theorem-like environments} |
| 6634 |
% |
| 6635 |
% Theorem-like environments are defined in \LaTeX{} with the help of |
| 6636 |
% \tn{newtheorem} declarations. Internally they used a list with a |
| 6637 |
% single item. Using lists was convenient back then, but in a tagged |
| 6638 |
% document you end up with a strange structure. We therefore alter the |
| 6639 |
% mechanism. |
| 6640 |
% |
| 6641 |
% |
| 6642 |
% \subsubsection{Declarations for theorem-like environments} |
| 6643 |
% |
| 6644 |
% \begin{macro}[no-user-doc]{\newtheorem} |
| 6645 |
% We reimplement the extended \pkg{amsthm} version of the declaration which |
| 6646 |
% also supports a star form indicating that this theorem-like |
| 6647 |
% environment should not be numbered. |
| 6648 |
% \changes{v0.9m}{2025-12-31}{Use an alias counter} |
| 6649 |
% \begin{macrocode} |
| 6650 |
\RenewDocumentCommand \newtheorem { s m o m o } { |
| 6651 |
% \end{macrocode} |
| 6652 |
% Is the environment definable at all? If not there is not much |
| 6653 |
% point in continuing. |
| 6654 |
% \begin{macrocode} |
| 6655 |
\expandafter\@ifdefinable\csname #2\endcsname |
| 6656 |
{ |
| 6657 |
% \end{macrocode} |
| 6658 |
% |
| 6659 |
% If a star was given then there is no need to set up a counter for |
| 6660 |
% this environment. Otherwise we do what \LaTeX2e{} did, except |
| 6661 |
% that we do all the variations in one go, rather than using |
| 6662 |
% \cs{@ynthm}, \cs{@xnthm}, and \cs{@othm}.\fmi{undefined the old |
| 6663 |
% internal commands?} |
| 6664 |
% \begin{macrocode} |
| 6665 |
\IfBooleanF #1 |
| 6666 |
{ |
| 6667 |
\IfNoValueTF {#3} |
| 6668 |
% \end{macrocode} |
| 6669 |
% If there was no counter to use (\verb=#2=) then we set up a |
| 6670 |
% counter with the same name as the environment (\verb=#2=). |
| 6671 |
% \begin{macrocode} |
| 6672 |
{ |
| 6673 |
\@definecounter {#2} |
| 6674 |
% \end{macrocode} |
| 6675 |
% If there was no \enquote{counter within} the counter |
| 6676 |
% representation is simple, otherwise we build it up from the two |
| 6677 |
% counters: |
| 6678 |
% \begin{macrocode} |
| 6679 |
\IfNoValueTF {#5} |
| 6680 |
{ % @ynthm |
| 6681 |
\tl_gset:ce { the #2 } |
| 6682 |
{ |
| 6683 |
\@thmcounter{#2} |
| 6684 |
} |
| 6685 |
} |
| 6686 |
{ % @xnthm |
| 6687 |
\@newctr{#2}[#5] |
| 6688 |
\tl_gset:ce { the #2 } |
| 6689 |
{ |
| 6690 |
\expandafter\noexpand\csname the#5\endcsname |
| 6691 |
\@thmcountersep |
| 6692 |
\@thmcounter{#2} |
| 6693 |
} |
| 6694 |
} |
| 6695 |
} |
| 6696 |
{ % @othm |
| 6697 |
% \end{macrocode} |
| 6698 |
% If we should reuse an existing counter (\verb=#3= was given) we |
| 6699 |
% check that this counter actually exists and if so use it: |
| 6700 |
% \begin{macrocode} |
| 6701 |
\@ifundefined{c@#3} |
| 6702 |
{ \@nocounterr{#3} } |
| 6703 |
{ |
| 6704 |
\newcounteralias{#2}{#3} |
| 6705 |
} |
| 6706 |
} |
| 6707 |
} |
| 6708 |
% \end{macrocode} |
| 6709 |
% With the counter defined we are ready to declare the |
| 6710 |
% environments. There is a slight complication though: the |
| 6711 |
% \enquote{theorem-like} environments have an optional argument |
| 6712 |
% which contains a possible note, but now we also want to use the |
| 6713 |
% first optional argument to hold a key/value list with parameter |
| 6714 |
% settings. We therefore define this argument via \verb/={note}o/ |
| 6715 |
% so that a simple note, if given is assigned to a \key{note} key. |
| 6716 |
% Further processing is then delegated to the command |
| 6717 |
% \cs{ParseLaTeXeTheoremlike} which, after sorting out the argument |
| 6718 |
% situation, eventually calls \cs{BlockEnv}. |
| 6719 |
% \begin{macrocode} |
| 6720 |
\NewDocumentEnvironment{#2}{ ={note}o } |
| 6721 |
{ \ParseLaTeXeTheoremlike {#2} \BooleanFalse {##1} } |
| 6722 |
{ \BlockEnvEnd } |
| 6723 |
% \end{macrocode} |
| 6724 |
% The starred form of the environment suppresses the number so we |
| 6725 |
% pass it \cs{BooleanTrue}, otherwise it is identical to the |
| 6726 |
% previous definition. |
| 6727 |
% \begin{macrocode} |
| 6728 |
\NewDocumentEnvironment{#2*}{ ={note}o } |
| 6729 |
{ \ParseLaTeXeTheoremlike {#2} \BooleanTrue {##1} } |
| 6730 |
{ \BlockEnvEnd } |
| 6731 |
% \end{macrocode} |
| 6732 |
% |
| 6733 |
% Now it is about time to provide all necessary template |
| 6734 |
% instances. They depend on the \cs{theoremstyle} specified by the |
| 6735 |
% user and possibly by a \cs{swapnumbers} declaration. We start by |
| 6736 |
% checking the requested \cs{theoremstyle} (if none was given then |
| 6737 |
% \texttt{plain} is the default and if it is an unknown name we |
| 6738 |
% also revert to \texttt{plain} after issuing a warning). |
| 6739 |
% \begin{macrocode} |
| 6740 |
\IfInstanceExistsF{thmstyle}{\l_@@_thmstyle_tl} |
| 6741 |
{ \@latex@warning{Unknown~ theoremstyle~ |
| 6742 |
'\l_@@_thmstyle_tl'~ using~ 'plain'} |
| 6743 |
\theoremstyle {plain} |
| 6744 |
} |
| 6745 |
% \end{macrocode} |
| 6746 |
% So now we know that \cs{l_@@_thmstyle_tl} holds a valid |
| 6747 |
% style. What we don't know is whether or not there are special |
| 6748 |
% \insttype{block} instances that go with that style (it might be a style |
| 6749 |
% that reuses the \instname{thm-\meta{style}block-...} instances). |
| 6750 |
% \begin{macrocode} |
| 6751 |
\IfInstanceExistsTF{block} { thm- \l_@@_thmstyle_tl -1 } |
| 6752 |
{ \@@_debug_typeout:n{...~ style~ \l_@@_thmstyle_tl\space exists } } |
| 6753 |
{ \@@_debug_typeout:n{...~ style~ \l_@@_thmstyle_tl\space |
| 6754 |
does~ not ~exist;~ 'plain'~ used } } |
| 6755 |
% \end{macrocode} |
| 6756 |
% So here is the \insttype{blockenv} instance for the new |
| 6757 |
% \enquote{theorem-like} environment. It uses a |
| 6758 |
% \insttype{captionedtext} instance for the \key{inner-instance} |
| 6759 |
% which we also have to declare. |
| 6760 |
% \begin{macrocode} |
| 6761 |
\DeclareInstance{blockenv}{#2}{std} |
| 6762 |
{ |
| 6763 |
name = theorem-like |
| 6764 |
,tag-name = \UseStructureName{block/theorem-like} |
| 6765 |
,tag-attr-class = |
| 6766 |
,tagging-recipe = standalone |
| 6767 |
,inner-level-counter = |
| 6768 |
,transparent-level = true |
| 6769 |
,legacy-code = |
| 6770 |
% \end{macrocode} |
| 6771 |
% What block instance to use is determined by checking if a special |
| 6772 |
% one exists or whether we should use \texttt{plain}: |
| 6773 |
% \begin{macrocode} |
| 6774 |
,block-instance:e = thm- |
| 6775 |
\IfInstanceExistsTF{block} |
| 6776 |
{thm- \l_@@_thmstyle_tl -1} |
| 6777 |
{ \l_@@_thmstyle_tl } { plain } |
| 6778 |
,inner-instance-type = captionedtext |
| 6779 |
,inner-instance = #2 |
| 6780 |
% \end{macrocode} |
| 6781 |
% By default the body text is justified, but perhaps we should not |
| 6782 |
% set anything here and use whatever is current.\fmi{decide} |
| 6783 |
% \begin{macrocode} |
| 6784 |
,para-instance = justify |
| 6785 |
} |
| 6786 |
% \end{macrocode} |
| 6787 |
% The \insttype{captionedtext} instance is simple: the counter, if |
| 6788 |
% present, is either argument \texttt{\#2} or \texttt{\#3}; the \key{title} |
| 6789 |
% receives argument \texttt{\#4}, and the \key{style} to use is |
| 6790 |
% stored in \cs{l_@@_thmstyle_tl}. If \cs{swapnumbers} was |
| 6791 |
% requested we use a style variant with the suffix \texttt{-swap} appended. |
| 6792 |
% \begin{macrocode} |
| 6793 |
\DeclareInstance{captionedtext}{#2}{thmlike} |
| 6794 |
{ |
| 6795 |
% \end{macrocode} |
| 6796 |
% The counter to use is either none or \texttt{\#2} |
| 6797 |
% based on the arguments given: |
| 6798 |
% \begin{macrocode} |
| 6799 |
,counter:e = \IfBooleanF #1 { #2 } |
| 6800 |
,title = #4 |
| 6801 |
,style:e = \l_@@_thmstyle_tl |
| 6802 |
\bool_if:NT \l_@@_swap_number_bool {-swap} |
| 6803 |
} |
| 6804 |
% \end{macrocode} |
| 6805 |
% We already know that the style \cs{l_@@_thmstyle_tl} exists, since |
| 6806 |
% we have tested that earlier, but we don't know if that is also |
| 6807 |
% true for the \texttt{-swap} variant. So we have to check that and |
| 6808 |
% declare it if necessary. |
| 6809 |
% \begin{macrocode} |
| 6810 |
\bool_if:NT \l_@@_swap_number_bool { |
| 6811 |
\IfInstanceExistsF{thmstyle}{\l_@@_thmstyle_tl -swap} |
| 6812 |
{ |
| 6813 |
% \end{macrocode} |
| 6814 |
% If it doesn't exist we first make a copy of the base instance. |
| 6815 |
% \begin{macrocode} |
| 6816 |
\DeclareInstanceCopy{thmstyle} |
| 6817 |
{\l_@@_thmstyle_tl -swap} |
| 6818 |
{\l_@@_thmstyle_tl} |
| 6819 |
% \end{macrocode} |
| 6820 |
% Then we retrieve the value of the \key{order} key from that |
| 6821 |
% instance which is a clist. |
| 6822 |
% \begin{macrocode} |
| 6823 |
\clist_set:Ne \l_@@_order_clist |
| 6824 |
{ \InstanceValue { thmstyle } |
| 6825 |
{ \l_@@_thmstyle_tl } |
| 6826 |
{ order } |
| 6827 |
} |
| 6828 |
% \end{macrocode} |
| 6829 |
% Then we step through this clist and build a new one in |
| 6830 |
% \cs{l_@@_tmp_clist} with the \texttt{title} and \texttt{number} |
| 6831 |
% swapped. That is done under the assumption that both actually |
| 6832 |
% exist in the clist which would be the case if the instance was |
| 6833 |
% declared with \cs{newtheoremstyle}, i.e., for legacy setups. |
| 6834 |
% \begin{macrocode} |
| 6835 |
\clist_clear:N \l_@@_tmp_clist |
| 6836 |
\clist_map_inline:Nn \l_@@_order_clist |
| 6837 |
{ |
| 6838 |
\clist_put_right:Ne \l_@@_tmp_clist { |
| 6839 |
\str_case:nnF {##1} |
| 6840 |
{ {title} {number} |
| 6841 |
{number} {title} } |
| 6842 |
{##1} |
| 6843 |
} |
| 6844 |
} |
| 6845 |
% \end{macrocode} |
| 6846 |
% Once that is done we put the new value for \key{order} in the new |
| 6847 |
% instance. |
| 6848 |
% \begin{macrocode} |
| 6849 |
\EditInstance {thmstyle}{\l_@@_thmstyle_tl -swap} |
| 6850 |
{ order:e = \l_@@_tmp_clist } |
| 6851 |
} |
| 6852 |
} |
| 6853 |
} |
| 6854 |
} |
| 6855 |
% \end{macrocode} |
| 6856 |
% \end{macro} |
| 6857 |
% |
| 6858 |
% |
| 6859 |
% |
| 6860 |
% |
| 6861 |
% |
| 6862 |
% \begin{macro}{\ParseLaTeXeTheoremlike} |
| 6863 |
% The arguments to \cs{ParseLaTeXeTheoremlike} are as follows: |
| 6864 |
% \begin{itemize} |
| 6865 |
% \item[\#1:] instance name to use (of type \enquote{blockenv}) |
| 6866 |
% \item[\#2:] unnumbered? boolean normally provided by using the star |
| 6867 |
% form of the environment |
| 6868 |
% \item[\#3:] key/val for layout adjustments settings provided in the |
| 6869 |
% optional argument of the \enquote{theorem-like} |
| 6870 |
% environment. If a note to the theorem was given in that argument, |
| 6871 |
% then it has been turned into \verb=note={...}= |
| 6872 |
% \end{itemize} |
| 6873 |
% To be able to pick up the \key{note}, if provided, we make the |
| 6874 |
% following declaration: |
| 6875 |
% \begin{macrocode} |
| 6876 |
\keys_define:nn {blockenv} { |
| 6877 |
, note .tl_set:N = \l_@@_note_tl |
| 6878 |
, note .groups:n = { interface } |
| 6879 |
} |
| 6880 |
% \end{macrocode} |
| 6881 |
% |
| 6882 |
% \begin{macrocode} |
| 6883 |
\cs_new_protected:Npn \ParseLaTeXeTheoremlike #1 #2 #3 { |
| 6884 |
% |
| 6885 |
% \@@_debug_typeout:n{Parse~#1.~ Arguments~ found:~ \IfBooleanT{#2}{*} |
| 6886 |
% \IfValueT{#3}{[\exp_not:n{#3}]}} |
| 6887 |
% |
| 6888 |
% \end{macrocode} |
| 6889 |
% Normally, no note is provided, so that's the starting point: |
| 6890 |
% \begin{macrocode} |
| 6891 |
\tl_set:Nn \l_@@_note_tl { \NoValue } |
| 6892 |
% \end{macrocode} |
| 6893 |
% Then we check \texttt{\#3} if it contains a key/val list |
| 6894 |
% containing \key{note}. This then sets \cs{l_@@_note_tl} and puts |
| 6895 |
% all other key/vals in \cs{l_@@_instance_keys_tl}. Otherwise the |
| 6896 |
% complete key/val list ends up there. |
| 6897 |
% \begin{macrocode} |
| 6898 |
\IfNoValueTF { #3 } |
| 6899 |
{ \tl_clear:N \l_@@_instance_keys_tl } |
| 6900 |
{ \keys_set_groups:nnnN {blockenv} {interface} { #3 } |
| 6901 |
\l_@@_instance_keys_tl } |
| 6902 |
% \end{macrocode} |
| 6903 |
% We are now ready to invoke the \insttype{blockenv} instance for |
| 6904 |
% \texttt{\#1} but we need to expand some of the values first, |
| 6905 |
% hence the \cs{use:e}. |
| 6906 |
% \begin{macrocode} |
| 6907 |
\use:e { |
| 6908 |
\exp_not:N \BlockEnv { #1 } |
| 6909 |
{ \exp_not:o \l_@@_instance_keys_tl } |
| 6910 |
{ #2 } |
| 6911 |
{ \exp_not:o \l_@@_note_tl } |
| 6912 |
} |
| 6913 |
% \end{macrocode} |
| 6914 |
% We don't have any use for the last argument (the sub-caption) in |
| 6915 |
% the standard setup, so we pass \cs{NoValue}. |
| 6916 |
% \begin{macrocode} |
| 6917 |
\NoValue |
| 6918 |
} |
| 6919 |
% \end{macrocode} |
| 6920 |
% \end{macro} |
| 6921 |
% |
| 6922 |
% |
| 6923 |
% |
| 6924 |
% \begin{macro}{\swapnumbers} |
| 6925 |
% Beside declaring theorem-like environments with \cs{newtheorem} |
| 6926 |
% and \cs{theoremstyle}, the \pkg{amsthm} package also introduced |
| 6927 |
% \cs{swapnumbers} to swap title and number in all environments |
| 6928 |
% (because that is a common requirement). The new implementation |
| 6929 |
% supports this approach as well. |
| 6930 |
% |
| 6931 |
% It is implemented with a boolean \cs{l_@@_swap_number_bool} which |
| 6932 |
% is toggled by \cs{swapnumbers}. |
| 6933 |
% \begin{macrocode} |
| 6934 |
\bool_new:N \l_@@_swap_number_bool |
| 6935 |
\cs_new_protected:Npn \swapnumbers { \bool_set_inverse:N \l_@@_swap_number_bool } |
| 6936 |
% \end{macrocode} |
| 6937 |
% \end{macro} |
| 6938 |
% |
| 6939 |
% |
| 6940 |
% |
| 6941 |
% |
| 6942 |
% |
| 6943 |
% |
| 6944 |
% |
| 6945 |
% |
| 6946 |
% |
| 6947 |
% |
| 6948 |
% \begin{macro}{\newtheoremstyle} |
| 6949 |
% The \cs{newtheoremstyle} declaration was originally provided in |
| 6950 |
% the \pkg{amsthm} package. It has 9 mandatory arguments that sets |
| 6951 |
% some aspects of theorem styles. We map those to the template |
| 6952 |
% mechanism and generate \insttype{thmstyle} instances from them. |
| 6953 |
% |
| 6954 |
% \cs{newtheoremstyle} has a bunch of argument conventions that |
| 6955 |
% haven't been fully implemented yet, e.g., \texttt{\#8} can be a |
| 6956 |
% blank (meaning normal word space or \cs{newline}) or a skip. Those |
| 6957 |
% should eventually also be covered.\fmi{extend} |
| 6958 |
% \begin{macrocode} |
| 6959 |
\cs_set_protected:Npn \newtheoremstyle #1#2#3#4#5#6#7#8#9 { |
| 6960 |
% \end{macrocode} |
| 6961 |
% First we build a \insttype{thmstyle} instance: |
| 6962 |
% \changes{v0.9n}{2026/02/01}{Argument applied to the wrong keys (tagging/1202)} |
| 6963 |
% \begin{macrocode} |
| 6964 |
\DeclareInstance{thmstyle}{#1}{std}{ |
| 6965 |
,caption-decls = {#6} |
| 6966 |
,before-hspace:e = \tl_if_empty:nTF{#5}{0pt}{#5} |
| 6967 |
,body-decls = {#4} |
| 6968 |
,punct = {#7} |
| 6969 |
,order = {title, space, number, space, note, punct} |
| 6970 |
,number-decls = \upshape |
| 6971 |
,note-decls = \upshape\mdseries |
| 6972 |
% \end{macrocode} |
| 6973 |
% This setting doesn't cover all syntax possibilities. |
| 6974 |
% \begin{macrocode} |
| 6975 |
,after-hspace:e = \tl_if_empty:nTF{#8}{0pt} |
| 6976 |
{\tl_if_blank:nTF{#8}{3.3pt}{#8}} |
| 6977 |
} |
| 6978 |
% \end{macrocode} |
| 6979 |
% If \texttt{\#2} or \texttt{\#3} are not empty we also have to set |
| 6980 |
% up a \insttype{block} instance to account for the fact that |
| 6981 |
% special vertical spacing is requested: |
| 6982 |
% \begin{macrocode} |
| 6983 |
\tl_if_empty:nF { #2#3 } |
| 6984 |
{ |
| 6985 |
\DeclareInstance{block}{thm-#1-1}{std}{ |
| 6986 |
,begin-vspace:e = \tl_if_empty:nTF{#2}{0pt}{#2} |
| 6987 |
,end-vspace:e = \tl_if_empty:nTF{#3}{0pt}{#3} |
| 6988 |
,left-margin = 0pt |
| 6989 |
,para-indent = \parindent |
| 6990 |
,para-vspace = \parskip |
| 6991 |
} |
| 6992 |
% \end{macrocode} |
| 6993 |
% As elsewhere we provide two levels. |
| 6994 |
% \begin{macrocode} |
| 6995 |
\DeclareInstanceCopy{block}{thm-#1-2}{thm-#1-1} |
| 6996 |
} |
| 6997 |
% \end{macrocode} |
| 6998 |
% More complicated is argument \texttt{\#9}. If not empty it can |
| 6999 |
% contain \cs{thmname}, \cs{thmnumber}, and/or \cs{thmnote} to |
| 7000 |
% define the layout of the theorem caption. All the spacing has to |
| 7001 |
% be given inside the arguments of these commands which means that |
| 7002 |
% this doesn't work together with \cs{swapnumbers}, but this is the |
| 7003 |
% way \pkg{amsthm} was defined. If the instances are manually |
| 7004 |
% defined then it is easy to make them work with and without a |
| 7005 |
% \cs{swapnumbers} declaration. So basically, this here is good for |
| 7006 |
% a subset of cases and for backwards compatibility with |
| 7007 |
% \pkg{amsthm}. |
| 7008 |
% |
| 7009 |
% The approach used doesn't cover all circumstances, e.g., if the |
| 7010 |
% argument contains low-level programming on top of the interface |
| 7011 |
% commands that the translation below will fail, but most existing |
| 7012 |
% code should work and the rest would need a replacement using |
| 7013 |
% instances that are directly set up. |
| 7014 |
% \begin{macrocode} |
| 7015 |
\tl_if_empty:oF { \exp_not:n{#9} } |
| 7016 |
{ |
| 7017 |
% \end{macrocode} |
| 7018 |
% Give special definitions for the commands and then expand |
| 7019 |
% \texttt{\#9} and use the result to edit the instance we defined |
| 7020 |
% earlier. |
| 7021 |
% \begin{macrocode} |
| 7022 |
\cs_set:Npn \thmname ##1 {title-format={{\exp_not:n{##1}}},} |
| 7023 |
\cs_set:Npn \thmnumber ##1 {number-format={{\exp_not:n{##1}}},} |
| 7024 |
\cs_set:Npn \thmnote ##1 {note-format={{\exp_not:n{##1}}},} |
| 7025 |
\cs_set:Npn \@@_tmp:w ##1##2##3 { |
| 7026 |
\exp_args:Nnne \EditInstance{thmstyle}{#1}{#9}} |
| 7027 |
\@@_tmp:w {##1} {##1} {##1} |
| 7028 |
% \end{macrocode} |
| 7029 |
% We then also use the commands to deduce a suitable \key{order} |
| 7030 |
% and put that into the instance as well. |
| 7031 |
% \begin{macrocode} |
| 7032 |
\cs_set:Npn \thmname ##1 {title,} |
| 7033 |
\cs_set:Npn \thmnumber ##1 {number,} |
| 7034 |
\cs_set:Npn \thmnote ##1 {note,} |
| 7035 |
\cs_set:Npn \@@_tmp:w##1##2##3 { |
| 7036 |
\exp_args:Nnne \EditInstance{thmstyle}{#1}{order={#9 punct}}} |
| 7037 |
\@@_tmp:w {##1} {##1} {##1} |
| 7038 |
} |
| 7039 |
% \end{macrocode} |
| 7040 |
% If block tracing is turned on we show the final result: |
| 7041 |
% \begin{macrocode} |
| 7042 |
\@@_debug:n { \ShowInstanceValues{thmstyle}{#1} } |
| 7043 |
} |
| 7044 |
% \end{macrocode} |
| 7045 |
% \end{macro} |
| 7046 |
% |
| 7047 |
% |
| 7048 |
% |
| 7049 |
% |
| 7050 |
% |
| 7051 |
% \subsubsection{Supporting QED in proofs} |
| 7052 |
% |
| 7053 |
% The \pkg{amsthm} package contains some elaborate code to support |
| 7054 |
% placing a QED symbol into the proof (by default at the end, but |
| 7055 |
% alternatively manually placed with \cs{qedhere}). This code is |
| 7056 |
% simply lifted and not adjusted in any way for now (and therefore |
| 7057 |
% also not documented---see the \pkg{amsthm} package for |
| 7058 |
% documentation for now). |
| 7059 |
% |
| 7060 |
% \changes{v0.9n}{2026/02/01}{Stray definition of \cs{math@qedhere} removed (taggging/1203)} |
| 7061 |
% \begin{macrocode} |
| 7062 |
\ExplSyntaxOff |
| 7063 |
\def\math@qedhere{% |
| 7064 |
\@ifundefined{\@currenvir @qed}{% |
| 7065 |
\qed@warning\quad\hbox{\qedsymbol}% |
| 7066 |
}{% |
| 7067 |
\@xp\aftergroup\csname\@currenvir @qed\endcsname |
| 7068 |
}% |
| 7069 |
} |
| 7070 |
\def\displaymath@qed{% |
| 7071 |
\relax |
| 7072 |
\ifmmode |
| 7073 |
\ifinner \aftergroup\linebox@qed |
| 7074 |
\else |
| 7075 |
\eqno |
| 7076 |
\let\eqno\relax \let\leqno\relax \let\veqno\relax |
| 7077 |
\hbox{\qedsymbol}% |
| 7078 |
\fi |
| 7079 |
\else |
| 7080 |
\aftergroup\linebox@qed |
| 7081 |
\fi |
| 7082 |
} |
| 7083 |
\expandafter\let\csname equation*@qed\endcsname\displaymath@qed |
| 7084 |
\def\equation@qed{% |
| 7085 |
\iftagsleft@ |
| 7086 |
\hbox{\phantom{\quad\qedsymbol}}% |
| 7087 |
\gdef\alt@tag{% |
| 7088 |
\rlap{\hbox to\displaywidth{\hfil\qedsymbol}}% |
| 7089 |
\global\let\alt@tag\@empty |
| 7090 |
}% |
| 7091 |
\else |
| 7092 |
\gdef\alt@tag{% |
| 7093 |
\global\let\alt@tag\@empty |
| 7094 |
\vtop{\ialign{\hfil####\cr |
| 7095 |
\tagform@\theequation\cr |
| 7096 |
\qedsymbol\cr}}% |
| 7097 |
% \end{macrocode} |
| 7098 |
% The original code in \pkg{amsthm} only contained |
| 7099 |
% \verb=\setbox\z@= at this point to remove \cs{hbox} produced by |
| 7100 |
% \cs{maketag@@@@@@}. However, when the sockets for the tagging are |
| 7101 |
% added this doesn't work any more because they come between the |
| 7102 |
% \cs{setbox} and the \cs{hbox}. We therefore set |
| 7103 |
% \texttt{measuring@} to true so that the branch without the |
| 7104 |
% sockets is used. |
| 7105 |
% \changes{v0.9o}{2026/02/05}{Add \cs{measuring@true} before grabbing |
| 7106 |
% the equation tag box (tagging/1037)} |
| 7107 |
% \begin{macrocode} |
| 7108 |
\measuring@true |
| 7109 |
\setbox\z@ |
| 7110 |
}% |
| 7111 |
\fi |
| 7112 |
} |
| 7113 |
\def\qed@tag{% |
| 7114 |
\global\tag@true \nonumber |
| 7115 |
&\omit\setboxz@h {\strut@ \qedsymbol}\tagsleft@false |
| 7116 |
\place@tag@gather |
| 7117 |
\kern-\tabskip |
| 7118 |
\ifst@rred \else \global\@eqnswtrue \fi \global\advance\row@\@ne \cr |
| 7119 |
} |
| 7120 |
\def\split@qed{% |
| 7121 |
\def\endsplit{\crcr\egroup \egroup \ctagsplit@false \rendsplit@ |
| 7122 |
\aftergroup\align@qed |
| 7123 |
}% |
| 7124 |
} |
| 7125 |
\def\align@qed{% |
| 7126 |
\ifmeasuring@ \tag*{\qedsymbol}% |
| 7127 |
\else \let\math@cr@@@\qed@tag |
| 7128 |
\fi |
| 7129 |
} |
| 7130 |
\expandafter\let\csname align*@qed\endcsname\align@qed |
| 7131 |
\expandafter\let\csname gather*@qed\endcsname\align@qed |
| 7132 |
% |
| 7133 |
\DeclareRobustCommand{\qed}{% |
| 7134 |
\ifmmode \mathqed |
| 7135 |
\else |
| 7136 |
\leavevmode\unskip\penalty9999 \hbox{}\nobreak\hfill |
| 7137 |
\quad\hbox{\qedsymbol}% |
| 7138 |
\fi |
| 7139 |
}% |
| 7140 |
\let\QED@stack\@empty |
| 7141 |
\let\qed@elt\relax |
| 7142 |
\newcommand{\pushQED}[1]{% |
| 7143 |
\toks@{\qed@elt{#1}}\@temptokena\expandafter{\QED@stack}% |
| 7144 |
\xdef\QED@stack{\the\toks@\the\@temptokena}% |
| 7145 |
}% |
| 7146 |
\newcommand{\popQED}{% |
| 7147 |
\begingroup\let\qed@elt\popQED@elt \QED@stack\relax\relax\endgroup |
| 7148 |
}% |
| 7149 |
\def\popQED@elt#1#2\relax{#1\gdef\QED@stack{#2}}% |
| 7150 |
\newcommand{\qedhere}{% |
| 7151 |
\begingroup \let\mathqed\math@qedhere |
| 7152 |
\let\qed@elt\setQED@elt \QED@stack\relax\relax \endgroup |
| 7153 |
}% |
| 7154 |
\def\setQED@elt#1#2\relax{% |
| 7155 |
\ifmeasuring@ |
| 7156 |
\else \iffirstchoice@ \gdef\QED@stack{\qed@elt{}#2}\fi |
| 7157 |
\fi |
| 7158 |
#1% |
| 7159 |
}% |
| 7160 |
\def\qed@warning{% |
| 7161 |
\PackageWarning{amsthm}{The \@nx\qedhere command may not work |
| 7162 |
correctly here}% |
| 7163 |
}% |
| 7164 |
\newcommand{\mathqed}{\quad\hbox{\qedsymbol}}% |
| 7165 |
\DeclareRobustCommand{\qed}{% |
| 7166 |
\ifmmode \mathqed |
| 7167 |
\else |
| 7168 |
\leavevmode\unskip\penalty9999 \hbox{}\nobreak\hfill |
| 7169 |
\quad\hbox{\qedsymbol}% |
| 7170 |
\fi |
| 7171 |
} |
| 7172 |
\newcommand{\openbox}{\leavevmode |
| 7173 |
\hbox to.77778em{% |
| 7174 |
\hfil\vrule |
| 7175 |
\vbox to.675em{\hrule width.6em\vfil\hrule}% |
| 7176 |
\vrule\hfil}} |
| 7177 |
\providecommand{\qedsymbol}{\openbox} |
| 7178 |
\ExplSyntaxOn |
| 7179 |
% \end{macrocode} |
| 7180 |
% |
| 7181 |
% |
| 7182 |
% |
| 7183 |
% |
| 7184 |
% |
| 7185 |
% |
| 7186 |
% \section{Support for other packages and classes} |
| 7187 |
% |
| 7188 |
% \subsection{Replacement for \pkg{alltt}} |
| 7189 |
% |
| 7190 |
% The tools package \pkg{alltt} by Leslie Lamport has been |
| 7191 |
% completely implemented using the template approach and is |
| 7192 |
% therefore no longer necessary. In fact it has also been extended |
| 7193 |
% by providing \env{alltt*}. |
| 7194 |
% \begin{macrocode} |
| 7195 |
\declare@file@substitution{alltt.sty}{null.tex} |
| 7196 |
% \end{macrocode} |
| 7197 |
% |
| 7198 |
% |
| 7199 |
% \subsection{Replacement for \pkg{amsthm}} |
| 7200 |
% |
| 7201 |
% The \pkg{amsthm} package is basically supported out of the box (though there |
| 7202 |
% are currently still a few limitation with \cs{newtheoremstyle} and |
| 7203 |
% perhaps also in other places). So this here is a bit premature, |
| 7204 |
% but for now we disable loading \pkg{amsthm} and wait to see how |
| 7205 |
% far this gets us. |
| 7206 |
% We may have to provide a bit more for better compatibility. |
| 7207 |
% \begin{macrocode} |
| 7208 |
\declare@file@substitution{amsthm.sty}{null.tex} |
| 7209 |
% \end{macrocode} |
| 7210 |
% |
| 7211 |
% |
| 7212 |
% |
| 7213 |
% \subsection{Support for \cls{amsart} and \cls{amsbook} classes} |
| 7214 |
% |
| 7215 |
% Unfortunately, the \cls{amsart} class contains a full |
| 7216 |
% implementation of \pkg{amsthm} inside the class (why ever) |
| 7217 |
% and they use \cs{newcommand}, sigh. |
| 7218 |
% |
| 7219 |
% Thus, to make the new code work with this class we have to hide |
| 7220 |
% some definitions, load the class and only afterwards restore our |
| 7221 |
% own versions. |
| 7222 |
% |
| 7223 |
% So first save some of the problematical definitions under some |
| 7224 |
% other names: |
| 7225 |
% \begin{macrocode} |
| 7226 |
\let \amsnewtheorem \newtheorem |
| 7227 |
\let \amsnewtheoremstyle \newtheoremstyle |
| 7228 |
\let \amstheoremstyle \theoremstyle |
| 7229 |
\let \amsproof \proof |
| 7230 |
\let \amsendproof \endproof |
| 7231 |
% \end{macrocode} |
| 7232 |
% |
| 7233 |
% Then undefine them just before the class gets loaded (quite a handful): |
| 7234 |
% \begin{macrocode} |
| 7235 |
\AddToHook{class/amsart/before}[block]{ |
| 7236 |
\let \newtheoremstyle \relax |
| 7237 |
\let \theoremstyle \relax |
| 7238 |
% \end{macrocode} |
| 7239 |
% |
| 7240 |
% \begin{macrocode} |
| 7241 |
\let \proof \relax |
| 7242 |
\let \endproof \relax |
| 7243 |
% \end{macrocode} |
| 7244 |
% |
| 7245 |
% \begin{macrocode} |
| 7246 |
\let \pushQED \relax |
| 7247 |
\let \popQED \relax |
| 7248 |
\let \qedhere \relax |
| 7249 |
\let \mathqed \relax |
| 7250 |
\let \openbox \relax |
| 7251 |
} |
| 7252 |
% \end{macrocode} |
| 7253 |
% Same for \cls{amsbook} and \cls{amsproc}: |
| 7254 |
% \begin{macrocode} |
| 7255 |
\AddToHook{class/amsbook/before}[block]{ |
| 7256 |
\let \newtheoremstyle \relax |
| 7257 |
\let \theoremstyle \relax |
| 7258 |
\let \proof \relax |
| 7259 |
\let \endproof \relax |
| 7260 |
\let \pushQED \relax |
| 7261 |
\let \popQED \relax |
| 7262 |
\let \qedhere \relax |
| 7263 |
\let \mathqed \relax |
| 7264 |
\let \openbox \relax |
| 7265 |
} |
| 7266 |
% \end{macrocode} |
| 7267 |
% \begin{macrocode} |
| 7268 |
\AddToHook{class/amsproc/before}[block]{ |
| 7269 |
\let \newtheoremstyle \relax |
| 7270 |
\let \theoremstyle \relax |
| 7271 |
\let \proof \relax |
| 7272 |
\let \endproof \relax |
| 7273 |
\let \pushQED \relax |
| 7274 |
\let \popQED \relax |
| 7275 |
\let \qedhere \relax |
| 7276 |
\let \mathqed \relax |
| 7277 |
\let \openbox \relax |
| 7278 |
} |
| 7279 |
% \end{macrocode} |
| 7280 |
% And once the class is loaded restore our versions again. Note |
| 7281 |
% that we don't have to restored all the QED-related commands as |
| 7282 |
% ours are identical to those defined by the AMS. |
| 7283 |
% \begin{macrocode} |
| 7284 |
\AddToHook{class/amsart/after}[block]{ |
| 7285 |
\let \newtheorem \amsnewtheorem |
| 7286 |
\let \newtheoremstyle \amsnewtheoremstyle |
| 7287 |
\let \theoremstyle \amstheoremstyle |
| 7288 |
\let \proof \amsproof |
| 7289 |
\let \endproof \amsendproof |
| 7290 |
} |
| 7291 |
% \end{macrocode} |
| 7292 |
% |
| 7293 |
% \begin{macrocode} |
| 7294 |
\AddToHook{class/amsbook/after}[block]{ |
| 7295 |
\let \newtheorem \amsnewtheorem |
| 7296 |
\let \newtheoremstyle \amsnewtheoremstyle |
| 7297 |
\let \theoremstyle \amstheoremstyle |
| 7298 |
\let \proof \amsproof |
| 7299 |
\let \endproof \amsendproof |
| 7300 |
} |
| 7301 |
% \end{macrocode} |
| 7302 |
% |
| 7303 |
% \begin{macrocode} |
| 7304 |
\AddToHook{class/amsproc/after}[block]{ |
| 7305 |
\let \newtheorem \amsnewtheorem |
| 7306 |
\let \newtheoremstyle \amsnewtheoremstyle |
| 7307 |
\let \theoremstyle \amstheoremstyle |
| 7308 |
\let \proof \amsproof |
| 7309 |
\let \endproof \amsendproof |
| 7310 |
} |
| 7311 |
% \end{macrocode} |
| 7312 |
% |
| 7313 |
% |
| 7314 |
% |
| 7315 |
% |
| 7316 |
% |
| 7317 |
% \subsection{Support for the \pkg{enumitem} interfaces} |
| 7318 |
% |
| 7319 |
% The current implementation incorporates most features of |
| 7320 |
% \pkg{enumitem}. The plan is that the enumitem interfaces are |
| 7321 |
% either natively available or are emulated and mapped to new |
| 7322 |
% interfaces, so that documents using \pkg{enumitem} work |
| 7323 |
% seamlessly. |
| 7324 |
% |
| 7325 |
% Most (or even all of the \pkg{enumitem} keys have gotten new |
| 7326 |
% names, so there the task is to map old names to new names. One |
| 7327 |
% question to decide here is which (if any) of the original keys |
| 7328 |
% should remain natively available even if \pkg{enumitem} is not |
| 7329 |
% loaded, and which should only be supported if the document |
| 7330 |
% explicitly loads \pkg{enumitem}, i.e., support them only for |
| 7331 |
% compatibility with old documents. Providing the full set by |
| 7332 |
% default means one ends up with a fairly inconsistent interface, |
| 7333 |
% but not providing some of them may result in people unnecessarily |
| 7334 |
% loading \pkg{enumitem} in new documents just to get at, say, |
| 7335 |
% \key{nosep}.\fmi{decide} |
| 7336 |
% |
| 7337 |
% The \pkg{enumitem} package also provides declarations to build |
| 7338 |
% out new lists and adjust the layout of existing list using |
| 7339 |
% commands like \cs{newlist} or \cs{setlist}. |
| 7340 |
% With the new implementation this is normally done differently, |
| 7341 |
% e.g., defining instances and simple document level commands via |
| 7342 |
% \cs{SimpleBlockEnv}, etc. However, we probably also want a |
| 7343 |
% declaration such as \cs{newlist} (same name?) to provide a simple |
| 7344 |
% way to make this happen in the document preamble in one go. |
| 7345 |
% |
| 7346 |
% I'm less sure about \cs{setlist} at least as far as its optional |
| 7347 |
% argument is concerned (even though we have to support it in an |
| 7348 |
% emulation.\fmi{decide} |
| 7349 |
% |
| 7350 |
% We put the code that emulates \pkg{enumitem} in a separate file |
| 7351 |
% to be loaded instead of the original package, but eventually some |
| 7352 |
% of the code from there has to move back to the kernel to be |
| 7353 |
% always present. |
| 7354 |
% |
| 7355 |
% \begin{macrocode} |
| 7356 |
%\declare@file@substitution{enumitem.sty}{latex-lab-enumitem.sty} |
| 7357 |
% \end{macrocode} |
| 7358 |
% But for now we simply disable \pkg{enumitem} loading and |
| 7359 |
% unconditionally load our replacement into the kernel for ease of |
| 7360 |
% testing. In the end we have to decide which parts of the |
| 7361 |
% interface (if any) we provide out of the box and which parts are |
| 7362 |
% only available if the document requests \pkg{enumitem}. |
| 7363 |
% \begin{macrocode} |
| 7364 |
\declare@file@substitution{enumitem.sty}{null} |
| 7365 |
\RequirePackage{latex-lab-enumitem} |
| 7366 |
% \end{macrocode} |
| 7367 |
% |
| 7368 |
% |
| 7369 |
% \subsection{Support for the \pkg{doc} package} |
| 7370 |
% |
| 7371 |
% When the \pkg{doc} package is loaded it wants to remove a |
| 7372 |
% \texttt{\%} sign from the start of each verbatim line. For this |
| 7373 |
% it uses \cs{check@percent} which we stick into the |
| 7374 |
% \socket{verbatim/startline} socket. |
| 7375 |
% |
| 7376 |
% \begin{plugdecl}{doc} |
| 7377 |
% \begin{macrocode} |
| 7378 |
\NewSocketPlug {verbatim/startline}{doc}{ \check@percent } |
| 7379 |
\AddToHook{package/doc/after}{ |
| 7380 |
\AssignSocketPlug{verbatim/startline}{doc} |
| 7381 |
} |
| 7382 |
% \end{macrocode} |
| 7383 |
% \end{plugdecl} |
| 7384 |
% |
| 7385 |
% \begin{macrocode} |
| 7386 |
%</package-finish> |
| 7387 |
% \end{macrocode} |
| 7388 |
% |
| 7389 |
% \end{implementation} |
| 7390 |
% |
| 7391 |
% |
| 7392 |
% \Finale |
| 7393 |
% |
| 7394 |
% \endinput ^^A don't typeset the first prototype notes ------- |
| 7395 |
% |
| 7396 |
% |
| 7397 |
% |
| 7398 |
% \appendix |
| 7399 |
% |
| 7400 |
% \section{Documentation from first prototype implementations} |
| 7401 |
% |
| 7402 |
% |
| 7403 |
% \subsection{Open questions} |
| 7404 |
% \begin{itemize} |
| 7405 |
% \item Existing questions --- moved to issues --- |
| 7406 |
% \end{itemize} |
| 7407 |
% |
| 7408 |
% \subsection{Code cleanup} |
| 7409 |
% \begin{itemize} |
| 7410 |
% \raggedright |
| 7411 |
% \item Actually implement what's announced. |
| 7412 |
% |
| 7413 |
% \item Encapsulate most uses of \cs[no-index]{legacy_if\dots} into |
| 7414 |
% commands with \pkg{expl3} syntax: we cannot rename these booleans |
| 7415 |
% for compatibility reasons but we can make the code cleaner |
| 7416 |
% nevertheless. --- made issue --- |
| 7417 |
% |
| 7418 |
% \item The \tn{topsep} and \tn{partopsep} business is tricky to |
| 7419 |
% reproduce exactly (see \tn{@topsepadd} and \tn{@topsep}) because of |
| 7420 |
% how it accumulates when lists are nested immediately. |
| 7421 |
% |
| 7422 |
% \end{itemize} |
| 7423 |
% |
| 7424 |
% |
| 7425 |
% |
| 7426 |
% \subsection{Tasks} |
| 7427 |
% \begin{itemize} |
| 7428 |
% |
| 7429 |
% \item Change author to LaTeX Team once it's nice enough to deserve |
| 7430 |
% that label. |
| 7431 |
% |
| 7432 |
% \item Reproducing exactly the standard layouts and examples in the |
| 7433 |
% \pkg{enumitem} documentation. |
| 7434 |
% |
| 7435 |
% \item Hooks, but do not duplicate those that already exist as |
| 7436 |
% environment hooks. Hence, mostly around items. |
| 7437 |
% |
| 7438 |
% \item Customization and interaction with LDB: |
| 7439 |
% \begin{itemize} |
| 7440 |
% \item Allow arbitrary nesting depth with automatically defined |
| 7441 |
% styles for labels, counters etc. |
| 7442 |
% \item Adapt everything to font size! (e.g. footnotes). |
| 7443 |
% \item How to model the inheritance from trivlist to list to |
| 7444 |
% enumerate? |
| 7445 |
% \end{itemize} |
| 7446 |
% |
| 7447 |
% \item Add key--value settings mimicking \pkg{enumitem}'s ability to |
| 7448 |
% set any four of five horizontal parameters and deduce the fifth by |
| 7449 |
% $\tn{leftmargin} + \tn{itemindent} = \tn{labelindent} + |
| 7450 |
% \tn{labelwidth} + \tn{labelsep}$. |
| 7451 |
% |
| 7452 |
% \item Provide good ways to customize how overlong labels are dealt with. |
| 7453 |
% |
| 7454 |
% \item Use the \texttt{.aux} file. |
| 7455 |
% \begin{itemize} |
| 7456 |
% \item Implement the \tn{ref} styles that \pkg{enumitem} provides. |
| 7457 |
% \item Reverse enumerations, important in publication lists and the |
| 7458 |
% like. Somehow avoid needing 3 compilations for references to |
| 7459 |
% reverse enumerations to settle? |
| 7460 |
% \item Ability to calculate \tn{labelwidth} from the label contents. |
| 7461 |
% Share calculated parameters between multiple environments (cf.\ |
| 7462 |
% \texttt{resume} option). |
| 7463 |
% \end{itemize} |
| 7464 |
% |
| 7465 |
% \item Related to grabbing the whole list environment, and input syntax |
| 7466 |
% variations: |
| 7467 |
% \begin{itemize} |
| 7468 |
% \item Other layouts: tabular (see \pkg{listliketab} vs |
| 7469 |
% \pkg{typed-checklist}), multicolumn and horizontally numbered (see |
| 7470 |
% \pkg{tasks}), inline lists, runin lists in the easy case where |
| 7471 |
% there is no intervening \tn{par}. |
| 7472 |
% \item Formatting the item text in a |
| 7473 |
% box or similar (requires grabbing the whole list). |
| 7474 |
% \item Filtering which items to show: hide certain items according to |
| 7475 |
% criteria (useful together with list reuse), see |
| 7476 |
% \pkg{typed-checklist}. |
| 7477 |
% \item Shorthands \tn{iitem} for automatic nested lists, or \cs{1}, |
| 7478 |
% \cs{2} etc from \pkg{outlines}. |
| 7479 |
% \item Support markdown input like \pkg{asciilist}. |
| 7480 |
% \end{itemize} |
| 7481 |
% |
| 7482 |
% \item Check interaction with \texttt{babel} options such as |
| 7483 |
% \texttt{french} or \texttt{accadian} (see FrenchItemizeSpacing) |
| 7484 |
% |
| 7485 |
% \item RTL and vertical typesetting. |
| 7486 |
% \end{itemize} |
| 7487 |
% |
| 7488 |
% |
| 7489 |
% |
| 7490 |
% |
| 7491 |
% |
| 7492 |
% \section{Plan of attack of first prototype (historical info)} |
| 7493 |
% |
| 7494 |
% Typesetting list environments involves a rather large number of |
| 7495 |
% parameters. They can be affected by the context such as the total |
| 7496 |
% list nesting level, the nesting level of the given type of list, and |
| 7497 |
% the font size. An environment like \texttt{enumerate} has two main |
| 7498 |
% aspects. |
| 7499 |
% \begin{itemize} |
| 7500 |
% \item It has a certain layout in the page, with vertical and |
| 7501 |
% horizontal spacing around it. This type of layout is shared with |
| 7502 |
% environments such as \texttt{quote}, \texttt{flushright}, or |
| 7503 |
% \texttt{tabbing}. This common layout is implemented in \LaTeXe{} |
| 7504 |
% through \tn{trivlist} (or \tn{list}). |
| 7505 |
% \item It defines how each \tn{item} should be typeset: how to |
| 7506 |
% construct the label, in particular the \texttt{counter} name, and |
| 7507 |
% how to format the content of the item. |
| 7508 |
% \end{itemize} |
| 7509 |
% |
| 7510 |
% This suggests defining two template types, \xt{block} and \xt{item} |
| 7511 |
% covering these two aspects.\footnote{Possibly also \xt{endblock} to |
| 7512 |
% deal with decorations at the end?} While the \xt{item} type will |
| 7513 |
% perhaps have a single template, one could typeset a \xt{block} template |
| 7514 |
% in several ways, for instance the standard \LaTeXe{} way or a fancy |
| 7515 |
% colored box. |
| 7516 |
% |
| 7517 |
% The \xt{general} \xt{block} template should receive the following |
| 7518 |
% parameters. The \xt{plain} \xt{block} template is a restricted |
| 7519 |
% template that freezes all item-related parameters to dummy values |
| 7520 |
% (\texttt{counter}, \texttt{start}, \texttt{resume}, |
| 7521 |
% \texttt{label-width}, \texttt{label-sep} and all \texttt{item-*}). |
| 7522 |
% The \xt{list} \xt{block} template is a restricted template\footnote{A |
| 7523 |
% better approach could be to have a notion of inheritance for template |
| 7524 |
% types, so that we end up with two different \emph{template types}. Then |
| 7525 |
% we can implement other template for the list template type: \xt{table} |
| 7526 |
% for lists typeset as rows/columns of a table, \xt{inline} for lists |
| 7527 |
% typeset in horizontal mode within a paragraph, and \xt{runin} for |
| 7528 |
% run-in lists.} that omits the \texttt{heading} parameter and whose |
| 7529 |
% default for \texttt{item-instance} is non-empty. |
| 7530 |
% \begin{itemize} |
| 7531 |
% \raggedright |
| 7532 |
% \item Structural parameters: the \texttt{heading} to place before, |
| 7533 |
% \texttt{counter} name, \texttt{start} value, whether to |
| 7534 |
% \texttt{resume} a previous list, and the \texttt{item-instance} (an |
| 7535 |
% \xt{item} instance) to use when typesetting items. |
| 7536 |
% \item Vertical spacing and penalties: \texttt{begin-penalty}, |
| 7537 |
% \texttt{begin-vspace}, \texttt{begin-extra-vspace}, \texttt{item-penalty}, |
| 7538 |
% \texttt{item-vspace}, \texttt{item-par-skip}, \texttt{end-penalty}, |
| 7539 |
% \texttt{end-vspace}, \texttt{end-extra-vspace}. |
| 7540 |
% \item Horizontal spacing: \texttt{right-margin}, \texttt{left-margin}, |
| 7541 |
% \texttt{para-indent}, \texttt{item-indent}, \texttt{label-width}, |
| 7542 |
% \texttt{label-sep}. |
| 7543 |
% \end{itemize} |
| 7544 |
% A \docclass should edit these templates (or define restricted |
| 7545 |
% templates) to set up default values that depend on \tn{g_block_nesting_depth_int}, |
| 7546 |
% namely how many lists are nested overall.\footnote{Does |
| 7547 |
% \pkg{xtemplate} provide a way to specify default values that are only |
| 7548 |
% evaluated once an instance is used?} The document class should then |
| 7549 |
% set up an instance of these templates for each environment, with |
| 7550 |
% appropriate settings such as a \texttt{heading}, a suitable |
| 7551 |
% \texttt{item-instance}, or making \texttt{margin-right} equal to |
| 7552 |
% \texttt{margin-left} in a \texttt{quote} environment. |
| 7553 |
% |
| 7554 |
% The \xt{inline-list} \xt{block} template receives many fewer |
| 7555 |
% parameters. Note that \texttt{begin-vspace}, \texttt{item-vspace}, |
| 7556 |
% \texttt{end-vspace} are now \emph{horizontal} skips.\fmi{Text wrong |
| 7557 |
% and or concept with vspace and hspace questionable!} |
| 7558 |
% \begin{itemize} |
| 7559 |
% \item Structural parameters: \texttt{counter}, \texttt{start}, |
| 7560 |
% \texttt{resume}, \texttt{item-instance}. |
| 7561 |
% \item Spacing and penalties: \texttt{begin-penalty}, |
| 7562 |
% \texttt{begin-vspace}, \texttt{item-penalty}, \texttt{item-vspace}, |
| 7563 |
% \texttt{end-penalty}, \texttt{end-vspace}.\fmi{revisit!} |
| 7564 |
% \item Horizontal spacing: \texttt{label-width}, \texttt{label-sep}.\fmi{check!} |
| 7565 |
% \end{itemize} |
| 7566 |
% |
| 7567 |
% The \xt{std} \xt{item} template should receive the following |
| 7568 |
% parameters. They depend on the type of list and its nesting level |
| 7569 |
% among lists of such type, but typically not on the total nesting |
| 7570 |
% level. |
| 7571 |
% \begin{itemize} |
| 7572 |
% \item Counter name (\texttt{counter}), shared with the parent |
| 7573 |
% \xt{list} \xt{block} template, but needed for incrementing. |
| 7574 |
% \item Label construction: a function \texttt{counter-label} that |
| 7575 |
% produces the label from the counter name, used if \tn{item} is given |
| 7576 |
% without argument. |
| 7577 |
% \item References: a function \texttt{counter-ref} for how the label |
| 7578 |
% should be referred to when it is constructed from the counter, |
| 7579 |
% \texttt{label-ref} and \texttt{label-autoref} used when \tn{item} |
| 7580 |
% has an optional argument. |
| 7581 |
% \item Label formatting: \texttt{label-format} function, |
| 7582 |
% \texttt{label-strut} boolean. |
| 7583 |
% \item Label alignment (\texttt{label-align}, \texttt{label-boxed}, |
| 7584 |
% \texttt{next-line}). |
| 7585 |
% \item Content parameters: \key{text-font}. |
| 7586 |
% \item A \texttt{compatibility} boolean that controls for instance |
| 7587 |
% whether \tn{makelabel} is used. |
| 7588 |
% \end{itemize} |
| 7589 |
% The \docclass should set up an instance such as \xt{enumiii} for each |
| 7590 |
% environment and nesting level.\footnote{This should be made easily |
| 7591 |
% extendible to deeper levels.} |
| 7592 |
% |
| 7593 |
% A given environment will adjust some nesting levels, then call the |
| 7594 |
% \xt{block} instance appropriate to the environment type, passing it |
| 7595 |
% the \xt{item} instance appropriate to the environment and depth. |
| 7596 |
% Additional context-dependence could be provided by \pkg{l3ldb}, but |
| 7597 |
% the main context-dependence should not rely on it for simplicity |
| 7598 |
% reasons and incidentally because \pkg{l3ldb} is not yet available. |
| 7599 |
% |
| 7600 |
% |
| 7601 |
% |
| 7602 |
|
| 7603 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 7604 |
\endinput |