summaryrefslogtreecommitdiff
path: root/macros/latex-dev/required/tools/varioref.dtx
blob: 579c41186886169d2f4c5c47ec8cfc95200e1ba4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
1892
1893
1894
1895
1896
1897
1898
1899
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
1928
1929
1930
1931
1932
1933
1934
1935
1936
1937
1938
1939
1940
1941
1942
1943
1944
1945
1946
1947
1948
1949
1950
1951
1952
1953
1954
1955
1956
1957
1958
1959
1960
1961
1962
1963
1964
1965
1966
1967
1968
1969
1970
1971
1972
1973
1974
1975
1976
1977
1978
1979
1980
1981
1982
1983
1984
1985
1986
1987
1988
1989
1990
1991
1992
1993
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
2027
2028
2029
2030
2031
2032
2033
2034
2035
2036
2037
2038
2039
2040
2041
2042
2043
2044
2045
2046
2047
2048
2049
2050
2051
2052
2053
2054
2055
2056
2057
2058
2059
2060
2061
2062
2063
2064
2065
2066
2067
2068
2069
2070
2071
2072
2073
2074
2075
2076
2077
2078
2079
2080
2081
2082
2083
2084
2085
2086
2087
2088
2089
2090
2091
2092
2093
2094
2095
2096
2097
2098
2099
2100
2101
2102
2103
2104
2105
2106
2107
2108
2109
2110
2111
2112
2113
2114
2115
2116
2117
2118
2119
2120
2121
2122
2123
2124
2125
2126
2127
2128
2129
2130
2131
2132
2133
2134
2135
2136
2137
2138
2139
2140
2141
2142
2143
2144
2145
2146
2147
2148
2149
2150
2151
2152
2153
2154
2155
2156
2157
2158
2159
2160
2161
2162
2163
2164
2165
2166
2167
2168
2169
2170
2171
2172
2173
2174
2175
2176
2177
2178
2179
2180
2181
2182
2183
2184
2185
2186
2187
2188
2189
2190
2191
2192
2193
2194
2195
2196
2197
2198
2199
2200
2201
2202
2203
2204
2205
2206
2207
2208
2209
2210
2211
2212
2213
2214
2215
2216
2217
2218
2219
2220
2221
2222
2223
2224
2225
2226
2227
2228
2229
2230
2231
2232
2233
2234
2235
2236
2237
2238
2239
2240
2241
2242
2243
2244
2245
2246
2247
2248
2249
2250
2251
2252
2253
2254
2255
2256
2257
2258
2259
2260
2261
2262
2263
2264
2265
2266
2267
2268
2269
2270
2271
2272
2273
2274
2275
2276
2277
2278
2279
2280
2281
2282
2283
2284
2285
2286
2287
2288
2289
2290
2291
2292
2293
2294
2295
2296
2297
2298
2299
2300
2301
2302
2303
2304
2305
2306
2307
2308
2309
2310
2311
2312
2313
2314
2315
2316
2317
2318
2319
2320
2321
2322
2323
2324
2325
2326
2327
2328
2329
2330
2331
2332
2333
2334
2335
2336
2337
2338
2339
2340
2341
2342
2343
2344
2345
2346
2347
2348
2349
2350
2351
2352
2353
2354
2355
2356
2357
2358
2359
2360
2361
2362
2363
2364
2365
2366
2367
2368
2369
2370
2371
2372
2373
2374
2375
2376
2377
2378
2379
2380
2381
2382
2383
2384
2385
2386
2387
2388
2389
2390
2391
2392
2393
2394
2395
2396
2397
2398
2399
2400
2401
2402
2403
2404
2405
2406
2407
2408
2409
2410
2411
2412
2413
2414
2415
2416
2417
2418
2419
2420
2421
2422
2423
2424
2425
2426
2427
2428
2429
2430
2431
2432
2433
2434
2435
2436
2437
2438
2439
2440
2441
2442
2443
2444
2445
2446
2447
2448
2449
2450
2451
2452
2453
2454
2455
2456
2457
2458
2459
2460
2461
2462
2463
2464
2465
2466
2467
2468
2469
2470
2471
2472
2473
2474
2475
2476
2477
2478
2479
2480
2481
2482
2483
2484
2485
2486
2487
2488
2489
2490
2491
2492
2493
2494
2495
2496
2497
2498
2499
2500
2501
2502
2503
2504
2505
2506
2507
2508
2509
2510
2511
2512
2513
2514
2515
2516
2517
2518
2519
2520
2521
2522
2523
2524
2525
2526
2527
2528
2529
2530
2531
2532
2533
2534
2535
2536
2537
2538
2539
2540
2541
2542
2543
2544
2545
2546
2547
2548
2549
2550
2551
2552
2553
2554
2555
2556
2557
2558
2559
2560
2561
2562
2563
2564
2565
2566
2567
2568
2569
2570
2571
2572
2573
2574
2575
2576
2577
2578
2579
2580
2581
2582
2583
2584
2585
2586
2587
2588
2589
2590
2591
2592
2593
2594
2595
2596
2597
2598
2599
2600
2601
2602
2603
2604
2605
2606
2607
2608
2609
2610
2611
2612
2613
2614
2615
2616
2617
2618
2619
2620
2621
2622
2623
2624
2625
2626
2627
2628
2629
2630
2631
2632
2633
2634
2635
2636
2637
2638
2639
2640
2641
2642
2643
2644
2645
2646
2647
2648
2649
2650
2651
2652
2653
2654
2655
2656
2657
2658
2659
2660
2661
2662
2663
2664
2665
2666
2667
2668
2669
2670
2671
2672
2673
2674
2675
2676
2677
2678
2679
2680
2681
2682
2683
2684
2685
2686
2687
2688
2689
2690
2691
2692
2693
2694
2695
2696
2697
2698
2699
2700
2701
2702
2703
2704
2705
2706
2707
2708
2709
2710
2711
2712
2713
% \iffalse meta-comment
%
% Copyright (C) 1993-2022
%
% The LaTeX Project and any individual authors listed elsewhere
% in this file.
%
% This file is part of the Standard LaTeX `Tools Bundle'.
% -------------------------------------------------------
%
% It may be distributed and/or modified under the
% conditions of the LaTeX Project Public License, either version 1.3c
% of this license or (at your option) any later version.
% The latest version of this license is in
%    https://www.latex-project.org/lppl.txt
% and version 1.3c or later is part of all distributions of LaTeX
% version 2008 or later.
%
% The list of all files belonging to the LaTeX `Tools Bundle' is
% given in the file `manifest.txt'.
%
% \fi
% \iffalse
%% Package varioref to use with LaTeX2e
%% Copyright (C) 1992-2020  Frank Mittelbach, all rights reserved.
%%
%% For additions or updates to the language options please contact
%% the author at
%%
%%   frank.mittelbach@latex-project.org
%%
%% or open an issue at https://github.com/latex3/latex2e.
%%
%
%<package>\NeedsTeXFormat{LaTeX2e}[1995/05/16]
%<package>\providecommand\DeclareRelease[3]{}
%<package>\providecommand\DeclareCurrentRelease[2]{}
%<package>
%<package>\DeclareRelease{}{2016-02-16}{varioref-2016-02-16.sty}
%<package>\DeclareCurrentRelease{}{2019-10-01}
%<package>
%<package>\ProvidesPackage{varioref}
%<package>    [2022/01/09 v1.6f package for extended references (FMi)]
% \fi
%
%%
%
%
% \changes{v1.0a}{1993/12/06}{Upgrade to LaTeX2e}
% \changes{v1.0g}{1994/05/27}{Use \cmd\DeclareRobustCommand}
% \changes{v1.5c}{2016/02/09}{Revamped some of the documentation to better
%	explain how varioref could be used in a multi-lingual context}
% \changes{v1.6a}{2019/08/25}{\cs{labelformat} and \cs{Ref} now available in the kernel
%       so removed from this package but only in new kernel}
%
%
% \newcommand\NewIn[1]{\marginpar{\fbox{\fbox{\sffamily\tabular{l}New
%    in\\#1\endtabular}}}}
% \newcommand\ChangedIn[1]{\marginpar{\fbox{\fbox{\sffamily\tabular{l}Changed
%    in\\#1\endtabular}}}}
%
% \providecommand\pkg[1]{\texttt{#1}}
% \providecommand\option[1]{\texttt{#1}}
% \providecommand\meta[1]{$\langle§\textit{#1}$\rangle$}
%
%
% \makeatletter
% \def\allowtofu{^^A
%\def\UTFviii@undefined@err##1{^^A
%  \PackageWarning{inputenc}{Unicode character \expandafter
%                          \UTFviii@splitcsname\string##1\relax
%                          \MessageBreak
%                          not set up for use with LaTeX -- ignored}^^A
%  \raisebox{.8pt}{\fboxsep1pt\kern.1pt\fbox{$\cdot$}\kern.1pt}^^A
%   }}
% \makeatother
%
% \title{The \pkg{varioref} package\thanks{This file
%        has version number \fileversion, last
%        revised \filedate.}}
% \author{Frank Mittelbach}
% \date{\filedate}
%
% \MaintainedByLaTeXTeam{tools}
% \maketitle
%
%
% \begin{abstract}
%   This package defines the commands |\vref|, |\vpageref|,
%   |\vrefrange|, and |\vpagerefrange| for
%   \LaTeXe. |\vref| is similar to |\ref| but adds an additional
%   page reference, like `on the facing page' or `on page 27' whenever
%   the corresponding |\label| is not on the same page. The command
%   |\vpageref| is a variation to |\pageref| with a similar
%   functionality.  The |\v...range| commands take two labels as arguments
%   and produce strings which depend on whether or not these labels
%    fall onto a single page or on different pages.
%   Generated strings are customizable so that these
%   commands are usable with various languages.
% \end{abstract}
%
%
% \columnsep=2\columnsep
% \begin{multicols}{2}
%   \tableofcontents
% \end{multicols}
%
% \section{Introduction}
%
% In many cases it is helpful when referring to a figure or table to
% put both a |\ref| and a |\pageref| command into the document
% especially when there are one or more pages between the reference
% and the object.  Therefore some people use a command like
% \begin{verbatim}
%  \newcommand{\fullref}[1]{\ref{#1} on page~\pageref{#1}}
%\end{verbatim}
% which reduces the number of key strokes, necessary to make such a
% complete reference.  But since one never knows where the referenced
% object finally falls, using such a device may result in a page
% reference to the current page which is disturbing and therefore
% should be avoided.
%
%
%
% \section{Loading the package}
%
%
% The suggested way of loading the package these days is by
% \emph{always} using
% the package option \option{nospace},
% \NewIn{2019}
% i.e.,
% \begin{verbatim}
%  \usepackage[nospace]{varioref}
%\end{verbatim}
% See below for an explanation of why this is needed. There are some
% other options that you may want to use additionally; they are
% explained \vpageref{options}.
%
%
%
% \section{The user interface}
%
%\DescribeMacro\vref The implementation of |\vref| below produces only
% a |\ref| when reference and |\label| are on the same page. It will
% additionally produce one of the strings `on the facing page', `on
% the preceding page', or `on the following page', if label and
% reference differ by one and it will produce both |\ref| and
% |\pageref| when the difference is larger.  The word `facing' is used
% when label and reference both fall onto a double spread.  However,
% if a special page numbering scheme is used instead of the usual
% Arabic numbering (e.g., |\pagenumbering{roman}|) then there will be
% no distinction between one or many pages off.
%
%\DescribeMacro\vpageref Sometimes one wants to refer only to page
% number and again such a reference should normally be suppressed if
% we are referring to the current page. For this purpose the package
% defines the |\vpageref| command. It will produce the same strings as
% |\vref| except that it doesn't start with the |\ref|. A further
%    difference is that
% it will produce the string that is saved in |\reftextcurrent| if
% label and reference fall onto the same page (and no optional
%    argument is used). By defining
% |\reftextcurrent| to produce ``on this page'' or something similar,
% we can avoid that
% \begin{verbatim}
%   ... see the example \vpageref{ex:foo} which shows ...
%\end{verbatim}
% comes out as ``\ldots~see the example which shows~\ldots'', which
% could be misleading.
%
% A space in front of |\vpageref| it will be ignored if
% the command doesn't produce any text at all.
%
% But in fact |\vpageref| allows even more control. It has two
% optional arguments. With the first one, one can specify the text
% that should be used if label and reference fall on the same page.
% This is very helpful if both are near to each other, so that they
% may or may not be separated by a page break. In such a case we
% usually know (!) whether the reference is before or after the label
% so that we can say something like
% \begin{verbatim}
%   ... see the example \vpageref[above]{ex:foo} which shows ...
%\end{verbatim}
% which will then come out as ``\ldots~see the example above which
% shows~\ldots'' if we are still on the same page, but as ``\ldots~see
% the example on the page before which shows~\ldots'' (or something
% similar depending on the settings of the |\reftext..before|
% commands) when there was a page break in the meantime. One warning
% however, if you use |\vpageref| with the optional argument to refer
% to a figure or table, keep in mind that depending on the float
% placement parameters the float may show up on top of the current
% page and therefore before the reference even if it came after it in
% the source file.
%
% But maybe you prefer to say ``\ldots~see the above example'' if
% example and reference fall onto the same page, i.e., reverse the
% word order.  In fact, in some languages the word order automatically
% changes in that case.  To allow for this variation the second
% optional argument can be used. It specifies the text preceding the
% generated reference if object and reference do not fall onto the
% same page. Thus one would write
% \begin{verbatim}
%   ... see the \vpageref[above example][example]{ex:foo}
%       which shows ...
%\end{verbatim}
% to achieve the desired effect.
%
%
% \DescribeMacro\vrefrange
% This command is similar to |\vref| but it
% takes two mandatory arguments denoting a range to refer to (e.g., a
% sequences of figures or a sequence of equations, etc.). So if
% |fig:a| is your first figure in the sequence and |fig:c| your last
% you can write
%\begin{verbatim}
%   ... see figures \vrefrange{fig:a}{fig:c} ...
%\end{verbatim}
% which would then be formatted as
% \begin{quote}
% \ldots\ see figures 3.4 to 3.6 on pages 23--24 \ldots
% \end{quote}
% or, if they happen to all fall onto the next page, as
% \begin{quote}
% \ldots\ see figures 3.4 to 3.6 on the following page \ldots
% \end{quote}
% i.e., the command is deciding what to say depending on where the two
% labels are placed in relation to each other; it is essentially
% implemented using |\vpagerefrange| described below.
% The optional argument the command may take is the text to use in case
% both labels are placed on the current page.
%
%
% \DescribeMacro\vpagerefrange This command is similar to |\vpageref|
% but takes two mandatory arguments which are two labels denoting a
% range. If both labels fall onto the same page, the command acts
% exactly like |\vpageref| (with a single label), otherwise it produces
% something like ``on pages~15--18'' (see customization possibilities
% below). The optional argument it may take is the text to use in case
% both labels are placed on the current page.

% \DescribeMacro\vrefpagenum This macro is provided to allow the user
% to write their own small commands which implement functions similar
% to those provided by the two previous commands. It takes two
% arguments: the second is a label (i.e., as used in |\label| or
% |\ref|) and the first is an arbitrary command name (make sure you
% use our own) that receives the page number related to this label.
% So if you have two (or more) labels you could retrieve their page
% numbers, compare them and then decide what to print.  For example,
% the following not very serious definition (also using the
% \pkg{ifthen} package)
%\begin{verbatim}
% \newcommand\amusingversion[2]{the definition%
%   \vrefpagenum\firstnum{#1}%
%   \vrefpagenum\secondnum{#2}%
%   \ifthenelse{\equal\firstnum\secondnum}%
%     {s of \ref{#1} and \ref{#2} \vpageref{#1}}%
%     { of \ref{#1} \vpageref{#1} and of \ref{#2} \vpageref{#2}}%
% }
%
% ...\amusingversion{foo}{bar}
%\end{verbatim}
% will print something like
% \begin{quote}
%  \ldots the definitions of 3 and 4 on the previous page
% \end{quote}
% in the case both labels are on the same page but something like
% \begin{quote}
%  \ldots the definition of 3 on the next page and of 4 on page~13
% \end{quote}
% in case they are on different pages.
%
% \DescribeMacro\vpagerefcompare
% \NewIn{2019}
% For this kind of application the package also provides
% |\vpagerefcompare| as a command that takes four argument: two labels for
% comparison and a \meta{true} and \meta{false} argument. One of them
% is executed depending on whether the two labels are on the same page
% or on different pages. With its help the above definition could be
% shortened to
%\begin{verbatim}
% \newcommand\amusingversion[2]{the definition%
%   \vpagerefcompare{#1}{#2}%
%     {s of \ref{#1} and \ref{#2} \vpageref{#1}}%
%     { of \ref{#1} \vpageref{#1} and of \ref{#2} \vpageref{#2}}%
% }
%\end{verbatim}
% and you don't have to load the \pkg{ifthen} package any longer to
% make it work.
%
% \DescribeMacro\vpagerefnearby
% \NewIn{2019}
% Another command for conditional processing is |\vpagerefnearby|. It
% takes three arguments: a label and a \meta{true} and \meta{false}
% argument. It compares the page reference to the label with the
% current page number and if both are Arabic number and only differ by
% $\pm1$ the \meta{true} argument is executed otherwise the
% \meta{false} argument. In other words it tells you if a |\vpageref|
% to the label would result in a textual reference to the previous,
% current or next page.\footnote{There is also a
% \cs{vpagerefcomparenearby} but this is only meant for package
% writers, so it is only documented in the implementation section.}

%
%
% If you don't use the \texttt{nospace} option the user commands
% |\vref|, |\vpageref|, and |\vpagerefrange| all work by first
% removing any space on their left and then inserting some space of
% their own (|\vref|, for example, a nonbreakable space). That seemed
% like a good idea back then, but it has the disadvantage that you
% can't use these macros in situations where you definitely do not
% want any space before the generated text. E.g., in situations like
% |(\vref{foo} ...)| you end up with a space after the open
% parenthesis.
%
% \DescribeMacro{\vref*}
% \DescribeMacro{\vpageref*}
% \DescribeMacro{\vpagerefrange*}
% Since it was too late to change the default in 2001 I  added star
% versions of the macros which do not add any space before the
% generated text (they do nevertheless remove space at the left).
%
% However, that too has problems (one is that \pkg{hyperref}
% \ChangedIn{2019}
% introduced the star forms as a means to generating references
% without hyperlinks (which is clearly the more important
% application).
% So these days I recommend to always call the package with the option
% \option{nospace} which prevents \pkg{varioref} from messing with the
% space in front. Of course you are then responsible to always add it
% when necessary, but that does make the source more readable so it is
% a good thing. This also has the advantage that the star forms are
% now unnecessary again and can be used in the way implemented by
% \pkg{hyperref} if both packages are used together.
%
% In fact it would be much nicer to make that the
% default but the package has been used by many people for so many
% years that changing the default would break way too many older documents.
%
%
% \DescribeMacro\labelformat
% A reference via |\ref| produces by default the data associated with
% the corresponding |\label| command (typically a number); any
% additional formatting has to be provided by the user. With
% |\labelformat| it is possible to declare such formatting for each
% ``reference'' counter, e.g.,
%\begin{verbatim}
%  \labelformat{section}{section~#1}
%  \labelformat{equation}{equation~(#1)}}
%\end{verbatim}
%
%
% \DescribeMacro\Vref
% \DescribeMacro\Ref
% A side effect of using |\labelformat| is that, depending on the
% defined formatting, it becomes impossible to use |\ref| at the
% beginning of a sentence (if its replacement text starts with a
% lowercase letter).
% \ChangedIn{2019}
% For that reason \pkg{varioref} provided the commands |\Ref| and
% |\Vref|.  They behave like |\ref| and |\vref| except that they
% uppercase the first token of the generated string. These days
% |\labelformat| and |\Ref| are already provided by the \LaTeX{}
% kernel; only |\Vref| is still defined within the \pkg{varioref}
% package.
%
% To make |\Ref| or |\Vref| work properly the very first token in the
% second argument of |\labelformat| has to be a simple \textsc{ascii}
% or UTF-8 letter, otherwise the capitalization will fail or worse,
% you will end up with some error messages. If you actually need
% something more complicated in this place (e.g., an accented letter
% not written as a UTF-8 character) you have to explicitly surround it
% with braces, to identify the part that needs to be capitalized. For
% example, for figure references in the Hungarian language you might
% want to write |\labelformat{figure}{{\'a}bra~\thefigure}| or use
% |\labelformat{figure}{ábra~\thefigure}| which avoids the brace
% problem.
%
% \DescribeMacro\thevpagerefnum
% If you like to have |\vref| suppress the page number on pages where
% label and reference fall onto the same page, but prefer reference to
% page numbers otherwise then |\thevpagerefnum| can be used. This macro
% hold the current page ``number'' when |\vpageref| and friends are
% executed. Thus, by defining, for example
%\begin{verbatim}
%\renewcommand\reftextfaceafter {on page~\thevpagerefnum}
%\renewcommand\reftextfacebefore{on page~\thevpagerefnum}
%\renewcommand\reftextafter     {on page~\thevpagerefnum}
%\renewcommand\reftextbefore    {on page~\thevpagerefnum}
%\end{verbatim}
% textual references can be suppressed.
%
%
%
% \section{Multi-lingual usage}
%
% The package works well together with the babel system if it is
% loaded \textit{after} the babel package, e.g., a document in English
% (default), French and German text could load the packages as
% follows:
%\begin{verbatim}
%   \usepackage[ngerman,french,english]{babel,varioref}
%\end{verbatim}
% (or in two separate lines if you prefer one |\usepackage| line per
% package). Depending on the current babel language |\vref| and
% friends would then generate strings in different languages. If the
% language options are given as global options to the document class
% then it is enough to use
%\begin{verbatim}
%   \usepackage{babel,varioref}
%\end{verbatim}
% to achieve the same effect.
%
% If more than one language is specified with \pkg{varioref} then
% it will start using the last language selected. Switching of
% languages is managed through Babel; nevertheless all languages of
% interest need to be specified when \pkg{varioref} is loaded so
% that it can integrate their strings into the Babel system.
%
%
% \section{Customization}
%
% The package supports all options defined by the babel package to
% translate the fixed strings into other languages than English.
% (Some languages need updating, however---help is appreciated.)  It
% also supports languages currently not in babel (those can only be
% used standalone, obviously); check the section on options later~on.
%
%
% \pagebreak[3]
%
% You can also modify some or all of the strings by redefining the
% following commands after the package has been loaded.
%\DescribeMacro\reftextbefore
%\DescribeMacro\reftextfacebefore
%\DescribeMacro\reftextafter
%\DescribeMacro\reftextfaceafter Backward references use
% |\reftextbefore| if the label is on the preceding page but invisible
% and |\reftextfacebefore| if it is one the facing page (i.e., if the
% current page number is odd).  Similarly |\reftextafter| is used
% when the label comes on the next page but one has to turn the page
% and |\reftextfaceafter| if it is on the following but facing page.
%
% In fact, |\reftextface...| is used only if the user or the document
% class specified two-sided printing.
%
%\DescribeMacro\reftextfaraway Finally we have |\reftextfaraway| which
% is used whenever label and reference differ by more than one or when
% they aren't numeric. This macro is a bit different because it takes
% one argument, the symbolic reference string so that one cane make
% use of |\pageref| in its replacement text.
%
%
%\DescribeMacro\reftextvario To allow a bit random variation in the
% generated strings one can use the command |\reftextvario| inside the
% string macros. It takes two arguments and selects one or the other
% for printing depending on the number of already seen |\vref| or
% |\vpageref| commands.  As an example see the definitions of
% |\reftextbefore| etc.\ \vpageref[below]{reftextbefore}.
%
% The commands |\vrefrange| and |\vpagerefrange| produce their text
% \NewIn{1998}
% using two macros described below. By redefining them one can modify
% the results to accommodate special requirements.
%
%
% They both take two mandatory arguments denoting the first and the
% last label of the range.
%
%
% \DescribeMacro\reftextpagerange This macro produces text that
% describes the page range of the two labels, e.g., the default
% for English is ``|on pages~\pageref{#1}--\pageref{#2}}|''.
%
%
% \DescribeMacro\reftextlabelrange This macro produces text that
% describes the range of figures, tables, or whatever the labels refer
% to, the default for English is ``|\ref{#1} to~\ref{#2}|''.
%
% 
% \NewIn{2020}
% \DescribeMacro\vrefformat
% \DescribeMacro\Vrefformat
% \DescribeMacro\vrefrangeformat
% \DescribeMacro\fullrefformat
% In some languages (currently only for Japanese) the generated text
% has to typeset in different word order to most other (Western) languages.
% To accommodate for this \cs{vrefformat}, etc.\ has been
% added to allow to alter this on a per language basis.
% There should be normally no need to alter the setup. For details see
% the code section.
%
% \subsection{\ldots\ if Babel is used}
%
% \begin{itshape} If babel is being used then the above commands need to be
% changed using the Babel mechanism, e.g.,
%\begin{verbatim}
%  \addto\extrasngerman{%
%     \renewcommand\reftextfaceafter {auf der n\"achsten Seite}%
%      ... }
%\end{verbatim}
% Otherwise babel will reintroduce its own defaults whenever the language is
% changed (which happens in particular during |\begin{document}| where the
%    main language is selected).
% \end{itshape}
%
%
%
%
% \section{Options} \label{options}
%
% As mentioned above the package supports all standard options offered
% by the Babel system to customize the strings produced, it may also
% have a few not supported by babel, for a full list look
% in section~\vref{sec:impoptions}. In addition it offers the option
% \texttt{draft} to turn error messages into warnings during
% development. The default \texttt{final} produces error message when
% a generated string falls onto a page boundary (see next section).
%
% Newly introduced in 2019 are the options \option{space} (default)
% and \option{nospace}. While the former is the default to allow
% \NewIn{2019}
% documents written in the last twenty years to continue to work
% correctly, I nowadays, suggest that you always use the package with
% the option \option{nospace}. This will stop \pkg{varioref} from
% meddling with the spaces preceding commands and thus make the star
% forms |\vref*| and |\vpageref*| unnecessary.
%
% This means that the star forms can then be used as defined by
% \pkg{hyperref} for suppressing a hyperlink when both packages are
% used together (which is a rather typical scenario these days).
%
%
% \section{A few warnings}
%
% Defining commands like the ones described above poses some
% interesting problems. Suppose, for example, that a generated text
% like `on the next page' gets broken across pages. If this happens it
% is very difficult to find an acceptable solution and in fact can
% even result in a document that will always change from one state to
% another (i.e., inserting one string, finding that this is wrong,
% inserting another string on the next run which makes the first
% string correct again, inserting \ldots).  The current implementation
% of \pkg{varioref} therefore issues an error message whenever the
% generated text is broken across page boundaries, e.g.,
% \begin{quote}
%   table 5 on the current \meta{page break} page
% \end{quote}
% would result in an error, which needs to be resolved by the
% user by replacing the |\vref| command with an ordinary |\ref| just
% before the final run.  This is not
% completely satisfactory but in such case no solution really is.
% \DescribeMacro\vrefwarning
% During document preparation, while one is still changing the text,
% such error messages can be turned into warnings by placing a
% |\vrefwarning| command in the preamble. This is equivalent to
% specifying ``draft'' as an option to the package.
% \DescribeMacro\vrefshowerrors
% |\vrefshowerrors| ensures that varioref stops when detecting a
% possible loop. This is the default and equivalent to specifying
% ``final'' as an option.
%
% At the end final a warning: every use of |\vref| will internally
% generate two macro names to keep track of the string positions
% within the document. As a result you may run out of name space or
% main memory\footnote{Not really that likely these days, but one
% never knows \ldots.  In any case \TeX{} will process your document a
% tiny bit faster.} if you make heavy use of this macro on a small
% \TeX{} installation.
%\DescribeMacro\fullref For this reason the primitive command
% |\fullref| is also provided. This command can be used whenever you
% know for sure that label and reference can't fall onto nearby pages.
%
%
% \MaybeStop{\PrintIndex\PrintChanges}
%
%
% \section{The documentation driver file}
%
% The next bit of code contains the documentation driver file for
% \TeX{}, i.e., the file that will produce the documentation you are
% currently reading. It will be extracted from this file by the
% \pkg{docstrip} program.
%    \begin{macrocode}
%<*driver>
\documentclass{ltxdoc}
\usepackage{multicol,varioref}
\GetFileInfo{varioref.sty}
\setlength\hfuzz{1pt}    % ignore slight overfulls
\EnableCrossrefs
%\DisableCrossrefs   % Say \DisableCrossrefs if index is ready

\RecordChanges       % Gather update information
%\OnlyDescription    % comment out for implementation details
\begin{document}
   \DocInput{varioref.dtx}
\end{document}
%</driver>
%    \end{macrocode}
%
%
% \section{The implementation}
%
% The main implementation idea is to generate an internal label
% command for every |\vpageref| and compare the page reference of this
% label with the page reference of the user-requested label.  Since
% this means one additional macro name for each use of |\vpageref| or
% |vref| (which is implemented in terms of |\vpageref|) the memory
% requirements of this package may be high in terms of main and macro
% name memory.  Since the information held in the internal labels is
% used only once one could envision a different scheme if suitable
% primitives for this kind of ``one place information'' would be
% provided by \LaTeX.  This type of data structure is planned for
% \LaTeX3 but for the moment we have to live with the memory
% restrictions.
%
% We start by checking if this file was already loaded. If not we
% identify the current version. This is actually done at the top
% of the file, so we comment it out here
% \changes{v0.1h}{1993/08/15}{Small documentation changes}
%    \begin{macrocode}
%<*package>
%\NeedsTeXFormat{LaTeX2e}[1994/06/01]
%\ProvidesPackage{varioref}[\filedate\space\fileversion\space
%                     LaTeX2e package for extended references (FMi)]
%    \end{macrocode}
%
%
%  \begin{macro}{\vref@addto}
% \changes{v1.0b}{1994/01/31}{Avoid using babel `addto}
% \changes{v1.0b}{1994/01/31}{The babel commands are starting
%                             with extras}
%    To support the use of babel we want to add the additional strings
%    to the |\extras|\meta{language} commands. Since |\addto| in the
%    current implementation of babel has a bug that does not allow to
%    use arguments containing hashmarks we do this by hand.
%    \begin{macrocode}
\def\vref@addto#1#2{%
  #2%
  \@temptokena{#2}%
  \ifx#1\undefined
     \edef#1{\the\@temptokena}%
  \else
     \toks@\expandafter{#1}%
     \edef#1{\the\toks@\the\@temptokena}%
  \fi
  \@temptokena{}\toks@\@temptokena
}
\@onlypreamble\vref@addto
%    \end{macrocode}
%  \end{macro}
%
%
% \subsection{Options}\label{sec:impoptions}
%
%  \begin{macro}{\vref@excuse}
%    Excuse that we don't know the strings for a certain language.
% \changes{v1.0q}{1995/04/06}{Use `PackageWarning}
%    \begin{macrocode}
\def\vref@excuse#1{%
  \PackageWarningNoLine{varioref}{Sorry, language `#1'
            not supported%
            \MessageBreak
            in this version.
            English strings used by default.
            \MessageBreak
            Please modify \protect\reftext... commands manually.%
            \MessageBreak\MessageBreak
            If you can suggest translations for
            this language,%
            \MessageBreak
            please mail them
            to the author of this package}}
\@onlypreamble\vref@excuse
%    \end{macrocode}
%  \end{macro}
%
%  \begin{macro}{\vref@stringwarning}
%    And we sometimes just don't know some strings~\ldots
% \changes{v1.2a}{1998/08/01}{Macro added}
%    \begin{macrocode}
\def\vref@stringwarning#1{%
  \PackageWarningNoLine{varioref}{Sorry, there is no proper
            translation for the string\MessageBreak
            produced by \protect#1\on@line.\MessageBreak
            English string used instead.\MessageBreak
            \MessageBreak
            If you can suggest translations for
            the current\MessageBreak
            language, please mail them
            to the author of this\MessageBreak package}}
%    \end{macrocode}
%  \end{macro}
%
%
%  \begin{macro}{\reftextfaceafter}
%  \begin{macro}{\reftextfacebefore}
%  \begin{macro}{\reftextafter}
%  \begin{macro}{\reftextbefore}
%  \begin{macro}{\reftextcurrent}
% \label{reftextbefore} The options do set the macros that
%    generate the textual strings. Note, that they do not start with a
%    space, the space is already added in the main macro below.
% \changes{v1.2a}{1998/08/22}{Added American defaults for
%      \cs{reftextpagerange} and \cs{reftextlabelrange}}
% \changes{v1.4d}{2002/11/11}{Changed default for \cs{reftextbefore}}
%
%    Afrikaans option contributed by Danie Els
%    (\texttt{dnjels@sun.ac.za}).
% \changes{v1.4g}{2003/03/29}{Added afrikaans option}
%    \begin{macrocode}
\DeclareOption{afrikaans}
  {\vref@addto\extrasafrikaans{%
    \def\reftextfaceafter {op die \reftextvario{regterbladsy}%
                                               {bladsy langsaan}}%
    \def\reftextfacebefore{op die \reftextvario{linkerbladsy}%
                                                {bladsy langsaan}}%
    \def\reftextafter     {op die \reftextvario{volgende bladsy}%
                                               {bladsy hierna}}%
    \def\reftextbefore    {op die \reftextvario{vorige bladsy}%
                                               {bladsy hiervoor}}%
    \def\reftextcurrent   {op \reftextvario{hierdie}%
                                           {die huidige} bladsy}%
    \def\reftextfaraway#1{op bladsy~\pageref{#1}}%
    \def\reftextpagerange#1#2{op bladsye~\pageref{#1}--\pageref{#2}}%
    \def\reftextlabelrange#1#2{\ref{#1} tot~\ref{#2}}%
    \let\vrefformat\vrefdefaultformat
    \let\Vrefformat\Vrefdefaultformat
    \let\fullrefformat\fullrefdefaultformat
    \let\vrefrangeformat\vrefrangedefaultformat
  }}
%    \end{macrocode}
%
%    \begin{macrocode}
\DeclareOption{american}
  {\vref@addto\extrasamerican{%
    \def\reftextfaceafter {on the \reftextvario{facing}{next} page}%
    \def\reftextfacebefore{on the \reftextvario{facing}{preceding}
                           page}%
    \def\reftextafter     {on the \reftextvario{following}{next} page}%
    \def\reftextbefore    {on the \reftextvario{preceding}{previous} page}%
    \def\reftextcurrent   {on \reftextvario{this}{the current} page}%
    \def\reftextfaraway#1{on page~\pageref{#1}}%
    \def\reftextpagerange#1#2{on pages~\pageref{#1}--\pageref{#2}}%
    \def\reftextlabelrange#1#2{\ref{#1} to~\ref{#2}}%
    \let\vrefformat\vrefdefaultformat
    \let\Vrefformat\Vrefdefaultformat
    \let\fullrefformat\fullrefdefaultformat
    \let\vrefrangeformat\vrefrangedefaultformat
  }}
%    \end{macrocode}
%    Arabic option text was contributed by Ihab Samir Mattar
%    (\texttt{dr\_kremlin@hotmail.com}). As our standard documentation
%    workflow uses pdf\TeX{} the Arabic letters can't be displayed
%    easily, so you will see missing glyphs below. To see the real
%    letters you have to look at the source or package file.
% \changes{v1.6b}{2019/09/08}{Option arabic added}
% \begin{allowtofu}
%    \begin{macrocode}
\DeclareOption{arabic}
  {\vref@addto\extrasarabic{%
    \def\reftextfaceafter {بالصفحة \reftextvario{المقابلة}{اللاحقة}}%
    \def\reftextfacebefore{بالصفحة \reftextvario{المقابلة}{المُنْصَرِمَةٌ}}%
    \def\reftextafter     {بالصفحة \reftextvario{اللاحقة}{التالية}}%
    \def\reftextbefore    {بالصفحة \reftextvario{السابقة}{المُنْصَرِمَةٌ}}%
    \def\reftextcurrent   {ب\reftextvario{الصفحة الحالية}{هذه الصفحة}}%
    \def\reftextfaraway#1{بالصفحة رقم~\pageref{#1}}%
    \def\reftextpagerange#1#2{بالصفحات~\pageref{#1}--\pageref{#2}}%
    \def\reftextlabelrange#1#2{\ref{#1} حتى~\ref{#2}}%
    \let\vrefformat\vrefdefaultformat
    \let\Vrefformat\Vrefdefaultformat
    \let\fullrefformat\fullrefdefaultformat
    \let\vrefrangeformat\vrefrangedefaultformat
  }}
%    \end{macrocode}
% \end{allowtofu}
% \changes{v1.2a}{1998/11/27}{Added austrian defaults (identical to german)}
%    The austrian defaults are the same as the german ones.
%    \begin{macrocode}
\DeclareOption{austrian}
  {\vref@addto\extrasaustrian{%
    \def\reftextfaceafter {auf der n\"achsten Seite}%
    \def\reftextfacebefore{auf der vorherigen Seite}%
    \let\reftextafter     \reftextfaceafter
    \let\reftextbefore    \reftextfacebefore
    \def\reftextcurrent   {auf dieser Seite}%
    \def\reftextfaraway#1{auf Seite~\pageref{#1}}%
    \def\reftextpagerange#1#2{auf Seiten~\pageref{#1}--\pageref{#2}}%
    \def\reftextlabelrange#1#2{\ref{#1} bis~\ref{#2}}%
    \let\vrefrangeformat\vrefrangedefaultformat
  }}
%    \end{macrocode}
% \changes{v1.2d}{2000/01/11}{Added naustrian defaults (identical to german)}
%    The naustrian defaults are the same but needed for ``Neue Rechtschreibung''.
%    \begin{macrocode}
\DeclareOption{naustrian}
  {\vref@addto\extrasnaustrian{%
    \def\reftextfaceafter {auf der n\"achsten Seite}%
    \def\reftextfacebefore{auf der vorherigen Seite}%
    \let\reftextafter     \reftextfaceafter
    \let\reftextbefore    \reftextfacebefore
    \def\reftextcurrent   {auf dieser Seite}%
    \def\reftextfaraway#1{auf Seite~\pageref{#1}}%
    \def\reftextpagerange#1#2{auf Seiten~\pageref{#1}--\pageref{#2}}%
    \def\reftextlabelrange#1#2{\ref{#1} bis~\ref{#2}}%
    \let\vrefformat\vrefdefaultformat
    \let\Vrefformat\Vrefdefaultformat
    \let\fullrefformat\fullrefdefaultformat
    \let\vrefrangeformat\vrefrangedefaultformat
  }}
%    \end{macrocode}
%    Text for basque defaults was contributed by
%    I\~naki Larra\~naga Murgoitio (aka dooteo)
%    (|<dooteo@euskalgnu.org>|).
% \changes{v1.4k}{2005/04/09}{Basque defaults added.}
%    \begin{macrocode}
\DeclareOption{basque}
  {\vref@addto\extrasbasque{%
    \def\reftextfaceafter {hurrengo orrialdean}%
    \def\reftextfacebefore{aurreko orrialdean}%
    \let\reftextafter     \reftextfaceafter
    \let\reftextbefore    \reftextfacebefore
    \def\reftextcurrent   {uneko orrialdean}%
    \def\reftextfaraway#1{~\pageref{#1}. orrialdean}%
    \def\reftextpagerange#1#2{~\pageref{#1}--\pageref{#2} orrialdeetan}%
    \def\reftextlabelrange#1#2{\ref{#1}.etik \ref{#2}.eraino}%
    \let\vrefformat\vrefdefaultformat
    \let\Vrefformat\Vrefdefaultformat
    \let\fullrefformat\fullrefdefaultformat
    \let\vrefrangeformat\vrefrangedefaultformat
  }}
%    \end{macrocode}
%    Text for the Bahasa Malaysia defaults was contributed by
%    Bob Margolis 2005-12-02.
%
%    Notes: pada muka surat translates as ``on the page'' though BM has no
%    definite (or indefinite) article; adjectives and other modifiers follow
%    the noun (clause); bertentangan is ``opposite'' in the sense of
%    ``facing''; berikutnya is ``next'' (in this context - actually
%    next-to-this, literally); berikutnya also translates as ``following
%    this'' sebelumnya is ``preceding''; also ``previous'' ``ini'' translates,
%    literally, as ``this'' but is also used in the sense of current page.
% \changes{v1.4o}{2005/12/02}{Bahasa Malaysia defaults added.}
%    \begin{macrocode}
\DeclareOption{bahasam}
  {\vref@addto\extrasbahasam{%
    \def\reftextfaceafter {pada muka surat \reftextvario{bertentangan}{berikutnya}}%
    \def\reftextfacebefore{pada muka surat \reftextvario{bertentangan}{sebelumnya} }%
    \def\reftextafter     {pada muka surat berikutnya}%
    \def\reftextbefore    {pada muka surat sebelumnya}%
    \def\reftextcurrent   {pada muka surat ini}%
    \def\reftextfaraway#1{pada muka surat~\pageref{#1}}%
    \def\reftextpagerange#1#2{pada muka surat~\pageref{#1}--\pageref{#2}}%
    \def\reftextlabelrange#1#2{\ref{#1}--\ref{#2}}%
    \let\vrefformat\vrefdefaultformat
    \let\Vrefformat\Vrefdefaultformat
    \let\fullrefformat\fullrefdefaultformat
    \let\vrefrangeformat\vrefrangedefaultformat
  }}
%    \end{macrocode}
%    Text for brazil defaults was contributed by
%    Alcino Dall Igna Junior\\
%    (|adij@di.ufpe.br|).
% \changes{v1.0g}{1994/05/18}{Brazil defaults added.}
% \changes{v1.4o}{2005/11/07}{Added a few more brazil strings}
% \changes{v1.4r}{2007/05/26}{Misspelling of \cs{extrasbrazil}}
%    \begin{macrocode}
\DeclareOption{brazil}
  {\vref@addto\extrasbrazil{%
    \def\reftextfaceafter {na \reftextvario{p\'agina oposta}{pr\'oxima
                           p\'agina}}%
    \def\reftextfacebefore{na p\'agina \reftextvario{oposta}{anterior}}%
    \def\reftextafter     {na \reftextvario{p\'agina seguinte}{pr\'oxima
                           p\'agina}}%
    \def\reftextbefore{na p\'agina \reftextvario{anterior}{precedente}}%
    \def\reftextcurrent   {\reftextvario{nesta p\'agina}{na p\'agina
                           corrente}}%
    \def\reftextfaraway#1{na p\'agina~\pageref{#1}}%
    \def\reftextpagerange#1#2{nas p\'aginas~\pageref{#1}--\pageref{#2}}%
    \def\reftextlabelrange#1#2{\ref{#1} a~\ref{#2}}%
    \let\vrefformat\vrefdefaultformat
    \let\Vrefformat\Vrefdefaultformat
    \let\fullrefformat\fullrefdefaultformat
    \let\vrefrangeformat\vrefrangedefaultformat
  }}
%    \end{macrocode}
%    Text for Breton defaults was contributed by
%    Christian ROLLAND\\
%    (|Christian.Rolland@univ-brest.fr|).
% \changes{v1.0o}{1994/09/27}{Added defaults for breton}
%    \begin{macrocode}
\DeclareOption{breton}
  {\vref@excuse{breton}%
   \vref@addto\extrasbreton{%
    \def\reftextfaceafter {war ar bajenn \reftextvario{a-dal}{da heul}}%
    \def\reftextfacebefore{war ar bajenn \reftextvario{a-dal}{a-raok}}%
    \def\reftextafter     {war ar bajenn da heul}%
    \def\reftextbefore    {war ar bajenn a-raok}%
    \def\reftextcurrent   {war ar \reftextvario{bajenn-ma\~n}%
                                               {bajenn war-wel}}%
    \def\reftextfaraway#1{war ar bajenn~\pageref{#1}}%
    \def\reftextpagerange#1#2{\vref@stringwarning\reftextpagerange
                              on pages~\pageref{#1}--\pageref{#2}}%
    \def\reftextlabelrange#1#2{\vref@stringwarning\reflabelpagerange
                               \ref{#1} to~\ref{#2}}%
    \let\vrefformat\vrefdefaultformat
    \let\Vrefformat\Vrefdefaultformat
    \let\fullrefformat\fullrefdefaultformat
    \let\vrefrangeformat\vrefrangedefaultformat
  }}
%    \end{macrocode}
%    Text for Bulgarian defaults was contributed by
%    Georgi Boshnakov\\  (|georgi.boshnakov@gmail.com|).
% \changes{v1.4q}{2006/05/23}{Added defaults for bulgarian}
%    \begin{macrocode}
\DeclareOption{bulgarian}%
 {\vref@addto\extrasbulgarian{%
   \def\reftextfaceafter{\cyrn\cyra\
         \reftextvario{\cyrs\cyrery\cyrs\cyre\cyrd\cyrn\cyra\cyrt\cyra}%
                      {\cyrs\cyrl\cyre\cyrd\cyrv\cyra\cyrshch\cyra\cyrt\cyra}
         \cyrs\cyrt\cyrr\cyra\cyrn\cyri\cyrc\cyra}%
   \def\reftextfacebefore{\cyrn\cyra\
         \reftextvario{\cyrs\cyrery\cyrs\cyre\cyrd\cyrn\cyra\cyrt\cyra}%
                      {\cyrp\cyrr\cyre\cyrd\cyrn\cyra\cyrt\cyra}
         \cyrs\cyrt\cyrr\cyra\cyrn\cyri\cyrc\cyra}%
   \def\reftextafter{\cyrn\cyra\
         \reftextvario{\cyrs\cyrl\cyre\cyrd\cyrv\cyra\cyrshch\cyra\cyrt\cyra}%
                      {\cyrs\cyrl\cyre\cyrd\cyrv\cyra\cyrshch\cyra\cyrt\cyra}
         \cyrs\cyrt\cyrr\cyra\cyrn\cyri\cyrc\cyra}%
   \def\reftextbefore{\cyrn\cyra\
         \reftextvario{\cyrp\cyrr\cyre\cyrd\cyrn\cyra\cyrt\cyra}%
                      {\cyrp\cyrr\cyre\cyrd\cyri\cyrsh\cyrn\cyra\cyrt\cyra}
         \cyrs\cyrt\cyrr\cyra\cyrn\cyri\cyrc\cyra}%
   \def\reftextcurrent{\cyrn\cyra\
         \reftextvario{\cyrt\cyra\cyrz\cyri}%
                      {\cyrt\cyre\cyrk\cyru\cyrshch\cyra\cyrt\cyra}
         \cyrs\cyrt\cyrr\cyra\cyrn\cyri\cyrc\cyra}%
   \def\reftextfaraway#1{\cyrn\cyra\ \cyrs\cyrt\cyrr\cyra\cyrn\cyri\cyrc\cyra
                         ~\pageref{#1}}%
   \def\reftextpagerange#1#2{\cyrn\cyra\
                        \cyrs\cyrt\cyrr\cyra\cyrn\cyri\cyrc\cyri
                        ~\pageref{#1}--\pageref{#2}}%
   \def\reftextlabelrange#1#2{\ref{#1} \cyrd\cyro~\ref{#2}}%
    \let\vrefformat\vrefdefaultformat
    \let\Vrefformat\Vrefdefaultformat
    \let\fullrefformat\fullrefdefaultformat
    \let\vrefrangeformat\vrefrangedefaultformat
 }}
%    \end{macrocode}
%    Text for catalan defaults was contributed by Robert Fuster\\
%    (\verb=rfuster@mat.upv.es=).
% \changes{v1.1c}{1997/06/12}{Added defaults for catalan}
% \changes{v1.2g}{2000/08/22}{Updated defaults for catalan}
%    \begin{macrocode}
\DeclareOption{catalan}
  {\vref@addto\extrascatalan{%
    \def\reftextfaceafter {a la p\`agina seg\"uent}%
    \def\reftextfacebefore{a la p\`agina anterior}%
    \let\reftextafter     \reftextfaceafter
    \let\reftextbefore    \reftextfacebefore
    \def\reftextcurrent   {en aquesta p\`agina}%
    \def\reftextfaraway#1{a la p\`agina~\pageref{#1}}%
    \def\reftextpagerange#1#2{a les
                     p\`agines~\pageref{#1}--\pageref{#2}}%
    \def\reftextlabelrange#1#2{\ref{#1} a~\ref{#2}}%
    \let\vrefformat\vrefdefaultformat
    \let\Vrefformat\Vrefdefaultformat
    \let\fullrefformat\fullrefdefaultformat
    \let\vrefrangeformat\vrefrangedefaultformat
  }}
%    \end{macrocode}
%    Text for croatian defaults was contributed by \v{S}ime Ungar
%    (\verb=ungar@math.hr=).
% \changes{v1.4p}{2006/05/13}{Added defaults for croatian}
%    \begin{macrocode}
\DeclareOption{croatian}
   {\vref@addto\extrascroatian{%
     \def\reftextfaceafter {na sljede\'coj stranici}%
     \def\reftextfacebefore{na prethodnoj stranici}%
     \let\reftextafter     \reftextfaceafter
     \let\reftextbefore    \reftextfacebefore
     \def\reftextcurrent   {na ovoj stranici}%
     \def\reftextfaraway#1{na stranici~\pageref{#1}}%
     \def\reftextpagerange#1#2{na stranicama~\pageref{#1}--\pageref{#2}}%
     \def\reftextlabelrange#1#2{\ref{#1} do~\ref{#2}}%
    \let\vrefformat\vrefdefaultformat
    \let\Vrefformat\Vrefdefaultformat
    \let\fullrefformat\fullrefdefaultformat
    \let\vrefrangeformat\vrefrangedefaultformat
   }}
%    \end{macrocode}
%    Defaults for the Czech option provided by Milan Vancura
%    \verb=<milan@suse.cz>=.
% \changes{v1.2e}{2000/04/04}{Added czech defaults}
%    \begin{macrocode}
\DeclareOption{czech}
  {%\vref@excuse{czech}%
   \vref@addto\extrasczech{%
    \def\reftextfaceafter {na n\'a\-sle\-du\-j\'\i c\'\i\ stran\v{e}}%
    \def\reftextfacebefore{na p\v{r}ed\-choz\'\i\ stran\v{e}}%
    \def\reftextafter     {na n\'a\-sle\-du\-j\'\i c\'\i\ stran\v{e}}%
    \def\reftextbefore    {na p\v{r}ed\-choz\'\i\ stran\v{e}}%
    \def\reftextcurrent   {na t\'eto stran\v{e}}%
    \def\reftextfaraway#1{na stran\v{e}~\pageref{#1}}%
    \def\reftextpagerange#1#2{na stran\'ach~\pageref{#1}\--\pageref{#2}}%
    \def\reftextlabelrange#1#2{\ref{#1} a\v{z}~\ref{#2}}%
    \let\vrefformat\vrefdefaultformat
    \let\Vrefformat\Vrefdefaultformat
    \let\fullrefformat\fullrefdefaultformat
    \let\vrefrangeformat\vrefrangedefaultformat
  }}
%    \end{macrocode}
%    Defaults for Danish provided by Torsten Martinsen
%    (\verb=tmar91@kom.auc.dk=). Further defaults by Ole Laursen
%    (\verb=olau@hardworking.dk=).
% \changes{v1.0n}{1994/09/25}{Added Danish defaults}
% \changes{v1.2h}{2000/12/30}{Updates to Danish defaults}
%    \begin{macrocode}
\DeclareOption{danish}
  {\vref@addto\extrasdanish{%
    \def\reftextfaceafter {p\aa{} \reftextvario{modst\aa ende}%
                                               {n\ae ste} side}%
    \def\reftextfacebefore{p\aa{} \reftextvario{modst\aa ende}%
                                               {forrige} side}%
    \def\reftextafter     {p\aa{} \reftextvario{den f\o lgende}%
                                               {n\ae ste} side}%
    \def\reftextbefore    {p\aa{} \reftextvario{forrige side}
                                               {foreg\aa ende side}}%
    \def\reftextcurrent   {p\aa{} denne side}%
    \def\reftextfaraway#1{p\aa{} side~\pageref{#1}}%
    \def\reftextpagerange#1#2{p\aa{} side~\pageref{#1}--\pageref{#2}}%
    \def\reftextlabelrange#1#2{\ref{#1} til~\ref{#2}}%
    \let\vrefformat\vrefdefaultformat
    \let\Vrefformat\Vrefdefaultformat
    \let\fullrefformat\fullrefdefaultformat
    \let\vrefrangeformat\vrefrangedefaultformat
  }}
%    \end{macrocode}
%    Default string for dutch have been contributed by Frank Poppe
%    (\verb=POPPE@SWOV.NL=).
%    This option currently supports one additional string macro
%    |\refpagename| so that you can easily change to |bladzijde|
%    instead of |pagina| if you prefer this word for ``page''.
%    However, I will not guarantee that this will survive future
%    versions of this package, so use it on your own risk (you can
%    always update the full strings to be on the safe side).
% \changes{v1.0l}{1994/07/07}{Added dutch defaults}
% \changes{v1.2a}{1998/08/22}{Added dutch defaults for
%      \cs{reftextpagerange} and \cs{reftextlabelrange}}
%    \begin{macrocode}
\DeclareOption{dutch}
  {\vref@addto\extrasdutch{%
    \def\refpagename{pagina}%
    \def\reftextfaceafter {op de \reftextvario{rechter \refpagename}%
                                          {\refpagename\ hiernaast}}%
    \def\reftextfacebefore{op de \reftextvario{linker \refpagename}%
                                         {\refpagename\ hiernaast}}%
    \def\reftextafter     {op de \reftextvario{volgende \refpagename}%
                                              {\refpagename\ hierna}}%
    \def\reftextbefore    {op de \reftextvario{vorige \refpagename}%
                                          {\refpagename\ hiervoor}}%
    \def\reftextcurrent   {op deze \refpagename}%
    \def\reftextfaraway#1{op \refpagename~\pageref{#1}}%
%    \end{macrocode}
%    Concerning the next defaults I received the following comment by
%    Frederik Fouvry \texttt{<fouvry@coli.uni-sb.de>}:
%    ``In the Dutch options (where I can exert a proper language
%    judgement ;-), `t/m' is not used in formal (scientific) texts.  I
%    would either use `--' or `tot en met' (the abbreviation written
%    out). ''
% \changes{v1.4d}{2002/11/11}{Changed default for \cs{reftextlabelrange}}
% \changes{v1.4m}{2005/06/09}{Fixed \cs{reftextlabelrange} (pr/3791)}
%    \begin{macrocode}
    \def\reftextpagerange#1#2{op pagina's~\pageref{#1}--\pageref{#2}}%
    \def\reftextlabelrange#1#2{\ref{#1}--\ref{#2}}%
    \let\vrefformat\vrefdefaultformat
    \let\Vrefformat\Vrefdefaultformat
    \let\fullrefformat\fullrefdefaultformat
    \let\vrefrangeformat\vrefrangedefaultformat
  }}
%    \end{macrocode}
% \changes{v1.2a}{1998/08/22}{Added english defaults for
%      \cs{reftextpagerange} and \cs{reftextlabelrange}}
% \changes{v1.4d}{2002/11/11}{Changed default for \cs{reftextbefore}}
%    \begin{macrocode}
\DeclareOption{english}
  {\vref@addto\extrasenglish{%
    \def\reftextfaceafter {on the \reftextvario{facing}{next} page}%
    \def\reftextfacebefore{on the \reftextvario{facing}{preceding}
                           page}%
    \def\reftextafter     {on the \reftextvario{following}{next} page}%
    \def\reftextbefore    {on the \reftextvario{preceding}{previous} page}%
    \def\reftextcurrent   {on \reftextvario{this}{the current} page}%
    \def\reftextfaraway#1{on page~\pageref{#1}}%
    \def\reftextpagerange#1#2{on pages~\pageref{#1}--\pageref{#2}}%
    \def\reftextlabelrange#1#2{\ref{#1} to~\ref{#2}}%
    \let\vrefformat\vrefdefaultformat
    \let\Vrefformat\Vrefdefaultformat
    \let\fullrefformat\fullrefdefaultformat
    \let\vrefrangeformat\vrefrangedefaultformat
  }}
%    \end{macrocode}
%
%    The esperanto strings were suggested by Albert Reiner
%    (\verb=areiner@tph.tuwien.ac.at=).
%  \changes{v1.4x}{2010/08/04}{Defaults for esperanto added}
%    \begin{macrocode}
\DeclareOption{esperanto}
  {\vref@addto\extrasesperanto{%
    \def\reftextfaceafter{en la
        \reftextvario{flanka}{sekva} pa\^go}%
    \def\reftextfacebefore{en la
        \reftextvario{flanka}{anta\u ua} pa\^go}%
    \def\reftextafter{en la sekva pa\^go}%
    \def\reftextbefore{en la anta\u ua pa\^go}%
    \def\reftextcurrent{\reftextvario{\^ci-pa\^ge}%
        {en \^ci tiu pa\^go}}%
    \def\reftextfaraway#1{en pa\^go~\pageref{#1}}%
    \def\reftextpagerange#1#2{en pa\^goj~\pageref{#1} \^gis \pageref{#2}}%
    \def\reftextlabelrange#1#2{\ref{#1} \^gis~\ref{#2}}%
    \let\vrefformat\vrefdefaultformat
    \let\Vrefformat\Vrefdefaultformat
    \let\fullrefformat\fullrefdefaultformat
    \let\vrefrangeformat\vrefrangedefaultformat
  }}
%    \end{macrocode}
%    The finnish strings were suggested by Matti Rintala
%    (\verb=bitti@cs.tut.fi=) and Hillevi Gavel
%    \verb=Hillevi.Gavel@mdh.se=.
% \changes{v1.0m}{1994/09/23}{Added finnish strings}
% \changes{v1.4o}{2005/11/07}{Added a few more finnish strings}
%    \begin{macrocode}
\DeclareOption{finnish}
  {\vref@addto\extrasfinnish{%
    \def\reftextfaceafter {\reftextvario{viereisell\"a}%
                                        {seuraavalla} sivulla}%
    \def\reftextfacebefore{\reftextvario{viereisell\"a}%
                                        {edellisell\"a} sivulla}%
    \def\reftextafter     {seuraavalla sivulla}%
    \def\reftextbefore    {edellisell\"a sivulla}%
    \def\reftextcurrent   {t\"all\"a sivulla}%
    \def\reftextfaraway#1{sivulla~\pageref{#1}}%
     \def\reftextpagerange#1#2{sivuilla~\pageref{#1}--\pageref{#2}}%
%    \end{macrocode}
%    Can't combine numbers with the necessary suffix well.
%    \begin{macrocode}
     \def\reftextlabelrange#1#2{\ref{#1}--\ref{#2}}%
    \let\vrefformat\vrefdefaultformat
    \let\Vrefformat\Vrefdefaultformat
    \let\fullrefformat\fullrefdefaultformat
    \let\vrefrangeformat\vrefrangedefaultformat
  }}
%    \end{macrocode}
%    French defaults are provided by Daniel Flippo
%    (\verb=Daniel.Flipo@univ-lille1.fr=).
% \changes{v1.0j}{1994/06/21}{Added french defaults}
% \changes{v1.2a}{1998/08/22}{Added french defaults for
%      \cs{reftextpagerange} and \cs{reftextlabelrange}}
%    \begin{macrocode}
\DeclareOption{french}
  {\vref@addto\extrasfrench{%
    \def\reftextfaceafter {page \reftextvario{ci-contre}{suivante}}%
    \def\reftextfacebefore{page \reftextvario{ci-contre}%
                          {pr\'ec\'edente}}%
    \def\reftextafter     {page suivante}%
    \def\reftextbefore    {page pr\'ec\'edente}%
    \def\reftextcurrent   {de la pr\'esente page}%
    \def\reftextfaraway#1{page~\pageref{#1}}%
    \def\reftextpagerange#1#2{pages~\pageref{#1}--\pageref{#2}}%
    \def\reftextlabelrange#1#2{\ref{#1} \`a~\ref{#2}}%
    \let\vrefformat\vrefdefaultformat
    \let\Vrefformat\Vrefdefaultformat
    \let\fullrefformat\fullrefdefaultformat
    \let\vrefrangeformat\vrefrangedefaultformat
  }}
%    \end{macrocode}
%    Galician defaults are provided by Matthias Moebius\\
%    (\texttt{Matthias.Moebius@uni-konstanz.de}).
% \changes{v1.1f}{1998/04/25}{Added galician defaults}
% \changes{v1.4o}{2005/11/10}{Added further galician defaults}
% \changes{v1.4o}{2005/11/26}{Some further corrections}
% \changes{v1.5b}{2015/09/22}{Fixed blunder from 2005 -
%                             galician option clearly never used}
%    \begin{macrocode}
\DeclareOption{galician}
  {\vref@addto\extrasgalician{%
    \def\reftextfaceafter {na p\'axina oposta}%
    \def\reftextfacebefore\reftextfaceafter
    \def\reftextafter     {na p\'axina seguinte}%
    \def\reftextbefore    {na p\'axina anterior}%
    \def\reftextcurrent   {nesta p\'axina}%
    \def\reftextfaraway#1{na p\'axina~\pageref{#1}}%
     \def\reftextpagerange#1#2{%
                nas p\'axinas~\pageref{#1}-\pageref{#2}}%
     \def\reftextlabelrange#1#2{\ref{#1} a~\ref{#2}}%
    \let\vrefformat\vrefdefaultformat
    \let\Vrefformat\Vrefdefaultformat
    \let\fullrefformat\fullrefdefaultformat
    \let\vrefrangeformat\vrefrangedefaultformat
  }}
%    \end{macrocode}
%    There are no good variants for German (I think and still think but
%    this is a matter of taste :-).
% \changes{v1.0b}{1994/01/31}{Replace in incorrect `def by `let}
%    The following definitions were recently suggested to me but since
%    the original are in for a long time i don't want to change them
%    now since that could make a lot of documents change their formatting.
%    If you fancy them, add a redefinition of the corresponding macro(s)
%    to the preamble of your document.
%\begin{verbatim}
%    \def\reftextfaceafter {auf der \reftextvario
%          {gegen\"uberliegenden}{anderen} Seite}%
%    \def\reftextfacebefore {auf der \reftextvario
%          {gegen\"uberliegenden}{anderen} Seite}%
%    \def\reftextafter     {auf der \reftextvario
%          {n\"achsten}{folgenden} Seite}%
%    \def\reftextbefore    {auf der \reftextvario
%          {vorigen}{vorhergehenden} Seite}%
%    \def\reftextcurrent   {\reftextvario
%          {auf dieser}{diese} Seite}%
%\end{verbatim}
% \changes{v1.4n}{2005/07/24}{Small change}
%    \begin{macrocode}
\DeclareOption{german}
  {\vref@addto\extrasgerman{%
    \def\reftextfaceafter {auf der n\"achsten Seite}%
    \def\reftextfacebefore{auf der vorherigen Seite}%
    \let\reftextafter     \reftextfaceafter
    \let\reftextbefore    \reftextfacebefore
    \def\reftextcurrent   {auf dieser Seite}%
    \def\reftextfaraway#1{auf Seite~\pageref{#1}}%
    \def\reftextpagerange#1#2{auf den Seiten~\pageref{#1}--\pageref{#2}}%
    \def\reftextlabelrange#1#2{\ref{#1} bis~\ref{#2}}%
    \let\vrefformat\vrefdefaultformat
    \let\Vrefformat\Vrefdefaultformat
    \let\fullrefformat\fullrefdefaultformat
    \let\vrefrangeformat\vrefrangedefaultformat
  }}
%    \end{macrocode}
% \changes{v1.2d}{2000/01/11}{Added ngerman defaults (identical to german)}
% \changes{v1.4n}{2005/07/24}{Small change}
%    The ngerman defaults are the same but needed for ``Neue Rechtschreibung''
%    (i.e., a different set of hyphenation patterns).
%    \begin{macrocode}
\DeclareOption{ngerman}
  {\vref@addto\extrasngerman{%
    \def\reftextfaceafter {auf der n\"achsten Seite}%
    \def\reftextfacebefore{auf der vorherigen Seite}%
    \let\reftextafter     \reftextfaceafter
    \let\reftextbefore    \reftextfacebefore
    \def\reftextcurrent   {auf dieser Seite}%
    \def\reftextfaraway#1{auf Seite~\pageref{#1}}%
    \def\reftextpagerange#1#2{auf den Seiten~\pageref{#1}--\pageref{#2}}%
    \def\reftextlabelrange#1#2{\ref{#1} bis~\ref{#2}}%
    \let\vrefformat\vrefdefaultformat
    \let\Vrefformat\Vrefdefaultformat
    \let\fullrefformat\fullrefdefaultformat
    \let\vrefrangeformat\vrefrangedefaultformat
  }}
%    \end{macrocode}
%    Defaults for greek suggested by Apostolos Syropoulos\\
%    (\verb=apostolo@obelix.ee.duth.gr=).
% \changes{v1.2a}{1998/08/22}{Added defaults for greek}
%    \begin{macrocode}
\DeclareOption{greek}
  {\vref@addto\extrasgreek{%
    \def\reftextfaceafter {sthn \reftextvario{paro'usa}%
                           {ep'omenh} sel'ida}%
    \def\reftextfacebefore{sthn \reftextvario{paro'usa}{prohgo'umenh}
                           sel'ida}%
    \def\reftextafter     {sthn ep'omenh sel'ida}%
    \def\reftextbefore    {sthn prohgo'umenh sel'ida}%
    \def\reftextcurrent   {s'' aut'h th sel'ida}%
    \def\reftextfaraway#1{sth sel'ida\nobreakspace\pageref{#1}}%
    \def\reftextpagerange#1#2{stis sel'ides\nobreakspace
                          \pageref{#1}---\pageref{#2}}%
    \def\reftextlabelrange#1#2{\ref{#1} ws\nobreakspace\ref{#2}}%
    \let\vrefformat\vrefdefaultformat
    \let\Vrefformat\Vrefdefaultformat
    \let\fullrefformat\fullrefdefaultformat
    \let\vrefrangeformat\vrefrangedefaultformat
  }}
%    \end{macrocode}
%    Icelandic defaults suggested by Thorhallur Sverrisson
%    (\verb=thorhs@basis.is=).
% \changes{v1.4t}{2007/09/07}{Added defaults for icelandic}
%    \begin{macrocode}
\DeclareOption{icelandic}
  {\vref@addto\extrasicelandic{%
    \def\reftextfaceafter {\'{a} \reftextvario{n{\ae}stu}%
                                              {n{\ae}stu} s\'{i}{\dh}u}%
    \def\reftextfacebefore{\'{a} \reftextvario{fyrri}%
                                              {fyrri} s\'{i}{\dh}u}%
    \def\reftextafter     {\'{a} \reftextvario{n{\ae}stu}%
                                              {n{\ae}stu} s\'{i}{\dh}u}%
    \def\reftextbefore    {\'{a} \reftextvario{fyrri}{fyrri} s\'{i}{\dh}u}%
    \def\reftextcurrent   {\'{a} \reftextvario{{\th}essari}%
                                              {{\th}essari} s\'{i}{\dh}u}%
    \def\reftextfaraway#1{\'{a} s\'{i}{\dh}u~\pageref{#1}}%
    \def\reftextpagerange#1#2{\'{a} s\'{i}{\dh}um~\pageref{#1}--\pageref{#2}}%
    \def\reftextlabelrange#1#2{\ref{#1} til~\ref{#2}}%
    \let\vrefformat\vrefdefaultformat
    \let\Vrefformat\Vrefdefaultformat
    \let\fullrefformat\fullrefdefaultformat
    \let\vrefrangeformat\vrefrangedefaultformat
  }}
%    \end{macrocode}
%    Defaults for Italian suggested by Giovanni Pensa
%    (\verb=pensa@dsi.unimi.it=) with i{\TeX}nici.
% \changes{v1.1b}{1995/10/19}{Added defaults for Italian}
% \changes{v1.2a}{1998/08/22}{Removed incorrect warning}
% \changes{v1.4k}{2004/10/30}{Added missing defaults supplied by Lapo Mori}
% \changes{v1.4n}{2005/07/24}{Small change}
% \changes{v1.4u}{2009/03/21}{Correction for \cs{reftextfaraway} suggested
%                             by Lorenzo Pantieri}
%    \begin{macrocode}
\DeclareOption{italian}
  {\vref@addto\extrasitalian{%
    \def\reftextfaceafter {\reftextvario{a fronte}%
                           {nella pagina successiva}}%
    \def\reftextfacebefore{\reftextvario{a fronte}%
                           {nella pagina precedente}}%
    \def\reftextafter     {nella pagina \reftextvario{seguente}%
                           {successiva}}%
    \def\reftextbefore    {nella pagina precedente}%
    \def\reftextcurrent   {in questa pagina}%
    \def\reftextfaraway#1{a pagina~\pageref{#1}}%
    \def\reftextpagerange#1#2{nelle pagine~\pageref{#1}--\pageref{#2}}%
    \def\reftextlabelrange#1#2{da~\ref{#1} a~\ref{#2}}%
    \let\vrefformat\vrefdefaultformat
    \let\Vrefformat\Vrefdefaultformat
    \let\fullrefformat\fullrefdefaultformat
    \let\vrefrangeformat\vrefrangedefaultformat
  }}
%    \end{macrocode}
%    Defaults for Japanese. It needs a special \cs{vrefformat},
%    \cs{Vrefformat}, \cs{fullrefformat} and \cs{vrefrangeformat}
%    for grammatical reasons. As our standard documentation
%    workflow uses pdf\TeX{} the Japanese letters can't be displayed
%    easily, so you will see missing glyphs below. To see the real
%    letters you have to look at the source or package file.
% \changes{v1.6d}{2020/07/20}{Option japanese added (gh/352)}
% \changes{v1.6e}{2020/07/25}{Option japanese changed (gh/352)}
% \begin{allowtofu}
%    \begin{macrocode}
\DeclareOption{japanese}
  {\vref@addto\extrasjapanese{%
    \def\reftextfaceafter {\reftextvario{見開き}{次}ページ}%
    \def\reftextfacebefore{\reftextvario{見開き}{前}ページ}%
    \def\reftextafter     {\reftextvario{直後の}{次}ページ}%
    \def\reftextbefore    {\reftextvario{直前の}{前}ページ}%
    \def\reftextcurrent   {\reftextvario{この}{現}ページ}%
    \def\reftextfaraway#1{\pageref{#1}ページ}%
    \def\reftextpagerange#1#2{\pageref{#1}から\pageref{#2}ページ}%
    \def\reftextlabelrange#1#2{\ref{#1}から\ref{#2}}%
%    \end{macrocode}
%    Note that the parentheses below are not normal ones but full width
%    ones U+FF08 and U+FF09!
%    \begin{macrocode}
    \def\vrefformat#1#2{\ref{#2}(\vpageref[#1]{#2})}%
    \def\Vrefformat#1#2{\Ref{#2}(\vpageref[#1]{#2})}%
    \def\fullrefformat#1{\ref{#1}(\reftextfaraway{#1})}%
    \def\vrefrangeformat#1#2#3{\reftextlabelrange{#2}{#3}%
                               (\vpagerefrange[{#1}]{#2}{#3})}%
  }}
%    \end{macrocode}
% \end{allowtofu}
%   Defaults for Hungarian by Jeff Goldberg
%   (\verb=jeffrey@goldmark.org=).
%   There is a problem with the use of the definite article
%   \textit{a} or \textit{az} in Hungarian before expansions
%   of |\vref| or |\ref|.  The problem is that the word
%   should be \textit{az} if the number following would begin with
%   a vowel if spelled out, and \textit{a} if the number would begin
%   with a consonant.
%
%   The option assumes that there is a command |\aza| defined which
%   helps resolving this problem.\footnote{This information is actually quite
%   old but unfortunately never made it into \pkg{varioref}. In case any work
%   has been undertaken to resolve this please inform the author about it.}
% \changes{v1.2a}{1998/08/22}{Added defaults for magyar}
% \changes{v1.4j}{2005/01/22}{Defined \cs{reftextfaceafter} and
%       \cs{reftextfacebefore} instead of \cs{reftextafter} and \cs{reftextbefore}}
%    \begin{macrocode}
\DeclareOption{magyar}
  {\vref@addto\extrasmagyar{%
    \def\reftextafter {a k\"o\-vet\-kez\H{o} ol\-da\-lon}%
    \def\reftextbefore{az el\H{o}\-z\H{o} ol\-da\-lon}%
    \def\reftextfaceafter {\reftextvario{a t\'ul\-ol\-da\-lon}%
                          {a k\"o\-vet\-kez\H{o} ol\-da\-lon}}%
    \def\reftextfacebefore{\reftextvario{a t\'ul\-ol\-da\-lon}%
                          {az el\H{o}\-z\H{o} ol\-da\-lon}}%
    \def\reftextcurrent   {ezen az ol\-da\-lon}%
%    \end{macrocode}
%    The following suggested patch has not been added yet (pending changes
%    in babel system).
%\begin{verbatim}
%    \def\reftextfaraway#1{a~\csname @@magyar@az@lowxu\endcsname
%                                                {\pageref{#1}}.~ol\-da\-lon}%
%    \def\reftextpagerange#1#2{a~\csname @@magyar@az@lowxu\endcsname
%                                                        {\pageref{#1}}%
%      --\pageref{#2}.~ol\-da\-la\-kon}%
%    \def\reftextlabelrange#1#2{{}\csname @@magyar@told\endcsname\ref{#1}+tol
%      \ref{#2}-ig}% Dat: `{}' is here for anti-\capitalize
%\end{verbatim}
%    \begin{macrocode}
    \def\reftextfaraway#1{\aza{\pageref{#1}} \pageref{#1}.~ol\-da\-lon}%
    \def\reftextpagerange#1#2{\vref@stringwarning\reftextpagerange
                              on pages~\pageref{#1}--\pageref{#2}}%
    \def\reftextlabelrange#1#2{\vref@stringwarning\reflabelpagerange
                               \ref{#1} to~\ref{#2}}%
    \let\vrefformat\vrefdefaultformat
    \let\Vrefformat\Vrefdefaultformat
    \let\fullrefformat\fullrefdefaultformat
    \let\vrefrangeformat\vrefrangedefaultformat
   }%
%    \end{macrocode}
%    The |\AtBeginDocument| needs to be executed when the option is
%    processed and not inside the babel interface.
% \changes{v1.4i}{2004/02/27}{Moved \cs{AtBeginDocument}}
%    \begin{macrocode}
   \AtBeginDocument{\providecommand\aza[1]{a/az%
       \PackageError{varioref}{%
         Proper definition for command \noexpand\aza missing}%
        {You need to (re)define the command \noexpand\aza that
         takes one argument (a number or a \noexpand\pageref command)
         and produces the string `a' or `az' depending on the argument
         value. It should also accept an optional argument (default `l')
         to denote whether or not the string should be lowercase or
         uppercase.}}}%
  }
%    \end{macrocode}
%    The Norwegian and `nynorsk' translations have been provided by
%    Dag F Langmyhr \verb=<dag@ifi.uio.no>= and Karl Ove Hufthammer
%    \verb=<huftis@bigfoot.com>=.
% \changes{v1.0q}{1995/04/06}{Added defaults for norsk}
% \changes{v1.0q}{1995/04/06}{Added defaults for nynorsk}
% \changes{v1.2a}{1998/08/22}{Updated defaults for norsk}
% \changes{v1.2a}{1998/08/22}{Updated defaults for nynorsk}
% \changes{v1.2a}{1998/08/22}{Added norsk defaults for
%      \cs{reftextpagerange} and \cs{reftextlabelrange}}
% \changes{v1.2a}{1998/08/22}{Added nynorsk defaults for
%      \cs{reftextpagerange} and \cs{reftextlabelrange}}
% \changes{v1.2i}{2001/01/12}{Updated nynorsk defaults}
%    \begin{macrocode}
\DeclareOption{norsk}
  {\vref@addto\extrasnorsk{%
    \def\reftextfaceafter {p\aa{} neste side}%
    \def\reftextfacebefore{p\aa{} forrige side}%
    \def\reftextafter     {p\aa{} neste side}%
    \def\reftextbefore    {p\aa{} forrige side}%
    \def\reftextcurrent   {p\aa{} denne siden}%
    \def\reftextfaraway#1{p\aa{} side~\pageref{#1}}%
    \def\reftextpagerange#1#2{p\aa{} side~\pageref{#1}--\pageref{#2}}%
    \def\reftextlabelrange#1#2{\ref{#1} til~\ref{#2}}%
    \let\vrefformat\vrefdefaultformat
    \let\Vrefformat\Vrefdefaultformat
    \let\fullrefformat\fullrefdefaultformat
    \let\vrefrangeformat\vrefrangedefaultformat
  }}
\DeclareOption{nynorsk}
  {\vref@addto\extrasnynorsk{%
    \def\reftextfaceafter {p\aa{} neste side}%
    \def\reftextfacebefore{p\aa{} f\o{}rre side}%
    \def\reftextafter     {p\aa{} neste side}%
    \def\reftextbefore    {p\aa{} f\o{}rre side}%
    \def\reftextcurrent   {p\aa{} denne sida}%
    \def\reftextfaraway#1{p\aa{} side~\pageref{#1}}%
    \def\reftextpagerange#1#2{p\aa{} side~\pageref{#1}--\pageref{#2}}%
    \def\reftextlabelrange#1#2{\ref{#1} til~\ref{#2}}%
    \let\vrefformat\vrefdefaultformat
    \let\Vrefformat\Vrefdefaultformat
    \let\fullrefformat\fullrefdefaultformat
    \let\vrefrangeformat\vrefrangedefaultformat
  }}
%    \end{macrocode}
%    The polish translations have been provided by
%    Tomasz Michniewski \\
%    \verb=<tomekm@ias.wat.waw.pl>=.
%    The use of the command \verb=\eob= and \verb=aob= etc.\
%    requires appropriate definitions as provided, for example, by
%    the babel system. This should probably be handled differently
%    but it would require modifications in babel's language support.
% \changes{v1.1d}{1997/12/06}{Added defaults for polish}
% \changes{v1.2a}{1998/08/22}{Added polish defaults for
%      \cs{reftextpagerange} and \cs{reftextlabelrange}}
% \changes{v1.4n}{2005/09/14}{Changed default for \cs{reftextfaraway}}
%    \begin{macrocode}
\DeclareOption{polish}
  {\vref@addto\extraspolish{%
    \def\reftextfaceafter {na \reftextvario{s\aob{}siedniej}%
                                   {nast\eob{}pnej} stronie}%
    \def\reftextfacebefore{na \reftextvario{s\aob{}siedniej}%
                                   {poprzedniej} stronie}%
    \def\reftextafter     {na nast\eob{}pnej stronie}%
    \def\reftextbefore    {na poprzedniej stronie}%
    \def\reftextcurrent   {na \reftextvario{tej
                           samej}{bie\zkb{}\aob{}cej} stronie}%
    \def\reftextfaraway#1{na stronie~\pageref{#1}}%
    \def\reftextpagerange#1#2{na stronach~\pageref{#1}--\pageref{#2}}%
    \def\reftextlabelrange#1#2{od~\ref{#1} do~\ref{#2}}%
    \let\vrefformat\vrefdefaultformat
    \let\Vrefformat\Vrefdefaultformat
    \let\fullrefformat\fullrefdefaultformat
    \let\vrefrangeformat\vrefrangedefaultformat
  }}
%    \end{macrocode}
%    The Portuges default text has been provided by
%    Jos\'e Carlos Oliveira Santos \verb=jcsantos@fc.up.pt=.
% \changes{v1.2b}{1999/11/25}{Added portuguese defaults}
% \changes{v1.2c}{1999/12/02}{Added more portuguese defaults}
% \changes{v1.4r}{2007/05/26}{Misspelling of \cs{extrasportuges}}
%    \begin{macrocode}
\DeclareOption{portuges}
  {\vref@addto\extrasportuges{%
    \def\reftextfaceafter {na \reftextvario{p\'agina ao lado}{pr\'oxima
                           p\'agina}}%
    \def\reftextfacebefore{na p\'agina \reftextvario{ao lado}{anterior}}%
    \def\reftextafter     {na \reftextvario{p\'agina seguinte}{pr\'oxima
                           p\'agina}}%
    \def\reftextbefore{na p\'agina \reftextvario{anterior}{precedente}}%
    \def\reftextcurrent   {nesta p\'agina}%
    \def\reftextfaraway#1{na p\'agina~\pageref{#1}}%
     \def\reftextpagerange#1#2{nas p\'aginas~\pageref{#1}--\pageref{#2}}%
     \def\reftextlabelrange#1#2{\ref{#1} a~\ref{#2}}%
    \let\vrefformat\vrefdefaultformat
    \let\Vrefformat\Vrefdefaultformat
    \let\fullrefformat\fullrefdefaultformat
    \let\vrefrangeformat\vrefrangedefaultformat
  }}
%    \end{macrocode}
% Updates to the default text for Romanian have been suggested by Florin Oprina
%  (\verb=<florin.oprina@gmail.com>=).
% \changes{v1.4v}{2009/06/13}{Incorrect text in \cs{reftextafter} (pr/4070)}
% \changes{v1.5a}{2014/07/03}{Correct text in \cs{reftextbefore}}
%    \begin{macrocode}
\DeclareOption{romanian}
  {\vref@addto\extrasromanian{%
    \def\reftextfaceafter {pe pagina \reftextvario{opus\u{a}}{urm\u{a}toarei}}%
    \def\reftextfacebefore{pe pagina \reftextvario{opus\u{a}}{precedentei}}%
    \def\reftextafter     {\reftextvario{pe pagina urm\u{a}toare}%
                                        {pe urm\u{a}toarea pagin\u{a}}}%
    \def\reftextbefore    {pe pagina \reftextvario{precedent\u{a}}%
                                                  {precedentei}}%
    \def\reftextcurrent   {pe aceast\u{a} pagin\u{a}}%
    \def\reftextfaraway#1{pe pagina~\pageref{#1}}%
    \def\reftextpagerange#1#2{pe paginile~\pageref{#1}--\pageref{#2}}%
    \def\reftextlabelrange#1#2{\ref{#1} la~\ref{#2}}%
    \let\vrefformat\vrefdefaultformat
    \let\Vrefformat\Vrefdefaultformat
    \let\fullrefformat\fullrefdefaultformat
    \let\vrefrangeformat\vrefrangedefaultformat
  }}
%    \end{macrocode}
%    The text for Russian was taken from the book in Russian by
%    I.~A.~Kotelnikov and P.~Z.~Chebotaev, and adapted
%    to the encoding-independent form by Vladimir Volovich
%    (\verb=vvv@vsu.ru=).
% \changes{v1.2a}{1998/11/23}{Added russian strings}
% \changes{v1.2a}{1998/11/24}{Added defaults for
%      \cs{reftextpagerange} and \cs{reftextlabelrange}}
%    \begin{macrocode}
\DeclareOption{russian}
  {\vref@addto\extrasrussian{%
    \def\reftextfaceafter{\cyrn\cyra\ \reftextvario{\cyrp\cyrr\cyro
      \cyrt\cyri\cyrv\cyro\cyrp\cyro\cyrl\cyro\cyrzh\cyrn\cyro\cyrishrt}%
      {\cyrs\cyrl\cyre\cyrd\cyru\cyryu\cyrshch\cyre\cyrishrt}\ \cyrs\cyrt
      \cyrr\cyra\cyrn\cyri\cyrc\cyre}%
    \def\reftextfacebefore{\cyrn\cyra\ \reftextvario{\cyrp\cyrr\cyro
      \cyrt\cyri\cyrv\cyro\cyrp\cyro\cyrl\cyro\cyrzh\cyrn\cyro\cyrishrt}%
      {\cyrp\cyrr\cyre\cyrd\cyrery\cyrd\cyru\cyrshch\cyre\cyrishrt}\
      \cyrs\cyrt\cyrr\cyra\cyrn\cyri\cyrc\cyre}%
    \def\reftextafter{\cyrn\cyra\ \cyrs\cyrl\cyre\cyrd\cyru\cyryu\cyrshch
      \cyre\cyrishrt\ \cyrs\cyrt\cyrr\cyra\cyrn\cyri\cyrc\cyre}%
    \def\reftextbefore{\cyrn\cyra\ \reftextvario{\cyrp\cyrr\cyre\cyrd
      \cyrsh\cyre\cyrs\cyrt\cyrv\cyru\cyryu\cyrshch\cyre\cyrishrt}%
      {\cyrp\cyrr\cyre\cyrd\cyrery\cyrd\cyru\cyrshch\cyre\cyrishrt}%
      \ \cyrs\cyrt\cyrr\cyra\cyrn\cyri\cyrc\cyre}%
    \def\reftextcurrent{\cyrn\cyra\ \reftextvario{\cyrerev\cyrt\cyro
      \cyrishrt}{\cyrd\cyra\cyrn\cyrn\cyro\cyrishrt}\ \cyrs\cyrt\cyrr
      \cyra\cyrn\cyri\cyrc\cyre}%
    \def\reftextfaraway#1{\cyrn\cyra\ \cyrs.~\pageref{#1}}%
    \def\reftextpagerange#1#2{\cyrn\cyra\ \cyrs\cyrt\cyrr\cyra\cyrn
      \cyri\cyrc\cyra\cyrh~\pageref{#1}--\pageref{#2}}%
    \def\reftextlabelrange#1#2{\cyrs~\ref{#1}\ \cyrp\cyro~\ref{#2}}%
    \let\vrefformat\vrefdefaultformat
    \let\Vrefformat\Vrefdefaultformat
    \let\fullrefformat\fullrefdefaultformat
    \let\vrefrangeformat\vrefrangedefaultformat
  }}
%    \end{macrocode}
%    The text for Slovak defaults was contributed by Miroslav Sedivy\\
%    (\verb=<miro@slovensko.com>=).
% \changes{v1.4b}{2002/03/11}{Contributed defaults added}
%    \begin{macrocode}
\DeclareOption{slovak}
  {\vref@addto\extrasslovak{%
    \def\reftextfaceafter {na \reftextvario{proti\v lahlej}%
                          {nasleduj\'ucej} strane}%
    \def\reftextfacebefore{na \reftextvario{proti\v lahlej}%
                          {predch\'adzaj\'ucej} strane}%
    \def\reftextafter     {na \reftextvario{nasleduj\'ucej}%
                          {\v dal\v sej} strane}%
    \def\reftextbefore    {na \reftextvario{predch\'adzaj\'ucej}%
                          {predo\v slej} strane}%
    \def\reftextcurrent   {na tejto strane}%
    \def\reftextfaraway#1{na strane~\pageref{#1}}%
    \def\reftextpagerange#1#2{na stran\'ach~\pageref{#1}--\pageref{#2}}%
    \def\reftextlabelrange#1#2{\ref{#1} a\v z~\ref{#2}}%
    \let\vrefformat\vrefdefaultformat
    \let\Vrefformat\Vrefdefaultformat
    \let\fullrefformat\fullrefdefaultformat
    \let\vrefrangeformat\vrefrangedefaultformat
  }}
%    \end{macrocode}
%    The text for Slovene defaults was contributed by Roman Maurer\\
%    (\verb=<roman.maurer@amis.net>=).
% \changes{v1.4a}{2002/03/05}{Contributed defaults added}
%    \begin{macrocode}
\DeclareOption{slovene}
  {\vref@addto\extrasslovene{%
    \def\reftextfaceafter {na naslednji strani}%
    \def\reftextfacebefore{na prej\v{s}nji strani}%
    \let\reftextafter     \reftextfaceafter
    \let\reftextbefore    \reftextfacebefore
    \def\reftextcurrent   {na \reftextvario{tej}{trenutni} strani}%
    \def\reftextfaraway#1{na strani~\pageref{#1}}%
    \def\reftextpagerange#1#2{na straneh~\pageref{#1}--\pageref{#2}}%
    \def\reftextlabelrange#1#2{od~\ref{#1} do~\ref{#2}}%
    \let\vrefformat\vrefdefaultformat
    \let\Vrefformat\Vrefdefaultformat
    \let\fullrefformat\fullrefdefaultformat
    \let\vrefrangeformat\vrefrangedefaultformat
  }}
%    \end{macrocode}
%    Text for Spanish defaults was contributed by Julio Sanchez
%    (\verb=jsanchez@gmv.es=) and Fernando Dobladez (\verb=<ferd@fuego.com>=).
% \changes{v1.0f}{1994/03/16}{Inserted missing hash mark}
% \changes{v1.0k}{1994/06/05}{Corrected misspelled cmd `extrasspanish}
% \changes{v1.4a}{2002/03/05}{Missing defaults added}
% \changes{v1.4o}{2005/11/26}{Single hyphen in range}
%    \begin{macrocode}
\DeclareOption{spanish}
  {\vref@addto\extrasspanish{%
    \def\reftextfaceafter {en la p\'agina siguiente}%
    \def\reftextfacebefore{en la p\'agina anterior}%
    \let\reftextafter     \reftextfaceafter
    \let\reftextbefore    \reftextfacebefore
    \def\reftextcurrent   {en esta p\'agina}%
    \def\reftextfaraway#1{en la p\'agina~\pageref{#1}}%
    \def\reftextpagerange#1#2{en las p\'aginas~\pageref{#1}%
                                             -\pageref{#2}}%
    \def\reftextlabelrange#1#2{\ref{#1} a~\ref{#2}}%
    \let\vrefformat\vrefdefaultformat
    \let\Vrefformat\Vrefdefaultformat
    \let\fullrefformat\fullrefdefaultformat
    \let\vrefrangeformat\vrefrangedefaultformat
  }}
%    \end{macrocode}
%    The text for Swedish was contributed by Mats Dahlgren
%    (\verb=matsd@sssk.se=).
% \changes{v1.0p}{1995/01/10}{Added swedish strings}
% \changes{v1.2a}{1998/08/22}{Added swedish defaults for
%      \cs{reftextpagerange} and \cs{reftextlabelrange}}
%    \begin{macrocode}
\DeclareOption{swedish}
  {\vref@addto\extrasswedish{%
     \def\reftextfaceafter {p\aa\ \reftextvario{motst\aa ende}%
                                             {n\"{a}sta} sida}%
     \def\reftextfacebefore{p\aa\ \reftextvario{motst\aa ende}%
                                      {f\"{o}reg\aa ende} sida}%
     \def\reftextafter     {p\aa\ \reftextvario{f\"{o}ljande}%
                                            {n\"{a}sta} sida}%
     \def\reftextbefore    {p\aa\ f\"{o}reg\aa ende sida}%
     \def\reftextcurrent   {p\aa\ denna sida}%
     \def\reftextfaraway#1{p\aa\ sidan~\pageref{#1}}%
     \def\reftextpagerange#1#2{p\aa\
                               sidorna~\pageref{#1}--\pageref{#2}}%
     \def\reftextlabelrange#1#2{\ref{#1} till~\ref{#2}}%
    \let\vrefformat\vrefdefaultformat
    \let\Vrefformat\Vrefdefaultformat
    \let\fullrefformat\fullrefdefaultformat
    \let\vrefrangeformat\vrefrangedefaultformat
  }}
\DeclareOption{turkish}
  {\vref@excuse{turkish}%
   \vref@addto\extrasturkish{%
    \def\reftextfaceafter {on the \reftextvario{facing}{next} page}%
    \def\reftextfacebefore{on the \reftextvario{facing}{preceding}
                           page}%
    \def\reftextafter     {on the \reftextvario{following}{next} page}%
    \def\reftextbefore    {on the \reftextvario{preceding}{previous} page}%
    \def\reftextcurrent   {on \reftextvario{this}{the current} page}%
    \def\reftextfaraway#1{on page~\pageref{#1}}%
    \def\reftextpagerange#1#2{on pages~\pageref{#1}--\pageref{#2}}%
    \def\reftextlabelrange#1#2{\ref{#1} to~\ref{#2}}%
    \let\vrefrangeformat\vrefrangedefaultformat
  }}
%    \end{macrocode}
%    The text for Ukrainian defaults was contributed by Mykola Lyakhovych\\
%    (\verb=<lyakhovych@mail.ru>=).
% \changes{v1.4l}{2005/04/24}{Contributed defaults added}
%    \begin{macrocode}
\DeclareOption{ukrainian}
   {\vref@addto\extrasukrainian{%
     \def\reftextfaceafter{\cyrn\cyra\ \reftextvario{\cyrp\cyrr\cyro
       \cyrt\cyri\cyrl\cyre\cyrzh\cyrn\cyrii\cyrishrt}%
       {\cyrn\cyra\cyrs\cyrt\cyru\cyrp\cyrn\cyrii\cyrishrt}\ \cyrs\cyrt
       \cyro\cyrr\cyri\cyrn\cyrc\cyrii}%
     \def\reftextfacebefore{\cyrn\cyra\ \reftextvario{\cyrp\cyrr\cyro
       \cyrt\cyri\cyrl\cyre\cyrzh\cyrn\cyrii\cyrishrt}%
       {\cyrp\cyro\cyrp\cyre\cyrr\cyre\cyrd\cyrn\cyrii\cyrishrt}\
       \cyrs\cyrt\cyro\cyrr\cyrii\cyrn\cyrc\cyrii}%
     \def\reftextafter{\cyrn\cyra\ \cyrn\cyra\cyrs\cyrt\cyru\cyrp\cyrn
       \cyrii\cyrishrt\ \cyrs\cyrt\cyro\cyrr\cyrii\cyrn\cyrc\cyrii}%
     \def\reftextbefore{\cyrn\cyra\ \cyrp\cyro\cyrp\cyre\cyrr\cyre\cyrd
       \cyrn\cyrii\cyrishrt\ \cyrs\cyrt\cyro\cyrr\cyrii\cyrn\cyrc\cyrii}%
     \def\reftextcurrent{\cyrn\cyra\ \reftextvario{\cyrc\cyrii\cyrishrt}%
       {\cyrd\cyra\cyrn\cyrii\cyrishrt}\ \cyrs\cyrt\cyro\cyrr\cyrii\cyrn
       \cyrc\cyrii}%
     \def\reftextfaraway#1{\cyrn\cyra\ \cyrs.~\pageref{#1}}%
     \def\reftextpagerange#1#2{\cyrn\cyra\ \cyrs\cyrt\cyro\cyrr\cyrii
       \cyrn\cyrk\cyra\cyrh~\pageref{#1}--\pageref{#2}}%
     \def\reftextlabelrange#1#2{\cyrz~\ref{#1}\ \cyrd\cyro~\ref{#2}}%
    \let\vrefformat\vrefdefaultformat
    \let\Vrefformat\Vrefdefaultformat
    \let\fullrefformat\fullrefdefaultformat
    \let\vrefrangeformat\vrefrangedefaultformat
   }}
%    \end{macrocode}
%    We support francais as an alternative to french since people
%    might be used to it, but we discourage it.
%    \begin{macrocode}
\DeclareOption{francais}{%
   \typeout{Please use `french' instead of `francais'}%
   \ExecuteOptions{french}}
\DeclareOption{germanb}{%
   \typeout{Please use `german' instead of `germanb'}%
   \ExecuteOptions{german}}
%    \end{macrocode}
%  \end{macro}
%  \end{macro}
%  \end{macro}
%  \end{macro}
%  \end{macro}
%
%    During document preparation errors due to |\vref| are usually of
%    not much interest. For this reason the draft option turns them into
%    warnings by issuing a |\vrefwarning| command. The final option
%    (default) stops with an error message when varioref detects a possible
%    loop.
% \changes{v1.1h}{1998/08/01}{Added draft and final options}
%    \begin{macrocode}
\DeclareOption{draft}{\AtEndOfPackage\vrefwarning}
\DeclareOption{final}{\AtEndOfPackage\vrefshowerrors} % the default
%    \end{macrocode}
%
%
%    Whether or not \pkg{varioref} uses its own white space and
%    removes the one in the source document is handled by the
%    following two options. For historical reasons the default is to
%    handle the space, but the recommendation these days is to use
%    \texttt{nospace}.
% \changes{v1.6a}{2019/08/25}{Provide options \texttt{space} and \texttt{nospace}}
%    \begin{macrocode}
\newif\if@vrefhandlespace
\DeclareOption{space}  {\@vrefhandlespacetrue}
\DeclareOption{nospace}{\@vrefhandlespacefalse}
%    \end{macrocode}
%
%
%
%
%    After all options are declared we execute the default option
%    \texttt{english} to set up the defaults and then call
%    |\ProcessOptions*| to handle any option passed to the package.
%    The star form is used since we want to execute the options in the
%    order they are given (in case this isn't used together with the
%    \pkg{babel} package).
%    \begin{macrocode}
\ExecuteOptions{english,final,space}
%    \end{macrocode}
%
%
% \subsection{Defining the main macros}
%
% \begin{macro}{\vr@cnt}
%    To generate new labels we use a counter and construct the
%    internal label names by prefixing the current counter value with
%    the string |vr@|. We need a \LaTeX{} counter to get |\include|s
%    handled correctly.
% \changes{v0.1e}{1992/11/15}{use LaTeX counter}
%    \begin{macrocode}
\newcounter{vrcnt}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\vpageref}
% \changes{v1.3a}{2001/04/12}{Scan for star form}
% \begin{macro}{\vp@geref}
%    The command |\vpageref| generates the appropriate string by first
%    parsing the optional arguments (if any) and then compares the
%    internal and the user label.  This command should be robust since
%    the user might put it anywhere.
%
%    We now start by scanning for a star and then call either
%    |\vp@gerefstar| or |\vp@geref|.
%    The space handling logic is a bit twisted these days: if the
%    option \texttt{space} is
%    in force then preceding spaces in the document are removed and
%    the star means that the command should not add its own
%    space. However, with option \texttt{nospace} any space already in the
%    source will be left alone and the command doesn't add its own
%    space either. Thus in this case the star form doesn't
%    have any effect and below |\vp@gerefstar| is let to
%    |\vp@geref|. This allows a package like \pkg{hyperef} to redefine
%    it and use it for its own tasks (like denoting that no link should
%    be produced).
%    \begin{macrocode}
\DeclareRobustCommand\vpageref{\@ifstar
     {\let\vref@maybe@space\@empty\vp@gerefstar}%
     {\let\vref@maybe@space\space \vp@geref}}
%    \end{macrocode}
%
%    \begin{macrocode}
\def\vp@geref{\@ifnextchar[%
%    \end{macrocode}
%    The default for the first optional argument is the string hidden
%    in the macro |\reftextcurrent|.
%    \begin{macrocode}
  \@vpageref{\@vpageref[\reftextcurrent]}%
}
%    \end{macrocode}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\vref@space}
% \begin{macro}{\vref@maybe@space}
% \changes{v1.4a}{2002/03/06}{Default added}
%    A default for |\vref@space|. This isn't really needed except in
%    the case that somebody has hooked into the \pkg{varioref}
%    interfaces at a lower level (which isn't really supported,
%    but\ldots). So giving a default will prevent an error message in
%    that case (and should hopefully produce the same behavior as before).
% \changes{v1.6c}{2019/11/05}{Support (mis)use of internal interface by
%                             fancyref (sx/515106)}
%    \begin{macrocode}
\let\vref@space\space
\let\vref@maybe@space\space
%    \end{macrocode}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\@vpageref}
%    More parsing\ldots
%    \begin{macrocode}
\def\@vpageref[#1]{\@ifnextchar[%
%    \end{macrocode}
%    By default the second optional argument is empty.
% \changes{v1.0h}{1994/06/11}{Pass first argument in both cases}
% \changes{v1.0i}{1994/06/20}{Do it correctly}
% \changes{v1.6a}{2019/08/25}{Default for optional argument changed}
%    \begin{macrocode}
  {\@@vpageref{#1}}{\@@vpageref{#1}[]}}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\@@vpageref}
%     The |\@@vpageref| macro finally generates the references by
%    comparing the value of an internal label with the value of the
%    user label.
% \changes{v1.0h}{1994/06/11}{Change internal interface}
%    \begin{macrocode}
\def\@@vpageref#1[#2]#3{%
%    \end{macrocode}
%    First it switches to horizontal mode if necessary. If there was a
%    preceding space we remember its size in |\@tempskipa| and then remove it for
%    reinsertion later.
% \changes{v1.6a}{2019/08/25}{Don't drop a preceding space completely
%     but reinsert it later after setting a label}
%    \begin{macrocode}
  \leavevmode
  \@tempskipa\lastskip \unskip
%    \end{macrocode}
%    Then it advances the counter |\c@vrcnt| by one which is used to
%    generate internal label names.
%    \begin{macrocode}
  \global\advance\c@vrcnt\@ne
%    \end{macrocode}
%    Then it checks if for the current value of |\c@vrcnt| a label
%    command was issued in the last run. If not it pretends that there
%    was one with the value |{??}{??}|.  Thereafter it stores the
%    pageref value for this label in the macro |\@tempa|.
%    \begin{macrocode}
  \vref@pagenum\@tempa{\the\c@vrcnt @vr}%
%    \end{macrocode}
%    Here we check that the generated text is not going across a page
%    boundary.
% \changes{v0.1f}{1993/01/01}{Add another label to catch cross-overs}
%    \begin{macrocode}
  \vref@pagenum\@tempb{\the\c@vrcnt @xvr}%
%    \end{macrocode}
% \changes{v1.0l}{1994/07/07}{Explicitly expand `label argument for
%                            babel}
%    In version 1.0l the label string has been turned around so that
%    the number comes first. This was done to allow easy explicit
%    expansion of the number before it is passed to the |\label|
%    command. In the babel system the argument of |label| was not
%    expanded with the result that wrong label strings have been
%    generated. This is a general problem that might need a completely
%    different solution in babel but for now the change below (and in
%    some other places in the code) should solve the problem for this
%    special combination of packages.
%
%    These days we actually use |\vref@label| instead of |\label| as
%    this avoids problems with Babel or \pkg{amsmath} redefining
%    the latter command.
% \changes{v1.4e}{2003/01/08}{Use \cs{vref@label} instead of
%    \cs{label} (pr/3489)}
%    \begin{macrocode}
  \vref@label{\the\c@vrcnt @xvr}%
%    \end{macrocode}
%    Since we have removed
%    any leading space above we now insert a space here after the
%    label. It is done here so that it is still visible from following
%    code---the space before the label would be hidden.
%    What kind of space depends on the options to the
%    package. If \texttt{space} was specified, we insert our own
%    space, namely |\vref@maybe@space|. This will typeset a space
%    unless the star form of the current command was used.
%    \begin{macrocode}
  \if@vrefhandlespace
    \vref@maybe@space
  \else
%    \end{macrocode}
%    But if \texttt{nospace} is in force we simply use the same space
%    value that was used in the source document (unless that was zero
%    or non-existent.
%    \begin{macrocode}
    \ifdim\@tempskipa=\z@ \else
      \hskip\@tempskipa
    \fi
  \fi
%    \end{macrocode}
% \changes{v1.1g}{1998/05/10}{Test if inside AMS display (pr2175)}
%    Inside displays of the \pkg{amsmath} package the |\label| command
%    is redefined which makes the test for loops incorrect if a |\vref|
%    is used in, say, |\intertext|. So we test this condition first and
%    only do the test if |\label| doesn't have a special meaning.
%    [This is no longer necessary as |\label| isn't used any more]
%    \begin{macrocode}
%  \ifx\label\label@in@display\else
  \ifx\@tempa\@tempb
    \let\vref@may@loop\relax
  \else
%    \end{macrocode}
%    If both points do not fall onto the same page with either issue
%    an error or a warning message.
%    However, we do no longer issue that warning now but wait until we
%    are sure that both labels aren't ``far away'' because in that
%    case it doesn't matter. So we just save that info in a macro now.
% \changes{v1.0g}{1994/05/27}{Looping pages shown in wrong order}
% \changes{v1.5c}{2016/02/16}{Delay generating the looping warning
%                until we know more}
%    \begin{macrocode}
    \edef\vref@may@loop{%
      \noexpand\vref@err{\noexpand\vref or \noexpand\vpageref
              at page boundary
              \@tempb-\@tempa\space (may loop)%
              }%
      }%
   \fi
%  \fi
%    \end{macrocode}
%    Same game for the user requested label; this time the page
%    reference is saved in |\thevpagerefnum|.
% \changes{v1.4c}{2002/06/14}{Use \cs{thevpagerefnum} instead of \cs{@tempb}}
%    \begin{macrocode}
  \vrefpagenum\thevpagerefnum{#3}%
%    \end{macrocode}
%    Now after the internal label has served its purpose if would be
%    nice to free the memory it occupies by using something like
%    \begin{verbatim}
% \global\expandafter\let
%        \csname r@\the\c@vrcnt @vr\endcsname\@empty
%\end{verbatim}
%    But this is not possible because it would result in getting
%    `Labels may have changed\ldots' warnings for every run.  Now we
%    are ready to produce the textual strings.
%    \begin{macrocode}
  \ifx\@tempa\thevpagerefnum
%    \end{macrocode}
%    If they are the same we insert the first argument into the input
%    stream.  Otherwise we insert the second argument.  Recall that
%    those are the two optional arguments of |...|. However, if the
%    user explicitly requested an empty text string using the optional
%    argument we cancel any preceding space since in this case we are
%    otherwise likely to end up with spaces one before and one after
%    |\vpageref|.
% \changes{v1.2f}{2000/07/07}{Don't output space if optional argument
%    empty (pr/3230)}
%    \begin{macrocode}
    \def\@tempc{#1}%
    \ifx\@tempc\@empty
       \unskip
    \else
       #1%
    \fi
  \else
%    \end{macrocode}
%    If |#2| is empty we do nothing otherwise we insert it followed by
%    a space.
%    \begin{macrocode}
    \def\@tempc{#2}%
    \ifx\@tempc\@empty \else
      #2\vref@space
    \fi
%    \end{macrocode}
%    Now we check if the page number of the referenced object (stored
%    in |\thevpagerefnum| is a single positive number.
%    \begin{macrocode}
    \is@pos@number\thevpagerefnum
       {%
%    \end{macrocode}
%    If so, we check if the current position (stored in |\@tempa|) is
%    a positive number. If this is the case we assign this number to
%    the counter register |\@tempcnta| and add one to it.
%    \begin{macrocode}
        \is@pos@number\@tempa
         {\@tempcnta\@tempa
          \advance\@tempcnta\@ne
         }%
%    \end{macrocode}
%    If it is not a positive number we assign the largest possible
%    number to |\@tempcnta| and thereby pretending that label and
%    reference are miles away from each other.
%    \begin{macrocode}
         {\@tempcnta\maxdimen}%
%    \end{macrocode}
%    Now we are ready to check if reference and object are on nearby
%    pages. |\thevpagerefnum| will expand to the page number of the object
%    (and we know that this is a number) and |\@tempcnta| is either
%    one higher than the reference page or completely out of bounds.
%    So if both represent the same value then the object lies one page
%    after its reference.
%    \begin{macrocode}
        \ifnum \thevpagerefnum =\@tempcnta
%    \end{macrocode}
%    Thus if the object falls onto an odd page then the reference is
%    on the facing even page (and so we insert |\reftextfaceafter|),
%    otherwise the object can not be seen from the reference (and we
%    in insert |\reftextafter|).  Don't be surprised if we are not
%    using |\thevpagerefnum| in the check. Since |\@tempcnta| has the same
%    value it is faster to use the register instead of parsing the
%    macro contents anew.
%    \begin{macrocode}
         \ifodd\@tempcnta
%    \end{macrocode}
%    In fact we are going to use |\reftextfaceafter| only if we are
%    doing two-sided printing, otherwise |\reftextafter| is always
%    used.
%    Since the value of |\if@twoside| is evaluated before reading in
%    packages we could do better (saving some tokens) by defining
%    the current macro in dependence of this boolean.
%    \begin{macrocode}
           \if@twoside
             \reftextfaceafter
           \else
             \reftextafter
           \fi
         \else
           \reftextafter
         \fi
%    \end{macrocode}
%    If the object is not on the page following the reference we check
%    if it is on the page before the reference. In \LaTeX{} this
%    situation is not too common, for example with floats it normally
%    does not occur, but of course it isn't impossible if you more
%    than one reference to the same object, or if you have back
%    references to sections, theorems, etc.  To test this we now
%    subtract two from the current value of |\@tempcnta| (which was
%    set to one higher as the reference page number). Note, that
%    subtraction is also possible if the value was |\maxdimen| --- we
%    still get something that is much larger than any sensible page
%    number.
%    \begin{macrocode}
        \else
          \advance\@tempcnta-2
%    \end{macrocode}
%    If now |\thevpagerefnum| and |\@tempcnta| have the same value then the
%    object lies one page before the reference.
%    \begin{macrocode}
          \ifnum \thevpagerefnum =\@tempcnta
%    \end{macrocode}
%    Again we have to check for odd or even pages to distinguish
%    between the facing and the non-facing situation.
%    \begin{macrocode}
            \ifodd\@tempcnta
              \reftextbefore
            \else
%    \end{macrocode}
%    Again the |\reftextfacebefore| only if |@twoside| evaluates to
%    true.
%    \begin{macrocode}
              \if@twoside
                \reftextfacebefore
              \else
                \reftextbefore
              \fi
            \fi
%    \end{macrocode}
%    If the above test also returns false then we have object and
%    references on pages which are far away or don't contain simple
%    page numbers. Therefore we generate the |\reftextfaraway| string
%    and drop any possible ``looping warning'' in |\vref@may@loop|.
%    Recall that this is a macro which has the user label as an
%    argument.
%    \begin{macrocode}
          \else
          \let\vref@may@loop\relax % added
          \reftextfaraway{#3}%
          \fi
        \fi
       }%
%    \end{macrocode}
%    We do the same if our first test (that the page with the object
%    has a positive page number) turns out to be false.
%    \begin{macrocode}
       {%
         \let\vref@may@loop\relax %added
         \reftextfaraway{#3}}%
  \fi
%    \end{macrocode}
%    Finally we generate the internal label so that it can be check on
%    the next run. This means that we compare the position after the
%    string with the position of the referenced object. There is one
%    thing to note: to conserve space we locally make |\@currentlabel|
%    empty since we are only interested in the page number value of
%    this internal label.
% \changes{v1.0l}{1994/07/07}{Explicitly expand \cs{label} argument for babel}
%
%    These days we actually use |\vref@label| instead of |\label| as
%    this avoids problems with Babel or \pkg{amsmath} redefining
%    the latter command.
% \changes{v1.4e}{2003/01/08}{Use \cs{vref@label} instead of
%    \cs{label}  (pr/3489)}
% \changes{v1.5c}{2016/02/16}{}
%    \begin{macrocode}
   \vref@label{\the\c@vrcnt @vr}%
%    \end{macrocode}
%    Finally we run |\vref@may@loop| which is either |\relax| or generates
%    a ``may loop'' warning or error as appropriate.
%    \begin{macrocode}
   \vref@may@loop
}
%    \end{macrocode}
% \end{macro}
%
%
%  \begin{macro}{\vp@gerefstar}
%    The default code for the star form is identical to the previous
%    macro |\vp@geref|. It only produces a different result because
%    before calling it we set |\vref@maybe@space| to do nothing.
%
%    The \pkg{hyperref} package can then change the meaning of this
%    command to suppress a hyperlink.
%
%    It is also a good way to check if we are running with a new
%    \pkg{varioref} by testing
%\begin{verbatim}
%  \ifdefined\vp@gerefstar
%     ... code for new varioref
%  \else
%    ... code for old varioref
%  \fi
%\end{verbatim}
%
% \changes{v1.6a}{2019/08/25}{Command added to support hyperref better}
%    \begin{macrocode}
\let\vp@gerefstar\vp@geref
%    \end{macrocode}
%  \end{macro}
%
%

%  \begin{macro}{\vref@label}
% \changes{v1.4e}{2003/01/08}{Macro added (pr/3489)}
%    This macro is like |\label| in the kernel but without passing on
%    |\@currentlabel|, ie useful if all we are interested in is the
%    page number. It also has the effect that it is unaffected by
%    \pkg{amsmath} or Babel redefining the |\label| command.
%    \begin{macrocode}
\def\vref@label#1{\@bsphack
  \protected@write\@auxout{}%
         {\string\newlabel{#1}{{}{\thepage}}}%
  \@esphack}
%    \end{macrocode}
% \end{macro}
%
%
%  \begin{macro}{\vpagerefnum}
% \changes{v1.4c}{2002/06/14}{Macro added}
%    This macro allows to define |\reftextafter| and friends to refer
%    to the page number rather than producing a textual reference.
%    \begin{macrocode}
\let\thevpagerefnum\@empty
%    \end{macrocode}
% \end{macro}
%
%
%  \begin{macro}{\vrefwarning}
% \changes{v0.1g}{1993/02/14}{Macro added}
%  \begin{macro}{\vrefshowerrors}
% \changes{v1.1h}{1998/08/01}{Macro added}
%  \begin{macro}{\vref@err}
% \changes{v0.1g}{1993/02/14}{Macro added}
%    When the |\vref| command detects a possible crossing over a page
%    boundary it will call |\vref@err| to generate an error message.
%    During document preparation one can turn such errors into
%    warnings by issuing a |\vrefwarning| declaration.
% \changes{v1.0g}{1993/02/14}{Macro added}
%    \begin{macrocode}
\def\vrefwarning{\def\vref@err{\PackageWarning{varioref}}}
%    \end{macrocode}
%    \begin{macrocode}
\def\vrefshowerrors{\def\vref@err##1{\PackageError{varioref}{##1}%
    {Please check the pages in question. You might need to replace
     the \string\vref\MessageBreak
     or \noexpand\vpageref by a normal \noexpand\(page)ref to
     stop LaTeX running forever.}}}
%    \end{macrocode}
%  \end{macro}
%  \end{macro}
%  \end{macro}
%
%
% \begin{macro}{\vref}
%    We start by scanning for a star form and then continue in a
%    different macro depending on the result.
% \changes{v1.3a}{2001/04/12}{Scan for star form}
% \changes{v1.6a}{2019/08/25}{Adjusted for new spacing regime}
%    \begin{macrocode}
\DeclareRobustCommand\vref{\@ifstar
   {\vref@star}{\vr@f}}
%    \end{macrocode}
%  \end{macro}



%  \begin{macro}{\vref@star}
%
%    The star form is easy (and just a convenient shortcut), just call
%    |\ref| followed by |\vpageref| and pass the optional argument to
%    the latter. We don't support the second optional argument of
%    |\vpageref|, it that is needed one has to call both commands
%    explicitly
% \changes{v1.6a}{2019/08/25}{Command added to support hyperref better}
% \changes{v1.6e}{2020/07/25}{Changed for Japanese (gh/352)}
%    \begin{macrocode}
\newcommand\vref@star[1][]{\vrefformat{#1}}
%    \end{macrocode}
%  \end{macro}
%
%
%  \begin{macro}{\vrefformat,\vrefdefaultformat}
%    Japanese needs a different word order in \cs{vref@star} so this
%    is separated out o that it can be changed on language level.
% \changes{v1.6e}{2020/07/25}{Macro added (gh/352)}
%    \begin{macrocode}
\def\vrefdefaultformat#1#2{% 
  \ref{#2}
  \vpageref[#1]{#2}}
%    \end{macrocode}
%    Most languages need the above definition.
%    \begin{macrocode}
\let\vrefformat\vrefdefaultformat
%    \end{macrocode}
%  \end{macro}

% \begin{macro}{\vr@f}
%    The normal case is a little bit more elaborated \ldots
% \changes{v1.3c}{2001/09/04}{Correct typo in name}
% \changes{v1.6a}{2019/08/25}{Adjusted for new spacing regime}
%    \begin{macrocode}
\def\vr@f{%
  \leavevmode
%    \end{macrocode}
%    If option \texttt{space} is used then we remove a preceding space
%    and add our own unbreakable space instead. Otherwise we don't do
%    any space-handling.
%    \begin{macrocode}
  \if@vrefhandlespace
    \unskip \nobreakspace
  \fi
%    \end{macrocode}
%    The use of|\nobreakspace| or |~| after the |\unskip| means that
%    this command will always produce a normal space while
%    something like |\nobreak\space| will
%    react to settings of |\nonfrenchspacing|.
%    Unfortunately the latter will also act in cases where one really
%    wants a normal space, e.g., in |Fig.~\vref{..}|, resulting in
%    a large extra space after the dot. For this reason the first solution
%    is used.
% \changes{v1.1e}{1998/03/09}{Don't use \cs{nobreakspace} (pr/1866)}
% \changes{v1.2a}{1998/11/27}{Use \cs{nobreakspace} (pr/2909)}
% \changes{v1.2a}{1998/11/27}{Add \cs{leavevmode}}
%
%    After having handled (or not  handled) the spacing we call
%    |\vref@star| to scan the optional arguments and do the rest.
%    If that command has been altered by \pkg{hyperref} then the
%    current one needs altering too and does the argument scanning explicitly.
%    \begin{macrocode}
  \vref@star                    % in hyperref this needs to be explicit
}
%    \end{macrocode}
% \end{macro}
%
%
%  \begin{macro}{\is@pos@number}
%    The utility macro |\is@pos@number| takes three arguments: a
%    string that is tested for being a valid non-negative integer and the
%    actions to be taken in case the test comes out true or false.
%
%    We start by passing the string to the macro |\is@pos@num| after
%    prefixing it with a \texttt{0} and adding a space after it. To have
%    a well-defined ending point we also add |\@nil| at the end.
%\label{isposnumber}
%    \begin{macrocode}
\def\is@pos@number#1{\is@pos@num0#1\space\@nil}
%    \end{macrocode}
%    Now we parse the enlarged string into a counter register.  To get
%    control back after everything that is regarded by \TeX{} as a
%    number is put into that register we assign |\is@pos@num@| to the
%    |\afterassignment| token.  Since the string started with 0, we
%    can be sure that the register assignment will be carried out
%    without an error message.  In case of counter assignments leading
%    zeros are discarded.
%    \begin{macrocode}
\def\is@pos@num{\afterassignment\is@pos@num@ \count@}
%    \end{macrocode}
%    Now we have to check whether or not the whole string was parsed
%    into that register or some remainder was left over. Since we have
%    added a |\@nil| token at the very end we can use that to delimit
%    the argument of |\is@pos@num@|. Note, that the added space in
%    |\is@pos@number| \vpageref[above]{isposnumber} gets parsed away
%    by the counter assignment. If it would be missing, and the full
%    string would consist of a number, \TeX{}would try to replace
%    |\@nil| by its definition to see if it would contain additional
%    digits and thus we would be in trouble at this point.
%    \begin{macrocode}
\def\is@pos@num@#1\@nil{%
%    \end{macrocode}
%    Now we have to check if the argument is empty. We can do this
%    with an |\ifx| (i.e., in an expandable way) since we know for
%    sure that it can not start with |\@nil|.
% \changes{v1.4j}{2004/05/08}{Use \cs{@nil} for testing}
%    \begin{macrocode}
  \ifx\@nil#1\@nil
%    \end{macrocode}
%    Depending on the result we execute the second or third argument
%    of the command |\is@pos@number| using a technique that removes
%    the |\else| or |\fi| from the input stream first, so that in
%    principle input stream parsing could be done from within the
%    arguments.
%    \begin{macrocode}
    \expandafter\@firstoftwo \else
    \expandafter\@secondoftwo  \fi}
%    \end{macrocode}
%  \end{macro}
%
%  \begin{macro}{\reftextvario}
%    This macro gives a little bit of random variation in the text
%    because the outcome depends on the number of |\vref| commands
%    seen before.
%    \begin{macrocode}
\def\reftextvario#1#2{\ifodd\c@vrcnt #1\else#2\fi}
%    \end{macrocode}
%  \end{macro}
%
%  \begin{macro}{\fullref}
%    And here is the primitive command that always produces a |\ref|
%    and a |\pageref|.
% \changes{v1.6e}{2020/07/25}{Changed for Japanese (gh/352)}
%    \begin{macrocode}
\newcommand\fullref{\fullrefformat}
%    \end{macrocode}
%  \end{macro}
%
%
%  \begin{macro}{\fullrefformat,\fullrefdefaultformat}
%    Japanese needs a different word order in \cs{fullref}  so this
%    is separated out o that it can be changed on language level.
% \changes{v1.6e}{2020/07/25}{Macro added (gh/352)}
%    \begin{macrocode}
\def\fullrefdefaultformat#1{% 
  \ref{#1} \reftextfaraway{#1}}
%    \end{macrocode}
%    Most languages need the above definition.
%    \begin{macrocode}
\let\fullrefformat\fullrefdefaultformat
%    \end{macrocode}
%  \end{macro}
%
%
% \subsubsection{Supporting ranges}
%
%  \begin{macro}{\vref@pagenum}
% \changes{v1.2a}{1998/08/01}{Macro added}
%    This command takes a label as |#1| extracts the page number
%    associated with it and saves the result in a csname which is
%    passed as |#1|. If the label isn't associated with a page number
%    it essentially associates it with |??| for both the label number
%    and the page, thus defining the label this way.  This means that
%    no label warning is generated for this label in case it is
%    undefined.
% \changes{v1.6f}{2021/07/07}{Use 3 additional (empty) arguments as
%                              default in case nameref is active}
%    \begin{macrocode}
\def\vref@pagenum#1#2{%
  \@ifundefined{r@#2}{\@namedef{r@#2}{{??}{??}{}{}{}}}{}%
%    \end{macrocode}
%    Extracting and saving the page number turned out to be a source of subtle
%    bugs. Initially it was done through an |\edef| with a bunch of
%    |\expandafter| commands inside. This posed a problem if the page number
%    itself contained code which needed protection (e.g., pr/4080) so this got
%    changed to use |\protected@edef|. However, that in turn failed with Babel
%    (pr/4093)
%    if the label contained active characters, e.g., a ``:'' in French. So now
%    we use even more |\expandafter| commands to avoid any expansion other
%    than what is absolutely  required---I'm sure there is now a simpler way
%    to code this, but \ldots\ in fact we didn't use enough initially resulting in another
%    bug (pr/4159):
% \changes{v1.4w}{2009/09/13}{Use \cs{protected@edef} to avoid problems
%              in complicated setups, e.g., microtype (pr/4080)}
% \changes{v1.4y}{2010/11/12}{Avoid even \cs{protected@edef} to pacify french
%    babel (pr/4093)}
% \changes{v1.4z}{2011/10/02}{Previous fix need one more expansion
%                            (pr/4159,pr/4171)}
%    \begin{macrocode}
  \expandafter\expandafter\expandafter\vref@@pagenum
  \csname r@#2\endcsname{}{}\@nil#1%
}
\def\vref@@pagenum#1#2#3\@nil#4{%
  \def#4{#2}%
}
%    \end{macrocode}
%  \end{macro}
%
%  \begin{macro}{\vrefpagenum}
% \changes{v1.2a}{1998/08/01}{Macro added}
%    Same as the above but this time we generate a warning for
%    undefined labels.
%    \begin{macrocode}
\def\vrefpagenum#1#2{%
  \@ifundefined{r@#2}%
    {\G@refundefinedtrue
     \@latex@warning{Reference `#2' on page \thepage \space
             undefined}}{}%
  \vref@pagenum{#1}{#2}}
%    \end{macrocode}
%  \end{macro}
%
%  \begin{macro}{\vpagerefrange}
%  \begin{macro}{\@vpagerefrange}
%  \begin{macro}{\@svpagerefrange}
% \changes{v1.2a}{1998/08/01}{Macro added}
% \changes{v1.3b}{2001/04/14}{Scan for star form}
% \changes{v1.4s}{2007/08/07}
%         {Prevent loss of brackets}
%    If both labels refer to the same page then we produce a
%    |\vpageref|. Otherwise we produce the result of
%    |\reftextpagerange|.
%
%    One could think of making this command even more clever by
%    producing a special string if the difference between the two page
%    number is one (but this is not done).
%
%    We need two versions to implement a star form:
%    \begin{macrocode}
\newcommand\@svpagerefrange[3][\reftextcurrent]{%
  \vrefpagenum\@tempa{#2}%
  \vrefpagenum\@tempb{#3}%
  \ifx\@tempa\@tempb
    \vpageref*[{#1}]{#2}%
  \else
    \reftextpagerange{#2}{#3}%
  \fi
}
%    \end{macrocode}
%    And the same but using |\vpageref|:
%    \begin{macrocode}
\newcommand\@vpagerefrange[3][\reftextcurrent]{%
  \vrefpagenum\@tempa{#2}%
  \vrefpagenum\@tempb{#3}%
  \ifx\@tempa\@tempb
    \vpageref[{#1}]{#2}%
  \else
    \reftextpagerange{#2}{#3}%
  \fi
}
%    \end{macrocode}
%    And here we put things together.
%    \begin{macrocode}
\newcommand\vpagerefrange{\@ifstar\@svpagerefrange\@vpagerefrange}
%    \end{macrocode}
%  \end{macro}
%  \end{macro}
%  \end{macro}
%
%
%  \begin{macro}{\vrefrange}
% \changes{v1.2a}{1998/08/01}{Macro added}
% \changes{v1.4s}{2006/08/07}
%         {Prevent loss of brackets}
% \changes{v1.6d}{2020/07/20}{Changed for Japanese (gh/352)}
%    Argument two and three are implicitly picked up.
%    \begin{macrocode}
\newcommand\vrefrange[1][\reftextcurrent]{\vrefrangeformat{#1}}
%    \end{macrocode}
%    
%  \end{macro}
%
%
%  \begin{macro}{\vrefrangeformat,\vrefrangedefaultformat}
%    Japanese needs a different word order in \cs{vrefrange}  so this
%    is separated out o that it can be changed on language level.
% \changes{v1.6d}{2020/07/20}{Macro added (gh/352)}
%    \begin{macrocode}
\def\vrefrangedefaultformat#1#2#3{% 
  \reftextlabelrange{#2}{#3} \vpagerefrange[{#1}]{#2}{#3}}
%    \end{macrocode}
%    Most languages need the above definition.
%    \begin{macrocode}
\let\vrefrangeformat\vrefrangedefaultformat
%    \end{macrocode}
%  \end{macro}
%
%  \begin{macro}{\Vref}
%  \changes{v1.4a}{2002/02/24}{Macro added}
%    |\Vref| is the counterpart to |\vref| with |\ref| replaced by
%    |\Ref| in its definition.
% \changes{v1.6a}{2019/08/25}{Adjusted for new spacing regime}
%    \begin{macrocode}
\DeclareRobustCommand\Vref{\@ifstar
   {\Vref@star}%
   {\Vr@f}}
%    \end{macrocode}
%  \end{macro}
%
%  \begin{macro}{\Vref@star}
% \changes{v1.6a}{2019/08/25}{Command added to support hyperref better}
% \changes{v1.6e}{2020/07/25}{Changed for Japanese (gh/352)}
%    \begin{macrocode}
\newcommand\Vref@star[1][]{\Vrefformat{#1}}
%    \end{macrocode}
%  \end{macro}
%
%
%  \begin{macro}{\Vrefformat,\Vrefdefaultformat}
%    Japanese needs a different word order in \cs{Vref}  so this
%    is separated out o that it can be changed on language level.
% \changes{v1.6e}{2020/07/25}{Macro added (gh/352)}
%    \begin{macrocode}
\def\Vrefdefaultformat#1#2{% 
  \Ref{#2}
  \vpageref[#1]{#2}}
%    \end{macrocode}
%    Most languages need the above definition.
%    \begin{macrocode}
\let\Vrefformat\Vrefdefaultformat
%    \end{macrocode}
%  \end{macro}
%
%  \begin{macro}{\Vr@f}
%  \changes{v1.4a}{2002/02/24}{Macro added}
%  \changes{v1.4x}{2010/08/04}{Correct spacing -- same mistake as in \cs{vref}
%                              (pr/4123)}
% \changes{v1.6a}{2019/08/25}{Adjusted for new spacing regime}
%    \begin{macrocode}
\def\Vr@f{%
  \if@vrefhandlespace
    \unskip \vref@space
  \fi
  \Vref@star                  % in hyperref this needs to be explicit
}
%    \end{macrocode}
%  \end{macro}


%  \begin{macro}{\vpagerefcompare}
%
% \changes{v1.6a}{2019/08/25}{Macro added}
%    \begin{macrocode}
\DeclareRobustCommand\vpagerefcompare[2]{%  label1, label2, TRUE, FALSE
  \vrefpagenum\@tempa{#1}%
  \vrefpagenum\@tempb{#2}%
  \ifx\@tempa\@tempb
    \expandafter\@firstoftwo
  \else
    \expandafter\@secondoftwo
  \fi
}
%    \end{macrocode}
%  \end{macro}
%
%
%
%  \begin{macro}{\vpagerefnearby}
% \changes{v1.6a}{2019/08/25}{Macro added}
%    Test if |\vpageref| is going to be at most $\pm1$ off from
%    current page.
%    \begin{macrocode}
\DeclareRobustCommand\vpagerefnearby[1]{%  label, TRUE, FALSE
  \leavevmode
  \@tempskipa\lastskip \unskip
  \global\advance\c@vrcnt\tw@    % keep oddness to not disturb \vrefvario
  \vref@label{\the\c@vrcnt @vn}%
  \ifdim\@tempskipa=\z@ \else
    \hskip\@tempskipa
  \fi
  \vref@pagenum\@tempa{\the\c@vrcnt @vn}%
  \is@pos@number\@tempa
      {%
        \vrefpagenum\@tempb{#1}%
        \is@pos@number\@tempb
            {%
              \ifcase\numexpr \@tempa -\@tempb+1\relax
              \or \or \else \expandafter \@thirdofthree \fi
              \@firstoftwo
            }%
            {\@secondoftwo}%
      }%
      {\@secondoftwo}%
}
%    \end{macrocode}
%  \end{macro}
%

%  \begin{macro}{\vpagerefcomparenearby}
% \changes{v1.6a}{2019/08/25}{Macro added}
%    True if the two pages have Arabic page numbers are at most off by
%    one so that |\vpageref| would produce a special string.
%
%    This is in some sense a general version of |\vpagerefnearby| for
%    use in more complex situations. I.e., if you try to determine if
%    a larger set of references would be close to the current page and
%    you use each time |\vpagerefnearby| then you generate a lot of
%    internal labels for the current point. Thus by setting the label
%    yourself you can save processing time and space. On the other
%    hand you have to be careful to place the label into the right
%    place which can be a bit complicated if you look at the
%    definition of |\vpagerefnearby| that does all this automatically
%    for you. This is why the current macro is not discussed in the
%    user interface section as it is really just for package
%    developers.
%    \begin{macrocode}
\DeclareRobustCommand\vpagerefcomparenearby[2]{%  label1, label2, TRUE, FALSE
  \vrefpagenum\@tempa{#1}%
  \is@pos@number\@tempa
      {%
        \vrefpagenum\@tempb{#2}%
        \is@pos@number\@tempb
            {%
              \ifcase\numexpr \@tempa -\@tempb+1\relax
              \or \or \else \expandafter \@thirdofthree \fi
              \@firstoftwo
            }%
            {\@secondoftwo}%
      }%
      {\@secondoftwo}%
}
%    \end{macrocode}
%  \end{macro}

%
%
%  \subsubsection{Compatibility with older \LaTeX{} formats}
%
%
%  \begin{macro}{\labelformat}
%  \begin{macro}{\Ref}
%  \begin{macro}{\refstepcounter}
%    We don't need to define \cs{labelformat} and \cs{Ref} or change the
%    definition of \cs{refstepcounter} any longer because this is now
%    done in the \LaTeX{} kernel. However, if this package is used
%    together with an older kernel, this is not true, so for this
%    special case we keep the definitions.
%    \begin{macrocode}
\ifx\labelformat\@undefined  % assume we are in an older kernel
  \def\labelformat#1{\expandafter\def\csname p@#1\endcsname##1}
  \DeclareRobustCommand\Ref[1]{\protected@edef\@tempa{\ref{#1}}%
     \expandafter\MakeUppercase\@tempa}
  \def\refstepcounter#1{\stepcounter{#1}%
      \protected@edef\@currentlabel
         {\csname p@#1\expandafter\endcsname\csname the#1\endcsname}}
\fi
%    \end{macrocode}
%  \end{macro}
%  \end{macro}
%  \end{macro}
%
% \changes{v1.6e}{2020/07/25}{Move to handle
% the language-specific reference formats. (gh/352)}
%    \begin{macrocode}
\ProcessOptions*
%    \end{macrocode}
%
%    \begin{macrocode}
%</package>
%    \end{macrocode}
% \Finale
%
\endinput