Move a tag
[latex2e.git] / latex2e-20151001 / required / tools / varioref.dtx
blob905b17f2199807814ec4329ecac0ef4666e6870b
1 % \iffalse meta-comment
3 % Copyright 1993-2015
5 % The LaTeX3 Project and any individual authors listed elsewhere
6 % in this file.
8 % This file is part of the Standard LaTeX `Tools Bundle'.
9 % -------------------------------------------------------
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 %    http://www.latex-project.org/lppl.txt
16 % and version 1.3c or later is part of all distributions of LaTeX
17 % version 2005/12/01 or later.
19 % The list of all files belonging to the LaTeX `Tools Bundle' is
20 % given in the file `manifest.txt'.
22 % \fi
23 % \iffalse
24 %% Package varioref to use with LaTeX2e
25 %% Copyright (C) 1992-2015  Frank Mittelbach, all rights reserved.
27 %% For additions or updates to the language options please contact
28 %% the author at
30 %%   frank.mittelbach@latex-project.org
32 %% In case of bugs, please use "latexbug.tex" (category tools) to report them.
35 %<package>\NeedsTeXFormat{LaTeX2e}[1995/05/16]
36 %<package>\ProvidesPackage{varioref}
37 %<package>    [2015/09/22 v1.5b package for extended references (FMi)]
38 % \fi
40 % \CheckSum{2165}
41 %% \CharacterTable
42 %%  {Upper-case    \A\B\C\D\E\F\G\H\I\J\K\L\M\N\O\P\Q\R\S\T\U\V\W\X\Y\Z
43 %%   Lower-case    \a\b\c\d\e\f\g\h\i\j\k\l\m\n\o\p\q\r\s\t\u\v\w\x\y\z
44 %%   Digits        \0\1\2\3\4\5\6\7\8\9
45 %%   Exclamation   \!     Double quote  \"     Hash (number) \#
46 %%   Dollar        \$     Percent       \%     Ampersand     \&
47 %%   Acute accent  \'     Left paren    \(     Right paren   \)
48 %%   Asterisk      \*     Plus          \+     Comma         \,
49 %%   Minus         \-     Point         \.     Solidus       \/
50 %%   Colon         \:     Semicolon     \;     Less than     \<
51 %%   Equals        \=     Greater than  \>     Question mark \?
52 %%   Commercial at \@     Left bracket  \[     Backslash     \\
53 %%   Right bracket \]     Circumflex    \^     Underscore    \_
54 %%   Grave accent  \`     Left brace    \{     Vertical bar  \|
55 %%   Right brace   \}     Tilde         \~}
59 % \changes{v1.0a}{1993/12/06}{Upgrade to LaTeX2e}
60 % \changes{v1.0g}{1994/05/27}{Use \cmd\DeclareRobustCommand}
63 % \title{The \texttt{varioref} package\thanks{This file
64 %        has version number \fileversion, last
65 %        revised \filedate.}}
66 % \author{Frank Mittelbach}
67 % \date{\filedate}
69 % \MaintainedByLaTeXTeam{tools}
70 % \maketitle
73 % \begin{abstract}
74 %   This package defines the commands |\vref|, |\vpageref|,
75 %   |\vrefrange|, and |\vpagerefrange| for
76 %   \LaTeXe. |\vref| is similar to |\ref| but adds an additional
77 %   page reference, like `on the facing page' or `on page 27' whenever
78 %   the corresponding |\label| is not on the same page. The command
79 %   |\vpageref| is a variation to |\pageref| with a similar
80 %   functionality.  The |\v...range| commands take two labels as arguments
81 %   and produce strings which depend on whether or not these labels
82 %    fall onto a single page or on different pages.
83 %   Generated strings are customizable so that these
84 %   commands are usable with various languages.
85 % \end{abstract}
87 % \section{Introduction}
89 % In many cases it is helpful when referring to a figure or table to
90 % put both a |\ref| and a |\pageref| command into the document
91 % especially when there are one or more pages between the reference
92 % and the object.  Therefore some people use a command like
93 % \begin{verbatim}
94 %  \newcommand{\fullref}[1]{\ref{#1} on page~\pageref{#1}}
95 %\end{verbatim}
96 % which reduces the number of key strokes, necessary to make such a
97 % complete reference.  But since one never knows where the referenced
98 % object finally falls, using such a device may result in a page
99 % reference to the current page which is disturbing and therefore
100 % should be avoided.
104 % \section{The user interface}
106 %\DescribeMacro\vref The implementation of |\vref| below produces only
107 % a |\ref| when reference and |\label| are on the same page. It will
108 % additionally produce one of the strings `on the facing page', `on
109 % the preceding page', or `on the following page', if label and
110 % reference differ by one and it will produce both |\ref| and
111 % |\pageref| when the difference is larger.  The word `facing' is used
112 % when label and reference both fall onto a double spread.  However,
113 % if a special page numbering scheme is used instead of the usual
114 % arabic numbering (e.g., |\pagenumbering{roman}|) then there will be
115 % no distinction between one or many pages off.
117 %\DescribeMacro\vpageref Sometimes one wants to refer only to page
118 % number and again such a reference should normally be suppressed if
119 % we are referring to the current page. For this purpose the package
120 % defines the |\vpageref| command. It will produce the same strings as
121 % |\vref| except that it doesn't start with the |\ref| and except that
122 % it will produce the string that is saved in |\reftextcurrent| if
123 % label and reference fall onto the same page. By defining
124 % |\reftextcurrent| to produce ``on this page'' or something similar,
125 % we can avoid that
126 % \begin{verbatim}
127 %   ... see the example \vpageref{ex:foo} which shows ...
128 %\end{verbatim}
129 % comes out as ``\ldots~see the example which shows~\ldots'', which
130 % could be misleading.
132 % You can put a space in front of |\vpageref| it will be ignored if
133 % the command doesn't produce any text at all.
135 % But in fact |\vpageref| allows even more control. If has two
136 % optional arguments. With the first one, one can specify the text
137 % that should be used if label and reference fall on the same page.
138 % This is very helpful if both are near to each other, so that they
139 % may or may not be separated by a page break. In such a case we
140 % usually know (!) whether the reference is before or after the label
141 % so that we can say something like
142 % \begin{verbatim}
143 %   ... see the example \vpageref[above]{ex:foo} which shows ...
144 %\end{verbatim}
145 % which will then come out as ``\ldots~see the example above which
146 % shows~\ldots'' if we are still on the same page, but as ``\ldots~see
147 % the example on the page before which shows~\ldots'' (or something
148 % similar depending on the settings of the |\reftext..before|
149 % commands) when there was a page break in the meantime. One warning
150 % however, if you use |\vpageref| with the optional argument to refer
151 % to a figure or table, keep in mind that depending on the float
152 % placement parameters the float may show up on top of the current
153 % page and therefore before the reference even if it came after it in
154 % the source file.
156 % But maybe you prefer to say ``\ldots~see the above example'' if
157 % example and reference fall onto the same page, i.e., reverse the
158 % word order.  In fact, in some languages the word order automatically
159 % changes in that case.  To allow for this variation the second
160 % optional argument can be used. It specifies the text preceding the
161 % generated reference if object and reference do not fall onto the
162 % same page. Thus one would write
163 % \begin{verbatim}
164 %   ... see the \vpageref[above example][example]{ex:foo}
165 %       which shows ...
166 %\end{verbatim}
167 % to achieve the desired effect.
170 % \subsection{Additions in 1998}
172 % \DescribeMacro\vrefrange This command is similar to |\vref| but it
173 % takes two mandatory arguments denoting a range to refer to (e.g., a
174 % sequences of figures or a sequence of equations, etc.). So if
175 % |fig:a| is your first figure in the sequence and |fig:c| your last
176 % you can write
177 %\begin{verbatim}
178 %   ... see figures \vrefrange{fig:a}{fig:c} ...
179 %\end{verbatim}
180 % which would then be formatted as
181 % \begin{quote}
182 % \ldots\ see figures 3.4 to 3.6 on pages 23--24 \ldots
183 % \end{quote}
184 % or, if they happen to all fall onto the next page, as
185 % \begin{quote}
186 % \ldots\ see figures 3.4 to 3.6 on the following page \ldots
187 % \end{quote}
188 % i.e., the command is deciding what to say depending on where the two
189 % labels are placed in relation to each other; it is essentially
190 % implemented using |\vpagerefrange| described below.
191 % The optional argument the command may take is the text to use in case
192 % both labels are placed on the current page.
195 % \DescribeMacro\vpagerefrange This command is similar to |\vpageref|
196 % but takes two mandatory arguments which are two labels denoting a
197 % range. If both labels fall onto the same page, the command acts
198 % exactly like |\vpageref| (with a single label), otherwise it produces
199 % something like ``on pages~15--18'' (see customization possibilities
200 % below). The optional argument it may take is the text to use in case
201 % both labels are placed on the current page.
203 % \DescribeMacro\vrefpagenum This macro is provided to allow the user
204 % to write their own small commands which implement functions similar
205 % to those provided by the two previous commands. It takes two
206 % arguments: the second is a label (i.e., as used in |\label| or
207 % |\ref|) and the first is an arbitrary command name (make sure you
208 % use our own) that receives the page number related to this label.
209 % So if you have two (or more) labels you could retrieve their page
210 % numbers, compare them and then decide what to print.  For example,
211 % the following not very serious definition (also using the
212 % \texttt{ifthen} package)
213 %\begin{verbatim}
214 % \newcommand\amusingversion[2]{%
215 %   \vrefpagenum\firstnum{#1}%
216 %   \vrefpagenum\secondnum{#2}%
217 %   the definition%
218 %   \ifthenelse{\equal\firstnum\secondnum}%
219 %     {s of \ref{#1} and \ref{#2} \vpageref{#1}}%
220 %     { of \ref{#1} \vpageref{#1} and of \ref{#2} \vpageref{#2}}%
221 % }
223 % ...\amusingversion{foo}{bar}
224 %\end{verbatim}
225 % will print something like
226 % \begin{quote}
227 %  \ldots the definitions of 3 and 4 on the previous page
228 % \end{quote}
229 % in the case both labels are on the same page but something like
230 % \begin{quote}
231 %  \ldots the definition of 3 on the next page and of 4 on page~13
232 % \end{quote}
233 % in case the are on different pages.
235 % \subsection{Additions in 2001}
237 % The user commands |\vref|, |\vpageref|, and |\vpagerefrange| all
238 % work by first removing any space on their left and then inserting
239 % some space of their own (|\vref|, for example, a nonbreakable
240 % space). That seemed like a good idea back then, but it has the
241 % disadvantage that you can't use these macros in situations where you
242 % definitely do not want any space before the generated text. E.g., in
243 % situations like |(\vref{foo} ...)| you end up with a space after the
244 % open parenthesis.
246 % \DescribeMacro{\vref*}
247 % \DescribeMacro{\vpageref*}
248 % \DescribeMacro{\vpagerefrange*}
249 % Since it is too late to change the default behaviour I've added star
250 % versions of the macros which do not add any space before the
251 % generated text (they do nevertheless remove space at the left).
254 % \subsection{Additions in 2002}
256 % \DescribeMacro\labelformat
257 % A reference via |\ref| produces by default the data associated with
258 % the corresponding |\label| command (typically a number); any
259 % additional formatting has to be provided by the user. If, for
260 % example, references to equations are always to be typeset as
261 % ``equation (\textit{number})'', one has to code
262 % ``\verb=equation (\ref{=\textit{key}\verb=})=''.  With |\labelformat|
263 % the \texttt{varioref} package offers a possibility to generate such
264 % frills automatically. The command takes two arguments: the first is
265 % the name of a counter and the second is its representation when
266 % referenced. This means that for a successful usage, one has to know
267 % the counter name being used for generating the label, though in
268 % practice this should not pose a problem. The current counter number
269 % is picked up as an argument.
270 % Here are two examples:
271 %\begin{verbatim}
272 %  \labelformat{section}{section~#1}
273 %  \labelformat{equation}{equation~(#1)}}
274 %\end{verbatim}
277 % \DescribeMacro\Vref
278 % \DescribeMacro\Ref
279 % A side effect of using |\labelformat| is that, depending on the
280 % defined formatting, it becomes impossible to use |\ref| at the
281 % beginning of a sentence (if its replacement text starts with a
282 % lowercase letter). To overcome this problem \texttt{varioref}
283 % introduces the commands |\Ref| and |\Vref| that behave like
284 % |\ref| and |\{vref| except that they uppercase the first token
285 % of the generated string.
287 % To make |\Ref| or |\Vref| work properly the very first token in
288 % the second argument of |\labelformat| has to be a simple \textsc{ascii}
289 % letter, otherwise the capitalization will fail or worse, you will end
290 % up with some error messages. If you actually need something more
291 % complicated in this place (e.g., an accented letter)
292 % you have to explicitly surround it with braces, to
293 % identify the part that needs to be capitalized. For example, for
294 % figure references in the Hungarian language you might want to write
295 % |\labelformat{figure}{{\'a}bra~\thefigure}|.
297 % \DescribeMacro\vpagerefnum
298 % If you like to have |\vref| suppress the page number on pages where
299 % label and reference fall onto the same page, but prefer reference to
300 % page numbers otherwise then |\vpagerefnum| can be used. This macro
301 % hold the current page ``number'' when |\vpageref| and friends are
302 % executed. Thus, by defining, for example
303 %\begin{verbatim}
304 %\renewcommand\reftextfaceafter {on page~\thevpagerefnum}
305 %\renewcommand\reftextfacebefore{on page~\thevpagerefnum}
306 %\renewcommand\reftextafter     {on page~\thevpagerefnum}
307 %\renewcommand\reftextbefore    {on page~\thevpagerefnum}
308 %\end{verbatim}
309 % textual references can be suppressed.
312 % \section{Customization}
314 % The package supports all options defined by the babel package to
315 % translate the fixed strings into other languages than English.
316 % (Some languages need updating, however.)
317 % It also supports languages currently not in babel;
318 % check the section on options later on.
320 % You can also modify some or all of the strings by redefining the
321 % following commands.
322 %\DescribeMacro\reftextbefore
323 %\DescribeMacro\reftextfacebefore
324 %\DescribeMacro\reftextafter
325 %\DescribeMacro\reftextfaceafter Backward references use
326 % |\reftextbefore| if the label is on the preceding page but invisible
327 % and |\reftextfacebefore| if it is one the facing page (i.e., if the
328 % current page number is odd).  Similarly |\reftextafter| is used
329 % when the label comes on the next page but one has to turn the page
330 % and |\reftextfaceafter| if it is on the following but facing page.
332 % In fact, |\reftextface...| is used only if the user or the document
333 % class specified two-sided printing.
335 %\DescribeMacro\reftextfaraway Finally we have |\reftextfaraway| which
336 % is used whenever label and reference differ by more than one or when
337 % they aren't numeric. This macro is a bit different because it takes
338 % one argument, the symbolic reference string so that one cane make
339 % use of |\pageref| in its replacement text.
342 %\DescribeMacro\reftextvario To allow a bit random variation in the
343 % generated strings one can use the command |\reftextvario| inside the
344 % string macros. It takes two arguments and selects one or the other
345 % for printing depending on the number of already seens |\vref| or
346 % |\vpageref| commands.  As an example see the definitions of
347 % |\reftextbefore| etc.\ \vpageref[below]{reftextbefore}.
349 % \begin{itshape} If babel is being used then the above commands need to be
350 % changed using the Babel mechanism, e.g.,
351 %\begin{verbatim}
352 %\addto\extrasngerman{%
353 %   \renewcommand\reftextfaceafter {auf der n\"achsten Seite}%
354 %    ...
355 %  }
356 %\end{verbatim}
357 % Otherwise babel will reintroduce its own defaults each time the language is
358 % changed (which happens in particular during |\begin{document}| where the
359 %    main language is selected).
360 % \end{itshape}
362 % \subsection{Additions in 1998}
364 % The commands |\vrefrange| and |\vpagerefrange| produce their text
365 % using two macros described below. By redefining them one can modify
366 % the results to accommodate special requirements.
369 % They both take two mandatory arguments denoting the first and the
370 % last label of the range.
373 % \DescribeMacro\reftextpagerange This macro produces text that
374 % describes the page range of the two labels, e.g., the default
375 % for English is ``|on pages~\pageref{#1}--\pageref{#2}}|''.
378 % \DescribeMacro\reftextlabelrange This macro produces text that
379 % describes the range of figures, tables, or whatever the labels refer
380 % to, the default for English is ``|\ref{#1} to~\ref{#2}|''.
383 % \section{Options}
385 % As mentioned above the package supports all standard options offered
386 % by the Babel system to customize the strings produced. In addition it
387 % offers the option \texttt{draft} to turn error messages into warnings
388 % during development. The default \texttt{final} produces error message
389 % when a generated string falls onto a page boundary (see next section).
392 % \section{A few warnings}
394 % Defining commands like the ones described above poses some
395 % interesting problems. Suppose, for example, that a generated text
396 % like `on the next page' gets broken across pages. If this happens it
397 % is very difficult to find an acceptable solution and in fact can
398 % even result in a document that will always change from one state to
399 % another (i.e., inserting one string, finding that this is wrong,
400 % inserting another string on the next run which makes the first
401 % string correct again, inserting \ldots).  The current implementation
402 % of \texttt{varioref} therefore issues an error message whenever the
403 % generated text is broken across page boundaries, e.g.,
404 % \begin{quote}
405 %   table 5 on the current \meta{page break} page
406 % \end{quote}
407 % would would result in an error, which needs to be resolved by the
408 % user by replacing the |\vref| command with an ordinary |\ref| just
409 % before the final run.  This is not
410 % completely satisfactory but in such case no solution really is.
411 % \DescribeMacro\vrefwarning
412 % During document preparation, while one is still changing the text,
413 % such error messages can be turned into warnings by placing a
414 % |\vrefwarning| command in the preamble. This is equivalent to
415 % specifying ``draft'' as an option to the package.
416 % \DescribeMacro\vrefshowerrors
417 % |\vrefshowerrors| ensures that varioref stops when detecting a
418 % possible loop. This is the default and equivalent to specifying
419 % ``final'' as an option.
421 % At the end final a warning: every use of |\vref| will internally
422 % generate two macro names to keep track of the string positions
423 % within the document. As a result you may run out of name space or
424 % main memory if you make heavy use of this macro on a small \TeX{}
425 % installation.
426 %\DescribeMacro\fullref For this reason the primitive command
427 % |\fullref| is also provided. This command can be used whenever you
428 % know for sure that label and reference can't fall onto nearby pages.
430 % \StopEventually{\PrintIndex\PrintChanges}
433 % \section{The documentation driver file}
435 % The next bit of code contains the documentation driver file for
436 % \TeX{}, i.e., the file that will produce the documentation you are
437 % currently reading. It will be extracted from this file by the
438 % \texttt{docstrip} program.
439 %    \begin{macrocode}
440 %<*driver>
441 \documentclass{ltxdoc}
442 \usepackage{varioref}
443 \GetFileInfo{varioref.sty}
444 \setlength\hfuzz{1pt}    % ignore slight overfulls
445 \EnableCrossrefs
446 %\DisableCrossrefs   % Say \DisableCrossrefs if index is ready
448 \RecordChanges       % Gather update information
449 %\OnlyDescription    % comment out for implementation details
450 \begin{document}
451    \DocInput{varioref.dtx}
452 \end{document}
453 %</driver>
454 %    \end{macrocode}
457 % \section{The implementation}
459 % The main implementation idea is to generate an internal label
460 % command for every |\vpageref| and compare the page reference of this
461 % label with the page reference of the user-requested label.  Since
462 % this means one additional macro name for each use of |\vpageref| or
463 % |vref| (which is implemented in terms of |\vpageref|) the memory
464 % requirements of this package may be high in terms of main and macro
465 % name memory.  Since the information held in the internal labels is
466 % used only once one could envision a different scheme if suitable
467 % primitives for this kind of ``one place information'' would be
468 % provided by \LaTeX.  This type of data structure is planned for
469 % \LaTeX3 but for the moment we have to live with the memory
470 % restrictions.
472 % We start by checking if this file was already loaded. If not we
473 % identify the current version. This is actually done at the top
474 % of the file, so we comment it out here
475 % \changes{v0.1h}{1993/08/15}{Small documentation changes}
476 %    \begin{macrocode}
477 %<*package>
478 %\NeedsTeXFormat{LaTeX2e}[1994/06/01]
479 %\ProvidesPackage{varioref}[\filedate\space\fileversion\space
480 %                     LaTeX2e package for extended references (FMi)]
481 %    \end{macrocode}
484 %  \begin{macro}{\vref@addto}
485 % \changes{v1.0b}{1994/01/31}{Avoid using babel `addto}
486 % \changes{v1.0b}{1994/01/31}{The babel commands are starting
487 %                             with extras}
488 %    To support the use of babel we want to add the additional strings
489 %    to the |\extras|\meta{language} commands. Since |\addto| in the
490 %    current implementation of babel has a bug that does not allow to
491 %    use arguments containing hashmarks we do this by hand.
492 %    \begin{macrocode}
493 \def\vref@addto#1#2{%
494   #2%
495   \@temptokena{#2}%
496   \ifx#1\undefined
497      \edef#1{\the\@temptokena}%
498   \else
499      \toks@\expandafter{#1}%
500      \edef#1{\the\toks@\the\@temptokena}%
501   \fi
502   \@temptokena{}\toks@\@temptokena
504 \@onlypreamble\vref@addto
505 %    \end{macrocode}
506 %  \end{macro}
509 % \subsection{Options}
511 %  \begin{macro}{\vref@excuse}
512 %    Excuse that we don't know the strings for a certain language.
513 % \changes{v1.0q}{1995/04/06}{Use `PackageWarning}
514 %    \begin{macrocode}
515 \def\vref@excuse#1{%
516   \PackageWarningNoLine{varioref}{Sorry, language `#1'
517             not supported%
518             \MessageBreak
519             in this version.
520             English strings used by default.
521             \MessageBreak
522             Please modify \protect\reftext... commands manually.%
523             \MessageBreak\MessageBreak
524             If you can suggest translations for
525             this language,%
526             \MessageBreak
527             please mail them
528             to the author of this package}}
529 \@onlypreamble\vref@excuse
530 %    \end{macrocode}
531 %  \end{macro}
533 %  \begin{macro}{\vref@stringwarning}
534 %    And we sometimes just don't know some strings~\ldots
535 % \changes{v1.2a}{1998/08/01}{Macro added}
536 %    \begin{macrocode}
537 \def\vref@stringwarning#1{%
538   \PackageWarningNoLine{varioref}{Sorry, there is no proper
539             translation for the string\MessageBreak
540             produced by \protect#1\on@line.\MessageBreak
541             English string used instead.\MessageBreak
542             \MessageBreak
543             If you can suggest translations for
544             the current\MessageBreak
545             language, please mail them
546             to the author of this\MessageBreak package}}
547 %    \end{macrocode}
548 %  \end{macro}
551 %  \begin{macro}{\reftextfaceafter}
552 %  \begin{macro}{\reftextfacebefore}
553 %  \begin{macro}{\reftextafter}
554 %  \begin{macro}{\reftextbefore}
555 %  \begin{macro}{\reftextcurrent}
556 % \label{reftextbefore} The options do set the macros that
557 %    generate the textual strings. Note, that they do not start with a
558 %    space, the space is already added in the main macro below.
559 % \changes{v1.2a}{1998/08/22}{Added american defaults for
560 %      \cs{reftextpagerange} and \cs{reftextlabelrange}}
561 % \changes{v1.4d}{2002/11/11}{Changed default for \cs{reftextbefore}}
563 %    Afrikaans option contributed by Danie Els
564 %    (\texttt{dnjels@sun.ac.za}).
565 % \changes{v1.4g}{2003/03/29}{Added afrikaans option}
566 %    \begin{macrocode}
567 \DeclareOption{afrikaans}
568   {\vref@addto\extrasafrikaans{%
569     \def\reftextfaceafter {op die \reftextvario{regterbladsy}%
570                                                {bladsy langsaan}}%
571     \def\reftextfacebefore{op die \reftextvario{linkerbladsy}%
572                                                 {bladsy langsaan}}%
573     \def\reftextafter     {op die \reftextvario{volgende bladsy}%
574                                                {bladsy hierna}}%
575     \def\reftextbefore    {op die \reftextvario{vorige bladsy}%
576                                                {bladsy hiervoor}}%
577     \def\reftextcurrent   {op \reftextvario{hierdie}%
578                                            {die huidige} bladsy}%
579     \def\reftextfaraway#1{op bladsy~\pageref{#1}}%
580     \def\reftextpagerange#1#2{op bladsye~\pageref{#1}--\pageref{#2}}%
581     \def\reftextlabelrange#1#2{\ref{#1} tot~\ref{#2}}%
582   }}
583 %    \end{macrocode}
585 %    \begin{macrocode}
586 \DeclareOption{american}
587   {\vref@addto\extrasamerican{%
588     \def\reftextfaceafter {on the \reftextvario{facing}{next} page}%
589     \def\reftextfacebefore{on the \reftextvario{facing}{preceding}
590                            page}%
591     \def\reftextafter     {on the \reftextvario{following}{next} page}%
592     \def\reftextbefore    {on the \reftextvario{preceding}{previous} page}%
593     \def\reftextcurrent   {on \reftextvario{this}{the current} page}%
594     \def\reftextfaraway#1{on page~\pageref{#1}}%
595     \def\reftextpagerange#1#2{on pages~\pageref{#1}--\pageref{#2}}%
596     \def\reftextlabelrange#1#2{\ref{#1} to~\ref{#2}}%
597   }}
598 %    \end{macrocode}
599 % \changes{v1.2a}{1998/11/27}{Added austrian defaults (identical to german)}
600 %    The austrian defaults are the same as the german ones.
601 %    \begin{macrocode}
602 \DeclareOption{austrian}
603   {\vref@addto\extrasaustrian{%
604     \def\reftextfaceafter {auf der n\"achsten Seite}%
605     \def\reftextfacebefore{auf der vorherigen Seite}%
606     \let\reftextafter     \reftextfaceafter
607     \let\reftextbefore    \reftextfacebefore
608     \def\reftextcurrent   {auf dieser Seite}%
609     \def\reftextfaraway#1{auf Seite~\pageref{#1}}%
610     \def\reftextpagerange#1#2{auf Seiten~\pageref{#1}--\pageref{#2}}%
611     \def\reftextlabelrange#1#2{\ref{#1} bis~\ref{#2}}%
612   }}
613 %    \end{macrocode}
614 % \changes{v1.2d}{2000/01/11}{Added naustrian defaults (identical to german)}
615 %    The naustrian defaults are the same but needed for ``Neue Rechtschreibung''.
616 %    \begin{macrocode}
617 \DeclareOption{naustrian}
618   {\vref@addto\extrasnaustrian{%
619     \def\reftextfaceafter {auf der n\"achsten Seite}%
620     \def\reftextfacebefore{auf der vorherigen Seite}%
621     \let\reftextafter     \reftextfaceafter
622     \let\reftextbefore    \reftextfacebefore
623     \def\reftextcurrent   {auf dieser Seite}%
624     \def\reftextfaraway#1{auf Seite~\pageref{#1}}%
625     \def\reftextpagerange#1#2{auf Seiten~\pageref{#1}--\pageref{#2}}%
626     \def\reftextlabelrange#1#2{\ref{#1} bis~\ref{#2}}%
627   }}
628 %    \end{macrocode}
629 %    Text for basque defaults was contributed by
630 %    I\~naki Larra\~naga Murgoitio (aka dooteo)
631 %    (|<dooteo@euskalgnu.org>|).
632 % \changes{v1.4k}{2005/04/09}{Basque defaults added.}
633 %    \begin{macrocode}
634 \DeclareOption{basque}
635   {\vref@addto\extrasbasque{%
636     \def\reftextfaceafter {hurrengo orrialdean}%
637     \def\reftextfacebefore{aurreko orrialdean}%
638     \let\reftextafter     \reftextfaceafter
639     \let\reftextbefore    \reftextfacebefore
640     \def\reftextcurrent   {uneko orrialdean}%
641     \def\reftextfaraway#1{~\pageref{#1}. orrialdean}%
642     \def\reftextpagerange#1#2{~\pageref{#1}--\pageref{#2} orrialdeetan}%
643     \def\reftextlabelrange#1#2{\ref{#1}.etik \ref{#2}.eraino}%
644   }}
645 %    \end{macrocode}
646 %    Text for the Bahasa Malaysia defaults was contributed by
647 %    Bob Margolis 2005-12-02.
649 %    Notes: pada muka surat translates as ``on the page'' though BM has no
650 %    definite (or indefinite) article; adjectives and other modifiers follow
651 %    the noun (clause); bertentangan is ``opposite'' in the sense of
652 %    ``facing''; berikutnya is ``next'' (in this context - actually
653 %    next-to-this, literally); berikutnya also translates as ``following
654 %    this'' sebelumnya is ``preceding''; also ``previous'' ``ini'' translates,
655 %    literally, as ``this'' but is also used in the sense of current page.
656 % \changes{v1.4o}{2005/12/02}{Bahasa Malaysia defaults added.}
657 %    \begin{macrocode}
658 \DeclareOption{bahasam}
659   {\vref@addto\extrasbahasam{%
660     \def\reftextfaceafter {pada muka surat \reftextvario{bertentangan}{berikutnya}}%
661     \def\reftextfacebefore{pada muka surat \reftextvario{bertentangan}{sebelumnya} }%
662     \def\reftextafter     {pada muka surat berikutnya}%
663     \def\reftextbefore    {pada muka surat sebelumnya}%
664     \def\reftextcurrent   {pada muka surat ini}%
665     \def\reftextfaraway#1{pada muka surat~\pageref{#1}}%
666     \def\reftextpagerange#1#2{pada muka surat~\pageref{#1}--\pageref{#2}}%
667     \def\reftextlabelrange#1#2{\ref{#1}--\ref{#2}}%
668   }}
669 %    \end{macrocode}
670 %    Text for brazil defaults was contributed by
671 %    Alcino Dall Igna Junior\\
672 %    (|adij@di.ufpe.br|).
673 % \changes{v1.0g}{1994/05/18}{Brazil defaults added.}
674 % \changes{v1.4o}{2005/11/07}{Added a few more brazil strings}
675 % \changes{v1.4r}{2007/05/26}{Misspelling of \cs{extrasbrazil}}
676 %    \begin{macrocode}
677 \DeclareOption{brazil}
678   {\vref@addto\extrasbrazil{%
679     \def\reftextfaceafter {na \reftextvario{p\'agina oposta}{pr\'oxima
680                            p\'agina}}%
681     \def\reftextfacebefore{na p\'agina \reftextvario{oposta}{anterior}}%
682     \def\reftextafter     {na \reftextvario{p\'agina seguinte}{pr\'oxima
683                            p\'agina}}%
684     \def\reftextbefore{na p\'agina \reftextvario{anterior}{precedente}}%
685     \def\reftextcurrent   {\reftextvario{nesta p\'agina}{na p\'agina
686                            corrente}}%
687     \def\reftextfaraway#1{na p\'agina~\pageref{#1}}%
688     \def\reftextpagerange#1#2{nas p\'aginas~\pageref{#1}--\pageref{#2}}%
689     \def\reftextlabelrange#1#2{\ref{#1} a~\ref{#2}}%
690   }}
691 %    \end{macrocode}
692 %    Text for Breton defaults was contributed by
693 %    Christian ROLLAND\\
694 %    (|Christian.Rolland@univ-brest.fr|).
695 % \changes{v1.0o}{1994/09/27}{Added defaults for breton}
696 %    \begin{macrocode}
697 \DeclareOption{breton}
698   {\vref@excuse{breton}%
699    \vref@addto\extrasbreton{%
700     \def\reftextfaceafter {war ar bajenn \reftextvario{a-dal}{da heul}}%
701     \def\reftextfacebefore{war ar bajenn \reftextvario{a-dal}{a-raok}}%
702     \def\reftextafter     {war ar bajenn da heul}%
703     \def\reftextbefore    {war ar bajenn a-raok}%
704     \def\reftextcurrent   {war ar \reftextvario{bajenn-ma\~n}%
705                                                {bajenn war-wel}}%
706     \def\reftextfaraway#1{war ar bajenn~\pageref{#1}}%
707     \def\reftextpagerange#1#2{\vref@stringwarning\reftextpagerange
708                               on pages~\pageref{#1}--\pageref{#2}}%
709     \def\reftextlabelrange#1#2{\vref@stringwarning\reflabelpagerange
710                                \ref{#1} to~\ref{#2}}%
711   }}
712 %    \end{macrocode}
713 %    Text for Bulgarian defaults was contributed by
714 %    Georgi Boshnakov\\  (|georgi.boshnakov@gmail.com|).
715 % \changes{v1.4q}{2006/05/23}{Added defaults for bulgarian}
716 %    \begin{macrocode}
717 \DeclareOption{bulgarian}%
718  {\vref@addto\extrasbulgarian{%
719    \def\reftextfaceafter{\cyrn\cyra\
720          \reftextvario{\cyrs\cyrery\cyrs\cyre\cyrd\cyrn\cyra\cyrt\cyra}%
721                       {\cyrs\cyrl\cyre\cyrd\cyrv\cyra\cyrshch\cyra\cyrt\cyra}
722          \cyrs\cyrt\cyrr\cyra\cyrn\cyri\cyrc\cyra}%
723    \def\reftextfacebefore{\cyrn\cyra\
724          \reftextvario{\cyrs\cyrery\cyrs\cyre\cyrd\cyrn\cyra\cyrt\cyra}%
725                       {\cyrp\cyrr\cyre\cyrd\cyrn\cyra\cyrt\cyra}
726          \cyrs\cyrt\cyrr\cyra\cyrn\cyri\cyrc\cyra}%
727    \def\reftextafter{\cyrn\cyra\
728          \reftextvario{\cyrs\cyrl\cyre\cyrd\cyrv\cyra\cyrshch\cyra\cyrt\cyra}%
729                       {\cyrs\cyrl\cyre\cyrd\cyrv\cyra\cyrshch\cyra\cyrt\cyra}
730          \cyrs\cyrt\cyrr\cyra\cyrn\cyri\cyrc\cyra}%
731    \def\reftextbefore{\cyrn\cyra\
732          \reftextvario{\cyrp\cyrr\cyre\cyrd\cyrn\cyra\cyrt\cyra}%
733                       {\cyrp\cyrr\cyre\cyrd\cyri\cyrsh\cyrn\cyra\cyrt\cyra}
734          \cyrs\cyrt\cyrr\cyra\cyrn\cyri\cyrc\cyra}%
735    \def\reftextcurrent{\cyrn\cyra\
736          \reftextvario{\cyrt\cyra\cyrz\cyri}%
737                       {\cyrt\cyre\cyrk\cyru\cyrshch\cyra\cyrt\cyra}
738          \cyrs\cyrt\cyrr\cyra\cyrn\cyri\cyrc\cyra}%
739    \def\reftextfaraway#1{\cyrn\cyra\ \cyrs\cyrt\cyrr\cyra\cyrn\cyri\cyrc\cyra
740                          ~\pageref{#1}}%
741    \def\reftextpagerange#1#2{\cyrn\cyra\
742                         \cyrs\cyrt\cyrr\cyra\cyrn\cyri\cyrc\cyri
743                         ~\pageref{#1}--\pageref{#2}}%
744    \def\reftextlabelrange#1#2{\ref{#1} \cyrd\cyro~\ref{#2}}%
745  }}
746 %    \end{macrocode}
747 %    Text for catalan defaults was contributed by Robert Fuster\\
748 %    (\verb=rfuster@mat.upv.es=).
749 % \changes{v1.1c}{1997/06/12}{Added defaults for catalan}
750 % \changes{v1.2g}{2000/08/22}{Updated defaults for catalan}
751 %    \begin{macrocode}
752 \DeclareOption{catalan}
753   {\vref@addto\extrascatalan{%
754     \def\reftextfaceafter {a la p\`agina seg\"uent}%
755     \def\reftextfacebefore{a la p\`agina anterior}%
756     \let\reftextafter     \reftextfaceafter
757     \let\reftextbefore    \reftextfacebefore
758     \def\reftextcurrent   {en aquesta p\`agina}%
759     \def\reftextfaraway#1{a la p\`agina~\pageref{#1}}%
760     \def\reftextpagerange#1#2{a les
761                      p\`agines~\pageref{#1}--\pageref{#2}}%
762     \def\reftextlabelrange#1#2{\ref{#1} a~\ref{#2}}%
763   }}
764 %    \end{macrocode}
765 %    Text for croatian defaults was contributed by \v{S}ime Ungar
766 %    (\verb=ungar@math.hr=).
767 % \changes{v1.4p}{2006/05/13}{Added defaults for croatian}
768 %    \begin{macrocode}
769 \DeclareOption{croatian}
770    {\vref@addto\extrascroatian{%
771      \def\reftextfaceafter {na sljede\'coj stranici}%
772      \def\reftextfacebefore{na prethodnoj stranici}%
773      \let\reftextafter     \reftextfaceafter
774      \let\reftextbefore    \reftextfacebefore
775      \def\reftextcurrent   {na ovoj stranici}%
776      \def\reftextfaraway#1{na stranici~\pageref{#1}}%
777      \def\reftextpagerange#1#2{na stranicama~\pageref{#1}--\pageref{#2}}%
778      \def\reftextlabelrange#1#2{\ref{#1} do~\ref{#2}}%
779    }}
780 %    \end{macrocode}
781 %    Defaults for the Czech option provided by Milan Vancura
782 %    \verb=<milan@suse.cz>=.
783 % \changes{v1.2e}{2000/04/04}{Added czech defaults}
784 %    \begin{macrocode}
785 \DeclareOption{czech}
786   {%\vref@excuse{czech}%
787    \vref@addto\extrasczech{%
788     \def\reftextfaceafter {na n\'a\-sle\-du\-j\'\i c\'\i\ stran\v{e}}%
789     \def\reftextfacebefore{na p\v{r}ed\-choz\'\i\ stran\v{e}}%
790     \def\reftextafter     {na n\'a\-sle\-du\-j\'\i c\'\i\ stran\v{e}}%
791     \def\reftextbefore    {na p\v{r}ed\-choz\'\i\ stran\v{e}}%
792     \def\reftextcurrent   {na t\'eto stran\v{e}}%
793     \def\reftextfaraway#1{na stran\v{e}~\pageref{#1}}%
794     \def\reftextpagerange#1#2{na stran\'ach~\pageref{#1}\--\pageref{#2}}%
795     \def\reftextlabelrange#1#2{\ref{#1} a\v{z}~\ref{#2}}%
796   }}
797 %    \end{macrocode}
798 %    Defaults for Danish provided by Torsten Martinsen
799 %    (\verb=tmar91@kom.auc.dk=). Further defaults by Ole Laursen
800 %    (\verb=olau@hardworking.dk=).
801 % \changes{v1.0n}{1994/09/25}{Added Danish defaults}
802 % \changes{v1.2h}{2000/12/30}{Updates to Danish defaults}
803 %    \begin{macrocode}
804 \DeclareOption{danish}
805   {\vref@addto\extrasdanish{%
806     \def\reftextfaceafter {p\aa{} \reftextvario{modst\aa ende}%
807                                                {n\ae ste} side}%
808     \def\reftextfacebefore{p\aa{} \reftextvario{modst\aa ende}%
809                                                {forrige} side}%
810     \def\reftextafter     {p\aa{} \reftextvario{den f\o lgende}%
811                                                {n\ae ste} side}%
812     \def\reftextbefore    {p\aa{} \reftextvario{forrige side}
813                                                {foreg\aa ende side}}%
814     \def\reftextcurrent   {p\aa{} denne side}%
815     \def\reftextfaraway#1{p\aa{} side~\pageref{#1}}%
816     \def\reftextpagerange#1#2{p\aa{} side~\pageref{#1}--\pageref{#2}}%
817     \def\reftextlabelrange#1#2{\ref{#1} til~\ref{#2}}%
818   }}
819 %    \end{macrocode}
820 %    Default string for dutch have been contributed by Frank Poppe
821 %    (\verb=POPPE@SWOV.NL=).
822 %    This option currently supports one additional string macro
823 %    |\refpagename| so that you can easily change to |bladzijde|
824 %    instead of |pagina| if you prefer this word for ``page''.
825 %    However, I will not guarantee that this will survive future
826 %    versions of this package, so use it on your own risk (you can
827 %    always update the full strings to be on the safe side).
828 % \changes{v1.0l}{1994/07/07}{Added dutch defaults}
829 % \changes{v1.2a}{1998/08/22}{Added dutch defaults for
830 %      \cs{reftextpagerange} and \cs{reftextlabelrange}}
831 %    \begin{macrocode}
832 \DeclareOption{dutch}
833   {\vref@addto\extrasdutch{%
834     \def\refpagename{pagina}%
835     \def\reftextfaceafter {op de \reftextvario{rechter \refpagename}%
836                                           {\refpagename\ hiernaast}}%
837     \def\reftextfacebefore{op de \reftextvario{linker \refpagename}%
838                                          {\refpagename\ hiernaast}}%
839     \def\reftextafter     {op de \reftextvario{volgende \refpagename}%
840                                               {\refpagename\ hierna}}%
841     \def\reftextbefore    {op de \reftextvario{vorige \refpagename}%
842                                           {\refpagename\ hiervoor}}%
843     \def\reftextcurrent   {op deze \refpagename}%
844     \def\reftextfaraway#1{op \refpagename~\pageref{#1}}%
845 %    \end{macrocode}
846 %    Concerning the next defaults I received the following comment by
847 %    Frederik Fouvry \texttt{<fouvry@coli.uni-sb.de>}:
848 %    ``In the Dutch options (where I can exert a proper language
849 %    judgement ;-), `t/m' is not used in formal (scientific) texts.  I
850 %    would either use `--' or `tot en met' (the abbreviation written
851 %    out). ''
852 % \changes{v1.4d}{2002/11/11}{Changed default for \cs{reftextlabelrange}}
853 % \changes{v1.4m}{2005/06/09}{Fixed \cs{reftextlabelrange} (pr/3791)}
854 %    \begin{macrocode}
855     \def\reftextpagerange#1#2{op pagina's~\pageref{#1}--\pageref{#2}}%
856     \def\reftextlabelrange#1#2{\ref{#1}--\ref{#2}}%
857   }}
858 %    \end{macrocode}
859 % \changes{v1.2a}{1998/08/22}{Added english defaults for
860 %      \cs{reftextpagerange} and \cs{reftextlabelrange}}
861 % \changes{v1.4d}{2002/11/11}{Changed default for \cs{reftextbefore}}
862 %    \begin{macrocode}
863 \DeclareOption{english}
864   {\vref@addto\extrasenglish{%
865     \def\reftextfaceafter {on the \reftextvario{facing}{next} page}%
866     \def\reftextfacebefore{on the \reftextvario{facing}{preceding}
867                            page}%
868     \def\reftextafter     {on the \reftextvario{following}{next} page}%
869     \def\reftextbefore    {on the \reftextvario{preceding}{previous} page}%
870     \def\reftextcurrent   {on \reftextvario{this}{the current} page}%
871     \def\reftextfaraway#1{on page~\pageref{#1}}%
872     \def\reftextpagerange#1#2{on pages~\pageref{#1}--\pageref{#2}}%
873     \def\reftextlabelrange#1#2{\ref{#1} to~\ref{#2}}%
874   }}
875 %    \end{macrocode}
877 %    The esperanto strings were suggested by Albert Reiner
878 %    (\verb=areiner@tph.tuwien.ac.at=).
879 %  \changes{v1.4x}{2010/08/04}{Defaults for esperanto added}
880 %    \begin{macrocode}
881 \DeclareOption{esperanto}
882   {\vref@addto\extrasesperanto{%
883     \def\reftextfaceafter{en la
884         \reftextvario{flanka}{sekva} pa\^go}%
885     \def\reftextfacebefore{en la
886         \reftextvario{flanka}{anta\u ua} pa\^go}%
887     \def\reftextafter{en la sekva pa\^go}%
888     \def\reftextbefore{en la anta\u ua pa\^go}%
889     \def\reftextcurrent{\reftextvario{\^ci-pa\^ge}%
890         {en \^ci tiu pa\^go}}%
891     \def\reftextfaraway#1{en pa\^go~\pageref{#1}}%
892     \def\reftextpagerange#1#2{en pa\^goj~\pageref{#1} \^gis \pageref{#2}}%
893     \def\reftextlabelrange#1#2{\ref{#1} \^gis~\ref{#2}}%
894   }}
895 %    \end{macrocode}
896 %    The finnish strings were suggested by Matti Rintala
897 %    (\verb=bitti@cs.tut.fi=) and Hillevi Gavel
898 %    \verb=Hillevi.Gavel@mdh.se=.
899 % \changes{v1.0m}{1994/09/23}{Added finnish strings}
900 % \changes{v1.4o}{2005/11/07}{Added a few more finnish strings}
901 %    \begin{macrocode}
902 \DeclareOption{finnish}
903   {\vref@addto\extrasfinnish{%
904     \def\reftextfaceafter {\reftextvario{viereisell\"a}%
905                                         {seuraavalla} sivulla}%
906     \def\reftextfacebefore{\reftextvario{viereisell\"a}%
907                                         {edellisell\"a} sivulla}%
908     \def\reftextafter     {seuraavalla sivulla}%
909     \def\reftextbefore    {edellisell\"a sivulla}%
910     \def\reftextcurrent   {t\"all\"a sivulla}%
911     \def\reftextfaraway#1{sivulla~\pageref{#1}}%
912      \def\reftextpagerange#1#2{sivuilla~\pageref{#1}--\pageref{#2}}%
913 %    \end{macrocode}
914 %    Can't combine numbers with the necessary suffix well.
915 %    \begin{macrocode}
916      \def\reftextlabelrange#1#2{\ref{#1}--\ref{#2}}%
917   }}
918 %    \end{macrocode}
919 %    French defaults are provided by Daniel Flippo
920 %    (\verb=Daniel.Flipo@univ-lille1.fr=).
921 % \changes{v1.0j}{1994/06/21}{Added french defaults}
922 % \changes{v1.2a}{1998/08/22}{Added french defaults for
923 %      \cs{reftextpagerange} and \cs{reftextlabelrange}}
924 %    \begin{macrocode}
925 \DeclareOption{french}
926   {\vref@addto\extrasfrench{%
927     \def\reftextfaceafter {page \reftextvario{ci-contre}{suivante}}%
928     \def\reftextfacebefore{page \reftextvario{ci-contre}%
929                           {pr\'ec\'edente}}%
930     \def\reftextafter     {page suivante}%
931     \def\reftextbefore    {page pr\'ec\'edente}%
932     \def\reftextcurrent   {de la pr\'esente page}%
933     \def\reftextfaraway#1{page~\pageref{#1}}%
934     \def\reftextpagerange#1#2{pages~\pageref{#1}--\pageref{#2}}%
935     \def\reftextlabelrange#1#2{\ref{#1} \`a~\ref{#2}}%
936   }}
937 %    \end{macrocode}
938 %    Galician defaults are provided by Matthias Moebius\\
939 %    (\texttt{Matthias.Moebius@uni-konstanz.de}).
940 % \changes{v1.1f}{1998/04/25}{Added galician defaults}
941 % \changes{v1.4o}{2005/11/10}{Added further galician defaults}
942 % \changes{v1.4o}{2005/11/26}{Some further corrections}
943 % \changes{v1.5b}{2015/09/22}{Fixed blunder from 2005 -
944 %                             galician option clearly never used}
945 %    \begin{macrocode}
946 \DeclareOption{galician}
947   {\vref@addto\extrasgalician{%
948     \def\reftextfaceafter {na p\'axina oposta}%
949     \def\reftextfacebefore\reftextfaceafter
950     \def\reftextafter     {na p\'axina seguinte}%
951     \def\reftextbefore    {na p\'axina anterior}%
952     \def\reftextcurrent   {nesta p\'axina}%
953     \def\reftextfaraway#1{na p\'axina~\pageref{#1}}%
954      \def\reftextpagerange#1#2{%
955                 nas p\'axinas~\pageref{#1}-\pageref{#2}}%
956      \def\reftextlabelrange#1#2{\ref{#1} a~\ref{#2}}%
957   }}
958 %    \end{macrocode}
959 %    There are no good variants for German (I think and still think but
960 %    this is a matter of taste :-).
961 % \changes{v1.0b}{1994/01/31}{Replace in incorrect `def by `let}
962 %    The following definitions were recently suggested to me but since
963 %    the original are in for a long time i don't want to change them
964 %    now since that could make a lot of documents change their formatting.
965 %    If you fancy them, add a redefinition of the corresponding macro(s)
966 %    to the preamble of your document.
967 %\begin{verbatim}
968 %    \def\reftextfaceafter {auf der \reftextvario
969 %          {gegen\"uberliegenden}{anderen} Seite}%
970 %    \def\reftextfacebefore {auf der \reftextvario
971 %          {gegen\"uberliegenden}{anderen} Seite}%
972 %    \def\reftextafter     {auf der \reftextvario
973 %          {n\"achsten}{folgenden} Seite}%
974 %    \def\reftextbefore    {auf der \reftextvario
975 %          {vorigen}{vorhergehenden} Seite}%
976 %    \def\reftextcurrent   {\reftextvario
977 %          {auf dieser}{diese} Seite}%
978 %\end{verbatim}
979 % \changes{v1.4n}{2005/07/24}{Small change}
980 %    \begin{macrocode}
981 \DeclareOption{german}
982   {\vref@addto\extrasgerman{%
983     \def\reftextfaceafter {auf der n\"achsten Seite}%
984     \def\reftextfacebefore{auf der vorherigen Seite}%
985     \let\reftextafter     \reftextfaceafter
986     \let\reftextbefore    \reftextfacebefore
987     \def\reftextcurrent   {auf dieser Seite}%
988     \def\reftextfaraway#1{auf Seite~\pageref{#1}}%
989     \def\reftextpagerange#1#2{auf den Seiten~\pageref{#1}--\pageref{#2}}%
990     \def\reftextlabelrange#1#2{\ref{#1} bis~\ref{#2}}%
991   }}
992 %    \end{macrocode}
993 % \changes{v1.2d}{2000/01/11}{Added ngerman defaults (identical to german)}
994 % \changes{v1.4n}{2005/07/24}{Small change}
995 %    The ngerman defaults are the same but needed for ``Neue Rechtschreibung''
996 %    (i.e., a different set of hyphenation patterns).
997 %    \begin{macrocode}
998 \DeclareOption{ngerman}
999   {\vref@addto\extrasngerman{%
1000     \def\reftextfaceafter {auf der n\"achsten Seite}%
1001     \def\reftextfacebefore{auf der vorherigen Seite}%
1002     \let\reftextafter     \reftextfaceafter
1003     \let\reftextbefore    \reftextfacebefore
1004     \def\reftextcurrent   {auf dieser Seite}%
1005     \def\reftextfaraway#1{auf Seite~\pageref{#1}}%
1006     \def\reftextpagerange#1#2{auf den Seiten~\pageref{#1}--\pageref{#2}}%
1007     \def\reftextlabelrange#1#2{\ref{#1} bis~\ref{#2}}%
1008   }}
1009 %    \end{macrocode}
1010 %    Defaults for greek suggested by Apostolos Syropoulos\\
1011 %    (\verb=apostolo@obelix.ee.duth.gr=).
1012 % \changes{v1.2a}{1998/08/22}{Added defaults for greek}
1013 %    \begin{macrocode}
1014 \DeclareOption{greek}
1015   {\vref@addto\extrasgreek{%
1016     \def\reftextfaceafter {sthn \reftextvario{paro'usa}%
1017                            {ep'omenh} sel'ida}%
1018     \def\reftextfacebefore{sthn \reftextvario{paro'usa}{prohgo'umenh}
1019                            sel'ida}%
1020     \def\reftextafter     {sthn ep'omenh sel'ida}%
1021     \def\reftextbefore    {sthn prohgo'umenh sel'ida}%
1022     \def\reftextcurrent   {s'' aut'h th sel'ida}%
1023     \def\reftextfaraway#1{sth sel'ida\nobreakspace\pageref{#1}}%
1024     \def\reftextpagerange#1#2{stis sel'ides\nobreakspace
1025                           \pageref{#1}---\pageref{#2}}%
1026     \def\reftextlabelrange#1#2{\ref{#1} ws\nobreakspace\ref{#2}}%
1027   }}
1028 %    \end{macrocode}
1029 %    Icelandic defaults suggested by Thorhallur Sverrisson
1030 %    (\verb=thorhs@basis.is=).
1031 % \changes{v1.4t}{2007/09/07}{Added defaults for icelandic}
1032 %    \begin{macrocode}
1033 \DeclareOption{icelandic}
1034   {\vref@addto\extrasicelandic{%
1035     \def\reftextfaceafter {\'{a} \reftextvario{n{\ae}stu}%
1036                                               {n{\ae}stu} s\'{i}{\dh}u}%
1037     \def\reftextfacebefore{\'{a} \reftextvario{fyrri}%
1038                                               {fyrri} s\'{i}{\dh}u}%
1039     \def\reftextafter     {\'{a} \reftextvario{n{\ae}stu}%
1040                                               {n{\ae}stu} s\'{i}{\dh}u}%
1041     \def\reftextbefore    {\'{a} \reftextvario{fyrri}{fyrri} s\'{i}{\dh}u}%
1042     \def\reftextcurrent   {\'{a} \reftextvario{{\th}essari}%
1043                                               {{\th}essari} s\'{i}{\dh}u}%
1044     \def\reftextfaraway#1{\'{a} s\'{i}{\dh}u~\pageref{#1}}%
1045     \def\reftextpagerange#1#2{\'{a} s\'{i}{\dh}um~\pageref{#1}--\pageref{#2}}%
1046     \def\reftextlabelrange#1#2{\ref{#1} til~\ref{#2}}%
1047   }}
1048 %    \end{macrocode}
1049 %    Defaults for Italian suggested by Giovanni Pensa
1050 %    (\verb=pensa@dsi.unimi.it=) with i{\TeX}nici.
1051 % \changes{v1.1b}{1995/10/19}{Added defaults for Italian}
1052 % \changes{v1.2a}{1998/08/22}{Removed incorrect warning}
1053 % \changes{v1.4k}{2004/10/30}{Added missing defaults supplied by Lapo Mori}
1054 % \changes{v1.4n}{2005/07/24}{Small change}
1055 % \changes{v1.4u}{2009/03/21}{Correction for \cs{reftextfaraway} suggested
1056 %                             by Lorenzo Pantieri}
1057 %    \begin{macrocode}
1058 \DeclareOption{italian}
1059   {\vref@addto\extrasitalian{%
1060     \def\reftextfaceafter {\reftextvario{a fronte}%
1061                            {nella pagina successiva}}%
1062     \def\reftextfacebefore{\reftextvario{a fronte}%
1063                            {nella pagina precedente}}%
1064     \def\reftextafter     {nella pagina \reftextvario{seguente}%
1065                            {successiva}}%
1066     \def\reftextbefore    {nella pagina precedente}%
1067     \def\reftextcurrent   {in questa pagina}%
1068     \def\reftextfaraway#1{a pagina~\pageref{#1}}%
1069     \def\reftextpagerange#1#2{nelle pagine~\pageref{#1}--\pageref{#2}}%
1070     \def\reftextlabelrange#1#2{da~\ref{#1} a~\ref{#2}}%
1071   }}
1072 %    \end{macrocode}
1073 %   Defaults for Hungarian by Jeff Goldberg
1074 %   (\verb=jeffrey@goldmark.org=).
1075 %   There is a problem with the use of the definite article
1076 %   \textit{a} or \textit{az} in Hungarian before expansions
1077 %   of |\vref| or |\ref|.  The problem is that the word
1078 %   should be \textit{az} if the number following would begin with
1079 %   a vowel if spelled out, and \textit{a} if the number would begin
1080 %   with a consonant.
1082 %   The option assumes that there is a command |\aza| defined which
1083 %   helps resolving this problem.\footnote{This information is actually quite
1084 %   old but unfortunately never made it into varioref. In case any work
1085 %   has been undertaken to resolve this please inform the author about it.}
1086 % \changes{v1.2a}{1998/08/22}{Added defaults for magyar}
1087 % \changes{v1.4j}{2005/01/22}{Defined \cs{reftextfaceafter} and
1088 %       \cs{reftextfacebefore} instead of \cs{reftextafter} and \cs{reftextbefore}}
1089 %    \begin{macrocode}
1090 \DeclareOption{magyar}
1091   {\vref@addto\extrasmagyar{%
1092     \def\reftextafter {a k\"o\-vet\-kez\H{o} ol\-da\-lon}%
1093     \def\reftextbefore{az el\H{o}\-z\H{o} ol\-da\-lon}%
1094     \def\reftextfaceafter {\reftextvario{a t\'ul\-ol\-da\-lon}%
1095                           {a k\"o\-vet\-kez\H{o} ol\-da\-lon}}%
1096     \def\reftextfacebefore{\reftextvario{a t\'ul\-ol\-da\-lon}%
1097                           {az el\H{o}\-z\H{o} ol\-da\-lon}}%
1098     \def\reftextcurrent   {ezen az ol\-da\-lon}%
1099 %    \end{macrocode}
1100 %    The following suggested patch has not been added yet (pending changes
1101 %    in babel system).
1102 %\begin{verbatim}
1103 %    \def\reftextfaraway#1{a~\csname @@magyar@az@lowxu\endcsname
1104 %                                                {\pageref{#1}}.~ol\-da\-lon}%
1105 %    \def\reftextpagerange#1#2{a~\csname @@magyar@az@lowxu\endcsname
1106 %                                                        {\pageref{#1}}%
1107 %      --\pageref{#2}.~ol\-da\-la\-kon}%
1108 %    \def\reftextlabelrange#1#2{{}\csname @@magyar@told\endcsname\ref{#1}+tol
1109 %      \ref{#2}-ig}% Dat: `{}' is here for anti-\capitalize
1110 %\end{verbatim}
1111 %    \begin{macrocode}
1112     \def\reftextfaraway#1{\aza{\pageref{#1}} \pageref{#1}.~ol\-da\-lon}%
1113     \def\reftextpagerange#1#2{\vref@stringwarning\reftextpagerange
1114                               on pages~\pageref{#1}--\pageref{#2}}%
1115     \def\reftextlabelrange#1#2{\vref@stringwarning\reflabelpagerange
1116                                \ref{#1} to~\ref{#2}}%
1117    }%
1118 %    \end{macrocode}
1119 %    The |\AtBeginDocument| needs to be executed when the option is
1120 %    processed and not inside the babel interface.
1121 % \changes{v1.4i}{2004/02/27}{Moved \cs{AtBeginDocument}}
1122 %    \begin{macrocode}
1123    \AtBeginDocument{\providecommand\aza[1]{a/az%
1124        \PackageError{varioref}{%
1125          Proper definition for command \noexpand\aza missing}%
1126         {You need to (re)define the command \noexpand\aza that
1127          takes one argument (a number or a \noexpand\pageref command)
1128          and produces the string `a' or `az' depending on the argument
1129          value. It should also accept an optional argument (default `l')
1130          to denote whether or not the string should be lowercase or
1131          uppercase.}}}%
1132   }
1133 %    \end{macrocode}
1134 %    The Norwegian and `nynorsk' translations have been provided by
1135 %    Dag F Langmyhr \verb=<dag@ifi.uio.no>= and Karl Ove Hufthammer
1136 %    \verb=<huftis@bigfoot.com>=.
1137 % \changes{v1.0q}{1995/04/06}{Added defaults for norsk}
1138 % \changes{v1.0q}{1995/04/06}{Added defaults for nynorsk}
1139 % \changes{v1.2a}{1998/08/22}{Updated defaults for norsk}
1140 % \changes{v1.2a}{1998/08/22}{Updated defaults for nynorsk}
1141 % \changes{v1.2a}{1998/08/22}{Added norsk defaults for
1142 %      \cs{reftextpagerange} and \cs{reftextlabelrange}}
1143 % \changes{v1.2a}{1998/08/22}{Added nynorsk defaults for
1144 %      \cs{reftextpagerange} and \cs{reftextlabelrange}}
1145 % \changes{v1.2i}{2001/01/12}{Updated nynorsk defaults}
1146 %    \begin{macrocode}
1147 \DeclareOption{norsk}
1148   {\vref@addto\extrasnorsk{%
1149     \def\reftextfaceafter {p\aa{} neste side}%
1150     \def\reftextfacebefore{p\aa{} forrige side}%
1151     \def\reftextafter     {p\aa{} neste side}%
1152     \def\reftextbefore    {p\aa{} forrige side}%
1153     \def\reftextcurrent   {p\aa{} denne siden}%
1154     \def\reftextfaraway#1{p\aa{} side~\pageref{#1}}%
1155     \def\reftextpagerange#1#2{p\aa{} side~\pageref{#1}--\pageref{#2}}%
1156     \def\reftextlabelrange#1#2{\ref{#1} til~\ref{#2}}%
1157   }}
1158 \DeclareOption{nynorsk}
1159   {\vref@addto\extrasnynorsk{%
1160     \def\reftextfaceafter {p\aa{} neste side}%
1161     \def\reftextfacebefore{p\aa{} f\o{}rre side}%
1162     \def\reftextafter     {p\aa{} neste side}%
1163     \def\reftextbefore    {p\aa{} f\o{}rre side}%
1164     \def\reftextcurrent   {p\aa{} denne sida}%
1165     \def\reftextfaraway#1{p\aa{} side~\pageref{#1}}%
1166     \def\reftextpagerange#1#2{p\aa{} side~\pageref{#1}--\pageref{#2}}%
1167     \def\reftextlabelrange#1#2{\ref{#1} til~\ref{#2}}%
1168   }}
1169 %    \end{macrocode}
1170 %    The polish translations have been provided by
1171 %    Tomasz Michniewski \\
1172 %    \verb=<tomekm@ias.wat.waw.pl>=.
1173 %    The use of the command \verb=\eob= and \verb=aob= etc.\
1174 %    requires appropriate definitions as provided, for example, by
1175 %    the babel system. This should probably be handled differently
1176 %    but it would require modifications in babel's language support.
1177 % \changes{v1.1d}{1997/12/06}{Added defaults for polish}
1178 % \changes{v1.2a}{1998/08/22}{Added polish defaults for
1179 %      \cs{reftextpagerange} and \cs{reftextlabelrange}}
1180 % \changes{v1.4n}{2005/09/14}{Changed default for \cs{reftextfaraway}}
1181 %    \begin{macrocode}
1182 \DeclareOption{polish}
1183   {\vref@addto\extraspolish{%
1184     \def\reftextfaceafter {na \reftextvario{s\aob{}siedniej}%
1185                                    {nast\eob{}pnej} stronie}%
1186     \def\reftextfacebefore{na \reftextvario{s\aob{}siedniej}%
1187                                    {poprzedniej} stronie}%
1188     \def\reftextafter     {na nast\eob{}pnej stronie}%
1189     \def\reftextbefore    {na poprzedniej stronie}%
1190     \def\reftextcurrent   {na \reftextvario{tej
1191                            samej}{bie\zkb{}\aob{}cej} stronie}%
1192     \def\reftextfaraway#1{na stronie~\pageref{#1}}%
1193     \def\reftextpagerange#1#2{na stronach~\pageref{#1}--\pageref{#2}}%
1194     \def\reftextlabelrange#1#2{od~\ref{#1} do~\ref{#2}}%
1195   }}
1196 %    \end{macrocode}
1197 %    The portuguese default text has been provided by
1198 %    Jos\'e Carlos Oliveira Santos \verb=jcsantos@fc.up.pt=.
1199 % \changes{v1.2b}{1999/11/25}{Added portuguese defaults}
1200 % \changes{v1.2c}{1999/12/02}{Added more portuguese defaults}
1201 % \changes{v1.4r}{2007/05/26}{Misspelling of \cs{extrasportuges}}
1202 %    \begin{macrocode}
1203 \DeclareOption{portuges}
1204   {\vref@addto\extrasportuges{%
1205     \def\reftextfaceafter {na \reftextvario{p\'agina ao lado}{pr\'oxima
1206                            p\'agina}}%
1207     \def\reftextfacebefore{na p\'agina \reftextvario{ao lado}{anterior}}%
1208     \def\reftextafter     {na \reftextvario{p\'agina seguinte}{pr\'oxima
1209                            p\'agina}}%
1210     \def\reftextbefore{na p\'agina \reftextvario{anterior}{precedente}}%
1211     \def\reftextcurrent   {nesta p\'agina}%
1212     \def\reftextfaraway#1{na p\'agina~\pageref{#1}}%
1213      \def\reftextpagerange#1#2{nas p\'aginas~\pageref{#1}--\pageref{#2}}%
1214      \def\reftextlabelrange#1#2{\ref{#1} a~\ref{#2}}%
1215   }}
1216 %    \end{macrocode}
1217 % Updates to the default text for Romanian have been suggested by Florin Oprina
1218 %  (\verb=<florin.oprina@gmail.com>=).
1219 % \changes{v1.4v}{2009/06/13}{Incorrect text in \cs{reftextafter} (pr/4070)}
1220 % \changes{v1.5a}{2014/07/03}{Correct text in \cs{reftextbefore}}
1221 %    \begin{macrocode}
1222 \DeclareOption{romanian}
1223   {\vref@addto\extrasromanian{%
1224     \def\reftextfaceafter {pe pagina \reftextvario{opus\u{a}}{urm\u{a}toarei}}%
1225     \def\reftextfacebefore{pe pagina \reftextvario{opus\u{a}}{precedentei}}%
1226     \def\reftextafter     {\reftextvario{pe pagina urm\u{a}toare}%
1227                                         {pe urm\u{a}toarea pagin\u{a}}}%
1228     \def\reftextbefore    {pe pagina \reftextvario{precedent\u{a}}%
1229                                                   {precedentei}}%
1230     \def\reftextcurrent   {pe aceast\u{a} pagin\u{a}}%
1231     \def\reftextfaraway#1{pe pagina~\pageref{#1}}%
1232     \def\reftextpagerange#1#2{pe paginile~\pageref{#1}--\pageref{#2}}%
1233     \def\reftextlabelrange#1#2{\ref{#1} la~\ref{#2}}%
1234   }}
1235 %    \end{macrocode}
1236 %    The text for russian was taken from the book in Russian by
1237 %    I.~A.~Kotelnikov and P.~Z.~Chebotaev, and adapted
1238 %    to the encoding-independent form by Vladimir Volovich
1239 %    (\verb=vvv@vsu.ru=).
1240 % \changes{v1.2a}{1998/11/23}{Added russian strings}
1241 % \changes{v1.2a}{1998/11/24}{Added defaults for
1242 %      \cs{reftextpagerange} and \cs{reftextlabelrange}}
1243 %    \begin{macrocode}
1244 \DeclareOption{russian}
1245   {\vref@addto\extrasrussian{%
1246     \def\reftextfaceafter{\cyrn\cyra\ \reftextvario{\cyrp\cyrr\cyro
1247       \cyrt\cyri\cyrv\cyro\cyrp\cyro\cyrl\cyro\cyrzh\cyrn\cyro\cyrishrt}%
1248       {\cyrs\cyrl\cyre\cyrd\cyru\cyryu\cyrshch\cyre\cyrishrt}\ \cyrs\cyrt
1249       \cyrr\cyra\cyrn\cyri\cyrc\cyre}%
1250     \def\reftextfacebefore{\cyrn\cyra\ \reftextvario{\cyrp\cyrr\cyro
1251       \cyrt\cyri\cyrv\cyro\cyrp\cyro\cyrl\cyro\cyrzh\cyrn\cyro\cyrishrt}%
1252       {\cyrp\cyrr\cyre\cyrd\cyrery\cyrd\cyru\cyrshch\cyre\cyrishrt}\
1253       \cyrs\cyrt\cyrr\cyra\cyrn\cyri\cyrc\cyre}%
1254     \def\reftextafter{\cyrn\cyra\ \cyrs\cyrl\cyre\cyrd\cyru\cyryu\cyrshch
1255       \cyre\cyrishrt\ \cyrs\cyrt\cyrr\cyra\cyrn\cyri\cyrc\cyre}%
1256     \def\reftextbefore{\cyrn\cyra\ \reftextvario{\cyrp\cyrr\cyre\cyrd
1257       \cyrsh\cyre\cyrs\cyrt\cyrv\cyru\cyryu\cyrshch\cyre\cyrishrt}%
1258       {\cyrp\cyrr\cyre\cyrd\cyrery\cyrd\cyru\cyrshch\cyre\cyrishrt}%
1259       \ \cyrs\cyrt\cyrr\cyra\cyrn\cyri\cyrc\cyre}%
1260     \def\reftextcurrent{\cyrn\cyra\ \reftextvario{\cyrerev\cyrt\cyro
1261       \cyrishrt}{\cyrd\cyra\cyrn\cyrn\cyro\cyrishrt}\ \cyrs\cyrt\cyrr
1262       \cyra\cyrn\cyri\cyrc\cyre}%
1263     \def\reftextfaraway#1{\cyrn\cyra\ \cyrs.~\pageref{#1}}%
1264     \def\reftextpagerange#1#2{\cyrn\cyra\ \cyrs\cyrt\cyrr\cyra\cyrn
1265       \cyri\cyrc\cyra\cyrh~\pageref{#1}--\pageref{#2}}%
1266     \def\reftextlabelrange#1#2{\cyrs~\ref{#1}\ \cyrp\cyro~\ref{#2}}%
1267   }}
1268 %    \end{macrocode}
1269 %    The text for slovak defaults was contributed by Miroslav Sedivy\\
1270 %    (\verb=<miro@slovensko.com>=).
1271 % \changes{v1.4b}{2002/03/11}{Contributed defaults added}
1272 %    \begin{macrocode}
1273 \DeclareOption{slovak}
1274   {\vref@addto\extrasslovak{%
1275     \def\reftextfaceafter {na \reftextvario{proti\v lahlej}%
1276                           {nasleduj\'ucej} strane}%
1277     \def\reftextfacebefore{na \reftextvario{proti\v lahlej}%
1278                           {predch\'adzaj\'ucej} strane}%
1279     \def\reftextafter     {na \reftextvario{nasleduj\'ucej}%
1280                           {\v dal\v sej} strane}%
1281     \def\reftextbefore    {na \reftextvario{predch\'adzaj\'ucej}%
1282                           {predo\v slej} strane}%
1283     \def\reftextcurrent   {na tejto strane}%
1284     \def\reftextfaraway#1{na strane~\pageref{#1}}%
1285     \def\reftextpagerange#1#2{na stran\'ach~\pageref{#1}--\pageref{#2}}%
1286     \def\reftextlabelrange#1#2{\ref{#1} a\v z~\ref{#2}}%
1287   }}
1288 %    \end{macrocode}
1289 %    The text for slovene defaults was contributed by Roman Maurer\\
1290 %    (\verb=<roman.maurer@amis.net>=).
1291 % \changes{v1.4a}{2002/03/05}{Contributed defaults added}
1292 %    \begin{macrocode}
1293 \DeclareOption{slovene}
1294   {\vref@addto\extrasslovene{%
1295     \def\reftextfaceafter {na naslednji strani}%
1296     \def\reftextfacebefore{na prej\v{s}nji strani}%
1297     \let\reftextafter     \reftextfaceafter
1298     \let\reftextbefore    \reftextfacebefore
1299     \def\reftextcurrent   {na \reftextvario{tej}{trenutni} strani}%
1300     \def\reftextfaraway#1{na strani~\pageref{#1}}%
1301     \def\reftextpagerange#1#2{na straneh~\pageref{#1}--\pageref{#2}}%
1302     \def\reftextlabelrange#1#2{od~\ref{#1} do~\ref{#2}}%
1303   }}
1304 %    \end{macrocode}
1305 %    Text for spanish defaults was contributed by Julio Sanchez
1306 %    (\verb=jsanchez@gmv.es=) and Fernando Dobladez (\verb=<ferd@fuego.com>=).
1307 % \changes{v1.0f}{1994/03/16}{Inserted missing hash mark}
1308 % \changes{v1.0k}{1994/06/05}{Corrected misspelled cmd `extrasspanish}
1309 % \changes{v1.4a}{2002/03/05}{Missing defaults added}
1310 % \changes{v1.4o}{2005/11/26}{Single hyphen in range}
1311 %    \begin{macrocode}
1312 \DeclareOption{spanish}
1313   {\vref@addto\extrasspanish{%
1314     \def\reftextfaceafter {en la p\'agina siguiente}%
1315     \def\reftextfacebefore{en la p\'agina anterior}%
1316     \let\reftextafter     \reftextfaceafter
1317     \let\reftextbefore    \reftextfacebefore
1318     \def\reftextcurrent   {en esta p\'agina}%
1319     \def\reftextfaraway#1{en la p\'agina~\pageref{#1}}%
1320     \def\reftextpagerange#1#2{en las p\'aginas~\pageref{#1}%
1321                                              -\pageref{#2}}%
1322     \def\reftextlabelrange#1#2{\ref{#1} a~\ref{#2}}%
1323   }}
1324 %    \end{macrocode}
1325 %    The text for swedish was contributed by Mats Dahlgren
1326 %    (\verb=matsd@sssk.se=).
1327 % \changes{v1.0p}{1995/01/10}{Added swedish strings}
1328 % \changes{v1.2a}{1998/08/22}{Added swedish defaults for
1329 %      \cs{reftextpagerange} and \cs{reftextlabelrange}}
1330 %    \begin{macrocode}
1331 \DeclareOption{swedish}
1332   {\vref@addto\extrasswedish{%
1333      \def\reftextfaceafter {p\aa\ \reftextvario{motst\aa ende}%
1334                                              {n\"{a}sta} sida}%
1335      \def\reftextfacebefore{p\aa\ \reftextvario{motst\aa ende}%
1336                                       {f\"{o}reg\aa ende} sida}%
1337      \def\reftextafter     {p\aa\ \reftextvario{f\"{o}ljande}%
1338                                             {n\"{a}sta} sida}%
1339      \def\reftextbefore    {p\aa\ f\"{o}reg\aa ende sida}%
1340      \def\reftextcurrent   {p\aa\ denna sida}%
1341      \def\reftextfaraway#1{p\aa\ sidan~\pageref{#1}}%
1342      \def\reftextpagerange#1#2{p\aa\
1343                                sidorna~\pageref{#1}--\pageref{#2}}%
1344      \def\reftextlabelrange#1#2{\ref{#1} till~\ref{#2}}%
1345   }}
1346 \DeclareOption{turkish}
1347   {\vref@excuse{turkish}%
1348    \vref@addto\extrasturkish{%
1349     \def\reftextfaceafter {on the \reftextvario{facing}{next} page}%
1350     \def\reftextfacebefore{on the \reftextvario{facing}{preceding}
1351                            page}%
1352     \def\reftextafter     {on the \reftextvario{following}{next} page}%
1353     \def\reftextbefore    {on the \reftextvario{preceding}{previous} page}%
1354     \def\reftextcurrent   {on \reftextvario{this}{the current} page}%
1355     \def\reftextfaraway#1{on page~\pageref{#1}}%
1356     \def\reftextpagerange#1#2{on pages~\pageref{#1}--\pageref{#2}}%
1357     \def\reftextlabelrange#1#2{\ref{#1} to~\ref{#2}}%
1358   }}
1359 %    \end{macrocode}
1360 %    The text for Ukrainian defaults was contributed by Mykola Lyakhovych\\
1361 %    (\verb=<lyakhovych@mail.ru>=).
1362 % \changes{v1.4l}{2005/04/24}{Contributed defaults added}
1363 %    \begin{macrocode}
1364 \DeclareOption{ukrainian}
1365    {\vref@addto\extrasukrainian{%
1366      \def\reftextfaceafter{\cyrn\cyra\ \reftextvario{\cyrp\cyrr\cyro
1367        \cyrt\cyri\cyrl\cyre\cyrzh\cyrn\cyrii\cyrishrt}%
1368        {\cyrn\cyra\cyrs\cyrt\cyru\cyrp\cyrn\cyrii\cyrishrt}\ \cyrs\cyrt
1369        \cyro\cyrr\cyri\cyrn\cyrc\cyrii}%
1370      \def\reftextfacebefore{\cyrn\cyra\ \reftextvario{\cyrp\cyrr\cyro
1371        \cyrt\cyri\cyrl\cyre\cyrzh\cyrn\cyrii\cyrishrt}%
1372        {\cyrp\cyro\cyrp\cyre\cyrr\cyre\cyrd\cyrn\cyrii\cyrishrt}\
1373        \cyrs\cyrt\cyro\cyrr\cyrii\cyrn\cyrc\cyrii}%
1374      \def\reftextafter{\cyrn\cyra\ \cyrn\cyra\cyrs\cyrt\cyru\cyrp\cyrn
1375        \cyrii\cyrishrt\ \cyrs\cyrt\cyro\cyrr\cyrii\cyrn\cyrc\cyrii}%
1376      \def\reftextbefore{\cyrn\cyra\ \cyrp\cyro\cyrp\cyre\cyrr\cyre\cyrd
1377        \cyrn\cyrii\cyrishrt\ \cyrs\cyrt\cyro\cyrr\cyrii\cyrn\cyrc\cyrii}%
1378      \def\reftextcurrent{\cyrn\cyra\ \reftextvario{\cyrc\cyrii\cyrishrt}%
1379        {\cyrd\cyra\cyrn\cyrii\cyrishrt}\ \cyrs\cyrt\cyro\cyrr\cyrii\cyrn
1380        \cyrc\cyrii}%
1381      \def\reftextfaraway#1{\cyrn\cyra\ \cyrs.~\pageref{#1}}%
1382      \def\reftextpagerange#1#2{\cyrn\cyra\ \cyrs\cyrt\cyro\cyrr\cyrii
1383        \cyrn\cyrk\cyra\cyrh~\pageref{#1}--\pageref{#2}}%
1384      \def\reftextlabelrange#1#2{\cyrz~\ref{#1}\ \cyrd\cyro~\ref{#2}}%
1385    }}
1386 %    \end{macrocode}
1387 %    We support francais as an alternative to french since people
1388 %    might be used to it, but we discurrage it.
1389 %    \begin{macrocode}
1390 \DeclareOption{francais}{%
1391    \typeout{Please use `french' instead of `francais'}%
1392    \ExecuteOptions{french}}
1393 \DeclareOption{germanb}{%
1394    \typeout{Please use `german' instead of `germanb'}%
1395    \ExecuteOptions{german}}
1396 %    \end{macrocode}
1397 %  \end{macro}
1398 %  \end{macro}
1399 %  \end{macro}
1400 %  \end{macro}
1401 %  \end{macro}
1403 %    During document preparation errors due to |\vref| are usually of
1404 %    not much interest. For this reason the draft option turns them into
1405 %    warnings by issuing a |\vrefwarning| command. The final option
1406 %    (default) stops with an error message when varioref detects a possible
1407 %    loop.
1408 % \changes{v1.1h}{1998/08/01}{Added draft and final options}
1409 %    \begin{macrocode}
1410 \DeclareOption{draft}{\AtEndOfPackage\vrefwarning}
1411 \DeclareOption{final}{\AtEndOfPackage\vrefshowerrors} % the default
1412 %    \end{macrocode}
1414 %    After all options are declared we execute the default option
1415 %    \texttt{english} to set up the defaults and then call
1416 %    |\ProcessOptions*| to handle any option passed to the package.
1417 %    The star form is used since we want to execute the options in the
1418 %    order they are given (in case this isn't used together with the
1419 %    \texttt{babel} package).
1420 %    \begin{macrocode}
1421 \ExecuteOptions{english,final}
1422 \ProcessOptions*
1423 %    \end{macrocode}
1426 % \subsection{Defining the main macros}
1428 % \begin{macro}{\vr@cnt}
1429 %    To generate new labels we use a counter and construct the
1430 %    internal label names by prefixing the current counter value with
1431 %    the string |vr@|. We need a \LaTeX{} counter to get |\include|s
1432 %    handled correctly.
1433 % \changes{v0.1e}{1992/11/15}{use LaTeX counter}
1434 %    \begin{macrocode}
1435 \newcounter{vrcnt}
1436 %    \end{macrocode}
1437 % \end{macro}
1439 % \begin{macro}{\vpageref}
1440 % \changes{v1.3a}{2001/04/12}{Scan for star form}
1441 % \begin{macro}{\vp@geref}
1442 %    The command |\vpageref| generates the appropriate string by first
1443 %    parsing the optional arguments (if any) and then compares the
1444 %    internal and the user label.  This command should be robust since
1445 %    the user might put it anywhere.
1447 %    We now start by scanning for a star which means: do not add a
1448 %    space in front of the generated text---ever.
1449 %    \begin{macrocode}
1450 \DeclareRobustCommand\vpageref{\@ifstar
1451      {\let\vref@space\relax\vp@geref}%
1452      {\let\vref@space\space\vp@geref}}
1453 %    \end{macrocode}
1455 %    \begin{macrocode}
1456 \def\vp@geref{\@ifnextchar[%
1457 %    \end{macrocode}
1458 %    The default for the first optional argument is the string hidden
1459 %    in the macro |\reftextcurrent|.
1460 %    \begin{macrocode}
1461   \@vpageref{\@vpageref[\reftextcurrent]}%
1463 %    \end{macrocode}
1464 % \end{macro}
1465 % \end{macro}
1467 % \begin{macro}{\vref@space}
1468 % \changes{v1.4a}{2002/03/06}{Default added}
1469 %    A default for |\vref@space|. This isn't really needed except in
1470 %    the case that somebody has hooked into the \texttt{varioref}
1471 %    interfaces at a lower level (which isn't really supported,
1472 %    but\ldots). So giving a default will prevent an error message in
1473 %    that case (and should hopefully produce the same behavior as before).
1474 %    \begin{macrocode}
1475 \let\vref@space\space
1476 %    \end{macrocode}
1477 % \end{macro}
1479 % \begin{macro}{\@vpageref}
1480 %    More parsing\ldots
1481 %    \begin{macrocode}
1482 \def\@vpageref[#1]{\@ifnextchar[%
1483 %    \end{macrocode}
1484 %    The default for the second optional argument is a space which is
1485 %    prefixed by |\unskip| to get rid of any leading space inserted
1486 %    already.
1487 % \changes{v1.0h}{1994/06/11}{Pass first argument in both cases}
1488 % \changes{v1.0i}{1994/06/20}{Do it correctly}
1489 %    \begin{macrocode}
1490   {\@@vpageref{#1}}{\@@vpageref{#1}[\unskip\vref@space]}}
1491 %    \end{macrocode}
1492 % \end{macro}
1494 % \begin{macro}{\@@vpageref}
1495 %     The |\@@vpageref| macro finally generates the references by
1496 %    comparing the value of an internal label with the value of the
1497 %    user label.
1498 % \changes{v1.0h}{1994/06/11}{Change internal interface}
1499 %    \begin{macrocode}
1500 \def\@@vpageref#1[#2]#3{%
1501 %    \end{macrocode}
1502 %    First it switches to horizontal mode if necessary and also
1503 %    removes any leading space.
1504 %    \begin{macrocode}
1505   \leavevmode\unskip
1506 %    \end{macrocode}
1507 %    Then it advances the counter |\c@vrcnt| by one which is used to
1508 %    generate internal label names.
1509 %    \begin{macrocode}
1510   \global\advance\c@vrcnt\@ne
1511 %    \end{macrocode}
1512 %    Then it checks if for the current value of |\c@vrcnt| a label
1513 %    command was issued in the last run. If not it pretends that there
1514 %    was one with the value |{??}{??}|.  Thereafter it stores the
1515 %    pageref value for this label in the macro |\@tempa|.
1516 %    \begin{macrocode}
1517   \vref@pagenum\@tempa{\the\c@vrcnt @vr}%
1518 %    \end{macrocode}
1519 %    Here we check that the generated text is not going across a page
1520 %    boundary.
1521 % \changes{v0.1f}{1993/01/01}{Add another label to catch cross-overs}
1522 %    \begin{macrocode}
1523   \vref@pagenum\@tempb{\the\c@vrcnt @xvr}%
1524 %    \end{macrocode}
1525 % \changes{v1.0l}{1994/07/07}{Explicitly expand `label argument for
1526 %                            babel}
1527 %    In version 1.0l the label string has been turned around so that
1528 %    the number comes first. This was done to allow easy explicit
1529 %    expansion of the number before it is passed to the |\label|
1530 %    command. In the babel system the argument of |label| was not
1531 %    expanded with the result that wrong label strings have been
1532 %    generated. This is a general problem that might need a completely
1533 %    different solution in babel but for now the change below (and in
1534 %    some other places in the code) should solve the problem for this
1535 %    special combination of packages.
1537 %    These days we actually use |\vref@label| instead of |\label| as
1538 %    this avoids problems with Babel or \texttt{amsmath} redefining
1539 %    the latter command.
1540 % \changes{v1.4e}{2003/01/08}{Use \cs{vref@label} instead of
1541 %    \cs{label} (pr/3489)}
1542 %    \begin{macrocode}
1543    \vref@label{\the\c@vrcnt @xvr}%
1544 %    \end{macrocode}
1545 % \changes{v1.1g}{1998/05/10}{Test if inside AMS display (pr2175)}
1546 %    Inside displays of the \texttt{amsmath} package the |\label| command
1547 %    is redefined which makes the test for loops incorrect if a |\vref|
1548 %    is used in, say, |\intertext|. So we test this condition first and
1549 %    only do the test if |\label| doesn't have a special meaning.
1550 %    [This is no longer necessary as |\label| isn't used any more]
1551 %    \begin{macrocode}
1552 %  \ifx\label\label@in@display\else
1553     \ifx\@tempa\@tempb\else
1554 %    \end{macrocode}
1555 %    If both points do not fall onto the same page with either issue
1556 %    an error or a warning message.
1557 % \changes{v1.0g}{1994/05/27}{Looping pages shown in wrong order}
1558 %    \begin{macrocode}
1559     \vref@err{\noexpand\vref or \noexpand\vpageref at page boundary
1560               \@tempb-\@tempa\space (may loop)%
1561               }%
1562     \fi
1563 %  \fi
1564 %    \end{macrocode}
1565 %    Same game for the user requested label; this time the page
1566 %    reference is saved in |\thevpagerefnum|.
1567 % \changes{v1.4c}{2002/06/14}{Use \cs{thevpagerefnum} instead of \cs{@tempb}}
1568 %    \begin{macrocode}
1569   \vrefpagenum\thevpagerefnum{#3}%
1570 %    \end{macrocode}
1571 %    Now after the internal label has served its purpose if would be
1572 %    nice to free the memory it occupies by using something like
1573 %    \begin{verbatim}
1574 % \global\expandafter\let
1575 %        \csname r@\the\c@vrcnt @vr\endcsname\@empty
1576 %\end{verbatim}
1577 %    But this is not possible because it would result in getting
1578 %    `Labels may have changed\ldots' warnings for every run.  Now we
1579 %    are ready to produce the textual strings.  Since we have removed
1580 %    any leading space we now insert a space (unless this was the star
1581 %    form of the command) and then compare the two
1582 %    page references.
1583 %    \begin{macrocode}
1584   \vref@space
1585   \ifx\@tempa\thevpagerefnum
1586 %    \end{macrocode}
1587 %    If they are the same we insert the first argument into the input
1588 %    stream.  Otherwise we insert the second argument.  Recall that
1589 %    those are the two optional arguments of |...|. However, if the
1590 %    user explicitly requested an empty text string using the optional
1591 %    argument we cancel any preceding space.
1592 % \changes{v1.2f}{2000/07/07}{Don't output space if optional argument
1593 %    empty (pr/3230)}
1594 %    \begin{macrocode}
1595     \def\@tempc{#1}%
1596     \ifx\@tempc\@empty
1597        \unskip
1598     \else
1599        #1%
1600     \fi
1601   \else
1602     #2%
1603 %    \end{macrocode}
1604 %    Now we check if the page number of the referenced object (stored
1605 %    in |\thevpagerefnum| is a single positive number.
1606 %    \begin{macrocode}
1607     \is@pos@number\thevpagerefnum
1608        {%
1609 %    \end{macrocode}
1610 %    If so, we check if the current position (stored in |\@tempa|) is
1611 %    a positive number. If this is the case we assign this number to
1612 %    the counter register |\@tempcnta| and add one to it.
1613 %    \begin{macrocode}
1614         \is@pos@number\@tempa
1615          {\@tempcnta\@tempa
1616           \advance\@tempcnta\@ne
1617          }%
1618 %    \end{macrocode}
1619 %    If it is not a positive number we assign the largest possible
1620 %    number to |\@tempcnta| and thereby pretending that label and
1621 %    reference are miles away from each other.
1622 %    \begin{macrocode}
1623          {\@tempcnta\maxdimen}%
1624 %    \end{macrocode}
1625 %    Now we are ready to check if reference and object are on nearby
1626 %    pages. |\thevpagerefnum| will expand to the page number of the object
1627 %    (and we know that this is a number) and |\@tempcnta| is either
1628 %    one higher than the reference page or completely out of bounds.
1629 %    So if both represent the same value then the object lies one page
1630 %    after its reference.
1631 %    \begin{macrocode}
1632         \ifnum \thevpagerefnum =\@tempcnta
1633 %    \end{macrocode}
1634 %    Thus if the object falls onto an odd page then the reference is
1635 %    on the facing even page (and so we insert |\reftextfaceafter|),
1636 %    otherwise the object can not be seen from the reference (and we
1637 %    in insert |\reftextafter|).  Don't be surprised if we are not
1638 %    using |\thevpagerefnum| in the check. Since |\@tempcnta| has the same
1639 %    value it is faster to use the register instead of parsing the
1640 %    macro contents anew.
1641 %    \begin{macrocode}
1642          \ifodd\@tempcnta
1643 %    \end{macrocode}
1644 %    In fact we are going to use |\reftextfaceafter| only if we are
1645 %    doing two-sided printing, otherwise |\reftextafter| is always
1646 %    used.
1647 %    Since the value of |\if@twoside| is evaluated before reading in
1648 %    packages we could do better (saving some tokens) by defining
1649 %    the current macro in dependence of this boolean.
1650 %    \begin{macrocode}
1651            \if@twoside
1652              \reftextfaceafter
1653            \else
1654              \reftextafter
1655            \fi
1656          \else
1657            \reftextafter
1658          \fi
1659 %    \end{macrocode}
1660 %    If the object is not on the page following the reference we check
1661 %    if it is on the page before the reference. In \LaTeX{} this
1662 %    situation is not too common, for example with floats it normally
1663 %    does not occur, but of course it isn't impossible if you more
1664 %    than one reference to the same object, or if you have back
1665 %    references to sections, theorems, etc.  To test this we now
1666 %    subtract two from the current value of |\@tempcnta| (which was
1667 %    set to one higher as the reference page number). Note, that
1668 %    subtraction is also possible if the value was |\maxdimen| --- we
1669 %    still get something that is much larger than any sensible page
1670 %    number.
1671 %    \begin{macrocode}
1672         \else
1673           \advance\@tempcnta-2
1674 %    \end{macrocode}
1675 %    If now |\thevpagerefnum| and |\@tempcnta| have the same value then the
1676 %    object lies one page before the reference.
1677 %    \begin{macrocode}
1678           \ifnum \thevpagerefnum =\@tempcnta
1679 %    \end{macrocode}
1680 %    Again we have to check for odd or even pages to distinguish
1681 %    between the facing and the non-facing situation.
1682 %    \begin{macrocode}
1683             \ifodd\@tempcnta
1684               \reftextbefore
1685             \else
1686 %    \end{macrocode}
1687 %    Again the |\reftextfacebefore| only if |@twoside| evaluates to
1688 %    true.
1689 %    \begin{macrocode}
1690               \if@twoside
1691                 \reftextfacebefore
1692               \else
1693                 \reftextbefore
1694               \fi
1695             \fi
1696 %    \end{macrocode}
1697 %    If the above test also returns false then we have object and
1698 %    references on pages which are far away or don't contain simple
1699 %    page numbers. Therefore we generate the |\reftextfaraway| string.
1700 %    Recall that this is a macro which has the user label as an
1701 %    argument.
1702 %    \begin{macrocode}
1703           \else
1704             \reftextfaraway{#3}%
1705           \fi
1706         \fi
1707        }%
1708 %    \end{macrocode}
1709 %    We do the same if our first test (that the page with the object
1710 %    has a positive page number) turns out to be false.
1711 %    \begin{macrocode}
1712        {\reftextfaraway{#3}}%
1713   \fi
1714 %    \end{macrocode}
1715 %    Finally we generate the internal label so that it can be check on
1716 %    the next run. This means that we compare the position after the
1717 %    string with the position of the referenced object. There is one
1718 %    thing to note: to conserve space we locally make |\@currentlabel|
1719 %    empty since we are only interested in the page number value of
1720 %    this internal label.
1721 % \changes{v1.0l}{1994/07/07}{Explicitly expand \cs{label} argument for babel}
1723 %    These days we actually use |\vref@label| instead of |\label| as
1724 %    this avoids problems with Babel or \texttt{amsmath} redefining
1725 %    the latter command.
1726 % \changes{v1.4e}{2003/01/08}{Use \cs{vref@label} instead of
1727 %    \cs{label}  (pr/3489)}
1728 %    \begin{macrocode}
1729    \vref@label{\the\c@vrcnt @vr}%
1731 %    \end{macrocode}
1732 % \end{macro}
1735 %  \begin{macro}{\vref@label}
1736 % \changes{v1.4e}{2003/01/08}{Macro added (pr/3489)}
1737 %    This macro is like |\label| in the kernel but without passing on
1738 %    |\@currentlabel|, ie useful if all we are interested in is the
1739 %    page number. It also has the effect that it is unaffected by
1740 %    \texttt{amsmath} or Babel redefining the |\label| command.
1741 %    \begin{macrocode}
1742 \def\vref@label#1{\@bsphack
1743   \protected@write\@auxout{}%
1744          {\string\newlabel{#1}{{}{\thepage}}}%
1745   \@esphack}
1746 %    \end{macrocode}
1747 % \end{macro}
1750 %  \begin{macro}{\vpagerefnum}
1751 % \changes{v1.4c}{2002/06/14}{Macro added}
1752 %    This macro allows to define |\reftextafter| and friends to refer
1753 %    to the page number rather than producing a textual reference.
1754 %    \begin{macrocode}
1755 \let\thevpagerefnum\@empty
1756 %    \end{macrocode}
1757 % \end{macro}
1760 %  \begin{macro}{\vrefwarning}
1761 % \changes{v0.1g}{1993/02/14}{Macro added}
1762 %  \begin{macro}{\vrefshowerrors}
1763 % \changes{v1.1h}{1998/08/01}{Macro added}
1764 %  \begin{macro}{\vref@err}
1765 % \changes{v0.1g}{1993/02/14}{Macro added}
1766 %    When the |\vref| command detects a possible crossing over a page
1767 %    boundary it will call |\vref@err| to generate an error message.
1768 %    During document preparation one can turn such errors into
1769 %    warnings by issuing a |\vrefwarning| declaration.
1770 % \changes{v1.0g}{1993/02/14}{Macro added}
1771 %    \begin{macrocode}
1772 \def\vrefwarning{\def\vref@err{\PackageWarning{varioref}}}
1773 %    \end{macrocode}
1774 %    \begin{macrocode}
1775 \def\vrefshowerrors{\def\vref@err##1{\PackageError{varioref}{##1}%
1776     {Please check the pages in question. You might need to replace
1777      the \string\vref\MessageBreak
1778      or \noexpand\vpageref by a normal \noexpand\(page)ref to
1779      stop LaTeX running forever.}}}
1780 %    \end{macrocode}
1781 %  \end{macro}
1782 %  \end{macro}
1783 %  \end{macro}
1786 % \begin{macro}{\vref}
1787 % \changes{v1.3a}{2001/04/12}{Scan for star form}
1788 %    We start by scanning for a star form in which case we do not put
1789 %    any space before the generated text (only remove some).
1790 % \begin{macro}{\vr@f}
1791 %    \begin{macrocode}
1792 \DeclareRobustCommand\vref{\@ifstar
1793    {\let\vref@space\relax\vr@f}%
1794    {\let\vref@space\nobreakspace\vr@f}}
1795 %    \end{macrocode}
1796 %    And now we do the real work\ldots
1797 % \changes{v1.3c}{2001/09/04}{Correct typo in name}
1798 %    \begin{macrocode}
1799 \def\vr@f#1{%
1800 %    \end{macrocode}
1801 %    The use of|\nobreakspace| or |~| after the |\unskip| means that
1802 %    this command will always produce a normal space while
1803 %    something like |\nobreak\space| will
1804 %    react to settings of |\nonfrenchspacing|.
1805 %    Unfortunately the latter will also act in cases where one really
1806 %    wants a normal space, e.g., in |Fig.~\vref{..}|, resulting in
1807 %    a large extra space after the dot. For this reason the first solution
1808 %    is used.
1809 % \changes{v1.1e}{1998/03/09}{Don't use \cs{nobreakspace} (pr/1866)}
1810 % \changes{v1.2a}{1998/11/27}{Use \cs{nobreakspace} (pr/2909)}
1811 % \changes{v1.2a}{1998/11/27}{Add \cs{leavevmode}}
1813 %    Above comments all refer to the earlier versions where there was
1814 %    no possibility to suppress the space at all. By now we have
1815 %    |\vref*| and |\vpageref*| to suppress the in internally generated
1816 %    space by redefining |\vref@space| appropriately.
1817 %    \begin{macrocode}
1818   \leavevmode\unskip\vref@space
1819   \ref{#1}%
1820 %    \end{macrocode}
1821 %    That means we have have to use |\vpageref| and not the internal
1822 %    |\@vpageref| --- otherwise we would pick up the
1823 %    ``current'' definition for  |\vref@space| instead of setting it
1824 %    back to |\space|.
1825 % \changes{v1.4c}{2002/06/18}{Use \cs{vpageref} not \cs{@vpageref} (pr/3403)}
1826 %    \begin{macrocode}
1827   \vpageref[\unskip]{#1}}
1828 %    \end{macrocode}
1829 % \end{macro}
1830 % \end{macro}
1833 %  \begin{macro}{\is@pos@number}
1834 %    The utility macro |\is@pos@number| takes three arguments: a
1835 %    string that is tested for being a valid non-negative integer and the
1836 %    actions to be taken in case the test comes out true or false.
1838 %    We start by passing the string to the macro |\is@pos@num| after
1839 %    prefixing it with a \texttt{0} and adding a space after it. To have
1840 %    a well-defined ending point we also add |\@nil| at the end.
1841 %\label{isposnumber}
1842 %    \begin{macrocode}
1843 \def\is@pos@number#1{\is@pos@num0#1\space\@nil}
1844 %    \end{macrocode}
1845 %    Now we parse the enlarged string into a counter register.  To get
1846 %    control back after everything that is regarded by \TeX{} as a
1847 %    number is put into that register we assign |\is@pos@num@| to the
1848 %    |\afterassignment| token.  Since the string started with 0, we
1849 %    can be sure that the register assignment will be carried out
1850 %    without an error message.  In case of counter assignments leading
1851 %    zeros are discarded.
1852 %    \begin{macrocode}
1853 \def\is@pos@num{\afterassignment\is@pos@num@ \count@}
1854 %    \end{macrocode}
1855 %    Now we have to check whether or not the whole string was parsed
1856 %    into that register or some remainder was left over. Since we have
1857 %    added a |\@nil| token at the very end we can use that to delimit
1858 %    the argument of |\is@pos@num@|. Note, that the added space in
1859 %    |\is@pos@number| \vpageref[above]{isposnumber} gets parsed away
1860 %    by the counter assignment. If it would be missing, and the full
1861 %    string would consist of a number, \TeX{}would try to replace
1862 %    |\@nil| by its definition to see if it would contain additional
1863 %    digits and thus we would be in trouble at this point.
1864 %    \begin{macrocode}
1865 \def\is@pos@num@#1\@nil{%
1866 %    \end{macrocode}
1867 %    Now we have to check if the argument is empty. We can do this
1868 %    with an |\ifx| (i.e., in an expandable way) since we know for
1869 %    sure that it can not start with |\@nil|.
1870 % \changes{v1.4j}{2004/05/08}{Use \cs{@nil} for testing}
1871 %    \begin{macrocode}
1872   \ifx\@nil#1\@nil
1873 %    \end{macrocode}
1874 %    Depending on the result we execute the second or third argument
1875 %    of the command |\is@pos@number| using a technique that removes
1876 %    the |\else| or |\fi| from the input stream first, so that in
1877 %    principle input stream parsing could be done from within the
1878 %    arguments.
1879 %    \begin{macrocode}
1880     \expandafter\@firstoftwo \else
1881     \expandafter\@secondoftwo  \fi}
1882 %    \end{macrocode}
1883 %  \end{macro}
1885 %  \begin{macro}{\reftextvario}
1886 %    This macro gives a little bit of random variation in the text
1887 %    because the outcome depends on the number of |\vref| commands
1888 %    seen before.
1889 %    \begin{macrocode}
1890 \def\reftextvario#1#2{\ifodd\c@vrcnt #1\else#2\fi}
1891 %    \end{macrocode}
1892 %  \end{macro}
1894 %  \begin{macro}{\fullref}
1895 %    And here is the primitive command that always produces a |\ref|
1896 %    and a |\pageref|.
1897 %    \begin{macrocode}
1898 \def\fullref#1{\ref{#1} \reftextfaraway{#1}}
1899 %    \end{macrocode}
1900 %  \end{macro}
1903 % \subsubsection{Supporting ranges}
1905 %  \begin{macro}{\vref@pagenum}
1906 % \changes{v1.2a}{1998/08/01}{Macro added}
1907 %    This command takes a label as |#1| extracts the page number
1908 %    associated with it and saves the result in a csname which is
1909 %    passed as |#1|. If the label isn't associated with a page number
1910 %    it essentially associates it with |??| for both the label number
1911 %    and the page, thus defining the label this way.  This means that
1912 %    no label warning is generated for this label in case it is
1913 %    undefined.
1914 %    \begin{macrocode}
1915 \def\vref@pagenum#1#2{%
1916   \@ifundefined{r@#2}{\@namedef{r@#2}{{??}{??}}}{}%
1917 %    \end{macrocode}
1918 %    Extracting and saving the page number turned out to be a source of subtle
1919 %    bugs. Initially it was done through an |\edef| with a bunch of
1920 %    |\expandafter| commands inside. This posed a problem if the page number
1921 %    itself contained code which needed protection (e.g., pr/4080) so this got
1922 %    changed to use |\protected@edef|. However, that in turn failed with Babel
1923 %    (pr/4093)
1924 %    if the label contained active characters, e.g., a ``:'' in French. So now
1925 %    we use even more |\expandafter| commands to avoid any expansion other
1926 %    than what is absolutely  required---I'm sure there is now a simpler way
1927 %    to code this, but \ldots\ in fact we didn't use enough initially resulting in another
1928 %    bug (pr/4159):
1929 % \changes{v1.4w}{2009/09/13}{Use \cs{protected@edef} to avoid problems
1930 %              in complicated setups, e.g., microtype (pr/4080)}
1931 % \changes{v1.4y}{2010/11/12}{Avoid even \cs{protected@edef} to pacify french
1932 %    babel (pr/4093)}
1933 % \changes{v1.4z}{2011/10/02}{Previous fix need one more expansion
1934 %                            (pr/4159,pr/4171)}
1935 %    \begin{macrocode}
1936   \expandafter\expandafter\expandafter\vref@@pagenum
1937   \csname r@#2\endcsname{}{}\@nil#1%
1939 \def\vref@@pagenum#1#2#3\@nil#4{%
1940   \def#4{#2}%
1942 %    \end{macrocode}
1943 %  \end{macro}
1945 %  \begin{macro}{\vrefpagenum}
1946 % \changes{v1.2a}{1998/08/01}{Macro added}
1947 %    Same as the above but this time we generate a warning for
1948 %    undefined labels.
1949 %    \begin{macrocode}
1950 \def\vrefpagenum#1#2{%
1951   \@ifundefined{r@#2}%
1952     {\G@refundefinedtrue
1953      \@latex@warning{Reference `#2' on page \thepage \space
1954              undefined}}{}%
1955   \vref@pagenum{#1}{#2}}
1956 %    \end{macrocode}
1957 %  \end{macro}
1959 %  \begin{macro}{\vpagerefrange}
1960 %  \begin{macro}{\@vpagerefrange}
1961 %  \begin{macro}{\@svpagerefrange}
1962 % \changes{v1.2a}{1998/08/01}{Macro added}
1963 % \changes{v1.3b}{2001/04/14}{Scan for star form}
1964 % \changes{v1.4s}{2007/08/07}
1965 %         {Prevent loss of brackets}
1966 %    If both labels refer to the same page then we produce a
1967 %    |\vpageref|. Otherwise we produce the result of
1968 %    |\reftextpagerange|.
1970 %    One could think of making this command even more clever by
1971 %    producing a special string if the difference between the two page
1972 %    number is one (but this is not done).
1974 %    We need two versions to implement a star form:
1975 %    \begin{macrocode}
1976 \newcommand\@svpagerefrange[3][\reftextcurrent]{%
1977   \vrefpagenum\@tempa{#2}%
1978   \vrefpagenum\@tempb{#3}%
1979   \ifx\@tempa\@tempb
1980     \vpageref*[{#1}]{#2}%
1981   \else
1982     \reftextpagerange{#2}{#3}%
1983   \fi
1985 %    \end{macrocode}
1986 %    And the same but using |\vpageref|:
1987 %    \begin{macrocode}
1988 \newcommand\@vpagerefrange[3][\reftextcurrent]{%
1989   \vrefpagenum\@tempa{#2}%
1990   \vrefpagenum\@tempb{#3}%
1991   \ifx\@tempa\@tempb
1992     \vpageref[{#1}]{#2}%
1993   \else
1994     \reftextpagerange{#2}{#3}%
1995   \fi
1997 %    \end{macrocode}
1998 %    And here we put things together.
1999 %    \begin{macrocode}
2000 \newcommand\vpagerefrange{\@ifstar\@svpagerefrange\@vpagerefrange}
2001 %    \end{macrocode}
2002 %  \end{macro}
2003 %  \end{macro}
2004 %  \end{macro}
2007 %  \begin{macro}{\vrefrange}
2008 % \changes{v1.2a}{1998/08/01}{Macro added}
2009 % \changes{v1.4s}{2006/08/07}
2010 %         {Prevent loss of brackets}
2011 %    \begin{macrocode}
2012 \newcommand\vrefrange[3][\reftextcurrent]
2013   {\reftextlabelrange{#2}{#3} \vpagerefrange[{#1}]{#2}{#3}}
2014 %    \end{macrocode}
2015 %  \end{macro}
2018 % \subsection{An extension of counter referencing}
2020 %  \begin{macro}{\refstepcounter}
2021 % \changes{v1.4a}{2002/02/24}{Macro redefined}
2023 %   At the moment a reference to a counter |foo| will generate the
2024 %   equivalent of |\p@foo\thefoo| although not quite in this form.  For
2025 %   some applications it would be nice of one could have |\thefoo| being
2026 %   an argument to |\p@foo| to be able to put material before and after
2027 %   the number generated by |\thefoo|. This can be easily achieved with
2028 %   a small change to one of the kernel commands as follows:
2029 %    \begin{macrocode}
2030 \def\refstepcounter#1{\stepcounter{#1}%
2031     \protected@edef\@currentlabel
2032        {\csname p@#1\expandafter\endcsname\csname the#1\endcsname}%
2034 %    \end{macrocode}
2035 %   The trick is to ensure that |\csname the#1\endcsname| is turned into
2036 %   a single token before |\p@...| is expanded further. This way, if the
2037 %   |\p@...| command is a macro with one argument it will receive
2038 %   |\the...|. With the kernel code (i.e., without the |\expandafter|)
2039 %   it will instead pick up |\csname| which would be disastrous.
2041 %   Using |\expandafter| instead of braces delimiting the argument is
2042 %   better because, assuming that the |\p@...| command is not defined as
2043 %   a macro with one argument, the braces will stay and prohibit kerning
2044 %   that might otherwise happen between the glyphs generated by
2045 %   |\the...| and surrounding glyphs.
2046 %  \end{macro}
2048 %  \begin{macro}{\labelformat}
2049 %  \changes{v1.4a}{2002/02/24}{Macro added}
2050 %    A shortcut to set the |\p@...| macro for a counter. It will pick
2051 %    up the counter representation as an argument so that it can be
2052 %    specially formatted.
2053 %    \begin{macrocode}
2054 \def\labelformat#1{\expandafter\def\csname p@#1\endcsname##1}
2055 %    \end{macrocode}
2056 %  \end{macro}
2058 %  \begin{macro}{\Ref}
2059 %  \changes{v1.4a}{2002/02/24}{Macro added}
2060 %    This macro expands the result of |\ref| and then uppercases the
2061 %    first token. Only useful if the label was generated via
2062 %    |\labelformat| and contains some lower case letter at its start. If
2063 %    the label starts with a complicated construct (e.g., an accented
2064 %    letter) one has to surround everything that needs uppercasing in
2065 %    a brace group in the definition of |\labelformat|.\footnote{There
2066 %    is one problem with this approach: the braces are kept in a
2067 %    normal \texttt{\textbackslash ref} which might spoil kerning.
2068 %    Perhaps one day this needs redoing.}
2069 %    \begin{macrocode}
2070 \DeclareRobustCommand\Ref[1]{\protected@edef\@tempa{\ref{#1}}%
2071    \expandafter\MakeUppercase\@tempa}
2072 %    \end{macrocode}
2073 %  \end{macro}
2075 %  \begin{macro}{\Vref}
2076 %  \changes{v1.4a}{2002/02/24}{Macro added}
2077 %  \begin{macro}{\Vr@f}
2078 %  \changes{v1.4a}{2002/02/24}{Macro added}
2079 %  \changes{v1.4x}{2010/08/04}{Correct spacing -- same mistake as in \cs{vref}
2080 %                              (pr/4123)}
2081 %    |\Vref| is the counterpart to |\vref| with |\ref| replaced by
2082 %    |\Ref| in its definition.
2083 %    \begin{macrocode}
2084 \DeclareRobustCommand\Vref{\@ifstar
2085    {\let\vref@space\relax\Vr@f}%
2086    {\let\vref@space\nobreakspace\Vr@f}}
2087 \def\Vr@f#1{%
2088   \leavevmode\unskip\vref@space
2089   \Ref{#1}%
2090   \vpageref[\unskip]{#1}}
2091 %    \end{macrocode}
2092 %  \end{macro}
2093 %  \end{macro}
2095 %    \begin{macrocode}
2096 %</package>
2097 %    \end{macrocode}
2098 % \Finale
2100 \endinput