Debian Codegraph @

texmf-dist/source/latex/fancylabel/fancylabel.dtx

raw
1 % \iffalse meta-comment
2 %
3 % Copyright (C) 2014-2018 by Dominik Siegel
4 %
5 % This file may be distributed and/or modified under the
6 % conditions of the LaTeX Project Public License, either
7 % version 1.2 of this license or (at your option) any later
8 % version. The latest version of this license is in:
9 %
10 % http://www.latex-project.org/lppl.txt
11 %
12 % and version 1.2 or later is part of all distributions of
13 % LaTeX version 1999/12/01 or later.
14 %%
15 %% To produce the documentation, do the following
16 %%
17 %% latex fancylabel.dtx
18 %% latex fancylabel.dtx
19 %% makeindex -s gind.ist -o fancylabel.ind fancylabel.idx
20 %% latex fancylabel.dtx
21 %
22 % <package>\NeedsTeXFormat{LaTeX2e}[2005/12/01]
23 % <package>\ProvidesPackage{fancylabel}
24 % <package>[2017/12/30 v1.1]
25 %
26 %<*driver>
27 \documentclass{ltxdoc}
28 \usepackage[numbering=continuous,families={mark,sym},level=sub,sort=true]{fancylabel}
29 \usepackage{subfig}
30 \usepackage[hidelinks]{hyperref}
31 \GetFileInfo{fancylabel.dtx}
32 \EnableCrossrefs
33 \CodelineIndex
34 \RecordChanges
35 \OnlyDescription
36 \date{2017/12/30}
37 \begin{document}
38 \DocInput{fancylabel.dtx}
39 \end{document}
40 %</driver>
41 % \fi
42 %
43 % \CheckSum{0}
44 %
45 % \CharacterTable
46 % {Upper-case \A\B\C\D\E\F\G\H\I\J\K\L\M\N\O\P\Q\R\S\T\U\V\W\X\Y\Z
47 % Lower-case \a\b\c\d\e\f\g\h\i\j\k\l\m\n\o\p\q\r\s\t\u\v\w\x\y\z
48 % Digits \0\1\2\3\4\5\6\7\8\9
49 % Exclamation \! Double quote \" Hash (number) \#
50 % Dollar \$ Percent \% Ampersand \&
51 % Acute accent \' Left paren \( Right paren \)
52 % Asterisk \* Plus \+ Comma \,
53 % Minus \- Point \. Solidus \/
54 % Colon \: Semicolon \; Less than \<
55 % Equals \= Greater than \> Question mark \?
56 % Commercial at \@ Left bracket \[ Backslash \\
57 % Right bracket \] Circumflex \^ Underscore \_
58 % Grave accent \` Left brace \{ Vertical bar \|
59 % Right brace \} Tilde \~}
60 %
61 % \changes{v1.0}{2014/07/15}{Initial version}
62 % \changes{v1.1}{2017/12/30}{Dependencies updated}
63 %
64 % \GetFileInfo{fancylabel.sty}
65 %
66 % \DoNotIndex{\@auxout,\@end@token,\@ifnextchar,\@ifundefined,\@namedef,\@nameuse,\@onlypreamble}
67 % \DoNotIndex{\alph,\arabic,\AtEndDocument}
68 % \DoNotIndex{\csname}
69 % \DoNotIndex{\DeclareOptionX,\DeclareRobustCommand,\def,\define@choicekey,\define@key}
70 % \DoNotIndex{\else,\endcsname,\equal,\expandafter}
71 % \DoNotIndex{\fi}
72 % \DoNotIndex{\g@addto@macro,\global}
73 % \DoNotIndex{\ifcase,\ifthenelse,\immediate}
74 % \DoNotIndex{\NeedsTeXFormat,\newcommand,\newcounter,\newif,\nr}
75 % \DoNotIndex{\or}
76 % \DoNotIndex{\PackageError,\PackageWarning,\presetkeys,\ProcessOptionsX,\ProvidesPackage}
77 % \DoNotIndex{\relax,\RequirePackage}
78 % \DoNotIndex{\setcounter,\stepcounter,\string}
79 % \DoNotIndex{\val}
80 % \DoNotIndex{\write}
81 % \DoNotIndex{\xdef}
82 %
83 % \title{The \textsf{fancylabel} package\thanks{This document corresponds to \textsf{fancylabel}~\fileversion{}, dated \filedate.}}
84 %
85 % \author{Dominik Siegel \\ \texttt{[email protected]}}
86 %
87 % \maketitle
88 %
89 % \begin{abstract}
90 % For \LaTeX{} referencing it is necessary to have unique labels. But sometimes you have similar objects (symbols, chemical structures, etc.) that appear more often than once in your document. When you write your document you cannot know from the beginning on in which position your object appears for the first time. Hence you don't know whether to place a |\label| or a |\ref|.
91 %
92 % This package basically provides the two new commands |\fancylabel| and |\fancyref|. With the |\fancylabel| command you don't have to know if it is time to set a |\label| or a |\ref|, |\fancylabel| will decide this for you.
93 %
94 % Additionally this package allows you various different numerations including numbering order, numbering level and numbering families.
95 % \end{abstract}
96 %
97 %
98 % \tableofcontents
99 %
100 % \section{Introduction}
101 %
102 % The idea of referencing in \LaTeX{} is to associate an object with a |\label|. Whenever you want to refer to it you just use |\ref|. This works as long as you have an unique object like a figure, a table, a section etc. But if you want the refer to repeating objects which are expected to have the same number like symbols, (chemical-) structures etc. referencing becomes more complex.
103 %
104 % \newcounter{mylabelcounter}
105 % \newcommand{\mylabel}[1]{\refstepcounter{mylabelcounter}\themylabelcounter\label{#1}}
106 % \begin{figure}[h]
107 % \centering
108 % \begin{tabular}{cccc}
109 % \Huge$\rightarrow$ & \Huge$\leftarrow$ &
110 % \Huge$\rightarrow$ & \Huge$\Leftarrow$ \\
111 % \mylabel{arrow1} & \mylabel{arrow2} &
112 % \ref{arrow1} & \mylabel{arrow3}
113 % \end{tabular}
114 % \caption{Some repeating objects. Here we refer to symbol \ref{arrow2}.}
115 % \end{figure}
116 %
117 % In our example same arrows are supposed to get the same number. We define a counter and a new label command. This was actually quite simple. But the big disadvantage of this solution is, that you always have to take care where your object occurs for the first time. At the first occurrence you have to label it, at any other occurrence you have to refer. Every time you change the order you have to adjust the labeling by hand.
118 %
119 % \begin{verbatim}
120 % \newcounter{mylabelcounter}
121 % \newcommand{\mylabel}[1]{\refstepcounter{mylabelcounter}\themylabelcounter\label{#1}}
122 % \begin{figure}[h]
123 % ...figure code...
124 % \begin{tabular}{cccc}
125 % \Huge$\rightarrow$ & \Huge$\leftarrow$ &
126 % \Huge$\rightarrow$ & \Huge$\Leftarrow$ \\
127 % \mylabel{arrow1} & \mylabel{arrow2} &
128 % \ref{arrow1} & \mylabel{arrow3}
129 % \end{tabular}
130 % ...figure code...
131 % \end{figure}
132 % \end{verbatim}
133 %
134 % Beside other additional functions and options this is exactly what the \textsf{fancylabel} package does for you. Whenever you insert an object you can use |\fancylabel|. The package will recognize if the label already exists and therefore decides whether to label or to refer.
135 %
136 % \begin{verbatim}
137 % \begin{figure}[h]
138 % ...figure code...
139 % \begin{tabular}{cccc}
140 % \Huge$\rightarrow$ & \Huge$\leftarrow$ &
141 % \Huge$\rightarrow$ & \Huge$\Leftarrow$ \\
142 % \fancylabel{arrow1} & \fancylabel{arrow2} &
143 % \fancylabel{arrow1} & \fancylabel{arrow3}
144 % \end{tabular}
145 % ...figure code...
146 % \end{figure}
147 % \end{verbatim}
148 % \fancylabel*{arrow1,arrow2,arrow3}
149 %
150 %
151 % \section{Package Commands}
152 % \subsection{Label commands}
153 % \DescribeMacro{\fancylabel}
154 % \DescribeMacro{\fancylabel*}
155 % |\fancylabel[<family>]{<marker>}|\\
156 % |\fancylabel*[<family>]{<marker>}|\vspace{0.5em}
157 %
158 % \noindent The |\fancylabel| command always checks if a label for |<marker>| already exists and creates it if not. Then it prints the reference as |\fancyref| does. Additionally a |<family>| can be defined (For description see section \ref{fam}). The starred versions create a label without printing the reference.
159 %
160 % The argument |<marker>| might also be a comma-separated list of indentifiers. In this case |\fancylabel| creates a label for all so far undefined indentifiers and prints a list of references. This list can be sorted and compressed automatically (see section \ref{sort} and \ref{compress}).
161 %
162 %
163 % \subsection{Sublabel commands}
164 % \DescribeMacro{\fancysublabel}
165 % \DescribeMacro{\fancysublabel-}
166 % \DescribeMacro{\fancysublabel*}
167 % |\fancysublabel[<family>]{<marker>}{<submarker>}|\\
168 % |\fancysublabel-[<family>]{<marker>}{<submarker>}|\\
169 % |\fancysublabel*[<family>]{<marker>}{<submarker>}|\vspace{0.5em}
170 %
171 % \noindent The |\fancysublabel| command is working in the same way as |\fancylabel| while providing a second level of referencing. If the corresponding label for |<marker>| was not previously defined, it will be created as well. The output of |\fancysublabel| is the complete reference consisting in label and sublabel (e.\,g. 1a). The output of |\fancysublabel-| is only the sublabel (e.\,g. a). The starred version |\fancysublabel*| creates the sublabel without any output.
172 %
173 % While the argument |<marker>| has to be a single indentifier, the |<submarker>| argument might be a comma-separated list. In this case |\fancysublabel| creates a sublabel for all so far undefined indentifiers and prints a list of references. This list can be sorted and compressed automatically (see section \ref{sort} and \ref{compress}).
174 %
175 %
176 % \subsection{Ref and subref commands}
177 % \DescribeMacro{\fancyref}
178 % \DescribeMacro{\fancyref*}
179 % \DescribeMacro{\fancysubref}
180 % \DescribeMacro{\fancysubref-}
181 % \DescribeMacro{\fancysubref*}
182 % |\fancyref[<family>]{<marker>}|\\
183 % |\fancyref*[<family>]{<marker>}|\\
184 % |\fancysubref[<family>]{<marker>}{<submarker>}|\\
185 % |\fancysubref-[<family>]{<marker>}{<submarker>}|\\
186 % |\fancysubref*[<family>]{<marker>}{<submarker>}|\vspace{0.5em}
187 %
188 % \noindent The function of these commands is compareable to their corresponding label commands. |\fancyref| prints the reference of |<marker>| and remembers that this |<marker>| has been requested. |\fancyref*| remembers the request without any output.
189 %
190 % |\fancysubref| prints the label and sublabel of |<marker>| and |<submarker>| and remembers the request. |\fancysubref-| prints only the sublabel and remembers the request. |\fancysubref*| does only remember the request.
191 %
192 %
193 % \section{Options}
194 % \subsection{The families option}\label{fam}
195 % \DescribeMacro{families=}
196 % |\usepackage[families={<comma-separated list>}]{fancylabel}|\vspace{0.5em}
197 %
198 % \noindent You can define different families for your labels to have different counters. This can be done with the |families| option. If you don't specify the family in label or ref commands |family=default| will be used. This is the only predefined family.
199 %
200 %
201 % \begin{verbatim}
202 % \begin{figure}[h]
203 % ...figure code...
204 % \begin{tabular}{cccc}
205 % \Huge$\rightarrow$ & \Large\textcopyright &
206 % \Huge$\oplus$ & \Huge$\ominus$ \\
207 % \fancylabel{arrow1} & \fancylabel[mark]{mark1} &
208 % \fancylabel[sym]{symbol1} & \fancylabel[sym]{symbol2}
209 % \end{tabular}
210 % ...figure code...
211 % \end{figure}
212 % \end{verbatim}
213 %
214 % \begin{figure}[h]
215 % \centering
216 % \begin{tabular}{cccc}
217 % \Huge$\rightarrow$ & \Large\textcopyright &
218 % \Huge$\oplus$ & \Huge$\ominus$ \\
219 % \fancylabel{arrow1} & \fancylabel[mark]{mark1} &
220 % \fancylabel[sym]{symbol1} & \fancylabel[sym]{symbol2}
221 % \end{tabular}
222 % \caption{Objects of different families. For this example the families \texttt{mark} and \texttt{sym} have been defined using the family option.}
223 % \end{figure}
224 %
225 %
226 %
227 % The (sub-)labels and (sub-)refs will have |<family>-| as prefix. This Prefix can be changed by redefining |\fancylabelformat<family>| and |\fancysublabelformat<family>|. For example the definition of the default-prefix can be changed by:
228 % \begin{verbatim}
229 % \renewcommand{\fancylabelformatdefault}{\arabic{fancylabel}}
230 % \end{verbatim}
231 %
232 %
233 % \subsection{The IgnoreFamilies option}
234 % \DescribeMacro{IgnoreFamilies=}
235 % |\usepackage[IgnoreFamilies=<boolean>]{fancylabel}|\vspace{0.5em}
236 %
237 % \noindent If the option |IgnoreFamilies=true|, every label will be interpreted as it would be part of the |default| family.
238 %
239 % \subsection{The numbering option}
240 % \DescribeMacro{numbering=}
241 % |\usepackage[numbering=<value>]{fancylabel}|\vspace{0.5em}
242 %
243 % \noindent The option |numbering| can have one of the following values: |continuous| (default), |ondemand| or |referenced|. We will now have a look on the following code compiled with different values for this option.
244 %
245 % \begin{verbatim}
246 % ...figure code...
247 % \begin{tabular}{cccc}
248 % \Huge$\Rightarrow$ & \Huge$\Leftrightarrow$ &
249 % \Huge$\Leftarrow$ & \Huge$\rightleftharpoons$ \\
250 % \fancylabel{arrow4} & \fancylabel{arrow5} &
251 % \fancylabel{arrow6} & \fancylabel{arrow7}
252 % \end{tabular}
253 % \caption{This is some random text where I refer to symbol%
254 % \fancyref{arrow7} and symbol \fancyref{arrow5}.}
255 % ...figure code...
256 % \end{verbatim}
257 %
258 % \DescribeMacro{numbering=continuous}
259 % The |continuous| numbering means, that every |\fancylabel| will get its reference. The referencing order is in the order |\fancylabel| asked for.
260 %
261 % \fancylabelResetCounter{default}
262 % \begin{figure}[h]
263 % \centering
264 % \begin{tabular}{cccc}
265 % \Huge$\Rightarrow$ & \Huge$\Leftrightarrow$ &
266 % \Huge$\Leftarrow$ & \Huge$\rightleftharpoons$ \\
267 % \fancylabel{arrow4} & \fancylabel{arrow5} &
268 % \fancylabel{arrow6} & \fancylabel{arrow7}
269 % \end{tabular}
270 % \caption{This is some random text where I refer to symbol \fancyref{arrow7} and symbol \fancyref{arrow5}.}
271 % \end{figure}
272 %
273 % \DescribeMacro{numbering=ondemand}
274 % The |ondemand| numbering means, that a |\fancylabel| will only get its reference, if a |\fancyref| refered to it. The referencing order is in the order |\fancylabel| asked for.
275 %
276 % \begin{figure}[h]
277 % \centering
278 % \begin{tabular}{cccc}
279 % \Huge$\Rightarrow$ & \Huge$\Leftrightarrow$ &
280 % \Huge$\Leftarrow$ & \Huge$\rightleftharpoons$ \\
281 % & 1 &
282 % & 2
283 % \end{tabular}
284 % \caption{This is some random text where I refer to symbol 2 and symbol 1.}
285 % \end{figure}
286 %
287 % \DescribeMacro{numbering=referenced}
288 % The |referenced| numbering means, that a |\fancylabel| will only get its reference, if a |\fancyref| refered to it. The referencing order is in the order |\fancyref| asked for.
289 %
290 % \begin{figure}[h]
291 % \centering
292 % \begin{tabular}{cccc}
293 % \Huge$\Rightarrow$ & \Huge$\Leftrightarrow$ &
294 % \Huge$\Leftarrow$ & \Huge$\rightleftharpoons$ \\
295 % & 2 &
296 % & 1
297 % \end{tabular}
298 % \caption{This is some random text where I refer to symbol 1 and symbol 2.}
299 % \end{figure}
300 %
301 %
302 %
303 % \subsection{The level option}
304 % \DescribeMacro{level=}
305 % |\usepackage[level=<value>]{fancylabel}|\vspace{0.5em}
306 %
307 % \noindent The option |level| can have one of the following values: |sub| (default) or |same|. The value |sub| means, that all sublabels defined by |\fancysublabel| are interpreted as thought (two level numbering). The value |same| means, that all sublabels are interpreted as the would be labels defined with |\fancylabel| (one level numbering).
308 %
309 % \begin{verbatim}
310 % \begin{figure}[h]
311 % \centering
312 % \begin{tabular}{ccc}
313 % \Huge$\diamondsuit$ &
314 % \Huge$\heartsuit$ &
315 % \Huge$\spadesuit$ \\
316 % \fancysublabel{cards}{diamond} &
317 % \fancysublabel{cards}{heart} &
318 % \fancysublabel{cards}{spade} \\
319 % \end{tabular}
320 % \end{figure}
321 % \end{verbatim}
322 %
323 % \captionsetup[subfigure]{labelformat=empty}
324 % \begin{figure}[h]
325 % \centering
326 % \subfloat[Option \texttt{level=sub}.]{
327 % \begin{tabular}{ccc}
328 % \Huge$\diamondsuit$ &
329 % \Huge$\heartsuit$ &
330 % \Huge$\spadesuit$ \\
331 % \fancysublabel{cards}{diamond} &
332 % \fancysublabel{cards}{heart} &
333 % \fancysublabel{cards}{spade} \\
334 % \end{tabular}
335 % }\quad\quad
336 % \subfloat[Option \texttt{level=same}.]{%
337 % \begin{tabular}{ccc}
338 % \Huge$\diamondsuit$ &
339 % \Huge$\heartsuit$ &
340 % \Huge$\spadesuit$ \\
341 % 5 &
342 % 6 &
343 % 7 \\
344 % \end{tabular}
345 % }
346 % \end{figure}
347 %
348 %
349 % \subsection{The sort option}\label{sort}
350 % \DescribeMacro{sort=}
351 % |\usepackage[sort=<boolean>]{fancylabel}|\vspace{0.5em}
352 %
353 % \noindent If |sort=true| the output of fancylabels und fancyrefs will be sorted. By default this option is |false|.
354 %
355 %
356 % \subsection{The compress option}\label{compress}
357 % \DescribeMacro{compress=}
358 % |\usepackage[compress=<boolean>]{fancylabel}|\vspace{0.5em}
359 %
360 % \noindent If |compress=true| the output of fancylabels und fancyrefs compressed. By default this option is |false|.
361 %
362 %
363 % \subsection{The CompressLink option}
364 % \DescribeMacro{CompressLink=}
365 % |\usepackage[CompressLink=<separator>]{fancylabel}|\vspace{0.5em}
366 %
367 % \noindent With the |CompressLink| option you can define the separator between the compressed labels. The default value is |CompressLink={-}|.
368 %
369 %
370 % \subsection{The CompressTwo option}
371 % \DescribeMacro{CompressTwo=}
372 % |\usepackage[CompressTwo=<boolean>]{fancylabel}|\vspace{0.5em}
373 %
374 % \noindent By this option you can define if compression takes place even if there are only two sequential labels. By default this option is |false|. Example: |CompressTwo=true| $\rightarrow$ 1-2 and 1-3 or |CompressTwo=false| $\rightarrow$ 1,2 but 1-3.
375 %
376 %
377 % \subsection{The ListLastSublabelOnly option}
378 % \DescribeMacro{ListLastSublabelOnly=}
379 % |\usepackage[ListLastSublabelOnly=<boolean>]{fancylabel}|\vspace{0.5em}
380 %
381 % \noindent If |ListLastSublabelOnly=true| (default), the output of a list of fancysublabels of fancysublabels is e.\,g. 1a-d,e. If |ListLastSublabelOnly=false|, the output of a list of fancysublabels of fancysublabels is e.\,g. 1a-1d,1e.
382 %
383 %
384 % \subsection{The ListSeparator option}
385 % \DescribeMacro{ListSeparator=}
386 % |\usepackage[ListSeparator=<separator>]{fancylabel}|\vspace{0.5em}
387 %
388 % \noindent This option defines the separator between two non-compressed values in a list. By default, |ListSeparator={,\hskip-0.16667em{ }}| which is a small white space allowing linebreak.
389 %
390 %
391 % \subsection{The ListLastLabelSeparator option}
392 % \DescribeMacro{ListLastLabelSeparator=}
393 % |\usepackage[ListLastLabelSeparator=<separator>]{fancylabel}|\vspace{0.5em}
394 %
395 % \noindent This option defines the separator between the last two values in a list (e.\,g. \texttt{ListLastLabelSeparator=\{\raisebox{-0.23em}{\textasciitilde}and\raisebox{-0.23em}{\textasciitilde}}\} $\rightarrow$ 1a-c,d~and~f). By default, this option has the same value as the |ListSeparator| option. Note: This option will only be applied in label commands!
396 %
397 %
398 % \subsection{The ListLastRefSeparator option}
399 % \DescribeMacro{ListLastRefSeparator=}
400 % |\usepackage[ListLastRefSeparator=<separator>]{fancylabel}|\vspace{0.5em}
401 %
402 % \noindent This option behaves like the |ListLastLabelSeparator| option but will only be applied in ref commands.
403 %
404 %
405 % \subsection{The DisableFamilyCheck option}
406 % \DescribeMacro{DisableFamilyCheck=}
407 % |\usepackage[DisableFamilyCheck=<boolean>]{fancylabel}|\vspace{0.5em}
408 %
409 % \noindent When a new |\fancylabel| is defined the \textsf{fancylabel} package checks whether this |<marker>| has already been used in other families and prints a warning. The option |DisableFamilyCheck=true| disables this check. The default value is |DisableFamilyCheck=false|.
410 %
411 %
412 % \section{Customization}
413 % \subsection{Reset counters}
414 % The label counters of each family can be reset by using the following command. Note that |<number>=0| means that the next label will get the value 1. Note: This might cause crazy lists if the options |sort| or |compress| are used!
415 % \begin{verbatim}
416 % \renewcommand{\fancylabel@familystorage@<family>}{<number>}
417 % \end{verbatim}
418 %
419 %
420 % \subsection{Label und sublabel format}
421 % The format of labels and sublabels of each family can be adjusted by redefining the corresponding labelformat. In the following example you have to replace |<family>| by |default| to adjust the format of the default family.
422 % \begin{verbatim}
423 % \renewcommand{\fancylabelformat<family>}{\arabic{fancylabel}}
424 % \renewcommand{\fancysublabelformat<family>}{\arabic{fancylabel}\alph{fancysublabel}}
425 % \renewcommand{\fancyonlysublabelformat<family>}{\alph{fancysublabel}}
426 % \end{verbatim}
427 %
428 %
429 % \subsection{NewLabelEvent}
430 % If you want to execute a macro everytime a new label has been defined you can modify the following command:
431 % \begin{verbatim}
432 % \fancylabelNewLabelEvent
433 % \end{verbatim}
434 %
435 %
436 % \subsection{ShowLabelEvent}
437 % If you want to execute a macro everytime a label is shown you can modify the following command:
438 % \begin{verbatim}
439 % \fancylabelShowLabelEvent
440 % \end{verbatim}
441 %
442 %
443 % \subsection{ShowRefEvent}
444 % If you want to execute a macro everytime a label is shown you can modify the following command:
445 % \begin{verbatim}
446 % \fancylabelShowRefEvent
447 % \end{verbatim}
448 %
449 %
450 % \subsection{Lists of labels}
451 % The \textsf{fancylabel} package draws up a comma-separated list of all labels that have been defined for each family. You can use these lists for further costumization.
452 % \begin{verbatim}
453 % \fancylabel@list@<family>
454 % \end{verbatim}
455 %
456 % \section{Change history}
457 % \begin{itemize}
458 % \item[2014/07/15] Initial version
459 % \item[2017/12/30] Dependencies updated (\textsf{xifthen} instead of \textsf{ifthen})
460 % \end{itemize}
461 %
462 % \StopEventually{}
463 %
464 % \section{The implementation}
465 %
466 % \subsection{Identification}
467 % \begin{macrocode}
468 \NeedsTeXFormat{LaTeX2e}[2005/12/01]
469 \ProvidesPackage{fancylabel}[2017/12/30 v1.1 Referencing in a fancy way]
470 % \end{macrocode}
471 %
472 % \subsection{Loading packages and define counters}
473 % \begin{macrocode}
474 \RequirePackage{xkeyval}
475 \RequirePackage{xifthen}
476 \RequirePackage{suffix}
477 \newcounter{fancylabel}
478 \setcounter{fancylabel}{0}
479 \newcounter{fancysublabel}
480 \setcounter{fancysublabel}{0}
481 \presetkeys{fancylabel}{numbering=continuous,%
482 level=sub,%
483 IgnoreFamilies=false,%
484 sort=false,%
485 compress=false,%
486 CompressLink={-},%
487 CompressTwo=false,%
488 ListLastSublabelOnly=true,
489 ListSeparator={,\hskip-0.16667em{ }},%
490 ListLastLabelSeparator=\fancyref@ListSeparator,%
491 ListLastRefSeparator=\fancyref@ListSeparator,%
492 DisableFamilyCheck=false%
493 }{}
494 % \end{macrocode}
495 %
496 % \subsection{The options}
497 % \begin{macro}{\fancyref@addtolist}
498 % \begin{macrocode}
499 \newcommand{\fancyref@addtolist}[2]{%
500 % #1=value to be added to the list #2
501 % #2=list
502 \ifthenelse{\equal{#1}{}}{}{%
503 \ifthenelse{\equal{#2}{}}{}{%
504 \g@addto@macro{#2}{,}%
505 }%
506 \g@addto@macro{#2}{#1}%
507 }%
508 }
509 % \end{macrocode}
510 % \end{macro}
511 % \begin{macro}{\fancyref@addtoprintlist}
512 % \begin{macrocode}
513 \newcommand{\fancyref@addtoprintlist}[2]{%
514 % #1=value to be added to the list #2
515 % #2=list
516 \ifthenelse{\equal{#1}{}}{}{%
517 \ifthenelse{\equal{#2}{}}{}{%
518 \g@addto@macro{#2}{\fancyref@ListSeparator}%
519 }%
520 \g@addto@macro{#2}{#1}%
521 }%
522 }
523 % \end{macrocode}
524 % \end{macro}
525 % \begin{macro}{families=}
526 % \begin{macrocode}
527 \define@key{fancylabel}{families}{%
528 \fancyref@foreach{\fancyref@DefineFamily}{}{#1}%
529 }
530 \newcommand{\fancyref@ListOfFamilies}{}
531 \newcommand{\fancyref@DefineFamily}[2]{%
532 % #1=empty
533 % #2=family
534 \@namedef{fancylabel@familystorage@#2}{0}%
535 \@namedef{fancylabelformat#2}{#2-\arabic{fancylabel}}%
536 \@namedef{fancyonlysublabelformat#2}{\alph{fancysublabel}}%
537 \@namedef{fancysublabelformat#2}{#2-\arabic{fancylabel}\alph{fancysublabel}}%
538 \@namedef{fancylabel@list@#2}{}%
539 \fancyref@addtolist{#2}{\fancyref@ListOfFamilies}%
540 }
541 \@onlypreamble\fancyref@DefineFamily
542 \fancyref@DefineFamily{}{default}
543 \renewcommand{\fancylabelformatdefault}{\arabic{fancylabel}}
544 \renewcommand{\fancysublabelformatdefault}{\arabic{fancylabel}\alph{fancysublabel}}
545 % \end{macrocode}
546 % \end{macro}
547 % \begin{macro}{numbering=}
548 % \begin{macrocode}
549 \define@choicekey*+{fancylabel}{numbering}[\val\nr]{continuous,ondemand,referenced}{%
550 % ##1=family
551 % ##2=label
552 % ##3=sublabel
553 \ifcase\nr\relax%
554 % numbering=continuous
555 % Label will be set un the first time, \fancylabel{} is called
556 % Order of labels depends on the appearance of fancylabel{}
557 \newcommand{\fancyref@define@LabelUndef}[3]{%
558 \fancyref@newlabel{##1}{##2}{##3}%
559 }%
560 \newcommand{\fancyref@show@LabelUndef}[3]{%
561 \fancyref@showlabel{##1}{##2}{##3}%
562 }%
563 \newcommand{\fancyref@define@LabelDef}[3]{}%
564 \newcommand{\fancyref@show@LabelDef}[3]{%
565 \fancyref@showlabel{##1}{##2}{##3}%
566 }%
567 \newcommand{\fancyref@define@RefUndef}[3]{}%
568 \newcommand{\fancyref@show@RefUndef}[3]{%
569 \@ifundefined{fancyref@PrevRun@##1@##2@##3}{%
570 \fancyref@labelerror{##2}{##3}%
571 ???%
572 }{%
573 \fancyref@showlabel{##1}{##2}{##3}%
574 }%
575 }%
576 \newcommand{\fancyref@define@RefDef}[3]{}%
577 \newcommand{\fancyref@show@RefDef}[3]{%
578 \fancyref@showlabel{##1}{##2}{##3}%
579 }%
580 \or%
581 % numbering=ondemand
582 % Only set label if it was asked for during the last run
583 % Order of labels depends on the appearance of fancylabel{}
584 \newcommand{\fancyref@define@LabelUndef}[3]{%
585 \@ifundefined{fancyref@AskedPrevRun@##1@##2@##3}{}{%
586 \fancyref@newlabel{##1}{##2}{##3}%
587 }%
588 }%
589 \newcommand{\fancyref@show@LabelUndef}[3]{%
590 \@ifundefined{fancyref@AskedPrevRun@##1@##2@##3}{}{%
591 \fancyref@showlabel{##1}{##2}{##3}%
592 }%
593 }%
594 \newcommand{\fancyref@define@LabelDef}[3]{}%
595 \newcommand{\fancyref@show@LabelDef}[3]{%
596 \fancyref@showlabel{##1}{##2}{##3}%
597 }%
598 \newcommand{\fancyref@define@RefUndef}[3]{}%
599 \newcommand{\fancyref@show@RefUndef}[3]{%
600 \@ifundefined{fancyref@PrevRun@##1@##2@##3}{%
601 \fancyref@labelerror{##2}{##3}%
602 ???%
603 }{%
604 \fancyref@showlabel{##1}{##2}{##3}%
605 }%
606 }%
607 \newcommand{\fancyref@define@RefDef}[3]{}%
608 \newcommand{\fancyref@show@RefDef}[3]{%
609 \fancyref@showlabel{##1}{##2}{##3}%
610 }%
611 \or%
612 % numbering=referenced
613 % Only set label if it was asked for during the last run
614 % Order of labels depends on the appearance of fancyref{}
615 \newcommand{\fancyref@define@LabelUndef}[3]{}%
616 \newcommand{\fancyref@show@LabelUndef}[3]{%
617 \@ifundefined{fancyref@AskedPrevRun@##1@##2@##3}{}{%
618 \fancyref@showlabel{##1}{##2}{##3}%
619 }%
620 }%
621 \newcommand{\fancyref@define@LabelDef}[3]{}%
622 \newcommand{\fancyref@show@LabelDef}[3]{%
623 \fancyref@showlabel{##1}{##2}{##3}%
624 }%
625 \newcommand{\fancyref@define@RefUndef}[3]{%
626 \fancyref@newlabel{##1}{##2}{##3}%
627 }%
628 \newcommand{\fancyref@show@RefUndef}[3]{%
629 \@ifundefined{fancyref@PrevRun@##1@##2@##3}{%
630 \fancyref@labelerror{##2}{##3}%
631 ???%
632 }{%
633 \fancyref@showlabel{##1}{##2}{##3}%
634 }%
635 }%
636 \newcommand{\fancyref@define@RefDef}[3]{%
637 \fancyref@newlabel{##1}{##2}{##3}%
638 }%
639 \newcommand{\fancyref@show@RefDef}[3]{%
640 \fancyref@showlabel{##1}{##2}{##3}% Show label
641 }%
642 \fi%
643 }{%
644 \PackageError{fancylabel}{This value is not allowed. Allowed values are:%
645 'continuous'(default), 'ondemand', 'referenced'.}{}%
646 }
647 % \end{macrocode}
648 % \end{macro}
649 % \begin{macro}{level=}
650 % \begin{macrocode}
651 \define@choicekey*+{fancylabel}{level}[\val\nr]{sub,same}{%
652 % ##1=family
653 % ##2=label
654 % ##3=sublabel
655 \ifcase\nr\relax%
656 % level=sub
657 \DeclareRobustCommand\fancysublabel[3][default]{{%
658 \fancysubreftrue%
659 \fancyref@subrefminusfalse%
660 \@fancylabel{##1}{##2}{##3}%
661 }}%
662 \WithSuffix\DeclareRobustCommand\fancysublabel-[3][default]{{%
663 \fancysubreftrue%
664 \fancyref@subrefminustrue%
665 \@fancylabel{##1}{##2}{##3}%
666 }}%
667 \WithSuffix\DeclareRobustCommand\fancysublabel*[3][default]{{%
668 \renewcommand{\@@fancylabel@show}[2]{}%
669 \fancysubreftrue%
670 \fancyref@subrefminusfalse%
671 \@fancylabel{##1}{##2}{##3}%
672 }}%
673 \DeclareRobustCommand\fancysubref[3][default]{{%
674 \fancysubreftrue%
675 \fancyref@subrefminusfalse%
676 \@fancyref{##1}{##2}{##3}%
677 }}%
678 \WithSuffix\DeclareRobustCommand\fancysubref-[3][default]{{%
679 \fancysubreftrue%
680 \fancyref@subrefminustrue%
681 \@fancyref{##1}{##2}{##3}%
682 }}%
683 \WithSuffix\DeclareRobustCommand\fancysubref*[3][default]{{%
684 \renewcommand{\@@fancylabel@show}[2]{}%
685 \fancysubreftrue%
686 \fancyref@subrefminusfalse%
687 \@fancyref{##1}{##2}{##3}%
688 }}%
689 \or%
690 % level=same
691 \DeclareRobustCommand\fancysublabel[3][default]{{%
692 \fancysubreffalse%
693 \fancyref@subrefminusfalse%
694 \@fancylabel{##1}{##2}{##3}%
695 }}%
696 \WithSuffix\DeclareRobustCommand\fancysublabel-[3][default]{{%
697 \fancysubreffalse%
698 \fancyref@subrefminustrue%
699 \@fancylabel{##1}{##2}{##3}%
700 }}%
701 \WithSuffix\DeclareRobustCommand\fancysublabel*[3][default]{{%
702 \renewcommand{\@@fancylabel@show}[2]{}%
703 \fancysubreffalse%
704 \fancyref@subrefminusfalse%
705 \@fancylabel{##1}{##2}{##3}%
706 }}%
707 \DeclareRobustCommand\fancysubref[3][default]{{%
708 \fancysubreffalse%
709 \fancyref@subrefminusfalse%
710 \@fancyref{##1}{##2}{##3}%
711 }}%
712 \WithSuffix\DeclareRobustCommand\fancysubref-[3][default]{{%
713 \fancysubreffalse%
714 \fancyref@subrefminustrue%
715 \@fancyref{##1}{##2}{##3}%
716 }}%
717 \WithSuffix\DeclareRobustCommand\fancysubref*[3][default]{{%
718 \renewcommand{\@@fancylabel@show}[2]{}%
719 \fancysubreffalse%
720 \fancyref@subrefminusfalse%
721 \@fancyref{##1}{##2}{##3}%
722 }}%
723 \fi%
724 }{%
725 \PackageError{fancylabel}{This value is not allowed. Allowed values are:%
726 'sub'(default), 'same'.}{}%
727 }
728 \newif\iffancyref@subrefminus\fancyref@subrefminusfalse
729 % \end{macrocode}
730 % \end{macro}
731 % \begin{macro}{IgnoreFamilies=}
732 % \begin{macrocode}
733 \define@boolkey{fancylabel}{IgnoreFamilies}{}
734 % \end{macrocode}
735 % \end{macro}
736 % \begin{macro}{sort=}
737 % \begin{macrocode}
738 \define@boolkey{fancylabel}{sort}{}
739 % \end{macrocode}
740 % \end{macro}
741 % \begin{macro}{compress=}
742 % \begin{macrocode}
743 \define@boolkey{fancylabel}{compress}{}
744 % \end{macrocode}
745 % \end{macro}
746 % \begin{macro}{CompressLink=}
747 % \begin{macrocode}
748 \define@key{fancylabel}{CompressLink}{\def\fancyref@CompressLink{#1}}
749 % \end{macrocode}
750 % \end{macro}
751 % \begin{macro}{CompressTwo=}
752 % \begin{macrocode}
753 \define@boolkey{fancylabel}{CompressTwo}{}
754 % \end{macrocode}
755 % \end{macro}
756 % \begin{macro}{ListLastSublabelOnly=}
757 % \begin{macrocode}
758 \define@boolkey{fancylabel}{ListLastSublabelOnly}{}
759 % \end{macrocode}
760 % \end{macro}
761 % \begin{macro}{ListSeparator=}
762 % \begin{macrocode}
763 \define@key{fancylabel}{ListSeparator}{\edef\fancyref@ListSeparator{#1}}
764 % \end{macrocode}
765 % \end{macro}
766 % \begin{macro}{ListLastLabelSeparator=}
767 % \begin{macrocode}
768 \define@key{fancylabel}{ListLastLabelSeparator}{\edef\fancyref@ListLastLabelSeparator{#1}}
769 % \end{macrocode}
770 % \end{macro}
771 % \begin{macro}{ListLastRefSeparator=}
772 % \begin{macrocode}
773 \define@key{fancylabel}{ListLastRefSeparator}{\edef\fancyref@ListLastRefSeparator{#1}}
774 % \end{macrocode}
775 % \end{macro}
776 % \begin{macro}{DisableFamilyCheck=}
777 % \begin{macrocode}
778 \define@boolkey{fancylabel}{DisableFamilyCheck}{}
779 % \end{macrocode}
780 % \end{macro}
781 % \subsection{Error routines}
782 % \begin{macrocode}
783 % Error routines
784 \newif\iffancyref@rerunerror\fancyref@rerunerrorfalse % ReRun error
785 \newif\iffancysubref\fancysubreffalse % Subref or Ref
786 \AtEndDocument{%
787 \iffancyref@rerunerror%
788 \PackageWarning{fancylabel}{Fancylabels may have changed. %
789 Please run latex again.}%
790 \fi%
791 }
792 \newcommand{\fancyref@labelerror}[2]{%
793 % #1=label
794 % #2=sublabel
795 \ifthenelse{\equal{#2}{}}{%
796 \PackageWarning{fancylabel}{Undefined fancylabel "#1".}%
797 }{%
798 \PackageWarning{fancylabel}{Undefined fancysublabel "#1@#2".}%
799 }%
800 \global\fancyref@rerunerrortrue%
801 }
802 % \end{macrocode}
803 % \subsection{User macros}
804 % \begin{macro}{\fancylabel}
805 % \begin{macrocode}
806 \DeclareRobustCommand\fancylabel[2][default]{{%
807 % #1=family
808 % #2=label or list of labels
809 \fancysubreffalse%
810 \@fancylabel{#1}{#2}{}%
811 }}
812 % \end{macrocode}
813 % \end{macro}
814 % \begin{macro}{\fancylabel*}
815 % \begin{macrocode}
816 \WithSuffix\DeclareRobustCommand\fancylabel*[2][default]{{%
817 % #1=family
818 % #2=label or list of labels
819 \renewcommand{\@@fancylabel@show}[2]{}%
820 \fancysubreffalse%
821 \@fancylabel{#1}{#2}{}%
822 }}
823 % \end{macrocode}
824 % \end{macro}
825 % \begin{macro}{\fancyref}
826 % \begin{macrocode}
827 \DeclareRobustCommand\fancyref[2][default]{{%
828 % #1=family
829 % #2=label or list of labels
830 \@fancyref{#1}{#2}{}%
831 }}
832 % \end{macrocode}
833 % \end{macro}
834 % \begin{macro}{\fancyref*}
835 % \begin{macrocode}
836 \WithSuffix\DeclareRobustCommand\fancyref*[2][default]{{%
837 % #1=family
838 % #2=label or list of labels
839 \renewcommand{\@@fancylabel@show}[2]{}%
840 \@fancyref{#1}{#2}{}%
841 }}
842 % \end{macrocode}
843 % \end{macro}
844 % \begin{macro}{\fancylabelNewLabelEvent}
845 % \begin{macrocode}
846 \newcommand{\fancylabelNewLabelEvent}{}
847 % \end{macrocode}
848 % \end{macro}
849 % \begin{macro}{\fancylabelShowLabelEvent}
850 % \begin{macrocode}
851 \newcommand{\fancylabelShowLabelEvent}{}
852 % \end{macrocode}
853 % \end{macro}
854 % \begin{macro}{\fancylabelShowRefEvent}
855 % \begin{macrocode}
856 \newcommand{\fancylabelShowRefEvent}{}
857 % \end{macrocode}
858 % \end{macro}
859 % \begin{macro}{\fancylabelResetCounter}
860 % \begin{macrocode}
861 \newcommand{\fancylabelResetCounter}[1]{%
862 % #1=family
863 \@ifundefined{fancylabel@familystorage@#1}{%
864 \PackageError{fancylabel}{No fancylabel family '#1' defined.}{}%
865 }{%
866 \@namedef{fancylabel@familystorage@#1}{0}%
867 }%
868 }
869 % \end{macrocode}
870 % \end{macro}
871 % \subsection{Helper macros}
872 % \begin{macro}{\@fancylabel}
873 % \begin{macrocode}
874 \newif\iffancyref@showlabel@FirstSublabelInList%
875 \fancyref@showlabel@FirstSublabelInListtrue%
876 \newcommand{\@fancylabel}[3]{%
877 % #1=family
878 % #2=label or list of labels
879 % #3=sublabel or list of sublabels
880 \@fancylabelANDref{#1}{#2}{#3}%
881 % Define labels
882 \expandafter\fancyref@@sort\expandafter{\@fancylabel@list}{\@@fancylabel@define}%
883 % Print labels
884 \setcounter{fancyref@sort@x}{0}%
885 \expandafter\fancyref@@sort\expandafter{\fancyref@compress@list}{\@@fancylabel@show}%
886 \fancyref@print@list%
887 }
888 % \end{macrocode}
889 % \end{macro}
890 % \begin{macro}{\@fancylabelANDref}
891 % \begin{macrocode}
892 \newcommand{\@fancylabelANDref}[3]{%
893 % #1=family
894 % #2=label or list of labels
895 % #3=sublabel or list of sublabels
896 \def\fancyref@sort@list{}%
897 \def\fancyref@sort@labellist@unsorted{}%
898 \def\fancyref@compress@list{}%
899 \def\fancyref@print@list{}%
900 \ifthenelse{\equal{#3}{}}{%
901 % true => List of labels
902 \newcommand{\@fancylabel@list}{#2}%
903 \newcommand{\@@fancylabel@define}[2]{%
904 % ##1=
905 % ##2=label (from list)
906 \@@@fancylabel@define{#1}{##2}{#3}%
907 }%
908 \newcommand{\@@fancyref@define}[2]{%
909 % ##1=
910 % ##2=label (from list)
911 \@@@fancyref@define{#1}{##2}{#3}%
912 }%
913 \def\fancyref@@@@@sort{%
914 fancyref@PrevRun@#1@\fancyref@@sort@value @%
915 }%
916 \def\fancyref@@@compress{%
917 fancyref@PrevRun@#1@\fancyref@@compress@value @%
918 }%
919 \newcommand{\fancyref@@@compress@entry}{%
920 {#1}{\fancyref@@compress@value}{}%
921 }%
922 }{%
923 % false => List of sublabels
924 \newcommand{\@fancylabel@list}{#3}%
925 \newcommand{\@@fancylabel@define}[2]{%
926 % ##1=
927 % ##2=sublabel (from list)
928 \@@@fancylabel@define{#1}{#2}{##2}%
929 }%
930 \newcommand{\@@fancyref@define}[2]{%
931 % ##1=
932 % ##2=sublabel (from list)
933 \@@@fancyref@define{#1}{#2}{##2}%
934 }%
935 \def\fancyref@@@@@sort{%
936 fancyref@PrevRun@#1@#2@\fancyref@@sort@value%
937 }%
938 \def\fancyref@@@compress{%
939 fancyref@PrevRun@#1@#2@\fancyref@@compress@value%
940 }%
941 \newcommand{\fancyref@@@compress@entry}{%
942 {#1}{#2}{\fancyref@@compress@value}%
943 }%
944 }%
945 % Sort
946 \fancyref@sort{\@fancylabel@list}%
947 % Compress
948 \fancyref@compress{\fancyref@sort@list}%
949 % Add the so far undefined labels to this list
950 \ifthenelse{\equal{\fancyref@sort@labellist@unsorted}{}}{}{%
951 \KV@fancylabel@compressfalse%
952 \fancyref@compress{\fancyref@sort@labellist@unsorted}%
953 \expandafter\fancyref@addtolist\expandafter{\fancyref@sort@labellist@unsorted}%
954 {\fancyref@sort@list}%
955 }%
956 }
957 % \end{macrocode}
958 % \end{macro}
959 % \begin{macro}{\@@@fancylabel@define}
960 % \begin{macrocode}
961 \newcommand{\@@@fancylabel@define}[3]{%
962 % #1=family
963 % #2=label
964 % #3=sublabel
965 \@ifundefined{fancylabel@familystorage@#1}{%
966 \PackageError{fancylabel}{No fancylabel family '#1' defined. %
967 Use package option families for definition.}{}%
968 }{%
969 \@ifundefined{fancyref@ThisRun@#1@#2@#3}{%
970 \fancyref@define@LabelUndef{#1}{#2}{#3}%
971 }{%
972 \fancyref@define@LabelDef{#1}{#2}{#3}%
973 }%
974 }%
975 }
976 % \end{macrocode}
977 % \end{macro}
978 % \begin{macro}{\@@fancylabel@show}
979 % \begin{macrocode}
980 \newcommand{\@@fancylabel@show}[2]{%
981 % #1=
982 % #2={<family>}{<label>}{<sublabel>},{<family>}{<label>}{<sublabel>}
983 \@@fancylabelANDref@show%
984 % Get first and second item
985 \expandafter\fancyref@@sort\expandafter{#2}{\@@fancylabel@@show}%
986 % Produce the output
987 \edef\fancyref@ListLastSeparator{\fancyref@ListLastLabelSeparator}%
988 \@@fancylabelANDref@show@%
989 \expandafter\@@@fancylabel@show\@@fancylabel@@show@begin%
990 \@@fancylabelANDref@show@@%
991 % Add the \fancylabelShowLabelEvent if the label is not empty
992 \ifthenelse{\equal{\fancyref@print@list}{}}{}{%
993 \g@addto@macro{\fancyref@print@list}{\fancylabelShowLabelEvent}%
994 }%
995 }%
996 % \end{macrocode}
997 % \end{macro}
998 % \begin{macro}{\@@fancyref@show}
999 % \begin{macrocode}
1000 \newcommand{\@@fancyref@show}[2]{%
1001 % #1=
1002 % #2={<family>}{<label>}{<sublabel>},{<family>}{<label>}{<sublabel>}
1003 \@@fancylabelANDref@show%
1004 % Get first and second item
1005 \expandafter\fancyref@@sort\expandafter{#2}{\@@fancylabel@@show}%
1006 % Produce the output
1007 \edef\fancyref@ListLastSeparator{\fancyref@ListLastRefSeparator}%
1008 \@@fancylabelANDref@show@%
1009 \expandafter\@@@fancyref@show\@@fancylabel@@show@begin%
1010 \@@fancylabelANDref@show@@%
1011 % Add the \fancylabelShowRefEvent
1012 % Add the \fancylabelShowLabelEvent if the label is not empty
1013 \ifthenelse{\equal{\fancyref@print@list}{}}{}{%
1014 \g@addto@macro{\fancyref@print@list}{\fancylabelShowRefEvent}%
1015 }%
1016 }%
1017 % \end{macrocode}
1018 % \end{macro}
1019 % \begin{macro}{\@@fancylabelANDref@show}
1020 % \begin{macrocode}
1021 \newcommand{\@@fancylabelANDref@show}{%
1022 \edef\@@fancylabel@@show@begin{}%
1023 \edef\@@fancylabel@@show@begin@entry{}%
1024 \edef\@@fancylabel@@show@end{}%
1025 \edef\@@fancylabel@@show@end@entry{}%
1026 \edef\@@fancylabel@@show@entry{}%
1027 }%
1028 % \end{macrocode}
1029 % \end{macro}
1030 % \begin{macro}{\@@fancylabelANDref@show@}
1031 % \begin{macrocode}
1032 \newcommand{\@@fancylabelANDref@show@}{%
1033 \stepcounter{fancyref@sort@x}%
1034 \ifthenelse{\thefancyref@sort@x = \@@fancylabel@@show@LengthOfPrintList}{}{%
1035 % This is the last item of the list
1036 \ifthenelse{\equal{\@@fancylabel@@show@end}{}}{%
1037 \edef\fancyref@ListSeparator{\fancyref@ListLastSeparator}%
1038 }{}%
1039 }%
1040 }%
1041 % \end{macrocode}
1042 % \end{macro}
1043 % \begin{macro}{\@@fancylabelANDref@show@@}
1044 % \begin{macrocode}
1045 \newcommand{\@@fancylabelANDref@show@@}{%
1046 \ifthenelse{\equal{@@fancylabel@@show@entry}{}}{}{%
1047 % \fancyref@showlabel has been executed
1048 % this means a label will be printed
1049 \edef\@@fancylabel@@show@begin@entry{\@@fancylabel@@show@entry}%
1050 \ifthenelse{\equal{\@@fancylabel@@show@end}{}}{}{%
1051 \expandafter\@@@fancylabel@show\@@fancylabel@@show@end%
1052 \edef\@@fancylabel@@show@end@entry{\@@fancylabel@@show@entry}%
1053 }%
1054 % Add to list
1055 \ifthenelse{\equal{\@@fancylabel@@show@end@entry}{}}{%
1056 % No compressing
1057 \edef\fancyref@print@list@entry{\@@fancylabel@@show@begin@entry}%
1058 }{%
1059 % Compressing
1060 \edef\fancyref@print@list@entry{\@@fancylabel@@show@begin@entry%
1061 \fancyref@CompressLink%
1062 \@@fancylabel@@show@end@entry}%
1063 }%
1064 \expandafter\fancyref@addtoprintlist\expandafter{%
1065 \fancyref@print@list@entry%
1066 }{%
1067 \fancyref@print@list%
1068 }%
1069 }%
1070 }%
1071 % \end{macrocode}
1072 % \end{macro}
1073 % \begin{macro}{\@@fancylabel@@show}
1074 % \begin{macrocode}
1075 \newcommand{\@@fancylabel@@show}[2]{%
1076 % #1=
1077 % #2={<family>}{<label>}{<sublabel>}
1078 \ifthenelse{\equal{\@@fancylabel@@show@begin}{}}{%
1079 \edef\@@fancylabel@@show@begin{#2}%
1080 }{%
1081 \edef\@@fancylabel@@show@end{#2}%
1082 }%
1083 }
1084 % \end{macrocode}
1085 % \end{macro}
1086 % \begin{macro}{\@@@fancylabel@show}
1087 % \begin{macrocode}
1088 \newcommand{\@@@fancylabel@show}[3]{%
1089 % #1=family
1090 % #2=label
1091 % #3=sublabel
1092 \@ifundefined{fancylabel@familystorage@#1}{%
1093 \PackageError{fancylabel}{No fancylabel family '#1' defined. %
1094 Use package option families for definition.}{}%
1095 }{%
1096 \@ifundefined{fancyref@ThisRun@#1@#2@#3}{%
1097 \fancyref@show@LabelUndef{#1}{#2}{#3}%
1098 }{%
1099 \fancyref@show@LabelDef{#1}{#2}{#3}%
1100 }%
1101 }%
1102 }
1103 % \end{macrocode}
1104 % \end{macro}
1105 % \begin{macro}{\@@@fancyref@show}
1106 % \begin{macrocode}
1107 \newcommand{\@@@fancyref@show}[3]{%
1108 % #1=family
1109 % #2=label
1110 % #3=sublabel
1111 \@ifundefined{fancylabel@familystorage@#1}{%
1112 \PackageError{fancylabel}{No fancylabel family '#1' defined. %
1113 Use package option families for definition.}{}%
1114 }{%
1115 \@ifundefined{fancyref@ThisRun@#1@#2@#3}{%
1116 \fancyref@show@RefUndef{#1}{#2}{#3}%
1117 }{%
1118 \fancyref@show@RefDef{#1}{#2}{#3}%
1119 }%
1120 }%
1121 }
1122 % \end{macrocode}
1123 % \end{macro}
1124 % \begin{macro}{\@fancyref}
1125 % \begin{macrocode}
1126 \newcommand{\@fancyref}[3]{%
1127 % #1=family
1128 % #2=label or list of labels
1129 % #3=sublabel or list of sublabels
1130 \@fancylabelANDref{#1}{#2}{#3}%
1131 % Define labels
1132 \expandafter\fancyref@@sort\expandafter{\@fancylabel@list}{\@@fancyref@define}%
1133 % Print labels
1134 \setcounter{fancyref@sort@x}{0}%
1135 \expandafter\fancyref@@sort\expandafter{\fancyref@compress@list}{\@@fancyref@show}%
1136 \fancyref@print@list%
1137 }
1138 % \end{macrocode}
1139 % \end{macro}
1140 % \begin{macro}{\@@fancyref}
1141 % \begin{macrocode}
1142 \newcommand{\@@fancyref}[3]{%
1143 % #1=family
1144 % #2=label
1145 % #3=sublabel
1146 \@ifundefined{fancyref@AskedThisRun@#1@#2@#3}{%
1147 \global\@namedef{fancyref@AskedThisRun@#1@#2@#3}{#2}%
1148 \immediate\write\@auxout{%
1149 \string\fancyref@aux{fancyref@AskedPrevRun@#1@#2@#3}{#2}%
1150 }%
1151 }{}%
1152 \@@@fancyref{#1}{#2}{#3}%
1153 }
1154 % \end{macrocode}
1155 % \end{macro}
1156 % \begin{macro}{\@@@fancyref@define}
1157 % \begin{macrocode}
1158 \newcommand{\@@@fancyref@define}[3]{%
1159 % #1=family
1160 % #2=label
1161 % #3=sublabel
1162 \@ifundefined{fancyref@AskedThisRun@#1@#2@#3}{%
1163 \global\@namedef{fancyref@AskedThisRun@#1@#2@#3}{#2}%
1164 \immediate\write\@auxout{%
1165 \string\fancyref@aux{fancyref@AskedPrevRun@#1@#2@#3}{#2}%
1166 }%
1167 }{}%
1168 \@ifundefined{fancyref@PrevRun@#1@#2@#3}{%
1169 \fancyref@define@RefUndef{#1}{#2}{#3}%
1170 }{%
1171 \fancyref@define@RefDef{#1}{#2}{#3}%
1172 }%
1173 }
1174 % \end{macrocode}
1175 % \end{macro}
1176 % \begin{macro}{\fancyref@newlabel}
1177 % \begin{macrocode}
1178 \newcommand{\fancyref@newlabel}[3]{%
1179 % #1=family
1180 % #2=label
1181 % #3=sublabel
1182 \@ifundefined{fancyref@ThisRun@#1@#2@#3}{%
1183 \ifKV@fancylabel@DisableFamilyCheck%
1184 \else%
1185 \expandafter\fancyref@CheckOtherFamilies%
1186 \expandafter{\fancyref@ListOfFamilies}{#1}{#2}%
1187 \iffancyref@@@@CheckOtherFamilies@error%
1188 \PackageWarning{fancylabel}{Label '#2' has been used in %
1189 multiple families.}%
1190 \fi%
1191 \fi%
1192 % Subref or Ref
1193 \iffancysubref% Subref
1194 \fancyref@@newsublabel{#1}{#2}{#3}%
1195 \else% Ref
1196 \fancyref@@newlabel{#1}{#2}{#3}%
1197 \fi%
1198 }{}%
1199 % Show Package Warning if labels have changed since the last run
1200 \@ifundefined{fancyref@PrevRun@#1@#2@#3}{%
1201 \global\fancyref@rerunerrortrue%
1202 }{%
1203 \ifthenelse{\equal{\@nameuse{fancyref@ThisRun@#1@#2@#3}}%
1204 {\@nameuse{fancyref@PrevRun@#1@#2@#3}}}{}{%
1205 \global\fancyref@rerunerrortrue%
1206 }%
1207 }%
1208 }
1209 % \end{macrocode}
1210 % \end{macro}
1211 % \begin{macro}{\fancyref@@newlabel}
1212 % \begin{macrocode}
1213 \newcommand{\fancyref@@newlabel}[3]{%
1214 % #1=family
1215 % #2=label
1216 % #3=sublabel
1217 \ifKV@fancylabel@IgnoreFamilies%
1218 \setcounter{fancylabel}{\@nameuse{fancylabel@familystorage@default}}%
1219 \stepcounter{fancylabel}%
1220 \expandafter\xdef\csname fancylabel@familystorage@default\endcsname{\thefancylabel}%
1221 \else%
1222 \setcounter{fancylabel}{\@nameuse{fancylabel@familystorage@#1}}%
1223 \stepcounter{fancylabel}%
1224 \expandafter\xdef\csname fancylabel@familystorage@#1\endcsname{\thefancylabel}%
1225 \fi%
1226 \immediate\write\@auxout{%
1227 \string\fancyref@aux{fancyref@PrevRun@#1@#2@#3}{\thefancylabel}%
1228 }%
1229 \immediate\write\@auxout{%
1230 \string\fancyref@addtolist{\string{#2\string}}{\string\fancylabel@list@#1}%
1231 }%
1232 \expandafter\xdef\csname fancyref@ThisRun@#1@#2@#3\endcsname{\thefancylabel}%
1233 % Uses specified Event following the newlabel command
1234 \fancylabelNewLabelEvent%
1235 }
1236 % \end{macrocode}
1237 % \end{macro}
1238 % \begin{macro}{\fancyref@@newsublabel}
1239 % \begin{macrocode}
1240 \newcommand{\fancyref@@newsublabel}[3]{%
1241 % #1=family
1242 % #2=label
1243 % #3=sublabel
1244 \@ifundefined{fancyref@ThisRun@#1@#2@}{%
1245 \fancyref@@newlabel{#1}{#2}{}%
1246 }{}%
1247 \@ifundefined{fancyref@highestsub@#1@#2}{%
1248 \setcounter{fancysublabel}{0}%
1249 }{%
1250 \setcounter{fancysublabel}{\@nameuse{fancyref@highestsub@#1@#2}}%
1251 }%
1252 \stepcounter{fancysublabel}%
1253 \immediate\write\@auxout{%
1254 \string\fancyref@aux{fancyref@PrevRun@#1@#2@#3}{\thefancysublabel}%
1255 }%
1256 \expandafter\xdef\csname fancyref@ThisRun@#1@#2@#3\endcsname{\thefancysublabel}%
1257 \expandafter\xdef\csname fancyref@highestsub@#1@#2\endcsname{\thefancysublabel}%
1258 }
1259 % \end{macrocode}
1260 % \end{macro}
1261 % \begin{macro}{\fancyref@showlabel}
1262 % \begin{macrocode}
1263 \newcommand{\fancyref@showlabel}[3]{%
1264 % #1=family
1265 % #2=label
1266 % #3=sublabel
1267 \iffancysubref% \fancysubref and level=sub
1268 \@ifundefined{fancyref@PrevRun@#1@#2@}{%
1269 \fancyref@rerunerrortrue%
1270 }{%
1271 \setcounter{fancylabel}{\@nameuse{fancyref@PrevRun@#1@#2@}}%
1272 }%
1273 \@ifundefined{fancyref@PrevRun@#1@#2@#3}{%
1274 \fancyref@rerunerrortrue%
1275 }{%
1276 \setcounter{fancysublabel}{\@nameuse{fancyref@PrevRun@#1@#2@#3}}%
1277 }%
1278 \iffancyref@subrefminus% minus => only subref without ref
1279 \ifKV@fancylabel@IgnoreFamilies%
1280 \edef\fancylabelthisformat{\@nameuse{fancyonlysublabelformatdefault}}%
1281 \else%
1282 \edef\fancylabelthisformat{\@nameuse{fancyonlysublabelformat#1}}%
1283 \fi%
1284 \else% Label and Sublabel
1285 \iffancyref@showlabel@FirstSublabelInList%
1286 % This is the very first label
1287 \ifKV@fancylabel@IgnoreFamilies%
1288 \edef\fancylabelthisformat{\@nameuse{fancysublabelformatdefault}}%
1289 \else%
1290 \edef\fancylabelthisformat{\@nameuse{fancysublabelformat#1}}%
1291 \fi%
1292 \fancyref@showlabel@FirstSublabelInListfalse%
1293 \else%
1294 % Any label after the first one
1295 \ifKV@fancylabel@ListLastSublabelOnly%
1296 % Output: 1a-c,d
1297 \ifKV@fancylabel@IgnoreFamilies%
1298 \edef\fancylabelthisformat{\@nameuse{fancyonlysublabelformatdefault}}%
1299 \else%
1300 \edef\fancylabelthisformat{\@nameuse{fancyonlysublabelformat#1}}%
1301 \fi%
1302 \else%
1303 % Output: 1a-1c,1d
1304 \ifKV@fancylabel@IgnoreFamilies%
1305 \edef\fancylabelthisformat{\@nameuse{fancysublabelformatdefault}}%
1306 \else%
1307 \edef\fancylabelthisformat{\@nameuse{fancysublabelformat#1}}%
1308 \fi%
1309 \fi%
1310 \fi%
1311 \fi%
1312 \else% \fancyref or \fancysubref and level=same
1313 \@ifundefined{fancyref@PrevRun@#1@#2@#3}{%
1314 \fancyref@rerunerrorfalse%
1315 }{%
1316 \setcounter{fancylabel}{\@nameuse{fancyref@PrevRun@#1@#2@#3}}%
1317 }%
1318 \ifKV@fancylabel@IgnoreFamilies%
1319 \edef\fancylabelthisformat{\@nameuse{fancylabelformatdefault}}%
1320 \else%
1321 \edef\fancylabelthisformat{\@nameuse{fancylabelformat#1}}%
1322 \fi%
1323 \fi%
1324 \edef\@@fancylabel@@show@entry{\fancylabelthisformat}%
1325 }
1326 % \end{macrocode}
1327 % \end{macro}
1328 % \begin{macro}{\fancyref@CheckOtherFamilies}
1329 % \begin{macrocode}
1330 \newcommand{\fancyref@CheckOtherFamilies}[3]{%
1331 % #1=list of families
1332 % #2=current family
1333 % #3=label
1334 \fancyref@foreach{\fancyref@@CheckOtherFamilies{#3}}{#2}{#1}%
1335 }
1336 % \end{macrocode}
1337 % \end{macro}
1338 % \begin{macro}{\fancyref@@CheckOtherFamilies}
1339 % \begin{macrocode}
1340 \newcommand{\fancyref@@CheckOtherFamilies}[3]{%
1341 % #1=label
1342 % #2=current family
1343 % #3=family (from list)
1344 \xdef\fancyref@helper{\csname fancylabel@list@#3\endcsname}%
1345 \ifthenelse{\equal{#2}{#3}}{}{%
1346 \expandafter\fancyref@@@CheckOtherFamilies\expandafter{\fancyref@helper}{#1}%
1347 }%
1348 }
1349 % \end{macrocode}
1350 % \end{macro}
1351 % \begin{macro}{\fancyref@@@CheckOtherFamilies}
1352 % \begin{macrocode}
1353 \newcommand{\fancyref@@@CheckOtherFamilies}[2]{%
1354 % #1=list of labels
1355 % #2=label
1356 \fancyref@foreach{\fancyref@@@@CheckOtherFamilies}{#2}{#1}%
1357 }
1358 % \end{macrocode}
1359 % \end{macro}
1360 % \begin{macro}{\fancyref@@@@CheckOtherFamilies}
1361 % \begin{macrocode}
1362 \newif\iffancyref@@@@CheckOtherFamilies@error
1363 \fancyref@@@@CheckOtherFamilies@errorfalse
1364 \newcommand{\fancyref@@@@CheckOtherFamilies}[2]{%
1365 % #1=label
1366 % #2=label (from list)
1367 \ifthenelse{\equal{#1}{#2}}{%
1368 \fancyref@@@@CheckOtherFamilies@errortrue%
1369 }{}%
1370 }
1371 % \end{macrocode}
1372 % \end{macro}
1373 % \begin{macro}{\fancyref@aux}
1374 % \begin{macrocode}
1375 \newcommand{\fancyref@aux}[2]{% Helps to read the aux file
1376 \global\@namedef{#1}{#2}%
1377 }
1378 % \end{macrocode}
1379 % \end{macro}
1380 % \begin{macro}{\fancyref@foreach}
1381 % \begin{macrocode}
1382 %%% Thanks to
1383 %%% http://stackoverflow.com/questions/2402354/split-comma-separated-parameters-in-latex
1384 % Functional foreach construct
1385 % #1 - Function to call on each comma-separated item in #3
1386 % #2 - Parameter to pass to function in #1 as first parameter
1387 % #3 - Comma-separated list of items to pass as second parameter to function #1
1388 \def\fancyref@foreach#1#2#3{%
1389 \fancyref@@test@foreach{#1}{#2}#3,\@end@token%
1390 }
1391
1392 % Internal helper function - Eats one input
1393 \def\fancyref@@swallow#1{}
1394
1395 % Internal helper function - Checks the next character after #1 and #2 and
1396 % continues loop iteration if \@end@token is not found
1397 \def\fancyref@@test@foreach#1#2{%
1398 \@ifnextchar\@end@token%
1399 {\fancyref@@swallow}%
1400 {\fancyref@@foreach{#1}{#2}}%
1401 }
1402
1403 % Internal helper function - Calls #1{#2}{#3} and recurses
1404 % The magic of splitting the third parameter occurs in the pattern matching of the \def
1405 \def\fancyref@@foreach#1#2#3,#4\@end@token{%
1406 #1{#2}{#3}%
1407 \fancyref@@test@foreach{#1}{#2}#4\@end@token%
1408 }
1409 % \end{macrocode}
1410 % \end{macro}
1411 % \begin{macrocode}
1412 \newcounter{fancyref@sort@x}
1413 \setcounter{fancyref@sort@x}{0}
1414 \newcounter{fancyref@sort@y}
1415 \setcounter{fancyref@sort@y}{0}
1416 % \end{macrocode}
1417 % \begin{macro}{\fancyref@sort}
1418 % \begin{macrocode}
1419 \newcommand{\fancyref@sort}[1]{%
1420 % #1=comma-separated list of labels or sublabels
1421 \ifKV@fancylabel@sort%
1422 % Generate a list of all values
1423 \def\fancyref@sort@valuelist@sorted{}%
1424 \setcounter{fancyref@sort@x}{0}%
1425 \expandafter\fancyref@@sort\expandafter{#1}{\fancyref@@@sort}%
1426 % Generate a sorted list of values
1427 \edef\fancyref@sort@arraylength{\thefancyref@sort@x}%
1428 \setcounter{fancyref@sort@x}{0}%
1429 \whiledo{\thefancyref@sort@x < \fancyref@sort@arraylength}{%
1430 \setcounter{fancyref@sort@y}{0}%
1431 % Set \fancyref@sort@smallest@temp the first list entry that is not 0
1432 \whiledo{\thefancyref@sort@y < \fancyref@sort@arraylength}{%
1433 \ifthenelse{\@nameuse{fancyref@sort@valuelist@\thefancyref@sort@y} = 0}{%
1434 \stepcounter{fancyref@sort@y}%
1435 }{%
1436 \edef\fancyref@sort@smallest@temp{\thefancyref@sort@y}%
1437 \setcounter{fancyref@sort@y}{\fancyref@sort@arraylength}%
1438 }%
1439 }%
1440 \setcounter{fancyref@sort@y}{0}%
1441 % Find the smallest value in the list
1442 \whiledo{\thefancyref@sort@y < \fancyref@sort@arraylength}{%
1443 \ifthenelse{\@nameuse{fancyref@sort@valuelist@\thefancyref@sort@y} = 0}{}{%
1444 \ifthenelse{\@nameuse{fancyref@sort@valuelist@\thefancyref@sort@y} < %
1445 \@nameuse{fancyref@sort@valuelist@\fancyref@sort@smallest@temp}}{%
1446 \edef\fancyref@sort@smallest@temp{\thefancyref@sort@y}%
1447 }{}%
1448 }%
1449 \stepcounter{fancyref@sort@y}%
1450 }%
1451 % Add this smallest value to the list
1452 \edef\fancyref@sort@smallest{%
1453 \@nameuse{fancyref@sort@valuelist@\fancyref@sort@smallest@temp}%
1454 }%
1455 \expandafter\fancyref@addtolist\expandafter{\fancyref@sort@smallest}%
1456 {\fancyref@sort@valuelist@sorted}%
1457 \expandafter\edef\csname fancyref@sort@valuelist@\fancyref@sort@smallest@temp\endcsname{0}%
1458 \stepcounter{fancyref@sort@x}%
1459 }%
1460 % Generate a sorted list of labels
1461 \ifthenelse{\equal{\fancyref@sort@valuelist@sorted}{}}{}{%
1462 \expandafter\fancyref@@sort\expandafter{\fancyref@sort@valuelist@sorted}{\fancyref@@@@sort}%
1463 }%
1464 \else%
1465 \expandafter\fancyref@addtolist\expandafter{#1}{\fancyref@sort@list}%
1466 \fi%
1467 }
1468 % \end{macrocode}
1469 % \end{macro}
1470 % \begin{macro}{\fancyref@@sort}
1471 % \begin{macrocode}
1472 \newcommand{\fancyref@@sort}[2]{%
1473 % #1=comma-separated list
1474 % #2=function to be executed on this list
1475 \fancyref@foreach{#2}{}{#1}%
1476 }
1477 % \end{macrocode}
1478 % \end{macro}
1479 % \begin{macro}{\fancyref@@@sort}
1480 % \begin{macrocode}
1481 \newcommand{\fancyref@@@sort}[2]{%
1482 % #1=
1483 % #2=label (from list)
1484 \def\fancyref@@sort@value{#2}%
1485 \@ifundefined{\fancyref@@@@@sort}{%
1486 \fancyref@addtolist{#2}{\fancyref@sort@labellist@unsorted}%
1487 }{%
1488 \expandafter\edef\csname fancyref@sort@labellist@\@nameuse{\fancyref@@@@@sort}\endcsname{#2}%
1489 \expandafter\edef\csname fancyref@sort@valuelist@\thefancyref@sort@x\endcsname{%
1490 \@nameuse{\fancyref@@@@@sort}%
1491 }%
1492 \stepcounter{fancyref@sort@x}%
1493 }%
1494 }%
1495 % \end{macrocode}
1496 % \end{macro}
1497 % \begin{macro}{\fancyref@@@@sort}
1498 % \begin{macrocode}
1499 \newcommand{\fancyref@@@@sort}[2]{%
1500 % #1=
1501 % #2=value (from sorted list of values)
1502 \fancyref@addtolist{\@nameuse{fancyref@sort@labellist@#2}}{\fancyref@sort@list}%
1503 }
1504 % \end{macrocode}
1505 % \end{macro}
1506 % \begin{macro}{\fancyref@compress}
1507 % \begin{macrocode}
1508 \newcommand{\fancyref@compress}[1]{%
1509 % #1=list of labels or sublabels
1510 \def\fancyref@compress@begin{}%
1511 \def\fancyref@compress@begin@entry{}%
1512 \def\fancyref@compress@end{}%
1513 \def\fancyref@compress@end@entry{}%
1514 \setcounter{fancyref@sort@y}{0}%
1515 \ifKV@fancylabel@compress%
1516 \ifthenelse{\equal{#1}{}}{}{%
1517 % Compress List
1518 \expandafter\fancyref@@sort\expandafter{#1}{\fancyref@@compress}%
1519 % Add last entry
1520 \fancyref@@@@compress@stop%
1521 }%
1522 \else%
1523 \expandafter\fancyref@@sort\expandafter{#1}{\fancyref@@nocompress}%
1524 \fi%
1525 \edef\@@fancylabel@@show@LengthOfPrintList{\thefancyref@sort@y}%
1526 }
1527 % \end{macrocode}
1528 % \end{macro}
1529 % \begin{macro}{\fancyref@@compress}
1530 % \begin{macrocode}
1531 \newcommand{\fancyref@@compress}[2]{%
1532 % #1=
1533 % #2=value (from sorted list of values)
1534 \def\fancyref@@compress@value{#2}%
1535 \ifthenelse{\equal{\fancyref@compress@begin}{}}{%
1536 % Start compressing
1537 \fancyref@@@@compress@start%
1538 }{%
1539 \stepcounter{fancyref@sort@x}%
1540 \ifthenelse{\@nameuse{\fancyref@@@compress} = \thefancyref@sort@x}{%
1541 % Continue compressing
1542 \fancyref@@@@compress@continue%
1543 }{%
1544 % Stop compressing and begin a new compressing
1545 \fancyref@@@@compress@stop%
1546 }%
1547 }%
1548 }
1549 % \end{macrocode}
1550 % \end{macro}
1551 % \begin{macro}{\fancyref@@@@compress@start}
1552 % \begin{macrocode}
1553 \newcommand{\fancyref@@@@compress@start}{%
1554 \edef\fancyref@compress@begin{\fancyref@@@compress}%
1555 \edef\fancyref@compress@begin@entry{\fancyref@@@compress@entry}%
1556 \setcounter{fancyref@sort@x}{\@nameuse{\fancyref@compress@begin}}%
1557 }
1558 % \end{macrocode}
1559 % \end{macro}
1560 % \begin{macro}{\fancyref@@@@compress@continue}
1561 % \begin{macrocode}
1562 \newcommand{\fancyref@@@@compress@continue}{%
1563 \edef\fancyref@compress@end{\fancyref@@@compress}%
1564 \edef\fancyref@compress@end@entry{\fancyref@@@compress@entry}%
1565 }
1566 % \end{macrocode}
1567 % \end{macro}
1568 % \begin{macro}{\fancyref@@@@compress@stop}
1569 % \begin{macrocode}
1570 \newcommand{\fancyref@@@@compress@stop}{%
1571 \ifKV@fancylabel@CompressTwo%
1572 % Compress even if difference is only 1
1573 \edef\fancyref@compress@listentry{{{\fancyref@compress@begin@entry},{\fancyref@compress@end@entry}}}%
1574 \expandafter\fancyref@addtolist\expandafter{\fancyref@compress@listentry}{\fancyref@compress@list}%
1575 \else%
1576 % Compress if difference > 1
1577 \setcounter{fancyref@sort@x}{\@nameuse{\fancyref@compress@begin}}%
1578 \stepcounter{fancyref@sort@x}%
1579 % Avoid empty \fancyref@compress@end
1580 \ifthenelse{\equal{\fancyref@compress@end}{}}{%
1581 \edef\fancyref@compress@listentry{{{\fancyref@compress@begin@entry},{\fancyref@compress@end@entry}}}%
1582 \expandafter\fancyref@addtolist\expandafter{\fancyref@compress@listentry}{\fancyref@compress@list}%
1583 }{%
1584 \ifthenelse{\@nameuse{\fancyref@compress@end} = \thefancyref@sort@x}{%
1585 % Difference = 1
1586 \edef\fancyref@compress@listentry{{{\fancyref@compress@begin@entry},{}}}%
1587 \expandafter\fancyref@addtolist\expandafter{\fancyref@compress@listentry}{\fancyref@compress@list}%
1588 \edef\fancyref@compress@listentry{{{\fancyref@compress@end@entry},{}}}%
1589 \expandafter\fancyref@addtolist\expandafter{\fancyref@compress@listentry}{\fancyref@compress@list}%
1590 }{%
1591 % Difference > 1
1592 \edef\fancyref@compress@listentry{%
1593 {{\fancyref@compress@begin@entry},{\fancyref@compress@end@entry}}%
1594 }%
1595 \expandafter\fancyref@addtolist\expandafter{\fancyref@compress@listentry}{\fancyref@compress@list}%
1596 }%
1597 }%
1598 \fi%
1599 \edef\fancyref@compress@begin{\fancyref@@@compress}%
1600 \edef\fancyref@compress@begin@entry{\fancyref@@@compress@entry}%
1601 \edef\fancyref@compress@end{}%
1602 \edef\fancyref@compress@end@entry{}%
1603 \setcounter{fancyref@sort@x}{\@nameuse{\fancyref@compress@begin}}%
1604 \stepcounter{fancyref@sort@y}%
1605 }
1606 % \end{macrocode}
1607 % \end{macro}
1608 % \begin{macro}{\fancyref@@nocompress}
1609 % \begin{macrocode}
1610 \newcommand{\fancyref@@nocompress}[2]{%
1611 % #1=
1612 % #2=value (from sorted list of values)
1613 \stepcounter{fancyref@sort@y}%
1614 \def\fancyref@@compress@value{#2}%
1615 \edef\fancyref@compress@listentry{{{\fancyref@@@compress@entry},{}}}%
1616 \expandafter\fancyref@addtolist\expandafter{\fancyref@compress@listentry}{\fancyref@compress@list}%
1617 }
1618 % \end{macrocode}
1619 % \end{macro}
1620 % \begin{macrocode}
1621 \ProcessOptionsX<fancylabel>
1622 % \end{macrocode}
1623 %
1624 %
1625 \endinput
1626 % \Finale