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 3042 3043 3044 3045 3046 3047 3048 3049 3050 3051 3052 3053 3054 3055 3056 3057 3058 3059 3060 3061 3062 3063 3064 3065 3066 3067 3068 3069 3070 3071 3072 3073 3074 3075 3076 3077 3078 3079 3080 3081 3082 3083 3084 3085 3086 3087 3088 3089 3090 3091 3092 3093 3094 3095 3096 3097 3098 3099 3100 3101 3102 3103 3104 3105 3106 3107 3108 3109 3110 3111 3112 3113 3114 3115 3116 3117 3118 3119 3120 3121 3122 3123 3124 3125 3126 3127 3128 3129 3130 3131 3132 3133 3134 3135 3136 3137 3138 3139 3140 3141 3142 3143 3144 3145 3146 3147 3148 3149 3150 3151 3152 3153 3154 3155 3156 3157 3158 3159 3160 3161 3162 3163 3164 3165 3166 3167 3168 3169 3170 3171 3172 3173 3174 3175 3176 3177 3178 3179 3180 3181 3182 3183 3184 3185 3186 3187 3188 3189 3190 3191 3192 3193 3194 3195 3196 3197 3198 3199 3200 3201 3202 3203 3204 3205 3206 3207 3208 3209 3210 3211 3212 3213 3214 3215 3216 3217 3218 3219 3220 3221 3222 3223 3224 3225 3226 3227 3228 3229 3230 3231 3232 3233 3234 3235 3236 3237 3238 3239 3240 3241 3242 3243 3244 3245 3246 3247 3248 3249 3250 3251 3252 3253 3254 3255 3256 3257 3258 3259 3260 3261 3262 3263 3264 3265 3266 3267 3268 3269 3270 3271 3272 3273 3274 3275 3276 3277 3278 3279 3280 3281 3282 3283 3284 3285 3286 3287 3288 3289 3290 3291 3292 3293 3294 3295 3296 3297 3298 3299 3300 3301 3302 3303 3304 3305 3306 3307 3308 3309 3310 3311 3312 3313 3314 3315 3316 3317 3318 3319 3320 3321 3322 3323 3324 3325 3326 3327 3328 3329 3330 3331 3332 3333 3334 3335 3336 3337 3338 3339 3340 3341 3342 3343 3344 3345 3346 3347 3348 3349 3350 3351 3352 3353 3354 3355 3356 3357 3358 3359 3360 3361 3362 3363 3364 3365 3366 3367 3368 3369 3370 3371 3372 3373 3374 3375 3376 3377 3378 3379 3380 3381 3382 3383 3384 3385 3386 3387 3388 3389 3390 3391 3392 3393 3394 3395 3396 3397 3398 3399 3400 3401 3402 3403 3404 3405 3406 3407 3408 3409 3410 3411 3412 3413 3414 3415 3416 3417 3418 3419 3420 3421 3422 3423 3424 3425 3426 3427 3428 3429 3430 3431 3432 3433 3434 3435 3436 3437 3438 3439 3440 3441 3442 3443 3444 3445 3446 3447 3448 3449 3450 3451 3452 3453 3454 3455 3456 3457 3458 3459 3460 3461 3462 3463 3464 3465 3466 3467 3468 3469 3470 3471 3472 3473 3474 3475 3476 3477 3478 3479 3480 3481 3482 3483 3484 3485 3486 3487 3488 3489 3490 3491 3492 3493 3494 3495 3496 3497 3498 3499 3500 3501 3502 3503 3504 3505 3506 3507 3508 3509 3510 3511 3512 3513 3514 3515 3516 3517 3518 3519 3520 3521 3522 3523 3524 3525 3526 3527 3528 3529 3530 3531 3532 3533 3534 3535 3536 3537 3538 3539 3540 3541 3542 3543 3544 3545 3546 3547 3548 3549 3550 3551 3552 3553 3554 3555 3556 3557 3558 3559 3560 3561 3562 3563 3564 3565 3566 3567 3568 3569 3570 3571 3572 3573 3574 3575 3576 3577 3578 3579 3580 3581 3582 3583 3584 3585 3586 3587 3588 3589 3590 3591 3592 3593 3594 3595 3596 3597 3598 3599 3600 3601 3602 3603 3604 3605 3606 3607 3608 3609 3610 3611 3612 3613 3614 3615 3616 3617 3618 3619 3620 3621 3622 3623 3624 3625 3626 3627 3628 3629 3630 3631 3632 3633 3634 3635 3636 3637 3638 3639 3640 3641 3642 3643 3644 3645 3646 3647 3648 3649 3650 3651 3652 3653 3654 3655 3656 3657 3658 3659 3660 3661 3662 3663 3664 3665 3666 3667 3668 3669 3670 3671 3672 3673 3674 3675 3676 3677 3678 3679 3680 3681 3682 3683 3684 3685 3686 3687 3688 3689 3690 3691 3692 3693 3694 3695 3696 3697 3698 3699 3700 3701 3702 3703 3704 3705 3706 3707 3708 3709 3710 3711 3712 3713 3714 3715 3716 3717 3718 3719 3720 3721 3722 3723 3724 3725 3726 3727 3728 3729 3730 3731 3732 3733 3734 3735 3736 3737 3738 3739 3740 3741 3742 3743 3744 3745 3746 3747 3748 3749 3750 3751 3752 3753 3754 3755 3756 3757 3758 3759 3760 3761 3762 3763 3764 3765 3766 3767 3768 3769 3770 3771 3772 3773 3774 3775 3776 3777 3778 3779 3780 3781 3782 3783 3784 3785 3786 3787 3788 3789 3790 3791 3792 3793 3794 3795 3796 3797 3798 3799 3800 3801 3802 3803 3804 3805 3806 3807 3808 3809 3810 3811 3812 3813 3814 3815 3816 3817 3818 3819 3820 3821 3822 3823 3824 3825 3826 3827 3828 3829 3830 3831 3832 3833 3834 3835 3836 3837 3838 3839 3840 3841 3842 3843 3844 3845 3846 3847 3848 3849 3850 3851 3852 3853 3854 3855 3856 3857 3858 3859 3860 3861 3862 3863 3864 3865 3866 3867 3868 3869 3870 3871 3872 3873 3874 3875 3876 3877 3878 3879 3880 3881 3882 3883 3884 3885 3886 3887 3888 3889 3890 3891 3892 3893 3894 3895 3896 3897 3898 3899 3900 3901 3902 3903 3904 3905 3906 3907 3908 3909 3910 3911 3912 3913 3914 3915 3916 3917 3918 3919 3920 3921 3922 3923 3924 3925 3926 3927 3928 3929 3930 3931 3932 3933 3934 3935 3936 3937 3938 3939 3940 3941 3942 3943 3944 3945 3946 3947 3948 3949 3950 3951 3952 3953 3954 3955 3956 3957 3958 3959 3960 3961 3962 3963 3964 3965 3966 3967 3968 3969 3970 3971 3972 3973 3974 3975 3976 3977 3978 3979 3980 3981 3982 3983 3984 3985 3986 3987 3988 3989 3990 3991 3992 3993 3994 3995 3996 3997 3998 3999 4000 4001 4002 4003 4004 4005 4006 4007 4008 4009 4010 4011 4012 4013 4014 4015 4016 4017 4018 4019 4020 4021 4022 4023 4024 4025 4026 4027 4028 4029 4030 4031 4032 4033 4034 4035 4036 4037 4038 4039 4040 4041 4042 4043 4044 4045 4046 4047 4048 4049 4050 4051 4052 4053 4054 4055 4056 4057 4058 4059 4060 4061 4062 4063 4064 4065 4066 4067 4068 4069 4070 4071 4072 4073 4074 4075 4076 4077 4078 4079 4080 4081 4082 4083 4084 4085 4086 4087 4088 4089 4090 4091 4092 4093 4094 4095 4096 4097 4098 4099 4100 4101 4102 4103 4104 4105 4106 4107 4108 4109 4110 4111 4112 4113 4114 4115 4116 4117 4118 4119 4120 4121 4122 4123 4124 4125 4126 4127 4128 4129 4130 4131 4132 4133 4134 4135 4136 4137 4138 4139 4140 4141 4142 4143 4144 4145 4146 4147 4148 4149 4150 4151 4152 4153 4154 4155 4156 4157 4158 4159 4160 4161 4162 4163 4164 4165 4166 4167 4168 4169 4170 4171 4172 4173 4174 4175 4176 4177 4178 4179 4180 4181 4182 4183 4184 4185 4186 4187 4188 4189 4190 4191 4192 4193 4194 4195 4196 4197 4198 4199 4200 4201 4202 4203 4204 4205 4206 4207 4208 4209 4210 4211 4212 4213 4214 4215 4216 4217 4218 4219 4220 4221 4222 4223 4224 4225 4226 4227 4228 4229 4230 4231 4232 4233 4234 4235 4236 4237 4238 4239 4240 4241 4242 4243 4244 4245 4246 4247 4248 4249 4250 4251 4252 4253 4254 4255 4256 4257 4258 4259 4260 4261 4262 4263 4264 4265 4266 4267 4268 4269 4270 4271 4272 4273 4274 4275 4276 4277 4278 4279 4280 4281 4282 4283 4284 4285 4286 4287 4288 4289 4290 4291 4292 4293 4294 4295 4296 4297 4298 4299 4300 4301 4302 4303 4304 4305 4306 4307 4308 4309 4310 4311 4312 4313 4314 4315 4316 4317 4318 4319 4320 4321 4322 4323 4324 4325 4326 4327 4328 4329 4330 4331 4332 4333 4334 4335 4336 4337 4338 4339 4340 4341 4342 4343 4344 4345 4346 4347 4348 4349 4350 4351 4352 4353 4354 4355 4356 4357 4358 4359 4360 4361 4362 4363 4364 4365 4366 4367 4368 4369 4370 4371 4372 4373 4374 4375 4376 4377 4378 4379 4380 4381 4382 4383 4384 4385 4386 4387 4388 4389 4390 4391 4392 4393 4394 4395 4396 4397 4398 4399 4400 4401 4402 4403 4404 4405 4406 4407 4408 4409 4410 4411 4412 4413 4414 4415 4416 4417 4418 4419 4420 4421 4422 4423 4424 4425 4426 4427 4428 4429 4430 4431 4432 4433 4434 4435 4436 4437 4438 4439 4440 4441 4442 4443 4444 4445 4446 4447 4448 4449 4450 4451 4452 4453 4454 4455 4456 4457 4458 4459 4460 4461 4462 4463 4464 4465 4466 4467 4468 4469 4470 4471 4472 4473 4474 4475 4476 4477 4478 4479 4480 4481 4482 4483 4484 4485 4486 4487 4488 4489 4490 4491 4492 4493 4494 4495 4496 4497 4498 4499 4500 4501 4502 4503 4504 4505 4506 4507 4508 4509 4510 4511 4512 4513 4514 4515 4516 4517 4518 4519 4520 4521 4522 4523 4524 4525 4526 4527 4528 4529 4530 4531 4532 4533 4534 4535 4536 4537 4538 4539 4540 4541 4542 4543 4544 4545 4546 4547 4548 4549 4550 4551 4552 4553 4554 4555 4556 4557 4558 4559 4560 4561 4562 4563 4564 4565 4566 4567 4568 4569 4570 4571 4572 4573 4574 4575 4576 4577 4578 4579 4580 4581 4582 4583 4584 4585 4586 4587 4588 4589 4590 4591 4592 4593 4594 4595 4596 4597 4598 4599 4600 4601 4602 4603 4604 4605 4606 4607 4608 4609 4610 4611 4612 4613 4614 4615 4616 4617 4618 4619 4620 4621 4622 4623 4624 4625 4626 4627 4628 4629 4630 4631 4632 4633 4634 4635 4636 4637 4638 4639 4640 4641 4642 4643 4644 4645 4646 4647 4648 4649 4650 4651 4652 4653 4654 4655 4656 4657 4658 4659 4660 4661 4662 4663 4664 4665 4666 4667 4668 4669 4670 4671 4672 4673 4674 4675 4676 4677 4678 4679 4680 4681 4682 4683 4684 4685 4686 4687 4688 4689 4690 4691 4692 4693 4694 4695 4696 4697 4698 4699 4700 4701 4702 4703 4704 4705 4706 4707 4708 4709 4710 4711 4712 4713 4714 4715 4716 4717 4718 4719 4720 4721 4722 4723 4724 4725 4726 4727 4728 4729 4730 4731 4732 4733 4734 4735 4736 4737 4738 4739 4740 4741 4742 4743 4744 4745 4746 4747 4748 4749 4750 4751 4752 4753 4754 4755 4756 4757 4758 4759 4760 4761 4762 4763 4764 4765 4766 4767 4768 4769 4770 4771 4772 4773 4774 4775 4776 4777 4778 4779 4780 4781 4782 4783 4784 4785 4786 4787 4788 4789 4790 4791 4792 4793 4794 4795 4796 4797 4798 4799 4800 4801 4802 4803 4804 4805 4806 4807 4808 4809 4810 4811 4812 4813 4814 4815 4816 4817 4818 4819 4820 4821 4822 4823 4824 4825 4826 4827 4828 4829 4830 4831 4832 4833 4834 4835 4836 4837 4838 4839 4840 4841 4842 4843 4844 4845 4846 4847 4848 4849 4850 4851 4852 4853 4854 4855 4856 4857 4858 4859 4860 4861 4862 4863 4864 4865 4866 4867 4868 4869 4870 4871 4872 4873 4874 4875 4876 4877 4878 4879 4880 4881 4882 4883 4884 4885 4886 4887 4888 4889 4890 4891 4892 4893 4894 4895 4896 4897 4898 4899
|
\def\filedate{2011/02/16}
\def\docdate{2011/02/16}
\def\fileversion{1.31}
\def\basename{ntheorem}
% \iffalse
%
% Package 'ntheorem' to use with LaTeX2e
% Copyright 1997 - 2011 by Wolfgang May and Andreas Schedler.
%
% Written and maintained by
% Wolfgang May (Uni Goettingen, formerly Uni Freiburg)
% [theorem-marks, general layout]
% and Andreas Schedler (formerly TU Clausthal; formerly
% Andreas Schlechte)
% [theorem-lists, list layout]
%
%% This file may be distributed and/or modified under the
%% conditions of the LaTeX Project Public License, either version 1.2
%% of this license or (at your option) any later version.
%% The latest version of this license is in
%% http://www.latex-project.org/lppl.txt
%% and version 1.2 or later is part of all distributions of LaTeX
%% version 1999/12/01 or later.
%
% Please send bugreports and suggestions to
%
% Wolfgang May
% Institut f"ur Informatik, Universit"at Goettingen
% e-mail: may@informatik.uni-goettingen.de
%
% Andreas Schedler
% e-mail: ntheorem@andreas-schedler.net
%
% \fi
%
% \CheckSum{2654}
%% \CharacterTable
%% {Upper-case \A\B\C\D\E\F\G\H\I\J\K\L\M\N\O\P\Q\R\S\T\U\V\W\X\Y\Z
%% Lower-case \a\b\c\d\e\f\g\h\i\j\k\l\m\n\o\p\q\r\s\t\u\v\w\x\y\z
%% Digits \0\1\2\3\4\5\6\7\8\9
%% Exclamation \! Double quote \" Hash (number) \#
%% Dollar \$ Percent \% Ampersand \&
%% Acute accent \' Left paren \( Right paren \)
%% Asterisk \* Plus \+ Comma \,
%% Minus \- Point \. Solidus \/
%% Colon \: Semicolon \; Less than \<
%% Equals \= Greater than \> Question mark \?
%% Commercial at \@ Left bracket \[ Backslash \\
%% Right bracket \] Circumflex \^ Underscore \_
%% Grave accent \` Left brace \{ Vertical bar \|
%% Right brace \} Tilde \~}
%
% \RecordChanges
% \changes{v0.80}{1997/02/11}{Started integration of `thmmarks.sty' with
% `newthm.sty':}
% \changes{v0.82}{1997/02/12}{included handling of theoremlists from
% newthm.sty (WM)}
% \changes{v0.85}{1997/02/14}{replaced `bf' by corresponding \LaTeXe-commands (AS)}
% \changes{v0.87}{1997/02/18}{Renamed style to `ntheorem.sty' (WM)}
% \changes{v0.88}{1997/02/18}{fixed some package-infos (AS)}
% \changes{v0.90}{1997/02/19}{changed `addtheoremline, @nthm, @othm' (WM)}
% \changes{v0.90}{1997/02/19}{counter only active if `if@thmmarks' (WM)}
% \changes{v0.91}{1997/02/24}{moved things from @othm, @xnthm, @ynthm to
% @newtheorem, introduced @@name (WM)}
% \changes{v0.91}{1997/02/24}{added name* (no entry in list) (WM)}
% \changes{v0.91}{1997/02/28}{included .sty in .dtx file (WM)}
% \changes{v1.00}{1997/04/21}{First official version, not changed against 0.94 (WM)}
% \changes{v1.01}{1997/05/01}{changed some `def' to `gdef' and `edef'
% to `xdef' in `newtheorem' and related
% macros (WM)}
% \changes{v1.17}{1999/09/06}{Y2K for changes in documentation (AS)}
% \changes{v1.17}{1999/09/06}{included option noconfig in driver (AS)}
% \changes{v1.18}{1999/12/23}{debugged starred version of 'newtheorem'
% (WM, reported by Jonathan King)}
% \changes{v1.18}{1999/12/25}{adapted for complex theorem keywords
% (WM, reported by Jonathan King)}
% \changes{v1.19}{2001/01/12}{adapted to amsmath-2.0 (WM, several
% solutions by Giovanni Dore)}
% \changes{v1.19}{2001/01/13}{added handling of amsmath-labels with thref;
% moved option thref before amsmath (amsmath needs redefinition of
% `label') (WM)}
% \changes{v1.21}{2002/12/30}{added theoremprework and postwork (WM)}
%
% \MakeShortVerb{\|}
% \def\envfont{\normalfont\ttfamily}
% \def\deflabel#1{\ttfamily #1\hfill}
% \def\deflist#1{\begin{list}{}{\settowidth\labelwidth{\ttfamily #1}%
% \setlength\leftmargin\labelwidth
% \addtolength\leftmargin\labelsep
% \let\makelabel\deflabel}}
% \def\enddeflist{\end{list}}
%
% \def\packedlist#1{%
% \begin{list}{}{\settowidth\labelwidth{#1}\setlength\leftmargin\labelwidth
% \addtolength\leftmargin\labelsep
% \topsep=0pt\itemsep=0.05cm\parsep=0.05cm
% \let\makelabel\nlabel}}
% \def\endpackedlist{\end{list}}
% \makeatletter
% \def\packeddescr{%
% \begin{list}{}{\leftmargin0.5cm
% \labelwidth\z@\itemindent-\leftmargin
% \topsep=0pt\itemsep=0.05cm\parsep=0.05cm
% \let\makelabel\nlabel}}
% \def\endpackeddescr{\end{list}}
%
% \def\Codelabel#1{\@bsphack
% \protected@write\@auxout{}{\string\newlabel{#1}{{\number\the
% \c@CodelineNo}{\thepage}}}\@esphack}
% \newcounter{tmpcount}
% \def\Coderef#1#2{\setcounter{tmpcount}{0}\@ifundefined{r@#1}\relax
% {\setcounter{tmpcount}{\ref{#1}}}\relax
% \addtocounter{tmpcount}{#2}\arabic{tmpcount}}
% \makeatother
%
% \def\nlabel#1{#1\hfill}
% \def\nlist#1{\begin{list}{}{\settowidth\labelwidth{#1}%
% \setlength\leftmargin\labelwidth
% \addtolength\leftmargin\labelsep
% \let\makelabel\nlabel}}
% \def\endnlist{\end{list}}
% \def\DANGER{{\LARGE\textbf{! }\rule{0pt}{2ex}}}
% \def\env{\meta{env}}
% \def\envx{\meta{env'}}
%
% \theoremstyle{marginbreak}
% \theoremheaderfont{\normalfont\bfseries}\theorembodyfont{\slshape}
% \theoremsymbol{\ensuremath{\diamondsuit}}
% \theoremseparator{:}
% \newtheorem{Theorem}{Theorem}
%
% \theoremstyle{changebreak}
% \theoremsymbol{\ensuremath{\heartsuit}}
% \theoremindent0.5cm
% \theoremnumbering{greek}
% \newtheorem{Lemma}{Lemma}
%
% \theoremindent0cm
% \theoremsymbol{\ensuremath{\spadesuit}}
% \theoremnumbering{arabic}
% \newtheorem{Corollary}[Theorem]{Corollary}
%
% \theoremstyle{change}
% \theorembodyfont{\upshape}
% \theoremsymbol{\ensuremath{\ast}}
% \theoremseparator{}
% \newtheorem{Example}{Example}
%
% \theoremstyle{plain}
% \theoremsymbol{\ensuremath{\clubsuit}}
% \theoremseparator{.}
% \theoremprework{\bigskip\hrule}
% \theorempostwork{\hrule\bigskip}
% \newtheorem{Definition}{Definition}
%
% \theoremheaderfont{\sc}\theorembodyfont{\upshape}
% \theoremstyle{nonumberplain}
% \theoremseparator{}
% \theoremsymbol{\rule{1ex}{1ex}}
% \newtheorem{Proof}{Proof}%
%
%
% \title{An Extension of the \LaTeX-Theorem Evironment\thanks{This
% file has version number \fileversion{}, last revised \filedate.}}
% \author{\setcounter{footnote}{2}%
% Wolfgang May\thanks{\texttt{may@informatik.uni-goettingen.de}}\\
% Institut f\"ur Informatik, \\
% Universit\"at G\"ottingen \\
% Germany
% \and
% Andreas Schedler\thanks{\texttt{ntheorem@andreas-schedler.net}}\\
% }
% \date{\filedate}
% \maketitle
%
% \begin{abstract}
% \noindent
% |ntheorem.sty| is a package for handling theorem-like
% environments.
% Aditionally to several features for defining the layout of
% theorem-like environments which can be regarded to be standard
% requirements for a theorem-package, it provides solutions for
% two related problems: placement of endmarks and generation of
% lists of theorem-like environments.
%
% In contrast to former approaches, it solves the problem of
% setting endmarks of theorem-like environments (theorems,
% definitions, examples, and proofs) \emph{automatically} at the
% right positions, even if the environment ends with a |displaymath|
% or (even nested) list environments, it also copes with the
% |amsmath| package.
% This is done in the same manner as the handling of labels by
% using the |.aux| file.
%
% It also introduces the generation of lists of theorem-like
% environments in the same manner as |listoffigures|. Additionally,
% more comfortable referencing is supported.
%
% After running \LaTeX\ several times (depending on the complexity
% of references, in general, three runs are sufficient), the endmarks
% are set correctly, and theoremlists are generated.
%
% Since |ntheorem.sty| uses the standard \LaTeX\ |\newtheorem|
% command, existing documents can be switched to
% |ntheorem.sty| without having to change the |.tex| file.
% Also, it is compatible with \LaTeX\ files using |theorem.sty|
% written by Frank Mittelbach.
% \end{abstract}
% \newpage
%
% \tableofcontents
%
%
% \section{Introduction}
%
% For our purposes here, ``theorems'' are labelled enunciations,
% often set off from the main text by extra space and a font change.
% Theorems, corollaries, conjectures, definitions, examples,
% remarks, and proofs are all instances of ``theorems''.
% The ``header'' of
% these structures is composed of the type of the structure
% (such as \textsc{Theorem} or \textsc{Remark}), a number
% which serializes the instances of the same type throughout the
% document, and an optional name (such as ``Correctness Theorem'').
%
% The layout of theorems can be changed by parameters as the fonts
% of the header and the body, the way how to arrange the headers,
% the indentation, and the way of numbering it.
% Confronted with these requirements, |theorem.sty|, a style for
% dealing with theorem layout was developed by Frank Mittelbach
% which was the standard theorem-environment for long time.
%
% But then the desire for additional features like ``endmarks''
% and ``theorem-lists'' arose.
% Two extensions of |theorem.sty| were developped: One for handling
% endmarks, |thmmarks.sty| and one for generating lists, |newthm.sty|.
% Thus, Frank Mittelbach suggested to combine the new features into
% one ``standard-to-be'' package.
% And now, here it is.
%
% \section{The User-Interface}
% \subsection{How to include the package}
%
% The package |ntheorem.sty| is included by
% \begin{quote}
% |\usepackage[|\meta{options}|]{ntheorem}|,
% \end{quote}
% where the optional parameter \meta{options} selects predefined
% configurations and special requirements.
%
% The following \meta{options} are available by now, concerning
% partially independent issues:
% \begin{description}
% \item[Predefined environments:] (see Section~\ref{sec:standard})
% With [standard] and [noconfig], it can be chosen, if and what
% file is used for activating a (user-defined) standard set of
% theorem environments.
% \item[Fancy boxes around theorems:] The [framed] option allows
% to use |framed.sty| that provides boxes even across pagebreaks.
% \item[Activation of endmarks:]
% [thmmarks] enables the automatical placement of endmarks
% (see \ref{sec:general}); when using the |amsmath|-package,
% [thmmarks] must be complemented by [amsmath]
% (see Section~\ref{sec:amslatex}).
% \item[Activation of extended reference features:]
% [thref] enables the extended reference features
% (see Section~\ref{sec-ExtRef}); when using the |amsmath|-package,
% [thref] must be complemented by [amsmath]
% (see Section~\ref{sec:amslatex}).
% \item[Compatibility with amsthm:] option [amsthm] provides
% compatibility with the theorem-layout
% commands of the |amsthm|-package (see Section~\ref{sec:amslatex}).
% \item[Compatibility with hyperref:] option [hyperref] provides
% compability with the |hyperref|-package
% (see Section~\ref{sec:hyperref}).
% \end{description}
%
% The package itself loads |ifthen.sty|.
%
% \subsection{Defining New Theorem Sets}
%
% \DescribeMacro\newtheorem
% The syntax and semantics is exactly the same as in standard
% \LaTeX{}: the command |\newtheorem| defines a new ``theorem set''
% or ``theorem-like structure''.
% Two required arguments name the new environment set and give the
% text to be typeset with each instance of the new ``set'', while
% an optional argument determines how the ``set'' is enumerated:
% \begin{description}
% \item[\ttfamily \bslash newtheorem\{foo\}\{bar\}]
% The theorem set {\envfont foo} (whose name is \texttt{bar})
% uses its own counter.
% \item[\ttfamily \bslash newtheorem\{foo2\}{[foo]}\{bar2\}]
% The theorem set {\envfont foo2} (printed name \texttt{bar2})
% uses the same counter as the theorem set \texttt{foo}.
% \item[\ttfamily \bslash newtheorem\{foo3\}\{bar\}{[section]}]
% The theorem set {\envfont foo3} (printed name \texttt{bar}) is
% enumerated within the counter \texttt{section}, i.e.\ with every
% new |\section| the enumeration begins again with 1, and
% the enumeration is composed from the section-number and the
% theorem counter itself.
% \end{description}
%
% For every environment \meta{name}\ defined by |\newtheorem|,
% \emph{two} enviroments \meta{name} and \meta{name|*|}\ are defined.
% In the main document, they have exactly the same effect, but
% the latter causes no entry in the respective list of theorems
% (cf.\ |\section| and |\section*|), see also Section
% \ref{sec:thmlists}.
%
% \DescribeMacro\renewtheorem
% Theorem sets can be redefined by |\renewtheorem|, with the same arguments
% as explained for |\newtheorem|. When redefining a theorem set, the
% counter is not re-initialized.
%
% \subsection{Defining the Layout of Theorem Sets}\label{sec:general}
%
% For theorem-like environments, the user can set parameters
% by setting several switches and then calling |\newtheorem|.
% The layout of a theorem set is defined with the values of the switches
% at the time |\newtheorem| is called.
%
% \subsubsection{Common Parameters for all Theorem Sets}
%
% \DescribeMacro\theorempreskipamount
% \DescribeMacro\theorempostskipamount
% These additional parameters affect the vertical space around
% theorem environments:
% |\theorempreskipamount| and |\theorempostskipamount| define,
% respectively, the spacing before and after such an environment.
% These parameters apply for all theorem sets and can be manipulated
% with the ordinary length macros. They are rubber lengths,
% (`\textsf{skips}'), and therefore can contain \texttt{plus} and
% \texttt{minus} parts.
%
% \subsubsection{Parameters for Individual Sets}
%
% The layout of individual theorem sets can be further determined
% by switches controlling the appearance of the headers and the
% header-body-layout:
%
% \begin{itemize}
% \item
% \DescribeMacro\theoremstyle
% |\theoremstyle{|\meta{style}|}|: The general structure of the
% theorem layout is defined via its |\theoremstyle|. |\ntheorem|
% provides several predefined styles including those of
% Frank Mittelbach's |theorem.sty|
% (cf.\ Section \ref{sec:predefdstyles}.
% Additional styles can be defined by |\newtheoremstyle|
% (cf.\ Section\ref{sec:newtheoremstyle}).
% \item
% \DescribeMacro\theoremheaderfont
% |\theoremheaderfont{|\meta{fontcmds}|}|: The theorem header is set
% in the font specified by \meta{fontcmds}.
%
% In contrast to |theorem.sty|, |\theoremheaderfont| can be set
% individually for each environment type.
% \item
% \DescribeMacro\theorembodyfont
% |\theorembodyfont{|\meta{fontcmds}|}|: The theorem body is set
% in the font specified by \meta{fontcmds}.
% \item
% \DescribeMacro\theoremseparator
% |\theoremseparator{|\meta{thing}|}|: \meta{thing} separates the
% header from the body of the theorem-environment.
% E.g., \meta{thing} can be
% ``:'' or ``.''.
% \item
% \DescribeMacro\theoremprework
% \changes{v1.30}{2010/08/14}{`theoremprework': added comment on
% `leavevmode' to documentation (WM)}
% |\theoremprework{|\meta{thing}|}|: \meta{thing} is performed
% before starting the theorem structure.
% E.g., \meta{thing} can be |\bigskip\hrule\leavevmode|.
% If the vertical space after your theoremprework does not look as
% intended, try to put |\leavevmode| at its end (as in the above
% example).
% \item
% \DescribeMacro\theorempostwork
% |\theorempostwork{|\meta{thing}|}|: \meta{thing} is performed
% after finishing the theorem structure.
% E.g., \meta{thing} can be |\hrule|.
% \item
% \DescribeMacro\theoremindent
% |\theoremindent{|\meta{dimen}|}| can be used to indent the theorem wrt.\
% the surrounding text.
%
% \DANGER It's a `\textsf(dimen)', so the user shouldn't try to specify a
% \texttt{plus} or \texttt{minus} part, because this leads to an error.
% \item
% \DescribeMacro\theoremnumbering
% |\theoremnumbering{|\meta{style}|}| specifies the appearance of
% the numbering of the theorem set. Possible \meta{styles} are
% |arabic| (default), |alph|, |Alph|, |roman|,
% |Roman|, |greek|, |Greek|, and |fnsymbol|.
%
% Clearly, if a theorem-environment uses the counter of another
% environment type, also the numbering style of that environment
% is used.
% \item
% \DescribeMacro\theoremsymbol
% |\theoremsymbol{|\meta{thing}|}|: This is only active if
% |ntheorem.sty| is loaded with option |[thmmarks]|.
% \meta{thing} is set as an endmark at the end of every instance
% of the environment.
% If no symbol should appear, say |\theoremsymbol{}|.
% \end{itemize}
%
% The flexibility provided by these command should relieve the
% users from the ugly hacking in |\newtheorem| to fit most of
% the requirements stated by publishers or supervisors.
%
% \DescribeMacro\theoremclass
% With the command |\theoremclass{|\meta{theorem-type}|}|
% (where \meta{theorem-type} must be an already defined theorem type),
% these parameters can be set to the values which were used when
% |\newtheorem| was called for \meta{theorem-type}.
%
% With |\theoremclass{LaTeX}|, the standard \LaTeX\ layout can be
% chosen.
%
% \subsubsection{Font Selection}
%
% From the document structuring point of view, theorem environments
% are regarded as special parts inside a document. Furthermore,
% the theorem header is only a distinguished part of a theorem
% environment.
% Thus, |\theoremheaderfont| inherits characteristics of
% |\theorembodyfont| which also inherits in characteristics of
% the font of the surrounding environment.
% Thus, if for example |\theorembodyfont| is |\itshape| and
% |\theoremheaderfont| is |\bfseries| the font selected for the
% header will have the characteristics `bold extended italic'.
% If this is not desired, the corresponding property has to be
% explicitly overwritten in |\theoremheaderfont|, e.g.
% by |\theoremheaderfont{\normalfont\bfseries}|
%
% \subsubsection{Predefined theorem styles}\label{sec:predefdstyles}
%
% The following theorem styles are predefined, covering those
% from |theorem.sty|:
% \begin{deflist}{nonumberbreak:}
% \item[plain]
% This theorem style emulates the original \LaTeX{} definition,
% except that additionally the parameters
% |\theorem...skipamount| are used.
% \item[break]
% In this style, the theorem header is followed by a line
% break.
% \item[change]
% Header number and text are interchanged, without a line break.
% \item[changebreak]
% Like \texttt{change}, but with a line break after the header.
% \item[margin]
% The number is set in the left margin, without a line break.
% \item[marginbreak]
% Like \texttt{margin}, but with a line break after the header.
% \item[nonumberplain]
% Like \texttt{plain}, without number (e.g.\ for proofs).
% \item[nonumberbreak]
% Like \texttt{break}, without number.
% \item[empty]
% No number, no name. Only the optional argument is typeset.
% \end{deflist}
%
% \subsubsection{Default Setting}
%
% If no option is given, i.e.\ |ntheorem.sty| is loaded by
% |\usepackage{ntheorem.sty}|, the following default is set up:
% \begin{quote}
% |\theoremstyle{plain}|,\\
% |\theoremheaderfont{\normalfont\bfseries}| and\\
% |\theorembodyfont{\itshape}|,\\
% |\theoremseparator{}|,\\
% |\theoremindent0cm|,\\
% |\theoremnumbering{arabic}|, \\
% |\theoremsymbol{}|.
% \end{quote}
% Thus, by only saying |\newtheorem{...}{...}|, the user gets
% the same layout as in standard \LaTeX.
%
%
% \subsubsection{A Standard Set of Theorems}\label{sec:standard}
%
% A standard configuration of theorem sets is provided within
% the file |ntheorem.std|, which will be included by the option
% |[standard]|. It uses the |amssymb| and |latexsym| (automatically
% loaded) packages and defines the following sets:
% \begin{nlist}{Definitions:}
% \item[Theorems:] % |Theorem|, |Lemma|, |Proposition|,
% |Corollary|, |Satz|, |Korollar|,
% \item[Definitions:] |Definition|,
% \item[Examples:] |Example|, |Beispiel|,
% \item[Remarks:] |Anmerkung|, |Bemerkung|, |Remark|,
% \item[Proofs:] |Proof| and |Beweis|.
% \end{nlist}
% These theorem sets seem to be the most frequently used environments
% in english and german
% documents.
%
% The layout is defined to be theoremstyle |plain|, bodyfont |\itshape|,
% Headerfont |\bfseries|, and endmark (theoremsymbol)
% |\ensuremath{_\Box}| for all theorem-like environments\footnote{Note,
% that mathmode is ensured for the symbol.}.
% For the definition-, remark- and example-like sets,
% the above setting is used, except bodyfont |\upshape|.
% The proof-like sets are handled a bit differently. There, the layout
% is defined as theoremstyle |nonumberplain|, bodyfont |\upshape|,
% headerfont |\scshape| and endmark |\ensuremath{_\blacksquare}|.
% For a more detailed information look at
% |ntheorem.std| or at the code-section.
%
% \subsubsection{Framed and Boxed Theorems}\label{sec:frames-and-boxes}
%
% With the advent of the |framed| package (by Donald Arseneau) in 2001,
% a feature that has often been asked for for ntheorem could be
% implemented: theorems that are framed, or that are put into a colored
% box.
% It requires to load the |framed| package; shaded theorems also
% require the |pstricks| package.
% Frames and colored boxes are orthogonal to the existing
% theoremstyles -- thus, they can be combined in arbitrary ways.
%
% \DescribeMacro\newframedtheorem
% A theorem type can be framed by defining it by
% \begin{quote}
% |\newframedtheorem{...}{...}|
% \end{quote}
% with the same parameters as usually for |\newtheorem|.
% Note that the use of the |framed| package also allows to have longer
% theorems across a page break framed (in this case, by default, there
% are horizontal lines before and after the page break; this can
% even be circumvented by combining with \texttt{mdframed} package
% (since 2010)).
%
% \DescribeMacro\newshadedtheorem
%
% The same ideas hold for theorems in shaded boxes. The declaration
% \begin{quote}
% |\newshadedtheorem{...}{...}|
% \end{quote}
% declares a theorem environment that is shaded. By default, the
% background color is |gray|. This can be changed by defining \\
% \begin{quote}
% |\shadecolor{|\meta{color}|}|
% \end{quote}
% before declaring the theorem type. Note that later declarations
% of other shaded theorem types can use another shadecolor.
%
% By default, the box is given as a |\psframebox| (see |pstricks|
% package) with shadecolor as |linecolor| and |fillcolor|. All
% these parameters can be changed by setting
% \begin{quote}
% |\def\theoremframecommand{|\meta{any box command}|}|
% \end{quote}
% before declaring the theorem type (for examples, the
% user is referred to section \ref{sec:examples}).
%
% For using pdflatex (where pstricks is not available), e.g.
% |\usepackage{color}| and
% |\theoremframecommand{\colorbox[rgb]{1,.9,.9}}| can be used.
%
% Note that |\theorempreskipamount| and |\theorempostskipamount| are
% applied integrated with the structure of the theorem itself. Thus,
% for framed and shaded theorems, they are applied
% \emph{inside} the frame/shade.
%
% To obtain vertical space \emph{before} and \emph{after} the
% shade or frame, |\theoremframepreskipamount| and
% |\theoremframepostskipamount| can be used (both defined by default to
% 0pt) analogously. (i.e., they are also common to all theorem types.)
%
% \subsubsection{Customization and Local Settings}
%
% Since the user should not change |ntheorem.std|,
% we've added the possibility to use an own configuration-file.
% If one places the file |ntheorem.cfg| in the path searched by
% \TeX, this file is read automatically (if |[standard]|
% is not given). The usage of |ntheorem.cfg| can be prevented by the
% |[noconfig]| option. Thus, just
% a copy of |ntheorem.std| to |ntheorem.cfg| must be made
% which then can freely be modified by the user. Note, that if a
% configuration-file exists, this will always be used (I.e.\ with
% option |standard| and an existing configuration-file, the |.cfg|
% file will be used and the |.std| file won't.
%
% \subsection{Generating Theoremlists}\label{sec:thmlists}
%
% \DescribeMacro\listtheorems
% Similar to the \LaTeX\ command |\listoffigures|,
% any theorem set defined with a |\newtheorem| statement
% may be listed at any place in your document by
% \begin{quote}
% |\listtheorems{|\meta{list}|}|
% \end{quote}
% The argument \meta{list} is a comma-separated list
% of the theorem sets to be listed.
% For a theorem set \meta{name}, only the instances are listed
% which are instantiated by |\begin{|\meta{name}|}|. Those
% instantiated by |\begin{|\meta{name}|*}| are omitted
% (cf.\ |\section| and |\section*|).
%
% For example,
% |\listtheorems{Corollary,Lemma}|
% leads to a list of all instances of one of the theorem sets
% ``Corollary'' or ``Lemma''.
% Note, that the set name given to the command is the first
% argument which is specified by |\newtheorem| which is also
% the one to be used in |\begin{theorem} ... \end{theorem}|.
%
% If |\listtheorems| is called for a set name which is not defined
% via |\newtheorem|, the user is informed that a list is generated,
% but there will be no typeset output at all.
%
% Note that in contrast to similar \LaTeX\ commands like
% |\listoffigures| etc.\, there is no automatically created
% heading. Users have to write it themselves -- but are free
% to choose what they want to have.
%
% \subsubsection{Defining the List Layout}
%
% \DescribeMacro\theoremlisttype
% Theoremlists can be formatted in different ways. Analogous to
% theorem layout, there are several predefined types which can be
% selected by
% \begin{quote}
% |\theoremlisttype{|\meta{type}|}|
% \end{quote}
% The following four \meta{type}s are available (for examples, the
% user is referred to section \ref{sec:examples}).
% \begin{deflist}{allname}
% \item[all] List any theorem of the specified set by number,
% (optional) name and pagenumber. This one is also the
% default value.
% \item[allname] Like |all|, additionally with leading theoremname.
% \item[opt] Analogous to |all|, but only the theorems which have an
% optional name are listed.
% \item[optname] Like |opt|, with leading theoremname.
% \end{deflist}
%
% \subsubsection{Writing Extra Stuff to the Theorem File}
%
% Similar to |\addcontentsline| and |\addtocontents|,
% additional entries to theoremlists are supported.
% Since entries to theoremlists are a bit more intricate than
% entries to the lists maintained by standard \LaTeX\,
% |\addcontentsline| and |\addtocontents| cannot be used in a
% straightforward way\footnote{for a theorem, its number has
% to be stored explicitly since different theorem sets can use
% the same counter. Also, it is optional to reset the counter for
% each section.}.
%
% \DescribeMacro\addtheoremline
% Analogous to |\addcontentsline|, an extra entry for a theorem
% list can be made by
% \begin{quote}
% |\addtheoremline{|\meta{name}|}{|\meta{text}|}|
% \end{quote}
% where \meta{name} is the name of a valid theorem set and \meta{text}
% is the text, which should appear in the list. For example,
% \begin{quote}
% |\addtheoremline{Example}{Extra Entry with number}|
% \end{quote}
% \addtheoremline{Example}{Extra Entry with number}
% generates an entry with the following characteristics:
% \begin{itemize}
% \item The Label of the theorem ``Example'' is used.
% \item The current value of the counter for ``Example'' is used
% \item The current pagenumber is used.
% \item The specified text is the optional text for the theorem.
% \end{itemize}
% Thus, the above command has the same effect as it would be for
% \begin{quote}
% |\begin{Example}[Extra Entry with number] \end{Example}|
% \end{quote}
% except, that there would be no output of the theorem, and the counter
% isn't advanced.
%
% \DescribeMacro{\addtheoremline*}
% Alternatively you can use
% \begin{quote}
% |\addtheoremline*{Example}{Extra Entry}|
% \end{quote}
% \addtheoremline*{Example}{Extra Entry}
% which is the same as above, except that the entry appears without
% number.
%
% \DescribeMacro\addtotheoremfile
% Sometimes, e.g.\ for long lists, special control sequences
% (e.g.\ a pagebreak) or additional text should be inserted into a
% list. This is done by
% \begin{quote}
% |\addtotheoremfile[|\meta{name}|]{|\meta{text}|}|
% \end{quote}
% where \meta{name} is the name of a theorem set and
% \meta{text} is the text to be written into the theorem file.
% If the optional argument \meta{name} is omitted, the given
% text is inserted in every list, otherwise it is only inserted
% for the given theorem set.
%
% \subsection{For Experts: Defining Layout Styles}
% \subsubsection{Defining New Theorem Layouts}\label{sec:newtheoremstyle}
%
% \DescribeMacro\newtheoremstyle
% Additional layout styles for theorems can be defined by
% \begin{quote}
% |\newtheoremstyle{|\meta{name}|}{|\meta{head}|}{|\meta{opt-head}|}|.
% \end{quote}
% After this, |\theoremstyle{|\meta{name}|}| is a valid
% |\theoremstyle|.
% Here, \meta{head} has to be a statement using two arguments,
% |##1|, containing the keyword, and |##2|, containing the number.
% \meta{opt-head} has to be a statement using three arguments where
% the additional argument |##3| contains the optional parameter.
%
% Since \LaTeX\ implements theorem-like environments by |\trivlist|s,
% both header declarations must be of the form
% |\item[... \theorem@headerfont ...]...|, where
% the dotted parts can be formulated by the user.
% If there are some statements producing
% output after the |\item[...]|, you have to care about implicit
% spaces.
%
% Because of the |@|, if |\newtheoremstyle| is used in a
% |.tex| file, it has to be put between |\makeatletter| and
% |\makeatother|.
%
% For details, look at the code documentation or the
% definitions of the predefined theoremstyles.
%
% \DescribeMacro\renewtheoremstyle
% Theorem styles can be redefined by |\renewtheoremstyle|, with the
% same arguments as explained for |\newtheoremstyle|.
%
% \subsubsection{Defining New Theorem List Layouts}\label{sec:listtypes}
%
% \DescribeMacro\newtheoremlisttype
% Analogous, additional layouts for theorem lists can be defined by
% \begin{quote}
% |\newtheoremlisttype{|\meta{name}|}{|\meta{start}|}{|\meta{line}%
% |}{|\meta{end}|}|.
% \end{quote}
% The first argument, \meta{name}, is the name of the listtype,
% which can the be used as a valid |\theoremlisttype|.
% \meta{start} is the sequence of commands to be executed at
% the very beginning of the list.
% Corresponding, \meta{end} will be executed at the end of the list.
% These two are set to do nothing in the standard-types.
% \meta{line} is the part to be called for every entry of the list.
% It has to be a statement using four arguments: |##1| will be
% replaced with the name of the theorem, |##2| with the number,
% |##3| with the theorem's optional text and |##4| with the pagenumber.
%
% WARNING: Self-defined Layouts will break with the |hyperref|-package.
%
% \DescribeMacro\renewtheoremlisttype
% Theorem list types can be redefined by |\renewtheoremlisttype|, with
% the same arguments as explained for |\newtheoremlisttype|.
%
% \subsection{Setting End Marks}
%
% The automatic placement of endmarks is activated by calling
% |ntheorem.sty| with the option |[thmmarks]|.
% Since then, the endmarks are set automatically, there are only
% a few commands for dealing with very special situations.
%
% \DescribeMacro\qed
% \DescribeMacro\qedsymbol
% If in a single environment, the user wants to replace the standard
% endmark by some other, this can be done by saying |\qed|,
% if |\qedsymbol| has been defined by |\qedsymbol{|\meta{something}|}|
% (in option standard, |\qedsymbol| is defined to be the symbol
% used for proofs, since a potential use of this features is to
% close trivial corollaries without explicitly proving them).
%
% Additionally, if in a single environment of a theorem set, that
% is defined without an endmark, the user wants to set an endmark,
% this is done with |\qedsymbol| and |\qed| as described above.
% |\qedsymbol| can be redefined everywhere in the document.
%
% \DescribeMacro\NoEndMark
% \DescribeMacro\TheoremSymbol
% On the other hand, if in some situation, the user decides to set
% the endmark manually (e.g.\ inside a figure or a minipage), the
% automatic handling can be turned off by |\NoEndMark| for the
% current environment.
% Then -- assumed that he current environment is of type \meta{name},
% the endmark can manually be set by just saying
% |\|\meta{name}|Symbol|.
%
% Note that there must be no empty line in the input before the
% |\end{theorem}|, since then, the end mark is ignored (cf.\
% Theorem~\ref{ex-empty-line} in Section~\ref{sec:examples}).
%
% \subsection{Extended Referencing Features}
%
% The extended referencing features are activated by calling
% |ntheorem.sty| with the option |[thref]|.
%
% Often, when writing a paper, one changes propositions into
% theorems, theorems into corollaries, lemmata into remarks
% an so on. Then, it is necessary to adjust also the references,
% i.e., from ``|see Proposition~\ref{completeness}|'' to
% ``|see Theorem~\ref{completeness}|''. For relieving the user
% from this burden, the type of the respective labeled entities
% can be associated with the label itself:
%
% \begin{quote}
% |\label{|\meta{label}|}[|\meta{type}|]|
% \end{quote}
% associates the type \meta{type} with \meta{label}. \\
% This task is automated for theorem-like environments:
%
% \begin{quote}
% |\begin{Theorem}[|\meta{name}|]\label{|\meta{label}|}|
% \end{quote}
% is equivalent to
% \begin{quote}
% |\begin{Theorem}[|\meta{name}|]\label{|\meta{label}|}[Theorem]|
% \end{quote}
%
% The additional information is used by
% \DescribeMacro\thref
% \begin{quote}
% |\thref{|\meta{label}|}|
% \end{quote}
% which outputs the respective environment-type \emph{and} the number,
% e.g., ``Theorem~42''. Note that \LaTeX\ has to be run twice after
% changing labels (similar to getting references OK; in the
% intermediate run, warnings about undefined reference types can
% occur).
%
% The |[thref]| option interferes with the |babel| package, thus in
% this case, |ntheorem| has to be loaded \emph{after} |babel|. It also
% interferes with |amsmath|; see Section~\ref{sec:amslatex}.
%
%
% \subsection{Miscellaneous}
%
% Inside a theorem-like environment \meta{env}, the name given as optional
% argument is accessible by |\|\meta{env}|name|.
%
% \section{Possible Interferences}
% Since |ntheorem| reimplements the handling of theorem-environments
% completely, it is incompatible with every package also concerning
% those macros.
%
% Additionally, the |thmmarks| algorithm for placing endmarks
% requires modifications of several environments (cf.\ Section
% \ref{sec:code}).
% Thus, environments which are reimplemented or additionally defined
% by document options or styles are not covered by the endmark
% algorithm of |ntheorem.sty|.
%
% The |[thref]| option changes the |\label| command and the treatment
% of labels when reading the |.aux| file. Thus it is potentially
% incompatible with all packages also changing |\label| (or
% |\newlabel|). Compatibility with babel's |\newlabel| isa
% achieved if babel is loaded before ntheorem.
%
% \subsection{Interfering Document Options.}
%
% |ntheorem.sty| also copes with the usual document options
% |leqno| and |fleqn|\footnote{although for \texttt{fleqn} and
% long formulas
% reaching to the right margin, equation numbers and endmarks can
% be smashed over the formula since \texttt{fleqn} does not use
% \texttt{\bslash eqno} for controlling the setting of the equation
% number.}.
% If one of those options is used in the |\documentclass|
% declaration, it is automatically recognized by the |thmmarks| part
% of |ntheorem.sty|.
%
% If one of those options is not used in |\documentclass|, but
% with |amsmath| (see next section), it must not be specified
% for |ntheorem|, since all |amsmath| environments detect this option
% by themselves.
%
% \subsection{Combination with amslatex.}\label{sec:amslatex}
%
% |ntheorem.sty| interferes with |amsmath.sty| and |amsthm.sty|.
%
% Note, that the LaTeX amstex package |amstex.sty| (\LaTeX2.09) is
% obsolete and you should use |amsmath| and |amstext| for
% \LaTeXe\ instead. Up to |ntheorem-1.18|, it is compatible with
% |amsmath-1.x|. Since |ntheorem-1.19|, it is (hopefully) compatible
% with |amsmath-2.x|.
%
% We would be happy if someone knowing and using |amsmath| would
% join the development and maintenance of this style.
%
% \subsubsection{amsmath}
%
% Compatibility with amsmath (end marks for math environments, and
% handling of labels in math environments) is provided in the option
% |[amsmath]|, (i.e., if |\usepackage{amsmath}| is used then
% \begin{itemize}
% \item |\usepackage[thmmarks]{ntheorem}| must be completed to \\
% |\usepackage[amsmath,thmmarks]{ntheorem}|), and also
% \item |\usepackage[thref]{ntheorem}| must be completed to \\
% |\usepackage[amsmath,thref]{ntheorem}|).
% \end{itemize}
% Note, that |amsmath| has to be loaded \emph{before} |ntheorem|
% since the definitions have to be overwritten.
%
% \subsubsection{amsthm}
%
% |amsthm.sty| conflicts with the definition of theorem
% layouts in |theorem.sty|, some features of |amsthm.sty|
% have been incorporated into option |[amsthm]| which has
% to be used \emph{instead of} |\usepackage{amsthm}|.
%
% The option provides theoremstyles |plain|, |definition|, and
% |remark|, and a |proof| environment as in |amsthm.sty|.
%
% The |\newtheorem*| command is defined even without this
% option. Note that |\newtheorem*| always switches to the
% nonumbered version of the current theoremstyle which
% thus must be defined.
%
% The command |\newtheoremstyle| is not taken over from
% |amsthm.sty|. Also, |\swapnumbers| is not implemented.
% Here, the user has to express his definitions by the
% |\newtheoremstyle| command provided by |ntheorem.sty|,
% including the use of |\theoremheaderfont| and |\theorembodyfont|.
% The options |[amsthm]| and |[standard]| are in conflict
% since they both define an environment |proof|.
%
% Thus, we recommend not to use
% |amsthm|, since the features for defining theorem-like
% environments in |ntheorem.sty|---following
% |theorem.sty|---seem to be more intuitive and user-friendly.
%
% \subsection{Babel}\label{sec:babel}
%
% The |[thref]| option interferes with the |babel| package, thus in
% case that |babel| is used, |ntheorem| has to be loaded \emph{after}
% |babel|.
%
% \subsection{Hyperref}\label{sec:hyperref}
%
% Since |hyperref| redefines the \LaTeX\ |\contentsline|-command, it
% breaks with |ntheorem| below version 1.17. Since version 1.17, the
% option |[hyperref]| makes |ntheorem| work with |hyperref|.
% The entries of theoremlists then act as hyperlinks to the actual
% theorems. Version 1.31 incorporated some bugfixes wrt.\ hyperref
% for theorem lists and for the |thref| option. One should always
% load |\usepackage{hyperref}| \emph{before} the first use of
% |\newtheorem| to obtain correct handling and referencing of
% counters.
% \medskip
%
% WARNING: The definition and redefinition of Theorem List Layouts
% (see Section~\ref{sec:listtypes}) isn't yet working with
% the |hyperref|-package.
%
%
% \section{Examples}\label{sec:examples}
%
% The setting is as follows.
% \begin{itemize}
% \item For Theorems:
% \begin{verbatim}
% \theoremstyle{marginbreak}
% \theoremheaderfont{\normalfont\bfseries}\theorembodyfont{\slshape}
% \theoremsymbol{\ensuremath{\diamondsuit}}
% \theoremseparator{:}
% \newtheorem{Theorem}{Theorem}\end{verbatim}
% \item For Lemmas:
% \begin{verbatim}
% \theoremstyle{changebreak}
% \theoremsymbol{\ensuremath{\heartsuit}}
% \theoremindent0.5cm
% \theoremnumbering{greek}
% \newtheorem{Lemma}{Lemma}\end{verbatim}
% \item For Corollaries:
% \begin{verbatim}
% \theoremindent0cm
% \theoremsymbol{\ensuremath{\spadesuit}}
% \theoremnumbering{arabic}
% \newtheorem{Corollary}[Theorem]{Corollary}\end{verbatim}
% \item For Examples:
% \begin{verbatim}
% \theoremstyle{change}
% \theorembodyfont{\upshape}
% \theoremsymbol{\ensuremath{\ast}}
% \theoremseparator{}
% \newtheorem{Example}{Example}\end{verbatim}
% \item For Definitions:
% \begin{verbatim}
% \theoremstyle{plain}
% \theoremsymbol{\ensuremath{\clubsuit}}
% \theoremseparator{.}
% \theoremprework{\bigskip\hrule}
% \theorempostwork{\hrule\bigskip}
% \newtheorem{Definition}{Definition}\end{verbatim}
% \item For Proofs (note that |theoremprework| and |theorempostwork|
% are reset -- proofs do not have lines above and below):
% \begin{verbatim}
% \theoremheaderfont{\sc}\theorembodyfont{\upshape}
% \theoremstyle{nonumberplain}
% \theoremseparator{}
% \theoremsymbol{\rule{1ex}{1ex}}
% \newtheorem{Proof}{Proof}\end{verbatim}
% \end{itemize}
% Note, that parts of the setting are inherited. For instance, the
% fonts are not reset before defining ``Lemma'', so the font setting
% of ``Theorem'' is used.
%
% \begin{Example}[Simple one]
% The first example is just a text.
%
% In the next examples, it is shown how an endmark is put at a
% displaymath, a single equation and both types of eqnarrays.
% \end{Example}
%
% \begin{Theorem}[Long Theorem]
% The examples are put into this theorem environment.
%
% The next example will not appear in the list of examples since
% it is written as
% \begin{quote}
% |\begin{Example*} ... \end{Example*}|
% \end{quote}
% \begin{Example*}[Ending with a displayed formula]
% Look, the endmark is really at the bottom of the line:
% \[ f^{(n)}(z) =
% \frac{n!}{2\pi i} \int \limits _{\partial D}
% \frac{f(\zeta)}{(\zeta-z)^{n+1}} d\zeta \]
% \end{Example*}
% At this point, we add an additional entry without number
% in the Example list:
% \begin{verbatim}
% \addtheoremline*{Example}{Extra Entry}\end{verbatim}
% \addtheoremline*{Example}{Extra Entry}
% \begin{Lemma}[Display with array]
% Lemmata are indented and numbered with greek symbols.
% Also for displayed arrays of this form, it looks good:
% \begin{verbatim}
% \[\begin{array}{l}
% a = \begin{array}[t]{l}
% first\ line \\
% second\ line
% \end{array}%
% \mbox{try to put this text in the lowest line}\end{array}\] \end{verbatim}
% Just try to get this with the presented array structure ... without
% using dirty tricks, you can position the outer array either [t], [c],
% or [b], and you will not get the desired effect.
% \[\begin{array}{l}
% a = \begin{array}[t]{l}
% first\ line \\
% second\ line
% \end{array} \mbox{try to put this text in the lowest line}
% \end{array}\]
% \end{Lemma}
% \begin{Lemma}[Equation]
% For |equation|s, we decided to put the endmark after the equation
% number, which is vertically centered.
% Currently, we do not know, how to get the equation number centered and
% the endmark at the bottom (one has to know the internal height of the
% math material) ... If anyone knows, please inform us.
% \begin{equation}
% \int_{\gamma} f(z)\, dz := \int_a^b f(\gamma (t)) \gamma'(t) \, dt
% \end{equation}
% \end{Lemma}
%
% With the |break|-theoremstyles, if the environment is labeled and
% written as
% \begin{quote}
% |\begin{Lemma}[Breakstyle]\label{breakstyle}|
% \end{quote}
% \begin{Lemma}[Breakstyle]\label{breakstyle}
% you see, there is a leading space \dots \\
% If a percent (comment) (or an explicit |\ignorespaces|) is put directly
% after the label, e.g.
% \begin{quote}
% |\begin{Lemma}[Breakstyle]\label{breakstyle}%|,
% \end{quote}
% the space disappears.
%
% From the predefined styles, this is exactly the case for the break-styles.
% That's no bug, it's \LaTeX-immanent.
%
% The example goes on with an |eqnarray|:
% \begin{eqnarray}
% f(z) &=&
% \frac{1}{2\pi i}
% \int \limits_{\partial D} \frac{f(\zeta)}{\zeta-z} d\zeta \\
% &= &
% \frac{1}{2\pi}
% \int \limits_0^{2\pi}
% f(z_0 + re^{it}) dt
% \end{eqnarray}
% \end{Lemma}
%
% \begin{Proof}[of nothing]
% \begin{eqnarray*}
% f(z) &=&
% \frac{1}{2\pi i}
% \int \limits_{\partial D} \frac{f(\zeta)}{\zeta-z} d\zeta \\
% &= &
% \frac{1}{2\pi}
% \int \limits_0^{2\pi}
% f(z_0 + re^{it}) dt
% \end{eqnarray*}
% \end{Proof}
% That's it (the end of the Theorem).
% \end{Theorem}
%
%
% If there are some environments in the same thm-environment,
% the last one gets the endmark:
% \begin{Definition}[With a list]
% \begin{equation}
% \int_{\gamma} f(z)\, dz := \int_a^b f(\gamma (t)) \gamma'(t) \, dt
% \end{equation}
% \begin{itemize}
% \item you've seen, how it works for text and
% \item math environments,
% \item and it works for lists.
% \end{itemize}
% \end{Definition}
%
% \begin{Corollary}[Q.E.D.]
% And here is a trivial corollary, which is ended by
% |\qedsymbol{\textrm{q.e.d}}| and |\qed|.
% \qedsymbol{q.e.d}\qed
% \end{Corollary}
%
% \begin{Example}
% \[ f^{(n)}(z) =
% \frac{n!}{2\pi i} \int \limits _{\partial D}
% \frac{f(\zeta)}{(\zeta-z)^{n+1}} d\zeta \]
% If there is some text after an environment, the endmark is put
% after the text.
% \end{Example}
%
% The next one is done by the following sequence. Note, that
% |~\hfill~| is inserted to prevent \LaTeX\ from using its nested list
% management (a verbatim is also a trivlist),
% i.e.\ this causes \LaTeX\ to start the |verbatim|-Part in a new line.
% \begin{quote}
% |\begin{Example}| \\
% |~\hfill~| \\
% |\begin{verbatim}| \\
% |And, it also works for verbatim|\\
% |... when the \end{verbatim} is in the|\\
% |same line as the text ends. \end{verbatim}|\\
% | ^| this space is important !!\\
% |\end{Example}|
% \end{quote}
%
% \begin{Example}[Using |verbatim|]
% ~\hfill~
% \begin{verbatim}
% And, it also works for verbatim
% ... when the end{verbatim} is in the
% same line as the text ends. \end{verbatim}
% \end{Example}
%
% There must be no empty line in the input before the |\end{theorem}|
% (since then, the end mark is ignored) \\
% \begin{quote}
% |\begin{Theorem}| \\
% |some text ... but no end mark| \\
% | | \\
% |\end{Theorem}|
% \end{quote}
%
% \begin{Theorem}\label{ex-empty-line}
% some text ... but no end mark
%
% \end{Theorem}
%
%
% Now, there is a corollary which should appear with a different
% name in the list of corollaries:
% \begin{quote}
% |\begin{Corollary*}[title in text]\label{otherlabel}| \\
% |...|\\
% |\end{Corollary*}|
% |\addtheoremline{Corollary}{title in list}| \\
% \end{quote}
% \begin{Corollary*}[title in text]\label{otherlabel}\ignorespaces
% let's do something weird:
% \begin{center}
% It also works in the \\
% center \\
% environment.
% \end{center}
% \end{Corollary*}
% \addtheoremline{Corollary}{title in list}
%
% \begin{Theorem}[Quote]
% \begin{quote}
% In quote environments, the text is normally indented from left
% and right by the same space. The endmark is not indented from the
% right margin, i.e., it is typeset to the right margin of the
% surrounding text.
% \end{quote}
% \end{Theorem}
%
% Here is an example for turning off the endmark automatics and
% manual handling:
%
% \begin{verbatim}
% \begin{Theorem}[Manual End Mark]\label{somelabel}
% a line of text with a manually set endmark \hfill\TheoremSymbol \\
% some more text, but no automatic endmark set. \NoEndMark
% \end{Theorem}\end{verbatim}
%
% \begin{Theorem}[Manual End Mark]\label{somelabel}
% a line of text with a manually set endmark \hfill\TheoremSymbol \\
% some more text, but no automatic endmark set. \NoEndMark
% \end{Theorem}
% Also, one should note, that |\hfill| is inserted to set
% the endmark at the right margin.
%
% \begin{Example}[Quickie] It also works for short one's.
% \end{Example}
%
% If you are tired of the greek numbers and the indentation for lemmata ...
% you can redefine it:
% \theoremstyle{changebreak}
% \theoremheaderfont{\normalfont\bfseries}\theorembodyfont{\slshape}
% \theoremsymbol{\ensuremath{\heartsuit}}
% \theoremsymbol{\ensuremath{\diamondsuit}}
% \theoremseparator{:}
% \theoremindent0cm
% \theoremnumbering{arabic}
% \renewtheorem{Lemma}{Lemma}
% \begin{quote}
% |\theoremstyle{changebreak}| \\
% |\theoremheaderfont{\normalfont\bfseries}\theorembodyfont{\slshape}| \\
% |\theoremsymbol{\ensuremath{\heartsuit}}|\\
% |\theoremsymbol{\ensuremath{\diamondsuit}}|\\
% |\theoremseparator{:}|\\
% |\theoremindent0.5cm|\\
% |\theoremnumbering{arabic}|\\
% |\renewtheorem{Lemma}{Lemma}|
% \end{quote}
% \begin{Lemma}
% another lemma, with arabic numbering ... note that the numbering
% continues.
% \end{Lemma}
%
% the optional argument (i.e.\ the `theorem'-name) can be accessed by
% |\|\meta{env}|name|.
%
% \begin{quote}
% |\begin{Theorem}[somename]|\\
% |Obviously, we are in Theorem~\Theoremname|.\\
% |\end{Theorem}|
% \end{quote}
% \begin{Theorem}[somename]
% Obviously, we are in Theorem~\Theoremname.
% \end{Theorem}
%
% This feature can e.g.\ be used for automatically generating
% executable code and a commented solution sheet:
% \begin{quote}
% |\begin{exercise}[quicksort]| \\
% \meta{the exercise text} \\
% |\begin{verbatimwrite}{solutions/\exercisename.c}|\\
% \meta{C-code} \\
% |\end{verbatimwrite}|\\
% |\verbatiminput{solutions/\exercisename.c}|\\
% |\end{exercise}|
% \end{quote}
% This will write the C-code to a file |solutions/quicksort.c| and
% type it also on the solution sheet.
%
% Now, we define an environment |KappaTheorem| which uses the same
% style parameters as Theorems and is numbered together with
% Corollaries (Theorems are also numbered with Corollaries).
% Note that we define a complex header text and a complex end mark.
%
% |\theoremclass{Theorem}|\\
% |\theoremsymbol{\ensuremath{a\atop b}}| \\
% |\newtheorem{KappaTheorem}[Corollary]{\(\kappa\)-Theorem}|
%
% \theoremclass{Theorem}
% \theoremsymbol{\ensuremath{a\atop b}}
% \newtheorem{KappaTheorem}[Theorem]{\(\kappa\)-Theorem}
%
% \begin{KappaTheorem}[1st \(\kappa\)-Theorem]\label{kappatheorem1}
% That's the first Kappa-Theorem.
% \end{KappaTheorem}
%
% \subsection{Extended Referencing Features}\label{sec-ExtRef}[Section]
%
% The standard |\label| command is extended by an optional argument
% which is intended to contain the ``name'' of the structure which
% is labeled, allowing more comfortable referencing; e.g., this
% section has been started with
%
% \begin{quote}
% |\subsection*{Extended Referencing Features}%|\\
% |\label{sec-ExtRef}[Section]|
% \end{quote}
%
% As already stated, for theorem-like environments the optional
% argument is filled in automatically, i.e.,
% \begin{quote}
% |\begin{Theorem}[Manual End Mark]\label{somelabel}|
% \end{quote}
% (cf.\ page~\pageref{somelabel}) is equivalent to
% \begin{quote}
% |\begin{Theorem}[Manual End Mark]\label{somelabel}[Theorem]|
% \end{quote}
%
% |\thref{|\meta{label}|}| additionally outputs the contents
% of the optional argument which has been associated with \meta{label}:
%
% \begin{quote}
% |This is \thref{sec-ExtRef}| \\
% |A theorem end mark has been set manually in \thref{somelabel}.| \\
% |A center environment has been shown in \thref{otherlabel}.| \\
% |The first Kappa-Theorem has been given in \thref{kappatheorem1}.|
% \end{quote}
%
% generates
% \begin{quote}
% This is \thref{sec-ExtRef}. \\
% A theorem end mark has been set manually in \thref{somelabel}.
% A center environment has been shown in \thref{otherlabel}.
% The first Kappa-Theorem has been given in \thref{kappatheorem1}.
% \end{quote}
%
% Here one must be careful that the handling of the optional
% argument is automated
% only for environments defined by |\newtheorem|, i.e., \emph{not}
% for sectioning, equations, or enumerations.
%
% Calling |\thref{|\meta{label}|}| for a label which has been
% set without an optional argument can result in different unintended
% results: If \meta{label} is not inside a theorem-like environment, an
% error message is obtained, otherwise the type of the surrounding
% theorem-like environment is output, e.g., calling |\thref{label}|
% then results in ``Theorem~\meta{number}''!
% Additionally, currently there is no support for multiple references
% such as ``see Theorems~5 and~7'' (this would require plural-forms
% for different languages and handling of |\ref|-lists, probably
% splitting into different sublists for different environments)\footnote{If
% someone is interested in programming this, please contact us; it
% seems to be algorithmically easy, but tedious.}.
%
% \subsection{Framed and Shaded Theorems}
%
% Framed theorem classes are defined as follows:
% \begin{quote}
% |\theoremclass{Theorem}| \\
% |\theoremstyle{break}| \\
% |\newframedtheorem{importantTheorem}[Theorem]{Theorem}|
% \end{quote}
% \theoremclass{Theorem}
% \theoremstyle{break}
% \newframedtheorem{importantTheorem}[Theorem]{Theorem}
% defines important theorems to use the same design as for theorems
% (except that the break header style is used except the margin header
% style), number them with the same counter, and put a frame around
% them:
%
% An instance is created by
% \begin{quote}
% |\begin{importantTheorem}[Important Theorem]| \\
% |This is an important theorem.| \\
% |\end{importantTheorem}|
% \end{quote}
% \begin{importantTheorem}[Important Theorem]
% This is an important theorem. \\
% \end{importantTheorem}
% More important theorems are shaded -- by default in grey:
%
% \begin{quote}
% |\theoremclass{Theorem}| \\
% |\theoremstyle{break}| \\
% |\newshadedtheorem{moreImportantTheorem}[Theorem]{Theorem}| \\
% |\begin{moreImportantTheorem}[More Important Theorem]| \\
% |This is a more important theorem.| \\
% |\end{moreImportantTheorem}|
% \end{quote}
% \theoremclass{Theorem}
% \theoremstyle{break}
% \newshadedtheorem{moreImportantTheorem}[Theorem]{Theorem}
% \begin{moreImportantTheorem}[More Important Theorem]
% This is a more important theorem.
% \end{moreImportantTheorem}
%
% Even more important theorems are shaded in red:
%
% \begin{quote}
% |\theoremclass{Theorem}| \\
% |\theoremstyle{break}| \\
% |\shadecolor{red}| \\
% |\newshadedtheorem{evenMoreImportantTheorem}[Theorem]{Theorem}| \\
% |\begin{evenMoreImportantTheorem}[Even More Important Theorem]| \\
% |This is an even more important theorem. | \\
% |\end{evenMoreImportantTheorem}|
% \end{quote}
% \theoremclass{Theorem}
% \theoremstyle{break}
% \shadecolor{red}
% \newshadedtheorem{evenMoreImportantTheorem}[Theorem]{Theorem}
% \begin{evenMoreImportantTheorem}[Even More Important Theorem]
% This is an even more important theorem.
% \end{evenMoreImportantTheorem}
%
% Most important theorems get a framed, blue colored box with a shadow.
% Here, |\def\theoremframecommand| is used:
%
% \begin{quote}
% |\theoremclass{Theorem}| \\
% |\theoremstyle{break}| \\
% |\shadecolor{red}| \\
% |\def\theoremframecommand{%| \\
% | \psshadowbox[fillstyle=solid,fillcolor=blue,linecolor=black]}| \\
% |\newshadedtheorem{MostImportantTheorem}[Theorem]{Theorem}| \\
% |\begin{MostImportantTheorem}[Most Important Theorem]| \\
% |This is a most important theorem. | \\
% |\end{MostImportantTheorem}|
% \end{quote}
% \theoremclass{Theorem}
% \theoremstyle{break}
% \shadecolor{red}
% \def\theoremframecommand{%
% \psshadowbox[fillstyle=solid,fillcolor=blue,linecolor=black]}
% \newshadedtheorem{MostImportantTheorem}[Theorem]{Theorem}
% \begin{MostImportantTheorem}[Most Important Theorem]
% This is a most important theorem.
% \end{MostImportantTheorem}
%
% \subsection{Lists of Theorems and Friends}
%
% Note, that we put the following lists into the |quote|-environment
% to emphazise them from the surrounding text. So the lists
% are indented slightly at the margin.
%
% With
% \begin{quote}
% |\addtotheoremfile{Added into all theorem lists}|,
% \end{quote}
% in every list, an additional line of text would be inserted.
% But it isn't actually done in this documentation since we want
% to use different list formats.
%
% Only for the list of Examples, this one is added:
% \begin{quote}
% |\addtotheoremfile[Example]{Only concerning Example lists}|
% \end{quote}
% \addtotheoremfile[Example]{Only concerning Example lists}
%
% With
% \begin{quote}
% |\theoremlisttype{all}| \\
% |\listtheorems{Lemma}|,
% \end{quote}
% all lemmas are listed:
% \begin{quote}
% \theoremlisttype{all}
% \listtheorems{Lemma}
% \end{quote}
%
% From the examples, only those are listed which have an optional name:
% \begin{quote}
% |\theoremlisttype{opt}| \\
% |\listtheorems{Example}|
% \end{quote}
% leads to
% \begin{quote}
% \theoremlisttype{opt}
% \listtheorems{Example}
% \end{quote}
% One should note the line \emph{Only concerning example lists}, which
% was added by the |\addtotheoremfile|-statement above.
%
% For the next list, another layout, using the |tabular|-environment,
% is defined:
% \begin{verbatim}
% \newtheoremlisttype{tab}%
% {\begin{tabular*}{\linewidth}{@{}lrl@{\extracolsep{\fill}}r@{}}}%
% {##1&##2&##3&##4\\}%
% {\end{tabular*}}\end{verbatim}
% Thus, by saying
% \begin{quote}
% |\theoremlisttype{tab}|\\
% |\listtheorems{Theorem,importantTheorem,moreImportantTheorem,|
% | evenMoreImportantTheorem,MostImportantTheorem,Lemma},|
% \end{quote}
% theorems (of all importance levels) and lemmata are listed:
% \begin{quote}
% \DeleteShortVerb{\|}
% \newtheoremlisttype{tab}%
% {\begin{tabular*}{\linewidth}{@{}lrl@{\extracolsep{\fill}}r@{}}}%
% {##1&##2&##3&##4\\}%
% {\end{tabular*}}
% \theoremlisttype{tab}
% \listtheorems{Theorem,importantTheorem,moreImportantTheorem,evenMoreImportantTheorem,MostImportantTheorem,Lemma}
% \MakeShortVerb{\|}
% \end{quote}
%
% \LaTeX-lists can also be used to format the theoremlist.
% The input
% \begin{verbatim}
% \newtheoremlisttype{list}%
% {\begin{trivlist}\item}
% {\item[##2 ##1:]\ ##3\dotfill ##4}%
% {\end{trivlist}}
% \theoremlisttype{list}
% \listtheorems{Corollary}\end{verbatim}
% leads to%
% \begin{quote}%
% \DeleteShortVerb{\|}%
% \newtheoremlisttype{list}%
% {\begin{trivlist}}%
% {\item[##2 ##1:]\ ##3\dotfill ##4}%
% {\end{trivlist}}%
% \theoremlisttype{list}\listtheorems{Corollary}%
% \MakeShortVerb{\|}%
% \end{quote}%
% In this example, after the item, \verb*!\ ! is used instead of
% \verb*! !, because in the latter case, |\dotfill| will produce an
% error if the optional argument (|##3|)
% is missing.
%
% \section{The End Mark Algorithm}
%
% \subsection{The Idea}
%
% The handling of endmarks with |thmmarks.sty| is based on the same
% two-pass principle as the handling of labels: the necessary information
% about endmarks is contained in the |.aux| file.
%
% With |thmmarks.sty|, \TeX\ is always aware whether it is in
% some theorem-like environment.
% There, potential positions for endmarks can be
% \begin{enumerate}
% \item\label{elist:1} at the end of simple text lines in open text,
% \item\label{elist:2} at the end of displaymaths,
% \item\label{elist:3} at the end of equations or equationarrays, or
% \item\label{elist:4} at the end of text lines at the end of lists (or, more general,
% |trivlists|, such as |verbatim| or |center|).
% \end{enumerate}
%
% The problem is, that in the cases (\ref{elist:2})--(\ref{elist:4}), the endmarks has to
% be placed in a box which is already shipped out, when
% |\end{...}| is processed.
% Thus, in those situations, \TeX\ needs to know from the |.aux|
% file, whether is has to put an endmark.
%
% When \TeX\ is in a theorem-like environment and comes to one of
% the points mentioned in (\ref{elist:2})--(\ref{elist:4}),
% and the |.aux| file says that there is an endmark, then
% it is put there.
% Anyway, it maintains a counter of the potential positions of an end
% mark in the current theorem-like environment.
% When it comes to an |\end{theorem}|, it looks if it is in
% situation (\ref{elist:1}) (then the endmark is simply put at the end of the
% current line).
% Otherwise, the last horizontal box is already shipped out
% (thus it contains a situation (\ref{elist:2})--(\ref{elist:4})) and the endmark must be
% set in it.
% In this case, a note is written in the |.aux| file, where the
% endmark actually has to be set (ie, at the latest potential point for
% setting an endmark inside the theorem).
%
% \subsection{The Realization}
%
% Let \env\ be a theorem-like environment. Then, additional to
% the counter \env, \TeX\ maintains two counters
% |curr|\env|ctr| and |end|\env|ctr|.
% In the $i$th environment of type \env, |curr|\env|ctr|$=i$
% (the \LaTeX\ counter \env\ cannot be used since a)
% environments can use the counter of other environments, and b)
% often counters are reinitialized inside a document).
% |end|\env|ctr| counts the potential situations for
% putting an endmark inside an environment.
% It is set to 1 when starting an environment. Each time, when
% a situation (\ref{elist:2})--(\ref{elist:4}) is reached, the command
% \begin{quote}
% |\mark|$<$|\thm@romannum{curr|env|ctr}|$>$\env
% $<$|\thm@romannum{end|\env|ctr}|$>$
% \end{quote}
% is called (where |\thm@romannum| just writes the value of a counter
% as its roman numeral representation, e.g., 17 as xvii). \\
% ($<$|\thm@romannum{curr|\env|ctr}|$>$\env
% $<$|\thm@romannum{end|\env|ctr}|$>$
% uniquely identifies all situations (\ref{elist:2})--(\ref{elist:4}) in a document).
%
% If at this position an endmark has to be set,
% \begin{quote}
% |\mark|$<$|\thm@romannum{curr|\env|ctr}|$>$\env
% $<$|\thm@romannum{end|\env|ctr}|$>$
% \end{quote}
% is defined in the |.aux| file to be |\end|\env|Symbol|,
% otherwise it is undefined and simply ignored.
%
% When \TeX\ comes to an |\end{|\env|}|, it looks if it is in
% situation (\ref{elist:1}). If so, the endmark is simply put at the end of the
% current line.
% Otherwise,
% \begin{quote}
% |\def\mark|$<$|\thm@romannum{curr|env|ctr}|$>$\env|%|\\
% $<$|\thm@romannum{end|\env|ctr}|$>$|{|\env|Symbol}|
% \end{quote}
% is written to the |.aux| file for setting the endmark
% at the latest potential position inside the theorem in the next run.
%
% \begin{Theorem}[Correctness]
% \begin{enumerate}
% \item For a |.tex| file, which does not contain nested theorem-like
% environments of the same type, in the above situation, the following
% holds:
% When compiling, at the $i$th situation in the $j$th environment of type
% \env, |mark|$\;j\,$\env$\;i$ is handled.
%
% For |.tex| files which contain nested theorem-like environments of
% the same type, |mark|$\;k\,$\env$\;l$ is handled, where
% $k$ is the number of the latest environment of type \env\ which
% has been called at this moment, and $l$ is the number of situations
% (\ref{elist:2})--(\ref{elist:4}) which have occurred in
% environments of type \env\ since
% the the $k$th |\begin{|\env|}|.
%
% \item When finishing an environment, either an endmark is set directly
% (when in a text line) or an order to put the end symbol at the latest
% potential position is written to the |.aux| file.
% \end{enumerate}
% \end{Theorem}
%
% \begin{Theorem}[Completeness]
% The handling of endmarks is complete wrt.\ plain text, |displaymath|,
% |equation|,\\ |eqnarray|, |eqnarray*|, and all environments
% ended by |endtrivlist|, including |center| and
% |verbatim|.
% \end{Theorem}
%
% So, where can be bugs ?
% \begin{itemize}
% \item in the plain \TeX\ handling of endmarks,
% \item in some special situations which have not been tested yet,
% \item in some special environments which have not been tested yet.
% \item in the |amsmath| environments. We seldom use them, so we do not
% know their pitfalls, and we ran only general test cases.
% \end{itemize}
%
% \section{Problems and Questions}
% \subsection{Known Limitations}
%
% \begin{itemize}
% \item Since |ntheorem.sty| uses the |.aux| file for storing
% information about the positions of endmarks, \LaTeX\ must be
% run twice for correctly setting the endmarks.
% \item Since |ntheorem.sty| uses the |.aux| file for storing
% information about lists in the |.thm| file, a minimum of
% two runs is needed. If theorems move in any of these
% runs up to five runs can be needed to generate correct lists.
% \item Since we need to expand the optional argument of theorems
% in various ways for the lists, we decided to copy the text verbatim
% into the |.thm| file. Thus, if you use things like |\thesection|
% etc., the list won't show the correct text. Therefore you shouldn't
% use any command that needs to be expanded.
% \item In nested environments ending at the same time,
% only the endmark for the inner environment is set, as the following
% example shows:
% \begin{verbatim}
% \begin{Lemma}
% Some text.
% \begin{Proof} The Proof \end{Proof}
% \end{Lemma}\end{verbatim}
% yields to
% \begin{Lemma}
% Some text.
% \begin{Proof} The Proof \end{Proof}
% \end{Lemma}
%
% You can handle this by specifying something invisible after the end
% of the inner theorem. Then the endmark for the outer theorem is
% set in the next line:
% \begin{verbatim}
% \begin{Lemma}
% Some text.
% \begin{Proof} The Proof \end{Proof}~
% \end{Lemma}\end{verbatim}
% yields to
% \begin{Lemma}
% Some text.
% \begin{Proof} The Proof \end{Proof}~
% \end{Lemma}
%
% \item Document option |fleqn| is problematic: |fleqn| handles
% equations not by |$$| but by lists (check what happens for
% \begin{quote}
% |\begin{theorem} \[ displaymath \] \end{theorem}|
% \end{quote}
% in standard \LaTeX:
% The displaymath is \emph{not} set in an own line).
% Also, for long formulas, the equation number and the endmark are
% smashed into the formula at the right text margin.
% \item Naturally, |ntheorem.sty| will not work correctly in
% combination with other styles which change the handling
% of
% \begin{enumerate}
% \item theorem-like environments, or
% \item environments concerned with the handling of endmarks, e.g.
% |\[...\]|, |eqnarray|, etc.
% \end{enumerate}
% \item |ntheorem.sty| is compatible with Frank Mittelbach's
% |theorem.sty|, which is the most widespread style for setting
% theorems.
%
% It cannot be used \emph{with} |theorem.sty|, but it can be
% used instead of it.
% \end{itemize}
%
% \subsection{Known ``Bugs'' and Problems}
%
% \begin{itemize}
% \item Ending a theorem \emph{directly} after the text, e.g.
% \begin{quote}
% |\begin{Theorem} text\end{Theorem}|
% \end{quote}
% suppresses the endmark:
% \begin{Theorem} text\end{Theorem}
% Therefore a space or a newline should be inserted
% before |\end{...}|.
% \item With theoremstyle break, if the linebreak would cause
% ugly linebreaking in the following text, it is suppressed.
% \end{itemize}
%
% \subsection{Open Questions}
% \begin{itemize}
% \item
% For |equation|s, we decided to put the endmark after the equation
% number, which is vertically centered.
% Currently, we do not know, how to get the equation number centered and
% the endmark at the bottom (one has to know the internal height of the
% math material).
% \item
% The placement of endmarks is mainly based on a check whether \LaTeX\
% is in an ordinary text line when encountering an end-of-environment.
% This question is \emph{partially} answered by |\ifhmode|: In a text
% line, \LaTeX\ is always in |\hmode|.
% But, after an displaymath, \LaTeX\ is also in |\hmode|. Thus,
% additionally |\lastskip| is checked: after a displaymath,
% |\lastskip|=0 holds.
% In most situations, when text has been written into a line,
% |\lastskip| $\neq$ 0. But, this does not hold, if the source code
% is of the following form: |...text\label{bla}|: then, |\lastskip|=0.
% In those situations, the endmark is suppressed. \\
% ?? How can it be detected whether \LaTeX\ has just ended a displaymath?
% \item
% The above problem with the label: The break style enforces a linebreak
% by |\hfill\penalty-8000| after the |\trivlist|-item. Thus, \TeX\
% gets back into the horizontal mode. The label places a ``whatsit''
% somewhere ... and, it seems that the ``whatsit'' makes \TeX\ think
% that there is a line of text.
% \end{itemize}
% If someone has a solution to one of those questions, please inform us.
% (You can be sure to be mentioned in the Acknowledgements.)
%
% \section{Code Documentation}\label{sec:code}
% \iffalse
% \subsection{The documentation driver file}
%
% The next bit of code contains the documentation driver file for
% \TeX{}, i.e., the file that will produce the documentation you are
% currently reading. It will be extracted from this file by the
% \texttt{docstrip} program. Since it is the first code in the file
% one can alternatively process this file directly with \LaTeXe{} to
% obtain the documentation.
%
% \begin{macrocode}
%<*driver>
\documentclass{ltxdoc} \usepackage{latexsym}
\usepackage{framed} \usepackage{pstricks}
\usepackage[thmmarks,thref,noconfig,framed]{ntheorem} \parindent0pt\hfuzz2pt
\setlength{\textwidth}{360pt}
\begin{document}
\DocInput{ntheorem.dtx}
\end{document}
%</driver>
% \end{macrocode}
%\fi
% \subsection{Documentation of the Macros}
% \setcounter{CodelineNo}{0}
%\iffalse
%<*package>\fi
% \begin{macrocode}
\typeout{Style `\basename', Version \fileversion\space <\filedate>}
\ProvidesPackage{ntheorem}[\filedate \space\fileversion]
\RequirePackage{ifthen}%
\newif\if@thmmarks\@thmmarksfalse
\newif\if@thref\@threffalse
\newif\ifthm@tempif
% \end{macrocode}
%
% general setup. \medskip
%
% \subsubsection{Thmmarks-Related Stuff}
%
% \setcounter{CodelineNo}{0}
% \changes{v0.87}{1997/02/18}{option 'thmmarks' added (WM)}
% \begin{macrocode}
\DeclareOption{thmmarks}{%*********************************
\PackageInfo{\basename}{Option `thmmarks' loaded}%
%
\@thmmarkstrue
\newcounter{endNonectr}
\newcounter{currNonectr}
\newif\ifsetendmark\setendmarktrue
% \end{macrocode}
%
% activate placement of endmarks and define counters for upper
% level. \\
% |\ifsetendmark|: true if an endmark has to be set in a complex
% situation which must be handled by the |.aux| file.
% For further comments see |\@endtheorem|.
%
%
% \begin{macro}{\thm@romannum}
% \changes{v1.28}{2009/07/02}{duplicate latex's definition (WM),
% reported by Ch. Garcia Duarte}
% The functionality of |latex.ltx|'s |\roman| command converts
% numbers into strings, e.g., 17 into xvii. It is used to put
% notes into the |.aux| file. It must be
% locally defined, just duplicating the definition of |\roman| in
% latex.ltx since some packages redefine |\roman|:
% \begin{macrocode}
\gdef\thm@romannum#1{\expandafter\thm@roman@num\csname c@#1\endcsname}%
\gdef\thm@roman@num#1{\romannumeral #1}%
% \end{macrocode}
% \end{macro}
%
% In the following, all relevant environments are changed for
% handling potential end mark positions:
%
% \paragraph{Changes to List Environment}\ \\
% Original: ltlists.dtx
%
% \begin{macro}{\endtrivlist}
% \changes{v1.19}{2001/01/13}{changed hbox into unskip (OK/WM)}
% Replaces \LaTeX's |\endtrivlist|. An augmented functionality of
% \LaTeX's |\endtrivlist| is contained in |\@endtrivlist|.
%
% \begin{macrocode}
\gdef\endtrivlist{%
\@endtrivlist{\PotEndMark{\unskip\nobreak\hfill\nobreak}}}
% \end{macrocode}
%
% At an |\endtrivlist| (which is called at the end
% of |\list| environments and several other environments),
% |\@endtrivlist| is called to end the |\trivlist| and
% set a potential position for an endmark at the end of the line if
% \TeX\ is in a text line.
% \end{macro}
%
%
% \begin{macro}{\@endtrivlist}
% A new command] which augments \LaTeX's functionality of
% |\endtrivlist| by checking if an end mark has to be set:
%
% \Codelabel{atendtrivlist}
% \begin{macrocode}
\gdef\@endtrivlist#1{% % from \endtrivlist
\if@inlabel \indent\fi
\if@newlist \@noitemerr\fi
\ifhmode
\ifdim\lastskip >\z@ #1\unskip \par %<<<<<<<<<<<<<<<<<<<<<<
\else \unskip \par \fi
\fi
\if@noparlist \else
\ifdim\lastskip >\z@
\@tempskipa\lastskip \vskip -\lastskip
\advance\@tempskipa\parskip \advance\@tempskipa -\@outerparskip
\vskip\@tempskipa
\fi
\@endparenv
\fi}
% \end{macrocode}
%
% New: parameter |#1|. \\
% |#1| is executed when the |\trivlist| ends with a text line (ie the
% endmark can be put simply at the end of the line): \\
% Line \Coderef{atendtrivlist}{5}:
% case split: if in |hmode| and |\lastskip| $>$ 0,
% then \TeX\ is in a text line, the endmark is set here.
% \end{macro}
%
% \paragraph{Changes to Math Environments}\ \\
% Original: ltmath.dtx
%
% \begin{macro}{\endequation}
% For equations, end marks are placed behind the equation number:
% \Codelabel{standard-endequation}
% \begin{macrocode}
\gdef\SetMark@endeqn{\quad}% as default, cf. option leqno
\gdef\endequation{\eqno \hbox{\@eqnnum \PotEndMark{\SetMark@endeqn}}%
$$\global\@ignoretrue}
% \end{macrocode}
%
% \begin{packeddescr}
% \item[Line \Coderef{standard-endequation}{1}:]
% As default, work for equation numbers at the right:
% Then, a |\quad| is placed between equation number and endmark.
% \item[Line \Coderef{standard-endequation}{2}:]
% In addition to the equation number (set by |\@eqnnum| at the
% right of the line) |\SetMark@endeqn| is carried out.
% \end{packeddescr}\end{macro}
%
% \begin{macro}{\[}
% \changes{v1.27}{2008/06/18}{fixed: start array with no additional
% space (WM, reported by Tillmann Berg)}
% \changes{v1.28}{2009/07/02}{replaced roman by thm@romannum (WM)}
% If an end mark is set, a displaymath is put into box such that
% the end marks appears at its bottom level at the right. Thus, also
% the definition of |\[| has to be changed:
% \Codelabel{st-b-displ}
% \begin{macrocode}
\gdef\[{%
\relax\ifmmode
\@badmath
\else
\ifvmode
\nointerlineskip
\makebox[.6\linewidth]%
\fi
$$\stepcounter{end\InTheoType ctr}%
\@ifundefined{mark\thm@romannum{curr\InTheoType ctr}%
\InTheoType\thm@romannum{end\InTheoType ctr}}{\relax}%
{\ifx\csname\InTheoType Symbol\endcsname\@empty\else
\boxmaxdepth=.5ex\begin{array}[b]{@{}l}%
\boxmaxdepth=\maxdimen\displaystyle\fi}%
\addtocounter{end\InTheoType ctr}{-1}%
%%$$ BRACE MATCH HACK
\fi}
% \end{macrocode}
%
% \begin{packeddescr}
% \item[Lines \Coderef{st-b-displ}{2}--\Coderef{st-b-displ}{8},
% \Coderef{st-b-displ}{16}, \Coderef{st-b-displ}{17}:]
% the old definition.
% \item[Lines \Coderef{st-b-displ}{9}--\Coderef{st-b-displ}{12}:]
% The end position of a displaymath inside a theorem-environment
% corresponds to |end\InTheoType ctr|+1.
% An endmark has to be set there, if \\
% \hspace*{0.5cm} |\mark|$<$|\thm@romannum{curr#1ctr}|$>$|#1|%
% $<$|\thm@romannum{end#1ctr}|$+1>$
% is defined and not the empty symbol.
% \item[Lines \Coderef{st-b-displ}{13}--\Coderef{st-b-displ}{14}:]
% If so, the whole displayed stuff is put in an array with
% maximal depth 0.5|ex| and vertically adjusted with its bottom line
% (then, the endmarks will appear adjusted to its bottom line).
% \item[Line \Coderef{st-b-displ}{15}:]The counter has to be re-decremented.
% \end{packeddescr}\end{macro}
%
% \begin{macro}{\]}
% \changes{v1.28}{2009/07/02}{replaced roman by thm@romannum (WM)}
% At the end of a displaymath, the end marks is set at its bottom level:
% \Codelabel{st-e-displ}
% \begin{macrocode}
\gdef\]{%
\stepcounter{end\InTheoType ctr}%
\@ifundefined{mark\thm@romannum{curr\InTheoType ctr}%
\InTheoType\thm@romannum{end\InTheoType ctr}}{\relax}%
{\ifx\csname\InTheoType Symbol\endcsname\@empty\else
\end{array}\fi}%
\addtocounter{end\InTheoType ctr}{-1}%
\relax\ifmmode
\ifinner
\@badmath
\else
\PotEndMark{\eqno}\global\@ignoretrue$$%%$$ BRACE MATCH HACK
\fi
\else
\@badmath
\fi
\ignorespaces}
% \end{macrocode}
%
% \begin{packeddescr}
% \item[Lines \Coderef{st-e-displ}{2}--\Coderef{st-e-displ}{7}:]
% Look, if an endmark has to be set in this displaymath
% (analogous to lines
% \Coderef{st-b-displ}{9}--\Coderef{st-b-displ}{15} of |\def\[|)
% If so, there is an inner array which has to be closed
% (line \Coderef{st-e-displ}{6}).
% \item[Lines \Coderef{st-e-displ}{8}--\Coderef{st-e-displ}{17}:]
% the old definition.
% \item[Line \Coderef{st-e-displ}{12}:] changed to set an endmark at
% the right of the line if necessary (this is done by |\eqno|).
% \end{packeddescr}\end{macro}
%
% \begin{macro}{\endeqnarray}
% For |\eqnarray|s, the end marks is set below the number
% of the last equation:
% \changes{v0.90}{1997/02/19}{fixed endmark for `eqnarrays' (WM)}
% \changes{v0.91}{1997/02/22}{fixed `endeqnarray' (WM)}
% \Codelabel{st-endeqnarray}
% \begin{macrocode}
\gdef\SetMark@endeqnarray#1{\llap{\raisebox{-1.3em}{#1}}}
\gdef\endeqnarray{%
\global\let\Oldeqnnum=\@eqnnum
\gdef\@eqnnum{\Oldeqnnum\PotEndMark{\SetMark@endeqnarray}}%
\@@eqncr
\egroup
\global\advance\c@equation\m@ne
$$\global\@ignoretrue
\global\let\@eqnnum\Oldeqnnum}
% \end{macrocode}
%
% \begin{packeddescr}
% \item[Line \Coderef{st-endeqnarray}{1}:]
% As default work for equation numbers at the right:
% Then, the endmark is placed below the last equation number at the
% right margin.
% \item[New: Lines \Coderef{st-endeqnarray}{3},%
% \Coderef{st-endeqnarray}{4}, \Coderef{st-endeqnarray}{9}:]\
% \item[Line \Coderef{st-endeqnarray}{3}:] save |\@eqnnum|.
% \item[Line \Coderef{st-endeqnarray}{4}:]
% define |\@eqnnum| to carry out |\Oldeqnnum|, then a potential endmark
% position is handled:
% if an endmark is set, between the equation number and the endmark,
% the command sequence |\SetMark@endeqnarray| is carried out --
% there, since |\SetMark@endeqnarray| is a function of one
% argument, the endmark will be this argument.
% \item[Lines \Coderef{st-endeqnarray}{5}--\Coderef{st-endeqnarray}{8}:]
% from |latex.ltx|.
% Line \Coderef{st-endeqnarray}{5} sets the equation number.
% \item[Line \Coderef{st-endeqnarray}{9}:] restore |\@eqnnum|.
% \end{packeddescr}\end{macro}
%
% \begin{macro}{\endeqnarray*}
% In an |\eqnarray*|, the end mark is set at the right of the
% last equation:
% \Codelabel{st-endeqnarray-star}
% \begin{macrocode}
\@namedef{endeqnarray*}{%
% from \@@eqncr:
\let\reserved@a\relax
\ifcase\@eqcnt \def\reserved@a{& & &}\or \def\reserved@a{& &}%
\or \def\reserved@a{&}\else
\let\reserved@a\@empty
\@latex@error{Too many columns in eqnarray environment}\@ehc\fi
\reserved@a {\normalfont \normalcolor \PotEndMark{}}%
\global\@eqnswtrue\global\@eqcnt\z@\cr
%
\egroup
\global\advance\c@equation\m@ne
$$\global\@ignoretrue}
% \end{macrocode}
%
% This is just \LaTeX's |\endeqnarray| where lines
% \Coderef{st-endeqnarray-star}{3}--\Coderef{st-endeqnarray-star}{9}
% are inserted from |\@@eqncr| and augmented (line
% \Coderef{st-endeqnarray-star}{8}) to set a potential endmark
% (with no additional commands) at the end of the current line.
% \end{macro}
%
% \paragraph{Changes to Tabbing Environment}\ \\
% Original: lttab.dtx
%
%\begin{macro}{\endtabbing}%
% \changes{v1.04}{1998/05/26}{added 'endtabbing' (WM)}
% Here, the |\endtrivlist| modification is not sufficient: \LaTeX\ is
% not in hmode when it calls |\endtrivlist| from |\endtabbing|;
% additionally, |\@stopline| already outputs a linebreak.
% Thus, the end mark is inserted \emph{before} |\@stopline| at
% the right margin (using |\`|).
% \begin{macrocode}
\gdef\endtabbing{%
\PotEndMark{\`}\@stopline\ifnum\@tabpush >\z@ \@badpoptabs
\fi\endtrivlist}
% \end{macrocode}
% \end{macro}
%
% \paragraph{Changes to Center Environment}\ \\
% Original: ltmiscen.dtx
%
%\begin{macro}{\endcenter}%
% \changes{v1.28}{2009/07/02}{replaced roman by thm@romannum (WM)}
% In \LaTeX, |\endcenter| just calls |\endtrivlist|.
% Here, the situation is more complex since the the endmark has
% to be put in the last line without affecting its centering:
% if in a text line (only then, here is a potential endmark
% position):
% \begin{macrocode}
\gdef\endcenter{%
\@endtrivlist
{\PotEndMark{\rightskip0pt%
\settowidth{\leftskip}%
{ \csname mark\thm@romannum{curr\InTheoType ctr}\InTheoType
\thm@romannum{end\InTheoType ctr}\endcsname}%
\advance\leftskip\@flushglue\hskip\@flushglue}}}
% \end{macrocode}
%
% The |\rightskip| of the line is set to 0, |\leftskip|
% is set to the width of one space (since on the right, one space is
% added after the text) plus the endmark and infinitely stretchable glue
% (|\@flushglue|), and also the line is continued with
% |\@flushglue| (the actual position is one space after the text),
% and then the endmark is placed (by |\PotEndMark|).
% \end{macro}
%
% \paragraph{Handling of Endmarks}
%
% \begin{macro}{\@endtheorem-thmmarks}
% |\@endtheorem| is called for every |\end{|\env|}|, where \env\ is a
% theorem-like environment. |\@endtheorem| is extended to organize
% the placement of the corresponding end mark
% (|\InTheoType| gives the innermost theorem-like environment,
% i.e.\ the one to be ended):
%
% \Codelabel{atendtheorem}
% \begin{macrocode}
\gdef\@empty{}
\gdef\@endtheorem{%
\expandafter
\ifx\csname\InTheoType Symbol\endcsname\@empty\setendmarkfalse\fi
\@endtrivlist
{\ifsetendmark
\unskip\nobreak\hfill\nobreak\csname\InTheoType Symbol\endcsname
\setendmarkfalse \fi}%
\ifsetendmark\OrganizeTheoremSymbol\else\global\setendmarktrue\fi
\csname\InTheoType @postwork\endcsname
}
% \end{macrocode}
% \changes{v0.91}{1997/02/27}{'@empty' fixed (WM)}
% \changes{v0.94}{1997/03/19}{'setendmarktrue' globalized (WM)}
% \changes{v1.19}{2001/01/13}{changed hbox into unskip (OK/WM)}
% \changes{v1.21}{2002/12/30}{added handling of 'theorempostwork' (WM)}
%
% \begin{packeddescr}
% \item[Lines \Coderef{atendtheorem}{3}, \Coderef{atendtheorem}{4}:]
% if the end symbol of the environment $\env$ to be closed is
% empty, simply no end symbol has to be set (it makes a difference, if no
% end symbol is set, or if an empty end symbol is set).
% \item[Lines \Coderef{atendtheorem}{5}, \Coderef{atendtheorem}{9}:]
% (originally, it calls |\endtrivlist|):
% \item[Lines \Coderef{atendtheorem}{5}, \Coderef{atendtheorem}{7},
% \Coderef{atendtheorem}{8}:]
% |\@endtrivlist| is called to put $\env$|Symbol|
% at the end of the line and set |setendmark| to false
% if \TeX\ is in a text line and |setendmark| is true. \\
% At this point, |setendmark| is false iff the user has disabled
% it locally or the end symbol is empty.
% \item[Line \Coderef{atendtheorem}{6}:] the endmark is not set,
% if |setendmark| is false.
% \item[Line \Coderef{atendtheorem}{9}:]
% if |setendmark| is true, the correct placement of the end
% symbol is organized, else (ie either |setendmarkfalse| is set
% by the user, or the endmark is already set by |\@endtrivlist|)
% reset |setendmark| to true.\\
% For further comments see |\@endtrivlist| and
% |\OrganizeTheoremSymbol|.
% \end{packeddescr}
% The construction in line \Coderef{atendtheorem}{7} guarantees that
% the endmark is put at the end of the line, even if it is the only
% letter in this line.
% \end{macro}
%
% \begin{macro}{\NoEndMark}
% By |\NoEndMark|, the automatical setting of an end mark is blocked
% for the \emph{current} environment.
% \begin{macrocode}
\gdef\NoEndMark{\global\setendmarkfalse}
% \end{macrocode}
% \changes{v0.94}{1997/03/19}{'NoEndMark' introduced (WM)}
% \end{macro}
%
% set |setendmark| to false. It is automatically reset to |true| after
% the end of the current environment.
%
% \begin{macro}{\qed}
% With |\qed|, the user can locally change the end symbol to appear:
% \begin{macrocode}
\gdef\qed{\expandafter\def\csname \InTheoType Symbol\endcsname
{\the\qedsymbol}}%
% \end{macrocode}\end{macro}
%
% When calling |\qed|, the end symbol of the innermost theorem-like
% environment at that time is set to the value stored in |\qedsymbol|
% at that time.
%
% \begin{macro}{\PotEndMark}
% Handling a potential endmark position:
%
% \begin{macrocode}
\gdef\PotEndMark#1{\SetEndMark{\InTheoType}{#1}}%
% \end{macrocode}
%
% Argument: \meta{cmd\_seq}:=|#1| is a command sequence to be
% executed when setting the endmark. \\
% It adds the current theorem type \env\ to the parameters, and
% calls \\
% |\PotEndMark{|\env|}{|\meta{cmd\_seq}|}|.
% \end{macro}
%
% \begin{macro}{\SetEndMark}
% |\SetEndMark| sets an endmark for an environment. It is
% called by |\PotEndMark|.
% \changes{v1.16}{1999/08/05}{extended for handling right indents (quote) (WM)}
% \changes{v1.16}{2001/11/28}{removed tilde in hbox (WM)}
% \changes{v1.28}{2009/07/02}{replaced roman by thm@romannum (WM)}
% \Codelabel{SetEndMark}
% \begin{macrocode}
\gdef\SetEndMark#1#2{%
\stepcounter{end#1ctr}%
\@ifundefined{mark\thm@romannum{curr#1ctr}#1\thm@romannum{end#1ctr}}%
{\relax}%
{#2{\csname mark\thm@romannum{curr#1ctr}#1\thm@romannum{end#1ctr}\endcsname
\ifdim\rightmargin>\z@\hskip-\rightmargin\fi
\hbox to 0cm{}}}}%
% \end{macrocode}
%
% Arguments: \\
% \env:=|#1|: current theorem-environment. \\
% \meta{cmd\_seq}:= |#2|: is a command sequence to be executed when setting
% the endmark. Both arguments are transmitted from by |\PotEndMark|. \\
% \begin{packeddescr}
% \item[Line \Coderef{SetEndMark}{2}:]
% increments |end|\env|ctr| for preparing the next situation
% for setting a potential endmark.
% \item[Line \Coderef{SetEndMark}{3}, \Coderef{SetEndMark}{4}:]
% if
% \begin{quote}
% |\mark|$<$|\thm@romannum{curr|\env|ctr}|$>$\env%
% $<$|\thm@romannum{end|\env|ctr}|$>$
% \end{quote}
% is undefined
% -- which is the case iff at this position no endmark has to be set --,
% nothing is done,
% \item[Line \Coderef{SetEndMark}{5}:]
% otherwise, \meta{cmd\_seq} and then
% \begin{quote}
% |\mark|$<$|\thm@romannum{curr|\env|ctr}|$>$|\env|%
% $<$|\thm@romannum{end|\env|ctr}|$>$,
% \end{quote}
% which is defined in the |.aux| file to be the end symbol are called. \\
% The construction \meta{cmd\_seq}|{|\ldots|}| in line
% \Coderef{SetEndMark}{5} allows the handling of the end symbol as an
% argument of \meta{cmd\_seq} as needed for |\endeqnarray|.
% \item[Line \Coderef{SetEndMark}{6}:]
% By |\hskip-\rightmargin\hbox to 0cm{}|, a negative hspace of
% amount |\rightmargin| is added \emph{after} the end symbol -- thus,
% the symbol is set as there were no right margin (this concerns,
% e.g., |\quote| environments). \\
% (applied only if |\rightmargin| is more than 0 -- otherwise bug
% if preceding line ends with hyphenation.)
% \end{packeddescr}
% \changes{v1.20}{2001/12/30}{apply negative hskip only if more than 0 (WM)}
%\end{macro}
%
% \paragraph{Writing to .aux file.}
% (copied from |\def\label| (ltxref.dtx))
%
% \changes{v0.91}{1997/02/20}{fixed `OrganizeTheoremSymbol' (WM)}
% \changes{v1.20}{2001/10/09}{check that not in vmode in bbsphack (WM)}
% \Codelabel{bbsphack}
% \begin{macrocode}
\newskip\mysavskip
\gdef\@bbsphack{%
\ifvmode\else\mysavskip\lastskip
\unskip\fi}
%
\gdef\@eesphack{%
\ifdim\mysavskip>\z@
\vskip\mysavskip \else\fi}
% \end{macrocode}
% \begin{packeddescr}
% \item[Lines \Coderef{bbsphack}{2}--\Coderef{bbsphack}{4} and
% \Coderef{bbsphack}{5}--\Coderef{bbsphack}{7}]
% are similar to |\@bsphack| and |\@bsphack|
% of latex.ltx. They undo resp.\ redo the last |skip|.
% \end{packeddescr}
% Note that |@bbsphack| and |@eesphack| are also part of the
% thref option. Change both if you change them.
%
% \begin{macro}{\OrganizeTheoremSymbol}
% \changes{v1.28}{2009/07/02}{replaced roman by thm@romannum (WM)}
% The information for setting the end marks is written to the .aux file:
%
% \Codelabel{OrgThSymb}
% \begin{macrocode}
\gdef\OrganizeTheoremSymbol{%
\@bbsphack
\edef\thm@tmp{\expandafter\expandafter\expandafter\thm@meaning
\expandafter\meaning\csname\InTheoType Symbol\endcsname\relax}%
\protected@write\@auxout{}%
{\string\global\string\def\string\mark%
\thm@romannum{curr\InTheoType ctr}\InTheoType \thm@romannum{end\InTheoType ctr}%
{\thm@tmp}}%
\@eesphack}
% \end{macrocode}
%
% \begin{packeddescr}
% \item[Lines \Coderef{OrgThSymb}{5}--\Coderef{OrgThSymb}{7}:]
% Write \\
% |\global\def\mark|$<$|\thm@romannum{curr|\env|ctr}|$>\env
% <$|\thm@romannum{end|\env|ctr}|$>$%
% |{<|\env|Symbol>}|
% to the |.aux| file. \\
% \env :=|\InTheoType| gives the innermost theorem-like environment,
% i.e. the one the end symbol has to be set for.
% \end{packeddescr}\end{macro}
%
% \begin{macrocode}
} % end of option [thmmarks]
% \end{macrocode}
%
% \subsubsection{Option leqno to Thmmarks}
%
% \Codelabel{Optleqno}
% \begin{macrocode}
\DeclareOption{leqno}{% *********************************************
\if@thmmarks
\PackageInfo{\basename}{Option `leqno' loaded}%
\gdef\SetMark@endeqn#1{\hss\llap{#1}}
\gdef\SetMark@endeqnarray#1{\hss\llap{#1}}
\fi}%
% \end{macrocode}
% |leqno| is only active it |thmmarks| is also active. \\
% \begin{packeddescr}
% \item[Line \Coderef{Optleqno}{4}, \Coderef{Optleqno}{5}:]
% Since with |leqno|, the equation number is placed on
% the left, after infinitely stretchable glue, the endmark can be
% set straight at the right margin.
% \end{packeddescr}
%
% \subsubsection{Option fleqn to Thmmarks}
%
% \begin{macrocode}
\DeclareOption{fleqn}{% *********************************************
\if@thmmarks
\PackageInfo{\basename}{Option `fleqn' loaded}%
% \end{macrocode}
%
% |fleqn| is only active it |thmmarks| is also active.
%
% \begin{macro}{\[}
% \changes{v1.27}{2008/06/18}{fixed: start array with no additional
% space (WM, reported by Tillmann Berg)}
% Since |fleqn| treats displayed math as trivlists, it's quite
% another thing:
%
% \Codelabel{fleqn-b-displ}
% \changes{v1.28}{2009/07/02}{replaced roman by thm@romannum (WM)}
% \begin{macrocode}
\renewcommand\[{\relax
\ifmmode\@badmath
\else
\begin{trivlist}%
\@beginparpenalty\predisplaypenalty
\@endparpenalty\postdisplaypenalty
\item[]\leavevmode
\hb@xt@\linewidth\bgroup $\m@th\displaystyle %$
\hskip\mathindent\bgroup
\stepcounter{end\InTheoType ctr}%
\@ifundefined{mark\thm@romannum{curr\InTheoType ctr}%
\InTheoType\thm@romannum{end\InTheoType ctr}}{\relax}%
{\ifx\csname\InTheoType Symbol\endcsname\@empty\else
\boxmaxdepth=.5ex\begin{array}[b]{@{}l}%
\boxmaxdepth=\maxdimen\displaystyle\fi}%
\addtocounter{end\InTheoType ctr}{-1}%
\fi}
% \end{macrocode}
%
% \begin{packeddescr}
% \item[Lines \Coderef{fleqn-b-displ}{1}--\Coderef{fleqn-b-displ}{9},%
% \Coderef{fleqn-b-displ}{17}:]
% the old definition.
% \item[Line \Coderef{fleqn-b-displ}{10}--\Coderef{fleqn-b-displ}{16}:]
% if an endmark has to be set in this displaymath, it
% is put into an array with depth $\le 0.5$|ex|, and vertically
% adjusted to the bottom line.
% \end{packeddescr}\end{macro}
%
% \begin{macro}{\]}
% \changes{v1.28}{2009/07/02}{replaced roman by thm@romannum (WM)}
% Here, the end mark is placed after a |\hfil| ate the end of the line
% containing the displaymath:
%
% \Codelabel{fleqn-e-displ}
% \begin{macrocode}
\renewcommand\]{%
\stepcounter{end\InTheoType ctr}%
\@ifundefined{mark\thm@romannum{curr\InTheoType ctr}%
\InTheoType\thm@romannum{end\InTheoType ctr}}{\relax}%
{\ifx\csname\InTheoType Symbol\endcsname\@empty\else
\end{array}\fi}%
\addtocounter{end\InTheoType ctr}{-1}%
\relax\ifmmode
\egroup $\hfil\PotEndMark{}% $
\egroup
\end{trivlist}%
\else \@badmath
\fi}
% \end{macrocode}
%
% \begin{packeddescr}
% \item[Lines \Coderef{fleqn-e-displ}{2}--\Coderef{fleqn-e-displ}{6}:]
% Look, if an endmark has to be set in this displaymath.
% If so, close the inner array.
% \item[Lines \Coderef{fleqn-e-displ}{8}--\Coderef{fleqn-e-displ}{13}:]
% the old definition.
% \item[Line \Coderef{fleqn-e-displ}{9}:] Added |\PotEndMark|.
% \end{packeddescr}\end{macro}
%
% \begin{macro}{\endequation}
% for equations, the end mark is also set with the equation number:
% \Codelabel{fleqn-endeqn}
% \begin{macrocode}
\gdef\endequation{%
$\hfil % $
\displaywidth\linewidth\hbox{\@eqnnum \PotEndMark{\SetMark@endeqn}}%
\egroup
\endtrivlist}
% \end{macrocode}
%
% \begin{packeddescr}
% \item[Line \Coderef{fleqn-endeqn}{3}:]
% When the equation number is set, also the endmark is set with
% the same trick as for |\endequation| without |fleqn|.
% \end{packeddescr}\end{macro}
%
% \begin{macro}{\endeqnarray}
% When the equation number is set, also the endmark is set with
% the same trick as for |\endeqnarray| without |fleqn| (see
% Lines \Coderef{fleqn-endeqnarray}{2}, \Coderef{fleqn-endeqnarray}{3},%
% \Coderef{fleqn-endeqnarray}{8}):
%
% \Codelabel{fleqn-endeqnarray}
% \begin{macrocode}
\gdef\endeqnarray{%
\global\let\Oldeqnnum=\@eqnnum
\gdef\@eqnnum{\Oldeqnnum\PotEndMark{\SetMark@endeqnarray}}%
\@@eqncr
\egroup
\global\advance\c@equation\m@ne$$% $$
\global\@ignoretrue
\global\let\@eqnnum\Oldeqnnum}
% \end{macrocode}
% \end{macro}
%
% \begin{macrocode}
\fi}% end of option fleqn
% \end{macrocode}
%
% \subsubsection{Extended Referencing Facilities}\label{sec:Referencing}
%
% \begin{macrocode}
\DeclareOption{thref}{%**********************************************
\PackageInfo{\basename}{Option `thref' loaded}%
\@threftrue
% \end{macrocode}
%
% Option |thref| needs a special handling when combined with amsmath.
% This is also a reason why it is handled first.
%
% \begin{macro}{\bbsphack(2)}
% \changes{v1.19}{2001/01/12}{added to thref option (error if thref
% was used without thmmarks; OK/WM)}
% \changes{v1.20}{2001/10/09}{check that not in vmode in bbsphack; (WM)}
% \begin{macrocode}
\newskip\mysavskip
\gdef\@bbsphack{%
\ifvmode\else\mysavskip\lastskip
\unskip\fi}
%
\gdef\@eesphack{%
\ifdim\mysavskip>\z@
\vskip\mysavskip \else\fi}
% \end{macrocode}
% Note that |@bbsphack| and |@eesphack| are also part of the
% thmmarks option. Change both if you change them.
% \end{macro}
%
% \paragraph{Communication of theorem types for references.}
%
% The |thref| functionality needs to know the respective theorem type
% of the referenced
% labels. This is incorporated as additional arguments in |label| and
% |newlabel/@newl@abel|. Note that if the |hyperref| package is used,
% the handling is different (see Option |hyperref|).
%
% \begin{macro}{\label}
% \changes{v1.1}{1998/08/30}{added optional argument to 'label'. (WM)}
% \changes{v1.18}{1999/12/25}{Adapted for complex keywords (WM)}
% The original |\label| macro is extended (cf.\ ltxref.dtx) with an
% optional argument, containing the type of the labeled construct.
% (when option |hyperref| is used, )
% \Codelabel{label}
% \begin{macrocode}
\def\label#1{%
\@ifnextchar[%]
{\label@optarg{#1}}%
{\thm@makelabel{#1}}}
%
\def\thm@makelabel#1{%
\@bbsphack
\edef\thm@tmp{\expandafter\expandafter\expandafter\thm@meaning
\expandafter\meaning\csname\InTheoType Keyword\endcsname\relax}%
\protected@write\@auxout{}%
{\string\newlabel{#1}{{\@currentlabel}{\thepage}}[\thm@tmp]}%
\@eesphack}
%
\def\label@optarg#1[#2]{%
\@bsphack
\protected@write\@auxout{}%
{\string\newlabel{#1}{{\@currentlabel}{\thepage}}[#2]}%
\@esphack}
% \end{macrocode}
%
% \begin{packeddescr}
% \item[|thm@makelabel|:]
% If no optional argument is given, the keyword of the current
% environment type is used instead.
% \item[|label@optarg|:]
% The original definition, extended with the optional argument
% which is appended to the |\newlabel|-command to be written
% to the .aux-file.
% \end{packeddescr}
% \end{macro}
%
% \begin{macro}{\newlabel}
% \changes{v1.1}{1998/08/30}{added modified macro '@newl@bel'. (WM)}
% The original behavior of |\newlabel| (called when evaluating
% the .aux-file) is also adapted. \\
% Original syntax:
% |\newlabel{|\meta{label}|}{{|\meta{section}|}{|\meta{page}|}}|\\
% Modified syntax:
% |\newlabel{|\meta{label}|}|%
% |{{|\meta{section}|}{|\meta{page}|}}[|\meta{type}|]|\\
% Definition of |\newlabel|: |\def\newlabel{\@newl@bel r}|. \\
% Therefore, the modification is encoded into the |\@newl@bel| macro:
%
% \Codelabel{newlabel}
% \changes{v1.18}{1999/12/26}{adapted to babel-3.6 (WM)}
% \begin{macrocode}
\def\@newl@bel#1#2#3{%
\@ifpackageloaded{babel}{\@safe@activestrue}\relax%
\@ifundefined{#1@#2}%
\relax
{\gdef \@multiplelabels {%
\@latex@warning@no@line{There were multiply-defined labels}}%
\@latex@warning@no@line{Label `#2' multiply defined}}%
\global\@namedef{#1@#2}{#3}%
\@ifnextchar[{\set@label@type{#1}{#2}}%]
\relax}%
\def\set@label@type#1#2[#3]{%
\global\@namedef{#1@#2@type}{#3}}
% \end{macrocode}
%
% the macro is called with three arguments (same as originally):\\
% |#1|=|r|, \\
% \meta{labelname} := |#2| is the label name,\\
% |#3| is a pair (section, page-number) consisting of the values
% needed for |\ref| and |\pageref|, respectively.
%
% \begin{packeddescr}
% \item[Line \Coderef{newlabel}{2}:] adaptation to babel
% \item[Lines \Coderef{newlabel}{3}--\Coderef{newlabel}{8}:]
% The original definition (both standard \LaTeX\ and babel).
% \item[Line \Coderef{newlabel}{9}:] if an optional argument
% follows (containing the environment-type), continue with
% |\set@label@type|, otherwise return (the original behavior).
% \item[Lines \Coderef{newlabel}{11},\Coderef{newlabel}{12}:]
% set |\r@|\meta{labelname}|@type| to the type of the
% respective environment.
% \end{packeddescr}
% \end{macro}
% \begin{macro}{\thref}
% \changes{v1.1}{1998/08/30}{added macro 'thref'. (WM)}
% \changes{v1.13}{1998/12/01}{made 'thref' an option. (WM)}
%
% |\thref| is an adaptation of |\ref|:
% \Codelabel{thref}
% \begin{macrocode}
\def\thref#1{%
\expandafter\ifx\csname r@#1@type\endcsname\None
\PackageWarning{\basename}{thref: Reference Type of `#1' on page
\thepage \space undefined}\G@refundefinedtrue
\else\csname r@#1@type\endcsname~\fi%
\expandafter\@setref\csname r@#1\endcsname\@firstoftwo{#1}}
% \end{macrocode}
%
% \begin{packeddescr}
% \item[Lines \Coderef{thref}{1},\Coderef{thref}{6}:]
% similar to |\ref|.
% \item[Line \Coderef{newlabel}{2}:] if a legal theorem type
% is given, then output
% |\r@|\meta{labelname}|@type| and avoid linebreaking
% between the type and the number.
% \end{packeddescr}
% \end{macro}
% \begin{macro}{\testdef}
% \changes{v1.19}{2001/01/12}{added (HO/WM, reported by Hans-Christoph Wirth)}
% \changes{v1.31}{2011/02/08}{changed '@gobbleopt' into 'thm@gobbleopt' after
% nameclash with hyperref) (AS/WM)}
% A problem occurred, when about 250 labels to theorem-like
% environments have been defined: after the end of a document,
% the .aux file is read once more (to check if references changed).
% Here, \LaTeX\ redefines |\@newl@bel| into |\@testdef| -- and
% \LaTeX\ does not know that ntheorem's |\label| has an additional
% optional argument. Thus, the argument values are not processed,
% but are output as normal text. Normally, this did not matter
% since output has already been finished by a |\clearpage| in
% |\end{document}|. For so many labels, a page gets filled
% and the output routine is called.
%
% \Codelabel{testdef}
% \begin{macrocode}
\newcommand\org@testdef{}
\let\org@testdef\@testdef
\def\@testdef#1#2#3{%
\org@testdef{#1}{#2}{#3}%
\@ifnextchar[{\thm@gobbleopt}{}%
}
\newcommand\thm@gobbleopt{}
\long\def\thm@gobbleopt[#1]{}
% \end{macrocode}
% \begin{packeddescr}
% \item[Line \Coderef{testdef}{4}:]
% process the optional argument.
% \end{packeddescr}
% \end{macro}
%
% \begin{macrocode}
}% end of option thref ************************************************
% \end{macrocode}
%
% \subsubsection{Option amsmath to Thmmarks}
% Most of the commands are extensions of commands in |amsmath.sty|.
%
% \begin{macrocode}
\DeclareOption{amsmath}{% ***************************************************
\if@thref
\PackageInfo{\basename}{option `amsmath' handling for `thref' loaded}%
% \end{macrocode}
%
% if |thref| is active, the handling of labels in amsmath equations has also
% to be adapted.
%
% \begin{macro}{ams-thref}
% \changes{v1.19}{2001/01/12}{added handling of thref in ams-equations
% (reported by Lars Relund).}
% \begin{macrocode}
\let\ltx@label\label
% \end{macrocode}
% keep the handling of |\label| ... (the one defined above in the thref option).
%
% amsmath implements a special handling of |\label| inside of displaymath
% environments. It is extended to process the optional argument provided
% be the thref option:
%
% \begin{macrocode}
\global\let\thm@df@label@optarg\@empty
\def\label@in@display#1{%
\ifx\df@label\@empty\else
\@amsmath@err{Multiple \string\label's:
label '\df@label' will be lost}\@eha
\fi
\gdef\df@label{#1}%
\@ifnextchar[{\thm@label@in@display@optarg}{\thm@label@in@display@noarg}%]
}
\def\thm@label@in@display@noarg{%
\global\let\thm@df@label@optarg\@empty
}
\def\thm@label@in@display@optarg[#1]{%
\gdef\thm@df@label@optarg{#1}%
}
% \end{macrocode}
% \changes{v1.22}{2003/06/25}{fixed thm@df@label@optarg (WM, reported by
% Marija Kulas)}
%
% The contents of |\df@label| is handled when the equation is finished.
% (Currently) this happens in three macros. The modification consists
% of the check if |\thm@df@label@optarg| is non-empty (i.e., holds the
% optional argument), and to handle it.
%
% \begin{macrocode}
\def\endmathdisplay@a{%
\if@eqnsw \gdef\df@tag{\tagform@\theequation}\fi
\if@fleqn \@xp\endmathdisplay@fleqn
\else \ifx\df@tag\@empty \else \veqno \alt@tag \df@tag \fi
\ifx\df@label\@empty \else
\ifx\thm@df@label@optarg\@empty \@xp\ltx@label\@xp{\df@label}%
\else \@xp\ltx@label\@xp{\df@label}[\thm@df@label@optarg]\fi
\fi
\fi
\ifnum\dspbrk@lvl>\m@ne
\postdisplaypenalty -\@getpen\dspbrk@lvl
\global\dspbrk@lvl\m@ne
\fi
}
\def\make@display@tag{%
\if@eqnsw
\refstepcounter{equation}%
\tagform@\theequation
\else
\iftag@
\df@tag
\global\let\df@tag\@empty
\fi
\fi
\ifmeasuring@
\else
\ifx\df@label\@empty\else
\ifx\thm@df@label@optarg\@empty \@xp\ltx@label\@xp{\df@label}%
\else \@xp\ltx@label\@xp{\df@label}[\thm@df@label@optarg]\fi
\global\let\df@label\@empty
\fi
\fi
}
\def\endmathdisplay@fleqn{%
$\hfil\hskip\@mathmargin\egroup
\ifnum\badness<\inf@bad \let\too@wide\@ne \else \let\too@wide\z@ \fi
\ifx\@empty\df@tag
\else
\setbox4\hbox{\df@tag
\ifx\thm@df@label@optarg\@empty \@xp\ltx@label\@xp{\df@label}%
\else \@xp\ltx@label\@xp{\df@label}[\thm@df@label@optarg]\fi
}%
\fi
\csname emdf@%
\ifx\df@tag\@empty U\else \iftagsleft@ L\else R\fi\fi
\endcsname
}
% \end{macrocode}
% \changes{v1.29}{2010/06/24}{fixed endmathdisplay@fleqn, make@display@tag,
% endmathdisplay@fleqn (WM, reported by Claas Hemig)}
% \end{macro}
% \begin{macrocode}
\fi
% end of option amsmath/thref ******************************************
\if@thmmarks
\PackageInfo{\basename}{option `amsmath' handling for `thmmarks' loaded}%
\newdimen\thm@amstmpdepth
% \end{macrocode}
% A temporarily used register.
%
% \begin{macro}{\TagsPlusEndmarks}
% \changes{v1.03}{1997/07/15}{Fixed 'TagsPlusEndMarks', introduced
% 'SetOnlyEndMark' and 'SetTagPlusEndMark' (WM)}
% Since |amsmath| uses ``tags'' for setting end marks,
% some macros are defined which prepare tags which include endmarks:
% \Codelabel{EndTags}
% \begin{macrocode}
\gdef\TagsPlusEndmarks{%
\global\let\Old@maketag@@@=\maketag@@@
\global\let\Old@df@tag=\df@tag
\if@eqnsw\SetTagPlusEndMark
\else
\iftag@\SetTagPlusEndMark
\else\SetOnlyEndMark
\fi
\fi}
% \end{macrocode}
% \begin{packeddescr}
% \item[Lines \Coderef{EndTags}{2}, \Coderef{EndTags}{3}:]
% store the original macros.
% \item[Line \Coderef{EndTags}{4}:]
% if equation numbers are set as default, call
% |\SetTagPlusEndMark| to set tag and end mark.
% \item[Lines \Coderef{EndTags}{5}, \Coderef{EndTags}{6}:]
% if a tag is set manually, call
% |\SetTagPlusEndMark| to set tag and end mark.
% \item[Line \Coderef{EndTags}{7}:]
% otherwise, call |\SetOnlyEndMark| to set only an end mark.
% \end{packeddescr}
% \end{macro}
%
% \begin{macro}{\SetOnlyEndMark}
% \Codelabel{OnlyEnd}
% \begin{macrocode}
\gdef\SetOnlyEndMark{%
\global\tag@true
\iftagsleft@
\gdef\df@tag{\hbox
to \displaywidth{\hss\PotEndMark{\maketag@@@}}}%
\else
\gdef\df@tag{\PotEndMark{\maketag@@@}}%
\fi}
% \end{macrocode}
% Set only an end mark:
%
% \begin{packeddescr}
% \item[Line \Coderef{OnlyEnd}{2}:]
% force setting the end mark as a tag:
% \item[Lines \Coderef{OnlyEnd}{4},\Coderef{OnlyEnd}{5}:]
% if tags are set to the left, the tag consists of a
% |\hbox| over the whole displaywidth, with the (potential) endmark
% at its right.
% \item[Line \Coderef{OnlyEnd}{7}:]
% if tags are set to the right, the tag consists only of the
% (potential) endmark.
% \end{packeddescr}
% \end{macro}
%
% \begin{macro}{\SetTagPlusEndMark}
% \Codelabel{TagPlus}
% \changes{v1.26}{2007/10/17}{fixed: box to tagwidth (problem with leqno; WM)}
% \begin{macrocode}
\newdimen{\tagwidth}
\gdef\SetTagPlusEndMark{%
\iftagsleft@
\gdef\maketag@@@##1{%
\settowidth{\tagwidth}{$##1$}%% %% WM 17.10.2007
\hbox to \tagwidth{%
\hbox to \displaywidth{\m@th\normalfont##1%
\hss\PotEndMark{\hss}}\hss}}%
\else
\gdef\maketag@@@##1{\hbox{\m@th\normalfont##1%
\llap{\hss\PotEndMark{\raisebox{-1.3em}}}}}%
\fi}
% \end{macrocode}
%
% Set a tag \emph{and} an end mark:
% \begin{packeddescr}
% \item[Lines \Coderef{TagPlus}{2}--\Coderef{TagPlus}{11}:]
% redefine the |\maketag@@@| macro:
% \item[Lines \Coderef{TagPlus}{3}--\Coderef{TagPlus}{7}:]
% if tags are set to the left, build a box of the whole
% displaywidth and put the original tag on the left, and the (potential)
% endmark at the right. Put this box with width 0 and continue.
% \item[Lines \Coderef{TagPlus}{8},\Coderef{TagPlus}{9}:]
% if the tags are set to the right, the (potential) end
% mark is put below it.
% \end{packeddescr}
% \changes{v1.20}{2001/12/29}{added hss if tags left (GD/WM)}
% \end{macro}
%
% \begin{macro}{\tagform@}
% \begin{packeddescr}
% \item |\maketag@@@| is also used via |\tagform@| in |eqref| that may be
% called inside an environment. There, the original functionality must
% be used.
% \end{packeddescr}
% \changes{v1.30}{2010/08/16}{added (WM), bug reported by Martin Schulze}
% \begin{macrocode}
\let\ams@@maketag@@@\maketag@@@
\gdef\tagform@#1{%
\ams@@maketag@@@{(\ignorespaces#1\unskip\@@italiccorr)}}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\RestoreTags}
% \Codelabel{RestoreTags}
% \begin{macrocode}
\gdef\RestoreTags{%
\global\let\maketag@@@=\Old@maketag@@@
\global\let\df@tag=\Old@df@tag}
% \end{macrocode}
%
% \begin{packeddescr}
% \item[Lines \Coderef{RestoreTags}{2},\Coderef{RestoreTags}{3}:]
% restore the original macros.
% \end{packeddescr}\end{macro}
%
% \begin{macro}{\endgather}
% \changes{v1.19}{2001/01/12}{adapted to amsmath-2.0 (GD/WM)}
% In the |gather| environment, just the augmented tag is used:
% \Codelabel{endgather}
% \begin{macrocode}
\gdef\endgather{%
\TagsPlusEndmarks % <<<<<<<<<
\math@cr
\black@\totwidth@
\egroup
$$%
\RestoreTags % <<<<<<<<<
\ignorespacesafterend}
%
\expandafter\let\csname endgather*\endcsname\endgather
% \end{macrocode}
%
% New:
% \begin{packeddescr}
% \item[Line \Coderef{endgather}{2}:]
% the last tag contains the potential endmark.
% \item[Line \Coderef{endgather}{7}:]
% restore the original macros.
% \item[Line \Coderef{endgather}{10}:]
% Since |let| always takes the expansion of a macro when the
% let is executed, all let's have to be adjusted (this is the same
% for all subsequent let-statements).
% \end{packeddescr}\end{macro}
%
% \begin{macro}{\math@cr@@@align}
% \changes{v1.12}{1998/11/15}{dropped redefinition of 'math@cr@@@align' (WM,
% reported by Frank-Christian Otto)}
% \end{macro}
%
% \begin{macro}{\endalign}
% |\endalign| also uses the augmented tags:
% \Codelabel{endalign}
% \begin{macrocode}
\def\endalign{%
\ifingather@\else % <<<<<<<<<
\TagsPlusEndmarks\fi % <<<<<<<<<
\math@cr
\black@\totwidth@
\egroup
\ifingather@
\restorealignstate@
\egroup
\nonumber
\ifnum0=`{\fi\iffalse}\fi
\else
$$%
\RestoreTags % <<<<<<<<<
\fi
\ignorespacesafterend}
% \end{macrocode}
%
% \changes{v1.19}{2001/01/12}{adapted to amsmath-2.0 (GD/WM)}
% New:
% \begin{packeddescr}
% \item[Lines \Coderef{endalign}{2}, \Coderef{endalign}{3}:]
% if the |align| is not inside another environment,
% its tags have to contain the endmarks.
% \item[Line \Coderef{endalign}{14}:]
% this case, the original macros have to be restored.
% \end{packeddescr}\end{macro}
%
% \begin{macrocode}
\expandafter\let\csname endalign*\endcsname\endalign
\let\endxalignat\endalign
\expandafter\let\csname endxalignat*\endcsname\endalign
\let\endxxalignat\endalign
\let\endalignat\endalign
\expandafter\let\csname endalignat*\endcsname\endalign
\let\endflalign\endalign
\expandafter\let\csname endflalign*\endcsname\endalign
% \end{macrocode}
%
% Adjust let-statements.
%
% \begin{macro}{\lendmultline}
% The |multline| environment has two different |\end| commands,
% depending if the equation numbers are set on the left or on the right:
% \Codelabel{lendmultline}
% \begin{macrocode}
\def\lendmultline@{%
\global\@eqnswfalse\tag@false\tagsleft@false
\rendmultline@}
% \end{macrocode}
%
% End of |multline| environment if tags are set to the left:
% in this case, the last line of a |multline| does not contain a tag.
% Thus the situation of setting an endmark tag at the right is faked:
% \begin{packeddescr}
% \item[Lines \Coderef{lendmultline}{2}, \Coderef{lendmultline}{3}:]
% display no equation number, don't set an equation tag
% (but use the tag mechanism for the end mark - see |\TagsPlusEndmarks|
% and |\SetOnlyEndMark|), set it at the right,
% and call |\rendmultline|.
% \end{packeddescr}
% \changes{v1.20}{2001/12/29}{debugged (GD/WM)}
% \end{macro}
%
% \begin{macro}{\rendmultline}
% |\rendmultline| also uses the augmented tags:
% \Codelabel{rendmultline}
% \begin{macrocode}
\def\rendmultline@{%
\TagsPlusEndmarks % <<<<<<<<<
\iftag@
$\let\endmultline@math\relax
\ifshifttag@
\hskip\multlinegap
\llap{\vtop{%
\raise@tag
\normalbaselines
\setbox\@ne\null
\dp\@ne\lineht@
\box\@ne
\hbox{\strut@\make@display@tag}%
}}%
\else
\hskip\multlinetaggap
\make@display@tag
\fi
\else
\hskip\multlinegap
\fi
\hfilneg
\math@cr
\egroup$$%
\RestoreTags} % <<<<<<<<<
% \end{macrocode}
%
% New: \\
% Line \Coderef{rendmultline}{2}:
% last tag contains the potential endmark. \\
% Line \Coderef{rendmultline}{26}:
% restore the original macros
% \changes{v1.19}{2001/01/12}{adapted to amsmath-2.0 (GD/WM)}
% \end{macro}
%
% \begin{macro}{\endmathdisplay}
%
% \Codelabel{ams-e-displ}
% \begin{macrocode}
\def\endmathdisplay#1{%
\ifmmode \else \@badmath \fi
\TagsPlusEndmarks % <<<<<<<<<
\endmathdisplay@a
$$%
\RestoreTags % <<<<<<<<<
\global\let\df@label\@empty \global\let\df@tag\@empty
\global\tag@false \global\let\alt@tag\@empty
\global\@eqnswfalse
}
% \end{macrocode}
% \changes{v0.94}{1997/03/19}{end mark with raisebox (WM)}
% \changes{v1.19}{2001/01/12}{completely new for amsmath-2.0, begin[ deleted (GD/WM)}
% \end{macro}
%
% Added Line \Coderef{ams-e-displ}{4}: set potential end mark at
% bottom niveau of displaymath.
%
% \begin{macro}{equation}
% \changes{v1.19}{2001/01/12}{adapted to amsmath-2.0 (WM)}
% \begin{macrocode}
\renewenvironment{equation}{%
\edef\reset@equation{%
\@nx\setcounter{equation}{\number\c@equation}}%
\refstepcounter{equation}%
\st@rredfalse \global\@eqnswtrue
\mathdisplay{equation}%
}{%
\endmathdisplay{equation}%
\ignorespacesafterend
}
\renewenvironment{equation*}{%
\st@rredtrue \global\@eqnswfalse
\mathdisplay{equation*}%
}{%
\endmathdisplay{equation*}%
\ignorespacesafterend
}
% \end{macrocode}
% unchanged from |amsmath.sty|.
% \end{macro}
%
% \begin{macrocode}
\fi
}% end of option amsmath/thmmarks **************************************
% \end{macrocode}
%
%
% \subsubsection{Theorem-Layout Stuff}
%
% \changes{v1.11}{1998/10/26}{added 'noconfig' option (AS/WM)}
% \begin{macrocode}
\let\thm@usestd\@undefined
\DeclareOption{standard}{\let\thm@usestd\relax}
\let\thm@noconfig\@undefined
\DeclareOption{noconfig}{\let\thm@noconfig\relax}
% \end{macrocode}
%
% Options for selection of a configuration: if no such option is given
% |ntheorem.cfg| will be loaded (which has to be provided by the
% user), |[standard]| will load |ntheorem.std|, a predefined setting,
% and |[noconfig]| does not preload any configuration.
%
% \begin{macrocode}
\gdef\InTheoType{None}
\gdef\NoneKeyword{None}
\gdef\NoneSymbol{None}
\gdef\None{None}
% \end{macrocode}
%
% Set |\InTheoType| to |none| on the upper document level.
%
% \begin{macro}{\newtheoremstyle}
% \changes{v0.93}{1997/03/12}{'newtheoremstyle' only if not yet defined (WM)}
% With |\newtheoremstyle|, new theorem-layout styles are defined.
% \Codelabel{newthmstyle}
% \begin{macrocode}
\gdef\newtheoremstyle#1#2#3{%
\expandafter\@ifundefined{th@#1}%
{\expandafter\gdef\csname th@#1\endcsname{%
\def\@begintheorem####1####2{#2}%
\def\@opargbegintheorem####1####2####3{#3}}}%
{\PackageError{\basename}{Theorem style #1 already defined}\@eha}}
% \end{macrocode}
%
% Arguments: \\
% \meta{style}:=|#1|: the name of the theoremstyle to be defined, \\
% \meta{cmd\_seq1}:=|#2|: command sequence for setting the header
% for environment instances with no optional text, \\
% \meta{cmd\_seq2}:=|#3|: command sequence for setting the header
% for environment instances with optional text. \\
% Line \Coderef{newthmstyle}{2}: if this style is not yet defined, define
% it. \\
% Line \Coderef{newthmstyle}{3}:
% define |\th@|\meta{style} to be a macro which defines \\
% Line \Coderef{newthmstyle}{4}:
% a) the two-argument macro |\@begintheorem#1#2| to be \meta{cmd\_seq1}, \\
% Line \Coderef{newthmstyle}{5}:
% b) |\@opargbegintheorem#1#2#3| to be \meta{cmd\_seq2}.
% \end{macro}
%
% The predefined theorem styles use this command.%
%
% \begin{macro}{\renewtheoremstyle}
% \changes{v0.93}{1997/03/12}{introduced 'renewtheoremstyle' (WM)}
% \Codelabel{renewthmstyle}
% \begin{macrocode}
\gdef\renewtheoremstyle#1#2#3{%
\expandafter\@ifundefined{th@#1}%
{\PackageError{\basename}{Theorem style #1 undefined}\@ehc}%
{}%
\expandafter\let\csname th@#1\endcsname\relax
\newtheoremstyle{#1}{#2}{#3}}
% \end{macrocode}
% \end{macro}
% Arguments: \\
% \meta{style}:=|#1|: the name of the theoremstyle to be defined, \\
% |#2|, |#3| as for |\newtheoremstyle|. \\
% Checks, if theoremstyle \meta{style} is already defined. If so,
% |\th@|\meta{style} is made undefined and |\newtheoremstyle| is called
% with the same arguments.
%
% \paragraph{Predefined Theorem Styles}
% \begin{macro}{theoremstyles}
% |th@plain|, |th@change|, and |th@margin| taken from theorem.sty by
% Frank Mittelbach; the break-styles have been changed.
%
% \changes{v1.03}{1997/07/15}{break styles changed (WM)}
% \changes{v1.15}{1999/02/01}{fixed nonumberbreak (WM)}
% \changes{v1.19}{2001/01/13}{break styles and empty style changed,
% now it is analogous to theorem.sty (OK/WM)}
% \begin{macrocode}
\newtheoremstyle{plain}%
{\item[\hskip\labelsep \theorem@headerfont ##1\ ##2\theorem@separator]}%
{\item[\hskip\labelsep \theorem@headerfont ##1\ ##2\ (##3)\theorem@separator]}
%
\newtheoremstyle{break}%
{\item[\rlap{\vbox{\hbox{\hskip\labelsep \theorem@headerfont
##1\ ##2\theorem@separator}\hbox{\strut}}}]}%
{\item[\rlap{\vbox{\hbox{\hskip\labelsep \theorem@headerfont
##1\ ##2\ (##3)\theorem@separator}\hbox{\strut}}}]}
%
\newtheoremstyle{change}%
{\item[\hskip\labelsep \theorem@headerfont ##2\ ##1\theorem@separator]}%
{\item[\hskip\labelsep \theorem@headerfont ##2\ ##1\ (##3)\theorem@separator]}
%
\newtheoremstyle{changebreak}%
{\item[\rlap{\vbox{\hbox{\hskip\labelsep \theorem@headerfont
##2\ ##1\theorem@separator}\hbox{\strut}}}]}%
{\item[\rlap{\vbox{\hbox{\hskip\labelsep \theorem@headerfont
##2\ ##1\ (##3)\theorem@separator}\hbox{\strut}}}]}
%
\newtheoremstyle{margin}%
{\item[\theorem@headerfont \llap{##2}\hskip\labelsep ##1\theorem@separator]}%
{\item[\theorem@headerfont \llap{##2}\hskip\labelsep ##1\ (##3)\theorem@separator]}
%
\newtheoremstyle{marginbreak}%
{\item[\rlap{\vbox{\hbox{\theorem@headerfont
\llap{##2}\hskip\labelsep\relax ##1\theorem@separator}\hbox{\strut}}}]}
{\item[\rlap{\vbox{\hbox{\theorem@headerfont
\llap{##2}\hskip\labelsep\relax ##1\
(##3)\theorem@separator}\hbox{\strut}}}]}
%
\newtheoremstyle{nonumberplain}%
{\item[\theorem@headerfont\hskip\labelsep ##1\theorem@separator]}%
{\item[\theorem@headerfont\hskip \labelsep ##1\ (##3)\theorem@separator]}
%
\newtheoremstyle{nonumberbreak}%
{\item[\rlap{\vbox{\hbox{\hskip\labelsep \theorem@headerfont
##1\theorem@separator}\hbox{\strut}}}]}%
{\item[\rlap{\vbox{\hbox{\hskip\labelsep \theorem@headerfont
##1\ (##3)\theorem@separator}\hbox{\strut}}}]}
%
\newtheoremstyle{empty}%
{\item[]}%
{\item[\theorem@headerfont \hskip\labelsep\relax ##3]}
\newtheoremstyle{emptybreak}%
{\item[]}%
{\item[\rlap{\vbox{\hbox{\hskip\labelsep\relax \theorem@headerfont
##3\theorem@separator}\hbox{\strut}}}]}
%
\@namedef{th@nonumbermargin}{\th@nonumberplain}
\@namedef{th@nonumberchange}{\th@nonumberplain}
\@namedef{th@nonumbermarginbreak}{\th@nonumberbreak}
\@namedef{th@nonumberchangebreak}{\th@nonumberbreak}
\@namedef{th@plainNo}{\th@nonumberplain}
\@namedef{th@breakNo}{\th@nonumberplain}
\@namedef{th@marginNo}{\th@nonumberplain}
\@namedef{th@changeNo}{\th@nonumberplain}
\@namedef{th@marginbreakNo}{\th@nonumberbreak}
\@namedef{th@changebreakNo}{\th@nonumberbreak}
% \end{macrocode}
% \changes{v0.81}{1997/02/12}{`theoremnumbering' and styles ...No added
% (WM)}
% \changes{v1.04}{1998/05/26}{theoremstyle empty added (WM)}
%\end{macro}
%
% For instance, |break| is commented:
%
% |\newtheoremstyle{break}| results in
% \begin{quote}
% |\gdef\th@break{%| \\
% | \def\@begintheorem##1##2{%| \\
% | \item[\hskip\labelsep \theorem@headerfont| \\
% | ##1\ ##2\theorem@separator]%| \\
% | \hfill\penalty-8000}%| \\
% | \def\@opargbegintheorem##1##2##3{%| \\
% | \item[\hskip\labelsep \theorem@headerfont| \\
% | ##1\ ##2\ (##3)\theorem@separator]%| \\
% | \hfill\penalty-8000}}|
% \end{quote}
%
% Then, calling |\th@break| sets |\@begintheorem| as follows: \\
% Since each theorem environment is basically a trivlist,
% the header is set as the item contents: |\theorem@headerfont|
% holds the font commands for the header font, |##1| is the
% keyword to be displayed, and |##2| its environment number.
% The linebreak after the header is achieved by offering to fill the
% line with space and the distinct wish to put a linebreak after it.
% Thus, if plain text follows, the line break is executed, but if
% a list or a display follows, it is not executed.
%
% Note: The |\hfill\penalty-8000| causes \TeX\ to leave vertical mode,
% setting the item contents (ie the header) and entering horizontal mode
% to perform the |\hfill|.
%
% \begin{macro}{\theoremstyle}
% The handling of |\theoremstyle|, |\theorembodyfont|, and
% |\theoremskipamounts| is taken from theorem.sty by Frank Mittelbach:
% \changes{v0.80}{1997/02/11}{`theoremseparator' added (WM)}
% \changes{v1.20}{2002/12/30}{`theoremprework' and `theorempostwork'
% added (WM)}
% \begin{macrocode}
\gdef\theoremstyle#1{%
\@ifundefined{th@#1}{\@warning
{Unknown theoremstyle `#1'. Using `plain'}%
\theorem@style{plain}}%
{\theorem@style{#1}}}
\newtoks\theorem@style
\newtoks\theorem@@style
\global\theorem@style{plain}
% \end{macrocode}\end{macro}
%
% If |\theoremstyle| is called, it is checked if the argument
% is a valid |theoremstyle|, and if so, it is stored in the token
% |\theorem@style|. It is initialized to |plain|.
%
% \begin{macro}{\theorembodyfont}
% \begin{macrocode}
\newtoks\theorembodyfont
\global\theorembodyfont{\itshape}
% \end{macrocode}\end{macro}
%
% \begin{macro}{\theoremnumbering}
% \begin{macrocode}
\newtoks\theoremnumbering
\global\theoremnumbering{arabic}
% \end{macrocode}\end{macro}
%
% \begin{macro}{\theorempreskipamount}
% \begin{macro}{\theorempostskipamount}
% \begin{macrocode}
\newskip\theorempreskipamount
\newskip\theorempostskipamount
\newskip\theoremframepreskipamount
\newskip\theoremframepostskipamount
\global\theorempreskipamount\topsep
\global\theorempostskipamount\topsep
\global\theoremframepreskipamount0pt
\global\theoremframepostskipamount0pt
% \end{macrocode}\end{macro}
% \changes{v0.94}{1997/03/20}{'theorem...skip' fixed (WM)}
% \end{macro}
%
% \begin{macro}{\theoremindent}
% \begin{macrocode}
\newdimen\theoremindent
\global\theoremindent0cm
\newdimen\theorem@indent
% \end{macrocode}\end{macro}
%
% \begin{macro}{\theoremheaderfont}
% \begin{macrocode}
\newtoks\theoremheaderfont
\global\theoremheaderfont{\normalfont\bfseries}
\def\theorem@headerfont{\normalfont\bfseries}
% \end{macrocode}\end{macro}
%
% \begin{macro}{\theoremseparator}
% \begin{macrocode}
\newtoks\theoremseparator
\global\theoremseparator{}
\def\theorem@separator{}
% \end{macrocode}\end{macro}
%
% \begin{macro}{\theoremprework}
% \begin{macro}{\theorempostwork}
% \begin{macrocode}
\newtoks\theoremprework
\global\theoremprework{\relax}
\newtoks\theorempostwork
\global\theorempostwork{\relax}
\def\theorem@prework{}
% \end{macrocode}\end{macro}
% \end{macro}
%
% \begin{macro}{\theoremsymbol}
% \begin{macrocode}
\newtoks\theoremsymbol
\global\theoremsymbol{}
% \end{macrocode}\end{macro}
%
% \begin{macro}{\qedsymbol}
% \begin{macrocode}
\newtoks\qedsymbol
\global\qedsymbol{}
% \end{macrocode}\end{macro}
%
% \begin{macro}{\theoremkeyword}
% \begin{macrocode}
\newtoks\theoremkeyword
\global\theoremkeyword{None}
% \end{macrocode}\end{macro}
%
% \begin{macro}{\theoremclass}
% \changes{v1.16}{1999/08/07}{introduced 'theoremclass' and
% defined 'th@class@LaTeX' (WM)}
% \begin{macrocode}
\gdef\theoremclass#1{%
\csname th@class@#1\endcsname}
\gdef\th@class@LaTeX{%
\theoremstyle{plain}
\theoremheaderfont{\normalfont\bfseries}
\theorembodyfont{\itshape}
\theoremseparator{}
\theoremprework{\relax}
\theorempostwork{\relax}
\theoremindent0cm
\theoremnumbering{arabic}
\theoremsymbol{}}
% \end{macrocode}\end{macro}
% Calling |\theoremclass{|\env|}| calls |\th@class@|\env\ (which is
% defined in |\@newtheorem| in Lines \Coderef{atnewthm}{31--45}).
% |\th@class@|\env\ restores all style parameters to their values
% given for \env.
% Especially, |\th@class@LaTeX| restores the standard LaTeX parameters.
%
% \begin{macro}{\qedsymbol}
% \begin{macrocode}
\newtoks\qedsymbol
\global\qedsymbol{}
% \end{macrocode}\end{macro}
%
% \paragraph{Compatibility with amsthm.}
%
% \begin{macro}{amsthm}
% \changes{v1.02}{1997/05/31}{proof-environment fixed (WM)}
% \begin{macrocode}
\DeclareOption{amsthm}{% *********************************************
\PackageInfo{\basename}{Option `amsthm' loaded}%
\def\swapnumbers{\PackageError{\basename}{swapnumbers not implemented.
Use theoremstyle change instead.}\@eha}
\gdef\th@plain{%
\def\theorem@headerfont{\normalfont\bfseries}\itshape%
\def\@begintheorem##1##2{%
\item[\hskip\labelsep \theorem@headerfont ##1\ ##2.]}%
\def\@opargbegintheorem##1##2##3{%
\item[\hskip\labelsep \theorem@headerfont ##1\ ##2\ (##3).]}}
\gdef\th@nonumberplain{%
\def\theorem@headerfont{\normalfont\bfseries}\itshape%
\def\@begintheorem##1##2{%
\item[\hskip\labelsep \theorem@headerfont ##1.]}%
\def\@opargbegintheorem##1##2##3{%
\item[\hskip\labelsep \theorem@headerfont ##1\ (##3).]}}
\gdef\th@definition{%
\th@plain\def\theorem@headerfont{\normalfont\bfseries}\itshape}
\gdef\th@nonumberdefinition{%
\th@nonumberplain\def\theorem@headerfont{\normalfont\bfseries}\itshape}
\gdef\th@remark{%
\th@plain\def\theorem@headerfont{\itshape}\normalfont}
\gdef\th@nonumberremark{%
\th@nonumberplain\def\theorem@headerfont{\itshape}\normalfont}
\newcounter{proof}%
\if@thmmarks
\newcounter{currproofctr}%
\newcounter{endproofctr}%
\fi
\newcommand{\openbox}{\leavevmode
\hbox to.77778em{%
\hfil\vrule
\vbox to.675em{\hrule width.6em\vfil\hrule}%
\vrule\hfil}}
\gdef\proofSymbol{\openbox}
\newcommand{\proofname}{Proof}
\newenvironment{proof}[1][\proofname]{
\th@nonumberplain
\def\theorem@headerfont{\itshape}%
\normalfont
\theoremsymbol{\ensuremath{_\blacksquare}}
\@thm{proof}{proof}{#1}}%
{\@endtheorem}
}% end of option amsthm **********************************************
% \end{macrocode}
% \end{macro}
%
% Defines theorem styles |plain|, |definition|, and
% |remark|, and environment |proof| according to
% |amsthm.sty|.
%
% \subsubsection{Theorem-Environment Handling Stuff}
% Original: ltthm.dtx
%
% \begin{macrocode}
\newskip\thm@topsepadd
% \end{macrocode}
%
% An auxiliary variable.
%
% \paragraph{Defining New Theorem-Environments.}
%
% \begin{macro}{\newtheorem}
% \changes{v1.18}{1999/12/23}{debugged starred version of 'newtheorem' (WM)}
% \changes{v1.23}{2004/06/13}{moved normal 'newtheorem' into 'newtheorem@i' (WM)}
% \changes{v1.23}{2004/06/13}{normal 'newtheorem': reset theoremprework and
% theorempostwork, then call 'newtheorem@i' (WM, reported by Christoph Kluss)}
% \changes{v1.24}{2004/09/20}{debugged: reset after call, moved downwards (WM)}
% \begin{macrocode}
\gdef\newtheorem{%
\newtheorem@i%
}
% \end{macrocode}
% \end{macro}
% \begin{macro}{\newtheorem@i}
% \changes{v1.23}{2004/06/13}{moved normal 'newtheorem' into 'ntheorem@i' (WM)}
% The syntax of the original |\newtheorem| is retained. The macro is extended
% to deal with the additional requirements:
% \begin{macrocode}
\gdef\newtheorem@i{%
\@ifstar
{\expandafter\@ifundefined{th@nonumber\the\theorem@style}%
{\PackageError{\basename}{Theorem style {nonumber\the\theorem@style}
undefined (you need it here for newtheorem*) }\@ehc}%
{}%
\edef\@tempa{{nonumber\the\theorem@style}}%
\expandafter\theorem@@style\@tempa\@newtheorem}%
{\edef\@tempa{{\the\theorem@style}}%
\expandafter\theorem@@style\@tempa\@newtheorem}}
% \end{macrocode}
% \end{macro}
%
% Defines |\theorem@@style| to be the current |\theoremstyle|
% or -- in case of |\newtheorem*| -- to be its non-numbered
% equivalent (which has to be defined!), and then calls |\@newtheorem|.
% \begin{macro}{\renewtheorem}
% \changes{v0.93}{1997/03/12}{introduced 'renewtheorem' (WM)}
% \changes{v1.18}{1999/12/23}{debugged starred version of 'renewtheorem' (WM)}
% \Codelabel{renewthm}
% \begin{macrocode}
\gdef\renewtheorem{%
\@ifstar
{\expandafter\@ifundefined{th@nonumber\the\theorem@style}%
{\PackageError{\basename}{Theorem style {nonumber\the\theorem@style}
undefined (you need it here for newtheorem*) }\@ehc}%
{}%
\edef\@tempa{{nonumber\the\theorem@style}}%
\expandafter\theorem@@style\@tempa\@renewtheorem}%
{\edef\@tempa{{\the\theorem@style}}%
\expandafter\theorem@@style\@tempa\@renewtheorem}}
% \end{macrocode}
% Analogous to |\newtheorem|.
% \end{macro}
%
% \begin{macro}{\@newtheorem}
% |\@newtheorem| does the main job for initializing a new theorem
% environment type. It is called by |\newtheorem|.
%
% \Codelabel{atnewthm}
% \changes{v0.83}{1997/02/13}{fixed, for bold math in headers (AS)}
% \changes{v0.93}{1997/03/12}{check ifdefinable star-env. added (WM)}
% \changes{v0.93}{1997/03/12}{newcounters only if not yet defined (WM)}
% \changes{v1.02}{1997/05/31}{fixed collision at '@thm', introduced
% 'setparms' and 'mkheader' (WM)}
% \changes{v1.16}{1999/08/07}{introduced 'th@class' (WM)}
% \changes{v1.18}{1999/12/23}{'protected@xdef' for Symbol (WM)}
% \changes{v1.21}{2002/12/30}{added handling of 'theoremprework' and
% 'theorempostwork' (WM)}
% \changes{v1.24}{2004/09/20}{debugged: reset theorempre/postwork (WM)}
% \begin{macrocode}
\gdef\@newtheorem#1{%
\thm@tempiffalse
\expandafter\@ifdefinable\csname #1\endcsname
{\expandafter\@ifdefinable\csname #1*\endcsname
{\thm@tempiftrue
\thm@definelthm{#1}% for lists
\if@thmmarks
\expandafter\@ifundefined{c@curr#1ctr}%
{\newcounter{curr#1ctr}}{}%
\expandafter\@ifundefined{c@end#1ctr}%
{\newcounter{end#1ctr}}{}%
\fi
\expandafter\protected@xdef\csname #1Symbol\endcsname{\the\theoremsymbol}%
\expandafter\protected@xdef\csname #1@postwork\endcsname{%
\the\theorempostwork}%
\expandafter\gdef\csname#1\endcsname{%
\let\thm@starredenv\@undefined
\csname mkheader@#1\endcsname}%
\expandafter\gdef\csname#1*\endcsname{%
\let\thm@starredenv\relax
\csname mkheader@#1\endcsname}%
\def\@tempa{\expandafter\noexpand\csname end#1\endcsname}%
\expandafter\xdef\csname end#1*\endcsname{\@tempa}%
\expandafter\xdef\csname setparms@#1\endcsname
{\noexpand \def \noexpand \theorem@headerfont
{\the\theoremheaderfont\noexpand\theorem@checkbold}%
\noexpand \def \noexpand \theorem@separator
{\the\theoremseparator}%
\noexpand \def \noexpand \theorem@prework
{\the\theoremprework}%
\noexpand \def \noexpand \theorem@indent
{\the\theoremindent}%
\the \theorembodyfont
\noexpand\csname th@\the \theorem@@style \endcsname}%
\expandafter\xdef\csname th@class@#1\endcsname
{\noexpand\theoremstyle{\the\theorem@style}%
\noexpand\theoremheaderfont{\the\theoremheaderfont}%
\noexpand\theorembodyfont{\the \theorembodyfont}%
\noexpand\theoremseparator{\the\theoremseparator}%
\noexpand\theoremprework{\the\theoremprework}%
\noexpand\theorempostwork{\the\theorempostwork}%
\noexpand\theoremindent\the\theoremindent%
\noexpand\theoremnumbering{\the\theoremnumbering}%
\noexpand\theoremsymbol{\the\theoremsymbol}}%
}}%
\theoremprework{\relax}%
\theorempostwork{\relax}%
\@ifnextchar[{\@othm{#1}}{\@nthm{#1}}}% MUST NOT BE IN ANY IF !!!
% \end{macrocode}
%
% Argument: \env:=|#1| is the (internal) environment name to be defined,
% which is read from the \LaTeX\ source.
% \begin{packeddescr}
% \item[Line \Coderef{atnewthm}{3}:]
% check if \env\ is not yet defined (or is redefined).
% \item[Lines \Coderef{atnewthm}{5}--\Coderef{atnewthm}{30}]
% are executed exactly if \env\ and \env * are not yet defined.
% \item[Line \Coderef{atnewthm}{5}:]
% |\thm@tempif=true| iff \env\ and \env * are not yet defined.
% \item[Line \Coderef{atnewthm}{6}:]
% Initialize theorem list handling for \env.
% \item[Lines \Coderef{atnewthm}{8}--\Coderef{atnewthm}{11}:]
% if |thmmarks| is active and the counters are not yet defined,
% for every theorem-like, define \\
% |curr|\env|ctr|: in the $i$th environment of type \env,
% $|curr|\env|ctr|=i$, and \\
% |end|\env|ctr|: when the innermost environment is of
% type \env, in the $j$th potential position for an end
% mark in this environment, $|end|\env|ctr|=j$.
% (if the counters are already defined, \env\ is redefined,
% and these internal counters have to be continued).
% \item[Lines \Coderef{atnewthm}{13}--\Coderef{atnewthm}{30}:]
% define several commands:
% (|\xdef| expands the definition at the time it is called and
% makes it global):
% \item[Line \Coderef{atnewthm}{13}:]
% store the current value of |\theoremsymbol|
% (|\edef|: expand |\the\theoremsymbol| now) as \env|Symbol|.
% \item[Line \Coderef{atnewthm}{14}:]
% store the current value of |\theorempostwork|
% (|\edef|: expand |\the\theorempostwork| now) as \env|postwork|.
% \item[Lines \Coderef{atnewthm}{15}--\Coderef{atnewthm}{17},
% \Coderef{atnewthm}{18}--\Coderef{atnewthm}{20}:]
% Define the commands |\env| and |\env*| to set the header
% of |\env|.
% (using a switch |\thm@starredenv|: |\relax| iff starred).
% \item[Lines \Coderef{atnewthm}{21}, \Coderef{atnewthm}{22}:]
% Set |\end|\env|*| to |\end|\env.
% \item[Lines \Coderef{atnewthm}{23}--\Coderef{atnewthm}{33}:]
% define |\setparms@|\env\ to set the style parameters of the
% header for every \env\ environment (in the sequel,
% \emph{current} means, at the moment |\@newtheorem| is called):
% \item[Lines \Coderef{atnewthm}{24}, \Coderef{atnewthm}{25}:]
% setting |\theorem@headerfont| to the \emph{current}
% value of |\theoremheaderfont|, followed by a check if
% it is a bold style,
% \item[Lines \Coderef{atnewthm}{26}, \Coderef{atnewthm}{27}:]
% setting |\theorem@separator| to the \emph{current}
% value of |\theoremseparator|,
% \item[Lines \Coderef{atnewthm}{28}, \Coderef{atnewthm}{29}:]
% setting |\theorem@prework| to the \emph{current}
% value of |\theoremprework|,
% \item[Lines \Coderef{atnewthm}{30}, \Coderef{atnewthm}{31}:]
% setting |\theorem@indent| to the \emph{current}
% value of |\theoremindent|,
% \item[Line \Coderef{atnewthm}{32}:]
% executing the command sequence currently stored in
% |\theorembodyfont|, and
% \item[Line \Coderef{atnewthm}{33}:]
% calling |th@\the\theorem@@style| (which initializes
% |\@begintheorem| and |\@opargbegintheorem| according to the
% \emph{current} value of |\theoremstyle| by calling
% |th@\the\theorem@@style|).
% \item [Line \Coderef{atnewthm}{34}--\Coderef{atnewthm}{48}:]
% define |\th@class@|\env\ to initialize all style
% parameters as they are set for the \env\ environment.
% \item[Note,] that the |\@ifdefinable| from line \Coderef{atnewthm}{3}
% ends after line \Coderef{atnewthm}{48}.
% \item[Line \Coderef{atnewthm}{49}:]
% According to the next character, call |\@othm{|\env|}|
% (if another counter is used) or |\@nthm{|\env|}|.
% \end{packeddescr}
%
% Thus, when calling |\@newthm| with |#1|=\env,
% for current values |\theoremstyle=plain|,
% |\theorembodyfont=\upshape|, |\theoremheaderfont=\bf|,
% |\theoremseparator=:|, |\theoremindent=1cm|,
% |\theoremnumbering=arabic|, and |\theoremsymbol=\Box|,
%
% the macro |\setparms@|\env\ is defined as
% \begin{quote}
% |\setparms@|\env| == \def\theorem@headerfont{\bf\theorem@checkbold}| \\
% | \def\theorem@separator{:}| \\
% | \def\theorem@indent{0cm}| \\
% | \upshape| \\
% | \th@plain|
% \end{quote}
% and the macro |\th@class@|\env\ is defined as
% \begin{quote}
% |\th@class@|\env| == \def\theoremstyle{plain}|\\
% | \def\theoremheaderfont{\bf}| \\
% | \def\theorembodyfont{\upshape}| \\
% | \def\theoremseparator{:}| \\
% | \def\theoremindent{0cm}| \\
% | \def\theoremnumbering{arabic}| \\
% | \def\theoremsymbol{\Box}|
% \end{quote}
% Note, that line \Coderef{atnewthm}{32} must not be inside
% \emph{any} |\if...\fi| construct.
% \end{macro}
%
% \begin{macro}{\@renewtheorem}
% \changes{v0.93}{1997/03/12}{introduced 'renewtheorem' (WM)}
% \changes{v1.18}{1999/12/23}{calls '@newtheorem' instead of
% 'newtheorem' (WM)}
% \changes{v1.25}{2005/07/07}{error message: 'keyword' (WM)}
% \Codelabel{atrenewthm}
% \begin{macrocode}
\gdef\@renewtheorem#1{%
\expandafter\@ifundefined{#1}%
{\PackageError{\basename}{Theorem keyword #1 undefined}\@ehc}%
{}%
\expandafter\let\csname #1\endcsname\relax
\expandafter\let\csname #1*\endcsname\relax
\@newtheorem{#1}}
% \end{macrocode}
% Argument: \env:=|#1| is the (internal) environment name to be
% redefined, which is read from the \LaTeX\ source. \\
% If \env\ is already defined, make it (and \env*, too) undefined
% and call |\@newtheorem{|\env|}|.
% \end{macro}
%
% \begin{macro}{\@nthm}
% \changes{v1.1}{1998/08/30}{added 'output@' to '@nthm' and '@othm'. (WM)}
% \changes{v1.18}{1999/12/25}{'protected@xdef' instead of 'xdef' (WM)}
% \changes{v1.18}{1999/12/25}{'output' changed and modified into
% 'Keyword' (WM)}
% \Codelabel{nthm}
% |\@nthm| is called by |\@newtheorem| if the environment to be defined
% has a counter of its own.
% \begin{macrocode}
\gdef\@nthm#1#2{%
\expandafter\protected@xdef\csname num@addtheoremline#1\endcsname{%
\noexpand\@num@addtheoremline{#1}{#2}}%
\expandafter\protected@xdef\csname nonum@addtheoremline#1\endcsname{%
\noexpand\@nonum@addtheoremline{#1}{#2}}%
\theoremkeyword{#2}%
\expandafter\protected@xdef\csname #1Keyword\endcsname
{\the\theoremkeyword}%
\@ifnextchar[{\@xnthm{#1}{#2}}{\@ynthm{#1}{#2}}}
% \end{macrocode}
%
% Arguments: \\
% \env:=|#1| is the (internal) environment name to be defined
% (transmitted from |\@newtheorem|). \\
% \meta{output\_name}:=|#2| is its keyword to be used in the
% output (read from the \LaTeX\ source).
% \begin{packeddescr}
% \item[Lines \Coderef{nthm}{2}--\Coderef{nthm}{5}:]
% Define |\|(no)|num@addtheoremline|\env\ to call \\
% |\@|(no)|num@addtheoremline{|\env|}{|\meta{output\_name}|}|. \\
% For comments on |\@num@addtheoremline| and
% |\@nonum@addtheoremline| see Section \ref{sec:CodeLists}.
% \item[Lines \Coderef{nthm}{6}--\Coderef{nthm}{8}:]
% Define |\|\env|Keyword|\env\ to typeset/output \meta{output\_name}.
% (note the similarity with the handling of |\theoremsymbol|
% for handling complex keywords)
% \item[Line \Coderef{nthm}{9}:]
% According to the next character, call
% |\@xnthm{|\env|}{|\meta{output\_name}|}| (if \env-environments
% should be numbered relative to some structuring level) or
% |\@ynthm{|\env|}{|\meta{output\_name}|}|.
% \end{packeddescr}
% \end{macro}
%
% \begin{macro}{\@othm}
% \changes{v1.02}{1997/05/31}{fixed collision at '@thm', introduced
% 'setparms' and 'mkheader' (WM)}
% \changes{v1.1}{1998/08/30}{added 'output@' to '@nthm' and '@othm'. (WM)}
% \changes{v1.12}{1998/11/15}{fixed a bug in '@output' (WM, reported by
% David Epstein)}
% \changes{v1.18}{1999/12/25}{'protected@xdef' instead of 'xdef' (WM)}
% \changes{v1.18}{1999/12/25}{'output' changed and modified into
% 'Keyword' (WM)}
% |\@othm| is called by |\@newtheorem| if the environment to be defined
% uses another counter.
% \Codelabel{othm}
% \begin{macrocode}
\gdef\@othm#1[#2]#3{%
\@ifundefined{c@#2}{\@nocounterr{#2}}%
{\ifthm@tempif
\global\@namedef{the#1}{\@nameuse{the#2}}%
\expandafter\protected@xdef\csname num@addtheoremline#1\endcsname{%
\noexpand\@num@addtheoremline{#1}{#3}}%
\expandafter\protected@xdef\csname nonum@addtheoremline#1\endcsname{%
\noexpand\@nonum@addtheoremline{#1}{#3}}%
\theoremkeyword{#3}%
\expandafter\protected@xdef\csname #1Keyword\endcsname
{\the\theoremkeyword}%
\expandafter\gdef\csname mkheader@#1\endcsname
{\csname setparms@#1\endcsname
\@thm{#1}{#2}{#3}}%
\global\@namedef{end#1}{\@endtheorem}\fi}}
% \end{macrocode}
%
% Arguments: \\
% \env:=|#1| is the (internal) environment name to be defined
% (transmitted from |\@newtheorem|). \\
% \meta{use\_ctr}:=|#2| is the internal name of the theorem which counter
% is used, and \\
% \meta{output\_name}:=|#3| is its ``name'' to be used in the
% output (both read from the \LaTeX\ source).
%
% \begin{packeddescr}
% \item[Line \Coderef{othm}{2}:]
% if the counter to be used is undefined, goto error, else
% set |\the|\env\ to use |\the|\meta{use\_ctr} and do the following:
% \item[Lines \Coderef{othm}{4}--\Coderef{othm}{12}]
% happen only if \env\ is not yet defined or gets redefined:
% \item[Line \Coderef{othm}{4}:] (from latex.ltx)
% make \env\ use the counter \meta{use\_ctr}.
% \item[Lines \Coderef{othm}{5}--\Coderef{othm}{11}]
% similar to lines \Coderef{nthm}{2}--\Coderef{nthm}{8}
% of |\@nthm|.
% \item[Lines \Coderef{othm}{12}--\Coderef{othm}{14}]
% define |\mkheader@|\env\ to set the style parameters of the header
% and set the header (by |\@thm|):
% \begin{quote}
% |\mkheader@|\env\ ==
% |\setparms@|\env|\@thm{|\env|}{|\meta{use\_ctr}|}{|\meta{output\_name}|}|.
% \end{quote}
% (|\setparms@|\env\ is defined when |\@newtheorem{|\env|}| is
% carried out).
% \item[Line \Coderef{othm}{15}:]
% (from latex.ltx): |\end|\env\ calls |\@endtheorem|.
% \end{packeddescr}
% \end{macro}
%
% \begin{macro}{\@xnthm}
% \changes{v0.93}{1997/03/12}{@definecounter only if not yet defined (WM)}
% \changes{v1.02}{1997/05/31}{fixed collision at '@thm', introduced
% 'setparms' and 'mkheader' (WM)}
% |\@xnthm| is called by |\@nthm| if the numbering is relative to some
% structuring level.
% \Codelabel{xnthm}
% \begin{macrocode}
\gdef\@xnthm#1#2[#3]{%
\ifthm@tempif
\expandafter\@ifundefined{c@#1}%
{\@definecounter{#1}}{}%
\@newctr{#1}[#3]%
\expandafter\xdef\csname the#1\endcsname{%
\expandafter\noexpand\csname the#3\endcsname \@thmcountersep
{\noexpand\csname\the\theoremnumbering\endcsname{#1}}}%
\expandafter\gdef\csname mkheader@#1\endcsname
{\csname setparms@#1\endcsname
\@thm{#1}{#1}{#2}}%
\global\@namedef{end#1}{\@endtheorem}\fi}
% \end{macrocode}
%
% Arguments: \\
% \env:=|#1| is the (internal) environment name to be defined
% (transmitted from |\@newtheorem|). \\
% \meta{output\_name}:=|#2| is its keyword to be used in the
% output, \\
% \meta{level}:=|#3| is the structuring level relative to which \env\
% has to be numbered (both read from the \LaTeX\ source).
%
% \begin{packeddescr}
% \item[Lines \Coderef{xnthm}{3}--\Coderef{xnthm}{12}]
% happen only if \env\ is not yet defined or gets redefined:
% \item[Lines \Coderef{xnthm}{3},\Coderef{xnthm}{4}:]
% in not yet defined, define \env- counter (otherwise, \env\
% is redefined).
% \item[Line \Coderef{xnthm}{6}:]
% (from latex.ltx): define the counter for \env\ and add
% \meta{level} to its reset-triggers.
% \item[Lines \Coderef{xnthm}{7}, \Coderef{xnthm}{8}:]
% define |\the|\env\ to be the command sequence
% \begin{quote}
% |\the|\meta{level}|\@thmcountersep|\meta{numbering}|{|\env|}|~,
% \end{quote}
% where \meta{numbering} is the value of |\theoremnumbering| when
% |\@xnthm| (and thus, |\newtheorem{|\env|}|) is called.
% \item[Lines \Coderef{xnthm}{9}--\Coderef{xnthm}{11}:]
% define |\mkheader@|\env\ to set the style parameters of the header
% and set the header (by |\@thm|):
% \begin{quote}
% |\mkheader@|\env\ ==
% |\setparms@|\env|\@thm{|\env|}{|\env|}{|\meta{output\_name}|}|.
% \end{quote}
% (|\setparms@|\env\ is defined when |\@newtheorem{|\env|}| is
% carried out).
% \item[Line \Coderef{xnthm}{12}:]
% (from latex.ltx): |\end|\env\ calls |\@endtheorem|.
% \end{packeddescr}
% \end{macro}
%
% \begin{macro}{\@ynthm}
% \changes{v0.93}{1997/03/12}{'@definecounter' only if not yet defined (WM)}
% \changes{v1.02}{1997/05/31}{fixed collision at '@thm', introduced
% 'setparms' and 'mkheader' (WM)}
% |\@ynthm| is called by |\@nthm| if the counter is not relative to any
% structuring level.\\
% \Codelabel{ynthm}
% \begin{macrocode}
\gdef\@ynthm#1#2{%
\ifthm@tempif
\expandafter\@ifundefined{c@#1}%
{\@definecounter{#1}}{}%
\expandafter\xdef\csname the#1\endcsname
{\noexpand\csname\the\theoremnumbering\endcsname{#1}}%
\expandafter\gdef\csname mkheader@#1\endcsname
{\csname setparms@#1\endcsname
\@thm{#1}{#1}{#2}}%
\global\@namedef{end#1}{\@endtheorem}\fi}
% \end{macrocode}
%
% Arguments: \\
% \env:=|#1| is the (internal) environment name to be defined
% (transmitted from |\@newtheorem|). \\
% \meta{output\_name}:=|#2| is its keyword to be used in the
% output. \\
% |\@ynthm| works analogous to |\@xnthm|.
% \end{macro}
%
% \paragraph{Handling Instances of Theorem-Environments.}
%
% \begin{macro}{\@thm}
% |\@thm| is called by |\@|\env\ (which is defined by
% |\@othm|/|\@xnthm|/|\@ynthm|).
% \changes{v1.21}{2002/12/30}{added handling of 'theoremprework' (WM)}
% \Codelabel{atthm}
% \begin{macrocode}
\gdef\@thm#1#2#3{%
\if@thmmarks
\stepcounter{end\InTheoType ctr}%
\fi
\renewcommand{\InTheoType}{#1}%
\if@thmmarks
\stepcounter{curr#1ctr}%
\setcounter{end#1ctr}{0}%
\fi
\refstepcounter{#2}%
\theorem@prework
\thm@topsepadd \theorempostskipamount % cf. latex.ltx: \@trivlist
\ifvmode \advance\thm@topsepadd\partopsep\fi
\trivlist
\@topsep \theorempreskipamount
\@topsepadd \thm@topsepadd % used by \@endparenv
\advance\linewidth -\theorem@indent
\advance\@totalleftmargin \theorem@indent
\parshape \@ne \@totalleftmargin \linewidth
\@ifnextchar[{\@ythm{#1}{#2}{#3}}{\@xthm{#1}{#2}{#3}}}
% \end{macrocode}
% \changes{v0.91}{1997/02/27}{'theorem...skip' fixed (WM)}
%
% Changed to three instead of two parameters (the first one is new): \\
% \env:=|#1|: (added) internal name of the theorem environment, \\
% \meta{use\_ctr}:=|#2|: internal name of the theorem which counter
% is used, \\
% \meta{output\_name}:=|#3|: keyword to be displayed in the output;
% all arguments are transmitted from |\@othm|/|\@xnthm|/|\@ynthm|.
% \begin{packeddescr}
% \item[Lines \Coderef{atthm}{2}--\Coderef{atthm}{4}:]
% if |thmmarks| is active, the counter for the current
% environment \envx\ is incremented, since the last endmark in
% environment \envx\ is definitely not the position for its endmark
% (necessary for nested environments ending at the same time).
% \item[Line \Coderef{atthm}{5}:]
% set |\InTheoType| to \env.
% \item[Lines \Coderef{atthm}{6}--\Coderef{atthm}{9}:]
% if |thmmarks| is active, increment |curr|\env|ctr| and
% set |end|\env|ctr| to 0.
% \item[Line \Coderef{atthm}{10}:]
% adapted from latex.ltx: increment the corresponding counter.
% \item[Line \Coderef{atthm}{11}:]
% perform |prework| (before theorem structure is generated).
% \item[Lines \Coderef{atthm}{12}--\Coderef{atthm}{16}:]
% handle |\theorempreskipamount| and |\theorempostskipamount|
% (if in |vmode|, there is additional space,
% cf.\ |\trivlist| and |\@trivlist| in latex.ltx).
% \item[Lines \Coderef{atthm}{17}--\Coderef{atthm}{19}:]
% handle |\theoremindent|.
% \item[Line \Coderef{atthm}{20}:]
% if there is an optional argument, call
% |\@ythm{|\env|}{|\meta{use\_ctr}|}{|\meta{output\_name}|}|, otherwise
% call |\@xthm{|\env|}{|\meta{use\_ctr}|}{|\meta{output\_name}|}|.
% \end{packeddescr}\end{macro}
%
% \begin{macro}{\@xthm}
% |\@xthm| is called by |\@thm| if there is no optional text in
% the theorem header.
% \Codelabel{xthm}
% \begin{macrocode}
\def\@xthm#1#2#3{%
\@begintheorem{#3}{\csname the#2\endcsname}%
\ifx\thm@starredenv\@undefined
\thm@thmcaption{#1}{{#3}{\csname the#2\endcsname}{}}\fi
\ignorespaces}
% \end{macrocode}
%
% Changed to three instead of two parameters (the first one is new): \\
% \env:=|#1|: (added) internal name of the theorem environment, \\
% \meta{use\_ctr}:=|#2|: internal name of the theorem which counter
% is used, \\
% \meta{output\_name}:=|#3|: keyword to be displayed in the output. \\
% All arguments are transmitted from |\@thm|. \\
% For comments, see |\@ythm|.
% \end{macro}
%
% \begin{macro}{\@ythm}
% \changes{v1.1}{1998/03/31}{added definition of 'env\-name' (WM)}
% |\@ythm| is called by |\@thm| if there is an optional text in
% the theorem header.
% \Codelabel{ythm}
% \begin{macrocode}
\def\@ythm#1#2#3[#4]{%
\expandafter\global\expandafter\def\csname#1name\endcsname{#4}%
\@opargbegintheorem{#3}{\csname the#2\endcsname}{#4}%
\ifx\thm@starredenv\@undefined
\thm@thmcaption{#1}{{#3}{\csname the#2\endcsname}{#4}}\fi%
\ignorespaces}
% \end{macrocode}
%
% Changed to four instead of three parameters (the first one is new): \\
% \env:=|#1|: (added) internal name of the theorem environment, \\
% \meta{use\_ctr}:=|#2|: internal name of the theorem which counter
% is used, \\
% \meta{output\_name}:=|#3|: keyword to be displayed in the output. \\
% \meta{opt\_text}:=|#4|: optional text to appear in the header. \\
% |#1|--|#3| are transmitted from |\@thm|, |#4| is read from the \LaTeX\
% source.
% \begin{packeddescr}
% \item[Line \Coderef{ythm}{2}:]
% define |\|\meta{env}|name| to be the optional argument.
% \item[Line \Coderef{ythm}{3}:] call
% \begin{quote}
% |\@opargbegintheorem{|\meta{output\_name}|}{\the|\meta{use\_ctr}|}{|\meta{opt\_text}|}|
% \end{quote}
% which outputs the header.
% \item[Line \Coderef{ythm}{4}, \Coderef{ythm}{5}:]
% if \env\ is not the starred version, call
% \begin{quote}
% |\thm@thmcaption{|\meta{env}|}{{|\meta{output\_name}|}|\ignorespaces
% |{\the|\meta{use\_ctr}|}{|\meta{opt\_text}|}}|
% \end{quote}
% which makes an entry into the theorem list.
% \end{packeddescr} \end{macro}
%
% \begin{macro}{\@endtheorem}
% \changes{v1.21}{2002/12/30}{added changes to '@endtheorem' in case that
% [thmmarks] is not active (WM)}
%
% |\@endtheorem| is called for every |\end{|\env|}|, where \env\ is a
% theorem-like environment.
% (note that |\@endtheorem| it is also changed by option [thmmarks]
% to organize the placement of the corresponding end mark).
% |\InTheoType| gives the innermost theorem-like environment,
% i.e.\ the one to be ended:
%
% \begin{macrocode}
\gdef\@endtheorem{%
\endtrivlist
\csname\InTheoType @postwork\endcsname
}
% \end{macrocode}
% \end{macro}
%
% \subsubsection{Framed and Boxed Theorems}
%
% The option `framed' activates framed and boxed layouts.
% It requires to load the |framed| package and the |pstricks| package.
%
% \changes{v1.21}{2002/12/30}{included option `framed' (WM)}
% \begin{macro}{framed}
%
% \begin{macrocode}
\DeclareOption{framed}{%*********************************
\newtoks\shadecolor
\shadecolor{gray}
\let\theoremframecommand\relax
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\newshadedtheorem}
% \changes{v1.21}{2002/12/30}{added (WM)}
% \changes{v1.30}{2010/08/15}{added `theoremframepre/postskipamount' (WM)}
% \begin{macrocode}
\def\newshadedtheorem#1{%
\expandafter\global\expandafter\xdef\csname#1@shadecolor\endcsname{%
\the\shadecolor}%
\ifx\theoremframecommand\relax
\expandafter\global\expandafter\xdef\csname#1@framecommand\endcsname{%
\noexpand\psframebox[fillstyle=solid,
fillcolor=\csname#1@shadecolor\endcsname,
linecolor=\csname#1@shadecolor\endcsname]}%
\else
\expandafter\global\expandafter\let\csname#1@framecommand\endcsname%
\theoremframecommand%
\fi
\theoremprework{%
\def\FrameCommand{\csname#1@framecommand\endcsname}%
\vskip\theoremframepreskipamount\framed}%
\theorempostwork{\endframed\vskip\theoremframepostskipamount}%
\newtheorem@i{#1}%
}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\newframedtheorem}
% \begin{macrocode}
\def\newframedtheorem#1{%
\theoremprework{\vskip\theoremframepreskipamount\framed}%
\theorempostwork{\endframed\vskip\theoremframepostskipamount}%
\newtheorem@i{#1}%
}
}% end of option framed **********************************************
% \end{macrocode}
% \end{macro}
%
% \subsubsection{Generation of Theorem Lists}\label{sec:CodeLists}
%
% The generation of lists of theorems, definitions, etc.\ is based
%
% The following macros are are needed for the generation of theorem-lists.
% We will document it for the theorem
% |\begin{definition}[optional]|, which we assume to be the first
% definition at all and which is placed on page 5.
%
% \begin{macro}{\thm@thmcaption}
% This macro, used internally, strips of the outer brackets
% from the second argument and calls |\thm@@thmcaption|.
% It's typically called like this
% \begin{quote}
% |\thm@thmcaption{definition}{{Definition}{1}{optional}}|
% \end{quote}
% (internal name of the environment, output keyword, running number,
% optional text)
% \begin{macrocode}
\def\thm@thmcaption#1#2{\thm@@thmcaption{#1}#2}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\thm@@thmcaption}
% \changes{v1.18}{1999/12/25}{'thm@parseforwriting' also for \#2 (WM)}
% |\thm@caption| is called from |\thm@caption|; it writes an
% appropriate entry to the |.thm|-file.
% \Codelabel{thmcaption}
% \begin{macrocode}
\def\thm@@thmcaption#1#2#3#4{%
\thm@parseforwriting{#2}%
\let\thm@tmpii\thm@tmp
\thm@parseforwriting{#4}%
\edef\thm@t{{\thm@tmpii}{#3}{\thm@tmp}}%
\addcontentsline{thm}{#1}{\thm@t}}
% \end{macrocode}
%
% Arguments:
% \env:=|#1| is the internal environment name,
% \meta{output\_name}:=|#2| is its keyword to be used in the
% output, |#3| is the running number, and |#4| is the optional
% text argument in the header.
%
% \begin{packeddescr}
% \item[Lines \Coderef{thmcaption}{1},\Coderef{thmcaption}{2}:]
% the command sequence for the output keyword is prepared by
% |\thm@parseforwriting| (which returns |\thm@tmpii|) and then
% stored in |\thm@tmpii|.
% \item[Line \Coderef{thmcaption}{3}:]
% the optional text is also prepared by |\thm@parseforwriting|
% \item[Lines \Coderef{thmcaption}{4},\Coderef{thmcaption}{5}:]
% The output is collected and written into the |.aux| file,
% which will forward it to the theorem-file.
% \end{packeddescr}
% \end{macro}
%
% The following two macros are just shortcuts, often needed
% for the output of one single line in the theorem-lists. The
% first one is used in unnamed lists, the second one in named.
% Warning: Don't remove the leading |\let|, since you will get
% wrong |\if|-|\fi|-nesting without it, if you don't use
% |hyperref|.
% \begin{macro}{\thm@@thmline@noname}
% \changes{v1.17}{1999/09/06}{intruduced shortcuts for single lines in lists (AS)}
% \changes{v1.17}{1999/09/07}{hyperref adjustment (AS)}
% \begin{macrocode}
\def\thm@@thmline@noname#1#2#3#4{%
\@dottedtocline{-2}{0em}{2.3em}%
{\protect\numberline{#2}#3}%
{#4}}
% \end{macrocode}
% \end{macro}
% \begin{macro}{\thm@@thmline@name}
% \begin{macrocode}
\def\thm@@thmline@name#1#2#3#4{%
\@dottedtocline{-2}{0em}{2.3em}%
{#1 \protect\numberline{#2}#3}%
{#4}}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\thm@thmline}
% This is another short one, which only discards the outer brackets
% from the first argument and calls |\thm@@thmline|. It's normally
% called like this:
% \begin{quote}
% |\thm@@thmline{{Definition}{1}{optional}}{5}|
% \end{quote}
% \begin{macrocode}
\def\thm@thmline#1#2{\thm@@thmline#1{#2}}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\thm@lgobble}
% \changes{v1.31}{2011/02/14}{split 'thm@lgobble' into 'thm@lgobble@entry'
% and 'thm@lgobble@freetext' (WM)}
% The following macros are used to ignore entries for theorem sets, that
% should not occur in a given list:
% \begin{macrocode}
\long\def\thm@lgobble@entry#1#2{\ignorespaces}
\long\def\thm@lgobble@freetext#1#2{\ignorespaces}
% \end{macrocode}
% \end{macro}
%
% The following four macros set up the predefined list-types. To do so,
% they define the internal macros |\thm@@thmlstart| (containing the code
% to be executed at the beginning of the list), |\thm@@thmlend| (code
% to be executed at the end of the list) and |\thm@@thmline| (code to
% be executed for every line). In order to gain compatibility with
% |newthm.sty|, we decided not to make this commands inaccessible
% to the user. But we recommend not using these commands, because they may
% disappear in later distributions.
%
% \begin{macro}{\theoremlistall}
% This one implements the type |all|.
% \begin{macrocode}
\def\theoremlistall{%
\let\thm@@thmlstart=\relax
\let\thm@@thmlend=\relax
\let\thm@@thmline=\thm@@thmline@noname}
% \end{macrocode}
% \end{macro}
% \begin{macro}{\theoremlistallname}
% And here's the type |allname|.
% \begin{macrocode}
\def\theoremlistallname{%
\let\thm@@thmlstart=\relax
\let\thm@@thmlend=\relax
\let\thm@@thmline=\thm@@thmline@name}
% \end{macrocode}
% \end{macro}
% \begin{macro}{\theoremlistoptional}
% This one is the list-type |opt|. In case of |[hyperref]|, the fifth
% argument, which is provided by |hyperref.sty| is automatically
% given to |\thm@@thmline@noname|.
% \begin{macrocode}
\def\theoremlistoptional{%
\let\thm@@thmlstart=\relax
\let\thm@@thmlend=\relax
\def\thm@@thmline##1##2##3##4{%
\ifx\empty ##3%
\else
\thm@@thmline@noname{##1}{##2}{##3}{##4}%
\fi}}
% \end{macrocode}
% \end{macro}
% \begin{macro}{\theoremlistoptname}
% And the last type, |optname|. In case of |[hyperref]|, the fifth
% argument, which is provided by |hyperref.sty| is automatically
% given to |\thm@@thmline@name|.
% \begin{macrocode}
\def\theoremlistoptname{%
\let\thm@@thmlstart=\relax
\let\thm@@thmlend=\relax
\def\thm@@thmline##1##2##3##4{%
\ifx\empty ##3%
\else%
\thm@@thmline@name{##1}{##2}{##3}{##4}%
\fi}}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\theoremlisttype}
% \changes{v0.92}{1997/03/03}{added error-handling (AS)}
% The next one is the user-interface for selecting the list-type. It simply
% calls |\thm@thml@|\meta{type}, if the given \meta{type} is defined.
% \begin{macrocode}
\def\theoremlisttype#1{%
\@ifundefined{thm@thml@#1}%
{\PackageError{\basename}{Listtype #1 not defined}\@eha}%
{\csname thm@thml@#1\endcsname}}
% \end{macrocode}
% \end{macro}
% Now, here is the code, which maps the types -- selected by
% |\theoremlisttype| -- to the defined macros.
% \begin{macrocode}
\def\thm@thml@all{\theoremlistall}
\def\thm@thml@opt{\theoremlistoptional}
\def\thm@thml@optname{\theoremlistoptname}
\def\thm@thml@allname{\theoremlistallname}
% \end{macrocode}
%
% \begin{macro}{\newtheoremlisttype}
% \changes{v0.86}{1997/02/15}{added (AS)}
% \changes{v0.92}{1997/03/03}{added error-handling (AS)}
% According to the given documentation, this one can be used to define
% new list-types. It's done by defininig the macro
% |\thm@thml@|\meta{type}, which \emph{locally} redefines
% the commands |\thm@thmlstart|, |\thm@@thmline| and |\thm@@thmlend|.
% \begin{macrocode}
\def\newtheoremlisttype#1#2#3#4{%
\@ifundefined{thm@thml@#1}%
{\expandafter\gdef\csname thm@thml@#1\endcsname{%
\def\thm@@thmlstart{#2}%
\def\thm@@thmline####1####2####3####4{#3}%
\def\thm@@thmlend{#4}}%
}{\PackageError{\basename}{list type #1 already defined}\@eha}}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\renewtheoremlisttype}
% \changes{v0.93}{1997/03/12}{introduced newtheoremlisttype (WM)}
% \begin{macrocode}
\def\renewtheoremlisttype#1#2#3#4{%
\@ifundefined{thm@thml@#1}%
{\PackageError{\basename}{List type #1 not defined}\@ehc}{}%
\expandafter\let\csname thm@thml@#1\endcsname\relax
\newtheoremlisttype{#1}{#2}{#3}{#4}}
% \end{macrocode}
% if the list type to be redefined is already defined, make it undefined
% and define it.
% \end{macro}
%
%
% \begin{macro}{\thm@definelthm}
% For each theorem-set, we need to initialize two commands:
% \begin{itemize}
% \item how to typeset entries in the list, |\l@|\meta{theorem-set}.
% it is called for each theorem when the list is generated.
% \item how to typeset additional text in the list,
% |\thm@listdo|\meta{theorem-set}. It is called, when something is
% to a list with |\addtotheoremfile|.
% \end{itemize}
% These macros are initially defined by |\newtheorem| to
% discard the input by calling |\thm@lgobble@entry| (for actual
% entries) and |\thm@lgobble@freetext| (for free text added by the user).
% These macros must be adapted if a package uses another format for
% |\contentsline| entries in the |.aux| file (e.g., |hyperref|).
% \begin{macrocode}
\def\thm@definelthm#1{%
\expandafter\gdef\csname l@#1\endcsname{\thm@lgobble@entry}%
\expandafter\gdef\csname thm@listdo#1\endcsname{\thm@lgobble@freetext}}
% \end{macrocode}
% \end{macro}
% \begin{macro}{\thm@inlistdo}
% When additional text is added to a theorem list via |\addtotheoremfile|,
% this is typeset by the following is macro. It simply discards
% the first argument and strips of the outer brackets from the second one.
% \begin{macrocode}
\long\def\thm@inlistdo#1#2{#2}%
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\listtheorems}
% \changes{v0.89}{1997/02/18}{fixed a bug for lists (AS)}
% \changes{v0.92}{1997/03/02}{made commands global in order to handle
% tabular-lists (AS)}
% The following macro provides the user interface:
% \Codelabel{listtheorems}
% \begin{macrocode}
\def\listtheorems#1{\begingroup
\c@tocdepth=-2%
\def\thm@list{#1}\thm@processlist
\endgroup}
% \end{macrocode}
%
% \begin{packeddescr}
% \item[Line \Coderef{listtheorems}{1}:]
% |#1| is a list of theorem sets, i.e., of the form |Theorem| or
% |Theorem, Definition, ...|.
% \item[Line \Coderef{listtheorems}{2}:] set |tocdepth| to $-2$ to assure
% that the predefined list-types work.
% \item[Line \Coderef{listtheorems}{3}:] store the list of names in |thm@list|
% and call |\thm@processlist|, which actually generates the list.
% \end{packeddescr}
% \end{macro}
% \begin{macro}{\thm@processlist}
%
% \changes{v1.17}{1999/09/06}{Switch to normal contentsline-behaviour for
% lists (hyperref) (AS)}
% \changes{v1.19}{2001/01/13}{check for yet undefined theoremsets (WM)}
% The file \meta{jobname}|.thm| contains commands of the form \\
% \hspace*{0.5cm}
% |\contentsline{|\meta{list-of-theoremsets}|}{{|\meta{header}|}{|\meta{number}|}}{|\meta{page}|}|.\\
% Thus, dependent on which theoremsets should be listed,
% |\contentsline| must be defined to evaluate the first argument and then
% to output all arguments, or to discard the second and third one.
%
% This is done as follows:
% The commands |\l@|\meta{theorem-set} and |\thm@listdo|\meta{theorem-set}
% (which initially were set to ignore everything by |\newtheorem|)
% are redefined for the theorem sets which should be listed to
% generate output.
% |\contentsline| is defined to call |\l@|\meta{theorem-set}, adding a
% line to the list or ignoring the entry.
% Since for theorem sets which are not yet known (i.e., if the list
% is created at the beginning of the document, and the theoremset is
% only defined later), |\l@|\meta{theorem-set} is not yet defined,
% |\contentsline| has to check if the command is defined, otherwise
% ignore the arguments.
%
% Then, the |.thm| file is processed, evaluating the |\contentsline|
% commands.
% After processing the |.thm| file, the mentioned commands are
% again redefined to discard everything. We need to define the macros
% globally for dealing with complex, user-defined, list-types.
%
% \changes{v1.31}{2011/02/14}{split 'thm@lgobble' into 'thm@lgobble@entry'
% and 'thm@lgobble@freetext' (WM, reported by Barbara Santa)}
% \begin{macrocode}
\def\thm@processlist{%
\begingroup
\typeout{** Generating table of \thm@list}%
\def\contentsline##1{%
\expandafter\@ifundefined{l@##1}%
{\thm@lgobble@entry}{\csname l@##1\endcsname}}%
\thm@@thmlstart
\@for\thm@currentlist:=\thm@list
\do{%
\ifx\thm@currentlist\@empty\else
\expandafter\gdef\csname l@\thm@currentlist\endcsname{\thm@thmline}%
\expandafter\gdef\csname thm@listdo\thm@currentlist\endcsname{\thm@inlistdo}%
\fi
}%
\@input{\jobname .thm}%
\thm@@thmlend
\@for\thm@currentlist:=\thm@list
\do{%
\ifx\thm@currentlist\@empty\else
\expandafter\gdef\csname l@\thm@currentlist\endcsname
{\thm@lgobble@entry}%
\expandafter\gdef\csname thm@listdo\thm@currentlist\endcsname
{\thm@lgobble@freetext}%
\fi
}%
\endgroup}
% \end{macrocode}
% \end{macro}
% \begin{macro}{\thm@enablelistoftheorems}
% \changes{v0.92}{1997/03/02}{renamed (AS)}
% Up to now, we've set up various macros for writing and reading the
% theorem-file.
% Thus, it's time to set up the file itself. This is done by the next macro.
% We simply took the lines for |\@starttoc| from the \LaTeX-base and
% changed some things. The main intention to copy |\@starttoc| is that
% we don't want the file to be input when it is set up -- like it's done
% by |\@starttoc|.
% \begin{macrocode}
\def\thm@enablelistoftheorems{%
\begingroup
\makeatletter
\if@filesw
\expandafter\newwrite\csname tf@thm\endcsname%
\immediate\openout \csname tf@thm\endcsname \jobname.thm\relax%
\fi
\@nobreakfalse
\endgroup}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\addtheoremline}
% \changes{v0.89}{1997/02/18}{added (AS)}
% By |\addtheoremline{|\meta{theorem-set}|}{|\meta{entry}|}|,
% the user can insert an extra entry into the theorem-file.
% |\addtheoremline*| calls the internal macro
% |\nonum@addtheoremline|, otherwise |\num@addtheoremline| is called.
% |\num/nonum@addtheoremline{|\meta{theorem-set}|}{|\meta{entry}|}|
% calls
% |\num/nonum@addtheoremline|\meta{theorem-set}|{|\meta{entry}|}|
% which are
% defined when \meta{theorem-set} is declared (cf.\ |\@nthm|).
% These in turn call |\@num/nonum@addtheoremline{|\meta{theorem-set}%
% |}{|\meta{keyword}|}{|\meta{entry}|}|
% which write information to the theorem file.
%
% \begin{macrocode}
\def\addtheoremline{\@ifstar{\nonum@addtheoremline}{\num@addtheoremline}}
\def\nonum@addtheoremline#1{\csname nonum@addtheoremline#1\endcsname}%
\def\num@addtheoremline#1{\csname num@addtheoremline#1\endcsname}%
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\@nonum@addtheoremline}
% |\@num@addtheoremline| and |\@nonum@addtheoremline| write the
% actual entries to the |.thm| file. \\
% Syntax: |\@num/nonum@addtheoremline{|%
% \meta{theorem-set}|}{|\meta{keyword}|}{|\meta{entry}|}|
% \begin{macrocode}
\def\@nonum@addtheoremline#1#2#3{%
\thm@parseforwriting{#3}%
\edef\thm@t{{#2}{}{\thm@tmp}}%
\addcontentsline{thm}{#1}{\thm@t}}
% \end{macrocode}
% \end{macro}
% \begin{macro}{\@num@addtheoremline}
% \begin{macrocode}
\def\@num@addtheoremline#1#2#3{%
\thm@parseforwriting{#3}%
\edef\thm@t{{#2}{\csname the#1\endcsname}{\thm@tmp}}%
\addcontentsline{thm}{#1}{\thm@t}}%
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\addtotheoremfile}
% \changes{v0.89}{1997/02/18}{added (AS)}
% To write any additional stuff into the theorem-file, the next macro
% is used. It first checks, if the optional name of a theorem-set is given.
% In that case, the macro |\@@addtotheoremfile|, otherwise
% |\@addtotheoremfile| is used to write the stuff into the file.
% \begin{macrocode}
\long\def\addtotheoremfile{%
\@ifnextchar[{\@@addtotheoremfile}{\@addtotheoremfile}}
% \end{macrocode}
% \end{macro}
% \begin{macro}{\@addtotheoremfile}
% Write additional stuff for all theorems.
% \begin{macrocode}
\long\def\@addtotheoremfile#1{%
\thm@parseforwriting{#1}%
\protected@write\@auxout%
{}{\string\@writefile{thm}{\thm@tmp}}}
% \end{macrocode}
% \end{macro}
% \begin{macro}{\@@addtotheoremfile}
% Write additional stuff for a given theorem-set.
% \begin{macrocode}
\long\def\@@addtotheoremfile[#1]#2{%
\thm@parseforwriting{#2}%
\protected@write\@auxout%
{}{\string\@writefile{thm}{\string\theoremlistdo{#1}{\thm@tmp}}}}
% \end{macrocode}
% \end{macro}
% \begin{macro}{\theoremlistdo}
% \changes{v1.19}{2001/01/13}{check for yet undefined theoremsets (WM)}
% This one is called from the theorem-file to insert the additional
% stuff for a theorem-set.
% \begin{macrocode}
\long\def\theoremlistdo#1#2{\expandafter\@ifundefined{thm@listdo#1}%
\relax{\csname thm@listdo#1\endcsname{#1}{#2}}}
% \end{macrocode}
% \end{macro}
%
% Now we assure, that the theorem-file is activated. This is done by
% inserting a hook at the end of the document.
% \changes{v0.83}{1997/02/13}{added `AtEndDocument'-Hook for lists (AS)}
% \begin{macrocode}
\AtEndDocument{\thm@enablelistoftheorems}
% \end{macrocode}
%
% \paragraph{Theoremlists and Hyperref}
%
% Since the |hyperref|-package redefines |\contentsline|, some
% commands are redefined:
% \begin{enumerate}
% \item Let the different versions of |\thm@@thmline@..| take a 5th
% argument, the one provided by |hyperref|.
% \item handle contentsline: restore the normal
% definition at the beginning of |\thm@processlist| (see there),
% that calls |l@|\meta{theorem-set} that in turn calls the
% adapted commands for typestting the entries (see below). .
% \item Let |\thm@lgobble@entry| take one more argument,
% the one provided by hyperref.
% \item Do the hyperlinks manually in the different versions of
% |\thm@@thmline| as defined by the theoremtypes.
% \end{enumerate}
%
% \begin{macro}{hyperref}
% \changes{v1.17}{1999/09/07}{added 'hyperref' option
% (AS, based on a proposal by Didier Verna)}
% \begin{macrocode}
\DeclareOption{hyperref}{% **********************************************
\def\thm@@thmline@noname#1#2#3#4#5{%
\ifx\\#5\\%
\@dottedtocline{-2}{0em}{2.3em}%
{\protect\numberline{#2}#3}%
{#4}%
\else
\ifHy@linktocpage\relax\relax
\@dottedtocline{-2}{0em}{2.3em}%
{\protect\numberline{#2}#3}%
{\hyper@linkstart{link}{#5}{#4}\hyper@linkend}
\else
\@dottedtocline{-2}{0em}{2.3em}%
{\hyper@linkstart{link}{#5}{\protect\numberline{#2}#3}%
\hyper@linkend}%
{#4}%
\fi
\fi}%
\def\thm@@thmline@name#1#2#3#4#5{%
\ifx\\#5\\%
\@dottedtocline{-2}{0em}{2.3em}%
{#1 \protect\numberline{#2}#3}%
{#4}
\else
\ifHy@linktocpage\relax\relax
\@dottedtocline{-2}{0em}{2.3em}%
{#1 \protect\numberline{#2}#3}%
{\hyper@linkstart{link}{#5}{#4}\hyper@linkend}%
\else
\@dottedtocline{-2}{0em}{2.3em}%
{\hyper@linkstart{link}{#5}%
{#1 \protect\numberline{#2}#3}\hyper@linkend}%
{#4}%
\fi
\fi}
\def\thm@thmline#1#2#3{\thm@@thmline#1{#2}{#3}}
\long\def\thm@lgobble@entry#1#2#3{\ignorespaces}
\def\theoremlistoptional{%
\let\thm@@thmlstart=\relax
\let\thm@@thmlend=\relax
\def\thm@@thmline##1##2##3##4##5{%
\ifx\empty ##3%
\else%
\thm@@thmline@noname{##1}{##2}{##3}{##4}{##5}%
\fi}}
\def\theoremlistoptname{%
\let\thm@@thmlstart=\relax
\let\thm@@thmlend=\relax
\def\thm@@thmline##1##2##3##4##5{%
\ifx\empty ##3%
\else%
\thm@@thmline@name{##1}{##2}{##3}{##4}{##5}%
\fi}}
% \end{macrocode}
% \changes{v1.20}{2002/01/07}{replaced ifhy by ifHy (AS, reported by J.J.Bataille)}
% \end{macro}
%
% \paragraph{Theorem References and Hyperref}
%
% \begin{macro}{hyperref-thref}
% When |hyperref| is active, the handling of |thref| described above via
% the |.aux| file redefinition of |\@newl@bel| is not possible (|hyperref|
% forces its definitions at |\AtBeginDocument|). Instead, an internal
% identifier of the form |Theorem.1.1| is used in the |.aux| file for
% the hypertarget (using the type of the counter; thus when a theorem type
% uses another counter, this does not give the theorem type itself).
% The same id is stored in the |.thm| file for
% the respective theorem. by this, given the id from the |\newlabel| in
% the |.aux| file, the |.thm| file can be searched for the actual type
% information.
%
% \changes{v1.31}{2011/02/15}{(WM, reported by Gunner Gewiss)}
% \Codelabel{hyperthref}
% \begin{macrocode}
\if@thref
\def\@firstofthree#1#2#3{#1}%
\def\getKeywordOf#1{%
\let\thm@oldcontentsline\contentsline
\def\contentsline##1##2##3##4{%
\ifthenelse{\equal{#1}{##4}}{\@firstofthree##2}{}%
\ignorespaces}%
\@input{\jobname .thm}%
\let\contentsline\thm@oldcontentsline
}
\def\thm@fmt@hyplabel@i#1#2#3#4#5{%
\getKeywordOf{#4}~\thm@fmt@hyplabel@ii#4}
\def\thm@fmt@hyplabel@ii#1.#2{#2}%
\def\thref#1{%
\expandafter\@setref\csname r@#1\endcsname\thm@fmt@hyplabel@i{#1}}%
\fi % end of \if@thref
}% end of option hyperref *********************************************
% \end{macrocode}
% \begin{packeddescr}
% \item[Lines \Coderef{hyperthref}{2}-\Coderef{hyperthref}{10}:]
% given an id |#1| of the form |Theorem.1.1|, scan the |.thm| file
% for a |\contentsline| whose 4th argument equals the id. If found,
% the third component of its second argument gives its theorem type.
% \item[Lines \Coderef{hyperthref}{11}-\Coderef{hyperthref}{13}:]
% this command must have 5 arguments because it is applied to
% the information stored with |\newlabel| in the |.aux| file. The
% 4th argument is the id |#4| of the form |Theorem.1.1|. \\
% Get the correct keyword by |\getKeywordOf{#4}| and its number
% (which is the part following the first ``.'').
% \item[Lines \Coderef{hyperthref}{14}-\Coderef{hyperthref}{15}:]
% create a hyperlink via |\@setref| (see |hyperref.sty|): |\@setref|
% takes three arguments: |r@|\meta{label} := $arg_1$ is the information
% from |\newlabel| in the |.aux| file (consisting of 5 components).
% The 2nd argument $arg_2$ must be a command that uses 5 arguments,
% here |\thm@fmt@hyplabel@i{#1}| as defined in Lines
% \Coderef{hyperthref}{11}-\Coderef{hyperthref}{13}. The
% 3rd one is the label, and is only used for error messages.
% |\@setref| then --roughly-- applies $arg_2$ on $arg_1$.
% \end{packeddescr}
% \end{macro}
%
% \subsubsection{Auxiliary macros}
%
% For generating theorem-lists, we need to write information into
% a separate file. Beause we don't want to expand this information,
% we parse it specially for writing.
% \begin{macrocode}
\def\thm@meaning#1->#2\relax{#2}% remove "macro: ->"
\long\def\thm@parseforwriting#1{%
\def\thm@tmp{#1}%
\edef\thm@tmp{\expandafter\thm@meaning\meaning\thm@tmp\relax}}
% \end{macrocode}
%
% In some countries it's usual to number theorems with greek letters:
%
% \begin{macro}{\theorem@checkbold}
% \changes{v0.83}{1997/02/13}{fixed greek numbering for bold headers (AS)}
% For correctness, we need to check if a bold font is active. This
% is done by the following macro:
% \begin{macrocode}
\def\theorem@checkbold{\if b\expandafter\@car\f@series\@nil\boldmath\fi}
% \end{macrocode}
% \end{macro}
% \begin{macro}{\@greek}
% Accoding to \LaTeX-base, this is the internal command for generating
% lowercase greek numberings.
% \begin{macrocode}
\def\@greek#1{\theorem@checkbold%
\ifcase#1\or$\alpha$\or$\beta$\or$\gamma$\or$\delta$\or$\varepsilon$%
\or$\zeta$\or$\eta$\or$\vartheta$\or$\iota$\or$\kappa$\or$\lambda$\or$%
\mu$\or$\nu$\or$\xi$\or$ o$\or$\varpi$\or$\varrho$\or$\varsigma$\or$\tau$%
\or$\upsilon$\or$\varphi$\or$\chi$\or$\psi$\or$\omega$\else\@ctrerr\fi}
% \end{macrocode}
% \end{macro}
% \begin{macro}{\@Greek}
% According to \LaTeX-base, this is the internal command for generating
% uppercase greek numberings.
% \begin{macrocode}
\def\@Greek#1{\theorem@checkbold%
\ifcase#1\or A\or B\or$\Gamma$\or$\Delta$\or E%
\or Z\or H\or$\Theta$\or I\or K\or$\Lambda$\or M%
\or N\or$\Xi$\or O\or$\Pi$\or P\or$\Sigma$\or T%
\or$\Upsilon$\or$\Phi$\or X\or$\Psi$\or$\Omega$\else\@ctrerr\fi}
% \end{macrocode}
% \end{macro}
% \begin{macro}{\greek}
% According to \LaTeX-base, this is the user interface for lowercase
% greek numberings.
% \begin{macrocode}
\def\greek#1{\@greek{\csname c@#1\endcsname}}
% \end{macrocode}
% \end{macro}
% \begin{macro}{\Greek}
% According to \LaTeX-base, this is the user interface for uppercase
% greek numberings.
% \begin{macrocode}
\def\Greek#1{\@Greek{\csname c@#1\endcsname}}
% \end{macrocode}
% \end{macro}
%
% \subsubsection{Other Things}
%
% After declaring several package-options, we need to process the
% specified ones. The additional |\relax| was mentioned by Rainer Sch\"opf
% at DANTE'97.
% \begin{macrocode}
\ProcessOptions\relax
% \end{macrocode}
% Now we set up the default theorem listtype. Make sure this is called after
% processing the options. Otherwise, |ntheorem| will break with |hyperref|.
% \begin{macrocode}
\theoremlistall
% \end{macrocode}
%
% If automatical configuration is not disabled by |[noconfig]|, it is
% checked if the file |ntheorem.cfg| exists and in this case
% the definitions in this file are read. If it does not exist and the
% option |standard| was specified, the file |ntheorem.std| is used.
%
% \changes{v0.84}{1997/02/13}{added 'ntheorem.cfg' feature (AS)}
% \changes{v1.11}{1998/10/26}{added 'noconfig' option (AS/WM)}
% \begin{macrocode}
\ifx\thm@noconfig\@undefined
\InputIfFileExists{ntheorem.cfg}%
{\PackageInfo{\basename}{Local config file ntheorem.cfg used}}%
{\ifx\thm@usestd\@undefined%
\else%
\InputIfFileExists{ntheorem.std}%
{\PackageInfo{\basename}{Standard config file ntheorem.std used}}{}
\fi}
\fi
% \end{macrocode}
%\iffalse
%</package>\fi
%
% \subsection{The Standard Configuration}
%
% \changes{v0.84}{1997/02/13}{moved standard-theorems to extra file (AS)}
% \setcounter{CodelineNo}{0}
%\iffalse
%<*standard>\fi
% \begin{macrocode}
\theoremnumbering{arabic}
\theoremstyle{plain}
\RequirePackage{latexsym}
\theoremsymbol{\ensuremath{_\Box}}
\theorembodyfont{\itshape}
\theoremheaderfont{\normalfont\bfseries}
\theoremseparator{}
\newtheorem{Theorem}{Theorem}
\newtheorem{theorem}{Theorem}
\newtheorem{Satz}{Satz}
\newtheorem{satz}{Satz}
\newtheorem{Proposition}{Proposition}
\newtheorem{proposition}{Proposition}
\newtheorem{Lemma}{Lemma}
\newtheorem{lemma}{Lemma}
\newtheorem{Korollar}{Korollar}
\newtheorem{korollar}{Korollar}
\newtheorem{Corollary}{Corollary}
\newtheorem{corollary}{Corollary}
\theorembodyfont{\upshape}
\newtheorem{Example}{Example}
\newtheorem{example}{Example}
\newtheorem{Beispiel}{Beispiel}
\newtheorem{beispiel}{Beispiel}
\newtheorem{Bemerkung}{Bemerkung}
\newtheorem{bemerkung}{Bemerkung}
\newtheorem{Anmerkung}{Anmerkung}
\newtheorem{anmerkung}{Anmerkung}
\newtheorem{Remark}{Remark}
\newtheorem{remark}{Remark}
\newtheorem{Definition}{Definition}
\newtheorem{definition}{Definition}
\theoremstyle{nonumberplain}
\theoremheaderfont{\scshape}
\theorembodyfont{\normalfont}
\theoremsymbol{\ensuremath{_\blacksquare}}
\RequirePackage{amssymb}
\newtheorem{Proof}{Proof}
\newtheorem{proof}{Proof}
\newtheorem{Beweis}{Beweis}
\newtheorem{beweis}{Beweis}
\qedsymbol{\ensuremath{_\blacksquare}}
\theoremclass{LaTeX}
% \end{macrocode}
%\iffalse
%</standard>\fi
%
% \section{History and Acknowledgements}
%
% \subsection{The endmark-Story (Wolfgang May)}
%
% In 1995, I started a hack for setting endmarks semiautomatically
% at the end of displayed formulas.
% The work on |thmmarks.sty| begun in October 1996
% by a thread asking for a routine for setting endmarks in
% \emph{de.comp.tex}
% initiated by Boris Piwinger.
% Version 0.1 incorporated the main features for setting endmarks
% automagically by using the |.aux| file. Version 0.2 included
% some bugfixes and was the first one accessible on the internet.
% Boris suggested to include |fleqn| and |leqno| which has been
% done in version 0.3 (which was never made public).
% Since at this point, |thmmarks.sty| was incompatible to the widely
% used |theorem.sty| written by Frank Mittelbach, in Version 0.4,
% the features of theorem.sty have been integrated.
%
% With version 0.5, the case of ``empty'' end symbols has been handled,
% |\qed| has been added (also suggested by Boris), and
% the handling of theoremstyles by |\newtheoremstyle| has been
% included.
%
% For version 0.6, the handling of endmarks in displaymaths has been
% changed in order to adjust them with the bottom of the displayed
% math.
%
% Version 0.6 was the first one announced in \emph{comp.text.tex}.
% For version 0.7, I added the handling of |amsmath| features,
% suggested by my colleague Peter Neuhaus.
%
% Versions 0.71 and 0.72 incorporated minor bugfixes.
%
% \subsection{Lists, Lists, Lists (Andreas Schedler)}
%
% I often saw questions on theoremlists in the
% german newsgroup \emph{de.comp.text.tex}, but I never
% spent any attention on those postings. This changed in
% summer 1996, when I needed those lists for myself. Thus, I
% asked the holy question. But none of the given answers
% satisfied my wish for a simple, easy to use and short
% solution.
%
% I decided to take a look at Frank Mittelbachs
% |theorem.sty|. First I didn't understand much of the code,
% but Bernd Raichle helped me a lot by answering my
% boring questions and I finally understood it.
%
% I started the coding and within a few days, a first
% experimental version was born. Not only that I had implemented
% the lists, I also inserted a separator and a flexible numbering
% of the theorems.
%
% After a long period of
% testing, I wanted to share the new features with other
% \TeX-Freaks and wrote an article for the ``Die \TeX nische Kom\"odie''
% (Journal of german tug, DANTE e.V.). As soon as I had sent
% the article to DANTE, I got first reactions on the style.
% Gerd Neugebauer gave me many hints. I hided several
% cryptical notations in easy definitions and improved the
% user interface.
%
% In January 1997, I released ``newthm'' to the world and it
% was uploaded to the CTAN-Archives. Few days later I sent
% my files to Frank Mittelbach in order to show him my extensions.
% He told me, that already other extensions were made, and that
% it would be good to combine alltogether.
%
% \subsection{Let's come together}
%
% With version 0.8, in February 1997, the combination of
% |thmmarks.sty| with |newthm.sty| to |ntheorem.sty| has been started.
% On April 21, 1997, version 0.94 beta has been made public as
% version 1.0.
%
% In course of the development, the following changes were made:
%
% \GlossaryPrologue{}
%
% \IfFileExists{ntheorem.gls}{\PrintChanges}
% {\begin{quote}You should create the list of changes by
%
% ~~~ \texttt{makeindex -s gglo.ist -o ntheorem.gls ntheorem.glo}
%
% and running \texttt{latex ntheorem.drv} again.\end{quote}}
%
%
% \subsection{Acknowledgements}
%
% This place is dedicated to all those, who helped us developing
% our separate styles and this combined package. Thanks to
% (listed in alphabetical order):
% \begin{quote}
% Donald Arseneau,
% Giovanni Dore,
% Oliver Karch,
% Frank Mittelbach,
% Gerd Neugebauer,
% Heiko Oberdiek,
% Boris Piwinger,
% Bernd Raichle,
% Rainer Sch\"opf,
% Didier Verna.
% \end{quote}
%
% \Finale
\endinput
% Local Variables:
% TeX-command-default: "LaTeX"
% TeX-master: t
% End:
% mode: latex
|