-
Notifications
You must be signed in to change notification settings - Fork 6
/
zref-clever-doc.tex
2583 lines (2303 loc) · 123 KB
/
zref-clever-doc.tex
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
% \iffalse meta-comment
%
% File: zref-clever.tex
%
% This file is part of the LaTeX package "zref-clever".
%
% Copyright (C) 2021-2023 gusbrs
%
% It may be distributed and/or modified under the conditions of the
% LaTeX Project Public License (LPPL), either version 1.3c of this
% license or (at your option) any later version. The latest version
% of this license is in the file:
%
% https://www.latex-project.org/lppl.txt
%
% and version 1.3 or later is part of all distributions of LaTeX
% version 2005/12/01 or later.
%
%
% This work is "maintained" (as per LPPL maintenance status) by gusbrs.
%
% This work consists of the files zref-clever.dtx,
% zref-clever.ins,
% zref-clever-doc.tex,
% zref-clever-code.tex,
% and the files generated from them.
%
% The released version of this package is available from CTAN.
%
% -----------------------------------------------------------------------
%
% The development version of the package can be found at
%
% https://github.com/gusbrs/zref-clever
%
% for those people who are interested.
%
% -----------------------------------------------------------------------
%
% \fi
\documentclass{l3doc}
\usepackage{fontspec}
\setmainfont{TeX Gyre Pagella}
\setsansfont{TeX Gyre Heros}[Scale=MatchLowercase]
\setmonofont{inconsolata}[Scale=MatchLowercase]
% The package itself *must* be loaded so that \GetFileInfo can pick up date
% and version data. Naturally, we also use it.
\usepackage{zref-clever}
\zcsetup{cap}
\usepackage{zref-check}
\usepackage{zref-titleref}
\usepackage{listings}
\usepackage{microtype}
\hypersetup{hidelinks}
\NewDocumentCommand\opt{m}{\texttt{#1}}
\NewDocumentCommand\contributor{m}{#1}
\NewDocumentCommand\username{m}{`\texttt{#1}'}
\makeatletter
\newcommand{\zcrequiredkernel}{\zrefclever@required@kernel}
\makeatother
\setlength{\marginparsep}{2\labelsep}
\definecolor{reffmtbox}{gray}{0.15}
\definecolor{reffmtback}{gray}{0.85}
\NewDocumentCommand\reffmt{m}{%
\fcolorbox{reffmtbox}{reffmtback}{%
\rule[-0.2\baselineskip]{0pt}{0.8\baselineskip}\texttt{#1}}}
\newlist{refformat}{itemize}{1}
\setlist[refformat]{label={}, beginpenalty=500, midpenalty=500}
\NewDocumentCommand\zctask{m}{%
\begin{description}
\item[Task] #1
\end{description}}
\lstdefinestyle{code}{
language=[LaTeX]TeX,
moretexcs={
AddToHook,
AddToHookWithArguments,
DeclareHookRule,
define@key,
patchcmd,
eq@setnumber,
DeclareFloatingEnvironment,
newlist,
setlist,
zexternaldocument,
next@label,
next@label@pre,
@empty,
tag,
text,
lstset,
condition,
RenewDocumentCommand,
NewCommandCopy,
ltx@gobble,
@currentcounter,
@currentHref,
zref@label,
zref@wrapper@babel,
zref@ifpropundefined,
zref@setcurrent,
zref@newprop,
zref@addprop,
beamer@old@zref@label,
alt,
beamer@nameslide,
beamer@dummynameslide,
uncover,
only,
ordinal,
tcbuselibrary,
tcbset,
newtcolorbox,
newtcbtheorem,
}
}
\lstdefinestyle{zrefclever}{
style=code,
moretexcs={
zcref,
zcpageref,
zlabel,
zcsetup,
zcLanguageSetup,
zcRefTypeSetup,
zcheck,
zvref,
zvpageref,
zvrefrange,
zvpagerefrange,
zfullref,
}
}
\lstset{
style=zrefclever,
basicstyle=\ttfamily\small,
columns=fullflexible,
keepspaces,
xleftmargin=\leftmargin,
xrightmargin=.5\leftmargin,
}
% Setup inspired by https://tex.stackexchange.com/a/4068. For how to use these
% environments in a .dtx context see https://tex.stackexchange.com/a/31026.
\newcounter{zchowto}
\lstnewenvironment{zchowto}[1][]{%
\renewcommand{\lstlistingname}{How-to}%
\renewcommand*\theHlstlisting{ht.\thelstlisting}%
\zcsetup{countertype={lstlisting=zchowto}}%
\lstset{#1}%
\stepcounter{zchowto}%
\setcounter{lstlisting}{\value{zchowto}-1}%
}{}
\newcounter{zcworkaround}
\lstnewenvironment{zcworkaround}[1][]{%
\renewcommand{\lstlistingname}{Work-around}%
\renewcommand*\theHlstlisting{wa.\thelstlisting}%
\zcsetup{countertype={lstlisting=zcworkaround}}%
\lstset{#1}%
\stepcounter{zcworkaround}%
\setcounter{lstlisting}{\value{zcworkaround}-1}%
}{}
\lstnewenvironment{zcexample}[1][]{%
\renewcommand{\lstlistingname}{Example}%
\lstset{#1}%
}{}
\zcRefTypeSetup{zchowto}{
Name-sg = {How-to},
name-sg = {how-to},
Name-pl = {How-tos},
name-pl = {how-tos},
}
\zcRefTypeSetup{zcworkaround}{
Name-sg = {Work-around},
name-sg = {work-around},
Name-pl = {Work-arounds},
name-pl = {work-arounds},
}
\begin{document}
\GetFileInfo{zref-clever.sty}
\title{%
The \pkg{zref-clever} package%
\texorpdfstring{\\{}\medskip{}}{ - }%
User manual%
\texorpdfstring{\medskip{}}{}%
}
\author{%
\texorpdfstring{\texttt{gusbrs}\\[0.8em]
\url{https://github.com/gusbrs/zref-clever}\\
\url{https://www.ctan.org/pkg/zref-clever}}{gusbrs}}
\date{Version \fileversion\ -- \filedate}
\maketitle
\begin{center}
{\bfseries \abstractname\vspace{-.5em}\vspace{0pt}}
\end{center}
\begin{quotation}
\pkg{zref-clever} provides a user interface for making \LaTeX{}
cross-references which automates some of their typical features, thus easing
their input in the document and improving the consistency of typeset
results. A reference made with \cs{zcref} includes a ``name'' according to
its ``type'' and lists of multiple labels can be automatically sorted and
compressed into ranges when due. The reference format is highly and easily
customizable, both globally and locally. \pkg{zref-clever} is based on
\pkg{zref}'s extensible referencing system.
\end{quotation}
\bigskip{}
\begin{center}
\textbf{EXPERIMENTAL}
Please read \zcref{sec:warning} carefully.
\end{center}
\clearpage{}
\tableofcontents
\clearpage{}
\section{Introduction}
Cross-referencing is an area which lends itself quite naturally to automation.
Not only for input convenience but also, and most importantly, for end results
consistency. Indeed, the standard \LaTeX{} cross-referencing system -- with
\cs{label}, \cs{ref}, and \cs{pageref} -- is already a form of automation, by
relieving us from checking the number of the referenced object, and the page
where it lies.
But the plethora of existing features, packages and document classes which, in
one way or another, extends this basic functionality is a clear indication of
a demand for more automation. Just to name the some of the most popular:
\pkg{cleveref}, \pkg{nameref}, \pkg{titleref}, \pkg{varioref}, \pkg{fancyref},
and the kernel's \cs{labelformat}.
However, the standard cross-referencing system traditionally stored two, and
only two, properties with the label: the printed representation of the counter
last incremented with \cs{refstepcounter} and the page. Of course, out of the
mentioned desire to automate more, the need arose to store more information
about the label to support this: the title or caption of the referenced
object; its counter or, even better, its ``type'', that is, whether it is a
section, chapter, figure, etc.; its hyperlink anchor, and so on. Thus those
two property ``fields'' of the standard label became quite a disputed real
state. And the packages in this area of functionality, or which somehow
depended on extending the cross-referencing mechanism, were bound to step on
each other's toes as a result. Nowadays (2024), many of these issues have
changed for the better. Notably, now the kernel's \cs{label} already stores
five arguments, regardless of the presence of \pkg{hyperref}, and also
provides a hook with the label as argument so that packages can extend its
functionality without the need to redefine it, as \pkg{nameref} now already
does (and so does \pkg{zref-clever}).\footnote{We are currently observing some
of the pains of adjusting the ecosystem to these improvements though\dots{}}
Out of this conundrum, Heiko Oberdiek eventually developed \pkg{zref}, which
implements an extensible referencing system, making the labels store a
property list of flexible length, so that new properties can be easily added
and queried. However, even when \pkg{zref} can rightfully boast this powerful
basic concept and is really quite featureful, with several different modules
available, it is fair to say that, for the average user, the package may
appear to be somewhat raw. Indeed, for someone who ``just wants to make a
cross-reference'', the user interface of the \pkg{zref-user} module is akin to
the standard \LaTeX{} cross-referencing system, and even requires some extra
work if you want to have a hyperlinked reference. In other words, \pkg{zref}
seems to have focused on infrastructure and on performing a number of
specialized tasks with different modules, and a large part of the landscape of
automation features available for the standard referencing system was not
carried over to \pkg{zref}, neither by the \pkg{zref} itself nor by other
packages.
\pkg{zref-clever} tries to cover this gap, by bringing a number of existing
features available for the standard referencing system to \pkg{zref}. And the
package's name makes it clear that the core of the envisaged feature set is
that of \pkg{cleveref}, even though the attempt was less one of replicating
functionality per se than that of having it as a successful point of
reference, from where we could then try to tap into \pkg{zref}'s potential.
Indeed, although there is a significant intersection, the features of
\pkg{zref-clever} are neither a superset nor a subset of those of
\pkg{cleveref}. There are things either of them can do that the other can't.
There are also important differences in user interface design. In particular,
\pkg{zref-clever} relies heavily on \texttt{key=value} interfaces both for
general configuration and for centering in a single user command, \cs{zcref},
as the main entrance for reference making, whose behavior can be modulated by
local options.
Considering that \pkg{zref} itself offers the \pkg{zref-titleref} module, and
that \pkg{zref-vario} offers integration of \pkg{zref-clever} with
\pkg{varioref}, a significant part of the most prominent automation features
available to the standard referencing system is thus brought to \pkg{zref},
working under a single consistent underlying infrastructure and user
interface. All in all, hopefully \pkg{zref-clever} can make \pkg{zref} more
accessible to the average user, and more interesting to users in general.
\section{Warning}
\label{sec:warning}
This package is in its early days, and should be considered experimental. By
this I don't mean I expect it to be ``edgy'', indeed quite a lot of effort has
been put into it so that this is not the case. However, during the initial
development, I had to make a number of calls for which I felt I had
insufficient information: in relation to features, packages, or classes I
don't use much, or to languages I don't know well, user needs I found hard to
anticipate etc. Hence, the package needs some time, and some use by more
adventurous people, until it can settle down with more conviction. In the
meantime, polishing the user interface and the infrastructure have a clear
priority over backward compatibility. So, if you choose to use this package,
you should be ready to accommodate to eventual upstream changes.
\section{\pkg{zref-clever} for the impatient}
Making cross-references with \pkg{zref-clever} is very similar to the standard
referencing system in its user interface: one sets a label, with \cs{label},
which can then be referenced, in our case with \cs{zcref}, which is the main
and basic entrance for making references with \pkg{zref-clever}. \cs{zcref}
receives a list of labels as argument and its behavior can be locally changed
through the optional argument.
A basic document using \pkg{zref-clever} is shown in \zcref{how:basic} which
should feel very familiar to any \LaTeX{} user acquainted with the standard
referencing system:
\begin{zchowto}[caption={Basic usage},label={how:basic}]
\documentclass{article}
\usepackage{zref-clever}
\usepackage{hyperref}
\begin{document}
\section{Section 1}
\label{sec:section-1}
\begin{figure}
A figure.
\caption{Figure 1}
\label{fig:figure-1}
\end{figure}
A reference to \zcref{sec:section-1}. \zcref[S]{fig:figure-1} shows some
interesting information.
A page reference can be done with either \zcpageref{sec:section-1} or with
\zcref[page]{sec:section-1}.
A reference can also be made to multiple labels, as in \zcref{sec:section-1,
fig:figure-1}.
\end{document}
\end{zchowto}
The references in the document of \zcref{how:basic} illustrate one of the main
features of \pkg{zref-clever}, which is to include an appropriate ``type
name'' of the reference, alongside of the reference itself. The document
renders its references as:
\begin{quote}
A reference to section 1. Figure 1 shows some interesting information. A
page reference can be done with either page 1 or with page 1. A reference
can also be made to multiple labels, as in section 1 and figure 1.
\end{quote}
\zcref[S]{how:basic} also illustrates the use the optional argument of
\cs{zcref} to modulate the behavior of the reference. In particular, the
\opt{S} option is one you should get acquainted with from the start, as it
ensures that the type name of a reference is properly capitalized and not
abbreviated, and it is meant to be used in references made at the beginning of
a sentence.
But \pkg{zref-clever} is highly customizable, and several other options exist,
and multiple places where you can set them:
\begin{itemize}
\item The optional argument of \cs{zcref}: for individual references.
\item \cs{zcsetup}: for settings meant to affect all references.
\item \cs{zcRefTypeSetup}: to customize the behavior of each reference type.
\item \cs{zcLanguageSetup}: for language-specific settings.
\end{itemize}
For the list of available options, and for these different scopes in which
they can be used, see \zcref{sec:user-interface, sec:options,
sec:reference-format, sec:internationalization}. Other usage examples are
available at \zcref{sec:how-tos}.
\section{Loading the package}
\label{sec:loading-package}
\pkg{zref-clever} can be loaded with the usual:
\begin{zcexample}
\usepackage{zref-clever}
\end{zcexample}
The package does not accept load-time options, package options must be set
using \cs{zcsetup} (see \zcref{sec:user-interface}).
\subsection{Dependencies}
\pkg{zref-clever} requires \pkg{zref}, particularly its \pkg{zref-base},
\pkg{zref-user} and \pkg{zref-abspage} modules, and the \LaTeX{} kernel
\zcrequiredkernel{}, or newer. It requires UTF-8 input encoding, which has
been the kernel's default for some time. It also needs \pkg{ifdraft}. Some
packages are leveraged by \pkg{zref-clever} if they are present, but are not
loaded by default or required by it, namely: \pkg{hyperref}, \pkg{zref-check},
and \pkg{zref}'s \pkg{zref-hyperref} and \pkg{zref-xr} modules.
\section{User interface}
\label{sec:user-interface}
\begin{function}{\zcref}
\begin{syntax}
\cs{zcref}\meta{*}\oarg{options}\marg{labels}
\end{syntax}
\end{function}
Typesets references to \meta{labels}, given as a comma separated list. When
\pkg{hyperref} support is enabled, references will be hyperlinked to their
respective anchors, according to options. The starred version of the command
does the same as the plain one, just does not form links. The \meta{options}
are (mostly) the same as those of the package, and can be given to local
effect. The \meta{labels} argument is protected by \pkg{zref}'s
\cs{zref@wrapper@babel}, so that it enjoys the same support for \pkg{babel}'s
active characters as \pkg{zref} itself does.
\begin{function}{\zcpageref}
\begin{syntax}
\cs{zcpageref}\meta{*}\oarg{options}\marg{labels}
\end{syntax}
\end{function}
Typesets page references to \meta{labels}, given as a comma separated list.
It is equivalent to calling \cs{zcref} with the \opt{ref=page} option:
\cs{zcref}\texttt{\meta{*}[}\meta{options}\texttt{,ref=page]}\marg{labels}.
\begin{function}{\zcsetup}
\begin{syntax}
\cs{zcsetup}\marg{options}
\end{syntax}
\end{function}
Sets \pkg{zref-clever}'s general options (see \zcref{sec:options,
sec:reference-format}). The settings performed by \cs{zcsetup} are local,
within the current group. But, of course, it can also be used to global
effects if ungrouped, e.g.\ in the preamble.
\begin{function}{\zcRefTypeSetup}
\begin{syntax}
\cs{zcRefTypeSetup}\marg{type}\marg{options}
\end{syntax}
\end{function}
Sets type-specific reference format options (see
\zcref{sec:reference-format}). Just as for \cs{zcsetup}, the settings
performed by \cs{zcRefTypeSetup} are local, within the current group.
\bigskip{}
Besides these, user facing commands related to \zcref*[ref=title,
noname]{sec:internationalization} are presented in
\zcref{sec:internationalization}. Note still that all user commands are
defined with \cs{NewDocumentCommand}, which translates into the usual handling
of arguments by it and/or processing by \pkg{l3keys}, particularly with regard
to brace-stripping and space-trimming.
Furthermore, \pkg{zref-clever} loads \pkg{zref}'s \pkg{zref-user} module by
default. So you also have its user commands available out of the box,
including \cs{zref} and \cs{zpageref}, but notably:
\section{Options}
\label{sec:options}
\pkg{zref-clever} is highly configurable, offering a lot of flexibility in
typeset results of the references, but it also tries to keep these ``handles''
as convenient and user friendly as possible. To this end, most of what one
can do with \pkg{zref-clever} (pretty much all of it), can be achieved
directly through the standard and familiar ``comma separated list of
\texttt{key=value} options''.
There are two main groups of options in \pkg{zref-clever}: ``general
options'', which affect the overall behavior of the package, or the reference
as a whole; and ``reference format options'', which control the detail of
reference formatting, including type-specific and language-specific settings.
This section covers the first group (for the second one, see
\zcref{sec:reference-format}). General options can be set globally by means
of \cs{zcsetup} in the preamble (see \zcref{sec:user-interface}). They can
also be set locally with \cs{zcsetup} along the document or through the
optional argument of \cs{zcref} (see \zcref{sec:user-interface}). Most
general options can be used in any of these contexts, but that is not
necessarily true for all cases, some restrictions may apply, as described in
each option's documentation.
\bigskip{}
\DescribeOption{ref} %
\DescribeOption{page} %
The \opt{ref} option controls the label property to which \cs{zcref} refers
to. It can receive \pkg{zref} properties, as long as they are declared, but
notably \texttt{default}, \texttt{page}, \texttt{thecounter} and, if
\pkg{zref-titleref} is loaded, \texttt{title}. The initial value is
\texttt{default}, which is our standard reference. \texttt{thecounter} is a
property set by \pkg{zref-clever} and is similar to \pkg{zref}'s
\texttt{default} property, except that it is not affected by the kernel's
\cs{labelformat}.\footnote{Technical note: the \texttt{default} property
stores \cs{@currentlabel}, while the \texttt{thecounter} property stores
\cs{the}\cs{@currentcounter}. The later is exactly what \cs{refstepcounter}
uses to build \cs{@currentlabel}, except for the \cs{labelformat} prefix
and, hence, has the advantage of being unaffected by it. But the former is
\emph{more reliable} since \cs{@currentlabel} is expected to be correct
pretty much anywhere whereas, although \cs{refstepcounter} does set
\cs{@currentcounter}, it is not everywhere that uses \cs{refstepcounter} for
the purpose. In the cases where the references from these two do diverge,
\pkg{zref-clever} will likely misbehave (reference type, sorting and
compression inevitably depend on a correct \opt{currentcounter}), but using
\texttt{default} at least ensures that the reference itself is correct.
That said, if you do set \cs{labelformat} for some reason,
\texttt{thecounter} may be useful.} By default, reference formatting,
sorting, and compression are done according to information inferred from the
\emph{current counter} (see \opt{currentcounter} option below). Special
treatment in these areas is provided for \texttt{page}, but not for any other
properties. The \opt{page} option is a convenience alias for
\texttt{ref=page}.
\DescribeOption{typeset} %
\DescribeOption{noname} %
\DescribeOption{noref} %
When \cs{zcref} typesets a set of references, each group of references of the
same type can be, and by default are, preceded by the type's ``name'', and
this is indeed an important feature of \pkg{zref-clever}. This is optional
however, and the \opt{typeset} option controls this behavior. It can receive
values \texttt{ref}, in which case it typesets only the reference(s),
\texttt{name}, in which case it typesets only the name(s), or \texttt{both},
in which case it typesets, well, both of them. Note that, when value
\texttt{name} is used, the name is still typeset according to the set of
references given to \cs{zcref}. For example, for multiple references, the
plural form is used, capitalization options are honored, etc. Also
hyperlinking behaves just \emph{as if} the references were present and,
depending on the corresponding options, the name may be linked to the first
reference of the type group. The \opt{noname} and \opt{noref} options are
convenience aliases for \texttt{typeset=ref} and \texttt{typeset=name},
respectively.
\DescribeOption{sort} %
\DescribeOption{nosort} %
The \opt{sort} option controls whether the list of \meta{labels} received as
argument by \cs{zcref} should be sorted or not. It is a boolean option, with
initial value \texttt{true}. The \opt{nosort} option is a convenience alias
for \texttt{sort=false}.
\DescribeOption{typesort} %
\DescribeOption{notypesort} %
Sorting references of the same type can be done with well defined logical
criteria. They either have the same counter or their counters share a clear
hierarchical relation (in the resetting behavior), such that a definite
sorting rule can be inferred from the label's data. The same is not true for
sorting of references of different types. Should ``tables'' come before or
after ``figures''? The \pkg{typesort} option allows to specify the sorting
priority of different reference types. It receives as value a comma separated
list of reference types, specifying that their sorting is to be done in the
order of that list. But \opt{typesort} does not need to receive \emph{all}
possible reference types. The special value \texttt{\{\{othertypes\}\}} (yes,
double braced, one for \pkg{l3keys}, so that the second can make the list) can
be placed anywhere along the list, to specify the sort priority of any type
not included explicitly. If \texttt{\{othertypes\}} is not present in the
list, it is presumed to be at the end of it. Any unspecified types (that is,
those falling implicitly or explicitly into the \texttt{\{othertypes\}}
category) get sorted between themselves in the order of their first appearance
in the label list given as argument to \cs{zcref}. I presume the common use
cases will not need to specify \texttt{\{othertypes\}} at all but, for the
sake of example, if you just really dislike equations, you could use
\texttt{typesort=\{\{\{othertypes\}\}, equation\}}. \opt{typesort}'s default
value is \texttt{\{part, chapter, section, paragraph\}}, which places the
sectioning reference types first in the list, in their hierarchical order, and
leaves everything else to the order of appearance of the labels. The
\opt{notypesort} option behaves like \texttt{typesort=\{\{\{othertypes\}\}\}}
would do, that is, it sorts all types in the order of the first appearance in
the labels' list.
\DescribeOption{comp} %
\DescribeOption{nocomp} %
\cs{zcref} can automatically compress a set of references of the same type
into a range, when they occur in immediate sequence. The \opt{comp} controls
whether this compression should take place or not. It is a boolean option,
with initial value \texttt{true}. The \opt{nocomp} option is a convenience
alias for \texttt{comp=false}. Of course, for better compression results the
\opt{sort} is recommended, but the two options are technically independent.
\DescribeOption{endrange} %
The \opt{endrange} option provides additional control over how the end
reference of a range is typeset, so as to achieve terse ranges. The option
can operate in two technically different ways. It may receive one of a number
of predefined values, which can process the end reference of the range,
comparing it with the beginning reference, to achieve a given end
result.\footnote{For the \TeX{}nically inclined: those values that perform
some processing -- namely \texttt{stripprefix}, \texttt{pagecomp}, and
\texttt{pagecomp2} -- fully expand the references before comparing them,
since it makes sense to perform this task as close as possible to the
printed representation of the references. I don't expect this to be a
problem in normal use cases, but it does represent a limitation on what the
references can contain. In case some control over this is needed, check the
\texttt{zref-clever/endrange-setup} hook in the code documentation.} Or, it
can specify a label property to be used directly, without any processing. The
available predefined values are: \texttt{ref}, \texttt{stripprefix},
\texttt{pagecomp}, and \texttt{pagecomp2}. \texttt{ref} corresponds to the
default behavior, and instructs \cs{zcref} to use whatever property was set at
the \opt{ref} option for the end of range reference. \texttt{stripprefix}
strips the common part at the start of each reference from the end one.
\texttt{pagecomp} is the equivalent of \texttt{stripprefix} for page numbers,
it does the same thing, but only if the references are comprised exclusively
of Arabic numerals. \texttt{pagecomp2} is a variant of \texttt{pagecomp} that
leaves at least two digits at the end reference (except for a leading zero).
If values other than the predefined ones are given to \opt{endrange} they are
considered as label properties, as long as they are declared. This property
is used to typeset the end of range reference if the label contains it, and if
both references would be ``compressible'' according to the \opt{comp} option,
otherwise the property specified by the \opt{ref} option is used. This is
useful for things like sub-elements for which we can build a proper
abbreviated sub-reference and populate the label with it (some compatibility
modules already provide a number of such properties, but other ones can be
built with \pkg{zref}, as needed).
\DescribeOption{range} %
\DescribeOption{rangetopair} %
By default (that is, when the \opt{range} option is not given), \cs{zcref}
typesets a complete list of references according to the \meta{labels} it
received as argument, and only compresses some of them into ranges if the
\opt{comp} option is enabled and if references of the same type occur in
immediate sequence. The \opt{range} option makes \cs{zcref} behave
differently. Sorting is implied by this option (the \opt{sort} option is
disregarded) and, for each reference type group in \meta{labels}, \cs{zcref}
builds a range from the first to the last reference in it, even if references
in between do not occur in immediate sequence. It is a boolean option, and
the initial value is \texttt{false}. \cs{zcref} is smart enough to recognize
when the first and last references of a type do happen to be contiguous, in
which case it typesets a ``pair'', instead of a ``range''. But this behavior
can be disabled by setting the \opt{rangetopair} option to \texttt{false}.
\DescribeOption{cap} %
\DescribeOption{nocap} %
\DescribeOption{capfirst} %
The \opt{cap} option controls whether the reference type names should be
capitalized or not. It is a boolean option, and it can also be set for
specific reference types or languages (see \zcref{sec:reference-format}). The
\opt{nocap} option is a convenience alias for \texttt{cap=false}. The
\opt{capfirst} option ensures that the reference type name of the \emph{first}
type block is capitalized, even when \opt{cap} is set to \texttt{false}.
\DescribeOption{abbrev} %
\DescribeOption{noabbrev} %
\DescribeOption{noabbrevfirst} %
The \opt{abbrev} option controls whether to use abbreviated reference type
names when they are available. It is a boolean option, and it can also be set
for specific reference types or languages (see \zcref{sec:reference-format}).
The \opt{noabbrev} option is a convenience alias for \texttt{abbrev=false}.
The \opt{noabbrevfirst} ensures that the reference type name of the
\emph{first} type block is never abbreviated, even when \opt{abbrev} is set to
\texttt{true}.
\DescribeOption{S} %
\opt{S} for ``Sentence''. The \opt{S} option is a convenience alias for
\texttt{noabbrevfirst=true, capfirst=true}, and is intended to be used in
references made at the beginning of a sentence. It is highly recommended that
you make a habit of using the \opt{S} option for beginning of sentence
references. Even if you do happen to be currently using \texttt{cap=true,
abbrev=false}, proper semantic markup will ensure you get expected results
even if you change your mind in that regard later on. For that reason, it was
made short and mnemonic, it can't get any easier.
\DescribeOption{hyperref} %
The \opt{hyperref} option controls the use of \pkg{hyperref} by
\pkg{zref-clever} and takes values \opt{auto}, \opt{true}, \opt{false}. The
initial value, \opt{auto}, makes \pkg{zref-clever} use \pkg{hyperref} if it is
loaded, meaning that references made with \cs{zcref} get hyperlinked to the
anchors of their respective \meta{labels}. \opt{true} does the same thing,
but warns if \pkg{hyperref} is not loaded (\pkg{hyperref} is never loaded for
you). In either of these cases, if \pkg{hyperref} is loaded, module
\pkg{zref-hyperref} is also loaded by \pkg{zref-clever}. \opt{false} means
not to use \pkg{hyperref} regardless of its availability. This is a preamble
only option, but \cs{zcref} provides granular control of hyperlinking by means
of its starred version.
\DescribeOption{nameinlink} %
The \opt{nameinlink} option controls whether the type name should be included
in the reference hyperlink or not (provided there is a link, of course).
Naturally, the name can only be included in the link of the \emph{first}
reference of each type block. \opt{nameinlink} can receive values
\texttt{true}, \texttt{false}, \texttt{single}, and \texttt{tsingle}. When
the value is \texttt{true} the type name is always included in the hyperlink.
When it is \texttt{false} the type name is never included in the link. When
the value is \texttt{single}, the type name is included in the link only if
\cs{zcref} is typesetting a single reference (not necessarily having received
a single label as argument, as they may have been compressed), otherwise, the
name is left out of the link. When the value is \texttt{tsingle}, the type
name is included in the link for each type block with a single reference,
otherwise, it isn't. An example: suppose you make a couple of references to
something like \cs{zcref}\texttt{\{chap:chapter1\}} and
\cs{zcref}\texttt{\{chap:chapter1, sec:section1, fig:figure1, fig:figure2\}}.
The ``figure'' type name will only be included in the hyperlink if
\opt{nameinlink} option is set to \texttt{true}. If it is set to
\texttt{tsingle}, the first reference will include the name in the link for
``chapter'', as expected, but also in the second reference the ``chapter'' and
``section'' names will be included in their respective links, while that of
``figure'' will not. If the option is set to \texttt{single}, only the name
for ``chapter'' in the first reference will be included in the link, while in
the second reference none of them will. The initial value is
\texttt{nameinlink=tsingle}, and the option given without a value is
equivalent to \texttt{nameinlink=true}.
\DescribeOption{lang} %
The \opt{lang} option controls the language used by \cs{zcref} when looking
for language-specific reference format options (see
\zcref{sec:reference-format}). The initial value, \texttt{current}, uses the
current language, as defined by \pkg{babel} or \pkg{polyglossia} (or
\texttt{english} if none of them is loaded). Value \texttt{main} uses the
main document language, as defined by \pkg{babel} or \pkg{polyglossia} (or
\texttt{english} if none of them is loaded). The \opt{lang} option also
accepts that the language be specified directly by its name, as long as it's a
language known by \pkg{zref-clever}. For more details on
\zcref*[ref=title,noname]{sec:internationalization}, see
\zcref{sec:internationalization}.
\DescribeOption{v} %
The \opt{v} option sets the variant, and affects the type name used for
typesetting the reference. Whether this option is operative, and which values
it accepts, depends on the declared setup for each language. For details, see
\zcref{sec:internationalization}.
\DescribeOption{nudge} %
\DescribeOption{nudgeif} %
\DescribeOption{nonudge} %
\DescribeOption{sg} %
\DescribeOption{g} %
This set of options revolving around \opt{nudge} aims to offer some guard
against mischievous automation on the part of \pkg{zref-clever} by providing a
number of ``nudges'' (compilation time messages) for cases in which you may
wish to revise material \emph{surrounding} the reference -- an article, a
preposition -- according to the reference typeset results. Useful mainly for
languages which inflect the preceding article to gender and/or number, but may
be used generally to fine-tune the language and style around the
cross-references made with \cs{zcref}. The \opt{nudge} option is the main
entrance to this feature and takes values \texttt{true}, \texttt{false},
\texttt{ifdraft}, or \texttt{iffinal}. The first two, respectively, enable or
disable the ``nudging'' unconditionally. With \texttt{ifdraft}, \opt{nudge}
keeps quiet when option \texttt{draft} is given to \cs{documentclass}, while
with \texttt{iffinal}, nudging is only enabled when option \texttt{final} is
(explicitly) passed to \cs{documentclass}. The option given without a value
is equivalent to \texttt{nudge=true} and the initial value is
\texttt{nudge=false}. \opt{nonudge} is a convenience alias for
\texttt{nudge=false}, and can be used to silence individual references. The
\opt{nudgeif} option controls the events which may trigger a nudge. It takes
a comma separated list of elements, and recognizes values \texttt{multitype},
\texttt{comptosing}, \texttt{gender}, and \texttt{all}. The
\texttt{multitype} nudge warns when the reference is composed by multiple type
blocks (see \zcref{sec:reference-format}). The \texttt{comptosing} nudge
let's you know when multiple labels of the same type have been compressed to a
singular type name form. It can be combined with the \opt{sg} option, which
is the way to tell \cs{zcref} you know it's a singular and so not to nudge if
a compression to singular occurs, but to nudge if the contrary occurs, that
is, when a plural type name form is employed. The \texttt{gender} nudge must
be combined with option \opt{g}, and depends on the language having support
for it. In essence language files can store the gender(s) of each type name
(this is done for built-in language files, but can also be done with
\cs{zcLanguageSetup} for languages declared to support it). The \opt{g}
option let's you specify the gender you expect for that particular reference
and the nudge is triggered if there is a mismatch between \opt{g} and the
gender(s) for the type name in the language file. Both the
\texttt{comptosing} and the \texttt{gender} nudges have a type block as its
scope. See \zcref{sec:internationalization} for more details and intended use
cases of the ``nudging'' feature.
\DescribeOption{font} %
The \opt{font} option can receive font styling commands to change the
appearance of the whole reference list (see also the \opt{namefont} and
\opt{reffont} reference format options in \zcref{sec:reference-format}). It
does not affect the content of the \opt{note}, however. The option is
intended exclusively for commands that only change font attributes: style,
family, shape, weight, size, color, etc. Anything else, particularly commands
that may generate typeset output, is not supported.
\DescribeOption{note} %
The \opt{note} option receives as value some text to be typeset at the end of
the whole reference list. It is separated from it by \opt{notesep} (see
\zcref{sec:reference-format}).
\DescribeOption{check} %
Provides integration of \pkg{zref-clever} with the \pkg{zref-check} package.
The option is only functional in the document body and if \pkg{zref-check} has
been loaded. \opt{check} requires a value, which works exactly like the
optional argument of \cs{zcheck}, and can receive both checks and
\cs{zcheck}'s options. And the checks are performed for each label in
\marg{labels} received as argument by \cs{zcref}. See the User manual of
\pkg{zref-check} for details. The checks done by the \opt{check} option in
\cs{zcref} comprise the complete reference, including the \opt{note} (see
\zcref{sec:reference-format}).
\DescribeOption{countertype} %
\DescribeOption{reftype} %
The \opt{countertype} option allows to specify the ``reference type'' of each
counter, which is stored as a label property when the label is set. This
reference type is what determines how a reference to this label will
eventually be typeset when it is referred to (see
\zcref{sec:reference-types}). A value like \texttt{countertype = \{foo =
bar\}} sets the \texttt{foo} counter to use the reference type \texttt{bar}.
There's only need to specify the \opt{countertype} for counters whose name
differs from that of their type, since \pkg{zref-clever} presumes the type has
the same name as the counter, unless otherwise specified. Also, the initial
value of the option already sets appropriate types for basic \LaTeX{}
counters, including those from the standard classes. Setting a counter type
to an empty value removes any (explicit) type association for that counter, in
practice, this means it then uses a type equal to its name. The \opt{reftype}
option allows one to specify the reference type manually, regardless of the
current counter. This can be used to locally override any \opt{countertype}
settings of the package and, for those acquainted with it, is the equivalent
of \pkg{cleveref}'s optional argument to \cs{label}. Normally, you'd want to
use this option within a group, but if you must do otherwise, the default
value can be restored by setting the option without a value. Since these
options only affect how labels are set, they are not available in \cs{zcref}.
\DescribeOption{\raisebox{-.2em}{\dbend}\ counterresetters} %
\DescribeOption{counterresetby} %
The sorting and compression of references done by \cs{zcref} requires that we
know the counter associated with a particular label but also information on
any counter whose stepping may trigger its resetting, or its ``enclosing
counters''. This information is not easily retrievable from the counter
itself but is (normally) stored with the counter that does the resetting. The
\opt{counterresetters} option receives a full comma separated list of counter
names, which \pkg{zref-clever} uses to search for ``enclosing counters'' of
the counter for which a label is being set. The order matters (see code
documentation for details), and you should also take care to start from the
initial value set by the package. Unfortunately, not every counter gets reset
through the standard machinery for this, including some \LaTeX{} kernel ones
(e.g. the \texttt{enumerate} environment counters). For those, there is
really no way to retrieve this information directly, so we have to just tell
\pkg{zref-clever} about them. And that's what the \opt{counterresetby} option
is made for. It receives a comma separated list of \texttt{key=value} pairs,
in which \texttt{key} is the counter, and \texttt{value} is its ``enclosing
counter'', that is, the counter whose stepping results in its resetting. This
is not really an ``option'' in the sense of ``user choice'', it is more of a
way to inform \pkg{zref-clever} of something it cannot know or automatically
find in general. One cannot place arbitrary information there, or
\pkg{zref-clever} can be thoroughly confused. The setting must correspond to
the actual resetting behavior of the involved counters. \opt{counterresetby}
has precedence over the search done in the \opt{counterresetters} list. The
initial value of \opt{counterresetters} includes the counters for sectioning
commands of the standard classes which, in most cases, should be the relevant
ones for cross-referencing purposes. The initial value of
\opt{counterresetby} includes the \texttt{enumerate} environment counters.
So, hopefully, you don't need to ever bother with either of these options.
But, if you do, they are here. Use them with caution though. Since these
options only affect how labels are set, they are not available in \cs{zcref}.
\DescribeOption{\raisebox{.4em}{\dbend}\ currentcounter} %
\LaTeX{}'s \cs{refstepcounter} sets two variables which potentially affect the
\cs{label} set after it: \cs{@currentlabel} and \cs{@currentcounter}. But,
since \pkg{zref-clever} relies heavily on the information of what the current
counter is, it must set \pkg{zref} to store that information with the label,
as it does. As long as the document element we are trying to refer to uses
the standard machinery of \cs{refstepcounter} we are on solid ground and can
retrieve the correct information. However, it is not always ensured that
\cs{@currentcounter} is kept up to date. For example, packages which handle
labels specially, for one reason or another, may or may not set
\cs{@currentcounter} as required. Considering the addition of
\cs{@currentcounter} to \cs{refstepcounter} itself is not that
old,\footnote{Traditionally, only the current label was thus stored, the
current counter was added to \cs{refstepcounter} somewhat recently (with the
2020-10-01 kernel release).} it is likely that in some places a reliable
\cs{@currentcounter} is not really in place. Therefore, it may happen we need
to tell \pkg{zref-clever} what the current counter is in certain
circumstances, and that's what \opt{currentcounter} does. The same as with
the previous two options, this is not really an ``user choice'' kind of
option, but a way to tell \pkg{zref-clever} a piece of information it has no
means to retrieve automatically. The setting must correspond to the actual
``current counter'', meaning here ``the counter underlying
\cs{@currentlabel}'' in a given situation. Also, when using the
\opt{currentcounter} option, take care that the setting is duly grouped
because, if set, it has precedence over \cs{@currentcounter} and, contrary to
the later, the former is not reset the next time \cs{refstepcounter} runs.
Its initial value is, quite naturally, \cs{@currentcounter}, which can be
reset by calling the option with no value. Since this option only affects how
labels are set, it is not available in \cs{zcref}.
\DescribeOption{\raisebox{.4em}{\dbend}\ labelhook} %
\opt{labelhook} is a boolean option which controls whether \pkg{zref-clever}
uses the kernel's \texttt{label} hook to, whenever a standard \cs{label} is
called, also set a \cs{zlabel} with the same name (which is what
\pkg{zref-clever} actually uses to make its references). The package's
initial value is \texttt{true} so that one can use \cs{label}s along the
document and refer to them (also) with \pkg{zref} and \pkg{zref-clever}
reference commands. This value is not only the default, but also a
recommended value. Disabling this option means you are on your own to handle
cases where \cs{zlabel} does not work, which are not many, but can be tricky
to deal with where they occur. Since this option only affects how labels are
set, it is not available in \cs{zcref}. See \zcref{sec:label-or-zlabel} for
some discussion of different labeling approaches this options allows for.
\DescribeOption{nocompat} %
Some packages, document classes, or LaTeX features may require specific
support to work with \pkg{zref-clever} (see \zcref{sec:limitations}).
\pkg{zref-clever} tries to make things smoother by covering some of them.
Depending on the case, this can take the form of some simple setup for
\pkg{zref-clever}, or may involve the use of hooks to external environments or
commands and, eventually, a patch or redefinition. By default, all the
available compatibility modules are enabled. Should this be undesired or
cause any problems in your environment, the option \opt{nocompat} can
selectively or completely inhibit their loading. \opt{nocompat} receives a
comma separated list of compatibility modules to disable (for the list of
available modules and details about each of them, see
\zcref{sec:comp-modules}). You can disable all modules by setting
\opt{nocompat} without a value (or an empty one). This is a preamble only
option.
\section{Reference types}
\label{sec:reference-types}
A ``reference type'' is the basic \pkg{zref-clever} setup unit for specifying
how a cross-reference group of a certain kind is to be typeset. Though,
usually, it will have the same name as the underlying \LaTeX{} \emph{counter},
they are conceptually different. \pkg{zref-clever} sets up \emph{reference
types} and an association between each \emph{counter} and its \emph{type},
it does not define the counters themselves, which are defined by your
document. One \emph{reference type} can be associated with one or more
\emph{counters}, and a \emph{counter} can be associated with different
\emph{types} at different points in your document. But each label is stored
with only one \emph{type}, as specified by the counter-type association at the
moment it is set, and that determines how the reference to that label is
typeset. References to different \emph{counters} of the same \emph{type} are
grouped together, and treated alike by \cs{zcref}. A \emph{reference type}
may be known to \pkg{zref-clever} when the \emph{counter} it is associated
with is not actually defined, and this inconsequential. In practice, the
contrary may also happen, a \emph{counter} may be defined but we have no
\emph{type} for it, but this must be handled by \pkg{zref-clever} as an error
(at least, if we try to refer to it), usually a ``missing name'' error.
\pkg{zref-clever} provides initial settings for the following reference types:
\texttt{part}, \texttt{chapter}, \texttt{section}, \texttt{paragraph},
\texttt{appendix}, \texttt{subappendix}, \texttt{page}, \texttt{line},
\texttt{figure}, \texttt{table}, \texttt{item}, \texttt{footnote},
\texttt{endnote}, \texttt{note}, \texttt{equation}, \texttt{theorem},
\texttt{lemma}, \texttt{corollary}, \texttt{proposition}, \texttt{definition},
\texttt{proof}, \texttt{result}, \texttt{remark}, \texttt{example},
\texttt{algorithm}, \texttt{listing}, \texttt{exercise}, and
\texttt{solution}. Therefore, if you are using a language for which
\pkg{zref-clever} has built-in support (see \zcref{sec:internationalization}),
these reference types are available for use out of the box.\footnote{There may
be slight availability differences depending on the language, but
\pkg{zref-clever} strives to keep this complete list available for the
languages it has built-in language files.} And, in any case, it is always
easy to setup custom reference types with \cs{zcRefTypeSetup} or
\cs{zcLanguageSetup} (see \zcref{sec:user-interface, sec:reference-format,
sec:internationalization}).
The association of a \emph{counter} to its \emph{type} is controlled by the
\opt{countertype} option. As seen in its documentation, \pkg{zref-clever}
presumes the \emph{type} to be the same as the \emph{counter} unless
instructed otherwise by that option. This association, as determined by the
local value of the option, affects how the \cs{label} is set, which stores the
type among its properties. However, when it comes to typesetting, that is
from the perspective of \cs{zcref}, only the \emph{type} matters. In other
words, how the reference is supposed to be typeset is determined at the point
the \cs{label} gets set. In sum, they may be namesakes (or not), but type is
type and counter is counter.
Indeed, a reference type can be associated with multiple counters because we
may want to refer to different document elements, with different
\emph{counters}, as a single \emph{type}, with a single name. One prominent
case of this are sectioning commands. \cs{section}, \cs{subsection}, and
\cs{subsubsection} have each their counter, but we'd like to refer to all of
them by ``sections'' and group them together. The same for \cs{paragraph} and
\cs{subparagraph}.
There are also cases in which we may want to use different \emph{reference
types} to refer to document objects sharing the same \emph{counter}.
Notably, the environments created with \LaTeX{}'s \cs{newtheorem} command and
the \cs{appendix}.
One more observation about ``reference types'' is due here. A \emph{type} is
not really ``defined'' in the sense a variable or a function is. It is more
of a ``name'' which \pkg{zref-clever} uses to look for a whole set of
type-specific reference format options (see \zcref{sec:reference-format}).
Each of these options individually may be ``set'' or not, ``defined'' or not.
And, depending on the setup and the relevant precedence rules for this, some
of them may be required and some not. In practice, \pkg{zref-clever} uses the
\emph{type} to look for these options when it needs one, and issues a
compilation warning when it cannot find a suitable value.