Debian Codegraph @

texmf-dist/source/latex/zref-clever/zref-clever.dtx

raw
1 % \iffalse meta-comment
2 %
3 % File: zref-clever.dtx
4 %
5 % This file is part of the LaTeX package "zref-clever".
6 %
7 % Copyright (C) 2021-2024 gusbrs
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 % and version 1.3 or later is part of all distributions of LaTeX
17 % version 2005/12/01 or later.
18 %
19 %
20 % This work is "maintained" (as per LPPL maintenance status) by gusbrs.
21 %
22 % This work consists of the files zref-clever.dtx,
23 % zref-clever.ins,
24 % zref-clever-doc.tex,
25 % zref-clever-code.tex,
26 % and the files generated from them.
27 %
28 % The released version of this package is available from CTAN.
29 %
30 % -----------------------------------------------------------------------
31 %
32 % The development version of the package can be found at
33 %
34 % https://github.com/gusbrs/zref-clever
35 %
36 % for those people who are interested.
37 %
38 % -----------------------------------------------------------------------
39 %
40 % \fi
41 %
42 % \iffalse
43 %<*driver>
44 \documentclass{l3doc}
45
46 \usepackage{fontspec}
47 \setmainfont{CMU Serif}
48 \setsansfont{CMU Sans Serif}
49 \setmonofont{CMU Typewriter Text}
50
51 % Have \GetFileInfo pick up date and version data and used in the
52 % documentation.
53 \usepackage{zref-clever}
54 \zcsetup{cap,nameinlink=false}
55 \usepackage{zref-check}
56 \usepackage{zref-titleref}
57
58 \begin{document}
59
60 \DocInput{zref-clever.dtx}
61
62 \end{document}
63 %</driver>
64 % \fi
65 %
66 % \DoNotIndex{\\,\{,\}}
67 % \DoNotIndex{\c@,\cl@,\c@enumN,\p@}
68 % \DoNotIndex{\the}
69 % \DoNotIndex{\A,\Z,\d}
70 %
71 % \NewDocumentCommand\githubissue{m}{^^A
72 % issue~\href{https://github.com/gusbrs/zref-clever/issues/#1}{\##1}}
73 %
74 % \NewDocumentCommand\githubPR{m}{^^A
75 % PR~\href{https://github.com/gusbrs/zref-clever/pull/#1}{\##1}}
76 %
77 % \NewDocumentCommand\contributor{m}{#1}
78 % \NewDocumentCommand\username{m}{`\texttt{#1}'}
79 %
80 % \NewDocumentCommand\opt{m}{\texttt{#1}}
81 %
82 % \pdfstringdefDisableCommands{^^A
83 % \def\opt#1{#1}
84 % }
85 %
86 % ^^A Have the Index at 'section' level rather than 'part'. Otherwise it is
87 % ^^A just the same definition from 'l3doc.cls'.
88 % \IndexPrologue{^^A
89 % \section*{Index}
90 % \markboth{Index}{Index}
91 % \addcontentsline{toc}{section}{Index}
92 % The italic numbers denote the pages where the corresponding entry is
93 % described, numbers underlined point to the definition, all others indicate
94 % the places where it is used.^^A
95 % }
96 %
97 %
98 % \GetFileInfo{zref-clever.sty}
99 %
100 % \title{^^A
101 % The \pkg{zref-clever} package^^A
102 % \texorpdfstring{\\{}\medskip{}}{ - }^^A
103 % Code documentation^^A
104 % \texorpdfstring{\medskip{}}{}^^A
105 % }
106 %
107 % \author{^^A
108 % \texorpdfstring{\texttt{gusbrs}\\[0.8em]
109 % \url{https://github.com/gusbrs/zref-clever}\\
110 % \url{https://www.ctan.org/pkg/zref-clever}}{gusbrs}}
111 %
112 % \date{Version \fileversion\ -- \filedate}
113 %
114 % \maketitle
115 %
116 % \begin{center}
117 % \textbf{EXPERIMENTAL}
118 % \end{center}
119 %
120 %
121 % \tableofcontents
122 %
123 %
124 % \section{Initial setup}
125 %
126 % Start the \pkg{DocStrip} guards.
127 % \begin{macrocode}
128 %<*package>
129 % \end{macrocode}
130 %
131 % Identify the internal prefix (\LaTeX3 \pkg{DocStrip} convention).
132 % \begin{macrocode}
133 %<@@=zrefclever>
134 % \end{macrocode}
135 %
136 % Taking a stance on backward compatibility of the package. During initial
137 % development, we have used freely recent features of the kernel (albeit
138 % refraining from \pkg{l3candidates}). We presume \pkg{xparse} (which made to
139 % the kernel in the 2020-10-01 release), and \pkg{expl3} as well (which made
140 % to the kernel in the 2020-02-02 release). We also just use UTF-8 for the
141 % language files (which became the default input encoding in the 2018-04-01
142 % release). Also, a couple of changes came with the 2021-11-15 kernel
143 % release, which are important here. First, a fix was made to the new hook
144 % management system (\pkg{ltcmdhooks}), with implications to the hook we add
145 % to \cs{appendix} (by \contributor{Phelype Oleinik} at
146 % \url{https://tex.stackexchange.com/q/617905} and
147 % \url{https://github.com/latex3/latex2e/pull/699}). Second, the support for
148 % \cs{@currentcounter} has been improved, including \cs{footnote} and
149 % \pkg{amsmath} (by \contributor{Frank Mittelbach} and \contributor{Ulrike
150 % Fischer} at \url{https://github.com/latex3/latex2e/issues/687}).
151 % Critically, the new \texttt{label} hook introduced in the 2023-06-01
152 % release, alongside the corresponding new hooks with arguments, just
153 % simplifies and improves label setting so much, by allowing \cs{zlabel} to be
154 % set with \cs{label}, that it is definitely a must for \pkg{zref-clever}, so
155 % we require that too. Finally, since we followed the move to \texttt{e}-type
156 % expansion, to play safe we require the 2023-11-01 kernel or newer.
157 %
158 % \begin{macrocode}
159 \def\zrefclever@required@kernel{2023-11-01}
160 \NeedsTeXFormat{LaTeX2e}[\zrefclever@required@kernel]
161 \providecommand\IfFormatAtLeastTF{\@ifl@t@r\fmtversion}
162 \IfFormatAtLeastTF{\zrefclever@required@kernel}
163 {}
164 {%
165 \PackageError{zref-clever}{LaTeX kernel too old}
166 {%
167 'zref-clever' requires a LaTeX kernel \zrefclever@required@kernel\space or newer.%
168 }%
169 }%
170 % \end{macrocode}
171 %
172 %
173 % Identify the package.
174 % \begin{macrocode}
175 \ProvidesExplPackage {zref-clever} {2024-11-28} {0.5.1}
176 {Clever LaTeX cross-references based on zref}
177 % \end{macrocode}
178 %
179 %
180 % \section{Dependencies}
181 %
182 % Required packages. Besides these, \pkg{zref-hyperref} may also be loaded
183 % depending on user options. \pkg{zref-clever} also requires UTF-8 input
184 % encoding (see discussion with \contributor{David Carlisle} at
185 % \url{https://chat.stackexchange.com/transcript/message/62644791#62644791}).
186 %
187 % \begin{macrocode}
188 \RequirePackage { zref-base }
189 \RequirePackage { zref-user }
190 \RequirePackage { zref-abspage }
191 \RequirePackage { ifdraft }
192 % \end{macrocode}
193 %
194 %
195 % \section{\pkg{zref} setup}
196 %
197 % For the purposes of the package, we need to store some information with the
198 % labels, some of it standard, some of it not so much. So, we have to setup
199 % \pkg{zref} to do so.
200 %
201 % Some basic properties are handled by \pkg{zref} itself, or some of its
202 % modules. The \texttt{default} and \texttt{page} properties are provided by
203 % \pkg{zref-base}, while \pkg{zref-abspage} provides the \texttt{abspage}
204 % property which gives us a safe and easy way to sort labels for page
205 % references.
206 %
207 % The \texttt{counter} property, in most cases, will be just the kernel's
208 % \cs{@currentcounter}, set by \cs{refstepcounter}. However, not everywhere
209 % is it assured that \cs{@currentcounter} gets updated as it should, so we
210 % need to have some means to manually tell \pkg{zref-clever} what the current
211 % counter actually is. This is done with the \opt{currentcounter} option, and
212 % stored in \cs{l_@@_current_counter_tl}, whose default is
213 % \cs{@currentcounter}.
214 %
215 % \begin{macrocode}
216 \zref@newprop { zc@counter } { \l_@@_current_counter_tl }
217 \zref@addprop \ZREF@mainlist { zc@counter }
218 % \end{macrocode}
219 %
220 % The reference itself, stored by \pkg{zref-base} in the \texttt{default}
221 % property, is somewhat a disputed real estate. In particular, the use of
222 % \cs{labelformat} (previously from \pkg{varioref}, now in the kernel) will
223 % include there the reference ``prefix'' and complicate the job we are trying
224 % to do here. Hence, we isolate \cs[no-index]{the}\meta{counter} and store it
225 % ``clean'' in \texttt{thecounter} for reserved use. Since
226 % \cs{@currentlabel}, which populates the \texttt{default} property, is
227 % \emph{more reliable} than \cs{@currentcounter}, \texttt{thecounter} is meant
228 % to be kept as an \emph{option} (\opt{ref} option), in case there's need to
229 % use \pkg{zref-clever} together with \cs{labelformat}. Based on the
230 % definition of \cs{@currentlabel} done inside \cs{refstepcounter} in
231 % \texttt{texdoc source2e}, section \texttt{ltxref.dtx}. We just drop the
232 % \cs[no-index]{p@...} prefix.
233 %
234 % \begin{macrocode}
235 \zref@newprop { thecounter }
236 {
237 \cs_if_exist:cTF { c@ \l_@@_current_counter_tl }
238 { \use:c { the \l_@@_current_counter_tl } }
239 {
240 \cs_if_exist:cT { c@ \@currentcounter }
241 { \use:c { the \@currentcounter } }
242 }
243 }
244 \zref@addprop \ZREF@mainlist { thecounter }
245 % \end{macrocode}
246 %
247 %
248 % Much of the work of \pkg{zref-clever} relies on the association between a
249 % label's ``counter'' and its ``type'' (see the User manual section on
250 % ``Reference types''). Superficially examined, one might think this relation
251 % could just be stored in a global property list, rather than in the label
252 % itself. However, there are cases in which we want to distinguish different
253 % types for the same counter, depending on the document context. Hence, we
254 % need to store the ``type'' of the ``counter'' for each ``label''. In
255 % setting this, the presumption is that the label's type has the same name as
256 % its counter, unless it is specified otherwise by the \opt{countertype}
257 % option, as stored in \cs{l_@@_counter_type_prop}.
258 %
259 % \begin{macrocode}
260 \zref@newprop { zc@type }
261 {
262 \tl_if_empty:NTF \l_@@_reftype_override_tl
263 {
264 \exp_args:NNe \prop_if_in:NnTF \l_@@_counter_type_prop
265 \l_@@_current_counter_tl
266 {
267 \exp_args:NNe \prop_item:Nn \l_@@_counter_type_prop
268 { \l_@@_current_counter_tl }
269 }
270 { \l_@@_current_counter_tl }
271 }
272 { \l_@@_reftype_override_tl }
273 }
274 \zref@addprop \ZREF@mainlist { zc@type }
275 % \end{macrocode}
276 %
277 %
278 % Since the \texttt{default}/\texttt{thecounter} and \texttt{page} properties
279 % store the ``\emph{printed} representation'' of their respective counters,
280 % for sorting and compressing purposes, we are also interested in their
281 % numeric values. So we store them in \texttt{zc@cntval} and
282 % \texttt{zc@pgval}. For this, we use \cs[no-index]{c@}\meta{counter}, which
283 % contains the counter's numerical value (see `texdoc source2e', section
284 % `ltcounts.dtx'). Also, even if we can't find a valid \cs{@currentcounter},
285 % we set the value of 0 to the property, so that it is never empty (the
286 % property's default is not sufficient to avoid that), because we rely on this
287 % value being a number and an empty value there will result in ``Missing
288 % number, treated as zero.'' error. A typical situation where this might
289 % occur is the user setting a label before \cs{refstepcounter} is called for
290 % the first time in the document. A user error, no doubt, but we should avoid
291 % a hard crash.
292 % \begin{macrocode}
293 \zref@newprop { zc@cntval } [0]
294 {
295 \bool_lazy_and:nnTF
296 { ! \tl_if_empty_p:N \l_@@_current_counter_tl }
297 { \cs_if_exist_p:c { c@ \l_@@_current_counter_tl } }
298 { \int_use:c { c@ \l_@@_current_counter_tl } }
299 {
300 \bool_lazy_and:nnTF
301 { ! \tl_if_empty_p:N \@currentcounter }
302 { \cs_if_exist_p:c { c@ \@currentcounter } }
303 { \int_use:c { c@ \@currentcounter } }
304 { 0 }
305 }
306 }
307 \zref@addprop \ZREF@mainlist { zc@cntval }
308 \zref@newprop* { zc@pgval } [0] { \int_use:c { c@page } }
309 \zref@addprop \ZREF@mainlist { zc@pgval }
310 % \end{macrocode}
311 %
312 %
313 % However, since many counters (may) get reset along the document, we require
314 % more than just their numeric values. We need to know the reset chain of a
315 % given counter, in order to sort and compress a group of references. Also
316 % here, the ``printed representation'' is not enough, not only because it is
317 % easier to work with the numeric values but, given we occasionally group
318 % multiple counters within a single type, sorting this group requires to know
319 % the actual counter reset chain.
320 %
321 % Furthermore, even if it is true that most of the definitions of counters,
322 % and hence of their reset behavior, is likely to be defined in the preamble,
323 % this is not necessarily true. Users can create counters, newtheorems
324 % mid-document, and alter their reset behavior along the way. Was that not
325 % the case, we could just store the desired information at
326 % \texttt{begindocument} in a variable and retrieve it when needed. But since
327 % it is, we need to store the information with the label, with the values as
328 % current when the label is set.
329 %
330 % Though counters can be reset at any time, and in different ways at that, the
331 % most important use case is the automatic resetting of counters when some
332 % other counter is stepped, as performed by the standard mechanisms of the
333 % kernel (optional argument of \cs{newcounter}, \cs{@addtoreset},
334 % \cs{counterwithin}, and related infrastructure). The canonical optional
335 % argument of \cs{newcounter} establishes that the counter being created (the
336 % mandatory argument) gets reset every time the ``enclosing counter'' gets
337 % stepped (this is called in the usual sources ``within-counter'', ``old
338 % counter'', ``supercounter'', ``parent counter'' etc.). This information is
339 % somewhat tricky to get. For starters, the counters which may reset the
340 % current counter are not retrievable from the counter itself, because this
341 % information is stored with the counter that does the resetting, not with the
342 % one that gets reset (the list is stored in \cs[no-index]{cl@}\meta{counter}
343 % with format
344 % \texttt{\cs{@elt}\{countera\}\cs{@elt}\{counterb\}\cs{@elt}\{counterc\}},
345 % see \file{ltcounts.dtx} in \texttt{texdoc source2e}). Besides, there may be
346 % a chain of resetting counters, which must be taken into account: if
347 % \texttt{counterC} gets reset by \texttt{counterB}, and \texttt{counterB}
348 % gets reset by \texttt{counterA}, stepping the latter affects all three of
349 % them.
350 %
351 % The procedure below examines a set of counters, those in
352 % \cs{l_@@_counter_resetters_seq}, and for each of them retrieves the set of
353 % counters it resets, as stored in \cs[no-index]{cl@}\meta{counter}, looking
354 % for the counter for which we are trying to set a label
355 % (\cs{l_@@_current_counter_tl}, by default \cs{@currentcounter}, passed as an
356 % argument to the functions). There is one relevant caveat to this procedure:
357 % \cs{l_@@_counter_resetters_seq} is populated by hand with the ``usual
358 % suspects'', there is no way (that I know of) to ensure it is exhaustive.
359 % However, it is not that difficult to create a reasonable ``usual suspects''
360 % list which, of course, should include the counters for the sectioning
361 % commands to start with, and it is easy to add more counters to this list if
362 % needed, with the option \opt{counterresetters}. Unfortunately, not all
363 % counters are created alike, or reset alike. Some counters, even some kernel
364 % ones, get reset by other mechanisms (notably, the \texttt{enumerate}
365 % environment counters do not use the regular counter machinery for resetting
366 % on each level, but are nested nevertheless by other means). Therefore,
367 % inspecting \cs[no-index]{cl@}\meta{counter} cannot possibly fully account
368 % for all of the automatic counter resetting which takes place in the
369 % document. And there's also no other ``general rule'' we could grab on for
370 % this, as far as I know. So we provide a way to manually tell
371 % \pkg{zref-clever} of these cases, by means of the \opt{counterresetby}
372 % option, whose information is stored in \cs{l_@@_counter_resetby_prop}. This
373 % manual specification has precedence over the search through
374 % \cs{l_@@_counter_resetters_seq}, and should be handled with care, since
375 % there is no possible verification mechanism for this.
376 %
377 %
378 % \begin{macro}[EXP]
379 % {
380 % \@@_get_enclosing_counters:n ,
381 % \@@_get_enclosing_counters_value:n ,
382 % }
383 % Recursively generate a \emph{sequence} of ``enclosing counters'' and
384 % values, for a given \meta{counter} and leave it in the input stream.
385 % These functions must be expandable, since they get called from
386 % \cs{zref@newprop} and are the ones responsible for generating the desired
387 % information when the label is being set. Note that the order in which we
388 % are getting this information is reversed, since we are navigating the
389 % counter reset chain bottom-up. But it is very hard to do otherwise here
390 % where we need expandable functions, and easy to handle at the reading
391 % side.
392 % \begin{syntax}
393 % \cs{@@_get_enclosing_counters:n} \Arg{counter}
394 % \cs{@@_get_enclosing_counters_value:n} \Arg{counter}
395 % \end{syntax}
396 % \begin{macrocode}
397 \cs_new:Npn \@@_get_enclosing_counters:n #1
398 {
399 \cs_if_exist:cT { c@ \@@_counter_reset_by:n {#1} }
400 {
401 { \@@_counter_reset_by:n {#1} }
402 \@@_get_enclosing_counters:e
403 { \@@_counter_reset_by:n {#1} }
404 }
405 }
406 \cs_new:Npn \@@_get_enclosing_counters_value:n #1
407 {
408 \cs_if_exist:cT { c@ \@@_counter_reset_by:n {#1} }
409 {
410 { \int_use:c { c@ \@@_counter_reset_by:n {#1} } }
411 \@@_get_enclosing_counters_value:e
412 { \@@_counter_reset_by:n {#1} }
413 }
414 }
415 % \end{macrocode}
416 %
417 % \begin{macrocode}
418 \cs_generate_variant:Nn \@@_get_enclosing_counters:n { e }
419 \cs_generate_variant:Nn \@@_get_enclosing_counters_value:n { e }
420 % \end{macrocode}
421 % \end{macro}
422 %
423 %
424 % \begin{macro}[EXP]{\@@_counter_reset_by:n}
425 % Auxiliary function for \cs{@@_get_enclosing_counters:n} and
426 % \cs{@@_get_enclosing_counters_value:n}, and useful on its own standing.
427 % It is broken in parts to be able to use the expandable mapping functions.
428 % \cs{@@_counter_reset_by:n} leaves in the stream the ``enclosing counter''
429 % which resets \meta{counter}.
430 % \begin{syntax}
431 % \cs{@@_counter_reset_by:n} \Arg{counter}
432 % \end{syntax}
433 % \begin{macrocode}
434 \cs_new:Npn \@@_counter_reset_by:n #1
435 {
436 \bool_if:nTF
437 { \prop_if_in_p:Nn \l_@@_counter_resetby_prop {#1} }
438 { \prop_item:Nn \l_@@_counter_resetby_prop {#1} }
439 {
440 \seq_map_tokens:Nn \l_@@_counter_resetters_seq
441 { \@@_counter_reset_by_aux:nn {#1} }
442 }
443 }
444 \cs_new:Npn \@@_counter_reset_by_aux:nn #1#2
445 {
446 \cs_if_exist:cT { c@ #2 }
447 {
448 \tl_if_empty:cF { cl@ #2 }
449 {
450 \tl_map_tokens:cn { cl@ #2 }
451 { \@@_counter_reset_by_auxi:nnn {#2} {#1} }
452 }
453 }
454 }
455 \cs_new:Npn \@@_counter_reset_by_auxi:nnn #1#2#3
456 {
457 \str_if_eq:nnT {#2} {#3}
458 { \tl_map_break:n { \seq_map_break:n {#1} } }
459 }
460 % \end{macrocode}
461 % \end{macro}
462 %
463 %
464 % Finally, we create the \texttt{zc@enclval} property, and add it to the
465 % \texttt{main} property list.
466 % \begin{macrocode}
467 \zref@newprop { zc@enclval }
468 {
469 \@@_get_enclosing_counters_value:e
470 { \l_@@_current_counter_tl }
471 }
472 \zref@addprop \ZREF@mainlist { zc@enclval }
473 % \end{macrocode}
474 %
475 % The \texttt{zc@enclcnt} property is provided for the purpose of easing the
476 % debugging of counter reset chains, thus it is not added \texttt{main}
477 % property list by default.
478 % \begin{macrocode}
479 \zref@newprop { zc@enclcnt }
480 { \@@_get_enclosing_counters:e \l_@@_current_counter_tl }
481 % \end{macrocode}
482 %
483 %
484 % Another piece of information we need is the page numbering format being used
485 % by \cs{thepage}, so that we know when we can (or not) group a set of page
486 % references in a range. Unfortunately, \texttt{page} is not a typical
487 % counter in ways which complicates things. First, it does commonly get reset
488 % along the document, not necessarily by the usual counter reset chains, but
489 % rather with \cs{pagenumbering} or variations thereof. Second, the format of
490 % the page number commonly changes in the document (roman, arabic, etc.), not
491 % necessarily, though usually, together with a reset. Trying to ``parse''
492 % \cs{thepage} to retrieve such information is bound to go wrong: we don't
493 % know, and can't know, what is within that macro, and that's the business of
494 % the user, or of the documentclass, or of the loaded packages. The technique
495 % used by \pkg{cleveref}, is simple and smart: store with the label what
496 % \cs{thepage} would return, if the counter \cs{c@page} was ``\(1\)''. That
497 % would not allow us to \emph{sort} the references, luckily however, we have
498 % \texttt{abspage} which solves this problem. But we can decide whether two
499 % labels can be compressed into a range or not based on this format: if they
500 % are identical, we can compress them, otherwise, we can't. However,
501 % expanding \cs{thepage} can lead to errors for some \pkg{babel} packages
502 % which redefine \cs{roman} containing non-expandable material (see
503 % \url{https://chat.stackexchange.com/transcript/message/63810027#63810027},
504 % \url{https://chat.stackexchange.com/transcript/message/63810318#63810318},
505 % \url{https://chat.stackexchange.com/transcript/message/63810720#63810720}
506 % and discussion). So I went for something a little different. As mentioned,
507 % we want to know if \cs{thepage} is the same for different labels, or if it
508 % has changed. We can thus test this directly, by comparing \cs{thepage} with
509 % a stored value of it, \cs{g_@@_prev_page_format_tl}, and stepping a counter
510 % every time they differ. Of course, this cannot be done at label setting
511 % time, since it is not expandable. But we can do that comparison before
512 % shipout and then define the label property as starred
513 % (\texttt{\cs{zref@newprop}*\{zc@pgfmt\}}), so that the label comes after the
514 % counter, and we can get the correct value of the counter.
515 %
516 % \begin{macrocode}
517 \int_new:N \g_@@_page_format_int
518 \tl_new:N \g_@@_prev_page_format_tl
519 \AddToHook { shipout / before }
520 {
521 \tl_if_eq:NNF \g_@@_prev_page_format_tl \thepage
522 {
523 \int_gincr:N \g_@@_page_format_int
524 \tl_gset_eq:NN \g_@@_prev_page_format_tl \thepage
525 }
526 }
527 \zref@newprop* { zc@pgfmt } { \int_use:N \g_@@_page_format_int }
528 \zref@addprop \ZREF@mainlist { zc@pgfmt }
529 % \end{macrocode}
530 %
531 %
532 % Still some other properties which we don't need to handle at the data
533 % provision side, but need to cater for at the retrieval side, are the ones
534 % from the \pkg{zref-xr} module, which are added to the labels imported from
535 % external documents, and needed to construct hyperlinks to them and to
536 % distinguish them from the current document ones at sorting and compressing:
537 % \texttt{urluse}, \texttt{url} and \texttt{externaldocument}.
538 %
539 %
540 %
541 % \section{Plumbing}
542 %
543 %
544 % \subsection{Auxiliary}
545 %
546 %
547 % \begin{macro}
548 % {
549 % \@@_if_package_loaded:n ,
550 % \@@_if_class_loaded:n ,
551 % }
552 % Just a convenience, since sometimes we just need one of the branches, and
553 % it is particularly easy to miss the empty F branch after a long T one.
554 % \begin{macrocode}
555 \prg_new_conditional:Npnn \@@_if_package_loaded:n #1 { T , F , TF }
556 { \IfPackageLoadedTF {#1} { \prg_return_true: } { \prg_return_false: } }
557 \prg_new_conditional:Npnn \@@_if_class_loaded:n #1 { T , F , TF }
558 { \IfClassLoadedTF {#1} { \prg_return_true: } { \prg_return_false: } }
559 % \end{macrocode}
560 % \end{macro}
561 %
562 %
563 % \begin{macro}
564 % {
565 % \l_@@_tmpa_tl ,
566 % \l_@@_tmpb_tl ,
567 % \l_@@_tmpa_seq ,
568 % \g_@@_tmpa_seq ,
569 % \l_@@_tmpa_bool ,
570 % \l_@@_tmpa_int ,
571 % }
572 % Temporary scratch variables.
573 % \begin{macrocode}
574 \tl_new:N \l_@@_tmpa_tl
575 \tl_new:N \l_@@_tmpb_tl
576 \seq_new:N \l_@@_tmpa_seq
577 \seq_new:N \g_@@_tmpa_seq
578 \bool_new:N \l_@@_tmpa_bool
579 \int_new:N \l_@@_tmpa_int
580 % \end{macrocode}
581 % \end{macro}
582 %
583 %
584 % \subsection{Messages}
585 %
586 %
587 % \begin{macrocode}
588 \msg_new:nnn { zref-clever } { option-not-type-specific }
589 {
590 Option~'#1'~is~not~type-specific~\msg_line_context:.~
591 Set~it~in~'\iow_char:N\\zcLanguageSetup'~before~first~'type'~
592 switch~or~as~package~option.
593 }
594 \msg_new:nnn { zref-clever } { option-only-type-specific }
595 {
596 No~type~specified~for~option~'#1'~\msg_line_context:.~
597 Set~it~after~'type'~switch.
598 }
599 \msg_new:nnn { zref-clever } { key-requires-value }
600 { The~'#1'~key~'#2'~requires~a~value~\msg_line_context:. }
601 \msg_new:nnn { zref-clever } { language-declared }
602 { Language~'#1'~is~already~declared~\msg_line_context:.~Nothing~to~do. }
603 \msg_new:nnn { zref-clever } { unknown-language-alias }
604 {
605 Language~'#1'~is~unknown~\msg_line_context:.~Can't~alias~to~it.~
606 See~documentation~for~'\iow_char:N\\zcDeclareLanguage'~and~
607 '\iow_char:N\\zcDeclareLanguageAlias'.
608 }
609 \msg_new:nnn { zref-clever } { unknown-language-setup }
610 {
611 Language~'#1'~is~unknown~\msg_line_context:.~Can't~set~it~up.~
612 See~documentation~for~'\iow_char:N\\zcDeclareLanguage'~and~
613 '\iow_char:N\\zcDeclareLanguageAlias'.
614 }
615 \msg_new:nnn { zref-clever } { unknown-language-opt }
616 {
617 Language~'#1'~is~unknown~\msg_line_context:.~
618 See~documentation~for~'\iow_char:N\\zcDeclareLanguage'~and~
619 '\iow_char:N\\zcDeclareLanguageAlias'.
620 }
621 \msg_new:nnn { zref-clever } { unknown-language-variant }
622 {
623 Can't~set~variant~'#1'~for~unknown~language~'#2'~\msg_line_context:.~
624 See~documentation~for~'\iow_char:N\\zcDeclareLanguage'~and~
625 '\iow_char:N\\zcDeclareLanguageAlias'.
626 }
627 \msg_new:nnn { zref-clever } { language-no-variants-ref }
628 {
629 Language~'#1'~has~no~declared~variants~\msg_line_context:.~
630 Nothing~to~do~with~option~'v=#2'.
631 }
632 \msg_new:nnn { zref-clever } { language-no-gender }
633 {
634 Language~'#1'~has~no~declared~gender~\msg_line_context:.~
635 Nothing~to~do~with~option~'#2=#3'.
636 }
637 \msg_new:nnn { zref-clever } { language-no-variants-setup }
638 {
639 Language~'#1'~has~no~declared~variants~\msg_line_context:.~
640 Nothing~to~do~with~option~'variant=#2'.
641 }
642 \msg_new:nnn { zref-clever } { unknown-variant }
643 {
644 Variant~'#1'~unknown~for~language~'#2'~\msg_line_context:.~
645 Using~default~variant.
646 }
647 \msg_new:nnn { zref-clever } { nudge-multitype }
648 {
649 Reference~with~multiple~types~\msg_line_context:.~
650 You~may~wish~to~separate~them~or~review~language~around~it.
651 }
652 \msg_new:nnn { zref-clever } { nudge-comptosing }
653 {
654 Multiple~labels~have~been~compressed~into~singular~type~name~
655 for~type~'#1'~\msg_line_context:.
656 }
657 \msg_new:nnn { zref-clever } { nudge-plural-when-sg }
658 {
659 Option~'sg'~signals~that~a~singular~type~name~was~expected~
660 \msg_line_context:.~But~type~'#1'~has~plural~type~name.
661 }
662 \msg_new:nnn { zref-clever } { gender-not-declared }
663 { Language~'#1'~has~no~'#2'~gender~declared~\msg_line_context:. }
664 \msg_new:nnn { zref-clever } { nudge-gender-mismatch }
665 {
666 Gender~mismatch~for~type~'#1'~\msg_line_context:.~
667 You've~specified~'g=#2'~but~type~name~is~'#3'~for~language~'#4'.
668 }
669 \msg_new:nnn { zref-clever } { nudge-gender-not-declared-for-type }
670 {
671 You've~specified~'g=#1'~\msg_line_context:.~
672 But~gender~for~type~'#2'~is~not~declared~for~language~'#3'.
673 }
674 \msg_new:nnn { zref-clever } { nudgeif-unknown-value }
675 { Unknown~value~'#1'~for~'nudgeif'~option~\msg_line_context:. }
676 \msg_new:nnn { zref-clever } { option-document-only }
677 { Option~'#1'~is~only~available~after~\iow_char:N\\begin\{document\}. }
678 \msg_new:nnn { zref-clever } { langfile-loaded }
679 { Loaded~'#1'~language~file. }
680 \msg_new:nnn { zref-clever } { zref-property-undefined }
681 {
682 Option~'ref=#1'~requested~\msg_line_context:.~
683 But~the~property~'#1'~is~not~declared,~falling-back~to~'default'.
684 }
685 \msg_new:nnn { zref-clever } { endrange-property-undefined }
686 {
687 Option~'endrange=#1'~requested~\msg_line_context:.~
688 But~the~property~'#1'~is~not~declared,~'endrange'~not~set.
689 }
690 \msg_new:nnn { zref-clever } { hyperref-preamble-only }
691 {
692 Option~'hyperref'~only~available~in~the~preamble~\msg_line_context:.~
693 To~inhibit~hyperlinking~locally,~you~can~use~the~starred~version~of~
694 '\iow_char:N\\zcref'.
695 }
696 \msg_new:nnn { zref-clever } { missing-hyperref }
697 { Missing~'hyperref'~package.~Setting~'hyperref=false'. }
698 \msg_new:nnn { zref-clever } { option-preamble-only }
699 { Option~'#1'~only~available~in~the~preamble~\msg_line_context:. }
700 \msg_new:nnn { zref-clever } { unknown-compat-module }
701 {
702 Unknown~compatibility~module~'#1'~given~to~option~'nocompat'.~
703 Nothing~to~do.
704 }
705 \msg_new:nnn { zref-clever } { refbounds-must-be-four }
706 {
707 The~value~of~option~'#1'~must~be~a~comma~sepatared~list~
708 of~four~items.~We~received~'#2'~items~\msg_line_context:.~
709 Option~not~set.
710 }
711 \msg_new:nnn { zref-clever } { missing-zref-check }
712 {
713 Option~'check'~requested~\msg_line_context:.~
714 But~package~'zref-check'~is~not~loaded,~can't~run~the~checks.
715 }
716 \msg_new:nnn { zref-clever } { zref-check-too-old }
717 {
718 Option~'check'~requested~\msg_line_context:.~
719 But~'zref-check'~newer~than~'#1'~is~required,~can't~run~the~checks.
720 }
721 \msg_new:nnn { zref-clever } { missing-type }
722 { Reference~type~undefined~for~label~'#1'~\msg_line_context:. }
723 \msg_new:nnn { zref-clever } { missing-property }
724 { Reference~property~'#1'~undefined~for~label~'#2'~\msg_line_context:. }
725 \msg_new:nnn { zref-clever } { missing-name }
726 { Reference~format~option~'#1'~undefined~for~type~'#2'~\msg_line_context:. }
727 \msg_new:nnn { zref-clever } { single-element-range }
728 { Range~for~type~'#1'~resulted~in~single~element~\msg_line_context:. }
729 \msg_new:nnn { zref-clever } { compat-package }
730 { Loaded~support~for~'#1'~package. }
731 \msg_new:nnn { zref-clever } { compat-class }
732 { Loaded~support~for~'#1'~documentclass. }
733 \msg_new:nnn { zref-clever } { option-deprecated }
734 {
735 Option~'#1'~has~been~deprecated~\msg_line_context:.\iow_newline:
736 Use~'#2'~instead.
737 }
738 \msg_new:nnn { zref-clever } { load-time-options }
739 {
740 'zref-clever'~does~not~accept~load-time~options.~
741 To~configure~package~options,~use~'\iow_char:N\\zcsetup'.
742 }
743 % \end{macrocode}
744 %
745 %
746 % \subsection{Data extraction}
747 %
748 %
749 % \begin{macro}{\@@_extract_default:Nnnn}
750 % Extract property \meta{prop} from \meta{label} and sets variable \meta{tl
751 % var} with extracted value. Ensure \cs{zref@extractdefault} is expanded
752 % exactly twice, but no further to retrieve the proper value. In case the
753 % property is not found, set \meta{tl var} with \meta{default}.
754 % \begin{syntax}
755 % \cs{@@_extract_default:Nnnn} \Arg{tl var}
756 % ~~\Arg{label} \Arg{prop} \Arg{default}
757 % \end{syntax}
758 % \begin{macrocode}
759 \cs_new_protected:Npn \@@_extract_default:Nnnn #1#2#3#4
760 {
761 \exp_args:NNNo \exp_args:NNo \tl_set:Nn #1
762 { \zref@extractdefault {#2} {#3} {#4} }
763 }
764 \cs_generate_variant:Nn \@@_extract_default:Nnnn { NVnn , Nnvn }
765 % \end{macrocode}
766 % \end{macro}
767 %
768 % \begin{macro}{\@@_extract_unexp:nnn}
769 % Extract property \meta{prop} from \meta{label}. Ensure that, in the
770 % context of an e expansion, \cs{zref@extractdefault} is expanded exactly
771 % twice, but no further to retrieve the proper value. Thus, this is meant
772 % to be use in an e expansion context, not in other situations. In case the
773 % property is not found, leave \meta{default} in the stream.
774 % \begin{syntax}
775 % \cs{@@_extract_unexp:nnn}\Arg{label}\Arg{prop}\Arg{default}
776 % \end{syntax}
777 % \begin{macrocode}
778 \cs_new:Npn \@@_extract_unexp:nnn #1#2#3
779 {
780 \exp_args:NNo \exp_args:No
781 \exp_not:n { \zref@extractdefault {#1} {#2} {#3} }
782 }
783 \cs_generate_variant:Nn \@@_extract_unexp:nnn { Vnn , nvn , Vvn }
784 % \end{macrocode}
785 % \end{macro}
786 %
787 % \begin{macro}{\@@_extract:nnn}
788 % An internal version for \cs{zref@extractdefault}.
789 % \begin{syntax}
790 % \cs{@@_extract:nnn}\Arg{label}\Arg{prop}\Arg{default}
791 % \end{syntax}
792 % \begin{macrocode}
793 \cs_new:Npn \@@_extract:nnn #1#2#3
794 { \zref@extractdefault {#1} {#2} {#3} }
795 % \end{macrocode}
796 % \end{macro}
797 %
798 %
799 % \subsection{Option infra}
800 %
801 % This section provides the functions in which the variables naming scheme of
802 % the package options is embodied, and some basic general functions to query
803 % these option variables.
804 %
805 % I had originally implemented the option handling of the package based on
806 % property lists, which are definitely very convenient. But as the number of
807 % options grew, I started to get concerned about the performance implications.
808 % That there was a toll was noticeable, even when we could live with it, of
809 % course. Indeed, at the time of writing, the typesetting of a reference
810 % queries about 24 different option values, most of them once per type-block,
811 % each of these queries can be potentially made in up to 5 option scope
812 % levels. Considering the size of the built-in language files is running at
813 % the hundreds, the package does have a lot of work to do in querying option
814 % values alone, and thus it is best to smooth things in this area as much as
815 % possible. This also gives me some peace of mind that the package will scale
816 % well in the long term. For some interesting discussion about alternative
817 % methods and their performance implications, see
818 % \url{https://tex.stackexchange.com/q/147966}. \contributor{Phelype Oleinik}
819 % also offered some insight on the matter at
820 % \url{https://tex.stackexchange.com/questions/629946/#comment1571118_629946}.
821 % The only real downside of this change is that we can no longer list the
822 % whole set of options in place at a given moment, which was useful for the
823 % purposes of regression testing, since we don't know what the whole set of
824 % active options is.
825 %
826 %
827 % \begin{macro}[EXP]{\@@_opt_varname_general:nn}
828 % Defines, and leaves in the input stream, the csname of the variable used
829 % to store the general \meta{option}. The data type of the variable must be
830 % specified (\texttt{tl}, \texttt{seq}, \texttt{bool}, etc.).
831 % \begin{syntax}
832 % \cs{@@_opt_varname_general:nn} \Arg{option} \Arg{data type}
833 % \end{syntax}
834 % \begin{macrocode}
835 \cs_new:Npn \@@_opt_varname_general:nn #1#2
836 { l_@@_opt_general_ #1 _ #2 }
837 % \end{macrocode}
838 % \end{macro}
839 %
840 % \begin{macro}[EXP]{\@@_opt_varname_type:nnn}
841 % Defines, and leaves in the input stream, the csname of the variable used
842 % to store the type-specific \meta{option} for \meta{ref type}.
843 % \begin{syntax}
844 % \cs{@@_opt_varname_type:nnn} \Arg{ref type} \Arg{option} \Arg{data type}
845 % \end{syntax}
846 % \begin{macrocode}
847 \cs_new:Npn \@@_opt_varname_type:nnn #1#2#3
848 { l_@@_opt_type_ #1 _ #2 _ #3 }
849 \cs_generate_variant:Nn \@@_opt_varname_type:nnn { enn , een }
850 % \end{macrocode}
851 % \end{macro}
852 %
853 % \begin{macro}[EXP]{\@@_opt_varname_language:nnn}
854 % Defines, and leaves in the input stream, the csname of the variable used
855 % to store the language \meta{option} for \meta{lang} (for general language
856 % options, those set with \cs{zcDeclareLanguage}). The
857 % ``\texttt{lang_unknown}'' branch should be guarded against, such as we
858 % normally should not get there, but this function \emph{must} return some
859 % valid csname. The random part is there so that, in the circumstance this
860 % could not be avoided, we (hopefully) don't retrieve the value for an
861 % ``unknown language'' inadvertently.
862 % \begin{syntax}
863 % \cs{@@_opt_varname_language:nnn} \Arg{lang} \Arg{option} \Arg{data type}
864 % \end{syntax}
865 % \begin{macrocode}
866 \cs_new:Npn \@@_opt_varname_language:nnn #1#2#3
867 {
868 \@@_language_if_declared:nTF {#1}
869 {
870 g_@@_opt_language_
871 \tl_use:c { \@@_language_varname:n {#1} }
872 _ #2 _ #3
873 }
874 { g_@@_opt_lang_unknown_ \int_rand:n { 1000000 } _ #3 }
875 }
876 \cs_generate_variant:Nn \@@_opt_varname_language:nnn { enn }
877 % \end{macrocode}
878 % \end{macro}
879 %
880 % \begin{macro}[EXP]{\@@_opt_varname_lang_default:nnn}
881 % Defines, and leaves in the input stream, the csname of the variable used
882 % to store the language-specific default reference format \meta{option} for
883 % \meta{lang}.
884 % \begin{syntax}
885 % \cs{@@_opt_varname_lang_default:nnn} \Arg{lang} \Arg{option} \Arg{data type}
886 % \end{syntax}
887 % \begin{macrocode}
888 \cs_new:Npn \@@_opt_varname_lang_default:nnn #1#2#3
889 {
890 \@@_language_if_declared:nTF {#1}
891 {
892 g_@@_opt_lang_
893 \tl_use:c { \@@_language_varname:n {#1} }
894 _default_ #2 _ #3
895 }
896 { g_@@_opt_lang_unknown_ \int_rand:n { 1000000 } _ #3 }
897 }
898 \cs_generate_variant:Nn \@@_opt_varname_lang_default:nnn { enn }
899 % \end{macrocode}
900 % \end{macro}
901 %
902 % \begin{macro}[EXP]{\@@_opt_varname_lang_type:nnnn}
903 % Defines, and leaves in the input stream, the csname of the variable used
904 % to store the language- and type-specific reference format \meta{option}
905 % for \meta{lang} and \meta{ref type}.
906 % \begin{syntax}
907 % \cs{@@_opt_varname_lang_type:nnnn} \Arg{lang} \Arg{ref type}
908 % ~~\Arg{option} \Arg{data type}
909 % \end{syntax}
910 % \begin{macrocode}
911 \cs_new:Npn \@@_opt_varname_lang_type:nnnn #1#2#3#4
912 {
913 \@@_language_if_declared:nTF {#1}
914 {
915 g_@@_opt_lang_
916 \tl_use:c { \@@_language_varname:n {#1} }
917 _type_ #2 _ #3 _ #4
918 }
919 { g_@@_opt_lang_unknown_ \int_rand:n { 1000000 } _ #4 }
920 }
921 \cs_generate_variant:Nn
922 \@@_opt_varname_lang_type:nnnn { eenn , eeen }
923 % \end{macrocode}
924 % \end{macro}
925 %
926 % \begin{macro}[EXP]{\@@_opt_varname_fallback:nn}
927 % Defines, and leaves in the input stream, the csname of the variable used
928 % to store the fallback \meta{option}.
929 % \begin{syntax}
930 % \cs{@@_opt_varname_fallback:nn} \Arg{option} \Arg{data type}
931 % \end{syntax}
932 % \begin{macrocode}
933 \cs_new:Npn \@@_opt_varname_fallback:nn #1#2
934 { c_@@_opt_fallback_ #1 _ #2 }
935 % \end{macrocode}
936 % \end{macro}
937 %
938 %
939 % \begin{macro}[EXP]{\@@_opt_var_set_bool:n}
940 % The \LaTeX3 programming layer does not have the concept of a variable
941 % \emph{existing} only locally, it also considers an ``error'' if an
942 % assignment is made to a variable which was not previously declared, but
943 % declaration is always global, which means that ``setting a local variable
944 % at a local scope'', given these requirements, results in it existing, and
945 % being empty, globally. Therefore, we need an independent mechanism from
946 % the mere existence of a variable to keep track of whether variables are
947 % ``set'' or ``unset'', within the logic of the precedence rules for options
948 % in different scopes. \cs{@@_opt_var_set_bool:n} expands to the name of
949 % the boolean variable used to track this state for \meta{option var}. See
950 % discussion with \contributor{Phelype Oleinik} at
951 % \url{https://tex.stackexchange.com/questions/633341/#comment1579825_633347}
952 % \begin{syntax}
953 % \cs{@@_opt_var_set_bool:n} \Arg{option var}
954 % \end{syntax}
955 % \begin{macrocode}
956 \cs_new:Npn \@@_opt_var_set_bool:n #1
957 { \cs_to_str:N #1 _is_set_bool }
958 % \end{macrocode}
959 % \end{macro}
960 %
961 %
962 %
963 % \begin{macro}
964 % {
965 % \@@_opt_tl_set:Nn ,
966 % \@@_opt_tl_clear:N ,
967 % \@@_opt_tl_gset:Nn ,
968 % \@@_opt_tl_gclear:N ,
969 % }
970 % \begin{syntax}
971 % \cs{@@_opt_tl_set:N} \Arg{option tl} \Arg{value}
972 % \cs{@@_opt_tl_clear:N} \Arg{option tl}
973 % \cs{@@_opt_tl_gset:N} \Arg{option tl} \Arg{value}
974 % \cs{@@_opt_tl_gclear:N} \Arg{option tl}
975 % \end{syntax}
976 % \begin{macrocode}
977 \cs_new_protected:Npn \@@_opt_tl_set:Nn #1#2
978 {
979 \tl_if_exist:NF #1
980 { \tl_new:N #1 }
981 \tl_set:Nn #1 {#2}
982 \bool_if_exist:cF { \@@_opt_var_set_bool:n {#1} }
983 { \bool_new:c { \@@_opt_var_set_bool:n {#1} } }
984 \bool_set_true:c { \@@_opt_var_set_bool:n {#1} }
985 }
986 \cs_generate_variant:Nn \@@_opt_tl_set:Nn { cn }
987 \cs_new_protected:Npn \@@_opt_tl_clear:N #1
988 {
989 \tl_if_exist:NF #1
990 { \tl_new:N #1 }
991 \tl_clear:N #1
992 \bool_if_exist:cF { \@@_opt_var_set_bool:n {#1} }
993 { \bool_new:c { \@@_opt_var_set_bool:n {#1} } }
994 \bool_set_true:c { \@@_opt_var_set_bool:n {#1} }
995 }
996 \cs_generate_variant:Nn \@@_opt_tl_clear:N { c }
997 \cs_new_protected:Npn \@@_opt_tl_gset:Nn #1#2
998 {
999 \tl_if_exist:NF #1
1000 { \tl_new:N #1 }
1001 \tl_gset:Nn #1 {#2}
1002 }
1003 \cs_generate_variant:Nn \@@_opt_tl_gset:Nn { cn }
1004 \cs_new_protected:Npn \@@_opt_tl_gclear:N #1
1005 {
1006 \tl_if_exist:NF #1
1007 { \tl_new:N #1 }
1008 \tl_gclear:N #1
1009 }
1010 \cs_generate_variant:Nn \@@_opt_tl_gclear:N { c }
1011 % \end{macrocode}
1012 % \end{macro}
1013 %
1014 % \begin{macro}{\@@_opt_tl_unset:N}
1015 % Unset \meta{option tl}.
1016 % \begin{syntax}
1017 % \cs{@@_opt_tl_unset:N} \Arg{option tl}
1018 % \end{syntax}
1019 % \begin{macrocode}
1020 \cs_new_protected:Npn \@@_opt_tl_unset:N #1
1021 {
1022 \tl_if_exist:NT #1
1023 {
1024 \tl_clear:N #1
1025 \bool_if_exist:cTF { \@@_opt_var_set_bool:n {#1} }
1026 { \bool_set_false:c { \@@_opt_var_set_bool:n {#1} } }
1027 { \bool_new:c { \@@_opt_var_set_bool:n {#1} } }
1028 }
1029 }
1030 \cs_generate_variant:Nn \@@_opt_tl_unset:N { c }
1031 % \end{macrocode}
1032 % \end{macro}
1033 %
1034 % \begin{macro}[EXP,TF]{\@@_opt_tl_if_set:N}
1035 % This conditional \emph{defines} what means to be unset for a token list
1036 % option. Note that the ``set bool'' not existing signals that the variable
1037 % \emph{is set}, that would be the case of all global option variables
1038 % (language-specific ones). But this means care should be taken to always
1039 % define and set the ``set bool'' for local variables.
1040 % \begin{syntax}
1041 % \cs{@@_opt_tl_if_set:N(TF)} \Arg{option tl} \Arg{true} \Arg{false}
1042 % \end{syntax}
1043 % \begin{macrocode}
1044 \prg_new_conditional:Npnn \@@_opt_tl_if_set:N #1 { F , TF }
1045 {
1046 \tl_if_exist:NTF #1
1047 {
1048 \bool_if_exist:cTF { \@@_opt_var_set_bool:n {#1} }
1049 {
1050 \bool_if:cTF { \@@_opt_var_set_bool:n {#1} }
1051 { \prg_return_true: }
1052 { \prg_return_false: }
1053 }
1054 { \prg_return_true: }
1055 }
1056 { \prg_return_false: }
1057 }
1058 % \end{macrocode}
1059 % \end{macro}
1060 %
1061 % \begin{macro}
1062 % {
1063 % \@@_opt_tl_gset_if_new:Nn ,
1064 % \@@_opt_tl_gclear_if_new:N ,
1065 % }
1066 % \begin{syntax}
1067 % \cs{@@_opt_tl_gset_if_new:Nn} \Arg{option tl} \Arg{value}
1068 % \cs{@@_opt_tl_gclear_if_new:N} \Arg{option tl}
1069 % \end{syntax}
1070 % \begin{macrocode}
1071 \cs_new_protected:Npn \@@_opt_tl_gset_if_new:Nn #1#2
1072 {
1073 \@@_opt_tl_if_set:NF #1
1074 {
1075 \tl_if_exist:NF #1
1076 { \tl_new:N #1 }
1077 \tl_gset:Nn #1 {#2}
1078 }
1079 }
1080 \cs_generate_variant:Nn \@@_opt_tl_gset_if_new:Nn { cn }
1081 \cs_new_protected:Npn \@@_opt_tl_gclear_if_new:N #1
1082 {
1083 \@@_opt_tl_if_set:NF #1
1084 {
1085 \tl_if_exist:NF #1
1086 { \tl_new:N #1 }
1087 \tl_gclear:N #1
1088 }
1089 }
1090 \cs_generate_variant:Nn \@@_opt_tl_gclear_if_new:N { c }
1091 % \end{macrocode}
1092 % \end{macro}
1093 %
1094 % \begin{macro}[TF]{\@@_opt_tl_get:NN}
1095 % \begin{syntax}
1096 % \cs{@@_opt_tl_get:NN(TF)} \Arg{option tl to get} \Arg{tl var to set}
1097 % ~~\Arg{true} \Arg{false}
1098 % \end{syntax}
1099 % \begin{macrocode}
1100 \prg_new_protected_conditional:Npnn \@@_opt_tl_get:NN #1#2 { F }
1101 {
1102 \@@_opt_tl_if_set:NTF #1
1103 {
1104 \tl_set_eq:NN #2 #1
1105 \prg_return_true:
1106 }
1107 { \prg_return_false: }
1108 }
1109 \prg_generate_conditional_variant:Nnn
1110 \@@_opt_tl_get:NN { cN } { F }
1111 % \end{macrocode}
1112 % \end{macro}
1113 %
1114 %
1115 %
1116 % \begin{macro}
1117 % {
1118 % \@@_opt_seq_set_clist_split:Nn ,
1119 % \@@_opt_seq_gset_clist_split:Nn ,
1120 % \@@_opt_seq_set_eq:NN ,
1121 % \@@_opt_seq_gset_eq:NN ,
1122 % }
1123 % \begin{syntax}
1124 % \cs{@@_opt_seq_set_clist_split:Nn} \Arg{option seq} \Arg{value}
1125 % \cs{@@_opt_seq_gset_clist_split:Nn} \Arg{option seq} \Arg{value}
1126 % \cs{@@_opt_seq_set_eq:NN} \Arg{option seq} \Arg{seq var}
1127 % \cs{@@_opt_seq_gset_eq:NN} \Arg{option seq} \Arg{seq var}
1128 % \end{syntax}
1129 % \begin{macrocode}
1130 \cs_new_protected:Npn \@@_opt_seq_set_clist_split:Nn #1#2
1131 { \seq_set_split:Nnn #1 { , } {#2} }
1132 \cs_new_protected:Npn \@@_opt_seq_gset_clist_split:Nn #1#2
1133 { \seq_gset_split:Nnn #1 { , } {#2} }
1134 \cs_new_protected:Npn \@@_opt_seq_set_eq:NN #1#2
1135 {
1136 \seq_if_exist:NF #1
1137 { \seq_new:N #1 }
1138 \seq_set_eq:NN #1 #2
1139 \bool_if_exist:cF { \@@_opt_var_set_bool:n {#1} }
1140 { \bool_new:c { \@@_opt_var_set_bool:n {#1} } }
1141 \bool_set_true:c { \@@_opt_var_set_bool:n {#1} }
1142 }
1143 \cs_generate_variant:Nn \@@_opt_seq_set_eq:NN { cN }
1144 \cs_new_protected:Npn \@@_opt_seq_gset_eq:NN #1#2
1145 {
1146 \seq_if_exist:NF #1
1147 { \seq_new:N #1 }
1148 \seq_gset_eq:NN #1 #2
1149 }
1150 \cs_generate_variant:Nn \@@_opt_seq_gset_eq:NN { cN }
1151 % \end{macrocode}
1152 % \end{macro}
1153 %
1154 % \begin{macro}{\@@_opt_seq_unset:N}
1155 % Unset \meta{option seq}.
1156 % \begin{syntax}
1157 % \cs{@@_opt_seq_unset:N} \Arg{option seq}
1158 % \end{syntax}
1159 % \begin{macrocode}
1160 \cs_new_protected:Npn \@@_opt_seq_unset:N #1
1161 {
1162 \seq_if_exist:NT #1
1163 {
1164 \seq_clear:N #1
1165 \bool_if_exist:cTF { \@@_opt_var_set_bool:n {#1} }
1166 { \bool_set_false:c { \@@_opt_var_set_bool:n {#1} } }
1167 { \bool_new:c { \@@_opt_var_set_bool:n {#1} } }
1168 }
1169 }
1170 \cs_generate_variant:Nn \@@_opt_seq_unset:N { c }
1171 % \end{macrocode}
1172 % \end{macro}
1173 %
1174 % \begin{macro}[EXP,TF]{\@@_opt_seq_if_set:N}
1175 % This conditional \emph{defines} what means to be unset for a sequence
1176 % option.
1177 % \begin{syntax}
1178 % \cs{@@_opt_seq_if_set:N(TF)} \Arg{option seq} \Arg{true} \Arg{false}
1179 % \end{syntax}
1180 % \begin{macrocode}
1181 \prg_new_conditional:Npnn \@@_opt_seq_if_set:N #1 { F , TF }
1182 {
1183 \seq_if_exist:NTF #1
1184 {
1185 \bool_if_exist:cTF { \@@_opt_var_set_bool:n {#1} }
1186 {
1187 \bool_if:cTF { \@@_opt_var_set_bool:n {#1} }
1188 { \prg_return_true: }
1189 { \prg_return_false: }
1190 }
1191 { \prg_return_true: }
1192 }
1193 { \prg_return_false: }
1194 }
1195 \prg_generate_conditional_variant:Nnn
1196 \@@_opt_seq_if_set:N { c } { F , TF }
1197 % \end{macrocode}
1198 % \end{macro}
1199 %
1200 % \begin{macro}[TF]{\@@_opt_seq_get:NN}
1201 % \begin{syntax}
1202 % \cs{@@_opt_seq_get:NN(TF)} \Arg{option seq to get} \Arg{seq var to set}
1203 % ~~\Arg{true} \Arg{false}
1204 % \end{syntax}
1205 % \begin{macrocode}
1206 \prg_new_protected_conditional:Npnn \@@_opt_seq_get:NN #1#2 { F }
1207 {
1208 \@@_opt_seq_if_set:NTF #1
1209 {
1210 \seq_set_eq:NN #2 #1
1211 \prg_return_true:
1212 }
1213 { \prg_return_false: }
1214 }
1215 \prg_generate_conditional_variant:Nnn
1216 \@@_opt_seq_get:NN { cN } { F }
1217 % \end{macrocode}
1218 % \end{macro}
1219 %
1220 %
1221 %
1222 % \begin{macro}{\@@_opt_bool_unset:N}
1223 % Unset \meta{option bool}.
1224 % \begin{syntax}
1225 % \cs{@@_opt_bool_unset:N} \Arg{option bool}
1226 % \end{syntax}
1227 % \begin{macrocode}
1228 \cs_new_protected:Npn \@@_opt_bool_unset:N #1
1229 {
1230 \bool_if_exist:NT #1
1231 {
1232 % \bool_set_false:N #1
1233 \bool_if_exist:cTF { \@@_opt_var_set_bool:n {#1} }
1234 { \bool_set_false:c { \@@_opt_var_set_bool:n {#1} } }
1235 { \bool_new:c { \@@_opt_var_set_bool:n {#1} } }
1236 }
1237 }
1238 \cs_generate_variant:Nn \@@_opt_bool_unset:N { c }
1239 % \end{macrocode}
1240 % \end{macro}
1241 %
1242 % \begin{macro}[EXP,TF]{\@@_opt_bool_if_set:N}
1243 % This conditional \emph{defines} what means to be unset for a boolean
1244 % option.
1245 % \begin{syntax}
1246 % \cs{@@_opt_bool_if_set:N(TF)} \Arg{option bool} \Arg{true} \Arg{false}
1247 % \end{syntax}
1248 % \begin{macrocode}
1249 \prg_new_conditional:Npnn \@@_opt_bool_if_set:N #1 { F , TF }
1250 {
1251 \bool_if_exist:NTF #1
1252 {
1253 \bool_if_exist:cTF { \@@_opt_var_set_bool:n {#1} }
1254 {
1255 \bool_if:cTF { \@@_opt_var_set_bool:n {#1} }
1256 { \prg_return_true: }
1257 { \prg_return_false: }
1258 }
1259 { \prg_return_true: }
1260 }
1261 { \prg_return_false: }
1262 }
1263 \prg_generate_conditional_variant:Nnn
1264 \@@_opt_bool_if_set:N { c } { F , TF }
1265 % \end{macrocode}
1266 % \end{macro}
1267 %
1268 % \begin{macro}
1269 % {
1270 % \@@_opt_bool_set_true:N ,
1271 % \@@_opt_bool_set_false:N ,
1272 % \@@_opt_bool_gset_true:N ,
1273 % \@@_opt_bool_gset_false:N ,
1274 % }
1275 % \begin{syntax}
1276 % \cs{@@_opt_bool_set_true:N} \Arg{option bool}
1277 % \cs{@@_opt_bool_set_false:N} \Arg{option bool}
1278 % \cs{@@_opt_bool_gset_true:N} \Arg{option bool}
1279 % \cs{@@_opt_bool_gset_false:N} \Arg{option bool}
1280 % \end{syntax}
1281 % \begin{macrocode}
1282 \cs_new_protected:Npn \@@_opt_bool_set_true:N #1
1283 {
1284 \bool_if_exist:NF #1
1285 { \bool_new:N #1 }
1286 \bool_set_true:N #1
1287 \bool_if_exist:cF { \@@_opt_var_set_bool:n {#1} }
1288 { \bool_new:c { \@@_opt_var_set_bool:n {#1} } }
1289 \bool_set_true:c { \@@_opt_var_set_bool:n {#1} }
1290 }
1291 \cs_generate_variant:Nn \@@_opt_bool_set_true:N { c }
1292 \cs_new_protected:Npn \@@_opt_bool_set_false:N #1
1293 {
1294 \bool_if_exist:NF #1
1295 { \bool_new:N #1 }
1296 \bool_set_false:N #1
1297 \bool_if_exist:cF { \@@_opt_var_set_bool:n {#1} }
1298 { \bool_new:c { \@@_opt_var_set_bool:n {#1} } }
1299 \bool_set_true:c { \@@_opt_var_set_bool:n {#1} }
1300 }
1301 \cs_generate_variant:Nn \@@_opt_bool_set_false:N { c }
1302 \cs_new_protected:Npn \@@_opt_bool_gset_true:N #1
1303 {
1304 \bool_if_exist:NF #1
1305 { \bool_new:N #1 }
1306 \bool_gset_true:N #1
1307 }
1308 \cs_generate_variant:Nn \@@_opt_bool_gset_true:N { c }
1309 \cs_new_protected:Npn \@@_opt_bool_gset_false:N #1
1310 {
1311 \bool_if_exist:NF #1
1312 { \bool_new:N #1 }
1313 \bool_gset_false:N #1
1314 }
1315 \cs_generate_variant:Nn \@@_opt_bool_gset_false:N { c }
1316 % \end{macrocode}
1317 % \end{macro}
1318 %
1319 %
1320 % \begin{macro}[TF]{\@@_opt_bool_get:NN}
1321 % \begin{syntax}
1322 % \cs{@@_opt_bool_get:NN(TF)} \Arg{option bool to get} \Arg{bool var to set}
1323 % ~~\Arg{true} \Arg{false}
1324 % \end{syntax}
1325 % \begin{macrocode}
1326 \prg_new_protected_conditional:Npnn \@@_opt_bool_get:NN #1#2 { F }
1327 {
1328 \@@_opt_bool_if_set:NTF #1
1329 {
1330 \bool_set_eq:NN #2 #1
1331 \prg_return_true:
1332 }
1333 { \prg_return_false: }
1334 }
1335 \prg_generate_conditional_variant:Nnn
1336 \@@_opt_bool_get:NN { cN } { F }
1337 % \end{macrocode}
1338 % \end{macro}
1339 %
1340 % \begin{macro}[EXP,TF]{\@@_opt_bool_if:N}
1341 % \begin{syntax}
1342 % \cs{@@_opt_bool_if:N(TF)} \Arg{option bool} \Arg{true} \Arg{false}
1343 % \end{syntax}
1344 % \begin{macrocode}
1345 \prg_new_conditional:Npnn \@@_opt_bool_if:N #1 { T , F , TF }
1346 {
1347 \@@_opt_bool_if_set:NTF #1
1348 { \bool_if:NTF #1 { \prg_return_true: } { \prg_return_false: } }
1349 { \prg_return_false: }
1350 }
1351 \prg_generate_conditional_variant:Nnn
1352 \@@_opt_bool_if:N { c } { T , F , TF }
1353 % \end{macrocode}
1354 % \end{macro}
1355 %
1356 %
1357 %
1358 % \subsection{Reference format}
1359 %
1360 % For a general discussion on the precedence rules for reference format
1361 % options, see Section ``Reference format'' in the User manual. Internally,
1362 % these precedence rules are handled / enforced in \cs{@@_get_rf_opt_tl:nnnN},
1363 % \cs{@@_get_rf_opt_seq:nnnN}, \cs{@@_get_rf_opt_bool:nnnnN}, and
1364 % \cs{@@_type_name_setup:} which are the basic functions to retrieve proper
1365 % values for reference format settings.
1366 %
1367 % The fact that we have multiple scopes to set reference format options has
1368 % some implications for how we handle these options, and for the resulting UI.
1369 % Since there is a clear precedence rule between the different levels, setting
1370 % an option at a high priority level shadows everything below it. Hence, it
1371 % may be relevant to be able to ``unset'' these options too, so as to be able
1372 % go back to the lower precedence level of the language-specific options at
1373 % any given point. However, since many of these options are token lists, or
1374 % clists, for which ``empty'' is a legitimate value, we cannot rely on
1375 % emptiness to distinguish that particular intention. How to deal with it,
1376 % depends on the kind of option (its data type, to be precise). For token
1377 % lists and clists/sequences, we leverage the distinction of an ``empty valued
1378 % key'' (\texttt{key=} or \texttt{key=\{\}}) from a ``key with no value''
1379 % (\texttt{key}). This distinction is captured internally by the lower-level
1380 % key parsing, but must be made explicit in \cs{keys_define:nn} by means of
1381 % the \texttt{.default:o} property of the key. For the technique, by
1382 % \contributor{Jonathan P.\ Spratte}, aka `Skillmon', and some discussion
1383 % about it, including further insights by \contributor{Phelype Oleinik}, see
1384 % \url{https://tex.stackexchange.com/q/614690} and
1385 % \url{https://github.com/latex3/latex3/pull/988}. However, Joseph Wright
1386 % seems to particularly dislike this use and the general idea of a ``key with
1387 % no value'' being somehow meaningful for \pkg{l3keys} (e.g. his comments on
1388 % the previous question, and
1389 % \url{https://tex.stackexchange.com/q/632157/#comment1576404_632157}), which
1390 % does make it somewhat risky to rely on this. For booleans, the situation is
1391 % different, since they cannot meaningfully receive an empty value and the
1392 % ``key with no value'' is a handy and expected shorthand for
1393 % \texttt{key=true}. Therefore, for reference format option booleans, we use
1394 % a third value ``\texttt{unset}'' for this purpose. And similarly for
1395 % ``choice'' options.
1396 %
1397 % However, ``unsetting'' options is only supported at the general and
1398 % reference type levels, that is, at \cs{zcsetup}, at \cs{zcref}, and at
1399 % \cs{zcRefTypeSetup}. For language-specific options -- in the language files
1400 % or at \cs{zcLanguageSetup} -- there is no unsetting, an option which has
1401 % been set can there only be changed to another value. This for two reasons.
1402 % First, these are low precedence levels, so it is less meaningful to be able
1403 % to unset these options. Second, these settings can only be done in the
1404 % preamble (or the package itself). They are meant to be global. So, do it
1405 % once, do it right, and if you need to locally change something along the
1406 % document, use a higher precedence level.
1407 %
1408 %
1409 % \begin{macro}
1410 % {
1411 % \l_@@_setup_type_tl ,
1412 % \l_@@_setup_language_tl ,
1413 % \l_@@_lang_variant_tl ,
1414 % \l_@@_lang_variants_seq ,
1415 % \l_@@_lang_gender_seq ,
1416 % }
1417 % Store ``current'' type, language, and variants in different places for
1418 % type-specific and language-specific options handling, notably in
1419 % \cs{@@_provide_langfile:n}, \cs{zcRefTypeSetup}, and \cs{zcLanguageSetup},
1420 % but also for language specific options retrieval.
1421 % \begin{macrocode}
1422 \tl_new:N \l_@@_setup_type_tl
1423 \tl_new:N \l_@@_setup_language_tl
1424 \tl_new:N \l_@@_lang_variant_tl
1425 \seq_new:N \l_@@_lang_variants_seq
1426 \seq_new:N \l_@@_lang_gender_seq
1427 % \end{macrocode}
1428 % \end{macro}
1429 %
1430 %
1431 % \begin{macro}
1432 % {
1433 % \g_@@_rf_opts_tl_not_type_specific_seq ,
1434 % \g_@@_rf_opts_tl_maybe_type_specific_seq ,
1435 % \g_@@_rf_opts_seq_refbounds_seq ,
1436 % \g_@@_rf_opts_bool_maybe_type_specific_seq ,
1437 % \g_@@_rf_opts_tl_type_names_seq ,
1438 % \g_@@_rf_opts_tl_typesetup_seq ,
1439 % \g_@@_rf_opts_tl_reference_seq ,
1440 % }
1441 % Lists of reference format options in ``categories''. Since these
1442 % options are set in different scopes, and at different places, storing
1443 % the actual lists in centralized variables makes the job not only easier
1444 % later on, but also keeps things consistent. These variables are
1445 % \emph{constants}, but I don't seem to be able to find a way to
1446 % concatenate two constants into a third one without triggering \LaTeX3
1447 % debug error ``Inconsistent local/global assignment''. And repeating
1448 % things in a new \cs{seq_const_from_clist:Nn} defeats the purpose of
1449 % these variables.
1450 % \begin{macrocode}
1451 \seq_new:N \g_@@_rf_opts_tl_not_type_specific_seq
1452 \seq_gset_from_clist:Nn
1453 \g_@@_rf_opts_tl_not_type_specific_seq
1454 {
1455 tpairsep ,
1456 tlistsep ,
1457 tlastsep ,
1458 notesep ,
1459 }
1460 \seq_new:N \g_@@_rf_opts_tl_maybe_type_specific_seq
1461 \seq_gset_from_clist:Nn
1462 \g_@@_rf_opts_tl_maybe_type_specific_seq
1463 {
1464 namesep ,
1465 pairsep ,
1466 listsep ,
1467 lastsep ,
1468 rangesep ,
1469 namefont ,
1470 reffont ,
1471 }
1472 \seq_new:N \g_@@_rf_opts_seq_refbounds_seq
1473 \seq_gset_from_clist:Nn
1474 \g_@@_rf_opts_seq_refbounds_seq
1475 {
1476 refbounds-first ,
1477 refbounds-first-sg ,
1478 refbounds-first-pb ,
1479 refbounds-first-rb ,
1480 refbounds-mid ,
1481 refbounds-mid-rb ,
1482 refbounds-mid-re ,
1483 refbounds-last ,
1484 refbounds-last-pe ,
1485 refbounds-last-re ,
1486 }
1487 \seq_new:N \g_@@_rf_opts_bool_maybe_type_specific_seq
1488 \seq_gset_from_clist:Nn
1489 \g_@@_rf_opts_bool_maybe_type_specific_seq
1490 {
1491 cap ,
1492 abbrev ,
1493 rangetopair ,
1494 }
1495 % \end{macrocode}
1496 % Only ``type names'' are ``necessarily type-specific'', which makes them
1497 % somewhat special on the retrieval side of things. In short, they don't have
1498 % their values queried by \cs{@@_get_rf_opt_tl:nnnN}, but by
1499 % \cs{@@_type_name_setup:}.
1500 % \begin{macrocode}
1501 \seq_new:N \g_@@_rf_opts_tl_type_names_seq
1502 \seq_gset_from_clist:Nn
1503 \g_@@_rf_opts_tl_type_names_seq
1504 {
1505 Name-sg ,
1506 name-sg ,
1507 Name-pl ,
1508 name-pl ,
1509 Name-sg-ab ,
1510 name-sg-ab ,
1511 Name-pl-ab ,
1512 name-pl-ab ,
1513 }
1514 % \end{macrocode}
1515 % And, finally, some combined groups of the above variables, for convenience.
1516 % \begin{macrocode}
1517 \seq_new:N \g_@@_rf_opts_tl_typesetup_seq
1518 \seq_gconcat:NNN \g_@@_rf_opts_tl_typesetup_seq
1519 \g_@@_rf_opts_tl_maybe_type_specific_seq
1520 \g_@@_rf_opts_tl_type_names_seq
1521 \seq_new:N \g_@@_rf_opts_tl_reference_seq
1522 \seq_gconcat:NNN \g_@@_rf_opts_tl_reference_seq
1523 \g_@@_rf_opts_tl_not_type_specific_seq
1524 \g_@@_rf_opts_tl_maybe_type_specific_seq
1525 % \end{macrocode}
1526 % \end{macro}
1527 %
1528 %
1529 % We set here also the ``derived'' \texttt{refbounds} options, which are
1530 % (almost) the same for every option scope.
1531 %
1532 % \begin{macrocode}
1533 \clist_map_inline:nn
1534 {
1535 reference ,
1536 typesetup ,
1537 langsetup ,
1538 langfile ,
1539 }
1540 {
1541 \keys_define:nn { zref-clever/ #1 }
1542 {
1543 +refbounds-first .meta:n =
1544 {
1545 refbounds-first = {##1} ,
1546 refbounds-first-sg = {##1} ,
1547 refbounds-first-pb = {##1} ,
1548 refbounds-first-rb = {##1} ,
1549 } ,
1550 +refbounds-mid .meta:n =
1551 {
1552 refbounds-mid = {##1} ,
1553 refbounds-mid-rb = {##1} ,
1554 refbounds-mid-re = {##1} ,
1555 } ,
1556 +refbounds-last .meta:n =
1557 {
1558 refbounds-last = {##1} ,
1559 refbounds-last-pe = {##1} ,
1560 refbounds-last-re = {##1} ,
1561 } ,
1562 +refbounds-rb .meta:n =
1563 {
1564 refbounds-first-rb = {##1} ,
1565 refbounds-mid-rb = {##1} ,
1566 } ,
1567 +refbounds-re .meta:n =
1568 {
1569 refbounds-mid-re = {##1} ,
1570 refbounds-last-re = {##1} ,
1571 } ,
1572 +refbounds .meta:n =
1573 {
1574 +refbounds-first = {##1} ,
1575 +refbounds-mid = {##1} ,
1576 +refbounds-last = {##1} ,
1577 } ,
1578 refbounds .meta:n = { +refbounds = {##1} } ,
1579 }
1580 }
1581 \clist_map_inline:nn
1582 {
1583 reference ,
1584 typesetup ,
1585 }
1586 {
1587 \keys_define:nn { zref-clever/ #1 }
1588 {
1589 +refbounds-first .default:o = \c_novalue_tl ,
1590 +refbounds-mid .default:o = \c_novalue_tl ,
1591 +refbounds-last .default:o = \c_novalue_tl ,
1592 +refbounds-rb .default:o = \c_novalue_tl ,
1593 +refbounds-re .default:o = \c_novalue_tl ,
1594 +refbounds .default:o = \c_novalue_tl ,
1595 refbounds .default:o = \c_novalue_tl ,
1596 }
1597 }
1598 \clist_map_inline:nn
1599 {
1600 langsetup ,
1601 langfile ,
1602 }
1603 {
1604 \keys_define:nn { zref-clever/ #1 }
1605 {
1606 +refbounds-first .value_required:n = true ,
1607 +refbounds-mid .value_required:n = true ,
1608 +refbounds-last .value_required:n = true ,
1609 +refbounds-rb .value_required:n = true ,
1610 +refbounds-re .value_required:n = true ,
1611 +refbounds .value_required:n = true ,
1612 refbounds .value_required:n = true ,
1613 }
1614 }
1615 % \end{macrocode}
1616 %
1617 %
1618 % \subsection{Languages}
1619 %
1620 %
1621 % \cs{l_@@_current_language_tl} is an internal alias for \pkg{babel}'s
1622 % \cs{languagename} or \pkg{polyglossia}'s \cs{mainbabelname} and, if none of
1623 % them is loaded, we set it to \texttt{english}. \cs{l_@@_main_language_tl}
1624 % is an internal alias for \pkg{babel}'s \cs{bbl@main@language} or for
1625 % \pkg{polyglossia}'s \cs{mainbabelname}, as the case may be. Note that for
1626 % \pkg{polyglossia} we get \pkg{babel}'s language names, so that we only need
1627 % to handle those internally. \cs{l_@@_ref_language_tl} is the internal
1628 % variable which stores the language in which the reference is to be made.
1629 %
1630 % \begin{macrocode}
1631 \tl_new:N \l_@@_ref_language_tl
1632 \tl_new:N \l_@@_current_language_tl
1633 \tl_new:N \l_@@_main_language_tl
1634 % \end{macrocode}
1635 %
1636 % \begin{macro}[int]{\l_zrefclever_ref_language_tl}
1637 % A public version of \cs{l_@@_ref_language_tl} for use in \pkg{zref-vario}.
1638 % \begin{macrocode}
1639 \tl_new:N \l_zrefclever_ref_language_tl
1640 \tl_set:Nn \l_zrefclever_ref_language_tl { \l_@@_ref_language_tl }
1641 % \end{macrocode}
1642 % \end{macro}
1643 %
1644 %
1645 % \begin{macro}[EXP]{\@@_language_varname:n}
1646 % Defines, and leaves in the input stream, the csname of the variable used
1647 % to store the \meta{base language} (as the value of this variable) for
1648 % a \meta{language} declared for \pkg{zref-clever}.
1649 % \begin{syntax}
1650 % \cs{@@_language_varname:n} \Arg{language}
1651 % \end{syntax}
1652 % \begin{macrocode}
1653 \cs_new:Npn \@@_language_varname:n #1
1654 { g_@@_declared_language_ #1 _tl }
1655 % \end{macrocode}
1656 % \end{macro}
1657 %
1658 % \begin{macro}[EXP,int]{\zrefclever_language_varname:n}
1659 % A public version of \cs{@@_language_varname:n} for use in
1660 % \pkg{zref-vario}.
1661 % \begin{macrocode}
1662 \cs_set_eq:NN \zrefclever_language_varname:n
1663 \@@_language_varname:n
1664 % \end{macrocode}
1665 % \end{macro}
1666 %
1667 % \begin{macro}[EXP,TF]{\@@_language_if_declared:n}
1668 % A language is considered to be declared for \pkg{zref-clever} if it passes
1669 % this conditional, which requires that a variable with
1670 % \cs{@@_language_varname:n}\texttt{\{\meta{language}\}} exists.
1671 % \begin{syntax}
1672 % \cs{@@_language_if_declared:n(TF)} \Arg{language}
1673 % \end{syntax}
1674 % \begin{macrocode}
1675 \prg_new_conditional:Npnn \@@_language_if_declared:n #1 { T , F , TF }
1676 {
1677 \tl_if_exist:cTF { \@@_language_varname:n {#1} }
1678 { \prg_return_true: }
1679 { \prg_return_false: }
1680 }
1681 \prg_generate_conditional_variant:Nnn
1682 \@@_language_if_declared:n { e } { T , F , TF }
1683 % \end{macrocode}
1684 % \end{macro}
1685 %
1686 % \begin{macro}[EXP,TF,int]{\zrefclever_language_if_declared:n}
1687 % A public version of \cs{@@_language_if_declared:n} for use in
1688 % \pkg{zref-vario}.
1689 % \begin{macrocode}
1690 \prg_set_eq_conditional:NNn \zrefclever_language_if_declared:n
1691 \@@_language_if_declared:n { TF }
1692 % \end{macrocode}
1693 % \end{macro}
1694 %
1695 %
1696 % \begin{macro}[int]{\zcDeclareLanguage}
1697 % Declare a new language for use with \pkg{zref-clever}. \meta{language} is
1698 % taken to be both the ``language name'' and the ``base language name''. A
1699 % ``base language'' (loose concept here, meaning just ``the name we gave for
1700 % the language file in that particular language'') is just like any other one,
1701 % the only difference is that the ``language name'' happens to be the same as
1702 % the ``base language name'', in other words, it is an ``alias to itself''.
1703 % \oarg{options} receive a \texttt{k=v} set of options, with three valid
1704 % options. The first, \opt{variants}, takes the variants for \meta{language}
1705 % as a comma separated list, whose first element is taken to be the default
1706 % case. The second, \opt{gender}, receives the genders for \meta{language} as
1707 % comma separated list. The third, \opt{allcaps}, is a boolean, and indicates
1708 % that for \meta{language} all nouns must be capitalized for grammatical
1709 % reasons, in which case, the \opt{cap} option is disregarded for
1710 % \meta{language}. If \meta{language} is already known, just warn. This
1711 % implies a particular restriction regarding \oarg{options}, namely that these
1712 % options, when defined by the package, cannot be redefined by the user. This
1713 % is deliberate, otherwise the built-in language files would become much too
1714 % sensitive to this particular user input, and unnecessarily so.
1715 % \cs{zcDeclareLanguage} is preamble only.
1716 % \begin{syntax}
1717 % \cs{zcDeclareLanguage} \oarg{options} \marg{language}
1718 % \end{syntax}
1719 % \begin{macrocode}
1720 \NewDocumentCommand \zcDeclareLanguage { O { } m }
1721 {
1722 \group_begin:
1723 \tl_if_empty:nF {#2}
1724 {
1725 \@@_language_if_declared:nTF {#2}
1726 { \msg_warning:nnn { zref-clever } { language-declared } {#2} }
1727 {
1728 \tl_new:c { \@@_language_varname:n {#2} }
1729 \tl_gset:cn { \@@_language_varname:n {#2} } {#2}
1730 \tl_set:Nn \l_@@_setup_language_tl {#2}
1731 \keys_set:nn { zref-clever/declarelang } {#1}
1732 }
1733 }
1734 \group_end:
1735 }
1736 \@onlypreamble \zcDeclareLanguage
1737 % \end{macrocode}
1738 % \end{macro}
1739 %
1740 %
1741 % \begin{macro}[int]{\zcDeclareLanguageAlias}
1742 % Declare \meta{language alias} to be an alias of \meta{aliased language}
1743 % (or ``base language''). \meta{aliased language} must be already known to
1744 % \pkg{zref-clever}.
1745 % \cs{zcDeclareLanguageAlias} is preamble only.
1746 % \begin{syntax}
1747 % \cs{zcDeclareLanguageAlias} \marg{language alias} \marg{aliased language}
1748 % \end{syntax}
1749 % \begin{macrocode}
1750 \NewDocumentCommand \zcDeclareLanguageAlias { m m }
1751 {
1752 \tl_if_empty:nF {#1}
1753 {
1754 \@@_language_if_declared:nTF {#2}
1755 {
1756 \tl_new:c { \@@_language_varname:n {#1} }
1757 \tl_gset:ce { \@@_language_varname:n {#1} }
1758 { \tl_use:c { \@@_language_varname:n {#2} } }
1759 }
1760 { \msg_warning:nnn { zref-clever } { unknown-language-alias } {#2} }
1761 }
1762 }
1763 \@onlypreamble \zcDeclareLanguageAlias
1764 % \end{macrocode}
1765 % \end{macro}
1766 %
1767 %
1768 %
1769 % \begin{macrocode}
1770 \keys_define:nn { zref-clever/declarelang }
1771 {
1772 variants .code:n =
1773 {
1774 \seq_new:c
1775 {
1776 \@@_opt_varname_language:enn
1777 { \l_@@_setup_language_tl } { variants } { seq }
1778 }
1779 \seq_gset_from_clist:cn
1780 {
1781 \@@_opt_varname_language:enn
1782 { \l_@@_setup_language_tl } { variants } { seq }
1783 }
1784 {#1}
1785 } ,
1786 variants .value_required:n = true ,
1787 % NOTE Option deprecated in 2024-11-24 for v0.5.0.
1788 declension .meta:n = { variants = {#1} } ,
1789 gender .code:n =
1790 {
1791 \seq_new:c
1792 {
1793 \@@_opt_varname_language:enn
1794 { \l_@@_setup_language_tl } { gender } { seq }
1795 }
1796 \seq_gset_from_clist:cn
1797 {
1798 \@@_opt_varname_language:enn
1799 { \l_@@_setup_language_tl } { gender } { seq }
1800 }
1801 {#1}
1802 } ,
1803 gender .value_required:n = true ,
1804 allcaps .choices:nn =
1805 { true , false }
1806 {
1807 \bool_new:c
1808 {
1809 \@@_opt_varname_language:enn
1810 { \l_@@_setup_language_tl } { allcaps } { bool }
1811 }
1812 \use:c { bool_gset_ \l_keys_choice_tl :c }
1813 {
1814 \@@_opt_varname_language:enn
1815 { \l_@@_setup_language_tl } { allcaps } { bool }
1816 }
1817 } ,
1818 allcaps .default:n = true ,
1819 }
1820 % \end{macrocode}
1821 %
1822 %
1823 %
1824 % \begin{macro}{\@@_process_language_settings:}
1825 % Auxiliary function for \cs{@@_zcref:nnn}, responsible for processing
1826 % language related settings. It is necessary to separate them from the
1827 % reference options machinery for two reasons. First, because their
1828 % behavior is language dependent, but the language itself can also be set as
1829 % an option (\opt{lang}, value stored in \cs{l_@@_ref_language_tl}).
1830 % Second, some of its tasks must be done regardless of any option being
1831 % given (e.g. the default variant, the \opt{allcaps} option). Hence, we
1832 % must validate the language settings after the reference options have been
1833 % set. It is expected to be called right (or soon) after \cs{keys_set:nn}
1834 % in \cs{@@_zcref:nnn}, where current values for \cs{l_@@_ref_language_tl}
1835 % and \cs{l_@@_ref_variant_tl} are in place.
1836 % \begin{macrocode}
1837 \cs_new_protected:Npn \@@_process_language_settings:
1838 {
1839 \@@_language_if_declared:eTF
1840 { \l_@@_ref_language_tl }
1841 {
1842 % \end{macrocode}
1843 % Validate the variant (\opt{v}) option against the declared variants for the
1844 % reference language. If the user value for the latter does not match the
1845 % variants declared for the former, the function sets an appropriate value for
1846 % \cs{l_@@_ref_variant_tl}, either using the default case, or clearing the
1847 % variable, depending on the language setup. And also issues a warning about
1848 % it.
1849 % \begin{macrocode}
1850 \@@_opt_seq_get:cNF
1851 {
1852 \@@_opt_varname_language:enn
1853 { \l_@@_ref_language_tl } { variants } { seq }
1854 }
1855 \l_@@_lang_variants_seq
1856 { \seq_clear:N \l_@@_lang_variants_seq }
1857 \seq_if_empty:NTF \l_@@_lang_variants_seq
1858 {
1859 \tl_if_empty:NF \l_@@_ref_variant_tl
1860 {
1861 \msg_warning:nnee { zref-clever }
1862 { language-no-variants-ref }
1863 { \l_@@_ref_language_tl }
1864 { \l_@@_ref_variant_tl }
1865 \tl_clear:N \l_@@_ref_variant_tl
1866 }
1867 }
1868 {
1869 \tl_if_empty:NTF \l_@@_ref_variant_tl
1870 {
1871 \seq_get_left:NN \l_@@_lang_variants_seq
1872 \l_@@_ref_variant_tl
1873 }
1874 {
1875 \seq_if_in:NVF \l_@@_lang_variants_seq
1876 \l_@@_ref_variant_tl
1877 {
1878 \msg_warning:nnee { zref-clever }
1879 { unknown-variant }
1880 { \l_@@_ref_variant_tl }
1881 { \l_@@_ref_language_tl }
1882 \seq_get_left:NN \l_@@_lang_variants_seq
1883 \l_@@_ref_variant_tl
1884 }
1885 }
1886 }
1887 % \end{macrocode}
1888 % Validate the gender (\opt{g}) option against the declared genders for the
1889 % reference language. If the user value for the latter does not match the
1890 % genders declared for the former, clear \cs{l_@@_ref_gender_tl} and warn.
1891 % \begin{macrocode}
1892 \@@_opt_seq_get:cNF
1893 {
1894 \@@_opt_varname_language:enn
1895 { \l_@@_ref_language_tl } { gender } { seq }
1896 }
1897 \l_@@_lang_gender_seq
1898 { \seq_clear:N \l_@@_lang_gender_seq }
1899 \seq_if_empty:NTF \l_@@_lang_gender_seq
1900 {
1901 \tl_if_empty:NF \l_@@_ref_gender_tl
1902 {
1903 \msg_warning:nneee { zref-clever }
1904 { language-no-gender }
1905 { \l_@@_ref_language_tl }
1906 { g }
1907 { \l_@@_ref_gender_tl }
1908 \tl_clear:N \l_@@_ref_gender_tl
1909 }
1910 }
1911 {
1912 \tl_if_empty:NF \l_@@_ref_gender_tl
1913 {
1914 \seq_if_in:NVF \l_@@_lang_gender_seq
1915 \l_@@_ref_gender_tl
1916 {
1917 \msg_warning:nnee { zref-clever }
1918 { gender-not-declared }
1919 { \l_@@_ref_language_tl }
1920 { \l_@@_ref_gender_tl }
1921 \tl_clear:N \l_@@_ref_gender_tl
1922 }
1923 }
1924 }
1925 % \end{macrocode}
1926 % Ensure the general \opt{cap} is set to \texttt{true} when the language was
1927 % declared with \opt{allcaps} option.
1928 % \begin{macrocode}
1929 \@@_opt_bool_if:cT
1930 {
1931 \@@_opt_varname_language:enn
1932 { \l_@@_ref_language_tl } { allcaps } { bool }
1933 }
1934 { \keys_set:nn { zref-clever/reference } { cap = true } }
1935 }
1936 {
1937 % \end{macrocode}
1938 % If the language itself is not declared, we still have to variant and gender
1939 % warnings, if \opt{d} or \opt{g} options were used.
1940 % \begin{macrocode}
1941 \tl_if_empty:NF \l_@@_ref_variant_tl
1942 {
1943 \msg_warning:nnee { zref-clever } { unknown-language-variant }
1944 { \l_@@_ref_variant_tl }
1945 { \l_@@_ref_language_tl }
1946 \tl_clear:N \l_@@_ref_variant_tl
1947 }
1948 \tl_if_empty:NF \l_@@_ref_gender_tl
1949 {
1950 \msg_warning:nneee { zref-clever }
1951 { language-no-gender }
1952 { \l_@@_ref_language_tl }
1953 { g }
1954 { \l_@@_ref_gender_tl }
1955 \tl_clear:N \l_@@_ref_gender_tl
1956 }
1957 }
1958 }
1959 % \end{macrocode}
1960 % \end{macro}
1961 %
1962 %
1963 %
1964 % \subsection{Language files}
1965 %
1966 % Contrary to general options and type options, which are always \emph{local},
1967 % language-specific settings are always \emph{global}. Hence, the loading of
1968 % built-in language files, as well as settings done with \cs{zcLanguageSetup},
1969 % should set the relevant variables globally.
1970 %
1971 % The built-in language files and their related infrastructure are designed to
1972 % perform ``on the fly'' loading of the language files, ``lazily'' as needed.
1973 % Much like \pkg{babel} does for languages not declared in the preamble, but
1974 % used in the document. This offers some convenience, of course, and that's
1975 % one reason to do it. But it also has the purpose of parsimony, of ``loading
1976 % the least possible''. Therefore, we load at \texttt{begindocument} one
1977 % single language (see \zcref[ref=title, noname]{sec:lang-option}), as
1978 % specified by the user in the preamble with the \opt{lang} option or, failing
1979 % any specification, the current language of the document, which is the
1980 % default. Anything else is lazily loaded, on the fly, along the document.
1981 %
1982 % This design decision has also implications to the \emph{form} the language
1983 % files assumed. As far as my somewhat impressionistic sampling goes,
1984 % dictionary or localization files of the most common packages in this area of
1985 % functionality, are usually a set of commands which perform the relevant
1986 % definitions and assignments in the preamble or at \texttt{begindocument}.
1987 % This includes \pkg{translator}, \pkg{translations}, but also \pkg{babel}'s
1988 % \file{.ldf} files, and \pkg{biblatex}'s \file{.lbx} files. I'm not really
1989 % well acquainted with this machinery, but as far as I grasp, they all rely on
1990 % some variation of \cs{ProvidesFile} and \cs{input}. And they can be safely
1991 % \cs{input} without generating spurious content, because they rely on being
1992 % loaded before the document has actually started. As far as I can tell,
1993 % \pkg{babel}'s ``on the fly'' functionality is not based on the \file{.ldf}
1994 % files, but on the \file{.ini} files, and on \cs{babelprovide}. And the
1995 % \file{.ini} files are not in this form, but actually resemble
1996 % ``configuration files'' of sorts, which means they are read and processed
1997 % somehow else than with just \cs{input}. So we do the more or less the same
1998 % here. It seems a reasonable way to ensure we can load language files on the
1999 % fly robustly mid-document, without getting paranoid with the last bit of
2000 % white-space in them, and without introducing any undue content on the stream
2001 % when we cannot afford to do it. Hence, \pkg{zref-clever}'s built-in
2002 % language files are a set of \emph{key-value options} which are read from the
2003 % file, and fed to \texttt{\cs{keys_set:nn}\{zref-clever/langfile\}} by
2004 % \cs{@@_provide_langfile:n}. And they use the same syntax and options as
2005 % \cs{zcLanguageSetup} does. The language file itself is read with
2006 % \cs{ExplSyntaxOn} with the usual implications for white-space and catcodes.
2007 %
2008 % \cs{@@_provide_langfile:n} is only meant to load the built-in language
2009 % files. For languages declared by the user, or for any settings to a known
2010 % language made with \cs{zcLanguageSetup}, values are populated directly to
2011 % corresponding variables. Hence, there is no need to ``load'' anything in
2012 % this case: definitions and assignments made by the user are performed
2013 % immediately.
2014 %
2015 %
2016 % \begin{macro}{\g_@@_loaded_langfiles_seq}
2017 % Used to keep track of whether a language file has already been loaded or
2018 % not.
2019 % \begin{macrocode}
2020 \seq_new:N \g_@@_loaded_langfiles_seq
2021 % \end{macrocode}
2022 % \end{macro}
2023 %
2024 %
2025 % \begin{macro}{\@@_provide_langfile:n}
2026 % Load language file for known \meta{language} if it is available and if it
2027 % has not already been loaded.
2028 % \begin{syntax}
2029 % \cs{@@_provide_langfile:n} \Arg{language}
2030 % \end{syntax}
2031 % \begin{macrocode}
2032 \cs_new_protected:Npn \@@_provide_langfile:n #1
2033 {
2034 \group_begin:
2035 \@bsphack
2036 \@@_language_if_declared:nT {#1}
2037 {
2038 \seq_if_in:NeF
2039 \g_@@_loaded_langfiles_seq
2040 { \tl_use:c { \@@_language_varname:n {#1} } }
2041 {
2042 \exp_args:Ne \file_get:nnNTF
2043 {
2044 zref-clever-
2045 \tl_use:c { \@@_language_varname:n {#1} }
2046 .lang
2047 }
2048 { \ExplSyntaxOn }
2049 \l_@@_tmpa_tl
2050 {
2051 \tl_set:Nn \l_@@_setup_language_tl {#1}
2052 \tl_clear:N \l_@@_setup_type_tl
2053 \@@_opt_seq_get:cNF
2054 {
2055 \@@_opt_varname_language:nnn
2056 {#1} { variants } { seq }
2057 }
2058 \l_@@_lang_variants_seq
2059 { \seq_clear:N \l_@@_lang_variants_seq }
2060 \seq_if_empty:NTF \l_@@_lang_variants_seq
2061 { \tl_clear:N \l_@@_lang_variant_tl }
2062 {
2063 \seq_get_left:NN \l_@@_lang_variants_seq
2064 \l_@@_lang_variant_tl
2065 }
2066 \@@_opt_seq_get:cNF
2067 {
2068 \@@_opt_varname_language:nnn
2069 {#1} { gender } { seq }
2070 }
2071 \l_@@_lang_gender_seq
2072 { \seq_clear:N \l_@@_lang_gender_seq }
2073 \keys_set:nV { zref-clever/langfile } \l_@@_tmpa_tl
2074 \seq_gput_right:Ne \g_@@_loaded_langfiles_seq
2075 { \tl_use:c { \@@_language_varname:n {#1} } }
2076 \msg_info:nne { zref-clever } { langfile-loaded }
2077 { \tl_use:c { \@@_language_varname:n {#1} } }
2078 }
2079 {
2080 % \end{macrocode}
2081 % Even if we don't have the actual language file, we register it as
2082 % ``loaded''. At this point, it is a known language, properly declared.
2083 % There is no point in trying to load it multiple times, if it was not found
2084 % the first time, it won't be the next.
2085 % \begin{macrocode}
2086 \seq_gput_right:Ne \g_@@_loaded_langfiles_seq
2087 { \tl_use:c { \@@_language_varname:n {#1} } }
2088 }
2089 }
2090 }
2091 \@esphack
2092 \group_end:
2093 }
2094 \cs_generate_variant:Nn \@@_provide_langfile:n { e }
2095 % \end{macrocode}
2096 % \end{macro}
2097 %
2098 %
2099 %
2100 % The set of keys for \texttt{{zref-clever/langfile}}, which is used to
2101 % process the language files in \cs{@@_provide_langfile:n}. The no-op cases
2102 % for each category have their messages sent to ``info''. These messages
2103 % should not occur, as long as the language files are well formed, but they're
2104 % placed there nevertheless, and can be leveraged in regression tests.
2105 %
2106 % \begin{macrocode}
2107 \keys_define:nn { zref-clever/langfile }
2108 {
2109 type .code:n =
2110 {
2111 \tl_if_empty:nTF {#1}
2112 { \tl_clear:N \l_@@_setup_type_tl }
2113 { \tl_set:Nn \l_@@_setup_type_tl {#1} }
2114 } ,
2115 variant .code:n =
2116 {
2117 \seq_if_empty:NTF \l_@@_lang_variants_seq
2118 {
2119 \msg_info:nnee { zref-clever } { language-no-variants-setup }
2120 { \l_@@_setup_language_tl } {#1}
2121 }
2122 {
2123 \seq_if_in:NnTF \l_@@_lang_variants_seq {#1}
2124 { \tl_set:Nn \l_@@_lang_variant_tl {#1} }
2125 {
2126 \msg_info:nnee { zref-clever } { unknown-variant }
2127 {#1} { \l_@@_setup_language_tl }
2128 \seq_get_left:NN \l_@@_lang_variants_seq
2129 \l_@@_lang_variant_tl
2130 }
2131 }
2132 } ,
2133 variant .value_required:n = true ,
2134 gender .value_required:n = true ,
2135 gender .code:n =
2136 {
2137 \seq_if_empty:NTF \l_@@_lang_gender_seq
2138 {
2139 \msg_info:nneee { zref-clever } { language-no-gender }
2140 { \l_@@_setup_language_tl } { gender } {#1}
2141 }
2142 {
2143 \tl_if_empty:NTF \l_@@_setup_type_tl
2144 {
2145 \msg_info:nnn { zref-clever }
2146 { option-only-type-specific } { gender }
2147 }
2148 {
2149 \seq_clear:N \l_@@_tmpa_seq
2150 \clist_map_inline:nn {#1}
2151 {
2152 \seq_if_in:NnTF \l_@@_lang_gender_seq {##1}
2153 { \seq_put_right:Nn \l_@@_tmpa_seq {##1} }
2154 {
2155 \msg_info:nnee { zref-clever }
2156 { gender-not-declared }
2157 { \l_@@_setup_language_tl } {##1}
2158 }
2159 }
2160 \@@_opt_seq_if_set:cF
2161 {
2162 \@@_opt_varname_lang_type:eenn
2163 { \l_@@_setup_language_tl }
2164 { \l_@@_setup_type_tl }
2165 { gender }
2166 { seq }
2167 }
2168 {
2169 \seq_new:c
2170 {
2171 \@@_opt_varname_lang_type:eenn
2172 { \l_@@_setup_language_tl }
2173 { \l_@@_setup_type_tl }
2174 { gender }
2175 { seq }
2176 }
2177 \seq_gset_eq:cN
2178 {
2179 \@@_opt_varname_lang_type:eenn
2180 { \l_@@_setup_language_tl }
2181 { \l_@@_setup_type_tl }
2182 { gender }
2183 { seq }
2184 }
2185 \l_@@_tmpa_seq
2186 }
2187 }
2188 }
2189 } ,
2190 }
2191 \seq_map_inline:Nn
2192 \g_@@_rf_opts_tl_not_type_specific_seq
2193 {
2194 \keys_define:nn { zref-clever/langfile }
2195 {
2196 #1 .value_required:n = true ,
2197 #1 .code:n =
2198 {
2199 \tl_if_empty:NTF \l_@@_setup_type_tl
2200 {
2201 \@@_opt_tl_gset_if_new:cn
2202 {
2203 \@@_opt_varname_lang_default:enn
2204 { \l_@@_setup_language_tl }
2205 {#1} { tl }
2206 }
2207 {##1}
2208 }
2209 {
2210 \msg_info:nnn { zref-clever }
2211 { option-not-type-specific } {#1}
2212 }
2213 } ,
2214 }
2215 }
2216 \seq_map_inline:Nn
2217 \g_@@_rf_opts_tl_maybe_type_specific_seq
2218 {
2219 \keys_define:nn { zref-clever/langfile }
2220 {
2221 #1 .value_required:n = true ,
2222 #1 .code:n =
2223 {
2224 \tl_if_empty:NTF \l_@@_setup_type_tl
2225 {
2226 \@@_opt_tl_gset_if_new:cn
2227 {
2228 \@@_opt_varname_lang_default:enn
2229 { \l_@@_setup_language_tl }
2230 {#1} { tl }
2231 }
2232 {##1}
2233 }
2234 {
2235 \@@_opt_tl_gset_if_new:cn
2236 {
2237 \@@_opt_varname_lang_type:eenn
2238 { \l_@@_setup_language_tl }
2239 { \l_@@_setup_type_tl }
2240 {#1} { tl }
2241 }
2242 {##1}
2243 }
2244 } ,
2245 }
2246 }
2247 \keys_define:nn { zref-clever/langfile }
2248 {
2249 endrange .value_required:n = true ,
2250 endrange .code:n =
2251 {
2252 \str_case:nnF {#1}
2253 {
2254 { ref }
2255 {
2256 \tl_if_empty:NTF \l_@@_setup_type_tl
2257 {
2258 \@@_opt_tl_gclear_if_new:c
2259 {
2260 \@@_opt_varname_lang_default:enn
2261 { \l_@@_setup_language_tl }
2262 { endrangefunc } { tl }
2263 }
2264 \@@_opt_tl_gclear_if_new:c
2265 {
2266 \@@_opt_varname_lang_default:enn
2267 { \l_@@_setup_language_tl }
2268 { endrangeprop } { tl }
2269 }
2270 }
2271 {
2272 \@@_opt_tl_gclear_if_new:c
2273 {
2274 \@@_opt_varname_lang_type:eenn
2275 { \l_@@_setup_language_tl }
2276 { \l_@@_setup_type_tl }
2277 { endrangefunc } { tl }
2278 }
2279 \@@_opt_tl_gclear_if_new:c
2280 {
2281 \@@_opt_varname_lang_type:eenn
2282 { \l_@@_setup_language_tl }
2283 { \l_@@_setup_type_tl }
2284 { endrangeprop } { tl }
2285 }
2286 }
2287 }
2288 { stripprefix }
2289 {
2290 \tl_if_empty:NTF \l_@@_setup_type_tl
2291 {
2292 \@@_opt_tl_gset_if_new:cn
2293 {
2294 \@@_opt_varname_lang_default:enn
2295 { \l_@@_setup_language_tl }
2296 { endrangefunc } { tl }
2297 }
2298 { @@_get_endrange_stripprefix }
2299 \@@_opt_tl_gclear_if_new:c
2300 {
2301 \@@_opt_varname_lang_default:enn
2302 { \l_@@_setup_language_tl }
2303 { endrangeprop } { tl }
2304 }
2305 }
2306 {
2307 \@@_opt_tl_gset_if_new:cn
2308 {
2309 \@@_opt_varname_lang_type:eenn
2310 { \l_@@_setup_language_tl }
2311 { \l_@@_setup_type_tl }
2312 { endrangefunc } { tl }
2313 }
2314 { @@_get_endrange_stripprefix }
2315 \@@_opt_tl_gclear_if_new:c
2316 {
2317 \@@_opt_varname_lang_type:eenn
2318 { \l_@@_setup_language_tl }
2319 { \l_@@_setup_type_tl }
2320 { endrangeprop } { tl }
2321 }
2322 }
2323 }
2324 { pagecomp }
2325 {
2326 \tl_if_empty:NTF \l_@@_setup_type_tl
2327 {
2328 \@@_opt_tl_gset_if_new:cn
2329 {
2330 \@@_opt_varname_lang_default:enn
2331 { \l_@@_setup_language_tl }
2332 { endrangefunc } { tl }
2333 }
2334 { @@_get_endrange_pagecomp }
2335 \@@_opt_tl_gclear_if_new:c
2336 {
2337 \@@_opt_varname_lang_default:enn
2338 { \l_@@_setup_language_tl }
2339 { endrangeprop } { tl }
2340 }
2341 }
2342 {
2343 \@@_opt_tl_gset_if_new:cn
2344 {
2345 \@@_opt_varname_lang_type:eenn
2346 { \l_@@_setup_language_tl }
2347 { \l_@@_setup_type_tl }
2348 { endrangefunc } { tl }
2349 }
2350 { @@_get_endrange_pagecomp }
2351 \@@_opt_tl_gclear_if_new:c
2352 {
2353 \@@_opt_varname_lang_type:eenn
2354 { \l_@@_setup_language_tl }
2355 { \l_@@_setup_type_tl }
2356 { endrangeprop } { tl }
2357 }
2358 }
2359 }
2360 { pagecomp2 }
2361 {
2362 \tl_if_empty:NTF \l_@@_setup_type_tl
2363 {
2364 \@@_opt_tl_gset_if_new:cn
2365 {
2366 \@@_opt_varname_lang_default:enn
2367 { \l_@@_setup_language_tl }
2368 { endrangefunc } { tl }
2369 }
2370 { @@_get_endrange_pagecomptwo }
2371 \@@_opt_tl_gclear_if_new:c
2372 {
2373 \@@_opt_varname_lang_default:enn
2374 { \l_@@_setup_language_tl }
2375 { endrangeprop } { tl }
2376 }
2377 }
2378 {
2379 \@@_opt_tl_gset_if_new:cn
2380 {
2381 \@@_opt_varname_lang_type:eenn
2382 { \l_@@_setup_language_tl }
2383 { \l_@@_setup_type_tl }
2384 { endrangefunc } { tl }
2385 }
2386 { @@_get_endrange_pagecomptwo }
2387 \@@_opt_tl_gclear_if_new:c
2388 {
2389 \@@_opt_varname_lang_type:eenn
2390 { \l_@@_setup_language_tl }
2391 { \l_@@_setup_type_tl }
2392 { endrangeprop } { tl }
2393 }
2394 }
2395 }
2396 }
2397 {
2398 \tl_if_empty:nTF {#1}
2399 {
2400 \msg_info:nnn { zref-clever }
2401 { endrange-property-undefined } {#1}
2402 }
2403 {
2404 \zref@ifpropundefined {#1}
2405 {
2406 \msg_info:nnn { zref-clever }
2407 { endrange-property-undefined } {#1}
2408 }
2409 {
2410 \tl_if_empty:NTF \l_@@_setup_type_tl
2411 {
2412 \@@_opt_tl_gset_if_new:cn
2413 {
2414 \@@_opt_varname_lang_default:enn
2415 { \l_@@_setup_language_tl }
2416 { endrangefunc } { tl }
2417 }
2418 { @@_get_endrange_property }
2419 \@@_opt_tl_gset_if_new:cn
2420 {
2421 \@@_opt_varname_lang_default:enn
2422 { \l_@@_setup_language_tl }
2423 { endrangeprop } { tl }
2424 }
2425 {#1}
2426 }
2427 {
2428 \@@_opt_tl_gset_if_new:cn
2429 {
2430 \@@_opt_varname_lang_type:eenn
2431 { \l_@@_setup_language_tl }
2432 { \l_@@_setup_type_tl }
2433 { endrangefunc } { tl }
2434 }
2435 { @@_get_endrange_property }
2436 \@@_opt_tl_gset_if_new:cn
2437 {
2438 \@@_opt_varname_lang_type:eenn
2439 { \l_@@_setup_language_tl }
2440 { \l_@@_setup_type_tl }
2441 { endrangeprop } { tl }
2442 }
2443 {#1}
2444 }
2445 }
2446 }
2447 }
2448 } ,
2449 }
2450 \seq_map_inline:Nn
2451 \g_@@_rf_opts_tl_type_names_seq
2452 {
2453 \keys_define:nn { zref-clever/langfile }
2454 {
2455 #1 .value_required:n = true ,
2456 #1 .code:n =
2457 {
2458 \tl_if_empty:NTF \l_@@_setup_type_tl
2459 {
2460 \msg_info:nnn { zref-clever }
2461 { option-only-type-specific } {#1}
2462 }
2463 {
2464 \tl_if_empty:NTF \l_@@_lang_variant_tl
2465 {
2466 \@@_opt_tl_gset_if_new:cn
2467 {
2468 \@@_opt_varname_lang_type:eenn
2469 { \l_@@_setup_language_tl }
2470 { \l_@@_setup_type_tl }
2471 {#1} { tl }
2472 }
2473 {##1}
2474 }
2475 {
2476 \@@_opt_tl_gset_if_new:cn
2477 {
2478 \@@_opt_varname_lang_type:eeen
2479 { \l_@@_setup_language_tl }
2480 { \l_@@_setup_type_tl }
2481 { \l_@@_lang_variant_tl - #1 } { tl }
2482 }
2483 {##1}
2484 }
2485 }
2486 } ,
2487 }
2488 }
2489 \seq_map_inline:Nn
2490 \g_@@_rf_opts_seq_refbounds_seq
2491 {
2492 \keys_define:nn { zref-clever/langfile }
2493 {
2494 #1 .value_required:n = true ,
2495 #1 .code:n =
2496 {
2497 \tl_if_empty:NTF \l_@@_setup_type_tl
2498 {
2499 \@@_opt_seq_if_set:cF
2500 {
2501 \@@_opt_varname_lang_default:enn
2502 { \l_@@_setup_language_tl } {#1} { seq }
2503 }
2504 {
2505 \seq_gclear:N \g_@@_tmpa_seq
2506 \@@_opt_seq_gset_clist_split:Nn
2507 \g_@@_tmpa_seq {##1}
2508 \bool_lazy_or:nnTF
2509 { \tl_if_empty_p:n {##1} }
2510 {
2511 \int_compare_p:nNn
2512 { \seq_count:N \g_@@_tmpa_seq } = { 4 }
2513 }
2514 {
2515 \@@_opt_seq_gset_eq:cN
2516 {
2517 \@@_opt_varname_lang_default:enn
2518 { \l_@@_setup_language_tl }
2519 {#1} { seq }
2520 }
2521 \g_@@_tmpa_seq
2522 }
2523 {
2524 \msg_info:nnee { zref-clever }
2525 { refbounds-must-be-four }
2526 {#1} { \seq_count:N \g_@@_tmpa_seq }
2527 }
2528 }
2529 }
2530 {
2531 \@@_opt_seq_if_set:cF
2532 {
2533 \@@_opt_varname_lang_type:eenn
2534 { \l_@@_setup_language_tl }
2535 { \l_@@_setup_type_tl } {#1} { seq }
2536 }
2537 {
2538 \seq_gclear:N \g_@@_tmpa_seq
2539 \@@_opt_seq_gset_clist_split:Nn
2540 \g_@@_tmpa_seq {##1}
2541 \bool_lazy_or:nnTF
2542 { \tl_if_empty_p:n {##1} }
2543 {
2544 \int_compare_p:nNn
2545 { \seq_count:N \g_@@_tmpa_seq } = { 4 }
2546 }
2547 {
2548 \@@_opt_seq_gset_eq:cN
2549 {
2550 \@@_opt_varname_lang_type:eenn
2551 { \l_@@_setup_language_tl }
2552 { \l_@@_setup_type_tl }
2553 {#1} { seq }
2554 }
2555 \g_@@_tmpa_seq
2556 }
2557 {
2558 \msg_info:nnee { zref-clever }
2559 { refbounds-must-be-four }
2560 {#1} { \seq_count:N \g_@@_tmpa_seq }
2561 }
2562 }
2563 }
2564 } ,
2565 }
2566 }
2567 \seq_map_inline:Nn
2568 \g_@@_rf_opts_bool_maybe_type_specific_seq
2569 {
2570 \keys_define:nn { zref-clever/langfile }
2571 {
2572 #1 .choice: ,
2573 #1 / true .code:n =
2574 {
2575 \tl_if_empty:NTF \l_@@_setup_type_tl
2576 {
2577 \@@_opt_bool_if_set:cF
2578 {
2579 \@@_opt_varname_lang_default:enn
2580 { \l_@@_setup_language_tl }
2581 {#1} { bool }
2582 }
2583 {
2584 \@@_opt_bool_gset_true:c
2585 {
2586 \@@_opt_varname_lang_default:enn
2587 { \l_@@_setup_language_tl }
2588 {#1} { bool }
2589 }
2590 }
2591 }
2592 {
2593 \@@_opt_bool_if_set:cF
2594 {
2595 \@@_opt_varname_lang_type:eenn
2596 { \l_@@_setup_language_tl }
2597 { \l_@@_setup_type_tl }
2598 {#1} { bool }
2599 }
2600 {
2601 \@@_opt_bool_gset_true:c
2602 {
2603 \@@_opt_varname_lang_type:eenn
2604 { \l_@@_setup_language_tl }
2605 { \l_@@_setup_type_tl }
2606 {#1} { bool }
2607 }
2608 }
2609 }
2610 } ,
2611 #1 / false .code:n =
2612 {
2613 \tl_if_empty:NTF \l_@@_setup_type_tl
2614 {
2615 \@@_opt_bool_if_set:cF
2616 {
2617 \@@_opt_varname_lang_default:enn
2618 { \l_@@_setup_language_tl }
2619 {#1} { bool }
2620 }
2621 {
2622 \@@_opt_bool_gset_false:c
2623 {
2624 \@@_opt_varname_lang_default:enn
2625 { \l_@@_setup_language_tl }
2626 {#1} { bool }
2627 }
2628 }
2629 }
2630 {
2631 \@@_opt_bool_if_set:cF
2632 {
2633 \@@_opt_varname_lang_type:eenn
2634 { \l_@@_setup_language_tl }
2635 { \l_@@_setup_type_tl }
2636 {#1} { bool }
2637 }
2638 {
2639 \@@_opt_bool_gset_false:c
2640 {
2641 \@@_opt_varname_lang_type:eenn
2642 { \l_@@_setup_language_tl }
2643 { \l_@@_setup_type_tl }
2644 {#1} { bool }
2645 }
2646 }
2647 }
2648 } ,
2649 #1 .default:n = true ,
2650 no #1 .meta:n = { #1 = false } ,
2651 no #1 .value_forbidden:n = true ,
2652 }
2653 }
2654 % \end{macrocode}
2655 %
2656 %
2657 %
2658 % It is convenient for a number of language typesetting options (some basic
2659 % separators) to have some ``fallback'' value available in case \pkg{babel} or
2660 % \pkg{polyglossia} is loaded and sets a language which \pkg{zref-clever} does
2661 % not know. On the other hand, ``type names'' are not looked for in
2662 % ``fallback'', since it is indeed impossible to provide any reasonable value
2663 % for them for a ``specified but unknown language''. Other typesetting
2664 % options, for which it is not a problem being empty, need not be catered for
2665 % with a fallback value.
2666 %
2667 % \begin{macrocode}
2668 \cs_new_protected:Npn \@@_opt_tl_cset_fallback:nn #1#2
2669 {
2670 \tl_const:cn
2671 { \@@_opt_varname_fallback:nn {#1} { tl } } {#2}
2672 }
2673 \keyval_parse:nnn
2674 { }
2675 { \@@_opt_tl_cset_fallback:nn }
2676 {
2677 tpairsep = {,~} ,
2678 tlistsep = {,~} ,
2679 tlastsep = {,~} ,
2680 notesep = {~} ,
2681 namesep = {\nobreakspace} ,
2682 pairsep = {,~} ,
2683 listsep = {,~} ,
2684 lastsep = {,~} ,
2685 rangesep = {\textendash} ,
2686 }
2687 % \end{macrocode}
2688 %
2689 %
2690 %
2691 % \subsection{Options}
2692 %
2693 %
2694 % \subsubsection*{Auxiliary}
2695 %
2696 %
2697 % \begin{macro}{\@@_prop_put_non_empty:Nnn}
2698 % If \meta{value} is empty, remove \meta{key} from \meta{property list}.
2699 % Otherwise, add \meta{key} = \meta{value} to \meta{property list}.
2700 % \begin{syntax}
2701 % \cs{@@_prop_put_non_empty:Nnn} \meta{property list} \Arg{key} \Arg{value}
2702 % \end{syntax}
2703 % \begin{macrocode}
2704 \cs_new_protected:Npn \@@_prop_put_non_empty:Nnn #1#2#3
2705 {
2706 \tl_if_empty:nTF {#3}
2707 { \prop_remove:Nn #1 {#2} }
2708 { \prop_put:Nnn #1 {#2} {#3} }
2709 }
2710 % \end{macrocode}
2711 % \end{macro}
2712 %
2713 %
2714 % \subsubsection*{\opt{ref} option}
2715 %
2716 % \cs{l_@@_ref_property_tl} stores the property to which the reference is
2717 % being made. Note that one thing \emph{must} be handled at this point: the
2718 % existence of the property itself, as far as \pkg{zref} is concerned. This
2719 % because typesetting relies on the check \cs{zref@ifrefcontainsprop}, which
2720 % \emph{presumes} the property is defined and silently expands the \emph{true}
2721 % branch if it is not (insightful comments by \contributor{Ulrike Fischer} at
2722 % \url{https://github.com/ho-tex/zref/issues/13}). Therefore, before adding
2723 % anything to \cs{l_@@_ref_property_tl}, check if first here with
2724 % \cs{zref@ifpropundefined}: close it at the door. We must also control for
2725 % an empty value, since ``empty'' passes both \cs{zref@ifpropundefined} and
2726 % \cs{zref@ifrefcontainsprop}.
2727 %
2728 %
2729 % \begin{macrocode}
2730 \tl_new:N \l_@@_ref_property_tl
2731 \keys_define:nn { zref-clever/reference }
2732 {
2733 ref .code:n =
2734 {
2735 \tl_if_empty:nTF {#1}
2736 {
2737 \msg_warning:nnn { zref-clever }
2738 { zref-property-undefined } {#1}
2739 \tl_set:Nn \l_@@_ref_property_tl { default }
2740 }
2741 {
2742 \zref@ifpropundefined {#1}
2743 {
2744 \msg_warning:nnn { zref-clever }
2745 { zref-property-undefined } {#1}
2746 \tl_set:Nn \l_@@_ref_property_tl { default }
2747 }
2748 { \tl_set:Nn \l_@@_ref_property_tl {#1} }
2749 }
2750 } ,
2751 ref .initial:n = default ,
2752 ref .value_required:n = true ,
2753 page .meta:n = { ref = page },
2754 page .value_forbidden:n = true ,
2755 }
2756 % \end{macrocode}
2757 %
2758 %
2759 %
2760 % \subsubsection*{\opt{typeset} option}
2761 %
2762 % \begin{macrocode}
2763 \bool_new:N \l_@@_typeset_ref_bool
2764 \bool_new:N \l_@@_typeset_name_bool
2765 \keys_define:nn { zref-clever/reference }
2766 {
2767 typeset .choice: ,
2768 typeset / both .code:n =
2769 {
2770 \bool_set_true:N \l_@@_typeset_ref_bool
2771 \bool_set_true:N \l_@@_typeset_name_bool
2772 } ,
2773 typeset / ref .code:n =
2774 {
2775 \bool_set_true:N \l_@@_typeset_ref_bool
2776 \bool_set_false:N \l_@@_typeset_name_bool
2777 } ,
2778 typeset / name .code:n =
2779 {
2780 \bool_set_false:N \l_@@_typeset_ref_bool
2781 \bool_set_true:N \l_@@_typeset_name_bool
2782 } ,
2783 typeset .initial:n = both ,
2784 typeset .value_required:n = true ,
2785 noname .meta:n = { typeset = ref } ,
2786 noname .value_forbidden:n = true ,
2787 noref .meta:n = { typeset = name } ,
2788 noref .value_forbidden:n = true ,
2789 }
2790 % \end{macrocode}
2791 %
2792 %
2793 %
2794 % \subsubsection*{\opt{sort} option}
2795 %
2796 % \begin{macrocode}
2797 \bool_new:N \l_@@_typeset_sort_bool
2798 \keys_define:nn { zref-clever/reference }
2799 {
2800 sort .bool_set:N = \l_@@_typeset_sort_bool ,
2801 sort .initial:n = true ,
2802 sort .default:n = true ,
2803 nosort .meta:n = { sort = false },
2804 nosort .value_forbidden:n = true ,
2805 }
2806 % \end{macrocode}
2807 %
2808 %
2809 %
2810 % \subsubsection*{\opt{typesort} option}
2811 %
2812 % \cs{l_@@_typesort_seq} is stored reversed, since the sort priorities are
2813 % computed in the negative range in \cs{@@_sort_default_different_types:nn},
2814 % so that we can implicitly rely on `0' being the ``last value'', and spare
2815 % creating an integer variable using \cs{seq_map_indexed_inline:Nn}.
2816 %
2817 % \begin{macrocode}
2818 \seq_new:N \l_@@_typesort_seq
2819 \keys_define:nn { zref-clever/reference }
2820 {
2821 typesort .code:n =
2822 {
2823 \seq_set_from_clist:Nn \l_@@_typesort_seq {#1}
2824 \seq_reverse:N \l_@@_typesort_seq
2825 } ,
2826 typesort .initial:n =
2827 { part , chapter , section , paragraph },
2828 typesort .value_required:n = true ,
2829 notypesort .code:n =
2830 { \seq_clear:N \l_@@_typesort_seq } ,
2831 notypesort .value_forbidden:n = true ,
2832 }
2833 % \end{macrocode}
2834 %
2835 %
2836 %
2837 % \subsubsection*{\opt{comp} option}
2838 %
2839 % \begin{macrocode}
2840 \bool_new:N \l_@@_typeset_compress_bool
2841 \keys_define:nn { zref-clever/reference }
2842 {
2843 comp .bool_set:N = \l_@@_typeset_compress_bool ,
2844 comp .initial:n = true ,
2845 comp .default:n = true ,
2846 nocomp .meta:n = { comp = false },
2847 nocomp .value_forbidden:n = true ,
2848 }
2849 % \end{macrocode}
2850 %
2851 %
2852 %
2853 % \subsubsection*{\opt{endrange} option}
2854 %
2855 % The working of \opt{endrange} option depends on two underlying option values
2856 % / variables: \texttt{endrangefunc} and \texttt{endrangeprop}.
2857 % \texttt{endrangefunc} is the more general one, and \texttt{endrangeprop} is
2858 % used when the first is set to \cs{@@_get_endrange_property:VVN}, which is
2859 % the case when the user is setting \opt{endrange} to an arbitrary \pkg{zref}
2860 % property, instead of one of the \cs{str_case:nn} matches.
2861 %
2862 % \texttt{endrangefunc} \emph{must} receive three arguments and, more
2863 % specifically, its signature \emph{must} be \texttt{VVN}. For this reason,
2864 % \texttt{endrangefunc} should be stored without the signature, which is
2865 % added, and hard-coded, at the calling place. The first argument is
2866 % \meta{beg range label}, the second \meta{end range label}, and the last
2867 % \meta{tl var to set}. Of course, \meta{tl var to set} must be set to a
2868 % proper value, and that's the main task of the function.
2869 % \texttt{endrangefunc} must also handle the case where
2870 % \cs{zref@ifrefcontainsprop} is false, since \cs{@@_get_ref_endrange:nnN}
2871 % cannot take care of that. For this purpose, it may set \meta{tl var to set}
2872 % to the special value \texttt{zc@missingproperty}, to signal a missing
2873 % property for \cs{@@_get_ref_endrange:nnN}.
2874 %
2875 % An empty \texttt{endrangefunc} signals that no processing is to be made to
2876 % the end range reference, that is, that it should be treated like any other
2877 % one, as defined by the \opt{ref} option. This may happen either because
2878 % \opt{endrange} was never set for the reference type, and empty is the value
2879 % ``returned'' by \cs{@@_get_rf_opt_tl:nnnN} for options not set, or because
2880 % \opt{endrange} was set to \texttt{ref} at some scope which happens to get
2881 % precedence.
2882 %
2883 % One thing I was divided about in this functionality was whether to expand
2884 % the references before processing them, when such processing is required. At
2885 % first sight, it makes sense to do so, since we are aiming at ``removing
2886 % common parts'' as close as possible to the printed representation of the
2887 % references (\pkg{cleveref} does expand them in \cs{crefstripprefix}). On
2888 % the other hand, this brings some new challenges: if a fragile command gets
2889 % there, we are in trouble; also, if a protected one gets there, though things
2890 % won't break as badly, we may ``strip'' the macro and stay with different
2891 % arguments, which will then end up in the input stream. I think
2892 % \pkg{biblatex} is a good reference here, and it offers \cs{NumCheckSetup},
2893 % \cs{NumsCheckSetup}, and \cs{PagesCheckSetup} aimed at locally redefining
2894 % some commands which may interfere with the processing. This is a good idea,
2895 % thus we offer a similar hook for the same purpose: \texttt{endrange-setup}.
2896 %
2897 % \begin{macrocode}
2898 \NewHook { zref-clever/endrange-setup }
2899 % \end{macrocode}
2900 %
2901 %
2902 % \begin{macrocode}
2903 \keys_define:nn { zref-clever/reference }
2904 {
2905 endrange .code:n =
2906 {
2907 \str_case:nnF {#1}
2908 {
2909 { ref }
2910 {
2911 \@@_opt_tl_clear:c
2912 {
2913 \@@_opt_varname_general:nn
2914 { endrangefunc } { tl }
2915 }
2916 \@@_opt_tl_clear:c
2917 {
2918 \@@_opt_varname_general:nn
2919 { endrangeprop } { tl }
2920 }
2921 }
2922 { stripprefix }
2923 {
2924 \@@_opt_tl_set:cn
2925 {
2926 \@@_opt_varname_general:nn
2927 { endrangefunc } { tl }
2928 }
2929 { @@_get_endrange_stripprefix }
2930 \@@_opt_tl_clear:c
2931 {
2932 \@@_opt_varname_general:nn
2933 { endrangeprop } { tl }
2934 }
2935 }
2936 { pagecomp }
2937 {
2938 \@@_opt_tl_set:cn
2939 {
2940 \@@_opt_varname_general:nn
2941 { endrangefunc } { tl }
2942 }
2943 { @@_get_endrange_pagecomp }
2944 \@@_opt_tl_clear:c
2945 {
2946 \@@_opt_varname_general:nn
2947 { endrangeprop } { tl }
2948 }
2949 }
2950 { pagecomp2 }
2951 {
2952 \@@_opt_tl_set:cn
2953 {
2954 \@@_opt_varname_general:nn
2955 { endrangefunc } { tl }
2956 }
2957 { @@_get_endrange_pagecomptwo }
2958 \@@_opt_tl_clear:c
2959 {
2960 \@@_opt_varname_general:nn
2961 { endrangeprop } { tl }
2962 }
2963 }
2964 { unset }
2965 {
2966 \@@_opt_tl_unset:c
2967 {
2968 \@@_opt_varname_general:nn
2969 { endrangefunc } { tl }
2970 }
2971 \@@_opt_tl_unset:c
2972 {
2973 \@@_opt_varname_general:nn
2974 { endrangeprop } { tl }
2975 }
2976 }
2977 }
2978 {
2979 \tl_if_empty:nTF {#1}
2980 {
2981 \msg_warning:nnn { zref-clever }
2982 { endrange-property-undefined } {#1}
2983 }
2984 {
2985 \zref@ifpropundefined {#1}
2986 {
2987 \msg_warning:nnn { zref-clever }
2988 { endrange-property-undefined } {#1}
2989 }
2990 {
2991 \@@_opt_tl_set:cn
2992 {
2993 \@@_opt_varname_general:nn
2994 { endrangefunc } { tl }
2995 }
2996 { @@_get_endrange_property }
2997 \@@_opt_tl_set:cn
2998 {
2999 \@@_opt_varname_general:nn
3000 { endrangeprop } { tl }
3001 }
3002 {#1}
3003 }
3004 }
3005 }
3006 } ,
3007 endrange .value_required:n = true ,
3008 }
3009 % \end{macrocode}
3010 %
3011 %
3012 % \begin{macrocode}
3013 \cs_new_protected:Npn \@@_get_endrange_property:nnN #1#2#3
3014 {
3015 \tl_if_empty:NTF \l_@@_endrangeprop_tl
3016 {
3017 \zref@ifrefcontainsprop {#2} { \l_@@_ref_property_tl }
3018 {
3019 \@@_extract_default:Nnvn #3
3020 {#2} { l_@@_ref_property_tl } { }
3021 }
3022 { \tl_set:Nn #3 { zc@missingproperty } }
3023 }
3024 {
3025 \zref@ifrefcontainsprop {#2} { \l_@@_endrangeprop_tl }
3026 {
3027 % \end{macrocode}
3028 % If the range came about by normal compression, we already know the beginning
3029 % and the end references share the same ``form'' and ``prefix'' (this is
3030 % ensured at \cs{@@_labels_in_sequence:nn}), but the same is not true if the
3031 % \opt{range} option is being used, in which case, we have to check the
3032 % replacement \cs{l_@@_ref_property_tl} by \cs{l_@@_endrangeprop_tl} is really
3033 % granted.
3034 % \begin{macrocode}
3035 \bool_if:NTF \l_@@_typeset_range_bool
3036 {
3037 \group_begin:
3038 \bool_set_false:N \l_@@_tmpa_bool
3039 \exp_args:Nee \tl_if_eq:nnT
3040 {
3041 \@@_extract_unexp:nnn
3042 {#1} { externaldocument } { }
3043 }
3044 {
3045 \@@_extract_unexp:nnn
3046 {#2} { externaldocument } { }
3047 }
3048 {
3049 \tl_if_eq:NnTF \l_@@_ref_property_tl { page }
3050 {
3051 \exp_args:Nee \tl_if_eq:nnT
3052 {
3053 \@@_extract_unexp:nnn
3054 {#1} { zc@pgfmt } { }
3055 }
3056 {
3057 \@@_extract_unexp:nnn
3058 {#2} { zc@pgfmt } { }
3059 }
3060 { \bool_set_true:N \l_@@_tmpa_bool }
3061 }
3062 {
3063 \exp_args:Nee \tl_if_eq:nnT
3064 {
3065 \@@_extract_unexp:nnn
3066 {#1} { zc@counter } { }
3067 }
3068 {
3069 \@@_extract_unexp:nnn
3070 {#2} { zc@counter } { }
3071 }
3072 {
3073 \exp_args:Nee \tl_if_eq:nnT
3074 {
3075 \@@_extract_unexp:nnn
3076 {#1} { zc@enclval } { }
3077 }
3078 {
3079 \@@_extract_unexp:nnn
3080 {#2} { zc@enclval } { }
3081 }
3082 { \bool_set_true:N \l_@@_tmpa_bool }
3083 }
3084 }
3085 }
3086 \bool_if:NTF \l_@@_tmpa_bool
3087 {
3088 \@@_extract_default:Nnvn \l_@@_tmpb_tl
3089 {#2} { l_@@_endrangeprop_tl } { }
3090 }
3091 {
3092 \zref@ifrefcontainsprop
3093 {#2} { \l_@@_ref_property_tl }
3094 {
3095 \@@_extract_default:Nnvn \l_@@_tmpb_tl
3096 {#2} { l_@@_ref_property_tl } { }
3097 }
3098 { \tl_set:Nn \l_@@_tmpb_tl { zc@missingproperty } }
3099 }
3100 \exp_args:NNNV
3101 \group_end:
3102 \tl_set:Nn #3 \l_@@_tmpb_tl
3103 }
3104 {
3105 \@@_extract_default:Nnvn #3
3106 {#2} { l_@@_endrangeprop_tl } { }
3107 }
3108 }
3109 {
3110 \zref@ifrefcontainsprop {#2} { \l_@@_ref_property_tl }
3111 {
3112 \@@_extract_default:Nnvn #3
3113 {#2} { l_@@_ref_property_tl } { }
3114 }
3115 { \tl_set:Nn #3 { zc@missingproperty } }
3116 }
3117 }
3118 }
3119 \cs_generate_variant:Nn \@@_get_endrange_property:nnN { VVN }
3120 % \end{macrocode}
3121 %
3122 %
3123 %
3124 % For the technique for smuggling the assignment out of the group, see
3125 % \contributor{Enrico Gregorio}'s answer at
3126 % \url{https://tex.stackexchange.com/a/56314}.
3127 %
3128 % \begin{macrocode}
3129 \cs_new_protected:Npn \@@_get_endrange_stripprefix:nnN #1#2#3
3130 {
3131 \zref@ifrefcontainsprop {#2} { \l_@@_ref_property_tl }
3132 {
3133 \group_begin:
3134 \UseHook { zref-clever/endrange-setup }
3135 \protected@edef \l_@@_tmpa_tl
3136 {
3137 \@@_extract:nnn
3138 {#1} { \l_@@_ref_property_tl } { }
3139 }
3140 \protected@edef \l_@@_tmpb_tl
3141 {
3142 \@@_extract:nnn
3143 {#2} { \l_@@_ref_property_tl } { }
3144 }
3145 \bool_set_false:N \l_@@_tmpa_bool
3146 \bool_until_do:Nn \l_@@_tmpa_bool
3147 {
3148 \exp_args:Nee \tl_if_eq:nnTF
3149 { \tl_head:V \l_@@_tmpa_tl }
3150 { \tl_head:V \l_@@_tmpb_tl }
3151 {
3152 \tl_set:Ne \l_@@_tmpa_tl
3153 { \tl_tail:V \l_@@_tmpa_tl }
3154 \tl_set:Ne \l_@@_tmpb_tl
3155 { \tl_tail:V \l_@@_tmpb_tl }
3156 \tl_if_empty:NT \l_@@_tmpb_tl
3157 { \bool_set_true:N \l_@@_tmpa_bool }
3158 }
3159 { \bool_set_true:N \l_@@_tmpa_bool }
3160 }
3161 \exp_args:NNNV
3162 \group_end:
3163 \tl_set:Nn #3 \l_@@_tmpb_tl
3164 }
3165 { \tl_set:Nn #3 { zc@missingproperty } }
3166 }
3167 \cs_generate_variant:Nn \@@_get_endrange_stripprefix:nnN { VVN }
3168 % \end{macrocode}
3169 %
3170 %
3171 % \begin{macro}{\@@_is_integer_rgx:n}
3172 % Test if argument is composed only of digits (adapted from
3173 % \url{https://tex.stackexchange.com/a/427559}).
3174 % \begin{macrocode}
3175 \prg_new_protected_conditional:Npnn
3176 \@@_is_integer_rgx:n #1 { F , TF }
3177 {
3178 \regex_match:nnTF { \A\d+\Z } {#1}
3179 { \prg_return_true: }
3180 { \prg_return_false: }
3181 }
3182 \prg_generate_conditional_variant:Nnn
3183 \@@_is_integer_rgx:n { V } { F , TF }
3184 % \end{macrocode}
3185 % \end{macro}
3186 %
3187 %
3188 % \begin{macrocode}
3189 \cs_new_protected:Npn \@@_get_endrange_pagecomp:nnN #1#2#3
3190 {
3191 \zref@ifrefcontainsprop {#2} { \l_@@_ref_property_tl }
3192 {
3193 \group_begin:
3194 \UseHook { zref-clever/endrange-setup }
3195 \protected@edef \l_@@_tmpa_tl
3196 {
3197 \@@_extract:nnn
3198 {#1} { \l_@@_ref_property_tl } { }
3199 }
3200 \protected@edef \l_@@_tmpb_tl
3201 {
3202 \@@_extract:nnn
3203 {#2} { \l_@@_ref_property_tl } { }
3204 }
3205 \bool_set_false:N \l_@@_tmpa_bool
3206 \@@_is_integer_rgx:VTF \l_@@_tmpa_tl
3207 {
3208 \@@_is_integer_rgx:VF \l_@@_tmpb_tl
3209 { \bool_set_true:N \l_@@_tmpa_bool }
3210 }
3211 { \bool_set_true:N \l_@@_tmpa_bool }
3212 \bool_until_do:Nn \l_@@_tmpa_bool
3213 {
3214 \exp_args:Nee \tl_if_eq:nnTF
3215 { \tl_head:V \l_@@_tmpa_tl }
3216 { \tl_head:V \l_@@_tmpb_tl }
3217 {
3218 \tl_set:Ne \l_@@_tmpa_tl
3219 { \tl_tail:V \l_@@_tmpa_tl }
3220 \tl_set:Ne \l_@@_tmpb_tl
3221 { \tl_tail:V \l_@@_tmpb_tl }
3222 \tl_if_empty:NT \l_@@_tmpb_tl
3223 { \bool_set_true:N \l_@@_tmpa_bool }
3224 }
3225 { \bool_set_true:N \l_@@_tmpa_bool }
3226 }
3227 \exp_args:NNNV
3228 \group_end:
3229 \tl_set:Nn #3 \l_@@_tmpb_tl
3230 }
3231 { \tl_set:Nn #3 { zc@missingproperty } }
3232 }
3233 \cs_generate_variant:Nn \@@_get_endrange_pagecomp:nnN { VVN }
3234 % \end{macrocode}
3235 %
3236 %
3237 % \begin{macrocode}
3238 \cs_new_protected:Npn \@@_get_endrange_pagecomptwo:nnN #1#2#3
3239 {
3240 \zref@ifrefcontainsprop {#2} { \l_@@_ref_property_tl }
3241 {
3242 \group_begin:
3243 \UseHook { zref-clever/endrange-setup }
3244 \protected@edef \l_@@_tmpa_tl
3245 {
3246 \@@_extract:nnn
3247 {#1} { \l_@@_ref_property_tl } { }
3248 }
3249 \protected@edef \l_@@_tmpb_tl
3250 {
3251 \@@_extract:nnn
3252 {#2} { \l_@@_ref_property_tl } { }
3253 }
3254 \bool_set_false:N \l_@@_tmpa_bool
3255 \@@_is_integer_rgx:VTF \l_@@_tmpa_tl
3256 {
3257 \@@_is_integer_rgx:VF \l_@@_tmpb_tl
3258 { \bool_set_true:N \l_@@_tmpa_bool }
3259 }
3260 { \bool_set_true:N \l_@@_tmpa_bool }
3261 \bool_until_do:Nn \l_@@_tmpa_bool
3262 {
3263 \exp_args:Nee \tl_if_eq:nnTF
3264 { \tl_head:V \l_@@_tmpa_tl }
3265 { \tl_head:V \l_@@_tmpb_tl }
3266 {
3267 \bool_lazy_or:nnTF
3268 { \int_compare_p:nNn { \l_@@_tmpb_tl } > { 99 } }
3269 {
3270 \int_compare_p:nNn
3271 { \tl_head:V \l_@@_tmpb_tl } = { 0 }
3272 }
3273 {
3274 \tl_set:Ne \l_@@_tmpa_tl
3275 { \tl_tail:V \l_@@_tmpa_tl }
3276 \tl_set:Ne \l_@@_tmpb_tl
3277 { \tl_tail:V \l_@@_tmpb_tl }
3278 }
3279 { \bool_set_true:N \l_@@_tmpa_bool }
3280 }
3281 { \bool_set_true:N \l_@@_tmpa_bool }
3282 }
3283 \exp_args:NNNV
3284 \group_end:
3285 \tl_set:Nn #3 \l_@@_tmpb_tl
3286 }
3287 { \tl_set:Nn #3 { zc@missingproperty } }
3288 }
3289 \cs_generate_variant:Nn \@@_get_endrange_pagecomptwo:nnN { VVN }
3290 % \end{macrocode}
3291 %
3292 %
3293 %
3294 % \subsubsection*{\opt{range} and \opt{rangetopair} options}
3295 %
3296 % The \opt{rangetopair} option is being handled with other reference format
3297 % option booleans at \cs{g_@@_rf_opts_bool_maybe_type_specific_seq}.
3298 %
3299 % \begin{macrocode}
3300 \bool_new:N \l_@@_typeset_range_bool
3301 \keys_define:nn { zref-clever/reference }
3302 {
3303 range .bool_set:N = \l_@@_typeset_range_bool ,
3304 range .initial:n = false ,
3305 range .default:n = true ,
3306 }
3307 % \end{macrocode}
3308 %
3309 %
3310 %
3311 % \subsubsection*{\opt{cap} and \opt{capfirst} options}
3312 %
3313 % The \opt{cap} option is currently being handled with other reference format
3314 % option booleans at \cs{g_@@_rf_opts_bool_maybe_type_specific_seq}.
3315 %
3316 % \begin{macrocode}
3317 \bool_new:N \l_@@_capfirst_bool
3318 \keys_define:nn { zref-clever/reference }
3319 {
3320 capfirst .bool_set:N = \l_@@_capfirst_bool ,
3321 capfirst .initial:n = false ,
3322 capfirst .default:n = true ,
3323 }
3324 % \end{macrocode}
3325 %
3326 %
3327 % \subsubsection*{\opt{abbrev} and \opt{noabbrevfirst} options}
3328 %
3329 % The \opt{abbrev} option is currently being handled with other reference
3330 % format option booleans at \cs{g_@@_rf_opts_bool_maybe_type_specific_seq}.
3331 %
3332 % \begin{macrocode}
3333 \bool_new:N \l_@@_noabbrev_first_bool
3334 \keys_define:nn { zref-clever/reference }
3335 {
3336 noabbrevfirst .bool_set:N = \l_@@_noabbrev_first_bool ,
3337 noabbrevfirst .initial:n = false ,
3338 noabbrevfirst .default:n = true ,
3339 }
3340 % \end{macrocode}
3341 %
3342 %
3343 %
3344 % \subsubsection*{\opt{S} option}
3345 %
3346 % \begin{macrocode}
3347 \keys_define:nn { zref-clever/reference }
3348 {
3349 S .meta:n =
3350 { capfirst = {#1} , noabbrevfirst = {#1} },
3351 S .default:n = true ,
3352 }
3353 % \end{macrocode}
3354 %
3355 %
3356 % \subsubsection*{\opt{hyperref} option}
3357 %
3358 % \begin{macrocode}
3359 \bool_new:N \l_@@_hyperlink_bool
3360 \bool_new:N \l_@@_hyperref_warn_bool
3361 \keys_define:nn { zref-clever/reference }
3362 {
3363 hyperref .choice: ,
3364 hyperref / auto .code:n =
3365 {
3366 \bool_set_true:N \l_@@_hyperlink_bool
3367 \bool_set_false:N \l_@@_hyperref_warn_bool
3368 } ,
3369 hyperref / true .code:n =
3370 {
3371 \bool_set_true:N \l_@@_hyperlink_bool
3372 \bool_set_true:N \l_@@_hyperref_warn_bool
3373 } ,
3374 hyperref / false .code:n =
3375 {
3376 \bool_set_false:N \l_@@_hyperlink_bool
3377 \bool_set_false:N \l_@@_hyperref_warn_bool
3378 } ,
3379 hyperref .initial:n = auto ,
3380 hyperref .default:n = true ,
3381 % \end{macrocode}
3382 % \opt{nohyperref} is provided mainly as a means to inhibit hyperlinking
3383 % locally in \pkg{zref-vario}'s commands without the need to be setting
3384 % \pkg{zref-clever}'s internal variables directly. What limits setting
3385 % \opt{hyperref} out of the preamble is that enabling hyperlinks requires
3386 % loading packages. But \opt{nohyperref} can only disable them, so we can use
3387 % it in the document body too.
3388 % \begin{macrocode}
3389 nohyperref .meta:n = { hyperref = false } ,
3390 nohyperref .value_forbidden:n = true ,
3391 }
3392 % \end{macrocode}
3393 %
3394 % \begin{macrocode}
3395 \AddToHook { begindocument }
3396 {
3397 \@@_if_package_loaded:nTF { hyperref }
3398 {
3399 \bool_if:NT \l_@@_hyperlink_bool
3400 { \RequirePackage { zref-hyperref } }
3401 }
3402 {
3403 \bool_if:NT \l_@@_hyperref_warn_bool
3404 { \msg_warning:nn { zref-clever } { missing-hyperref } }
3405 \bool_set_false:N \l_@@_hyperlink_bool
3406 }
3407 \keys_define:nn { zref-clever/reference }
3408 {
3409 hyperref .code:n =
3410 { \msg_warning:nn { zref-clever } { hyperref-preamble-only } } ,
3411 nohyperref .code:n =
3412 { \bool_set_false:N \l_@@_hyperlink_bool } ,
3413 }
3414 }
3415 % \end{macrocode}
3416 %
3417 %
3418 %
3419 % \subsubsection*{\opt{nameinlink} option}
3420 %
3421 % \begin{macrocode}
3422 \str_new:N \l_@@_nameinlink_str
3423 \keys_define:nn { zref-clever/reference }
3424 {
3425 nameinlink .choice: ,
3426 nameinlink / true .code:n =
3427 { \str_set:Nn \l_@@_nameinlink_str { true } } ,
3428 nameinlink / false .code:n =
3429 { \str_set:Nn \l_@@_nameinlink_str { false } } ,
3430 nameinlink / single .code:n =
3431 { \str_set:Nn \l_@@_nameinlink_str { single } } ,
3432 nameinlink / tsingle .code:n =
3433 { \str_set:Nn \l_@@_nameinlink_str { tsingle } } ,
3434 nameinlink .initial:n = tsingle ,
3435 nameinlink .default:n = true ,
3436 }
3437 % \end{macrocode}
3438 %
3439 %
3440 % \subsubsection*{\opt{preposinlink} option (deprecated)}
3441 %
3442 % \begin{macrocode}
3443 \keys_define:nn { zref-clever/reference }
3444 {
3445 preposinlink .code:n =
3446 {
3447 % NOTE Option deprecated in 2022-01-12 for v0.2.0-alpha.
3448 \msg_warning:nnnn { zref-clever }{ option-deprecated }
3449 { preposinlink } { refbounds }
3450 } ,
3451 }
3452 % \end{macrocode}
3453 %
3454 %
3455 % \subsubsection*{\opt{lang} option}
3456 % \phantomsection{}\zlabel{sec:lang-option}
3457 %
3458 % The overall setup here seems a little roundabout, but this is actually
3459 % required. In the preamble, we (potentially) don't yet have values for the
3460 % ``current'' and ``main'' document languages, this must be retrieved at a
3461 % \texttt{begindocument} hook. The \texttt{begindocument} hook is responsible
3462 % to get values for \cs{l_@@_current_language_tl} and
3463 % \cs{l_@@_main_language_tl}, and to set the default for
3464 % \cs{l_@@_ref_language_tl}. Package options, or preamble calls to
3465 % \cs{zcsetup} are also hooked at \texttt{begindocument}, but come after the
3466 % first hook, so that the pertinent variables have been set when they are
3467 % executed. Finally, we set a third \texttt{begindocument} hook, at
3468 % \texttt{begindocument/before}, so that it runs after any options set in the
3469 % preamble. This hook redefines the \opt{lang} option for immediate execution
3470 % in the document body, and ensures the \texttt{current} language's language
3471 % file gets loaded, if it hadn't been already.
3472 %
3473 % For the \pkg{babel} and \pkg{polyglossia} variables which store the
3474 % ``current'' and ``main'' languages, see
3475 % \url{https://tex.stackexchange.com/a/233178}, including comments,
3476 % particularly the one by Javier Bezos. For the \pkg{babel} and
3477 % \pkg{polyglossia} variables which store the list of loaded languages, see
3478 % \url{https://tex.stackexchange.com/a/281220}, including comments,
3479 % particularly PLK's. Note, however, that languages loaded by
3480 % \cs{babelprovide}, either directly, ``on the fly'', or with the
3481 % \texttt{provide} option, \texttt{do not} get included in \cs{bbl@loaded}.
3482 %
3483 %
3484 % \begin{macrocode}
3485 \AddToHook { begindocument }
3486 {
3487 \@@_if_package_loaded:nTF { babel }
3488 {
3489 \tl_set:Nn \l_@@_current_language_tl { \languagename }
3490 \tl_set:Nn \l_@@_main_language_tl { \bbl@main@language }
3491 }
3492 {
3493 \@@_if_package_loaded:nTF { polyglossia }
3494 {
3495 \tl_set:Nn \l_@@_current_language_tl { \babelname }
3496 \tl_set:Nn \l_@@_main_language_tl { \mainbabelname }
3497 }
3498 {
3499 \tl_set:Nn \l_@@_current_language_tl { english }
3500 \tl_set:Nn \l_@@_main_language_tl { english }
3501 }
3502 }
3503 }
3504 % \end{macrocode}
3505 %
3506 %
3507 % \begin{macrocode}
3508 \keys_define:nn { zref-clever/reference }
3509 {
3510 lang .code:n =
3511 {
3512 \AddToHook { begindocument }
3513 {
3514 \str_case:nnF {#1}
3515 {
3516 { current }
3517 {
3518 \tl_set:Nn \l_@@_ref_language_tl
3519 { \l_@@_current_language_tl }
3520 }
3521 { main }
3522 {
3523 \tl_set:Nn \l_@@_ref_language_tl
3524 { \l_@@_main_language_tl }
3525 }
3526 }
3527 {
3528 \tl_set:Nn \l_@@_ref_language_tl {#1}
3529 \@@_language_if_declared:nF {#1}
3530 {
3531 \msg_warning:nnn { zref-clever }
3532 { unknown-language-opt } {#1}
3533 }
3534 }
3535 \@@_provide_langfile:e
3536 { \l_@@_ref_language_tl }
3537 }
3538 } ,
3539 lang .initial:n = current ,
3540 lang .value_required:n = true ,
3541 }
3542 % \end{macrocode}
3543 %
3544 %
3545 % \begin{macrocode}
3546 \AddToHook { begindocument / before }
3547 {
3548 \AddToHook { begindocument }
3549 {
3550 % \end{macrocode}
3551 % Redefinition of the \texttt{lang} key option for the document body. Also,
3552 % drop the language file loading in the document body, it is somewhat
3553 % redundant, since \cs{@@_zcref:nnn} already ensures it.
3554 % \begin{macrocode}
3555 \keys_define:nn { zref-clever/reference }
3556 {
3557 lang .code:n =
3558 {
3559 \str_case:nnF {#1}
3560 {
3561 { current }
3562 {
3563 \tl_set:Nn \l_@@_ref_language_tl
3564 { \l_@@_current_language_tl }
3565 }
3566 { main }
3567 {
3568 \tl_set:Nn \l_@@_ref_language_tl
3569 { \l_@@_main_language_tl }
3570 }
3571 }
3572 {
3573 \tl_set:Nn \l_@@_ref_language_tl {#1}
3574 \@@_language_if_declared:nF {#1}
3575 {
3576 \msg_warning:nnn { zref-clever }
3577 { unknown-language-opt } {#1}
3578 }
3579 }
3580 } ,
3581 }
3582 }
3583 }
3584 % \end{macrocode}
3585 %
3586 %
3587 %
3588 % \subsubsection*{\opt{v} option}
3589 %
3590 % For setting the variant. Short for convenience and for not polluting the
3591 % markup too much given that, for languages that need it, it may get to be
3592 % used frequently.
3593 %
3594 % \contributor{\username{samcarter}} and \contributor{Alan Munn} provided
3595 % useful comments about declension on the TeX.SX chat. Also,
3596 % \contributor{Florent Rougon}'s efforts in this area, with the \pkg{xcref}
3597 % package (\url{https://github.com/frougon/xcref}), have been an insightful
3598 % source to frame the problem in general terms.
3599 %
3600 % \begin{macrocode}
3601 \tl_new:N \l_@@_ref_variant_tl
3602 \keys_define:nn { zref-clever/reference }
3603 {
3604 v .code:n =
3605 { \msg_warning:nnn { zref-clever } { option-document-only } { v } } ,
3606 % NOTE Option deprecated in 2024-11-24 for v0.5.0.
3607 d .meta:n = { v = {#1} } ,
3608 }
3609 \AddToHook { begindocument }
3610 {
3611 \keys_define:nn { zref-clever/reference }
3612 {
3613 % \end{macrocode}
3614 % We just store the value at this point, which is validated by
3615 % \cs{@@_process_language_settings:} after \cs{keys_set:nn}.
3616 % \begin{macrocode}
3617 v .tl_set:N = \l_@@_ref_variant_tl ,
3618 v .value_required:n = true ,
3619 % NOTE Option deprecated in 2024-11-24 for v0.5.0.
3620 d .meta:n = { v = {#1} } ,
3621 }
3622 }
3623 % \end{macrocode}
3624 %
3625 %
3626 %
3627 % \subsubsection*{\opt{nudge} \& co.\ options}
3628 %
3629 % \begin{macrocode}
3630 \bool_new:N \l_@@_nudge_enabled_bool
3631 \bool_new:N \l_@@_nudge_multitype_bool
3632 \bool_new:N \l_@@_nudge_comptosing_bool
3633 \bool_new:N \l_@@_nudge_singular_bool
3634 \bool_new:N \l_@@_nudge_gender_bool
3635 \tl_new:N \l_@@_ref_gender_tl
3636 \keys_define:nn { zref-clever/reference }
3637 {
3638 nudge .choice: ,
3639 nudge / true .code:n =
3640 { \bool_set_true:N \l_@@_nudge_enabled_bool } ,
3641 nudge / false .code:n =
3642 { \bool_set_false:N \l_@@_nudge_enabled_bool } ,
3643 nudge / ifdraft .code:n =
3644 {
3645 \ifdraft
3646 { \bool_set_false:N \l_@@_nudge_enabled_bool }
3647 { \bool_set_true:N \l_@@_nudge_enabled_bool }
3648 } ,
3649 nudge / iffinal .code:n =
3650 {
3651 \ifoptionfinal
3652 { \bool_set_true:N \l_@@_nudge_enabled_bool }
3653 { \bool_set_false:N \l_@@_nudge_enabled_bool }
3654 } ,
3655 nudge .initial:n = false ,
3656 nudge .default:n = true ,
3657 nonudge .meta:n = { nudge = false } ,
3658 nonudge .value_forbidden:n = true ,
3659 nudgeif .code:n =
3660 {
3661 \bool_set_false:N \l_@@_nudge_multitype_bool
3662 \bool_set_false:N \l_@@_nudge_comptosing_bool
3663 \bool_set_false:N \l_@@_nudge_gender_bool
3664 \clist_map_inline:nn {#1}
3665 {
3666 \str_case:nnF {##1}
3667 {
3668 { multitype }
3669 { \bool_set_true:N \l_@@_nudge_multitype_bool }
3670 { comptosing }
3671 { \bool_set_true:N \l_@@_nudge_comptosing_bool }
3672 { gender }
3673 { \bool_set_true:N \l_@@_nudge_gender_bool }
3674 { all }
3675 {
3676 \bool_set_true:N \l_@@_nudge_multitype_bool
3677 \bool_set_true:N \l_@@_nudge_comptosing_bool
3678 \bool_set_true:N \l_@@_nudge_gender_bool
3679 }
3680 }
3681 {
3682 \msg_warning:nnn { zref-clever }
3683 { nudgeif-unknown-value } {##1}
3684 }
3685 }
3686 } ,
3687 nudgeif .value_required:n = true ,
3688 nudgeif .initial:n = all ,
3689 sg .bool_set:N = \l_@@_nudge_singular_bool ,
3690 sg .initial:n = false ,
3691 sg .default:n = true ,
3692 g .code:n =
3693 { \msg_warning:nnn { zref-clever } { option-document-only } { g } } ,
3694 }
3695 \AddToHook { begindocument }
3696 {
3697 \keys_define:nn { zref-clever/reference }
3698 {
3699 % \end{macrocode}
3700 % We just store the value at this point, which is validated by
3701 % \cs{@@_process_language_settings:} after \cs{keys_set:nn}.
3702 % \begin{macrocode}
3703 g .tl_set:N = \l_@@_ref_gender_tl ,
3704 g .value_required:n = true ,
3705 }
3706 }
3707 % \end{macrocode}
3708 %
3709 %
3710 % \subsubsection*{\opt{font} option}
3711 %
3712 % \begin{macrocode}
3713 \tl_new:N \l_@@_ref_typeset_font_tl
3714 \keys_define:nn { zref-clever/reference }
3715 { font .tl_set:N = \l_@@_ref_typeset_font_tl }
3716 % \end{macrocode}
3717 %
3718 %
3719 % \subsubsection*{\opt{titleref} option}
3720 %
3721 % \begin{macrocode}
3722 \keys_define:nn { zref-clever/reference }
3723 {
3724 titleref .code:n =
3725 {
3726 % NOTE Option deprecated in 2022-04-22 for 0.3.0.
3727 \msg_warning:nnee { zref-clever }{ option-deprecated } { titleref }
3728 { \iow_char:N\\usepackage\iow_char:N\{zref-titleref\iow_char:N\} }
3729 } ,
3730 }
3731 % \end{macrocode}
3732 %
3733 %
3734 % \subsubsection*{\opt{vario} option}
3735 %
3736 % \begin{macrocode}
3737 \keys_define:nn { zref-clever/reference }
3738 {
3739 vario .code:n =
3740 {
3741 % NOTE Option deprecated in 2022-04-22 for 0.3.0.
3742 \msg_warning:nnee { zref-clever }{ option-deprecated } { vario }
3743 { \iow_char:N\\usepackage\iow_char:N\{zref-vario\iow_char:N\} }
3744 } ,
3745 }
3746 % \end{macrocode}
3747 %
3748 %
3749 % \subsubsection*{\opt{note} option}
3750 %
3751 % \begin{macrocode}
3752 \tl_new:N \l_@@_zcref_note_tl
3753 \keys_define:nn { zref-clever/reference }
3754 {
3755 note .tl_set:N = \l_@@_zcref_note_tl ,
3756 note .value_required:n = true ,
3757 }
3758 % \end{macrocode}
3759 %
3760 %
3761 % \subsubsection*{\opt{check} option}
3762 %
3763 % Integration with \pkg{zref-check}.
3764 %
3765 % \begin{macrocode}
3766 \bool_new:N \l_@@_zrefcheck_available_bool
3767 \bool_new:N \l_@@_zcref_with_check_bool
3768 \keys_define:nn { zref-clever/reference }
3769 {
3770 check .code:n =
3771 { \msg_warning:nnn { zref-clever } { option-document-only } { check } } ,
3772 }
3773 \AddToHook { begindocument }
3774 {
3775 \@@_if_package_loaded:nTF { zref-check }
3776 {
3777 \IfPackageAtLeastTF { zref-check } { 2021-09-16 }
3778 {
3779 \bool_set_true:N \l_@@_zrefcheck_available_bool
3780 \keys_define:nn { zref-clever/reference }
3781 {
3782 check .code:n =
3783 {
3784 \bool_set_true:N \l_@@_zcref_with_check_bool
3785 \keys_set:nn { zref-check/zcheck } {#1}
3786 } ,
3787 check .value_required:n = true ,
3788 }
3789 }
3790 {
3791 \bool_set_false:N \l_@@_zrefcheck_available_bool
3792 \keys_define:nn { zref-clever/reference }
3793 {
3794 check .code:n =
3795 {
3796 \msg_warning:nnn { zref-clever }
3797 { zref-check-too-old } { 2021-09-16~v0.2.1 }
3798 } ,
3799 }
3800 }
3801 }
3802 {
3803 \bool_set_false:N \l_@@_zrefcheck_available_bool
3804 \keys_define:nn { zref-clever/reference }
3805 {
3806 check .code:n =
3807 { \msg_warning:nn { zref-clever } { missing-zref-check } } ,
3808 }
3809 }
3810 }
3811 % \end{macrocode}
3812 %
3813 %
3814 % \subsubsection*{\opt{reftype} option}
3815 %
3816 % This allows one to manually specify the reference type. It is the
3817 % equivalent of \pkg{cleveref}'s optional argument to \cs{label}.
3818 %
3819 % NOTE \pkg{tcolorbox} uses the \opt{reftype} option to support its \opt{label
3820 % type} option. Hence \emph{don't} make any breaking changes here without
3821 % previous communication.
3822 %
3823 % \begin{macrocode}
3824 \tl_new:N \l_@@_reftype_override_tl
3825 \keys_define:nn { zref-clever/label }
3826 {
3827 reftype .tl_set:N = \l_@@_reftype_override_tl ,
3828 reftype .default:n = {} ,
3829 reftype .initial:n = {} ,
3830 }
3831 % \end{macrocode}
3832 %
3833 %
3834 % \subsubsection*{\opt{countertype} option}
3835 %
3836 % \cs{l_@@_counter_type_prop} is used by \texttt{zc@type} property, and stores
3837 % a mapping from ``counter'' to ``reference type''. Only those counters whose
3838 % type name is different from that of the counter need to be specified, since
3839 % \texttt{zc@type} presumes the counter as the type if the counter is not
3840 % found in \cs{l_@@_counter_type_prop}.
3841 %
3842 % \begin{macrocode}
3843 \prop_new:N \l_@@_counter_type_prop
3844 \keys_define:nn { zref-clever/label }
3845 {
3846 countertype .code:n =
3847 {
3848 \keyval_parse:nnn
3849 {
3850 \msg_warning:nnnn { zref-clever }
3851 { key-requires-value } { countertype }
3852 }
3853 {
3854 \@@_prop_put_non_empty:Nnn
3855 \l_@@_counter_type_prop
3856 }
3857 {#1}
3858 } ,
3859 countertype .value_required:n = true ,
3860 countertype .initial:n =
3861 {
3862 subsection = section ,
3863 subsubsection = section ,
3864 subparagraph = paragraph ,
3865 enumi = item ,
3866 enumii = item ,
3867 enumiii = item ,
3868 enumiv = item ,
3869 mpfootnote = footnote ,
3870 } ,
3871 }
3872 % \end{macrocode}
3873 %
3874 % One interesting comment I received (by \contributor{Denis Bitouzé}, at
3875 % \githubissue{1}) about the most appropriate type for \texttt{paragraph} and
3876 % \texttt{subparagraph} counters was that the reader of the document does not
3877 % care whether that particular document structure element has been introduced
3878 % by \cs{paragraph} or, e.g.\ by the \cs{subsubsection} command. This is a
3879 % difference the author knows, as they're using \LaTeX{}, but to the reader
3880 % the difference between them is not really relevant, and it may be just
3881 % confusing to refer to them by different names. In this case the type for
3882 % \texttt{paragraph} and \texttt{subparagraph} should just be
3883 % \texttt{section}. I don't have a strong opinion about this, and the matter
3884 % was not pursued further. Besides, I presume not many people would set
3885 % \texttt{secnumdepth} so high to start with. But, for the time being, I left
3886 % the \texttt{paragraph} type for them, since there is actually a visual
3887 % difference to the reader between the \cs{subsubsection} and \cs{paragraph}
3888 % in the standard classes: up to the former, the sectioning commands break a
3889 % line before the following text, while, from the later on, the sectioning
3890 % commands and the following text are part of the same line. So,
3891 % \cs{paragraph} is actually different from ``just a shorter way to write
3892 % \cs{subsubsubsection}''.
3893 %
3894 %
3895 % \subsubsection*{\opt{counterresetters} option}
3896 %
3897 % \cs{l_@@_counter_resetters_seq} is used by \cs{@@_counter_reset_by:n} to
3898 % populate the \texttt{zc@enclval} property, and stores the list of counters
3899 % which are potential ``enclosing counters'' for other counters.
3900 %
3901 % Note that, as far as \LaTeX{} is concerned, a given counter can be reset by
3902 % \emph{any number of counters}. \cs{counterwithin} just adds a new
3903 % ``within-counter'' for ``counter'' without removing any other existing ones.
3904 % However, the data structure of \pkg{zref-clever} can only account for
3905 % \emph{one} enclosing counter. In a way, this is hard to circumvent, because
3906 % the underlying counter reset behavior works ``top-down'', but when looking
3907 % to a label built from a given counter we need to infer the enclosing
3908 % counters ``bottom-up''. As a result, the reset chain we find is path
3909 % dependent or, more formally, what \cs{@@_counter_reset_by:n} returns depends
3910 % on the order in which it searches the list of
3911 % \cs{l_@@_counter_resetters_seq}, since it stops on the first match. This
3912 % representation mismatch should not be a problem in most cases. But one
3913 % should be aware of the limits it imposes.
3914 %
3915 % Consider the following case: the \cls{book} class sets, by default
3916 % \texttt{figure} and \texttt{table} counters to be reset every
3917 % \texttt{chapter}, \texttt{section} is also reset every \texttt{chapter}, of
3918 % course. Suppose now we say
3919 % \cs{counterwithin}\texttt{\{figure\}\{section\}}. Technically,
3920 % \texttt{figure} is being reset every \texttt{section} and every
3921 % \texttt{chapter}, but since \texttt{section} is also reset every
3922 % \texttt{chapter}, the original ``\texttt{chapter} resets \texttt{figure}''
3923 % behavior is now redundant. Innocuous, but is still there. Now, suppose we
3924 % want to find which counter is resetting \texttt{figure} using
3925 % \cs{@@_counter_reset_by:n}. If \texttt{chapter} comes before
3926 % \texttt{section} in \cs{l_@@_counter_resetters_seq}, \texttt{chapter} will
3927 % be returned, and that's not what we want. That's the reason
3928 % \opt{counterresetters} initial value goes bottom-up in the sectioning level,
3929 % since we'd expect the nesting of the reset chain to \emph{typically} work
3930 % top-down.
3931 %
3932 % If, despite all this, unexpected results still ensue, users can take care to
3933 % ``clean'' redundant resetting settings with \cs{counterwithout}. Besides,
3934 % users can already override, for any particular counter, the search done from
3935 % the set in \cs{l_@@_counter_resetters_seq} with the \opt{counterresetby}
3936 % option.
3937 %
3938 % For the above reasons, since order matters, the \opt{counterresetters}
3939 % option can only be set by the full list of counters. In other words, users
3940 % wanting to change this should take the initial value as their starting base.
3941 %
3942 % The \texttt{zc@enclcnt} \pkg{zref} property, not included by default in the
3943 % \texttt{main} property list, is provided for the purpose of easing the
3944 % debugging of counter reset chains. So, by adding
3945 % \cs{zref@addprop}\texttt{\{main\}\{zc@enclcnt\}} you can inspect what the
3946 % values in the \texttt{zc@enclval} property correspond to.
3947 %
3948 % \begin{macrocode}
3949 \seq_new:N \l_@@_counter_resetters_seq
3950 \keys_define:nn { zref-clever/label }
3951 {
3952 counterresetters .code:n =
3953 { \seq_set_from_clist:Nn \l_@@_counter_resetters_seq {#1} } ,
3954 counterresetters .initial:n =
3955 {
3956 subparagraph ,
3957 paragraph ,
3958 subsubsection ,
3959 subsection ,
3960 section ,
3961 chapter ,
3962 part ,
3963 },
3964 counterresetters .value_required:n = true ,
3965 }
3966 % \end{macrocode}
3967 %
3968 %
3969 %
3970 % \subsubsection*{\opt{counterresetby} option}
3971 %
3972 % \cs{l_@@_counter_resetby_prop} is used by \cs{@@_counter_reset_by:n} to
3973 % populate the \texttt{zc@enclval} property, and stores a mapping from
3974 % counters to the counter which resets each of them. This mapping has
3975 % precedence in \cs{@@_counter_reset_by:n} over the search through
3976 % \cs{l_@@_counter_resetters_seq}.
3977 %
3978 % \begin{macrocode}
3979 \prop_new:N \l_@@_counter_resetby_prop
3980 \keys_define:nn { zref-clever/label }
3981 {
3982 counterresetby .code:n =
3983 {
3984 \keyval_parse:nnn
3985 {
3986 \msg_warning:nnn { zref-clever }
3987 { key-requires-value } { counterresetby }
3988 }
3989 {
3990 \@@_prop_put_non_empty:Nnn
3991 \l_@@_counter_resetby_prop
3992 }
3993 {#1}
3994 } ,
3995 counterresetby .value_required:n = true ,
3996 counterresetby .initial:n =
3997 {
3998 % \end{macrocode}
3999 % The counters for the \texttt{enumerate} environment do not use the regular
4000 % counter machinery for resetting on each level, but are nested nevertheless
4001 % by other means, treat them as exception.
4002 % \begin{macrocode}
4003 enumii = enumi ,
4004 enumiii = enumii ,
4005 enumiv = enumiii ,
4006 } ,
4007 }
4008 % \end{macrocode}
4009 %
4010 %
4011 % \subsubsection*{\opt{currentcounter} option}
4012 %
4013 % \cs{l_@@_current_counter_tl} is pretty much the starting point of all of the
4014 % data specification for label setting done by \pkg{zref} with our setup for
4015 % it. It exists because we must provide some ``handle'' to specify the
4016 % current counter for packages/features that do not set \cs{@currentcounter}
4017 % appropriately.
4018 %
4019 % \begin{macrocode}
4020 \tl_new:N \l_@@_current_counter_tl
4021 \keys_define:nn { zref-clever/label }
4022 {
4023 currentcounter .tl_set:N = \l_@@_current_counter_tl ,
4024 currentcounter .default:n = \@currentcounter ,
4025 currentcounter .initial:n = \@currentcounter ,
4026 }
4027 % \end{macrocode}
4028 %
4029 %
4030 % \subsubsection*{\opt{labelhook} option}
4031 %
4032 % \begin{macrocode}
4033 \bool_new:N \l_@@_labelhook_bool
4034 \keys_define:nn { zref-clever/label }
4035 {
4036 labelhook .bool_set:N = \l_@@_labelhook_bool ,
4037 labelhook .initial:n = true ,
4038 labelhook .default:n = true ,
4039 }
4040 % \end{macrocode}
4041 %
4042 % We \emph{must} use the lower level \cs{zref@label} in this context, and
4043 % hence also handle protection with \cs{zref@wrapper@babel}, because
4044 % \cs{zlabel} makes itself no-op when \cs{label} is equal to \cs{ltx@gobble},
4045 % and that's precisely the case inside the \pkg{amsmath}'s \env{multline}
4046 % environment (and possibly elsewhere?). See
4047 % \url{https://tex.stackexchange.com/a/402297} and
4048 % \url{https://github.com/ho-tex/zref/issues/4}. Conversely, if \cs{label} is
4049 % gobbled, the \texttt{label} hook also won't be called.
4050 %
4051 % \begin{macrocode}
4052 \AddToHookWithArguments { label }
4053 {
4054 \bool_if:NT \l_@@_labelhook_bool
4055 { \zref@wrapper@babel \zref@label {#1} }
4056 }
4057 % \end{macrocode}
4058 %
4059 %
4060 %
4061 % \subsubsection*{\opt{nocompat} option}
4062 %
4063 %
4064 % \begin{macrocode}
4065 \bool_new:N \g_@@_nocompat_bool
4066 \seq_new:N \g_@@_nocompat_modules_seq
4067 \keys_define:nn { zref-clever/reference }
4068 {
4069 nocompat .code:n =
4070 {
4071 \tl_if_empty:nTF {#1}
4072 { \bool_gset_true:N \g_@@_nocompat_bool }
4073 {
4074 \clist_map_inline:nn {#1}
4075 {
4076 \seq_if_in:NnF \g_@@_nocompat_modules_seq {##1}
4077 {
4078 \seq_gput_right:Nn
4079 \g_@@_nocompat_modules_seq {##1}
4080 }
4081 }
4082 }
4083 } ,
4084 }
4085 \AddToHook { begindocument }
4086 {
4087 \keys_define:nn { zref-clever/reference }
4088 {
4089 nocompat .code:n =
4090 {
4091 \msg_warning:nnn { zref-clever }
4092 { option-preamble-only } { nocompat }
4093 }
4094 }
4095 }
4096 \AtEndOfPackage
4097 {
4098 \AddToHook { begindocument }
4099 {
4100 \seq_map_inline:Nn \g_@@_nocompat_modules_seq
4101 { \msg_warning:nnn { zref-clever } { unknown-compat-module } {#1} }
4102 }
4103 }
4104 % \end{macrocode}
4105 %
4106 % \begin{macro}{\@@_compat_module:nn}
4107 % Function to be used for compatibility modules loading. It should load the
4108 % module as long as \cs{l_@@_nocompat_bool} is false and \meta{module} is
4109 % not in \cs{l_@@_nocompat_modules_seq}. The \texttt{begindocument} hook is
4110 % needed so that we can have the option functional along the whole preamble,
4111 % not just at package load time. This requirement might be relaxed if we
4112 % made the option only available at load time, but this would not buy us
4113 % much leeway anyway, since for most compatibility modules, we must test for
4114 % the presence of packages at \texttt{begindocument}, only kernel features
4115 % and document classes could be checked reliably before that. Besides,
4116 % since we are using the new hook management system, there is always its
4117 % functionality to deal with potential loading order issues.
4118 % \begin{syntax}
4119 % \cs{@@_compat_module:nn} \Arg{module} \Arg{code}
4120 % \end{syntax}
4121 % \begin{macrocode}
4122 \cs_new_protected:Npn \@@_compat_module:nn #1#2
4123 {
4124 \AddToHook { begindocument }
4125 {
4126 \bool_if:NF \g_@@_nocompat_bool
4127 { \seq_if_in:NnF \g_@@_nocompat_modules_seq {#1} {#2} }
4128 \seq_gremove_all:Nn \g_@@_nocompat_modules_seq {#1}
4129 }
4130 }
4131 % \end{macrocode}
4132 % \end{macro}
4133 %
4134 %
4135 %
4136 % \subsubsection*{Reference options}
4137 % \zlabel{sec:reference-options}
4138 %
4139 % This is a set of options related to reference typesetting which receive
4140 % equal treatment and, hence, are handled in batch. Since we are dealing with
4141 % options to be passed to \cs{zcref} or to \cs{zcsetup}, only ``not
4142 % necessarily type-specific'' options are pertinent here.
4143 %
4144 %
4145 % \begin{macrocode}
4146 \seq_map_inline:Nn
4147 \g_@@_rf_opts_tl_reference_seq
4148 {
4149 \keys_define:nn { zref-clever/reference }
4150 {
4151 #1 .default:o = \c_novalue_tl ,
4152 #1 .code:n =
4153 {
4154 \tl_if_novalue:nTF {##1}
4155 {
4156 \@@_opt_tl_unset:c
4157 { \@@_opt_varname_general:nn {#1} { tl } }
4158 }
4159 {
4160 \@@_opt_tl_set:cn
4161 { \@@_opt_varname_general:nn {#1} { tl } }
4162 {##1}
4163 }
4164 } ,
4165 }
4166 }
4167 \keys_define:nn { zref-clever/reference }
4168 {
4169 refpre .code:n =
4170 {
4171 % NOTE Option deprecated in 2022-01-10 for v0.1.2-alpha.
4172 \msg_warning:nnnn { zref-clever }{ option-deprecated }
4173 { refpre } { refbounds }
4174 } ,
4175 refpos .code:n =
4176 {
4177 % NOTE Option deprecated in 2022-01-10 for v0.1.2-alpha.
4178 \msg_warning:nnnn { zref-clever }{ option-deprecated }
4179 { refpos } { refbounds }
4180 } ,
4181 preref .code:n =
4182 {
4183 % NOTE Option deprecated in 2022-01-14 for v0.2.0-alpha.
4184 \msg_warning:nnnn { zref-clever }{ option-deprecated }
4185 { preref } { refbounds }
4186 } ,
4187 postref .code:n =
4188 {
4189 % NOTE Option deprecated in 2022-01-14 for v0.2.0-alpha.
4190 \msg_warning:nnnn { zref-clever }{ option-deprecated }
4191 { postref } { refbounds }
4192 } ,
4193 }
4194 \seq_map_inline:Nn
4195 \g_@@_rf_opts_seq_refbounds_seq
4196 {
4197 \keys_define:nn { zref-clever/reference }
4198 {
4199 #1 .default:o = \c_novalue_tl ,
4200 #1 .code:n =
4201 {
4202 \tl_if_novalue:nTF {##1}
4203 {
4204 \@@_opt_seq_unset:c
4205 { \@@_opt_varname_general:nn {#1} { seq } }
4206 }
4207 {
4208 \seq_clear:N \l_@@_tmpa_seq
4209 \@@_opt_seq_set_clist_split:Nn
4210 \l_@@_tmpa_seq {##1}
4211 \bool_lazy_or:nnTF
4212 { \tl_if_empty_p:n {##1} }
4213 {
4214 \int_compare_p:nNn
4215 { \seq_count:N \l_@@_tmpa_seq } = { 4 }
4216 }
4217 {
4218 \@@_opt_seq_set_eq:cN
4219 { \@@_opt_varname_general:nn {#1} { seq } }
4220 \l_@@_tmpa_seq
4221 }
4222 {
4223 \msg_warning:nnee { zref-clever }
4224 { refbounds-must-be-four }
4225 {#1} { \seq_count:N \l_@@_tmpa_seq }
4226 }
4227 }
4228 } ,
4229 }
4230 }
4231 \seq_map_inline:Nn
4232 \g_@@_rf_opts_bool_maybe_type_specific_seq
4233 {
4234 \keys_define:nn { zref-clever/reference }
4235 {
4236 #1 .choice: ,
4237 #1 / true .code:n =
4238 {
4239 \@@_opt_bool_set_true:c
4240 { \@@_opt_varname_general:nn {#1} { bool } }
4241 } ,
4242 #1 / false .code:n =
4243 {
4244 \@@_opt_bool_set_false:c
4245 { \@@_opt_varname_general:nn {#1} { bool } }
4246 } ,
4247 #1 / unset .code:n =
4248 {
4249 \@@_opt_bool_unset:c
4250 { \@@_opt_varname_general:nn {#1} { bool } }
4251 } ,
4252 #1 .default:n = true ,
4253 no #1 .meta:n = { #1 = false } ,
4254 no #1 .value_forbidden:n = true ,
4255 }
4256 }
4257 % \end{macrocode}
4258 %
4259 %
4260 % \subsubsection*{Package options}
4261 %
4262 % The options have been separated in two different groups, so that we can
4263 % potentially apply them selectively to different contexts: \texttt{label} and
4264 % \texttt{reference}. Currently, the only use of this selection is the
4265 % ability to exclude label related options from \cs{zcref}'s options. Anyway,
4266 % for package options (\cs{zcsetup}) we want the whole set, so we aggregate
4267 % the two into \texttt{zref-clever/zcsetup}, and use that here.
4268 %
4269 % See \url{https://github.com/latex3/latex3/issues/1254}.
4270 %
4271 % ^^A zref-clever/zcsetup
4272 % \begin{macrocode}
4273 \keys_define:nn { zref-clever }
4274 {
4275 zcsetup .inherit:n =
4276 {
4277 zref-clever/label ,
4278 zref-clever/reference ,
4279 }
4280 }
4281 % \end{macrocode}
4282 %
4283 %
4284 % \pkg{zref-clever} does not accept load-time options. Despite the tradition
4285 % of so doing, Joseph Wright has a point in recommending otherwise at
4286 % \url{https://chat.stackexchange.com/transcript/message/60360822#60360822}:
4287 % separating ``loading the package'' from ``configuring the package'' grants
4288 % less trouble with ``option clashes'' and with expansion of options at
4289 % load-time.
4290 % \begin{macrocode}
4291 \bool_lazy_and:nnT
4292 { \tl_if_exist_p:c { opt@ zref-clever.sty } }
4293 { ! \tl_if_empty_p:c { opt@ zref-clever.sty } }
4294 { \msg_warning:nn { zref-clever } { load-time-options } }
4295 % \end{macrocode}
4296 %
4297 %
4298 % \section{Configuration}
4299 %
4300 % \subsection{\cs{zcsetup}}
4301 %
4302 %
4303 % \begin{macro}[int]{\zcsetup}
4304 % Provide \cs{zcsetup}.
4305 % \begin{syntax}
4306 % \cs{zcsetup}\marg{options}
4307 % \end{syntax}
4308 % \begin{macrocode}
4309 \NewDocumentCommand \zcsetup { m }
4310 { \@@_zcsetup:n {#1} }
4311 % \end{macrocode}
4312 % \end{macro}
4313 %
4314 % \begin{macro}{\@@_zcsetup:n}
4315 % A version of \cs{zcsetup} for internal use with variant.
4316 % \begin{syntax}
4317 % \cs{@@_zcsetup:n}\marg{options}
4318 % \end{syntax}
4319 % \begin{macrocode}
4320 \cs_new_protected:Npn \@@_zcsetup:n #1
4321 { \keys_set:nn { zref-clever/zcsetup } {#1} }
4322 \cs_generate_variant:Nn \@@_zcsetup:n { e }
4323 % \end{macrocode}
4324 % \end{macro}
4325 %
4326 %
4327 %
4328 % \subsection{\cs{zcRefTypeSetup}}
4329 % \zlabel{sec:zcreftypesetup}
4330 %
4331 % \cs{zcRefTypeSetup} is the main user interface for ``type-specific''
4332 % reference formatting. Settings done by this command have a higher
4333 % precedence than any language-specific setting, either done at
4334 % \cs{zcLanguageSetup} or by the package's language files. On the other hand,
4335 % they have a lower precedence than non type-specific general options. The
4336 % \meta{options} should be given in the usual \texttt{key=val} format. The
4337 % \meta{type} does not need to pre-exist, the property list variable to store
4338 % the properties for the type gets created if need be.
4339 %
4340 % \begin{macro}[int]{\zcRefTypeSetup}
4341 % \begin{syntax}
4342 % \cs{zcRefTypeSetup} \marg{type} \marg{options}
4343 % \end{syntax}
4344 % \begin{macrocode}
4345 \NewDocumentCommand \zcRefTypeSetup { m m }
4346 {
4347 \tl_set:Nn \l_@@_setup_type_tl {#1}
4348 \keys_set:nn { zref-clever/typesetup } {#2}
4349 \tl_clear:N \l_@@_setup_type_tl
4350 }
4351 % \end{macrocode}
4352 % \end{macro}
4353 %
4354 %
4355 %
4356 % \begin{macrocode}
4357 \seq_map_inline:Nn
4358 \g_@@_rf_opts_tl_not_type_specific_seq
4359 {
4360 \keys_define:nn { zref-clever/typesetup }
4361 {
4362 #1 .code:n =
4363 {
4364 \msg_warning:nnn { zref-clever }
4365 { option-not-type-specific } {#1}
4366 } ,
4367 }
4368 }
4369 \seq_map_inline:Nn
4370 \g_@@_rf_opts_tl_typesetup_seq
4371 {
4372 \keys_define:nn { zref-clever/typesetup }
4373 {
4374 #1 .default:o = \c_novalue_tl ,
4375 #1 .code:n =
4376 {
4377 \tl_if_novalue:nTF {##1}
4378 {
4379 \@@_opt_tl_unset:c
4380 {
4381 \@@_opt_varname_type:enn
4382 { \l_@@_setup_type_tl } {#1} { tl }
4383 }
4384 }
4385 {
4386 \@@_opt_tl_set:cn
4387 {
4388 \@@_opt_varname_type:enn
4389 { \l_@@_setup_type_tl } {#1} { tl }
4390 }
4391 {##1}
4392 }
4393 } ,
4394 }
4395 }
4396 \keys_define:nn { zref-clever/typesetup }
4397 {
4398 endrange .code:n =
4399 {
4400 \str_case:nnF {#1}
4401 {
4402 { ref }
4403 {
4404 \@@_opt_tl_clear:c
4405 {
4406 \@@_opt_varname_type:enn
4407 { \l_@@_setup_type_tl } { endrangefunc } { tl }
4408 }
4409 \@@_opt_tl_clear:c
4410 {
4411 \@@_opt_varname_type:enn
4412 { \l_@@_setup_type_tl } { endrangeprop } { tl }
4413 }
4414 }
4415 { stripprefix }
4416 {
4417 \@@_opt_tl_set:cn
4418 {
4419 \@@_opt_varname_type:enn
4420 { \l_@@_setup_type_tl } { endrangefunc } { tl }
4421 }
4422 { @@_get_endrange_stripprefix }
4423 \@@_opt_tl_clear:c
4424 {
4425 \@@_opt_varname_type:enn
4426 { \l_@@_setup_type_tl } { endrangeprop } { tl }
4427 }
4428 }
4429 { pagecomp }
4430 {
4431 \@@_opt_tl_set:cn
4432 {
4433 \@@_opt_varname_type:enn
4434 { \l_@@_setup_type_tl } { endrangefunc } { tl }
4435 }
4436 { @@_get_endrange_pagecomp }
4437 \@@_opt_tl_clear:c
4438 {
4439 \@@_opt_varname_type:enn
4440 { \l_@@_setup_type_tl } { endrangeprop } { tl }
4441 }
4442 }
4443 { pagecomp2 }
4444 {
4445 \@@_opt_tl_set:cn
4446 {
4447 \@@_opt_varname_type:enn
4448 { \l_@@_setup_type_tl } { endrangefunc } { tl }
4449 }
4450 { @@_get_endrange_pagecomptwo }
4451 \@@_opt_tl_clear:c
4452 {
4453 \@@_opt_varname_type:enn
4454 { \l_@@_setup_type_tl } { endrangeprop } { tl }
4455 }
4456 }
4457 { unset }
4458 {
4459 \@@_opt_tl_unset:c
4460 {
4461 \@@_opt_varname_type:enn
4462 { \l_@@_setup_type_tl } { endrangefunc } { tl }
4463 }
4464 \@@_opt_tl_unset:c
4465 {
4466 \@@_opt_varname_type:enn
4467 { \l_@@_setup_type_tl } { endrangeprop } { tl }
4468 }
4469 }
4470 }
4471 {
4472 \tl_if_empty:nTF {#1}
4473 {
4474 \msg_warning:nnn { zref-clever }
4475 { endrange-property-undefined } {#1}
4476 }
4477 {
4478 \zref@ifpropundefined {#1}
4479 {
4480 \msg_warning:nnn { zref-clever }
4481 { endrange-property-undefined } {#1}
4482 }
4483 {
4484 \@@_opt_tl_set:cn
4485 {
4486 \@@_opt_varname_type:enn
4487 { \l_@@_setup_type_tl }
4488 { endrangefunc } { tl }
4489 }
4490 { @@_get_endrange_property }
4491 \@@_opt_tl_set:cn
4492 {
4493 \@@_opt_varname_type:enn
4494 { \l_@@_setup_type_tl }
4495 { endrangeprop } { tl }
4496 }
4497 {#1}
4498 }
4499 }
4500 }
4501 } ,
4502 endrange .value_required:n = true ,
4503 }
4504 \keys_define:nn { zref-clever/typesetup }
4505 {
4506 refpre .code:n =
4507 {
4508 % NOTE Option deprecated in 2022-01-10 for v0.1.2-alpha.
4509 \msg_warning:nnnn { zref-clever }{ option-deprecated }
4510 { refpre } { refbounds }
4511 } ,
4512 refpos .code:n =
4513 {
4514 % NOTE Option deprecated in 2022-01-10 for v0.1.2-alpha.
4515 \msg_warning:nnnn { zref-clever }{ option-deprecated }
4516 { refpos } { refbounds }
4517 } ,
4518 preref .code:n =
4519 {
4520 % NOTE Option deprecated in 2022-01-14 for v0.2.0-alpha.
4521 \msg_warning:nnnn { zref-clever }{ option-deprecated }
4522 { preref } { refbounds }
4523 } ,
4524 postref .code:n =
4525 {
4526 % NOTE Option deprecated in 2022-01-14 for v0.2.0-alpha.
4527 \msg_warning:nnnn { zref-clever }{ option-deprecated }
4528 { postref } { refbounds }
4529 } ,
4530 }
4531 \seq_map_inline:Nn
4532 \g_@@_rf_opts_seq_refbounds_seq
4533 {
4534 \keys_define:nn { zref-clever/typesetup }
4535 {
4536 #1 .default:o = \c_novalue_tl ,
4537 #1 .code:n =
4538 {
4539 \tl_if_novalue:nTF {##1}
4540 {
4541 \@@_opt_seq_unset:c
4542 {
4543 \@@_opt_varname_type:enn
4544 { \l_@@_setup_type_tl } {#1} { seq }
4545 }
4546 }
4547 {
4548 \seq_clear:N \l_@@_tmpa_seq
4549 \@@_opt_seq_set_clist_split:Nn
4550 \l_@@_tmpa_seq {##1}
4551 \bool_lazy_or:nnTF
4552 { \tl_if_empty_p:n {##1} }
4553 {
4554 \int_compare_p:nNn
4555 { \seq_count:N \l_@@_tmpa_seq } = { 4 }
4556 }
4557 {
4558 \@@_opt_seq_set_eq:cN
4559 {
4560 \@@_opt_varname_type:enn
4561 { \l_@@_setup_type_tl } {#1} { seq }
4562 }
4563 \l_@@_tmpa_seq
4564 }
4565 {
4566 \msg_warning:nnee { zref-clever }
4567 { refbounds-must-be-four }
4568 {#1} { \seq_count:N \l_@@_tmpa_seq }
4569 }
4570 }
4571 } ,
4572 }
4573 }
4574 \seq_map_inline:Nn
4575 \g_@@_rf_opts_bool_maybe_type_specific_seq
4576 {
4577 \keys_define:nn { zref-clever/typesetup }
4578 {
4579 #1 .choice: ,
4580 #1 / true .code:n =
4581 {
4582 \@@_opt_bool_set_true:c
4583 {
4584 \@@_opt_varname_type:enn
4585 { \l_@@_setup_type_tl }
4586 {#1} { bool }
4587 }
4588 } ,
4589 #1 / false .code:n =
4590 {
4591 \@@_opt_bool_set_false:c
4592 {
4593 \@@_opt_varname_type:enn
4594 { \l_@@_setup_type_tl }
4595 {#1} { bool }
4596 }
4597 } ,
4598 #1 / unset .code:n =
4599 {
4600 \@@_opt_bool_unset:c
4601 {
4602 \@@_opt_varname_type:enn
4603 { \l_@@_setup_type_tl }
4604 {#1} { bool }
4605 }
4606 } ,
4607 #1 .default:n = true ,
4608 no #1 .meta:n = { #1 = false } ,
4609 no #1 .value_forbidden:n = true ,
4610 }
4611 }
4612 % \end{macrocode}
4613 %
4614 %
4615 % \subsection{\cs{zcLanguageSetup}}
4616 %
4617 % \cs{zcLanguageSetup} is the main user interface for ``language-specific''
4618 % reference formatting, be it ``type-specific'' or not. The difference
4619 % between the two cases is captured by the \texttt{type} key, which works as a
4620 % sort of a ``switch''. Inside the \meta{options} argument of
4621 % \cs{zcLanguageSetup}, any options made before the first \texttt{type} key
4622 % declare ``default'' (non type-specific) language options. When the
4623 % \texttt{type} key is given with a value, the options following it will set
4624 % ``type-specific'' language options for that type. The current type can be
4625 % switched off by an empty \texttt{type} key. \cs{zcLanguageSetup} is
4626 % preamble only.
4627 %
4628 % \begin{macro}[int]{\zcLanguageSetup}
4629 % \begin{syntax}
4630 % \cs{zcLanguageSetup}\marg{language}\marg{options}
4631 % \end{syntax}
4632 % \begin{macrocode}
4633 \NewDocumentCommand \zcLanguageSetup { m m }
4634 {
4635 \group_begin:
4636 \@@_language_if_declared:nTF {#1}
4637 {
4638 \tl_clear:N \l_@@_setup_type_tl
4639 \tl_set:Nn \l_@@_setup_language_tl {#1}
4640 \@@_opt_seq_get:cNF
4641 {
4642 \@@_opt_varname_language:nnn
4643 {#1} { variants } { seq }
4644 }
4645 \l_@@_lang_variants_seq
4646 { \seq_clear:N \l_@@_lang_variants_seq }
4647 \seq_if_empty:NTF \l_@@_lang_variants_seq
4648 { \tl_clear:N \l_@@_lang_variant_tl }
4649 {
4650 \seq_get_left:NN \l_@@_lang_variants_seq
4651 \l_@@_lang_variant_tl
4652 }
4653 \@@_opt_seq_get:cNF
4654 {
4655 \@@_opt_varname_language:nnn
4656 {#1} { gender } { seq }
4657 }
4658 \l_@@_lang_gender_seq
4659 { \seq_clear:N \l_@@_lang_gender_seq }
4660 \keys_set:nn { zref-clever/langsetup } {#2}
4661 }
4662 { \msg_warning:nnn { zref-clever } { unknown-language-setup } {#1} }
4663 \group_end:
4664 }
4665 \@onlypreamble \zcLanguageSetup
4666 % \end{macrocode}
4667 % \end{macro}
4668 %
4669 %
4670 %
4671 % The set of keys for \texttt{{zref-clever/langsetup}}, which is used to set
4672 % language-specific options in \cs{zcLanguageSetup}.
4673 %
4674 % \begin{macrocode}
4675 \keys_define:nn { zref-clever/langsetup }
4676 {
4677 type .code:n =
4678 {
4679 \tl_if_empty:nTF {#1}
4680 { \tl_clear:N \l_@@_setup_type_tl }
4681 { \tl_set:Nn \l_@@_setup_type_tl {#1} }
4682 } ,
4683 variant .code:n =
4684 {
4685 \seq_if_empty:NTF \l_@@_lang_variants_seq
4686 {
4687 \msg_warning:nnee { zref-clever } { language-no-variants-setup }
4688 { \l_@@_setup_language_tl } {#1}
4689 }
4690 {
4691 \seq_if_in:NnTF \l_@@_lang_variants_seq {#1}
4692 { \tl_set:Nn \l_@@_lang_variant_tl {#1} }
4693 {
4694 \msg_warning:nnee { zref-clever } { unknown-variant }
4695 {#1} { \l_@@_setup_language_tl }
4696 \seq_get_left:NN \l_@@_lang_variants_seq
4697 \l_@@_lang_variant_tl
4698 }
4699 }
4700 } ,
4701 variant .value_required:n = true ,
4702 % NOTE Option deprecated in 2024-11-24 for v0.5.0.
4703 case .meta:n = { variant = {#1} } ,
4704 gender .value_required:n = true ,
4705 gender .code:n =
4706 {
4707 \seq_if_empty:NTF \l_@@_lang_gender_seq
4708 {
4709 \msg_warning:nneee { zref-clever } { language-no-gender }
4710 { \l_@@_setup_language_tl } { gender } {#1}
4711 }
4712 {
4713 \tl_if_empty:NTF \l_@@_setup_type_tl
4714 {
4715 \msg_warning:nnn { zref-clever }
4716 { option-only-type-specific } { gender }
4717 }
4718 {
4719 \seq_clear:N \l_@@_tmpa_seq
4720 \clist_map_inline:nn {#1}
4721 {
4722 \seq_if_in:NnTF \l_@@_lang_gender_seq {##1}
4723 { \seq_put_right:Nn \l_@@_tmpa_seq {##1} }
4724 {
4725 \msg_warning:nnee { zref-clever }
4726 { gender-not-declared }
4727 { \l_@@_setup_language_tl } {##1}
4728 }
4729 }
4730 \@@_opt_seq_gset_eq:cN
4731 {
4732 \@@_opt_varname_lang_type:eenn
4733 { \l_@@_setup_language_tl }
4734 { \l_@@_setup_type_tl }
4735 { gender }
4736 { seq }
4737 }
4738 \l_@@_tmpa_seq
4739 }
4740 }
4741 } ,
4742 }
4743 \seq_map_inline:Nn
4744 \g_@@_rf_opts_tl_not_type_specific_seq
4745 {
4746 \keys_define:nn { zref-clever/langsetup }
4747 {
4748 #1 .value_required:n = true ,
4749 #1 .code:n =
4750 {
4751 \tl_if_empty:NTF \l_@@_setup_type_tl
4752 {
4753 \@@_opt_tl_gset:cn
4754 {
4755 \@@_opt_varname_lang_default:enn
4756 { \l_@@_setup_language_tl } {#1} { tl }
4757 }
4758 {##1}
4759 }
4760 {
4761 \msg_warning:nnn { zref-clever }
4762 { option-not-type-specific } {#1}
4763 }
4764 } ,
4765 }
4766 }
4767 \seq_map_inline:Nn
4768 \g_@@_rf_opts_tl_maybe_type_specific_seq
4769 {
4770 \keys_define:nn { zref-clever/langsetup }
4771 {
4772 #1 .value_required:n = true ,
4773 #1 .code:n =
4774 {
4775 \tl_if_empty:NTF \l_@@_setup_type_tl
4776 {
4777 \@@_opt_tl_gset:cn
4778 {
4779 \@@_opt_varname_lang_default:enn
4780 { \l_@@_setup_language_tl } {#1} { tl }
4781 }
4782 {##1}
4783 }
4784 {
4785 \@@_opt_tl_gset:cn
4786 {
4787 \@@_opt_varname_lang_type:eenn
4788 { \l_@@_setup_language_tl }
4789 { \l_@@_setup_type_tl }
4790 {#1} { tl }
4791 }
4792 {##1}
4793 }
4794 } ,
4795 }
4796 }
4797 \keys_define:nn { zref-clever/langsetup }
4798 {
4799 endrange .value_required:n = true ,
4800 endrange .code:n =
4801 {
4802 \str_case:nnF {#1}
4803 {
4804 { ref }
4805 {
4806 \tl_if_empty:NTF \l_@@_setup_type_tl
4807 {
4808 \@@_opt_tl_gclear:c
4809 {
4810 \@@_opt_varname_lang_default:enn
4811 { \l_@@_setup_language_tl }
4812 { endrangefunc } { tl }
4813 }
4814 \@@_opt_tl_gclear:c
4815 {
4816 \@@_opt_varname_lang_default:enn
4817 { \l_@@_setup_language_tl }
4818 { endrangeprop } { tl }
4819 }
4820 }
4821 {
4822 \@@_opt_tl_gclear:c
4823 {
4824 \@@_opt_varname_lang_type:eenn
4825 { \l_@@_setup_language_tl }
4826 { \l_@@_setup_type_tl }
4827 { endrangefunc } { tl }
4828 }
4829 \@@_opt_tl_gclear:c
4830 {
4831 \@@_opt_varname_lang_type:eenn
4832 { \l_@@_setup_language_tl }
4833 { \l_@@_setup_type_tl }
4834 { endrangeprop } { tl }
4835 }
4836 }
4837 }
4838 { stripprefix }
4839 {
4840 \tl_if_empty:NTF \l_@@_setup_type_tl
4841 {
4842 \@@_opt_tl_gset:cn
4843 {
4844 \@@_opt_varname_lang_default:enn
4845 { \l_@@_setup_language_tl }
4846 { endrangefunc } { tl }
4847 }
4848 { @@_get_endrange_stripprefix }
4849 \@@_opt_tl_gclear:c
4850 {
4851 \@@_opt_varname_lang_default:enn
4852 { \l_@@_setup_language_tl }
4853 { endrangeprop } { tl }
4854 }
4855 }
4856 {
4857 \@@_opt_tl_gset:cn
4858 {
4859 \@@_opt_varname_lang_type:eenn
4860 { \l_@@_setup_language_tl }
4861 { \l_@@_setup_type_tl }
4862 { endrangefunc } { tl }
4863 }
4864 { @@_get_endrange_stripprefix }
4865 \@@_opt_tl_gclear:c
4866 {
4867 \@@_opt_varname_lang_type:eenn
4868 { \l_@@_setup_language_tl }
4869 { \l_@@_setup_type_tl }
4870 { endrangeprop } { tl }
4871 }
4872 }
4873 }
4874 { pagecomp }
4875 {
4876 \tl_if_empty:NTF \l_@@_setup_type_tl
4877 {
4878 \@@_opt_tl_gset:cn
4879 {
4880 \@@_opt_varname_lang_default:enn
4881 { \l_@@_setup_language_tl }
4882 { endrangefunc } { tl }
4883 }
4884 { @@_get_endrange_pagecomp }
4885 \@@_opt_tl_gclear:c
4886 {
4887 \@@_opt_varname_lang_default:enn
4888 { \l_@@_setup_language_tl }
4889 { endrangeprop } { tl }
4890 }
4891 }
4892 {
4893 \@@_opt_tl_gset:cn
4894 {
4895 \@@_opt_varname_lang_type:eenn
4896 { \l_@@_setup_language_tl }
4897 { \l_@@_setup_type_tl }
4898 { endrangefunc } { tl }
4899 }
4900 { @@_get_endrange_pagecomp }
4901 \@@_opt_tl_gclear:c
4902 {
4903 \@@_opt_varname_lang_type:eenn
4904 { \l_@@_setup_language_tl }
4905 { \l_@@_setup_type_tl }
4906 { endrangeprop } { tl }
4907 }
4908 }
4909 }
4910 { pagecomp2 }
4911 {
4912 \tl_if_empty:NTF \l_@@_setup_type_tl
4913 {
4914 \@@_opt_tl_gset:cn
4915 {
4916 \@@_opt_varname_lang_default:enn
4917 { \l_@@_setup_language_tl }
4918 { endrangefunc } { tl }
4919 }
4920 { @@_get_endrange_pagecomptwo }
4921 \@@_opt_tl_gclear:c
4922 {
4923 \@@_opt_varname_lang_default:enn
4924 { \l_@@_setup_language_tl }
4925 { endrangeprop } { tl }
4926 }
4927 }
4928 {
4929 \@@_opt_tl_gset:cn
4930 {
4931 \@@_opt_varname_lang_type:eenn
4932 { \l_@@_setup_language_tl }
4933 { \l_@@_setup_type_tl }
4934 { endrangefunc } { tl }
4935 }
4936 { @@_get_endrange_pagecomptwo }
4937 \@@_opt_tl_gclear:c
4938 {
4939 \@@_opt_varname_lang_type:eenn
4940 { \l_@@_setup_language_tl }
4941 { \l_@@_setup_type_tl }
4942 { endrangeprop } { tl }
4943 }
4944 }
4945 }
4946 }
4947 {
4948 \tl_if_empty:nTF {#1}
4949 {
4950 \msg_warning:nnn { zref-clever }
4951 { endrange-property-undefined } {#1}
4952 }
4953 {
4954 \zref@ifpropundefined {#1}
4955 {
4956 \msg_warning:nnn { zref-clever }
4957 { endrange-property-undefined } {#1}
4958 }
4959 {
4960 \tl_if_empty:NTF \l_@@_setup_type_tl
4961 {
4962 \@@_opt_tl_gset:cn
4963 {
4964 \@@_opt_varname_lang_default:enn
4965 { \l_@@_setup_language_tl }
4966 { endrangefunc } { tl }
4967 }
4968 { @@_get_endrange_property }
4969 \@@_opt_tl_gset:cn
4970 {
4971 \@@_opt_varname_lang_default:enn
4972 { \l_@@_setup_language_tl }
4973 { endrangeprop } { tl }
4974 }
4975 {#1}
4976 }
4977 {
4978 \@@_opt_tl_gset:cn
4979 {
4980 \@@_opt_varname_lang_type:eenn
4981 { \l_@@_setup_language_tl }
4982 { \l_@@_setup_type_tl }
4983 { endrangefunc } { tl }
4984 }
4985 { @@_get_endrange_property }
4986 \@@_opt_tl_gset:cn
4987 {
4988 \@@_opt_varname_lang_type:eenn
4989 { \l_@@_setup_language_tl }
4990 { \l_@@_setup_type_tl }
4991 { endrangeprop } { tl }
4992 }
4993 {#1}
4994 }
4995 }
4996 }
4997 }
4998 } ,
4999 }
5000 \keys_define:nn { zref-clever/langsetup }
5001 {
5002 refpre .code:n =
5003 {
5004 % NOTE Option deprecated in 2022-01-10 for v0.1.2-alpha.
5005 \msg_warning:nnnn { zref-clever }{ option-deprecated }
5006 { refpre } { refbounds }
5007 } ,
5008 refpos .code:n =
5009 {
5010 % NOTE Option deprecated in 2022-01-10 for v0.1.2-alpha.
5011 \msg_warning:nnnn { zref-clever }{ option-deprecated }
5012 { refpos } { refbounds }
5013 } ,
5014 preref .code:n =
5015 {
5016 % NOTE Option deprecated in 2022-01-14 for v0.2.0-alpha.
5017 \msg_warning:nnnn { zref-clever }{ option-deprecated }
5018 { preref } { refbounds }
5019 } ,
5020 postref .code:n =
5021 {
5022 % NOTE Option deprecated in 2022-01-14 for v0.2.0-alpha.
5023 \msg_warning:nnnn { zref-clever }{ option-deprecated }
5024 { postref } { refbounds }
5025 } ,
5026 }
5027 \seq_map_inline:Nn
5028 \g_@@_rf_opts_tl_type_names_seq
5029 {
5030 \keys_define:nn { zref-clever/langsetup }
5031 {
5032 #1 .value_required:n = true ,
5033 #1 .code:n =
5034 {
5035 \tl_if_empty:NTF \l_@@_setup_type_tl
5036 {
5037 \msg_warning:nnn { zref-clever }
5038 { option-only-type-specific } {#1}
5039 }
5040 {
5041 \tl_if_empty:NTF \l_@@_lang_variant_tl
5042 {
5043 \@@_opt_tl_gset:cn
5044 {
5045 \@@_opt_varname_lang_type:eenn
5046 { \l_@@_setup_language_tl }
5047 { \l_@@_setup_type_tl }
5048 {#1} { tl }
5049 }
5050 {##1}
5051 }
5052 {
5053 \@@_opt_tl_gset:cn
5054 {
5055 \@@_opt_varname_lang_type:eeen
5056 { \l_@@_setup_language_tl }
5057 { \l_@@_setup_type_tl }
5058 { \l_@@_lang_variant_tl - #1 }
5059 { tl }
5060 }
5061 {##1}
5062 }
5063 }
5064 } ,
5065 }
5066 }
5067 \seq_map_inline:Nn
5068 \g_@@_rf_opts_seq_refbounds_seq
5069 {
5070 \keys_define:nn { zref-clever/langsetup }
5071 {
5072 #1 .value_required:n = true ,
5073 #1 .code:n =
5074 {
5075 \tl_if_empty:NTF \l_@@_setup_type_tl
5076 {
5077 \seq_gclear:N \g_@@_tmpa_seq
5078 \@@_opt_seq_gset_clist_split:Nn
5079 \g_@@_tmpa_seq {##1}
5080 \bool_lazy_or:nnTF
5081 { \tl_if_empty_p:n {##1} }
5082 {
5083 \int_compare_p:nNn
5084 { \seq_count:N \g_@@_tmpa_seq } = { 4 }
5085 }
5086 {
5087 \@@_opt_seq_gset_eq:cN
5088 {
5089 \@@_opt_varname_lang_default:enn
5090 { \l_@@_setup_language_tl }
5091 {#1} { seq }
5092 }
5093 \g_@@_tmpa_seq
5094 }
5095 {
5096 \msg_warning:nnee { zref-clever }
5097 { refbounds-must-be-four }
5098 {#1} { \seq_count:N \g_@@_tmpa_seq }
5099 }
5100 }
5101 {
5102 \seq_gclear:N \g_@@_tmpa_seq
5103 \@@_opt_seq_gset_clist_split:Nn
5104 \g_@@_tmpa_seq {##1}
5105 \bool_lazy_or:nnTF
5106 { \tl_if_empty_p:n {##1} }
5107 {
5108 \int_compare_p:nNn
5109 { \seq_count:N \g_@@_tmpa_seq } = { 4 }
5110 }
5111 {
5112 \@@_opt_seq_gset_eq:cN
5113 {
5114 \@@_opt_varname_lang_type:eenn
5115 { \l_@@_setup_language_tl }
5116 { \l_@@_setup_type_tl } {#1} { seq }
5117 }
5118 \g_@@_tmpa_seq
5119 }
5120 {
5121 \msg_warning:nnee { zref-clever }
5122 { refbounds-must-be-four }
5123 {#1} { \seq_count:N \g_@@_tmpa_seq }
5124 }
5125 }
5126 } ,
5127 }
5128 }
5129 \seq_map_inline:Nn
5130 \g_@@_rf_opts_bool_maybe_type_specific_seq
5131 {
5132 \keys_define:nn { zref-clever/langsetup }
5133 {
5134 #1 .choice: ,
5135 #1 / true .code:n =
5136 {
5137 \tl_if_empty:NTF \l_@@_setup_type_tl
5138 {
5139 \@@_opt_bool_gset_true:c
5140 {
5141 \@@_opt_varname_lang_default:enn
5142 { \l_@@_setup_language_tl }
5143 {#1} { bool }
5144 }
5145 }
5146 {
5147 \@@_opt_bool_gset_true:c
5148 {
5149 \@@_opt_varname_lang_type:eenn
5150 { \l_@@_setup_language_tl }
5151 { \l_@@_setup_type_tl }
5152 {#1} { bool }
5153 }
5154 }
5155 } ,
5156 #1 / false .code:n =
5157 {
5158 \tl_if_empty:NTF \l_@@_setup_type_tl
5159 {
5160 \@@_opt_bool_gset_false:c
5161 {
5162 \@@_opt_varname_lang_default:enn
5163 { \l_@@_setup_language_tl }
5164 {#1} { bool }
5165 }
5166 }
5167 {
5168 \@@_opt_bool_gset_false:c
5169 {
5170 \@@_opt_varname_lang_type:eenn
5171 { \l_@@_setup_language_tl }
5172 { \l_@@_setup_type_tl }
5173 {#1} { bool }
5174 }
5175 }
5176 } ,
5177 #1 .default:n = true ,
5178 no #1 .meta:n = { #1 = false } ,
5179 no #1 .value_forbidden:n = true ,
5180 }
5181 }
5182 % \end{macrocode}
5183 %
5184 %
5185 % \section{User interface}
5186 %
5187 % \subsection{\cs{zcref}}
5188 %
5189 %
5190 % \begin{macro}[int]{\zcref}
5191 % The main user command of the package.
5192 % \begin{syntax}
5193 % \cs{zcref}\meta{*}\oarg{options}\marg{labels}
5194 % \end{syntax}
5195 % \begin{macrocode}
5196 \NewDocumentCommand \zcref { s O { } m }
5197 { \zref@wrapper@babel \@@_zcref:nnn {#3} {#1} {#2} }
5198 % \end{macrocode}
5199 % \end{macro}
5200 %
5201 %
5202 % \begin{macro}{\@@_zcref:nnnn}
5203 % An intermediate internal function, which does the actual heavy lifting,
5204 % and places \Arg{labels} as first argument, so that it can be protected by
5205 % \cs{zref@wrapper@babel} in \cs{zcref}.
5206 % \begin{syntax}
5207 % \cs{@@_zcref:nnnn} \Arg{labels} \Arg{*} \Arg{options}
5208 % \end{syntax}
5209 % \begin{macrocode}
5210 \cs_new_protected:Npn \@@_zcref:nnn #1#2#3
5211 {
5212 \group_begin:
5213 % \end{macrocode}
5214 % Set options.
5215 % \begin{macrocode}
5216 \keys_set:nn { zref-clever/reference } {#3}
5217 % \end{macrocode}
5218 % Store arguments values.
5219 % \begin{macrocode}
5220 \seq_set_from_clist:Nn \l_@@_zcref_labels_seq {#1}
5221 \bool_set:Nn \l_@@_link_star_bool {#2}
5222 % \end{macrocode}
5223 % Ensure language file for reference language is loaded, if available. We
5224 % cannot rely on \cs{keys_set:nn} for the task, since if the \opt{lang} option
5225 % is set for \texttt{current}, the actual language may have changed outside
5226 % our control. \cs{@@_provide_langfile:e} does nothing if the language file
5227 % is already loaded.
5228 % \begin{macrocode}
5229 \@@_provide_langfile:e { \l_@@_ref_language_tl }
5230 % \end{macrocode}
5231 % Process language settings.
5232 % \begin{macrocode}
5233 \@@_process_language_settings:
5234 % \end{macrocode}
5235 % Integration with \pkg{zref-check}.
5236 % \begin{macrocode}
5237 \bool_lazy_and:nnT
5238 { \l_@@_zrefcheck_available_bool }
5239 { \l_@@_zcref_with_check_bool }
5240 { \zrefcheck_zcref_beg_label: }
5241 % \end{macrocode}
5242 % Sort the labels.
5243 % \begin{macrocode}
5244 \bool_lazy_or:nnT
5245 { \l_@@_typeset_sort_bool }
5246 { \l_@@_typeset_range_bool }
5247 { \@@_sort_labels: }
5248 % \end{macrocode}
5249 % Typeset the references. Also, set the reference font, and group it, so that
5250 % it does not leak to the note.
5251 % \begin{macrocode}
5252 \group_begin:
5253 \l_@@_ref_typeset_font_tl
5254 \@@_typeset_refs:
5255 \group_end:
5256 % \end{macrocode}
5257 % Typeset \texttt{note}.
5258 % \begin{macrocode}
5259 \tl_if_empty:NF \l_@@_zcref_note_tl
5260 {
5261 \@@_get_rf_opt_tl:neeN { notesep }
5262 { \l_@@_label_type_a_tl }
5263 { \l_@@_ref_language_tl }
5264 \l_@@_tmpa_tl
5265 \l_@@_tmpa_tl
5266 \l_@@_zcref_note_tl
5267 }
5268 % \end{macrocode}
5269 % Integration with \pkg{zref-check}.
5270 % \begin{macrocode}
5271 \bool_lazy_and:nnT
5272 { \l_@@_zrefcheck_available_bool }
5273 { \l_@@_zcref_with_check_bool }
5274 {
5275 \zrefcheck_zcref_end_label_maybe:
5276 \zrefcheck_zcref_run_checks_on_labels:n
5277 { \l_@@_zcref_labels_seq }
5278 }
5279 % \end{macrocode}
5280 % Integration with \pkg{mathtools}.
5281 % \begin{macrocode}
5282 \bool_if:NT \l_@@_mathtools_loaded_bool
5283 {
5284 \@@_mathtools_showonlyrefs:n
5285 { \l_@@_zcref_labels_seq }
5286 }
5287 \group_end:
5288 }
5289 % \end{macrocode}
5290 % \end{macro}
5291 %
5292 % \begin{macro}{\l_@@_zcref_labels_seq, \l_@@_link_star_bool}
5293 % \begin{macrocode}
5294 \seq_new:N \l_@@_zcref_labels_seq
5295 \bool_new:N \l_@@_link_star_bool
5296 % \end{macrocode}
5297 % \end{macro}
5298 %
5299 %
5300 %
5301 % \subsection{\cs{zcpageref}}
5302 %
5303 %
5304 % \begin{macro}[int]{\zcpageref}
5305 % A \cs{pageref} equivalent of \cs{zcref}.
5306 % \begin{syntax}
5307 % \cs{zcpageref}\meta{*}\oarg{options}\marg{labels}
5308 % \end{syntax}
5309 % \begin{macrocode}
5310 \NewDocumentCommand \zcpageref { s O { } m }
5311 {
5312 \group_begin:
5313 \IfBooleanT {#1}
5314 { \bool_set_false:N \l_@@_hyperlink_bool }
5315 \zcref [#2, ref = page] {#3}
5316 \group_end:
5317 }
5318 % \end{macrocode}
5319 % \end{macro}
5320 %
5321 %
5322 %
5323 % \section{Sorting}
5324 %
5325 % Sorting is certainly a ``big task'' for \pkg{zref-clever} but, in the end,
5326 % it boils down to ``carefully done branching'', and quite some of it. The
5327 % sorting of ``page'' references is very much lightened by the availability of
5328 % \texttt{abspage}, from the \pkg{zref-abspage} module, which offers ``just
5329 % what we need'' for our purposes. The sorting of ``default'' references
5330 % falls on two main cases: i) labels of the same type; ii) labels of different
5331 % types. The first case is sorted according to the priorities set by the
5332 % \opt{typesort} option or, if that is silent for the case, by the order in
5333 % which labels were given by the user in \cs{zcref}. The second case is the
5334 % most involved one, since it is possible for multiple counters to be bundled
5335 % together in a single reference type. Because of this, sorting must take
5336 % into account the whole chain of ``enclosing counters'' for the counters of
5337 % the labels at hand.
5338 %
5339 % \begin{macro}
5340 % {
5341 % \l_@@_label_type_a_tl ,
5342 % \l_@@_label_type_b_tl ,
5343 % \l_@@_label_enclval_a_tl ,
5344 % \l_@@_label_enclval_b_tl ,
5345 % \l_@@_label_extdoc_a_tl ,
5346 % \l_@@_label_extdoc_b_tl ,
5347 % }
5348 % Auxiliary variables, for use in sorting, and some also in typesetting.
5349 % Used to store reference information -- label properties -- of the
5350 % ``current'' (\texttt{a}) and ``next'' (\texttt{b}) labels.
5351 % \begin{macrocode}
5352 \tl_new:N \l_@@_label_type_a_tl
5353 \tl_new:N \l_@@_label_type_b_tl
5354 \tl_new:N \l_@@_label_enclval_a_tl
5355 \tl_new:N \l_@@_label_enclval_b_tl
5356 \tl_new:N \l_@@_label_extdoc_a_tl
5357 \tl_new:N \l_@@_label_extdoc_b_tl
5358 % \end{macrocode}
5359 % \end{macro}
5360 %
5361 % \begin{macro}{\l_@@_sort_decided_bool}
5362 % Auxiliary variable for \cs{@@_sort_default_same_type:nn}, signals if the
5363 % sorting between two labels has been decided or not.
5364 % \begin{macrocode}
5365 \bool_new:N \l_@@_sort_decided_bool
5366 % \end{macrocode}
5367 % \end{macro}
5368 %
5369 % \begin{macro}{\l_@@_sort_prior_a_int,\l_@@_sort_prior_b_int}
5370 % Auxiliary variables for \cs{@@_sort_default_different_types:nn}. Store
5371 % the sort priority of the ``current'' and ``next'' labels.
5372 % \begin{macrocode}
5373 \int_new:N \l_@@_sort_prior_a_int
5374 \int_new:N \l_@@_sort_prior_b_int
5375 % \end{macrocode}
5376 % \end{macro}
5377 %
5378 % \begin{macro}{\l_@@_label_types_seq}
5379 % Stores the order in which reference types appear in the label list
5380 % supplied by the user in \cs{zcref}. This variable is populated by
5381 % \cs{@@_label_type_put_new_right:n} at the start of \cs{@@_sort_labels:}.
5382 % This order is required as a ``last resort'' sort criterion between the
5383 % reference types, for use in \cs{@@_sort_default_different_types:nn}.
5384 % \begin{macrocode}
5385 \seq_new:N \l_@@_label_types_seq
5386 % \end{macrocode}
5387 % \end{macro}
5388 %
5389 %
5390 % \begin{macro}{\@@_sort_labels:}
5391 % The main sorting function. It does not receive arguments, but it is
5392 % expected to be run inside \cs{@@_zcref:nnnn} where a number of environment
5393 % variables are to be set appropriately. In particular,
5394 % \cs{l_@@_zcref_labels_seq} should contain the labels received as argument
5395 % to \cs{zcref}, and the function performs its task by sorting this
5396 % variable.
5397 % \begin{macrocode}
5398 \cs_new_protected:Npn \@@_sort_labels:
5399 {
5400 % \end{macrocode}
5401 % Store label types sequence.
5402 % \begin{macrocode}
5403 \seq_clear:N \l_@@_label_types_seq
5404 \tl_if_eq:NnF \l_@@_ref_property_tl { page }
5405 {
5406 \seq_map_function:NN \l_@@_zcref_labels_seq
5407 \@@_label_type_put_new_right:n
5408 }
5409 % \end{macrocode}
5410 % Sort.
5411 % \begin{macrocode}
5412 \seq_sort:Nn \l_@@_zcref_labels_seq
5413 {
5414 \zref@ifrefundefined {##1}
5415 {
5416 \zref@ifrefundefined {##2}
5417 {
5418 % Neither label is defined.
5419 \sort_return_same:
5420 }
5421 {
5422 % The second label is defined, but the first isn't, leave the
5423 % undefined first (to be more visible).
5424 \sort_return_same:
5425 }
5426 }
5427 {
5428 \zref@ifrefundefined {##2}
5429 {
5430 % The first label is defined, but the second isn't, bring the
5431 % second forward.
5432 \sort_return_swapped:
5433 }
5434 {
5435 % The interesting case: both labels are defined. References
5436 % to the "default" property or to the "page" are quite
5437 % different with regard to sorting, so we branch them here to
5438 % specialized functions.
5439 \tl_if_eq:NnTF \l_@@_ref_property_tl { page }
5440 { \@@_sort_page:nn {##1} {##2} }
5441 { \@@_sort_default:nn {##1} {##2} }
5442 }
5443 }
5444 }
5445 }
5446 % \end{macrocode}
5447 % \end{macro}
5448 %
5449 % \begin{macro}{\@@_label_type_put_new_right:n}
5450 % Auxiliary function used to store the order in which reference types appear
5451 % in the label list supplied by the user in \cs{zcref}. It is expected to
5452 % be run inside \cs{@@_sort_labels:}, and stores the types sequence in
5453 % \cs{l_@@_label_types_seq}. I have tried to handle the same task inside
5454 % \cs{seq_sort:Nn} in \cs{@@_sort_labels:} to spare mapping over
5455 % \cs{l_@@_zcref_labels_seq}, but it turned out it not to be easy to rely on
5456 % the order the labels get processed at that point, since the variable is
5457 % being sorted there. Besides, the mapping is simple, not a particularly
5458 % expensive operation. Anyway, this keeps things clean.
5459 % \begin{syntax}
5460 % \cs{@@_label_type_put_new_right:n} \Arg{label}
5461 % \end{syntax}
5462 % \begin{macrocode}
5463 \cs_new_protected:Npn \@@_label_type_put_new_right:n #1
5464 {
5465 \@@_extract_default:Nnnn
5466 \l_@@_label_type_a_tl {#1} { zc@type } { }
5467 \seq_if_in:NVF \l_@@_label_types_seq
5468 \l_@@_label_type_a_tl
5469 {
5470 \seq_put_right:NV \l_@@_label_types_seq
5471 \l_@@_label_type_a_tl
5472 }
5473 }
5474 % \end{macrocode}
5475 % \end{macro}
5476 %
5477 %
5478 % \begin{macro}{\@@_sort_default:nn}
5479 % The heavy-lifting function for sorting of defined labels for ``default''
5480 % references (that is, a standard reference, not to ``page''). This
5481 % function is expected to be called within the sorting loop of
5482 % \cs{@@_sort_labels:} and receives the pair of labels being considered for
5483 % a change of order or not. It should \emph{always} ``return'' either
5484 % \cs{sort_return_same:} or \cs{sort_return_swapped:}.
5485 % \begin{syntax}
5486 % \cs{@@_sort_default:nn} \Arg{label a} \Arg{label b}
5487 % \end{syntax}
5488 % \begin{macrocode}
5489 \cs_new_protected:Npn \@@_sort_default:nn #1#2
5490 {
5491 \@@_extract_default:Nnnn
5492 \l_@@_label_type_a_tl {#1} { zc@type } { zc@missingtype }
5493 \@@_extract_default:Nnnn
5494 \l_@@_label_type_b_tl {#2} { zc@type } { zc@missingtype }
5495 \tl_if_eq:NNTF
5496 \l_@@_label_type_a_tl
5497 \l_@@_label_type_b_tl
5498 { \@@_sort_default_same_type:nn {#1} {#2} }
5499 { \@@_sort_default_different_types:nn {#1} {#2} }
5500 }
5501 % \end{macrocode}
5502 % \end{macro}
5503 %
5504 %
5505 % \begin{macro}{\@@_sort_default_same_type:nn}
5506 % \begin{syntax}
5507 % \cs{@@_sort_default_same_type:nn} \Arg{label a} \Arg{label b}
5508 % \end{syntax}
5509 % \begin{macrocode}
5510 \cs_new_protected:Npn \@@_sort_default_same_type:nn #1#2
5511 {
5512 \@@_extract_default:Nnnn \l_@@_label_enclval_a_tl
5513 {#1} { zc@enclval } { }
5514 \tl_reverse:N \l_@@_label_enclval_a_tl
5515 \@@_extract_default:Nnnn \l_@@_label_enclval_b_tl
5516 {#2} { zc@enclval } { }
5517 \tl_reverse:N \l_@@_label_enclval_b_tl
5518 \@@_extract_default:Nnnn \l_@@_label_extdoc_a_tl
5519 {#1} { externaldocument } { }
5520 \@@_extract_default:Nnnn \l_@@_label_extdoc_b_tl
5521 {#2} { externaldocument } { }
5522 \bool_set_false:N \l_@@_sort_decided_bool
5523 % First we check if there's any "external document" difference (coming
5524 % from `zref-xr') and, if so, sort based on that.
5525 \tl_if_eq:NNF
5526 \l_@@_label_extdoc_a_tl
5527 \l_@@_label_extdoc_b_tl
5528 {
5529 \bool_if:nTF
5530 {
5531 \tl_if_empty_p:V \l_@@_label_extdoc_a_tl &&
5532 ! \tl_if_empty_p:V \l_@@_label_extdoc_b_tl
5533 }
5534 {
5535 \bool_set_true:N \l_@@_sort_decided_bool
5536 \sort_return_same:
5537 }
5538 {
5539 \bool_if:nTF
5540 {
5541 ! \tl_if_empty_p:V \l_@@_label_extdoc_a_tl &&
5542 \tl_if_empty_p:V \l_@@_label_extdoc_b_tl
5543 }
5544 {
5545 \bool_set_true:N \l_@@_sort_decided_bool
5546 \sort_return_swapped:
5547 }
5548 {
5549 \bool_set_true:N \l_@@_sort_decided_bool
5550 % Two different "external documents": last resort, sort by the
5551 % document name itself.
5552 \str_compare:eNeTF
5553 { \l_@@_label_extdoc_b_tl } <
5554 { \l_@@_label_extdoc_a_tl }
5555 { \sort_return_swapped: }
5556 { \sort_return_same: }
5557 }
5558 }
5559 }
5560 \bool_until_do:Nn \l_@@_sort_decided_bool
5561 {
5562 \bool_if:nTF
5563 {
5564 % Both are empty: neither label has any (further) "enclosing
5565 % counters" (left).
5566 \tl_if_empty_p:V \l_@@_label_enclval_a_tl &&
5567 \tl_if_empty_p:V \l_@@_label_enclval_b_tl
5568 }
5569 {
5570 \bool_set_true:N \l_@@_sort_decided_bool
5571 \int_compare:nNnTF
5572 { \@@_extract:nnn {#1} { zc@cntval } { -1 } }
5573 >
5574 { \@@_extract:nnn {#2} { zc@cntval } { -1 } }
5575 { \sort_return_swapped: }
5576 { \sort_return_same: }
5577 }
5578 {
5579 \bool_if:nTF
5580 {
5581 % `a' is empty (and `b' is not): `b' may be nested in `a'.
5582 \tl_if_empty_p:V \l_@@_label_enclval_a_tl
5583 }
5584 {
5585 \bool_set_true:N \l_@@_sort_decided_bool
5586 \int_compare:nNnTF
5587 { \@@_extract:nnn {#1} { zc@cntval } { -1 } }
5588 >
5589 { \tl_head:N \l_@@_label_enclval_b_tl }
5590 { \sort_return_swapped: }
5591 { \sort_return_same: }
5592 }
5593 {
5594 \bool_if:nTF
5595 {
5596 % `b' is empty (and `a' is not): `a' may be nested in `b'.
5597 \tl_if_empty_p:V \l_@@_label_enclval_b_tl
5598 }
5599 {
5600 \bool_set_true:N \l_@@_sort_decided_bool
5601 \int_compare:nNnTF
5602 { \tl_head:N \l_@@_label_enclval_a_tl }
5603 <
5604 { \@@_extract:nnn {#2} { zc@cntval } { -1 } }
5605 { \sort_return_same: }
5606 { \sort_return_swapped: }
5607 }
5608 {
5609 % Neither is empty: we can compare the values of the
5610 % current enclosing counter in the loop, if they are
5611 % equal, we are still in the loop, if they are not, a
5612 % sorting decision can be made directly.
5613 \int_compare:nNnTF
5614 { \tl_head:N \l_@@_label_enclval_a_tl }
5615 =
5616 { \tl_head:N \l_@@_label_enclval_b_tl }
5617 {
5618 \tl_set:Ne \l_@@_label_enclval_a_tl
5619 { \tl_tail:N \l_@@_label_enclval_a_tl }
5620 \tl_set:Ne \l_@@_label_enclval_b_tl
5621 { \tl_tail:N \l_@@_label_enclval_b_tl }
5622 }
5623 {
5624 \bool_set_true:N \l_@@_sort_decided_bool
5625 \int_compare:nNnTF
5626 { \tl_head:N \l_@@_label_enclval_a_tl }
5627 >
5628 { \tl_head:N \l_@@_label_enclval_b_tl }
5629 { \sort_return_swapped: }
5630 { \sort_return_same: }
5631 }
5632 }
5633 }
5634 }
5635 }
5636 }
5637 % \end{macrocode}
5638 % \end{macro}
5639 %
5640 %
5641 % \begin{macro}{\@@_sort_default_different_types:nn}
5642 % \begin{syntax}
5643 % \cs{@@_sort_default_different_types:nn} \Arg{label a} \Arg{label b}
5644 % \end{syntax}
5645 % \begin{macrocode}
5646 \cs_new_protected:Npn \@@_sort_default_different_types:nn #1#2
5647 {
5648 % \end{macrocode}
5649 % Retrieve sort priorities for \meta{label a} and \meta{label b}.
5650 % \cs{l_@@_typesort_seq} was stored in reverse sequence, and we compute the
5651 % sort priorities in the negative range, so that we can implicitly rely on `0'
5652 % being the ``last value''.
5653 % \begin{macrocode}
5654 \int_zero:N \l_@@_sort_prior_a_int
5655 \int_zero:N \l_@@_sort_prior_b_int
5656 \seq_map_indexed_inline:Nn \l_@@_typesort_seq
5657 {
5658 \tl_if_eq:nnTF {##2} {{othertypes}}
5659 {
5660 \int_compare:nNnT { \l_@@_sort_prior_a_int } = { 0 }
5661 { \int_set:Nn \l_@@_sort_prior_a_int { - ##1 } }
5662 \int_compare:nNnT { \l_@@_sort_prior_b_int } = { 0 }
5663 { \int_set:Nn \l_@@_sort_prior_b_int { - ##1 } }
5664 }
5665 {
5666 \tl_if_eq:NnTF \l_@@_label_type_a_tl {##2}
5667 { \int_set:Nn \l_@@_sort_prior_a_int { - ##1 } }
5668 {
5669 \tl_if_eq:NnT \l_@@_label_type_b_tl {##2}
5670 { \int_set:Nn \l_@@_sort_prior_b_int { - ##1 } }
5671 }
5672 }
5673 }
5674 % \end{macrocode}
5675 % Then do the actual sorting.
5676 % \begin{macrocode}
5677 \bool_if:nTF
5678 {
5679 \int_compare_p:nNn
5680 { \l_@@_sort_prior_a_int } <
5681 { \l_@@_sort_prior_b_int }
5682 }
5683 { \sort_return_same: }
5684 {
5685 \bool_if:nTF
5686 {
5687 \int_compare_p:nNn
5688 { \l_@@_sort_prior_a_int } >
5689 { \l_@@_sort_prior_b_int }
5690 }
5691 { \sort_return_swapped: }
5692 {
5693 % Sort priorities are equal: the type that occurs first in
5694 % `labels', as given by the user, is kept (or brought) forward.
5695 \seq_map_inline:Nn \l_@@_label_types_seq
5696 {
5697 \tl_if_eq:NnTF \l_@@_label_type_a_tl {##1}
5698 { \seq_map_break:n { \sort_return_same: } }
5699 {
5700 \tl_if_eq:NnT \l_@@_label_type_b_tl {##1}
5701 { \seq_map_break:n { \sort_return_swapped: } }
5702 }
5703 }
5704 }
5705 }
5706 }
5707 % \end{macrocode}
5708 % \end{macro}
5709 %
5710 %
5711 % \begin{macro}{\@@_sort_page:nn}
5712 % The sorting function for sorting of defined labels for references to
5713 % ``page''. This function is expected to be called within the sorting loop
5714 % of \cs{@@_sort_labels:} and receives the pair of labels being considered
5715 % for a change of order or not. It should \emph{always} ``return'' either
5716 % \cs{sort_return_same:} or \cs{sort_return_swapped:}. Compared to the
5717 % sorting of default labels, this is a piece of cake (thanks to
5718 % \texttt{abspage}).
5719 % \begin{syntax}
5720 % \cs{@@_sort_page:nn} \Arg{label a} \Arg{label b}
5721 % \end{syntax}
5722 % \begin{macrocode}
5723 \cs_new_protected:Npn \@@_sort_page:nn #1#2
5724 {
5725 \int_compare:nNnTF
5726 { \@@_extract:nnn {#1} { abspage } { -1 } }
5727 >
5728 { \@@_extract:nnn {#2} { abspage } { -1 } }
5729 { \sort_return_swapped: }
5730 { \sort_return_same: }
5731 }
5732 % \end{macrocode}
5733 % \end{macro}
5734 %
5735 %
5736 %
5737 % \section{Typesetting}
5738 %
5739 % ``Typesetting'' the reference, which here includes the parsing of the labels
5740 % and eventual compression of labels in sequence into ranges, is definitely
5741 % the ``crux'' of \pkg{zref-clever}. This because we process the label set as
5742 % a stack, in a single pass, and hence ``parsing'', ``compressing'', and
5743 % ``typesetting'' must be decided upon at the same time, making it difficult
5744 % to slice the job into more specific and self-contained tasks. So, do bear
5745 % this in mind before you curse me for the length of some of the functions
5746 % below, or before a more orthodox ``docstripper'' complains about me not
5747 % sticking to code commenting conventions to keep the code more readable in
5748 % the \file{.dtx} file.
5749 %
5750 % While processing the label stack (kept in \cs{l_@@_typeset_labels_seq}),
5751 % \cs{@@_typeset_refs:} ``sees'' two labels, and two labels only, the
5752 % ``current'' one (kept in \cs{l_@@_label_a_tl}), and the ``next'' one (kept
5753 % in \cs{l_@@_label_b_tl}). However, the typesetting needs (a lot) more
5754 % information than just these two immediate labels to make a number of
5755 % critical decisions. Some examples: i) We cannot know if labels ``current''
5756 % and ``next'' of the same type are a ``pair'', or just ``elements in a
5757 % list'', until we examine the label after ``next''; ii) If the ``next'' label
5758 % is of the same type as the ``current'', and it is in immediate sequence to
5759 % it, it potentially forms a ``range'', but we cannot know if ``next'' is
5760 % actually the end of the range until we examined an arbitrary number of
5761 % labels, and found one which is not in sequence from the previous one; iii)
5762 % When processing a type block, the ``name'' comes first, however, we only
5763 % know if that name should be plural, or if it should be included in the
5764 % hyperlink, after processing an arbitrary number of labels and find one of a
5765 % different type. One could naively assume that just examining ``next'' would
5766 % be enough for this, since we can know if it is of the same type or not.
5767 % Alas, ``there be ranges'', and a compression operation may boil down to a
5768 % single element, so we have to process the whole type block to know how its
5769 % name should be typeset; iv) Similar issues apply to lists of type blocks,
5770 % each of which is of arbitrary length: we can only know if two type blocks
5771 % form a ``pair'' or are ``elements in a list'' when we finish the
5772 % block. Etc.\ etc.\ etc.
5773 %
5774 % We handle this by storing the reference ``pieces'' in ``queues'', instead of
5775 % typesetting them immediately upon processing. The ``queues'' get typeset at
5776 % the point where all the information needed is available, which usually
5777 % happens when a type block finishes (we see something of a different type in
5778 % ``next'', signaled by \cs{l_@@_last_of_type_bool}), or the stack itself
5779 % finishes (has no more elements, signaled by \cs{l_@@_typeset_last_bool}).
5780 % And, in processing a type block, the type ``name'' gets added last (on the
5781 % left) of the queue. The very first reference of its type always follows the
5782 % name, since it may form a hyperlink with it (so we keep it stored
5783 % separately, in \cs{l_@@_type_first_label_tl}, with
5784 % \cs{l_@@_type_first_label_type_tl} being its type). And, since we may need
5785 % up to two type blocks in storage before typesetting, we have two of these
5786 % ``queues'': \cs{l_@@_typeset_queue_curr_tl} and
5787 % \cs{l_@@_typeset_queue_prev_tl}.
5788 %
5789 % Some of the relevant cases (e.g., distinguishing ``pair'' from ``list'') are
5790 % handled by counters, the main ones are: one for the ``type''
5791 % (\cs{l_@@_type_count_int}) and one for the ``label in the current type
5792 % block'' (\cs{l_@@_label_count_int}).
5793 %
5794 % Range compression, in particular, relies heavily on counting to be able do
5795 % distinguish relevant cases. \cs{l_@@_range_count_int} counts the number of
5796 % elements in the current sequential ``streak'', and
5797 % \cs{l_@@_range_same_count_int} counts the number of \emph{equal} elements in
5798 % that same ``streak''. The difference between the two allows us to
5799 % distinguish the cases in which a range actually ``skips'' a number in the
5800 % sequence, in which case we should use a range separator, from when they are
5801 % after all just contiguous, in which case a pair separator is called for.
5802 % Since, as usual, we can only know this when a arbitrarily long ``streak''
5803 % finishes, we have to store the label which (potentially) begins a range
5804 % (kept in \cs{l_@@_range_beg_label_tl}). \cs{l_@@_next_maybe_range_bool}
5805 % signals when ``next'' is potentially a range with ``current'', and
5806 % \cs{l_@@_next_is_same_bool} when their values are actually equal.
5807 %
5808 %
5809 % One further thing to discuss here -- to keep this ``on record'' -- is
5810 % inhibition of compression for individual labels. It is not difficult to
5811 % handle it at the infrastructure side, what gets sloppy is the user facing
5812 % syntax to signal such inhibition. For some possible alternatives for this,
5813 % suggested by \contributor{Enrico Gregorio}, \contributor{Phelype Oleinik},
5814 % and \contributor{Steven B.\ Segletes} (and good ones at that) see
5815 % \url{https://tex.stackexchange.com/q/611370}. Yet another alternative would
5816 % be an option receiving the label(s) not to be compressed, this would be a
5817 % repetition, but would keep the syntax clean. All in all, probably the best
5818 % is simply not to allow individual inhibition of compression. We can already
5819 % control compression of each \cs{zcref} call with existing options, this
5820 % should be enough. I don't think the small extra flexibility individual
5821 % label control for this would grant is worth the syntax disruption it would
5822 % entail. Anyway, it would be easy to deal with this in case the need arose,
5823 % by just adding another condition (coming from whatever the chosen syntax
5824 % was) when we check for \cs{@@_labels_in_sequence:nn} in
5825 % \cs{@@_typeset_refs_not_last_of_type:}. But I remain unconvinced of the
5826 % pertinence of doing so.
5827 %
5828 %
5829 % \subsection*{Variables}
5830 %
5831 % \begin{macro}
5832 % {
5833 % \l_@@_typeset_labels_seq ,
5834 % \l_@@_typeset_last_bool ,
5835 % \l_@@_last_of_type_bool ,
5836 % }
5837 % Auxiliary variables for \cs{@@_typeset_refs:} main stack control.
5838 % \begin{macrocode}
5839 \seq_new:N \l_@@_typeset_labels_seq
5840 \bool_new:N \l_@@_typeset_last_bool
5841 \bool_new:N \l_@@_last_of_type_bool
5842 % \end{macrocode}
5843 % \end{macro}
5844 %
5845 % \begin{macro}
5846 % {
5847 % \l_@@_type_count_int ,
5848 % \l_@@_label_count_int ,
5849 % \l_@@_ref_count_int ,
5850 % }
5851 % Auxiliary variables for \cs{@@_typeset_refs:} main counters.
5852 % \begin{macrocode}
5853 \int_new:N \l_@@_type_count_int
5854 \int_new:N \l_@@_label_count_int
5855 \int_new:N \l_@@_ref_count_int
5856 % \end{macrocode}
5857 % \end{macro}
5858 %
5859 % \begin{macro}
5860 % {
5861 % \l_@@_label_a_tl ,
5862 % \l_@@_label_b_tl ,
5863 % \l_@@_typeset_queue_prev_tl ,
5864 % \l_@@_typeset_queue_curr_tl ,
5865 % \l_@@_type_first_label_tl ,
5866 % \l_@@_type_first_label_type_tl
5867 % }
5868 % Auxiliary variables for \cs{@@_typeset_refs:} main ``queue'' control and
5869 % storage.
5870 % \begin{macrocode}
5871 \tl_new:N \l_@@_label_a_tl
5872 \tl_new:N \l_@@_label_b_tl
5873 \tl_new:N \l_@@_typeset_queue_prev_tl
5874 \tl_new:N \l_@@_typeset_queue_curr_tl
5875 \tl_new:N \l_@@_type_first_label_tl
5876 \tl_new:N \l_@@_type_first_label_type_tl
5877 % \end{macrocode}
5878 % \end{macro}
5879 %
5880 % \begin{macro}
5881 % {
5882 % \l_@@_type_name_tl ,
5883 % \l_@@_name_in_link_bool ,
5884 % \l_@@_type_name_missing_bool ,
5885 % \l_@@_name_format_tl ,
5886 % \l_@@_name_format_fallback_tl ,
5887 % \l_@@_type_name_gender_seq ,
5888 % }
5889 % Auxiliary variables for \cs{@@_typeset_refs:} type name handling.
5890 % \begin{macrocode}
5891 \tl_new:N \l_@@_type_name_tl
5892 \bool_new:N \l_@@_name_in_link_bool
5893 \bool_new:N \l_@@_type_name_missing_bool
5894 \tl_new:N \l_@@_name_format_tl
5895 \tl_new:N \l_@@_name_format_fallback_tl
5896 \seq_new:N \l_@@_type_name_gender_seq
5897 % \end{macrocode}
5898 % \end{macro}
5899 %
5900 % \begin{macro}
5901 % {
5902 % \l_@@_range_count_int ,
5903 % \l_@@_range_same_count_int ,
5904 % \l_@@_range_beg_label_tl ,
5905 % \l_@@_range_beg_is_first_bool ,
5906 % \l_@@_range_end_ref_tl ,
5907 % \l_@@_next_maybe_range_bool ,
5908 % \l_@@_next_is_same_bool ,
5909 % }
5910 % Auxiliary variables for \cs{@@_typeset_refs:} range handling.
5911 % \begin{macrocode}
5912 \int_new:N \l_@@_range_count_int
5913 \int_new:N \l_@@_range_same_count_int
5914 \tl_new:N \l_@@_range_beg_label_tl
5915 \bool_new:N \l_@@_range_beg_is_first_bool
5916 \tl_new:N \l_@@_range_end_ref_tl
5917 \bool_new:N \l_@@_next_maybe_range_bool
5918 \bool_new:N \l_@@_next_is_same_bool
5919 % \end{macrocode}
5920 % \end{macro}
5921 %
5922 % \begin{macro}
5923 % {
5924 % \l_@@_tpairsep_tl ,
5925 % \l_@@_tlistsep_tl ,
5926 % \l_@@_tlastsep_tl ,
5927 % \l_@@_namesep_tl ,
5928 % \l_@@_pairsep_tl ,
5929 % \l_@@_listsep_tl ,
5930 % \l_@@_lastsep_tl ,
5931 % \l_@@_rangesep_tl ,
5932 % \l_@@_namefont_tl ,
5933 % \l_@@_reffont_tl ,
5934 % \l_@@_endrangefunc_tl ,
5935 % \l_@@_endrangeprop_tl ,
5936 % \l_@@_cap_bool ,
5937 % \l_@@_abbrev_bool ,
5938 % \l_@@_rangetopair_bool ,
5939 % }
5940 % Auxiliary variables for \cs{@@_typeset_refs:} separators, and font and
5941 % other options.
5942 % \begin{macrocode}
5943 \tl_new:N \l_@@_tpairsep_tl
5944 \tl_new:N \l_@@_tlistsep_tl
5945 \tl_new:N \l_@@_tlastsep_tl
5946 \tl_new:N \l_@@_namesep_tl
5947 \tl_new:N \l_@@_pairsep_tl
5948 \tl_new:N \l_@@_listsep_tl
5949 \tl_new:N \l_@@_lastsep_tl
5950 \tl_new:N \l_@@_rangesep_tl
5951 \tl_new:N \l_@@_namefont_tl
5952 \tl_new:N \l_@@_reffont_tl
5953 \tl_new:N \l_@@_endrangefunc_tl
5954 \tl_new:N \l_@@_endrangeprop_tl
5955 \bool_new:N \l_@@_cap_bool
5956 \bool_new:N \l_@@_abbrev_bool
5957 \bool_new:N \l_@@_rangetopair_bool
5958 % \end{macrocode}
5959 % \end{macro}
5960 %
5961 % \begin{macro}
5962 % {
5963 % \l_@@_refbounds_first_seq ,
5964 % \l_@@_refbounds_first_sg_seq ,
5965 % \l_@@_refbounds_first_pb_seq ,
5966 % \l_@@_refbounds_first_rb_seq ,
5967 % \l_@@_refbounds_mid_seq ,
5968 % \l_@@_refbounds_mid_rb_seq ,
5969 % \l_@@_refbounds_mid_re_seq ,
5970 % \l_@@_refbounds_last_seq ,
5971 % \l_@@_refbounds_last_pe_seq ,
5972 % \l_@@_refbounds_last_re_seq ,
5973 % \l_@@_type_first_refbounds_seq ,
5974 % \l_@@_type_first_refbounds_set_bool ,
5975 % }
5976 % Auxiliary variables for \cs{@@_typeset_refs:}: advanced reference format
5977 % options.
5978 % \begin{macrocode}
5979 \seq_new:N \l_@@_refbounds_first_seq
5980 \seq_new:N \l_@@_refbounds_first_sg_seq
5981 \seq_new:N \l_@@_refbounds_first_pb_seq
5982 \seq_new:N \l_@@_refbounds_first_rb_seq
5983 \seq_new:N \l_@@_refbounds_mid_seq
5984 \seq_new:N \l_@@_refbounds_mid_rb_seq
5985 \seq_new:N \l_@@_refbounds_mid_re_seq
5986 \seq_new:N \l_@@_refbounds_last_seq
5987 \seq_new:N \l_@@_refbounds_last_pe_seq
5988 \seq_new:N \l_@@_refbounds_last_re_seq
5989 \seq_new:N \l_@@_type_first_refbounds_seq
5990 \bool_new:N \l_@@_type_first_refbounds_set_bool
5991 % \end{macrocode}
5992 % \end{macro}
5993 %
5994 % \begin{macro}{\l_@@_verbose_testing_bool}
5995 % Internal variable which enables extra log messaging at points of interest
5996 % in the code for purposes of regression testing. Particularly relevant to
5997 % keep track of expansion control in \cs{l_@@_typeset_queue_curr_tl}.
5998 % \begin{macrocode}
5999 \bool_new:N \l_@@_verbose_testing_bool
6000 % \end{macrocode}
6001 % \end{macro}
6002 %
6003 %
6004 % \subsection*{Main functions}
6005 %
6006 % \begin{macro}{\@@_typeset_refs:}
6007 % Main typesetting function for \cs{zcref}.
6008 % \begin{macrocode}
6009 \cs_new_protected:Npn \@@_typeset_refs:
6010 {
6011 \seq_set_eq:NN \l_@@_typeset_labels_seq
6012 \l_@@_zcref_labels_seq
6013 \tl_clear:N \l_@@_typeset_queue_prev_tl
6014 \tl_clear:N \l_@@_typeset_queue_curr_tl
6015 \tl_clear:N \l_@@_type_first_label_tl
6016 \tl_clear:N \l_@@_type_first_label_type_tl
6017 \tl_clear:N \l_@@_range_beg_label_tl
6018 \tl_clear:N \l_@@_range_end_ref_tl
6019 \int_zero:N \l_@@_label_count_int
6020 \int_zero:N \l_@@_type_count_int
6021 \int_zero:N \l_@@_ref_count_int
6022 \int_zero:N \l_@@_range_count_int
6023 \int_zero:N \l_@@_range_same_count_int
6024 \bool_set_false:N \l_@@_range_beg_is_first_bool
6025 \bool_set_false:N \l_@@_type_first_refbounds_set_bool
6026 % Get type block options (not type-specific).
6027 \@@_get_rf_opt_tl:neeN { tpairsep }
6028 { \l_@@_label_type_a_tl }
6029 { \l_@@_ref_language_tl }
6030 \l_@@_tpairsep_tl
6031 \@@_get_rf_opt_tl:neeN { tlistsep }
6032 { \l_@@_label_type_a_tl }
6033 { \l_@@_ref_language_tl }
6034 \l_@@_tlistsep_tl
6035 \@@_get_rf_opt_tl:neeN { tlastsep }
6036 { \l_@@_label_type_a_tl }
6037 { \l_@@_ref_language_tl }
6038 \l_@@_tlastsep_tl
6039 % Process label stack.
6040 \bool_set_false:N \l_@@_typeset_last_bool
6041 \bool_until_do:Nn \l_@@_typeset_last_bool
6042 {
6043 \seq_pop_left:NN \l_@@_typeset_labels_seq
6044 \l_@@_label_a_tl
6045 \seq_if_empty:NTF \l_@@_typeset_labels_seq
6046 {
6047 \tl_clear:N \l_@@_label_b_tl
6048 \bool_set_true:N \l_@@_typeset_last_bool
6049 }
6050 {
6051 \seq_get_left:NN \l_@@_typeset_labels_seq
6052 \l_@@_label_b_tl
6053 }
6054 \tl_if_eq:NnTF \l_@@_ref_property_tl { page }
6055 {
6056 \tl_set:Nn \l_@@_label_type_a_tl { page }
6057 \tl_set:Nn \l_@@_label_type_b_tl { page }
6058 }
6059 {
6060 \@@_extract_default:NVnn
6061 \l_@@_label_type_a_tl
6062 \l_@@_label_a_tl { zc@type } { zc@missingtype }
6063 \@@_extract_default:NVnn
6064 \l_@@_label_type_b_tl
6065 \l_@@_label_b_tl { zc@type } { zc@missingtype }
6066 }
6067 % First, we establish whether the "current label" (i.e. `a') is the
6068 % last one of its type. This can happen because the "next label"
6069 % (i.e. `b') is of a different type (or different definition status),
6070 % or because we are at the end of the list.
6071 \bool_if:NTF \l_@@_typeset_last_bool
6072 { \bool_set_true:N \l_@@_last_of_type_bool }
6073 {
6074 \zref@ifrefundefined { \l_@@_label_a_tl }
6075 {
6076 \zref@ifrefundefined { \l_@@_label_b_tl }
6077 { \bool_set_false:N \l_@@_last_of_type_bool }
6078 { \bool_set_true:N \l_@@_last_of_type_bool }
6079 }
6080 {
6081 \zref@ifrefundefined { \l_@@_label_b_tl }
6082 { \bool_set_true:N \l_@@_last_of_type_bool }
6083 {
6084 % Neither is undefined, we must check the types.
6085 \tl_if_eq:NNTF
6086 \l_@@_label_type_a_tl
6087 \l_@@_label_type_b_tl
6088 { \bool_set_false:N \l_@@_last_of_type_bool }
6089 { \bool_set_true:N \l_@@_last_of_type_bool }
6090 }
6091 }
6092 }
6093 % Handle warnings in case of reference or type undefined.
6094 % Test: `zc-typeset01.lvt': "Typeset refs: warn ref undefined"
6095 \zref@refused { \l_@@_label_a_tl }
6096 % Test: `zc-typeset01.lvt': "Typeset refs: warn missing type"
6097 \zref@ifrefundefined { \l_@@_label_a_tl }
6098 {}
6099 {
6100 \tl_if_eq:NnT \l_@@_label_type_a_tl { zc@missingtype }
6101 {
6102 \msg_warning:nne { zref-clever } { missing-type }
6103 { \l_@@_label_a_tl }
6104 }
6105 \zref@ifrefcontainsprop
6106 { \l_@@_label_a_tl }
6107 { \l_@@_ref_property_tl }
6108 { }
6109 {
6110 \msg_warning:nnee { zref-clever } { missing-property }
6111 { \l_@@_ref_property_tl }
6112 { \l_@@_label_a_tl }
6113 }
6114 }
6115 % Get possibly type-specific separators, refbounds, font and other
6116 % options, once per type.
6117 \int_compare:nNnT { \l_@@_label_count_int } = { 0 }
6118 {
6119 \@@_get_rf_opt_tl:neeN { namesep }
6120 { \l_@@_label_type_a_tl }
6121 { \l_@@_ref_language_tl }
6122 \l_@@_namesep_tl
6123 \@@_get_rf_opt_tl:neeN { pairsep }
6124 { \l_@@_label_type_a_tl }
6125 { \l_@@_ref_language_tl }
6126 \l_@@_pairsep_tl
6127 \@@_get_rf_opt_tl:neeN { listsep }
6128 { \l_@@_label_type_a_tl }
6129 { \l_@@_ref_language_tl }
6130 \l_@@_listsep_tl
6131 \@@_get_rf_opt_tl:neeN { lastsep }
6132 { \l_@@_label_type_a_tl }
6133 { \l_@@_ref_language_tl }
6134 \l_@@_lastsep_tl
6135 \@@_get_rf_opt_tl:neeN { rangesep }
6136 { \l_@@_label_type_a_tl }
6137 { \l_@@_ref_language_tl }
6138 \l_@@_rangesep_tl
6139 \@@_get_rf_opt_tl:neeN { namefont }
6140 { \l_@@_label_type_a_tl }
6141 { \l_@@_ref_language_tl }
6142 \l_@@_namefont_tl
6143 \@@_get_rf_opt_tl:neeN { reffont }
6144 { \l_@@_label_type_a_tl }
6145 { \l_@@_ref_language_tl }
6146 \l_@@_reffont_tl
6147 \@@_get_rf_opt_tl:neeN { endrangefunc }
6148 { \l_@@_label_type_a_tl }
6149 { \l_@@_ref_language_tl }
6150 \l_@@_endrangefunc_tl
6151 \@@_get_rf_opt_tl:neeN { endrangeprop }
6152 { \l_@@_label_type_a_tl }
6153 { \l_@@_ref_language_tl }
6154 \l_@@_endrangeprop_tl
6155 \@@_get_rf_opt_bool:nneeN { cap } { false }
6156 { \l_@@_label_type_a_tl }
6157 { \l_@@_ref_language_tl }
6158 \l_@@_cap_bool
6159 \@@_get_rf_opt_bool:nneeN { abbrev } { false }
6160 { \l_@@_label_type_a_tl }
6161 { \l_@@_ref_language_tl }
6162 \l_@@_abbrev_bool
6163 \@@_get_rf_opt_bool:nneeN { rangetopair } { true }
6164 { \l_@@_label_type_a_tl }
6165 { \l_@@_ref_language_tl }
6166 \l_@@_rangetopair_bool
6167 \@@_get_rf_opt_seq:neeN { refbounds-first }
6168 { \l_@@_label_type_a_tl }
6169 { \l_@@_ref_language_tl }
6170 \l_@@_refbounds_first_seq
6171 \@@_get_rf_opt_seq:neeN { refbounds-first-sg }
6172 { \l_@@_label_type_a_tl }
6173 { \l_@@_ref_language_tl }
6174 \l_@@_refbounds_first_sg_seq
6175 \@@_get_rf_opt_seq:neeN { refbounds-first-pb }
6176 { \l_@@_label_type_a_tl }
6177 { \l_@@_ref_language_tl }
6178 \l_@@_refbounds_first_pb_seq
6179 \@@_get_rf_opt_seq:neeN { refbounds-first-rb }
6180 { \l_@@_label_type_a_tl }
6181 { \l_@@_ref_language_tl }
6182 \l_@@_refbounds_first_rb_seq
6183 \@@_get_rf_opt_seq:neeN { refbounds-mid }
6184 { \l_@@_label_type_a_tl }
6185 { \l_@@_ref_language_tl }
6186 \l_@@_refbounds_mid_seq
6187 \@@_get_rf_opt_seq:neeN { refbounds-mid-rb }
6188 { \l_@@_label_type_a_tl }
6189 { \l_@@_ref_language_tl }
6190 \l_@@_refbounds_mid_rb_seq
6191 \@@_get_rf_opt_seq:neeN { refbounds-mid-re }
6192 { \l_@@_label_type_a_tl }
6193 { \l_@@_ref_language_tl }
6194 \l_@@_refbounds_mid_re_seq
6195 \@@_get_rf_opt_seq:neeN { refbounds-last }
6196 { \l_@@_label_type_a_tl }
6197 { \l_@@_ref_language_tl }
6198 \l_@@_refbounds_last_seq
6199 \@@_get_rf_opt_seq:neeN { refbounds-last-pe }
6200 { \l_@@_label_type_a_tl }
6201 { \l_@@_ref_language_tl }
6202 \l_@@_refbounds_last_pe_seq
6203 \@@_get_rf_opt_seq:neeN { refbounds-last-re }
6204 { \l_@@_label_type_a_tl }
6205 { \l_@@_ref_language_tl }
6206 \l_@@_refbounds_last_re_seq
6207 }
6208 % Here we send this to a couple of auxiliary functions.
6209 \bool_if:NTF \l_@@_last_of_type_bool
6210 % There exists no next label of the same type as the current.
6211 { \@@_typeset_refs_last_of_type: }
6212 % There exists a next label of the same type as the current.
6213 { \@@_typeset_refs_not_last_of_type: }
6214 }
6215 }
6216 % \end{macrocode}
6217 % \end{macro}
6218 %
6219 %
6220 % This is actually the one meaningful ``big branching'' we can do while
6221 % processing the label stack: i) the ``current'' label is the last of its type
6222 % block; or ii) the ``current'' label is \emph{not} the last of its type
6223 % block. Indeed, as mentioned above, quite a number of things can only be
6224 % decided when the type block ends, and we only know this when we look at the
6225 % ``next'' label and find something of a different ``type'' (loose here, maybe
6226 % different definition status, maybe end of stack). So, though this is not
6227 % very strict, \cs{@@_typeset_refs_last_of_type:} is more of a ``wrapping
6228 % up'' function, and it is indeed the one which does the actual typesetting,
6229 % while \cs{@@_typeset_refs_not_last_of_type:} is more of an
6230 % ``accumulation'' function.
6231 %
6232 %
6233 % \begin{macro}{\@@_typeset_refs_last_of_type:}
6234 % Handles typesetting when the current label is the last of its type.
6235 % \begin{macrocode}
6236 \cs_new_protected:Npn \@@_typeset_refs_last_of_type:
6237 {
6238 % Process the current label to the current queue.
6239 \int_case:nnF { \l_@@_label_count_int }
6240 {
6241 % It is the last label of its type, but also the first one, and that's
6242 % what matters here: just store it.
6243 % Test: `zc-typeset01.lvt': "Last of type: single"
6244 { 0 }
6245 {
6246 \tl_set:NV \l_@@_type_first_label_tl
6247 \l_@@_label_a_tl
6248 \tl_set:NV \l_@@_type_first_label_type_tl
6249 \l_@@_label_type_a_tl
6250 \seq_set_eq:NN \l_@@_type_first_refbounds_seq
6251 \l_@@_refbounds_first_sg_seq
6252 \bool_set_true:N \l_@@_type_first_refbounds_set_bool
6253 }
6254 % The last is the second: we have a pair (if not repeated).
6255 % Test: `zc-typeset01.lvt': "Last of type: pair"
6256 { 1 }
6257 {
6258 \int_compare:nNnTF { \l_@@_range_same_count_int } = { 1 }
6259 {
6260 \seq_set_eq:NN \l_@@_type_first_refbounds_seq
6261 \l_@@_refbounds_first_sg_seq
6262 \bool_set_true:N \l_@@_type_first_refbounds_set_bool
6263 }
6264 {
6265 \tl_put_right:Ne \l_@@_typeset_queue_curr_tl
6266 {
6267 \exp_not:V \l_@@_pairsep_tl
6268 \@@_get_ref:VN \l_@@_label_a_tl
6269 \l_@@_refbounds_last_pe_seq
6270 }
6271 \seq_set_eq:NN \l_@@_type_first_refbounds_seq
6272 \l_@@_refbounds_first_pb_seq
6273 \bool_set_true:N \l_@@_type_first_refbounds_set_bool
6274 }
6275 }
6276 }
6277 % Last is third or more of its type: without repetition, we'd have the
6278 % last element on a list, but control for possible repetition.
6279 {
6280 \int_case:nnF { \l_@@_range_count_int }
6281 {
6282 % There was no range going on.
6283 % Test: `zc-typeset01.lvt': "Last of type: not range"
6284 { 0 }
6285 {
6286 \int_compare:nNnTF { \l_@@_ref_count_int } < { 2 }
6287 {
6288 \tl_put_right:Ne \l_@@_typeset_queue_curr_tl
6289 {
6290 \exp_not:V \l_@@_pairsep_tl
6291 \@@_get_ref:VN \l_@@_label_a_tl
6292 \l_@@_refbounds_last_pe_seq
6293 }
6294 }
6295 {
6296 \tl_put_right:Ne \l_@@_typeset_queue_curr_tl
6297 {
6298 \exp_not:V \l_@@_lastsep_tl
6299 \@@_get_ref:VN \l_@@_label_a_tl
6300 \l_@@_refbounds_last_seq
6301 }
6302 }
6303 }
6304 % Last in the range is also the second in it.
6305 % Test: `zc-typeset01.lvt': "Last of type: pair in sequence"
6306 { 1 }
6307 {
6308 \int_compare:nNnTF
6309 { \l_@@_range_same_count_int } = { 1 }
6310 {
6311 % We know `range_beg_is_first_bool' is false, since this is
6312 % the second element in the range, but the third or more in
6313 % the type list.
6314 \tl_put_right:Ne \l_@@_typeset_queue_curr_tl
6315 {
6316 \exp_not:V \l_@@_pairsep_tl
6317 \@@_get_ref:VN
6318 \l_@@_range_beg_label_tl
6319 \l_@@_refbounds_last_pe_seq
6320 }
6321 \seq_set_eq:NN \l_@@_type_first_refbounds_seq
6322 \l_@@_refbounds_first_pb_seq
6323 \bool_set_true:N
6324 \l_@@_type_first_refbounds_set_bool
6325 }
6326 {
6327 \tl_put_right:Ne \l_@@_typeset_queue_curr_tl
6328 {
6329 \exp_not:V \l_@@_listsep_tl
6330 \@@_get_ref:VN
6331 \l_@@_range_beg_label_tl
6332 \l_@@_refbounds_mid_seq
6333 \exp_not:V \l_@@_lastsep_tl
6334 \@@_get_ref:VN \l_@@_label_a_tl
6335 \l_@@_refbounds_last_seq
6336 }
6337 }
6338 }
6339 }
6340 % Last in the range is third or more in it.
6341 {
6342 \int_case:nnF
6343 {
6344 \l_@@_range_count_int -
6345 \l_@@_range_same_count_int
6346 }
6347 {
6348 % Repetition, not a range.
6349 % Test: `zc-typeset01.lvt': "Last of type: range to one"
6350 { 0 }
6351 {
6352 % If `range_beg_is_first_bool' is true, it means it was also
6353 % the first of the type, and hence its typesetting was
6354 % already handled, and we just have to set refbounds.
6355 \bool_if:NTF \l_@@_range_beg_is_first_bool
6356 {
6357 \seq_set_eq:NN \l_@@_type_first_refbounds_seq
6358 \l_@@_refbounds_first_sg_seq
6359 \bool_set_true:N
6360 \l_@@_type_first_refbounds_set_bool
6361 }
6362 {
6363 \int_compare:nNnTF
6364 { \l_@@_ref_count_int } < { 2 }
6365 {
6366 \tl_put_right:Ne \l_@@_typeset_queue_curr_tl
6367 {
6368 \exp_not:V \l_@@_pairsep_tl
6369 \@@_get_ref:VN
6370 \l_@@_range_beg_label_tl
6371 \l_@@_refbounds_last_pe_seq
6372 }
6373 }
6374 {
6375 \tl_put_right:Ne \l_@@_typeset_queue_curr_tl
6376 {
6377 \exp_not:V \l_@@_lastsep_tl
6378 \@@_get_ref:VN
6379 \l_@@_range_beg_label_tl
6380 \l_@@_refbounds_last_seq
6381 }
6382 }
6383 }
6384 }
6385 % A `range', but with no skipped value, treat as pair if range
6386 % started with first of type, otherwise as list.
6387 % Test: `zc-typeset01.lvt': "Last of type: range to pair"
6388 { 1 }
6389 {
6390 % Ditto.
6391 \bool_if:NTF \l_@@_range_beg_is_first_bool
6392 {
6393 \seq_set_eq:NN \l_@@_type_first_refbounds_seq
6394 \l_@@_refbounds_first_pb_seq
6395 \bool_set_true:N
6396 \l_@@_type_first_refbounds_set_bool
6397 \tl_put_right:Ne \l_@@_typeset_queue_curr_tl
6398 {
6399 \exp_not:V \l_@@_pairsep_tl
6400 \@@_get_ref:VN \l_@@_label_a_tl
6401 \l_@@_refbounds_last_pe_seq
6402 }
6403 }
6404 {
6405 \tl_put_right:Ne \l_@@_typeset_queue_curr_tl
6406 {
6407 \exp_not:V \l_@@_listsep_tl
6408 \@@_get_ref:VN
6409 \l_@@_range_beg_label_tl
6410 \l_@@_refbounds_mid_seq
6411 }
6412 \tl_put_right:Ne \l_@@_typeset_queue_curr_tl
6413 {
6414 \exp_not:V \l_@@_lastsep_tl
6415 \@@_get_ref:VN \l_@@_label_a_tl
6416 \l_@@_refbounds_last_seq
6417 }
6418 }
6419 }
6420 }
6421 {
6422 % An actual range.
6423 % Test: `zc-typeset01.lvt': "Last of type: range"
6424 % Ditto.
6425 \bool_if:NTF \l_@@_range_beg_is_first_bool
6426 {
6427 \seq_set_eq:NN \l_@@_type_first_refbounds_seq
6428 \l_@@_refbounds_first_rb_seq
6429 \bool_set_true:N
6430 \l_@@_type_first_refbounds_set_bool
6431 }
6432 {
6433 \int_compare:nNnTF
6434 { \l_@@_ref_count_int } < { 2 }
6435 {
6436 \tl_put_right:Ne \l_@@_typeset_queue_curr_tl
6437 {
6438 \exp_not:V \l_@@_pairsep_tl
6439 \@@_get_ref:VN
6440 \l_@@_range_beg_label_tl
6441 \l_@@_refbounds_mid_rb_seq
6442 }
6443 \seq_set_eq:NN
6444 \l_@@_type_first_refbounds_seq
6445 \l_@@_refbounds_first_pb_seq
6446 \bool_set_true:N
6447 \l_@@_type_first_refbounds_set_bool
6448 }
6449 {
6450 \tl_put_right:Ne \l_@@_typeset_queue_curr_tl
6451 {
6452 \exp_not:V \l_@@_lastsep_tl
6453 \@@_get_ref:VN
6454 \l_@@_range_beg_label_tl
6455 \l_@@_refbounds_mid_rb_seq
6456 }
6457 }
6458 }
6459 \bool_lazy_and:nnTF
6460 { ! \tl_if_empty_p:N \l_@@_endrangefunc_tl }
6461 { \cs_if_exist_p:c { \l_@@_endrangefunc_tl :VVN } }
6462 {
6463 \use:c { \l_@@_endrangefunc_tl :VVN }
6464 \l_@@_range_beg_label_tl
6465 \l_@@_label_a_tl
6466 \l_@@_range_end_ref_tl
6467 \tl_put_right:Ne \l_@@_typeset_queue_curr_tl
6468 {
6469 \exp_not:V \l_@@_rangesep_tl
6470 \@@_get_ref_endrange:VVN
6471 \l_@@_label_a_tl
6472 \l_@@_range_end_ref_tl
6473 \l_@@_refbounds_last_re_seq
6474 }
6475 }
6476 {
6477 \tl_put_right:Ne \l_@@_typeset_queue_curr_tl
6478 {
6479 \exp_not:V \l_@@_rangesep_tl
6480 \@@_get_ref:VN \l_@@_label_a_tl
6481 \l_@@_refbounds_last_re_seq
6482 }
6483 }
6484 }
6485 }
6486 }
6487 % Handle "range" option. The idea is simple: if the queue is not empty,
6488 % we replace it with the end of the range (or pair). We can still
6489 % retrieve the end of the range from `label_a' since we know to be
6490 % processing the last label of its type at this point.
6491 \bool_if:NT \l_@@_typeset_range_bool
6492 {
6493 \tl_if_empty:NTF \l_@@_typeset_queue_curr_tl
6494 {
6495 \zref@ifrefundefined { \l_@@_type_first_label_tl }
6496 { }
6497 {
6498 \msg_warning:nne { zref-clever } { single-element-range }
6499 { \l_@@_type_first_label_type_tl }
6500 }
6501 }
6502 {
6503 \bool_set_false:N \l_@@_next_maybe_range_bool
6504 \bool_if:NT \l_@@_rangetopair_bool
6505 {
6506 \zref@ifrefundefined { \l_@@_type_first_label_tl }
6507 { }
6508 {
6509 \@@_labels_in_sequence:nn
6510 { \l_@@_type_first_label_tl }
6511 { \l_@@_label_a_tl }
6512 }
6513 }
6514 % Test: `zc-typeset01.lvt': "Last of type: option range"
6515 % Test: `zc-typeset01.lvt': "Last of type: option range to pair"
6516 \bool_if:NTF \l_@@_next_maybe_range_bool
6517 {
6518 \tl_set:Ne \l_@@_typeset_queue_curr_tl
6519 {
6520 \exp_not:V \l_@@_pairsep_tl
6521 \@@_get_ref:VN \l_@@_label_a_tl
6522 \l_@@_refbounds_last_pe_seq
6523 }
6524 \seq_set_eq:NN \l_@@_type_first_refbounds_seq
6525 \l_@@_refbounds_first_pb_seq
6526 \bool_set_true:N \l_@@_type_first_refbounds_set_bool
6527 }
6528 {
6529 \bool_lazy_and:nnTF
6530 { ! \tl_if_empty_p:N \l_@@_endrangefunc_tl }
6531 { \cs_if_exist_p:c { \l_@@_endrangefunc_tl :VVN } }
6532 {
6533 % We must get `type_first_label_tl' instead of
6534 % `range_beg_label_tl' here, since it is not necessary
6535 % that the first of type was actually starting a range for
6536 % the `range' option to be used.
6537 \use:c { \l_@@_endrangefunc_tl :VVN }
6538 \l_@@_type_first_label_tl
6539 \l_@@_label_a_tl
6540 \l_@@_range_end_ref_tl
6541 \tl_set:Ne \l_@@_typeset_queue_curr_tl
6542 {
6543 \exp_not:V \l_@@_rangesep_tl
6544 \@@_get_ref_endrange:VVN
6545 \l_@@_label_a_tl
6546 \l_@@_range_end_ref_tl
6547 \l_@@_refbounds_last_re_seq
6548 }
6549 }
6550 {
6551 \tl_set:Ne \l_@@_typeset_queue_curr_tl
6552 {
6553 \exp_not:V \l_@@_rangesep_tl
6554 \@@_get_ref:VN \l_@@_label_a_tl
6555 \l_@@_refbounds_last_re_seq
6556 }
6557 }
6558 \seq_set_eq:NN \l_@@_type_first_refbounds_seq
6559 \l_@@_refbounds_first_rb_seq
6560 \bool_set_true:N \l_@@_type_first_refbounds_set_bool
6561 }
6562 }
6563 }
6564 % If none of the special cases for the first of type refbounds have been
6565 % set, do it.
6566 \bool_if:NF \l_@@_type_first_refbounds_set_bool
6567 {
6568 \seq_set_eq:NN \l_@@_type_first_refbounds_seq
6569 \l_@@_refbounds_first_seq
6570 }
6571 % Now that the type block is finished, we can add the name and the first
6572 % ref to the queue. Also, if "typeset" option is not "both", handle it
6573 % here as well.
6574 \@@_type_name_setup:
6575 \bool_if:nTF
6576 { \l_@@_typeset_ref_bool && \l_@@_typeset_name_bool }
6577 {
6578 \tl_put_left:Ne \l_@@_typeset_queue_curr_tl
6579 { \@@_get_ref_first: }
6580 }
6581 {
6582 \bool_if:NTF \l_@@_typeset_ref_bool
6583 {
6584 % Test: `zc-typeset01.lvt': "Last of type: option typeset ref"
6585 \tl_put_left:Ne \l_@@_typeset_queue_curr_tl
6586 {
6587 \@@_get_ref:VN \l_@@_type_first_label_tl
6588 \l_@@_type_first_refbounds_seq
6589 }
6590 }
6591 {
6592 \bool_if:NTF \l_@@_typeset_name_bool
6593 {
6594 % Test: `zc-typeset01.lvt': "Last of type: option typeset name"
6595 \tl_set:Ne \l_@@_typeset_queue_curr_tl
6596 {
6597 \bool_if:NTF \l_@@_name_in_link_bool
6598 {
6599 \exp_not:N \group_begin:
6600 \exp_not:V \l_@@_namefont_tl
6601 \@@_hyperlink:nnn
6602 {
6603 \@@_extract_url_unexp:V
6604 \l_@@_type_first_label_tl
6605 }
6606 {
6607 \@@_extract_unexp:Vnn
6608 \l_@@_type_first_label_tl
6609 { anchor } { }
6610 }
6611 { \exp_not:V \l_@@_type_name_tl }
6612 \exp_not:N \group_end:
6613 }
6614 {
6615 \exp_not:N \group_begin:
6616 \exp_not:V \l_@@_namefont_tl
6617 \exp_not:V \l_@@_type_name_tl
6618 \exp_not:N \group_end:
6619 }
6620 }
6621 }
6622 {
6623 % Logically, this case would correspond to "typeset=none", but
6624 % it should not occur, given that the options are set up to
6625 % typeset either "ref" or "name". Still, leave here a
6626 % sensible fallback, equal to the behavior of "both".
6627 % Test: `zc-typeset01.lvt': "Last of type: option typeset none"
6628 \tl_put_left:Ne \l_@@_typeset_queue_curr_tl
6629 { \@@_get_ref_first: }
6630 }
6631 }
6632 }
6633 % Typeset the previous type block, if there is one.
6634 \int_compare:nNnT { \l_@@_type_count_int } > { 0 }
6635 {
6636 \int_compare:nNnT { \l_@@_type_count_int } > { 1 }
6637 { \l_@@_tlistsep_tl }
6638 \l_@@_typeset_queue_prev_tl
6639 }
6640 % Extra log for testing.
6641 \bool_if:NT \l_@@_verbose_testing_bool
6642 { \tl_show:N \l_@@_typeset_queue_curr_tl }
6643 % Wrap up loop, or prepare for next iteration.
6644 \bool_if:NTF \l_@@_typeset_last_bool
6645 {
6646 % We are finishing, typeset the current queue.
6647 \int_case:nnF { \l_@@_type_count_int }
6648 {
6649 % Single type.
6650 % Test: `zc-typeset01.lvt': "Last of type: single type"
6651 { 0 }
6652 { \l_@@_typeset_queue_curr_tl }
6653 % Pair of types.
6654 % Test: `zc-typeset01.lvt': "Last of type: pair of types"
6655 { 1 }
6656 {
6657 \l_@@_tpairsep_tl
6658 \l_@@_typeset_queue_curr_tl
6659 }
6660 }
6661 {
6662 % Last in list of types.
6663 % Test: `zc-typeset01.lvt': "Last of type: list of types"
6664 \l_@@_tlastsep_tl
6665 \l_@@_typeset_queue_curr_tl
6666 }
6667 % And nudge in case of multitype reference.
6668 \bool_lazy_all:nT
6669 {
6670 { \l_@@_nudge_enabled_bool }
6671 { \l_@@_nudge_multitype_bool }
6672 { \int_compare_p:nNn { \l_@@_type_count_int } > { 0 } }
6673 }
6674 { \msg_warning:nn { zref-clever } { nudge-multitype } }
6675 }
6676 {
6677 % There are further labels, set variables for next iteration.
6678 \tl_set_eq:NN \l_@@_typeset_queue_prev_tl
6679 \l_@@_typeset_queue_curr_tl
6680 \tl_clear:N \l_@@_typeset_queue_curr_tl
6681 \tl_clear:N \l_@@_type_first_label_tl
6682 \tl_clear:N \l_@@_type_first_label_type_tl
6683 \tl_clear:N \l_@@_range_beg_label_tl
6684 \tl_clear:N \l_@@_range_end_ref_tl
6685 \int_zero:N \l_@@_label_count_int
6686 \int_zero:N \l_@@_ref_count_int
6687 \int_incr:N \l_@@_type_count_int
6688 \int_zero:N \l_@@_range_count_int
6689 \int_zero:N \l_@@_range_same_count_int
6690 \bool_set_false:N \l_@@_range_beg_is_first_bool
6691 \bool_set_false:N \l_@@_type_first_refbounds_set_bool
6692 }
6693 }
6694 % \end{macrocode}
6695 % \end{macro}
6696 %
6697 %
6698 % \begin{macro}{\@@_typeset_refs_not_last_of_type:}
6699 % Handles typesetting when the current label is not the last of its type.
6700 % \begin{macrocode}
6701 \cs_new_protected:Npn \@@_typeset_refs_not_last_of_type:
6702 {
6703 % Signal if next label may form a range with the current one (only
6704 % considered if compression is enabled in the first place).
6705 \bool_set_false:N \l_@@_next_maybe_range_bool
6706 \bool_set_false:N \l_@@_next_is_same_bool
6707 \bool_if:NT \l_@@_typeset_compress_bool
6708 {
6709 \zref@ifrefundefined { \l_@@_label_a_tl }
6710 { }
6711 {
6712 \@@_labels_in_sequence:nn
6713 { \l_@@_label_a_tl } { \l_@@_label_b_tl }
6714 }
6715 }
6716 % Process the current label to the current queue.
6717 \int_compare:nNnTF { \l_@@_label_count_int } = { 0 }
6718 {
6719 % Current label is the first of its type (also not the last, but it
6720 % doesn't matter here): just store the label.
6721 \tl_set:NV \l_@@_type_first_label_tl
6722 \l_@@_label_a_tl
6723 \tl_set:NV \l_@@_type_first_label_type_tl
6724 \l_@@_label_type_a_tl
6725 \int_incr:N \l_@@_ref_count_int
6726 % If the next label may be part of a range, signal it (we deal with it
6727 % as the "first", and must do it there, to handle hyperlinking), but
6728 % also step the range counters.
6729 % Test: `zc-typeset01.lvt': "Not last of type: first is range"
6730 \bool_if:NT \l_@@_next_maybe_range_bool
6731 {
6732 \bool_set_true:N \l_@@_range_beg_is_first_bool
6733 \tl_set:NV \l_@@_range_beg_label_tl
6734 \l_@@_label_a_tl
6735 \tl_clear:N \l_@@_range_end_ref_tl
6736 \int_incr:N \l_@@_range_count_int
6737 \bool_if:NT \l_@@_next_is_same_bool
6738 { \int_incr:N \l_@@_range_same_count_int }
6739 }
6740 }
6741 {
6742 % Current label is neither the first (nor the last) of its type.
6743 \bool_if:NTF \l_@@_next_maybe_range_bool
6744 {
6745 % Starting, or continuing a range.
6746 \int_compare:nNnTF
6747 { \l_@@_range_count_int } = { 0 }
6748 {
6749 % There was no range going, we are starting one.
6750 \tl_set:NV \l_@@_range_beg_label_tl
6751 \l_@@_label_a_tl
6752 \tl_clear:N \l_@@_range_end_ref_tl
6753 \int_incr:N \l_@@_range_count_int
6754 \bool_if:NT \l_@@_next_is_same_bool
6755 { \int_incr:N \l_@@_range_same_count_int }
6756 }
6757 {
6758 % Second or more in the range, but not the last.
6759 \int_incr:N \l_@@_range_count_int
6760 \bool_if:NT \l_@@_next_is_same_bool
6761 { \int_incr:N \l_@@_range_same_count_int }
6762 }
6763 }
6764 {
6765 % Next element is not in sequence: there was no range, or we are
6766 % closing one.
6767 \int_case:nnF { \l_@@_range_count_int }
6768 {
6769 % There was no range going on.
6770 % Test: `zc-typeset01.lvt': "Not last of type: no range"
6771 { 0 }
6772 {
6773 \int_incr:N \l_@@_ref_count_int
6774 \tl_put_right:Ne \l_@@_typeset_queue_curr_tl
6775 {
6776 \exp_not:V \l_@@_listsep_tl
6777 \@@_get_ref:VN \l_@@_label_a_tl
6778 \l_@@_refbounds_mid_seq
6779 }
6780 }
6781 % Last is second in the range: if `range_same_count' is also
6782 % `1', it's a repetition (drop it), otherwise, it's a "pair
6783 % within a list", treat as list.
6784 % Test: `zc-typeset01.lvt': "Not last of type: range pair to one"
6785 % Test: `zc-typeset01.lvt': "Not last of type: range pair"
6786 { 1 }
6787 {
6788 \bool_if:NTF \l_@@_range_beg_is_first_bool
6789 {
6790 \seq_set_eq:NN \l_@@_type_first_refbounds_seq
6791 \l_@@_refbounds_first_seq
6792 \bool_set_true:N
6793 \l_@@_type_first_refbounds_set_bool
6794 }
6795 {
6796 \int_incr:N \l_@@_ref_count_int
6797 \tl_put_right:Ne \l_@@_typeset_queue_curr_tl
6798 {
6799 \exp_not:V \l_@@_listsep_tl
6800 \@@_get_ref:VN
6801 \l_@@_range_beg_label_tl
6802 \l_@@_refbounds_mid_seq
6803 }
6804 }
6805 \int_compare:nNnF
6806 { \l_@@_range_same_count_int } = { 1 }
6807 {
6808 \int_incr:N \l_@@_ref_count_int
6809 \tl_put_right:Ne \l_@@_typeset_queue_curr_tl
6810 {
6811 \exp_not:V \l_@@_listsep_tl
6812 \@@_get_ref:VN
6813 \l_@@_label_a_tl
6814 \l_@@_refbounds_mid_seq
6815 }
6816 }
6817 }
6818 }
6819 {
6820 % Last is third or more in the range: if `range_count' and
6821 % `range_same_count' are the same, its a repetition (drop it),
6822 % if they differ by `1', its a list, if they differ by more,
6823 % it is a real range.
6824 \int_case:nnF
6825 {
6826 \l_@@_range_count_int -
6827 \l_@@_range_same_count_int
6828 }
6829 {
6830 % Test: `zc-typeset01.lvt': "Not last of type: range to one"
6831 { 0 }
6832 {
6833 \bool_if:NTF \l_@@_range_beg_is_first_bool
6834 {
6835 \seq_set_eq:NN
6836 \l_@@_type_first_refbounds_seq
6837 \l_@@_refbounds_first_seq
6838 \bool_set_true:N
6839 \l_@@_type_first_refbounds_set_bool
6840 }
6841 {
6842 \int_incr:N \l_@@_ref_count_int
6843 \tl_put_right:Ne \l_@@_typeset_queue_curr_tl
6844 {
6845 \exp_not:V \l_@@_listsep_tl
6846 \@@_get_ref:VN
6847 \l_@@_range_beg_label_tl
6848 \l_@@_refbounds_mid_seq
6849 }
6850 }
6851 }
6852 % Test: `zc-typeset01.lvt': "Not last of type: range to pair"
6853 { 1 }
6854 {
6855 \bool_if:NTF \l_@@_range_beg_is_first_bool
6856 {
6857 \seq_set_eq:NN
6858 \l_@@_type_first_refbounds_seq
6859 \l_@@_refbounds_first_seq
6860 \bool_set_true:N
6861 \l_@@_type_first_refbounds_set_bool
6862 }
6863 {
6864 \int_incr:N \l_@@_ref_count_int
6865 \tl_put_right:Ne \l_@@_typeset_queue_curr_tl
6866 {
6867 \exp_not:V \l_@@_listsep_tl
6868 \@@_get_ref:VN
6869 \l_@@_range_beg_label_tl
6870 \l_@@_refbounds_mid_seq
6871 }
6872 }
6873 \int_incr:N \l_@@_ref_count_int
6874 \tl_put_right:Ne \l_@@_typeset_queue_curr_tl
6875 {
6876 \exp_not:V \l_@@_listsep_tl
6877 \@@_get_ref:VN \l_@@_label_a_tl
6878 \l_@@_refbounds_mid_seq
6879 }
6880 }
6881 }
6882 {
6883 % Test: `zc-typeset01.lvt': "Not last of type: range"
6884 \bool_if:NTF \l_@@_range_beg_is_first_bool
6885 {
6886 \seq_set_eq:NN
6887 \l_@@_type_first_refbounds_seq
6888 \l_@@_refbounds_first_rb_seq
6889 \bool_set_true:N
6890 \l_@@_type_first_refbounds_set_bool
6891 }
6892 {
6893 \int_incr:N \l_@@_ref_count_int
6894 \tl_put_right:Ne \l_@@_typeset_queue_curr_tl
6895 {
6896 \exp_not:V \l_@@_listsep_tl
6897 \@@_get_ref:VN
6898 \l_@@_range_beg_label_tl
6899 \l_@@_refbounds_mid_rb_seq
6900 }
6901 }
6902 % For the purposes of the serial comma, and thus for the
6903 % distinction of `lastsep' and `pairsep', a "range" counts
6904 % as one. Since `range_beg' has already been counted
6905 % (here or with the first of type), we refrain from
6906 % incrementing `ref_count_int'.
6907 \bool_lazy_and:nnTF
6908 { ! \tl_if_empty_p:N \l_@@_endrangefunc_tl }
6909 { \cs_if_exist_p:c { \l_@@_endrangefunc_tl :VVN } }
6910 {
6911 \use:c { \l_@@_endrangefunc_tl :VVN }
6912 \l_@@_range_beg_label_tl
6913 \l_@@_label_a_tl
6914 \l_@@_range_end_ref_tl
6915 \tl_put_right:Ne \l_@@_typeset_queue_curr_tl
6916 {
6917 \exp_not:V \l_@@_rangesep_tl
6918 \@@_get_ref_endrange:VVN
6919 \l_@@_label_a_tl
6920 \l_@@_range_end_ref_tl
6921 \l_@@_refbounds_mid_re_seq
6922 }
6923 }
6924 {
6925 \tl_put_right:Ne \l_@@_typeset_queue_curr_tl
6926 {
6927 \exp_not:V \l_@@_rangesep_tl
6928 \@@_get_ref:VN \l_@@_label_a_tl
6929 \l_@@_refbounds_mid_re_seq
6930 }
6931 }
6932 }
6933 }
6934 % We just closed a range, reset `range_beg_is_first' in case a
6935 % second range for the same type occurs, in which case its
6936 % `range_beg' will no longer be `first'.
6937 \bool_set_false:N \l_@@_range_beg_is_first_bool
6938 % Reset counters.
6939 \int_zero:N \l_@@_range_count_int
6940 \int_zero:N \l_@@_range_same_count_int
6941 }
6942 }
6943 % Step label counter for next iteration.
6944 \int_incr:N \l_@@_label_count_int
6945 }
6946 % \end{macrocode}
6947 % \end{macro}
6948 %
6949 %
6950 %
6951 % \subsection*{Auxiliary functions}
6952 %
6953 % \cs{@@_get_ref:nN} and \cs{@@_get_ref_first:} are the two functions which
6954 % actually build the reference blocks for typesetting. \cs{@@_get_ref:nN}
6955 % handles all references but the first of its type, and \cs{@@_get_ref_first:}
6956 % deals with the first reference of a type. Saying they do ``typesetting'' is
6957 % imprecise though, they actually prepare material to be accumulated in
6958 % \cs{l_@@_typeset_queue_curr_tl} inside \cs{@@_typeset_refs_last_of_type:}
6959 % and \cs{@@_typeset_refs_not_last_of_type:}. And this difference results
6960 % quite crucial for the \TeX{}nical requirements of these functions. This
6961 % because, as we are processing the label stack and accumulating content in
6962 % the queue, we are using a number of variables which are transient to the
6963 % current label, the label properties among them, but not only. Hence, these
6964 % variables \emph{must} be expanded to their current values to be stored in
6965 % the queue. Indeed, \cs{@@_get_ref:nN} and \cs{@@_get_ref_first:} get
6966 % called, as they must, in the context of \texttt{e} type expansions. But we
6967 % don't want to expand the values of the variables themselves, so we need to
6968 % get current values, but stop expansion after that. In particular, reference
6969 % options given by the user should reach the stream for its final typesetting
6970 % (when the queue itself gets typeset) \emph{unmodified} (``no manipulation'',
6971 % to use the \texttt{n} signature jargon). We also need to prevent premature
6972 % expansion of material that can't be expanded at this point (e.g. grouping,
6973 % \cs{zref@default} or \cs[replace=false]{hyper@@link}). In a nutshell, the
6974 % job of these two functions is putting the pieces in place, but with proper
6975 % expansion control.
6976 %
6977 %
6978 % \begin{macro}{\@@_ref_default:, \@@_name_default:}
6979 % Default values for undefined references and undefined type names,
6980 % respectively. We are ultimately using \cs{zref@default}, but calls to it
6981 % should be made through these internal functions, according to the case.
6982 % As a bonus, we don't need to protect them with \cs{exp_not:N}, as
6983 % \cs{zref@default} would require, since we already define them protected.
6984 % \begin{macrocode}
6985 \cs_new_protected:Npn \@@_ref_default:
6986 { \zref@default }
6987 \cs_new_protected:Npn \@@_name_default:
6988 { \zref@default }
6989 % \end{macrocode}
6990 % \end{macro}
6991 %
6992 %
6993 % \begin{macro}{\@@_get_ref:nN}
6994 % Handles a complete reference block to be accumulated in the ``queue'',
6995 % including refbounds, and hyperlinking. For use with all labels, except
6996 % the first of its type, which is done by \cs{@@_get_ref_first:}, and the
6997 % last of a range, which is done by \cs{@@_get_ref_endrange:nnN}.
6998 % \begin{syntax}
6999 % \cs{@@_get_ref:nN} \Arg{label} \Arg{refbounds}
7000 % \end{syntax}
7001 % \begin{macrocode}
7002 \cs_new:Npn \@@_get_ref:nN #1#2
7003 {
7004 \zref@ifrefcontainsprop {#1} { \l_@@_ref_property_tl }
7005 {
7006 \bool_if:nTF
7007 {
7008 \l_@@_hyperlink_bool &&
7009 ! \l_@@_link_star_bool
7010 }
7011 {
7012 \seq_item:Nn #2 { 1 }
7013 \@@_hyperlink:nnn
7014 { \@@_extract_url_unexp:n {#1} }
7015 { \@@_extract_unexp:nnn {#1} { anchor } { } }
7016 {
7017 \seq_item:Nn #2 { 2 }
7018 \exp_not:N \group_begin:
7019 \exp_not:V \l_@@_reffont_tl
7020 \@@_extract_unexp:nvn {#1}
7021 { l_@@_ref_property_tl } { }
7022 \exp_not:N \group_end:
7023 \seq_item:Nn #2 { 3 }
7024 }
7025 \seq_item:Nn #2 { 4 }
7026 }
7027 {
7028 \seq_item:Nn #2 { 1 }
7029 \seq_item:Nn #2 { 2 }
7030 \exp_not:N \group_begin:
7031 \exp_not:V \l_@@_reffont_tl
7032 \@@_extract_unexp:nvn {#1}
7033 { l_@@_ref_property_tl } { }
7034 \exp_not:N \group_end:
7035 \seq_item:Nn #2 { 3 }
7036 \seq_item:Nn #2 { 4 }
7037 }
7038 }
7039 { \@@_ref_default: }
7040 }
7041 \cs_generate_variant:Nn \@@_get_ref:nN { VN }
7042 % \end{macrocode}
7043 % \end{macro}
7044 %
7045 % \begin{macro}{\@@_get_ref_endrange:nnN}
7046 % \begin{syntax}
7047 % \cs{@@_get_ref_endrange:nnN} \Arg{label} \Arg{reference} \Arg{refbounds}
7048 % \end{syntax}
7049 % \begin{macrocode}
7050 \cs_new:Npn \@@_get_ref_endrange:nnN #1#2#3
7051 {
7052 \str_if_eq:nnTF {#2} { zc@missingproperty }
7053 { \@@_ref_default: }
7054 {
7055 \bool_if:nTF
7056 {
7057 \l_@@_hyperlink_bool &&
7058 ! \l_@@_link_star_bool
7059 }
7060 {
7061 \seq_item:Nn #3 { 1 }
7062 \@@_hyperlink:nnn
7063 { \@@_extract_url_unexp:n {#1} }
7064 { \@@_extract_unexp:nnn {#1} { anchor } { } }
7065 {
7066 \seq_item:Nn #3 { 2 }
7067 \exp_not:N \group_begin:
7068 \exp_not:V \l_@@_reffont_tl
7069 \exp_not:n {#2}
7070 \exp_not:N \group_end:
7071 \seq_item:Nn #3 { 3 }
7072 }
7073 \seq_item:Nn #3 { 4 }
7074 }
7075 {
7076 \seq_item:Nn #3 { 1 }
7077 \seq_item:Nn #3 { 2 }
7078 \exp_not:N \group_begin:
7079 \exp_not:V \l_@@_reffont_tl
7080 \exp_not:n {#2}
7081 \exp_not:N \group_end:
7082 \seq_item:Nn #3 { 3 }
7083 \seq_item:Nn #3 { 4 }
7084 }
7085 }
7086 }
7087 \cs_generate_variant:Nn \@@_get_ref_endrange:nnN { VVN }
7088 % \end{macrocode}
7089 % \end{macro}
7090 %
7091 % \begin{macro}{\@@_get_ref_first:}
7092 % Handles a complete reference block for the first label of its type to be
7093 % accumulated in the ``queue'', including ``pre'' and ``pos'' elements,
7094 % hyperlinking, and the reference type ``name''. It does not receive
7095 % arguments, but relies on being called in the appropriate place in
7096 % \cs{@@_typeset_refs_last_of_type:} where a number of variables are
7097 % expected to be appropriately set for it to consume. Prominently among
7098 % those is \cs{l_@@_type_first_label_tl}, but it also expected to be called
7099 % right after \cs{@@_type_name_setup:} which sets \cs{l_@@_type_name_tl} and
7100 % \cs{l_@@_name_in_link_bool} which it uses.
7101 % \begin{macrocode}
7102 \cs_new:Npn \@@_get_ref_first:
7103 {
7104 \zref@ifrefundefined { \l_@@_type_first_label_tl }
7105 { \@@_ref_default: }
7106 {
7107 \bool_if:NTF \l_@@_name_in_link_bool
7108 {
7109 \zref@ifrefcontainsprop
7110 { \l_@@_type_first_label_tl }
7111 { \l_@@_ref_property_tl }
7112 {
7113 \@@_hyperlink:nnn
7114 {
7115 \@@_extract_url_unexp:V
7116 \l_@@_type_first_label_tl
7117 }
7118 {
7119 \@@_extract_unexp:Vnn
7120 \l_@@_type_first_label_tl { anchor } { }
7121 }
7122 {
7123 \exp_not:N \group_begin:
7124 \exp_not:V \l_@@_namefont_tl
7125 \exp_not:V \l_@@_type_name_tl
7126 \exp_not:N \group_end:
7127 \exp_not:V \l_@@_namesep_tl
7128 \seq_item:Nn \l_@@_type_first_refbounds_seq { 1 }
7129 \seq_item:Nn \l_@@_type_first_refbounds_seq { 2 }
7130 \exp_not:N \group_begin:
7131 \exp_not:V \l_@@_reffont_tl
7132 \@@_extract_unexp:Vvn
7133 \l_@@_type_first_label_tl
7134 { l_@@_ref_property_tl } { }
7135 \exp_not:N \group_end:
7136 \seq_item:Nn \l_@@_type_first_refbounds_seq { 3 }
7137 }
7138 \seq_item:Nn \l_@@_type_first_refbounds_seq { 4 }
7139 }
7140 {
7141 \exp_not:N \group_begin:
7142 \exp_not:V \l_@@_namefont_tl
7143 \exp_not:V \l_@@_type_name_tl
7144 \exp_not:N \group_end:
7145 \exp_not:V \l_@@_namesep_tl
7146 \@@_ref_default:
7147 }
7148 }
7149 {
7150 \bool_if:nTF \l_@@_type_name_missing_bool
7151 {
7152 \@@_name_default:
7153 \exp_not:V \l_@@_namesep_tl
7154 }
7155 {
7156 \exp_not:N \group_begin:
7157 \exp_not:V \l_@@_namefont_tl
7158 \exp_not:V \l_@@_type_name_tl
7159 \exp_not:N \group_end:
7160 \tl_if_empty:NF \l_@@_type_name_tl
7161 { \exp_not:V \l_@@_namesep_tl }
7162 }
7163 \zref@ifrefcontainsprop
7164 { \l_@@_type_first_label_tl }
7165 { \l_@@_ref_property_tl }
7166 {
7167 \bool_if:nTF
7168 {
7169 \l_@@_hyperlink_bool &&
7170 ! \l_@@_link_star_bool
7171 }
7172 {
7173 \seq_item:Nn
7174 \l_@@_type_first_refbounds_seq { 1 }
7175 \@@_hyperlink:nnn
7176 {
7177 \@@_extract_url_unexp:V
7178 \l_@@_type_first_label_tl
7179 }
7180 {
7181 \@@_extract_unexp:Vnn
7182 \l_@@_type_first_label_tl { anchor } { }
7183 }
7184 {
7185 \seq_item:Nn
7186 \l_@@_type_first_refbounds_seq { 2 }
7187 \exp_not:N \group_begin:
7188 \exp_not:V \l_@@_reffont_tl
7189 \@@_extract_unexp:Vvn
7190 \l_@@_type_first_label_tl
7191 { l_@@_ref_property_tl } { }
7192 \exp_not:N \group_end:
7193 \seq_item:Nn
7194 \l_@@_type_first_refbounds_seq { 3 }
7195 }
7196 \seq_item:Nn
7197 \l_@@_type_first_refbounds_seq { 4 }
7198 }
7199 {
7200 \seq_item:Nn \l_@@_type_first_refbounds_seq { 1 }
7201 \seq_item:Nn \l_@@_type_first_refbounds_seq { 2 }
7202 \exp_not:N \group_begin:
7203 \exp_not:V \l_@@_reffont_tl
7204 \@@_extract_unexp:Vvn
7205 \l_@@_type_first_label_tl
7206 { l_@@_ref_property_tl } { }
7207 \exp_not:N \group_end:
7208 \seq_item:Nn \l_@@_type_first_refbounds_seq { 3 }
7209 \seq_item:Nn \l_@@_type_first_refbounds_seq { 4 }
7210 }
7211 }
7212 { \@@_ref_default: }
7213 }
7214 }
7215 }
7216 % \end{macrocode}
7217 % \end{macro}
7218 %
7219 % \begin{macro}{\@@_type_name_setup:}
7220 % Auxiliary function to \cs{@@_typeset_refs_last_of_type:}. It is
7221 % responsible for setting the type name variable \cs{l_@@_type_name_tl},
7222 % \cs{l_@@_name_in_link_bool}, and \cs{l_@@_type_name_missing_bool}. If a
7223 % type name can't be found, \cs{l_@@_type_name_tl} is cleared. The function
7224 % takes no arguments, but is expected to be called in
7225 % \cs{@@_typeset_refs_last_of_type:} right before \cs{@@_get_ref_first:},
7226 % which is the main consumer of the variables it sets, though not the only
7227 % one (and hence this cannot be moved into \cs{@@_get_ref_first:} itself).
7228 % It also expects a number of relevant variables to have been appropriately
7229 % set, and which it uses, prominently \cs{l_@@_type_first_label_type_tl},
7230 % but also the queue itself in \cs{l_@@_typeset_queue_curr_tl}, which should
7231 % be ``ready except for the first label'', and the type counter
7232 % \cs{l_@@_type_count_int}.
7233 % \begin{macrocode}
7234 \cs_new_protected:Npn \@@_type_name_setup:
7235 {
7236 \bool_if:nTF
7237 { \l_@@_typeset_ref_bool && ! \l_@@_typeset_name_bool }
7238 {
7239 % `typeset=ref' / `noname' option
7240 % Probably redundant, since in this case the type name is not being
7241 % typeset. But, for completeness sake:
7242 \tl_clear:N \l_@@_type_name_tl
7243 \bool_set_false:N \l_@@_name_in_link_bool
7244 \bool_set_true:N \l_@@_type_name_missing_bool
7245 }
7246 {
7247 \zref@ifrefundefined { \l_@@_type_first_label_tl }
7248 {
7249 \tl_clear:N \l_@@_type_name_tl
7250 \bool_set_true:N \l_@@_type_name_missing_bool
7251 }
7252 {
7253 \tl_if_eq:NnTF
7254 \l_@@_type_first_label_type_tl { zc@missingtype }
7255 {
7256 \tl_clear:N \l_@@_type_name_tl
7257 \bool_set_true:N \l_@@_type_name_missing_bool
7258 }
7259 {
7260 % Determine whether we should use capitalization,
7261 % abbreviation, and plural.
7262 \bool_lazy_or:nnTF
7263 { \l_@@_cap_bool }
7264 {
7265 \l_@@_capfirst_bool &&
7266 \int_compare_p:nNn { \l_@@_type_count_int } = { 0 }
7267 }
7268 { \tl_set:Nn \l_@@_name_format_tl {Name} }
7269 { \tl_set:Nn \l_@@_name_format_tl {name} }
7270 % If the queue is empty, we have a singular, otherwise,
7271 % plural.
7272 \tl_if_empty:NTF \l_@@_typeset_queue_curr_tl
7273 { \tl_put_right:Nn \l_@@_name_format_tl { -sg } }
7274 { \tl_put_right:Nn \l_@@_name_format_tl { -pl } }
7275 \bool_lazy_and:nnTF
7276 { \l_@@_abbrev_bool }
7277 {
7278 ! \int_compare_p:nNn
7279 { \l_@@_type_count_int } = { 0 } ||
7280 ! \l_@@_noabbrev_first_bool
7281 }
7282 {
7283 \tl_set:NV \l_@@_name_format_fallback_tl
7284 \l_@@_name_format_tl
7285 \tl_put_right:Nn \l_@@_name_format_tl { -ab }
7286 }
7287 { \tl_clear:N \l_@@_name_format_fallback_tl }
7288 % Handle number and gender nudges.
7289 % Note that these nudges get disabled for `typeset=ref' /
7290 % `noname' option, but in this case they are not really
7291 % meaningful anyway.
7292 \bool_if:NT \l_@@_nudge_enabled_bool
7293 {
7294 \bool_if:NTF \l_@@_nudge_singular_bool
7295 {
7296 \tl_if_empty:NF \l_@@_typeset_queue_curr_tl
7297 {
7298 \msg_warning:nne { zref-clever }
7299 { nudge-plural-when-sg }
7300 { \l_@@_type_first_label_type_tl }
7301 }
7302 }
7303 {
7304 \bool_lazy_all:nT
7305 {
7306 { \l_@@_nudge_comptosing_bool }
7307 { \tl_if_empty_p:N \l_@@_typeset_queue_curr_tl }
7308 {
7309 \int_compare_p:nNn
7310 { \l_@@_label_count_int } > { 0 }
7311 }
7312 }
7313 {
7314 \msg_warning:nne { zref-clever }
7315 { nudge-comptosing }
7316 { \l_@@_type_first_label_type_tl }
7317 }
7318 }
7319 \bool_lazy_and:nnT
7320 { \l_@@_nudge_gender_bool }
7321 { ! \tl_if_empty_p:N \l_@@_ref_gender_tl }
7322 {
7323 \@@_get_rf_opt_seq:neeN { gender }
7324 { \l_@@_type_first_label_type_tl }
7325 { \l_@@_ref_language_tl }
7326 \l_@@_type_name_gender_seq
7327 \seq_if_in:NVF
7328 \l_@@_type_name_gender_seq
7329 \l_@@_ref_gender_tl
7330 {
7331 \seq_if_empty:NTF \l_@@_type_name_gender_seq
7332 {
7333 \msg_warning:nneee { zref-clever }
7334 { nudge-gender-not-declared-for-type }
7335 { \l_@@_ref_gender_tl }
7336 { \l_@@_type_first_label_type_tl }
7337 { \l_@@_ref_language_tl }
7338 }
7339 {
7340 \msg_warning:nneeee { zref-clever }
7341 { nudge-gender-mismatch }
7342 { \l_@@_type_first_label_type_tl }
7343 { \l_@@_ref_gender_tl }
7344 {
7345 \seq_use:Nn
7346 \l_@@_type_name_gender_seq { ,~ }
7347 }
7348 { \l_@@_ref_language_tl }
7349 }
7350 }
7351 }
7352 }
7353 \tl_if_empty:NTF \l_@@_name_format_fallback_tl
7354 {
7355 \@@_opt_tl_get:cNF
7356 {
7357 \@@_opt_varname_type:een
7358 { \l_@@_type_first_label_type_tl }
7359 { \l_@@_name_format_tl }
7360 { tl }
7361 }
7362 \l_@@_type_name_tl
7363 {
7364 \tl_if_empty:NF \l_@@_ref_variant_tl
7365 {
7366 \tl_put_left:Nn \l_@@_name_format_tl { - }
7367 \tl_put_left:NV \l_@@_name_format_tl
7368 \l_@@_ref_variant_tl
7369 }
7370 \@@_opt_tl_get:cNF
7371 {
7372 \@@_opt_varname_lang_type:eeen
7373 { \l_@@_ref_language_tl }
7374 { \l_@@_type_first_label_type_tl }
7375 { \l_@@_name_format_tl }
7376 { tl }
7377 }
7378 \l_@@_type_name_tl
7379 {
7380 \tl_clear:N \l_@@_type_name_tl
7381 \bool_set_true:N \l_@@_type_name_missing_bool
7382 \msg_warning:nnee { zref-clever } { missing-name }
7383 { \l_@@_name_format_tl }
7384 { \l_@@_type_first_label_type_tl }
7385 }
7386 }
7387 }
7388 {
7389 \@@_opt_tl_get:cNF
7390 {
7391 \@@_opt_varname_type:een
7392 { \l_@@_type_first_label_type_tl }
7393 { \l_@@_name_format_tl }
7394 { tl }
7395 }
7396 \l_@@_type_name_tl
7397 {
7398 \@@_opt_tl_get:cNF
7399 {
7400 \@@_opt_varname_type:een
7401 { \l_@@_type_first_label_type_tl }
7402 { \l_@@_name_format_fallback_tl }
7403 { tl }
7404 }
7405 \l_@@_type_name_tl
7406 {
7407 \tl_if_empty:NF \l_@@_ref_variant_tl
7408 {
7409 \tl_put_left:Nn
7410 \l_@@_name_format_tl { - }
7411 \tl_put_left:NV \l_@@_name_format_tl
7412 \l_@@_ref_variant_tl
7413 \tl_put_left:Nn
7414 \l_@@_name_format_fallback_tl { - }
7415 \tl_put_left:NV
7416 \l_@@_name_format_fallback_tl
7417 \l_@@_ref_variant_tl
7418 }
7419 \@@_opt_tl_get:cNF
7420 {
7421 \@@_opt_varname_lang_type:eeen
7422 { \l_@@_ref_language_tl }
7423 { \l_@@_type_first_label_type_tl }
7424 { \l_@@_name_format_tl }
7425 { tl }
7426 }
7427 \l_@@_type_name_tl
7428 {
7429 \@@_opt_tl_get:cNF
7430 {
7431 \@@_opt_varname_lang_type:eeen
7432 { \l_@@_ref_language_tl }
7433 { \l_@@_type_first_label_type_tl }
7434 { \l_@@_name_format_fallback_tl }
7435 { tl }
7436 }
7437 \l_@@_type_name_tl
7438 {
7439 \tl_clear:N \l_@@_type_name_tl
7440 \bool_set_true:N
7441 \l_@@_type_name_missing_bool
7442 \msg_warning:nnee { zref-clever }
7443 { missing-name }
7444 { \l_@@_name_format_tl }
7445 { \l_@@_type_first_label_type_tl }
7446 }
7447 }
7448 }
7449 }
7450 }
7451 }
7452 }
7453 % Signal whether the type name is to be included in the hyperlink or
7454 % not.
7455 \bool_lazy_any:nTF
7456 {
7457 { ! \l_@@_hyperlink_bool }
7458 { \l_@@_link_star_bool }
7459 { \tl_if_empty_p:N \l_@@_type_name_tl }
7460 { \str_if_eq_p:Vn \l_@@_nameinlink_str { false } }
7461 }
7462 { \bool_set_false:N \l_@@_name_in_link_bool }
7463 {
7464 \bool_lazy_any:nTF
7465 {
7466 { \str_if_eq_p:Vn \l_@@_nameinlink_str { true } }
7467 {
7468 \str_if_eq_p:Vn \l_@@_nameinlink_str { tsingle } &&
7469 \tl_if_empty_p:N \l_@@_typeset_queue_curr_tl
7470 }
7471 {
7472 \str_if_eq_p:Vn \l_@@_nameinlink_str { single } &&
7473 \tl_if_empty_p:N \l_@@_typeset_queue_curr_tl &&
7474 \l_@@_typeset_last_bool &&
7475 \int_compare_p:nNn { \l_@@_type_count_int } = { 0 }
7476 }
7477 }
7478 { \bool_set_true:N \l_@@_name_in_link_bool }
7479 { \bool_set_false:N \l_@@_name_in_link_bool }
7480 }
7481 }
7482 }
7483 % \end{macrocode}
7484 % \end{macro}
7485 %
7486 %
7487 % \begin{macro}{\@@_hyperlink:nnn}
7488 % This avoids using the internal \cs[replace=false]{hyper@@link}, using only
7489 % public \pkg{hyperref} commands (see
7490 % \url{https://github.com/latex3/hyperref/issues/229#issuecomment-1093870142},
7491 % thanks \contributor{Ulrike Fischer}).
7492 % \begin{syntax}
7493 % \cs{@@_hyperlink:nnn} \Arg{url/file} \Arg{anchor} \Arg{text}
7494 % \end{syntax}
7495 % \begin{macrocode}
7496 \cs_new_protected:Npn \@@_hyperlink:nnn #1#2#3
7497 {
7498 \tl_if_empty:nTF {#1}
7499 { \hyperlink {#2} {#3} }
7500 { \hyper@linkfile {#3} {#1} {#2} }
7501 }
7502 % \end{macrocode}
7503 % \end{macro}
7504 %
7505 %
7506 % \begin{macro}{\@@_extract_url_unexp:n}
7507 % A convenience auxiliary function for extraction of the \texttt{url} /
7508 % \texttt{urluse} property, provided by the \pkg{zref-xr} module. Ensure
7509 % that, in the context of an e expansion, \cs{zref@extractdefault} is
7510 % expanded exactly twice, but no further to retrieve the proper value. See
7511 % documentation for \cs{@@_extract_unexp:nnn}.
7512 % \begin{macrocode}
7513 \cs_new:Npn \@@_extract_url_unexp:n #1
7514 {
7515 \zref@ifpropundefined { urluse }
7516 { \@@_extract_unexp:nnn {#1} { url } { } }
7517 {
7518 \zref@ifrefcontainsprop {#1} { urluse }
7519 { \@@_extract_unexp:nnn {#1} { urluse } { } }
7520 { \@@_extract_unexp:nnn {#1} { url } { } }
7521 }
7522 }
7523 \cs_generate_variant:Nn \@@_extract_url_unexp:n { V }
7524 % \end{macrocode}
7525 % \end{macro}
7526 %
7527 %
7528 % \begin{macro}{\@@_labels_in_sequence:nn}
7529 % Auxiliary function to \cs{@@_typeset_refs_not_last_of_type:}. Sets
7530 % \cs{l_@@_next_maybe_range_bool} to true if \meta{label b} comes in
7531 % immediate sequence from \meta{label a}. And sets both
7532 % \cs{l_@@_next_maybe_range_bool} and \cs{l_@@_next_is_same_bool} to true if
7533 % the two labels are the ``same'' (that is, have the same counter value).
7534 % These two boolean variables are the basis for all range and compression
7535 % handling inside \cs{@@_typeset_refs_not_last_of_type:}, so this function
7536 % is expected to be called at its beginning, if compression is enabled.
7537 % \begin{syntax}
7538 % \cs{@@_labels_in_sequence:nn} \Arg{label a} \Arg{label b}
7539 % \end{syntax}
7540 % \begin{macrocode}
7541 \cs_new_protected:Npn \@@_labels_in_sequence:nn #1#2
7542 {
7543 \exp_args:Nee \tl_if_eq:nnT
7544 { \@@_extract_unexp:nnn {#1} { externaldocument } { } }
7545 { \@@_extract_unexp:nnn {#2} { externaldocument } { } }
7546 {
7547 \tl_if_eq:NnTF \l_@@_ref_property_tl { page }
7548 {
7549 \exp_args:Nee \tl_if_eq:nnT
7550 { \@@_extract_unexp:nnn {#1} { zc@pgfmt } { } }
7551 { \@@_extract_unexp:nnn {#2} { zc@pgfmt } { } }
7552 {
7553 \int_compare:nNnTF
7554 { \@@_extract:nnn {#1} { zc@pgval } { -2 } + 1 }
7555 =
7556 { \@@_extract:nnn {#2} { zc@pgval } { -1 } }
7557 { \bool_set_true:N \l_@@_next_maybe_range_bool }
7558 {
7559 \int_compare:nNnT
7560 { \@@_extract:nnn {#1} { zc@pgval } { -1 } }
7561 =
7562 { \@@_extract:nnn {#2} { zc@pgval } { -1 } }
7563 {
7564 \bool_set_true:N \l_@@_next_maybe_range_bool
7565 \bool_set_true:N \l_@@_next_is_same_bool
7566 }
7567 }
7568 }
7569 }
7570 {
7571 \exp_args:Nee \tl_if_eq:nnT
7572 { \@@_extract_unexp:nnn {#1} { zc@counter } { } }
7573 { \@@_extract_unexp:nnn {#2} { zc@counter } { } }
7574 {
7575 \exp_args:Nee \tl_if_eq:nnT
7576 { \@@_extract_unexp:nnn {#1} { zc@enclval } { } }
7577 { \@@_extract_unexp:nnn {#2} { zc@enclval } { } }
7578 {
7579 \int_compare:nNnTF
7580 { \@@_extract:nnn {#1} { zc@cntval } { -2 } + 1 }
7581 =
7582 { \@@_extract:nnn {#2} { zc@cntval } { -1 } }
7583 { \bool_set_true:N \l_@@_next_maybe_range_bool }
7584 {
7585 \int_compare:nNnT
7586 { \@@_extract:nnn {#1} { zc@cntval } { -1 } }
7587 =
7588 { \@@_extract:nnn {#2} { zc@cntval } { -1 } }
7589 {
7590 % \end{macrocode}
7591 % If \texttt{zc@counter}s are equal, \texttt{zc@enclval}s are equal, and
7592 % \texttt{zc@enclval}s are equal, but the references themselves are different,
7593 % this means that \cs{@currentlabel} has somehow been set manually (e.g. by an
7594 % \pkg{amsmath}'s \cs{tag}), in which case we have no idea what's in there,
7595 % and we should not even consider this is still a range. If they are equal,
7596 % though, of course it is a range, and it is the same.
7597 % \begin{macrocode}
7598 \exp_args:Nee \tl_if_eq:nnT
7599 {
7600 \@@_extract_unexp:nvn {#1}
7601 { l_@@_ref_property_tl } { }
7602 }
7603 {
7604 \@@_extract_unexp:nvn {#2}
7605 { l_@@_ref_property_tl } { }
7606 }
7607 {
7608 \bool_set_true:N
7609 \l_@@_next_maybe_range_bool
7610 \bool_set_true:N
7611 \l_@@_next_is_same_bool
7612 }
7613 }
7614 }
7615 }
7616 }
7617 }
7618 }
7619 }
7620 % \end{macrocode}
7621 % \end{macro}
7622 %
7623 %
7624 %
7625 % Finally, some functions for retrieving reference options values, according
7626 % to the relevant precedence rules. They receive an \meta{option} as
7627 % argument, and store the retrieved value in an appropriate \meta{variable}.
7628 % The difference between each of these functions is the data type of the
7629 % option each should be used for.
7630 %
7631 %
7632 % \begin{macro}{\@@_get_rf_opt_tl:nnnN}
7633 % \begin{syntax}
7634 % \cs{@@_get_rf_opt_tl:nnnN} \Arg{option}
7635 % ~~\Arg{ref type} \Arg{language} \Arg{tl variable}
7636 % \end{syntax}
7637 % \begin{macrocode}
7638 \cs_new_protected:Npn \@@_get_rf_opt_tl:nnnN #1#2#3#4
7639 {
7640 % First attempt: general options.
7641 \@@_opt_tl_get:cNF
7642 { \@@_opt_varname_general:nn {#1} { tl } }
7643 #4
7644 {
7645 % If not found, try type specific options.
7646 \@@_opt_tl_get:cNF
7647 { \@@_opt_varname_type:nnn {#2} {#1} { tl } }
7648 #4
7649 {
7650 % If not found, try type- and language-specific.
7651 \@@_opt_tl_get:cNF
7652 { \@@_opt_varname_lang_type:nnnn {#3} {#2} {#1} { tl } }
7653 #4
7654 {
7655 % If not found, try language-specific default.
7656 \@@_opt_tl_get:cNF
7657 { \@@_opt_varname_lang_default:nnn {#3} {#1} { tl } }
7658 #4
7659 {
7660 % If not found, try fallback.
7661 \@@_opt_tl_get:cNF
7662 { \@@_opt_varname_fallback:nn {#1} { tl } }
7663 #4
7664 { \tl_clear:N #4 }
7665 }
7666 }
7667 }
7668 }
7669 }
7670 \cs_generate_variant:Nn \@@_get_rf_opt_tl:nnnN { neeN }
7671 % \end{macrocode}
7672 % \end{macro}
7673 %
7674 %
7675 % \begin{macro}{\@@_get_rf_opt_seq:nnnN}
7676 % \begin{syntax}
7677 % \cs{@@_get_rf_opt_seq:nnnN} \Arg{option}
7678 % ~~\Arg{ref type} \Arg{language} \Arg{seq variable}
7679 % \end{syntax}
7680 % \begin{macrocode}
7681 \cs_new_protected:Npn \@@_get_rf_opt_seq:nnnN #1#2#3#4
7682 {
7683 % First attempt: general options.
7684 \@@_opt_seq_get:cNF
7685 { \@@_opt_varname_general:nn {#1} { seq } }
7686 #4
7687 {
7688 % If not found, try type specific options.
7689 \@@_opt_seq_get:cNF
7690 { \@@_opt_varname_type:nnn {#2} {#1} { seq } }
7691 #4
7692 {
7693 % If not found, try type- and language-specific.
7694 \@@_opt_seq_get:cNF
7695 { \@@_opt_varname_lang_type:nnnn {#3} {#2} {#1} { seq } }
7696 #4
7697 {
7698 % If not found, try language-specific default.
7699 \@@_opt_seq_get:cNF
7700 { \@@_opt_varname_lang_default:nnn {#3} {#1} { seq } }
7701 #4
7702 {
7703 % If not found, try fallback.
7704 \@@_opt_seq_get:cNF
7705 { \@@_opt_varname_fallback:nn {#1} { seq } }
7706 #4
7707 { \seq_clear:N #4 }
7708 }
7709 }
7710 }
7711 }
7712 }
7713 \cs_generate_variant:Nn \@@_get_rf_opt_seq:nnnN { neeN }
7714 % \end{macrocode}
7715 % \end{macro}
7716 %
7717 %
7718 % \begin{macro}{\@@_get_rf_opt_bool:nnnnN}
7719 % \begin{syntax}
7720 % \cs{@@_get_rf_opt_bool:nN} \Arg{option} \Arg{default}
7721 % ~~\Arg{ref type} \Arg{language} \Arg{bool variable}
7722 % \end{syntax}
7723 % \begin{macrocode}
7724 \cs_new_protected:Npn \@@_get_rf_opt_bool:nnnnN #1#2#3#4#5
7725 {
7726 % First attempt: general options.
7727 \@@_opt_bool_get:cNF
7728 { \@@_opt_varname_general:nn {#1} { bool } }
7729 #5
7730 {
7731 % If not found, try type specific options.
7732 \@@_opt_bool_get:cNF
7733 { \@@_opt_varname_type:nnn {#3} {#1} { bool } }
7734 #5
7735 {
7736 % If not found, try type- and language-specific.
7737 \@@_opt_bool_get:cNF
7738 { \@@_opt_varname_lang_type:nnnn {#4} {#3} {#1} { bool } }
7739 #5
7740 {
7741 % If not found, try language-specific default.
7742 \@@_opt_bool_get:cNF
7743 { \@@_opt_varname_lang_default:nnn {#4} {#1} { bool } }
7744 #5
7745 {
7746 % If not found, try fallback.
7747 \@@_opt_bool_get:cNF
7748 { \@@_opt_varname_fallback:nn {#1} { bool } }
7749 #5
7750 { \use:c { bool_set_ #2 :N } #5 }
7751 }
7752 }
7753 }
7754 }
7755 }
7756 \cs_generate_variant:Nn \@@_get_rf_opt_bool:nnnnN { nneeN }
7757 % \end{macrocode}
7758 % \end{macro}
7759 %
7760 %
7761 %
7762 % \section{Compatibility}
7763 %
7764 % This section is meant to aggregate any ``special handling'' needed for
7765 % \LaTeX{} kernel features, document classes, and packages, needed for
7766 % \pkg{zref-clever} to work properly with them.
7767 %
7768 %
7769 % \subsection{\opt{appendix}}
7770 %
7771 % One relevant case of different reference types sharing the same counter is
7772 % the \cs{appendix} which in some document classes, including the standard
7773 % ones, change the sectioning commands looks but, of course, keep using the
7774 % same counter. \file{book.cls} and \file{report.cls} reset counters
7775 % \texttt{chapter} and \texttt{section} to 0, change \cs{@chapapp} to use
7776 % \cs{appendixname} and use \cs{@Alph} for \cs{thechapter}. \file{article.cls}
7777 % resets counters \texttt{section} and \texttt{subsection} to 0, and uses
7778 % \cs{@Alph} for \cs{thesection}. \file{memoir.cls}, \file{scrbook.cls} and
7779 % \file{scrarticle.cls} do the same as their corresponding standard classes,
7780 % and sometimes a little more, but what interests us here is pretty much the
7781 % same. See also the \pkg{appendix} package.
7782 %
7783 % The standard \cs{appendix} command is a one way switch, in other words, it
7784 % cannot be reverted (see \url{https://tex.stackexchange.com/a/444057}). So,
7785 % even if the fact that it is a ``switch'' rather than an environment
7786 % complicates things, because we have to make ungrouped settings to correspond
7787 % to its effects, in practice this is not a big deal, since these settings are
7788 % never really reverted (by default, at least). Hence, hooking into
7789 % \cs{appendix} is a viable and natural alternative. The \cls{memoir} class
7790 % and the \pkg{appendix} package define the \texttt{appendices} and
7791 % \texttt{subappendices} environments, which provide for a way for the
7792 % appendix to ``end'', but in this case, of course, we can hook into the
7793 % environment instead.
7794 %
7795 % For the record, \url{https://tex.stackexchange.com/a/724742} is of
7796 % interest.
7797 %
7798 % \begin{macrocode}
7799 \@@_compat_module:nn { appendix }
7800 {
7801 \newcounter { zc@appendix }
7802 \cs_if_exist:cTF { chapter }
7803 {
7804 \@@_zcsetup:e
7805 {
7806 counterresetby =
7807 {
7808 % \end{macrocode}
7809 % In case someone did something like
7810 % \texttt{\textbackslash{}counterwithin\{chapter\}\{part\}}. Harmless
7811 % otherwise.
7812 % \begin{macrocode}
7813 zc@appendix = \@@_counter_reset_by:n { chapter } ,
7814 chapter = zc@appendix ,
7815 } ,
7816 }
7817 }
7818 {
7819 \cs_if_exist:cT { section }
7820 {
7821 \@@_zcsetup:e
7822 {
7823 counterresetby =
7824 {
7825 zc@appendix = \@@_counter_reset_by:n { section } ,
7826 section = zc@appendix ,
7827 } ,
7828 }
7829 }
7830 }
7831 \AddToHook { cmd / appendix / before }
7832 {
7833 \setcounter { zc@appendix } { 1 }
7834 \@@_zcsetup:n
7835 {
7836 countertype =
7837 {
7838 chapter = appendix ,
7839 section = appendix ,
7840 subsection = appendix ,
7841 subsubsection = appendix ,
7842 paragraph = appendix ,
7843 subparagraph = appendix ,
7844 }
7845 }
7846 }
7847 }
7848 % \end{macrocode}
7849 %
7850 % Depending on the definition of \cs{appendix}, using the hook may lead to
7851 % trouble with the first released version of \pkg{ltcmdhooks} (the one
7852 % released with the 2021-06-01 kernel). Particularly, if the definition of
7853 % the command being hooked at contains a double hash mark (\texttt{\#\#}) the
7854 % patch to add the hook, if it needs to be done with the \cs{scantokens}
7855 % method, may fail noisily (see \url{https://tex.stackexchange.com/q/617905},
7856 % with a detailed explanation and possible workaround by \contributor{Phelype
7857 % Oleinik}). The 2021-11-15 kernel release already handles this gracefully,
7858 % thanks to fix by \contributor{Phelype Oleinik} at
7859 % \url{https://github.com/latex3/latex2e/pull/699}.
7860 %
7861 %
7862 % \subsection{\opt{appendices}}
7863 %
7864 % This module applies both to the \pkg{appendix} package, and to the
7865 % \cls{memoir} class, since it ``emulates'' the package.
7866 %
7867 % \begin{macrocode}
7868 \@@_compat_module:nn { appendices }
7869 {
7870 \@@_if_package_loaded:nT { appendix }
7871 {
7872 \AddToHook { env / appendices / begin }
7873 {
7874 % \end{macrocode}
7875 % Technically, the \env{appendices} environment can be called multiple times.
7876 % By default, successive calls keep track of numbering and start where the
7877 % previous one left off. Which means just setting the \texttt{zc@appendix}
7878 % counter to 1 is enough for things to work, since the distinction between the
7879 % calls and the sorting of their respective references will depend on the
7880 % underlying sectioning. \pkg{appendix}'s documentation however, provides a
7881 % way to restart from A at each call (by redefining \cs{restoreapp} to do
7882 % nothing). In this case, the references inside different calls to
7883 % \env{appendices} get to be identical in every way, including printed form,
7884 % counter value, enclosing counters, etc., despite being different. We could
7885 % keep track of different calls to \env{appendices} by having the
7886 % \texttt{zc@appendix} counter be ``stepped'' at each call. Doing so would
7887 % mean though that \cs{zcref} would distingish things which are typeset
7888 % identically, granting some arguably weird results. True, the user
7889 % \emph{can} change the printed form for each \env{appendices} call,
7890 % e.g. redefining \cs{thechapter}, but in this case, they are responsible for
7891 % keeping track of this.
7892 % \begin{macrocode}
7893 \setcounter { zc@appendix } { 1 }
7894 \@@_zcsetup:n
7895 {
7896 countertype =
7897 {
7898 chapter = appendix ,
7899 section = appendix ,
7900 subsection = appendix ,
7901 subsubsection = appendix ,
7902 paragraph = appendix ,
7903 subparagraph = appendix ,
7904 }
7905 }
7906 }
7907 \AddToHook { env / appendices / end }
7908 { \setcounter { zc@appendix } { 0 } }
7909 \newcounter { zc@subappendix }
7910 \cs_if_exist:cTF { chapter }
7911 {
7912 \@@_zcsetup:e
7913 {
7914 counterresetby =
7915 {
7916 zc@subappendix = \@@_counter_reset_by:n { section } ,
7917 section = zc@subappendix ,
7918 } ,
7919 }
7920 }
7921 {
7922 \@@_zcsetup:e
7923 {
7924 counterresetby =
7925 {
7926 zc@subappendix = \@@_counter_reset_by:n { subsection } ,
7927 subsection = zc@subappendix ,
7928 } ,
7929 }
7930 }
7931 \AddToHook { env / subappendices / begin }
7932 {
7933 % \end{macrocode}
7934 % The \env{subappendices} environment, on the other hand, appears not to
7935 % support multiple calls inside the same chapter/section (the counter is reset
7936 % by default). Either way, the same reasoning applies.
7937 % \begin{macrocode}
7938 \setcounter { zc@subappendix } { 1 }
7939 \@@_zcsetup:n
7940 {
7941 countertype =
7942 {
7943 section = appendix ,
7944 subsection = appendix ,
7945 subsubsection = appendix ,
7946 paragraph = appendix ,
7947 subparagraph = appendix ,
7948 } ,
7949 }
7950 }
7951 \AddToHook { env / subappendices / end }
7952 { \setcounter { zc@subappendix } { 0 } }
7953 \msg_info:nnn { zref-clever } { compat-package } { appendix }
7954 }
7955 }
7956 % \end{macrocode}
7957 %
7958 %
7959 %
7960 % \subsection{\opt{memoir}}
7961 %
7962 % The \cls{memoir} document class has quite a number of cross-referencing
7963 % related features, mostly dealing with captions, subfloats, and notes. It
7964 % used to be the case that a good number of them where implemented in ways
7965 % which made difficult the use of \pkg{zref}, particularly \cs{zlabel}.
7966 % Problematic cases included: i) side captions; ii) bilingual captions; iii)
7967 % subcaption references; and iv) footnotes, verbfootnotes, sidefootnotes, and
7968 % pagenotes.
7969 %
7970 % However, since then, the situation has much improved, given two main
7971 % upstream changes: i) the kernel's new \texttt{label} hook with argument,
7972 % introduced in the release of 2023-06-01 (thanks to \contributor{Ulrike
7973 % Fischer} and \contributor{Phelype Oleinik}) and ii) better support for
7974 % \pkg{zref} and \pkg{zref-clever} from the \cls{memoir} class itself, with
7975 % release of \texttt{2023/08/08 v3.8} (thanks to \contributor{Lars Madsen}).
7976 %
7977 % Also, note that \cls{memoir}'s appendix features ``emulates'' the
7978 % \pkg{appendix} package, hence the corresponding compatibility module is
7979 % loaded for \cls{memoir} even if that package is not itself loaded. The same
7980 % is true for the \cs{appendix} command module, since it is also defined.
7981 %
7982 % \begin{macrocode}
7983 \@@_compat_module:nn { memoir }
7984 {
7985 \@@_if_class_loaded:nT { memoir }
7986 {
7987 % \end{macrocode}
7988 % Add subfigure and subtable support out of the box. Technically, this is not
7989 % ``default'' behavior for \cls{memoir}, users have to enable it with
7990 % \cs{newsubfloat}, but let this be smooth. Still, this does not cover any
7991 % other floats created with \cs{newfloat}. Also include setup for
7992 % \env{verse}.
7993 % \begin{macrocode}
7994 \@@_zcsetup:n
7995 {
7996 countertype =
7997 {
7998 subfigure = figure ,
7999 subtable = table ,
8000 poemline = line ,
8001 } ,
8002 counterresetby =
8003 {
8004 subfigure = figure ,
8005 subtable = table ,
8006 } ,
8007 }
8008 % \end{macrocode}
8009 % Support for \texttt{subcaption} references.
8010 % \begin{macrocode}
8011 \zref@newprop { subcaption }
8012 { \cs_if_exist_use:c { @@@@thesub \@captype } }
8013 \AddToHook{ memoir/subcaption/aftercounter }
8014 { \zref@localaddprop \ZREF@mainlist { subcaption } }
8015 % \end{macrocode}
8016 % Support for \cs{sidefootnote} and \cs{pagenote}.
8017 % \begin{macrocode}
8018 \@@_zcsetup:n
8019 {
8020 countertype =
8021 {
8022 sidefootnote = footnote ,
8023 pagenote = endnote ,
8024 } ,
8025 }
8026 \msg_info:nnn { zref-clever } { compat-class } { memoir }
8027 }
8028 }
8029 % \end{macrocode}
8030 %
8031 %
8032 %
8033 % \subsection{\opt{amsmath}}
8034 %
8035 % About this, see \url{https://tex.stackexchange.com/a/402297} and
8036 % \url{https://github.com/ho-tex/zref/issues/4}.
8037 %
8038 % \begin{macrocode}
8039 \@@_compat_module:nn { amsmath }
8040 {
8041 \@@_if_package_loaded:nT { amsmath }
8042 {
8043 % \end{macrocode}
8044 % The \env{subequations} environment uses \texttt{parentequation} and
8045 % \texttt{equation} as counters, but only the later is subject to
8046 % \cs{refstepcounter}. What happens is: at the start, \texttt{equation} is
8047 % refstepped, it is then stored in \texttt{parentequation} and set to `0' and,
8048 % at the end of the environment it is restored to the value of
8049 % \texttt{parentequation}. We cannot even set \cs{@currentcounter} at
8050 % \texttt{env/.../begin}, since the call to
8051 % \cs{refstepcounter}\texttt{\{equation\}} done by \env{subequations} will
8052 % override that in sequence. Unfortunately, the suggestion to set
8053 % \cs{@currentcounter} to \texttt{parentequation} here was not accepted, see
8054 % \url{https://github.com/latex3/latex2e/issues/687#issuecomment-951451024}
8055 % and subsequent discussion. So, for \env{subequations}, we really must
8056 % specify manually \opt{currentcounter} and the resetting. Note that, for
8057 % \env{subequations}, \cs{zlabel} works just fine (that is, if given
8058 % immediately after \texttt{\textbackslash{}begin\{subequations\}}, to refer
8059 % to the parent equation).
8060 % \begin{macrocode}
8061 \bool_new:N \l_@@_amsmath_subequations_bool
8062 \AddToHook { env / subequations / begin }
8063 {
8064 \@@_zcsetup:e
8065 {
8066 counterresetby =
8067 {
8068 parentequation =
8069 \@@_counter_reset_by:n { equation } ,
8070 equation = parentequation ,
8071 } ,
8072 currentcounter = parentequation ,
8073 countertype = { parentequation = equation } ,
8074 }
8075 \bool_set_true:N \l_@@_amsmath_subequations_bool
8076 }
8077 % \end{macrocode}
8078 % \pkg{amsmath} does use \cs{refstepcounter} for the \texttt{equation} counter
8079 % throughout and supposedly sets \cs{@currentcounter} for \cs{tag}s (I'm not
8080 % sure if it works in all environments, though. Once I tried to remove the
8081 % explicit \opt{currentcounter} setting and several labels to \cs{tag}s ended
8082 % up with type \texttt{section}. But I didn't investigate this further). But
8083 % we still have to manually reset \opt{currentcounter} to default because,
8084 % since we had to manually set \opt{currentcounter} to \texttt{parentequation}
8085 % in \env{subequations}, we also have to manually set it to \env{equation} in
8086 % environments which may be used within it. The \env{xxalignat} environment
8087 % is not included, because it is ``starred'' by default (i.e.\ unnumbered),
8088 % and does not display or accepts labels or tags anyway. The \env{-ed}
8089 % (\env{gathered}, \env{aligned}, and \env{alignedat}) and \env{cases}
8090 % environments ``must appear within an enclosing math environment''. Same
8091 % logic applies to other environments defined or redefined by the package,
8092 % like \env{array}, \env{matrix} and variations. Finally, \env{split} too can
8093 % only be used as part of another environment. We also arrange, at this
8094 % point, for the provision of the \texttt{subeq} property, for the convenience
8095 % of referring to them directly or to build terse ranges with the
8096 % \opt{endrange} option.
8097 % \begin{macrocode}
8098 \zref@newprop { subeq } { \alph { equation } }
8099 \clist_map_inline:nn
8100 {
8101 equation ,
8102 equation* ,
8103 align ,
8104 align* ,
8105 alignat ,
8106 alignat* ,
8107 flalign ,
8108 flalign* ,
8109 xalignat ,
8110 xalignat* ,
8111 gather ,
8112 gather* ,
8113 multline ,
8114 multline* ,
8115 }
8116 {
8117 \AddToHook { env / #1 / begin }
8118 {
8119 \@@_zcsetup:n { currentcounter = equation }
8120 \bool_if:NT \l_@@_amsmath_subequations_bool
8121 { \zref@localaddprop \ZREF@mainlist { subeq } }
8122 }
8123 }
8124 \msg_info:nnn { zref-clever } { compat-package } { amsmath }
8125 }
8126 }
8127 % \end{macrocode}
8128 %
8129 %
8130 %
8131 % \subsection{\opt{mathtools}}
8132 %
8133 % All math environments defined by \pkg{mathtools}, extending the
8134 % \pkg{amsmath} set, are meant to be used within enclosing math environments,
8135 % hence we don't need to handle them specially, since the numbering and the
8136 % counting is being done on the side of \pkg{amsmath}. This includes the new
8137 % \env{cases} and \env{matrix} variants, and also \env{multlined}.
8138 %
8139 % Hence, as far as I can tell, the only cross-reference related feature to
8140 % deal with is the \opt{showonlyrefs} option, whose machinery involves writing
8141 % an extra internal label to the \file{.aux} file to track for labels which
8142 % get actually referred to. This is a little more involved, and implies in
8143 % doing special handling inside \cs{zcref}, but the feature is very cool, so
8144 % it's worth it.
8145 %
8146 % Note that this support comes at a little cost. \opt{showonlyrefs} works by
8147 % setting a special \cs{MT@newlabel} for each label referenced with
8148 % \cs{eqref}. Now, \cs{eqref} is a specialized reference command, only used
8149 % to refer to equations, so it sets \cs{MT@newlabel} unconditionally on the
8150 % first run. \cs{zcref}, on the other hand, is a general purpose reference
8151 % command, used to reference labels of any type. But we wouldn't want to set
8152 % \cs{MT@newlabel} indiscriminately for all referenced labels in the document,
8153 % so we need to test for its type. Alas, the label must exist before its type
8154 % can be tested, thus we cannot set \cs{MT@newlabel} on the first run, only on
8155 % the second. In sum, since \cs{eqref} requires 3 runs to work, \cs{zcref}
8156 % needs 4.
8157 %
8158 % \begin{macrocode}
8159 \bool_new:N \l_@@_mathtools_loaded_bool
8160 \@@_compat_module:nn { mathtools }
8161 {
8162 \@@_if_package_loaded:nT { mathtools }
8163 {
8164 \bool_set_true:N \l_@@_mathtools_loaded_bool
8165 \cs_new_protected:Npn \@@_mathtools_showonlyrefs:n #1
8166 {
8167 \seq_map_inline:Nn #1
8168 {
8169 \tl_set:Ne \l_@@_tmpa_tl
8170 { \@@_extract_unexp:nnn {##1} { zc@type } { } }
8171 \bool_lazy_or:nnT
8172 { \str_if_eq_p:Vn \l_@@_tmpa_tl { equation } }
8173 { \str_if_eq_p:Vn \l_@@_tmpa_tl { parentequation } }
8174 { \noeqref {##1} }
8175 }
8176 }
8177 \msg_info:nnn { zref-clever } { compat-package } { mathtools }
8178 }
8179 }
8180 % \end{macrocode}
8181 %
8182 %
8183 % \subsection{\opt{breqn}}
8184 %
8185 % From the \pkg{breqn} documentation: \textquote{Use of the normal \cs{label}
8186 % command instead of the \opt{label} option works, I think, most of the time
8187 % (untested)}. Indeed, light testing suggests it does work for \cs{zlabel}
8188 % just as well.
8189 %
8190 % \begin{macrocode}
8191 \@@_compat_module:nn { breqn }
8192 {
8193 \@@_if_package_loaded:nT { breqn }
8194 {
8195 % \end{macrocode}
8196 % Contrary to the practice in \pkg{amsmath}, which prints \cs{tag} even in
8197 % unnumbered environments, the starred environments from \pkg{breqn} don't
8198 % typeset any tag/number at all, even for a manually given \opt{number=} as an
8199 % option. So, even if one can actually set a label in them, it is not really
8200 % meaningful to make a reference to them. Also contrary to \pkg{amsmath}'s
8201 % practice, \pkg{breqn} uses \cs{stepcounter} instead of \cs{refstepcounter}
8202 % for incrementing the equation counters (see
8203 % \url{https://tex.stackexchange.com/a/241150}).
8204 % \begin{macrocode}
8205 \bool_new:N \l_@@_breqn_dgroup_bool
8206 \AddToHook { env / dgroup / begin }
8207 {
8208 \@@_zcsetup:e
8209 {
8210 counterresetby =
8211 {
8212 parentequation =
8213 \@@_counter_reset_by:n { equation } ,
8214 equation = parentequation ,
8215 } ,
8216 currentcounter = parentequation ,
8217 countertype = { parentequation = equation } ,
8218 }
8219 \bool_set_true:N \l_@@_breqn_dgroup_bool
8220 }
8221 \zref@ifpropundefined { subeq }
8222 { \zref@newprop { subeq } { \alph { equation } } }
8223 { }
8224 \clist_map_inline:nn
8225 {
8226 dmath ,
8227 dseries ,
8228 darray ,
8229 }
8230 {
8231 \AddToHook { env / #1 / begin }
8232 {
8233 \@@_zcsetup:n { currentcounter = equation }
8234 \bool_if:NT \l_@@_breqn_dgroup_bool
8235 { \zref@localaddprop \ZREF@mainlist { subeq } }
8236 }
8237 }
8238 \msg_info:nnn { zref-clever } { compat-package } { breqn }
8239 }
8240 }
8241 % \end{macrocode}
8242 %
8243 %
8244 %
8245 % \subsection{\opt{listings}}
8246 %
8247 % \begin{macrocode}
8248 \@@_compat_module:nn { listings }
8249 {
8250 \@@_if_package_loaded:nT { listings }
8251 {
8252 \@@_zcsetup:n
8253 {
8254 countertype =
8255 {
8256 lstlisting = listing ,
8257 lstnumber = line ,
8258 } ,
8259 counterresetby = { lstnumber = lstlisting } ,
8260 }
8261 % \end{macrocode}
8262 % Set \texttt{currentcounter} to \texttt{lstnumber} in the \texttt{Init} hook,
8263 % since \pkg{listings} itself sets \cs{@currentlabel} to \cs{thelstnumber}
8264 % here. Note that \pkg{listings} \emph{does use} \cs{refstepcounter} on
8265 % \texttt{lstnumber}, but does so in the \texttt{EveryPar} hook, and there
8266 % must be some grouping involved such that \cs{@currentcounter} ends up not
8267 % being visible to the label. See section ``Line numbers'' of `\texttt{texdoc
8268 % listings-devel}' (the \file{.dtx}), and search for the definition of macro
8269 % \cs{c@lstnumber}. Indeed, the fact that \pkg{listings} manually sets
8270 % \cs{@currentlabel} to \cs{thelstnumber} is a signal that the work of
8271 % \cs{refstepcounter} is being restrained somehow.
8272 % \begin{macrocode}
8273 \cs_if_exist:NT \lst@AddToHook
8274 {
8275 \lst@AddToHook { Init }
8276 { \@@_zcsetup:n { currentcounter = lstnumber } }
8277 }
8278 \msg_info:nnn { zref-clever } { compat-package } { listings }
8279 }
8280 }
8281 % \end{macrocode}
8282 %
8283 %
8284 % \subsection{\opt{enumitem}}
8285 %
8286 % The procedure below will ``see'' any changes made to the \texttt{enumerate}
8287 % environment (made with \pkg{enumitem}'s \cs{renewlist}) as long as it is
8288 % done in the preamble. Though, technically, \cs{renewlist} can be issued
8289 % anywhere in the document, this should be more than enough for the purpose at
8290 % hand. Besides, trying to retrieve this information ``on the fly'' would be
8291 % much overkill.
8292 %
8293 % The only real reason to ``renew'' \texttt{enumerate} itself is to change
8294 % \marg{max-depth}. \cs{renewlist} \emph{hard-codes} \texttt{max-depth} in
8295 % the environment's definition (well, just as the kernel does), so we cannot
8296 % retrieve this information from any sort of variable. But \cs{renewlist}
8297 % also creates any needed missing counters, so we can use their existence to
8298 % make the appropriate settings. In the end, the existence of the counters is
8299 % indeed what matters from \pkg{zref-clever}'s perspective. Since the first
8300 % four are defined by the kernel and already setup for \pkg{zref-clever} by
8301 % default, we start from \(5\), and stop at the first non-existent
8302 % \cs[no-index]{c@enumN} counter.
8303 %
8304 % \begin{macrocode}
8305 \@@_compat_module:nn { enumitem }
8306 {
8307 \@@_if_package_loaded:nT { enumitem }
8308 {
8309 \int_set:Nn \l_@@_tmpa_int { 5 }
8310 \bool_while_do:nn
8311 {
8312 \cs_if_exist_p:c
8313 { c@ enum \int_to_roman:n { \l_@@_tmpa_int } }
8314 }
8315 {
8316 \@@_zcsetup:e
8317 {
8318 counterresetby =
8319 {
8320 enum \int_to_roman:n { \l_@@_tmpa_int } =
8321 enum \int_to_roman:n { \l_@@_tmpa_int - 1 }
8322 } ,
8323 countertype =
8324 { enum \int_to_roman:n { \l_@@_tmpa_int } = item } ,
8325 }
8326 \int_incr:N \l_@@_tmpa_int
8327 }
8328 \int_compare:nNnT { \l_@@_tmpa_int } > { 5 }
8329 { \msg_info:nnn { zref-clever } { compat-package } { enumitem } }
8330 }
8331 }
8332 % \end{macrocode}
8333 %
8334 %
8335 %
8336 % \subsection{\opt{subcaption}}
8337 %
8338 %
8339 % \begin{macrocode}
8340 \@@_compat_module:nn { subcaption }
8341 {
8342 \@@_if_package_loaded:nT { subcaption }
8343 {
8344 \@@_zcsetup:n
8345 {
8346 countertype =
8347 {
8348 subfigure = figure ,
8349 subtable = table ,
8350 } ,
8351 counterresetby =
8352 {
8353 subfigure = figure ,
8354 subtable = table ,
8355 } ,
8356 }
8357 % \end{macrocode}
8358 % Support for \texttt{subref} reference.
8359 % \begin{macrocode}
8360 \zref@newprop { subref }
8361 { \cs_if_exist_use:c { thesub \@captype } }
8362 \tl_if_exist:NT \caption@subtypehook
8363 {
8364 \tl_put_right:Nn \caption@subtypehook
8365 { \zref@localaddprop \ZREF@mainlist { subref } }
8366 }
8367 }
8368 }
8369 % \end{macrocode}
8370 %
8371 %
8372 % \subsection{\opt{subfig}}
8373 %
8374 % Though \pkg{subfig} offers \cs{subref} (as \pkg{subcaption}), I could not
8375 % find any reasonable place to add the \texttt{subref} property to
8376 % \pkg{zref}'s main list.
8377 %
8378 % \begin{macrocode}
8379 \@@_compat_module:nn { subfig }
8380 {
8381 \@@_if_package_loaded:nT { subfig }
8382 {
8383 \@@_zcsetup:n
8384 {
8385 countertype =
8386 {
8387 subfigure = figure ,
8388 subtable = table ,
8389 } ,
8390 counterresetby =
8391 {
8392 subfigure = figure ,
8393 subtable = table ,
8394 } ,
8395 }
8396 }
8397 }
8398 % \end{macrocode}
8399 %
8400 %
8401 % \subsection{\opt{beamer}}
8402 %
8403 % FIXME When \cls{beamer} releases fixes for these issues, remove this
8404 % compatibility module. See
8405 % \url{https://github.com/josephwright/beamer/issues/917}.
8406 %
8407 % \cls{beamer} does some really atypical things with regard to
8408 % cross-references. To start with, it redefines \cs{label} to receive an
8409 % optional \texttt{<\meta{overlay specification}>} argument. Then, presumably
8410 % to support overlays, it goes on and hijacks \pkg{hyperref}'s anchoring
8411 % system, sets anchors (\cs{hypertarget}s) to each \emph{label} in the
8412 % \file{.snm} file, while letting every standard label's anchor in the
8413 % \file{.aux} file default to \texttt{Doc-Start}. Of course, having rendered
8414 % useless \pkg{hyperref}'s anchoring, it has to redefine \cs{ref} so that it
8415 % uses its own \file{.snm} provided ``label anchors'' to make hyperlinks. In
8416 % particular, from our perspective, there is no support at all for \pkg{zref}
8417 % provided by \cls{beamer}. Which is specially unfortunate since the above
8418 % procedures also appear to break \pkg{cleveref}. See, for example,
8419 % \url{https://tex.stackexchange.com/q/266080},
8420 % \url{https://tex.stackexchange.com/q/668998}, and
8421 % \url{https://github.com/josephwright/beamer/issues/750}. The work-around
8422 % provided at \url{https://tex.stackexchange.com/a/266109} is not general
8423 % enough since it breaks \pkg{cleveref}'s ability to receive a list of labels
8424 % as argument. Finally, \cls{beamer} also does not set \cs{@currentcounter}
8425 % for the frames, making it hard for \pkg{zref-clever} to assign the proper
8426 % type to labels set in that scope.
8427 %
8428 % The technique to set proper anchors is is thanks to \contributor{Ulrike
8429 % Fischer} at \url{https://tex.stackexchange.com/a/730792}.
8430 %
8431 % \begin{macrocode}
8432 \@@_compat_module:nn { beamer }
8433 {
8434 \@@_if_class_loaded:nT { beamer }
8435 {
8436 \AddToHookWithArguments { label } [ zref-clever/compat/beamer ]
8437 { \xdef\@currentHref{#1} }
8438 \DeclareHookRule { label }
8439 { zref-clever/compat/beamer } { before } { zref-clever }
8440 \AddToHookWithArguments { cmd/refcounter/before }
8441 [ zref-clever/compat/beamer ]
8442 { \edef\@currentcounter{#1} }
8443 }
8444 }
8445 % \end{macrocode}
8446 %
8447 %
8448 % \begin{macrocode}
8449 %</package>
8450 % \end{macrocode}
8451 %
8452 %
8453 %
8454 % \section{Language files}
8455 %
8456 % Initial values for the English, German, French, Portuguese, and Spanish
8457 % language files have been provided by the author. Translations available for
8458 % document elements' names in other packages have been an useful reference for
8459 % the purpose, namely: \pkg{babel}, \pkg{cleveref}, \pkg{translator}, and
8460 % \pkg{translations}.
8461 %
8462 %
8463 % \subsection{Localization guidelines}
8464 %
8465 % Since the task of localizing \pkg{zref-clever} to work in different
8466 % languages depends on the generous work of contributors, it is a good idea to
8467 % set some guidelines not only to ease the task itself but also to document
8468 % what the package expects in this regard.
8469 %
8470 % The first general observation is that, contrary to a common initial reaction
8471 % of those faced with the task of localizing the reference types, is that the
8472 % job is not quite one of ``translation''. The reference type names are just
8473 % the internal names used by the package to refer to them, technically, they
8474 % could just as well be foobars. Of course, for practical reasons, they were
8475 % chosen to be semantic. However, what we are searching for is not really the
8476 % translation to the reference type name itself, but rather for the word /
8477 % term / expression which is typically used to refer to the document object
8478 % that the reference type is meant to represent. And terms that should work
8479 % well in the contexts which cross-references are commonly used.
8480 %
8481 % That said, some comments about the reference types and common pitfalls.
8482 %
8483 % \textbf{Sectioning:} A number of reference types are provided to support
8484 % referencing to document sectioning commands. Obviously, \texttt{part},
8485 % \texttt{chapter}, \texttt{section}, and \texttt{paragraph} are meant to
8486 % refer to the sectioning commands of the standard classes and elsewhere,
8487 % which anyone reading this is certainly acquainted with. Note that
8488 % \pkg{zref-clever} uses -- by default at least, which is what the language
8489 % files cater for -- the \texttt{section} reference type to refer to
8490 % \cs{subsections} and \cs{subsubsections} as well, similarly,
8491 % \texttt{paragraph} also refers to \cs{subparagraph}. The \texttt{appendix}
8492 % reference type is meant to refer to any sectioning command -- be them
8493 % chapters, sections, or paragraphs -- issued after \cs{appendix}, which
8494 % corresponds to how the standard classes, the KOMA Script classes, and
8495 % \cls{memoir} deal with appendices. The \texttt{book} reference type
8496 % deserves some explanation. The word ``book'' has a good number of meanings,
8497 % and the most common one is not the one which is intended here. The Webster
8498 % dictionary gives us a couple of definitions of interest: ``1. A collection
8499 % of sheets of paper, or similar material, blank, written, or printed, bound
8500 % together; commonly, many folded and bound sheets containing continuous
8501 % printing or writing.'' and ``3. A part or subdivision of a treatise or
8502 % literary work; as, the tenth book of `Paradise Lost'.'' It is this third
8503 % meaning which the \texttt{book} reference type is meant to support: a major
8504 % subdivision of a work, much like \cs{part}. Even if it does not exist in
8505 % the standard classes, it may exist elsewhere, in particular, it is provided
8506 % by \cls{memoir}.
8507 %
8508 % \textbf{Common numbered objects:} Nothing surprising here, just being
8509 % explicit. \texttt{table} and \texttt{figure} refer to the document's
8510 % respective floats objects. \texttt{page} to the page number. \texttt{item}
8511 % to the item number in \env{enumerate} environments. Similarly,
8512 % \texttt{line} is meant to refer to line numbers.
8513 %
8514 % \textbf{Notes:} \pkg{zref-clever} provides three reference types in this
8515 % area: \texttt{footnote}, \texttt{endnote}, and \texttt{note}. The first two
8516 % refer to footnotes and end notes, respectively. The third is meant as a
8517 % convenience for a general ``note'' object, either the other two, or
8518 % something else. By experience, here is one place where that initial
8519 % observation of not simply translating the reference types names is
8520 % particularly relevant. There's a natural temptation, because three
8521 % different types exist and are somewhat close to each other, to distinguish
8522 % them clearly. Duty would compel us to do so. But that may lead to less
8523 % than ideal results. Different terms work well for some languages, like
8524 % English and German, which have compound words for the purpose. But less so
8525 % for other languages, like Portuguese, French, or Italian. For example, in a
8526 % document in French which only contains footnotes, arguably a very common use
8527 % case, would it be better to refer to a footnote as just ``note'', or be very
8528 % precise with ``note infrapaginale''? Of course, in a document which
8529 % contains both footnotes and end notes, we may need the distinction. But is
8530 % it really the better default? True, possibly the inclusion of the
8531 % \texttt{note} reference type, with no clear object to refer to, creates more
8532 % noise than convenience here. If I recall correctly, my intention was to
8533 % provide an easy way out for users from possible contentious localizations
8534 % for \texttt{footnote} and \texttt{endnote}, but I'm not sure if it's been
8535 % working like this in practice, and I should probably have refrained from
8536 % adding it in the first place.
8537 %
8538 % \textbf{Math \& Co.:} A good number of reference types provided by the
8539 % package are meant to cater for document objects commonly used in Mathematics
8540 % and related areas. They are either straight math environments, defined by
8541 % the kernel, \pkg{amsmath} or other packages, or environments which are
8542 % normally not pre-defined by the kernel or the standard classes, but are
8543 % traditionally defined by users with the kernel's \cs{newtheorem} or similar
8544 % constructs available in the \LaTeX{} package ecosystem. For most of them,
8545 % localization should strive as much as possible to use the formal terms,
8546 % jargon really, typically employed by mathematicians, logicians, and friends.
8547 % Namely for the reference types: \texttt{equation}, \texttt{theorem},
8548 % \texttt{lemma}, \texttt{corollary}, \texttt{proposition},
8549 % \texttt{definition}, \texttt{proof}, \texttt{result}, and \texttt{remark}.
8550 % Regarding \texttt{example}, \texttt{exercise}, and \texttt{solution} being
8551 % somewhat less formal is admissible. But the chosen terms should still be
8552 % fit for use in Math related contexts, and should be assumed were created by
8553 % \cs{newtheorem} or similar, even if users may well find other uses for these
8554 % types.
8555 %
8556 % \textbf{Code:} A couple of reference types are provided for code related
8557 % environments: \texttt{algorithm} and \texttt{listing}. By experience, the
8558 % \texttt{listing} type has already proven to be a particularly challenging
8559 % one. Formally, it should be a good default term to encompass anything which
8560 % may regularly be included in a \env{lstlisting} environment as provided by
8561 % the \pkg{listings} package. However, it seems that in different languages
8562 % it is quite difficult to find a satisfying term for it. Though my English
8563 % is decent, I'm not a native speaker, still I'm not even sure how common the
8564 % term is used for the purpose even in English. It seems to be traditional
8565 % enough in the \LaTeX{} community at least. In doubt, pend to the jargon
8566 % side, anglicism if need be. Since we are bound to displease mostly everyone
8567 % anyway, at least we do so in a consistent manner.
8568 %
8569 % \textbf{Completeness and abbreviated forms:} Ideally, the language file
8570 % should be as complete as possible. ``Complete'' meaning it contains: i) the
8571 % defaults for all basic separators, \opt{namesep}, \opt{pairsep},
8572 % \opt{listsep}, \opt{lastsep}, \opt{tpairsep}, \opt{tlistsep},
8573 % \opt{tlastsep}, \opt{notesep}, and \opt{rangesep}; ii) the non-abbreviated
8574 % forms of names for all the supported reference types, according to the
8575 % language definitions, that is, usually for \opt{Name-sg}, \opt{name-sg},
8576 % \opt{Name-pl}, \opt{name-pl}, but only for the capitalized forms if the
8577 % language was declared with \opt{allcaps} option, and names for each variant,
8578 % if the language was declared with \opt{variants}; iii) genders for each
8579 % reference type, if the language was declared with \opt{gender}. The
8580 % language file may include some other things, like some type specific
8581 % settings for separators or refbounds, and also some abbreviated name forms.
8582 % In the case of abbreviated name forms, it is usual and desirable to provide
8583 % some, but they should be used sparingly, only for cases where the
8584 % abbreviation is a common and well established tradition for the language.
8585 % The reason is that \texttt{abbrev=true} is quite a common use case, and it
8586 % is easier to provide an occasional wanted abbreviated form, if the language
8587 % file didn't include it, than it is to disable several unwanted ones, if the
8588 % language file includes too many of them. What should be aimed at is to
8589 % provide a good default abbreviations set. Unusual or disputable
8590 % abbreviations should be avoided. In particular, there is no need at all to
8591 % provide the same set of abbreviations for each language. It is not because
8592 % English has them for a given type that some other language has to have them,
8593 % and it is not because English lacks them for another type, that other
8594 % languages shouldn't have them. Still, with regard to abbreviated forms, it
8595 % is better to be conservative than opinionated.
8596 %
8597 % \textbf{\pkg{babel} names:} As is known, \pkg{babel} defines a set of
8598 % captions for different document objects for each supported language. In
8599 % some cases, they intersect with the objects referred to with
8600 % cross-references, in which case consistency with \pkg{babel} should be
8601 % maintained as much as possible. This is specially the case for prominent
8602 % and traditional objects, such as \cs{chaptername}, \cs{figurename},
8603 % \cs{tablename}, \cs{pagename}, \cs{partname}, and \cs{appendixname}. This
8604 % is not set in stone, but there should be good reason to diverge from it. In
8605 % particular, if a certain term is contentious in a given language,
8606 % \pkg{babel}'s default should be preferred. For example, ``table''
8607 % vs. ``tableau'' in French, or ``cuadro'' vs. ``tabla'' in Spanish.
8608 %
8609 % \textbf{Input encoding of language files:} When \pkg{zref-clever} was
8610 % released, the \LaTeX{} kernel already used UTF-8 as default input encoding.
8611 % Indeed, \pkg{zref-clever} requires a kernel even newer than the one where
8612 % the default input encoding was changed. That given, UTF-8 input encoding
8613 % was made a requirement of the package, and hence the language files should
8614 % be in UTF-8, since it makes them easier to read and maintain than LICR.
8615 %
8616 % \textbf{Precedence rule for options in the language files:} Any option given
8617 % twice or more times has to have some precedence rule. Normally, the
8618 % language files should not contain options in duplicity, but they may happen
8619 % when setting some ``group'' \opt{refbounds} options, in which case
8620 % precedence rules become relevant. For user facing options (those set with
8621 % \cs{zcLanguageSetup}), the option is always set, regardless of its previous
8622 % state. Which means that the last value takes precedence. For the language
8623 % files, we have to load them at \texttt{begindocument} (or later), since
8624 % that's the point where we know from \pkg{babel} or \pkg{polyglossia} the
8625 % \cs{languagename}. But we also don't want to override any options the user
8626 % has actively set in the preamble. So the language files only set the values
8627 % if they were not previously set. In other words, for them the precedence
8628 % order is inverted, the first value takes precedence.
8629 %
8630 % \textbf{\pkg{zref-vario}:} If you are interested in the localization of
8631 % \pkg{zref-clever} to your language, and willing to contribute to it, you may
8632 % also want to consider doing the same for the companion package
8633 % \pkg{zref-vario}. It is actually a much simpler task than localizing
8634 % \pkg{zref-clever}.
8635 %
8636 %
8637 % \subsection{English}
8638 %
8639 % English language file has been initially provided by the author.
8640 %
8641 % \begin{macrocode}
8642 %<*package>
8643 \zcDeclareLanguage { english }
8644 \zcDeclareLanguageAlias { american } { english }
8645 \zcDeclareLanguageAlias { australian } { english }
8646 \zcDeclareLanguageAlias { british } { english }
8647 \zcDeclareLanguageAlias { canadian } { english }
8648 \zcDeclareLanguageAlias { newzealand } { english }
8649 \zcDeclareLanguageAlias { UKenglish } { english }
8650 \zcDeclareLanguageAlias { USenglish } { english }
8651 %</package>
8652 % \end{macrocode}
8653 %
8654 % \begin{macrocode}
8655 %<*lang-english>
8656 % \end{macrocode}
8657 %
8658 % \begin{macrocode}
8659 namesep = {\nobreakspace} ,
8660 pairsep = {~and\nobreakspace} ,
8661 listsep = {,~} ,
8662 lastsep = {~and\nobreakspace} ,
8663 tpairsep = {~and\nobreakspace} ,
8664 tlistsep = {,~} ,
8665 tlastsep = {,~and\nobreakspace} ,
8666 notesep = {~} ,
8667 rangesep = {~to\nobreakspace} ,
8668
8669 type = book ,
8670 Name-sg = Book ,
8671 name-sg = book ,
8672 Name-pl = Books ,
8673 name-pl = books ,
8674
8675 type = part ,
8676 Name-sg = Part ,
8677 name-sg = part ,
8678 Name-pl = Parts ,
8679 name-pl = parts ,
8680
8681 type = chapter ,
8682 Name-sg = Chapter ,
8683 name-sg = chapter ,
8684 Name-pl = Chapters ,
8685 name-pl = chapters ,
8686
8687 type = section ,
8688 Name-sg = Section ,
8689 name-sg = section ,
8690 Name-pl = Sections ,
8691 name-pl = sections ,
8692
8693 type = paragraph ,
8694 Name-sg = Paragraph ,
8695 name-sg = paragraph ,
8696 Name-pl = Paragraphs ,
8697 name-pl = paragraphs ,
8698 Name-sg-ab = Par. ,
8699 name-sg-ab = par. ,
8700 Name-pl-ab = Par. ,
8701 name-pl-ab = par. ,
8702
8703 type = appendix ,
8704 Name-sg = Appendix ,
8705 name-sg = appendix ,
8706 Name-pl = Appendices ,
8707 name-pl = appendices ,
8708
8709 type = page ,
8710 Name-sg = Page ,
8711 name-sg = page ,
8712 Name-pl = Pages ,
8713 name-pl = pages ,
8714 rangesep = {\textendash} ,
8715 rangetopair = false ,
8716
8717 type = line ,
8718 Name-sg = Line ,
8719 name-sg = line ,
8720 Name-pl = Lines ,
8721 name-pl = lines ,
8722
8723 type = figure ,
8724 Name-sg = Figure ,
8725 name-sg = figure ,
8726 Name-pl = Figures ,
8727 name-pl = figures ,
8728 Name-sg-ab = Fig. ,
8729 name-sg-ab = fig. ,
8730 Name-pl-ab = Figs. ,
8731 name-pl-ab = figs. ,
8732
8733 type = table ,
8734 Name-sg = Table ,
8735 name-sg = table ,
8736 Name-pl = Tables ,
8737 name-pl = tables ,
8738
8739 type = item ,
8740 Name-sg = Item ,
8741 name-sg = item ,
8742 Name-pl = Items ,
8743 name-pl = items ,
8744
8745 type = footnote ,
8746 Name-sg = Footnote ,
8747 name-sg = footnote ,
8748 Name-pl = Footnotes ,
8749 name-pl = footnotes ,
8750
8751 type = endnote ,
8752 Name-sg = Note ,
8753 name-sg = note ,
8754 Name-pl = Notes ,
8755 name-pl = notes ,
8756
8757 type = note ,
8758 Name-sg = Note ,
8759 name-sg = note ,
8760 Name-pl = Notes ,
8761 name-pl = notes ,
8762
8763 type = equation ,
8764 Name-sg = Equation ,
8765 name-sg = equation ,
8766 Name-pl = Equations ,
8767 name-pl = equations ,
8768 Name-sg-ab = Eq. ,
8769 name-sg-ab = eq. ,
8770 Name-pl-ab = Eqs. ,
8771 name-pl-ab = eqs. ,
8772 refbounds-first-sg = {,(,),} ,
8773 refbounds = {(,,,)} ,
8774
8775 type = theorem ,
8776 Name-sg = Theorem ,
8777 name-sg = theorem ,
8778 Name-pl = Theorems ,
8779 name-pl = theorems ,
8780
8781 type = lemma ,
8782 Name-sg = Lemma ,
8783 name-sg = lemma ,
8784 Name-pl = Lemmas ,
8785 name-pl = lemmas ,
8786
8787 type = corollary ,
8788 Name-sg = Corollary ,
8789 name-sg = corollary ,
8790 Name-pl = Corollaries ,
8791 name-pl = corollaries ,
8792
8793 type = proposition ,
8794 Name-sg = Proposition ,
8795 name-sg = proposition ,
8796 Name-pl = Propositions ,
8797 name-pl = propositions ,
8798
8799 type = definition ,
8800 Name-sg = Definition ,
8801 name-sg = definition ,
8802 Name-pl = Definitions ,
8803 name-pl = definitions ,
8804
8805 type = proof ,
8806 Name-sg = Proof ,
8807 name-sg = proof ,
8808 Name-pl = Proofs ,
8809 name-pl = proofs ,
8810
8811 type = result ,
8812 Name-sg = Result ,
8813 name-sg = result ,
8814 Name-pl = Results ,
8815 name-pl = results ,
8816
8817 type = remark ,
8818 Name-sg = Remark ,
8819 name-sg = remark ,
8820 Name-pl = Remarks ,
8821 name-pl = remarks ,
8822
8823 type = example ,
8824 Name-sg = Example ,
8825 name-sg = example ,
8826 Name-pl = Examples ,
8827 name-pl = examples ,
8828
8829 type = algorithm ,
8830 Name-sg = Algorithm ,
8831 name-sg = algorithm ,
8832 Name-pl = Algorithms ,
8833 name-pl = algorithms ,
8834
8835 type = listing ,
8836 Name-sg = Listing ,
8837 name-sg = listing ,
8838 Name-pl = Listings ,
8839 name-pl = listings ,
8840
8841 type = exercise ,
8842 Name-sg = Exercise ,
8843 name-sg = exercise ,
8844 Name-pl = Exercises ,
8845 name-pl = exercises ,
8846
8847 type = solution ,
8848 Name-sg = Solution ,
8849 name-sg = solution ,
8850 Name-pl = Solutions ,
8851 name-pl = solutions ,
8852 % \end{macrocode}
8853 %
8854 % \begin{macrocode}
8855 %</lang-english>
8856 % \end{macrocode}
8857 %
8858 %
8859 %
8860 % \subsection{German}
8861 %
8862 % German language file has been initially provided by the author.
8863 %
8864 % \pkg{babel-german} also has \file{.ldf}s for \texttt{germanb} and
8865 % \texttt{ngermanb}, but they are deprecated as options and, if used, they
8866 % fall back respectively to \texttt{german} and \texttt{ngerman}.
8867 %
8868 % \begin{macrocode}
8869 %<*package>
8870 \zcDeclareLanguage
8871 [ variants = { N , A , D , G } , gender = { f , m , n } , allcaps ]
8872 { german }
8873 \zcDeclareLanguageAlias { ngerman } { german }
8874 \zcDeclareLanguageAlias { austrian } { german }
8875 \zcDeclareLanguageAlias { naustrian } { german }
8876 \zcDeclareLanguageAlias { swissgerman } { german }
8877 \zcDeclareLanguageAlias { nswissgerman } { german }
8878 %</package>
8879 % \end{macrocode}
8880 %
8881 % \begin{macrocode}
8882 %<*lang-german>
8883 % \end{macrocode}
8884 %
8885 % \begin{macrocode}
8886 namesep = {\nobreakspace} ,
8887 pairsep = {~und\nobreakspace} ,
8888 listsep = {,~} ,
8889 lastsep = {~und\nobreakspace} ,
8890 tpairsep = {~und\nobreakspace} ,
8891 tlistsep = {,~} ,
8892 tlastsep = {~und\nobreakspace} ,
8893 notesep = {~} ,
8894 rangesep = {~bis\nobreakspace} ,
8895
8896 type = book ,
8897 gender = n ,
8898 variant = N ,
8899 Name-sg = Buch ,
8900 Name-pl = Bücher ,
8901 variant = A ,
8902 Name-sg = Buch ,
8903 Name-pl = Bücher ,
8904 variant = D ,
8905 Name-sg = Buch ,
8906 Name-pl = Büchern ,
8907 variant = G ,
8908 Name-sg = Buches ,
8909 Name-pl = Bücher ,
8910
8911 type = part ,
8912 gender = m ,
8913 variant = N ,
8914 Name-sg = Teil ,
8915 Name-pl = Teile ,
8916 variant = A ,
8917 Name-sg = Teil ,
8918 Name-pl = Teile ,
8919 variant = D ,
8920 Name-sg = Teil ,
8921 Name-pl = Teilen ,
8922 variant = G ,
8923 Name-sg = Teiles ,
8924 Name-pl = Teile ,
8925
8926 type = chapter ,
8927 gender = n ,
8928 variant = N ,
8929 Name-sg = Kapitel ,
8930 Name-pl = Kapitel ,
8931 variant = A ,
8932 Name-sg = Kapitel ,
8933 Name-pl = Kapitel ,
8934 variant = D ,
8935 Name-sg = Kapitel ,
8936 Name-pl = Kapiteln ,
8937 variant = G ,
8938 Name-sg = Kapitels ,
8939 Name-pl = Kapitel ,
8940
8941 type = section ,
8942 gender = m ,
8943 variant = N ,
8944 Name-sg = Abschnitt ,
8945 Name-pl = Abschnitte ,
8946 variant = A ,
8947 Name-sg = Abschnitt ,
8948 Name-pl = Abschnitte ,
8949 variant = D ,
8950 Name-sg = Abschnitt ,
8951 Name-pl = Abschnitten ,
8952 variant = G ,
8953 Name-sg = Abschnitts ,
8954 Name-pl = Abschnitte ,
8955
8956 type = paragraph ,
8957 gender = m ,
8958 variant = N ,
8959 Name-sg = Absatz ,
8960 Name-pl = Absätze ,
8961 variant = A ,
8962 Name-sg = Absatz ,
8963 Name-pl = Absätze ,
8964 variant = D ,
8965 Name-sg = Absatz ,
8966 Name-pl = Absätzen ,
8967 variant = G ,
8968 Name-sg = Absatzes ,
8969 Name-pl = Absätze ,
8970
8971 type = appendix ,
8972 gender = m ,
8973 variant = N ,
8974 Name-sg = Anhang ,
8975 Name-pl = Anhänge ,
8976 variant = A ,
8977 Name-sg = Anhang ,
8978 Name-pl = Anhänge ,
8979 variant = D ,
8980 Name-sg = Anhang ,
8981 Name-pl = Anhängen ,
8982 variant = G ,
8983 Name-sg = Anhangs ,
8984 Name-pl = Anhänge ,
8985
8986 type = page ,
8987 gender = f ,
8988 variant = N ,
8989 Name-sg = Seite ,
8990 Name-pl = Seiten ,
8991 variant = A ,
8992 Name-sg = Seite ,
8993 Name-pl = Seiten ,
8994 variant = D ,
8995 Name-sg = Seite ,
8996 Name-pl = Seiten ,
8997 variant = G ,
8998 Name-sg = Seite ,
8999 Name-pl = Seiten ,
9000 rangesep = {\textendash} ,
9001 rangetopair = false ,
9002
9003 type = line ,
9004 gender = f ,
9005 variant = N ,
9006 Name-sg = Zeile ,
9007 Name-pl = Zeilen ,
9008 variant = A ,
9009 Name-sg = Zeile ,
9010 Name-pl = Zeilen ,
9011 variant = D ,
9012 Name-sg = Zeile ,
9013 Name-pl = Zeilen ,
9014 variant = G ,
9015 Name-sg = Zeile ,
9016 Name-pl = Zeilen ,
9017
9018 type = figure ,
9019 gender = f ,
9020 variant = N ,
9021 Name-sg = Abbildung ,
9022 Name-pl = Abbildungen ,
9023 Name-sg-ab = Abb. ,
9024 Name-pl-ab = Abb. ,
9025 variant = A ,
9026 Name-sg = Abbildung ,
9027 Name-pl = Abbildungen ,
9028 Name-sg-ab = Abb. ,
9029 Name-pl-ab = Abb. ,
9030 variant = D ,
9031 Name-sg = Abbildung ,
9032 Name-pl = Abbildungen ,
9033 Name-sg-ab = Abb. ,
9034 Name-pl-ab = Abb. ,
9035 variant = G ,
9036 Name-sg = Abbildung ,
9037 Name-pl = Abbildungen ,
9038 Name-sg-ab = Abb. ,
9039 Name-pl-ab = Abb. ,
9040
9041 type = table ,
9042 gender = f ,
9043 variant = N ,
9044 Name-sg = Tabelle ,
9045 Name-pl = Tabellen ,
9046 variant = A ,
9047 Name-sg = Tabelle ,
9048 Name-pl = Tabellen ,
9049 variant = D ,
9050 Name-sg = Tabelle ,
9051 Name-pl = Tabellen ,
9052 variant = G ,
9053 Name-sg = Tabelle ,
9054 Name-pl = Tabellen ,
9055
9056 type = item ,
9057 gender = m ,
9058 variant = N ,
9059 Name-sg = Punkt ,
9060 Name-pl = Punkte ,
9061 variant = A ,
9062 Name-sg = Punkt ,
9063 Name-pl = Punkte ,
9064 variant = D ,
9065 Name-sg = Punkt ,
9066 Name-pl = Punkten ,
9067 variant = G ,
9068 Name-sg = Punktes ,
9069 Name-pl = Punkte ,
9070
9071 type = footnote ,
9072 gender = f ,
9073 variant = N ,
9074 Name-sg = Fußnote ,
9075 Name-pl = Fußnoten ,
9076 variant = A ,
9077 Name-sg = Fußnote ,
9078 Name-pl = Fußnoten ,
9079 variant = D ,
9080 Name-sg = Fußnote ,
9081 Name-pl = Fußnoten ,
9082 variant = G ,
9083 Name-sg = Fußnote ,
9084 Name-pl = Fußnoten ,
9085
9086 type = endnote ,
9087 gender = f ,
9088 variant = N ,
9089 Name-sg = Endnote ,
9090 Name-pl = Endnoten ,
9091 variant = A ,
9092 Name-sg = Endnote ,
9093 Name-pl = Endnoten ,
9094 variant = D ,
9095 Name-sg = Endnote ,
9096 Name-pl = Endnoten ,
9097 variant = G ,
9098 Name-sg = Endnote ,
9099 Name-pl = Endnoten ,
9100
9101 type = note ,
9102 gender = f ,
9103 variant = N ,
9104 Name-sg = Anmerkung ,
9105 Name-pl = Anmerkungen ,
9106 variant = A ,
9107 Name-sg = Anmerkung ,
9108 Name-pl = Anmerkungen ,
9109 variant = D ,
9110 Name-sg = Anmerkung ,
9111 Name-pl = Anmerkungen ,
9112 variant = G ,
9113 Name-sg = Anmerkung ,
9114 Name-pl = Anmerkungen ,
9115
9116 type = equation ,
9117 gender = f ,
9118 variant = N ,
9119 Name-sg = Gleichung ,
9120 Name-pl = Gleichungen ,
9121 variant = A ,
9122 Name-sg = Gleichung ,
9123 Name-pl = Gleichungen ,
9124 variant = D ,
9125 Name-sg = Gleichung ,
9126 Name-pl = Gleichungen ,
9127 variant = G ,
9128 Name-sg = Gleichung ,
9129 Name-pl = Gleichungen ,
9130 refbounds-first-sg = {,(,),} ,
9131 refbounds = {(,,,)} ,
9132
9133 type = theorem ,
9134 gender = n ,
9135 variant = N ,
9136 Name-sg = Theorem ,
9137 Name-pl = Theoreme ,
9138 variant = A ,
9139 Name-sg = Theorem ,
9140 Name-pl = Theoreme ,
9141 variant = D ,
9142 Name-sg = Theorem ,
9143 Name-pl = Theoremen ,
9144 variant = G ,
9145 Name-sg = Theorems ,
9146 Name-pl = Theoreme ,
9147
9148 type = lemma ,
9149 gender = n ,
9150 variant = N ,
9151 Name-sg = Lemma ,
9152 Name-pl = Lemmata ,
9153 variant = A ,
9154 Name-sg = Lemma ,
9155 Name-pl = Lemmata ,
9156 variant = D ,
9157 Name-sg = Lemma ,
9158 Name-pl = Lemmata ,
9159 variant = G ,
9160 Name-sg = Lemmas ,
9161 Name-pl = Lemmata ,
9162
9163 type = corollary ,
9164 gender = n ,
9165 variant = N ,
9166 Name-sg = Korollar ,
9167 Name-pl = Korollare ,
9168 variant = A ,
9169 Name-sg = Korollar ,
9170 Name-pl = Korollare ,
9171 variant = D ,
9172 Name-sg = Korollar ,
9173 Name-pl = Korollaren ,
9174 variant = G ,
9175 Name-sg = Korollars ,
9176 Name-pl = Korollare ,
9177
9178 type = proposition ,
9179 gender = m ,
9180 variant = N ,
9181 Name-sg = Satz ,
9182 Name-pl = Sätze ,
9183 variant = A ,
9184 Name-sg = Satz ,
9185 Name-pl = Sätze ,
9186 variant = D ,
9187 Name-sg = Satz ,
9188 Name-pl = Sätzen ,
9189 variant = G ,
9190 Name-sg = Satzes ,
9191 Name-pl = Sätze ,
9192
9193 type = definition ,
9194 gender = f ,
9195 variant = N ,
9196 Name-sg = Definition ,
9197 Name-pl = Definitionen ,
9198 variant = A ,
9199 Name-sg = Definition ,
9200 Name-pl = Definitionen ,
9201 variant = D ,
9202 Name-sg = Definition ,
9203 Name-pl = Definitionen ,
9204 variant = G ,
9205 Name-sg = Definition ,
9206 Name-pl = Definitionen ,
9207
9208 type = proof ,
9209 gender = m ,
9210 variant = N ,
9211 Name-sg = Beweis ,
9212 Name-pl = Beweise ,
9213 variant = A ,
9214 Name-sg = Beweis ,
9215 Name-pl = Beweise ,
9216 variant = D ,
9217 Name-sg = Beweis ,
9218 Name-pl = Beweisen ,
9219 variant = G ,
9220 Name-sg = Beweises ,
9221 Name-pl = Beweise ,
9222
9223 type = result ,
9224 gender = n ,
9225 variant = N ,
9226 Name-sg = Ergebnis ,
9227 Name-pl = Ergebnisse ,
9228 variant = A ,
9229 Name-sg = Ergebnis ,
9230 Name-pl = Ergebnisse ,
9231 variant = D ,
9232 Name-sg = Ergebnis ,
9233 Name-pl = Ergebnissen ,
9234 variant = G ,
9235 Name-sg = Ergebnisses ,
9236 Name-pl = Ergebnisse ,
9237
9238 type = remark ,
9239 gender = f ,
9240 variant = N ,
9241 Name-sg = Bemerkung ,
9242 Name-pl = Bemerkungen ,
9243 variant = A ,
9244 Name-sg = Bemerkung ,
9245 Name-pl = Bemerkungen ,
9246 variant = D ,
9247 Name-sg = Bemerkung ,
9248 Name-pl = Bemerkungen ,
9249 variant = G ,
9250 Name-sg = Bemerkung ,
9251 Name-pl = Bemerkungen ,
9252
9253 type = example ,
9254 gender = n ,
9255 variant = N ,
9256 Name-sg = Beispiel ,
9257 Name-pl = Beispiele ,
9258 variant = A ,
9259 Name-sg = Beispiel ,
9260 Name-pl = Beispiele ,
9261 variant = D ,
9262 Name-sg = Beispiel ,
9263 Name-pl = Beispielen ,
9264 variant = G ,
9265 Name-sg = Beispiels ,
9266 Name-pl = Beispiele ,
9267
9268 type = algorithm ,
9269 gender = m ,
9270 variant = N ,
9271 Name-sg = Algorithmus ,
9272 Name-pl = Algorithmen ,
9273 variant = A ,
9274 Name-sg = Algorithmus ,
9275 Name-pl = Algorithmen ,
9276 variant = D ,
9277 Name-sg = Algorithmus ,
9278 Name-pl = Algorithmen ,
9279 variant = G ,
9280 Name-sg = Algorithmus ,
9281 Name-pl = Algorithmen ,
9282
9283 type = listing ,
9284 gender = n ,
9285 variant = N ,
9286 Name-sg = Listing ,
9287 Name-pl = Listings ,
9288 variant = A ,
9289 Name-sg = Listing ,
9290 Name-pl = Listings ,
9291 variant = D ,
9292 Name-sg = Listing ,
9293 Name-pl = Listings ,
9294 variant = G ,
9295 Name-sg = Listings ,
9296 Name-pl = Listings ,
9297
9298 type = exercise ,
9299 gender = f ,
9300 variant = N ,
9301 Name-sg = Übungsaufgabe ,
9302 Name-pl = Übungsaufgaben ,
9303 variant = A ,
9304 Name-sg = Übungsaufgabe ,
9305 Name-pl = Übungsaufgaben ,
9306 variant = D ,
9307 Name-sg = Übungsaufgabe ,
9308 Name-pl = Übungsaufgaben ,
9309 variant = G ,
9310 Name-sg = Übungsaufgabe ,
9311 Name-pl = Übungsaufgaben ,
9312
9313 type = solution ,
9314 gender = f ,
9315 variant = N ,
9316 Name-sg = Lösung ,
9317 Name-pl = Lösungen ,
9318 variant = A ,
9319 Name-sg = Lösung ,
9320 Name-pl = Lösungen ,
9321 variant = D ,
9322 Name-sg = Lösung ,
9323 Name-pl = Lösungen ,
9324 variant = G ,
9325 Name-sg = Lösung ,
9326 Name-pl = Lösungen ,
9327 % \end{macrocode}
9328 %
9329 % \begin{macrocode}
9330 %</lang-german>
9331 % \end{macrocode}
9332 %
9333 %
9334 %
9335 % \subsection{French}
9336 %
9337 % French language file has been initially provided by the author, and has been
9338 % improved thanks to \contributor{Denis Bitouzé} and \contributor{François
9339 % Lagarde} (at \githubissue{1}) and participants of the Groupe francophone des
9340 % Utilisateurs de \TeX{} (GUTenberg) (at
9341 % \url{https://groups.google.com/g/gut_fr/c/rNLm6weGcyg}) and the
9342 % \texttt{fr.comp.text.tex} (at
9343 % \url{https://groups.google.com/g/fr.comp.text.tex/c/Fa11Tf6MFFs}) mailing
9344 % lists.
9345 %
9346 % \pkg{babel-french} also has \file{.ldf}s for \texttt{francais},
9347 % \texttt{frenchb}, and \texttt{canadien}, but they are deprecated as options
9348 % and, if used, they fall back to either \texttt{french} or \texttt{acadian}.
9349 %
9350 % \begin{macrocode}
9351 %<*package>
9352 \zcDeclareLanguage [ gender = { f , m } ] { french }
9353 \zcDeclareLanguageAlias { acadian } { french }
9354 %</package>
9355 % \end{macrocode}
9356 %
9357 % \begin{macrocode}
9358 %<*lang-french>
9359 % \end{macrocode}
9360 %
9361 % \begin{macrocode}
9362 namesep = {\nobreakspace} ,
9363 pairsep = {~et\nobreakspace} ,
9364 listsep = {,~} ,
9365 lastsep = {~et\nobreakspace} ,
9366 tpairsep = {~et\nobreakspace} ,
9367 tlistsep = {,~} ,
9368 tlastsep = {~et\nobreakspace} ,
9369 notesep = {~} ,
9370 rangesep = {~à\nobreakspace} ,
9371
9372 type = book ,
9373 gender = m ,
9374 Name-sg = Livre ,
9375 name-sg = livre ,
9376 Name-pl = Livres ,
9377 name-pl = livres ,
9378
9379 type = part ,
9380 gender = f ,
9381 Name-sg = Partie ,
9382 name-sg = partie ,
9383 Name-pl = Parties ,
9384 name-pl = parties ,
9385
9386 type = chapter ,
9387 gender = m ,
9388 Name-sg = Chapitre ,
9389 name-sg = chapitre ,
9390 Name-pl = Chapitres ,
9391 name-pl = chapitres ,
9392
9393 type = section ,
9394 gender = f ,
9395 Name-sg = Section ,
9396 name-sg = section ,
9397 Name-pl = Sections ,
9398 name-pl = sections ,
9399
9400 type = paragraph ,
9401 gender = m ,
9402 Name-sg = Paragraphe ,
9403 name-sg = paragraphe ,
9404 Name-pl = Paragraphes ,
9405 name-pl = paragraphes ,
9406
9407 type = appendix ,
9408 gender = f ,
9409 Name-sg = Annexe ,
9410 name-sg = annexe ,
9411 Name-pl = Annexes ,
9412 name-pl = annexes ,
9413
9414 type = page ,
9415 gender = f ,
9416 Name-sg = Page ,
9417 name-sg = page ,
9418 Name-pl = Pages ,
9419 name-pl = pages ,
9420 rangesep = {-} ,
9421 rangetopair = false ,
9422
9423 type = line ,
9424 gender = f ,
9425 Name-sg = Ligne ,
9426 name-sg = ligne ,
9427 Name-pl = Lignes ,
9428 name-pl = lignes ,
9429
9430 type = figure ,
9431 gender = f ,
9432 Name-sg = Figure ,
9433 name-sg = figure ,
9434 Name-pl = Figures ,
9435 name-pl = figures ,
9436
9437 type = table ,
9438 gender = f ,
9439 Name-sg = Table ,
9440 name-sg = table ,
9441 Name-pl = Tables ,
9442 name-pl = tables ,
9443
9444 type = item ,
9445 gender = m ,
9446 Name-sg = Point ,
9447 name-sg = point ,
9448 Name-pl = Points ,
9449 name-pl = points ,
9450
9451 type = footnote ,
9452 gender = f ,
9453 Name-sg = Note ,
9454 name-sg = note ,
9455 Name-pl = Notes ,
9456 name-pl = notes ,
9457
9458 type = endnote ,
9459 gender = f ,
9460 Name-sg = Note ,
9461 name-sg = note ,
9462 Name-pl = Notes ,
9463 name-pl = notes ,
9464
9465 type = note ,
9466 gender = f ,
9467 Name-sg = Note ,
9468 name-sg = note ,
9469 Name-pl = Notes ,
9470 name-pl = notes ,
9471
9472 type = equation ,
9473 gender = f ,
9474 Name-sg = Équation ,
9475 name-sg = équation ,
9476 Name-pl = Équations ,
9477 name-pl = équations ,
9478 refbounds-first-sg = {,(,),} ,
9479 refbounds = {(,,,)} ,
9480
9481 type = theorem ,
9482 gender = m ,
9483 Name-sg = Théorème ,
9484 name-sg = théorème ,
9485 Name-pl = Théorèmes ,
9486 name-pl = théorèmes ,
9487
9488 type = lemma ,
9489 gender = m ,
9490 Name-sg = Lemme ,
9491 name-sg = lemme ,
9492 Name-pl = Lemmes ,
9493 name-pl = lemmes ,
9494
9495 type = corollary ,
9496 gender = m ,
9497 Name-sg = Corollaire ,
9498 name-sg = corollaire ,
9499 Name-pl = Corollaires ,
9500 name-pl = corollaires ,
9501
9502 type = proposition ,
9503 gender = f ,
9504 Name-sg = Proposition ,
9505 name-sg = proposition ,
9506 Name-pl = Propositions ,
9507 name-pl = propositions ,
9508
9509 type = definition ,
9510 gender = f ,
9511 Name-sg = Définition ,
9512 name-sg = définition ,
9513 Name-pl = Définitions ,
9514 name-pl = définitions ,
9515
9516 type = proof ,
9517 gender = f ,
9518 Name-sg = Démonstration ,
9519 name-sg = démonstration ,
9520 Name-pl = Démonstrations ,
9521 name-pl = démonstrations ,
9522
9523 type = result ,
9524 gender = m ,
9525 Name-sg = Résultat ,
9526 name-sg = résultat ,
9527 Name-pl = Résultats ,
9528 name-pl = résultats ,
9529
9530 type = remark ,
9531 gender = f ,
9532 Name-sg = Remarque ,
9533 name-sg = remarque ,
9534 Name-pl = Remarques ,
9535 name-pl = remarques ,
9536
9537 type = example ,
9538 gender = m ,
9539 Name-sg = Exemple ,
9540 name-sg = exemple ,
9541 Name-pl = Exemples ,
9542 name-pl = exemples ,
9543
9544 type = algorithm ,
9545 gender = m ,
9546 Name-sg = Algorithme ,
9547 name-sg = algorithme ,
9548 Name-pl = Algorithmes ,
9549 name-pl = algorithmes ,
9550
9551 type = listing ,
9552 gender = m ,
9553 Name-sg = Listing ,
9554 name-sg = listing ,
9555 Name-pl = Listings ,
9556 name-pl = listings ,
9557
9558 type = exercise ,
9559 gender = m ,
9560 Name-sg = Exercice ,
9561 name-sg = exercice ,
9562 Name-pl = Exercices ,
9563 name-pl = exercices ,
9564
9565 type = solution ,
9566 gender = f ,
9567 Name-sg = Solution ,
9568 name-sg = solution ,
9569 Name-pl = Solutions ,
9570 name-pl = solutions ,
9571 % \end{macrocode}
9572 %
9573 % \begin{macrocode}
9574 %</lang-french>
9575 % \end{macrocode}
9576 %
9577 %
9578 %
9579 % \subsection{Portuguese}
9580 %
9581 % Portuguese language file provided by the author, who's a native speaker of
9582 % (Brazilian) Portuguese. I do expect this to be sufficiently general, but if
9583 % Portuguese speakers from other places feel the need for a Portuguese
9584 % variant, please let me know.
9585 %
9586 % \begin{macrocode}
9587 %<*package>
9588 \zcDeclareLanguage [ gender = { f , m } ] { portuguese }
9589 \zcDeclareLanguageAlias { brazilian } { portuguese }
9590 \zcDeclareLanguageAlias { brazil } { portuguese }
9591 \zcDeclareLanguageAlias { portuges } { portuguese }
9592 %</package>
9593 % \end{macrocode}
9594 %
9595 % \begin{macrocode}
9596 %<*lang-portuguese>
9597 % \end{macrocode}
9598 %
9599 % \begin{macrocode}
9600 namesep = {\nobreakspace} ,
9601 pairsep = {~e\nobreakspace} ,
9602 listsep = {,~} ,
9603 lastsep = {~e\nobreakspace} ,
9604 tpairsep = {~e\nobreakspace} ,
9605 tlistsep = {,~} ,
9606 tlastsep = {~e\nobreakspace} ,
9607 notesep = {~} ,
9608 rangesep = {~a\nobreakspace} ,
9609
9610 type = book ,
9611 gender = m ,
9612 Name-sg = Livro ,
9613 name-sg = livro ,
9614 Name-pl = Livros ,
9615 name-pl = livros ,
9616
9617 type = part ,
9618 gender = f ,
9619 Name-sg = Parte ,
9620 name-sg = parte ,
9621 Name-pl = Partes ,
9622 name-pl = partes ,
9623
9624 type = chapter ,
9625 gender = m ,
9626 Name-sg = Capítulo ,
9627 name-sg = capítulo ,
9628 Name-pl = Capítulos ,
9629 name-pl = capítulos ,
9630
9631 type = section ,
9632 gender = f ,
9633 Name-sg = Seção ,
9634 name-sg = seção ,
9635 Name-pl = Seções ,
9636 name-pl = seções ,
9637
9638 type = paragraph ,
9639 gender = m ,
9640 Name-sg = Parágrafo ,
9641 name-sg = parágrafo ,
9642 Name-pl = Parágrafos ,
9643 name-pl = parágrafos ,
9644 Name-sg-ab = Par. ,
9645 name-sg-ab = par. ,
9646 Name-pl-ab = Par. ,
9647 name-pl-ab = par. ,
9648
9649 type = appendix ,
9650 gender = m ,
9651 Name-sg = Apêndice ,
9652 name-sg = apêndice ,
9653 Name-pl = Apêndices ,
9654 name-pl = apêndices ,
9655
9656 type = page ,
9657 gender = f ,
9658 Name-sg = Página ,
9659 name-sg = página ,
9660 Name-pl = Páginas ,
9661 name-pl = páginas ,
9662 rangesep = {\textendash} ,
9663 rangetopair = false ,
9664
9665 type = line ,
9666 gender = f ,
9667 Name-sg = Linha ,
9668 name-sg = linha ,
9669 Name-pl = Linhas ,
9670 name-pl = linhas ,
9671
9672 type = figure ,
9673 gender = f ,
9674 Name-sg = Figura ,
9675 name-sg = figura ,
9676 Name-pl = Figuras ,
9677 name-pl = figuras ,
9678 Name-sg-ab = Fig. ,
9679 name-sg-ab = fig. ,
9680 Name-pl-ab = Figs. ,
9681 name-pl-ab = figs. ,
9682
9683 type = table ,
9684 gender = f ,
9685 Name-sg = Tabela ,
9686 name-sg = tabela ,
9687 Name-pl = Tabelas ,
9688 name-pl = tabelas ,
9689
9690 type = item ,
9691 gender = m ,
9692 Name-sg = Item ,
9693 name-sg = item ,
9694 Name-pl = Itens ,
9695 name-pl = itens ,
9696
9697 type = footnote ,
9698 gender = f ,
9699 Name-sg = Nota ,
9700 name-sg = nota ,
9701 Name-pl = Notas ,
9702 name-pl = notas ,
9703
9704 type = endnote ,
9705 gender = f ,
9706 Name-sg = Nota ,
9707 name-sg = nota ,
9708 Name-pl = Notas ,
9709 name-pl = notas ,
9710
9711 type = note ,
9712 gender = f ,
9713 Name-sg = Nota ,
9714 name-sg = nota ,
9715 Name-pl = Notas ,
9716 name-pl = notas ,
9717
9718 type = equation ,
9719 gender = f ,
9720 Name-sg = Equação ,
9721 name-sg = equação ,
9722 Name-pl = Equações ,
9723 name-pl = equações ,
9724 Name-sg-ab = Eq. ,
9725 name-sg-ab = eq. ,
9726 Name-pl-ab = Eqs. ,
9727 name-pl-ab = eqs. ,
9728 refbounds-first-sg = {,(,),} ,
9729 refbounds = {(,,,)} ,
9730
9731 type = theorem ,
9732 gender = m ,
9733 Name-sg = Teorema ,
9734 name-sg = teorema ,
9735 Name-pl = Teoremas ,
9736 name-pl = teoremas ,
9737
9738 type = lemma ,
9739 gender = m ,
9740 Name-sg = Lema ,
9741 name-sg = lema ,
9742 Name-pl = Lemas ,
9743 name-pl = lemas ,
9744
9745 type = corollary ,
9746 gender = m ,
9747 Name-sg = Corolário ,
9748 name-sg = corolário ,
9749 Name-pl = Corolários ,
9750 name-pl = corolários ,
9751
9752 type = proposition ,
9753 gender = f ,
9754 Name-sg = Proposição ,
9755 name-sg = proposição ,
9756 Name-pl = Proposições ,
9757 name-pl = proposições ,
9758
9759 type = definition ,
9760 gender = f ,
9761 Name-sg = Definição ,
9762 name-sg = definição ,
9763 Name-pl = Definições ,
9764 name-pl = definições ,
9765
9766 type = proof ,
9767 gender = f ,
9768 Name-sg = Demonstração ,
9769 name-sg = demonstração ,
9770 Name-pl = Demonstrações ,
9771 name-pl = demonstrações ,
9772
9773 type = result ,
9774 gender = m ,
9775 Name-sg = Resultado ,
9776 name-sg = resultado ,
9777 Name-pl = Resultados ,
9778 name-pl = resultados ,
9779
9780 type = remark ,
9781 gender = f ,
9782 Name-sg = Observação ,
9783 name-sg = observação ,
9784 Name-pl = Observações ,
9785 name-pl = observações ,
9786
9787 type = example ,
9788 gender = m ,
9789 Name-sg = Exemplo ,
9790 name-sg = exemplo ,
9791 Name-pl = Exemplos ,
9792 name-pl = exemplos ,
9793
9794 type = algorithm ,
9795 gender = m ,
9796 Name-sg = Algoritmo ,
9797 name-sg = algoritmo ,
9798 Name-pl = Algoritmos ,
9799 name-pl = algoritmos ,
9800
9801 type = listing ,
9802 gender = f ,
9803 Name-sg = Listagem ,
9804 name-sg = listagem ,
9805 Name-pl = Listagens ,
9806 name-pl = listagens ,
9807
9808 type = exercise ,
9809 gender = m ,
9810 Name-sg = Exercício ,
9811 name-sg = exercício ,
9812 Name-pl = Exercícios ,
9813 name-pl = exercícios ,
9814
9815 type = solution ,
9816 gender = f ,
9817 Name-sg = Solução ,
9818 name-sg = solução ,
9819 Name-pl = Soluções ,
9820 name-pl = soluções ,
9821 % \end{macrocode}
9822 %
9823 % \begin{macrocode}
9824 %</lang-portuguese>
9825 % \end{macrocode}
9826 %
9827 %
9828 %
9829 % \subsection{Spanish}
9830 %
9831 % Spanish language file has been initially provided by the author.
9832 %
9833 % \begin{macrocode}
9834 %<*package>
9835 \zcDeclareLanguage [ gender = { f , m } ] { spanish }
9836 %</package>
9837 % \end{macrocode}
9838 %
9839 % \begin{macrocode}
9840 %<*lang-spanish>
9841 % \end{macrocode}
9842 %
9843 % \begin{macrocode}
9844 namesep = {\nobreakspace} ,
9845 pairsep = {~y\nobreakspace} ,
9846 listsep = {,~} ,
9847 lastsep = {~y\nobreakspace} ,
9848 tpairsep = {~y\nobreakspace} ,
9849 tlistsep = {,~} ,
9850 tlastsep = {~y\nobreakspace} ,
9851 notesep = {~} ,
9852 rangesep = {~a\nobreakspace} ,
9853
9854 type = book ,
9855 gender = m ,
9856 Name-sg = Libro ,
9857 name-sg = libro ,
9858 Name-pl = Libros ,
9859 name-pl = libros ,
9860
9861 type = part ,
9862 gender = f ,
9863 Name-sg = Parte ,
9864 name-sg = parte ,
9865 Name-pl = Partes ,
9866 name-pl = partes ,
9867
9868 type = chapter ,
9869 gender = m ,
9870 Name-sg = Capítulo ,
9871 name-sg = capítulo ,
9872 Name-pl = Capítulos ,
9873 name-pl = capítulos ,
9874
9875 type = section ,
9876 gender = f ,
9877 Name-sg = Sección ,
9878 name-sg = sección ,
9879 Name-pl = Secciones ,
9880 name-pl = secciones ,
9881
9882 type = paragraph ,
9883 gender = m ,
9884 Name-sg = Párrafo ,
9885 name-sg = párrafo ,
9886 Name-pl = Párrafos ,
9887 name-pl = párrafos ,
9888
9889 type = appendix ,
9890 gender = m ,
9891 Name-sg = Apéndice ,
9892 name-sg = apéndice ,
9893 Name-pl = Apéndices ,
9894 name-pl = apéndices ,
9895
9896 type = page ,
9897 gender = f ,
9898 Name-sg = Página ,
9899 name-sg = página ,
9900 Name-pl = Páginas ,
9901 name-pl = páginas ,
9902 rangesep = {\textendash} ,
9903 rangetopair = false ,
9904
9905 type = line ,
9906 gender = f ,
9907 Name-sg = Línea ,
9908 name-sg = línea ,
9909 Name-pl = Líneas ,
9910 name-pl = líneas ,
9911
9912 type = figure ,
9913 gender = f ,
9914 Name-sg = Figura ,
9915 name-sg = figura ,
9916 Name-pl = Figuras ,
9917 name-pl = figuras ,
9918
9919 type = table ,
9920 gender = m ,
9921 Name-sg = Cuadro ,
9922 name-sg = cuadro ,
9923 Name-pl = Cuadros ,
9924 name-pl = cuadros ,
9925
9926 type = item ,
9927 gender = m ,
9928 Name-sg = Punto ,
9929 name-sg = punto ,
9930 Name-pl = Puntos ,
9931 name-pl = puntos ,
9932
9933 type = footnote ,
9934 gender = f ,
9935 Name-sg = Nota ,
9936 name-sg = nota ,
9937 Name-pl = Notas ,
9938 name-pl = notas ,
9939
9940 type = endnote ,
9941 gender = f ,
9942 Name-sg = Nota ,
9943 name-sg = nota ,
9944 Name-pl = Notas ,
9945 name-pl = notas ,
9946
9947 type = note ,
9948 gender = f ,
9949 Name-sg = Nota ,
9950 name-sg = nota ,
9951 Name-pl = Notas ,
9952 name-pl = notas ,
9953
9954 type = equation ,
9955 gender = f ,
9956 Name-sg = Ecuación ,
9957 name-sg = ecuación ,
9958 Name-pl = Ecuaciones ,
9959 name-pl = ecuaciones ,
9960 refbounds-first-sg = {,(,),} ,
9961 refbounds = {(,,,)} ,
9962
9963 type = theorem ,
9964 gender = m ,
9965 Name-sg = Teorema ,
9966 name-sg = teorema ,
9967 Name-pl = Teoremas ,
9968 name-pl = teoremas ,
9969
9970 type = lemma ,
9971 gender = m ,
9972 Name-sg = Lema ,
9973 name-sg = lema ,
9974 Name-pl = Lemas ,
9975 name-pl = lemas ,
9976
9977 type = corollary ,
9978 gender = m ,
9979 Name-sg = Corolario ,
9980 name-sg = corolario ,
9981 Name-pl = Corolarios ,
9982 name-pl = corolarios ,
9983
9984 type = proposition ,
9985 gender = f ,
9986 Name-sg = Proposición ,
9987 name-sg = proposición ,
9988 Name-pl = Proposiciones ,
9989 name-pl = proposiciones ,
9990
9991 type = definition ,
9992 gender = f ,
9993 Name-sg = Definición ,
9994 name-sg = definición ,
9995 Name-pl = Definiciones ,
9996 name-pl = definiciones ,
9997
9998 type = proof ,
9999 gender = f ,
10000 Name-sg = Demostración ,
10001 name-sg = demostración ,
10002 Name-pl = Demostraciones ,
10003 name-pl = demostraciones ,
10004
10005 type = result ,
10006 gender = m ,
10007 Name-sg = Resultado ,
10008 name-sg = resultado ,
10009 Name-pl = Resultados ,
10010 name-pl = resultados ,
10011
10012 type = remark ,
10013 gender = f ,
10014 Name-sg = Observación ,
10015 name-sg = observación ,
10016 Name-pl = Observaciones ,
10017 name-pl = observaciones ,
10018
10019 type = example ,
10020 gender = m ,
10021 Name-sg = Ejemplo ,
10022 name-sg = ejemplo ,
10023 Name-pl = Ejemplos ,
10024 name-pl = ejemplos ,
10025
10026 type = algorithm ,
10027 gender = m ,
10028 Name-sg = Algoritmo ,
10029 name-sg = algoritmo ,
10030 Name-pl = Algoritmos ,
10031 name-pl = algoritmos ,
10032
10033 type = listing ,
10034 gender = m ,
10035 Name-sg = Listado ,
10036 name-sg = listado ,
10037 Name-pl = Listados ,
10038 name-pl = listados ,
10039
10040 type = exercise ,
10041 gender = m ,
10042 Name-sg = Ejercicio ,
10043 name-sg = ejercicio ,
10044 Name-pl = Ejercicios ,
10045 name-pl = ejercicios ,
10046
10047 type = solution ,
10048 gender = f ,
10049 Name-sg = Solución ,
10050 name-sg = solución ,
10051 Name-pl = Soluciones ,
10052 name-pl = soluciones ,
10053 % \end{macrocode}
10054 %
10055 % \begin{macrocode}
10056 %</lang-spanish>
10057 % \end{macrocode}
10058 %
10059 %
10060 %
10061 % \subsection{Dutch}
10062 %
10063 % Dutch language file initially contributed by \contributor{\username{niluxv}}
10064 % (\githubPR{5}). All genders were checked against the ``Dikke Van Dale''.
10065 % Many words have multiple genders.
10066 %
10067 % \begin{macrocode}
10068 %<*package>
10069 \zcDeclareLanguage [ gender = { f , m , n } ] { dutch }
10070 %</package>
10071 % \end{macrocode}
10072 %
10073 % \begin{macrocode}
10074 %<*lang-dutch>
10075 % \end{macrocode}
10076 %
10077 % \begin{macrocode}
10078 namesep = {\nobreakspace} ,
10079 pairsep = {~en\nobreakspace} ,
10080 listsep = {,~} ,
10081 lastsep = {~en\nobreakspace} ,
10082 tpairsep = {~en\nobreakspace} ,
10083 tlistsep = {,~} ,
10084 tlastsep = {,~en\nobreakspace} ,
10085 notesep = {~} ,
10086 rangesep = {~t/m\nobreakspace} ,
10087
10088 type = book ,
10089 gender = n ,
10090 Name-sg = Boek ,
10091 name-sg = boek ,
10092 Name-pl = Boeken ,
10093 name-pl = boeken ,
10094
10095 type = part ,
10096 gender = n ,
10097 Name-sg = Deel ,
10098 name-sg = deel ,
10099 Name-pl = Delen ,
10100 name-pl = delen ,
10101
10102 type = chapter ,
10103 gender = n ,
10104 Name-sg = Hoofdstuk ,
10105 name-sg = hoofdstuk ,
10106 Name-pl = Hoofdstukken ,
10107 name-pl = hoofdstukken ,
10108
10109 type = section ,
10110 gender = m ,
10111 Name-sg = Paragraaf ,
10112 name-sg = paragraaf ,
10113 Name-pl = Paragrafen ,
10114 name-pl = paragrafen ,
10115
10116 type = paragraph ,
10117 gender = f ,
10118 Name-sg = Alinea ,
10119 name-sg = alinea ,
10120 Name-pl = Alinea's ,
10121 name-pl = alinea's ,
10122
10123 % \end{macrocode}
10124 % 2022-12-27, \contributor{\username{niluxv}}: ``bijlage'' is chosen over
10125 % ``appendix'' (plural ``appendices'', gender: m, n) for consistency with
10126 % babel/polyglossia. ``bijlages'' is also a valid plural; ``bijlagen'' is
10127 % chosen for consistency with babel/polyglossia.
10128 % \begin{macrocode}
10129 type = appendix ,
10130 gender = { f, m } ,
10131 Name-sg = Bijlage ,
10132 name-sg = bijlage ,
10133 Name-pl = Bijlagen ,
10134 name-pl = bijlagen ,
10135
10136 type = page ,
10137 gender = { f , m } ,
10138 Name-sg = Pagina ,
10139 name-sg = pagina ,
10140 Name-pl = Pagina's ,
10141 name-pl = pagina's ,
10142 rangesep = {\textendash} ,
10143 rangetopair = false ,
10144
10145 type = line ,
10146 gender = m ,
10147 Name-sg = Regel ,
10148 name-sg = regel ,
10149 Name-pl = Regels ,
10150 name-pl = regels ,
10151
10152 type = figure ,
10153 gender = { n , f , m } ,
10154 Name-sg = Figuur ,
10155 name-sg = figuur ,
10156 Name-pl = Figuren ,
10157 name-pl = figuren ,
10158
10159 type = table ,
10160 gender = { f , m } ,
10161 Name-sg = Tabel ,
10162 name-sg = tabel ,
10163 Name-pl = Tabellen ,
10164 name-pl = tabellen ,
10165
10166 type = item ,
10167 gender = n ,
10168 Name-sg = Punt ,
10169 name-sg = punt ,
10170 Name-pl = Punten ,
10171 name-pl = punten ,
10172
10173 type = footnote ,
10174 gender = { f , m } ,
10175 Name-sg = Voetnoot ,
10176 name-sg = voetnoot ,
10177 Name-pl = Voetnoten ,
10178 name-pl = voetnoten ,
10179
10180 type = endnote ,
10181 gender = { f , m } ,
10182 Name-sg = Eindnoot ,
10183 name-sg = eindnoot ,
10184 Name-pl = Eindnoten ,
10185 name-pl = eindnoten ,
10186
10187 type = note ,
10188 gender = f ,
10189 Name-sg = Opmerking ,
10190 name-sg = opmerking ,
10191 Name-pl = Opmerkingen ,
10192 name-pl = opmerkingen ,
10193
10194 type = equation ,
10195 gender = f ,
10196 Name-sg = Vergelijking ,
10197 name-sg = vergelijking ,
10198 Name-pl = Vergelijkingen ,
10199 name-pl = vergelijkingen ,
10200 Name-sg-ab = Vgl. ,
10201 name-sg-ab = vgl. ,
10202 Name-pl-ab = Vgl.'s ,
10203 name-pl-ab = vgl.'s ,
10204 refbounds-first-sg = {,(,),} ,
10205 refbounds = {(,,,)} ,
10206
10207 type = theorem ,
10208 gender = f ,
10209 Name-sg = Stelling ,
10210 name-sg = stelling ,
10211 Name-pl = Stellingen ,
10212 name-pl = stellingen ,
10213
10214 % \end{macrocode}
10215 % 2022-01-09, \contributor{\username{niluxv}}: An alternative plural is
10216 % ``lemmata''. That is also a correct English plural for lemma, but the
10217 % English language file chooses ``lemmas''. For consistency we therefore
10218 % choose ``lemma's''.
10219 % \begin{macrocode}
10220 type = lemma ,
10221 gender = n ,
10222 Name-sg = Lemma ,
10223 name-sg = lemma ,
10224 Name-pl = Lemma's ,
10225 name-pl = lemma's ,
10226
10227 type = corollary ,
10228 gender = n ,
10229 Name-sg = Gevolg ,
10230 name-sg = gevolg ,
10231 Name-pl = Gevolgen ,
10232 name-pl = gevolgen ,
10233
10234 type = proposition ,
10235 gender = f ,
10236 Name-sg = Propositie ,
10237 name-sg = propositie ,
10238 Name-pl = Proposities ,
10239 name-pl = proposities ,
10240
10241 type = definition ,
10242 gender = f ,
10243 Name-sg = Definitie ,
10244 name-sg = definitie ,
10245 Name-pl = Definities ,
10246 name-pl = definities ,
10247
10248 type = proof ,
10249 gender = n ,
10250 Name-sg = Bewijs ,
10251 name-sg = bewijs ,
10252 Name-pl = Bewijzen ,
10253 name-pl = bewijzen ,
10254
10255 type = result ,
10256 gender = n ,
10257 Name-sg = Resultaat ,
10258 name-sg = resultaat ,
10259 Name-pl = Resultaten ,
10260 name-pl = resultaten ,
10261
10262 type = remark ,
10263 gender = f ,
10264 Name-sg = Opmerking ,
10265 name-sg = opmerking ,
10266 Name-pl = Opmerkingen ,
10267 name-pl = opmerkingen ,
10268
10269 type = example ,
10270 gender = n ,
10271 Name-sg = Voorbeeld ,
10272 name-sg = voorbeeld ,
10273 Name-pl = Voorbeelden ,
10274 name-pl = voorbeelden ,
10275
10276 % \end{macrocode}
10277 % 2022-12-27, \contributor{\username{niluxv}}: ``algoritmes'' is also a valid
10278 % plural. ``algoritmen'' is chosen to be consistent with using ``bijlagen''
10279 % (and not ``bijlages'') as the plural of ``bijlage''.
10280 % \begin{macrocode}
10281 type = algorithm ,
10282 gender = { n , f , m } ,
10283 Name-sg = Algoritme ,
10284 name-sg = algoritme ,
10285 Name-pl = Algoritmen ,
10286 name-pl = algoritmen ,
10287
10288 % \end{macrocode}
10289 % 2022-01-09, \contributor{\username{niluxv}}: EN-NL Van Dale translates
10290 % listing as (3) ``uitdraai van computerprogramma'', ``listing''.
10291 % \begin{macrocode}
10292 type = listing ,
10293 gender = m ,
10294 Name-sg = Listing ,
10295 name-sg = listing ,
10296 Name-pl = Listings ,
10297 name-pl = listings ,
10298
10299 type = exercise ,
10300 gender = { f , m } ,
10301 Name-sg = Opgave ,
10302 name-sg = opgave ,
10303 Name-pl = Opgaven ,
10304 name-pl = opgaven ,
10305
10306 type = solution ,
10307 gender = f ,
10308 Name-sg = Oplossing ,
10309 name-sg = oplossing ,
10310 Name-pl = Oplossingen ,
10311 name-pl = oplossingen ,
10312 % \end{macrocode}
10313 %
10314 % \begin{macrocode}
10315 %</lang-dutch>
10316 % \end{macrocode}
10317 %
10318 %
10319 % \subsection{Italian}
10320 %
10321 % Italian language file initially contributed by \contributor{Matteo
10322 % Ferrigato} (\githubissue{11}), with the help of participants of the Gruppo
10323 % Utilizzatori Italiani di \TeX{} (GuIT) forum (at
10324 % \url{https://www.guitex.org/home/it/forum/5-tex-e-latex/121856-closed-zref-clever-e-localizzazione-in-italiano}).
10325 %
10326 % \begin{macrocode}
10327 %<*package>
10328 \zcDeclareLanguage [ gender = { f , m } ] { italian }
10329 %</package>
10330 % \end{macrocode}
10331 %
10332 % \begin{macrocode}
10333 %<*lang-italian>
10334 % \end{macrocode}
10335 %
10336 % \begin{macrocode}
10337 namesep = {\nobreakspace} ,
10338 pairsep = {~e\nobreakspace} ,
10339 listsep = {,~} ,
10340 lastsep = {~e\nobreakspace} ,
10341 tpairsep = {~e\nobreakspace} ,
10342 tlistsep = {,~} ,
10343 tlastsep = {,~e\nobreakspace} ,
10344 notesep = {~} ,
10345 rangesep = {~a\nobreakspace} ,
10346 +refbounds-rb = {da\nobreakspace,,,} ,
10347
10348 type = book ,
10349 gender = m ,
10350 Name-sg = Libro ,
10351 name-sg = libro ,
10352 Name-pl = Libri ,
10353 name-pl = libri ,
10354
10355 type = part ,
10356 gender = f ,
10357 Name-sg = Parte ,
10358 name-sg = parte ,
10359 Name-pl = Parti ,
10360 name-pl = parti ,
10361
10362 type = chapter ,
10363 gender = m ,
10364 Name-sg = Capitolo ,
10365 name-sg = capitolo ,
10366 Name-pl = Capitoli ,
10367 name-pl = capitoli ,
10368
10369 type = section ,
10370 gender = m ,
10371 Name-sg = Paragrafo ,
10372 name-sg = paragrafo ,
10373 Name-pl = Paragrafi ,
10374 name-pl = paragrafi ,
10375
10376 type = paragraph ,
10377 gender = m ,
10378 Name-sg = Capoverso ,
10379 name-sg = capoverso ,
10380 Name-pl = Capoversi ,
10381 name-pl = capoversi ,
10382
10383 type = appendix ,
10384 gender = f ,
10385 Name-sg = Appendice ,
10386 name-sg = appendice ,
10387 Name-pl = Appendici ,
10388 name-pl = appendici ,
10389
10390 type = page ,
10391 gender = f ,
10392 Name-sg = Pagina ,
10393 name-sg = pagina ,
10394 Name-pl = Pagine ,
10395 name-pl = pagine ,
10396 Name-sg-ab = Pag. ,
10397 name-sg-ab = pag. ,
10398 Name-pl-ab = Pag. ,
10399 name-pl-ab = pag. ,
10400 rangesep = {\textendash} ,
10401 rangetopair = false ,
10402 +refbounds-rb = {,,,} ,
10403
10404 type = line ,
10405 gender = f ,
10406 Name-sg = Riga ,
10407 name-sg = riga ,
10408 Name-pl = Righe ,
10409 name-pl = righe ,
10410
10411 type = figure ,
10412 gender = f ,
10413 Name-sg = Figura ,
10414 name-sg = figura ,
10415 Name-pl = Figure ,
10416 name-pl = figure ,
10417 Name-sg-ab = Fig. ,
10418 name-sg-ab = fig. ,
10419 Name-pl-ab = Fig. ,
10420 name-pl-ab = fig. ,
10421
10422 type = table ,
10423 gender = f ,
10424 Name-sg = Tabella ,
10425 name-sg = tabella ,
10426 Name-pl = Tabelle ,
10427 name-pl = tabelle ,
10428 Name-sg-ab = Tab. ,
10429 name-sg-ab = tab. ,
10430 Name-pl-ab = Tab. ,
10431 name-pl-ab = tab. ,
10432
10433 type = item ,
10434 gender = m ,
10435 Name-sg = Punto ,
10436 name-sg = punto ,
10437 Name-pl = Punti ,
10438 name-pl = punti ,
10439
10440 type = footnote ,
10441 gender = f ,
10442 Name-sg = Nota ,
10443 name-sg = nota ,
10444 Name-pl = Note ,
10445 name-pl = note ,
10446
10447 type = endnote ,
10448 gender = f ,
10449 Name-sg = Nota ,
10450 name-sg = nota ,
10451 Name-pl = Note ,
10452 name-pl = note ,
10453
10454 type = note ,
10455 gender = f ,
10456 Name-sg = Nota ,
10457 name-sg = nota ,
10458 Name-pl = Note ,
10459 name-pl = note ,
10460
10461 type = equation ,
10462 gender = f ,
10463 Name-sg = Equazione ,
10464 name-sg = equazione ,
10465 Name-pl = Equazioni ,
10466 name-pl = equazioni ,
10467 Name-sg-ab = Eq. ,
10468 name-sg-ab = eq. ,
10469 Name-pl-ab = Eq. ,
10470 name-pl-ab = eq. ,
10471 +refbounds-rb = {da\nobreakspace(,,,)} ,
10472 refbounds-first-sg = {,(,),} ,
10473 refbounds = {(,,,)} ,
10474
10475 type = theorem ,
10476 gender = m ,
10477 Name-sg = Teorema ,
10478 name-sg = teorema ,
10479 Name-pl = Teoremi ,
10480 name-pl = teoremi ,
10481
10482 type = lemma ,
10483 gender = m ,
10484 Name-sg = Lemma ,
10485 name-sg = lemma ,
10486 Name-pl = Lemmi ,
10487 name-pl = lemmi ,
10488
10489 type = corollary ,
10490 gender = m ,
10491 Name-sg = Corollario ,
10492 name-sg = corollario ,
10493 Name-pl = Corollari ,
10494 name-pl = corollari ,
10495
10496 type = proposition ,
10497 gender = f ,
10498 Name-sg = Proposizione ,
10499 name-sg = proposizione ,
10500 Name-pl = Proposizioni ,
10501 name-pl = proposizioni ,
10502
10503 type = definition ,
10504 gender = f ,
10505 Name-sg = Definizione ,
10506 name-sg = definizione ,
10507 Name-pl = Definizioni ,
10508 name-pl = definizioni ,
10509
10510 type = proof ,
10511 gender = f ,
10512 Name-sg = Dimostrazione ,
10513 name-sg = dimostrazione ,
10514 Name-pl = Dimostrazioni ,
10515 name-pl = dimostrazioni ,
10516
10517 type = result ,
10518 gender = m ,
10519 Name-sg = Risultato ,
10520 name-sg = risultato ,
10521 Name-pl = Risultati ,
10522 name-pl = risultati ,
10523
10524 type = remark ,
10525 gender = f ,
10526 Name-sg = Osservazione ,
10527 name-sg = osservazione ,
10528 Name-pl = Osservazioni ,
10529 name-pl = osservazioni ,
10530
10531 type = example ,
10532 gender = m ,
10533 Name-sg = Esempio ,
10534 name-sg = esempio ,
10535 Name-pl = Esempi ,
10536 name-pl = esempi ,
10537
10538 type = algorithm ,
10539 gender = m ,
10540 Name-sg = Algoritmo ,
10541 name-sg = algoritmo ,
10542 Name-pl = Algoritmi ,
10543 name-pl = algoritmi ,
10544
10545 type = listing ,
10546 gender = m ,
10547 Name-sg = Listato ,
10548 name-sg = listato ,
10549 Name-pl = Listati ,
10550 name-pl = listati ,
10551
10552 type = exercise ,
10553 gender = m ,
10554 Name-sg = Esercizio ,
10555 name-sg = esercizio ,
10556 Name-pl = Esercizi ,
10557 name-pl = esercizi ,
10558
10559 type = solution ,
10560 gender = f ,
10561 Name-sg = Soluzione ,
10562 name-sg = soluzione ,
10563 Name-pl = Soluzioni ,
10564 name-pl = soluzioni ,
10565 % \end{macrocode}
10566 %
10567 % \begin{macrocode}
10568 %</lang-italian>
10569 % \end{macrocode}
10570 %
10571 %
10572 % \subsection{Russian}
10573 %
10574 % Russian language file initially contributed by \contributor{Sergey Slyusarev
10575 % \username{jemmybutton}} (\githubPR{29}). Russian localization in consistent
10576 % with that of \pkg{cleveref}, with the following exceptions: ``equation'' is
10577 % translated as ``уравнение'', rather than ``formula'', ``proposition'' is
10578 % translated as ``предложение'', rather than ``утверждение''; several
10579 % abbreviations are replaced with more common ones, e.g. abbreviated plural of
10580 % ``item'' is ``пп.'', not ``п.п.''.
10581 %
10582 % \begin{macrocode}
10583 %<*package>
10584 \zcDeclareLanguage
10585 [ variants = { n , a , g , d , i , p } , gender = { f , m , n } ]
10586 { russian }
10587 %</package>
10588 % \end{macrocode}
10589 %
10590 % \begin{macrocode}
10591 %<*lang-russian>
10592 % \end{macrocode}
10593 %
10594 % \begin{macrocode}
10595 namesep = {\nobreakspace} ,
10596 pairsep = {~и\nobreakspace} ,
10597 listsep = {,~} ,
10598 lastsep = {~и\nobreakspace} ,
10599 tpairsep = {~и\nobreakspace} ,
10600 tlistsep = {,~} ,
10601 tlastsep = {,~и\nobreakspace} ,
10602 notesep = {~} ,
10603 rangesep = {~по\nobreakspace} ,
10604 +refbounds-rb = {с\nobreakspace,,,} ,
10605
10606 type = book ,
10607 gender = f ,
10608 variant = n ,
10609 Name-sg = Книга ,
10610 name-sg = книга ,
10611 Name-pl = Книги ,
10612 name-pl = книги ,
10613 variant = a ,
10614 Name-sg = Книгу ,
10615 name-sg = книгу ,
10616 Name-pl = Книги ,
10617 name-pl = книги ,
10618 variant = g ,
10619 Name-sg = Книги ,
10620 name-sg = книги ,
10621 Name-pl = Книг ,
10622 name-pl = книг ,
10623 variant = d ,
10624 Name-sg = Книге ,
10625 name-sg = книге ,
10626 Name-pl = Книгам ,
10627 name-pl = книгам ,
10628 variant = i ,
10629 Name-sg = Книгой ,
10630 name-sg = книгой ,
10631 Name-pl = Книгами ,
10632 name-pl = книгами ,
10633 variant = p ,
10634 Name-sg = Книге ,
10635 name-sg = книге ,
10636 Name-pl = Книгах ,
10637 name-pl = книгах ,
10638
10639 type = part ,
10640 gender = f ,
10641 variant = n ,
10642 Name-sg = Часть ,
10643 name-sg = часть ,
10644 Name-pl = Части ,
10645 name-pl = части ,
10646 Name-sg-ab = Ч. ,
10647 name-sg-ab = ч. ,
10648 Name-pl-ab = Чч. ,
10649 name-pl-ab = чч. ,
10650 variant = a ,
10651 Name-sg = Часть ,
10652 name-sg = часть ,
10653 Name-pl = Части ,
10654 name-pl = части ,
10655 Name-sg-ab = Ч. ,
10656 name-sg-ab = ч. ,
10657 Name-pl-ab = Чч. ,
10658 name-pl-ab = чч. ,
10659 variant = g ,
10660 Name-sg = Части ,
10661 name-sg = части ,
10662 Name-pl = Частей ,
10663 name-pl = частей ,
10664 Name-sg-ab = Ч. ,
10665 name-sg-ab = ч. ,
10666 Name-pl-ab = Чч. ,
10667 name-pl-ab = чч. ,
10668 variant = d ,
10669 Name-sg = Части ,
10670 name-sg = части ,
10671 Name-pl = Частям ,
10672 name-pl = частям ,
10673 Name-sg-ab = Ч. ,
10674 name-sg-ab = ч. ,
10675 Name-pl-ab = Чч. ,
10676 name-pl-ab = чч. ,
10677 variant = i ,
10678 Name-sg = Частью ,
10679 name-sg = частью ,
10680 Name-pl = Частями ,
10681 name-pl = частями ,
10682 Name-sg-ab = Ч. ,
10683 name-sg-ab = ч. ,
10684 Name-pl-ab = Чч. ,
10685 name-pl-ab = чч. ,
10686 variant = p ,
10687 Name-sg = Части ,
10688 name-sg = части ,
10689 Name-pl = Частях ,
10690 name-pl = частях ,
10691 Name-sg-ab = Ч. ,
10692 name-sg-ab = ч. ,
10693 Name-pl-ab = Чч. ,
10694 name-pl-ab = чч. ,
10695
10696 type = chapter ,
10697 gender = f ,
10698 variant = n ,
10699 Name-sg = Глава ,
10700 name-sg = глава ,
10701 Name-pl = Главы ,
10702 name-pl = главы ,
10703 Name-sg-ab = Гл. ,
10704 name-sg-ab = гл. ,
10705 Name-pl-ab = Гл. ,
10706 name-pl-ab = гл. ,
10707 variant = a ,
10708 Name-sg = Главу ,
10709 name-sg = главу ,
10710 Name-pl = Главы ,
10711 name-pl = главы ,
10712 Name-sg-ab = Гл. ,
10713 name-sg-ab = гл. ,
10714 Name-pl-ab = Гл. ,
10715 name-pl-ab = гл. ,
10716 variant = g ,
10717 Name-sg = Главы ,
10718 name-sg = главы ,
10719 Name-pl = Глав ,
10720 name-pl = глав ,
10721 Name-sg-ab = Гл. ,
10722 name-sg-ab = гл. ,
10723 Name-pl-ab = Гл. ,
10724 name-pl-ab = гл. ,
10725 variant = d ,
10726 Name-sg = Главе ,
10727 name-sg = главе ,
10728 Name-pl = Главам ,
10729 name-pl = главам ,
10730 Name-sg-ab = Гл. ,
10731 name-sg-ab = гл. ,
10732 Name-pl-ab = Гл. ,
10733 name-pl-ab = гл. ,
10734 variant = i ,
10735 Name-sg = Главой ,
10736 name-sg = главой ,
10737 Name-pl = Главами ,
10738 name-pl = главами ,
10739 Name-sg-ab = Гл. ,
10740 name-sg-ab = гл. ,
10741 Name-pl-ab = Гл. ,
10742 name-pl-ab = гл. ,
10743 variant = p ,
10744 Name-sg = Главе ,
10745 name-sg = главе ,
10746 Name-pl = Главах ,
10747 name-pl = главах ,
10748 Name-sg-ab = Гл. ,
10749 name-sg-ab = гл. ,
10750 Name-pl-ab = Гл. ,
10751 name-pl-ab = гл. ,
10752
10753 type = section ,
10754 gender = m ,
10755 variant = n ,
10756 Name-sg = Раздел ,
10757 name-sg = раздел ,
10758 Name-pl = Разделы ,
10759 name-pl = разделы ,
10760 variant = a ,
10761 Name-sg = Раздел ,
10762 name-sg = раздел ,
10763 Name-pl = Разделы ,
10764 name-pl = разделы ,
10765 variant = g ,
10766 Name-sg = Раздела ,
10767 name-sg = раздела ,
10768 Name-pl = Разделов ,
10769 name-pl = разделов ,
10770 variant = d ,
10771 Name-sg = Разделу ,
10772 name-sg = разделу ,
10773 Name-pl = Разделам ,
10774 name-pl = разделам ,
10775 variant = i ,
10776 Name-sg = Разделом ,
10777 name-sg = разделом ,
10778 Name-pl = Разделами ,
10779 name-pl = разделами ,
10780 variant = p ,
10781 Name-sg = Разделе ,
10782 name-sg = разделе ,
10783 Name-pl = Разделах ,
10784 name-pl = разделах ,
10785
10786 type = paragraph ,
10787 gender = m ,
10788 variant = n ,
10789 Name-sg = Абзац ,
10790 name-sg = абзац ,
10791 Name-pl = Абзацы ,
10792 name-pl = абзацы ,
10793 variant = a ,
10794 Name-sg = Абзац ,
10795 name-sg = абзац ,
10796 Name-pl = Абзацы ,
10797 name-pl = абзацы ,
10798 variant = g ,
10799 Name-sg = Абзаца ,
10800 name-sg = абзаца ,
10801 Name-pl = Абзацев ,
10802 name-pl = абзацев ,
10803 variant = d ,
10804 Name-sg = Абзацу ,
10805 name-sg = абзацу ,
10806 Name-pl = Абзацам ,
10807 name-pl = абзацам ,
10808 variant = i ,
10809 Name-sg = Абзацем ,
10810 name-sg = абзацем ,
10811 Name-pl = Абзацами ,
10812 name-pl = абзацами ,
10813 variant = p ,
10814 Name-sg = Абзаце ,
10815 name-sg = абзаце ,
10816 Name-pl = Абзацах ,
10817 name-pl = абзацах ,
10818
10819 type = appendix ,
10820 gender = n ,
10821 variant = n ,
10822 Name-sg = Приложение ,
10823 name-sg = приложение ,
10824 Name-pl = Приложения ,
10825 name-pl = приложения ,
10826 variant = a ,
10827 Name-sg = Приложение ,
10828 name-sg = приложение ,
10829 Name-pl = Приложения ,
10830 name-pl = приложения ,
10831 variant = g ,
10832 Name-sg = Приложения ,
10833 name-sg = приложения ,
10834 Name-pl = Приложений ,
10835 name-pl = приложений ,
10836 variant = d ,
10837 Name-sg = Приложению ,
10838 name-sg = приложению ,
10839 Name-pl = Приложениям ,
10840 name-pl = приложениям ,
10841 variant = i ,
10842 Name-sg = Приложением ,
10843 name-sg = приложением ,
10844 Name-pl = Приложениями ,
10845 name-pl = приложениями ,
10846 variant = p ,
10847 Name-sg = Приложении ,
10848 name-sg = приложении ,
10849 Name-pl = Приложениях ,
10850 name-pl = приложениях ,
10851
10852 type = page ,
10853 gender = f ,
10854 variant = n ,
10855 Name-sg = Страница ,
10856 name-sg = страница ,
10857 Name-pl = Страницы ,
10858 name-pl = страницы ,
10859 Name-sg-ab = С. ,
10860 name-sg-ab = с. ,
10861 Name-pl-ab = Сс. ,
10862 name-pl-ab = сс. ,
10863 variant = a ,
10864 Name-sg = Страницу ,
10865 name-sg = страницу ,
10866 Name-pl = Страницы ,
10867 name-pl = страницы ,
10868 Name-sg-ab = С. ,
10869 name-sg-ab = с. ,
10870 Name-pl-ab = Сс. ,
10871 name-pl-ab = сс. ,
10872 variant = g ,
10873 Name-sg = Страницы ,
10874 name-sg = страницы ,
10875 Name-pl = Страниц ,
10876 name-pl = страниц ,
10877 Name-sg-ab = С. ,
10878 name-sg-ab = с. ,
10879 Name-pl-ab = Сс. ,
10880 name-pl-ab = сс. ,
10881 variant = d ,
10882 Name-sg = Странице ,
10883 name-sg = странице ,
10884 Name-pl = Страницам ,
10885 name-pl = страницам ,
10886 Name-sg-ab = С. ,
10887 name-sg-ab = с. ,
10888 Name-pl-ab = Сс. ,
10889 name-pl-ab = сс. ,
10890 variant = i ,
10891 Name-sg = Страницей ,
10892 name-sg = страницей ,
10893 Name-pl = Страницами ,
10894 name-pl = страницами ,
10895 Name-sg-ab = С. ,
10896 name-sg-ab = с. ,
10897 Name-pl-ab = Сс. ,
10898 name-pl-ab = сс. ,
10899 variant = p ,
10900 Name-sg = Странице ,
10901 name-sg = странице ,
10902 Name-pl = Страницах ,
10903 name-pl = страницах ,
10904 Name-sg-ab = С. ,
10905 name-sg-ab = с. ,
10906 Name-pl-ab = Сс. ,
10907 name-pl-ab = сс. ,
10908 rangesep = {\textendash} ,
10909 rangetopair = false ,
10910 +refbounds-rb = {,,,} ,
10911
10912 type = line ,
10913 gender = f ,
10914 variant = n ,
10915 Name-sg = Строка ,
10916 name-sg = строка ,
10917 Name-pl = Строки ,
10918 name-pl = строки ,
10919 variant = a ,
10920 Name-sg = Строку ,
10921 name-sg = строку ,
10922 Name-pl = Строки ,
10923 name-pl = строки ,
10924 variant = g ,
10925 Name-sg = Строки ,
10926 name-sg = строки ,
10927 Name-pl = Строк ,
10928 name-pl = строк ,
10929 variant = d ,
10930 Name-sg = Строке ,
10931 name-sg = строке ,
10932 Name-pl = Строкам ,
10933 name-pl = строкам ,
10934 variant = i ,
10935 Name-sg = Строкой ,
10936 name-sg = строкой ,
10937 Name-pl = Строками ,
10938 name-pl = строками ,
10939 variant = p ,
10940 Name-sg = Строке ,
10941 name-sg = строке ,
10942 Name-pl = Строках ,
10943 name-pl = строках ,
10944
10945 type = figure ,
10946 gender = m ,
10947 variant = n ,
10948 Name-sg = Рисунок ,
10949 name-sg = рисунок ,
10950 Name-pl = Рисунки ,
10951 name-pl = рисунки ,
10952 Name-sg-ab = Рис. ,
10953 name-sg-ab = рис. ,
10954 Name-pl-ab = Рис. ,
10955 name-pl-ab = рис. ,
10956 variant = a ,
10957 Name-sg = Рисунок ,
10958 name-sg = рисунок ,
10959 Name-pl = Рисунки ,
10960 name-pl = рисунки ,
10961 Name-sg-ab = Рис. ,
10962 name-sg-ab = рис. ,
10963 Name-pl-ab = Рис. ,
10964 name-pl-ab = рис. ,
10965 variant = g ,
10966 Name-sg = Рисунка ,
10967 name-sg = рисунка ,
10968 Name-pl = Рисунков ,
10969 name-pl = рисунков ,
10970 Name-sg-ab = Рис. ,
10971 name-sg-ab = рис. ,
10972 Name-pl-ab = Рис. ,
10973 name-pl-ab = рис. ,
10974 variant = d ,
10975 Name-sg = Рисунку ,
10976 name-sg = рисунку ,
10977 Name-pl = Рисункам ,
10978 name-pl = рисункам ,
10979 Name-sg-ab = Рис. ,
10980 name-sg-ab = рис. ,
10981 Name-pl-ab = Рис. ,
10982 name-pl-ab = рис. ,
10983 variant = i ,
10984 Name-sg = Рисунком ,
10985 name-sg = рисунком ,
10986 Name-pl = Рисунками ,
10987 name-pl = рисунками ,
10988 Name-sg-ab = Рис. ,
10989 name-sg-ab = рис. ,
10990 Name-pl-ab = Рис. ,
10991 name-pl-ab = рис. ,
10992 variant = p ,
10993 Name-sg = Рисунке ,
10994 name-sg = рисунке ,
10995 Name-pl = Рисунках ,
10996 name-pl = рисунках ,
10997 Name-sg-ab = Рис. ,
10998 name-sg-ab = рис. ,
10999 Name-pl-ab = Рис. ,
11000 name-pl-ab = рис. ,
11001
11002 type = table ,
11003 gender = f ,
11004 variant = n ,
11005 Name-sg = Таблица ,
11006 name-sg = таблица ,
11007 Name-pl = Таблицы ,
11008 name-pl = таблицы ,
11009 Name-sg-ab = Табл. ,
11010 name-sg-ab = табл. ,
11011 Name-pl-ab = Табл. ,
11012 name-pl-ab = табл. ,
11013 variant = a ,
11014 Name-sg = Таблицу ,
11015 name-sg = таблицу ,
11016 Name-pl = Таблицы ,
11017 name-pl = таблицы ,
11018 Name-sg-ab = Табл. ,
11019 name-sg-ab = табл. ,
11020 Name-pl-ab = Табл. ,
11021 name-pl-ab = табл. ,
11022 variant = g ,
11023 Name-sg = Таблицы ,
11024 name-sg = таблицы ,
11025 Name-pl = Таблиц ,
11026 name-pl = таблиц ,
11027 Name-sg-ab = Табл. ,
11028 name-sg-ab = табл. ,
11029 Name-pl-ab = Табл. ,
11030 name-pl-ab = табл. ,
11031 variant = d ,
11032 Name-sg = Таблице ,
11033 name-sg = таблице ,
11034 Name-pl = Таблицам ,
11035 name-pl = таблицам ,
11036 Name-sg-ab = Табл. ,
11037 name-sg-ab = табл. ,
11038 Name-pl-ab = Табл. ,
11039 name-pl-ab = табл. ,
11040 variant = i ,
11041 Name-sg = Таблицей ,
11042 name-sg = таблицей ,
11043 Name-pl = Таблицами ,
11044 name-pl = таблицами ,
11045 Name-sg-ab = Табл. ,
11046 name-sg-ab = табл. ,
11047 Name-pl-ab = Табл. ,
11048 name-pl-ab = табл. ,
11049 variant = p ,
11050 Name-sg = Таблице ,
11051 name-sg = таблице ,
11052 Name-pl = Таблицах ,
11053 name-pl = таблицах ,
11054 Name-sg-ab = Табл. ,
11055 name-sg-ab = табл. ,
11056 Name-pl-ab = Табл. ,
11057 name-pl-ab = табл. ,
11058
11059 type = item ,
11060 gender = m ,
11061 variant = n ,
11062 Name-sg = Пункт ,
11063 name-sg = пункт ,
11064 Name-pl = Пункты ,
11065 name-pl = пункты ,
11066 Name-sg-ab = П. ,
11067 name-sg-ab = п. ,
11068 Name-pl-ab = Пп. ,
11069 name-pl-ab = пп. ,
11070 variant = a ,
11071 Name-sg = Пункт ,
11072 name-sg = пункт ,
11073 Name-pl = Пункты ,
11074 name-pl = пункты ,
11075 Name-sg-ab = П. ,
11076 name-sg-ab = п. ,
11077 Name-pl-ab = Пп. ,
11078 name-pl-ab = пп. ,
11079 variant = g ,
11080 Name-sg = Пункта ,
11081 name-sg = пункта ,
11082 Name-pl = Пунктов ,
11083 name-pl = пунктов ,
11084 Name-sg-ab = П. ,
11085 name-sg-ab = п. ,
11086 Name-pl-ab = Пп. ,
11087 name-pl-ab = пп. ,
11088 variant = d ,
11089 Name-sg = Пункту ,
11090 name-sg = пункту ,
11091 Name-pl = Пунктам ,
11092 name-pl = пунктам ,
11093 Name-sg-ab = П. ,
11094 name-sg-ab = п. ,
11095 Name-pl-ab = Пп. ,
11096 name-pl-ab = пп. ,
11097 variant = i ,
11098 Name-sg = Пунктом ,
11099 name-sg = пунктом ,
11100 Name-pl = Пунктами ,
11101 name-pl = пунктами ,
11102 Name-sg-ab = П. ,
11103 name-sg-ab = п. ,
11104 Name-pl-ab = Пп. ,
11105 name-pl-ab = пп. ,
11106 variant = p ,
11107 Name-sg = Пункте ,
11108 name-sg = пункте ,
11109 Name-pl = Пунктах ,
11110 name-pl = пунктах ,
11111 Name-sg-ab = П. ,
11112 name-sg-ab = п. ,
11113 Name-pl-ab = Пп. ,
11114 name-pl-ab = пп. ,
11115
11116 type = footnote ,
11117 gender = f ,
11118 variant = n ,
11119 Name-sg = Сноска ,
11120 name-sg = сноска ,
11121 Name-pl = Сноски ,
11122 name-pl = сноски ,
11123 variant = a ,
11124 Name-sg = Сноску ,
11125 name-sg = сноску ,
11126 Name-pl = Сноски ,
11127 name-pl = сноски ,
11128 variant = g ,
11129 Name-sg = Сноски ,
11130 name-sg = сноски ,
11131 Name-pl = Сносок ,
11132 name-pl = сносок ,
11133 variant = d ,
11134 Name-sg = Сноске ,
11135 name-sg = сноске ,
11136 Name-pl = Сноскам ,
11137 name-pl = сноскам ,
11138 variant = i ,
11139 Name-sg = Сноской ,
11140 name-sg = сноской ,
11141 Name-pl = Сносками ,
11142 name-pl = сносками ,
11143 variant = p ,
11144 Name-sg = Сноске ,
11145 name-sg = сноске ,
11146 Name-pl = Сносках ,
11147 name-pl = сносках ,
11148
11149 type = endnote ,
11150 gender = f ,
11151 variant = n ,
11152 Name-sg = Сноска ,
11153 name-sg = сноска ,
11154 Name-pl = Сноски ,
11155 name-pl = сноски ,
11156 variant = a ,
11157 Name-sg = Сноску ,
11158 name-sg = сноску ,
11159 Name-pl = Сноски ,
11160 name-pl = сноски ,
11161 variant = g ,
11162 Name-sg = Сноски ,
11163 name-sg = сноски ,
11164 Name-pl = Сносок ,
11165 name-pl = сносок ,
11166 variant = d ,
11167 Name-sg = Сноске ,
11168 name-sg = сноске ,
11169 Name-pl = Сноскам ,
11170 name-pl = сноскам ,
11171 variant = i ,
11172 Name-sg = Сноской ,
11173 name-sg = сноской ,
11174 Name-pl = Сносками ,
11175 name-pl = сносками ,
11176 variant = p ,
11177 Name-sg = Сноске ,
11178 name-sg = сноске ,
11179 Name-pl = Сносках ,
11180 name-pl = сносках ,
11181
11182 type = note ,
11183 gender = f ,
11184 variant = n ,
11185 Name-sg = Заметка ,
11186 name-sg = заметка ,
11187 Name-pl = Заметки ,
11188 name-pl = заметки ,
11189 variant = a ,
11190 Name-sg = Заметку ,
11191 name-sg = заметку ,
11192 Name-pl = Заметки ,
11193 name-pl = заметки ,
11194 variant = g ,
11195 Name-sg = Заметки ,
11196 name-sg = заметки ,
11197 Name-pl = Заметок ,
11198 name-pl = заметок ,
11199 variant = d ,
11200 Name-sg = Заметке ,
11201 name-sg = заметке ,
11202 Name-pl = Заметкам ,
11203 name-pl = заметкам ,
11204 variant = i ,
11205 Name-sg = Заметкой ,
11206 name-sg = заметкой ,
11207 Name-pl = Заметками ,
11208 name-pl = заметками ,
11209 variant = p ,
11210 Name-sg = Заметке ,
11211 name-sg = заметке ,
11212 Name-pl = Заметках ,
11213 name-pl = заметках ,
11214
11215 type = equation ,
11216 gender = n ,
11217 variant = n ,
11218 Name-sg = Уравнение ,
11219 name-sg = уравнение ,
11220 Name-pl = Уравнения ,
11221 name-pl = уравнения ,
11222 Name-sg-ab = Ур. ,
11223 name-sg-ab = ур. ,
11224 Name-pl-ab = Ур. ,
11225 name-pl-ab = ур. ,
11226 variant = a ,
11227 Name-sg = Уравнение ,
11228 name-sg = уравнение ,
11229 Name-pl = Уравнения ,
11230 name-pl = уравнения ,
11231 Name-sg-ab = Ур. ,
11232 name-sg-ab = ур. ,
11233 Name-pl-ab = Ур. ,
11234 name-pl-ab = ур. ,
11235 variant = g ,
11236 Name-sg = Уравнения ,
11237 name-sg = уравнения ,
11238 Name-pl = Уравнений ,
11239 name-pl = уравнений ,
11240 Name-sg-ab = Ур. ,
11241 name-sg-ab = ур. ,
11242 Name-pl-ab = Ур. ,
11243 name-pl-ab = ур. ,
11244 variant = d ,
11245 Name-sg = Уравнению ,
11246 name-sg = уравнению ,
11247 Name-pl = Уравнениям ,
11248 name-pl = уравнениям ,
11249 Name-sg-ab = Ур. ,
11250 name-sg-ab = ур. ,
11251 Name-pl-ab = Ур. ,
11252 name-pl-ab = ур. ,
11253 variant = i ,
11254 Name-sg = Уравнением ,
11255 name-sg = уравнением ,
11256 Name-pl = Уравнениями ,
11257 name-pl = уравнениями ,
11258 Name-sg-ab = Ур. ,
11259 name-sg-ab = ур. ,
11260 Name-pl-ab = Ур. ,
11261 name-pl-ab = ур. ,
11262 variant = p ,
11263 Name-sg = Уравнении ,
11264 name-sg = уравнении ,
11265 Name-pl = Уравнениях ,
11266 name-pl = уравнениях ,
11267 Name-sg-ab = Ур. ,
11268 name-sg-ab = ур. ,
11269 Name-pl-ab = Ур. ,
11270 name-pl-ab = ур. ,
11271 +refbounds-rb = {с\nobreakspace(,,,)} ,
11272 refbounds-first-sg = {,(,),} ,
11273 refbounds = {(,,,)} ,
11274
11275 type = theorem ,
11276 gender = f ,
11277 variant = n ,
11278 Name-sg = Теорема ,
11279 name-sg = теорема ,
11280 Name-pl = Теоремы ,
11281 name-pl = теоремы ,
11282 Name-sg-ab = Теор. ,
11283 name-sg-ab = теор. ,
11284 Name-pl-ab = Теор. ,
11285 name-pl-ab = теор. ,
11286 variant = a ,
11287 Name-sg = Теорему ,
11288 name-sg = теорему ,
11289 Name-pl = Теоремы ,
11290 name-pl = теоремы ,
11291 Name-sg-ab = Теор. ,
11292 name-sg-ab = теор. ,
11293 Name-pl-ab = Теор. ,
11294 name-pl-ab = теор. ,
11295 variant = g ,
11296 Name-sg = Теоремы ,
11297 name-sg = теоремы ,
11298 Name-pl = Теорем ,
11299 name-pl = теорем ,
11300 Name-sg-ab = Теор. ,
11301 name-sg-ab = теор. ,
11302 Name-pl-ab = Теор. ,
11303 name-pl-ab = теор. ,
11304 variant = d ,
11305 Name-sg = Теореме ,
11306 name-sg = теореме ,
11307 Name-pl = Теоремам ,
11308 name-pl = теоремам ,
11309 Name-sg-ab = Теор. ,
11310 name-sg-ab = теор. ,
11311 Name-pl-ab = Теор. ,
11312 name-pl-ab = теор. ,
11313 variant = i ,
11314 Name-sg = Теоремой ,
11315 name-sg = теоремой ,
11316 Name-pl = Теоремами ,
11317 name-pl = теоремами ,
11318 Name-sg-ab = Теор. ,
11319 name-sg-ab = теор. ,
11320 Name-pl-ab = Теор. ,
11321 name-pl-ab = теор. ,
11322 variant = p ,
11323 Name-sg = Теореме ,
11324 name-sg = теореме ,
11325 Name-pl = Теоремах ,
11326 name-pl = теоремах ,
11327 Name-sg-ab = Теор. ,
11328 name-sg-ab = теор. ,
11329 Name-pl-ab = Теор. ,
11330 name-pl-ab = теор. ,
11331
11332 type = lemma ,
11333 gender = f ,
11334 variant = n ,
11335 Name-sg = Лемма ,
11336 name-sg = лемма ,
11337 Name-pl = Леммы ,
11338 name-pl = леммы ,
11339 variant = a ,
11340 Name-sg = Лемму ,
11341 name-sg = лемму ,
11342 Name-pl = Леммы ,
11343 name-pl = леммы ,
11344 variant = g ,
11345 Name-sg = Леммы ,
11346 name-sg = леммы ,
11347 Name-pl = Лемм ,
11348 name-pl = лемм ,
11349 variant = d ,
11350 Name-sg = Лемме ,
11351 name-sg = лемме ,
11352 Name-pl = Леммам ,
11353 name-pl = леммам ,
11354 variant = i ,
11355 Name-sg = Леммой ,
11356 name-sg = леммой ,
11357 Name-pl = Леммами ,
11358 name-pl = леммами ,
11359 variant = p ,
11360 Name-sg = Лемме ,
11361 name-sg = лемме ,
11362 Name-pl = Леммах ,
11363 name-pl = леммах ,
11364
11365 type = corollary ,
11366 gender = m ,
11367 variant = n ,
11368 Name-sg = Вывод ,
11369 name-sg = вывод ,
11370 Name-pl = Выводы ,
11371 name-pl = выводы ,
11372 variant = a ,
11373 Name-sg = Вывод ,
11374 name-sg = вывод ,
11375 Name-pl = Выводы ,
11376 name-pl = выводы ,
11377 variant = g ,
11378 Name-sg = Вывода ,
11379 name-sg = вывода ,
11380 Name-pl = Выводов ,
11381 name-pl = выводов ,
11382 variant = d ,
11383 Name-sg = Выводу ,
11384 name-sg = выводу ,
11385 Name-pl = Выводам ,
11386 name-pl = выводам ,
11387 variant = i ,
11388 Name-sg = Выводом ,
11389 name-sg = выводом ,
11390 Name-pl = Выводами ,
11391 name-pl = выводами ,
11392 variant = p ,
11393 Name-sg = Выводе ,
11394 name-sg = выводе ,
11395 Name-pl = Выводах ,
11396 name-pl = выводах ,
11397
11398 type = proposition ,
11399 gender = n ,
11400 variant = n ,
11401 Name-sg = Предложение ,
11402 name-sg = предложение ,
11403 Name-pl = Предложения ,
11404 name-pl = предложения ,
11405 Name-sg-ab = Предл. ,
11406 name-sg-ab = предл. ,
11407 Name-pl-ab = Предл. ,
11408 name-pl-ab = предл. ,
11409 variant = a ,
11410 Name-sg = Предложение ,
11411 name-sg = предложение ,
11412 Name-pl = Предложения ,
11413 name-pl = предложения ,
11414 Name-sg-ab = Предл. ,
11415 name-sg-ab = предл. ,
11416 Name-pl-ab = Предл. ,
11417 name-pl-ab = предл. ,
11418 variant = g ,
11419 Name-sg = Предложения ,
11420 name-sg = предложения ,
11421 Name-pl = Предложений ,
11422 name-pl = предложений ,
11423 Name-sg-ab = Предл. ,
11424 name-sg-ab = предл. ,
11425 Name-pl-ab = Предл. ,
11426 name-pl-ab = предл. ,
11427 variant = d ,
11428 Name-sg = Предложению ,
11429 name-sg = предложению ,
11430 Name-pl = Предложениям ,
11431 name-pl = предложениям ,
11432 Name-sg-ab = Предл. ,
11433 name-sg-ab = предл. ,
11434 Name-pl-ab = Предл. ,
11435 name-pl-ab = предл. ,
11436 variant = i ,
11437 Name-sg = Предложением ,
11438 name-sg = предложением ,
11439 Name-pl = Предложениями ,
11440 name-pl = предложениями ,
11441 Name-sg-ab = Предл. ,
11442 name-sg-ab = предл. ,
11443 Name-pl-ab = Предл. ,
11444 name-pl-ab = предл. ,
11445 variant = p ,
11446 Name-sg = Предложении ,
11447 name-sg = предложении ,
11448 Name-pl = Предложениях ,
11449 name-pl = предложениях ,
11450 Name-sg-ab = Предл. ,
11451 name-sg-ab = предл. ,
11452 Name-pl-ab = Предл. ,
11453 name-pl-ab = предл. ,
11454
11455 type = definition ,
11456 gender = n ,
11457 variant = n ,
11458 Name-sg = Определение ,
11459 name-sg = определение ,
11460 Name-pl = Определения ,
11461 name-pl = определения ,
11462 Name-sg-ab = Опр. ,
11463 name-sg-ab = опр. ,
11464 Name-pl-ab = Опр. ,
11465 name-pl-ab = опр. ,
11466 variant = a ,
11467 Name-sg = Определение ,
11468 name-sg = определение ,
11469 Name-pl = Определения ,
11470 name-pl = определения ,
11471 Name-sg-ab = Опр. ,
11472 name-sg-ab = опр. ,
11473 Name-pl-ab = Опр. ,
11474 name-pl-ab = опр. ,
11475 variant = g ,
11476 Name-sg = Определения ,
11477 name-sg = определения ,
11478 Name-pl = Определений ,
11479 name-pl = определений ,
11480 Name-sg-ab = Опр. ,
11481 name-sg-ab = опр. ,
11482 Name-pl-ab = Опр. ,
11483 name-pl-ab = опр. ,
11484 variant = d ,
11485 Name-sg = Определению ,
11486 name-sg = определению ,
11487 Name-pl = Определениям ,
11488 name-pl = определениям ,
11489 Name-sg-ab = Опр. ,
11490 name-sg-ab = опр. ,
11491 Name-pl-ab = Опр. ,
11492 name-pl-ab = опр. ,
11493 variant = i ,
11494 Name-sg = Определением ,
11495 name-sg = определением ,
11496 Name-pl = Определениями ,
11497 name-pl = определениями ,
11498 Name-sg-ab = Опр. ,
11499 name-sg-ab = опр. ,
11500 Name-pl-ab = Опр. ,
11501 name-pl-ab = опр. ,
11502 variant = p ,
11503 Name-sg = Определении ,
11504 name-sg = определении ,
11505 Name-pl = Определениях ,
11506 name-pl = определениях ,
11507 Name-sg-ab = Опр. ,
11508 name-sg-ab = опр. ,
11509 Name-pl-ab = Опр. ,
11510 name-pl-ab = опр. ,
11511
11512 type = proof ,
11513 gender = n ,
11514 variant = n ,
11515 Name-sg = Доказательство ,
11516 name-sg = доказательство ,
11517 Name-pl = Доказательства ,
11518 name-pl = доказательства ,
11519 variant = a ,
11520 Name-sg = Доказательство ,
11521 name-sg = доказательство ,
11522 Name-pl = Доказательства ,
11523 name-pl = доказательства ,
11524 variant = g ,
11525 Name-sg = Доказательства ,
11526 name-sg = доказательства ,
11527 Name-pl = Доказательств ,
11528 name-pl = доказательств ,
11529 variant = d ,
11530 Name-sg = Доказательству ,
11531 name-sg = доказательству ,
11532 Name-pl = Доказательствам ,
11533 name-pl = доказательствам ,
11534 variant = i ,
11535 Name-sg = Доказательством ,
11536 name-sg = доказательством ,
11537 Name-pl = Доказательствами ,
11538 name-pl = доказательствами ,
11539 variant = p ,
11540 Name-sg = Доказательстве ,
11541 name-sg = доказательстве ,
11542 Name-pl = Доказательствах ,
11543 name-pl = доказательствах ,
11544
11545 type = result ,
11546 gender = m ,
11547 variant = n ,
11548 Name-sg = Результат ,
11549 name-sg = результат ,
11550 Name-pl = Результаты ,
11551 name-pl = результаты ,
11552 variant = a ,
11553 Name-sg = Результат ,
11554 name-sg = результат ,
11555 Name-pl = Результаты ,
11556 name-pl = результаты ,
11557 variant = g ,
11558 Name-sg = Результата ,
11559 name-sg = результата ,
11560 Name-pl = Результатов ,
11561 name-pl = результатов ,
11562 variant = d ,
11563 Name-sg = Результату ,
11564 name-sg = результату ,
11565 Name-pl = Результатам ,
11566 name-pl = результатам ,
11567 variant = i ,
11568 Name-sg = Результатом ,
11569 name-sg = результатом ,
11570 Name-pl = Результатами ,
11571 name-pl = результатами ,
11572 variant = p ,
11573 Name-sg = Результате ,
11574 name-sg = результате ,
11575 Name-pl = Результатах ,
11576 name-pl = результатах ,
11577
11578 type = remark ,
11579 gender = n ,
11580 variant = n ,
11581 Name-sg = Примечание ,
11582 name-sg = примечание ,
11583 Name-pl = Примечания ,
11584 name-pl = примечания ,
11585 Name-sg-ab = Прим. ,
11586 name-sg-ab = прим. ,
11587 Name-pl-ab = Прим. ,
11588 name-pl-ab = прим. ,
11589 variant = a ,
11590 Name-sg = Примечание ,
11591 name-sg = примечание ,
11592 Name-pl = Примечания ,
11593 name-pl = примечания ,
11594 Name-sg-ab = Прим. ,
11595 name-sg-ab = прим. ,
11596 Name-pl-ab = Прим. ,
11597 name-pl-ab = прим. ,
11598 variant = g ,
11599 Name-sg = Примечания ,
11600 name-sg = примечания ,
11601 Name-pl = Примечаний ,
11602 name-pl = примечаний ,
11603 Name-sg-ab = Прим. ,
11604 name-sg-ab = прим. ,
11605 Name-pl-ab = Прим. ,
11606 name-pl-ab = прим. ,
11607 variant = d ,
11608 Name-sg = Примечанию ,
11609 name-sg = примечанию ,
11610 Name-pl = Примечаниям ,
11611 name-pl = примечаниям ,
11612 Name-sg-ab = Прим. ,
11613 name-sg-ab = прим. ,
11614 Name-pl-ab = Прим. ,
11615 name-pl-ab = прим. ,
11616 variant = i ,
11617 Name-sg = Примечанием ,
11618 name-sg = примечанием ,
11619 Name-pl = Примечаниями ,
11620 name-pl = примечаниями ,
11621 Name-sg-ab = Прим. ,
11622 name-sg-ab = прим. ,
11623 Name-pl-ab = Прим. ,
11624 name-pl-ab = прим. ,
11625 variant = p ,
11626 Name-sg = Примечании ,
11627 name-sg = примечании ,
11628 Name-pl = Примечаниях ,
11629 name-pl = примечаниях ,
11630 Name-sg-ab = Прим. ,
11631 name-sg-ab = прим. ,
11632 Name-pl-ab = Прим. ,
11633 name-pl-ab = прим. ,
11634
11635 type = example ,
11636 gender = m ,
11637 variant = n ,
11638 Name-sg = Пример ,
11639 name-sg = пример ,
11640 Name-pl = Примеры ,
11641 name-pl = примеры ,
11642 variant = a ,
11643 Name-sg = Пример ,
11644 name-sg = пример ,
11645 Name-pl = Примеры ,
11646 name-pl = примеры ,
11647 variant = g ,
11648 Name-sg = Примера ,
11649 name-sg = примера ,
11650 Name-pl = Примеров ,
11651 name-pl = примеров ,
11652 variant = d ,
11653 Name-sg = Примеру ,
11654 name-sg = примеру ,
11655 Name-pl = Примерам ,
11656 name-pl = примерам ,
11657 variant = i ,
11658 Name-sg = Примером ,
11659 name-sg = примером ,
11660 Name-pl = Примерами ,
11661 name-pl = примерами ,
11662 variant = p ,
11663 Name-sg = Примере ,
11664 name-sg = примере ,
11665 Name-pl = Примерах ,
11666 name-pl = примерах ,
11667
11668 type = algorithm ,
11669 gender = m ,
11670 variant = n ,
11671 Name-sg = Алгоритм ,
11672 name-sg = алгоритм ,
11673 Name-pl = Алгоритмы ,
11674 name-pl = алгоритмы ,
11675 variant = a ,
11676 Name-sg = Алгоритм ,
11677 name-sg = алгоритм ,
11678 Name-pl = Алгоритмы ,
11679 name-pl = алгоритмы ,
11680 variant = g ,
11681 Name-sg = Алгоритма ,
11682 name-sg = алгоритма ,
11683 Name-pl = Алгоритмов ,
11684 name-pl = алгоритмов ,
11685 variant = d ,
11686 Name-sg = Алгоритму ,
11687 name-sg = алгоритму ,
11688 Name-pl = Алгоритмам ,
11689 name-pl = алгоритмам ,
11690 variant = i ,
11691 Name-sg = Алгоритмом ,
11692 name-sg = алгоритмом ,
11693 Name-pl = Алгоритмами ,
11694 name-pl = алгоритмами ,
11695 variant = p ,
11696 Name-sg = Алгоритме ,
11697 name-sg = алгоритме ,
11698 Name-pl = Алгоритмах ,
11699 name-pl = алгоритмах ,
11700
11701 type = listing ,
11702 gender = m ,
11703 variant = n ,
11704 Name-sg = Листинг ,
11705 name-sg = листинг ,
11706 Name-pl = Листинги ,
11707 name-pl = листинги ,
11708 variant = a ,
11709 Name-sg = Листинг ,
11710 name-sg = листинг ,
11711 Name-pl = Листинги ,
11712 name-pl = листинги ,
11713 variant = g ,
11714 Name-sg = Листинга ,
11715 name-sg = листинга ,
11716 Name-pl = Листингов ,
11717 name-pl = листингов ,
11718 variant = d ,
11719 Name-sg = Листингу ,
11720 name-sg = листингу ,
11721 Name-pl = Листингам ,
11722 name-pl = листингам ,
11723 variant = i ,
11724 Name-sg = Листингом ,
11725 name-sg = листинглм ,
11726 Name-pl = Листингами ,
11727 name-pl = листингами ,
11728 variant = p ,
11729 Name-sg = Листинге ,
11730 name-sg = листинге ,
11731 Name-pl = Листингах ,
11732 name-pl = листингах ,
11733
11734 type = exercise ,
11735 gender = n ,
11736 variant = n ,
11737 Name-sg = Упражнение ,
11738 name-sg = упражнение ,
11739 Name-pl = Упражнения ,
11740 name-pl = упражнения ,
11741 Name-sg-ab = Упр. ,
11742 name-sg-ab = упр. ,
11743 Name-pl-ab = Упр. ,
11744 name-pl-ab = упр. ,
11745 variant = a ,
11746 Name-sg = Упражнение ,
11747 name-sg = упражнение ,
11748 Name-pl = Упражнения ,
11749 name-pl = упражнения ,
11750 Name-sg-ab = Упр. ,
11751 name-sg-ab = упр. ,
11752 Name-pl-ab = Упр. ,
11753 name-pl-ab = упр. ,
11754 variant = g ,
11755 Name-sg = Упражнения ,
11756 name-sg = упражнения ,
11757 Name-pl = Упражнений ,
11758 name-pl = упражнений ,
11759 Name-sg-ab = Упр. ,
11760 name-sg-ab = упр. ,
11761 Name-pl-ab = Упр. ,
11762 name-pl-ab = упр. ,
11763 variant = d ,
11764 Name-sg = Упражнению ,
11765 name-sg = упражнению ,
11766 Name-pl = Упражнениям ,
11767 name-pl = упражнениям ,
11768 Name-sg-ab = Упр. ,
11769 name-sg-ab = упр. ,
11770 Name-pl-ab = Упр. ,
11771 name-pl-ab = упр. ,
11772 variant = i ,
11773 Name-sg = Упражнением ,
11774 name-sg = упражнением ,
11775 Name-pl = Упражнениями ,
11776 name-pl = упражнениями ,
11777 Name-sg-ab = Упр. ,
11778 name-sg-ab = упр. ,
11779 Name-pl-ab = Упр. ,
11780 name-pl-ab = упр. ,
11781 variant = p ,
11782 Name-sg = Упражнении ,
11783 name-sg = упражнении ,
11784 Name-pl = Упражнениях ,
11785 name-pl = упражнениях ,
11786 Name-sg-ab = Упр. ,
11787 name-sg-ab = упр. ,
11788 Name-pl-ab = Упр. ,
11789 name-pl-ab = упр. ,
11790
11791 type = solution ,
11792 gender = n ,
11793 variant = n ,
11794 Name-sg = Решение ,
11795 name-sg = решение ,
11796 Name-pl = Решения ,
11797 name-pl = решения ,
11798 variant = a ,
11799 Name-sg = Решение ,
11800 name-sg = решение ,
11801 Name-pl = Решения ,
11802 name-pl = решения ,
11803 variant = g ,
11804 Name-sg = Решения ,
11805 name-sg = решения ,
11806 Name-pl = Решений ,
11807 name-pl = решений ,
11808 variant = d ,
11809 Name-sg = Решению ,
11810 name-sg = решению ,
11811 Name-pl = Решениям ,
11812 name-pl = решениям ,
11813 variant = i ,
11814 Name-sg = Решением ,
11815 name-sg = решением ,
11816 Name-pl = Решениями ,
11817 name-pl = решениями ,
11818 variant = p ,
11819 Name-sg = Решении ,
11820 name-sg = решении ,
11821 Name-pl = Решениях ,
11822 name-pl = решениях ,
11823 % \end{macrocode}
11824 %
11825 % \begin{macrocode}
11826 %</lang-russian>
11827 % \end{macrocode}
11828 %
11829 %
11830 % \subsection{Swedish}
11831 %
11832 % Swedish language file initially contributed by
11833 % \contributor{\username{Timmyfox}} (\githubissue{35}).
11834 %
11835 % \begin{macrocode}
11836 %<*package>
11837 \zcDeclareLanguage { swedish }
11838 %</package>
11839 % \end{macrocode}
11840 %
11841 % \begin{macrocode}
11842 %<*lang-swedish>
11843 % \end{macrocode}
11844 %
11845 % \begin{macrocode}
11846 namesep = {\nobreakspace} ,
11847 pairsep = {~och\nobreakspace} ,
11848 listsep = {,~} ,
11849 lastsep = {~och\nobreakspace} ,
11850 tpairsep = {~och\nobreakspace} ,
11851 tlistsep = {,~} ,
11852 tlastsep = {~och\nobreakspace} ,
11853 notesep = {~} ,
11854 rangesep = {\textendash} ,
11855 rangetopair = false ,
11856
11857 type = book ,
11858 Name-sg = Bok ,
11859 name-sg = bok ,
11860 Name-pl = Bok ,
11861 name-pl = bok ,
11862
11863 type = part ,
11864 Name-sg = Del ,
11865 name-sg = del ,
11866 Name-pl = Del ,
11867 name-pl = del ,
11868
11869 type = chapter ,
11870 Name-sg = Kapitel ,
11871 name-sg = kapitel ,
11872 Name-pl = Kapitel ,
11873 name-pl = kapitel ,
11874
11875 type = section ,
11876 Name-sg = Avsnitt ,
11877 name-sg = avsnitt ,
11878 Name-pl = Avsnitt ,
11879 name-pl = avsnitt ,
11880
11881 type = paragraph ,
11882 Name-sg = Paragraf ,
11883 name-sg = paragraf ,
11884 Name-pl = Paragraf ,
11885 name-pl = paragraf ,
11886
11887 type = appendix ,
11888 Name-sg = Bilaga ,
11889 name-sg = bilaga ,
11890 Name-pl = Bilaga ,
11891 name-pl = bilaga ,
11892
11893 type = page ,
11894 Name-sg = Sida ,
11895 name-sg = sida ,
11896 Name-pl = Sida ,
11897 name-pl = sida ,
11898
11899 type = line ,
11900 Name-sg = Rad ,
11901 name-sg = rad ,
11902 Name-pl = Rad ,
11903 name-pl = rad ,
11904
11905 type = figure ,
11906 Name-sg = Figur ,
11907 name-sg = figur ,
11908 Name-pl = Figur ,
11909 name-pl = figur ,
11910 Name-sg-ab = Fig. ,
11911 name-sg-ab = fig. ,
11912 Name-pl-ab = Fig. ,
11913 name-pl-ab = fig. ,
11914
11915 type = table ,
11916 Name-sg = Tabell ,
11917 name-sg = tabell ,
11918 Name-pl = Tabell ,
11919 name-pl = tabell ,
11920 Name-sg-ab = Tab. ,
11921 name-sg-ab = tab. ,
11922 Name-pl-ab = Tab. ,
11923 name-pl-ab = tab. ,
11924
11925 type = item ,
11926 Name-sg = Punkt ,
11927 name-sg = punkt ,
11928 Name-pl = Punkt ,
11929 name-pl = punkt ,
11930
11931 type = footnote ,
11932 Name-sg = Fotnot ,
11933 name-sg = fotnot ,
11934 Name-pl = Fotnot ,
11935 name-pl = fotnot ,
11936
11937 type = endnote ,
11938 Name-sg = Slutnot ,
11939 name-sg = slutnot ,
11940 Name-pl = Slutnot ,
11941 name-pl = slutnot ,
11942
11943 type = note ,
11944 Name-sg = Not ,
11945 name-sg = not ,
11946 Name-pl = Not ,
11947 name-pl = not ,
11948
11949 type = equation ,
11950 Name-sg = Ekvation ,
11951 name-sg = ekvation ,
11952 Name-pl = Ekvation ,
11953 name-pl = ekvation ,
11954 Name-sg-ab = Ekv. ,
11955 name-sg-ab = ekv. ,
11956 Name-pl-ab = Ekv. ,
11957 name-pl-ab = ekv. ,
11958 refbounds-first-sg = {,(,),} ,
11959 refbounds = {(,,,)} ,
11960
11961 type = theorem ,
11962 Name-sg = Sats ,
11963 name-sg = sats ,
11964 Name-pl = Sats ,
11965 name-pl = sats ,
11966
11967 type = lemma ,
11968 Name-sg = Hjälpsats ,
11969 name-sg = hjälpsats ,
11970 Name-pl = Hjälpsats ,
11971 name-pl = hjälpsats ,
11972
11973 type = corollary ,
11974 Name-sg = Följdsats ,
11975 name-sg = följdsats ,
11976 Name-pl = Följdsats ,
11977 name-pl = följdsats ,
11978
11979 type = proposition ,
11980 Name-sg = Påstående ,
11981 name-sg = påstående ,
11982 Name-pl = Påstående ,
11983 name-pl = påstående ,
11984
11985 type = definition ,
11986 Name-sg = Definition ,
11987 name-sg = definition ,
11988 Name-pl = Definition ,
11989 name-pl = definition ,
11990
11991 type = proof ,
11992 Name-sg = Bevis ,
11993 name-sg = bevis ,
11994 Name-pl = Bevis ,
11995 name-pl = bevis ,
11996
11997 type = result ,
11998 Name-sg = Resultat ,
11999 name-sg = resultat ,
12000 Name-pl = Resultat ,
12001 name-pl = resultat ,
12002
12003 type = remark ,
12004 Name-sg = Anmärkning ,
12005 name-sg = anmärkning ,
12006 Name-pl = Anmärkning ,
12007 name-pl = anmärkning ,
12008
12009 type = example ,
12010 Name-sg = Exempel ,
12011 name-sg = exempel ,
12012 Name-pl = Exempel ,
12013 name-pl = exempel ,
12014
12015 type = algorithm ,
12016 Name-sg = Algoritm ,
12017 name-sg = algoritm ,
12018 Name-pl = Algoritm ,
12019 name-pl = algoritm ,
12020
12021 type = listing ,
12022 Name-sg = Kod ,
12023 name-sg = kod ,
12024 Name-pl = Kod ,
12025 name-pl = kod ,
12026
12027 type = exercise ,
12028 Name-sg = Uppgift ,
12029 name-sg = uppgift ,
12030 Name-pl = Uppgift ,
12031 name-pl = uppgift ,
12032
12033 type = solution ,
12034 Name-sg = Lösning ,
12035 name-sg = lösning ,
12036 Name-pl = Lösning ,
12037 name-pl = lösning ,
12038 % \end{macrocode}
12039 %
12040 % \begin{macrocode}
12041 %</lang-swedish>
12042 % \end{macrocode}
12043 %
12044 %
12045 % \PrintIndex
12046 %
12047 % \endinput
12048 %
12049 %
12050 % Local Variables:
12051 % TeX-engine: luatex
12052 % End: