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 2714 2715 2716 2717 2718 2719 2720 2721 2722 2723 2724 2725 2726 2727 2728 2729 2730 2731 2732 2733 2734 2735 2736 2737 2738 2739 2740 2741 2742 2743 2744 2745 2746 2747 2748 2749 2750 2751 2752 2753 2754 2755 2756 2757 2758 2759 2760 2761 2762 2763 2764 2765 2766 2767 2768 2769 2770 2771 2772 2773 2774 2775 2776 2777 2778 2779 2780 2781 2782 2783 2784 2785 2786 2787 2788 2789 2790 2791 2792 2793 2794 2795 2796 2797 2798 2799 2800 2801 2802 2803 2804 2805 2806 2807 2808 2809 2810 2811 2812 2813 2814 2815 2816 2817 2818 2819 2820 2821 2822 2823 2824 2825 2826 2827 2828 2829 2830 2831 2832 2833 2834 2835 2836 2837 2838 2839 2840 2841 2842 2843 2844 2845 2846 2847 2848 2849 2850 2851 2852 2853 2854 2855 2856 2857 2858 2859 2860 2861 2862 2863 2864 2865 2866 2867 2868 2869 2870 2871 2872 2873 2874 2875 2876 2877 2878 2879 2880 2881 2882 2883 2884 2885 2886 2887 2888 2889 2890 2891 2892 2893 2894 2895 2896 2897 2898 2899 2900 2901 2902 2903 2904 2905 2906 2907 2908 2909 2910 2911 2912 2913 2914 2915 2916 2917 2918 2919 2920 2921 2922 2923 2924 2925 2926 2927 2928 2929 2930 2931 2932 2933 2934 2935 2936 2937 2938 2939 2940 2941 2942 2943 2944 2945 2946 2947 2948 2949 2950 2951 2952 2953 2954 2955 2956 2957 2958 2959 2960 2961 2962 2963 2964 2965 2966 2967 2968 2969 2970 2971 2972 2973 2974 2975 2976 2977 2978 2979 2980 2981 2982 2983 2984 2985 2986 2987 2988 2989 2990 2991 2992 2993 2994 2995 2996 2997 2998 2999 3000 3001 3002 3003 3004 3005 3006 3007 3008 3009 3010 3011 3012 3013 3014 3015 3016 3017 3018 3019 3020 3021 3022 3023 3024 3025 3026 3027 3028 3029 3030 3031 3032 3033 3034 3035 3036 3037 3038 3039 3040 3041
|
\iffalse; awk '/S[H]ELL1/' lineno.sty|sh;exit;
... see bottom for .tex documentation ...
Macro file lineno.sty for LaTeX: attach line numbers, refer to them.
\fi
\def\fileversion{v4.1c} \def\filedate{2005/01/10} %VERSION
%%% Copyright 1995--2003 Stephan I. B"ottcher <boettcher@physik.uni-kiel.de>;
%%% Copyright 2002--2004 Uwe L"uck, http://www.contact-ednotes.sty.de.vu
%%% for version 4 and code from former Ednotes bundle
%%% --author-maintained.
%%%
%%% This file can be redistributed and/or modified under
%%% the terms of the LaTeX Project Public License; either
%%% version 1.3a of the License, or any later version.
%%% The latest version of this license is in
%%% http://www.latex-project.org/lppl.txt
%%% We did our best to help you, but there is NO WARRANTY.
%
%%% $Id: lineno.sty,v 3.14.2.2 2004/09/13 19:30:39 stephan Exp $ %% was v4.00.
% \title{\texttt{\itshape
%% %% (UL 2004/10/09:) Italic TT is evil
%% %% ... or nice front page layout!?
%%
% lineno.sty \ \fileversion\ \filedate
% \unskip}\\\ \\
% A \LaTeX\ package to attach
% \\ line numbers to paragraphs
% \unskip}\author{%
% Stephan I. B\"ottcher
% \\ Uwe L\"uck
% \unskip}\date{%
% boettcher@physik.uni-kiel.de
% \\ http://www.contact-ednotes.sty.de.vu
%% \\ stephan@nevis.columbia.edu
%% \\ Stephan.Boettcher@cern.ch
% \\}
%
% \documentclass[a4paper,12pt]{article}%D
% \usepackage{lineno}%D
%% %% (New v4.00)
% \catcode`\_\active\let_~
%% %% Beware math!? (/New v4.00)
% \def~{\verb~}
% \let\lessthan<
% \catcode`\<\active
% \def<#1>{$\langle${\itshape#1}\/$\rangle$}
% \catcode`\|\active
%% (New v4.1: \tt star; in box anyway.)
% \def|#1{\ttfamily\string#1}
%% \def|#1{{\ttfamily\string#1}}
%% (/New v4.1)
% \newenvironment{code}
% {\par\runninglinenumbers
% \modulolinenumbers[1]%
% \linenumbersep.3em
% \footnotesize
% \def\linenumberfont
% {\normalfont\tiny\itshape}}
% {}
%% %% (New v4.00)
% {\makeatletter\gdef\scs#1{\texttt
% {\protect\@backslashchar#1}}}
% \def\old{\par\footnotesize}
%% %% (/New v4.00)
%% %% (New v4.1)
% {\catcode`\/\active
% \gdef\path{\begingroup\catcode`\/\active
% \let/\slash\dopath}
% \gdef\dopath#1{\slash\unpenalty#1\endgroup}}
%% %% (/New v4.1)
%
% \begin{document}%D
%% \DocInput{lineno}%D
% \pagewiselinenumbers
% \maketitle
% \tableofcontents
% \sloppy
%
%% %% New v4.00: `...section{%' + \unskip
% \section{%
% Introductions
%% %% New v4.00: `s'
% \unskip}
%
% (New v4.00) Parts of former first section
% have been rendered separate subsections for package
% version_v4.00. (/New v4.00)
%
% \subsection{%
% Introduction to versions $\textrm{v}\lessthan4$
% \unskip}
%
% This package provides line numbers on paragraphs.
% After \TeX\ has broken a paragraph into lines there will
% be line numbers attached to them, with the possibility to
% make references through the \LaTeX\ ~\ref~, ~\pageref~
% cross reference mechanism. This includes four issues:
% \begin{itemize}
% \item attach a line number on each line,
% \item create references to a line number,
% \item control line numbering mode,
% \item count the lines and print the numbers.
% \end{itemize}
% The first two points are implemented through patches to
% the output routine. The third by redefining ~\par~, ~\@par~
% and ~\@@par~. The counting is easy, as long as you want
% the line numbers run through the text. If they shall
% start over at the top of each page, the aux-file as well
% as \TeX s memory have to carry a load for each counted line.
%
% I wrote this package for my wife Petra, who needs it for
% transcriptions of interviews. This allows her to
% precisely refer to passages in the text. It works well
% together with ~\marginpar~s, but not too well with displaymath.
% ~\footnote~s are a problem, especially when they
% are split, but we may get there.
% (New v4.00 UL) Version v4.00 overcomes the problem, I believe.
% (/UL /New v4.00)
%
% lineno.sty works
% surprisingly well with other packages, for
% example, ~wrapfig.sty~. So please try if it
% works with whatever you need, and if it does,
% please tell me, and if it does not, tell me as
% well, so I can try to fix it.
%
% \subsection{%
% Introduction to versions v4.00 and v4.1 (UL)
% \unskip}
%
% lineno.sty has been maintained by Stephan until version_v3.14.
% From version_v4.00 onwards, maintenance is shifting towards
% Uwe L\"uck (UL), who is the author of v4\dots code and of v4\dots
% changes in documentation. This came about as follows.
%
% Since late 2002, Christian Tapp and Uwe L\"uck have employed
% lineno.sty for their ednotes.sty, a package supporting
% critical editions---cf.
% \begin{verse}\ttfamily
% http://www.homepages.ucl.ac.uk/\~{}ucgadkw/edmac/
% \end{verse}
% ---while you find ednotes.sty and surrounding files in
% CTAN folder \path{macros/latex/contrib/ednotes}.
%
% Soon, some weaknesses of lineno.sty showed up, mainly since
% Christian's critical editions (using ednotes.sty) needed lots
% of ~\linelabel~s and footnotes. (These weaknesses are due to
% weaknesses of \LaTeX's ~\marginpar~ mechanism that Stephan
% used for ~\linelabel~.) So we changed some lineno.sty
% definitions in some extra files, which moreover offered new
% features. We sent these files to Stephan, hoping he would take
% the changes into lineno.sty. However, he was too short of time.
%
% Writing a TUGboat article on Ednotes in 2004, we hoped to
% reduce the number of files in the Ednotes bundle and so asked
% Stephan again. Now he generously offered maintenance to me, so
% I could execute the changes on my own.
%
% The improvements are as follows:
% \begin{itemize}\item
% [(i)] Footnotes placement approaches intentions better
% (footnotes formerly liked to pile up at late pages).
% \item
% [(ii)] The number of ~\linelabel~s in one paragraph is no longer
% limited to 18.
% \item
% [(iii)] ~\pagebreak~, ~\nopagebreak~, ~\vspace~, and the star
% and optional versions of ~\\~ work as one would expect
% (section_\ref{s:MVadj}). %% Added for v4.1
% \item
% [(iv)] A command is offered which chooses the first line number
% to be printed in the margin
% (subsection_\ref{ss:Mod}). %% Added for v4.1
% \item
% [(v)] (New v4.1) \LaTeX\ tabular environments (optionally)
% get line numbers as well, and you can refer to them in the
% usual automatic way. (It may be considered a shortcoming that,
% precisely, \emph{rows} are numbered, not lines. See
% subsection_\ref{ss:Tab}.)
% \item
% [(vi)] We are moving towards referring to math items
% (subsection_\ref{ss:MathRef} and the hooks in
% subsection_\ref{ss:LL}).
% (/New v4.1)
% \end{itemize}
% (Thanks to Stephan for making this possible!)
%
% You may trace the earlier developments of these changes by
% requesting our files linenox0.sty, linenox1.sty, and
% lnopatch.sty. Most of our changes have been in linenox0.sty.
% Our linenox1.sty has extended linenox0.sty for one single
% purpose in a not very stable way.
%% (See ~\linenumberpar~ below).
% lnopatch.sty has done the first line number thing referred
% to in case_(iv) up to now.
% (New v4.1)
% Case_(v) earlier was provided by our edtab02.sty---now
% called `edtable.sty'.
% (/New v4.1)
%
% Ednotes moreover profits from Stephan's offer with regard
% to the documentation of our code which yielded these
% improvements formerly. This documentation now becomes
% printable, being part of the lineno.sty documentation.
%
% Of course, Stephan's previous lineno.sty versions were a great
% and ingenious work and exhibit greatest \TeX pertise. I never
% could have done this. I learnt a lot in studying the code when
% Christian pointed out strange output results and error
% messages, and there are still large portions of lineno.sty
% which I don't understand (consider only pagewise numbering of
% lines). Fortunately, Stephan has offered future help if
% needed.---My code for attaching line numbers to \emph{tabular
% environments} (as mentioned above, now still in
% edtable.sty) %% %% TODO
% developed from macros which Stephan and Christian experimented
% with in December 2002. Stephan built the basics.
% (However, I then became too proud to follow his advice only to
% use and modify longtable.sty.)
%
% There are some issues concerning use of counters on which I
% don't agree with Stephan and where I would like to change the
% code if lineno.sty is ``mine'' as Stephan offered. However,
% Stephan is afraid of compatibility problems from which, in
% particular, his wife could suffer in the near future. So he
% demanded that I change as little as possible for my first
% version. Instead of executing changes that I plan I just offer
% my opinions at the single occasions. I hope to get in touch
% this way with users who consider subtle features vital which I
% consider strange.
%
% On the other hand, the sections on improvements of the
% implementation have been blown up very much and may be tiring
% and litte understandable for mere \emph{users}. These users
% may profit from the present presentation just by jumping to
% sections_\ref{s:Opts} and_\ref{s:UserCmds}. There is a user's
% guide ulineno.tex which may be even more helpful, but it has
% not been updated for a while. %% TODO
%
% \subsection{%
% Availability
% \unskip}
%
% In case you have found the present file otherwise than from
% CTAN: A recent version and documentation of this package
% should be available from CTAN folder
% \path{macros/latex/contrib/lineno}.
% Or mail to one of the addresses at top of file.
%
% \subsection{%
% Introductory code
% \unskip}
%
% This style option is written for \LaTeXe, November 1994 or later,
% since we need the ~\protected@write~ macro.
%
% (New v4.00) And we use ~\newcommand*~ for
% controlling length of user macro arguments, which has been
% available since December 1994.
%%
\NeedsTeXFormat{LaTeX2e}[1994/12/01]
%% [1994/11/04]
\ProvidesPackage{lineno}
[\filedate\space line numbers on paragraphs \fileversion]
% (/New v4.00)
%%
%% History of versions:
%% v1.00 1995/03/31 SIB: first release for Petra's interview transcriptions
%% v1.01 1995/10/28 SIB: added ~pagewise~ mode
%% v1.02 1995/11/15 SIB: added ~modulo~ option
%% v1.03 1995/12/05 SIB: pagewise: try to reduce the hash-size requirements
%% v2.00 1995/12/06 SIB: .. it works, new user interface
%% v2.01 1996/09/17 SIB: put into CVS
%% v2.02 1997/03/17 SIB: add: \@reinserts, for footnotes
%% v2.04 1998/03/09 SIB: add: linenomath environment
%% v2.05 1998/04/26 SIB: add: prevgraf test
%% v2.06 1999/03/02 SIB: LPPL added
%% v3.00 1999/06/11 SiB: include the extension in the main file
%% v3.01 1999/08/28 SiB: \@reinserts -> \holdinginserts
%% v3.02 2000/03/10 SiB: \@LN@output
%% v3.03 2000/07/01 SiB: \@LN@ExtraLabelItems, hyperref
%% v3.04 2000/12/17 SiB: longtable compatibility.
%% v3.05 2001/01/02 SiB: [fleqn] detection.
%% v3.05a 2001/01/04 SiB: [fleqn] detection reverted for eqnarray.
%% v3.06 2001/01/17 SiB: [twocolumn] mode support.
%% v3.07 2001/07/30 SiB: [hyperref] option obsoleted.
%% v3.08 2001/08/02 SiB: linenomath wrapping for \[ \]
%% v3.08a 2001/08/04 SiB: linenomath wrapping for \[ \] fixed
%% v3.08b 2002/01/27 SiB: enquotation typo fix
%% v3.09 2003/01/14 SIB: hyperref detection fix
%% v3.10 2003/04/15 FMi: \MakeLineNo fix for deep boxes
%% v3.10a 2003/11/12 Uwe Lck: \lineref typo fix
%% v4.00 2004/09/02 UL: included linenox0, linenox1, lnopatch code with
%% documentation, usually indicated by `New v4.00';
%% discussions of old code, indicated by `UL';
%% LPPL v.1 -> LPPL v1.3, `program' -> `file';
%% first lines with \filedate and \fileversion,
%% according nawk lines; `November 1994 or later',
%% some earlier documentation typos (including a few
%% bad minus signs), { -> {% and } -> \unskip} at
%% line ends (so, e.g., alignment in TOC works); \scs.
%% 2004/09/03 UL: removed everything which indicated that the
%% present file were named `lineno4.sty'.
%% v4.1 2004/09/19 UL: Inserted Stephan's identification line, removed
%% some TODOs and remarks from v4.00.
%% 2004/10/04 UL: Added acknowledgement for Daniel Doherty;
%% `(New v4.00)' with [|\firstlinenumber]; changed
%% TODOs; Refining -> Redefining (\vadjust).
%% 2004/10/05 UL: ednmath0 -> mathrefs; \catcode`\~ -> \active;
%% \path; refined section on options `mathrefs';
%% changes in introduction.
%% 2004/10/06 UL: Changed/removed TODOs, e.g., for edtable.sty.
%% 2004/10/11 UL: Reminders: linenox0/1/lnopatch.sty obsolete;
%% \tt star in list of commands.
%% 2004/10/12 UL: Corrected blank lines in lineno.tex.
%% 2004/10/19 UL: Fixed minor typos; remark on \if@LN@edtable.
%% v4.1a 2004/11/07 UL: LPPL v1.3a.
%% v4.1b 2004/11/13 UL: Comment on \outputpenalty values.
%% v4.1c 2005/01/10 UL: Contact via http.
%%
%%
%% Acknowledgements:
%% v3.06: Donald Arseneau, pointed to mparhack.sty.
%% v3.07+: Frank Mittelbach, points out inconsistencies in the
%% user interface.
%% v3.10: Frank Mittelbach \MakeLineNo fix for deep boxes
%% v4.00: Daniel Doherty points out clash of \pagewise... with resetting
%% page number.
%
% \section{%
% Put the line numbers to the lines
% \unskip}
%
% (New v4.00) This section contained the most
% basic package code previously. For various purposes of
% version_4\dots, much of these basics have been to be modified.
% Much of my (UL's) reasoning on these modifications has been to
% be reported. Sorry, the present section has been blown up
% awfully thus and contains ramifications that may be difficult
% to trace. We add some ~\subsection~ commands in order to cope
% with the new situation. (/New v4.00)
%
% \subsection{%
% Basic code of lineno.sty \scs{output}
% \unskip}\label{ss:output}
%
% The line numbers have to be attached by the output
% routine. We simply set the ~\interlinepenalty~ to $-100000$.
% The output routine will be called after each line in the
% paragraph, except the last, where we trigger by ~\par~.
% The ~\linenopenalty~ is small enough to compensate a bunch of
% penalties (e.g., with ~\samepage~).
%
% (New v3.04) Longtable uses
% ~\penalty~$-30000$. The lineno penalty range was
% shrunk to $-188000 \dots -32000$. (/New v3.04)
% (UL) New values are listed below (11111f.). (/UL)
\newcount\linenopenalty\linenopenalty=-100000
% (UL) Hm. It is never needed below
% that this is a counter. ~\def\linenopenalty{-100000\relax}~
% would do. (I guess this consumes more memory, but it
% is more important to save counters than to save memory.)
% I was frightened by ~-\linenopenalty~ below, but indeed
% \TeX\ interprets the string ~--100000~ as 100000.
% Has any user or extension package writer ever called
% ~\linenopenalty=xxx~, or could I really change this?---The
% counter is somewhat faster than the macro. Together with the
% compatibility question this seems to support keeping the
% counter. (???) Note that Stephan chose ~\mathchardef~ below,
% so his choice above seems to have been deliberate. (/UL)
\mathchardef\linenopenaltypar=32000
% So let's make a hook to ~\output~, the direct way. The \LaTeX\
% macro ~\@reinserts~ puts the footnotes back on the page.
%
% (New v3.01) ~\@reinserts~ badly
% screws up split footnotes. The bottom part is
% still on the recent contributions list, and the
% top part will be put back there after the bottom
% part. Thus, since lineno.sty does not play well
% with ~\inserts~ anyway, we can safely experiment
% with ~\holdinginserts~, without making things
% much worse.
%
% Or that's what I thought, but: Just activating
% ~\holdinginserts~ while doing the ~\par~ will
% not do the trick: The ~\output~ routine may be
% called for a real page break before all line
% numbers are done, and how can we get control
% over ~\holdinginserts~ at that point?
%
% Let's try this: When the ~\output~ routine is
% run with ~\holdinginserts=3~ for a real page
% break, then we reset ~\holdinginserts~ and
% restart ~\output~.
%
% Then, again, how do we keep the remaining
% ~\inserts~ while doing further line numbers?
%
% If we find ~\holdinginserts~=$-3$ we activate it again
% after doing ~\output~. (/New v3.01)
%
% (New v3.02) To work with
% multicol.sty, the original output routine is now
% called indirectly, instead of being replaced.
% When multicol.sty changes ~\output~, it is a
% toks register, not the real thing. (/New v3.02)
%
% (New v4.00) Two further complications are added.
%%
%% TODO v4.2: Or three, ~\@nobreakfalse~ after ~\MakeLineNo~
%% for getting rid of ~\my@nopagebreak~.
% \begin{itemize}\item
% [(i)] Problems with footnotes formerly resulted from
% \LaTeX's ~\@reinserts~ in ~\@specialoutput~ which Stephan's
% ~\linelabel~ called via the ~\marginpar~ mechanism.
% \item
% [(ii)] \LaTeX\ commands using ~\vadjust~ formerly didn't work
% as one would have hoped. The problem is as follows:
% Printing the line number results from
% a box that the output routine inserts at the place of the
% ~\interlinepenalty~. ~\vadjust~ items appear \emph{above} the
% ~\interlinepenalty~ (\TeX book p._105). So ~\pagebreak~, e.g.,
% formerly sent the line number to the next page, while the
% penalty from ~\nopagebreak~ could not tie the following line,
% since it was screened off by the line number box.---Our trick
% is putting the ~\vadjust~ items into a list macro from which
% the output routine transfers them into the vertical list,
% below the line number box.
% \end{itemize}
% In this case_(ii), like in case_(i), footnotes would suffer
% if ~\holdinginserts~ were non-positive. Indeed, in both
% cases_(i) and_(ii) we tackle the footnote problem by extending
% that part of Stephan's output routine that is active when
% ~\holdinginserts~ is positive. This extension writes the line
% number ~\newlabel~ to the .aux file (which was formerly done
% under $~\holdinginserts~=-3$) and handles the ~\vadjust~
% items.---To trigger ~\output~ and its ~\linelabel~ or, resp.,
% ~\vadjust~ part, the list of signal penalties started
% immediately before is increased here (first for ~\linelabel~,
% second for postponed ~\vadjust~ items):
\mathchardef\@Mllbcodepen=11111
\mathchardef\@Mppvacodepen=11112
% (/New v4.00)
\let\@LN@output\output
\newtoks\output
\output=\expandafter{\the\@LN@output}
% Now we add two cases to Stephan's output routine. (New v4.00)
\@LN@output={%
\LineNoTest
\if@tempswa
%%
%% (UL) Learnt that even in def.s blank line means ~\par~.
%% to leave visual space in present file with having a
%% blank line neither in present nor in .tex file,
%% use double comment mark (`%%'). (/UL)
%%
% (New v4.00)
% We insert recognition of waiting ~\linelabel~ items---
%%
\ifnum\outputpenalty=-\@Mllbcodepen
\WriteLineNo
%%
% ---and of waiting ~\vadjust~ items:
%%
\else
\ifnum\outputpenalty=-\@Mppvacodepen
\PassVadjustList
\else
%%
% Now we give control back to Stephan.
% (/New v4.00)
\LineNoHoldInsertsTest
\if@tempswa
\if@twocolumn\let\@makecol\@LN@makecol\fi
\the\output
\ifnum\holdinginserts=-3
\global\holdinginserts 3
\fi
\else
\global\holdinginserts-3
\unvbox\@cclv
\ifnum\outputpenalty=10000\else
\penalty\outputpenalty
\fi
\fi
% (New v4.00)
% Two new ~\fi~s for the ~\linelabel~ and ~\vadjust~ tests---
%%
\fi
\fi
%%
% ---and the remaining is
%%%next three lines are
% Stephan's code again:
% (/New v4.00)
%%
\else
\MakeLineNo
\fi
}
% (New v4.00) Our new macros
% ~\WriteLineNo~ and ~\PassVadjustList~ will be dealt with in
% sections_\ref{s:LNref} and_\ref{ss:PVadj}. (/New v4.00)
%
% \subsection{%
% \scs{LineNoTest}
% \unskip}
%
% The float mechanism inserts ~\interlinepenalty~s during
% ~\output~. So carefully reset it before going on. Else
% we get doubled line numbers on every float placed in
% horizontal mode, e.g, from ~\linelabel~.
%
% Sorry, neither a ~\linelabel~ nor a ~\marginpar~ should
% insert a penalty, else the following linenumber
% could go to the next page. Nor should any other
% float. So let us suppress the ~\interlinepenalty~
% altogether with the ~\@nobreak~ switch.
%
% Since (ltspace.dtx, v1.2p)[1996/07/26], the ~\@nobreaktrue~ does
% it's job globally. We need to do it locally here.
\def\LineNoTest{%
\let\@@par\@@@par
\ifnum\interlinepenalty<-\linenopenaltypar
\advance\interlinepenalty-\linenopenalty
%%
% (UL) Following line renders previous line obsolete, doesn't it? (/UL)
%% %% TODO v4.2
\my@nobreaktrue
\fi
\@tempswatrue
\ifnum\outputpenalty>-\linenopenaltypar\else
\ifnum\outputpenalty>-188000\relax
\@tempswafalse
\fi
\fi
}
\def\my@nobreaktrue{\let\if@nobreak\iftrue}
% (UL) I would prefer ~\@LN@nobreaktrue~.---I thought here were
% another case of the save stack problem explained in \TeX book,
% p._301, namely through both local and global changing
% ~\if@nobreak~. However, ~\my@nobreak~ is called during
% ~\@LN@output~ only, while ~\@nobreaktrue~ is called by \LaTeX's
% ~\@startsection~ only. The latter never happens during
% ~\@LN@output~. So there is no local value of ~\if@nobreak~ on
% save stack when ~\@nobreaktrue~ acts, since ~\the\@LN@output~
% (where ~\@LN@output~ is a new name for the original ~\output~)
% is executed within a group (\TeX book p._21).
%%
%% 2004/09/19 Removed nonsense here according to Stephan 2004/09/02.
%%
% (/UL)
%
% \subsection{%
% \scs{LineNoHoldInsertsTest}
% \unskip}
%
% (New v4.00) No change here!
% Just a separate subsection. (/New v4.00)
\def\LineNoHoldInsertsTest{%
\ifnum\holdinginserts=3\relax
\@tempswafalse
\fi
}
%
% \subsection{%
% \scs{MakeLineNo}: Actually attach line number
% \unskip}\label{ss:MLN}
%
% We have to return all the page to the current page, and
% add a box with the line number, without adding
% breakpoints, glue or space. The depth of our line number
% should be equal to the previous depth of the page, in
% case the page breaks here, and the box has to be moved up
% by that depth.
%
% The ~\interlinepenalty~ comes after the ~\vadjust~ from a
% ~\linelabel~, so we increment the line number \emph{after}
% printing it. The macro ~\makeLineNumber~ produces the
% text of the line number, see section \ref{appearance}.
%
% (UL) I needed a while to understand
% the sentence on incrementing. Correctly: writing the
% ~\newlabel~ to the .aux file is triggered by the signal
% penalty that ~\end@float~ inserts via ~\vadjust~.
% However, this could be changed by our new ~\PostponeVadjust~.
% After ~\c@linenumber~ has been introduced as a \LaTeX\
% counter, it might be preferable that it behaved like standard
% \LaTeX\ counters which are incremented shortly before printing.
% But this may be of little practical relevance in this case,
% as ~\c@linenumber~ is driven in a very non-standard
% way.---However still, this behaviour of ~\c@linenumber~
% generates a problem with our edtable.sty.
%% \unskip---Before,
%% I thought that Stephan had reported his reasoning incorrectly
%% and rather did this because of his ~\resetlinenumber~ which
%% initializes ~\c@linenumber~ to 1 instead of 0---the latter is
%% usual with \LaTeX\ counters. Cf._additional comment at
%% ~\resetlinenumber~.
% (/UL).
%
% Finally we put in the natural ~\interlinepenalty~, except
% after the last line.
%
% (New v3.10) Frank Mittelbach points out that box255 may be
% less deep than the last box inside, so he proposes to
% measure the page depth with ~\boxmaxdepth=\maxdimen~.
% (/New v3.10)
%
% (UL, New v4.00) We also resume the matter of
% ~\vadjust~ items that was started in section_\ref{ss:output}.
%
% \TeX\ puts only nonzero interline
% penalties into the vertical list (\TeX book p._105), while
% lineno.sty formerly replaced the signal interline penalty by
% something closing with an explicit penalty of the value that
% the interline penalty would have without lineno.sty.
% This is usually 0. Now, explicit vertical penalties can be
% very nasty with respect to ~\nopagebreak~, e.g., a low (even
% positive) ~\widowpenalty~ may force a widow where you
% explicitly tried to forbid it by ~\nopagebreak~
% (see explanation soon below).
% The ~\nopagebreak~ we create here would never work if all
% those zero penalties were present.---On
% the other hand, we cannot just omit Stephan's zero penalties,
% because \TeX\ puts a penalty of 10000 after what lineno.sty
% inserts (\TeX book p._125). This penalty must be overridden
% to allow page breaks between ordinary lines. To revive
% ~\nopagebreak~, we therefore replace those zero (or low)
% penalties by penalties that the user demanded by
% ~\nopagebreak~.---This mechanism is not perfect and does not
% exactly restore the original \LaTeX\ working of ~\pagebreak~
% and ~\nopagebreak~. Viz., if there are several vertical
% penalties after a line which were produced by closely sitting
% ~\[no]pagebreak~s, without lineno.sty the lowest penalty would
% be effective (cf._\TeX book exercise_14.10). Our mechanism, by
% contrast, chooses the \emph{last} user-set penalty of the line
% as the effective one. It would not be very difficult to come
% more close to the original mechanism, but until someone urges
% us we will cling to the present simple way. You may consider an
% advantage of the difference between our mechanism and the
% original one that the user here can actually override low
% penalties by ~\nopagebreak~, which may be what a lay \LaTeX\
% user would expect.---Zero glue would do instead of zero
% penalty! This could make things easier. Maybe next time.
% (/UL, /New v4.00)
\def\MakeLineNo{%
\boxmaxdepth\maxdimen\setbox\z@\vbox{\unvbox\@cclv}%
\@tempdima\dp\z@ \unvbox\z@
\sbox\@tempboxa{\hbox to\z@{\makeLineNumber}}%
%%
% (New v4.00) Previously,
% \begin{old}\begin{verbatim}
% % \stepcounter{linenumber}%
% \end{verbatim}
% \end{old}
%% %% TODO: Still first `\begin{old}'?
% followed. (Of course, there was no
% comment mark; I put it there to make
% reading the actual code easy.)
%
% (UL) I wondered about this. Why not just
% ~\global\advance\c@linenumber\@ne~? %% TODO v4.1+: own line
% section_\ref{appearance}.
%% %% TODO v4.2: This: extra subsection!?
% OK, I keep it. (/UL)
%
% But then, our edtable.sty and its ~longtable~ option
% should use it as well. So use a shorthand supporting
% uniformity. You can even use it as a hook for choosing
% ~\global\advance\c@linenumber\@ne~ instead of our choice.
%%
\stepLineNumber
% (/New v4.00)
%%
\dp\@tempboxa=\@tempdima\ht\@tempboxa=\z@
\nointerlineskip\kern-\@tempdima\box\@tempboxa
%%
% (New v4.00)
% The line number has now been placed (it may be invisible
% depending on the modulo feature), so we can insert the
% ~\vadjust~ items. We cannot do this much later, because
% their right place is above the artificial interline
% penalty which Stephan's code will soon insert
% (cf._\TeX book p._105). The next command is just ~\relax~
% if no ~\vadjust~ items have been accumulated for the
% current line. Otherwise it is a list macro inserting
% the ~\vadjust~ items and finally resetting itself.
% (This is made in section_\ref{ss:PVadj} below.)
% If the final item is a penalty, it is stored so it can
% compete with other things about page breaking.
%%
\@LN@do@vadjusts
\count@\lastpenalty
%%
% At this place,
% \begin{old}\begin{verbatim}
% % \ifnum\outputpenalty=-\linenopenaltypar\else
% \end{verbatim}
% \end{old}
% originally followed. We need something \emph{before} the
% ~\else~:
%%
\ifnum\outputpenalty=-\linenopenaltypar
\ifnum\count@=\z@ \else
%%
% So final ~\pagebreak[0]~ or ~\nopagebreak[0]~ has no
% effect---but this will make a difference after headings only,
% where nobody should place such a thing anyway.
%%
\xdef\@LN@parpgbrk{\penalty\number\count@\relax
\gdef\noexpand\@LN@parpgbrk{\kern\z@}}%
%% %% TODO v4.1+: Stephan's advice
% That penalty will replace former ~\kern\z@~ in
% ~\linenumberpar~, see section_\ref{s:CtrlLN}.---A
% few days earlier, I tried to send just a penalty value.
% However, the ~\kern\z@~ in ~\linenumberpar~ is crucial,
% as I then found out. See below.---The final penalty is
% repeated, but this does no harm. (It would not be very
% difficult to avoid the repeating, but it may even be
% less efficient.) It may be repeated due to the previous
% ~\xdef~, but it may be repeated as well below in the
% present macro where artificial interline penalty is to
% be overridden.
%%
\fi
\else
%%
% (/New v4.00)
%%
\@tempcnta\outputpenalty
\advance\@tempcnta -\linenopenalty
%%
% (New v4.00)
% \begin{old}\begin{verbatim}
% % \penalty\@tempcnta
% \end{verbatim}
% \end{old}
% followed previously. To give ~\nopagebreak~ a chance,
% we do
%%
\penalty \ifnum\count@<\@tempcnta \@tempcnta \else \count@ \fi
%%
% instead.---In linenox0.sty, the ~\else~ thing once was omitted.
% Sergei Mariev's complaint (thanks!) showed that it is vital
% (see comment before ~\MakeLineNo~).
% The remaining ~\fi~ from previous package version closes the
% ~\ifnum\outputpenalty~\dots
% (/New v4.00)
%%
\fi
}
% (New v4.00)
\newcommand\stepLineNumber{\stepcounter{linenumber}}
% For reason, see use above. (/New v4.00)
%% %% TODO v4.2: ~\newcommand~ more often!?
%
% \section{%
% Control line numbering
% \unskip}\label{s:CtrlLN}
%
% The line numbering is controlled via ~\par~. \LaTeX\
% saved the \TeX-primitive ~\par~ in ~\@@par~. We push it
% one level further out, and redefine ~\@@par~ to insert
% the ~\interlinepenalty~ needed to trigger the
% line numbering. And we need to allow pagebreaks after a
% paragraph.
%
% New (2.05beta): the prevgraf test. A paragraph that ends with a
% displayed equation, a ~\noindent\par~ or ~wrapfig.sty~ produce empty
% paragraphs. These should not get a spurious line number via
% ~\linenopenaltypar~.
\let\@@@par\@@par
\newcount\linenoprevgraf
% (UL) And needs ~\linenoprevgraf~
% to be a counter? Perhaps there may be a paragraph having
% thousands of lines, so ~\mathchardef~ doesn't suffice (really??).
%%
%% %% TODO: limitations of lines per paragraph elsewhere?
%% %% Signal penalties, e.g.!? ~\deadcycles~!?
%%
% A macro ending on ~\relax~ might suffice, but would be
% somewhat slow. I think I will use ~\mathchardef~ next time.
% Or has any user used ~\linenoprevgraf~? (/UL)
\def\linenumberpar{\ifvmode\@@@par\else\ifinner\@@@par\else
\advance\interlinepenalty \linenopenalty
\linenoprevgraf\prevgraf
\global\holdinginserts3%
\@@@par
\ifnum\prevgraf>\linenoprevgraf
\penalty-\linenopenaltypar
\fi
%%
% (New v4.00)
% \begin{old}\begin{verbatim}
% % \kern\z@
% \end{verbatim}
% \end{old}
% was here previously. What for?
% According to \TeX book p._125, Stephan's
% interline penalty is changed into 10000. At the end of a
% paragraph, the ~\parskip~ would follow that penalty of 10000,
% so there could be a page break neither at the
% ~\parskip~ nor at the ~\baselineskip~ (\TeX book p. 110)---so
% there could never be a page break between two paragraphs.
% So something must screen off the 10000 penalty.
% Indeed, the ~\kern~ is a place to break.
% (Stephan once knew this: see `allow pagebreaks' above.)
%
% Formerly, I tried to replace ~\kern\z@~ by
% \begin{old}\begin{verbatim}
% % \penalty\@LN@parpgpen\relax
% \end{verbatim}
% \end{old}
% ---but this allows a page break after heading. So:
%%
\@LN@parpgbrk
%%
% After heading, ~\kern\z@~ resulting from previous line
% (see below) is followed by ~\write~ or ~\penalty10000~,
% so causes no page break.
%
% These and similar changes were formerly done by linenox1.sty.
% (/New v4.00)
%%
\global\holdinginserts0%
\advance\interlinepenalty -\linenopenalty
\fi\fi
}
%%
%% \global\let\@LN@parpgpen\z@ %% UL 2004/08/11 %% TODO v4.2: remove.
%%
% (New v4.00) Initialize ~\@LN@parpgbrk~:
\gdef\@LN@parpgbrk{\kern\z@}
% (/New v4.00)
%
% The basic commands to enable and disable line numbers.
% ~\@par~ and ~\par~ are only touched, when they are ~\let~
% to ~\@@@par~/~\linenumberpar~. The line number may be
% reset to 1 with the star-form, or set by an optional
% argument ~[~<number>~]~.
%
% (New v4.00) We add ~\ifLineNumbers~ etc.\ since
% a number of our new adjustments need to know whether
% linenumbering is active. This just provides a kind of
% shorthand for ~\ifx\@@par\linenumberpar~; moreover it is
% more stable: who knows what may happen to ~\@@par~?---A
% caveat: ~\ifLineNumbers~ may be wrong. E.g., it may be
% ~\iffalse~ where it acts, while a ~\linenumbers~ a few
% lines below---in the same paragraph---brings about that
% the line where the ~\ifLineNumbers~ appears gets a
% marginal number.
%% Better implementation suggested below.
\newif\ifLineNumbers \LineNumbersfalse
\def\linenumbers{\LineNumberstrue
\let\@@par\linenumberpar
% \begin{old}\begin{verbatim}
% % \def\linenumbers{\let\@@par\linenumberpar
% \end{verbatim}
% \end{old}
% (/New v4.00)
%%
\ifx\@par\@@@par\let\@par\linenumberpar\fi
\ifx\par\@@@par\let\par\linenumberpar\fi
\@ifnextchar[{\resetlinenumber}%]
{\@ifstar{\resetlinenumber}{}}%
}
% (New v4.00)
\def\nolinenumbers{\LineNumbersfalse
\let\@@par\@@@par
% \begin{old}\begin{verbatim}
% % \def\nolinenumbers{\let\@@par\@@@par
% \end{verbatim}
% \end{old}
% (/New v4.00)
%%
\ifx\@par\linenumberpar\let\@par\@@@par\fi
\ifx\par\linenumberpar\let\par\@@@par\fi
}
% (New v4.00) Moreover, it is useful to switch to
% ~\nolinenumbers~ in ~\@arrayparboxrestore~. We postpone this
% to section_\ref{ss:ReDef} where we'll have an appending macro
% for doing this. (/New v4.00)
%
% What happens with a display math? Since ~\par~ is not executed,
% when breaking the lines before a display, they will not get
% line numbers. Sorry, but I do not dare to change
% ~\interlinepenalty~ globally, nor do I want to redefine
% the display math environments here.
% \begin{displaymath}
% display \ math
% \end{displaymath}
% See the subsection below, for a wrapper environment to make
%% TODO 4.1+: which? \ref!?
% it work. But that requires to wrap each and every display
% in your LaTeX source.
%
% The next two commands are provided to turn on line
% numbering in a specific mode. Please note the difference:
% for pagewise numbering, ~\linenumbers~ comes first to
% inhibit it from seeing optional arguments, since
% re-/presetting the counter is useless.
\def\pagewiselinenumbers{\linenumbers\setpagewiselinenumbers}
\def\runninglinenumbers{\setrunninglinenumbers\linenumbers}
% Finally, it is a \LaTeX\ style, so we provide for the use
% of environments, including the suppression of the
% following paragraph's indentation.
%
% (UL) I'm drawing the following
% private thoughts of Stephan's to publicity so that others may
% think about them---or to remind myself of them in an efficient
% way. (/UL)
%% UL changed `%%%' to `% %' below.
% \begin{old}\begin{verbatim}
% % TO DO: add \par to \linenumbers, if called from an environment.
% % To DO: add an \@endpe hack if \linenumbers are turned on
% % in horizontal mode. {\par\parskip\z@\noindent} or
% % something.
% \end{verbatim}
% \end{old}
\@namedef{linenumbers*}{\par\linenumbers*}
\@namedef{runninglinenumbers*}{\par\runninglinenumbers*}
\def\endlinenumbers{\par\@endpetrue}
\let\endrunninglinenumbers\endlinenumbers
\let\endpagewiselinenumbers\endlinenumbers
\expandafter\let\csname endlinenumbers*\endcsname\endlinenumbers
\expandafter\let\csname endrunninglinenumbers*\endcsname\endlinenumbers
\let\endnolinenumbers\endlinenumbers
%
% \subsection{%
% Display math
% \unskip}
%
% Now we tackle the problem to get display math working.
% There are different options.
% \begin{enumerate}\item[
% 1.] Precede every display math with a ~\par~.
% Not too good.
% \item[
% 2.] Change ~\interlinepenalty~ and associates globally.
% Unstable.
% \item[
% 3.] Wrap each display math with a ~{linenomath}~
% environment.
% \end{enumerate}
% We'll go for option 3. See if it works:
% \begin{linenomath}
% \begin{equation}
% display \ math
% \end{equation}
% \end{linenomath}
% The star form ~{linenomath*}~ should also number the lines
% of the display itself,
% \begin{linenomath*}
% \begin{eqnarray}
% multi && line \\
% display && math \\
% &
% \begin{array}{c}
% with \\
% array
% \end{array}
% &
% \end{eqnarray}
% \end{linenomath*}
% including multline displays.
%
% First, here are two macros to turn
% on linenumbering on paragraphs preceeding displays, with
% numbering the lines of the display itself, or without.
% The ~\ifx..~ tests if line numbering is turned on. It
% does not harm to add these wrappers in sections that are
% not numbered. Nor does it harm to wrap a display
% twice, e.q, in case you have some ~{equation}~s wrapped
% explicitely, and later you redefine ~\equation~ to do it
% automatically.
%
% (UL) Newly, we could replace first lines
% by ~\ifLineNumbers~. (/UL)
\newcommand\linenomathNonumbers{%
\ifx\@@par\@@@par\else
\ifnum\interlinepenalty>-\linenopenaltypar
\global\holdinginserts3%
\advance\interlinepenalty \linenopenalty
\advance\predisplaypenalty \linenopenalty
\fi
\fi
\ignorespaces
}
\newcommand\linenomathWithnumbers{%
\ifx\@@par\@@@par\else
\ifnum\interlinepenalty>-\linenopenaltypar
\global\holdinginserts3%
\advance\interlinepenalty \linenopenalty
\advance\predisplaypenalty \linenopenalty
\advance\postdisplaypenalty \linenopenalty
\advance\interdisplaylinepenalty \linenopenalty
\fi
\fi
\ignorespaces
}
% The ~{linenomath}~ environment has two forms, with and
% without a star. The following two macros define the
% environment, where the stared/non-stared form does/doesn't number the
% lines of the display or vice versa.
\newcommand\linenumberdisplaymath{%
\def\linenomath{\linenomathWithnumbers}%
\@namedef{linenomath*}{\linenomathNonumbers}%
}
\newcommand\nolinenumberdisplaymath{%
\def\linenomath{\linenomathNonumbers}%
\@namedef{linenomath*}{\linenomathWithnumbers}%
}
\def\endlinenomath{%
\global\holdinginserts0
\@ignoretrue
}
\expandafter\let\csname endlinenomath*\endcsname\endlinenomath
% The default is not to number the lines of a display. But
% the package option ~mathlines~ may be used to switch
% that behavior.
\nolinenumberdisplaymath
%
% \section{%
% Line number references
% \unskip}\label{s:LNref}
%
% The only way to get a label to a line number in a
% paragraph is to ask the output routine to mark it.
%
% (New v4.00) The following two paragraphs don't hold any
% longer, see below. (/New v4.00)
% \begin{old}\begin{verbatim}
% % We use the marginpar mechanism to hook to ~\output~ for a
% % second time. Marginpars are floats with number $-1$, we
% % fake marginpars with No $-2$. Originally, every negative
% % numbered float was considered to be a marginpar.
% %
% % The float box number ~\@currbox~ is used to transfer the
% % label name in a macro called ~\@LNL@~<box-number>.
% \end{verbatim}
% \end{old}
% A ~\newlabel~ is written to the aux-file. The reference
% is to ~\theLineNumber~, \emph{not} ~\thelinenumber~.
% This allows to hook in, as done below for pagewise line
% numbering.
%
% (New v3.03) The ~\@LN@ExtraLabelItems~ are added for a hook
% to keep packages like ~{hyperref}~ happy. (/New v3.03)
%
% (New v4.00)
% We fire the ~\marginpar~ mechanism, so we leave \LaTeX's
% ~\@addmarginpar~ untouched.
% \begin{old}\begin{verbatim}
% % \let\@LN@addmarginpar\@addmarginpar
% % \def\@addmarginpar{%
% % \ifnum\count\@currbox>-2\relax
% % \expandafter\@LN@addmarginpar
% % \else
% % \@cons\@freelist\@currbox
% % \protected@write\@auxout{}{%
% % \string\newlabel
% % {\csname @LNL@\the\@currbox\endcsname}%
% % {{\theLineNumber}{\thepage}\@LN@ExtraLabelItems}}%
% % \fi}
% \end{verbatim}
% \end{old}
% OK, we keep Stephan's ~\@LN@ExtraLabelItems~:
% (/New v4.00)
\let\@LN@ExtraLabelItems\@empty
% (New v4.00)
% We imitate the ~\marginpar~ mechanism without using the
% ~\@freelist~ boxes. ~\linelabel~ will indeed place a signal
% penalty (~\@Mllbcodepen~, new), and it will put a label into
% some list macro ~\@LN@labellist~. A new part of the output
% routine will take the labels from the list and will write
% ~\newlabel~s to the .aux file.
%
% The following is a version of \LaTeX's ~\@xnext~.
\def\@LN@xnext#1\@lt#2\@@#3#4{\def#3{#1}\gdef#4{#2}}
% This takes an item ~#1~ from a list ~#4~ into ~#3~;
% to be used as ~\expandafter\@LN@xnext#4\@@#3#4~.
% Our lists use ~\@lt~ after each item for separating.
% Indeed, there will be another list macro which can
% appear as argument ~#4~, this will be used for moving
% ~\vadjust~ items (section_\ref{ss:PVadj}).
% The list for ~\linelabel~s is the following:
\global\let\@LN@labellist\@empty
% The next is the new part of the output routine writing the
% ~\newlabel~ to the .aux file. Since it is no real page output,
% the page is put back to top of the main vertical list.
\def\WriteLineNo{%
\unvbox\@cclv
\expandafter \@LN@xnext \@LN@labellist \@@
\@LN@label \@LN@labellist
\protected@write\@auxout{}{\string\newlabel{\@LN@label}%
{{\theLineNumber}{\thepage}\@LN@ExtraLabelItems}}%
}
% (/New v4.00)
%
% \subsection{%
% The \scs{linelabel} command
% \unskip}\label{ss:LL}
% To refer to a place in line ~\ref{~<foo>~}~ at page
% ~\pageref{~<foo>~}~ you place a ~\linelabel{~<foo>~}~ at
% that place.
%
% \linelabel{demo}
% \marginpar{\tiny\raggedright
% See if it works: This paragraph
% starts on page \pageref{demo}, line
% \ref{demo}.
% \unskip}%
% If you use this command outside a ~\linenumbers~
% paragraph, you will get references to some bogus
% line numbers, sorry. But we don't disable the command,
% because only the ~\par~ at the end of a paragraph may
% decide whether to print line numbers on this paragraph
% or not. A ~\linelabel~ may legally appear earlier than
% ~\linenumbers~.
%
% ~\linelabel~
% \begin{old}\begin{verbatim}
% %, via a fake float number $-2$, %% new mechanism v4.00
% \end{verbatim}
% \end{old}
% puts a
% ~\penalty~ into a ~\vadjust~, which triggers the
% pagebuilder after putting the current line to the main
% vertical list. A ~\write~ is placed on the main vertical
% list, which prints a reference to the current value of
% ~\thelinenumber~ and ~\thepage~ at the time of the
% ~\shipout~.
%
% A ~\linelabel~ is allowed only in outer horizontal mode.
% In outer vertical mode we start a paragraph, and ignore
% trailing spaces (by fooling ~\@esphack~).
%
% (New v4.00) We aim at relaxing the previous condition.
% We insert a hook ~\@LN@mathhook~ and a shorthand
% ~\@LN@postlabel~ to support the ~mathrefs~ option which
% allows ~\linelabel~ in math mode.
%
% The next paragraph is no longer valid.
% \begin{old}\begin{verbatim}
% % The argument of ~\linelabel~ is put into a macro with a
% % name derived from the number of the allocated float box.
% % Much of the rest is dummy float setup.
% \end{verbatim}
% \end{old}
% (/New v4.00)
\def\linelabel#1{%
\ifvmode
\ifinner \else
\leavevmode \@bsphack \@savsk\p@
\fi
\else
\@bsphack
\fi
\ifhmode
\ifinner
\@parmoderr
\else
%%
% (New v4.00)
%%
\@LN@postlabel{#1}%
% \begin{old}\begin{verbatim}
% % \@floatpenalty -\@Mii
% % \@next\@currbox\@freelist
% % {\global\count\@currbox-2%
% % \expandafter\gdef\csname @LNL@\the\@currbox\endcsname{#1}}%
% % {\@floatpenalty\z@ \@fltovf \def\@currbox{\@tempboxa}}%
% % \begingroup
% % \setbox\@currbox \color@vbox \vbox \bgroup \end@float
% % \endgroup
% % \@ignorefalse \@esphack
% \end{verbatim}
% \end{old}
% (/New v4.00)
%%
\@esphack
%%
% (New v4.00)
% The ~\@ignorefalse~ was appropriate before because the
% ~\@Esphack~ in ~\end@float~ set ~\@ignoretrue~. Cf._\LaTeX's
% ~\@xympar~. (/New v4.00)
%%
\fi
\else
%%
% (New v4.00)
%%
\@LN@mathhook{#1}%
% \begin{old}\begin{verbatim}
% % \@parmoderr
% \end{verbatim}
% \end{old}
% Instead of complaining, you may just do your job.
% (/New v4.00)
%%
\fi
}
% (New v4.00) The shorthand just does what happened
% with linenox0.sty before ednmath0.sty (New v4.1:
% now ~mathrefs~ option) appeared, and
% the hook is initialized to serve the same purpose.
% So errors come just where Stephan had built them in,
% and this is just the \LaTeX\ ~\marginpar~ behaviour.
\def\@LN@postlabel#1{\g@addto@macro\@LN@labellist{#1\@lt}%
\vadjust{\penalty-\@Mllbcodepen}}
\def\@LN@mathhook#1{\@parmoderr}
% (/New v4.00)
%
% \modulolinenumbers[3]
% \firstlinenumber{1}
% \section{%
% The appearance of the line numbers
% \unskip}\label{appearance}
%
% The line numbers are set as ~\tiny\sffamily\arabic{linenumber}~,
% $10pt$ left of the text. With options to place it
% right of the text, or . . .
%
% . . . here are the hooks:
\def\makeLineNumberLeft{\hss\linenumberfont\LineNumber\hskip\linenumbersep}
\def\makeLineNumberRight{\linenumberfont\hskip\linenumbersep\hskip\columnwidth
\hbox to\linenumberwidth{\hss\LineNumber}\hss}
\def\linenumberfont{\normalfont\tiny\sffamily}
\newdimen\linenumbersep
\newdimen\linenumberwidth
\linenumberwidth=10pt
\linenumbersep=10pt
% Margin switching requires ~pagewise~ numbering mode, but
% choosing the left or right margin for the numbers always
% works.
\def\switchlinenumbers{\@ifstar
{\let\makeLineNumberOdd\makeLineNumberRight
\let\makeLineNumberEven\makeLineNumberLeft}%
{\let\makeLineNumberOdd\makeLineNumberLeft
\let\makeLineNumberEven\makeLineNumberRight}%
}
\def\setmakelinenumbers#1{\@ifstar
{\let\makeLineNumberRunning#1%
\let\makeLineNumberOdd#1%
\let\makeLineNumberEven#1}%
{\ifx\c@linenumber\c@runninglinenumber
\let\makeLineNumberRunning#1%
\else
\let\makeLineNumberOdd#1%
\let\makeLineNumberEven#1%
\fi}%
}
\def\leftlinenumbers{\setmakelinenumbers\makeLineNumberLeft}
\def\rightlinenumbers{\setmakelinenumbers\makeLineNumberRight}
\leftlinenumbers*
% ~\LineNumber~ is a hook which is used for the modulo stuff.
% It is the command to use for the line number, when you
% customize ~\makeLineNumber~. Use ~\thelinenumber~ to
% change the outfit of the digits.
%
%
% We will implement two modes of operation:
% \begin{itemize}
% \item numbers ~running~ through (parts of) the text
% \item ~pagewise~ numbers starting over with one on top of
% each page.
% \end{itemize}
% Both modes have their own count register, but only one is
% allocated as a \LaTeX\ counter, with the attached
% facilities serving both.
\newcounter{linenumber}
\newcount\c@pagewiselinenumber
\let\c@runninglinenumber\c@linenumber
% Only the running mode counter may be reset, or preset,
% for individual paragraphs. The pagewise counter must
% give a unique anonymous number for each line.
%
% (UL) ~\newcounter{linenumber}~
% was the only ~\newcounter~ in the whole package. What is
% (or: ``was''!) its purpose (i.e., Stephan's reasoning)?
% (In fact, Stephan couldn't remember his thoughts on
% on similar questions---this is why I reason here as if I
% were a historian.)
% Firstly, there is the check whether the name has
% been introduced earlier---forget about this. Secondly,
% ~\thelinenumber~ is defined---we could do this on our own.
% Note that ~\setcounter{linenumber}~ and
% ~\addtocounter{linenumber}~ work even after
% ~\newcount\c@linenumber~, without ~\newcounter~.
% So the final (main) difference to ~\newcount~ is that
% ~\stepcounter{linenumber}~ resets \LaTeX\ counters <foo>
% that have been declared by
% ~\newcounter{~<foo>~}[linenumber]~.
% I wondered what this is needed for.
% It reminds me of ``sublines'' which are dealt with in
% John Lavagnino's and Dominik Wujastyk's EDMAC.---This
% is the main reason why I think it is really better to
% keep the ~\stepcounter~ facility and, so,
% ~\newcounter~. Finally, I found another reason for
% keeping it in section_\ref{ss:Mod}.
%
% 2004/12/11: The above list of effects of
% ~\newcounter{linenumber}~ is not complete.
% It must be added that this command causes ~\include~
% to save the final line number (plus 1) of the ~\included~
% part. This appears to me to be useful.
% (/UL)
%
% (New v4.00)
\newcommand*\resetlinenumber[1][1]{\c@runninglinenumber#1\relax}
%% \newcommand\resetlinenumber[1][1]{\c@runninglinenumber#1}
%%
% Added ~\relax~, being quite sure that this does no harm
% and is quite important, as with ~\setcounter~ etc.
% I consider this a bug fix (although perhaps no user has
% ever had a problem with this). (/New v4.00)
%
% (UL)
%% Optional argument should better be ~\@ne~.---%% %% TODO v4.2
%%
% I thought of incrementing ~\c@linenumber~ (which is the same as
% ~\c@linenumber~ when ~\resetlinenumber~ has an effect at all)
% \emph{before} printing (see what precedes ~\MakeLineNo~ above)
% and of adding ~\advance\c@runninglinenumber\m@ne~ here
% correspondingly. Even if incrementing is kept as it was:
% Now that we have decided to use ~\stepcounter{linenumber}~
% for incrementing---in order to support ``subordinate'' counters
% ~\c@foo~ that have been introduced by
% ~\newcounter{foo}[linenumber]~---subordinate counters should be
% reset here as well. This could be done as follows.
% \begin{old}\begin{verbatim}
% % \newcommand\resetlinenumber[1][1]{%
% % \ifx\c@linenumber\c@runninglinenumber
% % \c@linenumber#1\relax
% % \advance\c@linenumber\m@ne
% % \stepcounter{linenumber}%
% % \else
% % \PackageError{lineno}%
% % {You can't reset line number in pagewise mode}%
% % {This should suffice.}%
% % \fi
% % }
% \end{verbatim}
% \end{old}
% But be careful! Note that ~\resetlinenumber~ acts locally only,
% while ~\stepcounter~ acts globally!---Well, this is a problem
% due to the received ~\resetlinenumber~! The received situation
% raises the danger of misusing save stack---\TeX book p._301.
% ~\c@linenumber~ can hardly be incremented in another way than
% globally! This is a very serious reason to make
% ~\resetlinenumber~ act globally!---I should have added
% ~\global~ right now, but here I am afraid of a serious
% compatibility problem. Stephan urged me to avoid such problems
% this time. Moreover, note that section_\ref{s:UserCmds} says
% that the commands can be used ``globally'' as well as
% ``locally within groups''. Are we allowed to change this?
% We might introduce a star form which acts globally indeed.
% Or we just advise the user to precede the command with a ~\global~.
%%
%% TODO v4.2:
%% \newcommand*\resetlinenumber[1][\@ne]{%
%% \ifx\c@linenumber\c@runninglinenumber
%% \global\c@linenumber#1\relax
%% \global\advance\c@linenumber\m@ne
%% \stepLineNumber
%% \else
%% \PackageError{lineno}%% Shorthand!?
%% {You can't reset line number in pagewise mode}%
%% {This should suffice.}%
%% \fi
%% }
% (/UL)
%
% \subsection{%
% Running line numbers
% \unskip}
%
% Running mode is easy, ~\LineNumber~ and ~\theLineNumber~
% produce ~\thelinenumber~, which defaults to
% ~\arabic{linenumber}~, using the ~\c@runninglinenumber~
% counter. This is the default mode of operation.
\def\makeRunningLineNumber{\makeLineNumberRunning}
\def\setrunninglinenumbers{%
\def\theLineNumber{\thelinenumber}%
\let\c@linenumber\c@runninglinenumber
\let\makeLineNumber\makeRunningLineNumber
}
\setrunninglinenumbers\resetlinenumber
%
% \subsection{%
% Pagewise line numbers
% \unskip}
%
% Difficult, if you think about it. The number has to be
% printed when there is no means to know on which page it
% will end up, except through the aux-file. My solution
% is really expensive, but quite robust.
%
% With version ~v2.00~ the hashsize requirements are
% reduced, because we do not need one controlsequence for
% each line any more. But this costs some computation time
% to find out on which page we are.
%
% ~\makeLineNumber~ gets a hook to log the line and page
% number to the aux-file. Another hook tries to find out
% what the page offset is, and subtracts it from the counter
% ~\c@linenumber~. Additionally, the switch
% ~\ifoddNumberedPage~ is set true for odd numbered pages,
% false otherwise.
\def\setpagewiselinenumbers{%
\let\theLineNumber\thePagewiseLineNumber
\let\c@linenumber\c@pagewiselinenumber
\let\makeLineNumber\makePagewiseLineNumber
}
\def\makePagewiseLineNumber{\logtheLineNumber\getLineNumber
\ifoddNumberedPage
\makeLineNumberOdd
\else
\makeLineNumberEven
\fi
}
% Each numbered line gives a line to the aux file
% \begin{verse}
% ~\@LN{~<line>~}{~<page>~}~
% \end{verse}
% very similar to the ~\newlabel~ business, except that we need
% an arabic representation of the page number, not what
% there might else be in ~\thepage~.
\def\logtheLineNumber{\protected@write\@auxout{}{%
%%
% (New v4.00)
% As Daniel Doherty observed, the earlier line
% \begin{old}\begin{verbatim}
% % \string\@LN{\the\c@linenumber}{\noexpand\the\c@page}}}
% \end{verbatim}
% \end{old}
% here may lead into an infinite loop when the user resets
% the page number (think of ~\pagenumbering~, e.g.).
% (UL)
% Stephan and I brief\/ly discussed the matter and decided
% to introduce a ``physical''-page counter to which
% ~\logtheLineNumber~ refers. It was Stephan's idea to use
% ~\cl@page~ for reliably augmenting the ``physical''-page
% counter. However, this relies on the output routine once
% doing ~\stepcounter{page}~. Before Stephan's
% suggestion, I had thought of appending the stepping to
% \LaTeX's ~\@outputpage~.---So the macro definition ends
% as follows.
%%
\string\@LN{\the\c@linenumber}{%
\noexpand\number\n@LN@truepage}}}
\newcount\n@LN@truepage
\g@addto@macro\cl@page{\global\advance\n@LN@truepage\@ne}
% I had thought of offering more
% features of a \LaTeX\ counter. However, the user should
% better \emph{not} have access to this counter. ~\c@page~
% should suffice as a pagewise master counter.---To be sure,
% along the present lines the user \emph{can} manipulate
% ~\n@LN@truepage~ by ~\stepcounter{page}~. E.g., she might
% do this twice in order to manually insert a photography.
% Well, the physical-page counter will skip some values
% then, but this will not disable pagewise line numbering.
%% %% TODO v4.2: OK?
%
% The above usage of ~\g@addto@macro~ and ~\cl@page~ may be
% not as stable as Stephan intended. His proposal used
% ~\xdef~ directly. But he used ~\cl@page~ as well, and who
% knows \dots{} And as to ~\g@addto@macro~, I have introduced
% it for list macros anyway.
% (/UL) (/New v4.00)
%
% From the aux-file we get one macro ~\LN@P~<page> for each
% page with line numbers on it. This macro calls four other
% macros with one argument each. These macros are
% dynamically defined to do tests and actions, to find out
% on which page the current line number is located.
%
% We need sort of a pointer to the first page with line
% numbers, initiallized to point to nothing:
\def\LastNumberedPage{first}
\def\LN@Pfirst{\nextLN\relax}
% The four dynamic macros are initiallized to reproduce
% themselves in an ~\xdef~
\let\lastLN\relax % compare to last line on this page
\let\firstLN\relax % compare to first line on this page
\let\pageLN\relax % get the page number, compute the linenumber
\let\nextLN\relax % move to the next page
% During the end-document run through the aux-files, we
% disable ~\@LN~. I may put in a check here later, to give
% a rerun recommendation.
\AtEndDocument{\let\@LN\@gobbletwo}
% Now, this is the tricky part. First of all, the whole
% definition of ~\@LN~ is grouped, to avoid accumulation
% on the save stack. Somehow ~\csname~<cs>~\endcsname~ pushes
% an entry, which stays after an ~\xdef~ to that <cs>.
%
% If ~\LN@P~<page> is undefined, initialize it with the
% current page and line number, with the
% \emph{pointer-to-the-next-page} pointing to nothing. And
% the macro for the previous page will be redefined to point
% to the current one.
%
% If the macro for the current page already exists, just
% redefine the \emph{last-line-number} entry.
%
% Finally, save the current page number, to get the pointer to the
% following page later.
\def\@LN#1#2{{\expandafter\@@LN
\csname LN@P#2C\@LN@column\expandafter\endcsname
\csname LN@PO#2\endcsname
{#1}{#2}}}
\def\@@LN#1#2#3#4{\ifx#1\relax
\ifx#2\relax\gdef#2{#3}\fi
\expandafter\@@@LN\csname LN@P\LastNumberedPage\endcsname#1
\xdef#1{\lastLN{#3}\firstLN{#3}\pageLN{#4}{\@LN@column}{#2}\nextLN\relax}%
\else
\def\lastLN##1{\noexpand\lastLN{#3}}%
\xdef#1{#1}%
\fi
\xdef\LastNumberedPage{#4C\@LN@column}}
% The previous page macro gets its pointer to the
% current one, replacing the ~\relax~ with the cs-token
% ~\LN@P~<page>.
\def\@@@LN#1#2{{\def\nextLN##1{\noexpand\nextLN\noexpand#2}%
\xdef#1{#1}}}
% Now, to print a line number, we need to find the page,
% where it resides. This will most probably be the page where
% the last one came from, or maybe the next page. However, it can
% be a completely different one. We maintain a cache,
% which is ~\let~ to the last page's macro. But for now
% it is initialized to expand ~\LN@first~, where the poiner
% to the first numbered page has been stored in.
\def\NumberedPageCache{\LN@Pfirst}
% To find out on which page the current ~\c@linenumber~ is,
% we define the four dynamic macros to do something usefull
% and execute the current cache macro. ~\lastLN~ is run
% first, testing if the line number in question may be on a
% later page. If so, disable ~\firstLN~, and go on to the
% next page via ~\nextLN~.
\def\testLastNumberedPage#1{\ifnum#1<\c@linenumber
\let\firstLN\@gobble
\fi}
% Else, if ~\firstLN~ finds out that we need an earlier
% page, we start over from the beginning. Else, ~\nextLN~
% will be disabled, and ~\pageLN~ will run
% ~\gotNumberedPage~ with four arguments: the first line
% number on this column, the page number, the column
% number, and the first line on the page.
\def\testFirstNumberedPage#1{\ifnum#1>\c@linenumber
\def\nextLN##1{\testNextNumberedPage\LN@Pfirst}%
\else
\let\nextLN\@gobble
\def\pageLN{\gotNumberedPage{#1}}%
\fi}
% We start with ~\pageLN~ disabled and ~\nextLN~ defined to
% continue the search with the next page.
\long\def \@gobblethree #1#2#3{}
\def\testNumberedPage{%
\let\lastLN\testLastNumberedPage
\let\firstLN\testFirstNumberedPage
\let\pageLN\@gobblethree
\let\nextLN\testNextNumberedPage
\NumberedPageCache
}
% When we switch to another page, we first have to make
% sure that it is there. If we are done with the last
% page, we probably need to run \TeX\ again, but for the
% rest of this run, the cache macro will just return four
% zeros. This saves a lot of time, for example if you have
% half of an aux-file from an aborted run, in the next run
% the whole page-list would be searched in vain again and
% again for the second half of the document.
%
% If there is another page, we iterate the search.
\def\testNextNumberedPage#1{\ifx#1\relax
\global\def\NumberedPageCache{\gotNumberedPage0000}%
\PackageWarningNoLine{lineno}%
{Linenumber reference failed,
\MessageBreak rerun to get it right}%
\else
\global\let\NumberedPageCache#1%
\fi
\testNumberedPage
}
% \linelabel{demo2}
% \marginpar{\tiny\raggedright
% Let's see if it finds the label
% on page \pageref{demo},
% line \ref{demo}, and back here
% on page \pageref{demo2}, line
% \ref{demo2}.
% \unskip}%
% To separate the official hooks from the internals there is
% this equivalence, to hook in later for whatever purpose:
\let\getLineNumber\testNumberedPage
% So, now we got the page where the number is on. We
% establish if we are on an odd or even page, and calculate
% the final line number to be printed.
\newif\ifoddNumberedPage
\newif\ifcolumnwiselinenumbers
\columnwiselinenumbersfalse
\def\gotNumberedPage#1#2#3#4{\oddNumberedPagefalse
\ifodd \if@twocolumn #3\else #2\fi\relax\oddNumberedPagetrue\fi
\advance\c@linenumber 1\relax
\ifcolumnwiselinenumbers
\subtractlinenumberoffset{#1}%
\else
\subtractlinenumberoffset{#4}%
\fi
}
% You might want to run the pagewise mode with running line
% numbers, or you might not. It's your choice:
\def\runningpagewiselinenumbers{%
\let\subtractlinenumberoffset\@gobble
}
\def\realpagewiselinenumbers{%
\def\subtractlinenumberoffset##1{\advance\c@linenumber-##1\relax}%
}
\realpagewiselinenumbers
% For line number references, we need a protected call to
% the whole procedure, with the requested line number stored
% in the ~\c@linenumber~ counter. This is what gets printed
% to the aux-file to make a label:
\def\thePagewiseLineNumber{\protect
\getpagewiselinenumber{\the\c@linenumber}}%
% And here is what happens when the label is refered to:
\def\getpagewiselinenumber#1{{%
\c@linenumber #1\relax\testNumberedPage
\thelinenumber
}}
% %
% A summary of all per line expenses:
% \begin{description}\item
% [CPU:] The ~\output~ routine is called for each line,
% and the page-search is done.
% \item
% [DISK:] One line of output to the aux-file for each
% numbered line
% \item
% [MEM:] One macro per page. Great improvement over v1.02,
% which had one control sequence per line in
% addition. It blew the hash table after some five
% thousand lines.
% \end{description}
%
% \subsection{%
% Twocolumn mode (New v3.06)
% \unskip}
%
% Twocolumn mode requires another patch to the ~\output~
% routine, in order to print a column tag to the .aux
% file.
\let\@LN@orig@makecol\@makecol
\def\@LN@makecol{%
\@LN@orig@makecol
\setbox\@outputbox \vbox{%
\boxmaxdepth \@maxdepth
\protected@write\@auxout{}{%
\string\@LN@col{\if@firstcolumn1\else2\fi}%
}%
\box\@outputbox
}% \vbox
}
\def\@LN@col#1{\def\@LN@column{#1}}
\@LN@col{1}
%
% \subsection{%
% Numbering modulo $m$, starting at $f$
%% Numbering modulo 5
% \unskip}\label{ss:Mod}
%
% Most users want to have only one in five lines numbered.
% ~\LineNumber~ is supposed to produce the outfit of the
% line number attached to the line, while ~\thelinenumber~
% is used also for references, which should appear even if
% they are not multiples of five.
%
% (New v4.00) Moreover, some users want to
% control which linenumber should be printed first. Support of
% this is now introduced here.---numline.sty by Michael
% Jaegermann and James Fortune offers controlling which
% \emph{final} line numbers should not be printed. What is it
% good for? We ignore this here until some user demands
% it.---Peter Wilson's ledmac.sty offers much different
% choices of line numbers to be printed, due to Wayne Sullivan.
% (/New v4.00)
\newcount\c@linenumbermodulo
% (UL) On my question why, e.g.,
% ~\chardef~ would not have sufficed, Stephan couldn't remember
% exactly; guessed that he wanted to offer \LaTeX\ counter
% facilities. However, the typical ones don't come this way.
% So I'm quite sure that I will change this next time.
%
% However, I observed at least two times that users gave a very
% high value to ~\c@linenumbermodulo~ in order to suppress
% printing of the line number. One of these users preferred an
% own way of handling line numbers, just wanted to use
% ~\linelabel~ and Ednotes features. Should we support this?
% I rather would like to advise them to
% ~\let\makeLineNumber\relax~. (/UL)
%
% (New v4.00) ~\themodulolinenumber~ waits for
% being declared ~\LineNumber~ by ~\modulolinenumbers~. (This
% has been so before, no change.) Here is how it looked
% before:
% \begin{old}\begin{verbatim}
% % \def\themodulolinenumber{{\@tempcnta\c@linenumber
% % \divide\@tempcnta\c@linenumbermodulo
% % \multiply\@tempcnta\c@linenumbermodulo
% % \ifnum\@tempcnta=\c@linenumber\thelinenumber\fi
% % }}
% \end{verbatim}
% \end{old}
% (UL) This was somewhat slow. This arithmetic
% happens at every line. This time I tend to declare an extra
% line counter (as opposed to my usual recommendations to use
% counters as rarely as possible) which is stepped every line.
% It could be incremented in the same way as ~\n@truepage~
% is incremented via ~\cl@page~! This is another point in favour
% of ~{linenumber}~ being a \LaTeX\ counter!
% When this new counter equals ~\c@linenumbermodulo~, it is reset,
% and ~\thelinenumber~ is executed.---It gets much slower by my
% support of controlling the first line number below. I should
% improve this.---On
%% %% TODO v4.2--pagewise!?
% the other hand, time expense means very little nowadays,
% while the number of \TeX\ counters still is limited.
%
% For the same purpose, moreover, attaching the line number
% box could be intercepted earlier (in ~\MakeLineNo~),
% without changing ~\LineNumber~. However, this may be
% bad for the latter's announcement as a wizard interface
% in section_\ref{s:UserCmds}.
%%
%% I wonder about Stephan's group. Its only effect is that
%% ~\@tempcnta~ is restored after using it. What for is this?
%% I tend to remove the group braces. %% TODO v4.2
% (/UL)
%
% Here is the new code. It is very near to my lnopatch.sty code
% which introduced the first line number feature before.---I
% add starting with a ~\relax~ which is so often
% recommended---without understanding this really. At least,
% it will not harm.---Former group braces appear as
% ~\begingroup~/~\endgroup~ here.
\def\themodulolinenumber{\relax
\ifnum\c@linenumber<\n@firstlinenumber
\else
\begingroup
\@tempcnta\c@linenumber
\advance\@tempcnta-\n@firstlinenumber
\divide\@tempcnta\c@linenumbermodulo
\multiply\@tempcnta\c@linenumbermodulo
\advance\@tempcnta\n@firstlinenumber
\ifnum\@tempcnta=\c@linenumber \thelinenumber \fi
\endgroup
\fi
}
% (/New v4.00)
%
% The user command to set the modulo counter:
%% %% TODO v4.2: \newcommand*...[\z@]
\newcommand\modulolinenumbers[1][0]{%
\let\LineNumber\themodulolinenumber
\ifnum#1>1\relax
\c@linenumbermodulo#1\relax
\else\ifnum#1=1\relax
% \begin{old}\begin{verbatim}
% % \def\LineNumber{\thelinenumber}%
% \end{verbatim}
% \end{old}
% (New v4.00) I'm putting something here to enable
% ~\firstlinenumber~ with $~\c@linenumbermodulo~=1$.
% With lnopatch.sty, a trick was offered for this purpose.
% It is now obsolete.
%
\def\LineNumber{\@LN@ifgreat\thelinenumber}%
%%
% (/New v4.00)
%%
\fi\fi
}
% (New v4.00) The default of ~\@LN@ifgreat~ is
\let\@LN@ifgreat\relax
% The previous changes as soon as ~\firstlinenumber~ is used:
\newcommand*\firstlinenumber[1]{%
\chardef\n@firstlinenumber#1\relax
%%
% No counter, little values allowed only---OK?---(UL)
% The change is local---OK? The good thing is that
% ~\global\firstlinenumber{~<number>~}~ works. Moreover,
% ~\modulolinenumbers~ acts locally as well. (/UL)
%%
\def\@LN@ifgreat{%
\ifnum\c@linenumber<\n@firstlinenumber
\expandafter \@gobble
\fi
}%
}
% The default is 0. This is best for what one would
% expect from modulo printing.
\let\n@firstlinenumber=\z@
%
% Note that the line numbers of the present section
% demonstrate the two devices. (/New v4.00)
\setcounter{linenumbermodulo}{5}
\modulolinenumbers[1]
%
% \section{%
% Former package extensions
% \unskip}
%% (New v4.00)
%% \begin{old}\begin{verbatim}
%% % Package Extensions
%% \end{verbatim}
%% \end{old}
%% Sorry, these are `\emph{former} package extensions'.
%% Moreover, these are not ``package options'',
%% so install a new section. Move it above ``options''. (/New v4.00)
%% Hided 2004/09/19.
%% %% TODO remove
%
% The extensions in this section were previously supplied
% in separate ~.sty~ files.
%% %% TODO v4.2: `extensions' again ...
%
% \subsection{%
% $display math$
% \unskip}
%
% The standard \LaTeX\ display math environments are
% wrapped in a ~{linenomath}~ environment.
%
% (New 3.05) The ~[fleqn]~ option of the standard
% \LaTeX\ classes defines the display math
% environments such that line numbers appear just
% fine. Thus, we need not do any tricks when
% ~[fleqn]~ is loaded, as indicated by presents of
% the ~\mathindent~ register. (/New 3.05)
%
% (New 3.05a) for ~{eqnarray}~s we rather keep the
% old trick. (/New 3.05a)
%
% (New 3.08) Wrap ~\[~ and ~\]~ into ~{linenomath}~,
% instead of ~{displaymath}~. Also save the definition
% of ~\equation~, instead of replicating the current
% \LaTeX\ definition. (/New 3.08)
\ifx\do@mlineno\@empty
\@ifundefined{mathindent}{
\let\LN@displaymath\[
\let\LN@enddisplaymath\]
\renewcommand\[{\begin{linenomath}\LN@displaymath}
\renewcommand\]{\LN@enddisplaymath\end{linenomath}}
\let\LN@equation\equation
\let\LN@endequation\endequation
\renewenvironment{equation}
{\linenomath\LN@equation}
{\LN@endequation\endlinenomath}
}% \@ifundefined{mathindent}
\let\LN@eqnarray\eqnarray
\let\LN@endeqnarray\endeqnarray
\renewenvironment{eqnarray}
{\linenomath\LN@eqnarray}
{\LN@endeqnarray\endlinenomath}
\fi
% (UL) Indeed. The \LaTeX\ macros are saved for
% unnumbered mode, which is detected by ~\linenomath~.
% (/UL)
%
% \subsection{%
% Line numbers in internal vertical mode
% \unskip}
%
% The command ~\internallinenumbers~ adds line numbers in
% internal vertical mode, but with limitations: we assume
% fixed baseline skip.
\def\internallinenumbers{\setrunninglinenumbers
\let\@@par\internallinenumberpar
\ifx\@par\@@@par\let\@par\internallinenumberpar\fi
\ifx\par\@@@par\let\par\internallinenumberpar\fi
\ifx\@par\linenumberpar\let\@par\internallinenumberpar\fi
\ifx\par\linenumberpar\let\par\internallinenumberpar\fi
\@ifnextchar[{\resetlinenumber}%]
{\@ifstar{\let\c@linenumber\c@internallinenumber
\c@linenumber\@ne}{}}%
}
\let\endinternallinenumbers\endlinenumbers
\@namedef{internallinenumbers*}{\internallinenumbers*}
\expandafter\let\csname endinternallinenumbers*\endcsname\endlinenumbers
\newcount\c@internallinenumber
% (UL)
% This counter appears in ~\internallinenumbers~ only. It seems
% to have been meant to be a version of ~\c@linenumber~ which
% is changed only \emph{locally}---see ~{internallinenumbers*}~,
% where the initialization is local. However, Stephan incremented
% it \emph{globally} then, see below. Now, even this global
% incrementing would not increment the ~\c@linenumber~ version
% \emph{outside} ~{internallinenumbers}~---another reason to
% consider ~\c@internallinenumber~ an ``internal version'' of
% ~\c@linenumber~. And another reason not to increment it
% globally, see below.---A drawback of this kind of ``internal''
% seems to be: ~{internallinenumbers}~ cannot be used to
% ``continue line counting in internal vertical mode
% temporarily'', exactly because, e.g., ~\c@runninglinenumber~
% has the same value after ~\end{internallinenumbers}~ as it had
% at ~\begin{internallinenumbers}~.
% (/UL)
\newcount\c@internallinenumbers
\def\internallinenumberpar{\ifvmode\@@@par\else\ifinner\@@@par\else\@@@par
\begingroup
\c@internallinenumbers\prevgraf
\setbox\@tempboxa\hbox{\vbox{\makeinternalLinenumbers}}%
\dp\@tempboxa\prevdepth
\ht\@tempboxa\z@
\nobreak\vskip-\prevdepth
\nointerlineskip\box\@tempboxa
\endgroup
\fi\fi
}
\def\makeinternalLinenumbers{\ifnum\c@internallinenumbers>0\relax
% (New v4.00)
% \begin{old}\begin{verbatim}
% % \hbox to\z@{\makeLineNumber}\global\advance\c@linenumber\@ne
% \end{verbatim}
% \end{old}
% followed here previously. Why no ~\stepcounter~?
% OK, with unit ~\baselineskip~ there is no space for ``sublines''
% anyway.---More serious:
% ~\c@linenumber~ is ~\c@internallinenumber~ here, which in
% ~{internallinenumbers*}~has been initialized to be 1---locally!
% Save stack problem again. We could use ~\global~
% \emph{depending} on whether the star version is used or not.
% However, the ``external'' line counter is not affected anyway,
% and the ~\global~ is not needed internally. So just drop it.
% I have no idea how a compatibility problem could arise.
%% %% TODO v4.2: TEST
\hbox to\z@{\makeLineNumber}\advance\c@linenumber\@ne
%%
% (/New v4.00)
%%
\advance\c@internallinenumbers\m@ne
\expandafter\makeinternalLinenumbers\fi
}
%
% \subsection{%
% Line number references with offset
% \unskip}
%
% This extension defines macros to refer to line
% numbers with an offset, e.g., to refer to a line
% which cannot be labeled directly (display math).
% This was formerly knows as ~rlineno.sty~.
%
% To refer to a pagewise line number with offset:
% \begin{quote}
% ~\linerefp[~<OFFSET>~]{~<LABEL>~}~
% \end{quote}
% To refer to a running line number with offset:
% \begin{quote}
% ~\linerefr[~<OFFSET>~]{~<LABEL>~}~
% \end{quote}
% To refer to a line number labeled in the same mode as currently
% selected:
% \begin{quote}
% ~\lineref[~<OFFSET>~]{~<LABEL>~}~
% \end{quote}
\newcommand\lineref{%
\ifx\c@linenumber\c@runninglinenumber
\expandafter\linerefr
\else
\expandafter\linerefp
\fi
}
\newcommand\linerefp[2][\z@]{{%
\let\@thelinenumber\thelinenumber
\edef\thelinenumber{\advance\c@linenumber#1\relax\noexpand\@thelinenumber}%
\ref{#2}%
}}
% This goes deep into \LaTeX's internals.
\newcommand\linerefr[2][\z@]{{%
\def\@@linerefadd{\advance\c@linenumber#1}%
\expandafter\@setref\csname r@#2\endcsname
\@linerefadd{#2}%
}}
\newcommand\@linerefadd[2]{\c@linenumber=#1\@@linerefadd\relax
\thelinenumber}
% (UL) Insert `LN' in internal command names. (/UL)
%
% \subsection{%
% Numbered quotation environments
% \unskip}
%
% The ~{numquote}~ and ~{numquotation}~
% environments are like ~{quote}~ and
% ~{quotation}~, except there will be line
% numbers.
%
% An optional argument gives the number to count
% from. A star ~*~ (inside or outside the closing
% ~}~) prevent the reset of the line numbers.
% Default is to count from one.
\newcommand\quotelinenumbers
{\@ifstar\linenumbers{\@ifnextchar[\linenumbers{\linenumbers*}}}
\newdimen\quotelinenumbersep
\quotelinenumbersep=\linenumbersep
\let\quotelinenumberfont\linenumberfont
\newcommand\numquotelist
{\leftlinenumbers
\linenumbersep\quotelinenumbersep
\let\linenumberfont\quotelinenumberfont
\addtolength{\linenumbersep}{-\@totalleftmargin}%
\quotelinenumbers
}
\newenvironment{numquote} {\quote\numquotelist}{\endquote}
\newenvironment{numquotation} {\quotation\numquotelist}{\endquotation}
\newenvironment{numquote*} {\quote\numquotelist*}{\endquote}
\newenvironment{numquotation*}{\quotation\numquotelist*}{\endquotation}
%
% \subsection{%
% Frame around a paragraph
% \unskip}
%
% The ~{bframe}~ environment draws a frame around
% some text, across page breaks, if necessary.
%
% This works only for plain text paragraphs,
% without special height lines. All lines must be
% ~\baselineskip~ apart, no display math.
\newenvironment{bframe}
{\par
\@tempdima\textwidth
\advance\@tempdima 2\bframesep
\setbox\bframebox\hbox to\textwidth{%
\hskip-\bframesep
\vrule\@width\bframerule\@height\baselineskip\@depth\bframesep
\advance\@tempdima-2\bframerule
\hskip\@tempdima
\vrule\@width\bframerule\@height\baselineskip\@depth\bframesep
\hskip-\bframesep
}%
\hbox{\hskip-\bframesep
\vrule\@width\@tempdima\@height\bframerule\@depth\z@}%
\nointerlineskip
\copy\bframebox
\nobreak
\kern-\baselineskip
\runninglinenumbers
\def\makeLineNumber{\copy\bframebox\hss}%
}
{\par
\kern-\prevdepth
\kern\bframesep
\nointerlineskip
\@tempdima\textwidth
\advance\@tempdima 2\bframesep
\hbox{\hskip-\bframesep
\vrule\@width\@tempdima\@height\bframerule\@depth\z@}%
}
\newdimen\bframerule
\bframerule=\fboxrule
\newdimen\bframesep
\bframesep=\fboxsep
\newbox\bframebox
%
%
% \section{%
% Move \scs{vadjust} items (New v4.00)
% \unskip}\label{s:MVadj}
%
% This section completes reviving ~\pagebreak~, ~\nopagebreak~,
% ~\vspace~, and the star and optional form of ~\\~. This was
% started in section_\ref{ss:output} and resumed in
% sections_\ref{ss:MLN} and_\ref{s:CtrlLN}.
% The problem was explained in section_\ref{ss:output}:
% ~\vadjust~ items come out at a bad position, and the
% \LaTeX\ commands named before work with ~\vadjust~ indeed.
% Our solution was sketched there as well.
%
% According to the caveat in section_\ref{s:CtrlLN} concerning
% ~\ifLineNumbers~, the \LaTeX\ commands enumerated may go
% wrong if you switch line numbering inside or at the end of
% a paragraph.
%% %% TODO v4.2
%
% \subsection{%
% Redefining \scs{vadjust}
% \unskip}\label{ss:PVadj}
%
% ~\vadjust~ will temporarily be changed into the following
% command.
\def\PostponeVadjust#1{%
\global\let\vadjust\@LN@@vadjust
%%
% This undoes a ~\global\let\vadjust\PostponeVadjust~ which will
% start each of the refined \LaTeX\ commands. The ~\global~s
% are most probably superfluous. They might be useful should one
% ~\vadjust~ appear in a group starting after the change of
% ~\vadjust~ into ~\PostponeVadjust~.
% (UL) Even the undoing may be superfluous, cf._discussion
% in section_\ref{ss:ReDef} below. (UL)
%%
\vadjust{\penalty-\@Mppvacodepen}%
\g@addto@macro\@LN@vadjustlist{#1\@lt}%
}
\let\@LN@@vadjust\vadjust
\global\let\@LN@vadjustlist\@empty
\global\let\@LN@do@vadjusts\relax
% These ~\global~s are just to remind that
% all the changes of the strings after ~\let~ should be
% ~\global~ (\TeX book p._301). ~\@LN@vadjustlist~ collects
% the ~\vadjust~ items of a paragraph. ~\PassVadjustList~
% tears one ~\vadjust~ item for the current line out of
% ~\@LN@vadjustlist~ and puts it into ~\@LN@do@vadjusts~.
% The latter is encountered each line in ~\MakeLineNo~
% (section_\ref{ss:MLN}), while those \LaTeX\ ~\vadjust~
% commands will come rather rarely. So I decided that
% ~\@LN@do@vadjust~ is ~\relax~ until a ~\vadjust~ item
% is waiting. In the latter case, ~\@LN@do@vadjusts~
% is turned into a list macro which resets itself to
% ~\relax~ when the other contents have been placed in
% the vertical list.---~\PassVadjustList~ is invoked by
% the output routine (section_\ref{ss:output}), so the
% ~\box255~ must be put back.
\def\PassVadjustList{%
\unvbox\@cclv
\expandafter \@LN@xnext \@LN@vadjustlist \@@
\@tempa \@LN@vadjustlist
\ifx\@LN@do@vadjusts\relax
\gdef\@LN@do@vadjusts{\global\let\@LN@do@vadjusts\relax}%
\fi
\expandafter \g@addto@macro \expandafter \@LN@do@vadjusts
\expandafter {\@tempa}%
}
%
% \subsection{%
% Redefining the \LaTeX\ commands
% \unskip}\label{ss:ReDef}
%
% Now we change ~\pagebreak~ etc.\
% so that they use ~\PostponeVadjust~ in place of ~\vadjust~.
%% Following the advices of the \LaTeX\ team, we %% TODO v4.2: remove
% We try to do this as independently as possible of the
% implementation of the \LaTeX\ commands to be redefined.
% Therefore, we don't just copy macro definition code from any
% single implementation (say, latest \LaTeX) and insert our
% changes, but attach a conditional
% ~\global\let\vadjust\PostponeVadjust~
% to their left ends in a way which should work rather
% independantly of their actual code.
% However, ~\vadjust~ should be the primitive again after
% execution of the command. So the ~\global\let...~ may be used
% only if it's guaranteed that a ~\vadjust~ is near.---(UL)
% Sure? In line numbering mode, probably each ~\vadjust~
% coming from a \LaTeX\ command should be ~\PostponeVadjust~.
% ~\marginpar~s and floats seem to be the only cases which
% are not explicitly dealt with in the present section.
% This would be a way to avoid ~\my@nobreaktrue~!
% Of course, the ~\vadjust~s that the present package uses
% then must be replaced by ~\@LN@@vadjust~.---Maybe
% next time. (/UL)
%% %% TODO v4.2
%
% The next command and something else will be added to the
% \LaTeX\ commands we are concerned with here.
\DeclareRobustCommand\@LN@changevadjust{%
\ifvmode\else\ifinner\else
\global\let\vadjust\PostponeVadjust
\fi\fi
}
% (UL) What about math mode? Math display? Warn? (/UL)
%% %% TODO v4.2
%
% ~\@tempa~ will now become a two place macro which adds first
% argument (single token), enclosed by ~\ifLineNumbers~\,\dots
% ~\fi~ to the left of second argument. As long as we need it,
% we can't use the star form of ~\DeclareRobustCommand~ or
% the like, because AMS-\LaTeX\ uses ~\@tempa~ for ~\@ifstar~.
\def\@tempa#1#2{%
\expandafter \def \expandafter#2\expandafter{\expandafter
\ifLineNumbers\expandafter#1\expandafter\fi#2}
}
% (UL) This ~\ifLineNumber~ can be fooled by
% ~\linenumbers~ ahead etc. It might be better to place
% a signal penalty in any case and let the output routine
% decide what to do.
%%
%% And when this has been done, remove warnings about this.
% (/UL)
%
% We use the occasion to switch off linenumbers where they
% don't work anyway and where we don't want them,
% especially in footnotes:
\@tempa\nolinenumbers\@arrayparboxrestore
% We hope this suffices $\dots$ let's check one thing
% at least:
\CheckCommand*\@parboxrestore{\@arrayparboxrestore\let\\\@normalcr}
% Now for the main theme of the section.
% The next lines assume that ~\vspace~, ~\pagebreak~, and
% ~\nopagebreak~ use ~\vadjust~ whenever they occur outside
% vertical mode; moreover, that they don't directly read
% an argument. Indeed ~\pagebreak~ and ~\nopagebreak~ first
% call something which tests for a left bracket ahead,
% while ~\vspace~ first tests for a star.
\@tempa\@LN@changevadjust\vspace
\@tempa\@LN@changevadjust\pagebreak
\@tempa\@LN@changevadjust\nopagebreak
% ~\\~, however, uses ~\vadjust~ only in star or optional form.
% We relax independency of implementation in assuming
% that ~\@normalcr~ is the fragile version of ~\\~
% (and we use ~\@ifstar~!).
%%
%% \@ifstar reimplemented 1995/10/16, but seems to be much older.
%% TODO v4.2:
%% \def\@LN@cr{%
%% \@ifnextchar*{\@LN@changevadjust\@normalcr}%
%% {\@ifnextchar[{\@LN@changevadjust\@normalcr}\@normalcr}%
%% }
%% ---same number of tokens, expansion step less.
%%
% (Using a copy of ~\\~ would be safer, but an ugly repetition
% of ~\protect~.)
%% %% TODO v4.2
\DeclareRobustCommand\\{%
\ifLineNumbers
\expandafter \@LN@cr
\else
\expandafter \@normalcr
\fi
}
\def\@LN@cr{%
\@ifstar{\@LN@changevadjust\@normalcr*}%
{\@ifnextchar[{\@LN@changevadjust\@normalcr}\@normalcr}%
}
% Moreover we hope that ~\newline~ never leads to a ~\vadjust~,
% although names of some commands invoked by ~\\~ contain
% ~newline~. At last, this seems to have been OK since 1989 or
% even earlier.
%
% \modulolinenumbers[1]
% \firstlinenumber{0}
% Let's have a few tests.\vspace*{.5\baselineskip}
% Testing ~\pagebreak~ and ~\nopagebreak~ would be too expensive
% here, but---oops!---we have just experienced a successful
% ~\vspace*{.5\baselineskip}~. A
% ~\\*[.5\baselineskip]~\\*[.5\baselineskip] may look even more
% drastical, but this time we are happy about it. Note that the
% line numbers have moved with the lines. Without our changes,
% one line number\vadjust{\kern.5\baselineskip} would have
% ``anticipated'' the move of the next line, just as you can
% observe it now.
% (/New v4.00)
%
% \switchlinenumbers
%
% \subsection{%
% Reminder on obsoleteness
% \unskip}
%
% (New v4.1) We have completed inclusion of the earlier
% extension packages linenox0.sty, linenox1.sty, and
% lnopatch.sty. If one of them is loaded, though,
% we produce an error message before something weird happens.
% We avoid ~\newif~ because the switchings occur so rarely.
\AtBeginDocument{%
\let\if@LN@obsolete\iffalse
\@ifpackageloaded{linenox0}{\let\if@LN@obsolete\iftrue}\relax
\@ifpackageloaded{linenox1}{\let\if@LN@obsolete\iftrue}\relax
\@ifpackageloaded{lnopatch}{\let\if@LN@obsolete\iftrue}\relax
\if@LN@obsolete
\PackageError{lineno}{Obsolete extension package(s)}{%
With lineno.sty version 4.00 or later,\MessageBreak
linenox0/linenox1/lnopatch.sty must no longer be loaded.}%
\fi
}
%
% \modulolinenumbers[1]
% \section{%
% Package options
% \unskip}\label{s:Opts}
%
% (New v4.1)
% The last heading formerly was the heading of what is now
% subsection_\ref{ss:v3Opt}. The options declared there were
% said to execute user commands only. This was wrong already
% concerning ~displaymath~ and ~hyperref~. At least, however,
% these options were no or almost no occasion to skip definitions
% or allocations. This is different with the options that we now
% insert.
%
% \subsection{%
% \scs{linelabel} in math mode
% \unskip}\label{ss:MathRef}
%
% We have made some first steps towards allowing ~\linelabel~ in
% math mode. Because our code for this is presently experimental,
% we leave it to the user to decide for the experiment by calling
% option ~mathrefs~. We are in a hurry now and thus leave the
% code, explanations, and discussion in the separate package
% ednmath0.sty. Maybe we later find the time to improve the code
% and move the relevant content of ednmath0.sty to here.
% The optimal situation would be to define ~\linelabel~ from
% the start so it works in math mode, omitting the ~mathrefs~
% option.
%
% Actually, this package even provides adjustments for analogously
% allowing ednotes.sty commands in math mode. Loading the package
% is postponed to ~\AtBeginDocument~ when we know whether these
% adjustments are needed.
\DeclareOption{mathrefs}{\AtBeginDocument
{\RequirePackage{ednmath0}[2004/08/20]}}
%
% \subsection{%
% \scs{linelabel} in tabular environments
% \unskip}\label{ss:Tab}
%
% We provide adjustments to make ~\linelabel~ work in some
% \LaTeX\ tabular environments. We do this similarly as with
% with option ~mathrefs~ before. We leave code
% and explanations in the separate package edtable.sty.
% This package provides adjustments for ednotes.sty as well.
% However, in the present case we don't try to avoid them
% unless ednotes.sty is loaded. Package option ~edtable~
% defines---by loading edtable.sty---an environment ~{edtable}~
% which is able to change some \LaTeX\ tabular environments
% with the desired effects.
%
% This method doesn't work with longtable.sty, however.
% To make up for this, ~{longtable}~ is adjusted in a different
% way---and this happens only when another lineno.sty
% option ~longtable~ is called. In this case, option ~edtable~
% needn't be called explicitly: option ~longtable~ works as if
% ~edtable~ had been called.
%
% Now, we are convinced that vertical spacing around
% ~{longtable}~ works wrongly---see \LaTeX\ bugs database
% tools/3180 and 3485, or see explanations in the package
% ltabptch.sty (which is to be obtained from CTAN folder
% \path{macros/latex/ltabptch}). Our conviction is so strong
% that the ~longtable~ option loads---after longtable.sty---the
% patch package ltabptch.sty. If the user doesn't want this
% (maybe preferring her own arrangement with the vertical
% spacing), she can forbid it by calling ~nolongtablepatch~.
%
% The following code just collects some choices, which are
% then executed in section_\ref{ss:ExOpt}. We use an ~\if...~
% without ~\newif~ since ~\if...true~ and ~\if...false~
% would occur at most two times and only within the present
% package. (~\AtEndOfClass{\RequirePackage{edtable}}~
% could be used instead, I just overlooked this. Now I don't
% change it because it allows to change the version requirement
% at one place only.)
\let\if@LN@edtable\iffalse
\DeclareOption{edtable}{\let\if@LN@edtable\iftrue}
\DeclareOption{longtable}{\let\if@LN@edtable\iftrue
\PassOptionsToPackage{longtable}{edtable}}
\DeclareOption{nolongtablepatch}{%
\PassOptionsToPackage{nolongtablepatch}{edtable}}
% (/New v4.1)
%
% \subsection{%
% Switch among settings
% \unskip}\label{ss:v3Opt}
%
% There is a bunch of package options, all of them
% executing only user commands (see below).
%%
%% %% TODO v4.2!? `All of ...' still OK with edtable/longtable?
%% %% TODO v4.2: wrong with displaymath and hyperref
%%
%
% Options ~left~ (~right~) put the line numbers on the left
% (right) margin. This works in all modes. ~left~ is the
% default.
\DeclareOption{left}{\leftlinenumbers*}
\DeclareOption{right}{\rightlinenumbers*}
% Option ~switch~ (~switch*~) puts the line numbers on the
% outer (inner) margin of the text. This requires running
% the pagewise mode, but we turn off the page offset
% subtraction, getting sort of running numbers again. The
% ~pagewise~ option may restore true pagewise mode later.
\DeclareOption{switch}{\setpagewiselinenumbers
\switchlinenumbers
\runningpagewiselinenumbers}
\DeclareOption{switch*}{\setpagewiselinenumbers
\switchlinenumbers*%
\runningpagewiselinenumbers}
% In twocolumn mode, we can switch the line numbers to
% the outer margin, and/or start with number 1 in each
% column. Margin switching is covered by the ~switch~
% options.
\DeclareOption{columnwise}{\setpagewiselinenumbers
\columnwiselinenumberstrue
\realpagewiselinenumbers}
% The options ~pagewise~ and ~running~ select the major
% linenumber mechanism. ~running~ line numbers refer to a real
% counter value, which can be reset for any paragraph,
% even getting multiple paragraphs on one page starting
% with line number one. ~pagewise~ line numbers get a
% unique hidden number within the document, but with the
% opportunity to establish the page on which they finally
% come to rest. This allows the subtraction of the page
% offset, getting the numbers starting with 1 on top of each
% page, and margin switching in twoside formats becomes
% possible. The default mode is ~running~.
%
% The order of declaration of the options is important here
% ~pagewise~ must come after ~switch~, to overide running
% pagewise mode. ~running~ comes last, to reset the running
% line number mode, e.g, after selecting margin switch mode
% for ~pagewise~ running. Once more, if you specify all
% three of the options ~[switch,pagewise,running]~, the
% result is almost nothing, but if you later say
% ~\pagewiselinenumbers~, you get margin switching, with
% real pagewise line numbers.
%
\DeclareOption{pagewise}{\setpagewiselinenumbers
\realpagewiselinenumbers}
\DeclareOption{running}{\setrunninglinenumbers}
% The option ~modulo~ causes only those linenumbers to be
% printed which are multiples of five.
\DeclareOption{modulo}{\modulolinenumbers\relax}
% The package option ~mathlines~ switches the behavior of
% the ~{linenomath}~ environment with its star-form.
% Without this option, the ~{linenomath}~ environment does
% not number the lines of the display, while the star-form
% does. With this option, its just the opposite.
%
%%% 1999-06-10: renamed ~displaymath~ to ~mathlines~.
\DeclareOption{mathlines}{\linenumberdisplaymath}
% ~displaymath~ now calls for wrappers of the standard
% LaTeX display math environment. This was previously
% done by ~mlineno.sty~.
\let\do@mlineno\relax
\DeclareOption{displaymath}{\let\do@mlineno\@empty}
% The ~hyperref~ package, via ~nameref~, requires three more
% groups in the second argment of a ~\newlabel~. Well, why
% shouldn't it get them? (New v3.07) The presence of the
% ~nameref~ package is now detected automatically
% ~\AtBeginDocument~. (/New v3.07) (Fixed in v3.09) We try
% to be smart, and test ~\AtBeginDocument~ if the ~nameref~
% package is loaded, but ~hyperref~ postpones the loading of
% ~nameref~ too, so this is all in vain.
%% %% TODO v4.2: Test at first occurrence!?
\DeclareOption{hyperref}{\PackageWarningNoLine{lineno}{%
Option [hyperref] is obsolete.
\MessageBreak The hyperref package is detected automatically.}}
\AtBeginDocument{%
\@ifpackageloaded{nameref}{%
\def\@LN@ExtraLabelItems{{}{}{}}}{}}
% (New v4.1)
%
% \subsection{%
% A note on calling so many options
% \unskip}
%
% The number of package options may stimulate worrying about how to
% \emph{enter} all the options that one would like to use---they may
% not fit into one line. Fortunately, you can safely break code lines
% after the commas separating the option names in the ~\usepackage~
% command (no comment marks needed).
%
% \subsection{%
% Execute options
% \unskip}\label{ss:ExOpt}
%
% We stop declaring options and execute the ones that are
% called by the user. (/New v4.1)
\ProcessOptions
% (New v4.1) Now we know whether edtable.sty is wanted
% and (if it is) with which options it is to be called.
\if@LN@edtable \RequirePackage{edtable}[2004/10/12] \fi
% (/New v4.1)
%
% \section{%
% The final touch
% \unskip}
%
% There is one deadcycle for each line number.
\advance\maxdeadcycles 100
\endinput
%
% \section{%
% The user commands
% \unskip}\label{s:UserCmds}
%
% The user commands to turn on and off line numbering
% are
% \begin{description}\item
% [|\linenumbers] \ \par
% Turn on line numbering in the current mode.
%
% \item
% [|\linenumbers*] \ \par$\qquad$
% and reset the line number to 1.
% \def\NL{<number>]}\item
%% %% Boldface italic occurs here, which is evil. (UL)
% [|\linenumbers[\NL] \ \par$\qquad$
% and start with <number>.
% \item
% [|\nolinenumbers] \ \par
% Turn off line numbering.
% \item
% [|\runninglinenumbers*[\NL] \ \par
% Turn on ~running~ line numbers, with the same optional
% arguments as ~\linenumbers~. The numbers are running
% through the text over pagebreaks. When you turn
% numbering off and on again, the numbers will continue,
% except, of cause, if you ask to reset or preset the
% counter.
% \item
% [|\pagewiselinenumbers] \ \par
% Turn on ~pagewise~ line numbers. The lines on each
% page are numbered beginning with one at the first
% ~pagewise~ numbered line.
% \item
% [|\resetlinenumber[\NL] \ \par
% Reset ~[~Set~]~ the line number to 1
% ~[~<number>~]~.
% \item
% [|\setrunninglinenumbers] \ \par
% Switch to ~running~ line number mode. Do \emph{not}
% turn it on or off.
% \item
% [|\setpagewiselinenumbers] \ \par
% Switch to ~pagewise~ line number mode. Do \emph{not}
% turn it on or off.
% \item
% [|\switchlinenumbers*] \ \par
% Causes margin switching in pagewise modes. With the
% star, put the line numbers on the inner margin.
% \item
% [|\leftlinenumbers*] \ \par
% \item
% [|\rightlinenumbers*] \ \par
% Set the line numbers in the left/right margin. With the
% star this works for both modes of operation, without
% the star only for the currently selected mode.
% \item
% [|\runningpagewiselinenumbers] \ \par
% When using the pagewise line number mode, do not
% subtract the page offset. This results in running
% line numbers again, but with the possibility to switch
% margins. Be careful when doing line number
% referencing, this mode status must be the same while
% setting the paragraph and during references.
% \item
% [|\realpagewiselinenumbers] \ \par
% Reverses the effect of ~\runningpagewiselinenumbers~.
% \item
% [|\modulolinenumbers[\NL] \ \par
% Give a number only to lines which are multiples of
% ~[~<number>~]~. If <number> is not specified, the
% current value in the counter ~linenumbermodulo~ is
% retained. <number>=1 turns this off without changing
% ~linenumbermodulo~. The counter is initialized to 5.
%%
%% %% TODO v4.2: `counter', he says. Cf._above.
%%
%% (New v4.00)
% \item
% [|\firstlinenumber] \ \par
% ~\firstlinenumber{~<filino>~}~ brings about that
% (after it) line numbers less than <filino> do
% \emph{not} appear in the margin. Moreover, with
% ~\modulolinenumbers[~<number>~]~, just the line
% numbers which are <filino> plus a multiple of
% <number> are printed.---If you had
% ~\firstlinenumber{~<pos>~}~ with some $\mbox{<pos>}>0$
% and want to switch to printing multiples of, e.g.,
% 4, you best do ~\modulolinenumbers[4]~ and
% ~\firstlinenumber{0}~
%% (/New v4.00)
% \item
% [|\linenumberdisplaymath] \ \par
% Number the lines of a display math in a ~{linenomath}~
% environment, but do not in a ~{linenomath*}~
% environment. This is used by the package option
% ~[mathlines]~.
% \item
% [|\nolinenumberdisplaymath] \ \par
% Do not Number the lines of a display math in a
% ~{linenomath}~ environment, but do in a
% ~{linenomath*}~ environment. This is the default.
% \item
% [|\linelabel] \ \par
% Set a ~\linelabel{~<foo>~}~ to the line number where
% this commands is in. Refer to it with the \LaTeX\
% referencing commands ~\ref{~<foo>~}~ and
% ~\pageref{~<foo>~}~.
% \end{description}
% The commands can be used globally, locally within groups
% or as environments. It is important to know that they
%%
%% %% TODO: \linelabel? others?
%%
% take action only when the ~\par~ is executed. The
%%
%% %% TODO: sure? ~\modulo...~, e.g.? well, in a sense ...
%%
% ~\end{~<mode>~linenumbers}~ commands provide a ~\par~.
% Examples:
% \begin{verse}
% ~{\linenumbers~ <text> ~\par}~ \\
% \ \\
% ~\begin{linenumbers}~ \\
% <text> \\
% ~\end{linenumbers}~ \\
% \ \\
% <paragraph> ~{\linenumbers\par}~ \\
% \ \\
% ~\linenumbers~ \\
% <text> ~\par~ \\
% ~\nolinenumbers~ \\
% \ \\
% ~\linenumbers~ \\
% <paragraph> ~{\nolinenumbers\par}~ \\
% \end{verse}
% (New v4.00)
% However, the examples containing <paragraph> show what you
% should \emph{not} do, at least if you use ~\pagebreak~,
% ~\nopagebreak~, ~\vspace~, ~\\*~ or
% ~\\[~<space>~]~---cf._section_\ref{s:MVadj}.
%
% The same care should be applied to the ``wizard'' devices
% ~\ifLineNumbers~ (section_\ref{s:CtrlLN}) and
% ~\PostponeVadjust~ (section_\ref{ss:PVadj}).
% (/New v4.00)
%
% \subsection{%
% Customization hooks
% \unskip}
%
% There are several hooks to customize the appearance of the
% line numbers, and some low level hooks for special
% effects.
% \begin{description}\item
% [|\thelinenumber] \ \par
% This macro should give the representation of the line
% number in the \LaTeX-counter ~linenumber~. The
% default is provided by \LaTeX: \par$\qquad$
% ~\arabic{linenumber}~
% \item
% [|\makeLineNumberLeft] \ \par
% This macro is used to attach a line number to the left
% of the text page. This macro should fill an ~\hbox to 0pt~
% which will be placed at the left margin of the
% page, with the reference point aligned to the line to
% which it should give a number. Please use the macro
% ~\LineNumber~ to refer to the line number.
%
% The default definition is \par$\qquad$
% ~\hss\linenumberfont\LineNumber\hskip\linenumbersep~
% \item
% [|\makeLineNumberRight] \ \par
% Like ~\makeLineNumberLeft~, but for line numbers on
% the right margin.
%
% The default definition is \par$\qquad$
% ~\linenumberfont\hskip\linenumbersep\hskip\textwidth~ \par$\qquad$
% ~\hbox to\linenumberwidth{\hss\LineNumber}\hss~
% \item
% [|\linenumberfont] \ \par
% This macro is initialized to \par$\qquad$
% ~\normalfont\tiny\sffamily~
% \item
% [|\linenumbersep] \ \par
% This dimension register sets the separation of the
% linenumber to the text. Default value is ~10pt~.
% \item
% [|\linenumberwidth] \ \par
% This dimension register sets the width of the line
% number box on the right margin. The distance of the
% right edge of the text to the right edge of the line
% number is ~\linenumbersep~ + ~\linenumberwidth~. The
% default value is ~10pt~.
% \item
% [|\theLineNumber] (for wizards) \ \par
% This macro is called for printing a ~\newlabel~ entry
% to the aux-file. Its definition depends on the mode.
% For running line numbers it's just ~\thelinenumber~,
% while in pagewise mode, the page offset subtraction
% is done in here.
% \item
% [|\makeLineNumber] (for wizards) \ \par
% This macro produces the line numbers. The definition
% depends on the mode. In the running line numbers
% mode it just expands ~\makeLineNumberLeft~.
% \item
% [|\LineNumber] (for wizards) \ \par
% This macro is called by ~\makeLineNumber~ to typeset
% the line number. This hook is changed by the modulo
% mechanism
%% %%%.
% and by ~\firstlinenumber~.
%% %% New v4.00
% \end{description}
%%
%% TODO: \stepLineNumber---another wizard command!?
%% Not sure, may be retreated.
% \end{document}%D
------------------------------------------------------------------------------
%SSTOPP
%% TODO v4.1+ (search for)
%% TODO v4.2: Check for unwanted comment marks in new comments
%% (resulting from manual aligning): search `New v4.1'
%% and/or ` % '!
%% TODO v4.2: Check for missing comment marks where a paragraph
%% should end/start. Also to prevent empty "code" lines.
%% Especially, new comments at section ends must be
%% followed by comment mark lines.
%% And prevent ~\par~s from blank lines in definitions!
%% See `visual space' above.
%% For proper appearance in lineno.tex, note that a comment
%% in a final code line changes behaviour.
%% TODO v4.2: Require README for redistribution?
%% TODO v4.2: Since discussions of code have increased so much, it
%% would be appropriate not to give to this file
%% extension `.sty' (e.g., `dty'!??). ?? Is quickly read though!
%% A .sty extraction may be possible even if the present
%% file is neither a .doc nor a .dtx. (!???)
%% Use awk line below (etc.) for .doc at least; + .ins or so.
%% ^ must not be caps! To escape awk.
%% TODO v4.2: Underful lines!? (due to long code quotations)
%% TODO v4.2: Sometimes paragraph indents may be appropriate
%% TODO Swap first line (`\iffalse...') with corresponding below.
Or do *not* swap, maybe nawk is more reliable.
%% TODO v4.2: Ponder Stephan's mail from 2004/09/02.
\iffalse; awk '/S[H]ELL0/' lineno.sty|sh;exit;\fi
%% TODO v4.2: 3\relax -> \thr@@, 0\relax -> \z@, 1\relax -> \@ne,
%% 10000 -> \@M, analogously default arguments, \hbox to -> \hb@xt@;
%% use \@ET@makeLineNumber.
%% plus almost all `(UL)'
%% plus lots of bad boxes messages
%% change v4.1 TODOs when postponed
%% remove {old} environments.
------------------------------------------------------------------------------
# awk command lines for v4.00, mixed with former ones:
echo "Don't bother about unknown 'iffalse'." # SHELL1
nawk '/A[W]K/' lineno.sty | nawk -f - lineno.sty >lineno.tex; # SHELL1
latex lineno; latex lineno; latex lineno; latex lineno; # SHELL1
BEGIN{DOC=-1; # AWK DOC A W K
BEGINCODE = "\\begin{code}\\begin{verbatim}"; # AWK
ENDCODE = "\\end{verbatim}\n\\end{code}"; } # AWK
BEGINCODE = "% \\begin{macrocode}"; # DOC A W K
ENDCODE = "% \\end{macrocode}"; } # DOC A W K
/^[ \t]*$/ { ECNT++; next; } # AWK DOC A W K
/\\documentclass/{ sub("article","ltxdoc") } # DOC A W K
/%D$/ { sub("^%* *",""); sub("%D$",""); # DOC A W K
print > "lineno.drv"; next } # DOC A W K
/^%%/ { next; } # AWK DOC A W K
/^%/ { if (!DOC) { print ENDCODE; } # AWK DOC A W K
DOC=1; ECNT=0; # AWK DOC A W K
sub("^% *",""); # AWK
sub("^% *","% "); # DOC A W K
print; next; } # AWK DOC A W K
/%VERSION/ { sub("%VERSION",""); print; next; } # AWK
/%SSTOPP/ { exit } # AWK
DOC<0 { next } # AWK DOC A W K
/^-+-$/ { if (!DOC) print ENDCODE; exit } # AWK DOC A W K
{ if (DOC) { ECNT=DOC=0; print BEGINCODE; } # AWK DOC A W K
while (ECNT>0) { print " "; ECNT--; } # AWK DOC A W K
print $0; } # AWK DOC A W K
# New v4.00, UL: know nothing about awk; found present solution
# in hours of trial and error.
% Earlier (should be inhibited by %SSTOPP above and otherwise):
echo "expect errors for unknown commands 'iffalse' and 'fi'";# SHELL0 SHELL#1
awk '/A[W]K/' lineno.sty | awk -f - lineno.sty >lineno.tex; # SHELL0
latex lineno; latex lineno; latex lineno; latex lineno; # SHELL0
nawk '/A[W]K/' lineno4.sty | nawk -f - lineno4.sty >lineno4.tex; # SHELL#1
latex lineno4; latex lineno4; latex lineno4; latex lineno4; # SHELL#1
awk '/DOC A [W] K/' lineno.sty | awk -f - lineno.sty >lineno.doc; # DOC SH
BEGIN{DOC=-1; # A#WK DOC A W K
BEGINCODE = "\\begin{code}\\begin{verbatim}"; # A#WK
ENDCODE = "\\end{verbatim}\n\\end{code}"; } # A#WK
BEGINCODE = "% \\begin{macrocode}"; # DOC A W K
ENDCODE = "% \\end{macrocode}"; } # DOC A W K
/^[ \t]*$/ { ECNT++; next; } # A#WK DOC A W K
/\\documentclass/{ sub("article","ltxdoc") } # DOC A W K
/%D$/ { sub("^%* *",""); sub("%D$",""); # DOC A W K
print > "lineno.drv"; next } # DOC A W K
/^%%/ { next; } # A#WK DOC A W K
/^%/ { if (!DOC) { print ENDCODE; } # A#WK DOC A W K
DOC=1; ECNT=0; # A#WK DOC A W K
sub("^% *",""); # A#WK
sub("^% *","% "); # DOC A W K
print; next; } # A#WK DOC A W K
DOC<0 { next } # A#WK DOC A W K
/^-+-$/ { if (!DOC) print ENDCODE; exit } # A#WK DOC A W K
{ if (DOC) { ECNT=DOC=0; print BEGINCODE; } # A#WK DOC A W K
while (ECNT>0) { print " "; ECNT--; } # A#WK DOC A W K
print $0; } # A#WK DOC A W K
------------------------------------------------------------------------------
If you are looking here because of the two top lines of the file:
A .tex documentation of this macro file can be obtained by
sh lineno.sty
under UNIX.--You may find this hint little helpful. One
reason may be that the awk versions to which you have access
don't work suitably. Another reason may be that you don't have
access to UNIX (in some sense). However, a .tex, .dvi, or .pdf
version of such a documentation should be available from CTAN,
in the same folder as the present file. When we typed this, that
folder was /macros/latex/contrib/lineno. If this has changed in
the meantime, a CTAN search should lead you to a folder
containing such a documentation. Or you may get help from one of
the e-mail addresses above.
|