Debian Codegraph @

texmf-dist/source/latex/tools/varioref.dtx

raw
1 % \iffalse meta-comment
2 %
3 % Copyright (C) 1993-2025
4 %
5 % The LaTeX Project and any individual authors listed elsewhere
6 % in this file.
7 %
8 % This file is part of the Standard LaTeX `Tools Bundle'.
9 % -------------------------------------------------------
10 %
11 % It may be distributed and/or modified under the
12 % conditions of the LaTeX Project Public License, either version 1.3c
13 % of this license or (at your option) any later version.
14 % The latest version of this license is in
15 % https://www.latex-project.org/lppl.txt
16 % and version 1.3c or later is part of all distributions of LaTeX
17 % version 2008 or later.
18 %
19 % The list of all files belonging to the LaTeX `Tools Bundle' is
20 % given in the file `manifest.txt'.
21 %
22 % \fi
23 % \iffalse
24 %% Package varioref to use with LaTeX2e
25 %% Copyright (C) 1992-2020 Frank Mittelbach, all rights reserved.
26 %%
27 %% For additions or updates to the language options please contact
28 %% the author at
29 %%
30 %% [email protected]
31 %%
32 %% or open an issue at https://github.com/latex3/latex2e.
33 %%
34 %
35 %<package>\NeedsTeXFormat{LaTeX2e}[1995/05/16]
36 %<package>
37 %
38 % For any rollback before 2019 load the 2016 version and hope for the best:
39 %<package>\DeclareRelease{}{1994-06-01}{varioref-2016-02-16.sty}
40 %<package>\DeclareRelease{}{2016-02-16}{varioref-2016-02-16.sty}
41 %<package>\DeclareCurrentRelease{}{2019-10-01}
42 %<package>
43 %<package>\ProvidesPackage{varioref}
44 %<package> [2025/01/14 v1.6g package for extended references (FMi)]
45 % \fi
46 %
47 %%
48 %
49 %
50 % \changes{v1.0a}{1993/12/06}{Upgrade to LaTeX2e}
51 % \changes{v1.0g}{1994/05/27}{Use \cmd\DeclareRobustCommand}
52 % \changes{v1.5c}{2016/02/09}{Revamped some of the documentation to better
53 % explain how varioref could be used in a multi-lingual context}
54 % \changes{v1.6a}{2019/08/25}{\cs{labelformat} and \cs{Ref} now available in the kernel
55 % so removed from this package but only in new kernel}
56 %
57 %
58 % \newcommand\NewIn[1]{\marginpar{\fbox{\fbox{\sffamily\tabular{l}New
59 % in\\#1\endtabular}}}}
60 % \newcommand\ChangedIn[1]{\marginpar{\fbox{\fbox{\sffamily\tabular{l}Changed
61 % in\\#1\endtabular}}}}
62 %
63 % \providecommand\pkg[1]{\texttt{#1}}
64 % \providecommand\option[1]{\texttt{#1}}
65 % \providecommand\meta[1]{$\langle§\textit{#1}$\rangle$}
66 %
67 %
68 % \makeatletter
69 % \def\allowtofu{^^A
70 %\def\UTFviii@undefined@err##1{^^A
71 % \PackageWarning{inputenc}{Unicode character \expandafter
72 % \UTFviii@splitcsname\string##1\relax
73 % \MessageBreak
74 % not set up for use with LaTeX -- ignored}^^A
75 % \raisebox{.8pt}{\fboxsep1pt\kern.1pt\fbox{$\cdot$}\kern.1pt}^^A
76 % }}
77 % \makeatother
78 %
79 % \title{The \pkg{varioref} package\thanks{This file
80 % has version number \fileversion, last
81 % revised \filedate.}}
82 % \author{Frank Mittelbach}
83 % \date{\filedate}
84 %
85 % \MaintainedByLaTeXTeam{tools}
86 % \maketitle
87 %
88 %
89 % \begin{abstract}
90 % This package defines the commands |\vref|, |\vpageref|,
91 % |\vrefrange|, and |\vpagerefrange| for
92 % \LaTeXe. |\vref| is similar to |\ref| but adds an additional
93 % page reference, like `on the facing page' or `on page 27' whenever
94 % the corresponding |\label| is not on the same page. The command
95 % |\vpageref| is a variation to |\pageref| with a similar
96 % functionality. The |\v...range| commands take two labels as arguments
97 % and produce strings which depend on whether or not these labels
98 % fall onto a single page or on different pages.
99 % Generated strings are customizable so that these
100 % commands are usable with various languages.
101 % \end{abstract}
102 %
103 %
104 % \columnsep=2\columnsep
105 % \begin{multicols}{2}
106 % \tableofcontents
107 % \end{multicols}
108 %
109 % \section{Introduction}
110 %
111 % In many cases it is helpful when referring to a figure or table to
112 % put both a |\ref| and a |\pageref| command into the document
113 % especially when there are one or more pages between the reference
114 % and the object. Therefore some people use a command like
115 % \begin{verbatim}
116 % \newcommand{\fullref}[1]{\ref{#1} on page~\pageref{#1}}
117 %\end{verbatim}
118 % which reduces the number of key strokes, necessary to make such a
119 % complete reference. But since one never knows where the referenced
120 % object finally falls, using such a device may result in a page
121 % reference to the current page which is disturbing and therefore
122 % should be avoided.
123 %
124 %
125 %
126 % \section{Loading the package}
127 %
128 %
129 % The suggested way of loading the package these days is by
130 % \emph{always} using
131 % the package option \option{nospace},
132 % \NewIn{2019}
133 % i.e.,
134 % \begin{verbatim}
135 % \usepackage[nospace]{varioref}
136 %\end{verbatim}
137 % See below for an explanation of why this is needed. There are some
138 % other options that you may want to use additionally; they are
139 % explained \vpageref{options}.
140 %
141 %
142 %
143 % \section{The user interface}
144 %
145 %\DescribeMacro\vref The implementation of |\vref| below produces only
146 % a |\ref| when reference and |\label| are on the same page. It will
147 % additionally produce one of the strings `on the facing page', `on
148 % the preceding page', or `on the following page' if label and
149 % reference differ by one; and it will produce both |\ref| and
150 % |\pageref| when the difference is larger. The word `facing' is used
151 % when label and reference both fall onto a double spread. However,
152 % if a special page numbering scheme is used instead of the usual
153 % Arabic numbering (e.g., |\pagenumbering{roman}|) then there will be
154 % no distinction between one or many pages off.
155 %
156 %\DescribeMacro\vpageref Sometimes one wants to refer only to page
157 % number and again such a reference should normally be suppressed if
158 % we are referring to the current page. For this purpose the package
159 % defines the |\vpageref| command. It will produce the same strings as
160 % |\vref| except that it doesn't start with the |\ref|. A further
161 % difference is that
162 % it will produce the string that is saved in |\reftextcurrent| if
163 % label and reference fall onto the same page (and no optional
164 % argument is used). By defining
165 % |\reftextcurrent| to produce ``on this page'' or something similar,
166 % we can avoid that
167 % \begin{verbatim}
168 % ... see the example \vpageref{ex:foo} which shows ...
169 %\end{verbatim}
170 % comes out as ``\ldots~see the example which shows~\ldots'', which
171 % could be misleading.
172 %
173 % A space in front of |\vpageref| will be ignored if
174 % the command doesn't produce any text at all.
175 %
176 % But in fact |\vpageref| allows even more control. It has two
177 % optional arguments. With the first one, one can specify the text
178 % that should be used if label and reference fall on the same page.
179 % This is very helpful if both are near to each other, so that they
180 % may or may not be separated by a page break. In such a case we
181 % usually know (!) whether the reference is before or after the label
182 % so that we can say something like
183 % \begin{verbatim}
184 % ... see the example \vpageref[above]{ex:foo} which shows ...
185 %\end{verbatim}
186 % which will then come out as ``\ldots~see the example above which
187 % shows~\ldots'' if we are still on the same page, but as ``\ldots~see
188 % the example on the page before which shows~\ldots'' (or something
189 % similar depending on the settings of the |\reftext..before|
190 % commands) when there was a page break in the meantime. One warning
191 % however, if you use |\vpageref| with the optional argument to refer
192 % to a figure or table, keep in mind that depending on the float
193 % placement parameters the float may show up on top of the current
194 % page and therefore before the reference even if it came after it in
195 % the source file.
196 %
197 % But maybe you prefer to say ``\ldots~see the above example'' if
198 % example and reference fall onto the same page, i.e., reverse the
199 % word order. In fact, in some languages the word order automatically
200 % changes in that case. To allow for this variation the second
201 % optional argument can be used. It specifies the text preceding the
202 % generated reference if object and reference do not fall onto the
203 % same page. Thus one would write
204 % \begin{verbatim}
205 % ... see the \vpageref[above example][example]{ex:foo}
206 % which shows ...
207 %\end{verbatim}
208 % to achieve the desired effect.
209 %
210 %
211 % \DescribeMacro\vrefrange
212 % This command is similar to |\vref| but it
213 % takes two mandatory arguments denoting a range to refer to (e.g., a
214 % sequence of figures or a sequence of equations, etc.). So if
215 % |fig:a| is your first figure in the sequence and |fig:c| your last
216 % you can write
217 %\begin{verbatim}
218 % ... see figures \vrefrange{fig:a}{fig:c} ...
219 %\end{verbatim}
220 % which would then be formatted as
221 % \begin{quote}
222 % \ldots\ see figures 3.4 to 3.6 on pages 23--24 \ldots
223 % \end{quote}
224 % or, if they happen to all fall onto the next page, as
225 % \begin{quote}
226 % \ldots\ see figures 3.4 to 3.6 on the following page \ldots
227 % \end{quote}
228 % i.e., the command is deciding what to say depending on where the two
229 % labels are placed in relation to each other; it is essentially
230 % implemented using |\vpagerefrange| described below.
231 % The optional argument the command may take is the text to use in case
232 % both labels are placed on the current page.
233 %
234 %
235 % \DescribeMacro\vpagerefrange This command is similar to |\vpageref|
236 % but takes two mandatory arguments which are two labels denoting a
237 % range. If both labels fall onto the same page, the command acts
238 % exactly like |\vpageref| (with a single label), otherwise it produces
239 % something like ``on pages~15--18'' (see customization possibilities
240 % below). The optional argument it may take is the text to use in case
241 % both labels are placed on the current page.
242
243 % \DescribeMacro\vrefpagenum This macro is provided to allow the user
244 % to write their own small commands which implement functions similar
245 % to those provided by the two previous commands. It takes two
246 % arguments: the second is a label (i.e., as used in |\label| or
247 % |\ref|) and the first is an arbitrary command name (make sure you
248 % use our own) that receives the page number related to this label.
249 % So if you have two (or more) labels you could retrieve their page
250 % numbers, compare them and then decide what to print. For example,
251 % the following not very serious definition (also using the
252 % \pkg{ifthen} package)
253 %\begin{verbatim}
254 % \newcommand\amusingversion[2]{the definition%
255 % \vrefpagenum\firstnum{#1}%
256 % \vrefpagenum\secondnum{#2}%
257 % \ifthenelse{\equal\firstnum\secondnum}%
258 % {s of \ref{#1} and \ref{#2} \vpageref{#1}}%
259 % { of \ref{#1} \vpageref{#1} and of \ref{#2} \vpageref{#2}}%
260 % }
261 %
262 % ...\amusingversion{foo}{bar}
263 %\end{verbatim}
264 % will print something like
265 % \begin{quote}
266 % \ldots the definitions of 3 and 4 on the previous page
267 % \end{quote}
268 % in the case both labels are on the same page but something like
269 % \begin{quote}
270 % \ldots the definition of 3 on the next page and of 4 on page~13
271 % \end{quote}
272 % in case they are on different pages.
273 %
274 % \DescribeMacro\vpagerefcompare
275 % \NewIn{2019}
276 % For this kind of application the package also provides
277 % |\vpagerefcompare| as a command that takes four arguments: two labels
278 % for comparison and a \meta{true} and \meta{false} argument. One of them
279 % is executed depending on whether the two labels are on the same page
280 % or on different pages. With its help the above definition could be
281 % shortened to
282 %\begin{verbatim}
283 % \newcommand\amusingversion[2]{the definition%
284 % \vpagerefcompare{#1}{#2}%
285 % {s of \ref{#1} and \ref{#2} \vpageref{#1}}%
286 % { of \ref{#1} \vpageref{#1} and of \ref{#2} \vpageref{#2}}%
287 % }
288 %\end{verbatim}
289 % and you don't have to load the \pkg{ifthen} package any longer to
290 % make it work.
291 %
292 % \DescribeMacro\vpagerefnearby
293 % \NewIn{2019}
294 % Another command for conditional processing is |\vpagerefnearby|. It
295 % takes three arguments: a label and a \meta{true} and \meta{false}
296 % argument. It compares the page reference to the label with the
297 % current page number; if each of these is a positive integer
298 % (expressed in Arabic numerals) and they differ by at most
299 % $\pm1$, the \meta{true} argument is executed, otherwise the
300 % \meta{false} argument. In other words it tells you if a |\vpageref|
301 % to the label would result in a textual reference to the previous,
302 % current or next page.\footnote{There is also a
303 % \cs{vpagerefcomparenearby} but this is only meant for package
304 % writers, so it is only documented in the implementation section.}
305
306 %
307 %
308 % If you don't use the \texttt{nospace} option the user commands
309 % |\vref|, |\vpageref|, and |\vpagerefrange| all work by first
310 % removing any space on their left and then inserting some space of
311 % their own (|\vref|, for example, a nonbreakable space). That seemed
312 % like a good idea back then, but it has the disadvantage that you
313 % can't use these macros in situations where you definitely do not
314 % want any space before the generated text. E.g., in situations like
315 % |(\vref{foo} ...)| you end up with a space after the open
316 % parenthesis.
317 %
318 % \DescribeMacro{\vref*}
319 % \DescribeMacro{\vpageref*}
320 % \DescribeMacro{\vpagerefrange*}
321 % Since it was too late to change the default in 2001 I added star
322 % versions of the macros which do not add any space before the
323 % generated text (they do nevertheless remove space at the left).
324 %
325 % However, that too has problems: one is that \pkg{hyperref}
326 % \ChangedIn{2019}
327 % introduced the star forms as a means of generating references
328 % without hyperlinks, which is clearly the more important
329 % application.
330 % So these days I recommend to always call the package with the option
331 % \option{nospace} which prevents \pkg{varioref} from messing with the
332 % space in front. Of course you are then responsible to always add it
333 % when necessary, but that does make the source more readable so it is
334 % a good thing. This also has the advantage that the star forms are
335 % now unnecessary again and can be used in the way implemented by
336 % \pkg{hyperref} if both packages are used together.
337 %
338 % In fact it would be much nicer to make that the
339 % default but the package has been used by many people for so many
340 % years that changing the default would break way too many older documents.
341 %
342 %
343 % \DescribeMacro\labelformat
344 % A reference via |\ref| produces by default the data associated with
345 % the corresponding |\label| command (typically a number); any
346 % additional formatting has to be provided by the user. With
347 % |\labelformat| it is possible to declare such formatting for each
348 % ``reference'' counter, e.g.,
349 %\begin{verbatim}
350 % \labelformat{section}{section~#1}
351 % \labelformat{equation}{equation~(#1)}}
352 %\end{verbatim}
353 %
354 %
355 % \DescribeMacro\Vref
356 % \DescribeMacro\Ref
357 % A side effect of using |\labelformat| is that, depending on the
358 % defined formatting, it becomes impossible to use |\ref| at the
359 % beginning of a sentence (if its replacement text starts with a
360 % lowercase letter).
361 % \ChangedIn{2019}
362 % For that reason \pkg{varioref} provided the commands |\Ref| and
363 % |\Vref|. They behave like |\ref| and |\vref| except that they
364 % uppercase the first token of the generated string. These days
365 % |\labelformat| and |\Ref| are already provided by the \LaTeX{}
366 % kernel; only |\Vref| is still defined within the \pkg{varioref}
367 % package.
368 %
369 % To make |\Ref| or |\Vref| work properly the very first token in the
370 % second argument of |\labelformat| has to be a simple \textsc{ascii}
371 % or UTF-8 letter, otherwise the capitalization will fail or worse,
372 % you will end up with some error messages. If you actually need
373 % something more complicated in this place (e.g., an accented letter
374 % not written as a UTF-8 character) you have to explicitly surround it
375 % with braces, to identify the part that needs to be capitalized. For
376 % example, for figure references in the Hungarian language you might
377 % want to write |\labelformat{figure}{{\'a}bra~\thefigure}| or use
378 % |\labelformat{figure}{Ɣbra~\thefigure}| which avoids the brace
379 % problem.
380 %
381 % \DescribeMacro\thevpagerefnum
382 % If you like to have |\vref| suppress the page number on pages where
383 % label and reference fall onto the same page, but prefer reference to
384 % page numbers otherwise then |\thevpagerefnum| can be used. This macro
385 % hold the current page ``number'' when |\vpageref| and friends are
386 % executed. Thus, by defining, for example,
387 %\begin{verbatim}
388 %\renewcommand\reftextfaceafter {on page~\thevpagerefnum}
389 %\renewcommand\reftextfacebefore{on page~\thevpagerefnum}
390 %\renewcommand\reftextafter {on page~\thevpagerefnum}
391 %\renewcommand\reftextbefore {on page~\thevpagerefnum}
392 %\end{verbatim}
393 % textual references can be suppressed.
394 %
395 %
396 %
397 % \section{Multi-lingual usage}
398 %
399 % The package works well together with the babel system if it is
400 % loaded \textit{after} the babel package, e.g., a document in English
401 % (default), French and German text could load the packages as
402 % follows:
403 %\begin{verbatim}
404 % \usepackage[ngerman,french,english]{babel,varioref}
405 %\end{verbatim}
406 % (or in two separate lines if you prefer one |\usepackage| line per
407 % package). Depending on the current babel language |\vref| and
408 % friends would then generate strings in different languages. If the
409 % language options are given as global options to the document class
410 % then it is enough to use
411 %\begin{verbatim}
412 % \usepackage{babel,varioref}
413 %\end{verbatim}
414 % to achieve the same effect.
415 %
416 % If more than one language is specified with \pkg{varioref} then
417 % it will start using the last language selected. Switching of
418 % languages is managed through Babel; nevertheless all languages of
419 % interest need to be specified when \pkg{varioref} is loaded so
420 % that it can integrate their strings into the Babel system.
421 %
422 %
423 % \section{Customization}
424 %
425 % The package supports all options defined by the babel package to
426 % translate the fixed strings into other languages than English.
427 % (Some languages need updating, however---help is appreciated.) It
428 % also supports languages currently not in babel (those can only be
429 % used standalone, obviously); check the section on options later~on.
430 %
431 %
432 % \pagebreak[3]
433 %
434 % You can also modify some or all of the strings by redefining the
435 % following commands after the package has been loaded.
436 %\DescribeMacro\reftextbefore
437 %\DescribeMacro\reftextfacebefore
438 %\DescribeMacro\reftextafter
439 %\DescribeMacro\reftextfaceafter Backward references use
440 % |\reftextbefore| if the label is on the preceding page but invisible
441 % and |\reftextfacebefore| if it is on the facing page (i.e., if the
442 % current page number is odd). Similarly |\reftextafter| is used
443 % when the label comes on the next page but one has to turn the page
444 % and |\reftextfaceafter| if it is on the following but facing page.
445 %
446 % In fact, |\reftextface...| is used only if the user or the document
447 % class specified two-sided printing.
448 %
449 %\DescribeMacro\reftextfaraway Finally we have |\reftextfaraway| which
450 % is used whenever label and reference differ by more than one or when
451 % they aren't numeric. This macro is a bit different because it takes
452 % one argument, the symbolic reference string, so that one can make
453 % use of |\pageref| in its replacement text.
454 %
455 % In the somewhat unusual case that you want to make some or all of
456 % the |\reftext...| texts empty, it is necessary to get rid of the
457 % space that is automatically put in front of them. You can do this by
458 % defining them to expand to |\unskip|.
459 %
460 %
461 %\DescribeMacro\reftextvario To allow a bit random variation in the
462 % generated strings one can use the command |\reftextvario| inside the
463 % string macros. It takes two arguments and selects one or the other
464 % for printing depending on the number of already seen |\vref| or
465 % |\vpageref| commands. As an example see the definitions of
466 % |\reftextbefore| etc.\ \vpageref[below]{reftextbefore}.
467 %
468 % The commands |\vrefrange| and |\vpagerefrange| produce their text
469 % \NewIn{1998}
470 % using two macros described below. By redefining them one can modify
471 % the results to accommodate special requirements.
472 %
473 %
474 % They both take two mandatory arguments denoting the first and the
475 % last label of the range.
476 %
477 %
478 % \DescribeMacro\reftextpagerange This macro produces text that
479 % describes the page range of the two labels, e.g., the default
480 % for English is ``|on pages~\pageref{#1}--\pageref{#2}}|''.
481 %
482 %
483 % \DescribeMacro\reftextlabelrange This macro produces text that
484 % describes the range of figures, tables, or whatever the labels refer
485 % to, the default for English is ``|\ref{#1} to~\ref{#2}|''.
486 %
487 %
488 % \NewIn{2020}
489 % \DescribeMacro\vrefformat
490 % \DescribeMacro\Vrefformat
491 % \DescribeMacro\vrefrangeformat
492 % \DescribeMacro\fullrefformat
493 % In some languages (currently only for Japanese) the generated text
494 % has to typeset in different word order to most other (Western) languages.
495 % To accommodate for this \cs{vrefformat}, etc.\ has been
496 % added to allow to alter this on a per language basis.
497 % There should be normally no need to alter the setup. For details see
498 % the code section.
499 %
500 % \subsection{\ldots\ if Babel is used}
501 %
502 % \begin{itshape} If babel is being used then the above commands need to be
503 % changed using the Babel mechanism, e.g.,
504 %\begin{verbatim}
505 % \addto\extrasngerman{%
506 % \renewcommand\reftextfaceafter {auf der n\"achsten Seite}%
507 % ... }
508 %\end{verbatim}
509 % Otherwise babel will reintroduce its own defaults whenever the language is
510 % changed (which happens in particular during |\begin{document}| where the
511 % main language is selected).
512 % \end{itshape}
513 %
514 %
515 %
516 %
517 % \section{Options} \label{options}
518 %
519 % As mentioned above the package supports all standard options offered
520 % by the Babel system to customize the strings produced, it may also
521 % have a few not supported by babel, for a full list look
522 % in section~\vref{sec:impoptions}. In addition it offers the option
523 % \texttt{draft} to turn error messages into warnings during
524 % development. The default \texttt{final} produces error message when
525 % a generated string falls onto a page boundary (see next section).
526 %
527 % Newly introduced in 2019 are the options \option{space} (default)
528 % and \option{nospace}. While the former is the default to allow
529 % \NewIn{2019}
530 % documents written in the last twenty years to continue to work
531 % correctly, I nowadays suggest that you always use the package with
532 % the option \option{nospace}. This will stop \pkg{varioref} from
533 % meddling with the spaces preceding commands and thus make the star
534 % forms |\vref*| and |\vpageref*| unnecessary.
535 %
536 % This means that the star forms can then be used as defined by
537 % \pkg{hyperref} for suppressing a hyperlink when both packages are
538 % used together (which is a rather typical scenario these days).
539 %
540 %
541 % \section{A few warnings}
542 %
543 % Defining commands like the ones described above poses some
544 % interesting problems. Suppose, for example, that a generated text
545 % like `on the next page' gets broken across pages. If this happens it
546 % is very difficult to find an acceptable solution and it can, in fact,
547 % even result in a document that will always change from one state to
548 % another (i.e., inserting one string, finding that this is wrong,
549 % inserting another string on the next run which makes the first
550 % string correct again, inserting \ldots). The current implementation
551 % of \pkg{varioref} therefore issues an error message whenever the
552 % generated text is broken across page boundaries, e.g.,
553 % \begin{quote}
554 % table 5 on the current \meta{page break} page
555 % \end{quote}
556 % would result in an error, which needs to be resolved by the
557 % user by replacing the |\vref| command with an ordinary |\ref| just
558 % before the final run. This is not
559 % completely satisfactory but in such case no solution really is.
560 % \DescribeMacro\vrefwarning
561 % During document preparation, while one is still changing the text,
562 % such error messages can be turned into warnings by placing a
563 % |\vrefwarning| command in the preamble. This is equivalent to
564 % specifying ``draft'' as an option to the package.
565 % \DescribeMacro\vrefshowerrors
566 % |\vrefshowerrors| ensures that varioref stops when detecting a
567 % possible loop. This is the default and equivalent to specifying
568 % ``final'' as an option.
569 %
570 % At the end final a warning: every use of |\vref| will internally
571 % generate two macro names to keep track of the string positions
572 % within the document. As a result you may run out of name space or
573 % main memory\footnote{Not really that likely these days, but one
574 % never knows \ldots. In any case \TeX{} will process your document a
575 % tiny bit faster.} if you make heavy use of this macro on a small
576 % \TeX{} installation.
577 %\DescribeMacro\fullref For this reason the primitive command
578 % |\fullref| is also provided. This command can be used whenever you
579 % know for sure that label and reference can't fall onto nearby pages.
580 %
581 %
582 % \MaybeStop{\PrintIndex\PrintChanges}
583 %
584 %
585 % \section{The documentation driver file}
586 %
587 % The next bit of code contains the documentation driver file for
588 % \TeX{}, i.e., the file that will produce the documentation you are
589 % currently reading. It will be extracted from this file by the
590 % \pkg{docstrip} program.
591 % \begin{macrocode}
592 %<*driver>
593 \documentclass{ltxdoc}
594 \usepackage{multicol,varioref}
595 \GetFileInfo{varioref.sty}
596 \setlength\hfuzz{1pt} % ignore slight overfulls
597 \EnableCrossrefs
598 %\DisableCrossrefs % Say \DisableCrossrefs if index is ready
599
600 \RecordChanges % Gather update information
601 %\OnlyDescription % comment out for implementation details
602 \begin{document}
603 \DocInput{varioref.dtx}
604 \end{document}
605 %</driver>
606 % \end{macrocode}
607 %
608 %
609 % \section{The implementation}
610 %
611 % The main implementation idea is to generate an internal label
612 % command for every |\vpageref| and compare the page reference of this
613 % label with the page reference of the user-requested label. Since
614 % this means one additional macro name for each use of |\vpageref| or
615 % |vref| (which is implemented in terms of |\vpageref|) the memory
616 % requirements of this package may be high in terms of main and macro
617 % name memory. Since the information held in the internal labels is
618 % used only once one could envision a different scheme if suitable
619 % primitives for this kind of ``one place information'' would be
620 % provided by \LaTeX. This type of data structure is planned for
621 % \LaTeX3 but for the moment we have to live with the memory
622 % restrictions.
623 %
624 % We start by checking if this file was already loaded. If not we
625 % identify the current version. This is actually done at the top
626 % of the file, so we comment it out here
627 % \changes{v0.1h}{1993/08/15}{Small documentation changes}
628 % \begin{macrocode}
629 %<*package>
630 %\NeedsTeXFormat{LaTeX2e}[1994/06/01]
631 %\ProvidesPackage{varioref}[\filedate\space\fileversion\space
632 % LaTeX2e package for extended references (FMi)]
633 % \end{macrocode}
634 %
635 %
636 % \begin{macro}{\vref@addto}
637 % \changes{v1.0b}{1994/01/31}{Avoid using babel `addto}
638 % \changes{v1.0b}{1994/01/31}{The babel commands are starting
639 % with extras}
640 % To support the use of babel we want to add the additional strings
641 % to the |\extras|\meta{language} commands. Since |\addto| in the
642 % current implementation of babel has a bug that does not allow to
643 % use arguments containing hashmarks we do this by hand.
644 % \begin{macrocode}
645 \def\vref@addto#1#2{%
646 #2%
647 \@temptokena{#2}%
648 \ifx#1\undefined
649 \edef#1{\the\@temptokena}%
650 \else
651 \toks@\expandafter{#1}%
652 \edef#1{\the\toks@\the\@temptokena}%
653 \fi
654 \@temptokena{}\toks@\@temptokena
655 }
656 \@onlypreamble\vref@addto
657 % \end{macrocode}
658 % \end{macro}
659 %
660 %
661 % \subsection{Options}\label{sec:impoptions}
662 %
663 % \begin{macro}{\vref@excuse}
664 % Excuse that we don't know the strings for a certain language.
665 % \changes{v1.0q}{1995/04/06}{Use `PackageWarning}
666 % \begin{macrocode}
667 \def\vref@excuse#1{%
668 \PackageWarningNoLine{varioref}{Sorry, language `#1'
669 not supported%
670 \MessageBreak
671 in this version.
672 English strings used by default.
673 \MessageBreak
674 Please modify \protect\reftext... commands manually.%
675 \MessageBreak\MessageBreak
676 If you can suggest translations for
677 this language,%
678 \MessageBreak
679 please mail them
680 to the author of this package}}
681 \@onlypreamble\vref@excuse
682 % \end{macrocode}
683 % \end{macro}
684 %
685 % \begin{macro}{\vref@stringwarning}
686 % And we sometimes just don't know some strings~\ldots
687 % \changes{v1.2a}{1998/08/01}{Macro added}
688 % \begin{macrocode}
689 \def\vref@stringwarning#1{%
690 \PackageWarningNoLine{varioref}{Sorry, there is no proper
691 translation for the string\MessageBreak
692 produced by \protect#1\on@line.\MessageBreak
693 English string used instead.\MessageBreak
694 \MessageBreak
695 If you can suggest translations for
696 the current\MessageBreak
697 language, please mail them
698 to the author of this\MessageBreak package}}
699 % \end{macrocode}
700 % \end{macro}
701 %
702 %
703 % \begin{macro}{\reftextfaceafter}
704 % \begin{macro}{\reftextfacebefore}
705 % \begin{macro}{\reftextafter}
706 % \begin{macro}{\reftextbefore}
707 % \begin{macro}{\reftextcurrent}
708 % \label{reftextbefore} The options do set the macros that
709 % generate the textual strings. Note that they do not start with a
710 % space, the space is already added in the main macro below.
711 % \changes{v1.2a}{1998/08/22}{Added American defaults for
712 % \cs{reftextpagerange} and \cs{reftextlabelrange}}
713 % \changes{v1.4d}{2002/11/11}{Changed default for \cs{reftextbefore}}
714 %
715 % Afrikaans option contributed by Danie Els
716 % (\texttt{[email protected]}).
717 % \changes{v1.4g}{2003/03/29}{Added afrikaans option}
718 % \begin{macrocode}
719 \DeclareOption{afrikaans}
720 {\vref@addto\extrasafrikaans{%
721 \def\reftextfaceafter {op die \reftextvario{regterbladsy}%
722 {bladsy langsaan}}%
723 \def\reftextfacebefore{op die \reftextvario{linkerbladsy}%
724 {bladsy langsaan}}%
725 \def\reftextafter {op die \reftextvario{volgende bladsy}%
726 {bladsy hierna}}%
727 \def\reftextbefore {op die \reftextvario{vorige bladsy}%
728 {bladsy hiervoor}}%
729 \def\reftextcurrent {op \reftextvario{hierdie}%
730 {die huidige} bladsy}%
731 \def\reftextfaraway#1{op bladsy~\pageref{#1}}%
732 \def\reftextpagerange#1#2{op bladsye~\pageref{#1}--\pageref{#2}}%
733 \def\reftextlabelrange#1#2{\ref{#1} tot~\ref{#2}}%
734 \let\vrefformat\vrefdefaultformat
735 \let\Vrefformat\Vrefdefaultformat
736 \let\fullrefformat\fullrefdefaultformat
737 \let\vrefrangeformat\vrefrangedefaultformat
738 }}
739 % \end{macrocode}
740 %
741 % \begin{macrocode}
742 \DeclareOption{american}
743 {\vref@addto\extrasamerican{%
744 \def\reftextfaceafter {on the \reftextvario{facing}{next} page}%
745 \def\reftextfacebefore{on the \reftextvario{facing}{preceding}
746 page}%
747 \def\reftextafter {on the \reftextvario{following}{next} page}%
748 \def\reftextbefore {on the \reftextvario{preceding}{previous} page}%
749 \def\reftextcurrent {on \reftextvario{this}{the current} page}%
750 \def\reftextfaraway#1{on page~\pageref{#1}}%
751 \def\reftextpagerange#1#2{on pages~\pageref{#1}--\pageref{#2}}%
752 \def\reftextlabelrange#1#2{\ref{#1} to~\ref{#2}}%
753 \let\vrefformat\vrefdefaultformat
754 \let\Vrefformat\Vrefdefaultformat
755 \let\fullrefformat\fullrefdefaultformat
756 \let\vrefrangeformat\vrefrangedefaultformat
757 }}
758 % \end{macrocode}
759 % Arabic option text was contributed by Ihab Samir Mattar
760 % (\texttt{dr\[email protected]}). As our standard documentation
761 % workflow uses pdf\TeX{} the Arabic letters can't be displayed
762 % easily, so you will see missing glyphs below. To see the real
763 % letters you have to look at the source or package file.
764 % \changes{v1.6b}{2019/09/08}{Option arabic added}
765 % \begin{allowtofu}
766 % \begin{macrocode}
767 \DeclareOption{arabic}
768 {\vref@addto\extrasarabic{%
769 \def\reftextfaceafter {بالصفحة \reftextvario{المقابلة}{اللاحقة}}%
770 \def\reftextfacebefore{بالصفحة \reftextvario{المقابلة}{Ų§Ł„Ł…ŁŁ†Ł’ŲµŁŽŲ±ŁŁ…ŁŽŲ©ŁŒ}}%
771 \def\reftextafter {بالصفحة \reftextvario{اللاحقة}{Ų§Ł„ŲŖŲ§Ł„ŁŠŲ©}}%
772 \def\reftextbefore {بالصفحة \reftextvario{السابقة}{Ų§Ł„Ł…ŁŁ†Ł’ŲµŁŽŲ±ŁŁ…ŁŽŲ©ŁŒ}}%
773 \def\reftextcurrent {ŲØ\reftextvario{الصفحة Ų§Ł„Ų­Ų§Ł„ŁŠŲ©}{هذه الصفحة}}%
774 \def\reftextfaraway#1{بالصفحة رقم~\pageref{#1}}%
775 \def\reftextpagerange#1#2{بالصفحات~\pageref{#1}--\pageref{#2}}%
776 \def\reftextlabelrange#1#2{\ref{#1} حتى~\ref{#2}}%
777 \let\vrefformat\vrefdefaultformat
778 \let\Vrefformat\Vrefdefaultformat
779 \let\fullrefformat\fullrefdefaultformat
780 \let\vrefrangeformat\vrefrangedefaultformat
781 }}
782 % \end{macrocode}
783 % \end{allowtofu}
784 % \changes{v1.2a}{1998/11/27}{Added austrian defaults (identical to german)}
785 % The austrian defaults are the same as the german ones.
786 % \begin{macrocode}
787 \DeclareOption{austrian}
788 {\vref@addto\extrasaustrian{%
789 \def\reftextfaceafter {auf der n\"achsten Seite}%
790 \def\reftextfacebefore{auf der vorherigen Seite}%
791 \let\reftextafter \reftextfaceafter
792 \let\reftextbefore \reftextfacebefore
793 \def\reftextcurrent {auf dieser Seite}%
794 \def\reftextfaraway#1{auf Seite~\pageref{#1}}%
795 \def\reftextpagerange#1#2{auf Seiten~\pageref{#1}--\pageref{#2}}%
796 \def\reftextlabelrange#1#2{\ref{#1} bis~\ref{#2}}%
797 \let\vrefrangeformat\vrefrangedefaultformat
798 }}
799 % \end{macrocode}
800 % \changes{v1.2d}{2000/01/11}{Added naustrian defaults (identical to german)}
801 % The naustrian defaults are the same but needed for ``Neue Rechtschreibung''.
802 % \begin{macrocode}
803 \DeclareOption{naustrian}
804 {\vref@addto\extrasnaustrian{%
805 \def\reftextfaceafter {auf der n\"achsten Seite}%
806 \def\reftextfacebefore{auf der vorherigen Seite}%
807 \let\reftextafter \reftextfaceafter
808 \let\reftextbefore \reftextfacebefore
809 \def\reftextcurrent {auf dieser Seite}%
810 \def\reftextfaraway#1{auf Seite~\pageref{#1}}%
811 \def\reftextpagerange#1#2{auf Seiten~\pageref{#1}--\pageref{#2}}%
812 \def\reftextlabelrange#1#2{\ref{#1} bis~\ref{#2}}%
813 \let\vrefformat\vrefdefaultformat
814 \let\Vrefformat\Vrefdefaultformat
815 \let\fullrefformat\fullrefdefaultformat
816 \let\vrefrangeformat\vrefrangedefaultformat
817 }}
818 % \end{macrocode}
819 % Text for basque defaults was contributed by
820 % I\~naki Larra\~naga Murgoitio (aka dooteo)
821 % (|<[email protected]>|).
822 % \changes{v1.4k}{2005/04/09}{Basque defaults added.}
823 % \begin{macrocode}
824 \DeclareOption{basque}
825 {\vref@addto\extrasbasque{%
826 \def\reftextfaceafter {hurrengo orrialdean}%
827 \def\reftextfacebefore{aurreko orrialdean}%
828 \let\reftextafter \reftextfaceafter
829 \let\reftextbefore \reftextfacebefore
830 \def\reftextcurrent {uneko orrialdean}%
831 \def\reftextfaraway#1{~\pageref{#1}. orrialdean}%
832 \def\reftextpagerange#1#2{~\pageref{#1}--\pageref{#2} orrialdeetan}%
833 \def\reftextlabelrange#1#2{\ref{#1}.etik \ref{#2}.eraino}%
834 \let\vrefformat\vrefdefaultformat
835 \let\Vrefformat\Vrefdefaultformat
836 \let\fullrefformat\fullrefdefaultformat
837 \let\vrefrangeformat\vrefrangedefaultformat
838 }}
839 % \end{macrocode}
840 % Text for the Bahasa Malaysia defaults was contributed by
841 % Bob Margolis 2005-12-02.
842 %
843 % Notes: pada muka surat translates as ``on the page'' though BM has no
844 % definite (or indefinite) article; adjectives and other modifiers follow
845 % the noun (clause); bertentangan is ``opposite'' in the sense of
846 % ``facing''; berikutnya is ``next'' (in this context - actually
847 % next-to-this, literally); berikutnya also translates as ``following
848 % this''; sebelumnya is ``preceding'', also ``previous''; ``ini'' translates,
849 % literally, as ``this'' but is also used in the sense of current page.
850 % \changes{v1.4o}{2005/12/02}{Bahasa Malaysia defaults added.}
851 % \begin{macrocode}
852 \DeclareOption{bahasam}
853 {\vref@addto\extrasbahasam{%
854 \def\reftextfaceafter {pada muka surat \reftextvario{bertentangan}{berikutnya}}%
855 \def\reftextfacebefore{pada muka surat \reftextvario{bertentangan}{sebelumnya} }%
856 \def\reftextafter {pada muka surat berikutnya}%
857 \def\reftextbefore {pada muka surat sebelumnya}%
858 \def\reftextcurrent {pada muka surat ini}%
859 \def\reftextfaraway#1{pada muka surat~\pageref{#1}}%
860 \def\reftextpagerange#1#2{pada muka surat~\pageref{#1}--\pageref{#2}}%
861 \def\reftextlabelrange#1#2{\ref{#1}--\ref{#2}}%
862 \let\vrefformat\vrefdefaultformat
863 \let\Vrefformat\Vrefdefaultformat
864 \let\fullrefformat\fullrefdefaultformat
865 \let\vrefrangeformat\vrefrangedefaultformat
866 }}
867 % \end{macrocode}
868 % Text for brazil defaults was contributed by
869 % Alcino Dall Igna Junior\\
870 % (|[email protected]|).
871 % \changes{v1.0g}{1994/05/18}{Brazil defaults added.}
872 % \changes{v1.4o}{2005/11/07}{Added a few more brazil strings}
873 % \changes{v1.4r}{2007/05/26}{Misspelling of \cs{extrasbrazil}}
874 % \begin{macrocode}
875 \DeclareOption{brazil}
876 {\vref@addto\extrasbrazil{%
877 \def\reftextfaceafter {na \reftextvario{p\'agina oposta}{pr\'oxima
878 p\'agina}}%
879 \def\reftextfacebefore{na p\'agina \reftextvario{oposta}{anterior}}%
880 \def\reftextafter {na \reftextvario{p\'agina seguinte}{pr\'oxima
881 p\'agina}}%
882 \def\reftextbefore{na p\'agina \reftextvario{anterior}{precedente}}%
883 \def\reftextcurrent {\reftextvario{nesta p\'agina}{na p\'agina
884 corrente}}%
885 \def\reftextfaraway#1{na p\'agina~\pageref{#1}}%
886 \def\reftextpagerange#1#2{nas p\'aginas~\pageref{#1}--\pageref{#2}}%
887 \def\reftextlabelrange#1#2{\ref{#1} a~\ref{#2}}%
888 \let\vrefformat\vrefdefaultformat
889 \let\Vrefformat\Vrefdefaultformat
890 \let\fullrefformat\fullrefdefaultformat
891 \let\vrefrangeformat\vrefrangedefaultformat
892 }}
893 % \end{macrocode}
894 % Text for Breton defaults was contributed by
895 % Christian ROLLAND\\
896 % (|[email protected]|).
897 % \changes{v1.0o}{1994/09/27}{Added defaults for breton}
898 % \begin{macrocode}
899 \DeclareOption{breton}
900 {\vref@excuse{breton}%
901 \vref@addto\extrasbreton{%
902 \def\reftextfaceafter {war ar bajenn \reftextvario{a-dal}{da heul}}%
903 \def\reftextfacebefore{war ar bajenn \reftextvario{a-dal}{a-raok}}%
904 \def\reftextafter {war ar bajenn da heul}%
905 \def\reftextbefore {war ar bajenn a-raok}%
906 \def\reftextcurrent {war ar \reftextvario{bajenn-ma\~n}%
907 {bajenn war-wel}}%
908 \def\reftextfaraway#1{war ar bajenn~\pageref{#1}}%
909 \def\reftextpagerange#1#2{\vref@stringwarning\reftextpagerange
910 on pages~\pageref{#1}--\pageref{#2}}%
911 \def\reftextlabelrange#1#2{\vref@stringwarning\reflabelpagerange
912 \ref{#1} to~\ref{#2}}%
913 \let\vrefformat\vrefdefaultformat
914 \let\Vrefformat\Vrefdefaultformat
915 \let\fullrefformat\fullrefdefaultformat
916 \let\vrefrangeformat\vrefrangedefaultformat
917 }}
918 % \end{macrocode}
919 % Text for Bulgarian defaults was contributed by
920 % Georgi Boshnakov\\ (|[email protected]|).
921 % \changes{v1.4q}{2006/05/23}{Added defaults for bulgarian}
922 % \begin{macrocode}
923 \DeclareOption{bulgarian}%
924 {\vref@addto\extrasbulgarian{%
925 \def\reftextfaceafter{\cyrn\cyra\
926 \reftextvario{\cyrs\cyrery\cyrs\cyre\cyrd\cyrn\cyra\cyrt\cyra}%
927 {\cyrs\cyrl\cyre\cyrd\cyrv\cyra\cyrshch\cyra\cyrt\cyra}
928 \cyrs\cyrt\cyrr\cyra\cyrn\cyri\cyrc\cyra}%
929 \def\reftextfacebefore{\cyrn\cyra\
930 \reftextvario{\cyrs\cyrery\cyrs\cyre\cyrd\cyrn\cyra\cyrt\cyra}%
931 {\cyrp\cyrr\cyre\cyrd\cyrn\cyra\cyrt\cyra}
932 \cyrs\cyrt\cyrr\cyra\cyrn\cyri\cyrc\cyra}%
933 \def\reftextafter{\cyrn\cyra\
934 \reftextvario{\cyrs\cyrl\cyre\cyrd\cyrv\cyra\cyrshch\cyra\cyrt\cyra}%
935 {\cyrs\cyrl\cyre\cyrd\cyrv\cyra\cyrshch\cyra\cyrt\cyra}
936 \cyrs\cyrt\cyrr\cyra\cyrn\cyri\cyrc\cyra}%
937 \def\reftextbefore{\cyrn\cyra\
938 \reftextvario{\cyrp\cyrr\cyre\cyrd\cyrn\cyra\cyrt\cyra}%
939 {\cyrp\cyrr\cyre\cyrd\cyri\cyrsh\cyrn\cyra\cyrt\cyra}
940 \cyrs\cyrt\cyrr\cyra\cyrn\cyri\cyrc\cyra}%
941 \def\reftextcurrent{\cyrn\cyra\
942 \reftextvario{\cyrt\cyra\cyrz\cyri}%
943 {\cyrt\cyre\cyrk\cyru\cyrshch\cyra\cyrt\cyra}
944 \cyrs\cyrt\cyrr\cyra\cyrn\cyri\cyrc\cyra}%
945 \def\reftextfaraway#1{\cyrn\cyra\ \cyrs\cyrt\cyrr\cyra\cyrn\cyri\cyrc\cyra
946 ~\pageref{#1}}%
947 \def\reftextpagerange#1#2{\cyrn\cyra\
948 \cyrs\cyrt\cyrr\cyra\cyrn\cyri\cyrc\cyri
949 ~\pageref{#1}--\pageref{#2}}%
950 \def\reftextlabelrange#1#2{\ref{#1} \cyrd\cyro~\ref{#2}}%
951 \let\vrefformat\vrefdefaultformat
952 \let\Vrefformat\Vrefdefaultformat
953 \let\fullrefformat\fullrefdefaultformat
954 \let\vrefrangeformat\vrefrangedefaultformat
955 }}
956 % \end{macrocode}
957 % Text for catalan defaults was contributed by Robert Fuster\\
958 % (\[email protected]=).
959 % \changes{v1.1c}{1997/06/12}{Added defaults for catalan}
960 % \changes{v1.2g}{2000/08/22}{Updated defaults for catalan}
961 % \begin{macrocode}
962 \DeclareOption{catalan}
963 {\vref@addto\extrascatalan{%
964 \def\reftextfaceafter {a la p\`agina seg\"uent}%
965 \def\reftextfacebefore{a la p\`agina anterior}%
966 \let\reftextafter \reftextfaceafter
967 \let\reftextbefore \reftextfacebefore
968 \def\reftextcurrent {en aquesta p\`agina}%
969 \def\reftextfaraway#1{a la p\`agina~\pageref{#1}}%
970 \def\reftextpagerange#1#2{a les
971 p\`agines~\pageref{#1}--\pageref{#2}}%
972 \def\reftextlabelrange#1#2{\ref{#1} a~\ref{#2}}%
973 \let\vrefformat\vrefdefaultformat
974 \let\Vrefformat\Vrefdefaultformat
975 \let\fullrefformat\fullrefdefaultformat
976 \let\vrefrangeformat\vrefrangedefaultformat
977 }}
978 % \end{macrocode}
979 % Text for croatian defaults was contributed by \v{S}ime Ungar
980 % (\[email protected]=).
981 % \changes{v1.4p}{2006/05/13}{Added defaults for croatian}
982 % \begin{macrocode}
983 \DeclareOption{croatian}
984 {\vref@addto\extrascroatian{%
985 \def\reftextfaceafter {na sljede\'coj stranici}%
986 \def\reftextfacebefore{na prethodnoj stranici}%
987 \let\reftextafter \reftextfaceafter
988 \let\reftextbefore \reftextfacebefore
989 \def\reftextcurrent {na ovoj stranici}%
990 \def\reftextfaraway#1{na stranici~\pageref{#1}}%
991 \def\reftextpagerange#1#2{na stranicama~\pageref{#1}--\pageref{#2}}%
992 \def\reftextlabelrange#1#2{\ref{#1} do~\ref{#2}}%
993 \let\vrefformat\vrefdefaultformat
994 \let\Vrefformat\Vrefdefaultformat
995 \let\fullrefformat\fullrefdefaultformat
996 \let\vrefrangeformat\vrefrangedefaultformat
997 }}
998 % \end{macrocode}
999 % Defaults for the Czech option provided by Milan Vancura
1000 % \verb=<[email protected]>=.
1001 % \changes{v1.2e}{2000/04/04}{Added czech defaults}
1002 % \begin{macrocode}
1003 \DeclareOption{czech}
1004 {%\vref@excuse{czech}%
1005 \vref@addto\extrasczech{%
1006 \def\reftextfaceafter {na n\'a\-sle\-du\-j\'\i c\'\i\ stran\v{e}}%
1007 \def\reftextfacebefore{na p\v{r}ed\-choz\'\i\ stran\v{e}}%
1008 \def\reftextafter {na n\'a\-sle\-du\-j\'\i c\'\i\ stran\v{e}}%
1009 \def\reftextbefore {na p\v{r}ed\-choz\'\i\ stran\v{e}}%
1010 \def\reftextcurrent {na t\'eto stran\v{e}}%
1011 \def\reftextfaraway#1{na stran\v{e}~\pageref{#1}}%
1012 \def\reftextpagerange#1#2{na stran\'ach~\pageref{#1}\--\pageref{#2}}%
1013 \def\reftextlabelrange#1#2{\ref{#1} a\v{z}~\ref{#2}}%
1014 \let\vrefformat\vrefdefaultformat
1015 \let\Vrefformat\Vrefdefaultformat
1016 \let\fullrefformat\fullrefdefaultformat
1017 \let\vrefrangeformat\vrefrangedefaultformat
1018 }}
1019 % \end{macrocode}
1020 % Defaults for Danish provided by Torsten Martinsen
1021 % (\[email protected]=). Further defaults by Ole Laursen
1022 % (\[email protected]=).
1023 % \changes{v1.0n}{1994/09/25}{Added Danish defaults}
1024 % \changes{v1.2h}{2000/12/30}{Updates to Danish defaults}
1025 % \begin{macrocode}
1026 \DeclareOption{danish}
1027 {\vref@addto\extrasdanish{%
1028 \def\reftextfaceafter {p\aa{} \reftextvario{modst\aa ende}%
1029 {n\ae ste} side}%
1030 \def\reftextfacebefore{p\aa{} \reftextvario{modst\aa ende}%
1031 {forrige} side}%
1032 \def\reftextafter {p\aa{} \reftextvario{den f\o lgende}%
1033 {n\ae ste} side}%
1034 \def\reftextbefore {p\aa{} \reftextvario{forrige side}
1035 {foreg\aa ende side}}%
1036 \def\reftextcurrent {p\aa{} denne side}%
1037 \def\reftextfaraway#1{p\aa{} side~\pageref{#1}}%
1038 \def\reftextpagerange#1#2{p\aa{} side~\pageref{#1}--\pageref{#2}}%
1039 \def\reftextlabelrange#1#2{\ref{#1} til~\ref{#2}}%
1040 \let\vrefformat\vrefdefaultformat
1041 \let\Vrefformat\Vrefdefaultformat
1042 \let\fullrefformat\fullrefdefaultformat
1043 \let\vrefrangeformat\vrefrangedefaultformat
1044 }}
1045 % \end{macrocode}
1046 % Default strings for Dutch have been contributed by Frank Poppe
1047 % (\[email protected]=).
1048 % This option currently supports one additional string macro
1049 % |\refpagename| so that you can easily change to |bladzijde|
1050 % instead of |pagina| if you prefer this word for ``page''.
1051 % However, I will not guarantee that this will survive future
1052 % versions of this package, so use it on your own risk (you can
1053 % always update the full strings to be on the safe side).
1054 % \changes{v1.0l}{1994/07/07}{Added dutch defaults}
1055 % \changes{v1.2a}{1998/08/22}{Added dutch defaults for
1056 % \cs{reftextpagerange} and \cs{reftextlabelrange}}
1057 % \begin{macrocode}
1058 \DeclareOption{dutch}
1059 {\vref@addto\extrasdutch{%
1060 \def\refpagename{pagina}%
1061 \def\reftextfaceafter {op de \reftextvario{rechter \refpagename}%
1062 {\refpagename\ hiernaast}}%
1063 \def\reftextfacebefore{op de \reftextvario{linker \refpagename}%
1064 {\refpagename\ hiernaast}}%
1065 \def\reftextafter {op de \reftextvario{volgende \refpagename}%
1066 {\refpagename\ hierna}}%
1067 \def\reftextbefore {op de \reftextvario{vorige \refpagename}%
1068 {\refpagename\ hiervoor}}%
1069 \def\reftextcurrent {op deze \refpagename}%
1070 \def\reftextfaraway#1{op \refpagename~\pageref{#1}}%
1071 % \end{macrocode}
1072 % Concerning the next defaults I received the following comment by
1073 % Frederik Fouvry \texttt{<[email protected]>}:
1074 % ``In the Dutch options (where I can exert a proper language
1075 % judgement ;-), `t/m' is not used in formal (scientific) texts. I
1076 % would either use `--' or `tot en met' (the abbreviation written
1077 % out). ''
1078 % \changes{v1.4d}{2002/11/11}{Changed default for \cs{reftextlabelrange}}
1079 % \changes{v1.4m}{2005/06/09}{Fixed \cs{reftextlabelrange} (pr/3791)}
1080 % \begin{macrocode}
1081 \def\reftextpagerange#1#2{op pagina's~\pageref{#1}--\pageref{#2}}%
1082 \def\reftextlabelrange#1#2{\ref{#1}--\ref{#2}}%
1083 \let\vrefformat\vrefdefaultformat
1084 \let\Vrefformat\Vrefdefaultformat
1085 \let\fullrefformat\fullrefdefaultformat
1086 \let\vrefrangeformat\vrefrangedefaultformat
1087 }}
1088 % \end{macrocode}
1089 % \changes{v1.2a}{1998/08/22}{Added english defaults for
1090 % \cs{reftextpagerange} and \cs{reftextlabelrange}}
1091 % \changes{v1.4d}{2002/11/11}{Changed default for \cs{reftextbefore}}
1092 % \begin{macrocode}
1093 \DeclareOption{english}
1094 {\vref@addto\extrasenglish{%
1095 \def\reftextfaceafter {on the \reftextvario{facing}{next} page}%
1096 \def\reftextfacebefore{on the \reftextvario{facing}{preceding}
1097 page}%
1098 \def\reftextafter {on the \reftextvario{following}{next} page}%
1099 \def\reftextbefore {on the \reftextvario{preceding}{previous} page}%
1100 \def\reftextcurrent {on \reftextvario{this}{the current} page}%
1101 \def\reftextfaraway#1{on page~\pageref{#1}}%
1102 \def\reftextpagerange#1#2{on pages~\pageref{#1}--\pageref{#2}}%
1103 \def\reftextlabelrange#1#2{\ref{#1} to~\ref{#2}}%
1104 \let\vrefformat\vrefdefaultformat
1105 \let\Vrefformat\Vrefdefaultformat
1106 \let\fullrefformat\fullrefdefaultformat
1107 \let\vrefrangeformat\vrefrangedefaultformat
1108 }}
1109 % \end{macrocode}
1110 %
1111 % The esperanto strings were suggested by Albert Reiner
1112 % (\[email protected]=).
1113 % \changes{v1.4x}{2010/08/04}{Defaults for esperanto added}
1114 % \begin{macrocode}
1115 \DeclareOption{esperanto}
1116 {\vref@addto\extrasesperanto{%
1117 \def\reftextfaceafter{en la
1118 \reftextvario{flanka}{sekva} pa\^go}%
1119 \def\reftextfacebefore{en la
1120 \reftextvario{flanka}{anta\u ua} pa\^go}%
1121 \def\reftextafter{en la sekva pa\^go}%
1122 \def\reftextbefore{en la anta\u ua pa\^go}%
1123 \def\reftextcurrent{\reftextvario{\^ci-pa\^ge}%
1124 {en \^ci tiu pa\^go}}%
1125 \def\reftextfaraway#1{en pa\^go~\pageref{#1}}%
1126 \def\reftextpagerange#1#2{en pa\^goj~\pageref{#1} \^gis \pageref{#2}}%
1127 \def\reftextlabelrange#1#2{\ref{#1} \^gis~\ref{#2}}%
1128 \let\vrefformat\vrefdefaultformat
1129 \let\Vrefformat\Vrefdefaultformat
1130 \let\fullrefformat\fullrefdefaultformat
1131 \let\vrefrangeformat\vrefrangedefaultformat
1132 }}
1133 % \end{macrocode}
1134 % The Finnish strings were suggested by Matti Rintala
1135 % (\[email protected]=) and Hillevi Gavel
1136 % (\[email protected]=).
1137 % \changes{v1.0m}{1994/09/23}{Added finnish strings}
1138 % \changes{v1.4o}{2005/11/07}{Added a few more finnish strings}
1139 % \begin{macrocode}
1140 \DeclareOption{finnish}
1141 {\vref@addto\extrasfinnish{%
1142 \def\reftextfaceafter {\reftextvario{viereisell\"a}%
1143 {seuraavalla} sivulla}%
1144 \def\reftextfacebefore{\reftextvario{viereisell\"a}%
1145 {edellisell\"a} sivulla}%
1146 \def\reftextafter {seuraavalla sivulla}%
1147 \def\reftextbefore {edellisell\"a sivulla}%
1148 \def\reftextcurrent {t\"all\"a sivulla}%
1149 \def\reftextfaraway#1{sivulla~\pageref{#1}}%
1150 \def\reftextpagerange#1#2{sivuilla~\pageref{#1}--\pageref{#2}}%
1151 % \end{macrocode}
1152 % Can't combine numbers with the necessary suffix well.
1153 % \begin{macrocode}
1154 \def\reftextlabelrange#1#2{\ref{#1}--\ref{#2}}%
1155 \let\vrefformat\vrefdefaultformat
1156 \let\Vrefformat\Vrefdefaultformat
1157 \let\fullrefformat\fullrefdefaultformat
1158 \let\vrefrangeformat\vrefrangedefaultformat
1159 }}
1160 % \end{macrocode}
1161 % French defaults are provided by Daniel Flippo
1162 % (\[email protected]=).
1163 % \changes{v1.0j}{1994/06/21}{Added french defaults}
1164 % \changes{v1.2a}{1998/08/22}{Added french defaults for
1165 % \cs{reftextpagerange} and \cs{reftextlabelrange}}
1166 % \begin{macrocode}
1167 \DeclareOption{french}
1168 {\vref@addto\extrasfrench{%
1169 \def\reftextfaceafter {page \reftextvario{ci-contre}{suivante}}%
1170 \def\reftextfacebefore{page \reftextvario{ci-contre}%
1171 {pr\'ec\'edente}}%
1172 \def\reftextafter {page suivante}%
1173 \def\reftextbefore {page pr\'ec\'edente}%
1174 \def\reftextcurrent {de la pr\'esente page}%
1175 \def\reftextfaraway#1{page~\pageref{#1}}%
1176 \def\reftextpagerange#1#2{pages~\pageref{#1}--\pageref{#2}}%
1177 \def\reftextlabelrange#1#2{\ref{#1} \`a~\ref{#2}}%
1178 \let\vrefformat\vrefdefaultformat
1179 \let\Vrefformat\Vrefdefaultformat
1180 \let\fullrefformat\fullrefdefaultformat
1181 \let\vrefrangeformat\vrefrangedefaultformat
1182 }}
1183 % \end{macrocode}
1184 % Galician defaults are provided by Matthias Moebius\\
1185 % (\texttt{[email protected]}).
1186 % \changes{v1.1f}{1998/04/25}{Added galician defaults}
1187 % \changes{v1.4o}{2005/11/10}{Added further galician defaults}
1188 % \changes{v1.4o}{2005/11/26}{Some further corrections}
1189 % \changes{v1.5b}{2015/09/22}{Fixed blunder from 2005 -
1190 % galician option clearly never used}
1191 % \begin{macrocode}
1192 \DeclareOption{galician}
1193 {\vref@addto\extrasgalician{%
1194 \def\reftextfaceafter {na p\'axina oposta}%
1195 \def\reftextfacebefore\reftextfaceafter
1196 \def\reftextafter {na p\'axina seguinte}%
1197 \def\reftextbefore {na p\'axina anterior}%
1198 \def\reftextcurrent {nesta p\'axina}%
1199 \def\reftextfaraway#1{na p\'axina~\pageref{#1}}%
1200 \def\reftextpagerange#1#2{%
1201 nas p\'axinas~\pageref{#1}-\pageref{#2}}%
1202 \def\reftextlabelrange#1#2{\ref{#1} a~\ref{#2}}%
1203 \let\vrefformat\vrefdefaultformat
1204 \let\Vrefformat\Vrefdefaultformat
1205 \let\fullrefformat\fullrefdefaultformat
1206 \let\vrefrangeformat\vrefrangedefaultformat
1207 }}
1208 % \end{macrocode}
1209 % There are no good variants for German (I think and still think but
1210 % this is a matter of taste :-)).
1211 % \changes{v1.0b}{1994/01/31}{Replace in incorrect `def by `let}
1212 % The following definitions were recently suggested to me but since
1213 % the originals have been there for a long time I don't want to change them
1214 % now since that could make a lot of documents change their formatting.
1215 % If you fancy them, add a redefinition of the corresponding macro(s)
1216 % to the preamble of your document.
1217 %\begin{verbatim}
1218 % \def\reftextfaceafter {auf der \reftextvario
1219 % {gegen\"uberliegenden}{anderen} Seite}%
1220 % \def\reftextfacebefore {auf der \reftextvario
1221 % {gegen\"uberliegenden}{anderen} Seite}%
1222 % \def\reftextafter {auf der \reftextvario
1223 % {n\"achsten}{folgenden} Seite}%
1224 % \def\reftextbefore {auf der \reftextvario
1225 % {vorigen}{vorhergehenden} Seite}%
1226 % \def\reftextcurrent {\reftextvario
1227 % {auf dieser}{diese} Seite}%
1228 %\end{verbatim}
1229 % \changes{v1.4n}{2005/07/24}{Small change}
1230 % \begin{macrocode}
1231 \DeclareOption{german}
1232 {\vref@addto\extrasgerman{%
1233 \def\reftextfaceafter {auf der n\"achsten Seite}%
1234 \def\reftextfacebefore{auf der vorherigen Seite}%
1235 \let\reftextafter \reftextfaceafter
1236 \let\reftextbefore \reftextfacebefore
1237 \def\reftextcurrent {auf dieser Seite}%
1238 \def\reftextfaraway#1{auf Seite~\pageref{#1}}%
1239 \def\reftextpagerange#1#2{auf den Seiten~\pageref{#1}--\pageref{#2}}%
1240 \def\reftextlabelrange#1#2{\ref{#1} bis~\ref{#2}}%
1241 \let\vrefformat\vrefdefaultformat
1242 \let\Vrefformat\Vrefdefaultformat
1243 \let\fullrefformat\fullrefdefaultformat
1244 \let\vrefrangeformat\vrefrangedefaultformat
1245 }}
1246 % \end{macrocode}
1247 % \changes{v1.2d}{2000/01/11}{Added ngerman defaults (identical to german)}
1248 % \changes{v1.4n}{2005/07/24}{Small change}
1249 % The ngerman defaults are the same but needed for ``Neue Rechtschreibung''
1250 % (i.e., a different set of hyphenation patterns).
1251 % \begin{macrocode}
1252 \DeclareOption{ngerman}
1253 {\vref@addto\extrasngerman{%
1254 \def\reftextfaceafter {auf der n\"achsten Seite}%
1255 \def\reftextfacebefore{auf der vorherigen Seite}%
1256 \let\reftextafter \reftextfaceafter
1257 \let\reftextbefore \reftextfacebefore
1258 \def\reftextcurrent {auf dieser Seite}%
1259 \def\reftextfaraway#1{auf Seite~\pageref{#1}}%
1260 \def\reftextpagerange#1#2{auf den Seiten~\pageref{#1}--\pageref{#2}}%
1261 \def\reftextlabelrange#1#2{\ref{#1} bis~\ref{#2}}%
1262 \let\vrefformat\vrefdefaultformat
1263 \let\Vrefformat\Vrefdefaultformat
1264 \let\fullrefformat\fullrefdefaultformat
1265 \let\vrefrangeformat\vrefrangedefaultformat
1266 }}
1267 % \end{macrocode}
1268 % Defaults for greek suggested by Apostolos Syropoulos\\
1269 % (\[email protected]=).
1270 % \changes{v1.2a}{1998/08/22}{Added defaults for greek}
1271 % \begin{macrocode}
1272 \DeclareOption{greek}
1273 {\vref@addto\extrasgreek{%
1274 \def\reftextfaceafter {sthn \reftextvario{paro'usa}%
1275 {ep'omenh} sel'ida}%
1276 \def\reftextfacebefore{sthn \reftextvario{paro'usa}{prohgo'umenh}
1277 sel'ida}%
1278 \def\reftextafter {sthn ep'omenh sel'ida}%
1279 \def\reftextbefore {sthn prohgo'umenh sel'ida}%
1280 \def\reftextcurrent {s'' aut'h th sel'ida}%
1281 \def\reftextfaraway#1{sth sel'ida\nobreakspace\pageref{#1}}%
1282 \def\reftextpagerange#1#2{stis sel'ides\nobreakspace
1283 \pageref{#1}---\pageref{#2}}%
1284 \def\reftextlabelrange#1#2{\ref{#1} ws\nobreakspace\ref{#2}}%
1285 \let\vrefformat\vrefdefaultformat
1286 \let\Vrefformat\Vrefdefaultformat
1287 \let\fullrefformat\fullrefdefaultformat
1288 \let\vrefrangeformat\vrefrangedefaultformat
1289 }}
1290 % \end{macrocode}
1291 % Icelandic defaults suggested by Thorhallur Sverrisson
1292 % (\[email protected]=).
1293 % \changes{v1.4t}{2007/09/07}{Added defaults for icelandic}
1294 % \begin{macrocode}
1295 \DeclareOption{icelandic}
1296 {\vref@addto\extrasicelandic{%
1297 \def\reftextfaceafter {\'{a} \reftextvario{n{\ae}stu}%
1298 {n{\ae}stu} s\'{i}{\dh}u}%
1299 \def\reftextfacebefore{\'{a} \reftextvario{fyrri}%
1300 {fyrri} s\'{i}{\dh}u}%
1301 \def\reftextafter {\'{a} \reftextvario{n{\ae}stu}%
1302 {n{\ae}stu} s\'{i}{\dh}u}%
1303 \def\reftextbefore {\'{a} \reftextvario{fyrri}{fyrri} s\'{i}{\dh}u}%
1304 \def\reftextcurrent {\'{a} \reftextvario{{\th}essari}%
1305 {{\th}essari} s\'{i}{\dh}u}%
1306 \def\reftextfaraway#1{\'{a} s\'{i}{\dh}u~\pageref{#1}}%
1307 \def\reftextpagerange#1#2{\'{a} s\'{i}{\dh}um~\pageref{#1}--\pageref{#2}}%
1308 \def\reftextlabelrange#1#2{\ref{#1} til~\ref{#2}}%
1309 \let\vrefformat\vrefdefaultformat
1310 \let\Vrefformat\Vrefdefaultformat
1311 \let\fullrefformat\fullrefdefaultformat
1312 \let\vrefrangeformat\vrefrangedefaultformat
1313 }}
1314 % \end{macrocode}
1315 % Defaults for Italian suggested by Giovanni Pensa
1316 % (\[email protected]=) with i{\TeX}nici.
1317 % \changes{v1.1b}{1995/10/19}{Added defaults for Italian}
1318 % \changes{v1.2a}{1998/08/22}{Removed incorrect warning}
1319 % \changes{v1.4k}{2004/10/30}{Added missing defaults supplied by Lapo Mori}
1320 % \changes{v1.4n}{2005/07/24}{Small change}
1321 % \changes{v1.4u}{2009/03/21}{Correction for \cs{reftextfaraway} suggested
1322 % by Lorenzo Pantieri}
1323 % \begin{macrocode}
1324 \DeclareOption{italian}
1325 {\vref@addto\extrasitalian{%
1326 \def\reftextfaceafter {\reftextvario{a fronte}%
1327 {nella pagina successiva}}%
1328 \def\reftextfacebefore{\reftextvario{a fronte}%
1329 {nella pagina precedente}}%
1330 \def\reftextafter {nella pagina \reftextvario{seguente}%
1331 {successiva}}%
1332 \def\reftextbefore {nella pagina precedente}%
1333 \def\reftextcurrent {in questa pagina}%
1334 \def\reftextfaraway#1{a pagina~\pageref{#1}}%
1335 \def\reftextpagerange#1#2{nelle pagine~\pageref{#1}--\pageref{#2}}%
1336 \def\reftextlabelrange#1#2{da~\ref{#1} a~\ref{#2}}%
1337 \let\vrefformat\vrefdefaultformat
1338 \let\Vrefformat\Vrefdefaultformat
1339 \let\fullrefformat\fullrefdefaultformat
1340 \let\vrefrangeformat\vrefrangedefaultformat
1341 }}
1342 % \end{macrocode}
1343 % Defaults for Japanese. It needs a special \cs{vrefformat},
1344 % \cs{Vrefformat}, \cs{fullrefformat} and \cs{vrefrangeformat}
1345 % for grammatical reasons. As our standard documentation
1346 % workflow uses pdf\TeX{} the Japanese letters can't be displayed
1347 % easily, so you will see missing glyphs below. To see the real
1348 % letters you have to look at the source or package file.
1349 % \changes{v1.6d}{2020/07/20}{Option japanese added (gh/352)}
1350 % \changes{v1.6e}{2020/07/25}{Option japanese changed (gh/352)}
1351 % \begin{allowtofu}
1352 % \begin{macrocode}
1353 \DeclareOption{japanese}
1354 {\vref@addto\extrasjapanese{%
1355 \def\reftextfaceafter {\reftextvario{č¦‹é–‹ć}{ꬔ}ćƒšćƒ¼ć‚ø}%
1356 \def\reftextfacebefore{\reftextvario{č¦‹é–‹ć}{前}ćƒšćƒ¼ć‚ø}%
1357 \def\reftextafter {\reftextvario{ē›“å¾Œć®}{ꬔ}ćƒšćƒ¼ć‚ø}%
1358 \def\reftextbefore {\reftextvario{ē›“å‰ć®}{前}ćƒšćƒ¼ć‚ø}%
1359 \def\reftextcurrent {\reftextvario{恓恮}{ē¾}ćƒšćƒ¼ć‚ø}%
1360 \def\reftextfaraway#1{\pageref{#1}ćƒšćƒ¼ć‚ø}%
1361 \def\reftextpagerange#1#2{\pageref{#1}恋悉\pageref{#2}ćƒšćƒ¼ć‚ø}%
1362 \def\reftextlabelrange#1#2{\ref{#1}恋悉\ref{#2}}%
1363 % \end{macrocode}
1364 % Note that the parentheses below are not normal ones but full width
1365 % ones U+FF08 and U+FF09!
1366 % \begin{macrocode}
1367 \def\vrefformat#1#2{\ref{#2}(\vpageref[#1]{#2})}%
1368 \def\Vrefformat#1#2{\Ref{#2}(\vpageref[#1]{#2})}%
1369 \def\fullrefformat#1{\ref{#1}(\reftextfaraway{#1})}%
1370 \def\vrefrangeformat#1#2#3{\reftextlabelrange{#2}{#3}%
1371 (\vpagerefrange[{#1}]{#2}{#3})}%
1372 }}
1373 % \end{macrocode}
1374 % \end{allowtofu}
1375 % Defaults for Hungarian by Jeff Goldberg
1376 % (\[email protected]=).
1377 % There is a problem with the use of the definite article
1378 % \textit{a} or \textit{az} in Hungarian before expansions
1379 % of |\vref| or |\ref|. The problem is that the word
1380 % should be \textit{az} if the number following would begin with
1381 % a vowel if spelled out, and \textit{a} if the number would begin
1382 % with a consonant.
1383 %
1384 % The option assumes that there is a command |\aza| defined which
1385 % helps resolving this problem.\footnote{This information is actually quite
1386 % old but unfortunately never made it into \pkg{varioref}. In case any work
1387 % has been undertaken to resolve this please inform the author about it.}
1388 % \changes{v1.2a}{1998/08/22}{Added defaults for magyar}
1389 % \changes{v1.4j}{2005/01/22}{Defined \cs{reftextfaceafter} and
1390 % \cs{reftextfacebefore} instead of \cs{reftextafter} and \cs{reftextbefore}}
1391 % \begin{macrocode}
1392 \DeclareOption{magyar}
1393 {\vref@addto\extrasmagyar{%
1394 \def\reftextafter {a k\"o\-vet\-kez\H{o} ol\-da\-lon}%
1395 \def\reftextbefore{az el\H{o}\-z\H{o} ol\-da\-lon}%
1396 \def\reftextfaceafter {\reftextvario{a t\'ul\-ol\-da\-lon}%
1397 {a k\"o\-vet\-kez\H{o} ol\-da\-lon}}%
1398 \def\reftextfacebefore{\reftextvario{a t\'ul\-ol\-da\-lon}%
1399 {az el\H{o}\-z\H{o} ol\-da\-lon}}%
1400 \def\reftextcurrent {ezen az ol\-da\-lon}%
1401 % \end{macrocode}
1402 % The following suggested patch has not been added yet (pending changes
1403 % in babel system).
1404 %\begin{verbatim}
1405 % \def\reftextfaraway#1{a~\csname @@magyar@az@lowxu\endcsname
1406 % {\pageref{#1}}.~ol\-da\-lon}%
1407 % \def\reftextpagerange#1#2{a~\csname @@magyar@az@lowxu\endcsname
1408 % {\pageref{#1}}%
1409 % --\pageref{#2}.~ol\-da\-la\-kon}%
1410 % \def\reftextlabelrange#1#2{{}\csname @@magyar@told\endcsname\ref{#1}+tol
1411 % \ref{#2}-ig}% Dat: `{}' is here for anti-\capitalize
1412 %\end{verbatim}
1413 % \begin{macrocode}
1414 \def\reftextfaraway#1{\aza{\pageref{#1}} \pageref{#1}.~ol\-da\-lon}%
1415 \def\reftextpagerange#1#2{\vref@stringwarning\reftextpagerange
1416 on pages~\pageref{#1}--\pageref{#2}}%
1417 \def\reftextlabelrange#1#2{\vref@stringwarning\reflabelpagerange
1418 \ref{#1} to~\ref{#2}}%
1419 \let\vrefformat\vrefdefaultformat
1420 \let\Vrefformat\Vrefdefaultformat
1421 \let\fullrefformat\fullrefdefaultformat
1422 \let\vrefrangeformat\vrefrangedefaultformat
1423 }%
1424 % \end{macrocode}
1425 % The |\AtBeginDocument| needs to be executed when the option is
1426 % processed and not inside the babel interface.
1427 % \changes{v1.4i}{2004/02/27}{Moved \cs{AtBeginDocument}}
1428 % \begin{macrocode}
1429 \AtBeginDocument{\providecommand\aza[1]{a/az%
1430 \PackageError{varioref}{%
1431 Proper definition for command \noexpand\aza missing}%
1432 {You need to (re)define the command \noexpand\aza that
1433 takes one argument (a number or a \noexpand\pageref command)
1434 and produces the string `a' or `az' depending on the argument
1435 value. It should also accept an optional argument (default `l')
1436 to denote whether or not the string should be lowercase or
1437 uppercase.}}}%
1438 }
1439 % \end{macrocode}
1440 % The Norwegian and `nynorsk' translations have been provided by
1441 % Dag F Langmyhr \verb=<[email protected]>= and Karl Ove Hufthammer
1442 % \verb=<[email protected]>=.
1443 % \changes{v1.0q}{1995/04/06}{Added defaults for norsk}
1444 % \changes{v1.0q}{1995/04/06}{Added defaults for nynorsk}
1445 % \changes{v1.2a}{1998/08/22}{Updated defaults for norsk}
1446 % \changes{v1.2a}{1998/08/22}{Updated defaults for nynorsk}
1447 % \changes{v1.2a}{1998/08/22}{Added norsk defaults for
1448 % \cs{reftextpagerange} and \cs{reftextlabelrange}}
1449 % \changes{v1.2a}{1998/08/22}{Added nynorsk defaults for
1450 % \cs{reftextpagerange} and \cs{reftextlabelrange}}
1451 % \changes{v1.2i}{2001/01/12}{Updated nynorsk defaults}
1452 % \begin{macrocode}
1453 \DeclareOption{norsk}
1454 {\vref@addto\extrasnorsk{%
1455 \def\reftextfaceafter {p\aa{} neste side}%
1456 \def\reftextfacebefore{p\aa{} forrige side}%
1457 \def\reftextafter {p\aa{} neste side}%
1458 \def\reftextbefore {p\aa{} forrige side}%
1459 \def\reftextcurrent {p\aa{} denne siden}%
1460 \def\reftextfaraway#1{p\aa{} side~\pageref{#1}}%
1461 \def\reftextpagerange#1#2{p\aa{} side~\pageref{#1}--\pageref{#2}}%
1462 \def\reftextlabelrange#1#2{\ref{#1} til~\ref{#2}}%
1463 \let\vrefformat\vrefdefaultformat
1464 \let\Vrefformat\Vrefdefaultformat
1465 \let\fullrefformat\fullrefdefaultformat
1466 \let\vrefrangeformat\vrefrangedefaultformat
1467 }}
1468 \DeclareOption{nynorsk}
1469 {\vref@addto\extrasnynorsk{%
1470 \def\reftextfaceafter {p\aa{} neste side}%
1471 \def\reftextfacebefore{p\aa{} f\o{}rre side}%
1472 \def\reftextafter {p\aa{} neste side}%
1473 \def\reftextbefore {p\aa{} f\o{}rre side}%
1474 \def\reftextcurrent {p\aa{} denne sida}%
1475 \def\reftextfaraway#1{p\aa{} side~\pageref{#1}}%
1476 \def\reftextpagerange#1#2{p\aa{} side~\pageref{#1}--\pageref{#2}}%
1477 \def\reftextlabelrange#1#2{\ref{#1} til~\ref{#2}}%
1478 \let\vrefformat\vrefdefaultformat
1479 \let\Vrefformat\Vrefdefaultformat
1480 \let\fullrefformat\fullrefdefaultformat
1481 \let\vrefrangeformat\vrefrangedefaultformat
1482 }}
1483 % \end{macrocode}
1484 % The polish translations have been provided by
1485 % Tomasz Michniewski \\
1486 % \verb=<[email protected]>=.
1487 % The use of the command \verb=\eob= and \verb=aob= etc.\
1488 % requires appropriate definitions as provided, for example, by
1489 % the babel system. This should probably be handled differently
1490 % but it would require modifications in babel's language support.
1491 % \changes{v1.1d}{1997/12/06}{Added defaults for polish}
1492 % \changes{v1.2a}{1998/08/22}{Added polish defaults for
1493 % \cs{reftextpagerange} and \cs{reftextlabelrange}}
1494 % \changes{v1.4n}{2005/09/14}{Changed default for \cs{reftextfaraway}}
1495 % \begin{macrocode}
1496 \DeclareOption{polish}
1497 {\vref@addto\extraspolish{%
1498 \def\reftextfaceafter {na \reftextvario{s\aob{}siedniej}%
1499 {nast\eob{}pnej} stronie}%
1500 \def\reftextfacebefore{na \reftextvario{s\aob{}siedniej}%
1501 {poprzedniej} stronie}%
1502 \def\reftextafter {na nast\eob{}pnej stronie}%
1503 \def\reftextbefore {na poprzedniej stronie}%
1504 \def\reftextcurrent {na \reftextvario{tej
1505 samej}{bie\zkb{}\aob{}cej} stronie}%
1506 \def\reftextfaraway#1{na stronie~\pageref{#1}}%
1507 \def\reftextpagerange#1#2{na stronach~\pageref{#1}--\pageref{#2}}%
1508 \def\reftextlabelrange#1#2{od~\ref{#1} do~\ref{#2}}%
1509 \let\vrefformat\vrefdefaultformat
1510 \let\Vrefformat\Vrefdefaultformat
1511 \let\fullrefformat\fullrefdefaultformat
1512 \let\vrefrangeformat\vrefrangedefaultformat
1513 }}
1514 % \end{macrocode}
1515 % The Portuges default text has been provided by
1516 % Jos\'e Carlos Oliveira Santos \[email protected]=.
1517 % \changes{v1.2b}{1999/11/25}{Added portuguese defaults}
1518 % \changes{v1.2c}{1999/12/02}{Added more portuguese defaults}
1519 % \changes{v1.4r}{2007/05/26}{Misspelling of \cs{extrasportuges}}
1520 % \begin{macrocode}
1521 \DeclareOption{portuges}
1522 {\vref@addto\extrasportuges{%
1523 \def\reftextfaceafter {na \reftextvario{p\'agina ao lado}{pr\'oxima
1524 p\'agina}}%
1525 \def\reftextfacebefore{na p\'agina \reftextvario{ao lado}{anterior}}%
1526 \def\reftextafter {na \reftextvario{p\'agina seguinte}{pr\'oxima
1527 p\'agina}}%
1528 \def\reftextbefore{na p\'agina \reftextvario{anterior}{precedente}}%
1529 \def\reftextcurrent {nesta p\'agina}%
1530 \def\reftextfaraway#1{na p\'agina~\pageref{#1}}%
1531 \def\reftextpagerange#1#2{nas p\'aginas~\pageref{#1}--\pageref{#2}}%
1532 \def\reftextlabelrange#1#2{\ref{#1} a~\ref{#2}}%
1533 \let\vrefformat\vrefdefaultformat
1534 \let\Vrefformat\Vrefdefaultformat
1535 \let\fullrefformat\fullrefdefaultformat
1536 \let\vrefrangeformat\vrefrangedefaultformat
1537 }}
1538 % \end{macrocode}
1539 % Updates to the default text for Romanian have been suggested by Florin Oprina
1540 % (\verb=<[email protected]>=).
1541 % \changes{v1.4v}{2009/06/13}{Incorrect text in \cs{reftextafter} (pr/4070)}
1542 % \changes{v1.5a}{2014/07/03}{Correct text in \cs{reftextbefore}}
1543 % \begin{macrocode}
1544 \DeclareOption{romanian}
1545 {\vref@addto\extrasromanian{%
1546 \def\reftextfaceafter {pe pagina \reftextvario{opus\u{a}}{urm\u{a}toarei}}%
1547 \def\reftextfacebefore{pe pagina \reftextvario{opus\u{a}}{precedentei}}%
1548 \def\reftextafter {\reftextvario{pe pagina urm\u{a}toare}%
1549 {pe urm\u{a}toarea pagin\u{a}}}%
1550 \def\reftextbefore {pe pagina \reftextvario{precedent\u{a}}%
1551 {precedentei}}%
1552 \def\reftextcurrent {pe aceast\u{a} pagin\u{a}}%
1553 \def\reftextfaraway#1{pe pagina~\pageref{#1}}%
1554 \def\reftextpagerange#1#2{pe paginile~\pageref{#1}--\pageref{#2}}%
1555 \def\reftextlabelrange#1#2{\ref{#1} la~\ref{#2}}%
1556 \let\vrefformat\vrefdefaultformat
1557 \let\Vrefformat\Vrefdefaultformat
1558 \let\fullrefformat\fullrefdefaultformat
1559 \let\vrefrangeformat\vrefrangedefaultformat
1560 }}
1561 % \end{macrocode}
1562 % The text for Russian was taken from the book in Russian by
1563 % I.~A.~Kotelnikov and P.~Z.~Chebotaev, and adapted
1564 % to the encoding-independent form by Vladimir Volovich
1565 % (\[email protected]=).
1566 % \changes{v1.2a}{1998/11/23}{Added russian strings}
1567 % \changes{v1.2a}{1998/11/24}{Added defaults for
1568 % \cs{reftextpagerange} and \cs{reftextlabelrange}}
1569 % \begin{macrocode}
1570 \DeclareOption{russian}
1571 {\vref@addto\extrasrussian{%
1572 \def\reftextfaceafter{\cyrn\cyra\ \reftextvario{\cyrp\cyrr\cyro
1573 \cyrt\cyri\cyrv\cyro\cyrp\cyro\cyrl\cyro\cyrzh\cyrn\cyro\cyrishrt}%
1574 {\cyrs\cyrl\cyre\cyrd\cyru\cyryu\cyrshch\cyre\cyrishrt}\ \cyrs\cyrt
1575 \cyrr\cyra\cyrn\cyri\cyrc\cyre}%
1576 \def\reftextfacebefore{\cyrn\cyra\ \reftextvario{\cyrp\cyrr\cyro
1577 \cyrt\cyri\cyrv\cyro\cyrp\cyro\cyrl\cyro\cyrzh\cyrn\cyro\cyrishrt}%
1578 {\cyrp\cyrr\cyre\cyrd\cyrery\cyrd\cyru\cyrshch\cyre\cyrishrt}\
1579 \cyrs\cyrt\cyrr\cyra\cyrn\cyri\cyrc\cyre}%
1580 \def\reftextafter{\cyrn\cyra\ \cyrs\cyrl\cyre\cyrd\cyru\cyryu\cyrshch
1581 \cyre\cyrishrt\ \cyrs\cyrt\cyrr\cyra\cyrn\cyri\cyrc\cyre}%
1582 \def\reftextbefore{\cyrn\cyra\ \reftextvario{\cyrp\cyrr\cyre\cyrd
1583 \cyrsh\cyre\cyrs\cyrt\cyrv\cyru\cyryu\cyrshch\cyre\cyrishrt}%
1584 {\cyrp\cyrr\cyre\cyrd\cyrery\cyrd\cyru\cyrshch\cyre\cyrishrt}%
1585 \ \cyrs\cyrt\cyrr\cyra\cyrn\cyri\cyrc\cyre}%
1586 \def\reftextcurrent{\cyrn\cyra\ \reftextvario{\cyrerev\cyrt\cyro
1587 \cyrishrt}{\cyrd\cyra\cyrn\cyrn\cyro\cyrishrt}\ \cyrs\cyrt\cyrr
1588 \cyra\cyrn\cyri\cyrc\cyre}%
1589 \def\reftextfaraway#1{\cyrn\cyra\ \cyrs.~\pageref{#1}}%
1590 \def\reftextpagerange#1#2{\cyrn\cyra\ \cyrs\cyrt\cyrr\cyra\cyrn
1591 \cyri\cyrc\cyra\cyrh~\pageref{#1}--\pageref{#2}}%
1592 \def\reftextlabelrange#1#2{\cyrs~\ref{#1}\ \cyrp\cyro~\ref{#2}}%
1593 \let\vrefformat\vrefdefaultformat
1594 \let\Vrefformat\Vrefdefaultformat
1595 \let\fullrefformat\fullrefdefaultformat
1596 \let\vrefrangeformat\vrefrangedefaultformat
1597 }}
1598 % \end{macrocode}
1599 % The text for Slovak defaults was contributed by Miroslav Sedivy\\
1600 % (\verb=<[email protected]>=).
1601 % \changes{v1.4b}{2002/03/11}{Contributed defaults added}
1602 % \begin{macrocode}
1603 \DeclareOption{slovak}
1604 {\vref@addto\extrasslovak{%
1605 \def\reftextfaceafter {na \reftextvario{proti\v lahlej}%
1606 {nasleduj\'ucej} strane}%
1607 \def\reftextfacebefore{na \reftextvario{proti\v lahlej}%
1608 {predch\'adzaj\'ucej} strane}%
1609 \def\reftextafter {na \reftextvario{nasleduj\'ucej}%
1610 {\v dal\v sej} strane}%
1611 \def\reftextbefore {na \reftextvario{predch\'adzaj\'ucej}%
1612 {predo\v slej} strane}%
1613 \def\reftextcurrent {na tejto strane}%
1614 \def\reftextfaraway#1{na strane~\pageref{#1}}%
1615 \def\reftextpagerange#1#2{na stran\'ach~\pageref{#1}--\pageref{#2}}%
1616 \def\reftextlabelrange#1#2{\ref{#1} a\v z~\ref{#2}}%
1617 \let\vrefformat\vrefdefaultformat
1618 \let\Vrefformat\Vrefdefaultformat
1619 \let\fullrefformat\fullrefdefaultformat
1620 \let\vrefrangeformat\vrefrangedefaultformat
1621 }}
1622 % \end{macrocode}
1623 % The text for Slovene defaults was contributed by Roman Maurer\\
1624 % (\verb=<[email protected]>=).
1625 % \changes{v1.4a}{2002/03/05}{Contributed defaults added}
1626 % \begin{macrocode}
1627 \DeclareOption{slovene}
1628 {\vref@addto\extrasslovene{%
1629 \def\reftextfaceafter {na naslednji strani}%
1630 \def\reftextfacebefore{na prej\v{s}nji strani}%
1631 \let\reftextafter \reftextfaceafter
1632 \let\reftextbefore \reftextfacebefore
1633 \def\reftextcurrent {na \reftextvario{tej}{trenutni} strani}%
1634 \def\reftextfaraway#1{na strani~\pageref{#1}}%
1635 \def\reftextpagerange#1#2{na straneh~\pageref{#1}--\pageref{#2}}%
1636 \def\reftextlabelrange#1#2{od~\ref{#1} do~\ref{#2}}%
1637 \let\vrefformat\vrefdefaultformat
1638 \let\Vrefformat\Vrefdefaultformat
1639 \let\fullrefformat\fullrefdefaultformat
1640 \let\vrefrangeformat\vrefrangedefaultformat
1641 }}
1642 % \end{macrocode}
1643 % Text for Spanish defaults was contributed by Julio Sanchez
1644 % (\[email protected]=) and Fernando Dobladez (\verb=<[email protected]>=).
1645 % \changes{v1.0f}{1994/03/16}{Inserted missing hash mark}
1646 % \changes{v1.0k}{1994/06/05}{Corrected misspelled cmd `extrasspanish}
1647 % \changes{v1.4a}{2002/03/05}{Missing defaults added}
1648 % \changes{v1.4o}{2005/11/26}{Single hyphen in range}
1649 % \begin{macrocode}
1650 \DeclareOption{spanish}
1651 {\vref@addto\extrasspanish{%
1652 \def\reftextfaceafter {en la p\'agina siguiente}%
1653 \def\reftextfacebefore{en la p\'agina anterior}%
1654 \let\reftextafter \reftextfaceafter
1655 \let\reftextbefore \reftextfacebefore
1656 \def\reftextcurrent {en esta p\'agina}%
1657 \def\reftextfaraway#1{en la p\'agina~\pageref{#1}}%
1658 \def\reftextpagerange#1#2{en las p\'aginas~\pageref{#1}%
1659 -\pageref{#2}}%
1660 \def\reftextlabelrange#1#2{\ref{#1} a~\ref{#2}}%
1661 \let\vrefformat\vrefdefaultformat
1662 \let\Vrefformat\Vrefdefaultformat
1663 \let\fullrefformat\fullrefdefaultformat
1664 \let\vrefrangeformat\vrefrangedefaultformat
1665 }}
1666 % \end{macrocode}
1667 % The text for Swedish was contributed by Mats Dahlgren
1668 % (\[email protected]=).
1669 % \changes{v1.0p}{1995/01/10}{Added swedish strings}
1670 % \changes{v1.2a}{1998/08/22}{Added swedish defaults for
1671 % \cs{reftextpagerange} and \cs{reftextlabelrange}}
1672 % \begin{macrocode}
1673 \DeclareOption{swedish}
1674 {\vref@addto\extrasswedish{%
1675 \def\reftextfaceafter {p\aa\ \reftextvario{motst\aa ende}%
1676 {n\"{a}sta} sida}%
1677 \def\reftextfacebefore{p\aa\ \reftextvario{motst\aa ende}%
1678 {f\"{o}reg\aa ende} sida}%
1679 \def\reftextafter {p\aa\ \reftextvario{f\"{o}ljande}%
1680 {n\"{a}sta} sida}%
1681 \def\reftextbefore {p\aa\ f\"{o}reg\aa ende sida}%
1682 \def\reftextcurrent {p\aa\ denna sida}%
1683 \def\reftextfaraway#1{p\aa\ sidan~\pageref{#1}}%
1684 \def\reftextpagerange#1#2{p\aa\
1685 sidorna~\pageref{#1}--\pageref{#2}}%
1686 \def\reftextlabelrange#1#2{\ref{#1} till~\ref{#2}}%
1687 \let\vrefformat\vrefdefaultformat
1688 \let\Vrefformat\Vrefdefaultformat
1689 \let\fullrefformat\fullrefdefaultformat
1690 \let\vrefrangeformat\vrefrangedefaultformat
1691 }}
1692 \DeclareOption{turkish}
1693 {\vref@excuse{turkish}%
1694 \vref@addto\extrasturkish{%
1695 \def\reftextfaceafter {on the \reftextvario{facing}{next} page}%
1696 \def\reftextfacebefore{on the \reftextvario{facing}{preceding}
1697 page}%
1698 \def\reftextafter {on the \reftextvario{following}{next} page}%
1699 \def\reftextbefore {on the \reftextvario{preceding}{previous} page}%
1700 \def\reftextcurrent {on \reftextvario{this}{the current} page}%
1701 \def\reftextfaraway#1{on page~\pageref{#1}}%
1702 \def\reftextpagerange#1#2{on pages~\pageref{#1}--\pageref{#2}}%
1703 \def\reftextlabelrange#1#2{\ref{#1} to~\ref{#2}}%
1704 \let\vrefrangeformat\vrefrangedefaultformat
1705 }}
1706 % \end{macrocode}
1707 % The text for Ukrainian defaults was contributed by Mykola Lyakhovych\\
1708 % (\verb=<[email protected]>=).
1709 % \changes{v1.4l}{2005/04/24}{Contributed defaults added}
1710 % \begin{macrocode}
1711 \DeclareOption{ukrainian}
1712 {\vref@addto\extrasukrainian{%
1713 \def\reftextfaceafter{\cyrn\cyra\ \reftextvario{\cyrp\cyrr\cyro
1714 \cyrt\cyri\cyrl\cyre\cyrzh\cyrn\cyrii\cyrishrt}%
1715 {\cyrn\cyra\cyrs\cyrt\cyru\cyrp\cyrn\cyrii\cyrishrt}\ \cyrs\cyrt
1716 \cyro\cyrr\cyri\cyrn\cyrc\cyrii}%
1717 \def\reftextfacebefore{\cyrn\cyra\ \reftextvario{\cyrp\cyrr\cyro
1718 \cyrt\cyri\cyrl\cyre\cyrzh\cyrn\cyrii\cyrishrt}%
1719 {\cyrp\cyro\cyrp\cyre\cyrr\cyre\cyrd\cyrn\cyrii\cyrishrt}\
1720 \cyrs\cyrt\cyro\cyrr\cyrii\cyrn\cyrc\cyrii}%
1721 \def\reftextafter{\cyrn\cyra\ \cyrn\cyra\cyrs\cyrt\cyru\cyrp\cyrn
1722 \cyrii\cyrishrt\ \cyrs\cyrt\cyro\cyrr\cyrii\cyrn\cyrc\cyrii}%
1723 \def\reftextbefore{\cyrn\cyra\ \cyrp\cyro\cyrp\cyre\cyrr\cyre\cyrd
1724 \cyrn\cyrii\cyrishrt\ \cyrs\cyrt\cyro\cyrr\cyrii\cyrn\cyrc\cyrii}%
1725 \def\reftextcurrent{\cyrn\cyra\ \reftextvario{\cyrc\cyrii\cyrishrt}%
1726 {\cyrd\cyra\cyrn\cyrii\cyrishrt}\ \cyrs\cyrt\cyro\cyrr\cyrii\cyrn
1727 \cyrc\cyrii}%
1728 \def\reftextfaraway#1{\cyrn\cyra\ \cyrs.~\pageref{#1}}%
1729 \def\reftextpagerange#1#2{\cyrn\cyra\ \cyrs\cyrt\cyro\cyrr\cyrii
1730 \cyrn\cyrk\cyra\cyrh~\pageref{#1}--\pageref{#2}}%
1731 \def\reftextlabelrange#1#2{\cyrz~\ref{#1}\ \cyrd\cyro~\ref{#2}}%
1732 \let\vrefformat\vrefdefaultformat
1733 \let\Vrefformat\Vrefdefaultformat
1734 \let\fullrefformat\fullrefdefaultformat
1735 \let\vrefrangeformat\vrefrangedefaultformat
1736 }}
1737 % \end{macrocode}
1738 % We support francais as an alternative to french since people
1739 % might be used to it, but we discourage it.
1740 % \begin{macrocode}
1741 \DeclareOption{francais}{%
1742 \typeout{Please use `french' instead of `francais'}%
1743 \ExecuteOptions{french}}
1744 \DeclareOption{germanb}{%
1745 \typeout{Please use `german' instead of `germanb'}%
1746 \ExecuteOptions{german}}
1747 % \end{macrocode}
1748 % \end{macro}
1749 % \end{macro}
1750 % \end{macro}
1751 % \end{macro}
1752 % \end{macro}
1753 %
1754 % During document preparation errors due to |\vref| are usually of
1755 % not much interest. For this reason the draft option turns them into
1756 % warnings by issuing a |\vrefwarning| command. The final option
1757 % (default) stops with an error message when varioref detects a possible
1758 % loop.
1759 % \changes{v1.1h}{1998/08/01}{Added draft and final options}
1760 % \begin{macrocode}
1761 \DeclareOption{draft}{\AtEndOfPackage\vrefwarning}
1762 \DeclareOption{final}{\AtEndOfPackage\vrefshowerrors} % the default
1763 % \end{macrocode}
1764 %
1765 %
1766 % Whether or not \pkg{varioref} uses its own white space and
1767 % removes the one in the source document is handled by the
1768 % following two options. For historical reasons the default is to
1769 % handle the space, but the recommendation these days is to use
1770 % \texttt{nospace}.
1771 % \changes{v1.6a}{2019/08/25}{Provide options \texttt{space} and \texttt{nospace}}
1772 % \begin{macrocode}
1773 \newif\if@vrefhandlespace
1774 \DeclareOption{space} {\@vrefhandlespacetrue}
1775 \DeclareOption{nospace}{\@vrefhandlespacefalse}
1776 % \end{macrocode}
1777 %
1778 %
1779 %
1780 %
1781 % After all options are declared we execute the default option
1782 % \texttt{english} to set up the defaults and then call
1783 % |\ProcessOptions*| to handle any option passed to the package.
1784 % The star form is used since we want to execute the options in the
1785 % order they are given (in case this isn't used together with the
1786 % \pkg{babel} package).
1787 % \begin{macrocode}
1788 \ExecuteOptions{english,final,space}
1789 % \end{macrocode}
1790 %
1791 %
1792 % \subsection{Defining the main macros}
1793 %
1794 % \begin{macro}{\vr@cnt}
1795 % To generate new labels we use a counter and construct the
1796 % internal label names by prefixing the current counter value with
1797 % the string |vr@|. We need a \LaTeX{} counter to get |\include|s
1798 % handled correctly.
1799 % \changes{v0.1e}{1992/11/15}{use LaTeX counter}
1800 % \begin{macrocode}
1801 \newcounter{vrcnt}
1802 % \end{macrocode}
1803 % \end{macro}
1804 %
1805 % \begin{macro}{\vpageref}
1806 % \changes{v1.3a}{2001/04/12}{Scan for star form}
1807 % \begin{macro}{\vp@geref}
1808 % The command |\vpageref| generates the appropriate string by first
1809 % parsing the optional arguments (if any) and then compares the
1810 % internal and the user label. This command should be robust since
1811 % the user might put it anywhere.
1812 %
1813 % We now start by scanning for a star and then call either
1814 % |\vp@gerefstar| or |\vp@geref|.
1815 % The space handling logic is a bit twisted these days: if the
1816 % option \texttt{space} is
1817 % in force then preceding spaces in the document are removed and
1818 % the star means that the command should not add its own
1819 % space. However, with option \texttt{nospace} any space already in the
1820 % source will be left alone and the command doesn't add its own
1821 % space either. Thus in this case the star form doesn't
1822 % have any effect and below |\vp@gerefstar| is let to
1823 % |\vp@geref|. This allows a package like \pkg{hyperef} to redefine
1824 % it and use it for its own tasks (like denoting that no link should
1825 % be produced).
1826 % \begin{macrocode}
1827 \DeclareRobustCommand\vpageref{\@ifstar
1828 {\let\vref@maybe@space\@empty\vp@gerefstar}%
1829 {\let\vref@maybe@space\space \vp@geref}}
1830 % \end{macrocode}
1831 %
1832 % \begin{macrocode}
1833 \def\vp@geref{\@ifnextchar[%
1834 % \end{macrocode}
1835 % The default for the first optional argument is the string hidden
1836 % in the macro |\reftextcurrent|.
1837 % \begin{macrocode}
1838 \@vpageref{\@vpageref[\reftextcurrent]}%
1839 }
1840 % \end{macrocode}
1841 % \end{macro}
1842 % \end{macro}
1843 %
1844 % \begin{macro}{\vref@space}
1845 % \begin{macro}{\vref@maybe@space}
1846 % \changes{v1.4a}{2002/03/06}{Default added}
1847 % A default for |\vref@space|. This isn't really needed except in
1848 % the case that somebody has hooked into the \pkg{varioref}
1849 % interfaces at a lower level (which isn't really supported,
1850 % but\ldots). So giving a default will prevent an error message in
1851 % that case (and should hopefully produce the same behavior as before).
1852 % \changes{v1.6c}{2019/11/05}{Support (mis)use of internal interface by
1853 % fancyref (sx/515106)}
1854 % \begin{macrocode}
1855 \let\vref@space\space
1856 \let\vref@maybe@space\space
1857 % \end{macrocode}
1858 % \end{macro}
1859 % \end{macro}
1860 %
1861 % \begin{macro}{\@vpageref}
1862 % More parsing\ldots
1863 % \begin{macrocode}
1864 \def\@vpageref[#1]{\@ifnextchar[%
1865 % \end{macrocode}
1866 % By default the second optional argument is empty.
1867 % \changes{v1.0h}{1994/06/11}{Pass first argument in both cases}
1868 % \changes{v1.0i}{1994/06/20}{Do it correctly}
1869 % \changes{v1.6a}{2019/08/25}{Default for optional argument changed}
1870 % \begin{macrocode}
1871 {\@@vpageref{#1}}{\@@vpageref{#1}[]}}
1872 % \end{macrocode}
1873 % \end{macro}
1874 %
1875 % \begin{macro}{\@@vpageref}
1876 % The |\@@vpageref| macro finally generates the references by
1877 % comparing the value of an internal label with the value of the
1878 % user label.
1879 % \changes{v1.0h}{1994/06/11}{Change internal interface}
1880 % \begin{macrocode}
1881 \def\@@vpageref#1[#2]#3{%
1882 % \end{macrocode}
1883 % First it switches to horizontal mode if necessary. If there was a
1884 % preceding space we remember its size in |\@tempskipa| and then remove it for
1885 % reinsertion later.
1886 % \changes{v1.6a}{2019/08/25}{Don't drop a preceding space completely
1887 % but reinsert it later after setting a label}
1888 % \begin{macrocode}
1889 \leavevmode
1890 \@tempskipa\lastskip \unskip
1891 % \end{macrocode}
1892 % Then it advances the counter |\c@vrcnt| by one which is used to
1893 % generate internal label names.
1894 % \begin{macrocode}
1895 \global\advance\c@vrcnt\@ne
1896 % \end{macrocode}
1897 % Then it checks if for the current value of |\c@vrcnt| a label
1898 % command was issued in the last run. If not it pretends that there
1899 % was one with the value |{??}{??}|. Thereafter it stores the
1900 % pageref value for this label in the macro |\@tempa|.
1901 % \begin{macrocode}
1902 \vref@pagenum\@tempa{\the\c@vrcnt @vr}%
1903 % \end{macrocode}
1904 % Here we check that the generated text is not going across a page
1905 % boundary.
1906 % \changes{v0.1f}{1993/01/01}{Add another label to catch cross-overs}
1907 % \begin{macrocode}
1908 \vref@pagenum\@tempb{\the\c@vrcnt @xvr}%
1909 % \end{macrocode}
1910 % \changes{v1.0l}{1994/07/07}{Explicitly expand `label argument for
1911 % babel}
1912 % In version 1.0l the label string has been turned around so that
1913 % the number comes first. This was done to allow easy explicit
1914 % expansion of the number before it is passed to the |\label|
1915 % command. In the babel system the argument of |label| was not
1916 % expanded with the result that wrong label strings have been
1917 % generated. This is a general problem that might need a completely
1918 % different solution in babel but for now the change below (and in
1919 % some other places in the code) should solve the problem for this
1920 % special combination of packages.
1921 %
1922 % These days we actually use |\vref@label| instead of |\label| as
1923 % this avoids problems with Babel or \pkg{amsmath} redefining
1924 % the latter command.
1925 % \changes{v1.4e}{2003/01/08}{Use \cs{vref@label} instead of
1926 % \cs{label} (pr/3489)}
1927 % \begin{macrocode}
1928 \vref@label{\the\c@vrcnt @xvr}%
1929 % \end{macrocode}
1930 % Since we have removed
1931 % any leading space above we now insert a space here after the
1932 % label. It is done here so that it is still visible from following
1933 % code---the space before the label would be hidden.
1934 % What kind of space depends on the options to the
1935 % package. If \texttt{space} was specified, we insert our own
1936 % space, namely |\vref@maybe@space|. This will typeset a space
1937 % unless the star form of the current command was used.
1938 % \begin{macrocode}
1939 \if@vrefhandlespace
1940 \vref@maybe@space
1941 \else
1942 % \end{macrocode}
1943 % But if \texttt{nospace} is in force we simply use the same space
1944 % value that was used in the source document (unless that was zero
1945 % or non-existent).
1946 % \begin{macrocode}
1947 \ifdim\@tempskipa=\z@ \else
1948 \hskip\@tempskipa
1949 \fi
1950 \fi
1951 % \end{macrocode}
1952 % \changes{v1.1g}{1998/05/10}{Test if inside AMS display (pr2175)}
1953 % Inside displays of the \pkg{amsmath} package the |\label| command
1954 % is redefined which makes the test for loops incorrect if a |\vref|
1955 % is used in, say, |\intertext|. So we test this condition first and
1956 % only do the test if |\label| doesn't have a special meaning.
1957 % [This is no longer necessary as |\label| isn't used any more]
1958 % \begin{macrocode}
1959 % \ifx\label\label@in@display\else
1960 \ifx\@tempa\@tempb
1961 \let\vref@may@loop\relax
1962 \else
1963 % \end{macrocode}
1964 % If both points do not fall onto the same page with either issue
1965 % an error or a warning message.
1966 % However, we do no longer issue that warning now but wait until we
1967 % are sure that both labels aren't ``far away'' because in that
1968 % case it doesn't matter. So we just save that info in a macro now.
1969 % \changes{v1.0g}{1994/05/27}{Looping pages shown in wrong order}
1970 % \changes{v1.5c}{2016/02/16}{Delay generating the looping warning
1971 % until we know more}
1972 % \begin{macrocode}
1973 \edef\vref@may@loop{%
1974 \noexpand\vref@err{\noexpand\vref or \noexpand\vpageref
1975 at page boundary
1976 \@tempb-\@tempa\space (may loop)%
1977 }%
1978 }%
1979 \fi
1980 % \fi
1981 % \end{macrocode}
1982 % Same game for the user requested label; this time the page
1983 % reference is saved in |\thevpagerefnum|.
1984 % \changes{v1.4c}{2002/06/14}{Use \cs{thevpagerefnum} instead of \cs{@tempb}}
1985 % \begin{macrocode}
1986 \vrefpagenum\thevpagerefnum{#3}%
1987 % \end{macrocode}
1988 % Now after the internal label has served its purpose it would be
1989 % nice to free the memory it occupies by using something like
1990 % \begin{verbatim}
1991 % \global\expandafter\let
1992 % \csname r@\the\c@vrcnt @vr\endcsname\@empty
1993 %\end{verbatim}
1994 % But this is not possible because it would result in getting
1995 % `Labels may have changed\ldots' warnings for every run. Now we
1996 % are ready to produce the textual strings.
1997 % \begin{macrocode}
1998 \ifx\@tempa\thevpagerefnum
1999 % \end{macrocode}
2000 % If they are the same we insert the first argument into the input
2001 % stream. Otherwise we insert the second argument. Recall that
2002 % those are the two optional arguments of |...|. However, if the
2003 % user explicitly requested an empty text string using the optional
2004 % argument we cancel any preceding space since in this case we are
2005 % otherwise likely to end up with spaces one before and one after
2006 % |\vpageref|.
2007 % \changes{v1.2f}{2000/07/07}{Don't output space if optional argument
2008 % empty (pr/3230)}
2009 % \begin{macrocode}
2010 \def\@tempc{#1}%
2011 \ifx\@tempc\@empty
2012 \unskip
2013 \else
2014 #1%
2015 \fi
2016 \else
2017 % \end{macrocode}
2018 % If |#2| is empty we do nothing, otherwise we insert it followed by
2019 % a space.
2020 % \begin{macrocode}
2021 \def\@tempc{#2}%
2022 \ifx\@tempc\@empty \else
2023 #2\vref@space
2024 \fi
2025 % \end{macrocode}
2026 % Now we check if the page number of the referenced object (stored
2027 % in |\thevpagerefnum|) is a single positive number.
2028 % \begin{macrocode}
2029 \is@pos@number\thevpagerefnum
2030 {%
2031 % \end{macrocode}
2032 % If so, we check if the current position (stored in |\@tempa|) is
2033 % a positive number. If this is the case we assign this number to
2034 % the counter register |\@tempcnta| and add one to it.
2035 % \begin{macrocode}
2036 \is@pos@number\@tempa
2037 {\@tempcnta\@tempa
2038 \advance\@tempcnta\@ne
2039 }%
2040 % \end{macrocode}
2041 % If it is not a positive number we assign the largest possible
2042 % number to |\@tempcnta|, thereby pretending that label and
2043 % reference are miles away from each other.
2044 % \begin{macrocode}
2045 {\@tempcnta\maxdimen}%
2046 % \end{macrocode}
2047 % Now we are ready to check if reference and object are on nearby
2048 % pages. |\thevpagerefnum| will expand to the page number of the object
2049 % (and we know that this is a number) and |\@tempcnta| is either
2050 % one higher than the reference page or completely out of bounds.
2051 % So if both represent the same value then the object lies one page
2052 % after its reference.
2053 % \begin{macrocode}
2054 \ifnum \thevpagerefnum =\@tempcnta
2055 % \end{macrocode}
2056 % Thus if the object falls onto an odd page then the reference is
2057 % on the facing even page (and so we insert |\reftextfaceafter|),
2058 % otherwise the object can not be seen from the reference (and we
2059 % insert |\reftextafter|). Don't be surprised if we are not
2060 % using |\thevpagerefnum| in the check. Since |\@tempcnta| has the same
2061 % value it is faster to use the register instead of parsing the
2062 % macro contents anew.
2063 % \begin{macrocode}
2064 \ifodd\@tempcnta
2065 % \end{macrocode}
2066 % In fact we are going to use |\reftextfaceafter| only if we are
2067 % doing two-sided printing, otherwise |\reftextafter| is always
2068 % used.
2069 % Since the value of |\if@twoside| is evaluated before reading in
2070 % packages we could do better (saving some tokens) by defining
2071 % the current macro depending on this boolean.
2072 % \begin{macrocode}
2073 \if@twoside
2074 \reftextfaceafter
2075 \else
2076 \reftextafter
2077 \fi
2078 \else
2079 \reftextafter
2080 \fi
2081 % \end{macrocode}
2082 % If the object is not on the page following the reference we check
2083 % if it is on the page before the reference. In \LaTeX{} this
2084 % situation is not too common, for example with floats it normally
2085 % does not occur, but of course it isn't impossible if you have more
2086 % than one reference to the same object, or if you have back
2087 % references to sections, theorems, etc. To test this we now
2088 % subtract two from the current value of |\@tempcnta| (which was
2089 % set to one higher as the reference page number). Note that
2090 % subtraction is also possible if the value was |\maxdimen| --- we
2091 % still get something that is much larger than any sensible page
2092 % number.
2093 % \begin{macrocode}
2094 \else
2095 \advance\@tempcnta-2
2096 % \end{macrocode}
2097 % If now |\thevpagerefnum| and |\@tempcnta| have the same value then the
2098 % object lies one page before the reference.
2099 % \begin{macrocode}
2100 \ifnum \thevpagerefnum =\@tempcnta
2101 % \end{macrocode}
2102 % Again we have to check for odd or even pages to distinguish
2103 % between the facing and the non-facing situation.
2104 % \begin{macrocode}
2105 \ifodd\@tempcnta
2106 \reftextbefore
2107 \else
2108 % \end{macrocode}
2109 % Again the |\reftextfacebefore| only if |@twoside| evaluates to
2110 % true.
2111 % \begin{macrocode}
2112 \if@twoside
2113 \reftextfacebefore
2114 \else
2115 \reftextbefore
2116 \fi
2117 \fi
2118 % \end{macrocode}
2119 % If the above test also returns false then we have object and
2120 % references on pages which are far away or don't contain simple
2121 % page numbers. Therefore we generate the |\reftextfaraway| string
2122 % and drop any possible ``looping warning'' in |\vref@may@loop|.
2123 % Recall that this is a macro which has the user label as an
2124 % argument.
2125 % \begin{macrocode}
2126 \else
2127 \let\vref@may@loop\relax % added
2128 \reftextfaraway{#3}%
2129 \fi
2130 \fi
2131 }%
2132 % \end{macrocode}
2133 % We do the same if our first test (that the page with the object
2134 % has a positive page number) turns out to be false.
2135 % \begin{macrocode}
2136 {%
2137 \let\vref@may@loop\relax %added
2138 \reftextfaraway{#3}}%
2139 \fi
2140 % \end{macrocode}
2141 % Finally, we generate the internal label so that it can be checked on
2142 % the next run. This means that we compare the position after the
2143 % string with the position of the referenced object. There is one
2144 % thing to note: to conserve space we locally make |\@currentlabel|
2145 % empty since we are only interested in the page number value of
2146 % this internal label.
2147 % \changes{v1.0l}{1994/07/07}{Explicitly expand \cs{label} argument for babel}
2148 %
2149 % These days we actually use |\vref@label| instead of |\label| as
2150 % this avoids problems with Babel or \pkg{amsmath} redefining
2151 % the latter command.
2152 % \changes{v1.4e}{2003/01/08}{Use \cs{vref@label} instead of
2153 % \cs{label} (pr/3489)}
2154 % \changes{v1.5c}{2016/02/16}{}
2155 % \begin{macrocode}
2156 \vref@label{\the\c@vrcnt @vr}%
2157 % \end{macrocode}
2158 % Finally we run |\vref@may@loop| which is either |\relax| or generates
2159 % a ``may loop'' warning or error as appropriate.
2160 % \begin{macrocode}
2161 \vref@may@loop
2162 }
2163 % \end{macrocode}
2164 % \end{macro}
2165 %
2166 %
2167 % \begin{macro}{\vp@gerefstar}
2168 % The default code for the star form is identical to the previous
2169 % macro |\vp@geref|. It only produces a different result because
2170 % before calling it we set |\vref@maybe@space| to do nothing.
2171 %
2172 % The \pkg{hyperref} package can then change the meaning of this
2173 % command to suppress a hyperlink.
2174 %
2175 % It is also a good way to check if we are running with a new
2176 % \pkg{varioref} by testing
2177 %\begin{verbatim}
2178 % \ifdefined\vp@gerefstar
2179 % ... code for new varioref
2180 % \else
2181 % ... code for old varioref
2182 % \fi
2183 %\end{verbatim}
2184 %
2185 % \changes{v1.6a}{2019/08/25}{Command added to support hyperref better}
2186 % \begin{macrocode}
2187 \let\vp@gerefstar\vp@geref
2188 % \end{macrocode}
2189 % \end{macro}
2190 %
2191 %
2192
2193 % \begin{macro}{\vref@label}
2194 % \changes{v1.4e}{2003/01/08}{Macro added (pr/3489)}
2195 % This macro is like |\label| in the kernel but without passing on
2196 % |\@currentlabel|, ie useful if all we are interested in is the
2197 % page number. It also has the effect that it is unaffected by
2198 % \pkg{amsmath} or Babel redefining the |\label| command.
2199 % \begin{macrocode}
2200 \def\vref@label#1{\@bsphack
2201 \protected@write\@auxout{}%
2202 {\string\newlabel{#1}{{}{\thepage}}}%
2203 \@esphack}
2204 % \end{macrocode}
2205 % \end{macro}
2206 %
2207 %
2208 % \begin{macro}{\vpagerefnum}
2209 % \changes{v1.4c}{2002/06/14}{Macro added}
2210 % This macro allows to define |\reftextafter| and friends to refer
2211 % to the page number rather than producing a textual reference.
2212 % \begin{macrocode}
2213 \let\thevpagerefnum\@empty
2214 % \end{macrocode}
2215 % \end{macro}
2216 %
2217 %
2218 % \begin{macro}{\vrefwarning}
2219 % \changes{v0.1g}{1993/02/14}{Macro added}
2220 % \begin{macro}{\vrefshowerrors}
2221 % \changes{v1.1h}{1998/08/01}{Macro added}
2222 % \begin{macro}{\vref@err}
2223 % \changes{v0.1g}{1993/02/14}{Macro added}
2224 % When the |\vref| command detects a possible crossing over a page
2225 % boundary it will call |\vref@err| to generate an error message.
2226 % During document preparation one can turn such errors into
2227 % warnings by issuing a |\vrefwarning| declaration.
2228 % \changes{v1.0g}{1993/02/14}{Macro added}
2229 % \begin{macrocode}
2230 \def\vrefwarning{\def\vref@err{\PackageWarning{varioref}}}
2231 % \end{macrocode}
2232 % \begin{macrocode}
2233 \def\vrefshowerrors{\def\vref@err##1{\PackageError{varioref}{##1}%
2234 {Please check the pages in question. You might need to replace
2235 the \string\vref\MessageBreak
2236 or \noexpand\vpageref by a normal \noexpand\(page)ref to
2237 stop LaTeX running forever.}}}
2238 % \end{macrocode}
2239 % \end{macro}
2240 % \end{macro}
2241 % \end{macro}
2242 %
2243 %
2244 % \begin{macro}{\vref}
2245 % We start by scanning for a star form and then continue in a
2246 % different macro depending on the result.
2247 % \changes{v1.3a}{2001/04/12}{Scan for star form}
2248 % \changes{v1.6a}{2019/08/25}{Adjusted for new spacing regime}
2249 % \begin{macrocode}
2250 \DeclareRobustCommand\vref{\@ifstar
2251 {\vref@star}{\vr@f}}
2252 % \end{macrocode}
2253 % \end{macro}
2254
2255
2256
2257 % \begin{macro}{\vref@star}
2258 %
2259 % The star form is easy (and just a convenient shortcut), just call
2260 % |\ref| followed by |\vpageref| and pass the optional argument to
2261 % the latter. We don't support the second optional argument of
2262 % |\vpageref|, if that is needed one has to call both commands
2263 % explicitly.
2264 % \changes{v1.6a}{2019/08/25}{Command added to support hyperref better}
2265 % \changes{v1.6e}{2020/07/25}{Changed for Japanese (gh/352)}
2266 % \begin{macrocode}
2267 \newcommand\vref@star[1][]{\vrefformat{#1}}
2268 % \end{macrocode}
2269 % \end{macro}
2270 %
2271 %
2272 % \begin{macro}{\vrefformat,\vrefdefaultformat}
2273 % Japanese needs a different word order in \cs{vref@star} so this
2274 % is separated out so that it can be changed at the language level.
2275 % \changes{v1.6e}{2020/07/25}{Macro added (gh/352)}
2276 % \begin{macrocode}
2277 \def\vrefdefaultformat#1#2{%
2278 \ref{#2}
2279 \vpageref[#1]{#2}}
2280 % \end{macrocode}
2281 % Most languages need the above definition.
2282 % \begin{macrocode}
2283 \let\vrefformat\vrefdefaultformat
2284 % \end{macrocode}
2285 % \end{macro}
2286
2287 % \begin{macro}{\vr@f}
2288 % The normal case is a little bit more elaborated \ldots
2289 % \changes{v1.3c}{2001/09/04}{Correct typo in name}
2290 % \changes{v1.6a}{2019/08/25}{Adjusted for new spacing regime}
2291 % \begin{macrocode}
2292 \def\vr@f{%
2293 \leavevmode
2294 % \end{macrocode}
2295 % If option \texttt{space} is used then we remove a preceding space
2296 % and add our own unbreakable space instead. Otherwise we don't do
2297 % any space-handling.
2298 % \begin{macrocode}
2299 \if@vrefhandlespace
2300 \unskip \nobreakspace
2301 \fi
2302 % \end{macrocode}
2303 % The use of |\nobreakspace| or |~| after the |\unskip| means that
2304 % this command will always produce a normal space while
2305 % something like |\nobreak\space| will
2306 % react to settings of |\nonfrenchspacing|.
2307 % Unfortunately the latter will also act in cases where one really
2308 % wants a normal space, e.g., in |Fig.~\vref{..}|, resulting in
2309 % a large extra space after the dot. For this reason the first solution
2310 % is used.
2311 % \changes{v1.1e}{1998/03/09}{Don't use \cs{nobreakspace} (pr/1866)}
2312 % \changes{v1.2a}{1998/11/27}{Use \cs{nobreakspace} (pr/2909)}
2313 % \changes{v1.2a}{1998/11/27}{Add \cs{leavevmode}}
2314 %
2315 % After having handled (or not handled) the spacing we call
2316 % |\vref@star| to scan the optional arguments and do the rest.
2317 % If that command has been altered by \pkg{hyperref} then the
2318 % current one needs altering too and does the argument scanning explicitly.
2319 % \begin{macrocode}
2320 \vref@star % in hyperref this needs to be explicit
2321 }
2322 % \end{macrocode}
2323 % \end{macro}
2324 %
2325 %
2326 % \begin{macro}{\is@pos@number}
2327 % The utility macro |\is@pos@number| takes three arguments: a
2328 % string that is tested for being a valid non-negative integer and the
2329 % actions to be taken in case the test comes out true or false.
2330 %
2331 % We start by passing the string to the macro |\is@pos@num| after
2332 % prefixing it with a \texttt{0} and adding a space after it. To have
2333 % a well-defined ending point we also add |\@nil| at the end.
2334 %\label{isposnumber}
2335 % \begin{macrocode}
2336 \def\is@pos@number#1{\is@pos@num0#1\space\@nil}
2337 % \end{macrocode}
2338 % Now we parse the enlarged string into a counter register. To get
2339 % control back after everything that is regarded by \TeX{} as a
2340 % number is put into that register we assign |\is@pos@num@| to the
2341 % |\afterassignment| token. Since the string started with 0, we
2342 % can be sure that the register assignment will be carried out
2343 % without an error message. In case of counter assignments leading
2344 % zeros are discarded.
2345 % \begin{macrocode}
2346 \def\is@pos@num{\afterassignment\is@pos@num@ \count@}
2347 % \end{macrocode}
2348 % Now we have to check whether or not the whole string was parsed
2349 % into that register or some remainder was left over. Since we have
2350 % added a |\@nil| token at the very end we can use that to delimit
2351 % the argument of |\is@pos@num@|. Note that the added space in
2352 % |\is@pos@number| \vpageref[above]{isposnumber} gets parsed away
2353 % by the counter assignment. If it would be missing, and the full
2354 % string would consist of a number, \TeX{} would try to replace
2355 % |\@nil| by its definition to see if it would contain additional
2356 % digits and thus we would be in trouble at this point.
2357 % \begin{macrocode}
2358 \def\is@pos@num@#1\@nil{%
2359 % \end{macrocode}
2360 % Now we have to check if the argument is empty. We can do this
2361 % with an |\ifx| (i.e., in an expandable way) since we know for
2362 % sure that it can not start with |\@nil|.
2363 % \changes{v1.4j}{2004/05/08}{Use \cs{@nil} for testing}
2364 % \begin{macrocode}
2365 \ifx\@nil#1\@nil
2366 % \end{macrocode}
2367 % Depending on the result we execute the second or third argument
2368 % of the command |\is@pos@number| using a technique that removes
2369 % the |\else| or |\fi| from the input stream first, so that in
2370 % principle input stream parsing could be done from within the
2371 % arguments.
2372 % \begin{macrocode}
2373 \expandafter\@firstoftwo \else
2374 \expandafter\@secondoftwo \fi}
2375 % \end{macrocode}
2376 % \end{macro}
2377 %
2378 % \begin{macro}{\reftextvario}
2379 % This macro gives a little bit of random variation in the text
2380 % because the outcome depends on the number of |\vref| commands
2381 % seen before.
2382 % \begin{macrocode}
2383 \def\reftextvario#1#2{\ifodd\c@vrcnt #1\else#2\fi}
2384 % \end{macrocode}
2385 % \end{macro}
2386 %
2387 % \begin{macro}{\fullref}
2388 % And here is the primitive command that always produces a |\ref|
2389 % and a |\pageref|.
2390 % \changes{v1.6e}{2020/07/25}{Changed for Japanese (gh/352)}
2391 % \begin{macrocode}
2392 \newcommand\fullref{\fullrefformat}
2393 % \end{macrocode}
2394 % \end{macro}
2395 %
2396 %
2397 % \begin{macro}{\fullrefformat,\fullrefdefaultformat}
2398 % Japanese needs a different word order in \cs{fullref} so this
2399 % is separated out so that it can be changed at the language level.
2400 % \changes{v1.6e}{2020/07/25}{Macro added (gh/352)}
2401 % \begin{macrocode}
2402 \def\fullrefdefaultformat#1{%
2403 \ref{#1} \reftextfaraway{#1}}
2404 % \end{macrocode}
2405 % Most languages need the above definition.
2406 % \begin{macrocode}
2407 \let\fullrefformat\fullrefdefaultformat
2408 % \end{macrocode}
2409 % \end{macro}
2410 %
2411 %
2412 % \subsubsection{Supporting ranges}
2413 %
2414 % \begin{macro}{\vref@pagenum}
2415 % \changes{v1.2a}{1998/08/01}{Macro added}
2416 % This command takes a label as |#1| extracts the page number
2417 % associated with it and saves the result in a csname which is
2418 % passed as |#1|. If the label isn't associated with a page number
2419 % it essentially associates it with |??| for both the label number
2420 % and the page, thus defining the label this way. This means that
2421 % no label warning is generated for this label in case it is
2422 % undefined.
2423 % \changes{v1.6f}{2021/07/07}{Use 3 additional (empty) arguments as
2424 % default in case nameref is active}
2425 % \begin{macrocode}
2426 \def\vref@pagenum#1#2{%
2427 \@ifundefined{r@#2}{\@namedef{r@#2}{{??}{??}{}{}{}}}{}%
2428 % \end{macrocode}
2429 % Extracting and saving the page number turned out to be a source of subtle
2430 % bugs. Initially it was done through an |\edef| with a bunch of
2431 % |\expandafter| commands inside. This posed a problem if the page number
2432 % itself contained code which needed protection (e.g., pr/4080) so this got
2433 % changed to use |\protected@edef|. However, that in turn failed with Babel
2434 % (pr/4093)
2435 % if the label contained active characters, e.g., a ``:'' in French. So now
2436 % we use even more |\expandafter| commands to avoid any expansion other
2437 % than what is absolutely required---I'm sure there is now a simpler way
2438 % to code this, but \ldots\ in fact we didn't use enough initially resulting in another
2439 % bug (pr/4159):
2440 % \changes{v1.4w}{2009/09/13}{Use \cs{protected@edef} to avoid problems
2441 % in complicated setups, e.g., microtype (pr/4080)}
2442 % \changes{v1.4y}{2010/11/12}{Avoid even \cs{protected@edef} to pacify french
2443 % babel (pr/4093)}
2444 % \changes{v1.4z}{2011/10/02}{Previous fix need one more expansion
2445 % (pr/4159,pr/4171)}
2446 % \begin{macrocode}
2447 \expandafter\expandafter\expandafter\vref@@pagenum
2448 \csname r@#2\endcsname{}{}\@nil#1%
2449 }
2450 \def\vref@@pagenum#1#2#3\@nil#4{%
2451 \def#4{#2}%
2452 }
2453 % \end{macrocode}
2454 % \end{macro}
2455 %
2456 % \begin{macro}{\vrefpagenum}
2457 % \changes{v1.2a}{1998/08/01}{Macro added}
2458 % Same as the above but this time we generate a warning for
2459 % undefined labels.
2460 % \begin{macrocode}
2461 \def\vrefpagenum#1#2{%
2462 \@ifundefined{r@#2}%
2463 {\G@refundefinedtrue
2464 \@latex@warning{Reference `#2' on page \thepage \space
2465 undefined}}{}%
2466 \vref@pagenum{#1}{#2}}
2467 % \end{macrocode}
2468 % \end{macro}
2469 %
2470 % \begin{macro}{\vpagerefrange}
2471 % \begin{macro}{\@vpagerefrange}
2472 % \begin{macro}{\@svpagerefrange}
2473 % \changes{v1.2a}{1998/08/01}{Macro added}
2474 % \changes{v1.3b}{2001/04/14}{Scan for star form}
2475 % \changes{v1.4s}{2007/08/07}
2476 % {Prevent loss of brackets}
2477 % If both labels refer to the same page then we produce a
2478 % |\vpageref|. Otherwise we produce the result of
2479 % |\reftextpagerange|.
2480 %
2481 % One could think of making this command even more clever by
2482 % producing a special string if the difference between the two page
2483 % number is one (but this is not done).
2484 %
2485 % We need two versions to implement a star form:
2486 % \begin{macrocode}
2487 \newcommand\@svpagerefrange[3][\reftextcurrent]{%
2488 \vrefpagenum\@tempa{#2}%
2489 \vrefpagenum\@tempb{#3}%
2490 \ifx\@tempa\@tempb
2491 \vpageref*[{#1}]{#2}%
2492 \else
2493 \reftextpagerange{#2}{#3}%
2494 \fi
2495 }
2496 % \end{macrocode}
2497 % And the same but using |\vpageref|:
2498 % \begin{macrocode}
2499 \newcommand\@vpagerefrange[3][\reftextcurrent]{%
2500 \vrefpagenum\@tempa{#2}%
2501 \vrefpagenum\@tempb{#3}%
2502 \ifx\@tempa\@tempb
2503 \vpageref[{#1}]{#2}%
2504 \else
2505 \reftextpagerange{#2}{#3}%
2506 \fi
2507 }
2508 % \end{macrocode}
2509 % And here we put things together.
2510 % \begin{macrocode}
2511 \newcommand\vpagerefrange{\@ifstar\@svpagerefrange\@vpagerefrange}
2512 % \end{macrocode}
2513 % \end{macro}
2514 % \end{macro}
2515 % \end{macro}
2516 %
2517 %
2518 % \begin{macro}{\vrefrange}
2519 % \changes{v1.2a}{1998/08/01}{Macro added}
2520 % \changes{v1.4s}{2006/08/07}
2521 % {Prevent loss of brackets}
2522 % \changes{v1.6d}{2020/07/20}{Changed for Japanese (gh/352)}
2523 % Argument two and three are implicitly picked up.
2524 % \begin{macrocode}
2525 \newcommand\vrefrange[1][\reftextcurrent]{\vrefrangeformat{#1}}
2526 % \end{macrocode}
2527 %
2528 % \end{macro}
2529 %
2530 %
2531 % \begin{macro}{\vrefrangeformat,\vrefrangedefaultformat}
2532 % Japanese needs a different word order in \cs{vrefrange} so this
2533 % is separated out so that it can be changed at the language level.
2534 % \changes{v1.6d}{2020/07/20}{Macro added (gh/352)}
2535 % \begin{macrocode}
2536 \def\vrefrangedefaultformat#1#2#3{%
2537 \reftextlabelrange{#2}{#3} \vpagerefrange[{#1}]{#2}{#3}}
2538 % \end{macrocode}
2539 % Most languages need the above definition.
2540 % \begin{macrocode}
2541 \let\vrefrangeformat\vrefrangedefaultformat
2542 % \end{macrocode}
2543 % \end{macro}
2544 %
2545 % \begin{macro}{\Vref}
2546 % \changes{v1.4a}{2002/02/24}{Macro added}
2547 % |\Vref| is the counterpart to |\vref| with |\ref| replaced by
2548 % |\Ref| in its definition.
2549 % \changes{v1.6a}{2019/08/25}{Adjusted for new spacing regime}
2550 % \begin{macrocode}
2551 \DeclareRobustCommand\Vref{\@ifstar
2552 {\Vref@star}%
2553 {\Vr@f}}
2554 % \end{macrocode}
2555 % \end{macro}
2556 %
2557 % \begin{macro}{\Vref@star}
2558 % \changes{v1.6a}{2019/08/25}{Command added to support hyperref better}
2559 % \changes{v1.6e}{2020/07/25}{Changed for Japanese (gh/352)}
2560 % \begin{macrocode}
2561 \newcommand\Vref@star[1][]{\Vrefformat{#1}}
2562 % \end{macrocode}
2563 % \end{macro}
2564 %
2565 %
2566 % \begin{macro}{\Vrefformat,\Vrefdefaultformat}
2567 % Japanese needs a different word order in \cs{Vref} so this
2568 % is separated out so that it can be changed at the language level.
2569 % \changes{v1.6e}{2020/07/25}{Macro added (gh/352)}
2570 % \begin{macrocode}
2571 \def\Vrefdefaultformat#1#2{%
2572 \Ref{#2}
2573 \vpageref[#1]{#2}}
2574 % \end{macrocode}
2575 % Most languages need the above definition.
2576 % \begin{macrocode}
2577 \let\Vrefformat\Vrefdefaultformat
2578 % \end{macrocode}
2579 % \end{macro}
2580 %
2581 % \begin{macro}{\Vr@f}
2582 % \changes{v1.4a}{2002/02/24}{Macro added}
2583 % \changes{v1.4x}{2010/08/04}{Correct spacing -- same mistake as in \cs{vref}
2584 % (pr/4123)}
2585 % \changes{v1.6a}{2019/08/25}{Adjusted for new spacing regime}
2586 % \begin{macrocode}
2587 \def\Vr@f{%
2588 \if@vrefhandlespace
2589 \unskip \vref@space
2590 \fi
2591 \Vref@star % in hyperref this needs to be explicit
2592 }
2593 % \end{macrocode}
2594 % \end{macro}
2595
2596
2597 % \begin{macro}{\vpagerefcompare}
2598 %
2599 % \changes{v1.6a}{2019/08/25}{Macro added}
2600 % \begin{macrocode}
2601 \DeclareRobustCommand\vpagerefcompare[2]{% label1, label2, TRUE, FALSE
2602 \vrefpagenum\@tempa{#1}%
2603 \vrefpagenum\@tempb{#2}%
2604 \ifx\@tempa\@tempb
2605 \expandafter\@firstoftwo
2606 \else
2607 \expandafter\@secondoftwo
2608 \fi
2609 }
2610 % \end{macrocode}
2611 % \end{macro}
2612 %
2613 %
2614 %
2615 % \begin{macro}{\vpagerefnearby}
2616 % \changes{v1.6a}{2019/08/25}{Macro added}
2617 % Test if |\vpageref| is going to be at most $\pm1$ off from
2618 % current page.
2619 % \begin{macrocode}
2620 \DeclareRobustCommand\vpagerefnearby[1]{% label, TRUE, FALSE
2621 \leavevmode
2622 \@tempskipa\lastskip \unskip
2623 \global\advance\c@vrcnt\tw@ % keep oddness to not disturb \vrefvario
2624 \vref@label{\the\c@vrcnt @vn}%
2625 \ifdim\@tempskipa=\z@ \else
2626 \hskip\@tempskipa
2627 \fi
2628 \vref@pagenum\@tempa{\the\c@vrcnt @vn}%
2629 \is@pos@number\@tempa
2630 {%
2631 \vrefpagenum\@tempb{#1}%
2632 \is@pos@number\@tempb
2633 {%
2634 \ifcase\numexpr \@tempa -\@tempb+1\relax
2635 \or \or \else \expandafter \@thirdofthree \fi
2636 \@firstoftwo
2637 }%
2638 {\@secondoftwo}%
2639 }%
2640 {\@secondoftwo}%
2641 }
2642 % \end{macrocode}
2643 % \end{macro}
2644 %
2645
2646 % \begin{macro}{\vpagerefcomparenearby}
2647 % \changes{v1.6a}{2019/08/25}{Macro added}
2648 % True if the two pages have Arabic page numbers are at most off by
2649 % one so that |\vpageref| would produce a special string.
2650 %
2651 % This is in some sense a general version of |\vpagerefnearby| for
2652 % use in more complex situations. I.e., if you try to determine if
2653 % a larger set of references would be close to the current page and
2654 % you use each time |\vpagerefnearby| then you generate a lot of
2655 % internal labels for the current point. Thus by setting the label
2656 % yourself you can save processing time and space. On the other
2657 % hand you have to be careful to place the label into the right
2658 % place which can be a bit complicated if you look at the
2659 % definition of |\vpagerefnearby| that does all this automatically
2660 % for you. This is why the current macro is not discussed in the
2661 % user interface section as it is really just for package
2662 % developers.
2663 % \begin{macrocode}
2664 \DeclareRobustCommand\vpagerefcomparenearby[2]{% label1, label2, TRUE, FALSE
2665 \vrefpagenum\@tempa{#1}%
2666 \is@pos@number\@tempa
2667 {%
2668 \vrefpagenum\@tempb{#2}%
2669 \is@pos@number\@tempb
2670 {%
2671 \ifcase\numexpr \@tempa -\@tempb+1\relax
2672 \or \or \else \expandafter \@thirdofthree \fi
2673 \@firstoftwo
2674 }%
2675 {\@secondoftwo}%
2676 }%
2677 {\@secondoftwo}%
2678 }
2679 % \end{macrocode}
2680 % \end{macro}
2681
2682 %
2683 %
2684 % \subsubsection{Compatibility with older \LaTeX{} formats}
2685 %
2686 %
2687 % \begin{macro}{\labelformat}
2688 % \begin{macro}{\Ref}
2689 % \begin{macro}{\refstepcounter}
2690 % We don't need to define \cs{labelformat} and \cs{Ref} or change the
2691 % definition of \cs{refstepcounter} any longer because this is now
2692 % done in the \LaTeX{} kernel. However, if this package is used
2693 % together with an older kernel, this is not true, so for this
2694 % special case we keep the definitions.
2695 % \begin{macrocode}
2696 \ifx\labelformat\@undefined % assume we are in an older kernel
2697 \def\labelformat#1{\expandafter\def\csname p@#1\endcsname##1}
2698 \DeclareRobustCommand\Ref[1]{\protected@edef\@tempa{\ref{#1}}%
2699 \expandafter\MakeUppercase\@tempa}
2700 \def\refstepcounter#1{\stepcounter{#1}%
2701 \protected@edef\@currentlabel
2702 {\csname p@#1\expandafter\endcsname\csname the#1\endcsname}}
2703 \fi
2704 % \end{macrocode}
2705 % \end{macro}
2706 % \end{macro}
2707 % \end{macro}
2708 %
2709 % \changes{v1.6e}{2020/07/25}{Move to handle
2710 % the language-specific reference formats. (gh/352)}
2711 % \begin{macrocode}
2712 \ProcessOptions*
2713 % \end{macrocode}
2714 %
2715 % \begin{macrocode}
2716 %</package>
2717 % \end{macrocode}
2718 % \Finale
2719 %
2720 \endinput