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 4900 4901 4902 4903 4904 4905 4906 4907 4908 4909 4910 4911 4912 4913 4914 4915 4916 4917 4918 4919 4920 4921 4922 4923 4924 4925 4926 4927 4928 4929 4930 4931 4932 4933 4934 4935 4936 4937 4938 4939 4940 4941 4942 4943 4944 4945 4946 4947 4948 4949 4950 4951 4952 4953 4954 4955 4956 4957 4958 4959 4960 4961 4962 4963 4964 4965 4966 4967 4968 4969 4970 4971 4972 4973 4974 4975 4976 4977 4978 4979 4980 4981 4982 4983 4984 4985 4986 4987 4988 4989 4990 4991 4992 4993 4994 4995 4996 4997 4998 4999 5000 5001 5002 5003 5004 5005 5006 5007 5008 5009 5010 5011 5012 5013 5014 5015 5016 5017 5018 5019 5020 5021 5022 5023 5024 5025 5026 5027 5028 5029 5030 5031 5032 5033 5034 5035 5036 5037 5038 5039 5040 5041 5042 5043 5044 5045 5046 5047 5048 5049 5050 5051 5052 5053 5054 5055 5056 5057 5058 5059 5060 5061 5062 5063 5064 5065 5066 5067 5068 5069 5070 5071 5072 5073 5074 5075 5076 5077 5078 5079 5080 5081 5082 5083 5084 5085 5086 5087 5088 5089 5090 5091 5092 5093 5094 5095 5096 5097 5098 5099 5100 5101 5102 5103 5104 5105 5106 5107 5108 5109 5110 5111 5112 5113 5114 5115 5116 5117 5118 5119 5120 5121 5122 5123 5124 5125 5126 5127 5128 5129 5130 5131 5132 5133 5134 5135 5136 5137 5138 5139 5140 5141 5142 5143 5144 5145 5146 5147 5148 5149 5150 5151 5152 5153 5154 5155 5156 5157 5158 5159 5160 5161 5162 5163 5164 5165 5166 5167 5168 5169 5170 5171 5172 5173 5174 5175 5176 5177 5178 5179 5180 5181 5182 5183 5184 5185 5186 5187 5188 5189 5190 5191 5192 5193 5194 5195 5196 5197 5198 5199 5200 5201 5202 5203 5204 5205 5206 5207 5208 5209 5210 5211 5212 5213 5214 5215 5216 5217 5218 5219 5220 5221 5222 5223 5224 5225 5226 5227 5228 5229 5230 5231 5232 5233 5234 5235 5236 5237 5238 5239 5240 5241 5242 5243 5244 5245 5246 5247 5248 5249 5250 5251 5252 5253 5254 5255 5256 5257 5258 5259 5260 5261 5262 5263 5264 5265 5266 5267 5268 5269 5270 5271 5272 5273 5274 5275 5276 5277 5278 5279 5280 5281 5282 5283 5284 5285 5286 5287 5288 5289 5290 5291 5292 5293 5294 5295 5296 5297 5298 5299 5300 5301 5302 5303 5304 5305 5306 5307 5308 5309 5310 5311 5312 5313 5314 5315 5316 5317 5318 5319 5320 5321 5322 5323 5324 5325 5326 5327 5328 5329 5330 5331 5332 5333 5334 5335 5336 5337 5338 5339 5340 5341 5342 5343 5344 5345 5346 5347 5348 5349 5350 5351 5352 5353 5354 5355 5356 5357 5358 5359 5360 5361 5362 5363 5364 5365 5366 5367 5368 5369 5370 5371 5372 5373 5374 5375 5376 5377 5378 5379 5380 5381 5382 5383 5384 5385 5386 5387 5388 5389 5390 5391 5392 5393 5394 5395 5396 5397 5398 5399 5400 5401 5402 5403 5404 5405 5406 5407 5408 5409 5410 5411 5412 5413 5414 5415 5416 5417 5418 5419 5420 5421 5422 5423 5424 5425 5426 5427 5428 5429 5430 5431 5432 5433 5434 5435 5436 5437 5438 5439 5440 5441 5442 5443 5444 5445 5446 5447 5448 5449 5450 5451 5452 5453 5454 5455 5456 5457 5458 5459 5460 5461 5462 5463 5464 5465 5466 5467 5468 5469 5470 5471 5472 5473 5474 5475 5476 5477 5478 5479 5480 5481 5482 5483 5484 5485 5486 5487 5488 5489 5490 5491 5492 5493 5494 5495 5496 5497 5498 5499 5500 5501 5502 5503 5504 5505 5506 5507 5508 5509 5510 5511 5512 5513 5514 5515 5516 5517 5518 5519 5520 5521 5522 5523 5524 5525 5526 5527 5528 5529 5530 5531 5532 5533 5534 5535 5536 5537 5538 5539 5540 5541 5542 5543 5544 5545 5546 5547 5548 5549 5550 5551 5552 5553 5554 5555 5556 5557 5558 5559 5560 5561 5562 5563 5564 5565 5566 5567 5568 5569 5570 5571 5572 5573 5574 5575 5576 5577 5578 5579 5580 5581 5582 5583 5584 5585 5586 5587 5588 5589 5590 5591 5592 5593 5594 5595 5596 5597 5598 5599 5600 5601 5602 5603 5604 5605 5606 5607 5608 5609 5610 5611 5612 5613 5614 5615 5616 5617 5618 5619 5620 5621 5622 5623 5624 5625 5626 5627 5628 5629 5630 5631 5632 5633 5634 5635 5636 5637 5638 5639 5640 5641 5642 5643 5644 5645 5646 5647 5648 5649 5650 5651 5652 5653 5654 5655 5656 5657 5658 5659 5660 5661 5662 5663 5664 5665 5666 5667 5668 5669 5670 5671 5672 5673 5674 5675 5676 5677 5678 5679 5680 5681 5682 5683 5684 5685 5686 5687 5688 5689 5690 5691 5692 5693 5694 5695 5696 5697 5698 5699 5700 5701 5702 5703 5704 5705 5706 5707 5708 5709 5710 5711 5712 5713 5714 5715 5716 5717 5718 5719 5720 5721 5722 5723 5724 5725 5726 5727 5728 5729 5730 5731 5732 5733 5734 5735 5736 5737 5738 5739 5740 5741 5742 5743 5744 5745 5746 5747 5748 5749 5750 5751 5752 5753 5754 5755 5756 5757 5758 5759 5760 5761 5762 5763 5764 5765 5766 5767 5768 5769 5770 5771 5772 5773 5774 5775 5776 5777 5778 5779 5780 5781 5782 5783 5784 5785 5786 5787 5788 5789 5790 5791 5792 5793 5794 5795 5796 5797 5798 5799 5800 5801 5802 5803 5804 5805 5806 5807 5808 5809 5810 5811 5812 5813 5814 5815 5816 5817 5818 5819 5820 5821 5822 5823 5824 5825 5826 5827 5828 5829 5830 5831 5832 5833 5834 5835 5836 5837 5838 5839 5840 5841 5842 5843 5844 5845 5846 5847 5848 5849 5850 5851 5852 5853 5854 5855 5856 5857 5858 5859 5860 5861 5862 5863 5864 5865 5866 5867 5868 5869 5870 5871 5872 5873 5874 5875 5876 5877 5878 5879 5880 5881 5882 5883 5884 5885 5886 5887 5888 5889 5890 5891 5892 5893 5894 5895 5896 5897 5898 5899 5900 5901 5902 5903 5904 5905 5906 5907 5908 5909 5910 5911 5912 5913 5914 5915 5916 5917 5918 5919 5920 5921 5922 5923 5924 5925 5926 5927 5928 5929 5930 5931 5932 5933 5934 5935 5936 5937 5938 5939 5940 5941 5942 5943 5944 5945 5946 5947 5948 5949 5950 5951 5952 5953 5954 5955 5956 5957 5958 5959 5960 5961 5962 5963 5964 5965 5966 5967 5968 5969 5970 5971 5972 5973 5974 5975 5976 5977 5978 5979 5980 5981 5982 5983 5984 5985 5986 5987 5988 5989 5990 5991 5992 5993 5994 5995 5996 5997 5998 5999 6000 6001 6002 6003 6004 6005 6006 6007 6008 6009 6010 6011 6012 6013 6014 6015 6016 6017 6018 6019 6020 6021 6022 6023 6024 6025 6026 6027 6028 6029 6030 6031 6032 6033 6034 6035 6036 6037 6038 6039 6040 6041 6042 6043 6044 6045 6046 6047 6048 6049 6050 6051 6052 6053 6054 6055 6056 6057 6058 6059 6060 6061 6062 6063 6064 6065 6066 6067 6068 6069 6070 6071 6072 6073 6074 6075 6076 6077 6078 6079 6080 6081 6082 6083 6084 6085 6086 6087 6088 6089 6090 6091 6092 6093 6094 6095 6096 6097 6098 6099 6100 6101 6102 6103 6104 6105 6106 6107 6108 6109 6110
|
% \iffalse meta-comment
%
% Copyright (C) 2004-2011 by Morten Hoegholm
% Copyright (C) 2012- by Lars Madsen
%
% This work may be distributed and/or modified under the
% conditions of the LaTeX Project Public License, either
% version 1.3 of this license or (at your option) any later
% version. The latest version of this license is in
% http://www.latex-project.org/lppl.txt
% and version 1.3 or later is part of all distributions of
% LaTeX version 2005/12/01 or later.
%
% This work has the LPPL maintenance status "maintained".
%
% This Current Maintainer of this work is
% Lars Madsen
%
% This work consists of the main source file mathtools.dtx
% and the derived files
% mathtools.sty, mathtools.pdf, mathtools.ins, mathtools.drv.
%
% Distribution:
% CTAN:macros/latex/contrib/mh/mathtools.dtx
% CTAN:macros/latex/contrib/mh/mathtools.pdf
%
% Unpacking:
% (a) If mathtools.ins is present:
% tex mathtools.ins
% (b) Without mathtools.ins:
% tex mathtools.dtx
% (c) If you insist on using LaTeX
% latex \let\install=y\input{mathtools.dtx}
% (quote the arguments according to the demands of your shell)
%
% Documentation:
% (a) If mathtools.drv is present:
% latex mathtools.drv
% (b) Without mathtools.drv:
% latex mathtools.dtx; ...
% The class ltxdoc loads the configuration file ltxdoc.cfg
% if available. Here you can specify further options, e.g.
% use A4 as paper format:
% \PassOptionsToClass{a4paper}{article}
%
% Programm calls to get the documentation (example):
% pdflatex mathtools.dtx
% makeindex -s gind.ist mathtools.idx
% pdflatex mathtools.dtx
% makeindex -s gind.ist mathtools.idx
% pdflatex mathtools.dtx
%
% Installation:
% TDS:tex/latex/mh/mathtools.sty
% TDS:doc/latex/mh/mathtools.pdf
% TDS:source/latex/mh/mathtools.dtx
%
%<*ignore>
\begingroup
\def\x{LaTeX2e}
\expandafter\endgroup
\ifcase 0\ifx\install y1\fi\expandafter
\ifx\csname processbatchFile\endcsname\relax\else1\fi
\ifx\fmtname\x\else 1\fi\relax
\else\csname fi\endcsname
%</ignore>
%<*install>
\input docstrip.tex
\Msg{************************************************************************}
\Msg{* Installation}
\Msg{* Package: mathtools 2018/01/08 v1.21}
\Msg{************************************************************************}
\keepsilent
\askforoverwritefalse
\preamble
This is a generated file.
Copyright (C) 2002-2011 by Morten Hoegholm
Copyright (C) 2012- by Lars Madsen
This work may be distributed and/or modified under the
conditions of the LaTeX Project Public License, either
version 1.3 of this license or (at your option) any later
version. The latest version of this license is in
http://www.latex-project.org/lppl.txt
and version 1.3 or later is part of all distributions of
LaTeX version 2005/12/01 or later.
This work has the LPPL maintenance status "maintained".
This Current Maintainer of this work is
Lars Madsen
This work consists of the main source file mathtools.dtx
and the derived files
mathtools.sty, mathtools.pdf, mathtools.ins, mathtools.drv.
\endpreamble
\generate{%
\file{mathtools.ins}{\from{mathtools.dtx}{install}}%
\file{mathtools.drv}{\from{mathtools.dtx}{driver}}%
\usedir{tex/latex/mh}%
\file{mathtools.sty}{\from{mathtools.dtx}{package}}%
}
\obeyspaces
\Msg{************************************************************************}
\Msg{*}
\Msg{* To finish the installation you have to move the following}
\Msg{* file into a directory searched by TeX:}
\Msg{*}
\Msg{* mathtools.sty}
\Msg{*}
\Msg{* To produce the documentation run the file `mathtools.drv'}
\Msg{* through LaTeX.}
\Msg{*}
\Msg{* Happy TeXing!}
\Msg{*}
\Msg{************************************************************************}
\endbatchfile
%</install>
%<*ignore>
\fi
%</ignore>
%<*driver>
\NeedsTeXFormat{LaTeX2e}
\ProvidesFile{mathtools.drv}%
[2018/01/08 v1.21 mathematical typesetting tools]
\documentclass{ltxdoc}
\IfFileExists{fourier.sty}{\usepackage{fourier}}{}
\addtolength\marginparwidth{-25pt}
\usepackage{mathtools}
\setcounter{IndexColumns}{2}
\providecommand*\pkg[1]{\textsf{#1}}
\providecommand*\env[1]{\texttt{#1}}
\providecommand*\email[1]{\href{mailto:#1}{\texttt{#1}}}
\providecommand*\mode[1]{\texttt{[#1]}}
\providecommand*\file[1]{\texttt{#1}}
\usepackage{xcolor,varioref,amssymb}
\makeatletter
\newcommand*\thinfbox[2][black]{\fboxsep0pt\textcolor{#1}{\rulebox{{\normalcolor#2}}}}
\newcommand*\thinboxed[2][black]{\thinfbox[#1]{\ensuremath{\displaystyle#2}}}
\newcommand*\rulebox[1]{%
\sbox\z@{\ensuremath{\displaystyle#1}}%
\@tempdima\dp\z@
\hbox{%
\lower\@tempdima\hbox{%
\vbox{\hrule height\fboxrule\box\z@\hrule height\fboxrule}%
}%
}%
}
\newenvironment{codesyntax}
{\par\small\addvspace{4.5ex plus 1ex}%
\vskip -\parskip
\noindent
\begin{tabular}{|l|}\hline\ignorespaces}%
{\\\hline\end{tabular}\nobreak\par\nobreak
\vspace{2.3ex}\vskip -\parskip\noindent\ignorespacesafterend}
\makeatletter
\newcommand*\FeatureRequest[2]{%
\hskip1sp
\marginpar{%
\parbox[b]{\marginparwidth}{\small\sffamily\raggedright
\strut Feature request by\\#1\\#2%
}
}%
}
\newcommand*\ProvidedBy[2]{%
\hskip1sp
\marginpar{%
\parbox[b]{\marginparwidth}{\small\sffamily\raggedright
\strut Feature provided by\\#1\\#2%
}
}%
}
\newcommand*\cttPosting[2]{%
\hskip1sp
\marginpar{%
\parbox[b]{\marginparwidth}{\small\sffamily\raggedright
\strut Posted on \texttt{comp.text.tex} \\#1\\#2%
}%
}%
}
\newcommand*\tsxPosting[2]{%
\hskip1sp
\marginpar{%
\parbox[b]{\marginparwidth}{\small\sffamily\raggedright
\strut Posted on \texttt{\small tex.stackexchange.com} \\#1\\#2%
}%
}%
}
\newcommand*\CommentAdded[1]{%
\hskip1sp
\marginpar{%
\parbox[b]{\marginparwidth}{\small\sffamily\raggedright
\strut Comment added\\#1%
}%
}%
}
\expandafter\def\expandafter\MakePrivateLetters\expandafter{%
\MakePrivateLetters \catcode`\_=11\relax
}
\providecommand*\SpecialOptIndex[1]{%
\@bsphack
\index{#1\actualchar{\protect\ttfamily #1}
(option)\encapchar usage}%
\index{options:\levelchar#1\actualchar{\protect\ttfamily #1}\encapchar
usage}\@esphack}
\providecommand*\opt[1]{\texttt{#1}}
\providecommand*\SpecialKeyIndex[1]{%
\@bsphack
\index{#1\actualchar{\protect\ttfamily #1}
(key)\encapchar usage}%
\index{keys:\levelchar#1\actualchar{\protect\ttfamily #1}\encapchar
usage}\@esphack}
\providecommand*\key[1]{\textsf{#1}}
\providecommand*\eTeX{$\m@th\varepsilon$-\TeX}
\def\MTmeta#1{%
\ensuremath\langle
\ifmmode \expandafter \nfss@text \fi
{%
\meta@font@select
\edef\meta@hyphen@restore
{\hyphenchar\the\font\the\hyphenchar\font}%
\hyphenchar\font\m@ne
\language\l@nohyphenation
#1\/%
\meta@hyphen@restore
}\ensuremath\rangle
\endgroup
}
\makeatother
\DeclareRobustCommand\meta{\begingroup\MakePrivateLetters\MTmeta}%
\def\MToarg#1{{\ttfamily[}\meta{#1}{\ttfamily]}\endgroup}
\DeclareRobustCommand\oarg{\begingroup\MakePrivateLetters\MToarg}%
\def\MHmarg#1{{\ttfamily\char`\{}\meta{#1}{\ttfamily\char`\}}\endgroup}
\DeclareRobustCommand\marg{\begingroup\MakePrivateLetters\MHmarg}%
\def\MHarg#1{{\ttfamily\char`\{#1\ttfamily\char`\}}\endgroup}
\DeclareRobustCommand\arg{\begingroup\MakePrivateLetters\MHarg}%
\def\MHcs#1{\texttt{\char`\\#1}\endgroup}
\DeclareRobustCommand\cs{\begingroup\MakePrivateLetters\MHcs}
\def\endverbatim{\if@newlist
\leavevmode\fi\endtrivlist\vspace{-\baselineskip}}
\expandafter\let\csname endverbatim*\endcsname =\endverbatim
\let\MTtheindex\theindex
\def\theindex{\MTtheindex\MakePrivateLetters}
\usepackage[final,
hyperindex=false,
]{hyperref}
\renewcommand*\usage[1]{\textit{\hyperpage{#1}}}
\OnlyDescription
\begin{document}
\DocInput{mathtools.dtx}
\end{document}
%</driver>
% \fi
%
% \changes{v1.19}{2017/03/31}{Updated to match some macro renaming in
% \pkg{mhsetup}}
% \changes{v1.0}{2004/07/26}{Initial release}
%
% \GetFileInfo{mathtools.drv}
%
% \CheckSum{3144}
%
% \title{The \pkg{mathtools} package\thanks{This file has version number
% \fileversion, last revised \filedate.}}
%
% \author{Morten H\o gholm, Lars Madsen}
% \date{\filedate}
%
% \maketitle
%
% \begin{abstract}
% \noindent The \pkg{mathtools} package is an extension package to
% \pkg{amsmath}. There are two things on \pkg{mathtools}' agenda:
% (1)~correct various bugs/defeciencies in \pkg{amsmath} until
% these are fixed by the \AmS{} and (2)~provide useful tools
% for mathematical typesetting, be it a small macro for
% typesetting a prescript or an underbracket, or entirely new
% display math constructs such as a \env{multlined} environment.
% \end{abstract}
%
% \tableofcontents
%
% \section{Introduction}
%
% Although \pkg{amsmath} provides many handy tools for mathematical
% typesetting, it is nonetheless a static package. This is not a bad
% thing, because what it does, it mostly does quite well and having
% a stable math typesetting package is ``a good thing.'' However,
% \pkg{amsmath} does not fulfill all the needs of the mathematical
% part of the \LaTeX{} community, resulting in many authors writing
% small snippets of code for tweaking the mathematical layout. Some
% of these snippets have also been posted to newsgroups and mailing
% lists over the years, although more often than not without being
% released as stand-alone packages.
%
%
% The \pkg{mathtools} package is exactly what its name implies: tools
% for mathematical typesetting. It is a collection of many of these
% often needed small tweaks---with some big tweaks added as well. It
% can only do so by having harvesting newsgroups for code and/or you
% writing the maintainers with wishes for code to be included, so if
% you have any good macros or just macros that help you when writing
% mathematics, then don't hesitate to report them. It is
% easiest to just contact Lars Madsen at
% \begin{quote}\email{daleif@math.au.dk}\end{quote}
% This is of course also the address to use in case of bug reports.
% Please put `\texttt{mathtools}' in the subject line.
%
%
% \medskip\noindent
% Update 2013: We now makes \cs{(}\cs{)} and \cs[\cs]
% robust (can be disabled via \texttt{nonrobust} package option).
%
% \section{Package loading}
%
%
% The \pkg{mathtools} package requires \pkg{amsmath} but is able to
% pass options to it as well. Thus a line like
% \begin{verbatim}
% \usepackage[fleqn,tbtags]{mathtools}
% \end{verbatim}
% is equivalent to
% \begin{verbatim}
% \usepackage[fleqn,tbtags]{amsmath}
% \usepackage{mathtools}
% \end{verbatim}
%
%
% \subsection{Special \pkg{mathtools} options}
%
% \begin{codesyntax}
% \SpecialOptIndex{fixamsmath}\opt{fixamsmath}\texttt{~~~~}
% \SpecialOptIndex{donotfixamsmathbugs}\opt{donotfixamsmathbugs}
% \end{codesyntax}
% The option \opt{fixamsmath} (default) fixes two bugs in
% \pkg{amsmath}.\footnote{See the online \LaTeX{} bugs database
% \url{http://www.latex-project.org/cgi-bin/ltxbugs2html} under
% \AmS\LaTeX{} problem reports 3591 and 3614.} Should you for some
% reason not want to fix these bugs then just add the option
% \opt{donotfixamsmathbugs} (if you can do it without typos). The
% reason for this extremely long name is that I really don't see why
% you wouldn't want these bugs to be fixed, so I've made it slightly
% difficult not to fix them.
%
% \begin{codesyntax}
% \SpecialOptIndex{allowspaces}\opt{allowspaces}\texttt{~~~~}
% \SpecialOptIndex{disallowspaces}\opt{disallowspaces}
% \end{codesyntax}
% Sometimes \pkg{amsmath} gives you nasty surprises, as here where
% things look seemingly innocent:
% \begin{verbatim}
% \[
% \begin{gathered}
% [p] = 100 \\
% [v] = 200
% \end{gathered}
% \]
% \end{verbatim}
% Without \pkg{mathtools} this will result in this output:
% \[
% \begin{gathered}[c]
% = 100 \\
% [v] = 200
% \end{gathered}
% \]
% Yes, the \texttt{[p]} has been gobbled without any warning
% whatsoever.\footnote{\pkg{amsmath} thought the \texttt[p] was an
% optional argument, checked if it was \texttt{t} or \texttt{b} and
% when both tests failed, assumed it was a \texttt{c}.} This is
% hardly what you'd expect as an end user, as the desired output was
% probably something like this instead:
% \[
% \begin{gathered}[c]
% [p] = 100 \\
% [v] = 200
% \end{gathered}
% \]
% With the option \opt{disallowspaces} (default) \pkg{mathtools}
% disallows spaces in front of optional arguments where it could
% possibly cause problems just as \pkg{amsmath} does with |\\|
% inside the display environments. This includes the environments
% \env{gathered} (and also those shown in \S
% \vref{subsec:gathered}), \env{aligned}, \env{multlined}, and the
% extended \env{matrix}-environments (\S \vref{subsubsec:matrices}).
% If you however want to preserve the more dangerous standard
% optional spaces, simply choose the option \opt{allowspaces}.
%
%
% \section{Tools for mathematical typesetting}
%
% \begin{codesyntax}
% \SpecialUsageIndex{\mathtoolsset}\cs{mathtoolsset}\marg{key val list}
% \end{codesyntax}
% Many of the tools shown in this manual can be turned on and off by
% setting a switch to either true or false. In all cases it is done
% with the command \cs{mathtoolsset}. A typical use could be something like
% \begin{verbatim}
% \mathtoolsset{
% showonlyrefs,
% mathic % or mathic = true
% }
% \end{verbatim}
% More information on the keys later on.
%
% \subsection{Fine-tuning mathematical layout}
%
% Sometimes you need to tweak the layout of formulas a little to get
% the best result and this part of the manual describes the various
% macros \pkg{mathtools} provides for this.
%
% \subsubsection{A complement to \texttt{\textbackslash smash},
% \texttt{\textbackslash llap}, and \texttt{\textbackslash rlap}}
%
% \begin{codesyntax}
% \SpecialUsageIndex{\mathllap}
% \cs{mathllap}\oarg{mathstyle}\marg{math}\texttt{~~}
% \SpecialUsageIndex{\mathclap}
% \cs{mathclap}\oarg{mathstyle}\marg{math}\\
% \SpecialUsageIndex{\mathrlap}
% \cs{mathrlap}\oarg{mathstyle}\marg{math}\texttt{~~}
% \SpecialUsageIndex{\clap}
% \cs{clap}\marg{text}\\
% \SpecialUsageIndex{\mathmbox}
% \cs{mathmbox}\marg{math}\phantom{\meta{mathstyle}}\texttt{~~~~}
% \SpecialUsageIndex{\mathmakebox}
% \cs{mathmakebox}\oarg{width}\oarg{pos}\marg{math}
% \end{codesyntax}
% In \cite{Perlis01}, Alexander R.~Perlis describes some simple yet
% useful macros for use in math displays. For example the display
% \begin{verbatim}
% \[
% X = \sum_{1\le i\le j\le n} X_{ij}
% \]
% \end{verbatim}
% \[
% X = \sum_{1\le i\le j\le n} X_{ij}
% \]
% contains a lot of excessive white space. The idea that comes to
% mind is to fake the width of the subscript. The command
% \cs{mathclap} puts its argument in a zero width box and centers
% it, so it could possibly be of use here.
% \begin{verbatim}
% \[
% X = \sum_{\mathclap{1\le i\le j\le n}} X_{ij}
% \]
% \end{verbatim}
% \[
% X = \sum_{\mathclap{1\le i\le j\le n}} X_{ij}
% \]
% For an in-depth discussion of
% these macros I find it better to read the article; an online
% version can be found at
% \begin{quote}
% \url{http://www.tug.org/TUGboat/Articles/tb22-4/tb72perlS.pdf}
% \end{quote}
% Note that the definitions shown in the article do not exactly
% match the definitions in \pkg{mathtools}. Besides providing an
% optional argument for specifying the desired math style, these
% versions also work around a most unfortunate \TeX{}
% ``feature.''\footnote{The faulty reboxing procedure.} The
% \cs{smash} macro is fixed too.
%
%
% \subsubsection{Forcing a cramped style}
%
% \begin{codesyntax}
% \SpecialUsageIndex{\cramped}
% \cs{cramped}\oarg{mathstyle}\marg{math}
% \end{codesyntax}
% \cttPosting{Michael Herschorn}{1992/07/21}
% Let's look at another example where we have used \cs{mathclap}:
% \begin{verbatim}
% \begin{equation}\label{eq:mathclap}
% \sum_{\mathclap{a^2<b^2<c}}\qquad
% \sum_{a^2<b^2<c}
% \end{equation}
% \end{verbatim}
% \begin{equation}\label{eq:mathclap}
% \sum_{\mathclap{a^2<b^2<c}}\qquad
% \sum_{a^2<b^2<c}
% \end{equation}
% Do you see the difference? Maybe if I zoomed in a bit:
% \begingroup \fontsize{24}{\baselineskip}\selectfont
% \[
% \sum_{\mathclap{a^2<b^2<c}}\qquad
% \sum_{a^2<b^2<c}
% \]
% \endgroup
% Notice how the limit of the right summation sign is typeset in a
% more compact style than the left. It is because \TeX{} sets the
% limits of operators in a \emph{cramped} style. For each of \TeX'
% four math styles (\cs{displaystyle}, \cs{textstyle},
% \cs{scriptstyle}, and \cs{scriptscriptstyle}), there also exists a
% cramped style that doesn't raise exponents as much. Besides in the
% limits of operators, \TeX{} also automatically uses these cramped
% styles in radicals such as \cs{sqrt} and in the denominators of
% fractions, but unfortunately there are no primitive commands that
% allows you to detect crampedness or switch to it.
%
% \pkg{mathtools} offers the command \cs{cramped} which forces a
% cramped style in normal un-cramped math. Additionally you can
% choose which of the four styles you want it in as well by
% specifying it as the optional argument:
% \begin{verbatim}
% \[
% \cramped{x^2} \leftrightarrow x^2 \quad
% \cramped[\scriptstyle]{x^2} \leftrightarrow {\scriptstyle x^2}
% \]
% \end{verbatim}
% \[
% \cramped{x^2} \leftrightarrow x^2 \quad
% \cramped[\scriptstyle]{x^2} \leftrightarrow {\scriptstyle x^2}
% \]
% You may be surprised how often the cramped style can be
% beneficial yo your output. Take a look at this example:
% \begin{verbatim}
% \begin{quote}
% The 2005 Euro\TeX{} conference is held in Abbaye des
% Pr\'emontr\'es, France, marking the 16th ($2^{2^2}$) anniversary
% of both Dante and GUTenberg (the German and French \TeX{} users
% group resp.).
% \end{quote}
% \end{verbatim}
% \begin{quote}
% The 2005 Euro\TeX{} conference is held in Abbaye des
% Pr\'emontr\'es, France, marking the 16th ($2^{2^2}$) anniversary
% of both Dante and GUTenberg (the German and French \TeX{} users
% group resp.).
% \end{quote}
% Typesetting on a grid is generally considered quite desirable, but
% as the second line of the example shows, the exponents of $2$
% causes the line to be too tall for the normal value of
% \cs{baselineskip}, so \TeX{} inserts a \cs{lineskip} (normal value
% is \the\lineskip). In order to circumvent the problem, we can
% force a cramped style so that the exponents aren't raised as much:
% \begin{verbatim}
% \begin{quote}
% The 2005 Euro\TeX{} ... 16th ($\cramped{2^{2^2}}$) ...
% \end{quote}
% \end{verbatim}
% \begin{quote}
% The 2005 Euro\TeX{} conference is held in Abbaye des
% Pr\'emontr\'es, France, marking the 16th ($\cramped{2^{2^2}}$)
% anniversary of both Dante and GUTenberg (the German and French
% \TeX{} users group resp.).
% \end{quote}
%
% \begin{codesyntax}
% \SpecialUsageIndex{\crampedllap}
% \cs{crampedllap}\oarg{mathstyle}\marg{math}\texttt{~~}
% \SpecialUsageIndex{\crampedclap}
% \cs{crampedclap}\oarg{mathstyle}\marg{math}\\
% \SpecialUsageIndex{\crampedrlap}
% \cs{crampedrlap}\oarg{mathstyle}\marg{math}
% \end{codesyntax}
% The commands \cs{crampedllap}, \cs{crampedclap}, and
% \cs{crampedrlap} are identical to the three \cs{mathXlap} commands
% described earlier except the argument is typeset in cramped style.
% You need this in order to typeset \eqref{eq:mathclap} correctly
% while still faking the width of the limit.
% \begin{verbatim}
% \begin{equation*}\label{eq:mathclap-b}
% \sum_{\crampedclap{a^2<b^2<c}}
% \tag{\ref{eq:mathclap}*}
% \end{equation*}
% \end{verbatim}
% \begin{equation*}\label{eq:mathclap-b}
% \sum_{\crampedclap{a^2<b^2<c}}
% \tag{\ref{eq:mathclap}*}
% \end{equation*}
% Of course you could just type
% \begin{verbatim}
% \sum_{\mathclap{\cramped{a^2<b^2<c}}}
% \end{verbatim}
% but it has one major disadvantage: In order for \cs{mathXlap} and
% \cs{cramped} to get the right size, \TeX{} has to process them
% four times, meaning that nesting them as shown above will cause
% \TeX{} to typeset $4^2$ instances before choosing the right one.
% In this situation however, we will of course need the same style
% for both commands so it makes sense to combine the commands in
% one, thus letting \TeX{} make the choice only once rather than
% twice.
%
%
%
% \subsubsection{Smashing an operator}
%
%
%
% \begin{codesyntax}
% \SpecialUsageIndex{\smashoperator}
% \cs{smashoperator}\oarg{pos}\marg{operator with limits}
% \end{codesyntax}
% \FeatureRequest{Lars Madsen}{2004/05/04}
% Above we shoved how to get \LaTeX{} to ignore the width of the
% subscript of an operator. However this approach takes a lot of
% extra typing, especially if you have a wide superscript, meaning
% you have to put in \cs{crampedclap} in both sub- and superscript.
% To make things easier, \pkg{mathtools} provides a
% \cs{smashoperator} command, which simply ignores the width of the
% sub- and superscript. It also takes an optional argument,
% \texttt{l}, \texttt{r}, or \texttt{lr} (default), denoting which
% side of the operator should be ignored (smashed).
% \begin{verbatim}
% \[
% V = \sum_{1\le i\le j\le n}^{\infty} V_{ij} \quad
% X = \smashoperator{\sum_{1\le i\le j\le n}^{3456}} X_{ij} \quad
% Y = \smashoperator[r]{\sum\limits_{1\le i\le j\le n}} Y_{ij} \quad
% Z = \smashoperator[l]{\mathop{T}_{1\le i\le j\le n}} Z_{ij}
% \]
% \end{verbatim}
% \[
% V = \sum_{1\le i\le j\le n}^{\infty} V_{ij} \quad
% X = \smashoperator{\sum_{1\le i\le j\le n}^{3456}} X_{ij} \quad
% Y = \smashoperator[r]{\sum\limits_{1\le i\le j\le n}} Y_{ij} \quad
% Z = \smashoperator[l]{\mathop{T}_{1\le i\le j\le n}} Z_{ij}
% \]
% Note that \cs{smashoperator} always sets its argument in display
% style and with limits even if you have used the \opt{nosumlimits}
% option of \pkg{amsmath}. If you wish, you can use shorthands for
% \texttt{\_} and \texttt{\textasciicircum} such as \cs{sb} and
% \cs{sp}.
%
%
% \subsubsection{Adjusting limits of operators}
%
% \begin{codesyntax}
% \SpecialUsageIndex{\adjustlimits}
% \cs{adjustlimits}\marg{operator$\sb1$}\texttt{\_}\marg{limit$\sb1$}
% \marg{operator$\sb2$}\texttt{\_}\marg{limit$\sb2$}
% \end{codesyntax}
% \FeatureRequest{Lars Madsen}{2004/07/09}
% When typesetting two consecutive operators with limits one often
% wishes the limits of the operators were better aligned. Look
% closely at these examples:
% \begin{verbatim}
% \[
% \text{a)} \lim_{n\to\infty} \max_{p\ge n} \quad
% \text{b)} \lim_{n\to\infty} \max_{p^2\ge n} \quad
% \text{c)} \lim_{n\to\infty} \sup_{p^2\ge nK} \quad
% \text{d)} \limsup_{n\to\infty} \max_{p\ge n}
% \]
% \end{verbatim}
% \[
% \text{a)} \lim_{n\to\infty} \max_{p\ge n} \quad
% \text{b)} \lim_{n\to\infty} \max_{p^2\ge n} \quad
% \text{c)} \lim_{n\to\infty} \sup_{p^2\ge nK} \quad
% \text{d)} \limsup_{n\to\infty} \max_{p\ge n}
% \]
% a) looks okay, but b) is not quite as good because the second
% limit ($\cramped{p^2\ge n}$) is significantly taller than the
% first ($n\to\infty$). With c)~things begin to look really bad,
% because the second operator has a descender while the first
% doesn't, and finally we have d)~which looks just as bad as~c). The
% command \cs{adjustlimits} is useful in these cases, as you can
% just put it in front of these consecutive operators and it'll make
% the limits line up.
% \medskip\par\noindent
% \begin{minipage}{\textwidth}
% \begin{verbatim}
% \[
% \text{a)} \adjustlimits\lim_{n\to\infty} \max_{p\ge n} \quad
% \text{b)} \adjustlimits\lim_{n\to\infty} \max_{p^2\ge n} \quad
% \text{c)} \adjustlimits\lim_{n\to\infty} \sup_{p^2\ge nK} \quad
% \text{d)} \adjustlimits\limsup_{n\to\infty} \max_{p\ge n}
% \]
% \end{verbatim}
% \end{minipage}
% \[
% \text{a)} \adjustlimits\lim_{n\to\infty} \max_{p\ge n} \quad
% \text{b)} \adjustlimits\lim_{n\to\infty} \max_{p^2\ge n} \quad
% \text{c)} \adjustlimits\lim_{n\to\infty} \sup_{p^2\ge nK} \quad
% \text{d)} \adjustlimits\limsup_{n\to\infty} \max_{p\ge n}
% \]
% The use of \cs{sb} instead of \texttt{\_} is allowed.
%
%
% \subsubsection{Swapping space above \texorpdfstring{\AmS}{AMS} display math environments }
% \label{sec:swapping}
%
% One feature that the plain old \env{equation} environment has that
% the \AmS\ environments does not (because of thechnical reasons), is
% the feature of using less space above the equation if the situation
% presents itself. The \AmS\ environments cannot do this, but one can
% manually, using
% \begin{codesyntax}
% \SpecialUsageIndex{\SwapAboveDisplaySkip}
% \cs{SwapAboveDisplaySkip}
% \end{codesyntax}
% as the very first content within an \AmS\ display math
% environment. It will then issue an \cs{abovedisplayshortskip}
% instead of the normal \cs{abovedisplayskip}.
%
% Note it will not work with the \env{equation} or \env{multline} environments.
%
% Here is an example of the effect
% \begin{verbatim}
% \noindent\rule\textwidth{1pt}
% \begin{align*} A &= B \end{align*}
% \noindent\rule\textwidth{1pt}
% \begin{align*}
% \SwapAboveDisplaySkip
% A &= B
% \end{align*}
% \end{verbatim}
% \noindent\rule\textwidth{1pt}
% \begin{align*} A &= B \end{align*}
% \noindent\rule\textwidth{1pt}
% \begin{align*}
% \SwapAboveDisplaySkip
% A &= B
% \end{align*}
%
%
% \subsection{Controlling tags}
%
% In this section various tools for altering the appearance of tags
% are shown. All of the tools here can be used at any point in the
% document but they should probably be affect the whole document, so
% the preamble is the best place to issue them.
%
% \subsubsection{The appearance of tags}
% \begin{codesyntax}
% \SpecialUsageIndex{\newtagform}
% \cs{newtagform}\marg{name}\oarg{inner_format}\marg{left}\marg{right}\\
% \SpecialUsageIndex{\renewtagform}
% \cs{renewtagform}\marg{name}\oarg{inner_format}\marg{left}\marg{right}\\
% \SpecialUsageIndex{\usetagform}
% \cs{usetagform}\marg{name}
% \end{codesyntax}
% Altering the layout of equation numbers in \pkg{amsmath} is not
% very user friendly (it involves a macro with three \texttt{@}'s in
% its name), so \pkg{mathtools} provides an interface somewhat
% reminiscent of the page style concept. This way you can define
% several different tag forms and then choose the one you prefer.
%
% As an example let's try to define a tag form which puts the
% equation number in square brackets. First we define a brand new tag
% form:
% \begin{verbatim}
% \newtagform{brackets}{[}{]}
% \end{verbatim}
% Then we activate it:
% \begin{verbatim}
% \usetagform{brackets}
% \end{verbatim}
% The result is then
% \newtagform{brackets}{[}{]}
% \usetagform{brackets}
% \begin{equation}
% E \neq m c^3
% \end{equation}
%
% Similarly you could define a second version of the brackets that
% prints the equation number in bold face instead
% \begin{verbatim}
% \newtagform{brackets2}[\textbf]{[}{]}
% \usetagform{brackets2}
% \begin{equation}
% E \neq m c^3
% \end{equation}
% \end{verbatim}
% \newtagform{brackets2}[\textbf]{[}{]}
% \usetagform{brackets2}
% \begin{equation}
% E \neq m c^3
% \end{equation}
% When you reference an equation with \cs{eqref}, the tag form in
% effect at the time of referencing controls the formatting, so be
% careful if you use different tag forms throughout your document.
%
% If you want to renew a tag form, then use the command
% \cs{renewtagform}. Should you want to
% return to the standard setting then choose\usetagform{default}
% \begin{verbatim}
% \usetagform{default}
% \end{verbatim}
%
% \changes{v1.12}{2012/05/09}{Added caveat}
% \noindent\textbf{Caveat regarding \pkg{ntheorem}}: If you like to
% change the appearence of the tags \emph{and} you are also using the
% \pkg{ntheorem} package, then please postpone the change of
% appearance until \emph{after} loading \pkg{ntheorem}. (In order to
% do its thing, \pkg{ntheorem} has to mess with the tags\dots)
%
% \subsubsection{Showing only referenced tags}
%
% \begin{codesyntax}
% \SpecialKeyIndex{showonlyrefs}$\key{showonlyrefs}=\texttt{true}\vert\texttt{false}$\\
% \SpecialKeyIndex{showmanualtags}$\key{showmanualtags}=\texttt{true}\vert\texttt{false}$\\
% \SpecialUsageIndex{\refeq}\cs{refeq}\marg{label}
% \end{codesyntax}
% An equation where the tag is produced with a manual \cs{tag*}
% shouldn't be referenced with the normal \cs{eqref} because that
% would format it according to the current tag format. Using just
% \cs{ref} on the other hand may not be a good solution either as
% the argument of \cs{tag*} is always set in upright shape in the
% equation and you may be referencing it in italic text. In the
% example below, the command \cs{refeq} is used to avoid what could
% possibly lead to confusion in cases where the tag font has very
% different form in upright and italic shape (here we switch to
% Palatino in the example):
% \begin{verbatim}
% \begin{quote}\renewcommand*\rmdefault{ppl}\normalfont\itshape
% \begin{equation*}
% a=b \label{eq:example}\tag*{Q\&A}
% \end{equation*}
% See \ref{eq:example} or is it better with \refeq{eq:example}?
% \end{quote}
% \end{verbatim}
% \begin{quote}\renewcommand*\rmdefault{ppl}\normalfont\itshape
% \begin{equation*}
% a=b \label{eq:example}\tag*{Q\&A}
% \end{equation*}
% See \ref{eq:example} or is it better with \refeq{eq:example}?
% \end{quote}
%
%
% Another problem sometimes faced is the need for showing the
% equation numbers for only those equations actually referenced. In
% \pkg{mathtools} this can be done by setting the key
% \key{showonlyrefs} to either true or false by using
% \cs{mathtoolsset}. You can also choose whether or not to show the
% manual tags specified with \cs{tag} or \cs{tag*} by setting the
% option \key{showmanualtags} to true or false.\footnote{I recommend
% setting \key{showmanualtags} to true, else the whole idea of using
% \cs{tag} doesn't really make sense, does it?} For both keys just
% typing the name of it chooses true as shown in the following
% example.
%
% \begin{verbatim}
% \mathtoolsset{showonlyrefs,showmanualtags}
% \usetagform{brackets}
% \begin{gather}
% a=a \label{eq:a} \\
% b=b \label{eq:b} \tag{**}
% \end{gather}
% This should refer to the equation containing $a=a$: \eqref{eq:a}.
% Then a switch of tag forms.
% \usetagform{default}
% \begin{align}
% c&=c \label{eq:c} \\
% d&=d \label{eq:d}
% \end{align}
% This should refer to the equation containing $d=d$: \eqref{eq:d}.
% \begin{equation}
% e=e
% \end{equation}
% Back to normal.\mathtoolsset{showonlyrefs=false}
% \begin{equation}
% f=f
% \end{equation}
% \end{verbatim}
% \mathtoolsset{showonlyrefs,showmanualtags}
% \usetagform{brackets}
% \begin{gather}
% a=a \label{eq:a} \\
% b=b \label{eq:b} \tag{**}
% \end{gather}
% This should refer to the equation containing $a=a$: \eqref{eq:a}.
% Then a switch of tag forms.
% \usetagform{default}
% \begin{align}
% c&=c \label{eq:c} \\
% d&=d \label{eq:d}
% \end{align}
% This should refer to the equation containing $d=d$: \eqref{eq:d}.
% \begin{equation}
% e=e
% \end{equation}
% Back to normal.\mathtoolsset{showonlyrefs=false}
% \begin{equation}
% f=f
% \end{equation}
%
% Note that this feature only works if you use \cs{eqref} or
% \cs{refeq} to reference your equations.
%
% When using \key{showonlyrefs} it might be useful to be able to
% actually add a few equation numbers without directly referring to
% them.
% \begin{codesyntax}
% \SpecialUsageIndex{\noeqref}\cs{noeqref}\marg{label,label,\dots}
% \end{codesyntax}
% \FeatureRequest{Rasmus Villemoes}{2008/03/26}
% The syntax is somewhat similar to \cs{nocite}. If a label in the
% list is undefined we will throw a warning in the same manner as
% \cs{ref}.
%
% \medskip\noindent\textbf{BUG 1:} Unfortunately the use of the
% \key{showonlyref} introduce a bug within amsmath's typesetting
% of formula versus equation number. This bug manifest itself by
% allowing formulas to be typeset close to or over the equation
% number. Currently no general fix is known, other than making sure
% that one's formulas are not long enough to touch the equation
% number.
%
% To make a long story short, amsmath typesets its math environments
% twice, one time for measuring and one time for the actual
% typesetting. In the measuring part, the width of the equation
% number is recorded such that the formula or the equation number can
% be moved (if necessary) in the typesetting part. When
% \key{showonlyref} is enabled, the width of the equation number
% depend on whether or not this number is referred~to. To determine
% this, we need to know the current label. But the current label is
% \emph{not} known in the measuring phase. Thus the measured width is
% always zero (because no label equals not referred to) and therefore
% the typesetting phase does not take the equation number into
% account.
%
% \medskip\noindent\textbf{BUG 2:} There is a bug between
% \key{showonlyrefs} and the \pkg{ntheorem} package, when the
% \pkg{ntheorem} option \key{thmmarks} is active. The shown equation
% numbers may come out wrong (seems to be multiplied by 2). Or the end
% marker may be placed in the wrong place if a proof ends with a
% displayed formula, and that formula is not refered to.
%
% There are two possible solutions to this both involving \pkg{empheq}.
% The easiest fix is to add the following line
% \begin{verbatim}
% \usepackage[overload,ntheorem]{empheq}
% \end{verbatim}
% before loading \pkg{ntheorem}. But the \texttt{overload} option of
% course disables things like \cs{intertext} and \cs{shotintertext}.
%
% The other thing to try is to use drop the \texttt{overload} option
% and use \env{empheq} on the very last expression, as in
% \begin{verbatim}
% \begin{empheq}{align}
% A &= B \label {eq:32}\\
% & = 1. \label{eq:31}
% \end{empheq}
% \end{proof}
% \end{verbatim}
%
% The \pkg{empheq} package fixes some
% problems with \pkg{ntheorem} and lets \pkg{mathtools} get correct
% access to the equation numbers again.
%
% \subsection{Extensible symbols}
%
% The number of horizontally extensible symbols in standard \LaTeX{}
% and \pkg{amsmath} is somewhat low. This part of the manual
% describes what \pkg{mathtools} does to help this situation.
%
% \subsubsection{Arrow-like symbols}
%
%
% \begin{codesyntax}
% \SpecialUsageIndex{\xleftrightarrow}
% \cs{xleftrightarrow}\oarg{sub}\marg{sup}\texttt{~~~~~~~~~}
% \SpecialUsageIndex{\xRightarrow}
% \cs{xRightarrow}\oarg{sub}\marg{sup}\\
% \SpecialUsageIndex{\xLeftarrow}
% \cs{xLeftarrow}\oarg{sub}\marg{sup}\texttt{~~~~~~~~~~~~~~}
% \SpecialUsageIndex{\xLeftrightarrow}
% \cs{xLeftrightarrow}\oarg{sub}\marg{sup}\\
% \SpecialUsageIndex{\xhookleftarrow}
% \cs{xhookleftarrow}\oarg{sub}\marg{sup}\texttt{~~~~~~~~~~}
% \SpecialUsageIndex{\xhookrightarrow}
% \cs{xhookrightarrow}\oarg{sub}\marg{sup}\\
% \SpecialUsageIndex{\xmapsto}
% \cs{xmapsto}\oarg{sub}\marg{sup}
% \end{codesyntax}
% Extensible arrows are part of \pkg{amsmath} in the form of the
% commands
% \begin{quote}
% \cs{xrightarrow}\oarg{subscript}\marg{superscript}\quad and\\
% \cs{xleftarrow}\oarg{subscript}\marg{superscript}
% \end{quote}
% But what about extensible versions of say, \cs{leftrightarrow} or
% \cs{Longleftarrow}? It turns out that the above mentioned
% extensible arrows are the only two of their kind defined by
% \pkg{amsmath}, but luckily \pkg{mathtools} helps with that. The
% extensible arrow-like symbols in \pkg{mathtools} follow the same
% naming scheme as the one's in \pkg{amsmath} so to get an extensible
% \cs{Leftarrow} you simply do a
% \begin{verbatim}
% \[
% A \xLeftarrow[under]{over} B
% \]
% \end{verbatim}
% \[
% A \xLeftarrow[under]{over} B
% \]
% \begin{codesyntax}
% \SpecialUsageIndex{\xrightharpoondown}
% \cs{xrightharpoondown}\oarg{sub}\marg{sup}\texttt{~~~~}
% \SpecialUsageIndex{\xrightharpoonup}
% \cs{xrightharpoonup}\oarg{sub}\marg{sup}\\
% \SpecialUsageIndex{\xleftharpoondown}
% \cs{xleftharpoondown}\oarg{sub}\marg{sup}\texttt{~~~~~}
% \SpecialUsageIndex{\xleftharpoonup}
% \cs{xleftharpoonup}\oarg{sub}\marg{sup}\\
% \SpecialUsageIndex{\xrightleftharpoons}
% \cs{xrightleftharpoons}\oarg{sub}\marg{sup}\texttt{~~~}
% \SpecialUsageIndex{\xleftrightharpoons}
% \cs{xleftrightharpoons}\oarg{sub}\marg{sup}
% \end{codesyntax}
% \pkg{mathtools} also provides the extensible harpoons shown above.
% They're taken from~\cite{Voss:2004}. For those liking visuals, here
% are the macros in use in the order listed in the two boxes above.
% \begin{align*}
% A &\xleftrightarrow[below]{above} B &
% A &\xRightarrow[below]{above} B \\
% A &\xLeftarrow[below]{above} B &
% A &\xLeftrightarrow[below]{above} B \\
% A &\xhookleftarrow[below]{above} B &
% A &\xhookrightarrow[below]{above} B \\
% A &\xmapsto[below]{above} B \\
% A &\xrightharpoondown[below]{above} B &
% A &\xrightharpoonup[below]{above} B \\
% A &\xleftharpoondown[below]{above} B &
% A &\xleftharpoonup[below]{above} B \\
% A &\xrightleftharpoons[below]{above} B &
% A &\xleftrightharpoons[below]{above} B \\
% \end{align*}
%
%
%
% \subsubsection{Braces and brackets}
%
% \LaTeX{} defines other kinds of extensible symbols like
% \cs{overbrace} and \cs{underbrace}, but sometimes you may want
% another symbol, say, a bracket.
% \begin{codesyntax}
% \SpecialUsageIndex{\underbracket}\cs{underbracket}\oarg{rule thickness}
% \oarg{bracket height}\marg{arg}\\
% \SpecialUsageIndex{\overbracket}\cs{overbracket}\oarg{rule thickness}
% \oarg{bracket height}\marg{arg}
% \end{codesyntax}
% The commands \cs{underbracket} and \cs{overbracket} are inspired
% by \cite{Voss:2004}, although the implementation here is slightly
% different.
% Used without the optional arguments the bracket commands produce this:
% \begin{quote}
% |$\underbracket {foo\ bar}_{baz}$|\quad $\underbracket {foo\ bar}_{baz}$ \\
% |$\overbracket {foo\ bar}^{baz}$ |\quad $\overbracket {foo\ bar}^{baz}$
% \end{quote}
% The default rule thickness is equal to that of \cs{underbrace}
% (app.~$5/18$\,ex) while the default bracket height is equal to
% app.~$0.7$\,ex. These values give really pleasing results in all
% font sizes, but feel free to use the optional arguments. That way
% you may get ``beauties'' like
% \begin{verbatim}
% \[
% \underbracket[3pt]{xxx\ yyy}_{zzz} \quad \text{and} \quad
% \underbracket[1pt][7pt]{xxx\ yyy}_{zzz}
% \]
% \end{verbatim}
% \[
% \underbracket[3pt]{xxx\ yyy}_{zzz} \quad \text{and} \quad
% \underbracket[1pt][7pt]{xxx\ yyy}_{zzz}
% \]
% \begin{codesyntax}
% \SpecialUsageIndex{\underbrace}\cs{underbrace}\marg{arg}\texttt{~~}
% \SpecialUsageIndex{\LaTeXunderbrace}\cs{LaTeXunderbrace}\marg{arg}\\
% \SpecialUsageIndex{\overbrace}\cs{overbrace}\marg{arg}\texttt{~~~}
% \SpecialUsageIndex{\LaTeXoverbrace}\cs{LaTeXoverbrace}\marg{arg}
% \end{codesyntax}
% The standard implementation of the math operators \cs{underbrace}
% and \cs{overbrace} in \LaTeX{} has some deficiencies. For example,
% all lengths used internally are \emph{fixed} and optimized for
% 10\,pt typesetting. As a direct consequence thereof, using font
% sizes other than 10 will produce less than optimal results.
% Another unfortunate feature is the size of the braces. In the
% example below, notice how the math operator \cs{sum} places its
% limit compared to \cs{underbrace}.
% \[
% \mathop{\thinboxed[blue]{\sum}}_{n}
% \mathop{\thinboxed[blue]{\LaTeXunderbrace{\thinboxed[green]{foof}}}}_{zzz}
% \]
% The blue lines indicate the dimensions of the math operator and
% the green lines the dimensions of $foof$. As you can see, there
% seems to be too much space between the brace and the $zzz$ whereas
% the space between brace and $foof$ is okay. Let's see what happens
% when we use a bigger font size:\par\Huge\vskip-\baselineskip
% \[
% \mathop{\thinboxed[blue]{\sum}}_{n}
% \mathop{\thinboxed[blue]{\LaTeXunderbrace{\thinboxed[green]{foof}}}}_{zzz}
% \]
% \normalsize Now there's too little space between the brace and the
% $zzz$ and also too little space between the brace and the $foof$.
% If you use Computer Modern you'll actually see that the $f$
% overlaps with the brace! Let's try in \cs{footnotesize}:
% \par\footnotesize
% \[
% \mathop{\thinboxed[blue]{\sum}}_{n}
% \mathop{\thinboxed[blue]{\LaTeXunderbrace{\thinboxed[green]{foof}}}}_{zzz}
% \]\normalsize
% Here the spacing above and below the brace is quite excessive.
%
% As \cs{overbrace} has the exact same problems, there are good
% reasons for \pkg{mathtools} to make redefinitions of
% \cs{underbrace} and \cs{overbrace}. These new versions work
% equally well in all font sizes and fixes the spacing issues and
% apart from working with the default Computer Modern fonts, they
% also work with the packages \pkg{mathpazo}, \pkg{pamath},
% \pkg{fourier}, \pkg{eulervm}, \pkg{cmbright}, and \pkg{mathptmx}.
% If you use the \pkg{ccfonts} to get the full Concrete fonts, the
% original version saved under the names \cs{LaTeXunderbrace} and
% \cs{LaTeXoverbrace} are better, due to of the special design of
% the Concrete extensible braces. In that case you should probably
% just add the lines
% \begin{verbatim}
% \let\underbrace\LaTeXunderbrace
% \let\overbrace\LaTeXoverbrace
% \end{verbatim}
% to your preamble after loading \pkg{mathtools} which will restore
% the original definitions of \cs{overbrace} and \cs{underbrace}.
%
%
%
%
% \subsection{New mathematical building blocks}
%
% In this part of the manual, various mathematical environments are
% described.
%
% \subsubsection{Matrices}\label{subsubsec:matrices}
%
% \begin{codesyntax}
% \SpecialEnvIndex{matrix*}\cs{begin}\arg{matrix*}\texttt{ }\oarg{col}
% \meta{contents} \cs{end}\arg{matrix*}\\
% \SpecialEnvIndex{pmatrix*}\cs{begin}\arg{pmatrix*}\oarg{col}
% \meta{contents} \cs{end}\arg{pmatrix*}\\
% \SpecialEnvIndex{bmatrix*}\cs{begin}\arg{bmatrix*}\oarg{col}
% \meta{contents} \cs{end}\arg{bmatrix*}\\
% \SpecialEnvIndex{Bmatrix*}\cs{begin}\arg{Bmatrix*}\oarg{col}
% \meta{contents} \cs{end}\arg{Bmatrix*}\\
% \SpecialEnvIndex{vmatrix*}\cs{begin}\arg{vmatrix*}\oarg{col}
% \meta{contents} \cs{end}\arg{vmatrix*}\\
% \SpecialEnvIndex{Vmatrix*}\cs{begin}\arg{Vmatrix*}\oarg{col}
% \meta{contents} \cs{end}\arg{Vmatrix*}
% \end{codesyntax}
% \FeatureRequest{Lars Madsen}{2004/04/05}
% All of the \pkg{amsmath} \env{matrix} environments center the
% columns by default, which is not always what you want. Thus
% \pkg{mathtools} provides a starred version for each of the original
% environments. These starred environments take an optional argument
% specifying the alignment of the columns, so that
% \begin{verbatim}
% \[
% \begin{pmatrix*}[r]
% -1 & 3 \\
% 2 & -4
% \end{pmatrix*}
% \]
% \end{verbatim}
% yields
% \[
% \begin{pmatrix*}[r]
% -1 & 3 \\
% 2 & -4
% \end{pmatrix*}
% \]
% The optional argument (default is \texttt{[c]}) can be any column
% type valid in the usual \env{array} environment.
%
% While we are at it, we also provide fenced versions of the
% \env{smallmatrix} environment, To keep up with the naming of the
% large matrix environments, we provide both a starred and a
% non-starred version. Since \env{smallmatrix} is defined in a
% different manner than the \env{matrix} environment, the option to
% say \env{smallmatrix*} \emph{has} to be either \texttt{c},
% \texttt{l} \emph{or}~\texttt{r}. The default is \texttt{c}, which
% can be changed globally using the \key{smallmatrix-align}=\meta{c,l
% or r}.
% \begin{codesyntax}
% \SpecialEnvIndex{smallmatrix*}\cs{begin}\arg{smallmatrix*}\texttt{ }\oarg{col}
% \meta{contents} \cs{end}\arg{smallmatrix*}\\
% \SpecialEnvIndex{psmallmatrix}\cs{begin}\arg{psmallmatrix}
% \meta{contents} \cs{end}\arg{psmallmatrix}\\
% \SpecialEnvIndex{psmallmatrix*}\cs{begin}\arg{psmallmatrix*}\oarg{col}
% \meta{contents} \cs{end}\arg{psmallmatrix*}\\
% \SpecialEnvIndex{bsmallmatrix}\cs{begin}\arg{bsmallmatrix}
% \meta{contents} \cs{end}\arg{bsmallmatrix}\\
% \SpecialEnvIndex{bsmallmatrix*}\cs{begin}\arg{bsmallmatrix*}\oarg{col}
% \meta{contents} \cs{end}\arg{bsmallmatrix*}\\
% \SpecialEnvIndex{Bsmallmatrix}\cs{begin}\arg{Bsmallmatrix}
% \meta{contents} \cs{end}\arg{Bsmallmatrix}\\
% \SpecialEnvIndex{Bsmallmatrix*}\cs{begin}\arg{Bsmallmatrix*}\oarg{col}
% \meta{contents} \cs{end}\arg{Bsmallmatrix*}\\
% \SpecialEnvIndex{vsmallmatrix}\cs{begin}\arg{vsmallmatrix}
% \meta{contents} \cs{end}\arg{vsmallmatrix}\\
% \SpecialEnvIndex{vsmallmatrix*}\cs{begin}\arg{vsmallmatrix*}\oarg{col}
% \meta{contents} \cs{end}\arg{vsmallmatrix*}\\
% \SpecialEnvIndex{Vsmallmatrix}\cs{begin}\arg{Vsmallmatrix}
% \meta{contents} \cs{end}\arg{Vsmallmatrix}\\
% \SpecialEnvIndex{Vsmallmatrix*}\cs{begin}\arg{Vsmallmatrix*}\oarg{col}
% \meta{contents} \cs{end}\arg{Vsmallmatrix*}\\
% \SpecialKeyIndex{smallmatrix-align}\makebox{$\key{smallmatrix-align}=\meta{c,l or r}$}\\
% \SpecialKeyIndex{smallmatrix-inner-space}\makebox{$\key{smallmatrix-inner-space}=\cs{,}$}
% \end{codesyntax}
% \ProvidedBy{Rasmus Villemoes}{2011/01/17}
% \begin{verbatim}
% \[
% \begin{bsmallmatrix} a & -b \\ -c & d \end{bsmallmatrix}
% \begin{bsmallmatrix*}[r] a & -b \\ -c & d \end{bsmallmatrix*}
% \]
% \end{verbatim}
% yields
% \[
% \begin{bsmallmatrix} a & -b \\ -c & d \end{bsmallmatrix}
% \begin{bsmallmatrix*}[r] a & -b \\ -c & d \end{bsmallmatrix*}
% \]
% Inside the \verb?Xsmallmatrix? construction a small space is
% inserted between the fences and the contents, the size of it can be
% changed using \key{smallmatrix-align}=\meta{some spacing command},
% the default is \cs{,}.
%
% As an extra trick the fences will behave as open and closing fences
% in constract to their auto-scaling nature.\footnote{\cs{left} and
% \cs{right} do \emph{not} produce open and closing fences, thus
% the space before or after may be too large. Inside this
% construction they behave.}
%
% \subsubsection{The \env{multlined} environment}
%
% \begin{codesyntax}
% \SpecialEnvIndex{multlined}\cs{begin}\arg{multlined}\oarg{pos}\oarg{width}
% \meta{contents} \cs{end}\arg{multlined}\\
% \SpecialUsageIndex{\shoveleft}\cs{shoveleft}\oarg{dimen}\marg{arg}\texttt{~~}
% \SpecialUsageIndex{\shoveright}\cs{shoveright}\oarg{dimen}\marg{arg}\\
% \makeatletter\settowidth\@tempdimc{\cs{shoveleft}\oarg{dimen}\marg{arg}}\global\@tempdimc\@tempdimc
% \SpecialKeyIndex{firstline-afterskip}\makebox[\@tempdimc][l]{$\key{firstline-afterskip}=\meta{dimen}$}\texttt{~~}
% \SpecialKeyIndex{lastline-preskip}$\key{lastline-preskip}=\meta{dimen}$\\
% \makeatletter\SpecialKeyIndex{multlined-width}\makebox[\@tempdimc][l]{$\key{multlined-width}=\meta{dimen}$}\texttt{~~}
% \SpecialKeyIndex{multlined-pos}$\key{multlined-pos}=\texttt{c}\vert\texttt{b}\vert\texttt{t}$
% \end{codesyntax}
% Some of the \pkg{amsmath} environments exist in two forms: an
% outer and an inner environment. One example is the pair
% \env{gather} \& \env{gathered}. There is one important omission on
% this list however, as there is no inner \env{multlined}
% environment, so this is where \pkg{mathtools} steps in.
%
% One might wonder what the sensible behavior should be. We want it
% to be an inner environment so that it is not wider than necessary,
% but on the other hand we would like to be able to control the
% width. The current implementation of \env{multlined} handles both
% cases. The idea is this: Set the first line flush left and add a
% hard space after it; this space is governed by the
% \key{firstline-afterskip} key. The last line should be set flush
% right and preceded by a hard space of size \key{lastline-preskip}.
% Both these hard spaces have a default value of \cs{multlinegap}.
% Here we use a `t' in the first optional argument denoting a
% top-aligned building block (the default is `c').
% \begin{verbatim}
% \[
% A = \begin{multlined}[t]
% \framebox[4cm]{first} \\
% \framebox[4cm]{last}
% \end{multlined} B
% \]
% \end{verbatim}
% \[
% A = \begin{multlined}[t]
% \framebox[4cm]{first} \\
% \framebox[4cm]{last}
% \end{multlined} B
% \]
% Note also that \env{multlined} gives you access to an extended
% syntax for \cs{shoveleft} and \cs{shoveright} as shown in the
% example below.
% \begin{verbatim}
% \[
% \begin{multlined}
% \framebox[.65\columnwidth]{First line} \\
% \framebox[.5\columnwidth]{Second line} \\
% \shoveleft{L+E+F+T} \\
% \shoveright{R+I+G+H+T} \\
% \shoveleft[1cm]{L+E+F+T} \\
% \shoveright[\widthof{$R+I+G+H+T$}]{R+I+G+H+T} \\
% \framebox[.65\columnwidth]{Last line}
% \end{multlined}
% \]
% \end{verbatim}
% \[
% \begin{multlined}
% \framebox[.65\columnwidth]{First line} \\
% \framebox[.5\columnwidth]{Second line} \\
% \shoveleft{L+E+F+T} \\
% \shoveright{R+I+G+H+T} \\
% \shoveleft[1cm]{L+E+F+T} \\
% \shoveright[\widthof{$R+I+G+H+T$}]{R+I+G+H+T} \\
% \framebox[.65\columnwidth]{Last line}
% \end{multlined}
% \]
%
% You can also choose the width yourself by specifying it as an
% optional argument:
% \begin{verbatim}
% \[
% \begin{multlined}[b][7cm]
% \framebox[4cm]{first} \\
% \framebox[4cm]{last}
% \end{multlined} = B
% \]
% \end{verbatim}
% \[
% \begin{multlined}[b][7cm]
% \framebox[4cm]{first} \\
% \framebox[4cm]{last}
% \end{multlined} = B
% \]
% There can be two optional arguments (position and width) and
% they're interchangeable.
%
% \medskip\noindent
% \textbf{Bug 1:}
% \CommentAdded{2014/05/11}
% If used inside an \env{array} or
% a derivative (say, a \env{matrix} variant), \env{multlined} does
% not work as expected. The implementation contains an `invisible'
% line after the first \env{multline} row, inside an \env{array} this
% line is no longer `invisible' because \env{array} sets
% \cs{baselineskip} to zero. Currently we have no general workaround
% for this.
%
% \medskip\noindent
% \textbf{Bug 2:}
% \CommentAdded{2015/11/12}
% Due to the way \env{multilined} is implemented, certain
% constructions does not work inside \env{multlined}. We have added a
% hook (\cs{MultlinedHook}) that can be added to. The default value
% is a fix for \env{subarray} and thus \cs{substack}.
%
% This can actually be used to fix Bug~1:
% \begin{verbatim}
% \usepackage{mathtools,etoolbox}
% \newlength\Normalbaselineskip{\baselineskip}
% \appto\MultlinedHook{
% \setlength\baselineskip{\Normalbaselineskip}
% }
% \end{verbatim}
%
% \medskip\noindent
% \textbf{Caveat:}
% \CommentAdded{2017/05/22}
% \cs{shoveleft} and \cs{shoveright} does not work as expected if
% used as the last line in \env{multlined}.
%
%
% \subsubsection{More \env{cases}-like environments}
%
% \begin{codesyntax}
% \SpecialEnvIndex{dcases}
% \cs{begin}\arg{dcases}\texttt{~} \meta{math_column} |&| \meta{math_column}
% \cs{end}\arg{dcases}\\
% \SpecialEnvIndex{dcases*}
% \cs{begin}\arg{dcases*} \meta{math_column} |&| \makebox[\widthof{\meta{math\_column}}][l]{\meta{text\_column}}
% \cs{end}\arg{dcases*}\\
% \SpecialEnvIndex{rcases}
% \cs{begin}\arg{rcases}\texttt{~~} \meta{math_column} |&| \makebox[\widthof{\meta{math\_column}}][l]{\meta{math\_column}}
% \cs{end}\arg{rcases}\\
% \SpecialEnvIndex{rcases*}
% \cs{begin}\arg{rcases*}\texttt{~} \meta{math_column} |&| \makebox[\widthof{\meta{math\_column}}][l]{\meta{text\_column}}
% \cs{end}\arg{rcases*}\\
% \SpecialEnvIndex{drcases}
% \cs{begin}\arg{drcases}\texttt{~} \meta{math_column} |&| \makebox[\widthof{\meta{math\_column}}][l]{\meta{math\_column}}
% \cs{end}\arg{drcases}\\
% \SpecialEnvIndex{drcases*}
% \cs{begin}\arg{drcases*} \meta{math_column} |&| \makebox[\widthof{\meta{math\_column}}][l]{\meta{text\_column}}
% \cs{end}\arg{drcases*}\\
% \SpecialEnvIndex{cases*}
% \cs{begin}\arg{cases*}\texttt{~} \meta{math_column} |&| \makebox[\widthof{\meta{math\_column}}][l]{\meta{text\_column}}
% \cs{end}\arg{cases*}
% \end{codesyntax}
% \FeatureRequest{Lars Madsen}{2004/07/01}
% Anyone who have tried to use an integral in the regular
% \env{cases} environment from \pkg{amsmath} will have noticed that
% it is set as
% \[
% a=\begin{cases}
% E = m c^2 & \text{Nothing to see here} \\
% \int x-3\, dx & \text{Integral is text style}
% \end{cases}
% \]
% \pkg{mathtools} provides two environments similar to \env{cases}.
% Using the \env{dcases} environment you get the same output as with
% \env{cases} except that the rows are set in display style.
% \begin{verbatim}
% \[
% \begin{dcases}
% E = m c^2 & c \approx 3.00\times 10^{8}\,\mathrm{m}/\mathrm{s} \\
% \int x-3\, dx & \text{Integral is display style}
% \end{dcases}
% \]
% \end{verbatim}
% \[
% \begin{dcases}
% E = m c^2 & c \approx 3.00\times 10^{8}\,\mathrm{m}/\mathrm{s} \\
% \int x-3\, dx & \text{Integral is display style}
% \end{dcases}
% \]
% Additionally the environment \env{dcases*} acts just the same, but
% the second column is set in the normal roman font of the
% document.\footnote{Or rather: it inherits the font characteristics
% active just before the \env{dcases*} environment.}
% \begin{verbatim}
% \[
% a= \begin{dcases*}
% E = m c^2 & Nothing to see here \\
% \int x-3\, dx & Integral is display style
% \end{dcases*}
% \]
% \end{verbatim}
% \[
% a= \begin{dcases*}
% E = m c^2 & Nothing to see here \\
% \int x-3\, dx & Integral is display style
% \end{dcases*}
% \]
% The environments \env{rcases}, \env{rcases*}, \env{drcases} and
% \env{drcases*} are equivalent to \env{cases} and \env{dcases}, but
% here the brace is placed on the right instead of on the left.
% \begin{verbatim}
% \[
% \begin{rcases*}
% x^2 & for $x>0$\\
% x^3 & else
% \end{rcases*} \quad \Rightarrow \cdots
% \]
% \end{verbatim}
% \[
% \begin{rcases*}
% x^2 & for $x>0$\\
% x^3 & else
% \end{rcases*} \quad \Rightarrow\cdots
% \]
%
%
% \subsubsection{Emulating indented lines in alignments}
% \begin{codesyntax}
% \SpecialEnvIndex{\MoveEqLeft}\cs{MoveEqLeft}\oarg{number}
% \end{codesyntax}
% \ProvidedBy{Lars Madsen}{2008/06/05} In \cite{Swanson}, Ellen
% Swanson recommends that when ever one has a long displayed formula,
% spanning several lines, and it is unfeasible to align against a
% relation within the first line, then all lines in the display
% should be aligned at the left most edge of the first line, and all
% subsequent lines should be indented by 2\,em (or if needed by a
% smaller amount). That is we are talking about displayes that end up
% looking like this
% \begin{align*}
% \MoveEqLeft \framebox[10cm][c]{Long first line}\\
% & = \framebox[6cm][c]{ \hphantom{g} 2nd line}\\
% & \leq \dots
% \end{align*}
% Traditionally one could do this by starting subsequent lines by
% \verb+&\qquad ...+, but that is tedious. Instead the example above
% was made using \cs{MoveEqLeft}:
% \begin{verbatim}
% \begin{align*}
% \MoveEqLeft \framebox[10cm][c]{Long first line}\\
% & = \framebox[6cm][c]{ \hphantom{g} 2nd line}\\
% & \leq \dots
% \end{align*}
% \end{verbatim}
% \cs{MoveEqLeft} is placed instead of the \verb+&+ on the first
% line, and will effectively \emph{move} the entire first line
% \oarg{number} of ems to the left (default is 2). If you choose to
% align to the right of the relation, use \cs{MoveEqLeft}\verb+[3]+
% to accommodate the extra distance to the alignment point:
% \begin{verbatim}
% \begin{align*}
% \MoveEqLeft[3] \framebox[10cm][c]{Part 1}\\
% = {} & \framebox[8cm][c]{2nd line}\\
% & + \framebox[4cm][c]{ last part}
% \end{align*}
% \end{verbatim}
% \begin{align*}
% \MoveEqLeft[3] \framebox[10cm][c]{Long first line}\\
% = {} & \framebox[6cm][c]{ 2nd line}\\
% & + \framebox[4cm][c]{ last part}
% \end{align*}
%
% \subsubsection{Boxing a single line in an alignment}
%
% The \texttt{amsmath} package provie the \cs{boxed} macro to box
% material in math mode. But this of course will not work if the box
% should cross an alignment point. We provide a macro that
% can.\footnote{Note that internally \cs{Aboxed} does use \cs{boxed}.}
% \hskip1sp
% \marginpar{%
% \parbox[b]{\marginparwidth}{\small\sffamily\raggedright
% \strut Evolved from a request by\\Merciadri Luca\\
% 2010/06/28\\on comp.text.tex%
% }\strut
% }%
% \marginpar{\strut\\%
% \parbox[b]{\marginparwidth}{\small\sffamily\raggedright
% \strut Reimplemented by\\Florent Chervet (GL) \\
% 2011/06/11\\on comp.text.tex%
% }\strut
% }%
% \begin{codesyntax}
% \SpecialEnvIndex{\Aboxed}\cs{Aboxed}\marg{left hand side
% \quad\texttt{\textnormal{\&}}\quad right hand side}
% \end{codesyntax}
% Example
% \begin{verbatim}
% \begin{align*}
% \Aboxed{ f(x) & = \int h(x)\, dx} \\
% & = g(x)
% \end{align*}
% \end{verbatim}
% Resulting in:
% \begin{align*}
% \Aboxed{ f(x) & = \int h(x)\, dx} \\
% & = g(x)
% \end{align*}
% One can have multiple boxes on each line, and the
% >>\texttt{\textnormal{\&}}\quad right hand side<< can even be
% missing. Here is an example of how the padding in the box can be changed
% \begin{verbatim}
% \begin{align*}
% \setlength\fboxsep{1em}
% \Aboxed{ f(x) &= 0 } & \Aboxed{ g(x) &= b} \\
% \Aboxed{ h(x) } & \Aboxed{ i(x) }
% \end{align*}
% \end{verbatim}
% \begin{align*}
% \setlength\fboxsep{1em}
% \Aboxed{ f(x) &= 0 } & \Aboxed{ g(x) &= b} \\
% \Aboxed{ h(x) } & \Aboxed{ i(x) }
% \end{align*}
% Note how the \cs{fboxsep} change only affect the box coming
% immediately after it.
%
% \marginpar{\strut\\%
% \parbox[b]{\marginparwidth}{\small\sffamily\raggedright
% \strut Comment by Qrrbrbirlbel on \url{tex.stackexchange.com}, 2013/05/20.
% }\strut
% }%
% As \cs{Aboxed} looks for the alignment \texttt{\&} it may be
% necessary to \emph{hide} constructions like matrices that also make
% use of \texttt{\&}. Just add a set of braces around the construction
% you want to hide.
%
% \subsubsection{Adding arrows between lines in an alignment}
%
% This first macro is a bit misleading, it is only intended to be
% used in combination with the \env{alignat(*)} environment.
% \begin{codesyntax}
% \SpecialEnvIndex{\ArrowBetweenLines}\cs{ArrowBetweenLines}\oarg{symbol}\\
% \SpecialEnvIndex{\ArrowBetweenLines*}\cs{ArrowBetweenLines*}\oarg{symbol}
% \end{codesyntax}
% \hskip1sp
% \marginpar{%
% \parbox[b]{\marginparwidth}{\small\sffamily\raggedright
% \strut Evolved from a request by\\Christian
% Bohr-Halling\\2004/03/31\\on dk.edb.tekst%
% }
% }%
% To add, say $\Updownarrow$ between two lines in an alignment use
% \cs{ArrowBetweenLines} and the \env{alignat} environment (note the
% extra pair of \texttt{\&}'s in front):
% \begin{verbatim}
% \begin{alignat}{2}
% && \framebox[1.5cm]{} &= \framebox[3cm]{}\\
% \ArrowBetweenLines % \Updownarrow is the default
% && \framebox[1.5cm]{} &= \framebox[2cm]{}
% \end{alignat}
% \end{verbatim}
% resulting in
% \begin{alignat}{2}
% && \framebox[1.5cm]{} &= \framebox[3cm]{}\\
% \ArrowBetweenLines
% && \framebox[1.5cm]{} &= \framebox[2cm]{}
% \end{alignat}
% Note the use of \verb+&&+ starting each \emph{regular} line of
% math. For adding the arrow on the right, use
% \cs{ArrowBetweenLines*}\oarg{symbol}, and end each line of math
% with \verb+&&+.
% \begin{verbatim}
% \begin{alignat*}{2}
% \framebox[1.5cm]{} &= \framebox[3cm]{} &&\\
% \ArrowBetweenLines*[\Downarrow]
% \framebox[1.5cm]{} &= \framebox[2cm]{} &&
% \end{alignat*}
% \end{verbatim}
% resulting in
% \begin{alignat*}{2}
% \framebox[1.5cm]{} &= \framebox[3cm]{} &&\\
% \ArrowBetweenLines*[\Downarrow]
% \framebox[1.5cm]{} &= \framebox[2cm]{} &&
% \end{alignat*}
%
%
% \subsubsection{Centered \texorpdfstring{\cs{vdots}}{\textbackslash vdots}}
%
% If one want to mark a vertical continuation, there is
% the \verb?\vdots? command, but combine this with an alignment and
% we get something rather suboptimal
% \FeatureRequest{Bruno Le Floch \\(and many others)}{2011/01/25}
% \begin{align*}
% \framebox[1.5cm]{} &= \framebox[3cm]{}\\
% & \vdots\\
% &= \framebox[3cm]{}
% \end{align*}
% It would be nice to have (1) a \verb?\vdots? centered within the
% width of another symbol, and (2) a construction similar to
% \verb?\ArrowBetweenLines? that does not take up so much space.
% We provide both.
% \begin{codesyntax}
% \SpecialUsageIndex{\vdotswithin}\cs{vdotswithin}\marg{symbol}\\
% \SpecialUsageIndex{\shortvdotswithin}\cs{shortvdotswithin}\marg{symbol}\\
% \SpecialUsageIndex{\shortvdotswithin*}\cs{shortvdotswithin*}\marg{symbol}\\
% \SpecialUsageIndex{\MTFlushSpaceAbove}\cs{MTFlushSpaceAbove}\\
% \SpecialUsageIndex{\MTFlushSpaceBelow}\cs{MTFlushSpaceBelow}\\
% \SpecialKeyIndex{shortvdotsadjustabove}\makebox{$\key{shortvdotsadjustabove}=\meta{length}$}\\
% \SpecialKeyIndex{shortvdotsadjustbelow}\makebox{$\key{shortvdotsadjustbelow}=\meta{length}$}
% \end{codesyntax}
% Two examples in one
% \begin{verbatim}
% \begin{align*}
% a &= b \\
% & \vdotswithin{=} \\
% & = c \\
% \shortvdotswithin{=}
% & = d
% \end{align*}
% \end{verbatim}
% yielding
% \begin{align*}
% a &= b \\
% & \vdotswithin{=} \\
% & = c \\
% \shortvdotswithin{=}
% & = d
% \end{align*}
% Thus \verb?\vdotswithin{=}? create a box corersponding to
% \verb?{}={}? and typeset a >>$\vdots$<< centered inside it. When doing
% this as a normal line in an alignment leaves us with excessive space
% which \verb?\shortvdotswithin{=}? takes care with for us.
%
% \verb?\shortvdotswithin{=}? corresponds to
% \begin{verbatim}
% \MTFlushSpaceAbove
% & \vdotswithin{=} \\
% \MTFlushSpaceBelow
% \end{verbatim}
% whereas \verb?\shortvdotswithin*{=}? is the case with
% \verb?\vdotswithin{=} & \\?. This also means one cannot write more
% on the line when using \verb?\shortvdotswithin? or the starred
% version. But one can de-construct the macro and arrive at
% \begin{verbatim}
% \begin{alignat*}{3}
% A&+ B &&= C &&+ D \\
% \MTFlushSpaceAbove
% &\vdotswithin{+} &&&& \vdotswithin{+}
% \MTFlushSpaceBelow
% C &+ D &&= Y &&+K
% \end{alignat*}
% \end{verbatim}
% yielding
% \begin{alignat*}{3}
% A&+ B &&= C &&+ D \\
% \MTFlushSpaceAbove
% &\vdotswithin{+} &&&& \vdotswithin{+}
% \MTFlushSpaceBelow
% C &+ D &&= Y &&+K
% \end{alignat*}
% If one has the need for such a construction.
%
% The de-spaced version does support the \env{spreadlines}
% environment. The actual amount of space being \emph{flushed} above
% and below can be controlled by the user using the two options
% indicated. Their original values are \verb?2.15\origjot? and
% \verb?\origjot? respectively (\verb?\origjot? is usually 3pt).
%
% \subsection{Intertext and short intertext}
%
%
% \begin{codesyntax}
% \SpecialUsageIndex{\shortintertext}\cs{shortintertext}\marg{text}
% \end{codesyntax}
% \cttPosting{Gabriel Zachmann and Donald Arseneau}{2000/05/12--13}
% \pkg{amsmath} provides the command \cs{intertext} for interrupting
% a multiline display while still maintaining the alignment points.
% However the spacing often seems quite excessive as seen below.
% \begin{verbatim}
% \begin{align}
% a&=b \intertext{Some text}
% c&=d
% \end{align}
% \end{verbatim}
% \begin{align}
% a&=b \intertext{Some text}
% c&=d
% \end{align}
%
% Using the command \cs{shortintertext} alleviates this situation
% somewhat:
% \begin{verbatim}
% \begin{align}
% a&=b \shortintertext{Some text}
% c&=d
% \end{align}
% \end{verbatim}
% \begin{align}
% a&=b \shortintertext{Some text}
% c&=d
% \end{align}
%
% \noindent
% It turns out that both \cs{shortintertext} and the original
% \cs{intertext} from \pkg{amsmath} has a slight problem. If we use
% the \env{spreadlines} (see section~\ref{sec:spread}) to open up
% the equations in a multiline calculation, then this opening up
% value also applies to the spacing above and below the original
% \cs{shortintertext} and \cs{intertext}. \tsxPosting{Tobias Weh
% \\(referring to a suggestion by Chung-chieh Shan)}{2011/05/29}
% It can be illustrated using the following example, an interested
% reader, can apply it with and with out the original \cs{intertext}
% and \cs{shortintertext}.
% \begin{verbatim}
% % the original \intertext and \shortintertext
% \mathtoolsset{original-intertext,original-shortintertext}
% \newcommand\myline{\par\noindent\rule{\textwidth}{1mm}}
% \myline
% \begin{spreadlines}{1em}
% \begin{align*}
% AA\\ BB\\ \intertext{\myline}
% AA\\ BB\\ \shortintertext{\myline}
% AA\\ BB
% \end{align*}
% \end{spreadlines}
% \myline
% \end{verbatim}
%
% We now fix this internaly for both \cs{intertext} and
% \cs{shortintertext}, plus we add the posibility to fine tune
% spacing around these constructions. The original versions can be
% brought back using the \texttt{original-x} keys below.
% \begin{codesyntax}
% \SpecialUsageIndex{\intertext}\cs{intertext}\marg{text}\\
% \SpecialUsageIndex{\shortintertext}\cs{shortintertext}\marg{text}\\
% \SpecialKeyIndex{original-intertext}$\key{original-intertext}=\texttt{true}\vert\texttt{false}$ \quad(default: \texttt{false})\\
% \SpecialKeyIndex{original-shortintertext}$\key{original-shortintertext}=\texttt{true}\vert\texttt{false}$
% \quad(default: \texttt{false})\\
% \SpecialKeyIndex{above-intertext-sep}$\key{above-intertext-sep}=\meta{dimen}$ \quad(default: 0pt)\\
% \SpecialKeyIndex{below-intertext-sep}$\key{below-intertext-sep}=\meta{dimen}$ \quad(default: 0pt)\\
% \SpecialKeyIndex{above-shortintertext-sep}$\key{above-shortintertext-sep}=\meta{dimen}$ \quad(default: 3pt)\\
% \SpecialKeyIndex{below-shortintertext-sep}$\key{below-shortintertext-sep}=\meta{dimen}$ \quad(default: 3pt)
% \end{codesyntax}
% The updated \cs{shortintertext} will look like the original version
% unless for areas with an enlarged \cs{jot} value (see for example
% the \env{spreadlines}, section~\ref{sec:spread}). Whereas \cs{intertext}
% will have a slightly smaller value above and below (corresponding
% to about 3pt less space above and below), the spacing around
% \cs{intertext} should now match the normal spacing going into and
% out of an \env{align}.
%
% \textbf{Tip:} \cs{intertext} and \cs{shortintertext} also works
% within \env{gather}.
%
%
% \subsection{Paired delimiters}
%
%
% \begin{codesyntax}
% \SpecialUsageIndex{\DeclarePairedDelimiter}
% \cs{DeclarePairedDelimiter}\marg{cmd}\marg{left_delim}\marg{right_delim}
% \end{codesyntax}
% \FeatureRequest{Lars Madsen}{2004/06/25}
% In the \pkg{amsmath} documentation it is shown how to define a few
% commands for typesetting the absolute value and norm. These
% definitions are:
% \begin{verbatim}
% \newcommand*\abs[1]{\lvert#1\rvert}
% \newcommand*\norm[1]{\lVert#1\rVert}
% \end{verbatim}
% \DeclarePairedDelimiter\abs\lvert\rvert
% While they produce correct horizontal spacing you have to be
% careful about the vertical spacing if the argument is just a
% little taller than usual as in
% \[
% \abs{\frac{a}{b}}
% \]
% Here it won't give a nice result, so you have to manually put in
% either \cs{left}--\cs{right} pair or a \cs{bigl}--\cs{bigr} pair.
% Both methods mean that you have to delete your \cs{abs} command,
% which may not sound like an ideal solution.
%
% With the command \cs{DeclarePairedDelimiter} you can combine all
% these features in one easy to use command. Let's show an example:
% \begin{verbatim}
% \DeclarePairedDelimiter\abs{\lvert}{\rvert}
% \end{verbatim}
% This defines the command \cs{abs} just like in the
% \pkg{amsmath} documentation but with a few additions:
% \begin{itemize}
% \item A starred variant: \cs{abs*} produces delimiters that are preceded
% by \cs{left} and \cs{right} resp.:
% \begin{verbatim}
% \[
% \abs*{\frac{a}{b}}
% \]
% \end{verbatim}
% \[
% \abs*{\frac{a}{b}}
% \]
% \item A variant with an optional argument:
% \cs{abs}\oarg{size_cmd}, where
% \meta{size_cmd} is either \cs{big}, \cs{Big}, \cs{bigg}, or
% \cs{Bigg} (if you have any bigggger versions you can use them
% too).
% \begin{verbatim}
% \[
% \abs[\Bigg]{\frac{a}{b}}
% \]
% \end{verbatim}
% \[
% \abs[\Bigg]{\frac{a}{b}}
% \]
% \end{itemize}
%
% \begin{codesyntax}
% \SpecialUsageIndex{\DeclarePairedDelimiterX}
% \cs{DeclarePairedDelimiterX}\marg{cmd}\oarg{num args}\marg{left_delim}\marg{right_delim}\marg{body}\\
% \cs{delimsize}
% \end{codesyntax}
% Sometimes one might want to have the capabilities of
% \cs{DeclarePairedDelimiter}, but also want a macro the takes more
% than one argument and specify plus being able to specify the body
% of the generated macro.
%
% \cs{DeclarePairedDelimiterX} extends the features of
% \cs{DeclarePairedDelimiter} such that the user will get a macro
% which is fenced off at either end, plus the capability to provide
% the \meta{body} for what ever the macro should do within these
% fences.
%
% Inside the \meta{body} part, the macro \cs{delimsize} refer to the
% size of the outer fences. It can then be used inside \meta{body} to
% scale any inner fences.
%
% Thus
% \begin{quote}
% \cs{DeclarePairedDelimiter}\marg{cmd}\marg{left_delim}\marg{right_delim}
% \end{quote}
% is the same thing as
% \begin{quote}
% \cs{DeclarePairedDelimiterX}\marg{cmd}\verb|[1]|\marg{left_delim}\marg{right_delim}\verb|{#1}|
% \end{quote}
% %
% Let us do some examples. First we want to prepare a macro for inner
% products, with two arguments such that we can hide the character
% separating the arguments (a~journal style might require a
% semi-colon, so we will save a lot of hand editing). This can be
% done via
% \begin{verbatim}
% \DeclarePairedDelimiterX\innerp[2]{\langle}{\rangle}{#1,#2}
% \end{verbatim}
% More interestingly we can refer to the size inside the
% \meta{code}. Here we do a weird three argument `braket'
% \begin{verbatim}
% \DeclarePairedDelimiterX\braket[3]{\langle}{\rangle}%
% {#1\,\delimsize\vert\,\mathopen{}#2\,\delimsize\vert\,\mathopen{}#3}
% \end{verbatim}
% \begin{itshape}
% Note the use of >>\verb|\mathopen{}|<< in the \meta{body} of
% \cs{braket}, this is very important when a scalable delimiter is
% being used and it does not present itself as a left or right
% delimiter. You will see why it is needed if you use
% \verb|\braket{A}{-B}| in a version without
% \verb|\mathopen{}|.\footnote{Basically, the problem is that
% \cs{vert} is a `symbol', thus $\vert-B$ is interpreted
% \emph{subtraction}, not a symbol followed by negative $B$. When
% \cs{mathopen\{\}} is added, \TeX\ is told that an opening
% delimiter just occurred, and it will adjust the minus
% accordingly.}
% \end{itshape}
%
% Then we get
% \DeclarePairedDelimiterX\innerp[2]{\langle}{\rangle}{#1,#2}
% \DeclarePairedDelimiterX\braket[3]{\langle}{\rangle}%
% {#1\,\delimsize\vert\,\mathopen{}#2\,\delimsize\vert\,\mathopen{}#3}
% \begin{verbatim}
% \[
% \innerp*{A}{ \frac{1}{2} } \quad
% \braket[\Big]{B}{\sum_{k} f_k}{C}
% \]
% \end{verbatim}
% \[
% \innerp*{A}{ \frac{1}{2} } \quad
% \braket[\Big]{B}{\sum_{k}}{C}
% \]
%
%
% \iffalse
% \bigskip
%
% \noindent
% \textbf{\textit{Side note:}} We have changed the internal code of
% \cs{DeclarePairedDelimiter} and \cs{DeclarePairedDelimiterX} such
% that the starred version does no longer give the odd spacings that
% \cs{left}\dots\cs{right} sometimes give. Compare this
% \begin{verbatim}
% \[
% 2\innerp{A}{B} \quad 2\innerp*{A}{B} \quad 2\left\langle A,B \right\rangle
% \]
% \end{verbatim}
% \[
% \sin\innerp{A}{B} \quad
% \sin\innerp*{A}{B} \quad
% \sin\left\langle A,B \right\rangle
% \]
% The spacing in the last one does not behave like other fences (this
% is a feature of the \cs{left}\dots\cs{right} construction).
% \fi
%
% With the inner scaling, we can provide macros whos syntax closely
% follow the mathematical meaning. Fx for building sets, try
% this\footnote{The reason for using a separate \cs{SetSymbol} macro
% has to do with complicated set definitions, where the condition
% spans several lines. In this case \cs{Set} cannot be used. Thus it
% is nice to be able to refer to the specific set building symbol we
% have decided to use in this document. Also remember to add
% \cs{allowbreak} \emph{before} the proceeding inserted space. Then
% that space will disappear when a line break occurs.}
% \begin{verbatim}
% % just to make sure it exists
% \providecommand\given{}
% % can be useful to refer to this outside \Set
% \newcommand\SetSymbol[1][]{%
% \nonscript\:#1\vert
% \allowbreak
% \nonscript\:
% \mathopen{}}
% \DeclarePairedDelimiterX\Set[1]\{\}{%
% \renewcommand\given{\SetSymbol[\delimsize]}
% #1
% }
% \end{verbatim}
% \providecommand\given{}
% \newcommand\SetSymbol[1][]{\nonscript\:#1\vert\allowbreak\nonscript\:\mathopen{}}
% \DeclarePairedDelimiterX\Set[1]\{\}{%
% \renewcommand\given{\SetSymbol[\delimsize]}
% #1
% }
% \begin{verbatim}
% \[ \Set*{ x \in X \given \frac{\sqrt{x}}{x^2+1} > 1 } \]
% \end{verbatim}
% \[ \Set*{ x \in X \given \frac{\sqrt{x}}{x^2+1} > 1 } \]
% Thus we end up with a syntax much closer to how we read this
% aloud. Also we hide the `given' symbol for easy replacement.
%
% Combining with \pkg{etoolbox} it becomes easy to make a function
% that automatically provide a marker for a blank argument:
% \begin{verbatim}
% \usepackage{etoolbox}
% \DeclarePairedDelimiterX\norm[1]\lVert\rVert{
% \ifblank{#1}{\:\cdot\:}{#1}
% }
% \end{verbatim}
% Then \verb|\norm{}| will give you $\lVert\:\cdot\:\rVert$ while
% \verb|\norm{a}| gives the expected $\lVert a \rVert$.
%
% \begin{codesyntax}
% \SpecialUsageIndex{\DeclarePairedDelimiterXPP}
% \cs{DeclarePairedDelimiterXPP}\marg{cmd}\oarg{num args}\marg{pre
% code}\marg{left_delim}\\%
% \marg{right_delim}\marg{post code}\marg{body}
% \end{codesyntax}
% \FeatureRequest{Barbara Beeton (on TSE)}{2013/10/07}
% \cs{DeclarePairedDelimiterX} has an annoying caveat: it is very hard
% to make a macro \verb|\lnorm{a}| that should result in $\lVert
% a\rVert_2$.\footnote{The added >>\texttt{\_2}<< is hard to get around
% the argument parsing.}
%
% As a consequence we provide
% \cs{DeclarePairedDelimiterXPP}.\footnote{Extended
% DeclarePairedDelimiter with Pre and Post code.} With the addition of
% the \marg{pre code} and \marg{post code} it is identical to
% \cs{DeclarePairedDelimiterX}. It should be interpreted as
% \begin{center}
% \marg{pre code} \marg{left_delim} \marg{body}
% \marg{right_delim} \marg{post code}
% \end{center}
%
%
% An $\mathcal{L}^2$ norm can now be defined as
% \begin{verbatim}
% \DeclarePairedDelimiterXPP\lnorm[1]{}\lVert\rVert{_2}{#1}
% \end{verbatim}
% A probability macro with build in support for conditionals
% (\cs{given} initialized as above)
% \begin{verbatim}
% \DeclarePairedDelimiterXPP\Prop[1]{\mathbb{P}}(){}{
% \renewcommand\given{\nonscript\:\delimsize\vert\nonscript\:\mathopen{}}
% #1}
% \end{verbatim}
% Thus giving support for \verb|\Prob{A \given B}|.
%
% \medskip\noindent\textbf{Note 1:} As the number of arguments increase
% the \cs{DeclarePairedDelimiter...} macros become hard for users to
% understand. A key-value interface would be better. This is planed
% for a future release. In
% \url{http://tex.stackexchange.com/a/136767/3929} there is a
% suggested replacement for \cs{DeclarePairedDelimiter}, that greatly
% reduces the number of macros and provides a key-val
% interface. However, the code use \pkg{xparse}, and if we want to use
% \pkg{xparse} for some of our macros, we might just as well rewrite
% the entire \pkg{mathtools} package in \pkg{expl3}. Also it is not
% obvious how to get \pkg{xparse} to support \verb|[3]| for the number
% of arguments. We will consider this for a future release.
%
% \medskip\noindent\textbf{Note 2:} If you want to define your own
% manual scaler macros, it is importent that you besides \cs{foo} also
% defines \cs{fool} and \cs{foor}. When a scaler is specified, in say
% \cs{abs[\cs{big}]}\marg{arg}, we actually use \cs{bigl} and \cs{bigr}.
%
%
% \subsubsection{Expert use}
%
% Within the starred version of \cs{DeclarePairedDelimiter} and
% \cs{DeclarePairedDelimiterX} we make a few changes such that the
% auto scaled \cs{left} and \cs{right} fences behave as opening and
% closing fences, i.e.\ $\sin(x)$ vs. $\sin\left(x\right)$ (the later
% made via \verb|$\sin\left(x\right)$|), notice the gab between
% '$\sin$' and '('. In some special cases it may be useful to be
% able to tinker with the behavior.
% \begin{codesyntax}
% \SpecialUsageIndex{\reDeclarePairedDelimiterInnerWrapper}\cs{reDeclarePairedDelimiterInnerWrapper}\marg{macro name}\marg{\textnormal{\texttt{star}} or \textnormal{\texttt{nostarnonscaled}} or \textnormal{\texttt{nostarscaled}}}\marg{code}
% \end{codesyntax}
% Internally several macros are created, including three call backs
% that take care of the formatting. There is one internal macro for
% the starred version, labeled \texttt{star}, the other two are
% labeled \texttt{nostarnonscaled} and \texttt{nostarscaled}. Within
% \meta{code}, \texttt{\#1} will be replaced by the (scaled) left
% fence, \texttt{\#3} the corresponding (scaled) right fence, and
% \texttt{\#2} the stuff in between. For example, here is how one
% might turn the content into \cs{mathinner}:
% \begin{verbatim}
% \DeclarePairedDelimiter\abs\lvert\rvert
% \reDeclarePairedDelimiterInnerWrapper\abs{star}{#1#2#3}
% \reDeclarePairedDelimiterInnerWrapper\abs{nostarnonscaled}{\mathinner{#1#2#3}}
% \reDeclarePairedDelimiterInnerWrapper\abs{nostarscaled}{\mathinner{#1#2#3}}
% \end{verbatim}
% The default values for the call backs corresponds to
% \begin{verbatim}
% star: \mathopen{}\mathclose\bgroup #1#2\aftergroup\egroup #3
% nostarnonscaled: \mathopen#1#2\mathclose#3
% nostarscaled: \mathopen{#1}#2\mathclose{#3}
% \end{verbatim}
% The two \texttt{nostar...} versions look the same, but they are
% not. In most (math) fonts, the first item in this list will be
% different from the rest (the superscript sits
% higher).\footnote{Interestingly it dod not show up in the font of
% this manual, which uses the \pkg{fourier} font set.}
% \begin{verbatim}
% \mathclose{\rvert}^2\mathclose\rvert^2\rvert^2
% \end{verbatim}
%
%
% \bigskip\noindent \textbf{Breaking change:} Prior to May 2017, we
% used two wrappers, the other named \texttt{nostar}. As of May 2017
% \texttt{nostar} has been split into \texttt{nostarnonscaled} and
% \texttt{nostarscaled} and \texttt{nostar} alone is no longer
% supported (will give an error).
%
% \bigskip\noindent \textbf{Note:} Since we are using macros to add
% the \verb|\left...\right| constructions around some body, it
% \emph{is} (in principle) possible to make such a construction
% breakable across lines, even breakable within an \env{align}
% construction. Currently, this can only be applied to macros made
% using \cs{DeclarePairedDelimiter} and \emph{not} macros made using
% \cs{DeclarePairedDelimiterX} or \cs{DeclarePairedDelimiterXPP} as
% the contents is typeset inside a group (to limit \cs{delimsize})
% and thus hide any \verb|&| or \verb|\\| from \env{align} and
% \env{align} breaks down.
%
% When \cs{DeclarePairedDelimiter} is used, Sebastien Gouezel has
% provided the following example \ProvidedBy{Sebastien
% Gouezel}{2014/05/14}
% \begin{verbatim}
% \newcommand\MTkillspecial[1]{% helper macro
% \bgroup
% \catcode`\&=9
% \let\\\relax%
% \scantokens{#1}%
% \egroup
% }
% \DeclarePairedDelimiter\abs\lvert\rvert
% \reDeclarePairedDelimiterInnerWrapper\abs{star}{
% \mathopen{#1\vphantom{\MTkillspecial{#2}}\kern-\nulldelimiterspace\right.}
% #2
% \mathclose{\left.\kern-\nulldelimiterspace\vphantom{\MTkillspecial{#2}}#3}}
% \end{verbatim}
% Then this example works just fine:
% \begin{verbatim}
% \begin{align*}
% f(a) &=
% \!\begin{aligned}[t]
% \abs*{ & \frac{1}{2}+\cdots \\
% & \dots+\frac{1}{2} }
% \end{aligned}
% \end{align*}
% \end{verbatim}
% \newcommand\MTkillspecial[1]{% helper macro
% \bgroup
% \catcode`\&=9
% \let\\\relax%
% \scantokens{#1}%
% \egroup
% }
% \let\abs\relax
% \MHInternalSyntaxOn
% \MH_let:NwN\MT_delim_abs_nostar:\relax
% \MHInternalSyntaxOff
% \DeclarePairedDelimiter\abs\lvert\rvert
% \reDeclarePairedDelimiterInnerWrapper\abs{star}{
% \mathopen{#1\vphantom{\MTkillspecial{#2}}\kern-\nulldelimiterspace\right.}
% #2
% \mathclose{\left.\kern-\nulldelimiterspace\vphantom{\MTkillspecial{#2}}#3}}
% \begin{align*}
% f(a) &=
% \!\begin{aligned}[t]
% \abs*{&\frac{1}{2}+\cdots \\
% &\dots+\frac{1}{2}}
% \end{aligned}
% \end{align*}
%
%
% \subsection{Special symbols}
%
% This part of the manual is about special symbols. So far only one
% technique is covered, but more will come.
%
% \subsubsection{Left and right parentheses}
%
% \begin{codesyntax}
% \SpecialUsageIndex{\lparen}\cs{lparen}\texttt{~~}
% \SpecialUsageIndex{\rparen}\cs{rparen}
% \end{codesyntax}
% When you want a big parenthesis or bracket in a math display you
% usually just type
% \begin{quote}
% |\left( ... \right)|\quad or\quad |\left[ ... \right]|
% \end{quote}
% \LaTeX{} also defines the macro names \cs{lbrack} and \cs{rbrack}
% to be shorthands for the left and right square bracket resp., but
% doesn't provide similar definitions for the parentheses. Some
% packages need command names to work with\footnote{The \pkg{empheq}
% package needs command names for delimiters in order to make
% auto-scaling versions.} so \pkg{mathtools} defines the commands
% \cs{lparen} and \cs{rparen} to represent the left and right
% parenthesis resp.
%
%
% \subsubsection{Vertically centered colon}
%
% \begin{codesyntax}
% \SpecialKeyIndex{centercolon}$\key{centercolon}=\texttt{true}\vert\texttt{false}$\\
% \SpecialUsageIndex{\vcentcolon}\cs{vcentcolon}\texttt{~~}
% \SpecialUsageIndex{\ordinarycolon}\cs{ordinarycolon}
% \end{codesyntax}
% \cttPosting{Donald Arseneau}{2000/12/07}
% When trying to show assignment operations as in $ a := b $, one
% quickly notices that the colon is not centered on the math axis as
% the equal sign, leading to an odd-looking output. The command
% \cs{vcentcolon} is a shorthand for such a vertically centered
% colon, and can be used as in |$a \vcentcolon= b$| and results in
% the desired output: $a \vcentcolon= b$. % for now
%
% Typing \cs{vcentcolon} every time is quite tedious, so one can use
% the key \key{centercolon} to make the colon active instead.
% \begin{verbatim}
% \mathtoolsset{centercolon}
% \[
% a := b
% \]
% \mathtoolsset{centercolon=false}
% \end{verbatim}
% \[\mathtoolsset{centercolon}
% a := b
% \]
% In this case the command \cs{ordinarycolon} typesets an~\ldots\
% ordinary colon (what a surprise).
%
% \medskip
% \noindent\textbf{Warning:} \texttt{centercolon} \emph{does not}
% work with languages that make use of an active colon, most notably
% \emph{French}. Sadly the \texttt{babel} package does not distinguish
% between text and math when it comes to active characters. Nor does
% it provide any hooks to deal with math. So currently no general
% solution exists for this problem.
%
% \begin{codesyntax}
% \SpecialUsageIndex{\coloneqq}\cs{coloneqq}\texttt{~~~~~}
% \SpecialUsageIndex{\Coloneqq}\cs{Coloneqq}\texttt{~~~~~}
% \SpecialUsageIndex{\coloneq}\cs{coloneq}\texttt{~~~}
% \SpecialUsageIndex{\Coloneq}\cs{Coloneq}\\
% \SpecialUsageIndex{\eqqcolon}\cs{eqqcolon}\texttt{~~~~~}
% \SpecialUsageIndex{\Eqqcolon}\cs{Eqqcolon}\texttt{~~~~~}
% \SpecialUsageIndex{\eqcolon}\cs{eqcolon}\texttt{~~~}
% \SpecialUsageIndex{\Eqcolon}\cs{Eqcolon}\\
% \SpecialUsageIndex{\colonapprox}\cs{colonapprox}\texttt{~~}
% \SpecialUsageIndex{\Colonapprox}\cs{Colonapprox}\texttt{~~}
% \SpecialUsageIndex{\colonsim}\cs{colonsim}\texttt{~~}
% \SpecialUsageIndex{\Colonsim}\cs{Colonsim}\\
% \SpecialUsageIndex{\dblcolon}\cs{dblcolon}
% \end{codesyntax}
% The font packages \pkg{txfonts} and \pkg{pxfonts} provides various
% symbols that include a vertically centered colon but with tighter
% spacing. For example, the combination |:=| exists as the symbol
% \cs{coloneqq} which typesets as $\coloneqq$ instead of
% $\vcentcolon=$. The primary disadvantage of using these fonts are
% the support packages' lack of support for \pkg{amsmath} (and thus
% \pkg{mathtools}) and worse yet, the side-bearings are way too
% tight; see~\cite{A-W:MG04} for examples. If you're not using these
% fonts, \pkg{mathtools} provides the symbols for you. Here are a few
% examples:
% \begin{verbatim}
% \[
% a \coloneqq b \quad c \Colonapprox d \quad e \dblcolon f
% \]
% \end{verbatim}
% \[
% a \coloneqq b \quad c \Colonapprox d \quad e \dblcolon f
% \]
%
%
%
% \subsubsection{A few missing symbols}
%
% Most provided math font sets are missing the symbols \cs{nuparrow}
% and \cs{ndownarrow} (i.e.\ negated up- and downarrow) plus a `big'
% version of \cs{times}. Therefore we will provide constructed
% versions of these whenever they are not already available.
% \begin{codesyntax}
% \SpecialUsageIndex{\nuparrow}\cs{nuparrow}\\
% \SpecialUsageIndex{\ndownarrow}\cs{ndownarrow}\\
% \SpecialUsageIndex{\bigtimes}\cs{bigtimes}
% \end{codesyntax}
%
% \noindent
% \textbf{Note:} that these symbols are constructed via
% features from the \pkg{graphicx} package, and thus may not display
% correctly in most DVI previewers. Also note that \cs{nuparrow} and
% \cs{ndownarrow} are constructed via \cs{nrightarrow} and
% \cs{nleftarrrow} respectively, so these needs to be
% present. Usually this is done via \pkg{amssymb}, but some packages
% may be incompatible with \pkg{amssymb} so the user will have to
% load \pkg{amssymb} or a similar package, that provides
% \cs{nrightarrow} and \cs{nleftarrow}, themselves.
%
% With those requirements in place, we have
% \begin{verbatim}
% \[
% \lim_{a\ndownarrow 0} f(a) \neq \bigtimes_n X_n \qquad
% \frac{ \bigtimes_{k=1}^7 B_k \nuparrow \Omega }{2}
% \]
% \end{verbatim}
% \[
% \lim_{a\ndownarrow 0} f(a) \neq \bigtimes_n X_n \qquad
% \frac{ \bigtimes_{k=1}^7 B_k \nuparrow \Omega }{2}
% \]
%
%
%
%
% \section{A tribute to Michael J.~Downes}
%
% Michael J.~Downes (1958--2003) was one of the major architects
% behind \pkg{amsmath} and member of the \LaTeX{} Team. He made many
% great contributions to the \TeX{} community; not only by the means
% of widely spread macro packages such as \pkg{amsmath} but also in
% the form of actively giving advice on newsgroups. Some of
% Michael's macro solutions on the newsgroups never made it into
% publicly available macro packages although they certainly deserved
% it, so \pkg{mathtools} tries to rectify this matter. The macros
% described in this section are either straight copies or heavily
% inspired by his original postings.
%
% \subsection{Mathematics within italic text}
%
% \begin{codesyntax}
% \SpecialKeyIndex{mathic}$\key{mathic}=\texttt{true}\vert\texttt{false}$
% \end{codesyntax}
% \cttPosting{Michael J.~Downes}{1998/05/14}
% \TeX{} usually takes care of italic corrections in text, but fails
% when it comes to math. If you use the \LaTeX{} inline math
% commands \cs{(} and \cs{)} you can however work around it by
% setting the key \key{mathic} to true as shown below.
% \begin{verbatim}
% \begin{quote}\itshape
% Compare these lines: \par
% \mathtoolsset{mathic} % or \mathtoolsset{mathic=true}
% Subset of \(V\) and subset of \(A\). \par
% \mathtoolsset{mathic=false}
% Subset of \(V\) and subset of \(A\).
% \par
% \end{quote}
% \end{verbatim}
% \begin{quote}\itshape
% Compare these lines: \par
% \mathtoolsset{mathic}
% Subset of \(V\) and subset of \(A\). \par
% \mathtoolsset{mathic=false}
% Subset of \(V\) and subset of \(A\).
% \par
% \end{quote}
% \noindent
% As of 2013, \cs(\cs) are robust, as is the italic corrected versions.
%
% \medskip\noindent \textbf{Caveat:} Italic correction is a
% treacherous area. For example any penalties will cancel the italic
% correction inserted by \verb|\(| (for an explanation see
% \cite{TBT}, section 4.3.3). We have changed Michaels original to
% accomodate one specific penalty construction: the \emph{tie}, i.e.,
% >>\verb|text~\(|<< will work as expected (as~of July, 2014).
%
% \subsection{Left sub/superscripts}
%
% \begin{codesyntax}
% \SpecialUsageIndex{\prescript}
% \cs{prescript}\marg{sup}\marg{sub}\marg{arg}\texttt{~~}
% \SpecialKeyIndex{prescript-sup-format}
% $\key{prescript-sup-format}=\meta{cmd}$\\
% \SpecialKeyIndex{prescript-sub-format}
% $\key{prescript-sub-format}=\meta{cmd}$\hfill
% \SpecialKeyIndex{prescript-arg-format}
% \rlap{$\key{prescript-arg-format}=\meta{cmd}$}^^A
% \phantom{$\key{prescript-sup-format}=\meta{cmd}$}
% \end{codesyntax}
% \cttPosting{Michael J.~Downes}{2000/12/20}
% Sometimes one wants to put a sub- or superscript on the left of
% the argument. The \cs{prescript} command does just that:
% \begin{verbatim}
% \[
% {}^{4}_{12}\mathbf{C}^{5+}_{2} \quad
% \prescript{14}{2}{\mathbf{C}}^{5+}_{2} \quad
% \prescript{4}{12}{\mathbf{C}}^{5+}_{2} \quad
% \prescript{14}{}{\mathbf{C}}^{5+}_{2} \quad
% \prescript{}{2}{\mathbf{C}}^{5+}_{2}
% \]
% \end{verbatim}
% \[
% {}^{4}_{12}\mathbf{C}^{5+}_{2} \quad
% \prescript{14}{2}{\mathbf{C}}^{5+}_{2} \quad
% \prescript{4}{12}{\mathbf{C}}^{5+}_{2} \quad
% \prescript{14}{}{\mathbf{C}}^{5+}_{2} \quad
% \prescript{}{2}{\mathbf{C}}^{5+}_{2}
% \]
%
% The formatting of the arguments is controlled by three keys. This
% silly example shows you how to use them:
% \begin{verbatim}
% \newcommand*\myisotope[3]{%
% \begingroup % to keep changes local. We cannot use a brace group
% % as it affects spacing!
% \mathtoolsset{
% prescript-sup-format=\mathit,
% prescript-sub-format=\mathbf,
% prescript-arg-format=\mathrm,
% }%
% \prescript{#1}{#2}{#3}%
% \endgroup
% }
% \[
% \myisotope{A}{Z}{X}\to \myisotope{A-4}{Z-2}{Y}+
% \myisotope{4}{2}{\alpha}
% \]
% \end{verbatim}
% \newcommand*\myisotope[3]{%
% \begingroup
% \mathtoolsset{
% prescript-sup-format=\mathit,
% prescript-sub-format=\mathbf,
% prescript-arg-format=\mathrm,
% }%
% \prescript{#1}{#2}{#3}%
% \endgroup
% }
% \[
% \myisotope{A}{Z}{X}\to \myisotope{A-4}{Z-2}{Y}+
% \myisotope{4}{2}{\alpha}
% \]
% (Though a package like \pkg{mhchem} might be more suitable for this
% type of material.)
%
% \subsection{Declaring math sizes}
%
% \begin{codesyntax}
% \SpecialUsageIndex{\DeclareMathSizes}
% \cs{DeclareMathSizes}\marg{dimen}\marg{dimen}\marg{dimen}\marg{dimen}
% \end{codesyntax}
% \cttPosting{Michael J.~Downes}{2002/10/17}
% If you don't know about \cs{DeclareMathSizes}, then skip the rest
% of this text. If you do know, then all that is needed to say is
% that with \pkg{mathtools} it is patched so that all regular
% dimension suffixes are now valid in the last three arguments. Thus
% a declaration such as
% \begin{verbatim}
% \DeclareMathSize{9.5dd}{9.5dd}{7.5dd}{6.5dd}
% \end{verbatim}
% will now work (it doesn't in standard \LaTeX). When this bug has
% been fixed in \LaTeX, this fix will be removed from
% \pkg{mathtools}.
%
% The \CommentAdded{2015/11/12} fix was added to the \LaTeX{} kernel i 2015. We will continue to
% provide it on older kernels.
%
% \subsection{Spreading equations}\label{sec:spread}
%
% \begin{codesyntax}
% \SpecialEnvIndex{spreadlines}
% \cs{begin}\arg{spreadlines}\marg{dimen} \meta{contents}
% \cs{end}\arg{spreadlines}
% \end{codesyntax}
% \cttPosting{Michael J.~Downes}{2002/10/17}
% The spacing between lines in a multiline math environment such as
% \env{gather} is governed by the dimension \cs{jot}. The
% \env{spreadlines} environment takes one argument denoting the
% value of \cs{jot} inside the environment:
% \begin{verbatim}
% \begin{spreadlines}{20pt}
% Large spaces between the lines.
% \begin{gather}
% a=b\\
% c=d
% \end{gather}
% \end{spreadlines}
% Back to normal spacing.
% \begin{gather}
% a=b\\
% c=d
% \end{gather}
% \end{verbatim}
% \begin{spreadlines}{20pt}
% Large spaces between the lines.
% \begin{gather}
% a=b\\
% c=d
% \end{gather}
% \end{spreadlines}
% Back to normal spacing.
% \begin{gather}
% a=b\\
% c=d
% \end{gather}
%
%
% \subsection{Gathered environments}\label{subsec:gathered}
%
% \begin{codesyntax}
% \SpecialEnvIndex{lgathered}\cs{begin}\arg{lgathered}\oarg{pos}
% \meta{contents} \cs{end}\arg{lgathered} \\
% \SpecialEnvIndex{rgathered}\cs{begin}\arg{rgathered}\oarg{pos}
% \meta{contents} \cs{end}\arg{rgathered} \\
% \SpecialUsageIndex{\newgathered}\cs{newgathered}\marg{name}\marg{pre_line}\marg{post_line}\marg{after}\\
% \SpecialUsageIndex{\renewgathered}\cs{renewgathered}\marg{name}\marg{pre_line}\marg{post_line}\marg{after}
% \end{codesyntax}
% \cttPosting{Michael J.~Downes}{2001/01/17}
% In a document set in \opt{fleqn}, you might sometimes want an
% inner \env{gathered} environment that doesn't center its lines but
% puts them flush left. The \env{lgathered} environment works just
% like the standard \env{gathered} except that it flushes its
% contents left:
% \begin{verbatim}
% \begin{equation}
% \begin{lgathered}
% x=1,\quad x+1=2 \\
% y=2
% \end{lgathered}
% \end{equation}
% \end{verbatim}
% \begin{equation}
% \begin{lgathered}
% x=1,\quad x+1=2 \\
% y=2
% \end{lgathered}
% \end{equation}
% Similarly the \env{rgathered} puts it contents flush right.
%
% More interesting is probably the command \cs{newgathered}. In this
% example we define a gathered version that centers the lines and
% also prints a star and a number at the left of each line.
% \begin{verbatim}
% \newcounter{steplinecnt}
% \newcommand\stepline{\stepcounter{steplinecnt}\thesteplinecnt}
% \newgathered{stargathered}
% {\llap{\stepline}$*$\quad\hfil}% \hfil for centering
% {\hfil}% \hfil for centering
% {\setcounter{steplinecnt}{0}}% reset counter
% \end{verbatim}
% \newcounter{steplinecnt}
% \newcommand\stepline{\stepcounter{steplinecnt}\thesteplinecnt}
% \newgathered{stargathered}{\llap{\stepline}$*$\quad\hfil}{\hfil}{\setcounter{steplinecnt}{0}}
% With these definitions we can get something like this:
% \begin{verbatim}
% \begin{gather}
% \begin{stargathered}
% x=1,\quad x+1=2 \\
% y=2
% \end{stargathered}
% \end{gather}
% \end{verbatim}
% \begin{gather}
% \begin{stargathered}
% x=1,\quad x+1=2 \\
% y=2
% \end{stargathered}
% \end{gather}
% \cs{renewgathered} renews a gathered environment of course.
%
% In all fairness it should be stated that the original concept by
% Michael has been extended quite a bit in \pkg{mathtools}. Only the
% end product of \env{lgathered} is the same.
%
% \subsection{Split fractions}
%
% \begin{codesyntax}
% \SpecialUsageIndex{\splitfrac}\cs{splitfrac}\marg{numer}\marg{denom}\texttt{~~}
% \SpecialUsageIndex{\splitdfrac}\cs{splitdfrac}\marg{numer}\marg{denom}
% \end{codesyntax}
% \cttPosting{Michael J.~Downes}{2001/12/06}
% These commands provide split fractions e.g., multiline fractions:
% \begin{verbatim}
% \[
% a=\frac{
% \splitfrac{xy + xy + xy + xy + xy}
% {+ xy + xy + xy + xy}
% }
% {z}
% =\frac{
% \splitdfrac{xy + xy + xy + xy + xy}
% {+ xy + xy + xy + xy}
% }
% {z}
% \]
% \end{verbatim}
% \[
% a=\frac{
% \splitfrac{xy + xy + xy + xy + xy}
% {+ xy + xy + xy + xy}
% }
% {z}
% =\frac{
% \splitdfrac{xy + xy + xy + xy + xy}
% {+ xy + xy + xy + xy}
% }
% {z}
% \]
%
%
%
%
%
%
%
%
%
%
%
%
%
%
%
%
%
%
%
%
%
%
%
%
%
%
%
%
%
%
%
%
%
%
%
%
%
%
%
%
%
%
%
%
%
%
%
%
%
%
%
%
%
%
%
%
%
%
%
%
%
%
%
%
%
%
%
%
%
%
%
%
%
%
%
%
%
%
%
%
%
%
%
%
%
% \begin{thebibliography}{9}
% \bibitem{Perlis01}
% Alexander R. Perlis,
% \emph{A complement to \cs{smash}, \cs{llap}, and \cs{rlap}},
% TUGboat 22(4) (2001).
% \bibitem{Ams99}
% American Mathematical Society and Michael Downes,
% \emph{Technical notes on the \pkg{amsmath} package} Version 2.0,
% 1999/10/29.
% (Available from CTAN as file \texttt{technote.tex}.)
% \bibitem{Ams00}
% Frank Mittelbach, Rainer Sch\"opf, Michael Downes, and David M.~Jones,
% \emph{The \pkg{amsmath} package} Version 2.13,
% 2000/07/18.
% (Available from CTAN as file \texttt{amsmath.dtx}.)
% \bibitem{A-W:MG04}
% Frank Mittelbach and Michel Goossens.
% \emph{The {\LaTeX} Companion}.
% Tools and Techniques for Computer Typesetting. Addison-Wesley,
% Boston, Massachusetts, 2 edition, 2004.
% With Johannes Braams, David Carlisle, and Chris Rowley.
%
% \bibitem{Carl99}
% David Carlisle,
% \emph{The \pkg{keyval} Package},
% Version 1.13, 1999/03/16.
% (Available from CTAN as file \texttt{keyval.dtx}.)
%
% \bibitem{Voss:2004}
% Herbert Vo\ss,
% \emph{Math mode}, Version 1.71,
% 2004/07/06.
% (Available from CTAN as file \texttt{Voss-Mathmode.pdf}.)
%
% \bibitem{Swanson}
% Ellen Swanson,
% \emph{Mathematics into type}.
% American Mathematical Society, updated edition, 1999.
% Updated by Arlene O'Sean and Antoinette Schleyer.
% \bibitem{TBT}
% Victor Eijkhout, \emph{\TeX\ by Topic, A Texnician’s Reference}, 2007.
% Freely available at \url{http://ctan.org/tex-archive/info/texbytopic}.
% \end{thebibliography}
%
%
% \StopEventually{}
%
%
% \section{Options and package loading}
%
%
% Lets start the package.
% \begin{macrocode}
%<*package>
\ProvidesPackage{mathtools}%
[2018/01/08 v1.21 mathematical typesetting tools]
% \end{macrocode}
% \changes{v1.10}{2011/02/12}{Might as well make sure that we need the
% latest version of \texttt{mhsetup}}
% \begin{macrocode}
\RequirePackage{keyval,calc}
\RequirePackage{mhsetup}[2017/03/31]
\MHInternalSyntaxOn
% \end{macrocode}
% \changes{v1.13}{2013/02/11}{Robustifying \cs{(}\cs{)}\cs{[}\cs{]}}
% We'd like to make \cs{(}\cs{)} and \cs{[}\cs{]} robust. This can
% easily be done via the \pkg{fixltx2e} package, but auto loading that
% package may cause problems for some. We make copies instead.
% \begin{macro}{\EQ_MakeRobust}
% \begin{macro}{\forced_EQ_MakeRobust}
% \begin{macrocode}
% borrowed from fixltx2e
\def\EQ_MakeRobust#1{%
\@ifundefined{\expandafter\@gobble\string#1}{%
\@latex@error{The control sequence `\string#1' is undefined!%
\MessageBreak There is nothing here to make robust}%
\@eha
}%
{%
\@ifundefined{\expandafter\@gobble\string#1\space}%
{%
\expandafter\let\csname
\expandafter\@gobble\string#1\space\endcsname=#1%
\edef\reserved@a{\string#1}%
\def\reserved@b{#1}%
\edef\reserved@b{\expandafter\strip@prefix\meaning\reserved@b}%
\edef#1{%
\ifx\reserved@a\reserved@b
\noexpand\x@protect\noexpand#1%
\fi
\noexpand\protect\expandafter\noexpand
\csname\expandafter\@gobble\string#1\space\endcsname}%
}%
{\@latex@info{The control sequence `\string#1' is already robust}}%
}%
}
% \end{macrocode}
% We also provide a handy alternativ version, that will robustify no
% matter what. Useful for the \texttt{mathic} option.
% \begin{macrocode}
\def\forced_EQ_MakeRobust#1{%
\@ifundefined{\expandafter\@gobble\string#1}{%
\@latex@error{The control sequence `\string#1' is undefined!%
\MessageBreak There is nothing here to make robust}%
\@eha
}%
{%
% \@ifundefined{\expandafter\@gobble\string#1\space}%
% {%
\expandafter\let\csname
\expandafter\@gobble\string#1\space\endcsname=#1%
\edef\reserved@a{\string#1}%
\def\reserved@b{#1}%
\edef\reserved@b{\expandafter\strip@prefix\meaning\reserved@b}%
\edef#1{%
\ifx\reserved@a\reserved@b
\noexpand\x@protect\noexpand#1%
\fi
\noexpand\protect\expandafter\noexpand
\csname\expandafter\@gobble\string#1\space\endcsname}%
% }%
% {\@latex@info{The control sequence `\string#1' is already robust}}%
}%
}
% \end{macrocode}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\MT_options_name:}
% \begin{macro}{\mathtoolsset}
% The name for the options and a user interface for setting keys.
% \begin{macrocode}
\def\MT_options_name:{mathtools}
\newcommand*\mathtoolsset[1]{\setkeys{\MT_options_name:}{#1}}
% \end{macrocode}
% \end{macro}
% \end{macro}
%
% Fix \pkg{amsmath} bugs (strongly recommended!). It requires a
% great deal of typing to avoid fixing the bugs. He he.
% \begin{macrocode}
\MH_new_boolean:n {fixamsmath}
\DeclareOption{fixamsmath}{
\MH_set_boolean_T:n {fixamsmath}
}
\DeclareOption{donotfixamsmathbugs}{
\MH_set_boolean_F:n {fixamsmath}
}
% \end{macrocode}
% Disallow spaces before optional arguments in certain \pkg{amsmath}
% building blocks.
% \begin{macrocode}
\DeclareOption{allowspaces}{
\MH_let:NwN \MaybeMHPrecedingSpacesOff
\relax
\MH_let:NwN \MH_maybe_nospace_ifnextchar:Nnn \kernel@ifnextchar
}
\DeclareOption{disallowspaces}{
\MH_let:NwN \MaybeMHPrecedingSpacesOff
\MHPrecedingSpacesOff
\MH_let:NwN \MH_maybe_nospace_ifnextchar:Nnn \MH_nospace_ifnextchar:Nnn
}
% \end{macrocode}
% \changes{v1.13}{2013/02/11}{Option to disable robustifying
% \cs{(}\cs{)} and \cs{[}\cs{]}}
% Option to disallow robustifying \cs{(}\cs{)} and \cs{[}\cs{]}.
% \begin{macrocode}
\MH_new_boolean:n {robustify}
\MH_set_boolean_T:n {robustify}
\DeclareOption{nonrobust}{
\MH_set_boolean_F:n {robustify}
}
% \end{macrocode}
% Pass all other options directly to \pkg{amsmath}.
% \begin{macrocode}
\DeclareOption*{
\PassOptionsToPackage{\CurrentOption}{amsmath}
}
% \end{macrocode}
% Executing options
% \begin{macrocode}
\ExecuteOptions{fixamsmath,disallowspaces}
\ProcessOptions\relax
% \end{macrocode}
% We have to turn off the new syntax when \pkg{amstext} is loaded.
% \begin{macrocode}
\MHInternalSyntaxOff
\RequirePackage{amsmath}[2016/11/05]
\MHInternalSyntaxOn
\AtEndOfPackage{\MHInternalSyntaxOff}
% \end{macrocode}
% \begin{macro}{\MT_true_false_error:}
% Make sure the user selects either `true' or `false' when asked too.
% \begin{macrocode}
\def\MT_true_false_error:{
\PackageError{mathtools}
{You~ have~ to~ select~ either~ `true'~ or~ `false'}
{I'll~ assume~ you~ chose~ `false'~ for~ now.}
}
% \end{macrocode}
% \end{macro}
% \changes{v1.13}{2013/02/11}{Make \cs{(}\cs{)} and \cs{[}\cs{]}
% robust}
% We start of with making \cs{(}\cs{)} and \cs{[}\cs{]} robust,
% unless the user explicitly asked us not to.
% \begin{macrocode}
\MH_if_boolean:nT {robustify}{
\EQ_MakeRobust\(
\EQ_MakeRobust\)
\EQ_MakeRobust\[
\EQ_MakeRobust\]
}
% \end{macrocode}
%
%
% \section{Macros I got ideas for myself}
%
%
%
% \subsection{Tag forms}
% This is quite simple, but why isn't it then a part of some widely
% distributed package? Beats me.
%
% \begin{macro}{\MT_define_tagform:nwnn}
% We start out by defining a command that will allow us to define
% commands similar to \cs{tagform@} only this will give us tag form
% \emph{types}. The actual code is very similar to the one in
% \pkg{amsmath}.
% \begin{macrocode}
\def\MT_define_tagform:nwnn #1[#2]#3#4{
\@namedef{MT_tagform_#1:n}##1
{\maketag@@@{#3\ignorespaces#2{##1}\unskip\@@italiccorr#4}}
}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\newtagform}
% Similar to \cs{newcommand}. Check if defined and scan for presence
% of optional argument. Then call generic command.
% \begin{macrocode}
\providecommand*\newtagform[1]{%
\@ifundefined{MT_tagform_#1:n}
{\@ifnextchar[%
{\MT_define_tagform:nwnn #1}%
{\MT_define_tagform:nwnn #1[]}%
}{\PackageError{mathtools}
{The~ tag~ form~ `#1'~ is~ already~ defined\MessageBreak
You~ probably~ want~ to~ look~ up~ \@backslashchar renewtagform~
instead}
{I~ will~ just~ ignore~ your~ wish~ for~ now.}}
}
% \end{macrocode}
% Provide a default tag form which---surprise, surprise---is
% identical to the standard definition.
% \begin{macrocode}
\newtagform{default}{(}{)}
% \end{macrocode}
% \end{macro}
% \begin{macro}{\renewtagform}
% Similar to \cs{renewcommand}.
% \begin{macrocode}
\providecommand*\renewtagform[1]{%
\@ifundefined{MT_tagform_#1:n}
{\PackageError{mathtools}
{The~ tag~ form~ `#1'~ is~ not~ defined\MessageBreak
You~ probably~ want~ to~ look~ up~ \@backslashchar newtagform~ instead}
{I~ will~ just~ ignore~ your~ wish~ for~ now.}}
{\@ifnextchar[%
{\MT_define_tagform:nwnn #1}%
{\MT_define_tagform:nwnn #1[]}%
}
}
% \end{macrocode}
% \end{macro}
% \begin{macro}{\usetagform}
% Then the activator. Test if the tag form is defined and then
% activate it by redefining \cs{tagform@}.
% \begin{macrocode}
\providecommand*\usetagform[1]{%
\@ifundefined{MT_tagform_#1:n}
{
\PackageError{mathtools}{%
You~ have~ chosen~ the~ tag~ form~ `#1'\MessageBreak
but~ it~ appears~ to~ be~ undefined}
{I~ will~ use~ the~ default~ tag~ form~ instead.}%
\@namedef{tagform@}{\@nameuse{MT_tagform_default:n}}
}
{ \@namedef{tagform@}{\@nameuse{MT_tagform_#1:n}} }
% \end{macrocode}
% Here we patch if we're using the special ``show only referenced
% equations'' feature.
% \begin{macrocode}
\MH_if_boolean:nT {show_only_refs}{
\MH_let:NwN \MT_prev_tagform:n \tagform@
\def\tagform@##1{\MT_extended_tagform:n {##1}}
}
}
% \end{macrocode}
% \end{macro}
%
% \subsubsection{Showing only referenced tags}
% A little more interesting is the way to print only the equation
% numbers that are actually referenced.
%
% A few booleans to help determine which situations we're in.
% \begin{macrocode}
\MH_new_boolean:n {manual_tag}
\MH_new_boolean:n {raw_maketag}
% \end{macrocode}
% \begin{macro}{\MT_AmS_tag_in_align:}
% \begin{macro}{\tag@in@align}
% \begin{macro}{\tag@in@display}
% We'll need to know when the user has put in a manual tag, and since
% \cs{tag} is \cs{let} to all sorts of things inside the \pkg{amsmath}
% code it is safer to provide a small hack to the functions it is copied
% from. Note that we can't use \cs{iftag@}.
% \begin{macrocode}
\MH_let:NwN \MT_AmS_tag_in_align: \tag@in@align
\def\tag@in@align{
\global\MH_set_boolean_T:n {manual_tag}
\MT_AmS_tag_in_align:
}
\def\tag@in@display#1#{
\relax
\global\MH_set_boolean_T:n {manual_tag}
\tag@in@display@a{#1}
}
% \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\MT_extended_tagform:n}
% \changes{v1.01}{2004/08/03}{Simplified quite a bit}
% The extended version of \cs{tagform@}.
% \begin{macrocode}
\def\MT_extended_tagform:n #1{
\MH_set_boolean_F:n {raw_maketag}
% \end{macrocode}
% We test if the equation was labelled. We already know if it was
% tagged manually. Have to watch out for \TeX\ inserting a blank line
% so do not let the tag have width zero. Rememeber
% \cs{@safe@activestrue/false} in order to handle active chars in labels.
% \changes{v1.12}{2012/04/24}{Added \cs{@safe@activestrue/false}}
% \changes{v1.19}{2017/03/31}{Added MH\_ prefix}
% \begin{macrocode}
\MH_if_meaning:NN \df@label\@empty
\MH_if_boolean:nTF {manual_tag}% this was \MH_if_boolean:nT before
{ \MH_if_boolean:nTF {show_manual_tags}
{ \MT_prev_tagform:n {#1} }
{ \stepcounter{equation} }
}{\kern1sp}% this last {\kern1sp} is new.
\MH_else:
\MH_if_boolean:nTF {manual_tag}
{ \MH_if_boolean:nTF {show_manual_tags}
{ \MT_prev_tagform:n {#1} }
{ \@safe@activestrue
\@ifundefined{MT_r_\df@label}
% \end{macrocode}
% Next we need to remember to deactivate the manual tags switch. This
% is usually done using \verb|\MT_extended_maketag:n|, but this is not
% the case if the show manual tags is false and the manual tag is not
% referred to.
% \changes{v1.12}{2011/06/08}{Added the falsification of manual tag
% when show manual tags is off and maual tag is not referred to}
% \changes{v1.19}{2017/03/31}{Added MH\_ prefix}
% \begin{macrocode}
{ \global\MH_set_boolean_F:n {manual_tag} }
{ \MT_prev_tagform:n {#1} }
\@safe@activesfalse
}
}
{
\@safe@activestrue
\@ifundefined{MT_r_\df@label}
{ }
{ \refstepcounter{equation}\MT_prev_tagform:n {#1} }
\@safe@activesfalse
}
\MH_fi:
\global\MH_set_boolean_T:n {raw_maketag}
}
% \end{macrocode}
% \end{macro}
% \begin{macro}{\MT_extended_maketag:n}
% The extended version of \cs{maketag@@@}.
% \changes{v1.12}{2012/04/24}{Added \cs{@safe@activestrue/false}}
% \changes{v1.19}{2017/03/31}{Added MH\_ prefix}
% \begin{macrocode}
\def\MT_extended_maketag:n #1{
\ifx\df@label\@empty
\MT_maketag:n {#1}
\MH_else:
\MH_if_boolean:nTF {raw_maketag}
{
\MH_if_boolean:nTF {show_manual_tags}
{ \MT_maketag:n {#1} }
{ \@safe@activestrue
\@ifundefined{MT_r_\df@label}
{ }
{ \MT_maketag:n {#1} }
\@safe@activesfalse
}
}
{ \MT_maketag:n {#1} }
\MH_fi:
% \end{macrocode}
% As this function is always called we let it set the marker for a manual
% tag false when exiting (well actually not true, see above).
% \begin{macrocode}
\global\MH_set_boolean_F:n {manual_tag}
}
% \end{macrocode}
% \end{macro}
% \begin{macro}{\MT_extended_eqref:n}
% \changes{v1.01}{2004/08/03}{Make it robust}
% We let \cs{eqref} write the label to the \file{aux} file, which is
% read at the beginning of the next run. Then we print the equation
% number as usual.
% \changes{v1.14}{2013/03/07}{It was not really robust}
% \begin{macrocode}
\def\MT_extended_eqref:n #1{
\protected@write\@auxout{}
{\string\MT@newlabel{#1}}
% \end{macrocode}
% \changes{v1.16}{2015/05/11}{Fix bug in \cs{eqref} in \cs{text} vs. \textsf{showonlyrefs}}
% The manner in which \key{showonlyrefs} is implemented causes
% problems when \cs{eqref} is used within \cs{text}. The problem is
% that \cs{MT_prev_tagform:n} is used both in \cs{eqref} and within,
% say, \env{align}. Thus a test within \cs{MT_prev_tagform:n} fails
% for \cs{eqref}. We fix this by making sure we end up in the proper
% branch of the test, when \cs{MT_prev_tagform:n} is used to typeset \cs{eqref}.
% \begin{macrocode}
\textup{\let\df@label\@empty\MT_prev_tagform:n {\ref{#1}}}
}
\EQ_MakeRobust\MT_extended_eqref:n
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\refeq}
% \begin{macro}{\MT_extended_refeq:n}
% Similar to \cs{eqref} and \cs{MT_extended_eqref:n}.
% \begin{macrocode}
\newcommand*\refeq[1]{
\textup{\ref{#1}}
}
\def\MT_extended_refeq:n #1{
\protected@write\@auxout{}
{\string\MT@newlabel{#1}}
\textup{\ref{#1}}
}
% \end{macrocode}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\MT@newlabel}
% We can't use |:| or |_| in the command name (yet). We define the
% special labels for the equations that have been referenced in the
% previous run.
% \begin{macrocode}
\newcommand*\MT@newlabel[1]{ \global\@namedef{MT_r_#1}{} }
% \end{macrocode}
% \end{macro}
% \changes{v1.19}{2017/03/31}{Added MH\_ prefix}
% \begin{macrocode}
\MH_new_boolean:n {show_only_refs}
\MH_new_boolean:n {show_manual_tags}
\define@key{\MT_options_name:}{showmanualtags}[true]{
\@ifundefined{MH_boolean_show_manual_tags_#1:}
{ \MT_true_false_error:
\@nameuse{MH_boolean_show_manual_tags_false:}
}
{ \@nameuse{MH_boolean_show_manual_tags_#1:} }
}
% \end{macrocode}
% \begin{macro}{\MT_showonlyrefs_true:}
% The implementation is based on the idea that \cs{tagform@} can be
% called in two circumstances: when the tag is being printed in the
% equation and when it is being printed during a reference.
% \begin{macrocode}
\newcommand*\MT_showonlyrefs_true:{
\MH_if_boolean:nF {show_only_refs}{
\MH_set_boolean_T:n {show_only_refs}
% \end{macrocode}
% Save the definitions of the original commands.
% \begin{macrocode}
\MH_let:NwN \MT_incr_eqnum: \incr@eqnum
\MH_let:NwN \incr@eqnum \@empty
\MH_let:NwN \MT_array_parbox_restore: \@arrayparboxrestore
\@xp\def\@xp\@arrayparboxrestore\@xp{\@arrayparboxrestore
\MH_let:NwN \incr@eqnum \@empty
}
\MH_let:NwN \MT_prev_tagform:n \tagform@
\MH_let:NwN \MT_eqref:n \eqref
\MH_let:NwN \MT_refeq:n \refeq
\MH_let:NwN \MT_maketag:n \maketag@@@
\MH_let:NwN \maketag@@@ \MT_extended_maketag:n
% \end{macrocode}
% We redefine \cs{tagform@}.
% \begin{macrocode}
\def\tagform@##1{\MT_extended_tagform:n {##1}}
% \end{macrocode}
% Then \cs{eqref}:
% \begin{macrocode}
\MH_let:NwN \eqref \MT_extended_eqref:n
\MH_let:NwN \refeq \MT_extended_refeq:n
}
}
% \end{macrocode}
% \end{macro}
% \begin{macro}{\MT_showonlyrefs_false:}
% This macro reverts the settings.
% \begin{macrocode}
\def\MT_showonlyrefs_false: {
\MH_if_boolean:nT {show_only_refs}{
\MH_set_boolean_F:n {show_only_refs}
\MH_let:NwN \tagform@ \MT_prev_tagform:n
\MH_let:NwN \eqref \MT_eqref:n
\MH_let:NwN \refeq \MT_refeq:n
\MH_let:NwN \maketag@@@ \MT_maketag:n
\MH_let:NwN \incr@eqnum \MT_incr_eqnum:
\MH_let:NwN \@arrayparboxrestore \MT_array_parbox_restore:
}
}
\define@key{\MT_options_name:}{showonlyrefs}[true]{
\@nameuse{MT_showonlyrefs_#1:}
}
% \end{macrocode}
% \end{macro}
%
%
% \begin{macro}{\nonumber}
% \changes{v1.01}{2004/08/03}{Fixed using \cs{notag} or \cs{nonumber}
% with the \key{showonlyrefs} feature}
% We have to redefine \cs{nonumber} else it will subtract one from the
% equation number where we don't want it. This is probably not needed
% since \cs{nonumber} is unnecessary when \key{showonlyrefs} is in
% effect, but now you can use it with old documents as well.
% \changes{v1.19}{2017/03/31}{Added MH\_ prefix}
% \begin{macrocode}
\renewcommand\nonumber{
\if@eqnsw
\MH_if_meaning:NN \incr@eqnum\@empty
% \end{macrocode}
% Only subtract the number if |show_only_refs| is false.
% \changes{v1.19}{2017/03/31}{Added MH\_ prefix}
% \begin{macrocode}
\MH_if_boolean:nF {show_only_refs}
{\addtocounter{equation}\m@ne}
\MH_fi:
\MH_fi:
\MH_let:NwN \print@eqnum\@empty \MH_let:NwN \incr@eqnum\@empty
\global\@eqnswfalse
}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\noeqref}
% \changes{v1.04}{2008/03/26}{Added \cs{noeqref} (daleif)}
% \changes{v1.12}{2012/04/20}{Labels containing active chars (babel)
% are now allowed}
% \changes{v1.12}{2012/04/24}{\cs{noeqref} will now make a reference
% warning if users use undefined labels in \cs{noeqref}, requested
% by Tue Christensen}
% Macro for adding numbers to non-referred equations. Syntax similar
% to \cs{nocite}.
% \begin{macrocode}
\MHInternalSyntaxOff
\newcommand\noeqref[1]{\@bsphack%
\@for\@tempa:=#1\do{%
\@safe@activestrue%
\edef\@tempa{\expandafter\@firstofone\@tempa}%
\@ifundefined{r@\@tempa}{%
\protect\G@refundefinedtrue%
\@latex@warning{Reference `\@tempa' on page \thepage \space
undefined (\string\noeqref)}%
}{}%
\if@filesw\protected@write\@auxout{}%
{\string\MT@newlabel{\@tempa}}\fi%
\@safe@activesfalse}%
\@esphack}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\@safe@activestrue}
% \begin{macro}{\@safe@activesfalse}
% These macros are provided by babel. We \emph{provide} them here,
% just to make sure they exist.
% \begin{macrocode}
\providecommand\@safe@activestrue{}%
\providecommand\@safe@activesfalse{}%
\MHInternalSyntaxOn
% \end{macrocode}
%
% \end{macro}
% \end{macro}
%
% \subsection{Extensible arrows etc.}
%
% \begin{macro}{\xleftrightarrow}
% \begin{macro}{\MT_leftrightarrow_fill:}
% \begin{macro}{\xLeftarrow}
% \begin{macro}{\xRightarrow}
% \begin{macro}{\xLeftrightarrow}
%
% These are straight adaptions from \pkg{amsmath}.
% \begin{macrocode}
\providecommand*\xleftrightarrow[2][]{%
\ext@arrow 3095\MT_leftrightarrow_fill:{#1}{#2}}
\def\MT_leftrightarrow_fill:{%
\arrowfill@\leftarrow\relbar\rightarrow}
\providecommand*\xLeftarrow[2][]{%
\ext@arrow 0055{\Leftarrowfill@}{#1}{#2}}
\providecommand*\xRightarrow[2][]{%
\ext@arrow 0055{\Rightarrowfill@}{#1}{#2}}
\providecommand*\xLeftrightarrow[2][]{%
\ext@arrow 0055{\Leftrightarrowfill@}{#1}{#2}}
% \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \begin{macro}{\MT_rightharpoondown_fill:}
% \begin{macro}{\MT_rightharpoonup_fill:}
% \begin{macro}{\MT_leftharpoondown_fill:}
% \begin{macro}{\MT_leftharpoonup_fill:}
% \begin{macro}{\xrightharpoondown}
% \begin{macro}{\xrightharpoonup}
% \begin{macro}{\xleftharpoondown}
% \begin{macro}{\xleftharpoonup}
% \begin{macro}{\xleftrightharpoons}
% \begin{macro}{\xrightleftharpoons}
% The harpoons.
% \begin{macrocode}
\def\MT_rightharpoondown_fill:{%
\arrowfill@\relbar\relbar\rightharpoondown}
\def\MT_rightharpoonup_fill:{%
\arrowfill@\relbar\relbar\rightharpoonup}
\def\MT_leftharpoondown_fill:{%
\arrowfill@\leftharpoondown\relbar\relbar}
\def\MT_leftharpoonup_fill:{%
\arrowfill@\leftharpoonup\relbar\relbar}
\providecommand*\xrightharpoondown[2][]{%
\ext@arrow 0359\MT_rightharpoondown_fill:{#1}{#2}}
\providecommand*\xrightharpoonup[2][]{%
\ext@arrow 0359\MT_rightharpoonup_fill:{#1}{#2}}
\providecommand*\xleftharpoondown[2][]{%
\ext@arrow 3095\MT_leftharpoondown_fill:{#1}{#2}}
\providecommand*\xleftharpoonup[2][]{%
\ext@arrow 3095\MT_leftharpoonup_fill:{#1}{#2}}
\providecommand*\xleftrightharpoons[2][]{\mathrel{%
\raise.22ex\hbox{%
$\ext@arrow 3095\MT_leftharpoonup_fill:{\phantom{#1}}{#2}$}%
\setbox0=\hbox{%
$\ext@arrow 0359\MT_rightharpoondown_fill:{#1}{\phantom{#2}}$}%
\kern-\wd0 \lower.22ex\box0}}
\providecommand*\xrightleftharpoons[2][]{\mathrel{%
\raise.22ex\hbox{%
$\ext@arrow 0359\MT_rightharpoonup_fill:{\phantom{#1}}{#2}$}%
\setbox0=\hbox{%
$\ext@arrow 3095\MT_leftharpoondown_fill:{#1}{\phantom{#2}}$}%
\kern-\wd0 \lower.22ex\box0}}
% \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \begin{macro}{\xhookleftarrow}
% \begin{macro}{\xhookrightarrow}
% \begin{macro}{\MT_hookright_fill:}
% The hooks.
% \begin{macrocode}
\providecommand*\xhookleftarrow[2][]{%
\ext@arrow 3095\MT_hookleft_fill:{#1}{#2}}
\def\MT_hookleft_fill:{%
\arrowfill@\leftarrow\relbar{\relbar\joinrel\rhook}}
\providecommand*\xhookrightarrow[2][]{%
\ext@arrow 3095\MT_hookright_fill:{#1}{#2}}
\def\MT_hookright_fill:{%
\arrowfill@{\lhook\joinrel\relbar}\relbar\rightarrow}
% \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
% \begin{macro}{\xmapsto}
% \begin{macro}{\MT_mapsto_fill:}
% The maps-to arrow.
% \begin{macrocode}
\providecommand*\xmapsto[2][]{%
\ext@arrow 0395\MT_mapsto_fill:{#1}{#2}}
\def\MT_mapsto_fill:{%
\arrowfill@{\mapstochar\relbar}\relbar\rightarrow}
% \end{macrocode}
% \end{macro}
% \end{macro}
% \subsection{Underbrackets etc.}
% \begin{macro}{\underbracket}
% \begin{macro}{\MT_underbracket_I:w}
% \begin{macro}{\MT_underbracket_II:w}
% \begin{macro}{\upbracketfill}
% \begin{macro}{\upbracketend}
% The \cs{underbracket} macro. Scan for two optional arguments. When
% \pkg{xparse} becomes the standard this will be so much easier.
% \begin{macrocode}
\providecommand*\underbracket{
\@ifnextchar[
{\MT_underbracket_I:w}
{\MT_underbracket_I:w[\l_MT_bracketheight_fdim]}}
\def\MT_underbracket_I:w[#1]{
\@ifnextchar[
{\MT_underbracket_II:w[#1]}
{\MT_underbracket_II:w[#1][.7\fontdimen5\textfont2]}}
\def\MT_underbracket_II:w[#1][#2]#3{%
\mathop{\vtop{\m@th\ialign{##
\crcr
$\hfil\displaystyle{#3}\hfil$%
\crcr
\noalign{\kern .2\fontdimen5\textfont2 \nointerlineskip}%
\upbracketfill {#1}{#2}%
\crcr}}}
\limits}
\def\upbracketfill#1#2{%
\sbox\z@{$\braceld$}
\edef\l_MT_bracketheight_fdim{\the\ht\z@}%
\upbracketend{#1}{#2}
\leaders \vrule \@height \z@ \@depth #1 \hfill
\upbracketend{#1}{#2}%
}
\def\upbracketend#1#2{\vrule \@height #2 \@width #1\relax}
% \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \begin{macro}{\overbracket}
% \begin{macro}{\MT_overbracket_I:w}
% \begin{macro}{\MT_overbracket_II:w}
% \begin{macro}{\downbracketfill}
% \begin{macro}{\downbracketend}
% The overbracket is quite similar.
% \begin{macrocode}
\providecommand*\overbracket{
\@ifnextchar[
{\MT_overbracket_I:w}
{\MT_overbracket_I:w[\l_MT_bracketheight_fdim]}}
\def\MT_overbracket_I:w[#1]{
\@ifnextchar[
{\MT_overbracket_II:w[#1]}
{\MT_overbracket_II:w[#1][.7\fontdimen5\textfont2]}}
\def\MT_overbracket_II:w[#1][#2]#3{%
\mathop{\vbox{\m@th\ialign{##
\crcr
\downbracketfill{#1}{#2}%
\crcr
\noalign{\kern .2\fontdimen5\textfont2 \nointerlineskip}%
$\hfil\displaystyle{#3}\hfil$
\crcr}}}%
\limits}
\def\downbracketfill#1#2{%
\sbox\z@{$\braceld$}\edef\l_MT_bracketheight_fdim{\the\ht\z@}
\downbracketend{#1}{#2}
\leaders \vrule \@height #1 \@depth \z@ \hfill
\downbracketend{#1}{#2}%
}
\def\downbracketend#1#2{\vrule \@width #1\@depth #2\relax}
% \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \begin{macro}{\LaTeXunderbrace}
% \begin{macro}{\underbrace}
% Redefinition of \cs{underbrace} and \cs{overbrace}.
% \begin{macrocode}
\MH_let:NwN \LaTeXunderbrace \underbrace
\def\underbrace#1{\mathop{\vtop{\m@th\ialign{##\crcr
$\hfil\displaystyle{#1}\hfil$\crcr
\noalign{\kern.7\fontdimen5\textfont2\nointerlineskip}%
% \end{macrocode}
% |.5\fontdimen5\textfont2| is the height of the tip of the brace.
% the remaining |.2\fontdimen5\textfont2| is for space between
% \begin{macrocode}
\upbracefill\crcr\noalign{\kern.5\fontdimen5\textfont2}}}}\limits}
% \end{macrocode}
% \end{macro}
% \end{macro}
% \begin{macro}{\LaTeXoverbrace}
% \begin{macro}{\overbrace}
% Same technique for \cs{overbrace}.
% \begin{macrocode}
\MH_let:NwN \LaTeXoverbrace \overbrace
\def\overbrace#1{\mathop{\vbox{\m@th\ialign{##\crcr
\noalign{\kern.5\fontdimen5\textfont2}%
% \end{macrocode}
% Adjust for tip height
% \begin{macrocode}
\downbracefill\crcr
\noalign{\kern.7\fontdimen5\textfont2\nointerlineskip}%
% \end{macrocode}
% |.5\fontdimen5\textfont2| is the height of the tip of the brace.
% The remaining |.2\fontdimen5\textfont2| is for space between
% \begin{macrocode}
$\hfil\displaystyle{#1}\hfil$\crcr}}}\limits}
% \end{macrocode}
% \end{macro}
% \end{macro}
%
%
%
%
%
% \subsection{Special symbols}
%
% \subsubsection{Command names for parentheses}
% \begin{macro}{\lparen}
% \begin{macro}{\rparen}
% Just an addition to the \LaTeXe\ kernel.
% \begin{macrocode}
\providecommand*\lparen{(}
\providecommand*\rparen{)}
% \end{macrocode}
% \end{macro}
% \end{macro}
% \subsubsection{Vertically centered colon}
%
% \begin{macro}{\vcentcolon}
% \begin{macro}{\ordinarycolon}
% \begin{macro}{\MT_active_colon_true:}
% \begin{macro}{\MT_active_colon_false:}
% This is from the hands of Donald Arseneau. Somehow it is not
% distributed, so I include it here. Here's the original text by
% Donald:
% \begin{verbatim}
% centercolon.sty Dec 7, 2000
% Donald Arseneau asnd@triumf.ca
% Public domain.
% Vertically center colon characters (:) in math mode.
% Particularly useful for $ a:=b$, and still correct for
% $f : x\to y$. May be used in any TeX.
% \end{verbatim}
%
% Slight change: the colon meaning is given only if \verb|centercolon|
% is explicitly requested (before it was always assigned even if : remained
% catcode 12). This allows better interaction with packages like babel
% that also make colon active.
% \begin{macrocode}
\def\vcentcolon{\mathrel{\mathop\ordinarycolon}}
\providecommand\ordinarycolon{:}
\begingroup
\catcode`\:=\active
\lowercase{\endgroup
\def\MT_activate_colon{%
\ifnum\mathcode`\:=32768\relax
\let\ordinarycolon= :%
\else
\mathchardef\ordinarycolon\mathcode`\: %
\fi
\let :\vcentcolon
}
}
% \end{macrocode}
% Option processing.
% The `false' branch can only be requested if the option has previously been set `true'.
% (By default neither are set.)
% \begin{macrocode}
\MH_new_boolean:n {center_colon}
\define@key{\MT_options_name:}{centercolon}[true]{
\@ifundefined{MT_active_colon_#1:}
{ \MT_true_false_error:n
\@nameuse{MT_active_colon_false:}
}
{ \@nameuse{MT_active_colon_#1:} }
}
\def\MT_active_colon_true: {
\MT_activate_colon
\MH_if_boolean:nF {center_colon}{
\MH_set_boolean_T:n {center_colon}
\edef\MT_active_colon_false:
{\mathcode`\noexpand\:=\the\mathcode`\:\relax}
\mathcode`\:=32768
}
}
% \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \begin{macro}{\dblcolon}
% \begin{macro}{\coloneqq}
% \begin{macro}{\Coloneqq}
% \begin{macro}{\coloneq}
% \begin{macro}{\Coloneq}
% \begin{macro}{\eqqcolon}
% \begin{macro}{\Eqqcolon}
% \begin{macro}{\eqcolon}
% \begin{macro}{\Eqcolon}
% \begin{macro}{\colonapprox}
% \begin{macro}{\Colonapprox}
% \begin{macro}{\colonsim}
% \begin{macro}{\Colonsim}
% This is just to simulate all the \cs{..colon..} symbols from
% \pkg{txfonts} and \pkg{pxfonts}.
% \changes{v1.08c}{2010/11/17}{Enclosed all in \cs{mathrel}}
% \changes{v1.18}{2015/11/12}{Moved the enclosing \cs{mathrel} to
% \cs{mkern}. This is a result of
% \url{http://chat.stackexchange.com/transcript/message/23630342#23630342} and \url{http://chat.stackexchange.com/transcript/message/25348032#25348032}}
% \begin{macrocode}
\AtBeginDocument{
\providecommand*\dblcolon{\vcentcolon\mathrel{\mkern-.9mu}\vcentcolon}
\providecommand*\coloneqq{\vcentcolon\mathrel{\mkern-1.2mu}=}
\providecommand*\Coloneqq{\dblcolon\mathrel{\mkern-1.2mu}=}
\providecommand*\coloneq{\vcentcolon\mathrel{\mkern-1.2mu}\mathrel{-}}
\providecommand*\Coloneq{\dblcolon\mathrel{\mkern-1.2mu}\mathrel{-}}
\providecommand*\eqqcolon{=\mathrel{\mkern-1.2mu}\vcentcolon}
\providecommand*\Eqqcolon{=\mathrel{\mkern-1.2mu}\dblcolon}
\providecommand*\eqcolon{\mathrel{-}\mathrel{\mkern-1.2mu}\vcentcolon}
\providecommand*\Eqcolon{\mathrel{-}\mathrel{\mkern-1.2mu}\dblcolon}
\providecommand*\colonapprox{\vcentcolon\mathrel{\mkern-1.2mu}\approx}
\providecommand*\Colonapprox{\dblcolon\mathrel{\mkern-1.2mu}\approx}
\providecommand*\colonsim{\vcentcolon\mathrel{\mkern-1.2mu}\sim}
\providecommand*\Colonsim{\dblcolon\mathrel{\mkern-1.2mu}\sim}
}
% \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
%
%
% \subsection{Multlined}
%
% \begin{macro}{\g_MT_multlinerow_int}
% \begin{macro}{\l_MT_multwidth_dim}
% Helpers.
% \begin{macrocode}
\let \AMS@math@cr@@ \math@cr@@
\MH_new_boolean:n {mult_firstline}
\MH_new_boolean:n {outer_mult}
\newcount\g_MT_multlinerow_int
\newdimen\l_MT_multwidth_dim
% \end{macrocode}
% \end{macro}
% \end{macro}
% \begin{macro}{\MT_test_for_tcb_other:nnnnn}
% This tests if the token(s) is/are equal to either t, c, or~b, or
% something entirely different.
% \changes{v1.19}{2017/03/31}{Added MH\_ prefix}
% \begin{macrocode}
\newcommand*\MT_test_for_tcb_other:nnnnn [1]{
\MH_if:w t#1\relax
\expandafter\MH_use_choice_i:nnnn
\MH_else:
\MH_if:w c#1\relax
\expandafter\expandafter\expandafter\MH_use_choice_ii:nnnn
\MH_else:
\MH_if:w b#1\relax
\expandafter\expandafter\expandafter
\expandafter\expandafter\expandafter\expandafter
\MH_use_choice_iii:nnnn
\MH_else:
\expandafter\expandafter\expandafter
\expandafter\expandafter\expandafter\expandafter
\MH_use_choice_iv:nnnn
\MH_fi:
\MH_fi:
\MH_fi:
}
% \end{macrocode}
% \end{macro}
% \begin{macro}{\MT_mult_invisible_line:}
% An invisible line.
% \textbf{BUG:} \cs{baselineskip} is zero inside an array or matrix,
% thus in those cases the line is \emph{not} invisible.
% \changes{v1.14}{2014/05/21}{Added -\cs{jot}}
% \changes{v1.19}{2017/05/24}{Removed -\cs{jot} again, do not
% remember why we added it in the first place}
% \begin{macrocode}
\def\MT_mult_invisible_line: {
\crcr
\global\MH_set_boolean_F:n {mult_firstline}
\hbox to \l_MT_multwidth_dim{}\crcr
\noalign{\vskip-\baselineskip \vskip-\normallineskip}
}
% \end{macrocode}
% \end{macro}
% \begin{macro}{\MT_mult_mathcr_atat:w}
% The normal \cs{math@cr@@} with our hooks.
% \changes{v1.19}{2017/03/31}{Added MH\_ prefix}
% \begin{macrocode}
\def\MT_mult_mathcr_atat:w [#1]{%
\MH_if_num:w 0=`{\MH_fi: \iffalse}\MH_fi:
\MH_if_boolean:nT {mult_firstline}{
\kern\l_MT_mult_left_fdim
\MT_mult_invisible_line:
}
\crcr
\noalign{\vskip#1\relax}
\global\advance\g_MT_multlinerow_int\@ne
\MH_if_num:w \g_MT_multlinerow_int=\l_MT_multline_lastline_fint
\MH_let:NwN \math@cr@@\MT_mult_last_mathcr:w
\MH_fi:
}
% \end{macrocode}
% \end{macro}
% \begin{macro}{\MT_mult_firstandlast_mathcr:w}
% The special case where there is a two-line \env{multlined}. We
% insert the first kern, then the invisible line of the desired
% width, the optional vertical space and then the last kern.
% \changes{v1.19}{2017/03/31}{Added MH\_ prefix}
% \begin{macrocode}
\def\MT_mult_firstandlast_mathcr:w [#1]{%
\MH_if_num:w 0=`{\MH_fi: \iffalse}\MH_fi:
\kern\l_MT_mult_left_fdim
\MT_mult_invisible_line:
\noalign{\vskip#1\relax}
\kern\l_MT_mult_right_fdim
}
% \end{macrocode}
% \end{macro}
% \begin{macro}{\MT_mult_last_mathcr:w}
% The normal last \cs{math@cr@@} which inserts the last kern.
% \changes{v1.19}{2017/03/31}{Added MH\_ prefix}
% \begin{macrocode}
\def\MT_mult_last_mathcr:w [#1]{
\MH_if_num:w 0=`{\MH_fi: \iffalse}\MH_fi:\math@cr@@@
\noalign{\vskip#1\relax}
\kern\l_MT_mult_right_fdim}
% \end{macrocode}
% \end{macro}
% \begin{macro}{\MT_start_mult:N}
% Setup for \env{multlined}. Finds the position.
% \begin{macrocode}
\newcommand\MT_start_mult:N [1]{
\MT_test_for_tcb_other:nnnnn {#1}
{ \MH_let:NwN \MT_next:\vtop }
{ \MH_let:NwN \MT_next:\vcenter }
{ \MH_let:NwN \MT_next:\vbox }
{
\PackageError{mathtools}
{Invalid~ position~ specifier.~ I'll~ try~ to~ recover~ with~
`c'}\@ehc
}
\collect@body\MT_mult_internal:n
}
% \end{macrocode}
% \end{macro}
% \begin{macro}{\MT_shoveright:wn}
% \begin{macro}{\MT_shoveleft:wn}
% Extended versions of \cs{shoveleft} and \cs{shoveright}.
% \begin{macrocode}
\newcommand*\MT_shoveright:wn [2][0pt]{%
#2\hfilneg
\setlength\@tempdima{#1}
\kern\@tempdima
}
\newcommand*\MT_shoveleft:wn [2][0pt]{%
\hfilneg
\setlength\@tempdima{#1}
\kern\@tempdima
#2
}
% \end{macrocode}
% \end{macro}
% \end{macro}
% \begin{macro}{\MT_mult_internal:n}
% \changes{v1.01a}{2004/10/10}{Added Ord atom to beginning of each line}
% The real internal \env{multlined}.
% \changes{v1.19}{2017/05/22}{Added \cs{alignedspace@left} instead of
% \cs{null}\cs{,}}
% \begin{macrocode}
\newcommand*\MT_mult_internal:n [1]{
\MH_if_boolean:nF {outer_mult}{\alignedspace@left} %<-- requires amsmath 2016/11/05
\MT_next:
\bgroup
% \end{macrocode}
% Restore the meaning of \cmd{\\} inside \env{multlined}, else it
% wouldn't work in the \env{equation} environment. Set the fake row
% counter to zero.
% \begin{macrocode}
\Let@
\def\l_MT_multline_lastline_fint{0 }
\chardef\dspbrk@context\@ne \restore@math@cr
% \end{macrocode}
% Use private versions.
% \begin{macrocode}
\MH_let:NwN \math@cr@@\MT_mult_mathcr_atat:w
\MH_let:NwN \shoveleft\MT_shoveleft:wn
\MH_let:NwN \shoveright\MT_shoveright:wn
\spread@equation
\MH_set_boolean_F:n {mult_firstline}
% \end{macrocode}
% Do some measuring.
% \begin{macrocode}
\MT_measure_mult:n {#1}
% \end{macrocode}
% Make sure the box is wide enough.
% \changes{v1.19}{2017/03/31}{Added MH\_ prefix}
% \begin{macrocode}
\MH_if_dim:w \l_MT_multwidth_dim<\l_MT_multline_measure_fdim
\MH_setlength:dn \l_MT_multwidth_dim{\l_MT_multline_measure_fdim}
\fi
\MH_set_boolean_T:n {mult_firstline}
% \end{macrocode}
% Tricky bit: If we only encountered one \cmd{\\} then use a very
% special \cs{math@cr@@} that inserts everything needed.
% \changes{v1.19}{2017/03/31}{Added MH\_ prefix}
% \begin{macrocode}
\MH_if_num:w \l_MT_multline_lastline_fint=\@ne
\MH_let:NwN \math@cr@@ \MT_mult_firstandlast_mathcr:w
\MH_fi:
% \end{macrocode}
% Do the typesetting.
% \begin{macrocode}
\ialign\bgroup
\hfil\strut@$\m@th\displaystyle{}##$\hfil
\crcr
\hfilneg
#1
}
% \end{macrocode}
% \end{macro}
% \begin{macro}{\MT_measure_mult:n}
% \changes{v1.01a}{2004/10/10}{Added Ord atom to beginning of each line}
% Measuring. Disable all labelling and check the number of lines.
% \changes{v1.18}{2015/11/12}{Added \cs{measuring@true} inside the
% \env{multlined}}
% \begin{macrocode}
\newcommand\MT_measure_mult:n [1]{
\begingroup
\measuring@true
\g_MT_multlinerow_int\@ne
\MH_let:NwN \label\MT_gobblelabel:w
\MH_let:NwN \tag\gobble@tag
\setbox\z@\vbox{
\ialign{\strut@$\m@th\displaystyle{}##$
\crcr
#1
\crcr
}
}
\xdef\l_MT_multline_measure_fdim{\the\wdz@}
\advance\g_MT_multlinerow_int\m@ne
\xdef\l_MT_multline_lastline_fint{\number\g_MT_multlinerow_int}
\endgroup
\g_MT_multlinerow_int\@ne
}
% \end{macrocode}
% \end{macro}
% \begin{macro}{\MT_multlined_second_arg:w}
% Scan for a second optional argument.
% \changes{v1.19}{2017/03/31}{Added MH\_ prefix}
% \begin{macrocode}
\MaybeMHPrecedingSpacesOff
\newcommand*\MT_multlined_second_arg:w [1][\@empty]{
\MT_test_for_tcb_other:nnnnn {#1}
{\def\MT_mult_default_pos:{#1}}
{\def\MT_mult_default_pos:{#1}}
{\def\MT_mult_default_pos:{#1}}
{
\MH_if_meaning:NN \@empty#1\@empty
\MH_else:
\setlength \l_MT_multwidth_dim{#1}
\MH_fi:
}
\MT_start_mult:N \MT_mult_default_pos:
}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\MultlinedHook}
% \changes{v1.18}{2015/11/12}{Added this hook}
% Due to the methods used by \env{multlined}, some constructions may
% fail. We already know that \env{multlined} does not work well inside
% arrays or matrices. Be things used inside \cs{multlined} may also
% fail. Thus we provide a hook that can be added to in order to make
% redefinitions of these constructions when used inside
% \env{multlined}. The default value include a fix to \env{subarray}
% and thus \cs{substack}. The fix to this environment was suggested by
% Ulrike Fisher, \url{http://chat.stackexchange.com/transcript/message/25105970#25105970}
% \begin{macrocode}
\newcommand\MultlinedHook{
\renewenvironment{subarray}[1]{%
\vcenter\bgroup
\Let@ \restore@math@cr \default@tag
\let\math@cr@@\AMS@math@cr@@ % <--- the fix
\baselineskip\fontdimen10 \scriptfont\tw@
\advance\baselineskip\fontdimen12 \scriptfont\tw@
\lineskip\thr@@\fontdimen8 \scriptfont\thr@@
\lineskiplimit\lineskip
\ialign\bgroup\ifx c##1\hfil\fi
$\m@th\scriptstyle####$\hfil\crcr
}{%
\crcr\egroup\egroup
}
}
% \end{macrocode}
% \end{macro}
%
% \begin{environment}{multlined}
% The user environment. Scan for an optional argument.
% \changes{v1.18}{2015/11/12}{Added \cs{MultlinedHook}}
% \changes{v1.19}{2017/03/31}{Added MH\_ prefix}
% \begin{macrocode}
\newenvironment{multlined}[1][]
{\MH_group_align_safe_begin:
\MultlinedHook
\MT_test_for_tcb_other:nnnnn {#1}
{\def\MT_mult_default_pos:{#1}}
{\def\MT_mult_default_pos:{#1}}
{\def\MT_mult_default_pos:{#1}}
{
\MH_if_meaning:NN \@empty#1\@empty
\MH_else:
\setlength \l_MT_multwidth_dim{#1}
\MH_fi:
}
\MT_multlined_second_arg:w
}
{
\hfilneg \endaligned \MH_group_align_safe_end:
}
\MHPrecedingSpacesOn
% \end{macrocode}
% \end{environment}
% The keys needed.
% \begin{macrocode}
\define@key{\MT_options_name:}
{firstline-afterskip}{\def\l_MT_mult_left_fdim{#1}}
\define@key{\MT_options_name:}
{lastline-preskip}{\def\l_MT_mult_right_fdim{#1}}
\define@key{\MT_options_name:}
{multlined-width}{\setlength \l_MT_multwidth_dim{#1}}
\define@key{\MT_options_name:}
{multlined-pos}{\def\MT_mult_default_pos:{#1}}
\setkeys{\MT_options_name:}{
firstline-afterskip=\multlinegap,
lastline-preskip=\multlinegap,
multlined-width=0pt,
multlined-pos=c,
}
% \end{macrocode}
% \begin{macro}{\MT_gobblelabel:w}
% Better than to assume that \cs{label} has exactly one mandatory
% argument, hence the \texttt{w} specifier.
% \begin{macrocode}
\def\MT_gobblelabel:w #1{}
% \end{macrocode}
% \end{macro}
%
%
%
%
% \section{Macros suggested/requested by Lars Madsen}
%
% The macros in this section are all requests made by Lars Madsen.
%
% \subsection{Paired delimiters}
%
% \changes{v1.13}{2012/05/10}{Extended \cs{DeclarePairedDelimiter(X)}}
% \begin{macro}{\MT_delim_default_inner_wrappers:n}
% In some cases users may want to control the internals a bit more. We
% therefore create two call back macros each time the
% \cs{DeclarePaired...} macro is issued. The default value of these
% call backs are provided by |\MT_delim_default_inner_wrappers:n|
% \begin{macrocode}
\newcommand\MT_delim_default_inner_wrappers:n [1]{
\@namedef{MT_delim_\MH_cs_to_str:N #1 _star_wrapper:nnn}##1##2##3{
\mathopen{}\mathclose\bgroup ##1 ##2 \aftergroup\egroup ##3
}
% \end{macrocode}
% Turns out that there is a difference between \verb|\mathclose{)}|
% and \verb|\mathclose)| (placement of for example superscript), so instead of two wrappers, we need three.
% \changes{v1.19}{2017/05/22}{added \cs{...nostarnonscaled..} wrapper}
% \changes{v1.19}{2017/05/22}{renamed \cs{...nostar..} to \cs{...nostarscaled..} }
% \begin{macrocode}
\@namedef{MT_delim_\MH_cs_to_str:N #1 _nostarscaled_wrapper:nnn}##1##2##3{
\mathopen{##1}##2\mathclose{##3}
}
\@namedef{MT_delim_\MH_cs_to_str:N #1 _nostarnonscaled_wrapper:nnn}##1##2##3{
\mathopen##1##2\mathclose##3
}
}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\reDeclarePairedDelimiterInnerWrapper}
% Macro enabling the user to alter an existing call back. First
% argument is the name of the macro we are altering (as defined via
% \cs{DeclarePaired...}), the second is \texttt{star},
% \texttt{nostarnonscaled} or \texttt{nostarscaled}. In the last
% argument \texttt{\#1} and \texttt{\#3} respectively refer to the
% scaled fences and \texttt{\#2} refer to whatever come between.
% \changes{v1.19}{2017/05/23}{Added a test and error}
% \begin{macrocode}
\newcommand\reDeclarePairedDelimiterInnerWrapper[3]{
\@ifundefined{MT_delim_\MH_cs_to_str:N #1 _ #2 _wrapper:nnn}{
\PackageError{mathtools}{
Wrapper~not~found~for~\string#1~and~option~'#2'.\MessageBreak
Either~\string#1~is~ not~ defined,~or~ you~ are~using~ the~
\MessageBreak
'nostar'~ option,~which~ is~ no~ longer~ supported.~
\MessageBreak
Please~ use~ 'nostarnonscaled'~ or~ 'nostarscaled~
\MessageBreak instead.~
}{See the manual}
}{
\@namedef{MT_delim_\MH_cs_to_str:N #1 _ #2 _wrapper:nnn}##1##2##3{
#3
}
}
}
% \end{macrocode}
%
% \begin{macro}{\MT_etb_ifdefempty_x:nnn}
% \begin{macro}{\MT_etb_ifblank:nnn}
% \changes{v1.19}{2017/05/23}{Added so we can test for empty args}
% This is a copy of \cs{etb@ifdefempty} (it is \emph{not} the same
% as \cs{ifdefempty}) and \cs{ifblank} from \pkg{etoolbox},
% currently we do not want to make \pkg{etoolbox} a requirement,
% that may change in the future. We need a reliable method to check
% whether a macro is blank or not (including spaces).
% \begin{macrocode}
\def\MT_etb_ifdefempty_x:nnn #1{
\expandafter\expandafter\expandafter
\MT_etb_ifblank:nnn
\expandafter\expandafter\expandafter{%
\expandafter\strip@prefix\meaning#1}
}
\def\MT_etb_ifblank:nnn #1{
\expandafter\ifx\expandafter\relax\detokenize\expandafter{\@gobble#1?}\relax
\expandafter\@firstoftwo
\else
\expandafter\@secondoftwo
\fi
}
% \end{macrocode}
% \end{macro}
% \end{macro}
% %
%
% \end{macro}
% \begin{macro}{\DeclarePairedDelimiter}
% \changes{v1.06}{2008/08/01}{Made user command robust}
% This macro defines |#1| to be a control sequence that takes either
% a star or an optional argument and one mandatory argument.
% \begin{macrocode}
\newcommand*\DeclarePairedDelimiter[3]{%
\@ifdefinable{#1}{
% \end{macrocode}
% Define the starred command to just put \cs{left} and \cs{right}
% before the delimiters, wrapped in a callback function.
% \changes{1.08e}{2010/09/02}{`Fixed' \cs{left}\dots\cs{right} bad spacing}
% \changes{1.08e}{2010/09/14}{redid the \cs{left}\dots\cs{right} fix,
% see \cs{DeclarePairedDelimiterXPP} for details.}
% \changes{v1.13}{2012/05/10}{Using call back instead}
% \begin{macrocode}
\MT_delim_default_inner_wrappers:n{#1} % define the wrappers
\@namedef{MT_delim_\MH_cs_to_str:N #1 _star:}##1
{ \@nameuse{MT_delim_\MH_cs_to_str:N #1 _star_wrapper:nnn}%
{\left#2}{##1}{\right#3} }%
% \end{macrocode}
% The command with optional argument. It should be \cs{bigg} or
% alike.
% \begin{macrocode}
\@xp\@xp\@xp
\newcommand
\@xp\csname MT_delim_\MH_cs_to_str:N #1 _nostar:\endcsname
[2][\\@gobble]
{
% \end{macrocode}
% With the default optional argument we wind up with \cs{relax},
% else we get \cs{biggr} and \cs{biggl} etc.
% \changes{v1.13}{2012/05/10}{Using call back instead}
% \changes{v1.19}{2017/05/23}{Split the wrappers in two, so know
% \cs{}\cs{@gobble} is now only used to check if the optional
% argument is empty.}
% \begin{macrocode}
\def\@tempa{\\@gobble}
\def\@tempb{##1}
\ifx\@tempa\@tempb
% \end{macrocode}
% As of May 2017, we now run explicit wrapper in the nonscaled
% version, so we can remove the feature to to add l and r version of
% the scaler (as there is none).
% \begin{macrocode}
\@nameuse{MT_delim_\MH_cs_to_str:N #1 _nostarnonscaled_wrapper:nnn}%
{#2}
{##2}
{#3}
\else
% \end{macrocode}
% Next we need to check whether \texttt{\#\#1} is blank as that
% should not be scaled
% \begin{macrocode}
\MT_etb_ifblank:nnn {##1}{
\@nameuse{MT_delim_\MH_cs_to_str:N #1 _nostarnonscaled_wrapper:nnn}%
{#2}
{##2}
{#3}
}{
\@nameuse{MT_delim_\MH_cs_to_str:N #1 _nostarscaled_wrapper:nnn}%
{\@nameuse {\MH_cs_to_str:N ##1 l} #2}
{##2}
{\@nameuse {\MH_cs_to_str:N ##1 r} #3}
}
\fi
}
% \end{macrocode}
% The user command comes here. Just check for the star and choose
% the right internal command.
% \begin{macrocode}
\DeclareRobustCommand{#1}{
\@ifstar
{\@nameuse{MT_delim_\MH_cs_to_str:N #1 _star:}}
{\@nameuse{MT_delim_\MH_cs_to_str:N #1 _nostar:}}
}
}
}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\MT_paired_delimx_arg_test:n}
% This tests the \oarg{num args} part of
% \cs{DeclarePairedDelimiterX} and \cs{DeclarePairedDelimiterXPP}
% (code reuse), and complains if it is not 1,\dots,9.
% \changes{v1.14}{2014/05/20}{Added}
% \begin{macrocode}
\def\MT_paired_delimx_arg_test:n #1{
\ifnum#1>9\relax
\PackageError{mathtools}{No~ more~ than~ 9~ arguments}{}
\else
\ifnum#1<1\relax
\PackageError{mathtools}{Macro~ need~ 1~ or~ more~
arguments.\MessageBreak Please~ change~ [#1]~ to~ [1]~ ... [9]}{}
\fi
\fi
}
% \end{macrocode}
% \end{macro}
% \begin{macro}{\MT_delim_inner_generator:n..n}
% \changes{v1.19}{2017/05/14}{Macro added, changes notes in the
% implementation are taken from when this code was not factored out}
% This generates the internal macro from
% \cs{DeclarePairedDelimiterX} and \cs{DeclarePairedDelimiterXPP}
% that handles the non-starred part of the generated macro. The
% macro takes 7 arguments mimicing the arguments of
% \cs{DeclarePairedDelimiterXPP}:
% \begin{enumerate}\setlength\itemsep{0pt}
% \item external macro name
% \item number of arguments, 1-9, already checked at this stage
% \item predata
% \item left scaler
% \item right scaler
% \item postdata
% \item body
% \end{enumerate}
%
% \begin{macrocode}
\def\@MHempty{}
\newcommand\MT_delim_inner_generator:nnnnnnn [7]{
% \end{macrocode}
% In order for the starred and non-starred version of
% \cs{DeclarePairedDelimiterX(PP)} to have the same arguments, we need
% to introduce an extra macro to catch the optional argument (this
% means that the non-starred version can actually support ten
% arguments!). Here we do things a little differently than with
% \cs{DeclarePairedDelimiter}. The optional argument have
% \cs{@MHempty} as the default. This was earlier locally redefined to
% eat l/r additions to the scaler when there were no scaler. In this
% implementation, we just look for that macro to see if no scaler has
% been given at all.
% \begin{macrocode}
\@xp\@xp\@xp
\newcommand
\@xp\csname MT_delim_\MH_cs_to_str:N #1 _nostar_inner:\endcsname
[#2]
{
% \end{macrocode}
% Add the (possibly empty) precode:
% \begin{macrocode}
#3
% \end{macrocode}
% Next we provide the inner workhorse. We need a bit of expansion
% magic to get \cs{delimsize} to work.
% \changes{v1.13}{2012/05/10}{Using call backs for \cs{mathopen} and
% \cs{mathclose} additions}
% \changes{v1.19}{2017/04/27}{Added resetting code for \cs{@MHempty},
% cannot rely on groups here. 2017/05/23 removed because of reimplementation}
%
% May 2017: Due to \verb+\mathclose{|}^2+ generally not being equal to
% \verb+\mathclose|^2+ we needed to split the wrapper macro into
% separate nonscaled and scaled versions. This also have the benefit
% of completely eliminating the need to gobble any chars. There is now
% the nonscaled version, which we do not add any scalers to and the
% manually scaled version where we \emph{know} there is a scaler. The
% complication is now that we need to be able to check for blank
% input, thus the including of a few macros from \pkg{etoolbox}.
% \changes{v1.19}{2017/05/23}{Split into two wrappers and some tests}
% First we need to look at \cs{delimsize} to see if it is equal to
% \cs{@MHempty}. If it is run the nonscaled version.
% \begin{macrocode}
\def\@tempa{\@MHempty}
\@xp\def\@xp\@tempb\@xp{\delimsize}
\ifx\@tempa\@tempb
\@nameuse{MT_delim_\MH_cs_to_str:N #1 _nostarnonscaled_wrapper:nnn}
{#4}{#7}{#5}
\else
% \end{macrocode}
% Next we use a copy of a macro from \pkg{etoolbox} to determine
% whether \cs{delimsize} is empty or not. This is to be sure that
% \verb|\abs[]| and similar still end up in the unscaled branch.
% \begin{macrocode}
\MT_etb_ifdefempty_x:nnn {\delimsize}{
\@nameuse{MT_delim_\MH_cs_to_str:N #1 _nostarnonscaled_wrapper:nnn}
{#4}{#7}{#5}
}{
% \end{macrocode}
% In the scaled version we add features to convert til scaler to its
% l/r versions.
% \begin{macrocode}
\@nameuse{MT_delim_\MH_cs_to_str:N #1 _nostarscaled_wrapper:nnn}
{
\@xp\@xp\@xp\csname\@xp\MH_cs_to_str:N \delimsize l\endcsname #4
}
{#7}
{
\@xp\@xp\@xp\csname\@xp\MH_cs_to_str:N \delimsize r\endcsname #5
}
}
\fi
% \end{macrocode}
% Add the (possibly empty) post code
% \begin{macrocode}
#6
\endgroup
}
}
% \end{macrocode}
%
% \end{macro}
% \begin{macro}{\DeclarePairedDelimiterXPP}
% \changes{v1.19}{2017/05/24}{Rewritten as we might as well
% implement ...X via ...XPP} It turns out it is useful to have a
% more general version of \cs{DeclarePairedDelimiter} where we can
% access the body and perhaps even add stuff on the outside of the
% fences. Historically, we added \cs{DeclarePairedDelimiterX} first,
% giving access to the body and the most general
% \cs{DeclarePairedDelimiterXPP} was requested after that, thus
% ending up with two macros so not to break existing document. As of
% May 2017, since \cs{DeclarePairedDelimiterX} is just
% \cs{DeclarePairedDelimiterXPP} with no pre- or postcode, we will
% use this update to just define \cs{DeclarePairedDelimiterXPP} and
% define \cs{DeclarePairedDelimiterX} from that.
%
% The arguments for \cs{DeclarePairedDelimiterXPP} are interpreted
% as
% \begin{center}
% \marg{macroname}\oarg{num~args}\allowbreak\marg{pre~code}\allowbreak\marg{left
% delim}\goodbreak \marg{right delim}\marg{post code}\marg{body}
% \end{center}
% Inside \marg{body} \cs{delimsize}
% refers to the current size of the scaler (\cs{middle} in the starred version).
% \begin{macrocode}
\def\DeclarePairedDelimiterXPP#1[#2]#3#4#5#6#7{%
\@ifdefinable{#1}{
% \end{macrocode}
% The constructor takes five arguments, the name of the macro, the
% number of arguments (1-9), the left and right delimiter, the inner
% code for the two macros. First we verify that the number of arguments fit.
% \changes{v1.14}{2014/05/20}{Factored out in separate macro
% (\cs{MT_paired_delimx_arg_test:n}) for reuse. Comment refers back to
% old \cs{DeclarePairedDelimiterX} implementation.}
% \begin{macrocode}
\MT_paired_delimx_arg_test:n{#2}
% \end{macrocode}
% \changes{v1.13}{2012/05/10}{Using call back instead}
% Define the default call backs.
% \begin{macrocode}
\MT_delim_default_inner_wrappers:n{#1}
% \end{macrocode}
% We make sure to store the delimiter size in the local variable
% \cs{delimsize}. Then users can refer to the size in the \marg{body}
% argument. In the starred version it will refer to \cs{middle} and in
% the normal version it will hold the provided optional argument.
% \begin{macrocode}
\@xp\@xp\@xp
\newcommand
\@xp\csname MT_delim_\MH_cs_to_str:N #1 _star:\endcsname
[#2]
{
\begingroup
\def\delimsize{\middle}
% \end{macrocode}
% Adding the \marg{precode} (possibly empty)
% \begin{macrocode}
#3
% \end{macrocode}
% This is slightly controversial, \cs{left}\dots\cs{right} are known
% to produce an inner atom, thus may cause different spacing than
% normal delimiters. We `fix' this by introducing \cs{mathopen} and
% \cs{mathclose}. This change is now factored out into call backs.
% \changes{v1.08e}{2010/09/14}{redid the left/right fix, inspired by
% ctt thread named `spacing after \cs{right}) and before \cs{left})'
% started 2010-08-12.}
% \changes{v1.13}{2012/05/10}{Using call back instead}
% \begin{macrocode}
\@nameuse{MT_delim_\MH_cs_to_str:N #1 _star_wrapper:nnn}
{\left#4}{#7}{\right#5}
#6
\endgroup
}
% \end{macrocode}
% In order for the starred and non-starred version to have the same
% arguments, we need to introduce an extra macro to catch the optional
% argument (this means that the non-starred version can actually
% support ten arguments!).
% \begin{macrocode}
\@xp\@xp\@xp
\newcommand
\@xp\csname MT_delim_\MH_cs_to_str:N #1 _nostar:\endcsname
[1][\@MHempty]
{
% \end{macrocode}
% We need to introduce a local group in order to support nesting. It
% is ended inside \verb|\MT_delim_\MH_cs_to_str:N #1 _nostar_inner:|,
% here we also stores the scaler in \cs{delimsize}.
% \begin{macrocode}
\begingroup
\def\delimsize{##1}
\@nameuse{MT_delim_\MH_cs_to_str:N #1 _nostar_inner:}
}
% \end{macrocode}
% To make the code easier to work with we factored the next macro
% out. Since \cs{DeclarePairedDelimiterX} is now implemented via
% \cs{DeclarePairedDelimiterXPP} we did not need to. But it makes the
% code a bit simpler. \cs{MT_delim_inner_generator:nnnnnnn} just
% takes care of generating the appropriate \cs{..._nostar_inner:} macro.
% \begin{macrocode}
\MT_delim_inner_generator:nnnnnnn {#1}{#2}{#3}{#4}{#5}{#6}{#7}
% \end{macrocode}
% At the end, generate the actual user command.
% \begin{macrocode}
\DeclareRobustCommand{#1}{
\@ifstar
{\@nameuse{MT_delim_\MH_cs_to_str:N #1 _star:}}
{\@nameuse{MT_delim_\MH_cs_to_str:N #1 _nostar:}}
}
}
}
% \end{macrocode}
% \end{macro}
% \begin{macro}{\DeclarePairedDelimiterX}
% \changes{v1.08}{2010/06/10}{Added
% \cs{DeclarePairedDelimiterX}. 2017/05/24: old comment, kept for
% historic reasons.}
% \changes{v1.08e}{2010/09/02}{Provided better implementation of
% \cs{DeclarePairedDelimiterX}. 2017/05/24: old comment, kept for
% historic reasons.}
% As of May 2017, this is now just a call to \cs{DeclarePairedDelimiterXPP}.
% \begin{macrocode}
\def\DeclarePairedDelimiterX#1[#2]#3#4#5{
\DeclarePairedDelimiterXPP{#1}[#2]{}{#3}{#4}{}{#5}
}
% \end{macrocode}
% \end{macro}
%
%
% \subsection{A \texttt{\textbackslash displaystyle} \env{cases} environment}
%
% \begin{macro}{\MT_start_cases:nnn}
% We define a single command that does all the hard work.
% \changes{v1.08}{2010/06/10}{made \cs{MT_start_cases:nnnn} more general}
% \begin{macrocode}
\def\MT_start_cases:nnnn #1#2#3#4{ % #1=sep,#2=lpreamble,#3=rpreamble,#4=delim
\RIfM@\else
\nonmatherr@{\begin{\@currenvir}}
\fi
\MH_group_align_safe_begin:
\left#4
\vcenter \bgroup
\Let@ \chardef\dspbrk@context\@ne \restore@math@cr
\let \math@cr@@\AMS@math@cr@@
\spread@equation
\ialign\bgroup
% \end{macrocode}
% Set the first column flush left in \cs{displaystyle} math and the
% second as specified by the second argument. The first argument is
% the separation between the columns. It could be a \cs{quad} or
% something entirely different.
% \begin{macrocode}
\strut@#2 \strut@
#3
\crcr
}
% \end{macrocode}
% \end{macro}
% \begin{macro}{\MH_end_cases:}
% \begin{macrocode}
\def\MH_end_cases:{\crcr\egroup
\restorecolumn@
\egroup
\MH_group_align_safe_end:
}
% \end{macrocode}
% \end{macro}
% \begin{macro}{\newcases}
% \begin{macro}{\renewcases}
% Easy creation of new \env{cases}-like environments.
% \changes{v1.08}{2010/06/10}{changed to match the change in \cs{MT_start_cases:nnnn}}
% \begin{macrocode}
\newcommand*\newcases[6]{% #1=name, #2=sep, #3=preamble, #4=left, #5=right
\newenvironment{#1}
{\MT_start_cases:nnnn {#2}{#3}{#4}{#5}}
{\MH_end_cases:\right#6}
}
\newcommand*\renewcases[6]{
\renewenvironment{#1}
{\MT_start_cases:nnnn {#2}{#3}{#4}{#5}}
{\MH_end_cases:\right#6}
}
% \end{macrocode}
% \begin{environment}{dcases}
% \begin{environment}{dcases*}
% \begin{environment}{rcases}
% \begin{environment}{rcases*}
% \begin{environment}{drcases}
% \begin{environment}{drcases*}
% \begin{environment}{cases*}
% \env{dcases} is a traditional cases with display style math in
% both columns, while \env{dcases*} has text in the second column.
% \changes{v1.08}{2010/06/10}{changed to match the change in
% \cs{newcases} plus added rcases and drcases}
% \begin{macrocode}
\newcases{dcases}{\quad}{%
$\m@th\displaystyle{##}$\hfil}{$\m@th\displaystyle{##}$\hfil}{\lbrace}{.}
\newcases{dcases*}{\quad}{%
$\m@th\displaystyle{##}$\hfil}{{##}\hfil}{\lbrace}{.}
\newcases{rcases}{\quad}{%
$\m@th{##}$\hfil}{$\m@th{##}$\hfil}{.}{\rbrace}
\newcases{rcases*}{\quad}{%
$\m@th{##}$\hfil}{{##}\hfil}{.}{\rbrace}
\newcases{drcases}{\quad}{%
$\m@th\displaystyle{##}$\hfil}{$\m@th\displaystyle{##}$\hfil}{.}{\rbrace}
\newcases{drcases*}{\quad}{%
$\m@th\displaystyle{##}$\hfil}{{##}\hfil}{.}{\rbrace}
\newcases{cases*}{\quad}{%
$\m@th{##}$\hfil}{{##}\hfil}{\lbrace}{.}
% \end{macrocode}
% \end{environment}
% \end{environment}
% \end{environment}
% \end{environment}
% \end{environment}
% \end{environment}
% \end{environment}
% \end{macro}
% \end{macro}
%
% \subsection{New matrix environments}
% \begin{macro}{\MT_matrix_begin:N}
% \begin{macro}{\MT_matrix_end:}
% Here are a few helpers for the matrices. \cs{MT_matrix_begin:N}
% takes one argument specifying the column type for the array inside
% the matrix. and \cs{MT_matrix_end:} inserts the correct ending.
% \begin{macrocode}
\def\MT_matrix_begin:N #1{%
\hskip -\arraycolsep
\MH_let:NwN \@ifnextchar \MH_nospace_ifnextchar:Nnn
\array{*\c@MaxMatrixCols #1}}
\def\MT_matrix_end:{\endarray \hskip -\arraycolsep}
% \end{macrocode}
% \end{macro}
% \end{macro}
% Before we define the environments we better make sure that spaces
% before the optional argument is disallowed. Else a user who types
% \begin{verbatim}
% \[
% \begin{pmatrix*}
% [c] & a \\
% b & d
% \end{pmatrix*}
% \]
% \end{verbatim}
% will lose the \texttt{[c]}!
% \begin{macrocode}
\MaybeMHPrecedingSpacesOff
% \end{macrocode}
% \begin{environment}{matrix*}
% This environment is just like \env{matrix} only it takes an
% optional argument specifying the column type.
% \begin{macrocode}
\newenvironment{matrix*}[1][c]
{\MT_matrix_begin:N #1}
{\MT_matrix_end:}
% \end{macrocode}
% \end{environment}
% \begin{environment}{pmatrix*}
% \begin{environment}{bmatrix*}
% \begin{environment}{Bmatrix*}
% \begin{environment}{vmatrix*}
% \begin{environment}{Vmatrix*}
% Then starred versions of the other \AmS{} matrices.
% \begin{macrocode}
\newenvironment{pmatrix*}[1][c]
{\left(\MT_matrix_begin:N #1}
{\MT_matrix_end:\right)}
\newenvironment{bmatrix*}[1][c]
{\left[\MT_matrix_begin:N #1}
{\MT_matrix_end:\right]}
\newenvironment{Bmatrix*}[1][c]
{\left\lbrace\MT_matrix_begin:N #1}
{\MT_matrix_end:\right\rbrace}
\newenvironment{vmatrix*}[1][c]
{\left\lvert\MT_matrix_begin:N #1}
{\MT_matrix_end:\right\rvert}
\newenvironment{Vmatrix*}[1][c]
{\left\lVert\MT_matrix_begin:N #1}
{\MT_matrix_end:\right\lVert}
% \end{macrocode}
% \end{environment}
% \end{environment}
% \end{environment}
% \end{environment}
% \end{environment}
%
% \changes{v1.10}{2011/02/12}{Added the code below, courtesy of Rasmus Villemoes}
% Now we are at it why not provide fenced versions of the
% \env{smallmatrix} construction as well. We will only provide a
% version that can be adjusted as \env{matrix*} above, thus we keep
% the * in the name. The implementation is courtesy of Rasmus
% Villemoes. Rasmus also suggested making the default alignment in
% these environments globally adjustable, so we did
% (\texttt{smallmatrix-align=c} by default). It \emph{is} possible to
% do something similar with the large matrix environments, but that
% might cause problems with the \texttt{array} package, thus for now
% we lease that feature alone.
%
% The base code is a variation over the original \env{smallmatrix}
% environmetn fround in \texttt{amsmath}, thus we will not comment it further.
%
% TODO: make the code check that the optional argument is either
% \texttt{c}, \texttt{l} or \texttt{r}.
% \begin{macrocode}
\def\MT_smallmatrix_begin:N #1{%
\Let@\restore@math@cr\default@tag
\baselineskip6\ex@ \lineskip1.5\ex@ \lineskiplimit\lineskip
\csname MT_smallmatrix_#1_begin:\endcsname
}
\def\MT_smallmatrix_end:{\crcr\egroup\egroup\MT_smallmatrix_inner_space:}
\def\MT_smallmatrix_l_begin:{\null\MT_smallmatrix_inner_space:\vcenter\bgroup
\ialign\bgroup$\m@th\scriptstyle##$\hfil&&\thickspace
$\m@th\scriptstyle##$\hfil\crcr
}
\def\MT_smallmatrix_c_begin:{\null\MT_smallmatrix_inner_space:\vcenter\bgroup
\ialign\bgroup\hfil$\m@th\scriptstyle##$\hfil&&\thickspace\hfil
$\m@th\scriptstyle##$\hfil\crcr
}
\def\MT_smallmatrix_r_begin:{\null\MT_smallmatrix_inner_space:\vcenter\bgroup
\ialign\bgroup\hfil$\m@th\scriptstyle##$&&\thickspace\hfil
$\m@th\scriptstyle##$\crcr
}
\newenvironment{smallmatrix*}[1][\MT_smallmatrix_default_align:]
{\MT_smallmatrix_begin:N #1}
{\MT_smallmatrix_end:}
% \end{macrocode}
% We would like to keep to the tradition of the \verb?Xmatrix? and
% \verb?Xmatrix*? macros we added earlier, since most code is similar
% we define them using a constructor macro. We also apply the trick
% used within \verb?\DeclarePairedDelimiter(X)? such that \verb?\left?
% \verb?\right? constructions produce spacings corresponding to
% \verb?\mathopen? and \verb?\mathclose?.
% \begin{macrocode}
\def\MT_fenced_sm_generator:nnn #1#2#3{%
\@ifundefined{#1}{%
\newenvironment{#1}
{\@nameuse{#1hook}\mathopen{}\mathclose\bgroup\left#2\MT_smallmatrix_begin:N c}%
{\MT_smallmatrix_end:\aftergroup\egroup\right#3}%
}{}%
\@ifundefined{#1*}{%
\newenvironment{#1*}[1][\MT_smallmatrix_default_align:]%
{\@nameuse{#1hook}\mathopen{}\mathclose\bgroup\left#2\MT_smallmatrix_begin:N ##1}%
{\MT_smallmatrix_end:\aftergroup\egroup\right#3}%
}{}%
}
\MT_fenced_sm_generator:nnn{psmallmatrix}()
\MT_fenced_sm_generator:nnn{bsmallmatrix}[]
\MT_fenced_sm_generator:nnn{Bsmallmatrix}\lbrace\rbrace
\MT_fenced_sm_generator:nnn{vsmallmatrix}\lvert\rvert
\MT_fenced_sm_generator:nnn{Vsmallmatrix}\lVert\rVert
% \end{macrocode}
%
% The options associated with this.
% \begin{macrocode}
\define@key{\MT_options_name:}
{smallmatrix-align}{\def\MT_smallmatrix_default_align:{#1}}
\define@key{\MT_options_name:}
{smallmatrix-inner-space}{\def\MT_smallmatrix_inner_space:{#1}}
\setkeys{\MT_options_name:}{
smallmatrix-align=c,
smallmatrix-inner-space=\,
}
% \end{macrocode}
% Restore the usual spacing behavior.
% \begin{macrocode}
\MHPrecedingSpacesOn
% \end{macrocode}
%
% \subsection{Smashing an operator with limits}
%
% \begin{macro}{\smashoperator}
% The user command. Define \cs{MT_smop_use:NNNNN} to be one of the
% specialized commands \cs{MT_smop_smash_l:NNNNN},
% \cs{MT_smop_smash_r:NNNNN}, or the default
% \cs{MT_smop_smash_lr:NNNNN}.
% \begin{macrocode}
\newcommand*\smashoperator[2][lr]{
\def\MT_smop_use:NNNNN {\@nameuse{MT_smop_smash_#1:NNNNN}}
\toks@{#2}
\expandafter\MT_smop_get_args:wwwNnNn
\the\toks@\@nil\@nil\@nil\@nil\@nil\@nil\@@nil
}
% \end{macrocode}
% \end{macro}
% \begin{macro}{\MT_smop_remove_nil_vi:N}
% \begin{macro}{\MT_smop_mathop:n}
% \begin{macro}{\MT_smop_limits:}
% Some helper functions.
% \begin{macrocode}
\def\MT_smop_remove_nil_vi:N #1\@nil\@nil\@nil\@nil\@nil\@nil{#1}
\def\MT_smop_mathop:n {\mathop}
\def\MT_smop_limits: {\limits}
% \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
% Some conditionals.
% \begin{macrocode}
\MH_new_boolean:n {smop_one}
\MH_new_boolean:n {smop_two}
% \end{macrocode}
% \begin{macro}{\MT_smop_get_args:wwwNnNn}
% The argument stripping. There are three different valid types of
% input:
% \begin{enumerate}
% \item An operator with neither subscript nor superscript.
% \item An operator with one subscript or superscript.
% \item An operator with both subscript and superscript.
% \end{enumerate}
% Additionally an operator can be either a single macro as in
% \cs{sum} or in \cs{mathop}\arg{A} and people might be tempted to
% put a \cs{limits} after the operator, even though it's not
% necessary. Thus the input with most tokens would be something like
% \begin{verbatim}
% \mathop{TTT}\limits_{sub}^{sup}
% \end{verbatim}
% Therefore we have to scan for seven arguments, but there might
% only be one actually. So let's list the possible situations:
% \begin{enumerate}
% \item \verb|\mathop{TTT}\limits_{subsub}^{supsup}|
% \item \verb|\mathop{TTT}_{subsub}^{supsup}|
% \item \verb|\sum\limits_{subsub}^{supsup}|
% \item \verb|\sum_{subsub}^{supsup}|
% \end{enumerate}
% Furthermore the |_{subsub}^{supsup}| part can also just be
% |_{subsub}| or empty.
% \begin{macrocode}
\def\MT_smop_get_args:wwwNnNn #1#2#3#4#5#6#7\@@nil{%
\begingroup
\def\MT_smop_arg_A: {#1} \def\MT_smop_arg_B: {#2}
\def\MT_smop_arg_C: {#3} \def\MT_smop_arg_D: {#4}
\def\MT_smop_arg_E: {#5} \def\MT_smop_arg_F: {#6}
\def\MT_smop_arg_G: {#7}
% \end{macrocode}
% Check if A is \cs{mathop}. If it is, we know that B is the argument
% of the \cs{mathop}.
% \changes{v1.19}{2017/03/31}{Added MH\_ prefix}
% \begin{macrocode}
\MH_if_meaning:NN \MT_smop_arg_A: \MT_smop_mathop:n
% \end{macrocode}
% If A was \cs{mathop} we check if C is \cs{limits}
% \changes{v1.19}{2017/03/31}{Added MH\_ prefix}
% \begin{macrocode}
\MH_if_meaning:NN \MT_smop_arg_C:\MT_smop_limits:
\def\MT_smop_final_arg_A:{#1{#2}}%
% \end{macrocode}
% Now we have something like \verb|\mathop{TTT}\limits|. Then check
% if D is \cs{@nil}.
% \changes{v1.19}{2017/03/31}{Added MH\_ prefix}
% \begin{macrocode}
\MH_if_meaning:NN \MT_smop_arg_D: \@nnil
\MH_else:
\MH_set_boolean_T:n {smop_one}
\MH_let:NwN \MT_smop_final_arg_B: \MT_smop_arg_D:
\MH_let:NwN \MT_smop_final_arg_C: \MT_smop_arg_E:
\MH_if_meaning:NN \MT_smop_arg_F: \@nnil
\MH_else:
\MH_set_boolean_T:n {smop_two}
\MH_let:NwN \MT_smop_final_arg_D: \MT_smop_arg_F:
\edef\MT_smop_final_arg_E:
{\expandafter\MT_smop_remove_nil_vi:N \MT_smop_arg_G: }
\MH_fi:
\MH_fi:
\MH_else:
% \end{macrocode}
% Here we have something like \verb|\mathop{TTT}|. Still check
% if D is \cs{@nil}.
% \changes{v1.19}{2017/03/31}{Added MH\_ prefix}
% \begin{macrocode}
\def\MT_smop_final_arg_A:{#1{#2}}%
\MH_if_meaning:NN \MT_smop_arg_D: \@nnil
\MH_else:
\MH_set_boolean_T:n {smop_one}
\MH_let:NwN \MT_smop_final_arg_B: \MT_smop_arg_C:
\MH_let:NwN \MT_smop_final_arg_C: \MT_smop_arg_D:
\MH_if_meaning:NN \MT_smop_arg_F: \@nnil
\MH_else:
\MH_set_boolean_T:n {smop_two}
\MH_let:NwN \MT_smop_final_arg_D: \MT_smop_arg_E:
\MH_let:NwN \MT_smop_final_arg_E: \MT_smop_arg_F:
\MH_fi:
\MH_fi:
\MH_fi:
% \end{macrocode}
% If A was not \cs{mathop}, it is an operator in itself, so we check
% if B is \cs{limits}
% \changes{v1.19}{2017/03/31}{Added MH\_ prefix}
% \begin{macrocode}
\MH_else:
\MH_if_meaning:NN \MT_smop_arg_B:\MT_smop_limits:
\def\MT_smop_final_arg_A:{#1}%
\MH_if_meaning:NN \MT_smop_arg_D: \@nnil
\MH_else:
\MH_set_boolean_T:n {smop_one}
\MH_let:NwN \MT_smop_final_arg_B: \MT_smop_arg_C:
\MH_let:NwN \MT_smop_final_arg_C: \MT_smop_arg_D:
\MH_if_meaning:NN \MT_smop_arg_F: \@nnil
\MH_else:
\MH_set_boolean_T:n {smop_two}
\MH_let:NwN \MT_smop_final_arg_D: \MT_smop_arg_E:
\MH_let:NwN \MT_smop_final_arg_E: \MT_smop_arg_F:
\MH_fi:
\MH_fi:
\MH_else:
% \end{macrocode}
% No \cs{limits} was found, so we already have the right input. Just
% forget about the last two arguments.
% \changes{v1.19}{2017/03/31}{Added MH\_ prefix}
% \begin{macrocode}
\def\MT_smop_final_arg_A:{#1}%
\MH_if_meaning:NN \MT_smop_arg_C: \@nnil
\MH_else:
\MH_set_boolean_T:n {smop_one}
\MH_let:NwN \MT_smop_final_arg_B: \MT_smop_arg_B:
\MH_let:NwN \MT_smop_final_arg_C: \MT_smop_arg_C:
\MH_if_meaning:NN \MT_smop_arg_D: \@nnil
\MH_else:
\MH_set_boolean_T:n {smop_two}
\MH_let:NwN \MT_smop_final_arg_D: \MT_smop_arg_D:
\MH_let:NwN \MT_smop_final_arg_E: \MT_smop_arg_E:
\MH_fi:
\MH_fi:
\MH_fi:
\MH_fi:
% \end{macrocode}
% No reason to measure if there's no sub or sup.
% \begin{macrocode}
\MH_if_boolean:nT {smop_one}{
\MT_smop_measure:NNNNN
\MT_smop_final_arg_A: \MT_smop_final_arg_B: \MT_smop_final_arg_C:
\MT_smop_final_arg_D: \MT_smop_final_arg_E:
}
\MT_smop_use:NNNNN
\MT_smop_final_arg_A: \MT_smop_final_arg_B: \MT_smop_final_arg_C:
\MT_smop_final_arg_D: \MT_smop_final_arg_E:
\endgroup
}
% \end{macrocode}
% \end{macro}
% Typeset what is necessary and ignore width of sub and sup:
% \begin{macrocode}
\def\MT_smop_needed_args:NNNNN #1#2#3#4#5{%
\displaystyle #1
\MH_if_boolean:nT {smop_one}{
% \end{macrocode}
% Let's use the internal versions of \cs{crampedclap} now that we now
% it is set in \cs{scriptstyle}.
% \begin{macrocode}
\limits#2{\MT_cramped_clap_internal:Nn \scriptstyle{#3}}
\MH_if_boolean:nT {smop_two}{
#4{\MT_cramped_clap_internal:Nn \scriptstyle{#5}}
}
}
}
% \end{macrocode}
% Measure the natural width. \cs{@tempdima} holds the dimen we need to
% adjust it all with.
% \begin{macrocode}
\def\MT_smop_measure:NNNNN #1#2#3#4#5{%
\MH_let:NwN \MT_saved_mathclap:Nn \MT_cramped_clap_internal:Nn
\MH_let:NwN \MT_cramped_clap_internal:Nn \@secondoftwo
\sbox\z@{$\m@th\MT_smop_needed_args:NNNNN #1#2#3#4#5$}
\MH_let:NwN \MT_cramped_clap_internal:Nn \MT_saved_mathclap:Nn
\sbox\tw@{$\m@th\displaystyle#1$}
\@tempdima=.5\wd0
\advance\@tempdima-.5\wd2
}
% \end{macrocode}
% The `l' variant
% \begin{macrocode}
\def\MT_smop_smash_l:NNNNN #1#2#3#4#5{
\MT_smop_needed_args:NNNNN #1#2#3#4#5\kern\@tempdima
}
% \end{macrocode}
% The `r' variant
% \begin{macrocode}
\def\MT_smop_smash_r:NNNNN #1#2#3#4#5{
\kern\@tempdima\MT_smop_needed_args:NNNNN #1#2#3#4#5
}
% \end{macrocode}
% The `lr' variant
% \begin{macrocode}
\def\MT_smop_smash_lr:NNNNN #1#2#3#4#5{
\MT_smop_needed_args:NNNNN #1#2#3#4#5
}
% \end{macrocode}
%
%
% \subsection{Adjusting limits}
%
%
% \begin{macro}{\MT_vphantom:Nn}
% \begin{macro}{\MT_hphantom:Nn}
% \begin{macro}{\MT_phantom:Nn}
% \begin{macro}{\MT_internal_phantom:N}
% The main advantage of \cs{phantom} et al., is the ability to
% choose the right size automatically, but it requires the input to
% be typeset four times. Since we will need to have a \cs{cramped}
% inside a \cs{vphantom} it is much, much faster to choose the style
% ourselves (we already know it). These macros make it possible.
% \begin{macrocode}
\def\MT_vphantom:Nn {\v@true\h@false\MT_internal_phantom:N}
\def\MT_hphantom:Nn {\v@false\h@true\MT_internal_phantom:N}
\def\MT_phantom:Nn {\v@true\h@true\MT_internal_phantom:N}
\def\MT_internal_phantom:N #1{
\ifmmode
\expandafter\mathph@nt\expandafter#1
\else
\expandafter\makeph@nt
\fi
}
% \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\adjustlimits}
% This is for making sure limits line up on two consecutive
% operators.
% \begin{macrocode}
\newcommand*\adjustlimits[6]{
% \end{macrocode}
% We measure the two operators and save the difference of their
% depths.
% \begin{macrocode}
\sbox\z@{$\m@th \displaystyle #1$}
\sbox\tw@{$\m@th \displaystyle #4$}
\@tempdima=\dp\z@ \advance\@tempdima-\dp\tw@
% \end{macrocode}
% We force \cs{displaystyle} for the operator and \cs{scripstyle}
% for the limit. If we make use of the regular \cs{smash},
% \cs{vphantom}, and \cs{cramped} macros, and let \TeX{} choose the
% right style for each one of them, we get a lot of redundant code
% as we have no need for the combination
% $(\cs{displaystyle},\cs{textstyle})$ etc. Only
% $(\cs{scriptstyle},\cs{scriptstyle})$ is useful.
% \changes{v1.19}{2017/03/31}{Added MH\_ prefix}
% \begin{macrocode}
\MH_if_dim:w \@tempdima>\z@
\mathop{#1}\limits#2{#3}
\MH_else:
\mathop{#1\MT_vphantom:Nn \displaystyle{#4}}\limits
#2{
\def\finsm@sh{\ht\z@\z@ \box\z@}
\mathsm@sh\scriptstyle{\MT_cramped_internal:Nn \scriptstyle{#3}}
\MT_vphantom:Nn \scriptstyle
{\MT_cramped_internal:Nn \scriptstyle{#6}}
}
\MH_fi:
\MH_if_dim:w \@tempdima>\z@
\mathop{#4\MT_vphantom:Nn \displaystyle{#1}}\limits
#5
{
\MT_vphantom:Nn \scriptstyle
{\MT_cramped_internal:Nn \scriptstyle{#3}}
\def\finsm@sh{\ht\z@\z@ \box\z@}
\mathsm@sh\scriptstyle{\MT_cramped_internal:Nn \scriptstyle{#6}}
}
\MH_else:
\mathop{#4}\limits#5{#6}
\MH_fi:
}
% \end{macrocode}
% \end{macro}
%
% \subsection{Swapping above display skip}
%
% \begin{macro}{\SwapAboveDisplaySkip}
% This macro is intended to be used at the start of \AmS\
% environments, in order to force it to use
% \cs{abovedisplayshortskip} instead of \cs{abovedisplayskip} above
% the displayed math. Because of the use of \cs{noalign} it will not
% work inside \env{equation} or \env{multline}.
% \begin{macrocode}
\newcommand\SwapAboveDisplaySkip{%
\noalign{\vskip-\abovedisplayskip\vskip\abovedisplayshortskip}
}
% \end{macrocode}
%
% \end{macro}
%
% \subsection{An aid to alignment}
%
% \begin{macro}{\MoveEqLeft}
% \changes{v1.05}{2008/06/05}{Added \cs{MoveEqLeft} (daleif)}
% \changes{v1.05b}{2008/06/18}{We don't need \cs{setlength} here
% (daleif), after discussion about \cs{global} and \cs{setlength}
% on ctt}
% \changes{v1.12}{2011/06/12}{We don't even need lengths. GL
% suggested on ctt to just apply them directly.}
% This is a very simple macro, we `move' a line in an
% alignment backwards in order to simulate that all subsequent lines
% have been indented. Note that simply using \verb+\kern-2m+ after
% the \verb+&+ is not enough, then the alignemnt environment never
% detects that there is anything (though simulated) in the cell
% before the \verb+&+.
% \begin{macrocode}
\newcommand\MoveEqLeft[1][2]{\kern #1em & \kern -#1em}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\Aboxed}
% \changes{v1.08}{2010/06/29}{Added \cs{Aboxed}}
% The idea from \cs{MoveEqLeft} can be used for other things. Here we
% create a macro that will allow a user to box an equation inside an
% alignment.
% \changes{v1.12}{2011/08/17}{\cs{Aboxed} reimplemented, cudos to GL}
% \begin{macrocode}
\newcommand\Aboxed[1]{\let\bgroup{\romannumeral-`}\@Aboxed#1&&\ENDDNE}
% \end{macrocode}
% \sloppy
% The macro has been reimplemented courtesy of Florent Chervet out of
% a posting on ctt, \url{https://groups.google.com/group/comp.text.tex/browse_thread/thread/5d66395f2a1b5134/93fd9661484bd8d8?#93fd9661484bd8d8}
% \begin{macrocode}
\def\@Aboxed#1\ENDDNE{%
\ifnum0=`{}\fi \setbox \z@
\hbox{$\displaystyle#1{}\m@th$\kern\fboxsep \kern\fboxrule }%
\edef\@tempa {\kern \wd\z@ &\kern -\the\wd\z@ \fboxsep
\the\fboxsep \fboxrule \the\fboxrule }\@tempa \boxed {#1#2}%
}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\ArrowBetweenLines}
% \changes{v1.05}{2008/06/05}{Added \cs{ArrowBetweenLines} as it
% belongs here and not just in my \LaTeX book (daleif)}
% ????Implementation notes are needed????
% \begin{macrocode}
\MHInternalSyntaxOff
\def\ArrowBetweenLines{\relax
\iffalse{\fi\ifnum0=`}\fi
\@ifstar{\ArrowBetweenLines@auxI{00}}{\ArrowBetweenLines@auxI{01}}}
\def\ArrowBetweenLines@auxI#1{%
\@ifnextchar[%
{\ArrowBetweenLines@auxII{#1}}%
{\ArrowBetweenLines@auxII{#1}[\Updownarrow]}}
\def\ArrowBetweenLines@auxII#1[#2]{%
\ifnum0=`{\fi \iffalse}\fi
% \end{macrocode}
% It turns out that for some reason the \cs{crcr} (next) removes the
% automatic equation number replacement. The replacement hack seems to
% the trick, though I have no idea why \cs{crcr} broke things (/daleif).
% \changes{v1.08}{2010/06/15}{fixed eq num replacement bug}
% \begin{macrocode}
% \crcr
\expandafter\in@\expandafter{\@currenvir}%
{alignedat,aligned,gathered}%
\ifin@ \else
\notag
\fi%
\\
\noalign{\nobreak\vskip-\baselineskip\vskip-\lineskip}%
\noalign{\expandafter\in@\expandafter{\@currenvir}%
{alignedat,aligned,gathered}%
\ifin@ \else\notag\fi%
}%
\if#1 &&\quad #2\else #2\quad\fi
\\\noalign{\nobreak\vskip-\lineskip}}
\MHInternalSyntaxOn
% \end{macrocode}
% \end{macro}
%
%
% \subsection{Centered vertical dots}
%
% Doing a \verb?\vdots? centered within a different sized box, is
% rather easy with the tools available. Note that it does \emph{not}
% check for the style we are running in, thus do not expect this to
% work well within \verb?\scriptstyle? and smaller. Basically we
% create a box of a width corresponding to \verb?{}#1{}? and center
% the \verb?\vdots? within it.
% \begin{macrocode}
\newcommand\vdotswithin[1]{%
{\mathmakebox[\widthof{\ensuremath{{}#1{}}}][c]{{\vdots}}}}
% \end{macrocode}
% Next we are inspired by \verb?\ArrowBetweenLines? and provide a
% costruction to be used within alignments with much less vertical
% space above and below.
%
% First in order to support \env{spreadlines} we need to store the
% original value of \verb?\jot? (and hope the user does not mess with it).
% \begin{macrocode}
\newlength\origjot
\setlength\origjot{\jot}
% \end{macrocode}
% Next define how much we spacing we flush out, and make this user adjustable.
% \begin{macrocode}
\newdimen\l_MT_shortvdotswithinadjustabove_dim
\newdimen\l_MT_shortvdotswithinadjustbelow_dim
\define@key{\MT_options_name:}
{shortvdotsadjustabove}{\setlength\l_MT_shortvdotswithinadjustabove_dim{#1}}
\define@key{\MT_options_name:}
{shortvdotsadjustbelow}{\setlength\l_MT_shortvdotswithinadjustbelow_dim{#1}}
% \end{macrocode}
% The actual defaults we found by trail and error.
% \begin{macrocode}
\setkeys{\MT_options_name:}{
shortvdotsadjustabove=2.15\origjot,
shortvdotsadjustbelow=\origjot
}
% \end{macrocode}
% The user macro comes in two versions, starred version corresponding
% to alignment \emph{before} and \verb?&? and a non-starred version
% with alignment \emph{after} \verb?&?.
% \begin{macrocode}
\def\shortvdotswithin{\relax
\@ifstar{\MT_svwi_aux:nn{00}}{\MT_svwi_aux:nn{01}}}
\def\MT_svwi_aux:nn #1#2{
\MTFlushSpaceAbove
\if#1 \vdotswithin{#2}& \else &\vdotswithin{#2} \fi
\MTFlushSpaceBelow
}
% \end{macrocode}
% We will need a way to remove any tags (eq. numbers) on the
% \verb?\vdots? line. We cannot use the method used by
% \verb?\ArrowBetweenLines? so we use inspiration from
% \texttt{etoolbox}.
% \begin{macrocode}
\def\MT_remove_tag_unless_inner:n #1{%
\begingroup
\def\etb@tempa##1|#1|##2\MT@END{\endgroup
\ifx\@empty##2\@empty\notag\fi}%
\expandafter\etb@tempa\expandafter|alignedat|aligned|split|#1|\MT@END}
%| emacs
% \end{macrocode}
% These macros take care of removing the space above or below. Since
% these may be useful for the user in very special cases, we provide
% them as separate macros.
% \begin{macrocode}
\newcommand\MTFlushSpaceAbove{
\expandafter\MT_remove_tag_unless_inner:n\expandafter{\@currenvir}
\\
\noalign{%
\nobreak\vskip-\baselineskip\vskip-\lineskip%
\vskip-\l_MT_shortvdotswithinadjustabove_dim
\vskip-\origjot
\vskip\jot
}%
\noalign{
\expandafter\MT_remove_tag_unless_inner:n\expandafter{\@currenvir}
}
}
\newcommand\MTFlushSpaceBelow{
\\\noalign{%
\nobreak\vskip-\lineskip
\vskip-\l_MT_shortvdotswithinadjustbelow_dim
\vskip-\origjot
\vskip\jot
}
}
% \end{macrocode}
%
%
% \section{A few extra symbols}
%
% Most math font sets are missing three symbols: \cs{nuparrow},
% \cs{ndownarrow} and \cs{bigtimes}. We provide \emph{simulated}
% versions of these symbols in case they are missing.
%
% \subsection{Negated up- and down arrows}
%
% Note that the \cs{nuparrow} and the \cs{ndownarrow} are made from
% \cs{nrightarrow} and \cs{nleftarrow}, so these have to be
% present. If they are not, we throw an error at use. The
% implementation details are due to Enrico Gregorio
% (\url{http://groups.google.com/group/comp.text.tex/msg/689cc8bd604fdb51}),
% the basic idea is to reflect and rotate existing negated
% arrows. Note that the reflection and rotation will not show up i
% most DVI previewers.
% \begin{macro}{\MH_nrotarrow:NN}
% \changes{v1.07}{2008/08/11}{Added support for \cs{nuparrow} and \cs{ndownaddow}}
% First a common construction macro.
% \begin{macrocode}
\def\MH_nrotarrow:NN #1#2{%
\setbox0=\hbox{$\m@th#1\uparrow$}\dimen0=\dp0
\setbox0=\hbox{%
\reflectbox{\rotatebox[origin=c]{90}{$\m@th#1\mkern2.22mu #2$}}}%
\dp0=\dimen0 \box0 \mkern2.3965mu
}
% \end{macrocode}
% \end{macro}
% The negated arrows are then made using this macro on respectively
% \cs{nrightarrow} and \cs{nleftarrow}
% \begin{macro}{\MH_nuparrow:}
% \begin{macro}{\MH_ndownarrow:}
% \begin{macrocode}
\def\MH_nuparrow: {%
\mathrel{\mathpalette\MH_nrotarrow:NN\nrightarrow} }
\def\MH_ndownarrow: {%
\mathrel{\mathpalette\MH_nrotarrow:NN\nleftarrow} }
% \end{macrocode}
% \end{macro}
% \end{macro}
% \begin{macro}{\nuparrow}
% \begin{macro}{\ndownarrow}
% Next we provide \cs{nuparrow} and \cs{ndownarrow} at begin
% document. Since they depend on \cs{nrightarrow} and
% \cs{nleftarrow} we test for these and let the macros throw an
% error if they are missing.
% \changes{v1.08b}{2010/07/21}{Moved graphicx loading down here such
% that we do not get into option clash problems}
% \begin{macrocode}
\AtBeginDocument{%
\RequirePackage{graphicx}%
\@ifundefined{nrightarrow}{%
\providecommand\nuparrow{%
\PackageError{mathtools}{\string\nuparrow\space~ is~
constructed~ from~ \string\nrightarrow,~ which~ is~ not~
provided.~ Please~ load~ the~ amssymb~ package~ or~ similar}{}
}}{ \providecommand\nuparrow{\MH_nuparrow:}}
\@ifundefined{nleftarrow}{%
\providecommand\ndownarrow{%
\PackageError{mathtools}{\string\ndownarrow\space~ is~
constructed~ from~ \string\nleftarrow,~ which~ is~ not~
provided.~ Please~ load~ the~ amssymb~ package~ or~ similar}{}
}}{ \providecommand\ndownarrow{\MH_ndownarrow:}} }
% \end{macrocode}
% \end{macro}
% \end{macro}
%
%
% \subsection{Providing bigtimes}
%
% The idea is to use the original \cs{times} and then scale it
% accordingly. Again the implementation details have been improved by
% Enrico Gregorio
% (\url{http://groups.google.com/group/comp.text.tex/msg/9685c9405df2ff94}).
%
% \begin{macro}{\MH_bigtimes_scaler:N}
% \begin{macro}{\MH_bigtimes_inner:}
% \begin{macro}{\MH_csym_bigtimes:}
% \changes{v1.07}{2008/08/11}{Added support for \cs{bigtimes}}
% \begin{macrocode}
\def\MH_bigtimes_scaler:N #1{%
\vcenter{\hbox{#1$\m@th\mkern-2mu\times\mkern-2mu$}}}
% \end{macrocode}
% This is then combined with \cs{mathchoice} to form the inner parts
% of the macro
% \begin{macrocode}
\def\MH_bigtimes_inner: {
\mathchoice{\MH_bigtimes_scaler:N \huge} % display style
{\MH_bigtimes_scaler:N \LARGE} % text style
{\MH_bigtimes_scaler:N {}} % script style
{\MH_bigtimes_scaler:N \footnotesize} % script script style
}
% \end{macrocode}
% And thus the internal prepresentaion of the \cs{bigtimes} macro.
% \begin{macrocode}
\def\MH_csym_bigtimes: {\mathop{\MH_bigtimes_inner:}\displaylimits}
% \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
% \begin{macro}{\bigtimes}
% In the end we provide \cs{bigtimes} if otherwise not defined.
% \begin{macrocode}
\AtBeginDocument{
\providecommand\bigtimes{\MH_csym_bigtimes:}
}
% \end{macrocode}
% \end{macro}
%
% \section{Macros by other people}
%
% \subsection{Intertext and short intertext}
%
% It turns out that \cs{intertext} use a bit too much
% space. Especially noticable if combined with the \env{spreadlines}
% environment, the extra space is also applied above and below
% \cs{intertext}, which ends up looking unproffesional. Chung-chieh
% Shan
% (\url{http://conway.rutgers.edu/~ccshan/wiki/blog/posts/Beyond_amsmath/})
% via Tobias Weh suggested a fix. We apply it here, but also keep the
% original \cs{intertext} in case a user would rather want it.
% \begin{macro}{\MT_orig_intertext:}
% \begin{macro}{\MT_intertext:}
% \changes{v1.13}{2012/08/19}{\cs{l_MT_X_intertext_dim} renamed to
% \cs{l_MT_X_intertext_sep}}
% \begin{macro}{\l_MT_above_intertext_sep}
% \begin{macro}{\l_MT_below_intertext_sep}
% First store the originam Ams version.
% \begin{macrocode}
\MH_let:NwN \MT_orig_intertext: \intertext@
% \end{macrocode}
% And then for some reconfiguration. First a few lengths
% \changes{v1.13}{2012/08/19}{Fixed typos and changed the names}
% \begin{macrocode}
\newdimen\l_MT_above_intertext_sep
\newdimen\l_MT_below_intertext_sep
\define@key{\MT_options_name:}
{aboveintertextdim}{\setlength\l_MT_above_intertext_sep{#1}}
\define@key{\MT_options_name:}
{belowintertextdim}{\setlength\l_MT_below_intertext_sep{#1}}
\define@key{\MT_options_name:}
{above-intertext-dim}{\setlength\l_MT_above_intertext_sep{#1}}
\define@key{\MT_options_name:}
{below-intertext-dim}{\setlength\l_MT_below_intertext_sep{#1}}
\define@key{\MT_options_name:}
{above-intertext-sep}{\setlength\l_MT_above_intertext_sep{#1}}
\define@key{\MT_options_name:}
{below-intertext-sep}{\setlength\l_MT_below_intertext_sep{#1}}
% \end{macrocode}
% Their default values are zero. Now for our extended version of
% CCShan's solution.
% \begin{macrocode}
\def\MT_intertext: {%
\def\intertext##1{%
\ifvmode\else\\\@empty\fi
\noalign{%
\penalty\postdisplaypenalty\vskip\belowdisplayskip
\vskip-\lineskiplimit % CCS
\vskip\normallineskiplimit % CCS
\vskip\l_MT_above_intertext_sep
\vbox{\normalbaselines
% \end{macrocode}
% \changes{v1.17}{2015/06/17}{Added extra `in list' check}
% Johannes Böttcher has reported a problem in \cs{intertext} in
% relation to usage within lists or constructs that locally changes
% the margin (often implemented as a list). Markus Kohm suggested to
% test not only \cs{linewidth} against \cs{columnwidth} but also if
% \cs{@totalleftmargin} is not zero. The implementation used is due to
% David Carlisle.
% \changes{v1.19}{2016/05/26}{Added \cs{ignorespaces} after
% \cs{noindent}, bug inherited from \pkg{amsmath}}
% \begin{macrocode}
\ifdim
\ifdim\@totalleftmargin=\z@
\linewidth
\else
-\maxdimen
\fi
=\columnwidth
\else \parshape\@ne \@totalleftmargin \linewidth
\fi
\noindent\ignorespaces##1\par}%
\penalty\predisplaypenalty\vskip\abovedisplayskip%
\vskip-\lineskiplimit % CCS
\vskip\normallineskiplimit % CCS
% \end{macrocode}
% \changes{v1.21}{2018/01/08}{Typo, it should use \texttt{\_below\_}
% not \texttt{\_above\_}}
% \begin{macrocode}
\vskip\l_MT_below_intertext_sep
}%
}%
% \end{macrocode}
% We might as well hook on to this and only activate
% \cs{shortintertext} whenever \cs{intertext} is active. This allows
% us to get the same error messages as \cs{intertext}.
% \changes{v1.19}{2017/03/31}{Added}
% \begin{macrocode}
% also activate \shortintertext, such that is is only available when
% \intertext is
\MH_let:NwN \shortintertext \shortintertext@
}
% \end{macrocode}
% And provide a key to switch
% \changes{v1.19}{2017/03/31}{Changed \cs{MT_orig_intertext_true:}}
% Changed \cs{MT_orig_intertext_true:} to also activate
% \cs{shortintertext}, because when this is active, our change to
% \cs{intertext@} is not active.
% \begin{macrocode}
\def\MT_orig_intertext_true: {
\MH_let:NwN \intertext@ \MT_orig_intertext:
\MH_let:NwN \shortintertext \shortintertext@
}
\def\MT_orig_intertext_false: { \MH_let:NwN \intertext@ \MT_intertext: }
\define@key{\MT_options_name:}{original-intertext}[true]{
\@nameuse{MT_orig_intertext_#1:}
}
% \end{macrocode}
% And use the new version as default.
% \begin{macrocode}
\setkeys{\MT_options_name:}{
original-intertext=false
}
% \end{macrocode}
%
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
%
% Gabriel Zachmann, Donald Arseneau on comp.text.tex 2000/05/12-13
% \begin{macro}{\shortintertext}
% \begin{macro}{\MT_orig_shortintertext}
% \begin{macro}{\MT_shortintertext}
% \begin{macro}{\l_above_shortintertext_sep}
% \begin{macro}{\l_below_shortintertext_sep}
% This is like \cs{intertext} but uses shorter skips between the
% math. Again this turned out to have the same problem as
% \cs{intertext}, so we provide two versions.
% \begin{macrocode}
\def\MT_orig_shortintertext:n #1{%
\ifvmode\else\\\@empty\fi
\noalign{%
\penalty\postdisplaypenalty\vskip\abovedisplayshortskip
\vbox{\normalbaselines
% \end{macrocode}
% \changes{v1.17}{2015/06/17}{Added extra `in list' check}
% Same comment as for \cs{intertext} above.
% \changes{v1.19}{2016/05/26}{Added \cs{ignorespaces} after
% \cs{noindent}, bug inherited from \pkg{amsmath}}
% \changes{v1.19}{2017/03/31}{Added MH\_ prefix}
% \begin{macrocode}
\MH_if_dim:w
\MH_if_dim:w \@totalleftmargin=\z@
\linewidth
\MH_else:
-\maxdimen
\MH_fi:
=\columnwidth
\MH_else:
\parshape\@ne \@totalleftmargin \linewidth
\MH_fi:
\noindent\ignorespaces#1\par}%
\penalty\predisplaypenalty\vskip\abovedisplayshortskip%
}%
}
% \end{macrocode}
% Lengths like above
% \changes{v1.13}{2012/08/19}{The option was named differently in the
% manual. Also renamed to use the postfix \emph{sep} instead. Though
% the old names remain for compatibility.}
% \changes{v1.14}{2014/01/20}{Apparently did not check it good enough,
% the option should have shortintertext not short-intertext}
% \begin{macrocode}
\newdimen\l_MT_above_shortintertext_sep
\newdimen\l_MT_below_shortintertext_sep
\define@key{\MT_options_name:}
{aboveshortintertextdim}{\setlength \l_MT_above_shortintertext_sep{#1}}
\define@key{\MT_options_name:}
{belowshortintertextdim}{\setlength \l_MT_below_shortintertext_sep{#1}}
\define@key{\MT_options_name:}
{above-short-intertext-dim}{\setlength \l_MT_above_shortintertext_sep{#1}}
% old typo in manual
\define@key{\MT_options_name:}
{below-short-intertext-dim}{\setlength \l_MT_below_shortintertext_sep{#1}}
\define@key{\MT_options_name:}
{above-short-intertext-sep}{\setlength \l_MT_above_shortintertext_sep{#1}}
% old typo in manual
\define@key{\MT_options_name:}
{below-short-intertext-sep}{\setlength \l_MT_below_shortintertext_sep{#1}}
\define@key{\MT_options_name:}
{above-shortintertext-sep}{\setlength \l_MT_above_shortintertext_sep{#1}}
\define@key{\MT_options_name:}
{below-shortintertext-sep}{\setlength \l_MT_below_shortintertext_sep{#1}}
% \end{macrocode}
% Looks best with the `old' values of the original \cs{jot}
% setting. So we set them to 3pt each.
% \begin{macrocode}
\setkeys{\MT_options_name:}{
aboveshortintertextdim=3pt,
belowshortintertextdim=3pt
}
% \end{macrocode}
% Next, just add the same as we did for \cs{intertext}
% \begin{macrocode}
\def\MT_shortintertext:n #1{%
\ifvmode\else\\\@empty\fi
\noalign{%
\penalty\postdisplaypenalty\vskip\abovedisplayshortskip
\vskip-\lineskiplimit
\vskip\normallineskiplimit
\vskip\l_MT_above_shortintertext_sep
\vbox{\normalbaselines
% \end{macrocode}
% \changes{v1.17}{2015/06/17}{Added extra `in list' check}
% Same comment as for \cs{intertext} above.
% \changes{v1.19}{2016/05/26}{Added \cs{ignorespaces} after
% \cs{noindent}, bug inherited from \pkg{amsmath}}
% \changes{v1.19}{2017/03/31}{Added MH\_ prefix}
% \begin{macrocode}
\MH_if_dim:w
\MH_if_dim:w \@totalleftmargin=\z@
\linewidth
\MH_else:
-\maxdimen
\MH_fi:
=\columnwidth
\MH_else:
\parshape\@ne \@totalleftmargin \linewidth
\MH_fi:
\noindent\ignorespaces#1\par}%
\penalty\predisplaypenalty\vskip\abovedisplayshortskip%
\vskip-\lineskiplimit
\vskip\normallineskiplimit
\vskip\l_MT_below_shortintertext_sep
}%
}
% \end{macrocode}
% Next we need to be able to switch.
% \changes{v1.19}{2017/03/31}{Changed \cs{shortintertext} to be
% internal here.}
% \begin{macrocode}
\def\MT_orig_shortintertext_true: { \MH_let:NwN \shortintertext@ \MT_orig_shortintertext:n }
\def\MT_orig_shortintertext_false: { \MH_let:NwN \shortintertext@ \MT_shortintertext:n }
% \end{macrocode}
% Next make \cs{shortintertext} a no-go everywhere. Thus \cs{shortintertext} is only
% available when \cs{intertext} is, or when
% \verb+original-intertext=true+ is used.
% \changes{v1.19}{2017/03/31}{Added}
% \begin{macrocode}
\newcommand{\shortintertext}{\@amsmath@err{\Invalid@@\shortintertext}\@eha}
% \end{macrocode}
% \begin{macrocode}
\define@key{\MT_options_name:}{original-shortintertext}[true]{
\@nameuse{MT_orig_shortintertext_#1:}
}
% \end{macrocode}
% With the updated one as the default.
% \begin{macrocode}
\setkeys{\MT_options_name:}{
original-shortintertext=false
}
% \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
%
% \subsection{Fine-tuning mathematical layout}
%
% \subsubsection{A complement to \texttt{\textbackslash smash},
% \texttt{\textbackslash llap}, and \texttt{\textbackslash rlap}}
% \begin{macro}{\clap}
% \begin{macro}{\mathllap}
% \begin{macro}{\mathrlap}
% \begin{macro}{\mathclap}
% \begin{macro}{\MT_mathllap:Nn}
% \begin{macro}{\MT_mathrlap:Nn}
% \begin{macro}{\MT_mathclap:Nn}
% First we'll \cs{provide} those macros (they are so simple that I
% think other packages might define them as well).
% \begin{macrocode}
\providecommand*\clap[1]{\hb@xt@\z@{\hss#1\hss}}
\providecommand*\mathllap[1][\@empty]{
\ifx\@empty#1\@empty
\expandafter \mathpalette \expandafter \MT_mathllap:Nn
\else
\expandafter \MT_mathllap:Nn \expandafter #1
\fi
}
\providecommand*\mathrlap[1][\@empty]{
\ifx\@empty#1\@empty
\expandafter \mathpalette \expandafter \MT_mathrlap:Nn
\else
\expandafter \MT_mathrlap:Nn \expandafter #1
\fi
}
\providecommand*\mathclap[1][\@empty]{
\ifx\@empty#1\@empty
\expandafter \mathpalette \expandafter \MT_mathclap:Nn
\else
\expandafter \MT_mathclap:Nn \expandafter #1
\fi
}
% \end{macrocode}
% We have to insert |{}| because we otherwise risk triggering a
% ``feature'' in \TeX.
% \begin{macrocode}
\def\MT_mathllap:Nn #1#2{{}\llap{$\m@th#1{#2}$}}
\def\MT_mathrlap:Nn #1#2{{}\rlap{$\m@th#1{#2}$}}
\def\MT_mathclap:Nn #1#2{{}\clap{$\m@th#1{#2}$}}
% \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \begin{macro}{\mathmbox}
% \begin{macro}{\MT_mathmbox:nn}
% \begin{macro}{\mathmakebox}
% \begin{macro}{\MT_mathmakebox_I:w}
% \begin{macro}{\MT_mathmakebox_II:w}
% \begin{macro}{\MT_mathmakebox_III:w}
% Then the \cs{mathmbox}\marg{arg} and
% \cs{mathmakebox}\oarg{width}\oarg{pos}\marg{arg} macros which are
% very similar to \cs{mbox} and \cs{makebox}. The differences are:
% \begin{itemize}
% \item \meta{arg} is set in math mode of course.
% \item No need for \cs{leavevmode} as we're in math mode.
% \item No need to make them \cs{long} (we're still in math mode).
% \item No need to support a picture version.
% \end{itemize}
% The first is easy.
% \begin{macrocode}
\providecommand*\mathmbox{\mathpalette\MT_mathmbox:nn}
\def\MT_mathmbox:nn #1#2{\mbox{$\m@th#1#2$}}
% \end{macrocode}
% We scan for the optional arguments first.
% \begin{macrocode}
\providecommand*\mathmakebox{
\@ifnextchar[ \MT_mathmakebox_I:w
\mathmbox}
\def\MT_mathmakebox_I:w[#1]{%
\@ifnextchar[ {\MT_mathmakebox_II:w[#1]}
{\MT_mathmakebox_II:w[#1][c]}}
% \end{macrocode}
% We had to get the optional arguments out of the way before calling
% upon the powers of \cs{mathpalette}.
% \begin{macrocode}
\def\MT_mathmakebox_II:w[#1][#2]{
\mathpalette{\MT_mathmakebox_III:w[#1][#2]}}
\def\MT_mathmakebox_III:w[#1][#2]#3#4{%
\@begin@tempboxa\hbox{$\m@th#3#4$}%
\setlength\@tempdima{#1}%
\hbox{\hb@xt@\@tempdima{\csname bm@#2\endcsname}}%
\@end@tempboxa}
% \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \begin{macro}{\mathsm@sh}
% Fix \cs{smash}.
% \begin{macrocode}
\def\mathsm@sh#1#2{%
\setbox\z@\hbox{$\m@th#1{#2}$}{}\finsm@sh}
% \end{macrocode}
% \end{macro}
%
%
% \subsubsection{A cramped style}
%
% comp.text.tex on 1992/07/21 by Michael Herschorn.
% With speed-ups by the Grand Wizard himself as shown on
% \begin{quote}\rightskip-\leftmargini
% \url{http://mirrors.ctan.org/info/digests/tex-implementors/042}
% \end{quote}
% The (better) user interface by the author.
%
% \begin{macro}{\cramped}
% Make sure the expansion is timed correctly.
% \begin{macrocode}
\providecommand*\cramped[1][\@empty]{
\ifx\@empty#1\@empty
\expandafter \mathpalette \expandafter \MT_cramped_internal:Nn
\else
\expandafter \MT_cramped_internal:Nn \expandafter #1
\fi
}
% \end{macrocode}
% \end{macro}
% \begin{macro}{\MT_cramped_internal:Nn}
% The internal command.
% \begin{macrocode}
\def\MT_cramped_internal:Nn #1#2{
% \end{macrocode}
% Create a box containing the math and force a cramped style by
% issuing a non-existing radical.
% \begin{macrocode}
\sbox\z@{$\m@th#1\nulldelimiterspace=\z@\radical\z@{#2}$}
% \end{macrocode}
% Then make sure the height is correct.
% \begin{macrocode}
\ifx#1\displaystyle
\dimen@=\fontdimen8\textfont3
\advance\dimen@ .25\fontdimen5\textfont2
\else
\dimen@=1.25\fontdimen8
\ifx#1\textstyle\textfont
\else
\ifx#1\scriptstyle
\scriptfont
\else
\scriptscriptfont
\fi
\fi
3
\fi
\advance\dimen@-\ht\z@ \ht\z@=-\dimen@
\box\z@
}
% \end{macrocode}
% \end{macro}
%
% \subsubsection{Cramped versions of \texttt{\textbackslash
% mathllap}, \texttt{\textbackslash mathclap}, and
% \texttt{\textbackslash mathrlap}}
% \begin{macro}{\crampedllap}
% \begin{macro}{\MT_cramped_llap_internal:Nn}
% \begin{macro}{\crampedclap}
% \begin{macro}{\MT_cramped_clap_internal:Nn}
% \begin{macro}{\crampedrlap}
% \begin{macro}{\MT_cramped_rlap_internal:Nn}
% Cramped versions of \cs{mathXlap} (for speed). Made by the author.
% \begin{macrocode}
\providecommand*\crampedllap[1][\@empty]{
\ifx\@empty#1\@empty
\expandafter \mathpalette \expandafter \MT_cramped_llap_internal:Nn
\else
\expandafter \MT_cramped_llap_internal:Nn \expandafter #1
\fi
}
\def\MT_cramped_llap_internal:Nn #1#2{
{}\llap{\MT_cramped_internal:Nn #1{#2}}
}
\providecommand*\crampedclap[1][\@empty]{
\ifx\@empty#1\@empty
\expandafter \mathpalette \expandafter \MT_cramped_clap_internal:Nn
\else
\expandafter \MT_cramped_clap_internal:Nn \expandafter #1
\fi
}
\def\MT_cramped_clap_internal:Nn #1#2{
{}\clap{\MT_cramped_internal:Nn #1{#2}}
}
\providecommand*\crampedrlap[1][\@empty]{
\ifx\@empty#1\@empty
\expandafter \mathpalette \expandafter \MT_cramped_rlap_internal:Nn
\else
\expandafter \MT_cramped_rlap_internal:Nn \expandafter #1
\fi
}
\def\MT_cramped_rlap_internal:Nn #1#2{
{}\rlap{\MT_cramped_internal:Nn #1{#2}}
}
% \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
%
%
% \section{Macros by Michael J.~Downes}
%
% The macros in this section are all by Michael J.~Downes. Either
% they are straight copies of his original macros or inspired and
% extended here.
%
%
% \subsection{Prescript}
% \begin{macro}{\prescript}
% This command is taken from a posting to comp.text.tex on
% December~20th 2000 by Michael J.~Downes. The comments are his. I
% have added some formatting options to the arguments so that a user
% can emulate the \pkg{isotope} package.
%
% \changes{v.1.12}{2012/04/19}{Extended \cs{prescript} to change style
% if used in say S context. Requestd by Oliver Buerschaper.}
% Update 2012: One drawback from MJD's original implementation, is
% that the math style is hardwired, such that if used in say
% \cs{scriptstyle} context, then the style/size of the prescript
% remain the same size. A slightly expensive fix, is to use the
% \cs{mathchoice} construction. First exdent MJD's code a little
% (keeping his comments)
% \begin{macro}{\MT_prescript_inner:}
% We make the style an extra forth argument
% \begin{macrocode}
\newcommand{\MT_prescript_inner:}[4]{
% \end{macrocode}
% Put the sup in box 0 and the sub in box 2.
% \changes{v1.19}{2017/03/31}{Added MH\_ prefix}
% \begin{macrocode}
\@mathmeasure\z@#4{\MT_prescript_sup:{#1}}
\@mathmeasure\tw@#4{\MT_prescript_sub:{#2}}
\MH_if_dim:w \wd\tw@>\wd\z@
\setbox\z@\hbox to\wd\tw@{\hfil\unhbox\z@}
\MH_else:
\setbox\tw@\hbox to\wd\z@{\hfil\unhbox\tw@}
\MH_fi:
% \end{macrocode}
% Do not let a preceding mathord symbol approach without any
% intervening space.
% \begin{macrocode}
\mathop{}
% \end{macrocode}
% Use \cs{mathopen} to suppress space between the prescripts and the
% base object even when the latter is not of type ord.
% \begin{macrocode}
\mathopen{\vphantom{\MT_prescript_arg:{#3}}}^{\box\z@}\sb{\box\tw@}
\MT_prescript_arg:{#3}
}
% \end{macrocode}
% \end{macro}
% Next create \cs{prescript} using \cs{mathchoice}
% \begin{macrocode}
\DeclareRobustCommand{\prescript}[3]{
\mathchoice
% \end{macrocode}
% In D and T style, we use MJD's default:
% \begin{macrocode}
{\MT_prescript_inner:{#1}{#2}{#3}{\scriptstyle}}
{\MT_prescript_inner:{#1}{#2}{#3}{\scriptstyle}}
% \end{macrocode}
% In the others we step one style down. Of couse in SS style, using
% \cs{scriptscript} may seem wrong, but there is no lower style.
% \begin{macrocode}
{\MT_prescript_inner:{#1}{#2}{#3}{\scriptscriptstyle}}
{\MT_prescript_inner:{#1}{#2}{#3}{\scriptscriptstyle}}
}
% \end{macrocode}
% \end{macro}
% Then the named arguments. Can you see I'm preparing for templates?
% \begin{macrocode}
\define@key{\MT_options_name:}
{prescript-sup-format}{\def\MT_prescript_sup:{#1}}
\define@key{\MT_options_name:}
{prescript-sub-format}{\def\MT_prescript_sub:{#1}}
\define@key{\MT_options_name:}
{prescript-arg-format}{\def\MT_prescript_arg:{#1}}
\setkeys{\MT_options_name:}{
prescript-sup-format={},
prescript-sub-format={},
prescript-arg-format={},
}
% \end{macrocode}
%
% \subsection{Math sizes}
% \begin{macro}{\@DeclareMathSizes}
% This command is taken from a posting to comp.text.tex on
% October~17th 2002 by Michael J.~Downes. The purpose is to be able
% to put dimensions on the last three arguments of
% \cs{DeclareMathSizes}.
%
% As of 2015, this fix has made it into the \LaTeX{} kernel. Thus we
% only provide the fix for older kernels.
% \changes{v1.18}{2015/11/12}{This was now moved into the kernel, thus
% we only provide it for older kernels}
% \changes{v1.19}{2017/03/31}{Added MH\_ prefix}
% \begin{macrocode}
\ifx\e@alloc\@undefined% kernel thus older than 2015
\def\@DeclareMathSizes #1#2#3#4#5{%
\@defaultunits\dimen@ #2pt\relax\@nnil
\MH_if:w $#3$%
\MH_let:cN {S@\strip@pt\dimen@}\math@fontsfalse
\MH_else:
\@defaultunits\dimen@ii #3pt\relax\@nnil
\@defaultunits\@tempdima #4pt\relax\@nnil
\@defaultunits\@tempdimb #5pt\relax\@nnil
\toks@{#1}%
\expandafter\xdef\csname S@\strip@pt\dimen@\endcsname{%
\gdef\noexpand\tf@size{\strip@pt\dimen@ii}%
\gdef\noexpand\sf@size{\strip@pt\@tempdima}%
\gdef\noexpand\ssf@size{\strip@pt\@tempdimb}%
\the\toks@
}%
\MH_fi:
}
\fi
% \end{macrocode}
% \end{macro}
%
% \subsection{Mathematics within italic text}
% mathic: Michael J.~Downes on comp.text.tex, 1998/05/14.
% \begin{macro}{\MT_mathic_true:}
% \begin{macro}{\MT_mathic_false:}
% Renew \cs{(} so that it detects the slant of the font and inserts
% an italic correction. In January 2013 Andrew Swann suggested that
% this should be made robust. It is a little tricky, but seems to
% work.
% \changes{v1.13}{2013/02/11}{Added robustness code}
% \begin{macrocode}
\def\MT_mathic_true: {
\MH_if_boolean:nF {math_italic_corr}{
\MH_set_boolean_T:n {math_italic_corr}
% \end{macrocode}
% Save the original meaning if you need to go back (note that this
% does not save the robust part of the macro, we fix this later on by
% rerobustifying).
% \changes{v1.19}{2017/03/31}{Added MH\_ prefix}
% \begin{macrocode}
\MH_if_boolean:nTF {robustify}{
\MH_let:NwN \MT_mathic_redeffer: \DeclareRobustCommand
}{
\MH_let:NwN \MT_mathic_redeffer: \renewcommand
}
\MH_let:NwN \MT_begin_inlinemath: \(
%\renewcommand*\({
\MT_mathic_redeffer:*\({
\relax\ifmmode\@badmath\else
\ifhmode
\MH_if_dim:w \fontdimen\@ne\font>\z@
% \end{macrocode}
% We have a small problem here, if the user use >>\verb|text~\(|<< then
% the italic correction is lost due to the penalty (see \cite{TBT},
% section 4.3.3). However, we \emph{know} what \verb|~| does, a
% (positive) penalty and a skip.
% \changes{v1.19}{2017/03/31}{Added MH\_ prefix}
% \begin{macrocode}
\MH_if_dim:w \lastskip>\z@
\skip@\lastskip\unskip
% \end{macrocode}
% \changes{v1.15}{2014/07/16}{Added penalty workaround}
% Here is the fix.
% \changes{v1.19}{2017/03/31}{Added MH\_ prefix}
% \begin{macrocode}
\MH_if_num:w \lastpenalty>\z@
\count@\lastpenalty\unpenalty
\MH_fi:
\@@italiccorr
% \end{macrocode}
% \changes{v1.15}{2014/07/16}{Added penalty workaround}
% And here it is inserted again.
% \changes{v1.19}{2017/03/31}{Added MH\_ prefix}
% \begin{macrocode}
\MH_if_num:w \count@>\z@
\penalty\count@
\MH_fi:
\hskip\skip@
\MH_else:
\@@italiccorr
\MH_fi:
\MH_fi:
\MH_fi:
$\MH_fi:
}
}
}
%$ for emacs coloring ;-)
% \end{macrocode}
% Just for restoring the old behavior.
% \begin{macrocode}
\def\MT_mathic_false: {
\MH_if_boolean:nT {math_italic_corr}{
\MH_set_boolean_F:n {math_italic_corr}
% \end{macrocode}
% When \cs{(} is robust, we cannot simply relet it to the old value,
% as all the robust macro is not saved. Instead we redefined partly
% and force robustness.
% \begin{macrocode}
\MH_if_boolean:nTF {robustify}{
\edef\({\MT_begin_inlinemath:}%
\forced_EQ_MakeRobust\(%
}{
\MH_let:NwN \( \MT_begin_inlinemath:
}
}
}
\MH_new_boolean:n {math_italic_corr}
\define@key{\MT_options_name:}{mathic}[true]{
\@ifundefined{MT_mathic_#1:}
{ \MT_true_false_error:
\@nameuse{MT_mathic_false:}
}
{ \@nameuse{MT_mathic_#1:} }
}
% \end{macrocode}
% \end{macro}
% \end{macro}
%
% \subsection{Spreading equations}
%
% Michael J.~Downes on comp.text.tex 1999/08/25
% \begin{environment}{spreadlines}
% This is meant to be used outside math, just like
% \env{subequations}.
% \begin{macrocode}
\newenvironment{spreadlines}[1]{
\setlength{\jot}{#1}
\ignorespaces
}{ \ignorespacesafterend }
% \end{macrocode}
% \end{environment}
%
% \subsection{Gathered}
%
% Inspired by Michael J.~Downes on comp.text.tex 2002/01/17.
% \begin{environment}{MT_gathered_env}
% Just like the normal \env{gathered}, only here we're allowed to
% specify actions before and after each line.
% \changes{2017/10/30}{v1.20}{added \cs{alignedspace@left} instead of
% \cs{null}\cs{,} as in the other amsmath adjustments}
% \begin{macrocode}
\MaybeMHPrecedingSpacesOff
\newenvironment{MT_gathered_env}[1][c]{%
\RIfM@\else
\nonmatherr@{\begin{\@currenvir}}%
\fi
%\null\,%
\alignedspace@left%
\if #1t\vtop \else \if#1b\vbox \else \vcenter \fi\fi \bgroup
\Let@ \chardef\dspbrk@context\@ne \restore@math@cr
\spread@equation
\ialign\bgroup
\MT_gathered_pre:
\strut@$\m@th\displaystyle##$
\MT_gathered_post:
\crcr
}{%
\endaligned
\MT_gathered_env_end:
}
\MHPrecedingSpacesOn
% \end{macrocode}
% \end{environment}
% \begin{macro}{\newgathered}
% \begin{macro}{\renewgathered}
% \begin{environment}{lgathered}
% \begin{environment}{rgathered}
% \begin{environment}{gathered}
% An easier interface.
% \begin{macrocode}
\newcommand*\newgathered[4]{
\newenvironment{#1}
{ \def\MT_gathered_pre:{#2}
\def\MT_gathered_post:{#3}
\def\MT_gathered_env_end:{#4}
\MT_gathered_env
}{\endMT_gathered_env}
}
\newcommand*\renewgathered[4]{
\renewenvironment{#1}
{ \def\MT_gathered_pre:{#2}
\def\MT_gathered_post:{#3}
\def\MT_gathered_env_end:{#4}
\MT_gathered_env
}{\endMT_gathered_env}
}
\newgathered{lgathered}{}{\hfil}{}
\newgathered{rgathered}{\hfil}{}{}
\renewgathered{gathered}{\hfil}{\hfil}{}
% \end{macrocode}
% \end{environment}
% \end{environment}
% \end{environment}
% \end{macro}
% \end{macro}
%
% \subsection{Split fractions}
%
% Michael J.~Downes on comp.text.tex 2001/12/06.
% \begin{macro}{\splitfrac}
% \begin{macro}{\splitdfrac}
% These commands use \cs{genfrac} to typeset a split fraction. The
% thickness of the fraction rule is simply set to zero.
% \begin{macrocode}
\newcommand*\splitfrac[2]{%
\genfrac{}{}{0pt}{1}%
{\textstyle#1\quad\hfill}%
{\textstyle\hfill\quad\mathstrut#2}%
}
\newcommand*\splitdfrac[2]{%
\genfrac{}{}{0pt}{0}{#1\quad\hfill}{\hfill\quad\mathstrut #2}%
}
% \end{macrocode}
% \end{macro}
% \end{macro}
%
%
% \section{Bug fixes for \pkg{amsmath}}
% The following fixes some bugs in \pkg{amsmath}, but only if the
% switch is true.
% \begin{macrocode}
\MH_if_boolean:nT {fixamsmath}{
% \end{macrocode}
% \begin{macro}{\place@tag}
% This corrects a bug in \pkg{amsmath} affecting tag placement in
% \env{flalign}.\footnote{See
% \url{http://www.latex-project.org/cgi-bin/ltxbugs2html?pr=amslatex/3591}}
% \begin{macrocode}
\def\place@tag{%
\iftagsleft@
\kern-\tagshift@
% \end{macrocode}
% The addition. If we're in \env{flalign} (meaning
% $\cs{xatlevel@}=\cs{tw@}$) we skip back by an amount of
% \cs{@mathmargin}. This test is also true for the \env{xxalignat}
% environment, but it doesn't matter because a)~it's not
% supported/described in the documentation anymore so new users
% won't know about it and b)~it forbids the use of \cs{tag}
% anyway.
% \changes{v1.19}{2017/03/31}{Added MH\_ prefix}
% \begin{macrocode}
\if@fleqn
\MH_if_num:w \xatlevel@=\tw@
\kern-\@mathmargin
\MH_fi:
\MH_fi:
% \end{macrocode}
% End of additions.
% \changes{v1.19}{2017/03/31}{Added MH\_ prefix}
% \begin{macrocode}
\MH_if:w 1\shift@tag\row@\relax
\rlap{\vbox{%
\normalbaselines
\boxz@
\vbox to\lineht@{}%
\raise@tag
}}%
\MH_else:
\rlap{\boxz@}%
\MH_fi:
\kern\displaywidth@
\MH_else:
\kern-\tagshift@
\MH_if:w 1\shift@tag\row@\relax
\llap{\vtop{%
\raise@tag
\normalbaselines
\setbox\@ne\null
\dp\@ne\lineht@
\box\@ne
\boxz@
}}%
\MH_else:
\llap{\boxz@}%
\MH_fi:
\MH_fi:
}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\x@calc@shift@lf}
% This corrects a bug\footnote{See
% \url{http://www.latex-project.org/cgi-bin/ltxbugs2html?pr=amslatex/3614}}
% in \pkg{amsmath} that could cause a non-positive value of the dimension
% \cs{@mathmargin} to cause an
% \begin{verbatim}
% ! Arithmetic overflow.
% <recently read> \@tempcntb
% \end{verbatim}
% when in \mode{fleqn,leqno} mode. Not very comprehensible for the user.
% \changes{v1.19}{2017/03/31}{Added MH\_ prefix}
% \begin{macrocode}
\def\x@calc@shift@lf{%
\MH_if_dim:w \eqnshift@=\z@
\global\eqnshift@\@mathmargin\relax
\alignsep@\displaywidth
\advance\alignsep@-\totwidth@
% \end{macrocode}
% The addition: If \cs{@tempcntb} is zero we avoid division.
% \changes{v1.19}{2017/03/31}{Added MH\_ prefix}
% \begin{macrocode}
\MH_if_num:w \@tempcntb=0
\MH_else:
\global\divide\alignsep@\@tempcntb % original line
\MH_fi:
% \end{macrocode}
% Addition end.
% \changes{v1.19}{2017/03/31}{Added MH\_ prefix}
% \begin{macrocode}
\MH_if_dim:w \alignsep@<\minalignsep\relax
\global\alignsep@\minalignsep\relax
\MH_fi:
\MH_fi:
\MH_if_dim:w \tag@width\row@>\@tempdima
\saveshift@1%
\MH_else:
\saveshift@0%
\MH_fi:}%
% \end{macrocode}
% \end{macro}
% \begin{macrocode}
}
% \end{macrocode}
% End of bug fixing.
%
% \subsection{Making environments safer}
%
% \begin{macro}{\aligned@a}
% Here we make the \pkg{amsmath} inner environments disallow spaces
% before their optional positioning specifier.
% \begin{macrocode}
\MaybeMHPrecedingSpacesOff
\renewcommand\aligned@a[1][c]{\start@aligned{#1}\m@ne}
\MHPrecedingSpacesOn
% \end{macrocode}
% \end{macro}
%
% This is the end of the \pkg{mathtools} package.
% \begin{macrocode}
%</package>
% \end{macrocode}
%
% \Finale
\endinput
|