Debian Codegraph @

texmf-dist/source/latex/l3packages/xtemplate/xtemplate.dtx

raw
1 % \iffalse meta-comment
2 %
3 %% File: xtemplate.dtx
4 %
5 % Copyright (C) 1999 Frank Mittelbach, Chris Rowley, David Carlisle
6 % (C) 2004-2010 Frank Mittelbach, The LaTeX Project
7 % (C) 2011-2025 The LaTeX Project
8 %
9 % It may be distributed and/or modified under the conditions of the
10 % LaTeX Project Public License (LPPL), either version 1.3c of this
11 % license or (at your option) any later version. The latest version
12 % of this license is in the file
13 %
14 % https://www.latex-project.org/lppl.txt
15 %
16 % This file is part of the "l3packages bundle" (The Work in LPPL)
17 % and all files in that bundle must be distributed together.
18 %
19 % -----------------------------------------------------------------------
20 %
21 % The development version of the bundle can be found at
22 %
23 % https://github.com/latex3/latex3
24 %
25 % for those people who are interested.
26 %
27 %<*driver>
28 \documentclass[full]{l3doc}
29 \usepackage{amstext}
30 \begin{document}
31 \DocInput{\jobname.dtx}
32 \end{document}
33 %</driver>
34 % \fi
35 %
36 % \title{^^A
37 % The \pkg{xtemplate} package\\ Prototype document functions^^A
38 % }
39 %
40 % \author{^^A
41 % The \LaTeX{} Project\thanks
42 % {^^A
43 % E-mail:
44 % \href{mailto:[email protected]}
45 % {[email protected]}^^A
46 % }^^A
47 % }
48 %
49 % \date{Released 2025-10-09}
50 %
51 % \maketitle
52 %
53 % \begin{documentation}
54 %
55 % There are three broad \enquote{layers} between putting down ideas into
56 % a source file and ending up with a typeset document. These layers of
57 % document writing are
58 % \begin{enumerate}
59 % \item authoring of the text with mark-up;
60 % \item document layout design;
61 % \item implementation (with \TeX{} programming) of the design.
62 % \end{enumerate}
63 % We write the text as an author, and we see the visual output of the design
64 % after the document is generated; the \TeX{} implementation in the middle is
65 % the glue between the two.
66 %
67 % \LaTeX{}'s greatest success has been to standardize a system of mark-up that
68 % balances the trade-off between ease of reading and ease of writing to suit
69 % almost all forms of technical writing. It's
70 % other original strength was a good background in typographical design; while
71 % the standard \LaTeXe{} classes look somewhat dated now in terms of their
72 % visual design, their typography is generally sound. (Barring the occasional
73 % minor faults.)
74 %
75 % However, \LaTeXe{} has always lacked a standard approach to customizing
76 % the visual design of a document. Changing the looks of the standard classes
77 % involved either:
78 % \begin{itemize}
79 % \item Creating a new version of the implementation code of the class and
80 % editing it.
81 % \item Loading one of the many packages to customize certain elements of
82 % the standard classes.
83 % \item Loading a completely different document class, such as
84 % \cls{KOMA-Script} or \cls{memoir}, that allows easy customization.
85 % \end{itemize}
86 % All three of these approaches have their drawbacks and learning curves.
87 %
88 % The idea behind \pkg{xtemplate} is to cleanly separate the three layers
89 % introduced at the beginning of this section, so that document authors who
90 % are not programmers can easily change the design of their documents.
91 % \pkg{xtemplate} also makes it easier for \LaTeX{} programmers to provide
92 % their own customizations on top of a pre-existing class.
93 %
94 % \section{What is a document?}
95 %
96 % Besides the textual content of the words themselves, the source file
97 % of a document contains mark-up elements that add structure to the
98 % document. These elements include sectional divisions, figure/table
99 % captions, lists of various sorts, theorems/proofs, and so on.
100 % The list will be different for every document that can be written.
101 %
102 % Each element can be represented logically without worrying about the
103 % formatting, with mark-up such as \cs{section}, \cs{caption},
104 % |\begin{enumerate}| and so on. The output of each one of these
105 % document elements will be a typeset representation of the information
106 % marked up, and the visual arrangement and design of these elements
107 % can vary widely in producing a variety of desired outcomes.
108 %
109 % For each type of document element, there may be design variations that
110 % contain the same sort of information but present it in slightly
111 % different ways. For example, the difference between a numbered and an
112 % unnumbered section, \cs{section} and |\section*|, or the difference
113 % between an itemized list or an enumerated list.
114 %
115 % There are three distinct layers in the definition of
116 % \enquote{a document} at this level
117 % \begin{enumerate}
118 % \item semantic elements such as the ideas of sections and lists;
119 % \item a set of design solutions for representing these elements
120 % visually;
121 % \item specific variations for these designs that represent the
122 % elements in the document.
123 % \end{enumerate}
124 % In the parlance of the template system, these are called object types,
125 % templates, and instances, and they are discussed below in sections
126 % \ref{sec:objects}, \ref{sec:templates}, and~\ref{sec:instances},
127 % respectively.
128 %
129 % \section {Objects, templates, and instances}
130 %
131 % By formally declaring documents to be composed of mark-up elements
132 % grouped into objects, which are interpreted and typeset with a set of
133 % templates, each of which has one or more instances with which to
134 % compose each and every semantic unit of the text, we can cleanly
135 % separate the components of document construction.
136 %
137 % All of the structures provided by the template system are global,
138 % and do not respect \TeX{} grouping.
139 %
140 % \section{Object types}
141 % \label{sec:objects}
142 %
143 % An \emph{object type} (sometimes just \enquote{object}) is an
144 % abstract idea of a document element that takes a fixed number of
145 % arguments corresponding to the information from the document author
146 % that it is representing. A sectioning object, for example, might take
147 % three inputs: \enquote{title}, \enquote{short title}, and
148 % \enquote{label}.
149 %
150 % Any given document class will define which object types are to be
151 % used in the document, and any template of a given object type can be
152 % used to generate an instance for the object. (Of course, different
153 % templates will produce different typeset representations, but the
154 % underlying content will be the same.)
155 %
156 % \begin{function}{\DeclareObjectType}
157 % \begin{syntax}
158 % \cs{DeclareObjectType} \Arg{object type} \Arg{no. of args}
159 % \end{syntax}
160 % This function defines an \meta{object type} taking
161 % \meta{number of arguments}, where the \meta{object type} is an
162 % abstraction as discussed above. For example,
163 % \begin{verbatim}
164 % \DeclareObjectType{sectioning}{3}
165 % \end{verbatim}
166 % creates an object type \enquote{sectioning}, where each use of that
167 % object type will need three arguments.
168 % \end{function}
169 %
170 % \section{Templates}
171 % \label{sec:templates}
172 %
173 % A \emph{template} is a generalized design solution for representing
174 % the information of a specified object type. Templates that do the same
175 % thing, but in different ways, are grouped together by their object type
176 % and given separate names. There are two important parts to a template:
177 % \begin{itemize}
178 % \item the parameters it takes to vary the design it is producing;
179 % \item the implementation of the design.
180 % \end{itemize}
181 % As a document author or designer does not care about the
182 % implementation but rather only the interface to the template, these two
183 % aspects of the template definition are split into two independent
184 % declarations, \cs{DeclareTemplateInterface} and
185 % \cs{DeclareTemplateCode}.
186 %
187 % \begin{function}{\DeclareTemplateInterface}
188 % \begin{syntax}
189 % \cs{DeclareTemplateInterface}
190 % ~~\Arg{object type} \Arg{template} \Arg{no.~of args}
191 % ~~\Arg{key list}
192 % \end{syntax}
193 % A \meta{template} interface is declared for a particular
194 % \meta{object type}, where the \meta{number of arguments} must
195 % agree with the object type declaration. The interface itself is
196 % defined by the \meta{key list}, which is itself a key--value list
197 % taking a specialized format:
198 % \begin{quotation}
199 % \obeylines
200 % \noindent
201 % \meta{key1}~":"~\meta{key type1}~","
202 % \meta{key2}~":"~\meta{key type2}~","
203 % \meta{key3}~":"~\meta{key type3}~"="~\meta{default3}~","
204 % \meta{key4}~":"~\meta{key type4}~"="~\meta{default4}~","
205 % \ldots
206 % \end{quotation}
207 % Each \meta{key} name should consist of \textsc{ascii} characters,
208 % with the exception of |,|, |=| and \verb*| |. The recommended form
209 % for key names is to use lower case letters, with dashes to separate
210 % out different parts. Spaces are ignored in key names, so they can be
211 % included or missed out at will. Each \meta{key} must have a
212 % \meta{key type}, which defined the type of input that the \meta{key}
213 % requires. A full list of key types is given in
214 % Table~\ref{tab:key-types}. Each key may have a \meta{default}
215 % value, which will be used in by the template if the \meta{key} is
216 % not set explicitly. The \meta{default} should be of the correct
217 % form to be accepted by the \meta{key type} of the \meta{key}: this
218 % is not checked by the code.
219 % \end{function}
220 %
221 % \begin{table}
222 % \centering
223 % \begin{tabular}{>{\ttfamily}ll}
224 % \toprule
225 % \multicolumn{1}{l}{Key-type} & Description of input \\
226 % \midrule
227 % boolean & \texttt{true} or \texttt{false} \\
228 % choice\Arg{choices}
229 % & A list of pre-defined \meta{choices} \\
230 % commalist & A comma-separated list \\
231 % function\Arg{$N$}
232 % & A function definition with $N$ arguments
233 % ($N$ from $0$ to $9$) \\
234 % instance\Arg{name}
235 % & An instance of type \meta{name} \\
236 % integer & An integer or integer expression \\
237 % length & A fixed length \\
238 % muskip & A math length with shrink and stretch components \\
239 % real & A real (floating point) value \\
240 % skip & A length with shrink and stretch components \\
241 % tokenlist & A token list: any text or commands \\
242 % \bottomrule
243 % \end{tabular}
244 % \caption{Key-types for defining template interfaces with
245 % \cs{DeclareTemplateInterface}.}
246 % \label{tab:key-types}
247 % \end{table}
248 %
249 % \begin{function}{\KeyValue}
250 % \begin{syntax}
251 % \cs{KeyValue} \Arg{key name}
252 % \end{syntax}
253 % There are occasions where the default (or value) for one key
254 % should be taken from another. The \cs{KeyValue} function can be
255 % used to transfer this information without needing to know the
256 % internal implementation of the key:
257 % \begin{verbatim}
258 % \DeclareTemplateInterface { object } { template } { no. of args }
259 % {
260 % key-name-1 : key-type = value ,
261 % key-name-2 : key-type = \KeyValue { key-name-1 },
262 % ...
263 % }
264 % \end{verbatim}
265 % \end{function}
266 %
267 % \begin{function}{\DeclareTemplateCode}
268 % \begin{syntax}
269 % \cs{DeclareTemplateCode}
270 % ~~\Arg{object type} \Arg{template} \Arg{no.~of args}
271 % ~~\Arg{key bindings} \Arg{code}
272 % \end{syntax}
273 % The relationship between a templates keys and the internal
274 % implementation is created using the \cs{DeclareTemplateCode}
275 % function. As with \cs{DeclareTemplateInterface}, the
276 % \meta{template} name is given along with the \meta{object type}
277 % and \meta{number of arguments} required. The \meta{key bindings}
278 % argument is a key--value list which specifies the relationship
279 % between each \meta{key} of the template interface with an
280 % underlying\meta{variable}.
281 %
282 % \begin{quotation}
283 % \obeylines
284 % \noindent
285 % \meta{key1}~"="~\meta{variable1},
286 % \meta{key2}~"="~\meta{variable2},
287 % \meta{key3}~"="~global~\meta{variable3},
288 % \meta{key4}~"="~global~\meta{variable4},
289 % \ldots
290 % \end{quotation}
291 % With the exception of the choice, code and function key types,
292 % the \meta{variable} here should be the name of an existing
293 % \LaTeX3 register. As illustrated, the key word \enquote{global}
294 % may be included in the listing to indicate that the \meta{variable}
295 % should be assigned globally. A full list of variable bindings is
296 % given in Table~\ref{tab:key-vars}.
297 %
298 % The \meta{code} argument of \cs{DeclareTemplateCode} is used
299 % as the replacement text for the template when it is used, either
300 % directly or as an instance. This may therefore accept arguments
301 % |#1|, |#2|, \emph{etc}.~as detailed by the \meta{number of arguments}
302 % taken by the object type.
303 % \end{function}
304 %
305 % \begin{table}
306 % \centering
307 % \begin{tabular}{>{\ttfamily}ll}
308 % \toprule
309 % \multicolumn{1}{l}{Key-type} & Description of binding \\
310 % \midrule
311 % boolean & Boolean variable, \emph{e.g}.~\cs{l_tmpa_bool} \\
312 % choice
313 % & List of choice implementations
314 % (see Section~\ref{sec:choices-key}) \\
315 % commalist & Comma list, \emph{e.g}.~\cs{l_tmpa_clist} \\
316 % function
317 % & Function taking $N$ arguments, \emph{e.g}.~\cs{use_i:nn} \\
318 % instance \\
319 % integer & Integer variable, \emph{e.g}.~\cs{l_tmpa_int} \\
320 % length & Dimension variable, \emph{e.g}.~\cs{l_tmpa_dim} \\
321 % muskip & Muskip variable, \emph{e.g}.~\cs{l_tmpa_muskip} \\
322 % real & Floating-point variable, \emph{e.g}.~\cs{l_tmpa_fp} \\
323 % skip & Skip variable, \emph{e.g}.~\cs{l_tmpa_skip} \\
324 % tokenlist & Token list variable, \emph{e.g}.~\cs{l_tmpa_tl} \\
325 % \bottomrule
326 % \end{tabular}
327 % \caption{Bindings required for different key types when defining
328 % template implementations with \cs{DeclareTemplateCode}. Apart
329 % from \texttt{code}, \texttt{choice} and \texttt{function}
330 % all of these accept the key word \texttt{global} to carry
331 % out a global assignment.}
332 % \label{tab:key-vars}
333 % \end{table}
334 %
335 % \begin{function}{\AssignTemplateKeys}
336 % \begin{syntax}
337 % \cs{AssignTemplateKeys}
338 % \end{syntax}
339 % In the final argument of \cs{DeclareTemplateCode} the assignment of
340 % keys defined by the template may be delayed by including the command
341 % \cs{AssignTemplateKeys}. If this is \emph{not} present, keys are assigned
342 % immediately before the template code. If \cs{AssignTemplateKeys} is
343 % present, assignment is delayed until this point. Note that the
344 % command must be \emph{directly} present in the code, not placed
345 % within a nested command/macro.
346 % \end{function}
347 %
348 % \section{Multiple choices}
349 % \label{sec:choices-key}
350 %
351 % The \texttt{choice} key type implements multiple choice input. At the
352 % interface level, only the list of valid choices is needed:
353 % \begin{verbatim}
354 % \DeclareTemplateInterface { foo } { bar } { 0 }
355 % { key-name : choice { A, B, C } }
356 % \end{verbatim}
357 % where the choices are given as a comma-list (which must therefore
358 % be wrapped in braces). A default value can also be given:
359 % \begin{verbatim}
360 % \DeclareTemplateInterface { foo } { bar } { 0 }
361 % { key-name : choice { A, B, C } = A }
362 % \end{verbatim}
363 %
364 % At the implementation level, each choice is associated with code,
365 % using a nested key--value list.
366 % \begin{verbatim}
367 % \DeclareTemplateCode { foo } { bar } { 0 }
368 % {
369 % key-name =
370 % {
371 % A = Code-A ,
372 % B = Code-B ,
373 % C = Code-C
374 % }
375 % }
376 % { ... }
377 % \end{verbatim}
378 % The two choice lists should match, but in the implementation a
379 % special \texttt{unknown} choice is also available. This can be used
380 % to ignore values and implement an \enquote{else} branch:
381 % \begin{verbatim}
382 % \DeclareTemplateCode { foo } { bar } { 0 }
383 % {
384 % key-name =
385 % {
386 % A = Code-A ,
387 % B = Code-B ,
388 % C = Code-C ,
389 % unknown = Else-code
390 % }
391 % }
392 % { ... }
393 % \end{verbatim}
394 % The \texttt{unknown} entry must be the last one given, and should
395 % \emph{not} be listed in the interface part of the template.
396 %
397 % For keys which accept the values \texttt{true} and \texttt{false}
398 % both the boolean and choice key types can be used. As template
399 % interfaces are intended to prompt clarity at the design level, the
400 % boolean key type should be favored, with the choice type reserved
401 % for keys which take arbitrary values.
402 %
403 % \section{Instances}
404 % \label{sec:instances}
405 %
406 % After a template is defined it still needs to be put to use. The
407 % parameters that it expects need to be defined before it can be used in
408 % a document. Every time a template has parameters given to it, an
409 % \emph{instance} is created, and this is the code that ends up in the
410 % document to perform the typesetting of whatever pieces of information
411 % are input into it.
412 %
413 % For example, a template might say \enquote{here is a section with or
414 % without a number that might be centered or left aligned and print its
415 % contents in a certain font of a certain size, with a bit of a gap
416 % before and after it} whereas an instance declares \enquote{this is a
417 % section with a number, which is centered and set in $12\,\text{pt}$
418 % italic with a $10\,\text{pt}$ skip before and a
419 % $12\,\text{pt}$ skip after it}. Therefore, an instance is just a
420 % frozen version of a template with specific settings as chosen by the
421 % designer.
422 %
423 % \begin{function}{\DeclareInstance}
424 % \begin{syntax}
425 % \cs{DeclareInstance}
426 % ~~\Arg{object type} \Arg{instance} \Arg{template} \Arg{parameters}
427 % \end{syntax}
428 % This function uses a \meta{template} for an \meta{object type}
429 % to create an \meta{instance}. The \meta{instance} will be set
430 % up using the \meta{parameters}, which will set some of the
431 % \meta{keys} in the \meta{template}.
432 %
433 % As a practical example, consider an object type for document sections
434 % (which might include chapters, parts, sections, \emph{etc}.), which
435 % is called \texttt{sectioning}. One possible template for this
436 % object type might be called \texttt{basic}, and one instance of this
437 % template would be a numbered section. The instance declaration might
438 % read:
439 % \begin{verbatim}
440 % \DeclareInstance { sectioning } { section-num } { basic }
441 % {
442 % numbered = true ,
443 % justification = center ,
444 % font =\normalsize\itshape ,
445 % before-skip = 10pt ,
446 % after-skip = 12pt ,
447 % }
448 % \end{verbatim}
449 % Of course, the key names here are entirely imaginary, but illustrate
450 % the general idea of fixing some settings.
451 % \end{function}
452 %
453 % \begin{function}{\IfInstanceExistT, \IfInstanceExistF, \IfInstanceExistTF}
454 % \begin{syntax}
455 % \cs{IfInstanceExistTF} \Arg{object type} \Arg{instance} \Arg{true code} \Arg{false code}
456 % \end{syntax}
457 % Tests if the named \meta{instance} of a \meta{object type} exists, and
458 % then inserts the appropriate code into the input stream.
459 % \end{function}
460 %
461 % \begin{function}{\DeclareInstanceCopy}
462 % \begin{syntax}
463 % \cs{DeclareInstanceCopy}
464 % ~~\Arg{object type} \Arg{instance2} \Arg{instance1}
465 % \end{syntax}
466 % Copies the \meta{values} for \meta{instance1} for an
467 % \meta{object type} to \meta{instance2}.
468 % \end{function}
469 %
470 % \section{Document interface}
471 %
472 % After the instances have been chosen, document commands must be
473 % declared to use those instances in the document. \cs{UseInstance}
474 % calls instances directly, and this command should be used internally
475 % in document-level mark-up.
476 %
477 % \begin{function}{\UseInstance}
478 % \begin{syntax}
479 % \cs{UseInstance}
480 % ~~\Arg{object type} \Arg{instance} \meta{arguments}
481 % \end{syntax}
482 % Uses an \meta{instance} of the \meta{object type}, which will require
483 % \meta{arguments} as determined by the number specified for the
484 % \meta{object type}. The \meta{instance} must have been declared
485 % before it can be used, otherwise an error is raised.
486 % \end{function}
487 %
488 % \begin{function}{\UseTemplate}
489 % \begin{syntax}
490 % \cs{UseTemplate} \Arg{object type} \Arg{template}
491 % ~~\Arg{settings} \meta{arguments}
492 % \end{syntax}
493 % Uses the \meta{template} of the specified \meta{object type},
494 % applying the \meta{settings} and absorbing \meta{arguments} as
495 % detailed by the \meta{object type} declaration. This in effect
496 % is the same as creating an instance using \cs{DeclareInstance}
497 % and immediately using it with \cs{UseInstance}, but without the
498 % instance having any further existence. It is therefore useful where
499 % a template needs to be used once.
500 %
501 % This function can also be used as the argument to \texttt{instance}
502 % key types:
503 % \begin{verbatim}
504 % \DeclareInstance { object } { template } { instance }
505 % {
506 % instance-key =
507 % \UseTemplate { object2 } { template2 } { <settings> }
508 % }
509 % \end{verbatim}
510 % \end{function}
511 %
512 % \section{Changing existing definitions}
513 %
514 % Template parameters may be assigned specific defaults for instances
515 % to use if the instance declaration doesn't explicit set those
516 % parameters. In some cases, the document designer will wish to edit
517 % these defaults to allow them to \enquote{cascade} to the instances.
518 % The alternative would be to set each parameter identically for each
519 % instance declaration, a tedious and error-prone process.
520 %
521 % \begin{function}{\EditTemplateDefaults}
522 % \begin{syntax}
523 % \cs{EditTemplateDefaults}
524 % ~~\Arg{object type} \Arg{template} \Arg{new defaults}
525 % \end{syntax}
526 % Edits the \meta{defaults} for a \meta{template} for an
527 % \meta{object type}. The \meta{new defaults}, given as a key--value
528 % list, replace the existing defaults for the \meta{template}. This
529 % means that the change will apply to instances declared after the
530 % editing, but that instances which have already been created are
531 % unaffected.
532 % \end{function}
533 %
534 % \begin{function}{\EditInstance}
535 % \begin{syntax}
536 % \cs{EditInstance}
537 % ~~\Arg{object type} \Arg{instance} \Arg{new values}
538 % \end{syntax}
539 % Edits the \meta{values} for an \meta{instance} for an
540 % \meta{object type}. The \meta{new values}, given as a key--value
541 % list, replace the existing values for the \meta{instance}. This
542 % function is complementary to \cs{EditTemplateDefaults}:
543 % \cs{EditInstance} changes a single instance while leaving the
544 % template untouched.
545 % \end{function}
546 %
547 % \section{When template parameters should be frozen}
548 %
549 % A class designer may be inheriting templates declared by someone else,
550 % either third-party code or the \LaTeX{} kernel itself. Sometimes these
551 % templates will be overly general for the purposes of the document.
552 % The user should be able to customize parts of the template instances,
553 % but otherwise be restricted to only those parameters allowed by the
554 % designer.
555 %
556 % \begin{function}{\DeclareRestrictedTemplate}
557 % \begin{syntax}
558 % \cs{DeclareRestrictedTemplate}
559 % ~~\Arg{object type} \Arg{parent template} \Arg{new template}
560 % ~~\Arg{parameters}
561 % \end{syntax}
562 % Creates a copy of the \meta{parent template} for the
563 % \meta{object type} called \meta{new template}. The key--value list
564 % of \meta{parameters} applies in the \meta{new template} and cannot
565 % be changed when creating an instance.
566 % \end{function}
567 %
568 % \section{\emph{Ad hoc} adjustment of templates}
569 %
570 % \begin{function}{\SetTemplateKeys}
571 % \begin{syntax}
572 % \cs{SetTemplateKeys} \Arg{object type} \Arg{template} \Arg{keyvals}
573 % \end{syntax}
574 % At point of use it may be useful to apply changed to individual instances.
575 % This is supported as each template key is made available for adjustment
576 % using \cs{SetTemplateKeys}.
577 % \end{function}
578 %
579 % For example, after
580 % \begin{verbatim}
581 % \DeclareObjectType{MyObj}{0}
582 % \DeclareTemplateInterface{MyObj}{TemplateA}{0}
583 % {
584 % akey: tokenlist ,
585 % bkey: function{2}
586 % }
587 % \DeclareTemplateCode{MyObj}{TemplateA}{0}
588 % {
589 % akey = SomeTokens ,
590 % bkey = \func:nn ,
591 % }
592 % \end{verbatim}
593 % the template keys could be adjusted in an \emph{ad hoc} fashion using
594 % \begin{verbatim}
595 % \SetTemplateKeys{MyObj}{TemplateA}
596 % {
597 % akey = OtherTokens ,
598 % bkey = \AltFunc:nn
599 % }
600 % \end{verbatim}
601 %
602 % \section{Getting information about templates and instances}
603 %
604 % \begin{function}{\ShowInstanceValues}
605 % \begin{syntax}
606 % \cs{ShowInstanceValues} \Arg{object type} \Arg{instance}
607 % \end{syntax}
608 % Shows the \meta{values} for an \meta{instance} of the given
609 % \meta{object type} at the terminal.
610 % \end{function}
611 %
612 % \begin{function}{\ShowTemplateCode}
613 % \begin{syntax}
614 % \cs{ShowTemplateCode} \Arg{object type} \Arg{template}
615 % \end{syntax}
616 % Shows the \meta{code} of a \meta{template} for an \meta{object type}
617 % in the terminal.
618 % \end{function}
619 %
620 % \begin{function}{\ShowTemplateDefaults}
621 % \begin{syntax}
622 % \cs{ShowTemplateDefaults} \Arg{object type} \Arg{template}
623 % \end{syntax}
624 % Shows the \meta{default} values of a \meta{template} for an
625 % \meta{object type} in the terminal.
626 % \end{function}
627 %
628 % \begin{function}{\ShowTemplateInterface}
629 % \begin{syntax}
630 % \cs{ShowTemplateInterface} \Arg{object type} \Arg{template}
631 % \end{syntax}
632 % Shows the \meta{keys} and associated \meta{key types} of a
633 % \meta{template} for an \meta{object type} in the terminal.
634 % \end{function}
635 %
636 % \begin{function}{\ShowTemplateVariables}
637 % \begin{syntax}
638 % \cs{ShowTemplateVariables} \Arg{object type} \Arg{template}
639 % \end{syntax}
640 % Shows the \meta{variables} and associated \meta{keys} of a
641 % \meta{template} for an \meta{object type} in the terminal. Note that
642 % \texttt{code} and \texttt{choice} keys do not map directly to variables
643 % but to arbitrary code. For \texttt{choice} keys, each valid choice
644 % is shown as a separate entry in the list, with the key name and choice
645 % separated by a space, for example
646 % \begin{verbatim}
647 % Template 'example' of object type 'example' has variable mapping:
648 % > demo unknown => \def \demo {?}
649 % > demo c => \def \demo {c}
650 % > demo b => \def \demo {b}
651 % > demo a => \def \demo {a}.
652 % \end{verbatim}
653 % would be shown for a choice key \texttt{demo} with valid choices
654 % \texttt{a}, \texttt{b} and \texttt{c}, plus code for an \texttt{unknown}
655 % branch.
656 % \end{function}
657 %
658 % \section{Collections}
659 %
660 % The implementation of templates includes a concept termed
661 % \enquote{collections}. The idea is that by activating a collection, a
662 % set of instances can rapidly be set up. An example use case would be
663 % collections for \texttt{frontmatter}, \texttt{mainmatter} and
664 % \texttt{backmatter} in a book. This mechanism is currently implemented
665 % by the commands \cs{DeclareCollectionInstance}, \cs{EditCollectionInstance}
666 % and \cs{UseCollection}. However, while the idea of switchable instances is
667 % a useful one, the team feel that collections are not the correct way to
668 % achieve this, at least with the current approach. As such, the collection
669 % functions should be regarded as deprecated: they remain available to support
670 % existing code, but will be removed when a better mechanism is developed.
671 %
672 %
673 % \begin{function}{\ShowCollectionInstanceValues}
674 % \begin{syntax}
675 % \cs{ShowInstanceValues} \Arg{collection} \Arg{object type} \Arg{instance}
676 % \end{syntax}
677 % Shows the \meta{values} for an \meta{instance} within
678 % a \meta{collection} of the given \meta{object type} at the terminal.
679 % As for other collection commands, this should be regarded as deprecated.
680 % \end{function}
681 %
682 % \end{documentation}
683 %
684 % \begin{implementation}
685 %
686 % \section{\pkg{xtemplate} implementation}
687 %
688 % \begin{macrocode}
689 %<*package>
690 % \end{macrocode}
691 %
692 % \begin{macrocode}
693 %<@@=template>
694 % \end{macrocode}
695 %
696 % \begin{macro}{\DeclareRestrictedTemplate}
697 % \begin{macro}{\DeclareObjectType}
698 % If the new kernel code is not loaded, hand over to the frozen version.
699 % Otherwise, make a couple of compatibility additions.
700 % \begin{macrocode}
701 \@ifundefined{NewTemplateType}
702 {%
703 \input{xtemplate-2023-10-10.sty}%
704 \endinput
705 }
706 {%
707 \ProvidesExplPackage{xtemplate}{2025-10-09}{}
708 {L3 Experimental prototype document functions}
709 \long\protected\def\DeclareRestrictedTemplate#1#2#3#4{%
710 \DeclareTemplateCopy{#1}{#3}{#2}%
711 \EditTemplateDefaults{#1}{#3}{#4}%
712 }%
713 \let\IfInstanceExistT\IfInstanceExistsT
714 \let\IfInstanceExistF\IfInstanceExistsF
715 \let\IfInstanceExistTF\IfInstanceExistsTF
716 }
717 \ExplSyntaxOn
718 \cs_new_protected:Npn \DeclareObjectType #1#2
719 { \@@_declare_type:nn {#1} {#2} }
720 \ExplSyntaxOff
721 % \end{macrocode}
722 % \end{macro}
723 % \end{macro}
724 %
725 % \begin{macrocode}
726 %</package>
727 % \end{macrocode}
728 %
729 %\end{implementation}
730 %
731 %\PrintIndex