Debian Codegraph @

texmf-dist/doc/latex/zref-clever/zref-clever-doc.tex

raw
1 % \iffalse meta-comment
2 %
3 % File: zref-clever.tex
4 %
5 % This file is part of the LaTeX package "zref-clever".
6 %
7 % Copyright (C) 2021-2023 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 \documentclass{l3doc}
43
44 \usepackage{fontspec}
45 \setmainfont{TeX Gyre Pagella}
46 \setsansfont{TeX Gyre Heros}[Scale=MatchLowercase]
47 \setmonofont{inconsolata}[Scale=MatchLowercase]
48
49 % The package itself *must* be loaded so that \GetFileInfo can pick up date
50 % and version data. Naturally, we also use it.
51 \usepackage{zref-clever}
52 \zcsetup{cap}
53 \usepackage{zref-check}
54 \usepackage{zref-titleref}
55
56 \usepackage{listings}
57
58 \usepackage{microtype}
59
60 \hypersetup{hidelinks}
61
62 \NewDocumentCommand\opt{m}{\texttt{#1}}
63
64 \NewDocumentCommand\contributor{m}{#1}
65 \NewDocumentCommand\username{m}{`\texttt{#1}'}
66
67 \makeatletter
68 \newcommand{\zcrequiredkernel}{\zrefclever@required@kernel}
69 \makeatother
70
71 \setlength{\marginparsep}{2\labelsep}
72
73 \definecolor{reffmtbox}{gray}{0.15}
74 \definecolor{reffmtback}{gray}{0.85}
75 \NewDocumentCommand\reffmt{m}{%
76 \fcolorbox{reffmtbox}{reffmtback}{%
77 \rule[-0.2\baselineskip]{0pt}{0.8\baselineskip}\texttt{#1}}}
78
79 \newlist{refformat}{itemize}{1}
80 \setlist[refformat]{label={}, beginpenalty=500, midpenalty=500}
81
82 \NewDocumentCommand\zctask{m}{%
83 \begin{description}
84 \item[Task] #1
85 \end{description}}
86
87 \lstdefinestyle{code}{
88 language=[LaTeX]TeX,
89 moretexcs={
90 AddToHook,
91 AddToHookWithArguments,
92 DeclareHookRule,
93 define@key,
94 patchcmd,
95 eq@setnumber,
96 DeclareFloatingEnvironment,
97 newlist,
98 setlist,
99 zexternaldocument,
100 next@label,
101 next@label@pre,
102 @empty,
103 tag,
104 text,
105 lstset,
106 condition,
107 RenewDocumentCommand,
108 NewCommandCopy,
109 ltx@gobble,
110 @currentcounter,
111 @currentHref,
112 zref@label,
113 zref@wrapper@babel,
114 zref@ifpropundefined,
115 zref@setcurrent,
116 zref@newprop,
117 zref@addprop,
118 beamer@old@zref@label,
119 alt,
120 beamer@nameslide,
121 beamer@dummynameslide,
122 uncover,
123 only,
124 ordinal,
125 tcbuselibrary,
126 tcbset,
127 newtcolorbox,
128 newtcbtheorem,
129 }
130 }
131 \lstdefinestyle{zrefclever}{
132 style=code,
133 moretexcs={
134 zcref,
135 zcpageref,
136 zlabel,
137 zcsetup,
138 zcLanguageSetup,
139 zcRefTypeSetup,
140 zcheck,
141 zvref,
142 zvpageref,
143 zvrefrange,
144 zvpagerefrange,
145 zfullref,
146 }
147 }
148 \lstset{
149 style=zrefclever,
150 basicstyle=\ttfamily\small,
151 columns=fullflexible,
152 keepspaces,
153 xleftmargin=\leftmargin,
154 xrightmargin=.5\leftmargin,
155 }
156 % Setup inspired by https://tex.stackexchange.com/a/4068. For how to use these
157 % environments in a .dtx context see https://tex.stackexchange.com/a/31026.
158 \newcounter{zchowto}
159 \lstnewenvironment{zchowto}[1][]{%
160 \renewcommand{\lstlistingname}{How-to}%
161 \renewcommand*\theHlstlisting{ht.\thelstlisting}%
162 \zcsetup{countertype={lstlisting=zchowto}}%
163 \lstset{#1}%
164 \stepcounter{zchowto}%
165 \setcounter{lstlisting}{\value{zchowto}-1}%
166 }{}
167 \newcounter{zcworkaround}
168 \lstnewenvironment{zcworkaround}[1][]{%
169 \renewcommand{\lstlistingname}{Work-around}%
170 \renewcommand*\theHlstlisting{wa.\thelstlisting}%
171 \zcsetup{countertype={lstlisting=zcworkaround}}%
172 \lstset{#1}%
173 \stepcounter{zcworkaround}%
174 \setcounter{lstlisting}{\value{zcworkaround}-1}%
175 }{}
176 \lstnewenvironment{zcexample}[1][]{%
177 \renewcommand{\lstlistingname}{Example}%
178 \lstset{#1}%
179 }{}
180
181 \zcRefTypeSetup{zchowto}{
182 Name-sg = {How-to},
183 name-sg = {how-to},
184 Name-pl = {How-tos},
185 name-pl = {how-tos},
186 }
187 \zcRefTypeSetup{zcworkaround}{
188 Name-sg = {Work-around},
189 name-sg = {work-around},
190 Name-pl = {Work-arounds},
191 name-pl = {work-arounds},
192 }
193
194 \begin{document}
195
196 \GetFileInfo{zref-clever.sty}
197
198 \title{%
199 The \pkg{zref-clever} package%
200 \texorpdfstring{\\{}\medskip{}}{ - }%
201 User manual%
202 \texorpdfstring{\medskip{}}{}%
203 }
204
205 \author{%
206 \texorpdfstring{\texttt{gusbrs}\\[0.8em]
207 \url{https://github.com/gusbrs/zref-clever}\\
208 \url{https://www.ctan.org/pkg/zref-clever}}{gusbrs}}
209
210 \date{Version \fileversion\ -- \filedate}
211
212 \maketitle
213
214 \begin{center}
215 {\bfseries \abstractname\vspace{-.5em}\vspace{0pt}}
216 \end{center}
217
218 \begin{quotation}
219 \pkg{zref-clever} provides a user interface for making \LaTeX{}
220 cross-references which automates some of their typical features, thus easing
221 their input in the document and improving the consistency of typeset
222 results. A reference made with \cs{zcref} includes a ``name'' according to
223 its ``type'' and lists of multiple labels can be automatically sorted and
224 compressed into ranges when due. The reference format is highly and easily
225 customizable, both globally and locally. \pkg{zref-clever} is based on
226 \pkg{zref}'s extensible referencing system.
227 \end{quotation}
228
229 \bigskip{}
230
231 \begin{center}
232 \textbf{EXPERIMENTAL}
233
234 Please read \zcref{sec:warning} carefully.
235 \end{center}
236
237 \clearpage{}
238
239 \tableofcontents
240
241 \clearpage{}
242
243 \section{Introduction}
244
245 Cross-referencing is an area which lends itself quite naturally to automation.
246 Not only for input convenience but also, and most importantly, for end results
247 consistency. Indeed, the standard \LaTeX{} cross-referencing system -- with
248 \cs{label}, \cs{ref}, and \cs{pageref} -- is already a form of automation, by
249 relieving us from checking the number of the referenced object, and the page
250 where it lies.
251
252 But the plethora of existing features, packages and document classes which, in
253 one way or another, extends this basic functionality is a clear indication of
254 a demand for more automation. Just to name the some of the most popular:
255 \pkg{cleveref}, \pkg{nameref}, \pkg{titleref}, \pkg{varioref}, \pkg{fancyref},
256 and the kernel's \cs{labelformat}.
257
258 However, the standard cross-referencing system traditionally stored two, and
259 only two, properties with the label: the printed representation of the counter
260 last incremented with \cs{refstepcounter} and the page. Of course, out of the
261 mentioned desire to automate more, the need arose to store more information
262 about the label to support this: the title or caption of the referenced
263 object; its counter or, even better, its ``type'', that is, whether it is a
264 section, chapter, figure, etc.; its hyperlink anchor, and so on. Thus those
265 two property ``fields'' of the standard label became quite a disputed real
266 state. And the packages in this area of functionality, or which somehow
267 depended on extending the cross-referencing mechanism, were bound to step on
268 each other's toes as a result. Nowadays (2024), many of these issues have
269 changed for the better. Notably, now the kernel's \cs{label} already stores
270 five arguments, regardless of the presence of \pkg{hyperref}, and also
271 provides a hook with the label as argument so that packages can extend its
272 functionality without the need to redefine it, as \pkg{nameref} now already
273 does (and so does \pkg{zref-clever}).\footnote{We are currently observing some
274 of the pains of adjusting the ecosystem to these improvements though\dots{}}
275
276 Out of this conundrum, Heiko Oberdiek eventually developed \pkg{zref}, which
277 implements an extensible referencing system, making the labels store a
278 property list of flexible length, so that new properties can be easily added
279 and queried. However, even when \pkg{zref} can rightfully boast this powerful
280 basic concept and is really quite featureful, with several different modules
281 available, it is fair to say that, for the average user, the package may
282 appear to be somewhat raw. Indeed, for someone who ``just wants to make a
283 cross-reference'', the user interface of the \pkg{zref-user} module is akin to
284 the standard \LaTeX{} cross-referencing system, and even requires some extra
285 work if you want to have a hyperlinked reference. In other words, \pkg{zref}
286 seems to have focused on infrastructure and on performing a number of
287 specialized tasks with different modules, and a large part of the landscape of
288 automation features available for the standard referencing system was not
289 carried over to \pkg{zref}, neither by the \pkg{zref} itself nor by other
290 packages.
291
292 \pkg{zref-clever} tries to cover this gap, by bringing a number of existing
293 features available for the standard referencing system to \pkg{zref}. And the
294 package's name makes it clear that the core of the envisaged feature set is
295 that of \pkg{cleveref}, even though the attempt was less one of replicating
296 functionality per se than that of having it as a successful point of
297 reference, from where we could then try to tap into \pkg{zref}'s potential.
298 Indeed, although there is a significant intersection, the features of
299 \pkg{zref-clever} are neither a superset nor a subset of those of
300 \pkg{cleveref}. There are things either of them can do that the other can't.
301 There are also important differences in user interface design. In particular,
302 \pkg{zref-clever} relies heavily on \texttt{key=value} interfaces both for
303 general configuration and for centering in a single user command, \cs{zcref},
304 as the main entrance for reference making, whose behavior can be modulated by
305 local options.
306
307 Considering that \pkg{zref} itself offers the \pkg{zref-titleref} module, and
308 that \pkg{zref-vario} offers integration of \pkg{zref-clever} with
309 \pkg{varioref}, a significant part of the most prominent automation features
310 available to the standard referencing system is thus brought to \pkg{zref},
311 working under a single consistent underlying infrastructure and user
312 interface. All in all, hopefully \pkg{zref-clever} can make \pkg{zref} more
313 accessible to the average user, and more interesting to users in general.
314
315
316 \section{Warning}
317 \label{sec:warning}
318
319 This package is in its early days, and should be considered experimental. By
320 this I don't mean I expect it to be ``edgy'', indeed quite a lot of effort has
321 been put into it so that this is not the case. However, during the initial
322 development, I had to make a number of calls for which I felt I had
323 insufficient information: in relation to features, packages, or classes I
324 don't use much, or to languages I don't know well, user needs I found hard to
325 anticipate etc. Hence, the package needs some time, and some use by more
326 adventurous people, until it can settle down with more conviction. In the
327 meantime, polishing the user interface and the infrastructure have a clear
328 priority over backward compatibility. So, if you choose to use this package,
329 you should be ready to accommodate to eventual upstream changes.
330
331
332 \section{\pkg{zref-clever} for the impatient}
333
334 Making cross-references with \pkg{zref-clever} is very similar to the standard
335 referencing system in its user interface: one sets a label, with \cs{label},
336 which can then be referenced, in our case with \cs{zcref}, which is the main
337 and basic entrance for making references with \pkg{zref-clever}. \cs{zcref}
338 receives a list of labels as argument and its behavior can be locally changed
339 through the optional argument.
340
341 A basic document using \pkg{zref-clever} is shown in \zcref{how:basic} which
342 should feel very familiar to any \LaTeX{} user acquainted with the standard
343 referencing system:
344
345 \begin{zchowto}[caption={Basic usage},label={how:basic}]
346 \documentclass{article}
347 \usepackage{zref-clever}
348 \usepackage{hyperref}
349 \begin{document}
350 \section{Section 1}
351 \label{sec:section-1}
352 \begin{figure}
353 A figure.
354 \caption{Figure 1}
355 \label{fig:figure-1}
356 \end{figure}
357 A reference to \zcref{sec:section-1}. \zcref[S]{fig:figure-1} shows some
358 interesting information.
359 A page reference can be done with either \zcpageref{sec:section-1} or with
360 \zcref[page]{sec:section-1}.
361 A reference can also be made to multiple labels, as in \zcref{sec:section-1,
362 fig:figure-1}.
363 \end{document}
364 \end{zchowto}
365
366 The references in the document of \zcref{how:basic} illustrate one of the main
367 features of \pkg{zref-clever}, which is to include an appropriate ``type
368 name'' of the reference, alongside of the reference itself. The document
369 renders its references as:
370 \begin{quote}
371 A reference to section 1. Figure 1 shows some interesting information. A
372 page reference can be done with either page 1 or with page 1. A reference
373 can also be made to multiple labels, as in section 1 and figure 1.
374 \end{quote}
375
376 \zcref[S]{how:basic} also illustrates the use the optional argument of
377 \cs{zcref} to modulate the behavior of the reference. In particular, the
378 \opt{S} option is one you should get acquainted with from the start, as it
379 ensures that the type name of a reference is properly capitalized and not
380 abbreviated, and it is meant to be used in references made at the beginning of
381 a sentence.
382
383 But \pkg{zref-clever} is highly customizable, and several other options exist,
384 and multiple places where you can set them:
385
386 \begin{itemize}
387 \item The optional argument of \cs{zcref}: for individual references.
388 \item \cs{zcsetup}: for settings meant to affect all references.
389 \item \cs{zcRefTypeSetup}: to customize the behavior of each reference type.
390 \item \cs{zcLanguageSetup}: for language-specific settings.
391 \end{itemize}
392
393 For the list of available options, and for these different scopes in which
394 they can be used, see \zcref{sec:user-interface, sec:options,
395 sec:reference-format, sec:internationalization}. Other usage examples are
396 available at \zcref{sec:how-tos}.
397
398
399 \section{Loading the package}
400 \label{sec:loading-package}
401
402 \pkg{zref-clever} can be loaded with the usual:
403
404 \begin{zcexample}
405 \usepackage{zref-clever}
406 \end{zcexample}
407
408 The package does not accept load-time options, package options must be set
409 using \cs{zcsetup} (see \zcref{sec:user-interface}).
410
411
412 \subsection{Dependencies}
413
414 \pkg{zref-clever} requires \pkg{zref}, particularly its \pkg{zref-base},
415 \pkg{zref-user} and \pkg{zref-abspage} modules, and the \LaTeX{} kernel
416 \zcrequiredkernel{}, or newer. It requires UTF-8 input encoding, which has
417 been the kernel's default for some time. It also needs \pkg{ifdraft}. Some
418 packages are leveraged by \pkg{zref-clever} if they are present, but are not
419 loaded by default or required by it, namely: \pkg{hyperref}, \pkg{zref-check},
420 and \pkg{zref}'s \pkg{zref-hyperref} and \pkg{zref-xr} modules.
421
422
423 \section{User interface}
424 \label{sec:user-interface}
425
426 \begin{function}{\zcref}
427 \begin{syntax}
428 \cs{zcref}\meta{*}\oarg{options}\marg{labels}
429 \end{syntax}
430 \end{function}
431 Typesets references to \meta{labels}, given as a comma separated list. When
432 \pkg{hyperref} support is enabled, references will be hyperlinked to their
433 respective anchors, according to options. The starred version of the command
434 does the same as the plain one, just does not form links. The \meta{options}
435 are (mostly) the same as those of the package, and can be given to local
436 effect. The \meta{labels} argument is protected by \pkg{zref}'s
437 \cs{zref@wrapper@babel}, so that it enjoys the same support for \pkg{babel}'s
438 active characters as \pkg{zref} itself does.
439
440 \begin{function}{\zcpageref}
441 \begin{syntax}
442 \cs{zcpageref}\meta{*}\oarg{options}\marg{labels}
443 \end{syntax}
444 \end{function}
445 Typesets page references to \meta{labels}, given as a comma separated list.
446 It is equivalent to calling \cs{zcref} with the \opt{ref=page} option:
447 \cs{zcref}\texttt{\meta{*}[}\meta{options}\texttt{,ref=page]}\marg{labels}.
448
449
450 \begin{function}{\zcsetup}
451 \begin{syntax}
452 \cs{zcsetup}\marg{options}
453 \end{syntax}
454 \end{function}
455 Sets \pkg{zref-clever}'s general options (see \zcref{sec:options,
456 sec:reference-format}). The settings performed by \cs{zcsetup} are local,
457 within the current group. But, of course, it can also be used to global
458 effects if ungrouped, e.g.\ in the preamble.
459
460 \begin{function}{\zcRefTypeSetup}
461 \begin{syntax}
462 \cs{zcRefTypeSetup}\marg{type}\marg{options}
463 \end{syntax}
464 \end{function}
465 Sets type-specific reference format options (see
466 \zcref{sec:reference-format}). Just as for \cs{zcsetup}, the settings
467 performed by \cs{zcRefTypeSetup} are local, within the current group.
468
469 \bigskip{}
470
471 Besides these, user facing commands related to \zcref*[ref=title,
472 noname]{sec:internationalization} are presented in
473 \zcref{sec:internationalization}. Note still that all user commands are
474 defined with \cs{NewDocumentCommand}, which translates into the usual handling
475 of arguments by it and/or processing by \pkg{l3keys}, particularly with regard
476 to brace-stripping and space-trimming.
477
478 Furthermore, \pkg{zref-clever} loads \pkg{zref}'s \pkg{zref-user} module by
479 default. So you also have its user commands available out of the box,
480 including \cs{zref} and \cs{zpageref}, but notably:
481
482
483 \section{Options}
484 \label{sec:options}
485
486 \pkg{zref-clever} is highly configurable, offering a lot of flexibility in
487 typeset results of the references, but it also tries to keep these ``handles''
488 as convenient and user friendly as possible. To this end, most of what one
489 can do with \pkg{zref-clever} (pretty much all of it), can be achieved
490 directly through the standard and familiar ``comma separated list of
491 \texttt{key=value} options''.
492
493 There are two main groups of options in \pkg{zref-clever}: ``general
494 options'', which affect the overall behavior of the package, or the reference
495 as a whole; and ``reference format options'', which control the detail of
496 reference formatting, including type-specific and language-specific settings.
497
498 This section covers the first group (for the second one, see
499 \zcref{sec:reference-format}). General options can be set globally by means
500 of \cs{zcsetup} in the preamble (see \zcref{sec:user-interface}). They can
501 also be set locally with \cs{zcsetup} along the document or through the
502 optional argument of \cs{zcref} (see \zcref{sec:user-interface}). Most
503 general options can be used in any of these contexts, but that is not
504 necessarily true for all cases, some restrictions may apply, as described in
505 each option's documentation.
506
507 \bigskip{}
508
509 \DescribeOption{ref} %
510 \DescribeOption{page} %
511 The \opt{ref} option controls the label property to which \cs{zcref} refers
512 to. It can receive \pkg{zref} properties, as long as they are declared, but
513 notably \texttt{default}, \texttt{page}, \texttt{thecounter} and, if
514 \pkg{zref-titleref} is loaded, \texttt{title}. The initial value is
515 \texttt{default}, which is our standard reference. \texttt{thecounter} is a
516 property set by \pkg{zref-clever} and is similar to \pkg{zref}'s
517 \texttt{default} property, except that it is not affected by the kernel's
518 \cs{labelformat}.\footnote{Technical note: the \texttt{default} property
519 stores \cs{@currentlabel}, while the \texttt{thecounter} property stores
520 \cs{the}\cs{@currentcounter}. The later is exactly what \cs{refstepcounter}
521 uses to build \cs{@currentlabel}, except for the \cs{labelformat} prefix
522 and, hence, has the advantage of being unaffected by it. But the former is
523 \emph{more reliable} since \cs{@currentlabel} is expected to be correct
524 pretty much anywhere whereas, although \cs{refstepcounter} does set
525 \cs{@currentcounter}, it is not everywhere that uses \cs{refstepcounter} for
526 the purpose. In the cases where the references from these two do diverge,
527 \pkg{zref-clever} will likely misbehave (reference type, sorting and
528 compression inevitably depend on a correct \opt{currentcounter}), but using
529 \texttt{default} at least ensures that the reference itself is correct.
530 That said, if you do set \cs{labelformat} for some reason,
531 \texttt{thecounter} may be useful.} By default, reference formatting,
532 sorting, and compression are done according to information inferred from the
533 \emph{current counter} (see \opt{currentcounter} option below). Special
534 treatment in these areas is provided for \texttt{page}, but not for any other
535 properties. The \opt{page} option is a convenience alias for
536 \texttt{ref=page}.
537
538 \DescribeOption{typeset} %
539 \DescribeOption{noname} %
540 \DescribeOption{noref} %
541 When \cs{zcref} typesets a set of references, each group of references of the
542 same type can be, and by default are, preceded by the type's ``name'', and
543 this is indeed an important feature of \pkg{zref-clever}. This is optional
544 however, and the \opt{typeset} option controls this behavior. It can receive
545 values \texttt{ref}, in which case it typesets only the reference(s),
546 \texttt{name}, in which case it typesets only the name(s), or \texttt{both},
547 in which case it typesets, well, both of them. Note that, when value
548 \texttt{name} is used, the name is still typeset according to the set of
549 references given to \cs{zcref}. For example, for multiple references, the
550 plural form is used, capitalization options are honored, etc. Also
551 hyperlinking behaves just \emph{as if} the references were present and,
552 depending on the corresponding options, the name may be linked to the first
553 reference of the type group. The \opt{noname} and \opt{noref} options are
554 convenience aliases for \texttt{typeset=ref} and \texttt{typeset=name},
555 respectively.
556
557 \DescribeOption{sort} %
558 \DescribeOption{nosort} %
559 The \opt{sort} option controls whether the list of \meta{labels} received as
560 argument by \cs{zcref} should be sorted or not. It is a boolean option, with
561 initial value \texttt{true}. The \opt{nosort} option is a convenience alias
562 for \texttt{sort=false}.
563
564 \DescribeOption{typesort} %
565 \DescribeOption{notypesort} %
566 Sorting references of the same type can be done with well defined logical
567 criteria. They either have the same counter or their counters share a clear
568 hierarchical relation (in the resetting behavior), such that a definite
569 sorting rule can be inferred from the label's data. The same is not true for
570 sorting of references of different types. Should ``tables'' come before or
571 after ``figures''? The \pkg{typesort} option allows to specify the sorting
572 priority of different reference types. It receives as value a comma separated
573 list of reference types, specifying that their sorting is to be done in the
574 order of that list. But \opt{typesort} does not need to receive \emph{all}
575 possible reference types. The special value \texttt{\{\{othertypes\}\}} (yes,
576 double braced, one for \pkg{l3keys}, so that the second can make the list) can
577 be placed anywhere along the list, to specify the sort priority of any type
578 not included explicitly. If \texttt{\{othertypes\}} is not present in the
579 list, it is presumed to be at the end of it. Any unspecified types (that is,
580 those falling implicitly or explicitly into the \texttt{\{othertypes\}}
581 category) get sorted between themselves in the order of their first appearance
582 in the label list given as argument to \cs{zcref}. I presume the common use
583 cases will not need to specify \texttt{\{othertypes\}} at all but, for the
584 sake of example, if you just really dislike equations, you could use
585 \texttt{typesort=\{\{\{othertypes\}\}, equation\}}. \opt{typesort}'s default
586 value is \texttt{\{part, chapter, section, paragraph\}}, which places the
587 sectioning reference types first in the list, in their hierarchical order, and
588 leaves everything else to the order of appearance of the labels. The
589 \opt{notypesort} option behaves like \texttt{typesort=\{\{\{othertypes\}\}\}}
590 would do, that is, it sorts all types in the order of the first appearance in
591 the labels' list.
592
593 \DescribeOption{comp} %
594 \DescribeOption{nocomp} %
595 \cs{zcref} can automatically compress a set of references of the same type
596 into a range, when they occur in immediate sequence. The \opt{comp} controls
597 whether this compression should take place or not. It is a boolean option,
598 with initial value \texttt{true}. The \opt{nocomp} option is a convenience
599 alias for \texttt{comp=false}. Of course, for better compression results the
600 \opt{sort} is recommended, but the two options are technically independent.
601
602 \DescribeOption{endrange} %
603 The \opt{endrange} option provides additional control over how the end
604 reference of a range is typeset, so as to achieve terse ranges. The option
605 can operate in two technically different ways. It may receive one of a number
606 of predefined values, which can process the end reference of the range,
607 comparing it with the beginning reference, to achieve a given end
608 result.\footnote{For the \TeX{}nically inclined: those values that perform
609 some processing -- namely \texttt{stripprefix}, \texttt{pagecomp}, and
610 \texttt{pagecomp2} -- fully expand the references before comparing them,
611 since it makes sense to perform this task as close as possible to the
612 printed representation of the references. I don't expect this to be a
613 problem in normal use cases, but it does represent a limitation on what the
614 references can contain. In case some control over this is needed, check the
615 \texttt{zref-clever/endrange-setup} hook in the code documentation.} Or, it
616 can specify a label property to be used directly, without any processing. The
617 available predefined values are: \texttt{ref}, \texttt{stripprefix},
618 \texttt{pagecomp}, and \texttt{pagecomp2}. \texttt{ref} corresponds to the
619 default behavior, and instructs \cs{zcref} to use whatever property was set at
620 the \opt{ref} option for the end of range reference. \texttt{stripprefix}
621 strips the common part at the start of each reference from the end one.
622 \texttt{pagecomp} is the equivalent of \texttt{stripprefix} for page numbers,
623 it does the same thing, but only if the references are comprised exclusively
624 of Arabic numerals. \texttt{pagecomp2} is a variant of \texttt{pagecomp} that
625 leaves at least two digits at the end reference (except for a leading zero).
626 If values other than the predefined ones are given to \opt{endrange} they are
627 considered as label properties, as long as they are declared. This property
628 is used to typeset the end of range reference if the label contains it, and if
629 both references would be ``compressible'' according to the \opt{comp} option,
630 otherwise the property specified by the \opt{ref} option is used. This is
631 useful for things like sub-elements for which we can build a proper
632 abbreviated sub-reference and populate the label with it (some compatibility
633 modules already provide a number of such properties, but other ones can be
634 built with \pkg{zref}, as needed).
635
636 \DescribeOption{range} %
637 \DescribeOption{rangetopair} %
638 By default (that is, when the \opt{range} option is not given), \cs{zcref}
639 typesets a complete list of references according to the \meta{labels} it
640 received as argument, and only compresses some of them into ranges if the
641 \opt{comp} option is enabled and if references of the same type occur in
642 immediate sequence. The \opt{range} option makes \cs{zcref} behave
643 differently. Sorting is implied by this option (the \opt{sort} option is
644 disregarded) and, for each reference type group in \meta{labels}, \cs{zcref}
645 builds a range from the first to the last reference in it, even if references
646 in between do not occur in immediate sequence. It is a boolean option, and
647 the initial value is \texttt{false}. \cs{zcref} is smart enough to recognize
648 when the first and last references of a type do happen to be contiguous, in
649 which case it typesets a ``pair'', instead of a ``range''. But this behavior
650 can be disabled by setting the \opt{rangetopair} option to \texttt{false}.
651
652 \DescribeOption{cap} %
653 \DescribeOption{nocap} %
654 \DescribeOption{capfirst} %
655 The \opt{cap} option controls whether the reference type names should be
656 capitalized or not. It is a boolean option, and it can also be set for
657 specific reference types or languages (see \zcref{sec:reference-format}). The
658 \opt{nocap} option is a convenience alias for \texttt{cap=false}. The
659 \opt{capfirst} option ensures that the reference type name of the \emph{first}
660 type block is capitalized, even when \opt{cap} is set to \texttt{false}.
661
662 \DescribeOption{abbrev} %
663 \DescribeOption{noabbrev} %
664 \DescribeOption{noabbrevfirst} %
665 The \opt{abbrev} option controls whether to use abbreviated reference type
666 names when they are available. It is a boolean option, and it can also be set
667 for specific reference types or languages (see \zcref{sec:reference-format}).
668 The \opt{noabbrev} option is a convenience alias for \texttt{abbrev=false}.
669 The \opt{noabbrevfirst} ensures that the reference type name of the
670 \emph{first} type block is never abbreviated, even when \opt{abbrev} is set to
671 \texttt{true}.
672
673 \DescribeOption{S} %
674 \opt{S} for ``Sentence''. The \opt{S} option is a convenience alias for
675 \texttt{noabbrevfirst=true, capfirst=true}, and is intended to be used in
676 references made at the beginning of a sentence. It is highly recommended that
677 you make a habit of using the \opt{S} option for beginning of sentence
678 references. Even if you do happen to be currently using \texttt{cap=true,
679 abbrev=false}, proper semantic markup will ensure you get expected results
680 even if you change your mind in that regard later on. For that reason, it was
681 made short and mnemonic, it can't get any easier.
682
683 \DescribeOption{hyperref} %
684 The \opt{hyperref} option controls the use of \pkg{hyperref} by
685 \pkg{zref-clever} and takes values \opt{auto}, \opt{true}, \opt{false}. The
686 initial value, \opt{auto}, makes \pkg{zref-clever} use \pkg{hyperref} if it is
687 loaded, meaning that references made with \cs{zcref} get hyperlinked to the
688 anchors of their respective \meta{labels}. \opt{true} does the same thing,
689 but warns if \pkg{hyperref} is not loaded (\pkg{hyperref} is never loaded for
690 you). In either of these cases, if \pkg{hyperref} is loaded, module
691 \pkg{zref-hyperref} is also loaded by \pkg{zref-clever}. \opt{false} means
692 not to use \pkg{hyperref} regardless of its availability. This is a preamble
693 only option, but \cs{zcref} provides granular control of hyperlinking by means
694 of its starred version.
695
696 \DescribeOption{nameinlink} %
697 The \opt{nameinlink} option controls whether the type name should be included
698 in the reference hyperlink or not (provided there is a link, of course).
699 Naturally, the name can only be included in the link of the \emph{first}
700 reference of each type block. \opt{nameinlink} can receive values
701 \texttt{true}, \texttt{false}, \texttt{single}, and \texttt{tsingle}. When
702 the value is \texttt{true} the type name is always included in the hyperlink.
703 When it is \texttt{false} the type name is never included in the link. When
704 the value is \texttt{single}, the type name is included in the link only if
705 \cs{zcref} is typesetting a single reference (not necessarily having received
706 a single label as argument, as they may have been compressed), otherwise, the
707 name is left out of the link. When the value is \texttt{tsingle}, the type
708 name is included in the link for each type block with a single reference,
709 otherwise, it isn't. An example: suppose you make a couple of references to
710 something like \cs{zcref}\texttt{\{chap:chapter1\}} and
711 \cs{zcref}\texttt{\{chap:chapter1, sec:section1, fig:figure1, fig:figure2\}}.
712 The ``figure'' type name will only be included in the hyperlink if
713 \opt{nameinlink} option is set to \texttt{true}. If it is set to
714 \texttt{tsingle}, the first reference will include the name in the link for
715 ``chapter'', as expected, but also in the second reference the ``chapter'' and
716 ``section'' names will be included in their respective links, while that of
717 ``figure'' will not. If the option is set to \texttt{single}, only the name
718 for ``chapter'' in the first reference will be included in the link, while in
719 the second reference none of them will. The initial value is
720 \texttt{nameinlink=tsingle}, and the option given without a value is
721 equivalent to \texttt{nameinlink=true}.
722
723 \DescribeOption{lang} %
724 The \opt{lang} option controls the language used by \cs{zcref} when looking
725 for language-specific reference format options (see
726 \zcref{sec:reference-format}). The initial value, \texttt{current}, uses the
727 current language, as defined by \pkg{babel} or \pkg{polyglossia} (or
728 \texttt{english} if none of them is loaded). Value \texttt{main} uses the
729 main document language, as defined by \pkg{babel} or \pkg{polyglossia} (or
730 \texttt{english} if none of them is loaded). The \opt{lang} option also
731 accepts that the language be specified directly by its name, as long as it's a
732 language known by \pkg{zref-clever}. For more details on
733 \zcref*[ref=title,noname]{sec:internationalization}, see
734 \zcref{sec:internationalization}.
735
736 \DescribeOption{v} %
737 The \opt{v} option sets the variant, and affects the type name used for
738 typesetting the reference. Whether this option is operative, and which values
739 it accepts, depends on the declared setup for each language. For details, see
740 \zcref{sec:internationalization}.
741
742 \DescribeOption{nudge} %
743 \DescribeOption{nudgeif} %
744 \DescribeOption{nonudge} %
745 \DescribeOption{sg} %
746 \DescribeOption{g} %
747 This set of options revolving around \opt{nudge} aims to offer some guard
748 against mischievous automation on the part of \pkg{zref-clever} by providing a
749 number of ``nudges'' (compilation time messages) for cases in which you may
750 wish to revise material \emph{surrounding} the reference -- an article, a
751 preposition -- according to the reference typeset results. Useful mainly for
752 languages which inflect the preceding article to gender and/or number, but may
753 be used generally to fine-tune the language and style around the
754 cross-references made with \cs{zcref}. The \opt{nudge} option is the main
755 entrance to this feature and takes values \texttt{true}, \texttt{false},
756 \texttt{ifdraft}, or \texttt{iffinal}. The first two, respectively, enable or
757 disable the ``nudging'' unconditionally. With \texttt{ifdraft}, \opt{nudge}
758 keeps quiet when option \texttt{draft} is given to \cs{documentclass}, while
759 with \texttt{iffinal}, nudging is only enabled when option \texttt{final} is
760 (explicitly) passed to \cs{documentclass}. The option given without a value
761 is equivalent to \texttt{nudge=true} and the initial value is
762 \texttt{nudge=false}. \opt{nonudge} is a convenience alias for
763 \texttt{nudge=false}, and can be used to silence individual references. The
764 \opt{nudgeif} option controls the events which may trigger a nudge. It takes
765 a comma separated list of elements, and recognizes values \texttt{multitype},
766 \texttt{comptosing}, \texttt{gender}, and \texttt{all}. The
767 \texttt{multitype} nudge warns when the reference is composed by multiple type
768 blocks (see \zcref{sec:reference-format}). The \texttt{comptosing} nudge
769 let's you know when multiple labels of the same type have been compressed to a
770 singular type name form. It can be combined with the \opt{sg} option, which
771 is the way to tell \cs{zcref} you know it's a singular and so not to nudge if
772 a compression to singular occurs, but to nudge if the contrary occurs, that
773 is, when a plural type name form is employed. The \texttt{gender} nudge must
774 be combined with option \opt{g}, and depends on the language having support
775 for it. In essence language files can store the gender(s) of each type name
776 (this is done for built-in language files, but can also be done with
777 \cs{zcLanguageSetup} for languages declared to support it). The \opt{g}
778 option let's you specify the gender you expect for that particular reference
779 and the nudge is triggered if there is a mismatch between \opt{g} and the
780 gender(s) for the type name in the language file. Both the
781 \texttt{comptosing} and the \texttt{gender} nudges have a type block as its
782 scope. See \zcref{sec:internationalization} for more details and intended use
783 cases of the ``nudging'' feature.
784
785 \DescribeOption{font} %
786 The \opt{font} option can receive font styling commands to change the
787 appearance of the whole reference list (see also the \opt{namefont} and
788 \opt{reffont} reference format options in \zcref{sec:reference-format}). It
789 does not affect the content of the \opt{note}, however. The option is
790 intended exclusively for commands that only change font attributes: style,
791 family, shape, weight, size, color, etc. Anything else, particularly commands
792 that may generate typeset output, is not supported.
793
794 \DescribeOption{note} %
795 The \opt{note} option receives as value some text to be typeset at the end of
796 the whole reference list. It is separated from it by \opt{notesep} (see
797 \zcref{sec:reference-format}).
798
799 \DescribeOption{check} %
800 Provides integration of \pkg{zref-clever} with the \pkg{zref-check} package.
801 The option is only functional in the document body and if \pkg{zref-check} has
802 been loaded. \opt{check} requires a value, which works exactly like the
803 optional argument of \cs{zcheck}, and can receive both checks and
804 \cs{zcheck}'s options. And the checks are performed for each label in
805 \marg{labels} received as argument by \cs{zcref}. See the User manual of
806 \pkg{zref-check} for details. The checks done by the \opt{check} option in
807 \cs{zcref} comprise the complete reference, including the \opt{note} (see
808 \zcref{sec:reference-format}).
809
810 \DescribeOption{countertype} %
811 \DescribeOption{reftype} %
812 The \opt{countertype} option allows to specify the ``reference type'' of each
813 counter, which is stored as a label property when the label is set. This
814 reference type is what determines how a reference to this label will
815 eventually be typeset when it is referred to (see
816 \zcref{sec:reference-types}). A value like \texttt{countertype = \{foo =
817 bar\}} sets the \texttt{foo} counter to use the reference type \texttt{bar}.
818 There's only need to specify the \opt{countertype} for counters whose name
819 differs from that of their type, since \pkg{zref-clever} presumes the type has
820 the same name as the counter, unless otherwise specified. Also, the initial
821 value of the option already sets appropriate types for basic \LaTeX{}
822 counters, including those from the standard classes. Setting a counter type
823 to an empty value removes any (explicit) type association for that counter, in
824 practice, this means it then uses a type equal to its name. The \opt{reftype}
825 option allows one to specify the reference type manually, regardless of the
826 current counter. This can be used to locally override any \opt{countertype}
827 settings of the package and, for those acquainted with it, is the equivalent
828 of \pkg{cleveref}'s optional argument to \cs{label}. Normally, you'd want to
829 use this option within a group, but if you must do otherwise, the default
830 value can be restored by setting the option without a value. Since these
831 options only affect how labels are set, they are not available in \cs{zcref}.
832
833 \DescribeOption{\raisebox{-.2em}{\dbend}\ counterresetters} %
834 \DescribeOption{counterresetby} %
835 The sorting and compression of references done by \cs{zcref} requires that we
836 know the counter associated with a particular label but also information on
837 any counter whose stepping may trigger its resetting, or its ``enclosing
838 counters''. This information is not easily retrievable from the counter
839 itself but is (normally) stored with the counter that does the resetting. The
840 \opt{counterresetters} option receives a full comma separated list of counter
841 names, which \pkg{zref-clever} uses to search for ``enclosing counters'' of
842 the counter for which a label is being set. The order matters (see code
843 documentation for details), and you should also take care to start from the
844 initial value set by the package. Unfortunately, not every counter gets reset
845 through the standard machinery for this, including some \LaTeX{} kernel ones
846 (e.g. the \texttt{enumerate} environment counters). For those, there is
847 really no way to retrieve this information directly, so we have to just tell
848 \pkg{zref-clever} about them. And that's what the \opt{counterresetby} option
849 is made for. It receives a comma separated list of \texttt{key=value} pairs,
850 in which \texttt{key} is the counter, and \texttt{value} is its ``enclosing
851 counter'', that is, the counter whose stepping results in its resetting. This
852 is not really an ``option'' in the sense of ``user choice'', it is more of a
853 way to inform \pkg{zref-clever} of something it cannot know or automatically
854 find in general. One cannot place arbitrary information there, or
855 \pkg{zref-clever} can be thoroughly confused. The setting must correspond to
856 the actual resetting behavior of the involved counters. \opt{counterresetby}
857 has precedence over the search done in the \opt{counterresetters} list. The
858 initial value of \opt{counterresetters} includes the counters for sectioning
859 commands of the standard classes which, in most cases, should be the relevant
860 ones for cross-referencing purposes. The initial value of
861 \opt{counterresetby} includes the \texttt{enumerate} environment counters.
862 So, hopefully, you don't need to ever bother with either of these options.
863 But, if you do, they are here. Use them with caution though. Since these
864 options only affect how labels are set, they are not available in \cs{zcref}.
865
866 \DescribeOption{\raisebox{.4em}{\dbend}\ currentcounter} %
867 \LaTeX{}'s \cs{refstepcounter} sets two variables which potentially affect the
868 \cs{label} set after it: \cs{@currentlabel} and \cs{@currentcounter}. But,
869 since \pkg{zref-clever} relies heavily on the information of what the current
870 counter is, it must set \pkg{zref} to store that information with the label,
871 as it does. As long as the document element we are trying to refer to uses
872 the standard machinery of \cs{refstepcounter} we are on solid ground and can
873 retrieve the correct information. However, it is not always ensured that
874 \cs{@currentcounter} is kept up to date. For example, packages which handle
875 labels specially, for one reason or another, may or may not set
876 \cs{@currentcounter} as required. Considering the addition of
877 \cs{@currentcounter} to \cs{refstepcounter} itself is not that
878 old,\footnote{Traditionally, only the current label was thus stored, the
879 current counter was added to \cs{refstepcounter} somewhat recently (with the
880 2020-10-01 kernel release).} it is likely that in some places a reliable
881 \cs{@currentcounter} is not really in place. Therefore, it may happen we need
882 to tell \pkg{zref-clever} what the current counter is in certain
883 circumstances, and that's what \opt{currentcounter} does. The same as with
884 the previous two options, this is not really an ``user choice'' kind of
885 option, but a way to tell \pkg{zref-clever} a piece of information it has no
886 means to retrieve automatically. The setting must correspond to the actual
887 ``current counter'', meaning here ``the counter underlying
888 \cs{@currentlabel}'' in a given situation. Also, when using the
889 \opt{currentcounter} option, take care that the setting is duly grouped
890 because, if set, it has precedence over \cs{@currentcounter} and, contrary to
891 the later, the former is not reset the next time \cs{refstepcounter} runs.
892 Its initial value is, quite naturally, \cs{@currentcounter}, which can be
893 reset by calling the option with no value. Since this option only affects how
894 labels are set, it is not available in \cs{zcref}.
895
896 \DescribeOption{\raisebox{.4em}{\dbend}\ labelhook} %
897 \opt{labelhook} is a boolean option which controls whether \pkg{zref-clever}
898 uses the kernel's \texttt{label} hook to, whenever a standard \cs{label} is
899 called, also set a \cs{zlabel} with the same name (which is what
900 \pkg{zref-clever} actually uses to make its references). The package's
901 initial value is \texttt{true} so that one can use \cs{label}s along the
902 document and refer to them (also) with \pkg{zref} and \pkg{zref-clever}
903 reference commands. This value is not only the default, but also a
904 recommended value. Disabling this option means you are on your own to handle
905 cases where \cs{zlabel} does not work, which are not many, but can be tricky
906 to deal with where they occur. Since this option only affects how labels are
907 set, it is not available in \cs{zcref}. See \zcref{sec:label-or-zlabel} for
908 some discussion of different labeling approaches this options allows for.
909
910 \DescribeOption{nocompat} %
911 Some packages, document classes, or LaTeX features may require specific
912 support to work with \pkg{zref-clever} (see \zcref{sec:limitations}).
913 \pkg{zref-clever} tries to make things smoother by covering some of them.
914 Depending on the case, this can take the form of some simple setup for
915 \pkg{zref-clever}, or may involve the use of hooks to external environments or
916 commands and, eventually, a patch or redefinition. By default, all the
917 available compatibility modules are enabled. Should this be undesired or
918 cause any problems in your environment, the option \opt{nocompat} can
919 selectively or completely inhibit their loading. \opt{nocompat} receives a
920 comma separated list of compatibility modules to disable (for the list of
921 available modules and details about each of them, see
922 \zcref{sec:comp-modules}). You can disable all modules by setting
923 \opt{nocompat} without a value (or an empty one). This is a preamble only
924 option.
925
926
927 \section{Reference types}
928 \label{sec:reference-types}
929
930 A ``reference type'' is the basic \pkg{zref-clever} setup unit for specifying
931 how a cross-reference group of a certain kind is to be typeset. Though,
932 usually, it will have the same name as the underlying \LaTeX{} \emph{counter},
933 they are conceptually different. \pkg{zref-clever} sets up \emph{reference
934 types} and an association between each \emph{counter} and its \emph{type},
935 it does not define the counters themselves, which are defined by your
936 document. One \emph{reference type} can be associated with one or more
937 \emph{counters}, and a \emph{counter} can be associated with different
938 \emph{types} at different points in your document. But each label is stored
939 with only one \emph{type}, as specified by the counter-type association at the
940 moment it is set, and that determines how the reference to that label is
941 typeset. References to different \emph{counters} of the same \emph{type} are
942 grouped together, and treated alike by \cs{zcref}. A \emph{reference type}
943 may be known to \pkg{zref-clever} when the \emph{counter} it is associated
944 with is not actually defined, and this inconsequential. In practice, the
945 contrary may also happen, a \emph{counter} may be defined but we have no
946 \emph{type} for it, but this must be handled by \pkg{zref-clever} as an error
947 (at least, if we try to refer to it), usually a ``missing name'' error.
948
949 \pkg{zref-clever} provides initial settings for the following reference types:
950 \texttt{part}, \texttt{chapter}, \texttt{section}, \texttt{paragraph},
951 \texttt{appendix}, \texttt{subappendix}, \texttt{page}, \texttt{line},
952 \texttt{figure}, \texttt{table}, \texttt{item}, \texttt{footnote},
953 \texttt{endnote}, \texttt{note}, \texttt{equation}, \texttt{theorem},
954 \texttt{lemma}, \texttt{corollary}, \texttt{proposition}, \texttt{definition},
955 \texttt{proof}, \texttt{result}, \texttt{remark}, \texttt{example},
956 \texttt{algorithm}, \texttt{listing}, \texttt{exercise}, and
957 \texttt{solution}. Therefore, if you are using a language for which
958 \pkg{zref-clever} has built-in support (see \zcref{sec:internationalization}),
959 these reference types are available for use out of the box.\footnote{There may
960 be slight availability differences depending on the language, but
961 \pkg{zref-clever} strives to keep this complete list available for the
962 languages it has built-in language files.} And, in any case, it is always
963 easy to setup custom reference types with \cs{zcRefTypeSetup} or
964 \cs{zcLanguageSetup} (see \zcref{sec:user-interface, sec:reference-format,
965 sec:internationalization}).
966
967 The association of a \emph{counter} to its \emph{type} is controlled by the
968 \opt{countertype} option. As seen in its documentation, \pkg{zref-clever}
969 presumes the \emph{type} to be the same as the \emph{counter} unless
970 instructed otherwise by that option. This association, as determined by the
971 local value of the option, affects how the \cs{label} is set, which stores the
972 type among its properties. However, when it comes to typesetting, that is
973 from the perspective of \cs{zcref}, only the \emph{type} matters. In other
974 words, how the reference is supposed to be typeset is determined at the point
975 the \cs{label} gets set. In sum, they may be namesakes (or not), but type is
976 type and counter is counter.
977
978 Indeed, a reference type can be associated with multiple counters because we
979 may want to refer to different document elements, with different
980 \emph{counters}, as a single \emph{type}, with a single name. One prominent
981 case of this are sectioning commands. \cs{section}, \cs{subsection}, and
982 \cs{subsubsection} have each their counter, but we'd like to refer to all of
983 them by ``sections'' and group them together. The same for \cs{paragraph} and
984 \cs{subparagraph}.
985
986 There are also cases in which we may want to use different \emph{reference
987 types} to refer to document objects sharing the same \emph{counter}.
988 Notably, the environments created with \LaTeX{}'s \cs{newtheorem} command and
989 the \cs{appendix}.
990
991 One more observation about ``reference types'' is due here. A \emph{type} is
992 not really ``defined'' in the sense a variable or a function is. It is more
993 of a ``name'' which \pkg{zref-clever} uses to look for a whole set of
994 type-specific reference format options (see \zcref{sec:reference-format}).
995 Each of these options individually may be ``set'' or not, ``defined'' or not.
996 And, depending on the setup and the relevant precedence rules for this, some
997 of them may be required and some not. In practice, \pkg{zref-clever} uses the
998 \emph{type} to look for these options when it needs one, and issues a
999 compilation warning when it cannot find a suitable value.
1000
1001
1002 \section{Reference format}
1003 \label{sec:reference-format}
1004
1005 Formatting how the reference is to be typeset is, quite naturally, a big part
1006 of the user interface of \pkg{zref-clever}. In this area, we tried to balance
1007 ``flexibility'' and ``user friendliness''. But the former does place a big
1008 toll overall, since there are indeed many places where tweaking may be
1009 desired, and the settings may depend on at least two important dimensions of
1010 variation: the reference type and the language. Combination of those
1011 necessarily makes for a large set of possibilities. Hence, the attempt here
1012 is to provide a rich set of ``handles'' for fine tuning the reference format
1013 but, at the same time, do not \emph{require} detailed setup by the users,
1014 unless they really want it.
1015
1016 With that in mind, we have settled with a user interface for reference
1017 formatting which allows settings to be done in different scopes, with more or
1018 less overarching effects, and some precedence rules to regulate the relation
1019 of settings given in each of these scopes. There are four scopes in which
1020 reference formatting can be specified by the user, in the following precedence
1021 order: i) as \emph{general options}; ii) as \emph{type-specific options}; iii)
1022 as \emph{language- and type-specific options}; and iv) as
1023 \emph{language-specific default options}. Besides those, there's a fifth
1024 \emph{internal} scope, with the least priority of all, a ``fallback'', for the
1025 cases where it is meaningful to provide some value, even for an unknown
1026 language. The package itself places the default setup for reference
1027 formatting at low precedence levels, and the users can easily and conveniently
1028 override them as desired.
1029
1030 ``General'' options (i) can be given by the user in the optional argument of
1031 \cs{zcref}, but also set through \cs{zcsetup} (see \zcref{sec:options}).
1032 ``Type'' specific options (ii) are handled by \cs{zcRefTypeSetup} (see
1033 \zcref{sec:user-interface}). ``Language'' options, whether ``type'' specific
1034 (iii) or ``default'' (iv) have their user interface in \cs{zcLanguageSetup},
1035 and have their values populated by the package's built-in language files (see
1036 \zcref{sec:internationalization}). Not all reference format specifications
1037 can be given in all of these scopes, though. Some of them can't be
1038 type-specific, others must be type-specific, so the set available in each
1039 scope depends on the pertinence of the case. \zcref{tab:reference-format}
1040 introduces the available reference format options, which will be discussed in
1041 more detail soon, and lists the scopes in which each is available.
1042
1043
1044 \begin{table}[htb]
1045 \centering
1046 \begin{tabular}{l>{\ttfamily}lcccc}
1047 \toprule
1048 & & General & Type & \multicolumn{2}{c}{Language} \\
1049 \cmidrule(lr){5-6}
1050 & & & & Type & Default \\
1051 & & (i) & (ii) & (iii) & (iv) \\
1052
1053 \midrule
1054 Typesetting & tpairsep & $\bullet$ & & & $\bullet$ \\
1055 (necessarily not & tlistsep & $\bullet$ & & & $\bullet$ \\
1056 type-specific) & tlastsep & $\bullet$ & & & $\bullet$ \\
1057 & notesep & $\bullet$ & & & $\bullet$ \\
1058
1059 \addlinespace
1060 Typesetting & namesep & $\bullet$ & $\bullet$ & $\bullet$ & $\bullet$ \\
1061 (possibly & pairsep & $\bullet$ & $\bullet$ & $\bullet$ & $\bullet$ \\
1062 type-specific) & listsep & $\bullet$ & $\bullet$ & $\bullet$ & $\bullet$ \\
1063 & lastsep & $\bullet$ & $\bullet$ & $\bullet$ & $\bullet$ \\
1064 & rangesep & $\bullet$ & $\bullet$ & $\bullet$ & $\bullet$ \\
1065 & refbounds & $\bullet$ & $\bullet$ & $\bullet$ & $\bullet$ \\
1066
1067 \addlinespace
1068 Typesetting & Name-sg & & $\bullet$ & $\bullet$ & \\
1069 (necessarily & name-sg & & $\bullet$ & $\bullet$ & \\
1070 type-specific) & Name-pl & & $\bullet$ & $\bullet$ & \\
1071 & name-pl & & $\bullet$ & $\bullet$ & \\
1072 & Name-sg-ab & & $\bullet$ & $\bullet$ & \\
1073 & name-sg-ab & & $\bullet$ & $\bullet$ & \\
1074 & Name-pl-ab & & $\bullet$ & $\bullet$ & \\
1075 & name-pl-ab & & $\bullet$ & $\bullet$ & \\
1076
1077 \addlinespace
1078 Font & namefont & $\bullet$ & $\bullet$ & $\bullet$ & $\bullet$ \\
1079 & reffont & $\bullet$ & $\bullet$ & $\bullet$ & $\bullet$ \\
1080
1081 \addlinespace
1082 Other & cap & $\bullet$ & $\bullet$ & $\bullet$ & $\bullet$ \\
1083 & abbrev & $\bullet$ & $\bullet$ & $\bullet$ & $\bullet$ \\
1084 & endrange & $\bullet$ & $\bullet$ & $\bullet$ & $\bullet$ \\
1085 & rangetopair & $\bullet$ & $\bullet$ & $\bullet$ & $\bullet$ \\
1086 \bottomrule
1087 \end{tabular}
1088 \caption{Reference format options and their scopes}
1089 \label{tab:reference-format}
1090 \end{table}
1091
1092
1093 Understanding the role of each of these reference format options is likely
1094 eased by some visual schemes of how \pkg{zref-clever} builds a reference based
1095 on the labels' data and the value of these options. Take a \texttt{ref} to be
1096 that which a standard \LaTeX{} \cs{ref} would typeset. A \pkg{zref-clever}
1097 ``reference block'', or \texttt{ref-block}, is constructed as:
1098
1099 \begin{refformat}
1100 \item \reffmt{ref-block} \(\equiv\)
1101 \item \reffmt{preref*}
1102 \raisebox{-\baselineskip}{\makebox[0pt]{\^{}}}%
1103 \raisebox{-1.2\baselineskip}{\makebox[0pt]{\footnotesize{}hyperlink start}}
1104 \reffmt{preref} \reffmt{ref} \reffmt{postref}
1105 \raisebox{-\baselineskip}{\makebox[0pt]{\^{}}}%
1106 \raisebox{-1.2\baselineskip}{\makebox[0pt]{\footnotesize{}hyperlink end}}
1107 \reffmt{postref*}
1108 \end{refformat}
1109
1110 Where the \opt{refbounds} option, which receives as value a comma separated
1111 list of four items in the form \texttt{\{preref*,preref,postref,postref*\}},
1112 sets the surrounding elements to \texttt{ref}.\footnote{As usual, if each of
1113 the items contains start or end spaces, or commas anywhere, they must be
1114 protected by a pair of braces. However, care is taken that empty items
1115 don't need such protection. So you can set, for example, something like
1116 \texttt{refbounds=\{(,{},{},)\}} to get parentheses around your references,
1117 outside the hyperlink.} A \texttt{ref-block} is built for \emph{each} label
1118 given as argument to \cs{zcref}. When the \meta{labels} argument is comprised
1119 of multiple labels, each ``reference type group'', or \texttt{type-group} is
1120 potentially made from the combination of single reference blocks, ``reference
1121 block pairs'', ``reference block lists'', or ``reference block ranges'', where
1122 each is respectively built as:
1123
1124 \begin{refformat}
1125 \item \reffmt{type-group} is a combination of:
1126 \item \reffmt{ref-block}
1127 \item \reffmt{ref-block1} \reffmt{pairsep} \reffmt{ref-block2}
1128 \item \reffmt{ref-block1} \reffmt{listsep} \reffmt{ref-block2}
1129 \reffmt{listsep} \reffmt{ref-block3} \dots{} \par \qquad
1130 \dots{}\reffmt{ref-blockN-1} \reffmt{lastsep} \reffmt{ref-blockN}
1131 \item \reffmt{ref-block1} \reffmt{rangesep} \reffmt{ref-blockN}
1132 \end{refformat}
1133
1134 To complete a ``type-block'', a \texttt{type-group} only needs to be
1135 accompanied by the ``type name'':
1136
1137 \begin{refformat}
1138 \item \reffmt{type-block} \(\equiv\)
1139 \item \reffmt{type-name} \reffmt{namesep} \reffmt{type-group}
1140 \end{refformat}
1141
1142 The \texttt{type-name} is determined not by one single reference format option
1143 but by the appropriate one among the \opt{[Nn]ame-} options according to the
1144 composition of \texttt{type-group} and the general options. The reference
1145 format name options are eight in total: \opt{Name-sg}, \opt{name-sg},
1146 \opt{Name-pl}, \opt{name-pl}, \opt{Name-sg-ab}, \opt{name-sg-ab},
1147 \opt{Name-pl-ab}, and \opt{name-pl-ab}. The initial uppercase ``\texttt{N}''
1148 signals the capitalized form of the type name. The \texttt{-sg} suffix stands
1149 for singular, while \texttt{-pl} for plural. The \texttt{-ab} is appended to
1150 the abbreviated type name form options. When setting up a type, not
1151 necessarily all forms need to be provided. \pkg{zref-clever} will always use
1152 the non-abbreviated form as a fallback to the abbreviated one, if the later is
1153 not available. Hence, if a reference type is not intended to be used with
1154 abbreviated names (the most common case), only the basic four forms are
1155 needed. Besides that, if you are using the \opt{cap} option, only the
1156 capitalized forms will ever be required by \cs{zcref}, so you can get away
1157 setting only \opt{Name-sg} and \opt{Name-pl}. You should not do the contrary
1158 though, and provide only the non-capitalized forms because, even if you are
1159 using the \opt{nocap} option, the capitalized forms will be still required for
1160 \opt{capfirst} and \opt{S} options to work. Whatever the case may be, you
1161 need not worry too much about being remiss in this area: if \cs{zcref} does
1162 lack a name form in any given reference, it will let you know with a
1163 compilation warning (and will typeset the usual missing reference sign:
1164 ``\textbf{??}'').
1165
1166 A complete reference typeset by \cs{zcref} may be comprised of multiple
1167 \texttt{type-block}s, in which case the ``type-block-group'' can also be made
1168 of single type blocks, ``type block pairs'' or ``type block lists'', where
1169 each is respectively built as:
1170
1171 \begin{refformat}
1172 \item \reffmt{type-block-group} is one of:
1173 \item \reffmt{type-block}
1174 \item \reffmt{type-block1} \reffmt{tpairsep} \reffmt{type-block2}
1175 \item \reffmt{type-block1} \reffmt{tlistsep} \reffmt{type-block2}
1176 \reffmt{tlistsep} \reffmt{type-block3} \dots{} \par \qquad \dots{}
1177 \reffmt{type-blockN-1} \reffmt{tlastsep} \reffmt{type-blockN}
1178 \end{refformat}
1179
1180 Finally, since \cs{zcref} can also receive an optional \opt{note}, its full
1181 typeset output is built as:
1182
1183 \begin{refformat}
1184 \item A complete \reffmt{\cs{zcref}} reference:
1185 \item \reffmt{type-block-group} \reffmt{notesep} \reffmt{note}
1186 \end{refformat}
1187
1188 Reference format options can yet be divided in three general categories: i)
1189 ``typesetting'' options, the ones which we have seen thus far, as ``building
1190 blocks'' of the reference; ii) ``font'' options, which control font attributes
1191 of parts of the reference, namely \opt{namefont} and \opt{reffont}; and iii)
1192 ``other'' options. ``Typesetting'' options are intended exclusively for
1193 typesetting material: things you expect to see in the output of your
1194 references. ``Font'' options set the font, respectively, for the
1195 \texttt{type-name} and for \texttt{ref} (to set the font for the whole
1196 reference, see the \opt{font} option in \zcref{sec:options}). These options
1197 are intended exclusively for commands that only change font attributes: style,
1198 family, shape, weight, size, color, etc. In either case, anything other than
1199 their intended uses is not supported.
1200
1201 Finally, a comment about the internal ``fallback'' reference format values
1202 mentioned above. These ``last resort'' option values are required by
1203 \pkg{zref-clever} for a clear particular case: if the user loads either
1204 \pkg{babel} or \pkg{polyglossia}, or explicitly sets a language, with a
1205 language that \pkg{zref-clever} does not know and has no language file for, it
1206 cannot guess what language that is, and thus has to provide some reasonable
1207 ``language agnostic'' default, at least for the options for which this makes
1208 sense. Users do not need to have access to this scope, since they know the
1209 language of their document, or know the values they want for those options,
1210 and can set them as general options, type-specific options, or language
1211 options through the user interface provided for the purpose. But the
1212 ``fallback'' options are documented here so that you can recognize when you
1213 are getting these values and change them appropriately as desired. Though
1214 hopefully reasonable, they may not be what you want. The ``fallback'' option
1215 values are the following:
1216
1217 \begin{zcexample}[escapeinside=`']
1218 tpairsep = {,`\textvisiblespace{}'} ,
1219 tlistsep = {,`\textvisiblespace{}'} ,
1220 tlastsep = {,`\textvisiblespace{}'} ,
1221 notesep = {`\textvisiblespace{}'} ,
1222 namesep = {\nobreakspace} ,
1223 pairsep = {,`\textvisiblespace{}'} ,
1224 listsep = {,`\textvisiblespace{}'} ,
1225 lastsep = {,`\textvisiblespace{}'} ,
1226 rangesep = {\textendash} ,
1227 \end{zcexample}
1228
1229
1230 \subsection{Advanced reference formatting}
1231
1232 The reference format options discussed above and presented in
1233 \zcref{tab:reference-format} should suffice for most needs. However, if more
1234 fine-grained control of the reference format is needed, this can be achieved
1235 through a more detailed specification of \opt{refbounds} for the different
1236 cases in which they may occur when a reference is processed. The options
1237 available for this purpose are presented in
1238 \zcref{tab:advanced-reference-format}.
1239
1240 \begin{table}
1241 \centering
1242 \DeleteShortVerb \|
1243 \begin{tabular}{l>{\ttfamily}lcccc}
1244 \toprule
1245 & & General & Type & \multicolumn{2}{c}{Language} \\
1246 \cmidrule(lr){5-6}
1247 & & & & Type & Default \\
1248 & & (i) & (ii) & (iii) & (iv) \\
1249
1250 \midrule
1251 Base & refbounds-first & $\bullet$ & $\bullet$ & $\bullet$ & $\bullet$ \\
1252 options & refbounds-first-sg & $\bullet$ & $\bullet$ & $\bullet$ & $\bullet$ \\
1253 & refbounds-first-pb & $\bullet$ & $\bullet$ & $\bullet$ & $\bullet$ \\
1254 & refbounds-first-rb & $\bullet$ & $\bullet$ & $\bullet$ & $\bullet$ \\
1255 & refbounds-mid & $\bullet$ & $\bullet$ & $\bullet$ & $\bullet$ \\
1256 & refbounds-mid-rb & $\bullet$ & $\bullet$ & $\bullet$ & $\bullet$ \\
1257 & refbounds-mid-re & $\bullet$ & $\bullet$ & $\bullet$ & $\bullet$ \\
1258 & refbounds-last & $\bullet$ & $\bullet$ & $\bullet$ & $\bullet$ \\
1259 & refbounds-last-pe & $\bullet$ & $\bullet$ & $\bullet$ & $\bullet$ \\
1260 & refbounds-last-re & $\bullet$ & $\bullet$ & $\bullet$ & $\bullet$ \\
1261
1262 \addlinespace
1263 Derived & +refbounds-first & $\bullet$ & $\bullet$ & $\bullet$ & $\bullet$ \\
1264 options & +refbounds-mid & $\bullet$ & $\bullet$ & $\bullet$ & $\bullet$ \\
1265 (groups) & +refbounds-last & $\bullet$ & $\bullet$ & $\bullet$ & $\bullet$ \\
1266 & +refbounds-rb & $\bullet$ & $\bullet$ & $\bullet$ & $\bullet$ \\
1267 & +refbounds-re & $\bullet$ & $\bullet$ & $\bullet$ & $\bullet$ \\
1268 & +refbounds & $\bullet$ & $\bullet$ & $\bullet$ & $\bullet$ \\
1269 \bottomrule
1270 \end{tabular}
1271 \caption{Advanced reference format options and their scopes}
1272 \label{tab:advanced-reference-format}
1273 \end{table}
1274
1275 The ``base'' options are the actually operative ones, while the ``derived''
1276 options are convenience aliases to set multiple base options in one go. In
1277 the naming scheme of these options, as is easy to presume, ``\texttt{first}''
1278 refers to the first reference of a type-block, ``\texttt{mid}'' to the middle
1279 ones, and ``\texttt{last}'' to the last reference of the type-block. Less
1280 obviously, but hopefully still mnemonic enough, ``\texttt{sg}'' stands for
1281 ``single'', ``\texttt{pb}'' and ``\texttt{pe}'' for ``pair begin'' and ``pair
1282 end'', and finally ``\texttt{rb}'' and ``\texttt{re}'' for ``range begin'' and
1283 ``range end''. Each of them receives as value a comma separated list of four
1284 items in the form \texttt{\{preref*,preref,postref,postref*\}}, just like
1285 \opt{refbounds}.
1286
1287 The base options are mutually exclusive, which means, for example, that it is
1288 not sufficient to set \opt{refbounds-first} to define the behavior of all
1289 first references of a type block. \opt{refbounds-first} is the value used for
1290 the first reference when not single, not the beginning of a pair, and not the
1291 beginning of a range. Setting a group of them is the purpose of the derived
1292 options. Each of these sets all options under it. Some examples.
1293 \opt{+refbounds-first} sets \opt{refbounds-first}, \opt{refbounds-first-sg},
1294 \opt{refbounds-first-pb}, and \opt{refbounds-first-rg}. In turn,
1295 \opt{+refbounds-rb} sets \opt{refbounds-first-rb} and \opt{refbounds-mid-rb}.
1296 And quite conveniently, \opt{+refbounds} sets \opt{+refbounds-first},
1297 \opt{+refbounds-mid}, and \opt{+refbounds-last}, it is hence sufficient to set
1298 it to define the behavior of what is typeset around all references for the
1299 whole type-block. As you probably guessed by now, the \opt{refbounds} option
1300 presented in \zcref{tab:reference-format} is an alias of \opt{+refbounds}.
1301
1302 Given that base and derived options are actually setting the same group of
1303 underlying options (the base ones), the order in which they are given is
1304 relevant: the last one prevails. The idea here is to use first the derived
1305 options to set some general defaults, and then change one or another base
1306 option to handle exceptions as needed. Of course, how best to use them
1307 depends on the case.
1308
1309
1310 \section{Internationalization}
1311 \label{sec:internationalization}
1312
1313 \pkg{zref-clever} provides internationalization facilities and integrates with
1314 \pkg{babel} and \pkg{polyglossia} to adapt to the languages in use by either
1315 of these language packages, or to a language specified directly by the user.
1316 This is primarily relevant for reference format options, particularly
1317 reference type \emph{names} (though not only, since most reference format
1318 options can have language-specific values see \zcref{sec:reference-format}).
1319 But other features of the package also cater for language specific needs.
1320
1321 As far as language selection is concerned, if the language is declared and
1322 \pkg{zref-clever} has a built-in ``language file'' for it, most use cases will
1323 likely be covered by the \opt{lang} option (see \zcref{sec:options}), and its
1324 values \texttt{current} and \texttt{main}. When the \opt{lang} option is set
1325 to \texttt{current} or \texttt{main}, \pkg{zref-check} will use, respectively,
1326 the \emph{current} or \emph{main} language of the document, as defined by
1327 \pkg{babel} or \pkg{polyglossia}.\footnote{Technically, \pkg{zref-clever} uses
1328 \cs{languagename} and \cs{bbl@main@language} for \pkg{babel}, and
1329 \cs{babelname} and \cs{mainbabelname} for \pkg{polyglossia}, which boils
1330 down to \pkg{zref-clever} always using \emph{\pkg{babel} names} internally,
1331 regardless of which language package is in use. Indeed, an acquainted user
1332 will note that \zcref{tab:languages-and-aliases} contains only \pkg{babel}
1333 language names.} Users can also set \opt{lang} to a specific language
1334 directly, in which case \pkg{babel} and \pkg{polyglossia} are disregarded.
1335 \pkg{zref-clever} provides a number of built-in ``language files'', for the
1336 languages listed in \zcref{tab:languages-and-aliases}, which also includes the
1337 declared aliases to those languages.
1338
1339 \pkg{zref-clever}'s ``language files'' are loaded sparingly and lazily. A
1340 language file for a single language -- that specified by user options in the
1341 preamble, which by default is the current document language -- is loaded at
1342 \texttt{begindocument}. If any other language file is needed, it is loaded on
1343 the fly, if and when required. Of course, in either case, conditioned on
1344 availability. In sum, \pkg{zref-clever} loads as little as possible, but
1345 allows for convenient on the fly loading of language files if the values are
1346 indeed required, without users having to worry about it at all.
1347
1348 \begin{table}
1349 \centering
1350 \begin{tabular}{ll}
1351 \toprule
1352 Language & Aliases \\
1353 \midrule
1354 dutch & \\
1355 english & american \\
1356 & australian \\
1357 & british \\
1358 & canadian \\
1359 & newzealand \\
1360 & UKenglish \\
1361 & USenglish \\
1362 french & acadian \\
1363 & \\
1364 & \\
1365 & \\
1366 \bottomrule
1367 \end{tabular}
1368 \quad
1369 \begin{tabular}{ll}
1370 \toprule
1371 Language & Aliases \\
1372 \midrule
1373 german & ngerman \\
1374 & austrian \\
1375 & naustrian \\
1376 & swissgerman \\
1377 & nswissgerman \\
1378 italian & \\
1379 portuguese & brazilian \\
1380 & brazil \\
1381 & portuges \\
1382 russian & \\
1383 spanish & \\
1384 swedish & \\
1385 \bottomrule
1386 \end{tabular}
1387 \caption{Declared languages and aliases}
1388 \label{tab:languages-and-aliases}
1389 \end{table}
1390
1391
1392 But if the built-in language files do not cover your language, or if you'd
1393 like to adjust some of the default language-specific options, this can be done
1394 with \cs{zcDeclareLanguage}, \cs{zcDeclareLanguageAlias}, and
1395 \cs{zcLanguageSetup}.\footnote{Needless to say, if you'd like to contribute a
1396 language file or improve an existing one, that is much welcome at
1397 \url{https://github.com/gusbrs/zref-clever/issues}.}
1398
1399 \begin{function}{\zcDeclareLanguage}
1400 \begin{syntax}
1401 \cs{zcDeclareLanguage}\oarg{options}\marg{language}
1402 \end{syntax}
1403 \end{function}
1404 Declare a new language for use with \pkg{zref-clever}. If \meta{language} has
1405 already been declared, just warn. The \meta{options} argument receives the
1406 usual \texttt{key=value} list and recognizes three keys: \opt{variants},
1407 \opt{gender}, and \opt{allcaps}. \opt{variants} receives a coma separated
1408 list of valid type name variants for \meta{language}.\footnote{This option was
1409 initially conceived to support declension cases, but was eventually
1410 generalized to encompass a broader meaning, and is now more flexibly
1411 interpreted as simply ``variants''.} The first element of the list is
1412 considered to be the default variant, both for the \opt{v} option in
1413 \cs{zcref} and for the \opt{variant} option in \cs{zcLanguageSetup}.
1414 Similarly, \opt{gender} receives a comma separated list of genders for
1415 \meta{language}. The elements in this list are those which are recognized as
1416 valid for the language for both the \opt{g} option in \cs{zcref} and the
1417 \opt{gender} option in \cs{zcLanguageSetup}. There is no default presumed in
1418 this case. Finally, \opt{allcaps} can be used with languages for which nouns
1419 must be always capitalized for grammatical reasons. For a language declared
1420 with the \opt{allcaps} option, the \opt{cap} reference option (see
1421 \zcref{sec:options}) is disregarded, and \cs{zcref} always uses the
1422 capitalized type name forms. This means that language files for languages
1423 with such a trait can be halved in size, and that user customization for them
1424 is simplified, only requiring the capitalized name forms. On the other hand,
1425 the non-capitalized \texttt{name-} reference format options are rendered no-op
1426 for the language in question. \zcref[S]{tab:language-options} presents an
1427 overview of the options in effect for the languages declared by
1428 \pkg{zref-clever}. \cs{zcDeclareLanguage} is preamble only.
1429
1430 \begin{table}
1431 \centering
1432 \begin{tabular}{l>{\ttfamily}c>{\ttfamily}c>{\ttfamily}c}
1433 \toprule
1434 Language & variants & gender & allcaps \\
1435 \midrule
1436 dutch & -- & f,m,n & -- \\
1437 english & -- & -- & -- \\
1438 french & -- & f,m & -- \\
1439 german & N,A,D,G & f,m,n & yes \\
1440 italian & -- & f,m & -- \\
1441 portuguese & -- & f,m & -- \\
1442 spanish & -- & f,m & -- \\
1443 russian & n,a,g,d,i,p & f,m,n & -- \\
1444 swedish & -- & -- & -- \\
1445 \bottomrule
1446 \end{tabular}
1447 \caption{Options for declared languages}
1448 \label{tab:language-options}
1449 \end{table}
1450
1451 \begin{function}{\zcDeclareLanguageAlias}
1452 \begin{syntax}
1453 \cs{zcDeclareLanguageAlias}\marg{language alias}\marg{aliased language}
1454 \end{syntax}
1455 \end{function}
1456 Declare \meta{language alias} to be an alias of \meta{aliased language}.
1457 \meta{aliased language} must be already known to \pkg{zref-clever}. Once set,
1458 the \meta{language alias} is treated by \pkg{zref-clever} as completely
1459 equivalent to the \meta{aliased language} for any language specification by
1460 the user. \cs{zcDeclareLanguageAlias} is preamble only.
1461
1462 \begin{function}{\zcLanguageSetup}
1463 \begin{syntax}
1464 \cs{zcLanguageSetup}\marg{language}\marg{options}
1465 \end{syntax}
1466 \end{function}
1467 Sets language-specific reference format options for \meta{language} (see
1468 \zcref{sec:reference-format}), be they type-specific or not. \meta{language}
1469 must be already known to \pkg{zref-clever}. Besides reference format options,
1470 \cs{zcLanguageSetup} knows three other keys: \opt{type}, \opt{variant}, and
1471 \opt{gender}. The first two work like a ``switch'' affecting the options
1472 \emph{following} it. For example, if \texttt{type=foo} is given in
1473 \meta{options} the options following it will be set as type-specific options
1474 for reference type \texttt{foo}. Similarly, after \texttt{variant=X}
1475 (provided \texttt{X} is a valid variant for \meta{language}), the following
1476 \texttt{[Nn]ame-} options will set values for the \texttt{X} variant (other
1477 reference format options are not affected by \opt{variant}). Before the first
1478 occurrence of either \opt{type} or \opt{variant} default values are set. For
1479 \opt{variant} this means the default variant, which is the first element of
1480 the list provided to the \opt{variants} option in \cs{zcDeclareLanguage}. For
1481 \opt{type} this means language-specific but not type-specific option values
1482 (see \zcref{sec:reference-format}). An empty valued \texttt{type=} key can
1483 also ``unset'' the type. The \opt{gender} key sets the gender of the current
1484 \texttt{type} (provided the value it receives is one of the declared genders
1485 for \meta{language}). For \texttt{type}s which have multiple valid genders
1486 for a given language, the option can also receive a comma separated list.
1487 \cs{zcLanguageSetup} is preamble only.
1488
1489 A couple of examples to illustrate the syntax of \cs{zcLanguageSetup}:
1490
1491 \begin{zcexample}
1492 \zcLanguageSetup{french}{
1493 type = section ,
1494 gender = f ,
1495 Name-sg = Section ,
1496 name-sg = section ,
1497 Name-pl = Sections ,
1498 name-pl = sections ,
1499 }
1500 \zcLanguageSetup{german}{
1501 type = section ,
1502 gender = m ,
1503 variant = N ,
1504 Name-sg = Abschnitt ,
1505 Name-pl = Abschnitte ,
1506 variant = A ,
1507 Name-sg = Abschnitt ,
1508 Name-pl = Abschnitte ,
1509 variant = D ,
1510 Name-sg = Abschnitt ,
1511 Name-pl = Abschnitten ,
1512 variant = G ,
1513 Name-sg = Abschnitts ,
1514 Name-pl = Abschnitte ,
1515 }
1516 \end{zcexample}
1517
1518 \bigskip{}
1519
1520 As already noted, \pkg{zref-clever} has some support for languages with
1521 declension. This means mainly the declension of \emph{nouns}, which is used
1522 for the reference type names. But some tools are also provided to support the
1523 user in getting better results for the text surrounding a reference,
1524 particularly for numbered and gendered articles, even if those don't have
1525 their typeset output automated.
1526
1527 For reference type names, the declension cases for each language must be
1528 declared as \opt{variants} with \cs{zcDeclareLanguage}, and the name reference
1529 format options must be provided for each case, which is done for built-in
1530 language files of languages which have noun declension, and can be done by the
1531 user with \cs{zcLanguageSetup}, as we've seen. \pkg{zref-clever} does not try
1532 to guess or infer the case though, you must tell it to \cs{zcref}. And this
1533 is done by means of the \opt{v} option (see \zcref{sec:options}). So you may
1534 write something like ``\texttt{nach den
1535 \cs{zcref}[v=D]\{sec:section-1,sec:section-2\}}'' to get ``nach den
1536 Abschnitten 1 und 2''. Or ``\texttt{trotz des
1537 \cs{zcref}[v=G]\{eq:theorem-1\}}'' to get ``trotz des Theorems 1''.
1538
1539 Regarding the text surrounding the reference -- the inflected article, the
1540 passing preposition, etc.\ --, the issue is more delicate. \pkg{zref-clever}
1541 cannot and intends not to typeset those for you. But, depending on the
1542 language, it is true that the kind of automation provided by \pkg{zref-clever}
1543 may betray your best efforts to get a proper surrounding text. Multiple
1544 labels passed to \cs{zcref} may result in singular type names, either because
1545 the labels are of different types, or because they got compressed into a
1546 single reference. References comprised of multiple type blocks may have each
1547 a name with a different gender. Or, worse, \opt{tpairsep}, \opt{tpairsep},
1548 and \opt{tlastsep} may not provide a general enough way to separate different
1549 type blocks in your language altogether. You may change something in your
1550 document that causes a label to change its type, and hence the gender of the
1551 type name. A page reference to a couple of floats which were by chance on the
1552 same page and all of a sudden no longer are. And so on.
1553
1554 In this area, the approach taken by \pkg{zref-clever} is to identify some
1555 typical situations in which your attention may be required in reviewing the
1556 surrounding text, and signal it at compilation time. Just like bad boxes, for
1557 example. This feature can be enabled by the \opt{nudge} option (which is
1558 opt-in, see \zcref{sec:options}). There are three ``nudges'' available for
1559 this purpose which trigger messages at different events: \opt{multitype},
1560 \opt{comptosing}, and \opt{gender}. \opt{multitype} nudges when a reference
1561 is comprised of multiple type blocks. \opt{comptosing} when multiple labels
1562 of the same type block have been compressed into a single one and, hence, the
1563 type name used is singular. Finally, \opt{gender} nudges when there is a
1564 mismatch between the gender specified in \cs{zcref} with the \opt{g} option
1565 and the gender of the type name, as set in the language file or with
1566 \cs{zcLanguageSetup}, for each type block. Which nudges to use is
1567 configurable with the option \opt{nudgeif}. And, if you're sure of the
1568 results for a particular \cs{zcref} call, you can always silence the nudges
1569 locally with the \opt{nonudge} option.
1570
1571 The main reason to watch for multiple type references with the \opt{multitype}
1572 nudge is that bundling together automatically a list of type blocks is less
1573 smooth an operation than it is for a single reference type. While it arguably
1574 works reasonably well for English, even there it is not always flawless, and
1575 depending on the language, results may range from ``poor style'' to outright
1576 wrong. A typical case would be of that of a language with inflected articles
1577 and a reference with multiple types of different genders or numbers. For
1578 example, in French, with a standard ``\texttt{au \cs{zcref}\{cha:chapter-3,
1579 sec:section-3.1\}}'' we get ``au chapitre 3 et section 3.1'' which sounds
1580 ugly, at best. So we may be better off writing instead ``\texttt{au
1581 \cs{zcref}\{cha:chapter-3\} et à la \cs{zcref}\{sec:section-3.1\}}''. Or
1582 something else, of course. But the general point is that, depending on
1583 circumstances and on the language, the results of automating the grouping of
1584 multiple reference types, as \pkg{zref-clever} is able to do, may leave things
1585 to be desired for. Hence it lets you know when one such case occurs, so that
1586 you can review it for best results.
1587
1588 The case of the \opt{comptosing} and \opt{gender} nudges is more objective in
1589 nature, they respectively signal mismatches of number and gender. When a
1590 reference is made with \cs{zcref} to a single label we are sure the type name
1591 will be a singular form. However, when \cs{zcref} receives multiple labels of
1592 the same type, the type name will normally be a plural, but not necessarily
1593 so, since the labels may be compressed into a single one (see the \opt{comp}
1594 option in \zcref{sec:options}), in which case the singular is used. The
1595 compression of multiple labels into a single reference should be an exception
1596 for default references, but not so for \opt{page} references, where it is easy
1597 to conceive practical situations where it may occur. Suppose, for example,
1598 you have two contiguous floats in your document and make a page reference to
1599 both of them. Will they end up in the same page or not? Maybe we know what
1600 the current state is, but we cannot know what may happen as the document keeps
1601 being edited. As a consequence, we don't know whether that reference will end
1602 up having a plural or a singular type name. That given, the logic of the
1603 \opt{comptosing} nudge is the following. If we are giving multiple labels to
1604 \cs{zcref}, we can \emph{presume} a plural type name, but we get a nudge in
1605 case the compression of the labels results in a singular type name form. If
1606 one such compression did happen to one of your references, you can use a
1607 singular article and then tell \cs{zcref} you did so with option \opt{sg}.
1608 The effect of the \opt{sg} option is to inhibit the nudge when a compression
1609 to singular occurs, but to do it instead when the compression \emph{ceases} to
1610 occur, that is, if we get a plural type name again at some point.
1611
1612 The \opt{gender} nudge aims to guard against one particular situation:
1613 possible changes of a reference's type. This does not occur by reason of any
1614 internal behavior of \pkg{zref-clever}, but it may be caused by changes in the
1615 document. You may wish to change one \texttt{theorem} into a
1616 \texttt{proposition} and, if you're writing in French or Portuguese, for
1617 example, that implies that the reference to it changes gender and the likely
1618 preceding article will no longer pass to the reference. The \opt{gender}
1619 nudge requires that the gender of each type name and of each reference be
1620 explicitly specified. For the type names, this is done for the built-in
1621 language files of languages were this matters, and can be done with
1622 \cs{zcLanguageSetup} as well. For the references, that is the purpose of the
1623 \opt{g} option. When there is a mismatch between the two for any type block,
1624 the nudge is triggered. Of couse, this means that the gender markup has to be
1625 supplied in the document at each reference. And given such type changes may
1626 not be frequent for you, or considered not particularly problematic, you'll
1627 have to balance if doing so is worth it. Still, the feature is available, and
1628 it's up to you.
1629
1630
1631 \section{How-tos}
1632 \label{sec:how-tos}
1633
1634 This section gathers some usage examples, or ``how-tos'', of cases which may
1635 require some \pkg{zref-clever} setup, or usage adjustments, and each item is
1636 set around a cross-reference ``task'' we'd like to perform with
1637 \pkg{zref-clever}.
1638
1639
1640 \subsection{Extended page references (\pkg{varioref})}
1641
1642 \zctask{Make cross-references to pages which are sensitive to the relative
1643 position between the reference and the label being referred to using
1644 \pkg{varioref}.}
1645
1646 The \pkg{zref-vario} package offers a layer of compatibility with
1647 \pkg{varioref} and provides \texttt{\textbackslash{}z}\dots{} counterparts for
1648 the latter's main reference commands.
1649
1650 \begin{zchowto}[caption={\pkg{zref-vario}}]
1651 \documentclass{article}
1652 \usepackage{zref-clever}
1653 \usepackage{zref-vario}
1654 \begin{document}
1655 \section{Section 1}
1656 \label{sec:section-1}
1657 \begin{figure}
1658 A figure.
1659 \caption{Figure 1}
1660 \label{fig:figure-1}
1661 \end{figure}
1662 \begin{figure}
1663 Another figure.
1664 \caption{Figure 2}
1665 \label{fig:figure-2}
1666 \end{figure}
1667 \zvref[S]{sec:section-1}\par
1668 \zvpageref{fig:figure-1}\par
1669 \zvrefrange{fig:figure-1}{fig:figure-2}\par
1670 \zvpagerefrange{fig:figure-1}{fig:figure-2}\par
1671 \zfullref{fig:figure-1}
1672 \end{document}
1673 \end{zchowto}
1674
1675
1676 \subsection{\cs{newtheorem}}
1677
1678 Since \LaTeX{}'s \cs{newtheorem} allows users to create arbitrary numbered
1679 environments, with respective arbitrary counters, the most \pkg{zref-clever}
1680 can do in this regard is to provide some ``typical'' built-in reference types
1681 to smooth user setup but, in the general case, some user setup may be indeed
1682 required. The examples below are equaly valid for \pkg{amsthm}'s
1683 \cs{newtheorem} since, even if it provides features beyond those available in
1684 the kernel, its syntax and underlying relation with counters is pretty much
1685 the same. The same for \pkg{ntheorem}. For \pkg{thmtools}'
1686 \cs{declaretheorem}, though some adjustments to the examples below may be
1687 required, the basic logic is the same (there is no integration with the
1688 \opt{Refname} and \opt{refname} options, which are targeted to the standard
1689 reference system, but you don't actually need them to get things working
1690 conveniently).
1691
1692
1693 \subsubsection*{Simple case}
1694
1695 \zctask{Setup up a new theorem environment created with \cs{newtheorem} to be
1696 referred to with \cs{zcref}. The theorem environment does not share its
1697 counter with other theorem environments, and one of \pkg{zref-clever}
1698 built-in reference types is adequate for my needs.}
1699
1700 Suppose you set a ``Lemma'' environment with:
1701
1702 \begin{zcexample}
1703 \newtheorem{lemma}{Lemma}[section]
1704 \end{zcexample}
1705
1706 In this case, since \pkg{zref-clever} provides a built-in \texttt{lemma} type
1707 (for supported languages) and presumes the reference type to be the same name
1708 as the counter, there is no need for setup, and things just work out of the
1709 box. So, you can go ahead with:
1710
1711 \begin{zchowto}[caption={\cs{newtheorem}, simple case}]
1712 \documentclass{article}
1713 \usepackage{zref-clever}
1714 \newtheorem{lemma}{Lemma}[section]
1715 \begin{document}
1716 \section{Section 1}
1717 \begin{lemma}\label{lemma-1}
1718 A lemma.
1719 \end{lemma}
1720 \zcref{lemma-1}
1721 \end{document}
1722 \end{zchowto}
1723
1724 If, however, you had chosen an environment name which did not happen to
1725 coincide with the built-in reference type, all you'd need to do is instruct
1726 \pkg{zref-clever} to associate the counter for your environment to the desired
1727 type with the \opt{countertype} option:
1728
1729 \begin{zchowto}[caption={\cs{newtheorem}, simple case}]
1730 \documentclass{article}
1731 \usepackage{zref-clever}
1732 \zcsetup{countertype={lem=lemma}}
1733 \newtheorem{lem}{Lemma}[section]
1734 \begin{document}
1735 \section{Section 1}
1736 \begin{lem}\label{lemma-1}
1737 A lemma.
1738 \end{lem}
1739 \zcref{lemma-1}
1740 \end{document}
1741 \end{zchowto}
1742
1743
1744 \subsubsection*{Shared counter}
1745
1746 \zctask{Setup up two new theorem environments created with \cs{newtheorem} to
1747 be referred to with \cs{zcref}. The theorem environments share the same
1748 counter, and the available \pkg{zref-clever} built-in reference types are
1749 adequate for my needs.}
1750
1751 In this case, we need to set the \opt{countertype} option in the appropriate
1752 contexts, so that the labels of each environment get set with the expected
1753 reference type. As we've seen (at \zcref{sec:user-interface}), \cs{zcsetup}
1754 has local effects, so it can be issued inside the respective environments for
1755 the purpose. Even better, we can leverage the kernel's new hook management
1756 system and just set it for all occurrences with
1757 \cs{AddToHook}\texttt{\{env/\meta{myenv}/begin\}}.
1758
1759 \begin{zchowto}[caption={\cs{newtheorem}, shared counter}]
1760 \documentclass{article}
1761 \usepackage{zref-clever}
1762 \AddToHook{env/mytheorem/begin}{%
1763 \zcsetup{countertype={mytheorem=theorem}}}
1764 \AddToHook{env/myproposition/begin}{%
1765 \zcsetup{countertype={mytheorem=proposition}}}
1766 \newtheorem{mytheorem}{Theorem}[section]
1767 \newtheorem{myproposition}[mytheorem]{Proposition}
1768 \begin{document}
1769 \section{Section 1}
1770 \begin{mytheorem}\label{theorem-1}
1771 A theorem.
1772 \end{mytheorem}
1773 \begin{myproposition}\label{proposition-1}
1774 A proposition.
1775 \end{myproposition}
1776 \zcref{theorem-1, proposition-1}
1777 \end{document}
1778 \end{zchowto}
1779
1780
1781 \subsubsection*{Custom type}
1782
1783 \zctask{Setup up a new theorem environment created with \cs{newtheorem} to be
1784 referred to with \cs{zcref}. The theorem environment does not share its
1785 counter with other theorem environments, but none of \pkg{zref-clever}
1786 built-in reference types is adequate for my needs.}
1787
1788 In this case, we need to provide \pkg{zref-clever} with settings pertaining to
1789 the custom reference type we'd like to use. Unless you need to typeset your
1790 cross-references in multiple languages, in which case you'd require
1791 \cs{zcLanguageSetup}, the most convenient way to setup a reference type is
1792 \cs{zcRefTypeSetup}. In most cases, what we really need to provide for a
1793 custom type are the ``type names'' and other reference format options can rely
1794 on default language options already provided by the package (assuming the
1795 language is supported).
1796
1797 \begin{zchowto}[caption={\cs{newtheorem}, custom type}]
1798 \documentclass{article}
1799 \usepackage{zref-clever}
1800 \newtheorem{myconjecture}{Conjecture}[section]
1801 \zcRefTypeSetup{myconjecture}{
1802 Name-sg = Conjecture ,
1803 name-sg = conjecture ,
1804 Name-pl = Conjectures ,
1805 name-pl = conjectures ,
1806 }
1807 \begin{document}
1808 \section{Section 1}
1809 \begin{myconjecture}\label{conjecture-1}
1810 A conjecture.
1811 \end{myconjecture}
1812 \zcref{conjecture-1}
1813 \end{document}
1814 \end{zchowto}
1815
1816
1817 \subsection{\pkg{newfloat}}
1818
1819 \zctask{Setup a new float environment created with \pkg{newfloat} to be
1820 referred to with \cs{zcref}. None of \pkg{zref-clever} built-in reference
1821 types is adequate for my needs.}
1822
1823 The case here is pretty much the same as that for \cs{newtheorem} with a
1824 custom type. Hence, we need to setup a corresponding type, for which
1825 providing the ``type names'' should normally suffice. Note that, as far as
1826 \pkg{zref-clever} is concerned, there's nothing specific to the \pkg{newfloat}
1827 package in the setup, the same procedure can be used with \cls{memoir}'s
1828 \cs{newfloat} command or with the \pkg{float}, \pkg{floatrow}, and
1829 \pkg{trivfloat} packages.
1830
1831 \begin{zchowto}[caption={\pkg{newfloat}}]
1832 \documentclass{article}
1833 \usepackage{newfloat}
1834 \DeclareFloatingEnvironment{diagram}
1835 \usepackage{zref-clever}
1836 \zcRefTypeSetup{diagram}{
1837 Name-sg = Diagram ,
1838 name-sg = diagram ,
1839 Name-pl = Diagrams ,
1840 name-pl = diagrams ,
1841 }
1842 \begin{document}
1843 \section{Section 1}
1844 \begin{diagram}
1845 A diagram.
1846 \caption{A diagram}
1847 \label{diagram-1}
1848 \end{diagram}
1849 \zcref{diagram-1}
1850 \end{document}
1851 \end{zchowto}
1852
1853
1854 \subsection{Overriding the reference type}
1855
1856 \zctask{Make references to a system of equations, which should be referred to
1857 in the plural.}
1858
1859 Though, usually, setting the \opt{countertype} option may provide a more
1860 general and convenient way to set the reference type of a given counter,
1861 sometimes we just need to do it for a particular label or set of labels. The
1862 \opt{reftype} option allows us to do so and set the reference type directly,
1863 regardless of what the current counter is.
1864
1865 \begin{zchowto}[caption={Overriding the reference type}]
1866 \documentclass{article}
1867 \usepackage{amsmath}
1868 \usepackage{zref-clever}
1869 \usepackage{hyperref}
1870 \zcRefTypeSetup{pluralequation}{
1871 Name-sg = Equations ,
1872 name-sg = equations ,
1873 Name-pl = Equations ,
1874 name-pl = equations ,
1875 }
1876 \begin{document}
1877 \section{Section 1}
1878 \begin{equation}
1879 \zcsetup{reftype=pluralequation}
1880 \label{eq:1}
1881 \begin{aligned}
1882 A+B&=B+A\\
1883 C&=D+E\\
1884 E&=F
1885 \end{aligned}
1886 \end{equation}
1887 \zcref{eq:1}
1888 \end{document}
1889 \end{zchowto}
1890
1891
1892 \subsection{\pkg{enumitem}}
1893
1894 \zctask{Setup a custom enumerate environment created with \pkg{enumitem} to be
1895 referred to.}
1896
1897 Since the \texttt{enumerate} environment's counters are reset at each nesting
1898 level, but not with the standard machinery, we have to inform
1899 \pkg{zref-clever} of this resetting behavior with the \opt{counterresetby}
1900 option. Also, given the naming of the underlying counters is tied with the
1901 environment's name and the level's number, we cannot really rely on an
1902 implicit counter-type association, and have to set it explicitly with the
1903 \opt{countertype} option.
1904
1905 \begin{zchowto}[caption={\pkg{enumitem}}]
1906 \documentclass{article}
1907 \usepackage{zref-clever}
1908 \zcsetup{
1909 countertype = {
1910 myenumeratei = item ,
1911 myenumerateii = item ,
1912 myenumerateiii = item ,
1913 myenumerateiv = item ,
1914 } ,
1915 counterresetby = {
1916 myenumerateii = myenumeratei ,
1917 myenumerateiii = myenumerateii ,
1918 myenumerateiv = myenumerateiii ,
1919 }
1920 }
1921 \usepackage{enumitem}
1922 \newlist{myenumerate}{enumerate}{4}
1923 \setlist[myenumerate,1]{label=(\arabic*)}
1924 \setlist[myenumerate,2]{label=(\Roman*)}
1925 \setlist[myenumerate,3]{label=(\Alph*)}
1926 \setlist[myenumerate,4]{label=(\roman*)}
1927 \begin{document}
1928 \begin{myenumerate}
1929 \item An item.\label{item-1}
1930 \begin{myenumerate}
1931 \item An item.\label{item-2}
1932 \begin{myenumerate}
1933 \item An item.\label{item-3}
1934 \begin{myenumerate}
1935 \item An item.\label{item-4}
1936 \end{myenumerate}
1937 \end{myenumerate}
1938 \end{myenumerate}
1939 \end{myenumerate}
1940 \zcref{item-1, item-2, item-3, item-4}
1941 \end{document}
1942 \end{zchowto}
1943
1944
1945 \subsection{\pkg{zref-xr}}
1946
1947 \zctask{Make references to labels set in an external document.}
1948
1949 \pkg{zref} itself offers this functionality with module \pkg{zref-xr}, and
1950 \pkg{zref-clever} is prepared to make use of it. Just a couple of details
1951 have to be taken care of, for it to work as intended: i) \pkg{zref-clever}
1952 must be loaded in both the main document and the external document, so that
1953 the imported labels also contain the properties required by \pkg{zref-clever};
1954 ii) since \cs{zexternaldocument} defines any properties it finds in the labels
1955 from the external document when it imports them, it must be called after
1956 \pkg{zref-clever} is loaded, otherwise the later will find its own internal
1957 properties already defined when it does get loaded, and will justifiably
1958 complain. Note as well that the starred version of \cs{zexternaldocument*},
1959 which imports the standard labels from the external document, is not
1960 sufficient for \pkg{zref-clever}, since the imported labels will not contain
1961 all the required properties.
1962
1963 Assuming here \file{documentA.tex} as the main file and \file{documentB.tex}
1964 as the external one, and also assuming we just want to refer in ``\texttt{A}''
1965 to the labels from ``\texttt{B}'', and not the contrary, a minimum setup would
1966 be the following.
1967
1968
1969 \begin{zchowto}[caption={\pkg{zref-xr}},escapeinside=`']
1970 `\hspace*{-1em}\file{documentA.tex}:\vspace{1ex}'
1971 \documentclass{article}
1972 \usepackage{zref-clever}
1973 \usepackage{zref-xr}
1974 \zexternaldocument[B-]{documentB}
1975 \usepackage{hyperref}
1976 \begin{document}
1977 \section{Section A1}
1978 \label{sec:section-a1}
1979 \zcref{sec:section-a1, B-sec:section-b1}
1980 \end{document}
1981 `\vspace{-1ex}'
1982 `\hspace*{-1em}\file{documentB.tex}:\vspace{1ex}'
1983 \documentclass{article}
1984 \usepackage{zref-clever}
1985 \usepackage{hyperref}
1986 \begin{document}
1987 \section{Section B1}
1988 \label{sec:section-b1}
1989 \end{document}
1990 \end{zchowto}
1991
1992
1993 \subsection{\pkg{tcolorbox}}
1994
1995 \zctask{Make references to boxes from the \pkg{tcolorbox} package.}
1996
1997 \pkg{tcolorbox} has support for \pkg{zref} and \pkg{zref-clever}, hence
1998 setting labels with the \opt{label} option works out of the box (as long as
1999 \opt{labelhook} is enabled). If you are using the \opt{auto counter}, or some
2000 other custom counter, \pkg{tcolorbox}'s \opt{label type} option can be used to
2001 set \pkg{zref-clever}'s \opt{reftype} for the relevant scope. Furthermore,
2002 those who prefer to work with \cs{zlabel}s only can set the \opt{label is
2003 zlabel} option, which makes the \opt{label} option set a \cs{zlabel}
2004 directly.
2005
2006 \begin{zchowto}[caption={\pkg{tcolorbox}}]
2007 \documentclass{article}
2008 \usepackage{zref-clever}
2009 \usepackage{zref-titleref}
2010 \usepackage{tcolorbox}
2011 \tcbuselibrary{theorems}
2012 \usepackage{hyperref}
2013 \newtcolorbox[auto counter,number within=section]{pabox}[2][]{%
2014 label type=example,
2015 title=Example~\thetcbcounter: #2,#1}
2016 \newtcolorbox[use counter from=pabox,number within=section]{pabox2}[2][]{%
2017 label type=solution,
2018 title=Solution~\thetcbcounter: #2,#1}
2019 \newtcbtheorem[number within=section]{mytheo}{My Theorem}{%
2020 label type=mytheorem}{th}
2021 \zcRefTypeSetup{mytheorem}{
2022 Name-sg=Mytheorem,
2023 name-sg=mytheorem,
2024 Name-pl=Mytheorems,
2025 name-pl=mytheorems,
2026 }
2027 \begin{document}
2028 \section{Section 1}
2029 \label{sec:section-1}
2030 \begin{pabox}[label={box:1}]{Title text}
2031 This is tcolorbox \zcref{box:1} on \zcpageref{box:1}.
2032 \end{pabox}
2033 \begin{pabox2}[label={box:2}]{Title text}
2034 This is tcolorbox \zcref{box:2} on \zcpageref{box:2}.
2035 \end{pabox2}
2036 \begin{mytheo}{This is my title}{theo}
2037 This is \zcref{th:theo} on \zcpageref{th:theo} and it is titled
2038 ``\zcref[noname,ref=title]{th:theo}''.
2039 \end{mytheo}
2040 \end{document}
2041 \end{zchowto}
2042
2043
2044 \subsection{\cls{beamer}}
2045
2046 \zctask{Making references in \cls{beamer}.}
2047
2048 \cls{beamer} does some atypical things with regard to cross-references, in
2049 particular it redefines \cs{label} to support overlays. The special treatment
2050 is not extended to \cs{zlabel}, hence \cls{beamer} requires the use of
2051 \cs{label} with the \opt{labelhook} option. Some setup for references to
2052 frames is also needed, with a fitting setting for the \opt{countertype} of the
2053 \texttt{framenumber} counter and, possibly, corresponding type names for
2054 it.\footnote{I'm not sure what the best type name for it would be though.
2055 ``Frame'' sounds too \cls{beamer}-specific, and possibly ``slide'' is what
2056 ``the audience'' would expect. But \emph{some} name (or preexisting type)
2057 would need to be assigned, and you can always choose something else, of
2058 course. This is just to illustrate the procedure.}
2059
2060 \begin{zchowto}[caption={\cls{beamer}}]
2061 \documentclass{beamer}
2062 \usepackage{zref-clever}
2063 \zcsetup{countertype={framenumber=slide}}
2064 \zcRefTypeSetup{slide}{
2065 Name-sg = Slide ,
2066 name-sg = slide ,
2067 Name-pl = Slides ,
2068 name-pl = slides ,
2069 }
2070 \begin{document}
2071 \begin{frame}[label={fr:1}]
2072 \begin{table}
2073 \begin{tabular}{cc}
2074 1 & 2 \\
2075 3 & 4 \\
2076 \end{tabular}
2077 \caption{Table 1}
2078 \label{tab:1}
2079 \end{table}
2080 \end{frame}
2081 \begin{frame}[label={fr:2}]
2082 \begin{figure}
2083 \rule{5cm}{5cm}
2084 \caption{Figure 1}
2085 \label{fig:1}
2086 \end{figure}
2087 \end{frame}
2088 \begin{frame}
2089 \zcref{fr:1,fr:2,tab:1,fig:1}
2090 \end{frame}
2091 \begin{frame}
2092 \begin{align}
2093 a &= b + c \label{eq:1}\\
2094 c &= d + e \label{eq:2}
2095 \end{align}
2096 Blah blah. \uncover<2>{More blah blah.}\par
2097 \only<3>{Specification is needed now.\label<3>{overlay}}
2098 \end{frame}
2099 \begin{frame}
2100 \zcref{eq:1,eq:2,overlay}
2101 \end{frame}
2102 \end{document}
2103 \end{zchowto}
2104
2105
2106 \subsection{Ordinal references}
2107
2108 \zctask{Typesetting the references as ordinal numbers.}
2109
2110 This example is intended as an illustration of the flexibility \pkg{zref}'s
2111 extensible referencing system grants us.\footnote{Though clearly simplified,
2112 the example is less than academic.
2113 See \url{https://tex.stackexchange.com/a/670088} for an application to add a
2114 reference suffix needed in Turkish.} Getting references as ordinal numbers,
2115 something that would be normally a tricky task, can be handled with a simple
2116 custom \pkg{zref} property, which we then use to set \pkg{zref-clever}'s
2117 \opt{ref} option.
2118
2119 \begin{zchowto}[caption={Ordinal references}]
2120 \documentclass{article}
2121 \usepackage{zref-clever}
2122 \usepackage{fmtcount}
2123 \makeatletter
2124 \zref@newprop{ordref}{\ordinal{\@currentcounter}}
2125 \zref@addprop{main}{ordref}
2126 \makeatother
2127 \zcsetup{ref=ordref}
2128 \begin{document}
2129 \section{Section 1}
2130 \label{sec:section-1}
2131 \begin{figure}
2132 A figure.
2133 \caption{Figure 1}
2134 \label{fig:figure-1}
2135 \end{figure}
2136 \zcref{sec:section-1,fig:figure-1}
2137 \end{document}
2138 \end{zchowto}
2139
2140
2141 \section{\cs{label} or \cs{zlabel}?}
2142 \label{sec:label-or-zlabel}
2143
2144 TL;DR: Just use \cs{label}, unless you have special requirements.
2145
2146 \medskip{}
2147
2148 Technically, \pkg{zref}'s referencing system, and thus also \pkg{zref-clever},
2149 require a label set with \cs{zlabel} to make a reference. However, the
2150 \opt{labelhook} option (see \zcref{sec:options}) leverages the kernel's
2151 \texttt{label} hook to also set a \cs{zlabel} when a standard \cs{label} is
2152 called, so that we can simply use \cs{label}s in our document and refer to
2153 them with either referencing system. Indeed, in some places the use of
2154 \cs{label} this way may be required. That given, which is to be preferred:
2155 use \cs{label} all around or normally use \cs{zlabel} and, occasionally resort
2156 to \cs{label} where required? I guess it depends, but we can reason the pros
2157 and cons of both alternatives.
2158
2159 Simply using \cs{label} across your document clearly speaks for convenience.
2160 You don't have to worry with the exceptional case where a \cs{zlabel} may not
2161 work or setting it is not possible. You can use either referencing system for
2162 your labels as desired. Your favorite editor may have some facilities to ease
2163 the insertion of labels, but does not support \cs{zlabel}. And so on. The
2164 only disadvantage I can see with this approach is that two labels end up in
2165 the \file{.aux} file which, arguably, may be seen as a redundancy, or waste.
2166
2167 It is probably fair to consider this redundancy, in most use cases, as a
2168 negligible cost. But you may disagree, or the size of your document or your
2169 requirements may say otherwise, in which case you may prefer the second
2170 approach and use \cs{zlabel} normally, with some occasional \cs{label} where
2171 required. Outright disabling the \opt{labelhook} option leaves you uncovered
2172 in such cases, but you can always locally (re-)enable it as needed. As far as
2173 my experience goes, the restrictions should not be that many, and some trial
2174 and error can easily tell what the situation is. See
2175 \zcref{sec:limitations,sec:comp-modules} for some discussion and known cases.
2176
2177 All in all, as far as \pkg{zref-clever} is concerned, the use of \cs{label}
2178 throughout (with the \opt{labelhook} option) is the recommended approach.
2179 Consider the use of \cs{zlabel} directly if you have some special requirements
2180 at stake and are willing to handle a few rough edges.
2181
2182
2183 \section{Limitations}
2184 \label{sec:limitations}
2185
2186 Being based on \pkg{zref} entails one significant advantage for
2187 \pkg{zref-clever}: the extensible referencing system of the former allows
2188 \pkg{zref-clever} to store and retrieve the information it needs to work
2189 without having to redefine some core \LaTeX{} commands. Which leads to less
2190 compatibility problems and load order issues than some traditional
2191 cross-reference related packages. On the other hand, being based on
2192 \pkg{zref} also has some potential implications to the supported scope of
2193 \pkg{zref-clever}. Not because of any particular limitation of either, but
2194 because any class or package which implements some special handling for
2195 reference labels universally does so aiming at the standard referencing
2196 system, and whether specific support for \pkg{zref} is included, or whether
2197 things work by spillover of the particular technique employed, is not
2198 guaranteed.
2199
2200 The limitation here is less one of \pkg{zref-clever} than that of a potencial
2201 lack of support for \pkg{zref} itself. Broadly speaking, what
2202 \pkg{zref-clever} does is setup \pkg{zref} so that its \cs{zref@newlabel}s
2203 contains the information we need using \pkg{zref}'s API. Once the \cs{zlabel}
2204 is set correctly, there is little in the way of \pkg{zref-clever}, it can just
2205 extract the label's information, again using \pkg{zref}'s API, and do its job.
2206 Therefore, the problems that may arise are really in \emph{label setting}.
2207
2208 For \cs{zlabel} to be able to set a label with everything \pkg{zref-clever}
2209 needs, some conditions must be fulfilled, most of which are pretty much the
2210 same as that of a regular label, but not only. As far as my experience goes,
2211 the following label setting requirements can be potentially problematic and
2212 are not necessarily granted for \cs{zlabel}:
2213
2214 \begin{enumerate}
2215 \item One must be able to call \cs{zlabel}, directly or indirectly, at the
2216 appropriate scope/location so as to set the label.
2217 \item When \cs{zlabel} is set, it must see a correct value of
2218 \cs{@currentcounter}.
2219 \end{enumerate}
2220
2221 As to the first, it is not everywhere we technically can set a (z)label. On
2222 verbatim-like environments it depends on how they are defined and whether they
2223 provide a proper place or option to do so. But other places may be
2224 problematic too, for example, \pkg{amsmath} display math environments also
2225 handle \cs{label} specially and the same work is not done for \cs{zlabel}.
2226 Classes and packages may offer label setting by means of arguments or options,
2227 and those usually only cater for the standard referencing system, etc.
2228 Fortunately for us, the \texttt{label} hook introduced by the \LaTeX{} kernel
2229 in the 2023-06-01 release improves the situation considerably.
2230 \pkg{zref-clever} makes use of it with the \opt{labelhook} option, enabled by
2231 default, so that a standard \cs{label} also sets a \cs{zlabel} with the same
2232 name, thus providing a very general and reliable way to deal with this issue.
2233
2234 Regarding the second, a correctly set \cs{@currentcounter} is critical for the
2235 task of \pkg{zref-clever}: the reference type will depend on that and,
2236 consequently, sorting and compression as well, counter resetting behavior
2237 information is also retrieved based on it, and so on. Since the 2020-10-01
2238 \LaTeX{} release, \cs{@currentcounter} is set by \cs{refstepcounter} alongside
2239 \cs{@currentlabel} and, since the 2021-11-15 release, the support for
2240 \cs{@currentcounter} has been further extended in the kernel. Hence, as long
2241 as kernel features are involved, or as long as \cs{refstepcounter} is the tool
2242 used for the purpose of reference setting, the label will tend to have all
2243 information within its grasp at the time it is set. But that's not
2244 necessarily always the case. For this reason, \pkg{zref-clever} has the
2245 option \opt{currentcounter} which at least allows for some viable work-arounds
2246 when the value of \cs{@currentcounter} cannot be relied upon. Whether we have
2247 a proper opening to set it, depends on the case. Still, \cs{refstepcounter}
2248 is ubiquitous enough a tool that we can count on \cs{@currentcounter} most of
2249 the time.
2250
2251 All in all, specially since the kernel's \texttt{label} hook has been made
2252 available, we can expect to find very little trouble in setting proper labels
2253 for \pkg{zref-clever}. Which is not to say ``none'', of course.
2254
2255
2256 \section{Compatibility modules}
2257 \label{sec:comp-modules}
2258
2259 This section gives a description of each compatibility module provided by
2260 \pkg{zref-clever}. These modules intend to smooth the interaction of \LaTeX{}
2261 features, document classes, and packages with \pkg{zref-clever} and
2262 \pkg{zref}, and they can be selectively or completely disabled with the option
2263 \opt{nocompat} (see \zcref{sec:options}). This set is not to be confused with
2264 ``the list of packages or classes supported by \pkg{zref-clever}''. In most
2265 circumstances, things should just work out of the box, and need no specific
2266 handling. These are just the ones for which some special treatment was
2267 required.
2268
2269 Note that settings performed by the compatibility modules require special care
2270 if they are to be changed by users. Since the modules depend on what has been
2271 loaded or not in the document, the settings are done at
2272 \texttt{begindocument}. Hence, to override a setting performed by a
2273 compatibility module, the user must ensure their change comes after that,
2274 e.g.\ by adding their setting to the \texttt{begindocument} hook.
2275
2276 The purpose of outlining to some extend what the compatibility modules do is
2277 twofold. First, some of them may require usage adjustments, or awareness,
2278 which must be somehow conveyed in this documentation. Second, the kind and
2279 degree of intervention in external code varies for each module, and since this
2280 is an area of potential friction, a minimum of information for the users to
2281 judge whether they want to leave these modules enabled or not is due. For
2282 this reason, this is also a little technical, but for more details, see the
2283 code documentation.
2284
2285 \bigskip{}
2286
2287 \DescribeOption{appendix} %
2288 The \cs{appendix} command provided by many document classes is normally used
2289 to change the behavior of the sectioning commands after that point. Usually,
2290 depending on the class, the changes that interest us involve using \cs{@Alph}
2291 for numbering and \cs{appendixname} for chapter's names. In sum, we'd like to
2292 refer to the appendix sectioning commands as ``appendices'' rather than
2293 ``chapters'' or ``sections''. Since the sectioning commands are the same as
2294 before \cs{appendix}, and so are their underlying counters, we must configure
2295 the counter type of the sectioning counters to \texttt{appendix}. Also, the
2296 sorting of appendix labels relative to those in the rest of the document
2297 requires attention, which is done by setting the main sectioning level counter
2298 as being reset by an internal counter with the \opt{counterresetby} option.
2299 And this is what this compatibility module does, using a \pkg{ltcmdhooks} hook
2300 on \cs{appendix} for the purpose. Hence, this module applies to any document
2301 class or package which provides that command.
2302
2303 \DescribeOption{appendices} %
2304 This module implements support for the \env{appendices} and
2305 \env{subappendices} environments provided by the \pkg{appendix} package, and
2306 also by \cls{memoir}. The task is the same as for the \texttt{appendix}
2307 module: set proper counter types for the sectioning counters and ensuring
2308 proper sorting of labels. This module employs environment hooks to
2309 \env{appendices} and \env{subappendices}.
2310
2311 \DescribeOption{memoir} %
2312 This compatibility module provides support for some of \cls{memoir}'s
2313 cross-referencing features. Namely, it: i) sets counter types for counters
2314 \texttt{subfigure}, \texttt{subtable}, \texttt{poemline} (used in the
2315 \env{verse} environment), \texttt{sidefootnote}, and \texttt{pagenote}; ii)
2316 configures resetting behavior (\opt{counterresetby} option) for
2317 \texttt{subfigure} and \texttt{subtable} counters; iii) provides the
2318 \pkg{zref} property ``\texttt{subcaption}'' so that we can use
2319 \texttt{ref=subcaption} to emulate the functionality of \cls{memoir}'s
2320 \cs{subcaptionref}.
2321
2322 \DescribeOption{amsmath} %
2323 \pkg{amsmath}'s display math environments have their contents processed twice,
2324 once for measuring and the second does the final typesetting. Hence,
2325 \pkg{amsmath} needs to handle \cs{label} specially inside these environments,
2326 otherwise we'd have duplicate labels all around, and indeed it does redefine
2327 \cs{label} locally inside them. Alas, the same treatment is not granted to
2328 \cs{zlabel}. Therefore, you must use \cs{label} (not \cs{zlabel}) inside
2329 \pkg{amsmath}'s display math environments, but unless you disabled the
2330 \opt{labelhook} option you need not worry about that, and can just go with
2331 \cs{label} as usual. The following environments are subject to this usage
2332 restriction: \env{equation}, \env{align}, \env{alignat}, \env{flalign},
2333 \env{xalignat}, \env{gather}, \env{multline}, and their respective starred
2334 versions. Besides that, the module ensures proper \opt{currentcounter} values
2335 are in place for the display math environments, for which it uses environment
2336 hooks. The module also provides a \texttt{subeq} property, for display math
2337 environments used inside the \env{subequations} environment, which can be used
2338 to refer to them directly with the \opt{ref} option, or to build terse ranges
2339 with the \opt{endrange} option.
2340
2341 \DescribeOption{mathtools} %
2342 \pkg{mathtools} has a feature to show the numbers only for those equations
2343 actually referenced (with \cs{eqref} or \cs{refeq}), which is enabled by the
2344 \opt{showonlyrefs} option. This compatibility module adds support for this
2345 feature, such that equation references made with \cs{zcref} also get marked as
2346 ``referenced'' for \pkg{mathtools}, when the option is active, of course. The
2347 module uses \pkg{mathtools}' \cs{noeqref} for the purpose, but does not need
2348 to redefine or hook into anything, everything is handled on
2349 \pkg{zref-clever}'s side.
2350
2351 \DescribeOption{breqn} %
2352 This compatibility module only sets proper \opt{currentcounter} values for the
2353 environments \env{dgroup}, \env{dmath}, \env{dseries}, and \env{darray}, and
2354 uses environment hooks for the purpose. Note that, in part, this is needed
2355 because \pkg{breqn} does not use \cs{refstepcounter} to increment the equation
2356 counters and, as a result, fails to set \cs{@currentcounter}. But, for the
2357 same reason, it also fails to set \pkg{hyperref} anchors for the equations
2358 (thus affecting the standard labels too). So, you may wish to use the
2359 work-around provided by Heiko Oberdiek at
2360 \url{https://tex.stackexchange.com/a/241150} (or equivalent).
2361
2362 \DescribeOption{listings} %
2363 Being \env{lstlisting} a verbatim environment, setting labels inside it
2364 requires special treatment. \pkg{zref-clever}'s \opt{labelhook} option
2365 provides that a label given to the \opt{label} works out of the box, so unless
2366 you disabled the \opt{labelhook} option you need not worry about it. Setting
2367 labels for specific lines of the environment can also be done, subject to
2368 escaping as due. The module sets appropriate \opt{countertype},
2369 \opt{counterresetby} and \opt{currentcounter} values for the \pkg{listings}'
2370 counters: \texttt{lstlisting} and \texttt{lstnumber}.
2371
2372 \DescribeOption{enumitem} %
2373 \LaTeX{}'s \env{enumerate} environment requires some special treatment from
2374 \pkg{zref-clever}, since its resetting behavior is not stored in the standard
2375 way, and the counters' names, given they are numbered by level, do not map to
2376 the reference type naturally. This is done by default for the up to four
2377 levels of nested \env{enumerate} environments the kernel offers.
2378 \pkg{enumitem}, though, allows one to increase this maximum list depth for
2379 \env{enumerate} and, if this is done, setup for these deeper nesting levels
2380 have also to be taken care of, and that's what this compatibility module does.
2381 All settings here are internal to \pkg{zref-clever}, no hooks or redefinitions
2382 are needed, we just check the existing pertinent counters at
2383 \texttt{begindocument}, and supply settings for them. Of course, this means
2384 that only \pkg{enumitem}'s settings done in the preamble will be visible to
2385 the module and provided for.
2386
2387 \DescribeOption{subcaption} %
2388 This compatibility module sets appropriate \opt{countertype} and
2389 \opt{counterresetby} for the \texttt{subfigure} and \texttt{subtable}
2390 counters, and provides the \pkg{zref} property ``\texttt{subref}'' so that we
2391 can refer to, for example, \texttt{\cs{zcref}[ref=subref]\{\meta{label}\}} to
2392 emulate the functionality of \cls{subcaption}'s \cs{subref}. The later
2393 feature uses the \cs{caption@subtypehook} provided by \pkg{caption} to locally
2394 add the \texttt{subref} property to \pkg{zref}'s main property list.
2395
2396 \DescribeOption{subfig} %
2397 This module just sets appropriate \opt{countertype} and \opt{counterresetby}
2398 for the \texttt{subfigure} and \texttt{subtable} counters.
2399
2400 \DescribeOption{beamer} %
2401 This compatibility module sets proper values of \cs{@currentHref}, so that the
2402 \cs{label}s are stored with anchors which correspond to the ones \cls{beamer}
2403 actually creates, using the \texttt{label} hook for the purpose, meaning this
2404 strictly requires the use of \cs{label} with the \opt{labelhook} option. It
2405 also sets appropriate \cs{@currentcounter} for frames, using a generic
2406 \texttt{cmd} hook on \cls{beamer}'s \cs{refcounter} macro.
2407
2408
2409 % \section{Work-arounds}
2410 %
2411 % \marginpar{\raggedleft\raisebox{-1.5ex}{\dbend}}The compatibility modules
2412 % presented in \zcref{sec:comp-modules} should go a long way in ensuring the
2413 % user has little to worry about in setting up \pkg{zref-clever} for some more
2414 % traditional document classes and packages, but they cannot be expected to go
2415 % all the way. Not only because this kind of support will never be exhaustive,
2416 % but also since, sometimes, given the way certain features are implemented,
2417 % there may not be a reasonable way to provide this support, from our side.
2418 % But, still, most of the time, it is still ``viable'' to get there, if one
2419 % really wishes to do so. So, this section keeps track of some known recipes,
2420 % which I don't think belong in \pkg{zref-clever} itself, but which you may
2421 % choose to use. Note that this list is intended to spare users from having to
2422 % reinvent the wheel every time someone needs something of the sort, but from
2423 % \pkg{zref-clever}'s perspective, their status is ``not supported''.
2424
2425
2426 \section{Acknowledgments}
2427
2428 \pkg{zref-clever} would not be possible without other people's previous work
2429 and help.
2430
2431 Heiko Oberdiek's \pkg{zref}, now maintained by the Oberdiek Package Support
2432 Group, is the underlying infrastructure of this package. The potential of its
2433 basic concept and the solid implementation were certainly among the reasons
2434 I've chosen to venture into these waters, to start with. And I believe they
2435 will remain one of the main assets of \pkg{zref-clever} as it matures.
2436
2437 The name of the package makes no secret that a major inspiration for the kind
2438 of ``feel'' I strove to achieve has been Toby Cubitt's \pkg{cleveref}.
2439 Indeed, I have been a user of \pkg{cleveref} for several years, and a happy
2440 one at that. But the role \pkg{cleveref} played in the development of
2441 \pkg{zref-clever} extends beyond the visible influence in the design of user
2442 facing functionality. Some technical solutions and, specially, the handling
2443 of support for other packages were a valuable reference. Hence, the
2444 accumulated experience of \pkg{cleveref} allowed for \pkg{zref-clever} to
2445 start on a more solid foundation than would otherwise be the case.
2446
2447 The long term efforts of the \LaTeX{} Project Team around \pkg{expl3} and
2448 \pkg{xparse} have also left their marks in this package. By implementing
2449 powerful tools and smoothing several regular programming tasks, they have
2450 certainly reduced my entry barrier to \LaTeX{} programming and enabled me to
2451 develop this package with a significantly reduced effort. And, given the
2452 constraints of my abilities, the result is no doubt much better than it would
2453 be in their absence.
2454
2455 Besides these more general acknowledgments, a number of people have
2456 contributed to \pkg{zref-clever}, whether they are aware of it or not.
2457 Suggestions, ideas, solutions to problems, bug reports or even encouragement
2458 were generously provided by (in chronological order):
2459 Ulrike Fischer,
2460 % 2021-07-03: It's Ulrike's fault :-) : https://tex.stackexchange.com/questions/603514/#comment1513982_603514
2461 % 2021-08-20: https://tex.stackexchange.com/q/611424/105447 (comments)
2462 % 2021-09-06: https://github.com/ho-tex/zref/issues/13
2463 % 2021-10-26: https://github.com/latex3/latex2e/issues/687
2464 % 2022-01-12: https://chat.stackexchange.com/transcript/message/60129233#60129233
2465 % 2022-04-09: https://github.com/latex3/hyperref/issues/229#issuecomment-1093870142
2466 % 2023-01-02: https://tex.stackexchange.com/q/670399 (comments)
2467 % 2023-06-01: https://github.com/latex3/latex2e/pull/956
2468 % 2023-07-27: https://chat.stackexchange.com/transcript/message/64067726#64067726
2469 % 2024-11-14: https://tex.stackexchange.com/a/730792
2470 % 2024-11-14: https://github.com/josephwright/beamer/issues/917
2471 Phelype Oleinik,
2472 % 2021-08-20: https://tex.stackexchange.com/q/611370 (comments)
2473 % 2021-09-09: https://tex.stackexchange.com/a/614704
2474 % 2021-10-06: https://tex.stackexchange.com/a/617998
2475 % 2021-10-21: https://github.com/latex3/latex2e/pull/699
2476 % 2022-01-12: https://tex.stackexchange.com/questions/629946/#comment1571118_629946
2477 % 2022-01-11: https://tex.stackexchange.com/questions/633341/#comment1579825_633347
2478 % 2023-06-01: https://github.com/latex3/latex2e/pull/1020
2479 Enrico Gregorio,
2480 % 2021-08-20: https://tex.stackexchange.com/a/611385
2481 % 2021-08-20: https://tex.stackexchange.com/q/611370/#comment1529282_611385
2482 Steven B.\ Segletes,
2483 % 2021-08-20: https://tex.stackexchange.com/a/611373
2484 Jonathan P.\ Spratte,
2485 % 2021-09-09: https://tex.stackexchange.com/a/614719
2486 % 2021-09-09: https://github.com/latex3/latex3/pull/988
2487 David Carlisle,
2488 % 2021-10-10: https://tex.stackexchange.com/questions/618434/#comment1544401_618439
2489 % 2022-01-12: https://chat.stackexchange.com/transcript/message/60129096#60129096
2490 % and following discussion.
2491 % 2022-12-26: https://chat.stackexchange.com/transcript/message/62644791#62644791
2492 % and following discussion.
2493 % 2023-01-02: https://chat.stackexchange.com/transcript/message/62684358#62684358
2494 % and following discussion.
2495 % 2023-02-10: https://tex.stackexchange.com/a/674846
2496 % 2023-07-27: https://chat.stackexchange.com/transcript/message/64067575#64067575
2497 Frank Mittelbach,
2498 % 2021-10-14: https://github.com/latex3/latex2e/issues/687
2499 \username{samcarter},
2500 % 2021-10-14: https://chat.stackexchange.com/transcript/message/59361777#59361777
2501 % 2021-10-21: https://chat.stackexchange.com/transcript/message/59418309#59418309
2502 % 2024-11-14: https://github.com/josephwright/beamer/issues/917
2503 Alan Munn,
2504 % 2021-10-14: https://chat.stackexchange.com/transcript/message/59364073#59364073
2505 % 2021-10-21: https://chat.stackexchange.com/transcript/message/59418189#59418189
2506 Florent Rougon,
2507 % https://github.com/frougon/xcref has been an useful reference for
2508 % declension support.
2509 Denis Bitouzé,
2510 % 2021-11-25: https://github.com/gusbrs/zref-clever/issues/1
2511 Marcel Krüger,
2512 % 2021-11-26: https://github.com/latex3/l3build/issues/215
2513 Jürgen Spitzmüller,
2514 % 2021-11-28: https://github.com/gusbrs/zref-clever/issues/2
2515 \username{niluxv},
2516 % 2022-01-05: https://github.com/gusbrs/zref-clever/issues/4
2517 Joseph Wright,
2518 % 2023-01-02: https://chat.stackexchange.com/transcript/message/62684358#62684358
2519 % and following discussion.
2520 Thomas F. Sturm,
2521 % 2023-02-09: https://github.com/T-F-S/tcolorbox/issues/206
2522 % 2023-05-12: https://github.com/T-F-S/tcolorbox/issues/230
2523 Yukai Chou, % 'muzimuzhi'
2524 % 2023-02-18: https://github.com/gusbrs/zref-clever/pull/14
2525 % 2023-02-18: https://github.com/gusbrs/zref-clever/pull/15
2526 % 2023-05-11: https://github.com/T-F-S/tcolorbox/issues/230
2527 % 2023-11-09: https://github.com/gusbrs/zref-clever/issues/20
2528 % 2024-01-20: https://github.com/gusbrs/zref-clever/pull/25
2529 % 2024-05-04: https://github.com/gusbrs/zref-clever/pull/27
2530 % 2024-07-19: https://github.com/gusbrs/zref-clever/pull/32
2531 and Lars Madsen.
2532 % 2023-07-24: https://chat.stackexchange.com/transcript/message/64039717#64039717
2533 % and following discussion.
2534 % 2023-07-26: https://chat.stackexchange.com/transcript/message/64057725#64057725
2535 % 2023-07-31: https://chat.stackexchange.com/transcript/message/64105457#64105457
2536 % and following discussion.
2537 % 2023-08-08: Improved 'zref' and 'zref-clever' support for 'memoir' with
2538 % v3.8. Email exchange "Subject: [FR] Improve support for zref
2539 % in memoir", starting with
2540 % rfc822msgid:CAM9ALR84v=nUTO14moPhbuDjQx9EJ1pcWAku5FdwOo9hbadwYA@mail.gmail.com.
2541
2542 The package's language files have been provided or improved thanks to:
2543 Denis Bitouzé (French),
2544 % 2021-11-25: https://github.com/gusbrs/zref-clever/issues/1
2545 François Lagarde (French), % 'flagarde'
2546 % 2021-12-09: discussion at https://github.com/gusbrs/zref-clever/issues/1
2547 \username{niluxv} (Dutch),
2548 % 2022-01-09: https://github.com/gusbrs/zref-clever/pull/5
2549 % 2022-12-27: https://github.com/gusbrs/zref-clever/pull/12
2550 % 2022-12-27: https://github.com/gusbrs/zref-clever/pull/13
2551 Matteo Ferrigato (Italian), % 'matteo339'
2552 % 2022-12-12: https://github.com/gusbrs/zref-clever/issues/11
2553 Sergey Slyusarev (Russian), % 'jemmybutton'
2554 % 2024-05-18: https://github.com/gusbrs/zref-clever/issues/28
2555 % 2024-05-19: https://github.com/gusbrs/zref-clever/pull/29
2556 % 2024-05-20: https://github.com/gusbrs/zref-clever/pull/30
2557 and \username{Timmyfox} (Swedish).
2558 % 2024-11-22: https://github.com/gusbrs/zref-clever/issues/35
2559
2560 If I have inadvertently left anyone off the list I apologize, and please let
2561 me know, so that I can correct the oversight.
2562
2563 Thank you all very much!
2564
2565
2566 \section{Change history}
2567
2568 A change log with relevant changes for each version, eventual upgrade
2569 instructions, and upcoming changes, is maintained in the package's repository,
2570 at \url{https://github.com/gusbrs/zref-clever/blob/main/CHANGELOG.md}. The
2571 change log is also distributed with the package's documentation through CTAN
2572 upon release so, most likely, \texttt{texdoc zref-clever/changelog} should
2573 provide easy local access to it. An archive of historical versions of the
2574 package is also kept at \url{https://github.com/gusbrs/zref-clever/releases}.
2575
2576 \end{document}
2577
2578 % Local Variables:
2579 % TeX-engine: luatex
2580 % End: