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
|
% \iffalse meta-comment
%
% Copyright 1993 1994 1995 1996 1997 1998 1999 2000 2001 2002 2003
% The LaTeX3 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.3
% of this license or (at your option) any later version.
% The latest version of this license is in
% http://www.latex-project.org/lppl.txt
% and version 1.3 or later is part of all distributions of LaTeX
% version 2003/12/01 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-2004 Frank Mittelbach, all rights reserved.
%%
%% For additions or updates to the language options please contact
%% the author at
%%
%% frank.mittelbach@latex-project.org
%%
%% In case of bugs, please use "latexbug.tex" (category tools) to report them.
%%
%
%<package>\NeedsTeXFormat{LaTeX2e}[1995/05/16]
%<package>\ProvidesPackage{varioref}
%<package> [2004/02/27 v1.4i package for extended references (FMi)]
% \fi
%
% \CheckSum{1683}
%% \CharacterTable
%% {Upper-case \A\B\C\D\E\F\G\H\I\J\K\L\M\N\O\P\Q\R\S\T\U\V\W\X\Y\Z
%% Lower-case \a\b\c\d\e\f\g\h\i\j\k\l\m\n\o\p\q\r\s\t\u\v\w\x\y\z
%% Digits \0\1\2\3\4\5\6\7\8\9
%% Exclamation \! Double quote \" Hash (number) \#
%% Dollar \$ Percent \% Ampersand \&
%% Acute accent \' Left paren \( Right paren \)
%% Asterisk \* Plus \+ Comma \,
%% Minus \- Point \. Solidus \/
%% Colon \: Semicolon \; Less than \<
%% Equals \= Greater than \> Question mark \?
%% Commercial at \@ Left bracket \[ Backslash \\
%% Right bracket \] Circumflex \^ Underscore \_
%% Grave accent \` Left brace \{ Vertical bar \|
%% Right brace \} Tilde \~}
%%
%
%
% \changes{v1.0a}{1993/12/06}{Upgrade to LaTeX2e}
% \changes{v1.0g}{1994/05/27}{Use \cmd\DeclareRobustCommand}
%
%
% \title{The \texttt{varioref} package\thanks{This file
% has version number \fileversion, last
% revised \filedate.}}
% \author{Frank Mittelbach}
% \date{\filedate}
%
% \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}
%
% \section{Introduction}
%
% In many cases it is helpful when refering 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{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 refering 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| and except that
% it will produce the string that is saved in |\reftextcurrent| if
% label and reference fall onto the same page. 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.
%
% You can put 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. If 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.
%
%
% \subsection{Additions in 1998}
%
% \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
% \texttt{ifthen} package)
%\begin{verbatim}
% \newcommand\amusingversion[2]{%
% \vrefpagenum\firstnum{#1}%
% \vrefpagenum\secondnum{#2}%
% the definition%
% \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 the are on different pages.
%
% \subsection{Additions in 2001}
%
% 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 is to late to change the default behaviour I've added star
% versions of the macros which do not add any space before the
% generated text (they do nevertheless remove space at the left).
%
%
% \subsection{Additions in 2002}
%
% \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. If, for
% example, references to equations are always to be typeset as
% ``equation (\textit{number})'', one has to code
% ``\verb=equation (\ref{=\textit{key}\verb=})=''. With |\labelformat|
% the \texttt{varioref} package offers a possibility to generate such
% frills automatically. The command takes two arguments: the first is
% the name of a counter and the second is its representation when
% referenced. This means that for a successful usage, one has to know
% the counter name being used for generating the label, though in
% practice this should not pose a problem. The current counter number
% is picked up as an argument.
% Here are two examples:
%\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). To overcome this problem \texttt{varioref}
% introduces the commands |\Ref| and |\Vref| that behave like
% |\ref| and |\{vref| except that they uppercase the first token
% of the generated string.
%
% To make |\Ref| or |\Vref| work properly the very first token in
% the second argument of |\labelformat| has to be a simple \textsc{ascii}
% 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)
% 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}|.
%
% \DescribeMacro\vpagerefnum
% 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 |\vpagerefnum| 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{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.)
% It also supports languages currently not in babel;
% check the section on options later on.
% You can also modify some or all of the strings by redefining the
% following commands.
%\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). Similarily |\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\vreftextvario 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 seens |\vref| or
% |\vpageref| commands. As an example see the definitions of
% |\reftextbefore| etc.\ \vpageref[below]{reftextbefore}.
%
%
% \subsection{Additions in 1998}
%
% The commands |\vrefrange| and |\vpagerefrange| produce their text
% 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}|''.
%
%
% \section{Options}
%
% As mentioned above the package supports all standard options offered
% by the Babel system to customize the strings produced. In addition it
% offers the option \texttt{draft} to turn error messages into warnings
% during development. The defaul \texttt{final} produces error message
% when a generated string falls onto a page boundary (see next section).
%
%
% \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 \texttt{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 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 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.
%
% \StopEventually{\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
% \texttt{docstrip} program.
% \begin{macrocode}
%<*driver>
\documentclass{ltxdoc}
\usepackage{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}
%
% \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 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}}%
}}
% \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}}%
}}
% \end{macrocode}
% \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}}%
}}
% \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}}%
}}
% \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.}
% \begin{macrocode}
\DeclareOption{brazil}
{\vref@addto\extrabrazil{%
\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{\vref@stringwarning\reftextpagerange
on pages~\pageref{#1}--\pageref{#2}}%
\def\reftextlabelrange#1#2{\vref@stringwarning\reflabelpagerange
\ref{#1} to~\ref{#2}}%
}}
% \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}}%
}}
% \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}}%
}}
\DeclareOption{croatian}
{\vref@excuse{croatian}%
\vref@addto\extrascroatian{%
\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}}%
}}
% \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}}%
}}
% \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}}%
}}
% \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}}
% \begin{macrocode}
\def\reftextpagerange#1#2{op pagina's~\pageref{#1}--\pageref{#2}}%
\def\reftextlabelrange#1#2{\ref#1--\ref{#2}}%
}}
% \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}}%
}}
\DeclareOption{esperanto}
{\vref@excuse{esperanto}%
\vref@addto\extrasesperanto{%
\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}}%
}}
% \end{macrocode}
% The finnish strings were suggested by Matti Rintala
% (\verb=bitti@cs.tut.fi=).
% \changes{v1.0m}{1994/09/23}{Added 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{\vref@stringwarning\reftextpagerange
on pages~\pageref{#1}--\pageref{#2}}%
\def\reftextlabelrange#1#2{\vref@stringwarning\reflabelpagerange
\ref{#1} to~\ref{#2}}%
}}
% \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}}%
}}
% \end{macrocode}
% Galician defaults are provided by Matthias Moebius\\
% (\texttt{Matthias.Moebius@uni-konstanz.de}).
% \changes{v1.1f}{1998/04/25}{Added galician defaults}
% \begin{macrocode}
\DeclareOption{galician}
{\vref@excuse{galician}%
\vref@addto\extrasgalician{%
\def\reftextfaceafter {na seguinte p\'axina}%
\def\reftextfacebefore{na p\'agina anterior}%
\let\reftextafter \reftextfaceafter
\let\reftextbefore \reftextfacebefore
\def\reftextcurrent {nesta p\'axina}%
\def\reftextfaraway#1{na p\'axina~\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}}%
}}
% \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}
% \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 Seiten~\pageref{#1}--\pageref{#2}}%
\def\reftextlabelrange#1#2{\ref{#1} bis~\ref{#2}}%
}}
% \end{macrocode}
% \changes{v1.2d}{2000/01/11}{Added ngerman defaults (identical to german)}
% 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 Seiten~\pageref{#1}--\pageref{#2}}%
\def\reftextlabelrange#1#2{\ref{#1} bis~\ref{#2}}%
}}
% \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}}%
}}
% \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}
% \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{\vref@stringwarning\reftextpagerange
on pages~\pageref{#1}--\pageref{#2}}%
\def\reftextlabelrange#1#2{\vref@stringwarning\reflabelpagerange
\ref{#1} to~\ref{#2}}%
}}
% \end{macrocode}
% 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 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 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}
% \begin{macrocode}
\DeclareOption{magyar}
{\vref@addto\extrasmagyar{%
\def\reftextfaceafter {a k\"o\-vet\-kez\H{o} ol\-da\-lon}%
\def\reftextfacebefore{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}}%
}%
% \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}}%
}}
\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}}%
}}
% \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}}
% \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 \pageref{#1}~stronie}%
\def\reftextpagerange#1#2{na stronach~\pageref{#1}--\pageref{#2}}%
\def\reftextlabelrange#1#2{od~\ref{#1} do~\ref{#2}}%
}}
% \end{macrocode}
% The portuguese 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}
% \begin{macrocode}
\DeclareOption{portuges}
{\vref@addto\extraportuges{%
\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}}%
}}
\DeclareOption{romanian}
{\vref@excuse{romanian}%
\vref@addto\extrasromanian{%
\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}}%
}}
% \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 russion 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}}%
}}
% \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}}%
}}
% \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}}%
}}
% \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}
% \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}}%
}}
% \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}}%
}}
\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}}%
}}
% \end{macrocode}
% We support francais as an alternative to french since people
% might be used to it, but we discurrage 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}
%
% 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
% \texttt{babel} package).
% \begin{macrocode}
\ExecuteOptions{english,final}
\ProcessOptions*
% \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 which means: do not add a
% space in front of the generated text---ever.
% \begin{macrocode}
\DeclareRobustCommand\vpageref{\@ifstar
{\let\vref@space\relax\vp@geref}%
{\let\vref@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}
% \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 \texttt{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).
% \begin{macrocode}
\let\vref@space\space
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\@vpageref}
% More parsing\ldots
% \begin{macrocode}
\def\@vpageref[#1]{\@ifnextchar[%
% \end{macrocode}
% The default for the second optional argument is a space which is
% prefixed by |\unskip| to get rid of any leading space inserted
% already.
% \changes{v1.0h}{1994/06/11}{Pass first argument in both cases}
% \changes{v1.0i}{1994/06/20}{Do it correctly}
% \begin{macrocode}
{\@@vpageref{#1}}{\@@vpageref{#1}[\unskip\vref@space]}}
% \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 and also
% removes any leading space.
% \begin{macrocode}
\leavevmode\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 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 \texttt{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}
% \changes{v1.1g}{1998/05/10}{Test if inside AMS display (pr2175)}
% Inside displays of the \texttt{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\else
% \end{macrocode}
% If both points do not fall onto the same page with either issue
% an error or a warning message.
% \changes{v1.0g}{1994/05/27}{Looping pages shown in wrong order}
% \begin{macrocode}
\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. Since we have removed
% any leading space we now insert a space (unless this was the star
% form of the command) and then compare the two
% page references.
% \begin{macrocode}
\vref@space
\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 preceeding space.
% \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
#2%
% \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 represend 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
% substract two from the current value of |\@tempcnta| (which was
% set to one higher as the reference page number). Note, that
% substraction 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.
% Recall that this is a macro which has the user label as an
% argument.
% \begin{macrocode}
\else
\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}
{\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 \texttt{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 @vr}%
}
% \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 uneffected by
% \texttt{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}
% \changes{v1.3a}{2001/04/12}{Scan for star form}
% We start by scanning for a star form in which case we do not put
% any space before the generated text (only remove some).
% \begin{macro}{\vr@f}
% \begin{macrocode}
\DeclareRobustCommand\vref{\@ifstar
{\let\vref@space\relax\vr@f}%
{\let\vref@space\nobreakspace\vr@f}}
% \end{macrocode}
% And now we do the real work\ldots
% \changes{v1.3c}{2001/09/04}{Correct typo in name}
% \begin{macrocode}
\def\vr@f#1{%
% \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}}
%
% Above comments all refer to the earlier versions where there was
% no posibility to suppress the space at all. By now we have
% |\vref*| and |\vpageref*| to suppress the in internally generated
% space by redefining |\vref@space| appropriately.
% \begin{macrocode}
\leavevmode\unskip\vref@space
\ref{#1}%
% \end{macrocode}
% That means we have have to use |\vpageref| and not the internal
% |\@vpageref| --- otherwise we would pick up the
% ``current'' definition for |\vref@space| instead of setting it
% back to |\space|.
% \changes{v1.4c}{2002/06/18}{Use \cs{vpageref} not \cs{@vpageref} (pr/3403)}
% \begin{macrocode}
\vpageref[\unskip]{#1}}
% \end{macrocode}
% \end{macro}
% \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 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 |\if| test (i.e., in an expandable way) since we know for
% sure that it can not start with a digit
% \begin{macrocode}
\if0#10%
% \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|.
% \begin{macrocode}
\def\fullref#1{\ref{#1} \reftextfaraway{#1}}
% \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 associates 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.
% \begin{macrocode}
\def\vref@pagenum#1#2{%
\@ifundefined{r@#2}{\@namedef{r@#2}{{??}{??}}}{}%
\edef#1{\expandafter\expandafter\expandafter
\@cdr\csname r@#2\endcsname
\@nil}%
}
% \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}
% 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}
% \begin{macrocode}
\newcommand\vrefrange[3][\reftextcurrent]
{\reftextlabelrange{#2}{#3} \vpagerefrange[#1]{#2}{#3}}
% \end{macrocode}
% \end{macro}
%
%
% \subsection{An extension of counter referencing}
%
% \begin{macro}{\refstepcounter}
% \changes{v1.4a}{2002/02/24}{Macro redefined}
%
% At the moment a reference to a counter |foo| will generate the
% equivalent of |\p@foo\thefoo| although not quite in this form. For
% some applications it would be nice of one could have |\thefoo| being
% an argument to |\p@foo| to be able to put material before and after
% the number generated by |\thefoo|. This can be easily achieved with
% a small change to one of the kernel commands as follows:
% \begin{macrocode}
\def\refstepcounter#1{\stepcounter{#1}%
\protected@edef\@currentlabel
{\csname p@#1\expandafter\endcsname\csname the#1\endcsname}%
}
% \end{macrocode}
% The trick is to ensure that |\csname the#1\endcsname| is turned into
% a single token before |\p@...| is expanded further. This way, if the
% |\p@...| command is a macro with one argument it will receive
% |\the...|. With the kernel code (i.e., without the |\expandafter|)
% it will instead pick up |\csname| which would be disastrous.
%
% Using |\expandafter| instead of braces delimiting the argument is
% better because, assuming that the |\p@...| command is not defined as
% a macro with one argument, the braces will stay and prohibit kerning
% that might otherwise happen between the glyphs generated by
% |\the...| and surrounding glyphs.
% \end{macro}
%
% \begin{macro}{\labelformat}
% \changes{v1.4a}{2002/02/24}{Macro added}
% A shortcut to set the |\p@...| macro for a counter. It will pick
% up the counter representation as an argument so that it can be
% specially formatted.
% \begin{macrocode}
\def\labelformat#1{\expandafter\def\csname p@#1\endcsname##1}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\Ref}
% \changes{v1.4a}{2002/02/24}{Macro added}
% This macro expands the result of |\ref| and then uppercases the
% first token. Only useful if the label was generated via
% |\labelformat| and contains some lower case letter at its start. If
% the label starts with a complicated construct (e.g., an accented
% letter) one has to surround everything that needs uppercasing in
% a brace group in the definition of |\labelformat|.\footnote{There
% is one problem with this approach: the braces are kept in a
% normal \texttt{\textbackslash ref} which might spoil kerning.
% Perhaps one day this needs redoing.}
% \begin{macrocode}
\DeclareRobustCommand\Ref[1]{\protected@edef\@tempa{\ref{#1}}%
\expandafter\MakeUppercase\@tempa}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\Vref}
% \changes{v1.4a}{2002/02/24}{Macro added}
% \begin{macro}{\Vr@f}
% \changes{v1.4a}{2002/02/24}{Macro added}
% |\Vref| is the counterpart to |\vref| with |\ref| replaced by
% |\Ref| in its definition.
% \begin{macrocode}
\DeclareRobustCommand\Vref{\@ifstar
{\let\vref@space\relax\Vr@f}%
{\let\vref@space\nobreakspace\Vr@f}}
\def\Vr@f#1{%
\leavevmode\unskip\vref@space
\Ref{#1}%
\@vpageref[\unskip]{#1}}
% \end{macrocode}
% \end{macro}
% \end{macro}
%
% \begin{macrocode}
%</package>
% \end{macrocode}
% \Finale
%
\endinput
|