Debian Codegraph @

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

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