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 6111 6112 6113 6114 6115 6116 6117 6118 6119 6120 6121 6122 6123 6124 6125 6126 6127 6128 6129 6130 6131 6132 6133 6134 6135 6136 6137 6138 6139 6140 6141 6142 6143 6144 6145 6146 6147 6148 6149 6150 6151 6152 6153 6154 6155 6156 6157 6158 6159 6160 6161 6162 6163 6164 6165 6166 6167 6168 6169 6170 6171 6172 6173 6174 6175 6176 6177 6178 6179 6180 6181 6182 6183 6184 6185 6186 6187 6188 6189 6190 6191 6192 6193 6194 6195 6196 6197 6198 6199 6200 6201 6202 6203 6204 6205 6206 6207 6208 6209 6210 6211 6212 6213 6214 6215 6216 6217 6218 6219 6220 6221 6222 6223 6224 6225 6226 6227 6228 6229 6230 6231 6232 6233 6234 6235 6236 6237 6238 6239 6240 6241 6242 6243 6244 6245 6246 6247 6248 6249 6250 6251 6252 6253 6254 6255 6256 6257 6258 6259 6260 6261 6262 6263 6264 6265 6266 6267 6268 6269 6270 6271 6272 6273 6274 6275 6276 6277 6278 6279 6280 6281 6282 6283 6284 6285 6286 6287 6288 6289 6290 6291 6292 6293 6294 6295 6296 6297 6298 6299 6300 6301 6302 6303 6304 6305 6306 6307 6308 6309 6310 6311 6312 6313 6314 6315 6316 6317 6318 6319 6320 6321 6322 6323 6324 6325 6326 6327 6328 6329 6330 6331 6332 6333 6334 6335 6336 6337 6338 6339 6340 6341 6342 6343 6344 6345 6346 6347 6348 6349 6350 6351 6352 6353 6354 6355 6356 6357 6358 6359 6360 6361 6362 6363 6364 6365 6366 6367 6368 6369 6370 6371 6372 6373 6374 6375 6376 6377 6378 6379 6380 6381 6382 6383 6384 6385 6386 6387 6388 6389 6390 6391 6392 6393 6394 6395 6396 6397 6398 6399 6400 6401 6402 6403 6404 6405 6406 6407 6408 6409 6410 6411 6412 6413 6414 6415 6416 6417 6418 6419 6420 6421 6422 6423 6424 6425 6426 6427 6428 6429 6430 6431 6432 6433 6434 6435 6436 6437 6438 6439 6440 6441 6442 6443 6444 6445 6446 6447 6448 6449 6450 6451 6452 6453 6454 6455 6456 6457 6458 6459 6460 6461 6462 6463 6464 6465 6466 6467 6468 6469 6470 6471 6472 6473 6474 6475 6476 6477 6478 6479 6480 6481 6482 6483 6484 6485 6486 6487 6488 6489 6490 6491 6492 6493 6494 6495 6496 6497 6498 6499 6500 6501 6502 6503 6504 6505 6506 6507 6508 6509 6510 6511 6512 6513 6514 6515 6516 6517 6518 6519 6520 6521 6522 6523 6524 6525 6526 6527 6528 6529 6530 6531 6532 6533 6534 6535 6536 6537 6538 6539 6540 6541 6542 6543 6544 6545 6546 6547 6548 6549 6550 6551 6552 6553 6554 6555 6556 6557 6558 6559 6560 6561 6562 6563 6564 6565 6566 6567 6568 6569 6570 6571 6572 6573 6574 6575 6576 6577 6578 6579 6580 6581 6582 6583 6584 6585 6586 6587 6588 6589 6590 6591 6592 6593 6594 6595 6596 6597 6598 6599 6600 6601 6602 6603 6604 6605 6606 6607 6608 6609 6610 6611 6612 6613 6614 6615 6616 6617 6618 6619 6620 6621 6622 6623 6624 6625 6626 6627 6628 6629 6630 6631 6632 6633 6634 6635 6636 6637 6638 6639 6640 6641 6642 6643 6644 6645 6646 6647 6648 6649 6650 6651 6652 6653 6654 6655 6656 6657 6658 6659 6660 6661 6662 6663 6664 6665 6666 6667 6668 6669 6670 6671 6672 6673 6674 6675 6676 6677 6678 6679 6680 6681 6682 6683 6684 6685 6686 6687 6688 6689 6690 6691 6692 6693 6694 6695 6696 6697 6698 6699 6700 6701 6702 6703 6704 6705 6706 6707 6708 6709 6710 6711 6712 6713 6714 6715 6716 6717 6718 6719 6720 6721 6722 6723 6724 6725 6726 6727 6728 6729 6730 6731 6732 6733 6734 6735 6736 6737 6738 6739 6740 6741 6742 6743 6744 6745 6746 6747 6748 6749 6750 6751 6752 6753 6754 6755 6756 6757 6758 6759 6760 6761 6762 6763 6764 6765 6766 6767 6768 6769 6770 6771 6772 6773 6774 6775 6776 6777 6778 6779 6780 6781 6782 6783 6784 6785 6786 6787 6788 6789 6790 6791 6792 6793 6794 6795 6796 6797 6798 6799 6800 6801 6802 6803 6804 6805 6806 6807 6808 6809 6810 6811 6812 6813 6814 6815 6816 6817 6818 6819 6820 6821 6822 6823 6824 6825 6826 6827 6828 6829 6830 6831 6832 6833 6834 6835 6836 6837 6838 6839 6840 6841 6842 6843 6844 6845 6846 6847 6848 6849 6850 6851 6852 6853 6854 6855 6856 6857 6858 6859 6860 6861 6862 6863 6864 6865 6866 6867 6868 6869 6870 6871 6872 6873 6874 6875 6876 6877 6878 6879 6880 6881 6882 6883 6884 6885 6886 6887 6888 6889 6890 6891 6892 6893 6894 6895 6896 6897 6898 6899 6900 6901 6902 6903 6904 6905 6906 6907 6908 6909 6910 6911 6912 6913 6914 6915 6916 6917 6918 6919 6920 6921 6922 6923 6924 6925 6926 6927 6928 6929 6930 6931 6932 6933 6934 6935 6936 6937 6938 6939 6940 6941 6942 6943 6944 6945 6946 6947 6948 6949 6950 6951 6952 6953 6954 6955 6956 6957 6958 6959 6960 6961 6962 6963 6964 6965 6966 6967 6968 6969 6970 6971 6972 6973 6974 6975 6976 6977 6978 6979 6980 6981 6982 6983 6984 6985 6986 6987 6988 6989 6990 6991 6992 6993 6994 6995 6996 6997 6998 6999 7000 7001 7002 7003 7004 7005 7006 7007 7008 7009 7010 7011 7012 7013 7014 7015 7016 7017 7018 7019 7020 7021 7022 7023 7024 7025 7026 7027 7028 7029 7030 7031 7032 7033 7034 7035 7036 7037 7038 7039 7040 7041 7042 7043 7044 7045 7046 7047 7048 7049 7050 7051 7052 7053 7054 7055 7056 7057 7058 7059 7060 7061 7062 7063 7064 7065 7066 7067 7068 7069 7070 7071 7072 7073 7074 7075 7076 7077 7078 7079 7080 7081 7082 7083 7084 7085 7086 7087 7088 7089 7090 7091 7092 7093 7094 7095 7096 7097 7098 7099 7100 7101 7102 7103 7104 7105 7106 7107 7108 7109 7110 7111 7112 7113 7114 7115 7116 7117 7118 7119 7120 7121 7122 7123 7124 7125 7126 7127 7128 7129 7130 7131 7132 7133 7134 7135 7136 7137 7138 7139 7140 7141 7142 7143 7144 7145 7146 7147 7148 7149 7150 7151 7152 7153 7154 7155 7156 7157 7158 7159 7160 7161 7162 7163 7164 7165 7166 7167 7168 7169 7170 7171 7172 7173 7174 7175 7176 7177 7178 7179 7180 7181 7182 7183 7184 7185 7186 7187 7188 7189 7190 7191 7192 7193 7194 7195 7196 7197 7198 7199 7200 7201 7202 7203 7204 7205 7206 7207 7208 7209 7210 7211 7212 7213 7214 7215 7216 7217 7218 7219 7220 7221 7222 7223 7224 7225 7226 7227 7228 7229 7230 7231 7232 7233 7234 7235 7236 7237 7238 7239 7240 7241 7242 7243 7244 7245 7246 7247 7248 7249 7250 7251 7252 7253 7254 7255 7256 7257 7258 7259 7260 7261 7262 7263 7264 7265 7266 7267 7268 7269 7270 7271 7272 7273 7274 7275 7276 7277 7278 7279 7280 7281 7282 7283 7284 7285 7286 7287 7288 7289 7290 7291 7292 7293 7294 7295 7296 7297 7298 7299 7300 7301 7302 7303 7304 7305 7306 7307 7308 7309 7310 7311 7312 7313 7314 7315 7316 7317 7318 7319 7320 7321 7322 7323 7324 7325 7326 7327 7328 7329 7330 7331 7332 7333 7334 7335 7336 7337 7338 7339 7340 7341 7342 7343 7344 7345 7346 7347 7348 7349 7350 7351 7352 7353 7354 7355 7356 7357 7358 7359 7360 7361 7362 7363 7364 7365 7366 7367 7368 7369 7370 7371 7372 7373 7374 7375 7376 7377 7378 7379 7380 7381 7382 7383 7384 7385 7386 7387 7388 7389 7390 7391 7392 7393 7394 7395 7396 7397 7398 7399 7400 7401 7402 7403 7404 7405 7406 7407 7408 7409 7410 7411 7412 7413 7414 7415 7416 7417 7418 7419 7420 7421 7422 7423 7424 7425 7426 7427 7428 7429 7430 7431 7432 7433 7434 7435 7436 7437 7438 7439 7440 7441 7442 7443 7444 7445 7446 7447 7448 7449 7450 7451 7452 7453 7454 7455 7456 7457 7458 7459 7460 7461 7462 7463 7464 7465 7466 7467 7468 7469 7470 7471 7472 7473 7474 7475 7476 7477 7478 7479 7480 7481 7482 7483 7484 7485 7486 7487 7488 7489 7490 7491 7492 7493 7494 7495 7496 7497 7498 7499 7500 7501 7502 7503 7504 7505 7506 7507 7508 7509 7510 7511 7512 7513 7514 7515 7516 7517 7518 7519 7520 7521 7522 7523 7524 7525 7526 7527 7528 7529 7530 7531 7532 7533 7534 7535 7536 7537 7538 7539 7540 7541 7542 7543 7544 7545 7546 7547 7548 7549 7550 7551 7552 7553 7554 7555 7556 7557 7558 7559 7560 7561 7562 7563 7564 7565 7566 7567 7568 7569 7570 7571 7572 7573 7574 7575 7576 7577 7578 7579 7580 7581 7582 7583 7584 7585 7586 7587 7588 7589 7590 7591 7592 7593 7594 7595 7596 7597 7598 7599 7600 7601 7602 7603 7604 7605 7606 7607 7608 7609 7610 7611 7612 7613 7614 7615 7616 7617 7618 7619 7620 7621 7622 7623 7624 7625 7626 7627 7628 7629 7630 7631 7632 7633 7634 7635 7636 7637 7638 7639 7640 7641 7642 7643 7644 7645 7646 7647 7648 7649 7650 7651 7652 7653 7654 7655 7656 7657 7658 7659 7660 7661 7662 7663 7664 7665 7666 7667 7668 7669 7670 7671 7672 7673 7674 7675 7676 7677 7678 7679 7680 7681 7682 7683 7684 7685 7686 7687 7688 7689 7690 7691 7692 7693 7694 7695 7696 7697 7698 7699 7700 7701 7702 7703 7704 7705 7706 7707 7708 7709 7710 7711 7712 7713 7714 7715 7716 7717 7718 7719 7720 7721 7722 7723 7724 7725 7726 7727 7728 7729 7730 7731 7732 7733 7734 7735 7736 7737 7738 7739 7740 7741 7742 7743 7744 7745 7746 7747 7748 7749 7750 7751 7752 7753 7754 7755 7756 7757 7758 7759 7760 7761 7762 7763 7764 7765 7766 7767 7768 7769 7770 7771 7772 7773 7774 7775 7776 7777 7778 7779 7780 7781 7782 7783 7784 7785 7786 7787 7788 7789 7790 7791 7792 7793 7794 7795 7796 7797 7798 7799 7800 7801 7802 7803 7804 7805 7806 7807 7808 7809 7810 7811 7812 7813 7814 7815 7816 7817 7818 7819 7820 7821 7822 7823 7824 7825 7826 7827 7828 7829 7830 7831 7832 7833 7834 7835 7836 7837 7838 7839 7840 7841 7842 7843 7844 7845 7846 7847 7848 7849 7850 7851 7852 7853 7854 7855 7856 7857 7858 7859 7860 7861 7862 7863 7864 7865 7866 7867 7868 7869 7870 7871 7872 7873 7874 7875 7876 7877 7878 7879 7880 7881 7882 7883 7884 7885 7886 7887 7888 7889 7890 7891 7892 7893 7894 7895 7896 7897 7898 7899 7900 7901 7902 7903 7904 7905 7906 7907 7908 7909 7910 7911 7912 7913 7914 7915 7916 7917 7918 7919 7920 7921 7922 7923 7924 7925 7926 7927 7928 7929 7930 7931 7932 7933 7934 7935 7936 7937 7938 7939 7940 7941 7942 7943 7944 7945 7946 7947 7948 7949 7950 7951 7952 7953 7954 7955 7956 7957 7958 7959 7960 7961 7962 7963 7964 7965 7966 7967 7968 7969 7970 7971 7972 7973 7974 7975 7976 7977 7978 7979 7980 7981 7982 7983 7984 7985 7986 7987 7988 7989 7990 7991 7992 7993 7994 7995 7996 7997 7998 7999 8000 8001 8002 8003 8004 8005 8006 8007 8008 8009 8010 8011 8012 8013 8014 8015 8016 8017 8018 8019 8020 8021 8022 8023 8024 8025 8026 8027 8028 8029 8030 8031 8032 8033 8034 8035 8036 8037 8038 8039 8040 8041 8042 8043 8044 8045 8046 8047 8048 8049 8050 8051 8052 8053 8054 8055 8056 8057 8058 8059 8060 8061 8062 8063 8064 8065 8066 8067 8068 8069 8070 8071 8072 8073 8074 8075 8076 8077 8078 8079 8080 8081 8082 8083 8084 8085 8086 8087 8088 8089 8090 8091 8092 8093 8094 8095 8096 8097 8098 8099 8100 8101 8102 8103 8104 8105 8106 8107 8108 8109 8110 8111 8112 8113 8114 8115 8116 8117 8118 8119 8120 8121 8122 8123 8124 8125 8126 8127 8128 8129 8130 8131 8132 8133 8134 8135 8136 8137 8138 8139 8140 8141 8142 8143 8144 8145 8146 8147 8148 8149 8150 8151 8152 8153 8154 8155 8156 8157 8158 8159 8160 8161 8162 8163 8164 8165 8166 8167 8168 8169 8170 8171 8172 8173 8174 8175 8176 8177 8178 8179 8180 8181 8182 8183 8184 8185 8186 8187 8188 8189 8190 8191 8192 8193 8194 8195 8196 8197 8198 8199 8200 8201 8202 8203 8204 8205 8206 8207 8208 8209 8210 8211 8212 8213 8214 8215 8216 8217 8218 8219 8220 8221 8222 8223 8224 8225 8226 8227 8228 8229 8230 8231 8232 8233 8234 8235 8236 8237 8238 8239 8240 8241 8242 8243 8244 8245 8246 8247 8248 8249 8250 8251 8252 8253 8254 8255 8256 8257 8258 8259 8260 8261 8262 8263 8264 8265 8266 8267 8268 8269 8270 8271
|
%%
%% This is file `Mathmode.tex',
%%
%% IMPORTANT NOTICE:
%%
%% Herbert Voss <hvoss at tug dot org>
%% 2009-04-08
%%
%% This program can be redistributed and/or modified under the terms
%% of the LaTeX Project Public License Distributed from CTAN archives
%% in directory macros/latex/base/lppl.txt.
%%
%% DESCRIPTION:
%% `Mathmode' is a document how the math mode works inside LaTeX
%%
\ifpdf\title{Math mode - v.\MathmodeVersion}\else
\title{\logo Math mode - v.\MathmodeVersion}\fi%\fi
%
\author{Herbert Vo\ss\footnote{\sloppy Thanks for the feedback to:
Hendri Adriaens; Juan Mari Alberdi;
Luciano Battaia;
Heiko Bauke; Neal Becker; Andrea Blomenhofer; Alexander Boronka; Walter Brown;
Alexander Buchner;
Christian Faulhammer; Jos\'e{} Luis G\'omez Dans;
Zongbao Fang;
Sabine Glaser; Sven Gleich;
Azzam Hassam; Gernot Hassenpflug; Henning Heinze; Martin Hensel; Mathias Hoffmann;
Jon Kirwan;
Morten H\o{}gholm; M. Kalidoss; Dan Lasley;
Angus Leeming; Vladimir Lomov; Tim Love; Ladislav Lukas; Dan Luecking;
Hendrik Maryns; Heinz Mezera;
David Neuway;
Luis Trucco Passadore; Joachim Punter;
Carl Riehm; Will Robertson; Christoph Rumsm\"uller;
Jos\'e{} Carlos Santos; Arnaud Schmittbuhl;
Rainer Sch\"opf; Jens Schwaiger; Uwe Siart; Martin Sievers; Heiko Stamer;
G. Stengert; Uwe St\"ohr;
Carsten Thiel;
Juan Luis Varona;
David Weenink;
Philipp Wook;
Michael Zedler;
Zou Yuan-Chuan;
and last but not least a special thanks to Monika Hattenbach for her
excellent job of proofreading.
}}
\date{\today}
\maketitle
\begin{abstract}
It is often said that \TeX{} was designed for mathematical or technical purposes.
This may be true when we remember the reasons why Donald Knuth created \TeX{}. But nowadays
there are many examples in which \TeX\ is
used for publications with no mathematical or technical background content. However,
writing publications with such
material is one of the important advantages of \TeX{}. Because it
seems impossible to
know all existing macros and options of \AllTeX{} and the several additional packages,
especially of \AmSmath. This is the reason why I have attempted to gather
all the relevant
facts in this paper. An advanced german version of this paper is available as a book~\cite{voss09},
for members of DANTE, the german \TeX\ users group, for a special price!
\vspace{3cm}
\noindent Please report typos or any other comments to this documentation to
\href{mailto:voss@perce.de}{voss@perce.de}.
%\noindent This document was written with the \LaTeX{} editor \verb+Kile 1.8+
%\verb+(Qt 3.3+ \verb+KDE 3.4)+
%\href{http://sourceforge.net/projects/kile/}{http://sourceforge.net/projects/kile/}
%and the PDF output was built with the Linux version of \texttt{V\TeX/Free}, Version 8.46
%(\href{http://www.micropress-inc.com/linux/}{http://www.micropress-inc.com/linux/})
This file can be redistributed and/or modified under the terms
of the \LaTeX\ Project Public License Distributed from \verb+CTAN+ archives
in directory \url{CTAN://macros/latex/base/lppl.txt}.
\end{abstract}
\clearpage
%\fancypagestyle{plain}
\tableofcontents{}
\clearpage
\pagestyle{fancy}
\part{Standard \protect\LaTeX{} math mode}
\section{Introduction}
The following sections describe all the math commands which are available
without any additional package. Most of them also work with special
packages and some of them are redefined.
At first some important facts for typesetting math expressions.
\section{The Inlinemode}\label{sec:The-Inlinemode}
As the name says there are always math expressions which are in a standard
textline, like this one: $f(x)=\int_{a}^{b}\frac{\sin x}{x}\,\mathrm{d}x$. There
are no limitations for the height of the math expressions, so that
the layout may be very lousy if you insert a big matrix in an inline mode
like this:
$\underline{A}=\left[\begin{array}{ccc}
a & b & c\\
d & e & f\\
g & h & i\end{array}\right]$. In this case it is better to use the \verb|\smallmatrix| environment
$\underline{A}=\left[\begin{smallmatrix}%
a & b & c\cr
d & e & f\cr
g & h & i\end{smallmatrix}\right]$ from the \AmSmath{} package (see section \vref{sec:ams-matrix}) or the
displaymath mode\index{Display math mode} (section~\vref{display}).
This inline mode is possible with three different commands:
\bigskip
\begin{minipage}{0.35\fullwidth}
\(\sum_{i=1}^{n}i=\frac{1}{2}n\cdot(n+1)\)\\[10pt]
$\sum_{i=1}^{n}i=\frac{1}{2}n\cdot(n+1)$\\[10pt]
\begin{math}
\sum_{i=1}^{n}i=\frac{1}{2}n\cdot(n+1)
\end{math}
\end{minipage}\hfill
\begin{minipage}{0.62\fullwidth}
\begin{lstlisting}
\(\sum_{i=1}^{n}i=\frac{1}{2}n\cdot(n+1)\)\\[10pt]
$\sum_{i=1}^{n}i=\frac{1}{2}n\cdot(n+1)$\\[10pt]
\begin{math}
\sum_{i=1}^{n}i=\frac{1}{2}n\cdot(n+1)
\end{math}
\end{lstlisting}
\end{minipage}
\begin{enumerate}
\item \CMD{( ... }\CMD{)} \mPar{\CMD{(}...\CMD{)}}, the problem is that \verb+\(+ is
not a robust macro (see section~\vref{subsec:mathInTitles}).
\item \verb+$ ... $+ \mPar{\$...\$}
\item \CMD{begin\{math\}} ... \CMD{end\{math\}}, also not robust%
\mPar{\CMD{begin\{math\}}\\...\\\CMD{end\{math\}}}
\end{enumerate}
\index{*@\texttt{\textbackslash\char040}}\index{*@\texttt{\textbackslash\char041}}
In general \verb+$...$+ is the best choice, but this does not work in environments like \verb+verbatim+
or \verb+alltt+. In this case \verb+\(...\)+ works.\index{$@\texttt{\$}}
\subsection{Limits}\label{sub:Limits-Inline}
In the inline mode the \Index{limits} are by default only in
super\index{Superscript} or subscript mode\index{Subscript} and
the fractions\index{Fraction} are always in the \Index{scriptstyle}%
\footnote{See section \vref{sec:Styles}.}\index{scriptstyle}
font size. For
example: $\int_{1}^{\infty}\frac{1}{x^2}\,\mathrm{d}x=1$, which is not too
big for the textline. You %
\mPar{\CMD{limits}}can change this with the command \CIndex{limits},
which must follow a math operator\footnote{To define a new operator see
page~\pageref{OperatorNames}}\index{Math operator} like %
\mPar{\CMD{int}\\\CMD{lim}\\\CMD{prod}\\\CMD{sum}}
an integral (\CIndex{int}), a sum (\CIndex{sum}),
a product (\CIndex{prod}) or a limes
(\CIndex{lim}). But this $\int\limits_{1}^{\infty}\frac{1}{x^2}\,\mathrm{d}x=1$
(\lstinline|$\int\limits_{1}^...|) %$
does not look very nice in a text line when it appears between two lines,
especially when there are multiline limits.\footnote{For more
information about limits see section~\vref{sub:Multiple-Limits} or section~\vref{sec:limit-AMS}.}
\subsection{Fraction command}\label{sub:fraction command}
For inlined formulas the fractions\index{Fraction} are by default
in the scriptstyle\index{scriptstyle@\textbackslash scriptstyle} (see tabular~\vref{cap:Mathstyles}),
which is good for typesetting $y=\frac{a}{b+1}$, because the
linespacing %
\mPar{\CMD{frac}}is nearly the same, but not optimal, when the formula shows some important
facts. There are two solutions to get a better reading:
\begin{enumerate}
\item choose the display mode instead of the inline mode, which is the better
one;
\item set the fontstyle to \CIndex{displaystyle}, which makes
the fraction $y={\displaystyle\frac{a}{b+1}}$ more readable but
the linespacing increases which is always a bad solution and should
only be used when the first solution makes no sense.\footnote{For an abbreviation see
section~\vref{sec:ams-fraction}, there is a special \CIndex{dfrac} macro.}
\bigskip
\begin{minipage}{0.25\fullwidth}
$y=\frac{a}{b+1}={\displaystyle\frac{a}{b+1}}$
\end{minipage}\hfill
\begin{minipage}{0.72\fullwidth}
\begin{lstlisting}
$y=\frac{a}{b+1}={\displaystyle\frac{a}{b+1}}$
\end{lstlisting}
\end{minipage}
\end{enumerate}
\subsection[Math in Chapter/Section Titles]{\label{inline-chapter}Math in \CIndex{part},
\CIndex{chapter}, \CIndex{section},
... titles like $f(x)=\prod_{i=1}^{n}\left(i-\frac{1}{2i}\right)$}\label{subsec:mathInTitles}
All commands which appear in positions like contents, index, header,
... must be robust\footnote{%
\texttt{robust} means that the macro is not expanded before it is moved
into for example the tableofcontents file (\texttt{*.toc}). No robustness is
often a problem, when a macro is part of another macro.}
which is the case for \verb+$...$+ but not for \verb+\(...\)+.
The latest package \PIndex{fixltx2e} defines an macro for declaring
existing commands to be robust. The package itself does this already for:
\begin{lstlisting}
\MakeRobust\(
\MakeRobust\)
\MakeRobust\[
\MakeRobust\]
\MakeRobust\makebox
\MakeRobust\savebox
\MakeRobust\framebox
\MakeRobust\parbox
\MakeRobust\rule
\MakeRobust\raisebox
\end{lstlisting}
If you do not have any contents, index, a.s.o.
you can write the mathstuff in \CIndex{chapter}, \CIndex{section},
a.s.o without any restriction. Otherwise use \verb+\protect\(+ and \verb+\protect\)+ or the
\verb+$...$+ version.\index{$@\texttt{\$}}
The whole math expression appears in the default font shape and not
in bold like the other text. Section~\vref{sec:titleItem} describes how the math
expressions can be printed also in bold.
\mPar{\CMD{texorpdfstring}}%
There are problems with the \PIndex{hyperref} package when there is no
text part in a title. It is possible with the command \CIndex{texorpdfstring}
to tell \verb+hyperref+ to use different
commands, one for the title and another one for the bookmarks:
\begin{verbatim}
\texorpdfstring{<TeX part>}{<hyperref part>}
\end{verbatim}
\begin{minipage}{\fullwidth}
\begin{lstlisting}
\texorpdfstring{$\int f(x)\,\mathrm{d}x$}{Integral function}
\end{lstlisting}
\end{minipage}
\subsection{Equation numbering}
It is obvious that the numbering of inline mathstuff makes no sense!
\subsection{Framed math}
With the \CIndex{fbox} macro everything of inline math can be framed\index{Framed inline
math}\index{boxed inline math}, like the following one:
\bigskip
\begin{minipage}{0.325\fullwidth}
\fbox{$f(x)=\prod_{i=1}^{n}\left(i-\frac{1}{2i}\right)$}
\end{minipage}\hfill
\begin{minipage}{0.67\fullwidth}
\begin{lstlisting}
\fbox{$f(x)=\prod_{i=1}^{n}\left(i-\frac{1}{2i}\right)$}
\end{lstlisting}
\end{minipage}
%$
Parameters are the width of \LIndex{fboxsep} and \LIndex{fboxrule}, the predefined values
from the file \verb|latex.ltx| are:
\bigskip
\begin{minipage}{\fullwidth}
\begin{lstlisting}
\fboxsep = 3pt
\fboxrule = .4pt
\end{lstlisting}
\end{minipage}
The same is possible with the \CIndex{colorbox}
\colorbox{yellow}{$f(x)=\prod_{i=1}^{n}\left(i-\frac{1}{2i}\right)$}
from the color package.
\bigskip
\begin{minipage}{\fullwidth}
\begin{lstlisting}
\colorbox{yellow}{$f(x)=\prod_{i=1}^{n}\left(i-\frac{1}{2i}\right)$}
\end{lstlisting}
\end{minipage}
%$
\subsection{Linebreak}\label{subsec:linebreak}
\LaTeX{} can break an inline formula only when a relation symbol ($=, <, >, \ldots$) or a
binary operation symbol ($+,-, \ldots$) exists and at least one of these symbols appears at
the outer level of a formula.
Thus \verb|$a+b+c$| can be broken across lines, but \verb|${a+b+c}$| not.\index{$@\texttt{\$}}
\begin{itemize}
\item The default: \hspace{1cm}
$f(x)=a_nx^n+a_{n-1}x^{n-1}+a_{n-2}x^{n-2}+\ldots
+a_ix^i +a_2x^2 +a_1x^1 +a_0$
\item The same inside a group \{...\}:
${f(x)=a_nx^n+a_{n-1}x^{n-1}+a_{n-2}x^{n-2}+\ldots
+a_ix^i +a_2x^2 +a_1x^1 +a_0}$
\item Without any symbol: \hspace{4cm}
$f(x)=a_n\left(a_{n-1}\left(a_{n-2}\left(\ldots\right)\ldots\right)\ldots\right)$
\end{itemize}
If it is not possible to have any mathsymbol, then split the inline formula in two
or more pieces (\verb|$...$ $...$|). If you do not want a linebreak for the whole
document, you can set in the preamble:
\begin{verbatim}
\relpenalty=9999
\binoppenalty=9999
\end{verbatim}
\noindent
which is the extreme case of grudgingly allowing breaks in extreme cases, or
%
\begin{verbatim}
\relpenalty=10000
\binoppenalty=10000
\end{verbatim}
%
for absolutely no breaks.
\subsection{Whitespace}\label{subsec:whitespace}
\LaTeX{} defines the length \LIndex{mathsurround} with the default value of
\verb|0pt|. This length is added before and after an inlined math expression
(see table~\vref{tab:whitespace}).
\begin{table}[htb]
\hspace*{-0.1\linewidth}%
\begin{tabular}{@{}cc@{}}
foo \fbox{$ f(x)=\int_1^{\infty}\frac{1}{x^2}\,\mathrm{d}x=1 $} bar &
\begin{minipage}{0.7\linewidth}
\begin{lstlisting}
foo \fbox{$ f(x)=\int_1^{\infty}\frac{1}{x^2}\,\mathrm{d}x=1 $} bar
\end{lstlisting}
\end{minipage}\tabularnewline
%
foo \rule{20pt}{\ht\strutbox}\fbox{$ f(x)=\int_1^{\infty}\frac{1}{x^2}\,\mathrm{d}x=1 $}\rule{20pt}{\ht\strutbox} bar &
\begin{minipage}{0.7\linewidth}
\begin{lstlisting}
foo \rule{20pt}{\ht\strutbox}\fbox{$ f(x)=\int_1^{\infty}\frac{1}{x^2}\,\mathrm{d}x=1 $}\rule{20pt}{\ht\strutbox} bar
\end{lstlisting}
\end{minipage}\tabularnewline
\setlength{\mathsurround}{20pt}foo \fbox{$ f(x)=\int_1^{\infty}\frac{1}{x^2}\,\mathrm{d}x=1 $} bar &
\begin{minipage}{0.7\linewidth}
\begin{lstlisting}
\setlength{\mathsurround}{20pt}
foo \fbox{$ f(x)=\int_1^{\infty}\frac{1}{x^2}\,\mathrm{d}x=1 $} bar
\end{lstlisting}
\end{minipage}
\end{tabular}
%
\caption{Meaning of \CMD{mathsurround}}\label{tab:whitespace}
\end{table}
%$
\subsection{\AmSmath for the inline mode}
None of the \AmSmath-functions are available in inline mode.
\section{Displaymath mode}\label{display}
This means, that every formula gets its own paragraph (line). There are
some differences in the layout to the one from the title
of \ref{inline-chapter}.
\subsection{\texttt{equation} environment}
For example:
\bigskip\noindent
\begin{tabular}{cc}
\begin{minipage}{0.35\linewidth}
\begin{equation}
f(x)=\prod_{i=1}^{n}\left(i-\frac{1}{2i}\right)
\end{equation}
\end{minipage} &
\begin{minipage}{0.63\linewidth}
\begin{lstlisting}
\begin{equation}
f(x)=\prod_{i=1}^{n}\left(i-\frac{1}{2i}\right)
\end{equation}
\end{lstlisting}
\end{minipage}
\end{tabular}
\bigskip
The delimiters\index{Delimiter}
\CMD{begin\{equation\} ... }\CMD{end\{equation\}} are the only difference to the inline version.
There are some equivalent commands for the display-math mode:
\begin{enumerate}
\mPar{\CMD{begin\{displaymath\}}\\
\ldots\\
\CMD{end\{displaymath\}}}%
\item \CMD{begin\{displaymath\}}\ldots\CMD{end\{displaymath\}}, same as
\CMD{[} \ldots \CMD{]}
%
\item \CMD{[\ldots}\CMD{]}. (see above) the short form of a displayed formula, no number%
\mPar{\texttt{\textbackslash[\ldots\textbackslash{}]}}
\[
f(x)=\prod_{i=1}^{n}\left(i-\frac{1}{2i}\right)
\]
%
displayed, no number. Same as 1.
%
\item \CMD{begin\{equation\}\ldots}\CMD{end\{equation\}}%
\mPar{\CMD{begin\{equation\}}\\
\ldots\\
\CMD{end\{equation\}}}%
%
\begin{equation}
f(x)=\prod_{i=1}^{n}\left(i-\frac{1}{2i}\right)
\end{equation}
%
displayed, a sequential equation number, which may be reset when
starting a new chapter or section.
\begin{enumerate}
\item There is only \textbf{one} equation number for the whole environment.
\item \mPar{\CMD{nonumber}}There exists no star-version of the equation environment
because \CIndex{[}\ldots\CIndex{]} is the equivalent. With the tag
\CIndex{nonumber} it is possible to suppress the equation number:
\begin{minipage}{0.5\linewidth}
\begin{equation}
f(x)= [...] \nonumber
\end{equation}
\end{minipage}%
\begin{minipage}{0.6\linewidth}
\begin{lstlisting}
\begin{equation}
f(x)= [...] \nonumber
\end{equation}
\end{lstlisting}
\end{minipage}
%
\end{enumerate}
\end{enumerate}
\subsection{\texttt{eqnarray} environment}\label{display:eqnarray}
This is by default an array with three columns and as many rows as
you like. \mPar{\CMD{begin\{eqnarray\}}\\
...\\
\CMD{end\{eqnarray\}}} It is nearly the same as an array with a \verb|rcl| column definition.
It is \textbf{not possible} to change the internal behaviour of the \verb|eqnarray| environment without
rewriting the environment.
It is always an impli\-cit array with \textbf{three} columns and the horizontal
alignment \verb|right-center-left (rcl)| and small \textbf{symbol} sizes for the
middle column. All this can not be changed by the user without rewriting
the whole environment in \verb|latex.ltx|.
\bigskip\noindent
\begin{tabular}{cc}
\begin{minipage}{0.35\linewidth}
\begin{eqnarray*}
\mathrm{left} & \mathrm{middle} & \mathrm{right}\\
\frac{1}{\sqrt{n}}= & \frac{\sqrt{n}}{n}= & \frac{n}{n\sqrt{n}}
\end{eqnarray*}
\end{minipage} &
\begin{minipage}{0.63\linewidth}
\begin{lstlisting}
\begin{eqnarray*}
\mathrm{left} & \mathrm{middle} & \mathrm{right}\\
\frac{1}{\sqrt{n}}= & \frac{\sqrt{n}}{n}= & \frac{n}{n\sqrt{n}}
\end{eqnarray*}
\end{lstlisting}
\end{minipage}
\end{tabular}
\bigskip
The \UIndex{eqnarray} should not be used as an array. As seen in the above
example the typesetting is wrong for the middle column. The numbering of eqnarray
environments is always for every row, means,
that four lines get four different equation numbers (for the labels see
section~\vref{sec:Labels}):
\bigskip
\begin{minipage}{0.5\columnwidth}
\begin{eqnarray}
y & = & d\label{eq:2}\\
y & = & cx+d\\
y & = & bx^{2}+cx+d\\
y & = & ax^{3}+bx^{2}+cx+d\label{eq:5}
\end{eqnarray}
\end{minipage}\hfill
\begin{minipage}{0.43\columnwidth}
\begin{lstlisting}
\begin{eqnarray}
y & = & d\label{eq:2}\\
y & = & cx+d\\
y & = & bx^{2}+cx+d\\
y & = & ax^{3}+bx^{2}+cx+d\label{eq:5}
\end{eqnarray}
\end{lstlisting}
\end{minipage}
\medskip
Toggling numbering off/on for \textbf{all} rows is possible
with the starred version of eqnarray.
\medskip
\begin{minipage}{0.45\columnwidth}
\begin{eqnarray*}
y & = & d\label{eq:3}\\
y & = & cx+d\\
y & = & bx^{2}+cx+d\\
y & = & ax^{3}+bx^{2}+cx+d\label{eq:4}
\end{eqnarray*}
\end{minipage}
\begin{minipage}{0.53\columnwidth}
\begin{lstlisting}
\begin{eqnarray*}
y & = & d\label{eq:3}\\
y & = & cx+d\\
y & = & bx^{2}+cx+d\\
y & = & ax^{3}+bx^{2}+cx+d\label{eq:4}
\end{eqnarray*}
\end{lstlisting}
\end{minipage}
\medskip
Toggling off/on for \textbf{single} rows is possible with the above
mentioned \CIndex{nonumber} tag at the end of a row
(before the newline command). For example:
\medskip
\begin{minipage}{0.45\columnwidth}
\begin{eqnarray}
y & = & d\nonumber \\
y & = & cx+d\nonumber \\
y & = & bx^{2}+cx+d\nonumber \\
y & = & ax^{3}+bx^{2}+cx+d
\end{eqnarray}
\end{minipage}
\begin{minipage}{0.53\columnwidth}
\begin{lstlisting}
\begin{eqnarray}
y & = & d\nonumber \\
y & = & cx+d\nonumber \\
y & = & bx^{2}+cx+d\nonumber \\
y & = & ax^{3}+bx^{2}+cx+d
\end{eqnarray}
\end{lstlisting}
\end{minipage}
\subsubsection{Short commands}\label{subsec:shortcommand}
It is possible to define short commands for the \UIndex{eqnarray}
%
\begin{lstlisting}
\makeatletter
\newcommand{\be}{%
\begingroup
% \setlength{\arraycolsep}{2pt}
\eqnarray%
\@ifstar{\nonumber}{}%
}
\newcommand{\ee}{\endeqnarray\endgroup}
\makeatother
\end{lstlisting}
\makeatletter
\newcommand{\be}{%
\begingroup
% \setlength{\arraycolsep}{2pt}
\eqnarray%
\@ifstar{\nonumber}{}%
}
\newcommand{\ee}{\endeqnarray\endgroup}
\makeatother
Now you can write the whole equation as
\begin{LTXexample}[width=0.5\columnwidth,wide]
\be
f(x) &=& \int\frac{\sin x}{x}\,\mathrm{d}x
\ee
\end{LTXexample}
\medskip
\noindent or, if you do not want to have a numbered equation as
\begin{LTXexample}[width=0.5\columnwidth,wide]
\be*
f(x) &=& \int\frac{\sin x}{x}\,\mathrm{d}x
\ee
\end{LTXexample}
\subsection{Equation numbering}\label{sub:Equationnumbering}
For all equations which can have one or %
\mPar{\CMD{nonumber}}more equation numbers (for every line/row) the numbering
for the whole equation can be disabled with switching from the unstarred to the star
version. This is still for the whole formula and doesn't work for single rows.
In this case use the \CIndex{nonumber} tag.
\begin{itemize}
\item This doc is written with the article-class, which counts the equations
continuously over all parts/sections. You can change this behaviour
in different ways (see the following subsections).
\item In standard \LaTeX{} it is a problem with too long equations and the
equation number, which may be printed with the equation one upon the other. In this case
use the \AmSmath package, where the number is set above or below
of a too long equation (see equation~\vref{eq:braces}).
\item For counting subequations see section~\vref{ams:subeqn}.
\end{itemize}
\subsubsection{Changing the style}
\mPar{\CMD{theequation}}%
With the beginning of Section \vref{sec:alignat environment} the
counting changes from ``\ref{eq:IntoSection}{}'' into the new style
``\ref{eq:newCounting}''. The command sequence is
\begin{lstlisting}
\renewcommand\theequation{\thepart-\arabic{equation}}
\end{lstlisting}
See section~\vref{sec:Equation-numbering} for the \AmSmath command.
\subsubsection{Resetting a counter style}
Removing a given reset is possible with the \PIndex{remreset}.%
\footnote{\href{http://www.ctan.org/tex-archive/macros/latex/contrib/supported/carlisle/remreset.sty}{CTAN://macros/latex/contrib/supported/carlisle/remreset.sty}} Write into the %
\mPar{\CMD{@removefromreset}} preamble
\begin{lstlisting}
\makeatletter
\@removefromreset{equation}{section}
\makeatother
\end{lstlisting}
or anywhere in the text.
Now the equation counter is no longer reset when a new section starts.
You can see this after section~\vref{split}.
\subsubsection{Equation numbers on the left side}
Choose package \PIndex{leqno}%
\footnote{\href{http://www.ctan.org/tex-archive/macros/latex/unpacked/leqno.sty}{CTAN://macros/latex/unpacked/leqno.sty}}
or have a look at your document class, if such an option exists.
\subsubsection{Changing the equation number style}
The number style can be changed with a redefinition of
\begin{verbatim}
\def\@eqnnum{{\normalfont \normalcolor (\theequation)}}
\end{verbatim}
For example: if you want the numbers not in parentheses write
\begin{lstlisting}
\makeatletter
\def\@eqnnum{{\normalfont \normalcolor \theequation}}
\makeatother
\end{lstlisting}
For \AmSmath there is another macro, see section~\ref{sec:Equation-numbering} on
page~\pageref{sec:Equation-numbering}.
\subsubsection{More than one equation counter}
You can have more than the default equation counter. With the following code you
can easily toggle between roman and arabic equation counting.
\makeatletter
%Roman counter
\newcounter{roem}
\renewcommand{\theroem}{\roman{roem}}
% save the original counter
\newcommand{\c@org@eq}{}
\let\c@org@eq\c@equation
\newcommand{\org@theeq}{}
\let\org@theeq\theequation
%\setroem sets roman counting
\newcommand{\setroem}{
\let\c@equation\c@roem
\let\theequation\theroem}
%\setarab the arabic counting
\newcommand{\setarab}{
\let\c@equation\c@org@eq
\let\theequation\org@theeq}
\makeatother
\begin{lstlisting}
%code by Heiko Oberdiek
\makeatletter
%Roman counter
\newcounter{roem}
\renewcommand{\theroem}{\roman{roem}}
% save the original counter
\newcommand{\c@org@eq}{}
\let\c@org@eq\c@equation
\newcommand{\org@theeq}{}
\let\org@theeq\theequation
%\setroem sets roman counting
\newcommand{\setroem}{
\let\c@equation\c@roem
\let\theequation\theroem}
%\setarab the arabic counting
\newcommand{\setarab}{
\let\c@equation\c@org@eq
\let\theequation\org@theeq}
\makeatother
\end{lstlisting}
The following examples show how it works:
\noindent
\begin{minipage}{1.2\linewidth}
\begin{minipage}{0.38\linewidth}
\begin{align}
f(x) &= \int\sin x\,\mathrm{d}x\label{eq:arab1}\\
g(x) &= \int\frac{1}{x}\,\mathrm{d}x
\end{align}
%
\setroem
%
\begin{align}
F(x) &=-\cos x\\
G(x) &=\ln x\label{eq:rom1}
\end{align}
%
\setarab
%
\begin{align}
f^{\prime} (x) &= \sin x\\
g^{\prime} (x) &= \frac{1}{x}\label{eq:arab2}
\end{align}
\end{minipage}\hfill
\begin{minipage}{0.58\linewidth}
\begin{lstlisting}
\begin{align}
f(x) &= \int\sin x\,\mathrm{d}x\label{eq:arab1}\\
g(x) &= \int\frac{1}{x}\,\mathrm{d}x
\end{align}
%
\setroem
%
\begin{align}
F(x) &=-\cos x\\
G(x) &=\ln x\label{eq:rom1}
\end{align}
%
\setarab
%
\begin{align}
f^{\prime} (x) &= \sin x\\
g^{\prime} (x) &= \frac{1}{x}\label{eq:arab2}
\end{align}
\end{lstlisting}
\end{minipage}
\end{minipage}
\medskip
There can be references to these equations in the usual way, like eq.\ref{eq:arab1},
\ref{eq:arab2} and for the roman one eq.\ref{eq:rom1}.
\subsection{Labels}\label{sec:Labels}
Every numbered equation can have a label\index{Label} to which a
reference\index{Reference} is possible.
\begin{itemize}
\item There is one restriction for the label names, they cannot include
one of \LaTeX{}'s command characters.\footnote{\$ \_ \^{} \textbackslash{} \& \% \{ \}}
\item The label names are replaced by the equation number.
\end{itemize}
%
\mPar{\CMD{tag}}If you do not want a reference to the equation number but to a self
defined name then use the \AmS{}math command \CMD{tag{...}},
which is described in section \vref{sec:Labels-and-Tags}\index{tag@\textbackslash tag}.
\subsection{Frames}\label{sec:Frames}
Similiar to the inline mode, displayed equations can also be framed with
the \CIndex{fbox} command, like equation \ref{eq:frame0}.
The only difference is
the fact, that the equation must be packed into a parbox or minipage. It is
nearly the same for a colored box, where the \verb|\fbox{...}| has to be
replaced with \verb|\colorbox{yellow}{...}|. The package \verb|color.sty| must
be loaded and --important -- the \PIndex{calc} package to get a correct boxwidth.
\noindent\fbox{\parbox{\linewidth-2\fboxsep-2\fboxrule}{%
\begin{equation}\label{eq:frame0}
f(x)=\int_1^{\infty}\dfrac{1}{x^2}\,\mathrm{d}x=1
\end{equation}%
}}
\medskip
\begin{lstlisting}
\noindent\fbox{\parbox{\linewidth-2\fboxsep-2\fboxrule}{%
\begin{equation}\label{eq:frame0}
f(x)=\int_1^{\infty}\dfrac{1}{x^2}\,\mathrm{d}x=1
\end{equation}%
}}
\end{lstlisting}
If the equation number should not be part of the frame, then it is a bit
complicated. There is one tricky solution, which puts an unnumbered equation
just beside an empty numbered equation. The \verb|\hfill| is only useful for
placing the equation number right aligned, which is not the default. The
following four equations \ref{eq:frame2}-\ref{eq:frame5} are the same,
only the second one written with the \verb|\myMathBox| macro which has the
border and background color as optional arguments with the defaults
\verb|white| for background and \verb|black| for the frame. If there is only
one optional argument, then it is still the one for the frame color (\ref{eq:frame3}).
\makeatletter
\def\myMathBox{\@ifnextchar[{\my@MBoxi}{\my@MBoxi[black]}}
\def\my@MBoxi[#1]{\@ifnextchar[{\my@MBoxii[#1]}{\my@MBoxii[#1][white]}}
\def\my@MBoxii[#1][#2]#3#4{%
\par\noindent%
\fcolorbox{#1}{#2}{%
\parbox{\linewidth-\labelwidth-2\fboxrule-2\fboxsep}{#3}%
}%
\parbox{\labelwidth}{%
\begin{eqnarray}\label{#4}\end{eqnarray}%
}%
\par%
}
\makeatother
\begin{lstlisting}
\makeatletter
\def\myMathBox{\@ifnextchar[{\my@MBoxi}{\my@MBoxi[black]}}
\def\my@MBoxi[#1]{\@ifnextchar[{\my@MBoxii[#1]}{\my@MBoxii[#1][white]}}
\def\my@MBoxii[#1][#2]#3#4{%
\par\noindent%
\fcolorbox{#1}{#2}{%
\parbox{\linewidth-\labelwidth-2\fboxrule-2\fboxsep}{#3}%
}%
\parbox{\labelwidth}{%
\begin{eqnarray}\label{#4}\end{eqnarray}%
}%
\par%
}
\makeatother
\end{lstlisting}
\begin{equation}\label{eq:frame2}
f(x)=x^2 +x
\end{equation}
\myMathBox[red]{\[f(x)=x^2 +x\]}{eq:frame3}
\myMathBox[red][yellow]{\[f(x)=x^2 +x\]}{eq:frame4}
\myMathBox{\[f(x)=x^2 +x\]}{eq:frame5}
\medskip
\begin{lstlisting}
\begin{equation}\label{eq:frame2}
f(x)=x^2 +x
\end{equation}
\myMathBox[red]{\[f(x)=x^2 +x\]}{eq:frame3}
\myMathBox[red][yellow]{\[f(x)=x^2 +x\]}{eq:frame4}
\myMathBox{\[f(x)=x^2 +x\]}{eq:frame5}
\end{lstlisting}
If you are using the \AmSmath package, then try the solutions from section
\vref{sec:ams-frames}.
\section{\texttt{array} environment}
\mPar{\CMD{begin\{array\}}\\...\\\CMD{end\{array\}}}
This is simply the same as the \UIndex{eqnarray} only with the
possibility of variable rows \textbf{and} columns and the fact, that
the whole formula has only \textbf{one} equation number and that the
\verb|array| environment can only be part of another math environment,
like the \UIndex{equation} or the \UIndex{displaymath}. With \verb+@{}+ before the
first and after the last column the additional space \LIndex{arraycolsep}
is not used, which maybe important when using left aligned equations.
\begin{equation}
\left.%
\begin{array}{@{}r@{\quad}ccrr@{}}
\textrm{a}) & y & = & c & (constant)\\
\textrm{b}) & y & = & cx+d & (linear)\\
\textrm{c}) & y & = & bx^{2}+cx+d & (square)\\
\textrm{d}) & y & = & ax^{3}+bx^{2}+cx+d & (cubic)
\end{array}%
\right\} \textrm{Polynomes}
\end{equation}
\begin{lstlisting}
\begin{equation}
\left.%
\begin{array}{@{}r@{\quad}ccrr@{}}
\textrm{a}) & y & = & c & (constant)\\
\textrm{b}) & y & = & cx+d & (linear)\\
\textrm{c}) & y & = & bx^{2}+cx+d & (square)\\
\textrm{d}) & y & = & ax^{3}+bx^{2}+cx+d & (cubic)
\end{array}%
\right\} \textrm{Polynomes}
\end{equation}
\end{lstlisting}
The horizontal alignment of the columns is the same as the one from the
\UIndex{tabular}.
For arrays with delimiters see section~\vref{delarray}.
\subsection{Cases structure}
If you do not want to use the \AmSmath package then write your own
cases structure\index{cases@\textbackslash cases} with the \verb|array| environment:
\begin{LTXexample}[pos=b]
\begin{equation}
x=\left\{ \begin{array}{cl}
0 & \textrm{if }A=\ldots\\
1 & \textrm{if }B=\ldots\\
x & \textrm{this runs with as much text as you like, but without an raggeright text.}\end{array}\right.
\end{equation}
\end{LTXexample}
It is obvious, that we need a \CMD{parbox} if the text is longer than the possible linewidth.
\begin{LTXexample}[pos=b]
\begin{equation}
x = \left\{%
\begin{array}{l>{\raggedright}p{.5\textwidth}}%
0 & if $A=\ldots$\tabularnewline
1 & if $B=\ldots$\tabularnewline
x & \parbox{0.5\columnwidth}{this runs with as much text as you like, %
because an automatic linebreak is given with %
a raggedright text. Without this %
\raggedright command, you'll get a formatted %
text like the following one ... but with a parbox ... it works}
\end{array}%
\right. %
\end{equation}
\end{LTXexample}
\subsection{\texttt{arraycolsep}}\label{sec:arraycolsep}
\mPar{\CMD{arraycolsep}}%
All the foregoing math environments use the array to typeset the math
expression. The predefined separation between two columns is the length
\LIndex{arraycolsep}|, which is set by nearly all document classes to \verb|5pt|,
which seems to be too big. The following equation is typeset with the
default value and the second one with \verb|\arraycolsep=1.4pt|
\bgroup
\fboxsep=0pt
\def\xstrut{\vphantom{\int\frac{\sin x}{x}}}
\begin{eqnarray*}
\boxed{f(x)\xstrut} & \boxed{=\xstrut} & \boxed{\int\frac{\sin x}{x}\,\mathrm{d}x}
\end{eqnarray*}
\vspace{-2ex}
\arraycolsep=1.4pt
\begin{eqnarray*}
\boxed{f(x)\xstrut} & \boxed{=\xstrut} & \boxed{\int\frac{\sin x}{x}\,\mathrm{d}x}
\end{eqnarray*}
\egroup
If this modification should be valid for all arrays/equations, then write it into the
preamble, otherwise put it into a group or define your own environment as done
in section~\vref{subsec:shortcommand}.
\begin{lstlisting}
\bgroup
\arraycolsep=1.4pt
\begin{eqnarray}
f(x) & = & \int\frac{\sin x}{x}\,\mathrm{d}x
\end{eqnarray}
\egroup
\end{lstlisting}
\begin{lstlisting}
\makeatletter
\newcommand{\be}{%
\begingroup
\setlength{\arraycolsep}{1.4pt}
[ ... ]
\end{lstlisting}
\section{Matrix}\label{sec:matrix}
\mPar{\CMD{begin\{matrix\}}\\\ldots\\\CMD{end\{matrix\}}\\\CMD{bordermatrix}}%
\TeX{} knows two macros and \LaTeX{} one more for typesetting a
matrix\index{bordermatrix@\textbackslash bordermatrix}:
\begin{LTXexample}
$\begin{matrix}
A & B & C \\
d & e & f \\
1 & 2 & 3 \\
\end{matrix}$
\end{LTXexample}
\vspace{-10pt}
\begin{LTXexample}
$\bordermatrix{%
& 0 & 1 & 2 \cr
0 & A & B & C \cr
1 & d & e & f \cr
2 & 1 & 2 & 3 \cr
}$
\end{LTXexample}
\iffalse % smallmatrix belongs to amsmath
\begin{minipage}{0.4\textwidth}
\begin{center}
$
\begin{smallmatrix}%
A & B & C \\
d & e & f \\
1 & 2 & 3
\end{smallmatrix}
$
\end{center}
\end{minipage}\hfill
\begin{minipage}{0.4\textwidth}
\begin{lstlisting}
\begin{smallmatrix}%
A & B & C \\
d & e & f \\
1 & 2 & 3
\end{smallmatrix}
\end{lstlisting}
\end{minipage}
\fi
The first two macros are listed here for some historical reason, because the
\UIndex{array} or especially the
\AmSmath package offers the same or better macros/environments. Nevertheless it is
possible to redefine the \CIndex{bordermatrix} macro to get other parentheses and a star
version which takes the left top part as matrix:
\makeatletter
\newif\if@borderstar
\def\bordermatrix{\@ifnextchar*{%
\@borderstartrue\@bordermatrix@i}{\@borderstarfalse\@bordermatrix@i*}%
}
\def\@bordermatrix@i*{\@ifnextchar[{\@bordermatrix@ii}{\@bordermatrix@ii[()]}}
\def\@bordermatrix@ii[#1]#2{%
\begingroup
\m@th\@tempdima8.75\p@\setbox\z@\vbox{%
\def\cr{\crcr\noalign{\kern 2\p@\global\let\cr\endline }}%
\ialign {$##$\hfil\kern 2\p@\kern\@tempdima & \thinspace %
\hfil $##$\hfil && \quad\hfil $##$\hfil\crcr\omit\strut %
\hfil\crcr\noalign{\kern -\baselineskip}#2\crcr\omit %
\strut\cr}}%
\setbox\tw@\vbox{\unvcopy\z@\global\setbox\@ne\lastbox}%
\setbox\tw@\hbox{\unhbox\@ne\unskip\global\setbox\@ne\lastbox}%
\setbox\tw@\hbox{%
$\kern\wd\@ne\kern -\@tempdima\left\@firstoftwo#1%
\if@borderstar\kern2pt\else\kern -\wd\@ne\fi%
\global\setbox\@ne\vbox{\box\@ne\if@borderstar\else\kern 2\p@\fi}%
\vcenter{\if@borderstar\else\kern -\ht\@ne\fi%
\unvbox\z@\kern-\if@borderstar2\fi\baselineskip}%
\if@borderstar\kern-2\@tempdima\kern2\p@\else\,\fi\right\@secondoftwo#1 $%
}\null \;\vbox{\kern\ht\@ne\box\tw@}%
\endgroup
}
\makeatother
\begin{LTXexample}
$\bordermatrix{%
& 1 & 2 \cr
1 & x1 & x2 \cr
2 & x3 & x4 \cr
3 & x5 & x6
}$
\end{LTXexample}
\vspace{-10pt}
\begin{LTXexample}
$\bordermatrix[{[]}]{%
& 1 & 2 \cr
1 & x1 & x2 \cr
2 & x3 & x4 \cr
3 & x5 & x6
}$
\end{LTXexample}
\vspace{-10pt}
\begin{LTXexample}
$\bordermatrix[\{\}]{%
& 1 & 2 \cr
1 & x1 & x2 \cr
2 & x3 & x4 \cr
3 & x5 & x6
}$
\end{LTXexample}
\vspace{-10pt}
\begin{LTXexample}
$\bordermatrix*{%
x1 & x2 & 1 \cr
x3 & x4 & 2 \cr
x5 & x6 & 3 \cr
1 & 2
}$
\end{LTXexample}
\vspace{-10pt}
\begin{LTXexample}
$\bordermatrix*[{[]}]{%
x1 & x2 & 1 \cr
x3 & x4 & 2 \cr
x5 & x6 & 3 \cr
1 & 2
}$
\end{LTXexample}
\vspace{-10pt}
\begin{LTXexample}
$\bordermatrix*[\{\}]{%
x1 & x2 & 1 \cr
x3 & x4 & 2 \cr
x5 & x6 & 3 \cr
1 & 2
}$
\end{LTXexample}
There is now an optional argument for the parenthesis with \verb|()| as the
default one. To get such a behaviour, write into the preamble:
\begin{lstlisting}[xleftmargin=-0.75cm,xrightmargin=-0.75cm]
\makeatletter
\newif\if@borderstar
\def\bordermatrix{\@ifnextchar*{%
\@borderstartrue\@bordermatrix@i}{\@borderstarfalse\@bordermatrix@i*}%
}
\def\@bordermatrix@i*{\@ifnextchar[{\@bordermatrix@ii}{\@bordermatrix@ii[()]}}
\def\@bordermatrix@ii[#1]#2{%
\begingroup
\m@th\@tempdima8.75\p@\setbox\z@\vbox{%
\def\cr{\crcr\noalign{\kern 2\p@\global\let\cr\endline }}%
\ialign {$##$\hfil\kern 2\p@\kern\@tempdima & \thinspace %
\hfil $##$\hfil && \quad\hfil $##$\hfil\crcr\omit\strut %
\hfil\crcr\noalign{\kern -\baselineskip}#2\crcr\omit %
\strut\cr}}%
\setbox\tw@\vbox{\unvcopy\z@\global\setbox\@ne\lastbox}%
\setbox\tw@\hbox{\unhbox\@ne\unskip\global\setbox\@ne\lastbox}%
\setbox\tw@\hbox{%
$\kern\wd\@ne\kern -\@tempdima\left\@firstoftwo#1%
\if@borderstar\kern2pt\else\kern -\wd\@ne\fi%
\global\setbox\@ne\vbox{\box\@ne\if@borderstar\else\kern 2\p@\fi}%
\vcenter{\if@borderstar\else\kern -\ht\@ne\fi%
\unvbox\z@\kern-\if@borderstar2\fi\baselineskip}%
\if@borderstar\kern-2\@tempdima\kern2\p@\else\,\fi\right\@secondoftwo#1 $%
}\null \;\vbox{\kern\ht\@ne\box\tw@}%
\endgroup
}
\makeatother
\end{lstlisting}
The \UIndex{matrix} macro cannot be used together with the \AmSmath package, it redefines
this environment (see section~\vref{sec:ams-matrix}).
\section{Super/Subscript and limits}\label{sec:limits}
Writing $a_{min}$ and $a_{max}$ gives the same depth for the \Index{subscript}, but
writing them in \Index{upright mode} with \verb+\mbox+ gives a different
depth: $a_{\mbox{min}}$ and $a_{\mbox{max}}$.
The problem is the different height, which can be modified in several ways
\begin{itemize}
\item \verb+$a_{\mbox{\vphantom{i}max}}+: $a_{\mbox{min}}$ and $a_{\mbox{\vphantom{i}max}}$;
\item \verb+$a_{\mathrm{max}}+: $a_{\mathrm{min}}$ and $a_{\mathrm{max}}$;
\item \verb+$a_{\max}+: $a_{\min}$ and $a_{\max}$. Both are predefined
operators (see section~\vref{sec:ltxOperators}).
\end{itemize}
%$
\subsection{Multiple limits}\label{sub:Multiple-Limits}
\mPar{\CMD{atop}}%
For general information about limits\index{Limits} read section
\vref{sub:Limits-Inline}. With the \TeX\ command \CIndex{atop}
multiple limits for a \CIndex{sum} or \CIndex{prod} are possible. The syntax is:
\begin{LTXexample}[width=0.4\linewidth]
\[ {above \atop below} \]
\end{LTXexample}
\noindent which is nearly the same as a fraction without a rule. This can
be enhanced to \verb|a\atop b\atop c| and so on. For equation \ref{eq:atop} do the following steps:
\begin{LTXexample}[width=0.4\linewidth]
\begin{equation}\label{eq:atop}
\sum_{{1\le j\le p\atop {%
{1\le j\le q\atop 1\le k\le r}}}%
}a_{ij}b_{jk}c_{ki}
\end{equation}
\end{LTXexample}
\bigskip
\mPar{\CMD{shortstack}}%
which is not the best solution because the space between the lines
is too big.
The \AmSmath package provides several commands for
limits (section~\vref{sec:limit-AMS}) and the \CIndex{underset} and \CIndex{overset}
commands (see section~\vref{sec:misc-AMS}).
\subsection{Problems}
\begin{equation}\label{eq:disp-limits}
\fboxsep=0pt\fboxrule=0.1pt
\boxed{\sum_{
{{1\le j\le p\atop {%
{1\le j\le q\atop 1\le k\le r}}}%
}}%
}\boxed{a_{ij}b_{jk}c_{ki}}
\end{equation}
The equation \ref{eq:disp-limits} shows that the horizontal alignment
is not optimal, because the math expression on the right follows at the
end of the limits which are a unit together with the sum symbol. There
is an elegant solution with \AmSmath, described in subsection
\vref{subsec:ams-limits}. If you do not want to use \AmSmath,
then use \CIndex{makebox}. But there is a problem when the general fontsize
is increased, \CMD{makebox} knows nothing about the actual math font
size. Equation \ref{eq:disp-limits2} shows the effect and equation
\ref{eq:disp-limits3} the view without the boxes.
\vspace{\abovedisplayskip}
\begin{subequations}
\begin{minipage}{0.45\textwidth}
\begin{equation}\label{eq:disp-limits2}
\fboxsep=0pt\fboxrule=0.1pt
\boxed{\sum_{%
\makebox[0pt]{$%
{{\scriptscriptstyle 1\le j\le p\atop {%
{1\le j\le q\atop 1\le k\le r}}}}%
$}%
}%
}\boxed{a_{ij}b_{jk}c_{ki}}
\end{equation}
\end{minipage}\hfill
\begin{minipage}{0.45\textwidth}
\begin{equation}\label{eq:disp-limits3}
\sum_{%
\makebox[0pt]{$%
{{\scriptscriptstyle 1\le j\le p\atop {%
{1\le j\le q\atop 1\le k\le r}}}}%
$}}a_{ij}b_{jk}c_{ki}
\end{equation}
\end{minipage}
\end{subequations}
\medskip
\begin{lstlisting}
\begin{equation}
\sum_{\makebox[0pt]{$%
{{\scriptscriptstyle 1\le j\le p\atop {%
{1\le j\le q\atop 1\le k\le r}}}}%
$}}a_{ij}b_{jk}c_{ki}
\end{equation}
\end{lstlisting}
\section{Roots}\label{sec:Roots}
The square root\index{Root} \CIndex{sqrt} is the default
for \LaTeX{} and the $n$-th root can be inserted with the optional
parameter \CMD{sqrt[n]\{\ldots\}}.
\mPar{\CMD{sqrt}}.
\begin{center}
\begin{tabular}{cc}
\verb|\sqrt{x}| & $\sqrt{x}$\\
\verb|\sqrt[3]{x}| & $\sqrt[3]{x}$
\end{tabular}
\end{center}
There is a different typesetting in roots. Equation~\vref{eq:root1}
has different heights for the roots, whereas equation~\vref{eq:root2}
has the same one. This is possible with the %
\mPar{\CMD{vphantom}}%
\CIndex{vphantom} command,
which reserves the vertical space (without a horizontal one) of the
parameter height.
\begin{LTXexample}[width=0.35\linewidth,wide]
\begin{equation}
\sqrt{a}\,%
\sqrt{T}\,%
\sqrt{2\alpha k_{B_1}T^i}\label{eq:root1}
\end{equation}
\end{LTXexample}
\vspace{-10pt}
\begin{LTXexample}[width=0.35\linewidth,wide]
\begin{equation}\label{eq:root2}
\sqrt{a\vphantom{k_{B_1}T^i}}\,%
\sqrt{T\vphantom{k_{B_1}T^i}}\,%
\sqrt{2\alpha k_{B_1}T^i}
\end{equation}
\end{LTXexample}
The typesetting looks much better, especially when the formula
has different roots in a row, like equation~\vref{eq:root1}. Using
\AmSmath with the \CIndex{smash} command%
\footnote{The \CMD{smash} command exists also in \LaTeX{}
but without an optional argument, which makes the use for roots possible.}
gives some more possibilities for the typesetting of roots (see section~\vref{sec:Roots-ams}).
\section[Brackets, braces \ldots]{Brackets, braces and parentheses}\label{sec:Brackets,-Braces-and}
This is one of the major problems inside the math mode, because there is often a need for different
brackets, braces and parentheses in different size. At first we had to admit, that
there is a difference between the characters ``\verb|()[]/\|
$\lbrace\rbrace$
|
$\Vert$
$\lfloor\rfloor$
$\lceil\rceil$
$\langle\rangle$
$\uparrow\Uparrow$
$\downarrow\Downarrow$
$\updownarrow\Updownarrow${}''
and their use as an argument %
\mPar{\CMD{leftX}\\\CMD{rightX}} of the \CIndex{left} and \CIndex{right}
command, where \LaTeX{} stretches the size in a way that everything between
the pair of left and right parentheses is smaller than the parentheses themselves. In some cases%
\footnote{See section \vref{cap:Use-of-the-vphantom} for example.}
it may be useful to choose a fixed height, which is possible with
the \CMD{big}-series. Instead of writing \CMD{leftX}
or \CMD{rightX} one of the following commands can
be chosen:
\medskip
\mPar{\CMD{bigX}\\\CMD{BigX}\\\CMD{biggX}\\\CMD{BiggX}}
\index{big@\textbackslash big}\index{Big@\textbackslash Big}%
\index{bigg@\textbackslash bigg}\index{Bigg@\textbackslash Bigg}
\begin{tabular}{rl}
default & ()[]/\textbackslash$\lbrace\rbrace$|$\Vert$ $\lfloor\rfloor$
$\lceil\rceil$ $\langle\rangle$ $\uparrow\Uparrow$ $\downarrow\Downarrow$%
$\updownarrow\Updownarrow$\\[2pt]
\CMD{bigX} & $\big(\big)$ $\big[\big]$
$\bigl/\big\backslash\big\{\big\}$
$\big|$ $\big\Vert$ $\big\lfloor\big\rfloor$ $\big\lceil\big\rceil$
$\big\langle\big\rangle$ $\big\uparrow\big\Uparrow$ $\big\downarrow\big\Downarrow$
$\big\updownarrow\big\Updownarrow$\\[2pt]
\CMD{BigX} & $\Big(\Big)$
$\Big[\Big]$ $\Bigl/\Big\backslash\Big\{\Big\}$
$\Big|$ $\Big\Vert$ $\Big\lfloor\Big\rfloor$
$\Big\lceil\Big\rceil$ $\Big\langle\Big\rangle$
$\Big\uparrow\Big\Uparrow$ $\Big\downarrow\Big\Downarrow$
$\Big\updownarrow\Big\Updownarrow$\\[4pt]
\CMD{biggX} & $\bigg(\bigg)$
$\bigg[\bigg]$ $\biggl/\bigg\backslash\bigg\{\bigg\}$%
$\bigg|$ $\bigg\Vert$ $\bigg\lfloor\bigg\rfloor$ $\bigg\lceil\bigg\rceil$
$\bigg\langle\bigg\rangle$ $\bigg\uparrow\bigg\Uparrow$
$\bigg\downarrow\bigg\Downarrow$ $\bigg\updownarrow\bigg\Updownarrow$\\[8pt]
\CMD{BiggX} & $\Bigg(\Bigg)$
$\Bigg[\Bigg]$ $\Biggl/\Bigg\backslash\Bigg\{\Bigg\}$
$\Bigg|$ $\Bigg\Vert$ $\Bigg\lfloor\Bigg\rfloor$
$\Bigg\lceil\Bigg\rceil$ $\Bigg\langle\Bigg\rangle$
$\Bigg\uparrow\Bigg\Uparrow$ $\Bigg\downarrow\Bigg\Downarrow$%
$\Bigg\updownarrow\Bigg\Updownarrow$
\end{tabular}
\medskip{}
Only a few commands can be written in a short form like \CMD{big(}.
The ``X{}'' has to be replaced with one of the following characters
or commands from table~\vref{tab:big}, which shows the parentheses
character, its code for the use with one of the ``big{}'' commands
and an example with the code for that.
\mPar{\CMD{biglX}\\\CMD{bigrX}}%
For all commands there exists a left/right version \CIndex{bigl},
\CIndex{bigr}, \CIndex{Bigl} and so on, which only makes sense when writing things like:
\begin{LTXexample}[width=0.3\linewidth,wide]
\begin{align}
\biggl)\times \frac{a}{b} \times\biggr(
\end{align}
\begin{align}
\bigg)\times \frac{a}{b} \times\bigg(
\end{align}
\end{LTXexample}
\LaTeX{} takes the \verb|\biggl)| as a \Index{mathopen symbol}, which has by default
another horizontal spacing.
In addition to the above commands there exist some more:
\CIndex{bigm}, \CIndex{Bigm}, \CIndex{biggm} and \CIndex{Biggm},
which work as the standard ones (without the addtional ``m{}'')
but add some more horizontal space%
\mPar{\CMD{bigmX}\\\CMD{bigmX}} %
between the delimiter and the formula before and after (see
table~\vref{cap:Difference-between-the-bigg}).
%$3\bigg|a^2-b^2-c^2\bigg|+2$
%$3\biggm|a^2-b^2-c^2\biggm|+2$
\begin{table}[!htb]
\caption{Difference between the default
\CMD{bigg} and the \CMD{biggm} command}\label{cap:Difference-between-the-bigg}
\begin{LTXexample}
$\bigg(\displaystyle\frac{1}{3}\bigg|\frac{3}{4}\bigg)$
\end{LTXexample}
\vspace{-15pt}
\begin{LTXexample}
$\bigg(\displaystyle\frac{1}{3}\biggm|\frac{3}{4}\bigg)$
\end{LTXexample}
\end{table}
\newcommand{\xstrut}{\rule{0pt}{0.55cm}}
{\setlength{\hangindent}{-\marginparwidth}
\def\arraystretch{1.5}
\begin{longtable}{@{}l>{\raggedright}p{2.4cm}l>{\raggedright}p{5.7cm}@{}}
\caption{Use of the different parentheses for the ``big{}'' commands} \label{tab:big}\tabularnewline
Char & Code & Example & Code\tabularnewline\hline
\endfirsthead
Char & Code & Example & Code\tabularnewline
\hline
\endhead
\xstrut$(\ )$ & ( ) & %
$3\Big(a^{2}+b^{c^{2}}\Big)$ & %
\texttt{3\CMD{Big}( a\^{}2+b\^{}\{c\^{}2\}\CMD{Big})}\tabularnewline
%
\xstrut$[\ ]$ & {[} {]}&
$3\Big[a^{2}+b^{c^{2}}\Big]$&
\texttt{3\CMD{Big}{[} a\^{}2+b\^{}\{c\^{}2\}\CMD{Big}{]}}\tabularnewline
%
\xstrut$/\ \backslash$ & \texttt{/}\CMD{backslash} & $3\Big/a^{2}+b^{c^{2}}\Big\backslash$ &
\texttt{3\CMD{Big}/ a\^{}2+b\^{}\{c\^{}2\}\CMD{Big}\CMD{backslash}}\tabularnewline
%
\xstrut$\{\ \}$ & \CMD{\{}\CMD{\}}\\
& $3\Big\{ a^{2}+b^{c^{2}}\Big\}$ &
\texttt{3\CMD{Big}\CMD{\{} a\^{}2+b\^{}\{c\^{}2\}\CMD{Big}\CMD{\}}}\tabularnewline
%
\xstrut$\vert\ \Vert$ & | \CMD{Vert} & $3\Big|a^{2}+b^{c^{2}}\Big\Vert$ & \texttt{3\CMD{Big}|a\^{}2+b\^{}\{c\^{}2\}\CMD{Big}\CMD{Vert}}\tabularnewline
%
\xstrut$\lfloor\ \rfloor$ & \CMD{lfloor} \CMD{rfloor} & %
$3\Big\lfloor a^{2}+b^{c^{2}}\Big\rfloor$ & %
\texttt{3\CMD{Big}\CMD{lfloor} a\^{}2+b\^{}\{c\^{}2\}
\CMD{Big}\CMD{rfloor}}\tabularnewline
%
\xstrut$\lceil\ \rceil$ & \CMD{lceil}\CMD{rceil} &
$3\Big\lceil a^{2}+b^{c^{2}}\Big\rceil$ &
\texttt{3\CMD{Big}\CMD{lceil} a\^{}2+b\^{}\{c\^{}2\} \CMD{Big}%
\CMD{rceil}}\tabularnewline
%
\xstrut$\langle\ \rangle$ & \CMD{langle}\CMD{rangle} &
$3\Big\langle a^{2}+b^{c^{2}}\Big\rangle$ &
\texttt{3\CMD{Big}\CMD{langle} a\^{}2+b\^{}\{c\^{}2\}%
\CMD{Big}\CMD{rangle}}\tabularnewline
%
\xstrut$\uparrow\ \Uparrow$ &
\CMD{uparrow} \CMD{Uparrow} &
$3\Big\uparrow a^{2}+b^{c^{2}}\Big\Uparrow$ &
\texttt{3\CMD{Big}\CMD{uparrow} a\^{}2+b\^{}\{c\^{}2\}%
\CMD{Big}\CMD{Uparrow}}\tabularnewline
%
\xstrut$\downarrow\ \Downarrow$ & \CMD{downarrow} \CMD{Downarrow} &
$3\Big\downarrow a^{2}+b^{c^{2}}\Big\Downarrow$ &
\texttt{3\CMD{Big}\CMD{downarrow} a\^{}2+b\^{}\{c\^{}2\}
\CMD{Big}\CMD{Downarrow}}\tabularnewline
%
\xstrut$\updownarrow\ \Updownarrow$ & \CMD{updownarrow} \CMD{Updownarrow} &
$3\Big\updownarrow a^{2}+b^{c^{2}}\Big\Updownarrow$ &
\texttt{3\CMD{Big}\CMD{updownarrow} a\^{}2+b\^{}\{c\^{}2\}
\CMD{Big}\CMD{Updownarrow}}\tabularnewline
\end{longtable}}
\clearpage
\subsection{Examples}
\subsubsection{Braces over several lines}\label{cap:Use-of-the-vphantom}
The following equation in the single line mode looks like
%
\begin{equation}
\frac{1}{2}\Delta(f_{ij}f^{ij})=2\left(\sum_{i<j}\chi_{ij}
(\sigma_{i}-\sigma_{j})^{2}+f^{ij}\nabla_{j}\nabla_{i}(\Delta f)
+\nabla_{k}f_{ij}\nabla^{k}f^{ij}+f^{ij}f^{k}[2\nabla_{i}R_{jk}
-\nabla_{k}R_{ij}]\right)\label{eq:braces}
\end{equation}
%
and is too long for the text width and the equation number has to be placed
under the equation.\footnote{In standard \LaTeX{} the equation and the number are
printed one over the other for too long
formulas. Only \AmSmath puts it one line over (left numbers) or under (right
numbers) the formula.} With the array environment the formula can be split in two smaller
pieces:
{\arraycolsep=2pt
\begin{equation}
\begin{array}{rcl}
\frac{1}{2}\Delta(f_{ij}f^{ij}) & = & 2\left({\displaystyle
\sum_{i<j}}\chi_{ij}(\sigma_{i}-\sigma_{j})^{2}+f^{ij}%
\nabla_{j}\nabla_{i}(\Delta f)+\right.\\
& & \left.+\nabla_{k}f_{ij}\nabla^{k}f^{ij}+f^{ij}f^{k}[2
\nabla_{i}R_{jk}-\nabla_{k}R_{ij}]\right)
\end{array}
\end{equation}
}
It is obvious that there is a problem with the right closing parentheses.
Because of the two pairs ``\verb|\left( ... \right.|''
and ``\verb|\left. ... \right)|''
they have a different size because every pair does it in its own
way. Using the \Index{Bigg} command changes this into a better
typesetting:
{\arraycolsep=2pt
\begin{equation}
\begin{array}{rcl}
\frac{1}{2}\Delta(f_{ij}f^{ij}) & = & 2\Bigg({\displaystyle
\sum_{i<j}}\chi_{ij}(\sigma_{i}-\sigma_{j})^{2}+f^{ij}%
\nabla_{j}\nabla_{i}(\Delta f)+\\
& & +\nabla_{k}f_{ij}\nabla^{k}f^{ij}+f^{ij}f^{k}[2
\nabla_{i}R_{jk}-\nabla_{k}R_{ij}]\Bigg)
\end{array}
\end{equation}
}
\begin{lstlisting}
{\arraycolsep=2pt
\begin{equation}
\begin{array}{rcl}
\frac{1}{2}\Delta(f_{ij}f^{ij}) & = & 2\Bigg({\displaystyle
\sum_{i<j}}\chi_{ij}(\sigma_{i}-\sigma_{j})^{2}+f^{ij}%
\nabla_{j}\nabla_{i}(\Delta f)+\\
& & +\nabla_{k}f_{ij}\nabla^{k}f^{ij}+f^{ij}f^{k}[2
\nabla_{i}R_{jk}-\nabla_{k}R_{ij}]\Bigg)
\end{array}
\end{equation}
}
\end{lstlisting}
Section~\vref{sec:Specials-for-multline} shows another solution
for getting the right size for parentheses when breaking the equation
in smaller pieces.
\begin{align*}
B(r,\phi,\lambda) = & \,\dfrac{\mu}{r}
\Bigg[\sum_{n=2}^{\infty} \Bigg( \left( \dfrac{R_e}{r} \right)^n J_nP_n(s\phi) \\
& +\sum_{m=1}^n \left( \dfrac{R_e}{r} \right) ^n
(C_{nm}\cos m\lambda+S_{nm}\sin m\lambda)P_{nm}(s\phi) \Bigg)\Bigg]
\end{align*}
\begin{lstlisting}
\begin{align*}
B(r,\phi,\lambda) = & \,\dfrac{\mu}{r}
\Bigg[\sum_{n=2}^{\infty} \Bigg( \left( \dfrac{R_e}{r} \right)^n J_nP_n(s\phi) \\
& +\sum_{m=1}^n \left( \dfrac{R_e}{r} \right) ^n
(C_{nm}\cos m\lambda+S_{nm}\sin m\lambda)P_{nm}(s\phi) \Bigg)\Bigg]
\end{align*}
\end{lstlisting}
\subsubsection{Middle bar}
See section~\vref{sec:braket} for examples and the use of package \PIndex{braket}.
\subsection{New delimiters}\label{subsec:delim}
The default delimiters\index{Delimiter} are defined in the file \verb|fontmath.ltx|\index{fontmath.ltx}
which is stored in general
in \path{[TEXMF]/tex/latex/base/fontmath.ltx}. If we need for example a thicker vertical symbol
than the existing \CIndex{vert} symbol we can define in the preamble:
\begin{lstlisting}
\DeclareMathDelimiter{\Norm}
{\mathord}{largesymbols}{"3E}{largesymbols}{"3E}
\end{lstlisting}
The character number $3E_{16}$ (decimal $62$) from the \FIndex{cmex10} font is the small
thick vertical rule. Now the new delimiter \verb|\Norm| can be used in the usual way:
\begin{LTXexample}[width=0.3\linewidth,wide]
$\left\Norm *BLA* \right\Norm$
$\left\Norm \dfrac{*BLA*}{*BLUB*} \right\Norm$
\end{LTXexample}
\subsection{Problems with parentheses}\label{subsec:Problems-with-parenthesis}
\mPar{\CMD{delimitershortfall}\\\CMD{delimiterfactor}}%
It is obvious that the following
equation has not the right size of the parenthesis in the
second integral, the inner one should be a bit smaller than the outer one.
%
\begin{LTXexample}[width=0.425\linewidth,wide]
\[
\int_\gamma F'(z) dz =\int_\alpha^\beta
F'\left(\gamma (t)\right)\cdot\gamma '(t)dt
\]
\end{LTXexample}
The problem is that \TeX{} controlls the height of the parenthesis with
\LIndex{delimitershortfall} and \CIndex{delimiterfactor}, with the default values
\begin{verbatim}
\delimitershortfall=5pt
\delimiterfactor=901
\end{verbatim}
\verb|\delimiterfactor/1000| is the relative size of the parenthesis for a given formula
environment. They could be of \verb|\delimitershortfall| too short. These values are valid
at the end of the formula, the best way is to set them straight before the math environment
or globally for all in the preamble.
\begin{LTXexample}[width=0.425\linewidth,wide]
{\delimitershortfall=-1pt
\[
\int_\gamma F'(z) dz =\int_\alpha^\beta
F'\left(\gamma (t)\right)\cdot\gamma '(t)dt
\]}
\end{LTXexample}
\section{Text in math mode}\label{sec:Text}
Standard \index{Text}text in math mode should be written in upright shape and not
in the italic\index{Italic} one. This shape is reserved for the variable
names: $\boxed{{I\ am\ \textrm{text}\ inside\ math.}}$ (see also
Zable~\vref{cap:Spaces-in-math mode}). There are different ways to write text inside math.
\mPar{\CMD{textstyle}\\\CMD{mbox}}
\begin{itemize}
\mPar{\CMD{mathrm}}
\item \CMD{mathrm}. It is like math mode (no spaces), but in upright mode
\item \CMD{textrm}. Upright mode with printed spaces (real textmode)
\item \CMD{mbox}. The font size is still the one from \CIndex{textstyle}
(see section~\vref{sec:Styles}), so that you have to place additional
commands when you use \CIndex{mbox} in a super- or subscript for limits.
\end{itemize}
Inserting long text is possible with a \CIndex{parbox}, which can be aligned as usual to the top,
bottom or center, \eg \index{Text!\textbackslash parbox}
\begin{eqnarray}
a+b+c+d+ef & = & g+h+i+j+k %
\qquad\textrm{\parbox[t]{.25\linewidth}{%
this is a very long description of a formula}%
}
\end{eqnarray}
\begin{lstlisting}
\begin{eqnarray}
a+b+c+d+ef & = & g+h+i+j+k %
\qquad\textrm{\parbox[t]{.25\linewidth}{%
this is a very long description of a formula}%
}
\end{eqnarray}
\end{lstlisting}
Additional commands for text inside math are provided by \AmSmath (see
section \vref{sec:Text-in-math mode}).
%$
\section{Font commands}
\subsection{Old-style font commands}
Should never be used, but are still present and supported by \LaTeX{}. The
default syntax for the old commands is
\begin{lstlisting}
{\XX test}
\end{lstlisting}
Table~\vref{cap:Old-Fontstyle-commands} shows what has to be replaced for the \verb+XX+.
The major difference to the new style is that these
\CMD{XX} are toggling the actual math mode into
the ``XX{}'' one, whereas the new commands start which, at its end,
switches back to the previous mode.
\begin{table}[!htb]
\centering
\begin{tabular}{rc|rc|rc|cc|cc}
\CMD{bf}\index{bf@\textbackslash bf} & ${\bf {\bf test}}$ &
\CMD{cal}\index{cal@\textbackslash cal} & ${\cal TEST}$ &
\CMD{it}\index{it@\textbackslash it} &
${\it test}$ &
\CMD{rm}\index{rm@\textbackslash rm} &
${\rm test}$ &
\CMD{tt}\index{tt@\textbackslash tt} &
${\tt test}$\tabularnewline
\end{tabular}
\caption{Old font style commands}\label{cap:Old-Fontstyle-commands}
\end{table}
\subsection{New-style font commands}\label{sub:New-Style-Fontcommands}
%
\mPar{\CMD{mathrm}\\
\CMD{mathfrak}\\
\CMD{mathcal}\\
\CMD{mathsf}\\
\CMD{mathbb}\\
\CMD{mathtt}\\
\CMD{mathit}\\
\CMD{mathbf}}
The default syntax is
\begin{lstlisting}
\mathXX{test}
\end{lstlisting}
Table~\ref{cap:Fonts-in-math-mode} shows what has to be
replaced for the XX. See section~\vref{sec:euscript.sty} for additional packages.
\begin{table}[htb]
\caption{Fonts in math mode}\label{cap:Fonts-in-math-mode}
\centering
\includegraphics{styles}
\iffalse
\begin{table}[!htb]
\begin{minipage}{\linewidth}
\centering
\begin{tabularx}{.9\linewidth}{l|X}
\textbf{Command} & \textbf{Test}\tabularnewline\hline
default & $ABCDEFGHIJKLMNOPQRSTUVWXYZ$
$abcdefghijklmnopqrstuvwxyz$\tabularnewline
\CMD{mathfrak} &
$\mathfrak{{ABCDEFGHIJKLMNOPQRSTUVWXYZ}}$
$\mathfrak{{abcdefghijklmnopqrstuvwxyz}}$\tabularnewline
\CMD{mathcal}%
\footnote{Not available for lower letters. For mathcal exists a
non free font for lower letters (http://www.pctex.com)}\addtocounter{mpfootnote}{-1} &
$\mathcal{ABCDEFGHIJKLMNOPQRSTUVWXYZ}$\tabularnewline
\CMD{mathsf}&
$\mathsf{ABCDEFGHIJKLMNOPQRSTUVWXYZ}$
$\mathsf{abcdefghijklmnopqrstuvwxyz}$\tabularnewline
\CMD{mathbb}${}^a$ & $\mathbb{ABCDEFGHIJKLMNOPQRSTUVWXYZ}$\tabularnewline
\CMD{mathtt} & $\mathtt{ABCDEFGHIJKLMNOPQRSTUVWXYZ}$
$\mathtt{abcdefghijklmnopqrstuvwxyz}$\tabularnewline
\CMD{mathit} & $\mathit{ABCDEFGHIJKLMNOPQRSTUVWXYZ}$
$\mathit{abcdefghijklmnopqrstuvwxyz}$\tabularnewline
\CMD{mathrm} & $\mathrm{ABCDEFGHIJKLMNOPQRSTUVWXYZ}$
$\mathrm{abcdefghijklmnopqrstuvwxyz}$\tabularnewline
\CMD{mathbf} & $\mathbf{ABCDEFGHIJKLMNOPQRSTUVWXYZ}$
$\mathbf{abcdefghijklmnopqrstuvwxyz}$\tabularnewline
\CMD{mathds}${}^b$ & $\mathds{ABCDEFGHIJKLMNOPQRSTUVWXYZ}$\tabularnewline
\end{tabularx}
\end{minipage}
\fi
\end{table}
\index{mathfrak@\textbackslash mathfrak}\index{mathsf@\textbackslash mathsf}
\index{mathbb@\textbackslash mathbb}\index{mathcal@\textbackslash mathcal}
\index{mathbf@\textbackslash mathbf}\index{mathit@\textbackslash mathit}
\index{mathrm@\textbackslash mathrm}\index{mathtt@\textbackslash mathtt}
\index{mathds@\textbackslash mathds}\index{double stroke}
\index{dsfont@\texttt{dsfont}}\index{Set symbol}
%\end{comment}
\section{Space}
\subsection{Math typesetting}\label{subsec:mathskip}
\mPar{\CMD{thinmuskip}\\
\CMD{medmuskip}\\
\CMD{thickmuskip}}
\LaTeX\ defines the three math lengths\footnote{For more
information see: \url{http://www.tug.org/utilities/plain/cseq.html}} with the following
values\footnote{see \texttt{\small fontmath.ltx}}:
\begin{lstlisting}
\thinmuskip=3mu
\medmuskip=4mu plus 2mu minus 4mu
\thickmuskip=5mu plus 5mu
\end{lstlisting}
\noindent where \verb|mu| is the abbreviation for \Index{math unit}.
\[
1 \mathrm{mu}= \dfrac{1}{18} \mathrm{em}
\]
\begin{table}[htb]
\centering
\begin{tabular}{ll}
\fboxsep=0pt
\text{default} & $\boxed{f(x)=x^2+3x_0\cdot\sin x}$\\
\CMD{thinmuskip=0mu} & {\thinmuskip=0mu $\boxed{f(x)=x^2+3x_0\cdot\sin x}$}\\
\CMD{medmuskip=0mu} & {\medmuskip=0mu $\boxed{f(x)=x^2+3x_0\cdot\sin x}$}\\
\CMD{thickmuskip=0mu} & {\thickmuskip=0mu $\boxed{f(x)=x^2+3x_0\cdot\sin x}$}\\
all set to zero & {\thickmuskip=0mu\thinmuskip=0mu\medmuskip=0mu $\boxed{f(x)=x^2+3x_0\cdot\sin x}$}\\
\end{tabular}
\caption{The meaning of the math spaces}\label{tab:mathSpaces}
\end{table}
These lengths can have all glue and are
used for the horizontal spacing in math expressions where \TeX{} puts spaces between symbols
and operators. The meaning of these different
horizontal skips is shown in table~\ref{tab:mathSpaces}. For a better typesetting \LaTeX{}
inserts different spaces between the symbols.
\begin{description}
\item[\CIndex{thinmuskip}] space between ordinary and operator atoms
\item[\CIndex{medmuskip}] space between ordinary and binary atoms in display and text styles
\item[\CIndex{thickmuskip}] space between ordinary and relation atoms in display and text styles
\end{description}
\subsection{Additional horizontal spacing}
\mPar{\CMD{thinspace}\\
\CMD{medspace}\\
\CMD{thickspace}\\
\CMD{negthinspace}\\
\CMD{negmedspace}\\
\CMD{negthickspace}}
\begin{table}[!htb]
\def\arraystretch{1.2}
\centering
\begin{tabular}{ll|ll}
\multicolumn{2}{l|}{Positive Space}&\multicolumn{2}{l}{Negative Space}\\\hline
\verb|$ab$| & $\boxed{a}\boxed{b}$\\
\verb|$a b$| & $\boxed{a} \boxed{b}$\\
\verb|$a\ b$| & $\boxed{a}\ \boxed{b}$\\
\verb|$a\mbox{\textvisiblespace}b$| & $\boxed{a}\mbox{\textvisiblespace}\boxed{b}$\\
\verb|$a\,b$|\index{,@\textbackslash ,} (\verb|$a\thinspace b$|)\index{thinspace@\textbackslash thinspace} & $\boxed{a}\,\boxed{b}$&
\verb|$a\! b$|\index{negthinspace@\textbackslash negthinspace} & $\boxed{a}\!\boxed{b}$\\
\verb|$a\: b$|\index{:@\textbackslash :} (\verb|$a\medspace b$|)\index{medspace@\textbackslash medspace}&
$\boxed{a}\:\boxed{b}$&
\verb|$a\negmedspace b$|\index{negmedspace@\textbackslash negmedspace} & $\boxed{a}\negmedspace\boxed{b}$\\
\verb|$a\; b$|\index{;@\textbackslash ;} (\verb|$a\thickspace b$|\index{thickspace@\textbackslash thickspace}&
$\boxed{a}\;\boxed{b}$&
\verb|$a\negthickspace b$|\index{negthickspace@\textbackslash negthickspace}&
$\boxed{a}\negthickspace\boxed{b}$\\
\verb|$a\quad b$|\index{quad@\textbackslash quad} & $\boxed{a}\quad\boxed{b}$\\
\verb|$a\qquad b$|\index{qquad@\textbackslash qquad} & $\boxed{a}\qquad\boxed{b}$\\
\verb|$a\hspace{0.5cm}b$|\index{hspace@\textbackslash hspace}& $\boxed{a}\hspace{0.5cm}\boxed{b}$&
\verb|$a\hspace{-0.5cm}b$| & $\boxed{a}\hspace{-0.5cm}\boxed{b}$\\
\verb|$a\kern0.5cm b$|\index{kern@\textbackslash kern} & $\boxed{a}\kern0.5cm \boxed{b}$ & \verb|$a\kern-0.5cm b$| & $\boxed{a}\kern-0.5cm \boxed{b}$\\
\verb|$a\hphantom{xx}b$|\index{hphantom@\textbackslash hphantom} & $\boxed{a}\hphantom{xx}\boxed{b}$\\
\verb|$axxb$| & $\boxed{a}xx\boxed{b}$
\end{tabular}
\caption{Spaces in math mode}\label{cap:Spaces-in-math mode}
\end{table}
%$
LaTeX defines the following short commands:
\begin{verbatim}
\def\>{\mskip\medmuskip}
\def\;{\mskip\thickmuskip}
\def\!{\mskip-\thinmuskip}
\end{verbatim}
In math mode there is often a need for additional tiny spaces between variables,
\eg $L\dfrac{di}{dt}$ written with a tiny space between $L$ and
$\dfrac{di}{dt}$ looks nicer: $L\:\dfrac{di}{dt}$. Table~\ref{cap:Spaces-in-math mode}
shows a list of all commands for horizontal space which can be used
in math mode. The ``space{}'' is seen ``between{}'' the boxed a
and b. For all examples a is \verb+\boxed{a}+ and
b is \verb+\boxed{b}+. The short forms for some
\mPar{\CMD{hspace}\\
\CMD{hphantom}\\
\CMD{kern}}
spaces may cause problems with other packages. In this case use the
long form of the commands.
\subsection{Problems}\label{space:problems}
Using \CIndex{hphantom} in mathmode depends to on object. \CIndex{hphantom}
reserves only the space of
the exact width without any additional space. In the following example the second line is
wrong: \verb+& \hphantom{\rightarrow} b\\+. It does not reserve any additional space.
\begin{LTXexample}[width=0.15\linewidth,wide]
\begin{align*}
a & \rightarrow b\\
& \hphantom{\rightarrow} b\\
& \mkern\thickmuskip\hphantom{\rightarrow}\mkern\thickmuskip b\\
& \mathrel{\hphantom{\rightarrow}} b
\end{align*}
\end{LTXexample}
This only works when the math symbol is a mathrel one, otherwise you have to change the
horizontal space to \CIndex{medmuskip} or \CIndex{thinmuskip} or to use an empty group after
the \CIndex{hphantom} command. For more informations
about the math objects look into \verb+fontmath.ltx+ or \PIndex{amssymb} or use the \CIndex{show}
macro, which prints out the type of the mathsymbol, \eg \verb+\show\rightarrow+ with the
output:
\begin{lstlisting}
> \rightarrow=\mathchar"3221.
l.20 \show\rightarrow
\end{lstlisting}
The first digit represents the type:
\begin{tabular}{l@{ : }l}
0 & ordinary\\
1 & large operator\\
2 & binary operation\\
3 & relation\\
4 & opening\\
5 & closing\\
6 & punctuation\\
7 & variable family
\end{tabular}
%\iffalse
\begingroup
\thinmuskip=3mu
\medmuskip=4mu plus 2mu minus 4mu
\thickmuskip=5mu plus 5mu
\medskip
Grouping a math symbol can change the behaviour in horizontal spacing. Compare
$50\mkern\thinmuskip\times\mkern\thinmuskip10^{12}$ and $50{\times}10^{12}$, the first one is typeset with
\verb+$50\times10^{12}$+ and the second one with \verb+$50{\times}10^{12}$+.
\endgroup
%\fi
Another possibilty is to use the \PIndex{numprint} package.\footnote{%
\href{ftp://ftp.dante.de/tex-archive/macros/latex/contrib/numprint/}%
{CTAN://macros/latex/contrib/numprint/}}
\subsection{Dot versus comma}\label{subsec:dot-comma}
\mPar{\CMD{mathpunct}\\\CMD{mathord}}%
In difference to a \Index{decimal point} and a \Index{comma} as a marker of thousands a lot of
countries prefer it vice versa. To get the same behaviour the meaning of \Index{dot} and
comma has to be changed:
\begin{align}
1,234,567.89 & \text{ default}\\
1.234.567,89 & \text{ vice versa, wrong spacing}\label{eq:comma}\\
1\mathpunct{.}234\mathpunct{.}567{,}89 & \text{ correct spacing}
\end{align}
\begin{lstlisting}
%\usepackage{amsmath}
1,234,567.89 & \text{ default}\\
1.234.567,89 & \text{ vice versa, wrong spacing}\\
1\mathpunct{.}234\mathpunct{.}567{,}89 & \text{ correct spacing}
\end{lstlisting}
The original definitions from \verb+fontmath.ltx+\footnote{%
Located in \url{texmf/tex/latex/base/}} are
\begin{verbatim}
\DeclareMathSymbol{,}{\mathpunct}{letters}{"3B}
\DeclareMathSymbol{.}{\mathord}{letters}{"3A}
\end{verbatim}
\noindent\CIndex{mathord} and \CIndex{mathpunct}
can be changed for a documentwide other behaviour. In the above equation~\ref{eq:comma}
the comma is only set in a pair of braces \verb+{,}+, which is the same as writing
\verb+\mathord{,}+ because \LaTeX{} handles everything
inside of parenthises as a formula, which gets the same spacing.
It is also possible to use the package \PIndex{icomma}\footnote{%
\href{ftp://ftp.dante.de/tex-archive/macros/latex/contrib/was/}%
{CTAN:// macros/latex/contrib/was/}} for a documentwide
correct spacing.
\subsection{Vertical whitespace}\label{subsec:vwhitespace}
\subsubsection{Before/after math expressions}\label{subsubsec:displayskip}
There are four predefined lengths, which control the vertical whitespace
of displayed formulas:
\begin{verbatim}
\abovedisplayskip=12pt plus 3pt minus 9pt
\abovedisplayshortskip=0pt plus 3pt
\belowdisplayskip=12pt plus 3pt minus 9pt
\belowdisplayshortskip=7pt plus 3pt minus 4pt
\end{verbatim}
\index{abovedisplayskip@\textbackslash abovedisplayskip}
\index{abovedisplayshortskip@\textbackslash abovedisplayshortskip}
\index{belowdisplayskip@\textbackslash belowdisplayskip}
\index{belowdisplayshortskip@\textbackslash belowdisplayshortskip}
The short skips are used if the formula starts behind the end of the foregoing
last line. Only for demonstration the shortskips
are set to \verb|0pt| in the following examples and the normal skips to
\verb|20pt| without any glue:
\medskip
\noindent\fbox{\begin{minipage}{\linewidth-2\fboxsep-2\fboxrule}
\abovedisplayshortskip=0pt
\belowdisplayshortskip=0pt
\abovedisplayskip=20pt
\belowdisplayskip=20pt
\noindent The line ends before.
\begin{equation}
f(x) = \int\frac{\sin x}{x}\,\mathrm{d}x
\end{equation}
\noindent The line doesn't end before the formula.
\begin{equation}
f(x) = \int\frac{\sin x}{x}\,\mathrm{d}x
\end{equation}
\noindent And the next line starts as usual with some text ...
\end{minipage}}
\medskip
\begin{lstlisting}
\abovedisplayshortskip=0pt
\belowdisplayshortskip=0pt
\abovedisplayskip=20pt
\belowdisplayskip=20pt
\noindent The line ends before.
\begin{equation}
f(x) = \int\frac{\sin x}{x}\,\mathrm{d}x
\end{equation}
\noindent The line doesn't end before the formula.
\begin{equation}
f(x) = \int\frac{\sin x}{x}\,\mathrm{d}x
\end{equation}
\noindent And the next line starts as usual with some text ...
\end{lstlisting}
%$
\mPar{\texttt{fleqn} class option}%
When using the \verb+fleqn+\index{fleqn@\texttt{fleqn}} classoption for left
aligned equations the math environments \uIndex{equation}
and \CIndex{[}\ldots\CIndex{]} are typeset as a list. This is the reason why the
vertical space is defined by the length registers for a list, especially
\LIndex{topsep}, instead of \LIndex{abovedisplayskip} and \LIndex{belowdisplayskip}.
This doesn't effect the \UIndex{eqnarray}.
\subsubsection{Inside math expressions}\label{subsec:vspacing}
\paragraph{\CMD{\textbackslash [<length>]}}
This works inside the math mode in the same way as in the text mode.
\paragraph{\CMD{jot}}\mPar{\CMD{jot}}
The vertical space between the lines for all math expressions which allow multiple
lines can be changed with the length \LIndex{jot}, which is predefined as
\begin{verbatim}
\newdimen\jot \jot=3pt
\end{verbatim}
The following three formulas show this for the default value, \verb|\setlength\jot{0pt}|
and \verb|\setlength\jot{10pt}|.
\begin{minipage}{0.3\linewidth}
\begin{eqnarray*}
y & = & d\\
y & = & c\frac{1}{x}+d\\
y & = & b\frac{1}{x^{2}}+cx+d\\
\end{eqnarray*}
\end{minipage}\hfill
\begin{minipage}{0.3\linewidth}
\setlength\jot{0pt}
\begin{eqnarray*}
y & = & d\\
y & = & c\frac{1}{x}+d\\
y & = & b\frac{1}{x^{2}}+cx+d\\
\end{eqnarray*}
\end{minipage}\hfill
\begin{minipage}{0.3\linewidth}
\setlength\jot{10pt}
\begin{eqnarray*}
y & = & d\\
y & = & c\frac{1}{x}+d\\
y & = & b\frac{1}{x^{2}}+cx+d\\
\end{eqnarray*}
\end{minipage}
Defining a new environment with a parameter makes things easier, because changes to the
length are locally.
\begin{lstlisting}
\newenvironment{mathspace}[1]{%
\setlength{\jot}{#1}%
\ignorespaces%
}{%
\ignorespacesafterend%
}
\end{lstlisting}
\paragraph{\CMD{arraystretch}}\cIndex{arraystretch}
\mPar{\CMD{arraystretch}}%
The vertical space between the lines for all math expressions which contain an
\UIndex{array} can be changed with the command
\CIndex{arraystretch}, which is predefined
as
\begin{verbatim}
\renewcommand\arraystretch{1}
\end{verbatim}
Renewing this definition is global to all following math expressions, so it should be used
in the same way as \LIndex{jot}.
\paragraph{\CMD{vskip}}\index{Vertical spacing}\index{Spacing!vertical}
Another spacing for single lines is possible with the \CIndex{vskip} macro:
\begin{LTXexample}[width=0.4\linewidth]
\[
\begin{pmatrix}
0 & 1 & 1 & 0 & 0 & 1 \\
1 & 0 & 0 & 1 & 1 & 0 \\
\noalign{\vskip2pt}
0 & 1 & 1 & 0 & \dfrac{1}{\sqrt{2}} & 1\\
\noalign{\vskip2pt}
1 & 0 & 1 & 0 & 1 & 0 \\
0 & 1 & 0 & 1 & 0 & 1 \\
\end{pmatrix}
\]
\end{LTXexample}
\paragraph{Package \texttt{setspace}}
To have all formulas with another vertical spacing, one can choose
the package \PIndex{setspace} and redefining some of the math macros, \eg
\begingroup
\newcommand*\Array[2][1]{\setstretch{#1}\array{#2}}
\let\endArray\endarray
\begin{lstlisting}
\newcommand*\Array[2][1]{\setstretch{#1}\array{#2}}
\let\endArray\endarray
\end{lstlisting}
\begin{LTXexample}[width=0.25\linewidth]
\[
\begin{Array}[2]{cc}
a =&b\\
a =&b\\
a =&b
\end{Array}
\]
text $\begin{Array}{cc}
a =&b\\
a =&b\\
a =&b
\end{Array}$ text
\end{LTXexample}
\endgroup
\section{Styles}\label{sec:Styles}
\begin{table}[htb]
\newlength\formula
\settowidth{\formula}{$f(t)=\frac{T}{2\pi }\int \frac{1}{\sin \frac{\omega }{t}}dt$}
\begin{tabular}{l|ll}
Mode & Inline & Displayed\\\hline
default & $f(t)=\frac{T}{2\pi}\int\frac{1}{\sin\frac{\omega}{t}}dt$&
\begin{minipage}{\formula}\[
f(t)=\frac{T}{2\pi}\int\frac{1}{\sin\frac{\omega}{t}}dt\]
\end{minipage}\\
\CMD{displaystyle} &
${\displaystyle f(t)=\frac{T}{2\pi}\int\frac{1}{\sin\frac{\omega}{t}}dt}$&
\begin{minipage}{\formula}\[
{\displaystyle f(t)=\frac{T}{2\pi}\int\frac{1}{\sin\frac{\omega}{t}}dt}\]
\end{minipage}\\
\CMD{scriptstyle} &
${\scriptstyle {\textstyle f(t)=\frac{T}{2\pi}\int\frac{1}{\sin\frac{\omega}{t}}dt}}$&
\begin{minipage}{\formula}\[
{\textstyle {\scriptstyle f(t)=\frac{T}{2\pi}\int\frac{1}{\sin\frac{\omega}{t}}dt}}\]
\end{minipage}\tabularnewline
\CMD{scriptscriptstyle} &
${\scriptscriptstyle f(t)=\frac{T}{2\pi}\int\frac{1}{\sin\frac{\omega}{t}}dt}$&
\begin{minipage}{\formula}\[
{\scriptscriptstyle f(t)=\frac{T}{2\pi}\int\frac{1}{\sin\frac{\omega}{t}}dt}\]
\end{minipage}\tabularnewline
\CMD{textstyle} &
${\textstyle f(t)=\frac{T}{2\pi}\int\frac{1}{\sin\frac{\omega}{t}}dt}$&
\begin{minipage}{\formula}\[
{\textstyle f(t)=\frac{T}{2\pi}\int\frac{1}{\sin\frac{\omega}{t}}dt}\]
\end{minipage}
\end{tabular}
\caption{Math styles}\label{cap:Mathstyles}
\end{table}
%$
\makeatletter
\newenvironment{smallequation}[1]{%
\skip@=\baselineskip
#1%
\baselineskip=\skip@
\equation
}{\endequation \ignorespacesafterend}
\makeatother
This depends on the environment in which they are used. An inline
formula has a default math %
\mPar{\CMD{textstyle}\\
\CMD{displaystyle}\\
\CMD{scriptstyle}\\
\CMD{scripscriptstyle}} fontsize called \CIndex{textstyle},
which is smaller than the one for a display formula (see section~\ref{display}), which is called
\CIndex{displaystyle}.
Beside this predefinition there are two other special fontstyles for
math, \CIndex{scriptstyle} and \CIndex{scriptscriptstyle}.
They are called ``style{}'' in difference to ``size{}'', because
they have a dynamic character, their real fontsize belongs to the
environment in which they are used. A fraction for example is by default in scriptstyle when it is in an
inline formula like this $\frac{a}{b}$, which can be changed to
${\displaystyle \frac{a}{b}}$.
This may be in some cases useful but it looks in general ugly because
the line spacing is too big.
These four styles\index{Style} are predefined and together in a
logical relationship. It is no problem to use the other styles like
\Index{large}, \CIndex{Large}, \ldots\ \textbf{outside} the math environment.
For example a fraction written with \CIndex{Huge}: {\Huge$\frac{a}{b}$}
(\verb|\Huge$\frac{a}{b}$|). This may cause some problems when you want to write
a displayed formula in another fontsize\index{Fontsize}, because it also affects the interline spacing of
the preceding part of the paragraph.
If you end the paragraph, you get problems with spacing and page breaking
above the equations. So it is better to declare the font size and then
restore the baselines:
\begin{smallequation}{\tiny}
\int_1^2\,\frac{1}{x^2}\,\mathrm{d}x=0.5
\end{smallequation}
\begin{lstlisting}
\makeatletter
\newenvironment{smallequation}[1]{%
\skip@=\baselineskip
#1%
\baselineskip=\skip@
\equation
}{\endequation \ignorespacesafterend}
\makeatother
\begin{smallequation}{\tiny}
\int_1^2\,\frac{1}{x^2}\,\mathrm{d}x=0.5
\end{smallequation}
\end{lstlisting}
If you use this the other way round for huge fontsizes, don't forget to load package
\PIndex{exscale} (see section~\vref{sec:exscale}). Also see this section for diffent symbol sizes.
\section{Dots\label{sec:Dots}}
\mPar{\CMD{cdots}\\
\CMD{dots}\\
\CMD{dotsb}\\
\CMD{dotsc}\\
\CMD{dotsi}\\
\CMD{dotsm}\\
\CMD{dotso}\\
\CMD{ldots}\\
\CMD{vdots}}%
In addition to the above decorations there are some more different
dots which are single commands and not by default over/under a letter.
It is not easy to see the differences between some of them. Dots from
lower left to upper right are possible with
\verb|\reflectbox{$\ddots$}|\index{reflectbox@\textbackslash reflectbox}
\reflectbox{$\ddots$}
\begin{table}[htb]
\centering
\begin{tabular}{*{5}{rc}}
\CMD{cdots}\index{cdots@\textbackslash cdots}&$\cdots$ &
\CMD{ddots}\index{ddots@\textbackslash ddots}&$\ddots$ &
\CMD{dotsb}\index{dotsb@\textbackslash dotsb}&$\dotsb$ &
\CMD{dotsc}\index{dotsc@\textbackslash dotsc}&$\dotsc$ &
\CMD{dotsi}\index{dotsi@\textbackslash dotsi}&$\dotsi$ \\\hline
\CMD{dotsm}\index{dotsm@\textbackslash dotsm}&$\dotsm$ &
\CMD{dotso}\index{dotso@\textbackslash dotso}&$\dotso$ &
\CMD{ldots}\index{ldots@\textbackslash ldots}&$\ldots$ &
\CMD{vdots}\index{vdots@\textbackslash vdots}&$\vdots$
\end{tabular}
\caption{Dots in math mode}
\end{table}
\section{Accents}\label{sec:Accents}
The letter ``a{}'' is only for demonstration. The table \ref{cap:Accents-in-math mode}
shows all in standard \LaTeX{} available accents and also the ones placed under a character.
With package \PIndex{amssymb} it is easy to define new accents. For
more information see section~\vref{amssymb} or
other possibilities at section \vref{sec:package-accent}.
\begin{table}[htb]
\makebox[\textwidth]{%
\begin{tabular}{rc|rc|rc}
\CIndex{acute}\index{acute@\textbackslash acute} &$\acute{a}$&
\CIndex{bar}\index{bar@\textbackslash bar}&$\bar{a}$&
\CIndex{breve}\index{breve@\textbackslash breve} & $\breve{a}$\\
\CIndex{bar}\index{bar@\textbackslash bar}&$\bar{a}$&
\CIndex{breve}\index{breve@\textbackslash breve} &$\breve{a}$\tabularnewline
\CIndex{check}\index{check@\textbackslash check} &$\check{a}$&
\CIndex{dddot} \index{dddot@\textbackslash dddot}&$\dddot{a}$&
\CIndex{ddot}\index{ddot@\textbackslash ddot}&$\ddot{a}$\tabularnewline
\CIndex{dot}\index{dot@\textbackslash dot}&$\dot{a}$&
\CIndex{grave}\index{grave@\textbackslash grave}&$\grave{a}$&
\CIndex{hat}\index{hat@\textbackslash hat}&$\hat{a}$\tabularnewline
\CIndex{mathring}\index{mathring@\textbackslash mathring}&$\mathring{a}$&
\CIndex{overbrace}\index{overbrace@\textbackslash overbrace}&$\overbrace{a}$&
\CIndex{overleftarrow}\index{overleftarrow@\textbackslash overleftarrow}&$\overleftarrow{a}$\tabularnewline
\CIndex{overleftrightarrow}\index{overleftrightarrow@\textbackslash overleftrightarrow}&$\overleftrightarrow{a}$&
\CIndex{overline}\index{overline@\textbackslash overline}&$\overline{a}$&
\CIndex{overrightarrow}\index{overrightarrow@\textbackslash overrightarrow}&$\overrightarrow{a}$\tabularnewline
\CIndex{tilde}\index{tilde@\textbackslash tilde}&$\tilde{a}$&
\CIndex{underbar}\index{underbar@\textbackslash underbar}&$\underbar{a}$&
\CIndex{underbrace}\index{underbrace@\textbackslash underbrace}&$\underbrace{a}$\tabularnewline
\CIndex{underleftarrow}\index{underleftarrow@\textbackslash underleftarrow}&$\underleftarrow{a}$&
\CIndex{underleftrightarrow}\index{underleftrightarrow@\textbackslash underleftrightarrow}&
$\underleftrightarrow{a}$&
\CIndex{underline}\index{underline@\textbackslash underline}&$\underline{a}$\tabularnewline
\CIndex{underrightarrow}\index{underrightarrow@\textbackslash underrightarrow}&$\underrightarrow{a}$&
\CIndex{vec}\index{vec@\textbackslash vec}&$\vec{a}$&
\CIndex{widehat}\index{widehat@\textbackslash widehat}&$\widehat{a}$\tabularnewline
\CIndex{widetilde}\index{widetilde@\textbackslash widetilde}&$\widetilde{a}$ & & & &
\end{tabular}%
}
\caption{Accents in math mode}\label{cap:Accents-in-math mode}
\end{table}
The letters \verb+i+ and \verb+j+ can be substituted with the macros \CIndex{imath}
and \CIndex{jmath} when an accents is placed over these letters and the dot should
disappear: $\vec{\imath}\ \dddot{\jmath}$ (\verb+$\vec{\imath}\ \dddot{\jmath}$+).
Accents can be used in different ways, \eg strike a single character with a horizontal line like
\verb+$\mathaccent`-A$+: $\mathaccent`-A$ or \verb+$\mathaccent\mathcode`-A$+: $\mathaccent\mathcode`-A$.
In section~\vref{cancel.sty} is a better solution for more than one character.
\subsection{Over- and underbrackets}
There are no \CIndex{underbracket} and \CIndex{overbracket}
commands in the list of accents. They can be defined in the preamble
with the following code.
\begin{lstlisting}[xleftmargin=-1cm,xrightmargin=-1cm]
\makeatletter
\def\underbracket{%
\@ifnextchar[{\@underbracket}{\@underbracket [\@bracketheight]}%
}
\def\@underbracket[#1]{%
\@ifnextchar[{\@under@bracket[#1]}{\@under@bracket[#1][0.4em]}%
}
\def\@under@bracket[#1][#2]#3{%\message {Underbracket: #1,#2,#3}
\mathop{\vtop{\m@th \ialign {##\crcr $\hfil \displaystyle {#3}\hfil $%
\crcr \noalign {\kern 3\p@ \nointerlineskip }\upbracketfill {#1}{#2}
\crcr \noalign {\kern 3\p@ }}}}\limits}
\def\upbracketfill#1#2{$\m@th \setbox \z@ \hbox {$\braceld$}
\edef\@bracketheight{\the\ht\z@}\bracketend{#1}{#2}
\leaders \vrule \@height #1 \@depth \z@ \hfill
\leaders \vrule \@height #1 \@depth \z@ \hfill \bracketend{#1}{#2}$}
\def\bracketend#1#2{\vrule height #2 width #1\relax}
\makeatother
\end{lstlisting}
%$
\begin{enumerate}
\item \verb/\underbrace{...}/ is an often used command:
\begin{eqnarray}
\underbrace{{x^{2}+2x+1}} & = & f(x)\\
\left(x+1\right)^{2}\,\,\,\nonumber
\end{eqnarray}
\item Sometimes an under\textbf{bracket} is needed, which can be used in
more ways than \verb/\underbrace{...}/. An example for \verb/\underbracket{...}/:
\begin{eqnarray*}
\textrm{Hate Science }& \underbracket[0.5pt]{1\rightarrow2\rightarrow3\rightarrow4}
\underbracket[0.75pt][0.75em]{\rightarrow5\rightarrow6\rightarrow7}
\underbracket[1pt][1em]{\rightarrow8\rightarrow9\rightarrow10} & \textrm{Love Science}\\
& \textrm{low}\hspace{1.5cm}\textrm{medium}\hspace{1.5cm}\textrm{high}
\end{eqnarray*}
\end{enumerate}
\subsubsection{Use of \CMD{underbracket\{...\}}}
The \verb/\underbracket{...}/ command has two optional parameters:
\begin{itemize}
\item the line thickness in any valid latex unit, \eg \verb/1pt/
\item the height of the edge brackets, \eg \verb/1em/
\end{itemize}
using without any parameters gives the same values for thickness and
height as predefined for the \CIndex{underbrace} command.
\vspace{0.3cm}
\begin{center}
\begin{tabular}{|c|c|c|}
\hline
1.& \verb/$\underbracket{foo~bar}$/ & $\underbracket{foo~bar}$ \tabularnewline\hline
2.& \verb/$\underbracket[2pt]{foo~bar}$/ & $\underbracket[2pt]{foo~bar}$ \tabularnewline\hline
3.& \verb/$\underbracket[2pt][1em] {foo~bar}$/& $\underbracket[2pt][1em] {foo~bar}$\tabularnewline\hline
\end{tabular}
\end{center}
\subsubsection{Overbracket}
In addition to the underbracket an overbracket is also useful, which can be used in
more ways than \verb/\overbrace{...}/. For example:
\begin{eqnarray*}
\textrm{Hate Science }& \overbracket[0.5pt]{1\rightarrow2\rightarrow3\rightarrow4}
\overbracket[0.75pt][0.75em]{\rightarrow5\rightarrow6\rightarrow7}
\overbracket[1pt][1em]{\rightarrow8\rightarrow9\rightarrow10} & \textrm{Love Science}\\
& \textrm{low}\hspace{1.5cm}\textrm{medium}\hspace{1.5cm}\textrm{high}\nonumber
\end{eqnarray*}
The \verb/\overbracket{...}/ command has two optional parameters:
\begin{itemize}
\item the line thickness in any valid latex unit, \eg \verb/1pt/
\item the height of the edge brackets, \eg \verb/1em/
\end{itemize}
using without any parameters gives the same values for thickness and
height as predefined for the \CIndex{overbrace} command.
\vspace{0.3cm}
\begin{center}\begin{tabular}{|c|c|c|}
\hline
1.&\verb/$\overbracket {foo\ bar}$/ & $\overbracket {foo\ bar}$ \tabularnewline\hline
2.&\verb/$\overbracket[2pt] {foo\ bar}$/ &$\overbracket[2pt] {foo\ bar}$ \tabularnewline\hline
3.&\verb/$\overbracket[2pt] [1em] {foo\ bar}$/&$\overbracket[2pt] [1em] {foo\ bar}$\tabularnewline\hline
\end{tabular}
\end{center}
%$
\subsection{Vectors}
Especially for vectors\index{Vector} there is the package \PIndex{esvect}%
\footnote{\href{http://www.ctan.org/tex-archive/macros/latex/contrib/esvect/}%
{CTAN://macros/latex/contrib/esvect/}} package, which looks better than the
\CMD{overrightarrow}\index{overrightarrow@\textbackslash overrightarrow}, \eg
\begin{table}[!htb]
\centering
\begin{tabular}{c|c}
\textbackslash{}vv\{...\}&\textbackslash{}overrightarrow\{...\}\tabularnewline\hline
$\vv{a}$ & $\overrightarrow{a}$\tabularnewline
$\vv{abc}$ & $\overrightarrow{abc}$\tabularnewline
$\vv{\imath}$ & $\overrightarrow{\imath}$\tabularnewline
$\vv*{A}{x}$ & $\overrightarrow{A}_{x}$\tabularnewline
\end{tabular}
\caption[Vectors with package \texttt{esvect}]%
{Vectors with package \texttt{esvect} (in the right column the default one from \LaTeX{})}
\end{table}
Look into the documentation for more details about the package \PIndex{esvect}.
%$
\section{Exponents and indices}\label{sec:exponents}
The two active characters \verb|_| and \verb|^| can only be used in math mode. The
\textbf{following} character will be printed as an index (\verb|$y=a_1x+a_0$|: $y=a_1x+a_0$)
or as an exponent (\verb|$x^2+y^2=r^2$|: $x^2+y^2=r^2$). For more than the next character
put it inside of \verb|{}|, like \verb|$a_{i-1}+a_{i+1}<a_i$|: $a_{i-1}+a_{i+1}<a_i$.
Especially for multiple exponents \index{Multiple exponents}
there are several possibilities. For example:
\begin{equation}
((x^2)^3)^4 = {({(x^2)}^3)}^4 = {\left({\left(x^2\right)}^3\right)}^4
\end{equation}
\begin{lstlisting}
((x^2)^3)^4 =
{({(x^2)}^3)}^4 =
{\left({\left(x^2\right)}^3\right)}^4
\end{lstlisting}
\index{Upright letters}
For variables with both exponent\index{Exponent} and indice index\index{Indice}
the order is not important, \verb|$a_1^2$| is
exactly the same than \verb|$a^2_1$|: $a_1^2=a^2_1$. By default all exponents and indices
are set as italic characters. It is possible to change this behaviour
to get upright characters. The following example shows this for the indices.
\bgroup
\begin{LTXexample}[width=4.5cm,preset=\raggedright]
$A_{abc_{xyz}123def}^{abc123def}aa$
\makeatletter
\catcode`\_\active
\def_#1{\sb{\operator@font#1}}
\makeatother
$A_{abc_{xyz}123def}^{abc123def}aa$
\end{LTXexample}
\egroup
\section{Operators}\label{sec:ltxOperators}
They are written in upright font shape and are placed with some additional
space before and after for a better typesetting. With the \AmSmath
package it is possible to define one's own operators\index{Operator} (see
section~\vref{OperatorNames}). Table~\vref{tab:operator} and \vref{tab:operator2} show a list of
the predefined ones for standard \LaTeX{}.
\begin{table}[htb]
\centering
\begin{tabular}{llllll}
\verb+\coprod+ &$\coprod$ &\verb+\bigvee+ &$\bigvee$ &\verb+\bigwedge+&$\bigwedge$\\
\verb+\biguplus+&$\biguplus$&\verb+\bigcap+ &$\bigcap$ &\verb+\bigcup+ &$\bigcup$ \\
\verb+\intop+ &$\intop$ &\verb+\int+ &$\int$ &\verb+\prod+ &$\prod$ \\
\verb+\sum+ &$\sum$ &\verb+\bigotimes+&$\bigotimes$&\verb+\bigoplus+&$\bigoplus$\\
\verb+\bigodot+ &$\bigodot$ &\verb+\ointop+ &$\ointop$ &\verb+\oint+ &$\oint$\\
\verb+\bigsqcup+&$\bigsqcup$&\verb+\smallint+ &$\smallint$
\end{tabular}
\caption{The predefined operators of \texttt{fontmath.ltx}}\label{tab:operator}
\end{table}
The difference between \CIndex{intop} and \CIndex{int} is that the first one has by default
over/under limits and the second subscript/superscript limits. Both can be changed
with the \CIndex{limits} or \CIndex{nolimits} command. The same behaviour happens to the
\CIndex{ointop} and \CIndex{oint} Symbols.
\begin{table}[htb]
\centering
\begin{tabular}{llllll}
\verb+\log+ & $\log$ &\verb+\lg+ & $\lg$ &\verb+\ln+ & $\ln$ \\
\verb+\lim+ & $\lim$ &\verb+\limsup+ & $\limsup$ &\verb+\liminf+ & $\liminf$ \\
\verb+\sin+ & $\sin$ &\verb+\arcsin+ & $\arcsin$ &\verb+\sinh+ & $\sinh$ \\
\verb+\cos+ & $\cos$ &\verb+\arccos+ & $\arccos$ &\verb+\cosh+ & $\cosh$ \\
\verb+\tan+ & $\tan$ &\verb+\arctan+ & $\arctan$ &\verb+\tanh+ & $\tanh$ \\
\verb+\cot+ & $\cot$ &\verb+\coth+ & $\coth$ &\verb+\sec+ & $\sec$ \\
\verb+\csc+ & $\csc$ &\verb+\max+ & $\max$ &\verb+\min+ & $\min$ \\
\verb+\sup+ & $\sup$ &\verb+\inf+ & $\inf$ &\verb+\arg+ & $\arg$ \\
\verb+\ker+ & $\ker$ &\verb+\dim+ & $\dim$ &\verb+\hom+ & $\hom$ \\
\verb+\det+ & $\det$ &\verb+\exp+ & $\exp$ &\verb+\Pr+ & $\Pr$ \\
\verb+\gcd+ & $\gcd$ &\verb+\deg+ & $\deg$ &\verb+\bmod+ & $\bmod$ \\
\verb+\pmod{a}+& $\pmod{a}$
\end{tabular}
\caption{The predefined operators of \texttt{latex.ltx}}\label{tab:operator2}
\end{table}
\makeatletter
\newcommand\foo{\mathop{\operator@font foo}\nolimits}
\makeatother
For more predefined operator names see table~\vref{tab:amsopn}. It is easy
to define a new operator with
%
\begin{lstlisting}
\makeatletter
\newcommand\foo{\mathop{\operator@font foo}\nolimits}
\makeatother
\end{lstlisting}
Now you can use \verb|\foo| in the usual way:
%
\begin{LTXexample}[width=4cm]
\[ \foo_1^2 = x^2 \]
\end{LTXexample}
In this example \verb|\foo| is defined with \verb|\nolimits|, means
that limits\index{Limits} are placed in
superscript/subscript mode and not over under. This is still possible with \verb|\limits| in the
definition or the equation:
\begin{LTXexample}[width=4cm]
\[ \foo\limits_1^2 = x^2 \]
\end{LTXexample}
\AmSmath has an own macro for a definition, have a look at section~\vref{OperatorNames}.
\section{Greek letters}\label{sec:greek}
The \AmSmath package simulates a bold font for the greek letters, it writes a
greek character twice with a small kerning. The \verb|\mathbf{<character>}|
doesn't work with lower greek character. See
section \vref{sec:greek-AMS} for the \CIndex{pmb} macro, which makes it possible
to print bold lower greek\index{Greek} letters. Not all upper case letters have
own macro names. If there is no difference to the roman font, then the default
letter is used, \eg A for the upper case of
$\alpha$. Table \ref{tab:greek-letters} shows only those upper case letters
which have own macro names. Some of the lower case letters have an additional
\verb|var| option for an alternative.
\bgroup
\tabcolsep=3pt
\begin{longtable}{lclccc}
lower & default & upper & default & \verb|\mathbf| & \verb|\mathit|\\\hline
\endhead
\verb|\alpha| & $\alpha$ \\
\verb|\beta| & $\beta$ \\
\verb|\gamma| & $\gamma$
& \verb|\Gamma| & $\Gamma$ & $\mathbf{\Gamma}$ & $\mathit{\Gamma}$\\
\verb|\delta| & $\delta$
& \verb|\Delta| & $\Delta$ & $\mathbf{\Delta}$ & $\mathit{\Delta}$\\
\verb|\epsilon| & $\epsilon$\\
\verb|\varepsilon| & $\varepsilon$\\
\verb|\zeta| & $\zeta$\\
\verb|\eta| & $\eta$ \\
\verb|\theta| & $\theta$
& \verb|\Theta| & $\Theta$ & $\mathbf{\Theta}$ & $\mathit{\Theta}$\\
\verb|\vartheta| & $\vartheta$\\
\verb|\iota| & $\iota$\\
\verb|\kappa| & $\kappa$\\
\verb|\lambda| & $\lambda$
& \verb|\Lambda| & $\Lambda$ & $\mathbf{\Lambda}$ & $\mathit{\Lambda}$\\
\verb|\mu| & $\mu$ \\
\verb|\nu| & $\nu$\\
\verb|\xi| & $\xi$
& \verb|\Xi| & $\Xi$ & $\mathbf{\Xi}$ & $\mathit{\Xi}$\\
\verb|\pi| & $\pi$
& \verb|\Pi| & $\Pi$ & $\mathbf{\Pi}$ & $\mathit{\Pi}$\\
\verb|\varpi| & $\varpi$ \\
\verb|\rho| & $\rho$\\
\verb|\varrho| & $\varrho$\\
\verb|\sigma| & $\sigma$
& \verb|\Sigma| & $\Sigma$ & $\mathbf{\Sigma}$ & $\mathit{\Sigma}$\\
\verb|\varsigma| & $\varsigma$\\
\verb|\tau| & $\tau$\\
\verb|\upsilon| & $\upsilon$
& \verb|\Upsilon| & $\Upsilon$ & $\mathbf{\Upsilon}$ & $\mathit{\Upsilon}$\\
\verb|\phi| & $\phi$
& \verb|\Phi| & $\Phi$ & $\mathbf{\Phi}$ & $\mathit{\Phi}$\\
\verb|\varphi| & $\varphi$\\
\verb|\chi| & $\chi$ \\
\verb|\psi| & $\psi$
& \verb|\Psi| & $\Psi$ & $\mathbf{\Psi}$ & $\mathit{\Psi}$\\
\verb|\omega| & $\omega$
& \verb|\Omega| & $\Omega$ & $\mathbf{\Omega}$ & $\mathit{\Omega}$\\[5pt]
\caption{The greek letters}\label{tab:greek-letters}\\
\end{longtable}
\egroup
Bold \Index{greek} letters are possible with the package \PIndex{bm} (see section~\vref{sec:bm})
and if they should also be upright with the package \PIndex{upgreek}:
\index{greek!upright}\index{greek!bold}
\medskip
\verb+$\bm{\upalpha}, \bm{\upbeta} ... $+ $ \bm{\upalpha}, \bm{\upbeta} ... $
A useful definition maybe:
\begin{lstlisting}
\usepackage{upgreek}
\makeatletter
\newcommand{\bfgreek}[1]{\bm{\@nameuse{up#1}}}
\makeatother
\end{lstlisting}
\makeatletter
\newcommand{\bfgreek}[1]{\bm{\@nameuse{up#1}}}
\makeatother
Then
\verb|$\bfgreek{mu}$| will allow you to type $\bfgreek{mu}$ to obtain an upright boldface $\mu$.
\section{Pagebreaks}
\mPar{\CMD{allowdisplaybreaks}}By default a displayed formula cannot
have a pagebreak. This makes some sense, but sometimes it gives a better
typesetting when a pagebreak is possible.
\begin{verbatim}
\allowdisplaybreaks
\end{verbatim}
\CIndex{allowdisplaybreaks} enables \TeX{} to insert pagebreaks into
displayed formulas whenever a newline command appears.\index{Pagebreak}
With the command \CIndex{displaybreak} it is also possible to insert a
pagebreak at any place.
\section{\CMD{stackrel}}
\CIndex{stackrel} puts a character on top of another one which may be important if a
used symbol is not predefined. For example ``$\stackrel{\wedge}{=}$''
(\verb|\stackrel{\wedge}{=}|). \mPar{\CMD{stackrel}}
The syntax is
\begin{lstlisting}
\stackrel{top}{base}
\end{lstlisting}
Such symbols may be often needed so that a macro definition in the preamble makes some sense:
\begin{lstlisting}
\newcommand{\eqdef}{%
\ensuremath{\mathrel{\stackrel{\mathrm{def}}{=}}}}
\end{lstlisting}
%
With the \CIndex{ensuremath} command we can use the new \CIndex{eqdef} command in text
and in math mode, \LaTeX{} switches automatically in math mode, which
saves some keystrokes like the following command, which is written
without the delimiters (\texttt{\$...\$}) for the math mode \eqdef ,
only \CMD{eqdef} with a space at the end. In math mode
together with another material it may look like
$\vec{x}\eqdef\left(x_{1},\ldots,x_{n}\right)$ and as command sequence
\begin{lstlisting}
$\vec{x}\eqdef\left(x_{1},\ldots,x_{n}\right)$
\end{lstlisting}
The fontsize of the top is one size smaller than the one from the
base, but it is no problem to get both the same size, just increase the
top or decrease the base.
\section{\CMD{choose}}
\CIndex{choose}\index{Binom} is like \CIndex{atop}
with delimiters or like \CIndex{frac}
without the fraction line and also with delimiters. It is often used
for binomial coefficients and has the following syntax:\mPar{\CMD{choose}}
\begin{lstlisting}
{above \choose below}
\end{lstlisting}
The two braces are not really important but it is safe to use them.
\begin{equation}
{{m+1 \choose n}}={{m \choose n}}+{{m \choose k-1}}\label{eq:choose}
\end{equation}
\begin{lstlisting}
{{m+1 \choose n}}={{m \choose n}}+{{m \choose k-1}}\label{eq:choose}
\end{lstlisting}
See section~\vref{sub:Binoms} for the \AmSmath equivalents and enhancements.
\section{Color in math expressions}\label{sec:color}
\index{Color}There is no difference in using colored text and colored math expressions. With
\begin{verbatim}
\usepackage{color}
\end{verbatim}
\noindent in the preamble the macro \verb|\textcolor{<color>}{<text or math>}| exists.
\begin{equation}
\textcolor{blue}{f(x)} = \int\limits_1^{\infty}\textcolor{red}{\frac{1}{x^2}}\,\mathrm{d}x=1
\end{equation}
\mPar{\CMD{textcolor}}
\begin{lstlisting}
\begin{equation}
\textcolor{blue}{f(x)} = \int\limits_1^{\infty}\textcolor{red}{\frac{1}{x^2}}\,\mathrm{d}x=1
\end{equation}
\end{lstlisting}
If all math expressions should be printed in the same color, then it is better
to use the \verb+everydisplay+ macro (section~\vref{sec:other}).
\section{Boldmath}\label{sec:boldmath}
\mPar{\CMD{mathversion}\\\CMD{boldmath}\\\CMD{unboldmath}}%
Writing a whole formula in bold\index{boldmath@\textbackslash boldmath} is possible with the command sequence
\CMD{boldmath} \ldots\ \CMD{unboldmath}, which itself must be written in textmode (outside the
formula) or with the command \verb+{\mathversion{bold} ... }+.
\index{mathversion@\textbackslash mathversion}\index{boldmath@\textbackslash
boldmath}\index{unboldmath@\textbackslash unboldmath}
\noindent\begin{minipage}{0.49\linewidth}
\[
\sum_{%
\makebox[0pt]{$%
{{\scriptscriptstyle 1\le j\le p\atop {%
{1\le j\le q\atop 1\le k\le r}}}}%
$}%
}a_{ij}b_{jk}c_{ki}
\]
\end{minipage}\hfill
\begin{minipage}{0.49\linewidth}
\boldmath
\[
\sum_{%
\makebox[0pt]{$%
{{\scriptscriptstyle 1\le j\le p\atop {%
{1\le j\le q\atop 1\le k\le r}}}}%
$}%
}a_{ij}b_{jk}c_{ki}
\]
\unboldmath
\end{minipage}
\medskip
\begin{lstlisting}
\boldmath
\[
\sum_{%
\makebox[0pt]{$%
{{\scriptscriptstyle 1\le j\le p\atop {%
{1\le j\le q\atop 1\le k\le r}}}}%
$}%
}a_{ij}b_{jk}c_{ki}
\]
\unboldmath
\end{lstlisting}
The \verb+\mathversion+ macro defines a math style which is valid for all following
math expressions. If you want to have all math in bold then use this macro instead of
\CIndex{boldmath}. But it is no problem to put \CIndex{mathversion} inside a group to hold
the changes locally.
{\mathversion{bold}%
\begin{equation}
y(x) = ax^3+bx^2+cx+d
\end{equation}}
\begin{lstlisting}
{\mathversion{bold}%
\begin{equation}
y(x) = ax^3+bx^2+cx+d
\end{equation}}
\end{lstlisting}
Single characters inside a formula can be written in bold with \CIndex{mathbf},
but only in upright mode, which is in general not useful as shown in
equation~\ref{eq:bold}. It is better
to use package \PIndex{bm} (see section~\vref{sec:bm}).
\begin{equation}\label{eq:bold}
\sum_{%
\makebox[0pt]{$%
{{\scriptscriptstyle 1\le j\le p\atop {%
{1\le j\le q\atop 1\le k\le r}}}}%
$}%
}a_{ij}\mathbf{b_{jk}}c_{ki}
\end{equation}
\subsection[Bold math titles and items]{Bold math expressions as part of titles and items}\label{sec:titleItem}
By default the titles in sections, subsections, a.s.o. are printed in bold. Same for the
\verb|description| environment. The problem is that a math expression in one of these
environments is printed in default font shape, like the following example for a \verb|section| and
\UIndex{description}:
\medskip
\fbox{%
\begin{minipage}{.75\linewidth}
\section*{\thesection\ Function $f(x)=x^2$}
\begin{description}
\item[This is $y=f(x)$] Only a demonstration.
\item[And $z=f(x,y)$] Another demonstration.
\end{description}
\end{minipage}%
}
\medskip
With a redefinition of the \CIndex{section} and
\CIndex{item} macros it is possible to get everything in bold font.
\medskip
\fbox{%
\begin{minipage}{.75\linewidth}
\let\itemOld\item
\makeatletter
\renewcommand\item[1][]{%
\def\@tempa{#1}
\ifx\@tempa\@empty\itemOld\else\boldmath\itemOld[#1]\unboldmath\fi%
}
\makeatother
\section*{\thesection\ \boldmath Function $f(x)=x^2$\unboldmath}
\begin{description}
\item[This is $y=f(x)$] Only a demonstration.
\item[And $z=f(x,y)$] Another demonstration.
\end{description}
\end{minipage}%
}
\medskip
\begin{lstlisting}
\let\itemOld\item
\makeatletter
\renewcommand\item[1][]{%
\def\@tempa{#1}
\ifx\@tempa\@empty\itemOld\else\boldmath\itemOld[#1]\unboldmath\fi%
}
\makeatother
\let\sectionOld\section
\renewcommand\section[2][\empty]{%
\boldmath\sectionOld[#1]{#2}\unboldmath%
}
\end{lstlisting}
\section{Multiplying numbers}
When the dot is used as the decimal marker as in the United States, the preferred sign
for the multiplication of
numbers or values of quantities is a cross (\verb|\times| $\times$ ), not a half-high and
centered dot (\verb|\cdot| $\cdot$ ).
When the comma is used as the decimal marker as in Europe, the preferred sign for the
multiplication of
numbers is the half-high dot. The multiplication of quantity symbols (or numbers in
parentheses or values of
quantities in parentheses) may be indicated in one of the following ways: $ab$,
$a\cdot b$, $a\times b$.
For more information see ``Nist Guide to SI Units -More on Printing and Using Symbols and
Numbers in Scientific and
Technical Documents''\footnote{\url{http://physics.nist.gov/Pubs/SP811/sec10.html}} or
the German DIN 1304, Teil 1.
\section{Other macros}\label{sec:other}
\mPar{\CMD{everymath}\\\CMD{everydisplay}\\\CMD{underline}}%
There are some other macros which are not mentioned in the foregoing text. Here comes
a not really complete list of these macros.
\begin{description}
\item[\CMD{everymath}] \index{everymath@\textbackslash everymath} puts the argument before
any inlined math expression, \eg \verb+\everymath{\displaysize}+. Using this macro doesn't really
make sense, when one is using footnotes because the footnote number is printed as superscript in
inline mathmode and an \CMD{everymath} will be valid, too.
\item[\CMD{everydisplay}] \index{everydisplay@\textbackslash everydisplay} puts the
argument before any displayed math expression, \eg \verb+\everydisplay{\color{blue}}+.
\item[\CMD{underline}] \index{underline@\textbackslash underline} underlines a math
expression and has to be used inside the math mode.
\[
\underline{F(x)=\int f(x)\,\mathrm{d}x}
\]
\end{description}
\part{\texorpdfstring{\AmSmath}{amsmath} package}\label{par:AMSmath-package}
In general the \AmS packages are at least a collection of three different ones:
\begin{enumerate}
\item \verb|amsmath.sty|
\item \verb|amssymb.sty|
\item \verb|amsfonts.sty|
\end{enumerate}
In the following only the first one is described in detail.
The \AmSmath has the following options:
\bigskip\noindent
\begin{tabularx}{\linewidth}{@{}lX@{}}
\verb+centertags+\index{centertags} & (default) For a split equation, place
equation numbers vertically centered on the total height of the equation.\\\hline
\verb+tbtags+\index{tbtags} & `Top-or-bottom tags' For a split equation,
place equation numbers level with the last (resp. first) line, if
numbers are on the right (resp. left).\\\hline
\verb+sumlimits+\index{sumlimits} & (default) Place the subscripts and superscripts
of summation symbols above and below, in displayed equations. This
option also affects other symbols of the same type -- $\prod$, $\coprod$,
$\bigotimes$, $\bigoplus$, and so forth -- but excluding integrals
(see below).\\\hline
\verb+nosumlimits+\index{nosumlimits} & Always place the subscripts and
superscripts of summation-type symbols to the side, even in displayed
equations.\\\hline
\verb+intlimits+\index{intlimits} & Like sumlimits, but for integral symbols.\\\hline
\verb+nointlimits+\index{nointlimits} & (default) Opposite of intlimits.\\\hline
\verb+namelimits+\index{namelimits} & (default) Like sumlimits, but for
certain `operator names' such as \verb+det+, \verb+inf+, \verb+lim+, \verb+max+, \verb+min+, that traditionally
have subscripts placed underneath when they occur in a displayed equation.\\\hline
\verb+nonamelimits+\index{nonamelimits} & Opposite of namelimits.\\\hline
\end{tabularx}
\bigskip
To use one of these package options, put the option name in the optional
argument, \eg
\verb|\usepackage[intlimits]{amsmath}|. The %%% ----- Martin -----
\AmSmath also recognises the following options which are normally
selected (implicitly or explicitly) through the \verb|documentclass|
command, and thus need not be repeated in the option list of the \verb|\usepackage{amsmath}| statement. %%% ----- Martin -----
\bigskip\noindent
\begin{tabularx}{\linewidth}{@{}lX@{}}
\verb+leqno+\index{leqno} & Place equation numbers on the left.\\\hline
\verb+reqno+\index{reqno} & (default) Place equation numbers on the right.\\\hline
\verb+fleqn+\index{fleqn} & Position equations at a fixed indent from the
left margin rather than centered in the text column. \AmSmath defines the
length \CMD{mathindent} and uses it when the equations have only one
tabbing character (\verb+&+).\index{mathindent@\textbackslash mathindent}\\\hline
\end{tabularx}
\bigskip\noindent All math environments are displayed ones, so there is no special inline
math.
\section{\texttt{align} environments}
There are four different align environments, described in the following
subsections. Their behaviour is shown in table \ref{cap:align}. The symbolic
code for all align environments is:
\begin{lstlisting}
\begin{<name>}
<name> &= x & x &= x\\
<name> &= x & x &= x
\end{<name>}
\end{lstlisting}
\begin{table}[htb]
\caption[Comparison between the different align environments]{Comparison between the different align environments
with the same code, where the first three can have an equation number}\label{cap:align}
\begin{align*}
\framebox[0.125\columnwidth]{align} &= \framebox[0.125\columnwidth]{x} & \framebox[0.125\columnwidth]{x}&= \framebox[0.125\columnwidth]{x}\\
\framebox[0.125\columnwidth]{align}&= \framebox[0.1\columnwidth]{x} & \framebox[0.1\columnwidth]{x} &= \framebox[0.1\columnwidth]{x}
\end{align*}
\begin{alignat*}{2}
\framebox[0.125\columnwidth]{alignat} &= \framebox[0.125\columnwidth]{x} & \framebox[0.125\columnwidth]{x} &= \framebox[0.125\columnwidth]{x}\\
\framebox[0.125\columnwidth]{alignat} &= \framebox[0.1\columnwidth]{x} & \framebox[0.1\columnwidth]{x} &= \framebox[0.1\columnwidth]{x}
\end{alignat*}
\begin{flalign*}
\framebox[0.125\columnwidth]{flalign} &= \framebox[0.125\columnwidth]{x} & \framebox[0.125\columnwidth]{x} &= \framebox[0.125\columnwidth]{x}\\
\framebox[0.125\columnwidth]{flalign} &= \framebox[0.1\columnwidth]{x} & \framebox[0.1\columnwidth]{x} &= \framebox[0.1\columnwidth]{x}
\end{flalign*}
\begin{xalignat*}{2}
\framebox[0.125\columnwidth]{xalignat} &= \framebox[0.125\columnwidth]{x} & \framebox[0.125\columnwidth]{x} &= \framebox[0.125\columnwidth]{x}\\
\framebox[0.125\columnwidth]{xalignat} &= \framebox[0.1\columnwidth]{x} & \framebox[0.1\columnwidth]{x} &= \framebox[0.1\columnwidth]{x}
\end{xalignat*}
\begin{xxalignat}{2}
\framebox[0.125\columnwidth]{xxalignat} &= \framebox[0.125\columnwidth]{x} & \framebox[0.125\columnwidth]{x} &= \framebox[0.125\columnwidth]{x}\\
\framebox[0.125\columnwidth]{xxalignat} &= \framebox[0.1\columnwidth]{x} & \framebox[0.1\columnwidth]{x} &= \framebox[0.1\columnwidth]{x}
\end{xxalignat}
\end{table}
In difference to the \UIndex{eqnarray} from standard \LaTeX{}
(section~\ref{display:eqnarray}), the ``three'' parts
of one equation \verb+expr.-symbol-expr.+ are divided by only one ampersand %%% ----- Martin -----
in two parts. In general the ampersand should be before the symbol to get the right spacing,
\eg \verb+y &= x+. Compare the following three equations, the second one has a wrong spacing. %%% ----- Martin -----
\noindent
~\hfill\includegraphics{amsalign}
\iffalse
\begin{minipage}{0.4\linewidth}
\begin{align}
\rnode[lt]{a}{y} &= \rnode[rt]{A}{x}
\end{align}
\vspace*{-3\abovedisplayskip}
\begin{align}
y =& x
\end{align}
\vspace*{-3\abovedisplayskip}
\begin{align}
\rnode[lb]{b}{y} ={}& \rnode[rb]{B}{x}
\end{align}
\ncline[nodesep=-10pt,linewidth=0.1pt]{A}{B}
\ncline[nodesepA=-11pt,nodesepB=-10pt,linewidth=0.1pt]{a}{b}
\end{minipage}
\hfill\begin{minipage}{0.4\linewidth}
\begin{lstlisting}
y &= x
y =& x
y ={}& x
\end{lstlisting}
\end{minipage}
\fi
\subsection{The default \texttt{align} environment}
The \texttt{eqnarray} environment has a not so good spacing between
the cells. Writing the equations no. \ref{eq:2} to \ref{eq:5} with
the \texttt{align} environment gives:
\begin{align}
y & =d\label{eq:IntoSection}\\
y & =cx+d\\
y_{12} & =bx^{2}+cx+d\\
y(x) & =ax^{3}+bx^{2}+cx+d
\end{align}
\noindent The code looks like:
\begin{lstlisting}
\begin{align}
y & =d\label{eq:IntoSection}\\
y & =cx+d\\
y_{12} & =bx^{2}+cx+d\\
y(x) & =ax^{3}+bx^{2}+cx+d
\end{align}
\end{lstlisting}
\begin{itemize}
\item The \texttt{align} environment has an implicit \textbf{\{rlrl...\}}
horizontal alignment with a vertical column-alignment, \eg
\begin{LTXexample}[width=0.5\linewidth]
\begin{align*}
1 & 2 & 3
\end{align*}
\end{LTXexample}
\item A nonumber-version \texttt{\small \textbackslash{}begin\{align{*}\}...\textbackslash{}end\{align{*}\}}
exists.
\item Unnumbered single rows are possible with \CMD{nonumber}. %%% ----- Martin -----
\item The \texttt{align} environment takes the whole horizontal space if
you have more than two columns:
\begin{align}
y & =d & z & =1\\
y & =cx+d & z & =x+1\\
y_{12} & =bx^{2}+cx+d & z & =x^{2}+x+1\nonumber \\
y(x) & =ax^{3}+bx^{2}+cx+d & z & =x^{3}+x^{2}+x+1
\end{align}
\end{itemize}
The code for this example looks like%
\begin{lstlisting}
\begin{align}
y & =d & z & =1\\
y & =cx+d & z & =x+1\\
y_{12} & =bx^{2}+cx+d & z & =x^{2}+x+1\nonumber \\
y(x) & =ax^{3}+bx^{2}+cx+d & z & =x^{3}+x^{2}+x+1
\end{align}
\end{lstlisting}
\subsection{\texttt{alignat} environment\label{sec:alignat environment}}
\mPar{\CMD{begin\{align\}\\...\\\CMD{end\{align\}}}}
\renewcommand{\theequation}{%
\thepart-\arabic{equation}%
}
\begin{leftbar}
>From now the counting of the equation changes. It is introduced with a foregoing command,
which doesn't really make sense, it is only for demonstration:\\
\verb|\renewcommand{\theequation}{\thepart-\arabic{equation}}|.
\end{leftbar}
This means ``align at several places{}'' and is something like
more than two \verb+align+ environment side by side.
Parameter is the number of the \verb+align+ environments, which
is not important for the user. The
above last \verb+align+ example looks like:
\begin{alignat}{2}
y & =d & z & =1\label{eq:newCounting}\\
y & =cx+d & z & =x+1\\
y_{12} & =bx^{2}+cx+d & z & =x^{2}+x+1\nonumber \\
y(x) & =ax^{3}+bx^{2}+cx+d\quad & z & =x^{3}+x^{2}+x+1\end{alignat}
The parameter was 2 and it is 3 for the following example: %%% ----- Martin -----
\begin{alignat}{3}
i_{11} & =0.25 & i_{12} & =i_{21} & i_{13} & =i_{23}\nonumber \\
i_{21} & =\frac{1}{3}i_{11} & i_{22} & =0.5i_{12} & i_{23} & =i_{31}\\
i_{31} & =0.33i_{22}\quad & i_{32} & =0.15i_{32}\quad & i_{33} & =i_{11}\end{alignat}
For this example the code is:
\begin{lstlisting}[xleftmargin=-1cm,xrightmargin=-1.5cm]
\begin{alignat}{3}
i_{11} & =0.25 & i_{12} & =i_{21} & i_{13} & =i_{23}\nonumber\\
i_{21} & =\frac{1}{3}i_{11} & i_{22} & =0.5i_{12}& i_{23} & =i_{31}\\
i_{31} & =0.33i_{22}\quad & i_{32} & =0.15i_{32}\quad & i_{33} & =i_{11}
\end{alignat}
\end{lstlisting}
With the \verb+alignat+ environment one can easily align equations vertically
at more than one marker:
\begin{alignat}{3}
abc &= xxx &&= xxxxxxxxxxxx &&= aaaaaaaaa \\
ab &= yyyyyyyyyyyyyyy &&= yyyy &&= ab
\end{alignat}
\begin{lstlisting}
\begin{alignat}{3}
abc &= xxx &&= xxxxxxxxxxxx &&= aaaaaaaaa \\
ab &= yyyyyyyyyyyyyyy &&= yyyy &&= ab
\end{alignat}
\end{lstlisting}
\begin{itemize}
\item The \texttt{alignat} environment has an implicit \{rlrl...rlrl\}
horizontal alignment with a vertical column alignment.
\item A nonumber-version \texttt{\small
\textbackslash{}begin\{alignat{*}\}...\textbackslash{}end\{alignat{*}\}}
exists.
\item Unnumbered single rows are possible with \CMD{nonumber}. %%% ----- Martin -----
\end{itemize}
\subsection{\texttt{flalign} environment}\label{ams:flalign}
\mPar{\CMD{begin\{flalign\}\\...\\\CMD{end\{flalign\}}}}This is the new replacement for the \texttt{xalignat} and \texttt{xxalignat}
environments. It is nearly the same as the \texttt{xalignat} environment, only
more ``out spaced'' and ``left aligned''.
\begin{LTXexample}[width=0.5\linewidth]
\begin{flalign}
i_{11} & =0.25\nonumber \\
i_{21} & =\frac{1}{3}i_{11}\\
i_{31} & =0.33i_{22}
\end{flalign}
\end{LTXexample}
\medskip
As seen, the equations are not really left aligned, when they have only one
ampersand. In this case \verb+flalign+ has the same behaviour as the \verb+align+
environment.\index{Alignment!left}\index{Indentation}
When there are more than one tabbing characters (\verb+&+), then the equations are
really left aligned. This is also an easy way to get an equation with only one
ampersand left aligned, see equation \ref{eq:leftaligned} below.
\begin{flalign}
i_{11} & =0.25 & i_{12} & =i_{21} & i_{13} & =i_{23}\nonumber \\
i_{21} & =\frac{1}{3}i_{11} & i_{22} & =0.5i_{12} & i_{23} & =i_{31}\\
i_{31} & =0.33i_{22} & i_{32} & =0.15i_{32} & i_{33} & =i_{11}
\end{flalign}
The code looks like:
\begin{lstlisting}[xleftmargin=-1cm,xrightmargin=-1.5cm]
\begin{flalign}
i_{11} & =0.25 & i_{12} & =i_{21} & i_{13} & =i_{23}\nonumber\\
i_{21} & =\frac{1}{3}i_{11} & i_{22} & =0.5i_{12}& i_{23} & =i_{31}\\
i_{31} & =0.33i_{22}\quad & i_{32} & =0.15i_{32}\quad & i_{33} & =i_{11}
\end{flalign}
\end{lstlisting}
\medskip
This environment can be used to mix centered and left aligned\index{Left aligned}
equations without
using the document wide valid option \verb|fleqn|.
\begin{align}\label{eq:centered}
f(x) & = \int\frac{1}{x^2}\,\mathrm{d}x
\end{align}
\begin{flalign}\label{eq:leftaligned}
f(x) & = \int\frac{1}{x^2}\,\mathrm{d}x &
\end{flalign}
Equation \ref{eq:leftaligned} is left aligned in fact of the second tabbing
character \verb|&|.
\begin{lstlisting}
\begin{align}\label{eq:centered}
f(x) & = \int\frac{1}{x^2}\,\mathrm{d}x
\end{align}
\begin{flalign}\label{eq:leftaligned}
f(x) & = \int\frac{1}{x^2}\,\mathrm{d}x &
\end{flalign}
\end{lstlisting}
Another case is placing text left aligned, whereas the formulas should be right aligned.
\begin{flalign*}
&& 12(x-1)+20(y-3)+14(z-2) &= 0\\
\text{same as } && 6x+10y+7z &= 0
\end{flalign*}
\begin{lstlisting}
\begin{flalign*}
&& 12(x-1)+20(y-3)+14(z-2) &= 0\\
\text{same as } && 6x+10y+7z &= 0
\end{flalign*}
\end{lstlisting}
\subsection{\texttt{xalignat} environment}
\mPar{\CMD{begin\{xalignat\}\\...\\\CMD{end\{xalignat\}}}}%
This is an obsolete macro but still supported by the \AmSmath package.
Same as \texttt{alignat} environment, only a little more ``out spaced{}''.
\begin{xalignat}{3}
i_{11} & =0.25 & i_{12} & =i_{21} & i_{13} & =i_{23}\nonumber \\
i_{21} & =\frac{1}{3}i_{11} & i_{22} & =0.5i_{12} & i_{23} & =i_{31}\\
i_{31} & =0.33i_{22} & i_{32} & =0.15i_{32} & i_{33} & =i_{11}
\end{xalignat}
The same code looks like:
\begin{lstlisting}[xleftmargin=-1cm,xrightmargin=-1.5cm]
\begin{xalignat}{3}
i_{11} & =0.25 & i_{12} & =i_{21} & i_{13} & =i_{23}\nonumber\\
i_{21} & =\frac{1}{3}i_{11} & i_{22} & =0.5i_{12}& i_{23} & =i_{31}\\
i_{31} & =0.33i_{22}\quad & i_{32} & =0.15i_{32}\quad & i_{33} & =i_{11}
\end{xalignat}
\end{lstlisting}
\subsection{\texttt{xxalignat} environment}
\mPar{\CMD{begin\{xxalignat\}\\...\\\CMD{end\{xxalignat\}}}}%
Like \texttt{xalignat} an obsolete macro but still supported by the \AmSmath package.
Same as \texttt{align} environment, only extremely ``out spaced{}'',
therefore no equation number!
\begin{xxalignat}{3}
i_{11} & =0.25 & i_{12} & =i_{21} & i_{13} & =i_{23}\\
i_{21} & =\frac{1}{3}i_{11} & i_{22} & =0.5i_{12} & i_{23} & =i_{31}\\
i_{31} & =0.33i_{22} & i_{32} & =0.15i_{32} & i_{33} & =i_{11}
\end{xxalignat}
The same code looks like:
\begin{lstlisting}[xleftmargin=-1cm,xrightmargin=-1.5cm]
\begin{xxalignat}{3}
i_{11} & =0.25 & i_{12} & =i_{21} & i_{13} & =i_{23}\nonumber\\
i_{21} & =\frac{1}{3}i_{11} & i_{22} & =0.5i_{12}& i_{23} & =i_{31}\\
i_{31} & =0.33i_{22} & i_{32} & =0.15i_{32} & i_{33} & =i_{11}
\end{xxalignat}
\end{lstlisting}
\subsection{\texttt{aligned} environment}\label{sec:aligned}
\mPar{\CMD{begin\{aligned\}\\...\\\CMD{end\{aligned\}}}}In difference to the
\verb|split| environment (section \vref{split})\index{Split equation}, the
\verb|aligned| environment allows more than one horizontal alignment but has
also only one equation number:
%
\begin{equation}
\begin{aligned}
2x+3 &= 7 & 2x+3-3 &=7-3 \\
2x &= 4 & \frac{2x}2 &=\frac42\\
x &= 2
\end{aligned}
\end{equation}
\begin{lstlisting}
\begin{equation}
\begin{aligned}
2x+3 &= 7 & 2x+3-3 &= 7-3 \\
2x &= 4 & \frac{2x}2 &= \frac42\\
x &= 2
\end{aligned}
\end{equation}
\end{lstlisting}
The \verb|aligned| environment is similar to the \verb|array|\index{array}
environment, there exists no
starred version and it has only one equation number and has to be part of
another math environment, which should be \verb|equation| environment.
The advantage of \verb|aligned| is the much
better horizontal and vertical spacing. %%% ----- Martin -----
\subsection{Problems}
When using one of the \verb+align+ environments, there should be no \verb+\\+ at the
end of the last line, otherwise you'll get another equation number for this
``empty{}'' line: %%% ----- Martin -----
\begin{LTXexample}[width=0.65\linewidth]
\begin{align}
2x+3 &= 7\\
\end{align}
\end{LTXexample}
\begin{LTXexample}[width=0.65\linewidth]
\begin{align}
2x+3 &= 7
\end{align}
\end{LTXexample}
\section{Other environments}
\subsection{\texttt{gather} environment}
\mPar{\CMD{begin\{gather\}\\...\\\CMD{end\{gather\}}}}
This is like a multi line environment with no special horizontal alignment.
All rows are centered and can have an own equation number:
%
\begin{gather}
i_{11}=0.25\\
i_{21}=\frac{1}{3}i_{11}\nonumber \\
i_{31}=0.33i_{22}
\end{gather}
%
For this example the code looks like:
\begin{lstlisting}
\begin{gather}
i_{11} = 0.25\\
i_{21} = \frac{1}{3}i_{11}\nonumber\\
i_{31} =0.33i_{22}
\end{gather}
\end{lstlisting}
\begin{itemize}
\item The \texttt{gather}\index{gather} environment has an implicit \texttt{\{c\}}
horizontal alignment with no vertical column alignment. It is just
like an one column array/table.
\item A nonumber-version \texttt{\small \textbackslash{}begin\{gather{*}\}...\textbackslash{}end\{gather{*}\}}
exists.
Look at section \vref{split} for an example.
\end{itemize}
\subsection{\texttt{gathered} environment}
\mPar{\CMD{begin\{gathered\}[c]\\...\\\CMD{end\{gathered\}}}}
The \verb+gathered+ environment is like the \verb+aligned+ or \verb+alignat+
\index{gathered}\index{aligned}\index{alignat}
environment. They use only so much horizontal space as the widest line needs.
In difference to the \verb+gather+ environment it must be itself inside the
math mode.
%
\begin{align}
\rule{2cm}{1pt}
\begin{gathered}
\quad i_{11}=0.25\\
\quad i_{21}=\frac{1}{3}i_{11}\\
\quad i_{31}=0.33i_{22}
\end{gathered}
\rule{2cm}{1pt}
\end{align}
%
\begin{lstlisting}
\begin{align}
\rule{2cm}{1pt}
\begin{gathered}
\quad i_{11}=0.25\\
\quad i_{21}=\frac{1}{3}i_{11}\\
\quad i_{31}=0.33i_{22}
\end{gathered}
\rule{2cm}{1pt}
\end{align}
\end{lstlisting}
%
The optional argument can be used for setting the vertical alignment which is
by default c (centered). It can also be t for top or b for bottom.
\begin{align}
\rule{1cm}{1pt}
\begin{gathered}[t]
\quad A=a\\
\quad B=b\\
\quad C=c
\end{gathered}
%
\begin{gathered}[c]
\quad A=a\\
\quad B=b\\
\quad C=c
\end{gathered}
%
\begin{gathered}[b]
\quad A=a\\
\quad B=b\\
\quad C=c
\end{gathered}
\ \rule{1cm}{1pt}
\end{align}
\begin{lstlisting}
\begin{align}
\rule{1cm}{1pt}
\begin{gathered}[t]
\quad A=a\\
\quad B=b\\
\quad C=c
\end{gathered}
%
\begin{gathered}[c]
\quad A=a\\
\quad B=b\\
\quad C=c
\end{gathered}
%
\begin{gathered}[b]
\quad A=a\\
\quad B=b\\
\quad C=c
\end{gathered}
\ \rule{1cm}{1pt}
\end{align}
\end{lstlisting}
When using a square bracket as first character inside the environment, then
everything is ignored by \AmS until a following closing bracket, because \AmS takes this
as an optional argument:
%
\begin{align}
\begin{gathered}
[A]\quad A=a\\
[B]\quad B=b\\
[C]\quad C=c
\end{gathered}
\end{align}
%
\begin{lstlisting}
\begin{align}
\begin{gathered}
[A]\quad A=a\\
[B]\quad B=b\\
[C]\quad C=c
\end{gathered}
\end{align}
\end{lstlisting}
%
The \verb+[A]+ is completely ignored, which can be avoided by using the
optional argument \verb+[c]+ or at least an empty one directly
after the \verb+\begin{gather}+. Another possibility is using the package \verb+empheq+,
which fixes this behaviour by default.
%
\begin{align}
\begin{gathered}[]
[A]\quad A=a\\
[B]\quad B=b\\
[C]\quad C=c
\end{gathered}
\end{align}
%
\begin{lstlisting}
\begin{align}
\begin{gathered}[]
[A]\quad A=a\\
[B]\quad B=b\\
[C]\quad C=c
\end{gathered}
\end{align}
\end{lstlisting}
%
\subsection{\texttt{multline} environment}
\mPar{\CMD{begin\{multline\}\\...\\\CMD{end\{multline\}}}}
This is also like a multi line%
\footnote{It is no typo, the name of the environment is \texttt{multline}, no
missing i here!} environment with a special vertical alignment. The \textbf{first}
row is \textbf{left aligned}, the second and all following ones except
the last one are \textbf{centered} and the \textbf{last} line is \textbf{right
aligned}. It is often used to write extremely long formulas:
\begin{lstlisting}[xleftmargin=-1cm,xrightmargin=-1.5cm]
\begin{multline}
A = \lim _{n\rightarrow \infty }\Delta x\left( a^{2}+\left( a^{2}+2a\Delta x
+\left( \Delta x\right) ^{2}\right)\right.\\
+\left( a^{2}+2\cdot 2a\Delta x+2^{2}\left( \Delta x\right) ^{2}\right)\\
+\left( a^{2}+2\cdot 3a\Delta x+3^{2}\left( \Delta x\right) ^{2}\right)\\
+ \ldots\\
\left.+\left( a^{2}+2\cdot (n-1)a\Delta x +(n-1)^{2}\left( \Delta x\right) ^{2}\right) \right)\\
= \frac{1}{3}\left( b^{3}-a^{3}\right)
\end{multline}
\end{lstlisting}
\begin{multline}
A=\lim_{n\rightarrow\infty}\Delta x\left(a^{2}+\left(a^{2}+2a\Delta x+\left(\Delta x\right)^{2}\right)\right.\label{eq:reset}\\
+\left(a^{2}+2\cdot2a\Delta x+2^{2}\left(\Delta x\right)^{2}\right)\\
+\left(a^{2}+2\cdot3a\Delta x+3^{2}\left(\Delta x\right)^{2}\right)\\
+\ldots\\
\left.+\left(a^{2}+2\cdot(n-1)a\Delta x+(n-1)^{2}\left(\Delta x\right)^{2}\right)\right)\\
=\frac{1}{3}\left(b^{3}-a^{3}\right)
\end{multline}
\begin{figure}[htb]
\begin{multline}
\framebox[0.5\columnwidth]{x}\\
\framebox[0.5\columnwidth]{x}\\
\framebox[0.5\columnwidth]{x}\\
\shoveright{\framebox[0.5\columnwidth]{x}}\\
\framebox[0.5\columnwidth]{x}\\
\framebox[0.5\columnwidth]{x}
\end{multline}
\caption{\texttt{multline} Alignment demo
(the fourth row is shifted to the right with \CMD{shoveright})}
\label{cap:multline-Alignment-Demo}
\end{figure}
\begin{figure}[htb]
\begin{minipage}[c]{0.45\textwidth}%
\fbox{\parbox{\columnwidth}{\begin{multline}
\framebox[0.5\columnwidth]{\textrm{\textbackslash multlinegap=}}\\
\framebox[0.5\columnwidth]{\the\multlinegap}\end{multline}
}}
\end{minipage}%
\hfill{}\begin{minipage}[c]{0.45\textwidth}%
{\setlength{\multlinegap}{0pt}\fbox{\parbox{\columnwidth}{\begin{multline}
\framebox[0.5\columnwidth]{\textbackslash\textrm{multlinegap=}}\\
\framebox[0.5\columnwidth]{\the\multlinegap}\end{multline}
}}}
\end{minipage}%
\caption{\label{cap:multlinegap}Demonstration of \CMD{multlinegap} (default is 0pt)}
\end{figure}
\begin{itemize}
\item A nonumber-version \CMD{begin\{multline{*}\}...}\CMD{end\{multline{*}\}}
exists.
\item By default only the last line (for right equation numbers) or the
first line (for left equation numbers) gets a number, the others can't.
\item The alignment of a single line can be changed with the command
\CMD{shoveright}\index{shoveright@\textbackslash shoveright} (figure \vref{cap:multline-Alignment-Demo})
\item The first line and the last line have a small gap to the text border.%
\footnote{When the first (numbers left) or last line (numbers right) has an
equation number then \CMD{multlinegap} is not used
for these ones, only for the line without a number.} See figure \ref{cap:multlinegap}, where the length of \CMD{multlinegap}\index{multlinegap@\textbackslash multlinegap}
is set to \texttt{0pt} for the right one.
\end{itemize}
\subsubsection{Examples for \texttt{multline}}\label{sec:Specials-for-multline}
With the multline environment the equation~\vref{eq:braces} looks like:
\begin{multline}
\frac{1}{2}\Delta(f_{ij}f^{ij})=2\left(\sum_{i<j}\chi_{ij}(\sigma_{i}-\sigma_{j})^{2}
+f^{ij}\nabla_{j}\nabla_{i}(\Delta f)+\right.\\
+\left.\nabla_{k}f_{ij}\nabla^{k}f^{ij}+f^{ij}f^{k}\left[2\nabla_{i}R_{jk}-\nabla_{k}R_{ij}
\right]\right)
\end{multline}
%
which is again a bad typesetting because of the two unequal parentheses.
Each one has a size which is correct for the line but not for the
whole formula. \LaTeX{} accepts only pairs of parentheses for one
line and has an ``empty{}'' parentheses, the dot ``\texttt{\textbackslash{}left.}''
or ``\texttt{\textbackslash{}right.}''{} to get only one of the ``pair{}''.
There are different solutions to get the right size of the parentheses.
One of them is to use the \CMD{vphantom} command,
which reserves the vertical space without any horizontal one, like
a vertical rule without any thickness. The sum symbol from the first
line is the biggest one and responsible for the height, so this one is
the argument of \CMD{vphantom} which has to be
placed anywhere.
\begin{multline}
\frac{1}{2}\Delta(f_{ij}f^{ij})=
2\left(\sum_{i<j}\chi_{ij}(\sigma_{i}-
\sigma_{j})^{2}+f^{ij}\nabla_{j}\nabla_{i}(\Delta f)+\right.\\
\left.+\nabla_{k}f_{ij}\nabla^{k}f^{ij}+
f^{ij}f^{k}\left[2\nabla_{i}R_{jk}-
\nabla_{k}R_{ij}\right]\vphantom{\sum_{i<j}}\right)
\end{multline}
%
\begin{lstlisting}[xleftmargin=-1cm,xrightmargin=-1.5cm]
\begin{multline}
\frac{1}{2}\Delta(f_{ij}f^{ij})=
2\left(\sum_{i<j}\chi_{ij}(\sigma_{i}-
\sigma_{j})^{2}+f^{ij}\nabla_{j}\nabla_{i}(\Delta f)+\right.\\
\left.+\nabla_{k}f_{ij}\nabla^{k}f^{ij}+
f^{ij}f^{k}\left[2\nabla_{i}R_{jk}-
\nabla_{k}R_{ij}\right]\vphantom{\sum_{i<j}}\right)
\end{multline}
\end{lstlisting}
%
Instead of using the \CMD{vphantom} command it is
also possible to use fixed-width parentheses, which is described in
section \vref{sec:Brackets,-Braces-and}.
A math expression with a very long fraction like the following one, which runs out
of the margin
could be written as a multiplication to avoid the fraction line.
%
%\begin{LTXexample}[pos=t,xleftmargin=-1cm,xrightmargin=-1.5cm]
\begin{equation}
\frac{\mathrm{d}G_\infty}{\mathrm{d}n}=\frac{\left[1-e^{-pn}\right]
\left[Q\left(n\right)-pR\left(n\right)+R'\left(n\right)\right]e^{-pn}
-\left[-\frac{Q \left(n\right)e^{-pn}}{p}+\frac{Q\left(0\right)}{p}+R
\left(n\right)e^{-pn} - A\right] pe^{-pn}}{\left({1-e^{-pn}}\right)^2} = 0
\end{equation}
%\end{LTXexample}
%
\begin{lstlisting}[xleftmargin=-1cm,xrightmargin=-1.5cm]
\begin{equation}
\frac{\mathrm{d}G_\infty}{\mathrm{d}n}=\frac{\left[1-e^{-pn}\right]
\left[Q\left(n\right)-pR\left(n\right)+R'\left(n\right)\right]e^{-pn}
-\left[-\frac{Q \left(n\right)e^{-pn}}{p}+\frac{Q\left(0\right)}{p}+R
\left(n\right)e^{-pn} - A\right] pe^{-pn}}{\left({1-e^{-pn}}\right)^2} = 0
\end{equation}
\end{lstlisting}
%
With the \verb+multline+ environment it can then be split into two or more parts:
%
\begin{LTXexample}[pos=t,xleftmargin=-1cm,xrightmargin=-1.5cm]
\begin{multline}
\frac{\mathrm{d}G_\infty}{\mathrm{d}n} =
\frac{1}{\left( {1-e^{-pn}} \right)^2 }\cdot
\left\{\vphantom{\frac{Q}{p}}% >>>> to get the correct height <<<<<
\left[ 1-e^{-pn} \right] \left[ Q \left( n \right) - pR
\left( n \right) + R'\left( n \right) \right]e^{-pn}\right.\\
- \left.\left[-\frac{Q \left( n \right) e^{-pn}}{p} +
\frac{Q \left( 0 \right)}{p} + R \left( n \right) e^{-pn}
- A\right] pe^{-pn}\right\} = 0
\end{multline}
\end{LTXexample}
\subsection{\texttt{split} environment}\label{split}
\mPar{\CMD{begin\{split\}\\...\\\CMD{end\{split\}}}}%
\makeatletter
\@removefromreset{equation}{section}
\makeatother
%
\begin{leftbar}
\noindent From now on the counting of the equations changes. It is introduced with a
foregoing command, which doesn't really make sense, it is only
for demonstration:
\begin{lstlisting}
\makeatletter
\@removefromreset{equation}{section}
\makeatother
\end{lstlisting}
\end{leftbar}
The \verb|split| environment is like the \verb|multline|\index{multline}
or \verb|array| environment for equations longer than the column
width. Just like the array environment and in contrast to \verb|multline|,
\verb|split| can only be used as \textbf{part of another environment}.
\verb|split| itself has no own numbering, this is given by the other
environment. Without an ampersand all lines in the split environment
are right-aligned and can be aligned at a special point by using an
ampersand. In difference to the \verb|aligned| environment (section \vref{sec:aligned}), the \verb|split| environment permits more than one horizontal alignment.
It is important that the split environment has another behaviour when used inside one of the %%% ----- Martin -----
``old'' \LaTeX{} environments \verb+\[...\]+ or \verb+\begin{equation}+ \verb+...+\verb+ \end{equation}+, in this
case more than one horizontal alignment tabs are possible.
\hspace*{-\marginparwidth}%
\begin{minipage}{0.5\columnwidth}
\[
\begin{split}
\framebox[0.35\columnwidth]{x}\\
\framebox[0.75\columnwidth]{x}\\
\framebox[0.65\columnwidth]{x}\\
\framebox[0.95\columnwidth]{x}
\end{split}
\]
\end{minipage}\hfill%
\begin{minipage}{0.5\columnwidth}
\footnotesize\begin{verbatim}
\[
\begin{split}
\framebox[0.35\columnwidth]{x}\\
\framebox[0.75\columnwidth]{x}\\
\framebox[0.65\columnwidth]{x}\\
\framebox[0.95\columnwidth]{x}
\end{split}
\]
\end{verbatim}
\end{minipage}
\vspace{2ex}
\hspace*{-\marginparwidth}%
\begin{minipage}{0.5\columnwidth}
\[
\begin{split}
\vec{a} = {}&\framebox[0.35\columnwidth]{x}\\
&\framebox[0.75\columnwidth]{x}\\
&\framebox[0.65\columnwidth]{x}\\
&\framebox[0.95\columnwidth]{x}
\end{split}
\]
\end{minipage}\hspace{1cm}%
\begin{minipage}{0.5\columnwidth}
\footnotesize%
\begin{verbatim}
\[
\begin{split}
\vec{a} = {}&\framebox[0.35\columnwidth]{x}\\
&\framebox[0.75\columnwidth]{x}\\
&\framebox[0.65\columnwidth]{x}\\
&\framebox[0.95\columnwidth]{x}
\end{split}
\]
\end{verbatim}
\end{minipage}
\vspace{1ex}
The following example shows the \texttt{split} environment as part
of the \texttt{equation} environment:
\begin{equation}
\begin{split}A_{1} & =\left|\int_{0}^{1}(f(x)-g(x))\,\mathrm{d}x\right|+\left|\int_{1}^{2}(g(x)-h(x))\,\mathrm{d}x\right|\\
& =\left|\int_{0}^{1}(x^{2}-3x)\,\mathrm{d}x\right|+\left|\int_{1}^{2}(x^{2}-5x+6)\,\mathrm{d}x\right|\\
& =\left|\frac{x^{3}}{3}-\frac{3}{2}x^{2}\right|_{0}^{1}+\left|\frac{x^{3}}{3}-\frac{5}{2}x^{2}+6x\right|_{1}^{2}\\
& =\left|\frac{1}{3}-\frac{3}{2}\right|+\left|\frac{8}{3}-\frac{20}{2}+12-\left(\frac{1}{3}-\frac{5}{2}+6\right)\right|\\
& =\left|-\frac{7}{6}\right|+\left|\frac{14}{3}-\frac{23}{6}\right|=\frac{7}{6}+\frac{5}{6}=2\,\textrm{FE}\end{split}
\label{eq:Beispiel-Integral}\end{equation}
\begin{lstlisting}[xleftmargin=-1cm,xrightmargin=-1.5cm]
\begin{equation}
\begin{split}
A_{1} & = \left| \int _{0}^{1}(f(x)-g(x))\,\mathrm{d}x\right| +\left|
\int _{1}^{2}(g(x)-h(x))\,\mathrm{d}x\right| \\
& = \left| \int _{0}^{1}(x^{2}-3x)\,\mathrm{d}x\right| +\left|
\int _{1}^{2}(x^{2}-5x+6)\,\mathrm{d}x\right| \\
& = \left| \frac{x^{3}}{3}-\frac{3}{2}x^{2}\right| _{0}^{1}+
\left| \frac{x^{3}}{3}-
\frac{5}{2}x^{2}+6x\right| _{1}^{2}\\
& = \left| \frac{1}{3}-\frac{3}{2}\right| +\left|
\frac{8}{3}-\frac{20}{2}+12-
\left( \frac{1}{3}-\frac{5}{2}+6\right) \right| \\
& = \left| -\frac{7}{6}\right| +\left| \frac{14}{3}-\frac{23}{6}
\right| =\frac{7}{6}+\frac{5}{6}=2\, \textrm{FE}
\end{split}
\end{equation}
\end{lstlisting}
\bigskip{}
The same using the \verb|array| environment with \verb|{rl}|-alignment
instead of \verb|split| gives same horizontal alignment, but another %%% ----- Martin -----
vertical spacing%
\footnote{Can be changed with \texttt{\textbackslash renewcommand\textbackslash arraystretch\{1.5\}}} and the
symbols are only in scriptsize and not textsize:\footnote{See section \vref{sec:Styles}} %%% ----- Martin -----
\begin{equation}
\begin{array}{rl}
A_{1} & =\left|\int_{0}^{1}(f(x)-g(x))\,\mathrm{d}x\right|+\left|\int_{1}^{2}(g(x)-h(x))\,\mathrm{d}x\right|\\
& =\left|\int_{0}^{1}(x^{2}-3x)\,\mathrm{d}x\right|+\left|\int_{1}^{2}(x^{2}-5x+6)\,\mathrm{d}x\right|\\
& =\left|\frac{x^{3}}{3}-\frac{3}{2}x^{2}\right|_{0}^{1}+\left|\frac{x^{3}}{3}-\frac{5}{2}x^{2}+6x\right|_{1}^{2}\\
& =\left|\frac{1}{3}-\frac{3}{2}\right|+\left|\frac{8}{3}-\frac{20}{2}+12-\left(\frac{1}{3}-\frac{5}{2}+6\right)\right|\\
& =\left|-\frac{7}{6}\right|+\left|\frac{14}{3}-\frac{23}{6}\right|=\frac{7}{6}+\frac{5}{6}=2\,\textrm{FE}
\end{array}
\end{equation}
Compare the following two examples for typesetting the minus sign. In the first case it
is typeset similiar to the plus character, and in the second example it is typeset
without the additional space for a binary math atom.
\begin{minipage}{0.49\linewidth}
\begin{align}
\begin{split}
a = {} & -b + c \\
& -d + e
\end{split}
\end{align}
%
\begin{align}
\begin{split}
a = {} & {-}b + c \\
& {-}d + e
\end{split}
\end{align}
\end{minipage}\hfill
\begin{minipage}{0.49\linewidth}
\begin{lstlisting}
\begin{align}
\begin{split}
a = {} & -b + c \\
& -d + e
\end{split}
\end{align}
%
\begin{align}
\begin{split}
a = {} & {-}b + c \\
& {-}d + e
\end{split}
\end{align}
\end{lstlisting}
\end{minipage}
\begin{itemize}
\item There exists no starred version (\texttt{\textbackslash{}begin\{split{*}\}}) %%% ----- Martin -----
of the \texttt{split} environment.
\end{itemize}
\subsection{\texttt{cases} environment }
This gives support for an often used mathematical construct.\index{cases@\textbackslash cases}
You can also choose the more than once described way to convert some
text into math, like
{\footnotesize\begin{verbatim}
$x=\begin{cases}
0 & \text{if A=...}\\
1 & \text{if B=...}\\
x & \textrm{this runs with as much text as you like,
but without an automatic linebreak, it runs out
of page....}
\end{cases}$
\end{verbatim}}
\noindent which gives equation~\vref{eq:cases}. It is obvious what the problem
is.
\begin{eqnarray}
x & = & \begin{cases}
0 & \text{if A=...}\\
1 & \text{if B=...}\\
x & \textrm{this runs with as much text as you like, but without a linebreak, it runs out of page....}\end{cases}\label{eq:cases}\end{eqnarray}
In this case it is better to use a parbox\index{parbox@\textbackslash parbox}
for the text part with a \texttt{flushleft} command for a better view.
\begin{equation}
x=\begin{cases}
0 & \text{if A=...}\\
1 & \text{if B=...}\\
x & \parbox{5cm}{\flushleft this runs with as much text as you like, but without an automatic linebreak, it runs out of page....}\end{cases}\end{equation}
\begin{lstlisting}
\begin{equation}
x=\begin{cases}
0 & \text{if A=...}\\
1 & \text{if B=...}\\
x & \parbox{5cm}{%
\flushleft%
this runs with as much text as you like,
but without an automatic linebreak,
it runs out of page....}%
\end{cases}
\end{equation}
\end{lstlisting}
\begin{leftbar}
\noindent From now on the counting of the equations changes. It is introduced
with a foregoing command, which doesn't really make sense, it is only for
demonstration:
\begin{lstlisting}
\renewcommand\theequation{\arabic{equation}}
\end{lstlisting}
\end{leftbar}
\renewcommand\theequation{\arabic{equation}}
\subsection{Matrix environments}\label{sec:ams-matrix}
%
\begin{table}[htb]
\centering\begin{tabular}{rcrcrc}
\textbackslash{}Vmatrix\index{Vmatrix@\textbackslash Vmatrix}&
$\begin{Vmatrix}a & b\\
c & d\end{Vmatrix}$&
\textbackslash{}Bmatrix\index{Bmatrix@\textbackslash Bmatrix}&
$\begin{Bmatrix}a & b\\
c & d\end{Bmatrix}$&
\textbackslash{}matrix\index{matrix@\textbackslash matrix}&
$\begin{matrix}a & b\\
c & d\end{matrix}$\tabularnewline
\rule{0pt}{0.85cm}\textbackslash{}vmatrix\index{vmatrix@\textbackslash vmatrix}&
$\begin{vmatrix}a & b\\
c & d\end{vmatrix}$&
\textbackslash{}bmatrix\index{bmatrix@\textbackslash bmatrix}&
$\begin{bmatrix}a & b\\
c & d\end{bmatrix}$&
\textbackslash{}pmatrix\index{pmatrix@\textbackslash pmatrix}&
$\begin{pmatrix}a & b\\
c & d\end{pmatrix}$\tabularnewline[10pt]
&&&&\textbackslash{}smallmatrix\index{smallmatrix@\textbackslash smallmatrix}&
$\begin{smallmatrix}a & b\\
c & d\end{smallmatrix}$
\end{tabular}
\caption{Matrix environments}
\end{table}
All matrix environments can be nested and an element may also contain
any other math environment, so that very complex structures are possible.
By default all cells have a centered alignment, which is often not the best
when having different decimal numbers or plus/minus values. Changing the
alignment to right (not for the \verb+smallmatrix+) is possible with
\mPar{%
\texttt{matrix}\\
\texttt{vmatrix}\\
\texttt{Vmatrix}\\
\texttt{bmatrix}\\
\texttt{Bmatrix}\\
\texttt{pmatrix}\\
\texttt{smallmatrix}%
}%
\begin{lstlisting}
\makeatletter
\def\env@matrix{\hskip -\arraycolsep
\let\@ifnextchar\new@ifnextchar
\array{*\c@MaxMatrixCols r}}
\makeatother
\end{lstlisting}
The special matrix environment \verb+smallmatrix+, which decreases
horizontal and vertical space is typeset in scriptstyle. The \verb|smallmatrix|
\index{smallmatrix@\textbackslash smallmatrix} environment makes some sense
in the inline mode to decrease the line height.
For dots over several columns look for \CMD{hdotsfor} in the following section.
\section{Vertical whitespace}\label{sec:ams-whitespace}
See section~\vref{subsec:vwhitespace} for the lengths which control the
vertical whitespace. There is no difference to \AmSmath.
\section{Dots}\label{sec:ams-dots}
In addition to section~\vref{sec:Dots} \AmSmath has two more commands
for dots: \CMD{dddot}\{...\}\footnote{already mentioned in section \ref{sec:Accents}} and \CMD{ddddot}\{...\}
\index{dddot@\textbackslash dddot}\index{ddddot@\textbackslash ddddot}
\verb|$\dddot{y}$|: $\dddot{y}$
\verb|$\ddddot{y}$|: $\ddddot{y}$
Another interesting dot command is \CMD{hdotsfor}\index{hdotsfor@\textbackslash hdotsfor}
with the syntax:
\begin{lstlisting}
\hdotsfor[<spacing factor>]{<number of columns>}
\end{lstlisting}
With the spacing factor the width of the dots can be stretched or
shrinked. The number of columns allows a continuing dotted line over
more columns. Equation \ref{eq:tridiagonal} shows the definition
of a tridiagonal matrix.
\begin{equation}
\underline{A}=\left[\begin{array}{ccccccc}
a_{11} & a_{12} & 0 & \ldots & \ldots & \ldots & 0\\
a_{21} & a_{22} & a_{23} & 0 & \ldots & \ldots & 0\\
0 & a_{32} & a_{33} & a_{34} & 0 & \ldots & 0\\
\vdots & \vdots & \vdots & \vdots & \vdots & \vdots & \vdots\\
\hdotsfor{7}\cr\vdots & \vdots & \vdots & \vdots & \vdots & \vdots & \vdots\\
0 & \ldots & 0 & a_{n-2,n-3} & a_{n-2,n-2} & a_{n-2,n-1} & 0\\
0 & \ldots & \ldots & 0 & q_{n-1,n-2} & a_{n-1,n-1} & a_{n-1,n}\\
0 & \ldots & \ldots & \ldots & 0 & a_{n,n-1} & a_{nn}
\end{array}\right]\label{eq:tridiagonal}
\end{equation}
\begin{lstlisting}[xleftmargin=-1cm,xrightmargin=-1.5cm]
\begin{equation}
\underline{A}=\left[\begin{array}{ccccccc}
a_{11} & a_{12} & 0 & \ldots & \ldots & \ldots & 0\\
a_{21} & a_{22} & a_{23} & 0 & \ldots & \ldots & 0\\
0 & a_{32} & a_{33} & a_{34} & 0 & \ldots & 0\\
\vdots & \vdots & \vdots & \vdots & \vdots & \vdots & \vdots\\
\hdotsfor{7}\cr\vdots & \vdots & \vdots & \vdots & \vdots & \vdots & \vdots\\
0 & \ldots & 0 & a_{n-2,n-3} & a_{n-2,n-2} & a_{n-2,n-1} & 0\\
0 & \ldots & \ldots & 0 & q_{n-1,n-2} & a_{n-1,n-1} & a_{n-1,n}\\
0 & \ldots & \ldots & \ldots & 0 & a_{n,n-1} & a_{nn}
\end{array}\right]
\end{equation}
\end{lstlisting}
\section{\texttt{fraction} commands}\label{sec:ams-fraction}
\subsection{Standard}
Additional to the font size problem described in subsection~\vref{sub:fraction command}
\AmSmath supports some more commands for fractions\index{Fraction}. The \CMD{frac} command
described in \cite{MathGuide}, does no more exist in \AmSmath. %%% ----- Martin -----
\begin{itemize}
\item The global fraction definition has five parameters\index{genfrac@\textbackslash genfrac}
\index{fraction@\textbackslash frac}
\begin{lstlisting}[xleftmargin=-1em,xrightmargin=-1em]
\genfrac{<left delim>}{<right delim>}{<thickness>}{<mathstyle>}{<nominator>}{<denominator>}
\end{lstlisting}
where thickness can have any length with a valid unit like \\
\verb|genfrac{}{}{1pt}{}{x^2+x+1}{3x-2}|
$\rightarrow\genfrac{}{}{1pt}{}{x^2+x+1}{3x-2}$
\item \CMD{cfrac}\index{cfrac@\textbackslash cfrac} (continued fraction) which is
by default set in the display mathstyle and useful for fractions like
\begin{equation}
\cfrac{1}{\sqrt{2}+\cfrac{1}{\sqrt{3}+\cfrac{1}{\sqrt{4}+\cfrac{1}{\ldots}}}}\label{cfrac}
\end{equation}
which looks with the default \CMD{frac} command like
\begin{equation}
\frac{1}{\sqrt{2}+\frac{1}{\sqrt{3}+\frac{1}{\sqrt{4}+\frac{1}{\ldots}}}}
\end{equation}
where the mathstyle decreases for every new level in the fraction.
The \CMD{cfrac} command can be called with an optional
parameter which defines the placing of the nominator, which can be
\texttt{[l]}eft, \texttt{[r]}ight or \texttt{[c]}enter (the default - see
equation~\ref{cfrac}):\\
\begin{minipage}[c]{0.40\textwidth}%
\[
\cfrac[l]{1}{\sqrt{2}+\cfrac[l]{1}{\sqrt{3}+\cfrac[l]{1}{\sqrt{4}+\cfrac[l]{1}{\ldots}}}}
\]
\end{minipage}%
\hfill{}\begin{minipage}[c]{0.40\textwidth}%
\[\cfrac[r]{1}{\sqrt{2}+\cfrac[r]{1}{\sqrt{3}+\cfrac[r]{1}{\sqrt{4}+\cfrac[r]{1}{\ldots}}}}\]
\end{minipage}%
\item \CMD{dfrac}\index{dfrac@\textbackslash dfrac}
which takes by default the displaystyle\index{displaystyle@\textbackslash displaystyle}, so that
fractions in inline mode $\dfrac{1}{2}$ have the same size than in
display mode.
\item \CMD{tfrac}\index{tfrac@\textbackslash tfrac} (vice versa to \CMD{dfrac}) which takes by default
the scriptstyle\index{scriptstyle@\textbackslash scriptstyle}, so that fractions in display
mode have the same size than in inline mode.
\end{itemize}
\[\tfrac{2}{3} \text{\hspace{0.5cm}\CMD{tfrac\{2\}\{3\}}} \]
\[\frac{2}{3} \text{\hspace{0.5cm}\CMD{frac\{2\}\{3\}}} \]
\subsection{Binoms}\label{sub:Binoms}
\mPar{\CMD{binom}\\\CMD{dbinom}\\\CMD{tbinom}}They are like fractions without a rule and its syntax is different
to the \CMD{choose} command from standard \LaTeX{}
(see section \vref{sub:fraction command}). \AmSmath{} provides three
different commands for binoms just like the ones for fractions.
\begin{table}[htb]
\centering%
\begin{tabular}{lcl}
Command & Inlinemath & Displaymath\tabularnewline
\hline
\texttt{\textbackslash{}binom\{m\}\{n\}} & $\binom{m}{n}$&
${\displaystyle \binom{m}{n}}$\tabularnewline
\texttt{\rule{0pt}{0.75cm}\textbackslash{}dbinom\{m\}\{n\}}&
$\dbinom{m}{n}$&
${\displaystyle \dbinom{m}{n}}$\tabularnewline
\texttt{\rule{0pt}{0.5cm}\textbackslash{}tbinom\{m\}\{n\}}&
$\tbinom{m}{n}$&
${\displaystyle \tbinom{m}{n}}$\tabularnewline
\end{tabular}
\caption{binom commands}
\end{table}
\section{Roots}\label{sec:Roots-ams}
The typesetting for roots\index{uproot@\textbackslash uproot} is sometimes not
the best. Some solutions for better typesetting are %
\mPar{\CMD{leftroot}\\\CMD{uproot}}%
described in section~\vref{sec:Roots} for standard \LaTeX{}. \AmSmath
has some more commands for the $n$-th root:
\begin{lstlisting}
\sqrt[\leftroot{<number>}\uproot{<number>}<root>]{< ... >}
\end{lstlisting}
\noindent \verb+<number>+ indicates a value for the points%
\footnote{In PostScript units (bp -- Big Points).} of which the root can be
adjusted to the left and/or to the top, \eg
$\sqrt[k_n]{a}$ (\verb+$\sqrt[k_n]{a}$+) has a too deep exponent, whereas $\sqrt[\uproot{2}k_n]{a}$ \verb+$\sqrt[\uproot{2}k_n]{a}$+ looks nicer.
\subsection{Roots with \CMD{smash} command}
\mPar{\CMD{smash}}The default for a root\index{Root} with $\lambda_{k_{i}}$ as root
argument looks like $\sqrt{\lambda_{k_{i}}}$, which may be not the %%% ----- Martin -----
best typesetting. It is possible to reduce the lowest point of the root
to the baseline with the \CMD{smash} command: $\sqrt{\lambda_{k_{i}}}\xrightarrow{\text{with \textbackslash smash}}\sqrt{\smash[b]{\lambda_{k_{i}}}}$
The syntax of the \CMD{smash} command%
\footnote{In \texttt{latex.ltx} \CMD{smash} is defined without an optional argument.} renewed by the \AmSmath package is %%% ----- Martin -----
\begin{lstlisting}
\smash[<position>]{<argument>}
\end{lstlisting}
The optional argument for the position can be:
\begin{description}
\item [t]keeps the bottom and annihilates the top
\item [b]keeps the top and annihilates the bottom
\item [tb]annihilates top and bottom (the default)
\end{description}
\section{Accents}\label{amssymb}
With the macro \verb|\mathaccent| it is easy to define new accent types, for example
\begin{lstlisting}
\def\dotcup{$\mathaccent\cdot\cup$}
\end{lstlisting}
$\mathaccent\cdot\cup$
\def\curvearrowleftright{%
\ensuremath{%
\mathaccent\curvearrowright{\mkern-5mu\curvearrowleft}%
}%
}
Overwriting of two symbols is also possible:
{\huge
$\curvearrowleft\curvearrowright\curvearrowleftright$}
In this case the second symbol has to be shifted to the left for a length %%% ----- Martin -----
of $5mu$ (mu: math unit\index{Math unit}).
\begin{lstlisting}
\def\curvearrowleftright{%
\ensuremath{%
\mathaccent\curvearrowright{\mkern-5mu\curvearrowleft}%
}%
}
\end{lstlisting}
For other possibilities to define new accents see section \vref{sec:package-accent}. %%% ----- Martin -----
\section{\CMD{mod} command}
In standard \LaTeX{} the modulo command is not an operator, though %%% ----- Martin -----
it is often used in formulas. \AmSmath provides two (three) different
commands for modulo, which are listed in tabular~\vref{cap:The-modulo commands}.
\begin{itemize}
\item They all insert some useful space before and behind the mod-operator.
\end{itemize}
\begin{table}[htb]
\centering\begin{tabular}{rrl}
a\textbackslash{}mod\{n\^{}2\}=b&
$\rightarrow$&
$a\mod{n^{2}}=b$\tabularnewline
a\textbackslash{}pmod\{n\^{}2\}=b&
$\rightarrow$&
$a\pmod{n^{2}}=b$\tabularnewline
a\textbackslash{}pod\{n\^{}2\}=b&
$\rightarrow$&
$a\pod{n^{2}}=b$\tabularnewline
\end{tabular}
\caption{\label{cap:The-modulo commands}The modulo commands and their meaning}
\end{table}
\section{Equation numbering\label{sec:Equation-numbering}}
See section \vref{sub:Equationnumbering} for equation numbering\index{Equation!numbering}.
It is mostly the %
\mPar{\textbackslash{}numberwithin%
}same, only one command is new to \AmSmath. If you want
a numbering like ``\ref{eq:IntoSection}{}'' then write either in the preamble %%% ----- Martin -----
or like this example anywhere in your doc:
\begin{lstlisting}
\numberwithin{equation}{section}
\end{lstlisting}
\begin{leftbar}
\numberwithin{equation}{section}From now on the numbering looks like %%% ----- Martin -----
equation \vref{eq:IntoSection}. For the book-class you can get the
same for chapters.
\end{leftbar}
If you want to get rid of the parentheses then write in the preamble: %%% ----- Martin -----
\begin{lstlisting}
\makeatletter
\def\tagform@#1{\maketag@@@{\ignorespaces#1\unskip\@@italiccorr}}
\makeatother
\end{lstlisting}
Now the following four subequation numbers have no parentheses.
\makeatletter
\let\oldTagForm\tagform@
\def\tagform@#1{\maketag@@@{\ignorespaces#1\unskip\@@italiccorr}}
\makeatother
\subsection{Subequations}\label{ams:subeqn}
Amsmath supports this with the environment \verb|subequation|\index{Subequations}.
For example:
\begin{subequations}
\begin{align}
y & = d\\
y & = cx+d\\
y & = bx^{2}+cx+d\\
y & = ax^{3}+bx^{2}+cx+d
\end{align}
\end{subequations}
\begin{lstlisting}
\begin{subequations}
\begin{align}
y & = d\\
y & = cx+d\\
y & = bx^{2}+cx+d\\
y & = ax^{3}+bx^{2}+cx+d
\end{align}
\end{subequations}
\end{lstlisting}
\makeatletter
\let\tagform@\oldTagForm
\makeatother
Inside of subequations only complete other environments (\texttt{\textbackslash{}begin\{...\}
... \textbackslash{}end\{...\}}) are possible.
\begin{lstlisting}
\renewcommand{\theequation}{%
\theparentequation{}-\arabic{equation}%
}
\end{lstlisting}
\begin{subequations}
\renewcommand{\theequation}{%
\theparentequation -\arabic{equation}%
}%
\begin{align}
y & = d\\
y & = cx+d\label{eq:subequation-neu}\\
y & = bx^{2}+cx+d\\
y & = ax^{3}+bx^{2}+cx+d
\end{align}
\end{subequations}
A ref to a subequation is possible like the one to equation \ref{eq:subequation-neu}.
The environment chooses the same counter ``\texttt{equation}''
but saves the old value into ``\texttt{parentequation}''.
\newcounter{mySubCounter}
\newcommand{\twocoleqn}[2]{
\setcounter{mySubCounter}{0}%
\let\OldTheEquation\theequation%
\renewcommand{\theequation}{\OldTheEquation\alph{mySubCounter}}%
\noindent%
\begin{minipage}{.49\textwidth}
\begin{equation}\refstepcounter{mySubCounter}
#1
\end{equation}
\end{minipage}\hfill%
\addtocounter{equation}{-1}%
\begin{minipage}{.49\textwidth}
\begin{equation}\refstepcounter{mySubCounter}
#2
\end{equation}
\end{minipage}
\let\theequation\OldTheEquation
}
It is also possible to place two equations side by side with counting as subfigures:
\twocoleqn{y=f(x)}{y=f(z)}
\vspace{1ex}
In this case, the \AmSmath internal subfigure counter cannot be used and an own
counter has to be defined:
\begin{lstlisting}
\newcounter{mySubCounter}
\newcommand{\twocoleqn}[2]{
\setcounter{mySubCounter}{0}%
\let\OldTheEquation\theequation%
\renewcommand{\theequation}{\OldTheEquation\alph{mySubCounter}}%
\noindent%
\begin{minipage}{.49\textwidth}
\begin{equation}\refstepcounter{mySubCounter}
#1
\end{equation}
\end{minipage}\hfill%
\addtocounter{equation}{-1}%
\begin{minipage}{.49\textwidth}
\begin{equation}\refstepcounter{mySubCounter}
#2
\end{equation}
\end{minipage}%
\let\theequation\OldTheEquation
}
[ ... ]
\twocoleqn{y=f(x)}{y=f(z)}
\end{lstlisting}
\section{Labels and tags}\label{sec:Labels-and-Tags}
For the \CMD{label} command\index{label@\textbackslash label} \mPar{\textbackslash{}tag%
}
see section \vref{sec:Labels}, it is just the same behaviour. \AmSmath
allows to define own single ``equation numbers\index{Equation number}''
with the \CMD{tag} command.
\begin{align}
f(x) & =a\tag{linear}\label{eq:linear}\\
g(x) & =\,\mathrm{d}x^{2}+cx+b\tag{quadratic}\label{eq:quadratic}\\
h(x) & =\sin x\tag*{trigonometric}
\end{align}
\begin{lstlisting}
\begin{align}
f(x) & =a\tag{linear}\label{eq:linear}\\
g(x) & =\,\mathrm{d}x^{2}+cx+b\tag{quadratic}\label{eq:quadratic}\\
h(x) & =\sin x\tag*{trigonometric}
\end{align}
\end{lstlisting}
\begin{itemize}
\item The \CMD{tag} command is also possible for unnumbered
equations, \LaTeX{} changes the behaviour when a tag is detected.
\item There exists a starred version \verb|\tag{*}{...}|, %%% ----- Martin -----
which supresses any annotations like parentheses for equation numbers\index{Equation!number}.
\item There exist two package options for tags, \verb|ctagsplit|\index{ctagsplit} %%% ----- Martin -----
and \verb|righttag|\index{righttag} (look at the beginning of this
part on page~\pageref{par:AMSmath-package}).
\end{itemize}
\section{Limits}\label{sec:limit-AMS}
By default the sum/prod has the limits above/below and the integral
at the side. To get the same behaviour for all symbols which can have
limits load the package \AmSmath in the preamble as %%% ----- Martin -----
\begin{lstlisting}
\usepackage[sumlimits,intlimits]{amsmath}
\end{lstlisting}
There exist also options for the vice versa (see page~\pageref{par:AMSmath-package}). %%% ----- Martin -----
See also Section~\ref{sec:misc-AMS} for the additional commands \CMD{underset} and \CMD{overset}.
\subsection{Multiple limits}
For general information about limits\index{Limits} read section
\vref{sub:Limits-Inline}. Standard \LaTeX{} provides the \texttt{\textbackslash{}atop}\index{atop@\textbackslash atop} command
for multiple limits (section \vref{sub:Multiple-Limits}). \AmSmath \mPar{\textbackslash{}substack%
}
has an additional command for that, which
can have several lines with the following syntax:
\mPar{\CMD{begin\{Sb\}}\\...\\\CMD{end\{Sb\}}\\\CMD{begin\{Sp\}}\\...\\\CMD{end\{Sp\}}%
}
\begin{lstlisting}
\substack{...\\...\\...}
\end{lstlisting}
The environments described in \cite{MathGuide}
\begin{lstlisting}
\begin{Sb} ... \end{Sb}
\begin{Sp} ... \end{Sp}
\end{lstlisting}
are obsolete and no more part of \AmSmath.
The example equation \vref{eq:atop} with the \CMD{substack}\index{substack@\textbackslash substack} command
looks like:
\begin{equation}\label{eq:multlimits}
\sum_{\substack{1\le i\le p\\
1\le j\le q\\
1\le k\le r}
}a_{ij}b_{jk}c_{ki}
\end{equation}
Insert these limits in the following way:
\begin{lstlisting}
\begin{equation}
\sum_{%
\substack{1\le i\le p\\
1\le j\le q\\
1\le k\le r}
}%
a_{ij}b_{jk}c_{ki}
\end{equation}
\end{lstlisting}
\subsection{Problems}\label{subsec:ams-limits}
There are still some problems with limits and the following math
expression. For example:
\[
X = \sum_{1\le i\le j\le n}X_{ij}
\]
\begin{lstlisting}
\[
X = \sum_{1\le i\le j\le n}X_{ij}
\]
\end{lstlisting}
\noindent does not look nice because of the long limit. Using a
\CMD{makebox} also does not really solve the problem, because
\CMD{makebox} is in \TeX{} horizontal mode and knows nothing about
the appropriate math font size, because limits have a smaller font size.
It is better to define a \CMD{mathclap}\index{mathclap@\textbackslash mathclap} macro, similiar to the two
macros \CMD{llap} and \CMD{rlap} and uses the also new defined \CMD{mathclap} macro\index{clap@\textbackslash clap}:
\begin{lstlisting}
\def\mathllap{\mathpalette\mathllapinternal}
\def\mathllapinternal#1#2{%
\llap{$\mathsurround=0pt#1{#2}$}% $
}
\def\clap#1{\hbox to 0pt{\hss#1\hss}}
\def\mathclap{\mathpalette\mathclapinternal}
\def\mathclapinternal#1#2{%
\clap{$\mathsurround=0pt#1{#2}$}%
}
\def\mathrlap{\mathpalette\mathrlapinternal}
\def\mathrlapinternal#1#2{%
\rlap{$\mathsurround=0pt#1{#2}$}% $
}
\end{lstlisting}
Now we can write limits which have a boxwidth of 0pt and the right font
size and the following math expression appears just behind the symbol:
\[
X = \sum_{\mathclap{1\le i\le j\le n}}X_{ij}
\]
\begin{lstlisting}
\[
X = \sum_{\mathclap{1\le i\le j\le n}}X_{ij}
\]
\end{lstlisting}
Another problem occurs when having operators with stacked limits in braces:\index{substack@\textbackslash substack}
\index{Braces!Problems}
\index{Stacked limits}
\begin{align}
\left[\sum_{\substack{i,j\\i>j}} \dots \right]
\end{align}
This case is not easy to handle when some other math expressions are around the braces
which should be on the same baseline. However, the following may help in some cases
to get better looking braces.
\begin{LTXexample}[width=0.45\linewidth,wide]
\begin{align}
foo \left[\begin{array}{@{}c@{}}
\displaystyle\sum_{\substack{i,j\\i>j}} \dots
\end{array}\right] bar
\end{align}
\end{LTXexample}
\subsection{\CMD{sideset}}
This is a command for a very special purpose, to combine over/under
limits with superscript/subscripts for \mPar{\CMD{sideset}}the
sum-symbol. For example: it is not possible to place the prime
for the equation \ref{eq:sideset} near to the sum\index{sum@\textbackslash sum} symbol,
because it becomes an upper limit when writing without an preceeding \verb|{}|.
\begin{equation}
\sum_{n<k\atop n\ \textrm{odd}}{}'nE_{n}\label{eq:sideset}
\end{equation}
The command \CMD{sideset}\index{sideset@\textbackslash sideset}
has the syntax
\begin{lstlisting}
\sideset{<before>}{<behind>}
\end{lstlisting}
It can place characters on all four corners of the sum-symbol:
\[
\sideset{_{LowerLeft}^{UpperLeft}}{_{LowerRight}^{UpperRight}}\sum_{B}^{T}
\]
\begin{lstlisting}
\[
\sideset{_{LowerLeft}^{UpperLeft}}{_{LowerRight}^{UpperRight}}\sum_{B}^{T}
\]
\end{lstlisting}
Now it is possible to write the equation \ref{eq:sideset} in a proper
way with the command \verb|\sideset{}{'}| before
the sum symbol:
\begin{equation}
\sideset{}{'}\sum_{n<k\atop n\ \textrm{odd}}nE_{n}
\end{equation}
\section{Operator names}\label{OperatorNames}
\mPar{\CMD{operatorname}}%
By default variables are written in italic\index{Italic} and operator
names\index{Operator!names} in upright mode, like $y=\sin(x)$.%
\footnote{See section \vref{sec:ltxOperators}, where all the standard \LaTeX{} %%% ----- Martin -----
known operator names are listed. Package \AmSmath has
some more (see documentation).} This happens only for the known operator names, but creating a new
one is very easy with:
\begin{lstlisting}
\newcommand{\mysin}{\operatorname{mysin}}
\end{lstlisting}
Now \CMD{mysin} is also written in upright mode
$y=\mysin(x)$ and with some additional space before and behind.
It is obvious, that only those names can be defined as new operator
names which are not commands in another way. Instead of using the
new definition as an operator, it is also possible to use the text
mode. But it is better to have all operators of the same type, so that
changing the style will have an effect for all operators.
\mPar{\CMD{operatornamewithlimits}}%
The new defined operator names cannot have limits\index{Limits}, only
superscript/subscript is possible. \verb+amsopn.sty+ has an additional command
\CMD{operatornamewithlimits}\index{operatornamewithlimits@\textbackslash operatornamewithlimits},
which supports over/under limits like the one from \CMD{int}
or \CMD{sum}.
\mPar{\CMD{mathop}}
It is also possible to use the macro \verb+\mathop+ to declare anything
as operator, like
\[ \sideset{_1}{}{\mathop{\mathrm{B}}} \]
\begin{lstlisting}
\[ \sideset{_1}{}{\mathop{\mathrm{B}}} \]
\end{lstlisting}
With this definition it is possible to use \CMD{sideset} for a forgoing index, which
is only possible for an operator.
For a real \LaTeX{} definition have a look at section \vref{sec:ltxOperators}.
\section{Text in math mode}\label{sec:Text-in-math mode}
If you need complex structures between formulas, look also at section \ref{sec:verticalAlignment}.
\subsection{\CMD{text} command}
\mPar{%
\CMD{text}\\
\CMD{mbox}\\
\CMD{textnormal}\\
\CMD{mathrm}%
}%
This is the equivalent command to \CMD{mathrm}\index{mathrm@\textbackslash mathrm}
or \CMD{mbox}\index{mbox@\textbackslash mbox}
from the standard \LaTeX{} (section~\vref{sec:Text}) with the exception, that \CMD{mathrm}
always uses the roman font and \CMD{text} the actual one and that the font size is different
when used in super- and subscript.
For example: $\boxed{f(x)=x\quad\text{this was math}}$.
\bigskip
{\sffamily\huge
$A^{\mbox{text}}_{\mbox{text}}$\quad
$A^{\text{text}}_{\text{text}}$\quad
$A^{\textnormal{text}}_{\textnormal{text}}$\quad
$A^{\mathrm{text}}_{\mathrm{text}}$
}
\medskip
\begin{lstlisting}
$\boxed{f(x)=x\quad\text{this was math}}$
{\sffamily\huge
$A^{\mbox{text}}_{\mbox{text}}$\quad
$A^{\text{text}}_{\text{text}}$\quad
$A^{\textnormal{text}}_{\textnormal{text}}$\quad
$A^{\mathrm{text}}_{\mathrm{text}}$
}
\end{lstlisting}
The \verb+\text+ macro can be used at any place and can be in some cases a better
solution as \verb+\intertext+ (see section~\ref{subsec:intertext}).
\begin{flalign*}
&& 12(x-1) + 20(y-3) + 14(z-2) & = 0 &&\\
\text{and} && 6x + 10y + 7z & = 0 &&
\end{flalign*}
\begin{align}
&& 12(x-1) + 20(y-3) + 14(z-2) & = 0\\
\text{and} && 6x + 10y + 7z & = 0
\end{align}
\begin{lstlisting}
\begin{flalign*}
&& 12(x-1) + 20(y-3) + 14(z-2) & = 0 &&\\
\text{and} && 6x + 10y + 7z & = 0 &&
\end{flalign*}
\begin{align}
&& 12(x-1) + 20(y-3) + 14(z-2) & = 0\\
\text{and} && 6x + 10y + 7z & = 0
\end{align}
\end{lstlisting}
\subsection{\CMD{intertext} command}\label{subsec:intertext}
This is useful when you want to place some text between two parts
of math stuff without leaving the math mode, like the name
``intertext\index{intertext@\textbackslash intertext}'' %%% ----- Martin -----
says. For example we write the equation~\vref{eq:Beispiel-Integral}
with an additional command after the second line.
\[
\begin{split}
A_{1} & = \left| \int _{0}^{1}(f(x)-g(x))\,\mathrm{d}x\right| +\left| \int _{1}^{2}(g(x)-h(x))\,\mathrm{d}x\right| \\
& = \left| \int _{0}^{1}(x^{2}-3x)\,\mathrm{d}x\right| +\left| \int _{1}^{2}(x^{2}-5x+6)\,\mathrm{d}x\right| \\
\intertext{Now the limits of the integrals are used}
& = \left| \frac{x^{3}}{3}-\frac{3}{2}x^{2}\right| _{0}^{1}+\left| \frac{x^{3}}{3}-
\frac{5}{2}x^{2}+6x\right| _{1}^{2}\\
& = \left| \frac{1}{3}-\frac{3}{2}\right| +\left| \frac{8}{3}-\frac{20}{2}+12-
\left( \frac{1}{3}-\frac{5}{2}+6\right) \right| \\
& = \left| -\frac{7}{6}\right| +\left| \frac{14}{3}-\frac{23}{6}\right| =\frac{7}{6}+
\frac{5}{6}=2\, \textrm{FE}
\end{split}
\]
The code looks like:\\
\begin{lstlisting}[xleftmargin=-1cm,xrightmargin=-1.5cm]
\begin{equation}
\begin{split}
A_{1} & = \left| \int _{0}^{1}(f(x)-g(x))\,\mathrm{d}x\right| +\left| \int _{1}^{2}(g(x)-h(x))\,\mathrm{d}x\right| \\
& = \left| \int _{0}^{1}(x^{2}-3x)\,\mathrm{d}x\right| +\left| \int _{1}^{2}(x^{2}-5x+6)\,\mathrm{d}x\right| \\
\intertext{Now the limits of the integrals are used}
& = \left| \frac{x^{3}}{3}-\frac{3}{2}x^{2}\right| _{0}^{1}+\left| \frac{x^{3}}{3}-
\frac{5}{2}x^{2}+6x\right| _{1}^{2}\\
& = \left| \frac{1}{3}-\frac{3}{2}\right| +\left| \frac{8}{3}-\frac{20}{2}+12-
\left( \frac{1}{3}-\frac{5}{2}+6\right) \right| \\
& = \left| -\frac{7}{6}\right| +\left| \frac{14}{3}-\frac{23}{6}\right| =\frac{7}{6}+
\frac{5}{6}=2\, \textrm{FE}
\end{split}
\end{equation}
\end{lstlisting}
Writing very long text is possible by using a \verb+parbox+, see section~\vref{sec:Text} for %%% ----- Martin -----
an example with \verb+\textrm+, which behaves in the same way as \verb+\text+.
\section{Extensible arrows}
\mPar{%
\CMD{xrightarrow}\\
\CMD{xleftarrow}\\
\CMD{xmapsto}}To write something like $\xrightarrow[\text{below}]{\text{above the arrow}}$ you can use the following macro
\begin{verbatim}
$\xrightarrow[\text{below}]{\text{above the arrow}}$
\end{verbatim}
\index{Arrows}\index{Extensible arrows}
\noindent and the same with \verb|\xleftarrow|. You can define your own extensible arrow macros
if you need other than these two predefined ones. To get a doublelined extensible
arrow like \verb|$\Longleftrightarrow$| ($\Longleftrightarrow$) but with the same
behaviour as an extensible one, write in the preamble %%% ----- Martin -----
\begin{lstlisting}
\newcommand\xLongLeftRightArrow[2][]{%
\ext@arrow 0055{\LongLeftRightArrowfill@}{#1}{#2}}
\def\LongLeftRightArrowfill@{%
\arrowfill@\Leftarrow\Relbar\Rightarrow}
\newcommand\xlongleftrightarrow[2][]{%
\ext@arrow 0055{\longleftrightarrowfill@}{#1}{#2}}
\def\longleftrightarrowfill@{%
\arrowfill@\leftarrow\relbar\rightarrow}
\end{lstlisting}
The three parts \verb|\Leftarrow\Relbar\Rightarrow| define left|middle|right of the
arrow, where the middle part would be stretched in a way that the arrow is at least
as long as the text above and/or below it. This macro has one optional and one
standard parameter. The optional one is written below and the standard one above this %%% ----- Martin -----
arrow. Now we can write
\begin{verbatim}
$\xLongLeftRightArrow[\text{below}]{\text{above the arrow}}$
$\xlongleftrightarrow[\text{below}]{\text{above the arrow}}$
\end{verbatim}
\noindent to get $\xLongLeftRightArrow[\text{below}]{\text{above the arrow}}$ or
$\xlongleftrightarrow[\text{below}]{\text{above the arrow}}$.
The ``number'' $0055$ after \verb+\ext@arrow+ defines the position relative to the extended arrow and is
not a number but four parameters for additional space in the math unit \verb+mu+.
\index{mapstofill@\CMD{mapstofill}}
\makeatletter
\def\mapstofill@{%
\arrowfill@{\mapstochar\relbar}\relbar\rightarrow}
\renewcommand*\xmapsto[6][]{%
\ext@arrow #3#4#5#6\mapstofill@{#1}{#2}}
\makeatother
\begin{lstlisting}
\def\mapstofill@{%
\arrowfill@{\mapstochar\relbar}\relbar\rightarrow}
\newcommand*\xmapsto[2][]{%
\ext@arrow <four digits>\mapstofill@{#1}{#2}}
\end{lstlisting}
{\fboxsep=0pt
\verb+$\ext@arrow 0000$+\quad{\huge $\xmapsto[\fbox{under}]{\fbox{over}}0000$}
\verb+$\ext@arrow 9000$+\quad{\huge $\xmapsto[\fbox{under}]{\fbox{over}}9000$}
\verb+$\ext@arrow 0900$+\quad{\huge $\xmapsto[\fbox{under}]{\fbox{over}}0900$}
\verb+$\ext@arrow 0009$+\quad{\huge $\xmapsto[\fbox{under}]{\fbox{over}}0009$}
\verb+$\ext@arrow 0090$+\quad{\huge $\xmapsto[\fbox{under}]{\fbox{over}}0090$}
\verb+$\ext@arrow 0099$+\quad{\huge $\xmapsto[\fbox{under}]{\fbox{over}}0099$}
\verb+$\ext@arrow 9999$+\quad{\huge $\xmapsto[\fbox{under}]{\fbox{over}}9999$}
}
% $
\begin{itemize}
\item 1st digit: space left
\item 2nd digit: space right
\item 3rd digit: space left and right
\item 4th digit: space relativ to the tip of the ``arrow''
\end{itemize}
The two macros \verb+\xrightarrow+ and \verb+\xleftarrow+ are defined as:
\begin{lstlisting}
\newcommand{\xrightarrow}[2][]{\ext@arrow 0359\rightarrowfill@{#1}{#2}}
\newcommand{\xleftarrow}[2][]{\ext@arrow 3095\leftarrowfill@{#1}{#2}}
\end{lstlisting}
\section{Frames}\label{sec:ams-frames}
\mPar{\CMD{boxed}}%
\AmSmath knows the macro \verb|\boxed|\index{boxed@\textbackslash boxed} which can
be used for inline $a\boxed{b+c}$ and displayed math expressions:
\begin{align}
\boxed{f(x)=\int_1^{\infty}\frac{1}{x^2}\,\mathrm{d}x=1}
\end{align}
\begin{lstlisting}
\begin{align}
\boxed{f(x)=\int_1^{\infty}\frac{1}{x^2}\,\mathrm{d}x=1}
\end{align}
\end{lstlisting}
For coloured boxes use package \verb|empheq|. For an example see section \vref{sec:empheq}.
\section{Greek letters}\label{sec:greek-AMS}
\mPar{\CMD{pmb}\\\CMD{boldsymbol}}%
The \AmSmath package simulates a bold font for the greek letters by writing a greek %%% ----- Martin -----
character twice with a small kerning. This is done with the macro
\verb|\pmb{<letter>}|\index{pmb@\textbackslash pmb}\index{Bold greek letters}. The
\verb|\mathbf{<character>}| doesn't work with lower greek character. However,
using the \CMD{boldsymbol} macro from \AmSmath{} is the better way when the font
has a bold symbol.
\index{boldsymbol@\CMD{boldsymbol}}
Uppercase greek letters are by default in upright mode. \AmSmath\ supports also
such letters in italic mode with a preceeding \verb+var+ e.g., \verb+\varGamma+
\medskip
\begin{tabular}{ccc|cc}
\emph{letter} & \CMD{pmb}\verb+{letter}+ & \CMD{boldsymbol}\verb+{letter}+ & \emph{letter} & \emph{italic}\\
$\alpha$ & $\pmb{\alpha}$ & $\boldsymbol{\alpha}$ & $\Gamma$ & $\varGamma$\\
$\beta$ & $\pmb{\beta}$ & $\boldsymbol{\beta}$ & $\Delta$ & $\varDelta$\\
$\gamma$ & $\pmb{\gamma}$ & $\boldsymbol{\gamma}$ & $\Theta$ & $\varTheta$\\
$\delta$ & $\pmb{\delta}$ & $\boldsymbol{\delta}$ & $\Lambda$ & $\varLambda$\\
$\epsilon$ & $\pmb{\epsilon}$ & $\boldsymbol{\epsilon}$ & $\Xi$ & $\varXi$\\
$\varepsilon$ & $\pmb{\varepsilon}$ & $\boldsymbol{\varepsilon}$ & $\Pi$ & $\varPi$\\
$\zeta$ & $\pmb{\zeta}$ & $\boldsymbol{\zeta}$ & $\Sigma$ & $\varSigma$\\
$\eta$ & $\pmb{\eta}$ & $\boldsymbol{\eta}$ & $\Upsilon$ & $\varUpsilon$\\
$\theta$ & $\pmb{\theta}$ & $\boldsymbol{\theta}$ & $\Phi$ & $\varPhi$\\
$\vartheta$ & $\pmb{\vartheta}$ & $\boldsymbol{\vartheta}$ & $\Psi$ & $\varPsi$\\
$\iota$ & $\pmb{\iota}$ & $\boldsymbol{\iota}$ & $\Omega$ & $\varOmega$\\
$\ldots$ & $\ldots$ & $\ldots$
\end{tabular}
\section{Miscellaneous commands}\label{sec:misc-AMS}
There are several commands which can be used in math mode:\mPar{\CMD{overset}\\\CMD{underset}}
Some examples are shown in table~\vref{cap:Different-Mathcommands-supported-AMS}.
\begin{table}[htb]
\centering
{\renewcommand{\arraystretch}{2}
\begin{tabular}{r|>{\raggedright}p{2cm}}
\verb|$\underset{under}{baseline}$| \index{underset@\textbackslash underset} &
$\underset{under}{baseline}$\tabularnewline
\verb|$\overset{over}{baseline}$| \index{overset@\textbackslash overset} &
$\overset{over}{baseline}$\tabularnewline
\verb+\boldsymbol{\Omega}+ & $\boldsymbol{\Omega}$
\end{tabular}}
\caption{Different mathcommands}\label{cap:Different-Mathcommands-supported-AMS}
\end{table}
\CMD{underset} is a useful macro for having limits under non-operators
(see page~\pageref{sec:amsopn}). %%% ----- Martin -----
\CMD{boldsymbol} can be used for a math symbol that remains unaffected by
\CMD{mathbf} if the current math font set includes a bold version of that symbol.
\section{Problems with \texttt{amsmath}}
\AmSmath{} is an excellent package with some ``funny features''.
When using an \verb+align+ environment inside a \verb+gather+ environment, it should
be centered just like the other lines. This is only true, when there is a number/tag or
an additional ampersand:
%\begin{LTXexample}[pos=t]
\begin{gather*}
\begin{align*}
m_2 &= m_2' + m_2''\\
&= \frac{V_2'}{v_2'} + \frac{V_2''}{v_2''}
\end{align*}\\
\Rightarrow m_2 v_2' = V - V_2'' + V_2''\frac{v_2'}{v_2''}\\
\end{gather*}
\begin{gather*}
\begin{align*}
m_2 &= m_2' + m_2''\\
&= \frac{V_2'}{v_2'} + \frac{V_2''}{v_2''} & %<<<====
\end{align*}\\
\Rightarrow m_2 v_2' = V - V_2'' + V_2''\frac{v_2'}{v_2''}\\
\end{gather*}
%\end{LTXexample}
\begin{lstlisting}
\begin{gather*}
\begin{align*}
m_2 &= m_2' + m_2''\\
&= \frac{V_2'}{v_2'} + \frac{V_2''}{v_2''}
\end{align*}\\
\Rightarrow m_2 v_2' = V - V_2'' + V_2''\frac{v_2'}{v_2''}\\
\end{gather*}
\begin{gather*}
\begin{align*}
m_2 &= m_2' + m_2''\\
&= \frac{V_2'}{v_2'} + \frac{V_2''}{v_2''} & %<<<====
\end{align*}\\
\Rightarrow m_2 v_2' = V - V_2'' + V_2''\frac{v_2'}{v_2''}\\
\end{gather*}
\end{lstlisting}
This effect depends to the horizontal width, which is wrong in the first example,
in fact of a missing tag or number the right whitespace is cut, but the left one
is still there. The additional ampersand prevents \AmSmath{} to change the right
margin.
Another kind of curiousity is the following example, which depends to the
same problem of cutting whitespace only on one side.
\bigskip\noindent%
%\begin{LTXexample}[pos=t]
\fbox{%
\begin{minipage}{10cm}
\begin{align*}
a&=b \\ c&=d
\end{align*}
\end{minipage}}
\noindent\fbox{%
\begin{minipage}{10cm}
\noindent\begin{align*}
a&=b \\ c&=d
\end{align*}
\end{minipage}}
%\end{LTXexample}
\bigskip
\begin{lstlisting}
\bigskip\noindent\fbox{%
\begin{minipage}{10cm}
\begin{align*}
a&=b \\ c&=d
\end{align*}
\end{minipage}}
\noindent\fbox{%
\begin{minipage}{10cm}
\noindent\begin{align*}
a&=b \\ c&=d
\end{align*}
\end{minipage}}
\end{lstlisting}
\part{\TeX{} and math}
There is in general no need to use the \TeX{} macros, because the ones defined with \LaTeX{}
or with \AmSmath{} are much more useful. Nevertheless there may be situations, where someone %%% ----- Martin -----
has to use one of the \TeX{} macros or special \TeX{} math length. One can not expect, that all
macros work in the usual way, a lot of them are redefined by \LaTeX{} %%% ----- Martin -----
or \AmSmath{}. On the other hand some of these basic macros or length definitions are used
in the \TeX{} way, so it might be interesting to have all declared in a short way for some
information.
\section{Length registers}
\subsection{\CMD{abovedisplayshortskip}}
\cIndex{abovedisplayshortskip}A length with glue, see section~\ref{subsubsec:displayskip} for an example.
\subsection{\CMD{abovedisplayskip}}
\cIndex{abovedisplayskip}A length with glue, see section~\ref{subsubsec:displayskip} for an example.
\subsection{\CMD{belowdisplayshortskip}}
\cIndex{belowdisplayshortskip}A length with glue, see section~\ref{subsubsec:displayskip} for an example.
\subsection{\CMD{belowdisplayskip}}
\cIndex{belowdisplayskip}A length with glue, see section~\ref{subsubsec:displayskip} for an example.
\subsection{\CMD{delimiterfactor}}
\cIndex{delimiterfactor}The height of a delimiter is often not optimally calculated by \TeX{}. In some cases it is %%% ----- Martin -----
too short. With \verb+\delimiterfactor+ one can correct this height. The delimiterheight
is $<\textrm{calculated height}>\cdot <\textrm{\#1}>/1000$ where \verb+#1+ is the parameter of
\verb+\delimiterfactor+. The default value is $901$.
\begin{LTXexample}[width=0.4\linewidth]
\[
y = \left\{%
\begin{array}{ll}
x^2+2x &\textrm{if }x<0,\\
x^3 &\textrm{if }0\le x<1,\\
x^2+x &\textrm{if }1\le x<2,\\
x^3-x^2 &\textrm{if }2\le x.
\end{array}%
\right.
\]
\end{LTXexample}
\begin{LTXexample}[width=0.4\linewidth]
\[
\delimiterfactor=1500
y = \left\{%
\begin{array}{ll}
x^2+2x &\textrm{if }x<0,\\
x^3 &\textrm{if }0\le x<1,\\
x^2+x &\textrm{if }1\le x<2,\\
x^3-x^2 &\textrm{if }2\le x.
\end{array}%
\right.
\]
\end{LTXexample}
\subsection{\CMD{delimitershortfall}}
\cIndex{delimitershortfall}Additionally to the forgoing \verb+\delimiterfactor+ one can modify the height of the
delimiter with another value. \TeX{} makes the delimiter larger than the values of
$<\textrm{calculated height}>\cdot <\textrm{delimiterfactor}>/1000$ and $<\textrm{calculated height}>-<\textrm{delimitershortfall}>$. This makes it possible to always get different heights %%% ----- Martin -----
of a sequence of delimiters.
\begin{LTXexample}[width=0.3\linewidth]
$x\cdot\left(\left(x^2-y^2\right)-3\right)$\\[7pt]
$
\delimitershortfall-1pt
x\cdot\left(\left(x^2-y^2\right)-3\right)$
\end{LTXexample}
\begin{LTXexample}[width=0.2\linewidth]
$\left(\left(\left(A\right)\right)\right)$\\[7pt]
$\delimitershortfall-1pt
\left(\left(\left(A\right)\right)\right)$
\end{LTXexample}
\subsection{\CMD{displayindent}}
\cIndex{displayindent}This is the left shift amount of a line holding displayed equation.
By default it is $0pt$ but
gets the value of an indented paragraph when there is an environment like the quotation one.\index{Indentation}
The following formula is typeset in the usual way without modifying anything.
\[ f(x) = \int \frac{\sin x}{x}\,\mathrm{d}x \]
Now we start a quotation environment which sets \CIndex{labelwidth} to new values for a
greater %%% ----- Martin -----
left margin.
\begin{itemize}
\item The following formula is typeset in the usual way without modifying anything.
\[ f(x) = \int \frac{\sin x}{x}\,\mathrm{d}x \]
\item Now we write the same equation, but now with modifying \Index{displayindent}, it is set to
the negative \verb+\leftskip+:
\[
\displayindent=-\labelwidth
f(x) = \int \frac{\sin x}{x}\,\mathrm{d}x
\]
\end{itemize}
\begin{lstlisting}
\[
\displayindent=-\leftskip
f(x) = \int \frac{\sin x}{x}\,\mathrm{d}x
\]
\end{lstlisting}
\subsection{\CMD{displaywidth}}
\cIndex{displaywidth}The width of the line holding a displayed equation, which is by default
\verb+\linewidth+. In the
second example the formula is centered for a display width of \verb+0.5\linewidth+.
\[ f(x) = \int \frac{\sin x}{x}\,\mathrm{d}x \]
\[
\displaywidth=0.5\linewidth
f(x) = \int \frac{\sin x}{x}\,\mathrm{d}x
\]
\begin{lstlisting}
\[ f(x) = \int \frac{\sin x}{x}\,\mathrm{d}x \]
\[
\displaywidth=0.5\linewidth
f(x) = \int \frac{\sin x}{x}\,\mathrm{d}x
\]
\end{lstlisting}
\subsection{\CMD{mathsurround}}
\cIndex{mathsurround}Extra space added when switching in and out of the
inline math mode (see section~\ref{subsec:whitespace}).
\subsection{\CMD{medmuskip}}
\cIndex{medmuskip}See section~\ref{subsec:mathskip} for an example.
\subsection{\CMD{mkern}}
\cIndex{mkern}Similiar to \verb+\kern+, but adds a math kern item to the current math list. Length must be a math unit.
\subsection{\CMD{mskip}}
\cIndex{mskip}Similiar to \verb+\skip+, but adds math glue to the current math list. Length must be a math unit.
\subsection{\CMD{muskip}}
\cIndex{muskip}Assigns a length with a math unit to one of the 256 \verb+\muskip+ register.
\subsection{\CMD{muskipdef}}
\cIndex{muskipdef}Defines a symbolic name for a \verb+\muskip+ register.
\subsection{\CMD{nonscript}}
\cIndex{nonscript}Ignores immediately following glue or kern in script and
scriptscript styles, which makes a redefinition of \verb+\mathchoice+ superfluous.
\subsection{\CMD{nulldelimiterspace}}
\cIndex{nulldelimiterspace}This is the width of a null or missing delimiter,
\eg \verb+\right.+ or for the left one.
\subsection{\CMD{predisplaysize}}
\cIndex{predisplaystyle}Is the effective width of the line preceeding a displayed equation, whether
\verb+\abovedisplayskip+ or \verb+abovedisplayshortskip+ is used for the vertical skip.
\subsection{\CMD{scriptspace}}
\cIndex{scriptspace}The space inserted after an exponent or index, predefined as \verb+\scriptspace=0.5pt+ %%% ----- Martin -----
\subsection{\CMD{thickmuskip}}
\cIndex{thickmuskip}See section~\ref{subsec:mathskip}.
\subsection{\CMD{thinmuskip}}
\cIndex{thinmuskip}The short version for positive skip is defined as \verb+\def\,{\mskip\thinmuskip}+ and the one
for a negative skip as \verb+\def\!{\mskip-\thinmuskip}+ (see also Section~\ref{subsec:mathskip}).
\begin{LTXexample}[width=0.35\linewidth]
$\sqrt 2 x$ -- $\sqrt 2\,x$\\
$\sqrt{\log x}$ -- $\sqrt{\,\log x}$\\
$P\left({1/\sqrt n}\right)$ -- $P\left({1/ \sqrt n}\,\right)$\\[8pt]
$[0,1)$ -- $[\,0,1)$\\
$x^2/2$ -- $x^2\!/2$\\
\end{LTXexample}
\begin{LTXexample}[width=0.35\linewidth]
\[\int\int_D \mathrm{d}x\mathrm{d}y \quad
\int\!\int_D \mathrm{d}x\,\mathrm{d}y\]
\[\int\!\!\int_D \mathrm{d}x\,\,\mathrm{d}y \quad
\int\!\!\!\int_D \mathrm{d}x\,\,\,\mathrm{d}y\]
\[\int\!\!\!\!\int_D \mathrm{d}x\,\,\,\,\mathrm{d}y \quad
\int\!\!\!\!\!\int_D \mathrm{d}x\,\,\,\,\,\mathrm{d}y\]
\[\int\!\!\!\int_D \mathrm{d}x\,\mathrm{d}y\]
\end{LTXexample}
\subsection{\CMD{medmuskip}}
See section~\ref{subsec:mathskip}.
\section{Math font macros}
\subsection{\CMD{delcode}}
\cIndex{delcode}Each character has not only a \CIndex{catcode} and \CIndex{mathcode} but also
a \verb+\delcode+
which defines for a single chracter how it should look when used as a math delimiter.
\subsection{\CMD{delimiter}}
\cIndex{delimiter}Every character can be declared as a delimiter, but \TeX{}
must know which characters
should be used for the default and the big size. For \LaTeX{}
the macro \CIndex{DeclareMathDelimiter} should be used (see section~\vref{subsec:delim}).
In the following example \verb+\tdela+ is the character $0x22$ ($\uparrow$) from
font number $2$ (\verb+csmy+) and character $0x78$ from font number $3$ (\verb+cmex+)
for the big version. \verb+\tdelb+ is the same vice versa ($\downarrow$).
\begin{LTXexample}[width=0.35\linewidth]
\def\tdela{\delimiter"4222378\relax}
\def\tdelb{\delimiter"5223379\relax}
$\tdela x-y\tdelb(x+y)=x^2-y^2$
\[\tdela\sum_{n=0}^\infty {1\over2^n}\tdelb^2 = 4\]
\[\left\tdela\sum_{n=0}^\infty {1\over2^n}\right\tdelb^2 = 4\]
\end{LTXexample}
\subsection{\CMD{displaystyle}}
\cIndex{displaystyle}See section~\ref{sec:Styles} for an example.
\subsection{\CMD{fam}}
\cIndex{fam}When \TeX{} switches into the math mode, it typesets everything using one of the 16
possible families of fonts. \verb+\fam+ is an internal register where other macros can check which font is the actual one. At the beginning \TeX{} starts with \verb+\fam=-1+.
\bigskip
\noindent
\includegraphics{family}
\iffalse
\begin{center}
\begin{tabular}{ll}
\verb+\fam=-1+ & $\fam=-1 123abcABC\alpha\beta\gamma$\\
\verb+\fam=0+ & $\fam=0 123abcABC\alpha\beta\gamma$\\
\verb+\fam=1+ & $\fam=1 123abcABC\alpha\beta\gamma$\\
\verb+\fam=2+ & $\fam=2 123abcABC\alpha\beta\gamma$\\
\verb+\fam=3+ & $\fam=3 123abcABC\alpha\beta\gamma$\\
\verb+\fam=4+ & $\fam=4 123abcABC\alpha\beta\gamma$\\
\verb+\fam=5+ & $\fam=5 123abcABC\alpha\beta\gamma$
\end{tabular}
\end{center}
\begin{LTXexample}[width=0.3\linewidth]
$\mathrm{123abcABC\alpha\beta\gamma (\the\fam)}$\\[5pt]
$\mathbf{123abcABC\alpha\beta\gamma (\the\fam)}$\\[5pt]
$\mathit{123abcABC\alpha\beta\gamma (\the\fam)}$\\[5pt]
$\mathtt{123abcABC\alpha\beta\gamma (\the\fam)}$\\[5pt]
$\mathsf{123abcABC\alpha\beta\gamma (\the\fam)}$\\[5pt]
$\mathnormal{123abcABC\alpha\beta\gamma (\the\fam)}$
\end{LTXexample}
\fi
\subsection{\CMD{mathaccent}}
\cIndex{mathaccent}Requires three parameter as one number, the class, the font family and the character.
\begin{LTXexample}[width=0.3\linewidth]
\def\dA{\mathaccent"7015\relax}
{\Large $\dA{A}$}
\end{LTXexample}
\subsection{\CMD{mathbin}}
\cIndex{mathbin}Declares a following character as a binary symbol with another
spacing before and behind such a symbol.
\begin{LTXexample}[width=0.3\linewidth]
{\Large
$a|b \quad a\mathbin| b$}
\end{LTXexample}
\subsection{\CMD{mathchar}}
\cIndex{mathchar}Declares a math character by three integer numbers as Parameters, giving its class, %%% ----- Martin -----
font family, and font position. In the following example \verb+\mathchar+ defines a
character of class 1 (big operators), font family 3 (math extension font) and number
58 (big sum character).
\begin{LTXexample}[width=0.3\linewidth]
{\Large
$a\sum\limits_{i=1}^{\infty} b \quad
a\mathchar"1358\limits_{i=1}^{\infty} b$}
\end{LTXexample}
\subsection{\CMD{mathchardef}}
\cIndex{mathchardef}This is in principle the same as \CIndex{mathchar},
it only allows to make such definitions permanent.
\begin{LTXexample}[width=0.25\linewidth]
\bgroup
\mathchardef\sum="1358
$a\sum\limits_{i=1}^{\infty}\sqrt{i+1}$\\[5pt]
\egroup
$a\sum\limits_{i=1}^{\infty}\sqrt{i+1}$
\end{LTXexample}
\subsection{\CMD{mathchoice}}
\cIndex{mathchoice}Specifies specific subformula sizes for the 4 main styles:
\CIndex{displaystyle} -- \CIndex{textstyle} --
\CIndex{scriptstyle} -- \CIndex{scriptscriptstyle}.
\begin{LTXexample}[width=0.15\linewidth]
\Large
\def\myRule{{%
\color{red}%
\mathchoice{\rule{2pt}{20pt}}{\rule{1pt}{10pt}}%
{\rule{0.5pt}{5pt}}{\rule{0.25pt}{2.5pt}}%
\mkern2mu}}
$\myRule\sum\limits_{\myRule i=1}^{\myRule\infty}%
\myRule\frac{\myRule\sqrt{\myRule i+1}}{\myRule i^2}$
\end{LTXexample}
\subsection{\CMD{mathclose}}\label{subsec:mathclose}
\cIndex{mathclose}Assigns class 5 (closing character) to the following
parameter, which can hold a single character or a subformula.
\begin{LTXexample}[width=0.2\linewidth]
{\large
$A:\frac{B}{C}:D$\\[5pt]
$A\mathopen:\frac{B}{C}\mathclose: D $}
\end{LTXexample}
\subsection{\CMD{mathcode}}
\cIndex{mathcode}A math font is far different from a text font. A lot of the characters has to be defined with
\verb+\mathcode+, which defines the character with its class, font family and character number, \eg
\verb+\mathcode`\<="313C+. It defines the character ``<''{} as a realtion symbol (class 3) from
the font family 1 and the character number 0x3C, which is 60 decimal.
\subsection{\CMD{mathop}}
\cIndex{mathop}Assigns class 1 (large operator) to the parameter, which can be a single character or a subformula.
\begin{LTXexample}[width=0.2\linewidth]
\[ A_{i=1}^{\infty} \]
\[ \mathop{A}_{i=1}^{\infty} \]
\end{LTXexample}
\subsection{\CMD{mathopen}}
\cIndex{mathopen}Vice versa to \verb+\mathclose+ (see section~\ref{subsec:mathclose}).
\subsection{\CMD{mathord}}
\cIndex{mathord}Assigns class 0 (ordinary character) to the following parameter, which can be a single character
or a subformula.
\begin{LTXexample}[width=0.2\linewidth]
{\large
$y = f(x)$\\[5pt]
$y \mathord= f(x)$}
\end{LTXexample}
\subsection{\CMD{mathpunct}}
\cIndex{mathpunct}Assigns class 6 (punctuation) to the following parameter, which can be a single character
or a subformula (see section~\ref{subsec:dot-comma} for an example).
\subsection{\CMD{mathrel}}
\cIndex{mathrel}Assigns class 3 (relation) to the following parameter, which can be a single character
or a subformula.
\begin{LTXexample}[width=0.25\linewidth]
{\large
$x_1 o x_2 o x_3$\\[5pt]
$x_1\mathrel o x_2\mathrel o x_3$}
\end{LTXexample}
\subsection{\CMD{scriptfont}}
\cIndex{scriptfont}Specifies the scriptstyle font (used for super/subscript) for a family.
\begin{LTXexample}[width=0.25\linewidth]
$A_1$
\font\tenxii=cmr12
\scriptfont0=\tenxii
$A_1$
\end{LTXexample}
\subsection{\CMD{scriptscriptfont}}
\cIndex{scriptscriptfont}Specifies the scriptscriptstyle font for a family.
\subsection{\CMD{scriptscriptstyle}}
\cIndex{scriptscriptstyle}Selects scriptscript style for the following characters.
\subsection{\CMD{scriptstyle}}
\cIndex{scriptstyle}Selects script style for the following characters.
\subsection{\CMD{skew}}
\cIndex{skew}Especially for italic characters double accents are often misplaced. \verb+\skew+ has three arguments
\begin{description}
\item[horizontal shift:] A value in math units for the additional shift of the accent.
\item[the accent:] The symbol which is placed above the character.
\item[the character:] This is in general a single character, but can also include itself an accent.
\end{description}
\AmSmath\ redefines the setting of double accents. This is the reason why there are only a few
cases where someone has to use \verb+\skew+ when the package \PIndex{amsmath} is loaded, like
in this document.
\begin{LTXexample}[width=0.2\linewidth]
\large
$\tilde i$ \qquad $\tilde{A}$\\[5pt]
$\skew{3}{\tilde}{i}$ \qquad $\skew{7}{\tilde}{A}$
\end{LTXexample}
\subsection{\CMD{skewchar}}
\cIndex{skewchar}Is -1 or the character (reference symbol) used to fine-tune the positioning of math accents.
\subsection{\CMD{textfont}}
\cIndex{textfont}Specifies the text font for a family.
\subsection{\CMD{textstyle}}
\cIndex{textstyle}Selects the text style for the following characters.
\section{Math macros}
\subsection{\CMD{above}}
\cIndex{above}
\begin{LTXexample}[width=0.2\linewidth]
$a\above0pt b$\\[8pt]
${a\above1pt b}$\\[8pt]
${a\above2.5pt b}$\\[8pt]
$\displaystyle{a\above0pt b}$
\end{LTXexample}
\subsection{\CMD{abovewithdelims}}
\cIndex{abovewithdelims}
\begin{LTXexample}[width=0.2\linewidth]
$a\abovewithdelims()0pt b$\\[8pt]
\def\fdelimA{\abovewithdelims\{)1.0pt}
${a\fdelimA b}$\\[8pt]
\def\fdelimB{\abovewithdelims[]2.0pt}
${a\fdelimB b}$\\[8pt]
\def\fdelimC{\abovewithdelims\{.0pt}
$\displaystyle{a\fdelimC b}$
\end{LTXexample}
\subsection{\CMD{atop}}
\cIndex{atop}
\begin{LTXexample}[width=0.2\linewidth]
$a\atop b$\\[8pt]
$({n \atop k}) = {n!\above1pt k!(n-k)!}$\\[8pt]
$\displaystyle{a\atop b}$
\end{LTXexample}
\subsection{\CMD{atopwithdelims}}
\cIndex{atopwithdelims}
\begin{LTXexample}[width=0.2\linewidth]
$a\atopwithdelims() b$\\[8pt]
${n \atopwithdelims() k} = {n!\above1pt k!(n-k)!}$\\[8pt]
$\displaystyle{a\atopwithdelims\{. b}$
\end{LTXexample}
\subsection{\CMD{displaylimits}}
\cIndex{displaylimits}Resets the conventions for using limits with operators to the standard for the used environment.
\subsection{\CMD{eqno}}\label{subsec:eqno}
\cIndex{eqno}Puts an equation number at the right margin, the parameter can hold anything. \verb+\eqno+ places
only the parameter, but doesn't increase any equation counter.
\begin{LTXexample}[width=0.5\linewidth]
\[ y=f(x) \eqno{(A12)} \]
\end{LTXexample}
\subsection{\CMD{everydisplay}}
\cIndex{everydisplay}Inserts the parameter at the start of every switch to display math mode.
\begin{LTXexample}[width=0.4\linewidth]
\everydisplay{\color{red}
}
\[ f(x) = \int \frac{\sin x}{x}\,\mathrm{d}x \]
\[ g(x) = \int \frac{\sin^2 x}{x^2}\,\mathrm{d}x \]
\end{LTXexample}
\subsection{\CMD{everymath}}
\cIndex{everymath}Same as \CIndex{everydisplay}, but now for the inline mode.
In the following example
the displaystyle is used (besides using color red) for every inline math expression.
\bgroup
\begin{LTXexample}[width=0.45\linewidth]
\everymath{\color{red}%
\displaystyle}
\[ f(x) = \int \frac{\sin x}{x}\,\mathrm{d}x \]
Instead of $\frac{\sin x}{x}$
now with $\frac{\cos x}{x}$:
\[ g(x) = \int \frac{\cos x}{x}\,\mathrm{d}x \]
\end{LTXexample}
\egroup
Pay attention for side effects on footnotes and other macros which use the math mode for superscript
and other math related modes. In this case you'll get the footnotes also in red.
\subsection{\CMD{left}}
\cIndex{left}\TeX{} calculates the size of the following delimiter needed at the left side of a formula.
Requires an additional \verb+right+.
\subsection{\CMD{leqno}}
\cIndex{leqno}Vice versa to \verb+\eqno+ (see section~\vref{subsec:eqno}).
\subsection{\CMD{limits}}
\cIndex{limits}Typesets limits above and/or below operators (see section~\vref{sec:limits}).
\subsection{\CMD{mathinner}}
\cIndex{mathinner}Defines the following parameter as subformula.
\subsection{\CMD{nolimits}}
\cIndex{nolimits}The opposite of \CIndex{limits}, instead of above/below limits are placed to the right of large
operators (class 1).
\subsection{\CMD{over}}
\cIndex{over}Is equivalent to the fraction macro of \LaTeX{} and equivalent to the
\verb+\overwithdelims+, see section~\vref{subsec:overwithdelims}.
\begin{LTXexample}[width=0.2\linewidth]
$ {a\over b} \qquad {{m\over n}\over{a+b}} $
\[ {m\over n}\over{a+b} \]
\end{LTXexample}
\subsection{\CMD{overline}}
\cIndex{overline}Puts a line over the following character or subformula and has the same problems with different
heights as underlines (see section~\ref{subsec:underline}).
\begin{LTXexample}[width=0.2\linewidth]
$\overline{x}+\overline{y}=\overline{z}$\\
\let\ol\overline
$ \ol{x} + \ol{A} = \ol{z} $\\[5pt]
\def\yPh{\vphantom{A}}
$ \ol{x\yPh} + \ol{A} = \ol{z\yPh} $
\end{LTXexample}
\subsection{\CMD{overwithdelims}}\label{subsec:overwithdelims}
\cIndex{overwithdelims}Is a generalized fraction command with preset fraction bar thickness. %%% ----- Martin -----
\begin{LTXexample}[width=0.25\linewidth]
$ {a\overwithdelims() b} \qquad {{m\over n}\overwithdelims[]{a+b}} $
\[ {m\over n}\overwithdelims\{.{a+b} \]
\end{LTXexample}
\subsection{\CMD{radical}}
\cIndex{radical}Makes a radical atom from the delimiter (27-bit number) and the math field.
\begin{LTXexample}[width=0.2\linewidth]
\def\mySqrt{\radical"0270371\relax}
$ \mySqrt{\frac{1}{7}} $\\[5pt]
\def\mySqrt{\radical"0270372\relax}
$ \mySqrt{\frac{1}{7}} $\\[5pt]
\def\mySqrt{\radical"0270373\relax}
$ \mySqrt{\frac{1}{7}} $\\[5pt]
\def\mySqrt{\radical"0270374\relax}
$ \mySqrt{\frac{1}{7}} $\\[5pt]
\end{LTXexample}
\subsection{\CMD{right}}
\cIndex{right}Opposite to \verb+\left+, makes \TeX{} calculate the size of the
delimiter needed at the right of a formula.
\subsection{\CMD{underline}}\label{subsec:underline}
\cIndex{underline}When there is a combination of variables with and without an index, the underlines are typeset %%% ----- Martin -----
with a different depth. Using \verb+\vphantom+ in this case is a good choice.
\begin{LTXexample}[width=0.2\linewidth]
$\underline{x}+\underline{y}=\underline{z}$\\
\let\ul\underline
\def\yPh{\vphantom{y}}
$ \ul{x\yPh} + \ul{y} = \ul{z\yPh} $\\
$ \ul{x_1} + \ul{y_2} = \ul{z_3} $
\end{LTXexample}
\subsection{\CMD{vcenter}}
\cIndex{vcenter}Centers vertical material with respect to the axis.
\section{Math penalties}
\subsection{\CMD{binoppenalty}}
\cIndex{binoppenalty}A penalty for breaking math expressions between lines in a paragraph. TeX breaks lines only
when the binary symbol is not the last one and when the penalty is below 10,000.
\subsection{\CMD{displaywidowpenalty}}
\cIndex{displaywidowpenalty}The penalty which is added after the penultimate line immediately preceeding a display math formula.
\subsection{\CMD{postdisplaypenalty}}
\cIndex{postdisplaypenalty}Is added immediately after a math display ends.
\subsection{\CMD{predisplaypenalty}}
\cIndex{predisplaypenalty}Is added immediately before a math display starts.
\subsection{\CMD{relpenalty}}
\cIndex{relpenalty}The penalty for a line break after a relation symbol (if a break is possible).
\part{Other packages}
The following sections are not a replacement for the package documentation!
\section{List of available math packages}
\markboth{Math packages}{Math packages}
\begin{center}
\noindent
\begin{tabular}{llll}
\href{http://www.dante.de/CTAN/help/Catalogue/entries/accents.html}{accents}&
\href{http://www.dante.de/CTAN/help/Catalogue/entries/alphalph.html}{alphalph}&
\href{http://www.dante.de/CTAN/help/Catalogue/entries/amsart.html}{amsart}&
\href{http://www.dante.de/CTAN/help/Catalogue/entries/amsbook.html}{amsbook}\\
\href{http://www.dante.de/CTAN//help/Catalogue/entries/amsbsy.html}{amsbsy}&
\href{http://www.dante.de/CTAN//help/Catalogue/entries/amscd.html}{amscd}&
\href{http://www.dante.de/CTAN//help/Catalogue/entries/amscls.html}{amscls}&
\href{http://www.dante.de/CTAN//help/Catalogue/entries/amsfonts.html}{amsfonts}\\
\href{http://www.dante.de/CTAN//help/Catalogue/entries/amslatex.html}{amslatex}&
\href{http://www.dante.de/CTAN//help/Catalogue/entries/amsltx11.html}{amsltx11}&
\href{http://www.dante.de/CTAN//help/Catalogue/entries/amsmath.html}{amsmath}&
\href{http://www.dante.de/CTAN//help/Catalogue/entries/amsppt.html}{amsppt}\\
\href{http://www.dante.de/CTAN//help/Catalogue/entries/amsppt1.html}{amsppt1}&
\href{http://www.dante.de/CTAN//help/Catalogue/entries/amsproc.html}{amsproc}&
\href{http://www.dante.de/CTAN//help/Catalogue/entries/amssym.html}{amssym (plain TeX)}&
\href{http://www.dante.de/CTAN//help/Catalogue/entries/amssymb.html}{amssymb (LaTeX)}\\
\href{http://www.dante.de/CTAN//help/Catalogue/entries/amstex.html}{amstex (Plain TeX)}&
\href{http://www.dante.de/CTAN//help/Catalogue/entries/amstext.html}{amstext}&
\href{http://www.dante.de/CTAN//help/Catalogue/entries/amsthm.html}{amsthm}&
\href{http://www.dante.de/CTAN//help/Catalogue/entries/bez123.html}{bez123}\\
\href{http://www.dante.de/CTAN//help/Catalogue/entries/bitfield.html}{bitfield}&
\href{http://www.dante.de/CTAN//help/Catalogue/entries/brclc.html}{brclc}&
\href{http://www.dante.de/CTAN//help/Catalogue/entries/breqn.html}{breqn}&
\href{http://www.dante.de/CTAN//help/Catalogue/entries/cancel.html}{cancel}\\
\href{http://www.dante.de/CTAN//help/Catalogue/entries/cases.html}{cases}&
\href{http://www.dante.de/CTAN//help/Catalogue/entries/comma.html}{comma}&
\href{http://www.dante.de/CTAN//help/Catalogue/entries/datenumber.html}{datenumber}&
\href{http://www.dante.de/CTAN//help/Catalogue/entries/diagxy.html}{diagxy}\\
\href{http://www.dante.de/CTAN//help/Catalogue/entries/doublestroke.html}{doublestroke}&
\href{http://www.dante.de/CTAN//help/Catalogue/entries/easyeqn.html}{easyeqn}&
\href{http://www.dante.de/CTAN//help/Catalogue/entries/easybmat.html}{easybmat}&
\href{http://www.dante.de/CTAN//help/Catalogue/entries/easymat.html}{easymat}\\
\href{http://www.dante.de/CTAN//help/Catalogue/entries/eqnarray.html}{eqnarray}&
\href{http://www.dante.de/CTAN//help/Catalogue/entries/esvect.html}{esvect}&
\href{http://www.dante.de/CTAN//help/Catalogue/entries/fixmath.html}{fixmath}&
\href{http://www.dante.de/CTAN//help/Catalogue/entries/fltpoint.html}{ftlpoint}\\
\href{http://www.dante.de/CTAN//help/Catalogue/entries/icomma.html}{icomma}&
\href{http://www.dante.de/CTAN//help/Catalogue/entries/leftidx.html}{leftidx}&
\href{http://www.dante.de/CTAN//help/Catalogue/entries/mathdots.html}{mathdots}&
\href{http://www.dante.de/CTAN//help/Catalogue/entries/mathtools.html}{mathtools}\\
\href{http://www.dante.de/CTAN//help/Catalogue/entries/mathematica.html}{mathematica}&
\href{http://www.dante.de/CTAN//help/Catalogue/entries/mil3.html}{mil3}&
\href{http://www.dante.de/CTAN//help/Catalogue/entries/mtbe.html}{mtbe}&
\href{http://www.dante.de/CTAN//help/Catalogue/entries/nath.html}{Nath}\\
\href{http://www.dante.de/CTAN//help/Catalogue/entries/numprint.html}{numprint}&
\href{http://www.dante.de/CTAN//help/Catalogue/entries/random.html}{random}&
\href{http://www.dante.de/CTAN//help/Catalogue/entries/romannum.html}{romannum}&
\href{http://www.dante.de/CTAN//help/Catalogue/entries/texaide.html}{TeXaide}
\end{tabular}
\end{center}
The following examples depend on the listed versions of the packages: %%% ----- Martin -----
{\small
\begin{verbatim}
amsopn.sty 1999/12/14 v2.01 operator names
bm.sty 1999/07/05 v1.0g Bold Symbol Support (DPC/FMi)
empheq.sty 2007/12/03 v2.12 Emphasizing equations (MH)
amscd.sty 1999/11/29 v2.0
accents.sty 2000/08/06 v1.2 Math Accent Tools
framed.sty 2007/10/04 v 0.95: framed or shaded text with page breaks
pstricks.sty 2004/05/06 v0.2k LaTeX wrapper for `PSTricks' (RN,HV)
pstricks.tex 2003/03/07 v97 patch 15 `PSTricks' (tvz)
pst-node.tex 2008/11/26 v1.01 PSTricks package for nodes (tvz,hv)
delarray.sty 1994/03/14 v1.01 array delimiter package (DPC)
xypic.sty 1999/02/16 Xy-pic version 3.7
exscale.eps Graphic file (type veps)
\end{verbatim}
}
\subsection{\texttt{accents}}\label{sec:package-accent}
If you want to write for example an underlined M, then you can do it by %%% ----- Martin -----
\medskip
\begin{tabular}{ll}
\verb|\underline{$M$}| & \underline{$M$}\\
\verb|\underbar{$M$}| & \underbar{$M$}\\
\verb|\underaccent{\bar}{M}| & $\underaccent{\bar}{M}$
\end{tabular}
\medskip
As seen, there is no difference between \CMD{underline} and \CMD{underbar}. For %%% ----- Martin -----
some reasons it may be better to use the \PIndex{accent} package with the
\CMD{underaccents} macro.
\subsection{\texttt{amscd} -- commutative diagrams}
The \PIndex{amscd} package is part of the \AmSmath bundle
or available at CTAN%
\footnote{\href{http://www.ctan.org/tex-archive/macros/latex/required/amslatex/math/amscd.dtx}%
{CTAN://macros/latex/required/amslatex/math/amscd.dtx}} and has no options for the
\verb|\usepackage| command.
\texttt{amscd} does not support diagonal arrows but is much %%% ----- Martin -----
easier to handle than the complex \PIndex{pstricks} package or
the \PIndex{xypic} package. On the other hand simple diagrams
can be written with the \UIndex{array} or look at \cite{taylor00}.
\[
\begin{CD}
R\times S\times T @>\text{restriction}>> S\times T \\
@VprojVV @VVprojV \\
R\times S @<<\text{inclusion}< S
\end{CD}
\]
\begin{lstlisting}
\[
\begin{CD}
R\times S\times T @>\text{restriction}>> S\times T \\
@VprojVV @VVprojV \\
R\times S @<<\text{inclusion}< S
\end{CD}
\]
\end{lstlisting}
\subsection{\texttt{amsopn}}\label{sec:amsopn}
With the \PIndex{amsopn} package it is very easy to declare new math operators, which are written in
upright mode:
$\underset{s=p}{Res}\quad\text{versus}\quad\underset{s=p}{\Res}$
\medskip
\begin{lstlisting}
\documentclass[10pt]{article}
\usepackage{amsmath}
\usepackage{amsopn}
\DeclareMathOperator{\Res}{Res}
\begin{document}
$\underset{s=p}{Res}\quad\underset{s=p}{\Res}$
\end{document}
\end{lstlisting}
Table~\ref{tab:amsopn} shows the predefined operatornames of \verb+amsopn+.
\begin{table}[htb]
\centering
\begin{tabular}{llllll}
\verb+\arccos+ & $\arccos$ & \verb+\arcsin+ & $\arcsin$ & \verb+\arctan+ & $\arctan$\\
\verb+\arg+ & $\arg$ & \verb+\cos+ & $\cos$ & \verb+\cosh+ & $\cosh$\\
\verb+\cot+ & $\cot$ & \verb+\coth+ & $\coth$ & \verb+\csc+ & $\csc$\\
\verb+\deg+ & $\deg$ & \verb+\det+ & $\det$ & \verb+\dim+ & $\dim$\\
\verb+\exp+ & $\exp$ & \verb+\gcd+ & $\gcd$ & \verb+\hom+ & $\hom$\\
\verb+\inf+ & $\inf$ & \verb+\injlim+ & $\injlim$ & \verb+\ker+ & $\ker$\\
\verb+\lg+ & $\lg$ & \verb+\lim+ & $\lim$ & \verb+\liminf+ & $\liminf$\\
\verb+\limsup+ & $\limsup$ & \verb+\ln+ & $\ln$ & \verb+\log+ & $\log$\\
\verb+\max+ & $\max$ & \verb+\min+ & $\min$ & \verb+\Pr+ & $\Pr$\\
\verb+\projlim+& $\projlim$& \verb+\sec+ & $\sec$ & \verb+\sin+ & $\sin$\\
\verb+\sinh+ & $\sinh$ & \verb+\sup+ & $\sup$ & \verb+\tan+ & $\tan$\\
\verb+\tanh+ & $\tanh$
\end{tabular}
\caption{The predefined operators of \texttt{amsopn.sty}}\label{tab:amsopn}
\end{table}
\subsection{\texttt{bigdel}}\label{sec:bigdelim}
This is a very useful package together with the \PIndex{multirow} package.
In the following example we need additional parentheses for a different
number of rows. This is also possible with the \UIndex{array},
but not as easy as with the \PIndex{bigdelim} package. The trick is that you need one
separate column for a big delimiter, but with empty cells in all rows, which
the delimiter spans.
\[
\begin{pmatrix}
& x_{11} & x_{12} & \dots & x_{1p} & \rdelim\}{4}{3cm}[some text]\\
\ldelim[{5}{1cm}[text] & x_{21} & x_{22} & \dots & x_{2p} \\
& \vdots\\
& x_{n_1 1}& x_{n_1 2} & \dots & x_{n_1 p}\\
& x_{n_1+1,1}&x_{n_1+1,2} & \dots & x_{n_1+1, p} &
\rdelim\}{3}{3cm}[some more text]\\
& \vdots\\
& x_{n_1+n_2, 1} & x_{n_1+n_2,2} & \dots & x_{n_1+n_2,p}\\
& \vdots \\
\end{pmatrix}
\]
\begin{lstlisting}[xleftmargin=-1cm,xrightmargin=-1.5cm]
\[
\begin{pmatrix}
& x_{11} & x_{12} & \dots & x_{1p} & \rdelim\}{4}{3cm}[some text]\\
\ldelim[{5}{1cm}[text] & x_{21} & x_{22} & \dots & x_{2p} \\
& \vdots\\
& x_{n_1 1}& x_{n_1 2} & \dots & x_{n_1 p}\\
& x_{n_1+1,1}&x_{n_1+1,2} & \dots & x_{n_1+1, p} &
\rdelim\}{3}{3cm}[some more text]\\
& \vdots\\
& x_{n_1+n_2, 1} & x_{n_1+n_2,2} & \dots & x_{n_1+n_2,p}\\
& \vdots \\
\end{pmatrix}
\]
\end{lstlisting}
As seen in the above listing the left big delimiter is placed in the first
column, all other rows start with second column. It is possible to use all
columns above and below the delimiter. For the \UIndex{array}
there must be two more columns defined, in case of a big delimiter left and
right. The syntax of \CIndex{ldelim} and \CIndex{rdelim} is:
%
\begin{verbatim}
\ldelim<delimiter>{<n rows>}{<added horizontal space>}[<text>]
\rdelim<delimiter>{<n rows>}{<added horizontal space>}[<text>]
\end{verbatim}
Any delimiter which is possible for the \CIndex{left} or \CIndex{right} command
is allowed, \eg ``\verb/()[]{}|/''. The text is an optional argument and
always typeset in text mode.
\subsection{\texttt{bm}}\label{sec:bm}
By default the math macro \CIndex{mathbf} writes everything in bold and in upright mode
$\mathbf{y=f(x)}$ (\verb|$\mathbf{y=f(x)}$|), but it should be in italic mode especially
for variables $\bm{y=f(x)}$ (\verb|$\bm{y=f(x)}$|), which is possible with the package \PIndex{bm}.
For writing a whole formula in bold have a look at section~\vref{sec:boldmath}.
\subsection{\texttt{braket}}\label{sec:braket}
It is available at
\href{http://www.ctan.org/tex-archive/macros/latex/contrib/other/misc/braket.sty}%
{CTAN://macros/latex/contrib/other/misc/braket.sty}
and provides several styles for writing math expressions inside brakets. For example:
\[ \left\{ x\in\mathbf{R} | 0<{|x|}<\frac{5}{3}\right\} \]
\begin{lstlisting}
\[ \left\{ x\in\mathbf{R} | 0<{|x|}<\frac{5}{3}\right\} \]
\end{lstlisting}
\noindent looks not quite right and it is not really easy to get the first vertical line in the same
size as the outer braces. Some solution may be using \CIndex{vphantom}:
\[
\left\{\vphantom{\frac{5}{3}}x\in\mathbf{R} \right|\left. 0<{|x|}<\frac{5}{3}\right\}
\]
\begin{lstlisting}
\[
\left\{\vphantom{\frac{5}{3}}x\in\mathbf{R} \right|\left. 0<{|x|}<\frac{5}{3}\right\}
\]
\end{lstlisting}
The package \PIndex{braket} has the macros
\begin{lstlisting}
\Bra{<math expression>}
\Ket{<math expression>}
\Braket{<math expression>}
\Set{<math expression>}
\end{lstlisting}
\noindent and the same with a leading lower letter, which are not really interesting.
\[ \Bra{x\in\mathbf{R} | 0<|x|<\frac{5}{3}} \]
\[ \Ket{x\in\mathbf{R} | 0<|x|<\frac{5}{3}} \]
\[ \Braket{x\in\mathbf{R} | 0<|x|<\frac{5}{3}} \]
\[ \Braket{x\in\mathbf{R} | 0<\vert x\vert <\frac{5}{3}} \]
\[ \Set{x\in\mathbf{R} | 0<|x|<\frac{5}{3}} \]
\begin{lstlisting}
\[ \Bra{x\in\mathbf{R} | 0<|x|<\frac{5}{3}} \]
\[ \Ket{x\in\mathbf{R} | 0<|x|<\frac{5}{3}} \]
\[ \Braket{x\in\mathbf{R} | 0<|x|<\frac{5}{3}} \]
\[ \Braket{x\in\mathbf{R} | 0<\vert x\vert <\frac{5}{3}} \]
\[ \Set{x\in\mathbf{R} | 0<|x|<\frac{5}{3}} \]
\end{lstlisting}
The difference between the \CIndex{Set} and the \CIndex{Braket} macro is the handling of the
vertical lines. In \CIndex{Set} only the first one gets the same size as the
braces\index{Braces} and in \CIndex{Braket} all.
\[ \Braket{ \phi | \frac{\partial^2}{\partial t^2} | \psi }\]
\[ \Set{ \phi | \frac{\partial^2}{\partial t^2} | \psi }\]
\begin{lstlisting}
\[\Braket{\phi | \frac{\partial^2}{\partial t^2} | \psi}\]
\[\Set{\phi | \frac{\partial^2}{\partial t^2} | \psi}\]
\end{lstlisting}
\CMD{Bra} and \CMD{Ket} do nothing with the inner vertical lines.
\subsection{\texttt{cancel}}\label{cancel.sty}
This is a nice package for canceling anything in mathmode with a slash,
backslash or a \verb+X+. To get
a horizontal line we can define an additional macro called \CIndex{hcancel}
with an optional argument
for the line color (requires package \PIndex{color}):
%
\begin{lstlisting}
\newcommand\hcancel[2][black]{\setbox0=\hbox{#2}%
\rlap{\raisebox{.45\ht0}{\textcolor{#1}{\rule{\wd0}{1pt}}}}#2}
\end{lstlisting}
It is no problem to redefine the \CIndex{cancel} macros to get also colored lines.
A horizontal line for
single characters is also decribed in section~\vref{sec:Accents}.
\medskip
\noindent
\verb+\cancel+: $f(x)=\dfrac{\left(x^2+1\right)\cancel{(x-1)}}{\cancel{(x-1)}(x+1)}$\\[0.5cm]
\verb+\bcancel+: $\bcancel{3}\qquad\bcancel{1234567}$\\[0.5cm]
\verb+\xcancel+: $\xcancel{3}\qquad\xcancel{1234567}$\\[0.5cm]
\verb+\hcancel+: $\hcancel{3}\qquad\hcancel[red]{1234567}$
\bigskip
\begin{lstlisting}
$f(x)=\dfrac{\left(x^2+1\right)\cancel{(x-1)}}{\cancel{(x-1)}(x+1)}$\\[0.5cm]
$\bcancel{3}\qquad\bcancel{1234567}$\\[0.5cm]
$\xcancel{3}\qquad\xcancel{1234567}$\\[0.5cm]
$\hcancel{3}\qquad\hcancel[red]{1234567}$
\end{lstlisting}
\subsection{\texttt{cool}}\label{cool}
The \PIndex{cool} package defines a lot of special mathematical expressions
to use them by the macro name. The following list shows only some of
them, for more informations look at the example file, which comes with
the package.
\bgroup
\parindent=0pt
\bigskip
\begin{tabular}{@{}ll@{}}
\CIndex{Sin}\verb|{x}| & $\displaystyle \Sin{x}$\\
\CIndex{Cos}\verb|{x}| & $\displaystyle \Cos{x}$\\
\CIndex{Tan}\verb|{x}| & $\displaystyle \Tan{x}$\\
\CIndex{Csc}\verb|{x}| & $\displaystyle \Csc{x}$\\
\CIndex{Sec}\verb|{x}| & $\displaystyle \Sec{x}$\\
\CIndex{Cot}\verb|{x}| & $\displaystyle \Cot{x}$
\end{tabular}
\bigskip
\Style{ArcTrig=inverse}%
\CMD{Style\{ArcTrig=inverse\}} (default)
\bigskip
\begin{tabular}{@{}ll@{}}
\CIndex{ArcSin}\verb|{x}|& $\displaystyle \ArcSin{x}$\\
\CIndex{ArcCos}\verb|{x}|& $\displaystyle \ArcCos{x}$\\
\CIndex{ArcTan}\verb|{x}|& $\displaystyle \ArcTan{x}$
\end{tabular}
\bigskip
\Style{ArcTrig=arc}
\CMD{Style\{ArcTrig=arc\}}
\bigskip
\begin{tabular}{@{}ll@{}}
\CIndex{ArcSin}\verb|{x}| & $\displaystyle \ArcSin{x}$\\
\CIndex{ArcCos}\verb|{x}| & $\displaystyle \ArcCos{x}$\\
\CIndex{ArcTan}\verb|{x}| & $\displaystyle \ArcTan{x}$\\
\CIndex{ArcCsc}\verb|{x}| & $\displaystyle \ArcCsc{x}$\\
\CIndex{ArcSec}\verb|{x}| & $\displaystyle \ArcSec{x}$\\
\CIndex{ArcCot}\verb|{x}| & $\displaystyle \ArcCot{x}$
\end{tabular}
\bigskip
\begin{tabular}{@{}ll@{}}
\CIndex{Factorial}\verb|{n}| & $\displaystyle \Factorial{n}$\\
\CIndex{DblFactorial}\verb|{n}| & $\displaystyle \DblFactorial{n}$\\
\CIndex{Binomial}\verb|{n}{k}| & $\displaystyle \Binomial{n}{k}$\\
\CIndex{Multinomial}\verb|{1,2,3,4}|& $\displaystyle \Multinomial{i_1,\ldots,i_n}$
\end{tabular}
\bigskip
\begin{tabular}{@{}ll@{}}
\CIndex{GammaFunc}\verb|{x}| & $\displaystyle \GammaFunc{x}$\\
\CIndex{IncGamma}\verb|{a}{x}| & $\displaystyle \IncGamma{a}{x}$\\
\CIndex{GenIncGamma}\verb|{a}{x}{y}|& $\displaystyle \GenIncGamma{a}{x}{y}$ \\
\CIndex{RegIncGamma}\verb|{a}{x}|& $\displaystyle \RegIncGamma{a}{x}$ \\
\CIndex{RegIncGammaInv}\verb|{a}{x}|& $\displaystyle \RegIncGammaInv{a}{x}$ \\
\CIndex{GenRegIncGamma}\verb|{a}{x}{y}| & $\displaystyle \GenRegIncGamma{a}{x}{y}$\\
\CIndex{GenRegIncGammaInv}\verb|{a}{x}{y}|& $\displaystyle \GenRegIncGammaInv{a}{x}{y}$\\
\CIndex{Pochhammer}\verb|{a}{n}| & $\displaystyle \Pochhammer{a}{n}$ \\
\CIndex{LogGamma}\verb|{x}| & $\displaystyle \LogGamma{x}$
\end{tabular}
\bigskip
\begin{tabular}{@{}ll@{}}
\CIndex{Hypergeometric}\verb|{0}{0}{}{}{x}| & $\displaystyle \Hypergeometric{0}{0}{}{}{x}$\\
\CIndex{Hypergeometric}\verb|{0}{1}{}{b}{x}|& $\displaystyle \Hypergeometric{0}{1}{}{b}{x}$
\end{tabular}
\bigskip
\begin{tabular}{@{}ll@{}}
\CIndex{RegHypergeometric}\verb|{0}{0}{}{}{x}| & $\displaystyle \RegHypergeometric{0}{0}{}{}{x}$\\
\CIndex{RegHypergeometric}\verb|{0}{1}{}{b}{x}|& $\displaystyle \RegHypergeometric{0}{1}{}{b}{x}$
\end{tabular}
\bigskip
\begin{tabular}{@{}l@{}}
\CIndex{MeijerG}\verb|[a,b]{n}{p}{m}{q}{x}| \\
\hspace*{2cm} $\displaystyle \MeijerG[a,b]{n}{p}{m}{q}{x}$ \\
\CIndex{MeijerG}\verb|{1,2,3,4}{5,6}{3,6,9}{12,15,18,21,24}{x}| \\
\hspace*{2cm} $\displaystyle \MeijerG{1,2,3,4}{5,6}{3,6,9}{12,15,18,21,24}{x}$
\end{tabular}
\index{Zeta!Functions}
\index{Polylogarithm}
\index{Zeta!Riemann}
\index{Zeta!Hurwitz}
\index{Zeta}
\bigskip
\begin{tabular}{@{}ll@{}}
\CIndex{RiemannZeta}\verb|{s}| & $\displaystyle \RiemannZeta{s}$\\
\CIndex{Zeta}\verb|{s}| & $\displaystyle \Zeta{s}$\\
\CIndex{HurwitzZeta}\verb|{s}{a}|& $\displaystyle \HurwitzZeta{s}{a}$\\
\CIndex{Zeta}\verb|{s,a}| & $\displaystyle \Zeta{s,a}$ \\
\CIndex{RiemannSiegelTheta}\verb|{x}|& $\displaystyle \RiemannSiegelTheta{x}$ \\
\CIndex{RiemannSiegelZ}\verb|{x}| & $\displaystyle \RiemannSiegelZ{x}$ \\
\CIndex{StieltjesGamma}\verb|{n}| & $\displaystyle \StieltjesGamma{n}$
\end{tabular}
\index{Mathieu!Functions}
\index{Mathieu!Characteristics}
\bigskip
\begin{tabular}{@{}ll@{}}
\CIndex{MathieuC}\verb|{a}{q}{z}| & $\displaystyle \MathieuC{a}{q}{z}$ \\
\CIndex{MathieuS}\verb|{a}{q}{z}| & $\displaystyle \MathieuS{a}{q}{z}$
\end{tabular}
\bigskip
\begin{tabular}{@{}ll@{}}
\CIndex{MathieuCharacteristicA}\verb|{r}{q}|& $\displaystyle \MathieuCharacteristicA{r}{q}$ \\
\CIndex{MathieuCharisticA}\verb|{r}{q}| & $\displaystyle \MathieuCharisticA{r}{q}$ \\
%%%%%%% Characteristic Value of Even Mathieu Fucntion b_r(q)
\CIndex{MathieuCharacteristicB}\verb|{r}{q}|& $\displaystyle \MathieuCharacteristicB{r}{q}$ \\
\CIndex{MathieuCharisticB}\verb|{r}{q}|& $\displaystyle \MathieuCharisticB{r}{q}$ \\
%%%%%%%% Characteristic Exponent of a Mathieu Fucntion r(a,q)
\CIndex{MathieuCharacteristicExponent}\verb|{a}{q}|& $\displaystyle \MathieuCharacteristicExponent{a}{q}$\\
\CIndex{MathieuCharisticExp}\verb|{a}{q}|& $\displaystyle \MathieuCharisticExp{a}{q}$
\end{tabular}
\egroup
\subsection{\texttt{delarray}}\label{delarray}
Package \PIndex{delarray}%
\footnote{\href{http://www.ctan.org/tex-archive/macros/latex/required/tools/delarray.dtx}{CTAN://macros/latex/required/tools/delarray.dtx}%
} supports different delimiters which are defined together with the
beginning of an array:
\begin{lstlisting}
\begin{array}<delLeft>{cc}<delRight>
...
\end{lstlisting}
\noindent defines an array with two centered columns and the delimiters\\
``\texttt{<delLeft><delRight>}{}'', \eg ``\texttt{()}{}''.
\medskip{}
\begin{minipage}[c]{0.45\textwidth}%
\begin{lstlisting}
\[
A=\begin{array}({cc})
a & b\\
c & d
\end{array}
\]
\end{lstlisting}
\end{minipage}%
\hfill{}\begin{minipage}[c]{0.45\textwidth}%
\[
A=\begin{array}({cc})
a & b \\
c & d
\end{array}
\]
\end{minipage}%
\medskip{}
The \PIndex{delarray} package expects a pair of delimiters. If you need only
one (like the cases structure) then use the dot for an ``empty''
delimiter, \eg
\medskip{}
\begin{minipage}[c]{0.45\textwidth}%
\begin{lstlisting}
\[
A=\begin{array}\{{cc}.
a & b\\
c & d
\end{array}
\]
\end{lstlisting}
\end{minipage}%
\hfill{}\begin{minipage}[c]{0.45\textwidth}%
\[A=\begin{array}\{{cc}.
a & b \\
c & d
\end{array}\]
\end{minipage}%
\medskip{}
\noindent which is a useful command for a cases structure without the \AmSmath
package, which is described in the \AmSmath part.
\subsection{\texttt{dotseqn}}\label{dotseqn}
This package%
\footnote{\href{http://www.ctan.org/tex-archive/macros/latex/contrib/dotseqn/}%
{CTAN://macros/latex/contrib/dotseqn}} fills the space between the math
expression and the equation
number with dots. Expect problems when using this package together with \AmSmath.
\begingroup
\makeatletter
% package couldn't be loaded, it redefines the math
% environments
\newcommand\EqnDots{\leaders\hbox{\kern4\p@ .\kern4\p@}\hfill}
\@ifundefined{mathindent}{\newdimen\mathindent \mathindent\leftmargini}{}
\renewcommand{\[}{\relax \ifmmode\@badmath \else
\begin{trivlist}%
\@beginparpenalty\predisplaypenalty \@endparpenalty\postdisplaypenalty
\item[]\leavevmode \hbox to\linewidth\bgroup $\m@th\displaystyle %$
\hskip\mathindent\bgroup
\fi}
\renewcommand{\]}{\relax\ifmmode \egroup $\hfil% $
\egroup \end{trivlist}%
\else \@badmath \fi}
\renewenvironment{equation}%
{\@beginparpenalty\predisplaypenalty \@endparpenalty\postdisplaypenalty
\refstepcounter{equation}\trivlist \item[]\leavevmode
\hbox to\linewidth\bgroup $\m@th% $
\displaystyle \hskip\mathindent}%
{$\EqnDots % $ Replace `\hfil' with dotted leaders `\EqnDots'.
\displaywidth\linewidth\hbox{\@eqnnum}\egroup \endtrivlist}
\renewenvironment{eqnarray}{%
\stepcounter{equation}%
\def\@currentlabel{\p@equation\theequation}%
\global\@eqnswtrue \m@th \global\@eqcnt\z@ \tabskip\mathindent
\let\\\@eqncr \setlength\abovedisplayskip\topsep
\ifvmode \addtolength\abovedisplayskip\partopsep \fi
\addtolength\abovedisplayskip\parskip
\setlength\belowdisplayskip\abovedisplayskip
\setlength\belowdisplayshortskip\abovedisplayskip
\setlength\abovedisplayshortskip\abovedisplayskip
$$\everycr{}\halign to\linewidth% $$
\bgroup
\hskip\@centering
$\displaystyle\tabskip\z@skip{##}$\@eqnsel&%
\global\@eqcnt\@ne \hfil${\DEQ@acs##\DEQ@acs}$\hfil&%
\global\@eqcnt\tw@ $\displaystyle{##}$\hskip\@centering\cr%
}% end of "\begin" part
{\@@eqncr
\noalign{% vertical skip up to overlay phantom line
\penalty\@M \vskip-\prevdepth
\edef\@tempa{\omit\span\omit\span\omit % span three columns
\vrule\@depth\the\prevdepth \@width\z@ % strut of proper depth
\kern-\mathindent \kern\linewidth}% % full line width
\nointerlineskip \expandafter % use saved |\@tempa| outside group
}\@tempa\cr
\egroup
\global\advance\c@equation\m@ne$$% $$
\global\@ignoretrue
}
\def\@@eqncr{\let\reserved@a\@empty
\ifcase\@eqcnt \def\reserved@a{& &}\or \def\reserved@a{&}\fi
\reserved@a
\if@eqnsw \egroup $\EqnDots \@eqnnum $\bgroup \stepcounter{equation}%
\fi \global\@eqnswtrue\global\@eqcnt\z@\cr}
\def\DEQ@acs{\hskip\tw@\arraycolsep}
\makeatother
\begin{eqnarray}
F(x) &=& \int f(x)\,\mathrm{d}x + C
\end{eqnarray}
%
\begin{equation}
F(x)=\int f(x)\,\mathrm{d}x + C
\end{equation}
\endgroup
\begin{lstlisting}
\begin{eqnarray}
F(x) &=& \int f(x)\,\mathrm{d}x + C
\end{eqnarray}
%
\begin{equation}
F(x)=\int f(x)\,\mathrm{d}x + C
\end{equation}
\end{lstlisting}
\subsection{\texttt{empheq}}\label{sec:empheq}
This package\footnote{The package is part of the \texttt{mh}-bundle
of Morten H\o gholm (\href{http://www.ctan.org/tex-archive/macros/latex/contrib/mh/}{CTAN://macros/latex/contrib/mh/}).}
supports different frames for math environments of the \AmSmath
package. It doesn't support all the environments from standard \LaTeX{} which
are not modified by \AmSmath, \eg \UIndex{eqnarray}.
With the optional argument of the \UIndex{empheq}
the preferred box type
can be specified. A simple one is \CIndex{fbox}
\begin{empheq}[box=\fbox]{align}
f(x)=\int_1^{\infty}\frac{1}{x^2}\,\mathrm{d}x=1
\end{empheq}
\begin{lstlisting}
\begin{empheq}[box=\fbox]{align}
f(x)=\int_1^{\infty}\frac{1}{x^2}\,\mathrm{d}x=1
\end{empheq}
\end{lstlisting}
The same is possible with the macro \verb|\colorbox|:
\begin{empheq}[box={\fboxsep=10pt\colorbox{yellow}}]{align}
f(x)=\int_1^{\infty}\frac{1}{x^2}\,\mathrm{d}x=1
\end{empheq}
\begin{lstlisting}
\begin{empheq}[box={\fboxsep=10pt\colorbox{yellow}}]{align}
f(x)=\int_1^{\infty}\frac{1}{x^2}\,\mathrm{d}x=1
\end{empheq}
\end{lstlisting}
The key \verb|box| can hold any possible \LaTeX{} command sequence. Boxing
subequations is also no problem, the \UIndex{empheq} works in the same way:
\begin{subequations}
\begin{empheq}[box={\fboxsep=10pt\colorbox{cyan}}]{align}
f(x) & =\int_1^{\infty}\frac{1}{x^1}\,\mathrm{d}x=1\\
f(x) & =\int_2^{\infty}\frac{1}{x^2}\,\mathrm{d}x=0.25
\end{empheq}
\end{subequations}
\begin{lstlisting}
\begin{subequations}
\begin{empheq}[box={\fboxsep=10pt\colorbox{cyan}}]{align}
f(x) & =\int_1^{\infty}\frac{1}{x^2}\,\mathrm{d}x=1\\
f(x) & =\int_2^{\infty}\frac{1}{x^2}\,\mathrm{d}x=0.25
\end{empheq}
\end{subequations}
\end{lstlisting}
For more information on \PIndex{empheq} package have a look at the documentation of the package
which is available at any CTAN server.
\subsection{\texttt{esint}}\label{sec:esint}
This is a very useful package when you want nice double or triple integral or curve
integral symbols. The ones from the \PIndex{wasysym} package%
\footnote{\href{http://www.ctan.org/tex-archive/macros/latex/contrib/wasysym/}%
{CTAN://macros/latex/contrib/wasysym/}} are not the best.
\verb|esint|\footnote{\href{http://www.ctan.org/tex-archive/macros/latex/contrib/esint/}%
{CTAN://macros/latex/contrib/esint/}
\href{http://www.ctan.org/tex-archive/fonts/ps-type1/esint/}{CTAN://fonts/ps-type1/esint/}} supports the following symbols:
\allowdisplaybreaks
\begin{align}
\text{\CMD{int}} &: \int\\
\text{\CMD{iint}} &: \iint\\
\text{\CMD{iiintop}} &: \iiintop\\
\text{\CMD{iiiintop}} &: \iiiintop\\
\text{\CMD{dotsintop}}&: \dotsintop\\
\text{\CMD{ointop}} &: \ointop\\
\text{\CMD{oiint}} &: \oiint\\
\text{\CMD{sqint}} &: \sqint\\
\text{\CMD{sqiint}} &: \sqiint\\
\text{\CMD{ointctrclockwise}} &: \ointctrclockwise\\
\text{\CMD{ointclockwise}} &: \ointclockwise\\
\text{\CMD{varointclockwise}} &: \varointclockwise\\
\text{\CMD{varointctrclockwise}} &: \varointctrclockwise\\
\text{\CMD{fint}} &: \fint\\
\text{\CMD{varoiint}} &: \varoiint\\
\text{\CMD{landupint}} &: \landupint\\
\text{\CMD{landdownint}} &: \landdownint
\end{align}
\subsection{\texttt{eucal} and \texttt{euscript}}\label{sec:euscript.sty}
These packages should be part of your local \TeX{} installation, because
they come with the \AmSmath packages. Otherwise get them from CTAN%
\footnote{\href{http://www.ctan.org/tex-archive/fonts/amsfonts/latex/euscript.sty}%
{CTAN://fonts/amsfonts/latex/euscript.sty}}. They support a scriptwriting of only uppercase
letters:
\begin{center}
\includegraphics{EuScript}
%\texttt{\textbackslash{}mathscr\{...\}}\index{EuScript@\textbackslash EuScript}
%{$\EuScript{ABCDEFGHIJKLMNOPQRSTUVWXYZ}$}
\end{center}
Read the documentation for the interdependence to the %%% ----- Martin -----
\verb|\mathcal| command. For the above example the
package \PIndex{eucal} was loaded with the option \verb|mathscr|.
\subsection{\texttt{exscale}}\label{sec:exscale}
The following formula is written with the default fontsize where everything
looks more or less well:
\[
\int_{-1}^{+1}\frac{f(x)}{\sqrt{1-x^{2}}}\,%
\,\mathrm{d}x\approx\frac{\pi}{n}\sum_{i=1}^{n}f\left(\cos\left(\frac{2i-1}{2n}\right)\right)\]
Writing the same with the fontsize \CIndex{huge} gives
a surprising result, which belongs to the historical development of
\LaTeX{}, the \CIndex{int} and \CIndex{sum} symbols
are not stretched. This extreme fontsize is often needed for slides
and not only written ``just for fun{}''.
\begin{center}
\includegraphics{exscale}
\end{center}
Using the \PIndex{exscale} package%
\footnote{\href{http://www.ctan.org/tex-archive/macros/latex/base/}%
{CTAN://macros/latex/base/}} package, which should be part of any local \TeX{}
installation, all symbols get the right size.
\begin{minipage}[c]{1.0\textwidth}%
\centering\huge\[
\int_{-1}^{+1}\frac{f(x)}{\sqrt{1-x^{2}}}\,\mathrm{d}x\approx\frac{\pi}{n}%
\sum_{i=1}^{n}f\left(\cos\left(\frac{2i-1}{2n}\right)\right)\]
\end{minipage}%
\subsection{\texttt{mathtools}}\label{sec:mathtools}
This package comes with a lot of additional features for typesetting math code.
Sometimes it is useful when only such equations are numbered which are
referenced in the text. This is possible with the switch \verb+\showonlyrefs+.
Matrices are set by default with a centered horizontal alignment, which is
often not the best way. The \PIndex{mathtools} package provides a starred version of
the matrix environments which allow an optional argument for the horizontal
alignment:
\[
\begin{pmatrix*}[r]
1 & -1 & 0 \\
-1 & 1 & -1 \\
1 & -1 & 0 \\
-11 & 11 &-11 \\
\end{pmatrix*}
\]
\begin{lstlisting}
\[
\begin{pmatrix*}[r]
1 & -1 & 0 \\
-1 & 1 & -1 \\
1 & -1 & 0 \\
-11 & 11 &-11 \\
\end{pmatrix*}
\]
\end{lstlisting}
\PIndex{mathtools} also provides some more environments for setting equations.
Very interesting is the \UIndex{lgathered}, which allows to typeset a formula in
the following way:
\begin{LTXexample}[width=0.6\linewidth]
\begin{align}
x &=
\begin{lgathered}[t]
a + b + c \\
d + e +
\!\begin{gathered}[t]
f + g + h \\
i + j + k
\end{gathered}
\end{lgathered}
\end{align}
\end{LTXexample}
The \CMD{!}\index{*@\textbackslash\char033} revokes the internal horizontal space
in front of the \UIndex{gathered}.
\subsection{\texttt{nicefrac}}\label{sec:nicefrac}
Typesetting fractions\index{Fraction} in the inline mode is often a bad choice, the vertical spacing
increases in fact of the fraction. The \PIndex{nicefrac} package defines the macro
\CIndex{nicefrac}, which is used in the same way as the \CIndex{frac} command, but it
typesets the fraction with a less height: \nicefrac{2}{3} \lstinline|\nicefrac{2}{3}|.
The package is part of the \PIndex{units} package bundle and can be found in the
directory of \PIndex{units}.
\subsection{\texttt{relsize}}\label{sec:relsize}
Often consecutives math operators are used, like two sum symbols, \eg
%
\[ \sum\sum_{i=1}^n i^2 \]
As seen the sums are of the same size. To increase the first operator size, someone
can use the \CIndex{scalebox} macro from package \UIndex{graphicx} and write an own macro %%% ----- Martin -----
\verb+\Sum+, \eg \index{Operator!size}\index{Size!Operator}
\begin{lstlisting}
\def\Sum{\ensuremath\mathop{\scalebox{1.2}{$\displaystyle\sum$}}}
\[ \Sum_{j=1}\sum_{i=1}^\infty i \]
\end{lstlisting}
\def\Sum{\ensuremath\mathop{\scalebox{1.2}{$\displaystyle\sum$}}}
\[ \Sum_{j=1}\sum_{i=1}^\infty i \]
Another solution is to use the \PIndex{relsize} package%
\footnote{\href{http://www.ctan.org/tex-archive/macros/latex/ltxmisc/}{CTAN://macros/latex/ltxmisc/}}
together with the \PIndex{exscale} one. \PIndex{relsize} defines a useful macro \CIndex{mathlarger}:
\begin{LTXexample}
\[ \mathlarger{\sum}\sum_{i=1}^n i^2 \]
\end{LTXexample}
\subsection{\texttt{xypic}}\label{xypic.sty}
The \CIndex{xymatrix} macro is part of the \PIndex{xypic} package%
\footnote{\href{http://www.ctan.org/tex-archive/support/latex2html/}%
{CTAN://macros/generic/diagrams/xypic/xy-3.7/}} which can be loaded with several options
which are not so important here.%
\footnote{For more information look at the package documentation or the
package \PIndex{xy} itself, which is often saved in \texttt{/usr/share/texmf/tex/generic}}.
\begin{equation}
\xymatrix{A\POS[];[d]**\dir{~},[];[dr]**\dir{-} & B & C\\
D & E\POS[];[l]**\dir{.},[];[r]**\dir{~} & F\POS[];[dl]**\dir{~}\\
G & H & I}
\label{eq:xymatrix}
\end{equation}
This matrix was created with
\begin{lstlisting}
\[
\xymatrix{ A\POS [];[d]**\dir {~},[];[dr]**\dir {-} & B & C\\
D & E\POS [];[l]**\dir {.},[];[r]**\dir {~} & F\POS [];[dl]**\dir {~}\\
G & H & I}
\]
\end{lstlisting}
\part{Math fonts}
Typesetting text and math is far different. There exist a lot of free text fonts without
additional math characters. This is the reason why we have to buy a commercial math font, e.\,g.
\Index{Palatino} (\PIndex{pamath}) or \Index{Helvetica} (\PIndex{hvmath}), or to
combine the free text font with another free math font.
\section{Computer modern}
This is the default font, designed by Knuth.\index{cmr}\index{Computer modern} For the PDF output
the Type 1 fonts cm-super and BlueSky were used.
\Mbox{cm-crop}
\section{Latin modern}
This is the new designed font which comes with an own Type 1 version.\FIndex{lm}\index{Latin modern}
\Mbox{lm-crop}
\section{Palatino}
There is a free package mathpazo.\PIndex{mathpazo}\index{Palatino}
\Mbox{pazo-crop}
\section{Palatino -- microimp}
There is the package \PIndex{pamath} for the nonfree palatino font.\PIndex{mathpazo}\index{Palatino}
\Mbox{pamath-crop}
\section{cmbright}
\Mbox{cmbright-crop}
\section{minion}
\Mbox{minionpro-crop}
\part{Special symbols}
In this section only those symbols are defined, which are not part of the %%% ----- Martin -----
list of all available symbols:
\href{http://www.ctan.org/tex-archive/info/symbols/comprehensive/symbols-a4.pdf}%
{CTAN://info/symbols/comprehensive/symbols-a4.pdf}. With
\verb+fontmath.ltx+ \LaTeX{} itself defines the following special symbols for using inside math: %%% ----- Martin -----
\begin{table}[htb]
\centering
\begin{tabular}{l|c}
Name & Meaning\\\hline
\verb+\mathparagraph+ & $\mathparagraph$\\
\verb+\mathsection+ & $\mathsection$\\
\verb+\mathdollar+ & $\mathdollar$\\
\verb+\mathsterling+ & $\mathsterling$\\
\verb+\mathunderscore+ & $\mathunderscore$\\
\verb+\mathellipsis+ & $\mathellipsis$\\
\end{tabular}
\caption{Predefined math symbols from \texttt{fontmath.ltx}}\label{fontmath.ltx}
\end{table}
\section{Integral symbols}
\index{Integral symbols}
\def\Xint#1{\mathchoice
{\XXint\displaystyle\textstyle{#1}}%
{\XXint\textstyle\scriptstyle{#1}}%
{\XXint\scriptstyle\scriptscriptstyle{#1}}%
{\XXint\scriptscriptstyle\scriptscriptstyle{#1}}%
\!\int}
\def\XXint#1#2#3{{\setbox0=\hbox{$#1{#2#3}{\int}$}
\vcenter{\hbox{$#2#3$}}\kern-.5\wd0}}
\def\ddashint{\Xint=}
\def\dashint{\Xint-}
\def\clockint{\Xint\circlearrowright} % GOOD!
\def\counterint{\Xint\rotcirclearrowleft} % Good for Computer Modern!
\def\rotcirclearrowleft{\mathpalette{\RotLSymbol{-30}}\circlearrowleft}
\def\RotLSymbol#1#2#3{\rotatebox[origin=c]{#1}{$#2#3$}}
\begin{center}
\begin{tabular}{lc}
Name & Symbol\\\hline
\verb|\dashint| & $\dashint$\\
\verb|\ddashint| & $\ddashint$\\
\verb|\clockint| & $\clockint$\\
\verb|\counterint| & $\counterint$
\end{tabular}
\end{center}
%$
For all new integral symbols limits can be used in the usual way:
\begin{equation}
\ddashint_01=\dashint_10<\oint\limits_{-\infty}^\infty = \clockint\counterint_A
\end{equation}
\begin{lstlisting}
\ddashint_01=\dashint_10<\oint\limits_{-\infty}^\infty = \clockint\counterint_A
\end{lstlisting}
Put the following definitions into the preamble to use one or all of these new
integral symbols.
\begin{lstlisting}
\def\Xint#1{\mathchoice
{\XXint\displaystyle\textstyle{#1}}%
{\XXint\textstyle\scriptstyle{#1}}%
{\XXint\scriptstyle\scriptscriptstyle{#1}}%
{\XXint\scriptscriptstyle\scriptscriptstyle{#1}}%
\!\int}
\def\XXint#1#2#3{{\setbox0=\hbox{$#1{#2#3}{\int}$}
\vcenter{\hbox{$#2#3$}}\kern-.5\wd0}}
\def\ddashint{\Xint=}
\def\dashint{\Xint-}
\def\clockint{\Xint\circlearrowright} % GOOD!
\def\counterint{\Xint\rotcirclearrowleft} % Good for Computer Modern!
\def\rotcirclearrowleft{\mathpalette{\RotLSymbol{-30}}\circlearrowleft}
\def\RotLSymbol#1#2#3{\rotatebox[origin=c]{#1}{$#2#3$}}
\end{lstlisting}
%\clearpage
\section{Harpoons}
\LaTeX{} knows no stretchable harpoon\index{Harpoon} symbols, like \verb|\xrightarrow|.
The following code defines several harpoon symbols.%
\index{xrightharpoondown@\textbackslash xrightharpoondown}
\index{xrightharpoonup@\textbackslash xrightharpoonup}
\index{xleftharpoondown@\textbackslash xleftharpoondown}
\index{xleftharpoonup@\textbackslash xleftharpoonup}
\index{xleftrightharpoons@\textbackslash xleftrightharpoons}
\index{xrightleftharpoons@\textbackslash xrightleftharpoons}%
%
\mPar{\CMD{xrightharpoondown}\\%
\CMD{xrightharpoonup}\\%
\CMD{xleftharpoondown}\\%
\CMD{xleftharpoonup}\\%
\CMD{xleftrightharpoons}\\%
\CMD{xrightleftharpoons}%
}
\begin{lstlisting}
\def\rightharpoondownfill@{%
\arrowfill@\relbar\relbar\rightharpoondown}
\def\rightharpoonupfill@{%
\arrowfill@\relbar\relbar\rightharpoonup}
\def\leftharpoondownfill@{%
\arrowfill@\leftharpoondown\relbar\relbar}
\def\leftharpoonupfill@{%
\arrowfill@\leftharpoonup\relbar\relbar}
\newcommand{\xrightharpoondown}[2][]{%
\ext@arrow 0359\rightharpoondownfill@{#1}{#2}}
\newcommand{\xrightharpoonup}[2][]{%
\ext@arrow 0359\rightharpoonupfill@{#1}{#2}}
\newcommand{\xleftharpoondown}[2][]{%
\ext@arrow 3095\leftharpoondownfill@{#1}{#2}}
\newcommand{\xleftharpoonup}[2][]{%
\ext@arrow 3095\leftharpoonupfill@{#1}{#2}}
\newcommand{\xleftrightharpoons}[2][]{\mathrel{%
\raise.22ex\hbox{%
$\ext@arrow 3095\leftharpoonupfill@{\phantom{#1}}{#2}$}%
\setbox0=\hbox{%
$\ext@arrow 0359\rightharpoondownfill@{#1}{\phantom{#2}}$}%
\kern-\wd0 \lower.22ex\box0}%
}
\newcommand{\xrightleftharpoons}[2][]{\mathrel{%
\raise.22ex\hbox{%
$\ext@arrow 3095\rightharpoonupfill@{\phantom{#1}}{#2}$}%
\setbox0=\hbox{%
$\ext@arrow 0359\leftharpoondownfill@{#1}{\phantom{#2}}$}%
\kern-\wd0 \lower.22ex\box0}%
}
\end{lstlisting}
\begin{tabular}{ll}
\verb|\xrightharpoondown[under]{over}| & $\xrightharpoondown[under]{over}$\\[10pt]
\verb|\xrightharpoonup[under]{over}| & $\xrightharpoonup[under]{over}$ \\[10pt]
\verb|\xleftharpoondown[under]{over}| & $\xleftharpoondown[under]{over}$\\[10pt]
\verb|\xleftharpoonup[under]{over}| & $\xleftharpoonup[under]{over}$ \\[10pt]
\verb|\xleftrightharpoons[under]{over}|& $\xleftrightharpoons[under]{over}$\\[10pt]
\verb|\xrightleftharpoons[under]{over}|& $\xrightleftharpoons[under]{over}$
\end{tabular}
%$
\section{Bijective mapping arrow}
To get something like \bijmap~we can define:
\begin{lstlisting}
\def\bijmap{%
\ensuremath{%
\mathrlap{\rightarrowtail}\rightarrow%
}%
}
\end{lstlisting}
This uses the \CIndex{mathrlap} definition from section~\vref{subsec:ams-limits}. With this
definition a huge symbol is also possible: \verb+{\Huge\bijmap}+ {\Huge\bijmap}.
\section{Stacked equal sign}
There are several symbols stacked with an equal sign, \eg \CIndex{doteq}, \CIndex{equiv} or
\CIndex{cong} ($\doteq$, $\equiv{}$, $\cong$ ). But there are still some missing, which are
shown in table~\ref{tab:equal} and the following definitions.
\begin{table}[htb]
\centering
\begin{tabular}{ll}
\verb+\eqdef+ & \eqdef\\
\verb+\eqexcl+ & \eqexcl\\
\verb+\eqhat+ & \eqhat
\end{tabular}
\caption{New symbols in combination with the equal sign}\label{tab:equal}
\end{table}
\begin{lstlisting}
\newcommand{\eqdef}{\ensuremath{\mathrel{\stackrel{\mathrm{def}}{=}}}}
\newcommand{\eqexcl}{\ensuremath{\mathrel{\stackrel{\mathrm{!}}{=}}}}
\newcommand{\eqhat}{\ensuremath{\mathrel{\widehat{=}}}}
\end{lstlisting}
\section{Other symbols}
\begin{minipage}{0.7\linewidth}
\begin{lstlisting}
\newcommand*{\threesim}{%
\mathrel{\vcenter{\offinterlineskip
\hbox{$\sim$}\vskip-.35ex\hbox{$\sim$}\vskip-.35ex\hbox{$\sim$}}}}
$\threesim ABC$
\end{lstlisting}%
\end{minipage}\hfill
\begin{minipage}{0.15\linewidth}
$\threesim ABC$
\end{minipage}
\noindent
\begin{minipage}{0.7\linewidth}
\begin{lstlisting}
\newcommand\Let{\mathrel{\mathop:\!\!=}}% Upper case L!
\newcommand\teL{\mathrel{=\!\!\mathop:}}
$x\Let y$ $y\teL x$
\end{lstlisting}%
\end{minipage}\hfill
\newcommand\Let{\mathrel{\mathop:\!\!=}}% Upper case L!
\newcommand\teL{\mathrel{=\!\!\mathop:}}
$x\Let y$ $y\teL x$
\begin{minipage}{0.15\linewidth}
\end{minipage}
%\lstset{xrightmargin=-\marginparwidth}
\part{Examples}
\section{Tuning math typesetting}
Chapter 18 of the \TeX book is named ,,Fine Points of Mathematics Typing``~\cite{knuth86}
and it
shows on 20 pages some more or less important facts when typesetting mathematical
expressions. Often inline formulas contain a \Index{punctuation} character like a
\Index{dot}, \Index{comma}, \Index{colon}, \etc. It is a general rule to write
those characters outside the math mode. Compare
\begin{LTXexample}[preset=\raggedright,width=0.4\linewidth]
$a, b, c, d, e, \textrm{and }f$ \\[5pt]
$a$, $b$, $c$, $d$, $e$, and $f$
\end{LTXexample}
Having such math as single expressions enables \TeX\ to insert a linebreak at several
places (see Section~\vref{subsec:linebreak}).
Writing an \Index{ellipses} as three single dots, doesn't look very nice, one should
always use the \CIndex{ldots} command:
\begin{LTXexample}[preset=\raggedright,width=0.4\linewidth]
$1,...,10$\\[5pt]
$1,\ldots,10$
\end{LTXexample}
This is correct as long as on the left and right are a comma as a separator.
For sums the \CIndex{cdot} command should be used instead:
\begin{LTXexample}[preset=\raggedright,width=0.4\linewidth]
$1+2+\cdots+10$\\[5pt]
$x_n=x_{n-1}=\cdots=n_0=1$
\end{LTXexample}
For a multiplication it is important which character is used, in european countries
often a centered dot. In such a case it is appropriate not to use the \CIndex{cdots}
command for a ellipsis.
For typesetting integrals\index{Integral} or differential equations\index{differential equation}
it makes sense to define the following short macros:
\begin{lstlisting}
\newcommand*{\diff}{\mathop{}\!\mathrm{d}}
\newcommand*\dst{\,\frac{\diff s}{\diff t}
\end{lstlisting}
\newcommand*{\diff}{\mathop{}\!\mathrm{d}}
\iffalse
\newcommand*\dy{\,\mathrm{d}y}
\newcommand*\dx{\,\mathrm{d}x}
\newcommand*\dyx{\,\frac{\mathrm{d}y}{\mathrm{d}x}}
\newcommand*\ds{\,\mathrm{d}s}
\newcommand*\dt{\,\mathrm{d}t}
\newcommand*\dst{\,\frac{\mathrm{d}s}{\mathrm{d}t}}
\fi
\begin{LTXexample}[preset=\raggedright,width=0.4\linewidth]
\begin{align*}
F(x) &= \int\!f(x)\diff x\\
v(t) &= \dst\\
a(t) &= \frac{\diff{}^2s}{\diff t^2}
\end{align*}
\end{LTXexample}
\begin{LTXexample}[preset=\raggedright,width=0.4\linewidth]
\begin{align*}
G(t) &= \underbrace{\,\int\cdots\!\int\!\!}_D\;\diff x\diff y\ldots\\
u_C(t) &= \int\!\,i_C(t)\diff t
\end{align*}
\end{LTXexample}
\bigskip
\section{Matrix}
\subsection{Identity matrix}
There are several possibilities to write this matrix. Here is a solution
with the default array environment.
\begin{LTXexample}[width=0.4\linewidth]
\[
\left(
\begin{array}{ccccc}
1\\
& 1 & & \text{{\huge{0}}}\\
& & 1\\
& \text{{\huge{0}}} & & 1\\
& & & & 1
\end{array}
\right)
\]
\end{LTXexample}
\subsection{System of linear equations}
\begin{LTXexample}[pos=t]
\[
\begin{array}{l@{\:=\:}*{5}{l@{\:+\:}}l}
y_1 & a_{11}x_1 & a_{12}x_2 & a_{13}x_3 & \dots & a_{1(n-1)}x_{n-1} & a_{1n}x_n \\
y_2 & a_{21}x_1 & a_{22}x_2 & a_{23}x_3 & \dots & a_{2(n-1)}x_{n-1} & a_{2n}x_n \\
\ \vdots &\ \vdots &\ \vdots &\ \vdots &\ \vdots &\ \vdots &\ \vdots\\
y_{n-1} & a_{(n-1)1}x_1 & a_{(n-1)2}x_2 & a_{(n-1)3}x_3 & \dots & a_{(n-1)(n-1)}x_{n-1} & a_{(n-1)n}x_n\\
y_n & a_{n1}x_1 & a_{n2}x_2 & a_{n3}x_3 & \dots & a_{(n)(n-1)}x_{n-1} & a_{nn}x_n
\end{array}
\]
\end{LTXexample}
\subsection{Matrix with comments on top}
\begin{LTXexample}[width=0.35\linewidth]
\def\rb#1{\rotatebox{90}{$\xleftarrow{#1}$}}
\begin{tabular}{c}
$\begin{matrix}
\rb{text1}&\rb{text1}&\rb{text1}&\rb{text1}\\
\end{matrix}$\\
$\begin{bmatrix}
X_x & Y_x & Z_x & T_x \\
X_y & Y_y & Z_y & T_y \\
X_z & Y_z & Z_z & T_z \\
0 & 0 & 0 & 1
\end{bmatrix}$
\end{tabular}
\end{LTXexample}
%$
\section{Cases structure}
\index{Cases!numbered lines}Sometimes it is better to use the array environment instead of amsmath's %%% ----- Martin -----
cases environment. To get optimal horizontal spacing for the conditions,
there are two matrixes in series, one $3\times 1$ followed by $3\times 3$ matrix.
To minimize the horizontal space around the variable $z$ a
\begin{lstlisting}
\addtolength{\arraycolsep}{-3pt}
\end{lstlisting}
is a useful command.
\begin{equation}
\addtolength{\arraycolsep}{-3pt}
I(z)=\delta_{0}\left\{%
\begin{array}{lcrcl}
D+z & \quad & -D & \le z\le & -p\\
D-\frac{1}{2}\left(p-\frac{z^{2}}{p}\right)%
& \quad & -p & \le z\le & \phantom{-}p\\
D-z & \quad & p & \le z\le & \phantom{-}D
\end{array}\right.
\end{equation}
\begin{lstlisting}
\begin{equation}
\addtolength{\arraycolsep}{-3pt}
I(z)=\delta_{0}\left\{%
\begin{array}{lcrcl}
D+z & \quad & -D & \le z\le & -p\\
D-\frac{1}{2}\left(p-\frac{z^{2}}{p}\right)%
& \quad & -p & \le z\le & \phantom{-}p\\
D-z & \quad & p & \le z\le & \phantom{-}D
\end{array}\right.
\end{equation}
\end{lstlisting}
The \CMD{phantom}\index{phantom@\textbackslash phantom} command
replaces exactly that place with whitespace which the argument needs.
\subsection{Cases with numbered lines}
This is not possible in an easy way, because \verb+cases+ uses the array
environment for typesetting which has by default no numbering. However, there
are some tricky ways to get numbered lines. The following three examples
use the \verb+tabular+, the \verb+tabularx+ and the \verb+array+ environment.
\bigskip\noindent
\begin{tabular}{rc}
\ldelim\{{2}{2.75cm}[some text here] & %%% ----- Martin -----
\parbox{{\linewidth-3cm-4\tabcolsep}}{
\vspace*{1ex}
\begin{flalign}
x & = 2\quad\text{if }y >2 &\\
x & = 3\quad\text{if }y \le 2&
\end{flalign}}
\end{tabular}
\bigskip
\begin{lstlisting}
\begin{tabular}{rc}
\ldelim\{{2}{2.75cm}[some text here] &
\parbox{{\linewidth-3cm-4\tabcolsep}}{
\vspace*{1ex}
\begin{flalign}
x & = 2\quad\text{if }y >2 &\\
x & = 3\quad\text{if }y \le 2&
\end{flalign}}
\end{tabular}
\end{lstlisting}
\bigskip\noindent
\begin{tabularx}{\linewidth}{rXc}
\ldelim\{{2}{2.75cm}[some text here] %%% ----- Martin -----
& $ x = 2\quad\text{if }y > 2 $ & \refstepcounter{equation}(\theequation)\\
& $ x = 3\quad\text{if }y \le 2$ &\refstepcounter{equation}(\theequation)
\end{tabularx}
\bigskip
\begin{lstlisting}
\begin{tabularx}{\linewidth}{rXc}
\ldelim\{{2}{2.75cm}[some text here]
& $x=2\quad\text{if }y>2$ &\refstepcounter{equation}(\theequation)\\
& $x=3\quad\text{if }y\le2$&\refstepcounter{equation}(\theequation)
\end{tabularx}
\end{lstlisting}
\bigskip
\[
\begin{array}{rc@{\qquad}c}
\ldelim\{{2}{2.75cm}[some text here] %%% ----- Martin -----
& x = 2\quad\text{if }y > 2 & \refstepcounter{equation}(\theequation)\\
& x = 3\quad\text{if }y \le 2& \refstepcounter{equation}(\theequation)
\end{array}
\]
\bigskip
\begin{lstlisting}
\[
\begin{array}{rc@{\qquad}c}
\ldelim\{{2}{2.75cm}[some text here]
& x = 2\quad\text{if }y > 2 & \refstepcounter{equation}(\theequation)\\
& x = 3\quad\text{if }y \le 2& \refstepcounter{equation}(\theequation)
\end{array}
\]
\end{lstlisting}
%$
\section{Arrays}
There is a general rule that a lot of mathematical stuff should be
divided in smaller pieces. But sometimes it is difficult to get a nice
horizontal alignment when splitting a formula. The following ones
uses the \texttt{array} environment to get a proper alignment.
\subsection{Quadratic equation}
\begin{equation}
\begin{array}{rcll}
y & = & x^{2}+bx+c\\
& = & x^{2}+2\cdot{\displaystyle\frac{b}{2}x+c}\\
& = & \underbrace{x^{2}+2\cdot\frac{b}{2}x+\left(\frac{b}{2}\right)^{2}}-{\displaystyle%
\left(\frac{b}{2}\right)^{2}+c}\\
& & \qquad\left(x+{\displaystyle \frac{b}{2}}\right)^{2}\\
& = & \left(x+{\displaystyle \frac{b}{2}}\right)^{2}-\left({\displaystyle%
\frac{b}{2}}\right)^{2}+c & \left|+\left({\displaystyle%
\frac{b}{2}}\right)^{2}-c\right.\\
y+\left({\displaystyle \frac{b}{2}}\right)^{2}-c & = & \left(x+{\displaystyle%
\frac{b}{2}}\right)^{2} & \left|(\textrm{Scheitelpunktform})\right.\\
y-y_{S} & = & (x-x_{S})^{2}\\
S(x_{S};y_{S}) & \,\textrm{bzw.}\, & S\left(-{\displaystyle%
\frac{b}{2};\,\left({\displaystyle \frac{b}{2}}\right)^{2}-c}\right)
\end{array}
\end{equation}
\begin{lstlisting}[xrightmargin=-\marginparwidth]
\begin{equation}
\begin{array}{rcll}
y & = & x^{2}+bx+c\\
& = & x^{2}+2\cdot{\displaystyle\frac{b}{2}x+c}\\
& = & \underbrace{x^{2}+2\cdot\frac{b}{2}x+\left(\frac{b}{2}\right)^{2}}-{\displaystyle%
\left(\frac{b}{2}\right)^{2}+c}\\
& & \qquad\left(x+{\displaystyle \frac{b}{2}}\right)^{2}\\
& = & \left(x+{\displaystyle \frac{b}{2}}\right)^{2}-\left({\displaystyle%
\frac{b}{2}}\right)^{2}+c & \left|+\left({\displaystyle%
\frac{b}{2}}\right)^{2}-c\right.\\
y+\left({\displaystyle \frac{b}{2}}\right)^{2}-c & = & \left(x+{\displaystyle%
\frac{b}{2}}\right)^{2} & \left|(\textrm{Scheitelpunktform})\right.\\
y-y_{S} & = & (x-x_{S})^{2}\\
S(x_{S};y_{S}) & \,\textrm{bzw.}\, & S\left(-{\displaystyle%
\frac{b}{2};\,\left({\displaystyle \frac{b}{2}}\right)^{2}-c}\right)
\end{array}
\end{equation}
\end{lstlisting}
\subsection{Vectors and matrices}
\index{Vector}
\begin{equation}
\begin{array}{rcl}
\underline{RS} & = & \left(\begin{array}{cccccccc}
01 & a4 & 55 & 87 & 5a & 58 & db & 9e\\
a4 & 56 & 82 & f3 & 1e & c6 & 68 & e5\\
02 & a1 & fc & c1 & 47 & ae & 3d & 19\\
a4 & 55 & 87 & 5a & 58 & db & 9e & 03\end{array}\right)\\
\\
\left(\begin{array}{c}
s_{i,0}\\
s_{i,1}\\
s_{i,2}\\
s_{i,3}
\end{array}\right) & = & \underline{RS}\cdot%
\left(\begin{array}{c}
m_{8i+0}\\
m_{8i+1}\\
\cdots\\
m_{8i+6}\\
m_{8i+7}
\end{array}\right)\\
\\
S_{i} & = & \sum_{j=0}^{3}s_{i,j}\cdot2^{8j}\qquad i=0,1,...,k-1\\
\\
S & = & \left(S_{k-1},S_{k-2},...,S_{1},S_{0}\right)
\end{array}
\end{equation}
\begin{lstlisting}
\begin{equation}
\begin{array}{rcl}
\underline{RS} & = & \left(\begin{array}{cccccccc}
01 & a4 & 55 & 87 & 5a & 58 & db & 9e\\
a4 & 56 & 82 & f3 & 1e & c6 & 68 & e5\\
02 & a1 & fc & c1 & 47 & ae & 3d & 19\\
a4 & 55 & 87 & 5a & 58 & db & 9e & 03\end{array}\right)\\
\\
\left(\begin{array}{c}
s_{i,0}\\
s_{i,1}\\
s_{i,2}\\
s_{i,3}
\end{array}\right) & = & \underline{RS}\cdot%
\left(\begin{array}{c}
m_{8i+0}\\
m_{8i+1}\\
\cdots\\
m_{8i+6}\\
m_{8i+7}
\end{array}\right)\\
\\
S_{i} & = & \sum_{j=0}^{3}s_{i,j}\cdot2^{8j}\qquad i=0,1,...,k-1\\
\\
S & = & \left(S_{k-1},S_{k-2},...,S_{1},S_{0}\right)
\end{array}
\end{equation}
\end{lstlisting}
\subsection{Cases with (eqn)array environment}
This solution is important when \AmSmath can't be used. %%% ----- Martin -----
$\lim\limits_{n->\infty}q^{n}=\left\{%
\begin{array}{lc@{\kern2pt}c@{\kern2pt}r}
\textrm{divergent}\ & q & \le & -1\\
0 & |q| & < & 1\\
1 & q & = & 1\\
\infty & q & > & 1
\end{array}\right.$
\medskip
\begin{lstlisting}
$\lim\limits_{n->\infty}q^{n}=\left\{%
\begin{array}{lc@{\kern2pt}c@{\kern2pt}r}
\textrm{divergent}\ & q & \le & -1\\
0 & |q| & < & 1\\
1 & q & = & 1\\
\infty & q & > & 1
\end{array}\right.$
\end{lstlisting}
%$
\subsection{Arrays inside arrays}
The array environment is a powerful one because it can be nested in several ways:
\[
\left(
\begin{array}{c@{}c@{}c}
\begin{array}{|cc|}
\hline
a_{11} & a_{12} \\
a_{21} & a_{22} \\
\hline
\end{array} & 0 & 0 \\
0 & \begin{array}{|ccc|}
\hline
b_{11} & b_{12} & b_{13}\\
b_{21} & b_{22} & b_{23}\\
b_{31} & b_{32} & b_{33}\\
\hline
\end{array} & 0 \\
0 & 0 & \begin{array}{|cc|}
\hline
c_{11} & c_{12} \\
c_{21} & c_{22} \\
\hline
\end{array} \\
\end{array}
\right)
\]
\begin{lstlisting}
\[
\left(
\begin{array}{c@{}c@{}c}
\begin{array}{|cc|}\hline
a_{11} & a_{12} \\
a_{21} & a_{22} \\\hline
\end{array} & \mathbf{0} & \mathbf{0} \\
\mathbf{0} &
\begin{array}{|ccc|}\hline
b_{11} & b_{12} & b_{13}\\
b_{21} & b_{22} & b_{23}\\
b_{31} & b_{32} & b_{33}\\\hline
\end{array} & \mathbf{0} \\
\mathbf{0} & \mathbf{0} &
\begin{array}{|cc|}\hline
c_{11} & c_{12} \\
c_{21} & c_{22} \\\hline
\end{array} \\
\end{array}
\right)
\]
\end{lstlisting}
\[
Y^1=
\begin{array}{c}
\null\\[1ex]% kann weg
\left[\begin{array}{rrrr}
0 & 0 & 1 & 0\\
1 & 0 & 1 & 0\\
1 & 1 & 1 & 1
\end{array}\right]\\[3ex]\hline
\begin{array}{rrrr}
% \hdotsfor{4}\\% statt \\[3ex]\hline
2 & 1 &3 & 1
\end{array}
\end{array}
\]
\begin{lstlisting}
\[
Y^1=
\begin{array}{c}
\null\\[1ex]% only vor vertical alignment
\left[\begin{array}{rrrr}
0 & 0 & 1 & 0\\
1 & 0 & 1 & 0\\
1 & 1 & 1 & 1
\end{array}\right]\\[3ex]\hline
\begin{array}{rrrr}
% \hdotsfor{4}\\%( needs \AmSmath) instead of \\[3ex]\hline
2 & 1 &3 & 1
\end{array}
\end{array}
\]
\end{lstlisting}
\subsection{Colored cells}\label{sub:color}
In general there is no difference in coloring tabular or array cells. The following example
shows how one can put \index{color}colors in rows, columns and cells.
\index{rowcolor@\textbackslash rowcolor}\index{columncolor@\textbackslash columncolor}
\medskip\noindent
\includegraphics[width=\columnwidth]{colArray}
%\[
%\left[\,
%\begin{array}{*{5}{>{\columncolor[gray]{0.95}}c}}
% {h_{k,1,0}(n)} & {h_{k,1,1}(n)} & {h_{k,1,2}(n)} & \zero & \zero \\
% {h_{k,2,0}(n)} & {h_{k,2,1}(n)} & {h_{k,2,2}(n)} & \zero & \zero \\
% {h_{k,3,0}(n)} & {h_{k,3,1}(n)} & {h_{k,3,2}(n)} & \zero & \zero \\
% {h_{k,4,0}(n)} & \colCell{umbra}{h_{k,4,1}(n)} & {h_{k,4,2}(n)} & \zero & \zero \\
% \zero & {h_{k,1,0}(n-1)} & {h_{k,1,1}(n-1)} & {h_{k,1,2}(n-1)} & \zero \\
% \zero & {h_{k,2,0}(n-1)} & {h_{k,2,1}(n-1)} & {h_{k,2,2}(n-1)} & \zero \\
% \zero & {h_{k,3,0}(n-1)} & {h_{k,3,1}(n-1)} & {h_{k,3,2}(n-1)} & \zero \\
% \zero & \colCell{umbra}{h_{k,4,0}(n-1)} & {h_{k,4,1}(n-1)} & {h_{k,4,2}(n-1)} & \zero \\
% \zero & \zero & {h_{k,1,0}(n-2)} & {h_{k,1,1}(n-2)} & {h_{k,1,2}(n-2)}\\
% \rowcolor[gray]{0.75}%
% \zero & \zero & {h_{k,2,0}(n-2)} & {h_{k,2,1}(n-2)} & {h_{k,2,2}(n-2)}\\
% \zero & \zero & {h_{k,3,0}(n-2)} & {h_{k,3,1}(n-2)} & {h_{k,3,2}(n-2)}\\
% \zero & \zero & {h_{k,4,0}(n-2)} & {h_{k,4,1}(n-2)} & {h_{k,4,2}(n-2)}
%\end{array} \,\right]
%\end]
\medskip
\begin{lstlisting}[xrightmargin=-\marginparwidth]
...
\usepackage{array}
\usepackage{colortbl}
\definecolor{umbra}{rgb}{0.8,0.8,0.5}
\def\zero{\multicolumn{1}{>{\columncolor{white}}c}{0}}
\def\colCell#1#2{\multicolumn{1}{>{\columncolor{#1}}c}{#2}}
\begin{document}
\[\left[\,
\begin{array}{*{5}{>{\columncolor[gray]{0.95}}c}}
h_{k,1,0}(n) & h_{k,1,1}(n) & h_{k,1,2}(n) & \zero & \zero\\
h_{k,2,0}(n) & h_{k,2,1}(n) & h_{k,2,2}(n) & \zero & \zero\\
h_{k,3,0}(n) & h_{k,3,1}(n) & h_{k,3,2}(n) & \zero & \zero\\
h_{k,4,0}(n)} & \colCell{umbra}{h_{k,4,1}(n)} & h_{k,4,2}(n) & \zero & \zero\\
\zero & h_{k,1,0}(n-1) & h_{k,1,1}(n-1) & h_{k,1,2}(n-1) & \zero\\
\zero & h_{k,2,0}(n-1) & h_{k,2,1}(n-1) & h_{k,2,2}(n-1) & \zero\\
\zero & h_{k,3,0}(n-1) & h_{k,3,1}(n-1) & h_{k,3,2}(n-1) & \zero\\
\zero & \colCell{umbra}{h_{k,4,0}(n-1)} & h_{k,4,1}(n-1) & h_{k,4,2}(n-1) & \zero\\
\zero & \zero & h_{k,1,0}(n-2) & h_{k,1,1}(n-2) & h_{k,1,2}(n-2)\\
\zero & \zero & h_{k,2,0}(n-2) & h_{k,2,1}(n-2) & h_{k,2,2}(n-2)\\
\zero & \zero & h_{k,3,0}(n-2) & h_{k,3,1}(n-2) & h_{k,3,2}(n-2)\\
\zero & \zero & h_{k,4,0}(n-2) & h_{k,4,1}(n-2) & h_{k,4,2}(n-2)
\end{array} \,\right]_{12\times 5}\]
...
\end{lstlisting}
\subsection{Boxed rows and columns}
\begin{LTXexample}[width=0.35\linewidth]
\[
\overrightarrow{A}=\left[
\begin{array}{cccc}
1 & 2 & 3 & 4\\
1 & 2 & 3 & 4\\\hline
\multicolumn{1}{|c}{1} & 2 & 3 &
\multicolumn{1}{c|}{4}\\\hline
1 & 2 & 3 & 4
\end{array}\right]
\]
\end{LTXexample}
\begin{LTXexample}[width=0.35\linewidth]
\[
\overrightarrow{A}=\left[
\begin{array}{cc|c|c}\cline{3-3}
1 & 2 & 3 & 4\\
1 & 2 & 3 & 4\\
1 & 2 & 3 & 4\\
1 & 2 & 3 & 4\\\cline{3-3}
\end{array}\right]
\]
\end{LTXexample}
\begin{LTXexample}[width=0.35\linewidth]
\[
\overrightarrow{A}=\left[
\begin{array}{cc|c|c}\cline{3-3}
1 & 2 & 3 & 4\\
1 & 2 & 3 & 4\\\hline
\multicolumn{1}{|c}{1} & 2 & 3 &
\multicolumn{1}{c|}{4}\\\hline
1 & 2 & 3 & 4\\\cline{3-3}
\end{array}\right]
\]
\end{LTXexample}
\section{Over- and underbraces}
\subsection{Braces and roots}
To put an underbrace in a root without enlarging the root symbol is possible with
the \verb+\makebox+ macro:
\[ z =\;\;\underbrace{\makebox[\widthof{~$x^2+y^2$}][r]{$\sqrt{x^2+y^2}$}}_{=z^2} \]
\begin{lstlisting}
\[
z =\;\;\underbrace{%
\makebox[\widthof{~$x^2+y^2$}][r]{%
$\sqrt{x^2+y^2}$}}_{=z^2}
\]
\end{lstlisting}
\subsection{Overlapping braces}
Overlapping under- and overbraces like%
\parbox{10em}{\begin{align*}
\qquad\overbrace{\qquad\qquad}^o\qquad\\[-16pt]
\underbrace{\qquad\qquad}_{u1}\underbrace{\qquad\qquad}_{u2}
\end{align*}} needs some tricky code, because we cannot have parts of the argument inside
\verb+overbrace+\index{overbrace@\textbackslash overbrace} and also \verb+underbrace+.
\index{underbrace@\textbackslash underbrace} The following equation~\vref{eq:pqFormel}
is an example for such a construction:
\begin{align}\label{eq:pqFormel}
y &= 2x^2 -3x +5\nonumber\\
& \hphantom{= \ 2\left(x^2-\frac{3}{2}\,x\right. }%
\textcolor{blue}{%
\overbrace{\hphantom{+\left(\frac{3}{4}\right)^2- %
\left(\frac{3}{4}\right)^2}}^{=0}}\nonumber\\[-11pt]
&= 2\left(\textcolor{red}{%
\underbrace{%
x^2-\frac{3}{2}\,x + \left(\frac{3}{4}\right)^2}%
}%
\underbrace{%
- \left(\frac{3}{4}\right)^2 + \frac{5}{2}}%
\right)\\
&= 2\left(\qquad\textcolor{red}{\left(x-\frac{3}{4}\right)^2}
\qquad + \ \frac{31}{16}\qquad\right)\nonumber\\
y\textcolor{blue}{-\frac{31}{8}}
&= 2\left(x\textcolor{cyan}{-\frac{3}{4}}\right)^2\nonumber
\end{align}
\medskip
\begin{lstlisting}[xrightmargin=-\marginparwidth]
\begin{align}\label{eq:pqFormel}
y &= 2x^2 -3x +5\nonumber\\
& \hphantom{= \ 2\left(x^2-\frac{3}{2}\,x\right. }%
\textcolor{blue}{%
\overbrace{\hphantom{+\left(\frac{3}{4}\right)^2- %
\left(\frac{3}{4}\right)^2}}^{=0}}\nonumber\\[-11pt]
&= 2\left(\textcolor{red}{%
\underbrace{%
x^2-\frac{3}{2}\,x + \left(\frac{3}{4}\right)^2}%
}%
\underbrace{%
- \left(\frac{3}{4}\right)^2 + \frac{5}{2}}%
\right)\\
&= 2\left(\qquad\textcolor{red}{\left(x-\frac{3}{4}\right)^2}
\qquad + \ \frac{31}{16}\qquad\right)\nonumber\\
y\textcolor{blue}{-\frac{31}{8}}
&= 2\left(x\textcolor{cyan}{-\frac{3}{4}}\right)^2\nonumber
\end{align}
\end{lstlisting}
\subsection[Vertical alignment]{Vertical alignment of different braces}
When having several braces in one formula line, then it looks better when all
braces are also on the same line, \eg
\begin{equation}
\binom{x_R}{y_R} = \underbrace{r\vphantom{\binom{A}{B}}}_{\text{Scaling}}\cdot%
\underbrace{%
\begin{pmatrix}
\sin \gamma & -\cos \gamma \\
\cos \gamma & \sin \gamma \\
\end{pmatrix}%
}_{\text{Rotation}}
\binom{x_K}{y_K} +
\underbrace{\binom{t_x}{t_y}}_{\text{Translation}}
\end{equation}
\begin{lstlisting}[xrightmargin=-\marginparwidth]
\begin{equation}
\binom{x_R}{y_R} = \underbrace{r\vphantom{\binom{A}{B}}}_{\text{Skaling}}\cdot%
\underbrace{%
\begin{pmatrix}
\sin \gamma & -\cos \gamma \\
\cos \gamma & \sin \gamma \\
\end{pmatrix}%
}_{\text{Rotation}}
\binom{x_K}{y_K} + \underbrace{\binom{t_x}{t_y}}_{\text{Translation}}
\end{equation}
\end{lstlisting}
It is again the \verb+\vphantom+ macro which reserves the needed vertical space.
Nevertheless the horizontal space around the \verb+r+ of the first underbrace and the last \verb|+| should
be decreased to get a better typesetting. This is possible with \verb+\hspace+ or
simply \verb+\kern+:
\[ \binom{x_R}{y_R} = %
\kern-10pt\underbrace{r\vphantom{\binom{A}{B}}}_{\text{Skaling}}\kern-10pt%
\cdot\underbrace{%
\begin{pmatrix}
\sin \gamma & -\cos \gamma \\
\cos \gamma & \sin \gamma \\
\end{pmatrix}%
}_{\text{Rotation}}
\binom{x_K}{y_K} +\kern-5pt%
\underbrace{\binom{t_x}{t_y}}_{\text{Translation}} \]
\begin{lstlisting}[xrightmargin=-\marginparwidth]
\[ \binom{x_R}{y_R} = %
\kern-10pt\underbrace{r\vphantom{\binom{A}{B}}}_{\text{Skaling}}\kern-10pt%
\cdot\underbrace{%
\begin{pmatrix}
\sin \gamma & -\cos \gamma \\
\cos \gamma & \sin \gamma \\
\end{pmatrix}%
}_{\text{Rotation}}
\binom{x_K}{y_K} +\kern-5pt%
\underbrace{\binom{t_x}{t_y}}_{\text{Translation}} \]
\end{lstlisting}
\subsection[Alignment]{Vertical and horizontal alignment}
The forgoing example simply uses \verb+\hspace+ to decrease the horizontal width between two
\index{underbrace@\textbackslash underbrace} underbraces. This may be okay for a single solution, but in general it is better to have some %%% ----- Martin -----
code which works in any case.
The following example looks simple but it needs some tricky code to get vertical and horizontal
alignment.\index{substack@\textbackslash substack}
\def\num#1{\hphantom{#1}}
\def\vsp{\vphantom{\rangle_1}}
\begin{equation*}
\frac{300}{5069}%
\underbrace{\longmapsto\vphantom{\frac{1}{1}}}_{%
\mathclap{\substack{%
\Delta a=271\num9\vsp \\[2pt]
\Delta b=4579\vsp\\[2pt]
\text{$1$ iteration}%
}}} \frac{29}{490}%
\underbrace{\longmapsto \frac{19}{321}\longmapsto}_{%
\mathclap{\substack{%
\Delta a=10\num{9}=\langle271\rangle_{29}\num{20}\\[2pt]
\Delta b=169=\langle4579\rangle_{490}\\[2pt]
\text{$2$ iterations}
}}} \frac{9}{152}
\underbrace{\longmapsto \frac{8}{135}\longmapsto\dots\longmapsto}_{%
\substack{%
\Delta a=1\num{7}=\langle10\rangle_{9}\num{119}\\[2pt]
\Delta b=17=\langle169\rangle_{152}\\[2pt]
\text{$8$ iterations}
}} \frac{1}{16}
\underbrace{\longmapsto\dots\longmapsto\vphantom{\frac{8}{135}}}_{%
\substack{%
\Delta a=0=\langle1\rangle_{1}\num{76} \\[2pt]
\Delta b=1=\langle17\rangle_{16} \\[2pt]
\text{$8$ iterations}
}} \frac{1}{1}
\end{equation*}
It uses the macro \verb+\mathclap+ defined in section\vref{subsec:ams-limits}
\index{mathclap@\textbackslash mathclap}\index{vphantom@\textbackslash vphantom}\index{hphantom@\textbackslash hphantom}
, which gives a better result. %%% ----- Martin -----
It is also possible to use \verb+\makebox[0pt]{...}+ but it works only in text mode
and this needs some more \verb+$...$+.\index{substack@\textbackslash substack}
\begin{lstlisting}[xrightmargin=-\marginparwidth]
\def\num#1{\hphantom{#1}}
\def\vsp{\vphantom{\rangle_1}}
\begin{equation*}
\frac{300}{5069}%
\underbrace{\longmapsto\vphantom{\frac{1}{1}}}_{%
\mathclap{\substack{%
\Delta a=271\num9\vsp \\[2pt]
\Delta b=4579\vsp\\[2pt]
\text{$1$ iteration}%
}}} \frac{29}{490}%
\underbrace{\longmapsto \frac{19}{321}\longmapsto}_{%
\mathclap{\substack{%
\Delta a=10\num{9}=\langle271\rangle_{29}\num{20}\\[2pt]
\Delta b=169=\langle4579\rangle_{490}\\[2pt]
\text{$2$ iterations}
}}} \frac{9}{152}
\underbrace{\longmapsto \frac{8}{135}\longmapsto\dots\longmapsto}_{%
\substack{%
\Delta a=1\num{7}=\langle10\rangle_{9}\num{119}\\[2pt]
\Delta b=17=\langle169\rangle_{152}\\[2pt]
\text{$8$ iterations}
}} \frac{1}{16}
\underbrace{\longmapsto\dots\longmapsto\vphantom{\frac{8}{135}}}_{%
\substack{%
\Delta a=0=\langle1\rangle_{1}\num{76} \\[2pt]
\Delta b=1=\langle17\rangle_{16} \\[2pt]
\text{$8$ iterations}
}} \frac{1}{1}
\end{equation*}
\end{lstlisting}
\section{Integrals}\label{sec:Integrals}
\index{underset@\textbackslash underset}
\def\Q#1#2{\frac{\partial #1}{\partial #2}}
%
The \emph{first theorem of Green} is:
\[
\underset{\mathcal{G}\quad}\iiint\!%
\left[u\nabla^{2}v+\left(\nabla u,\nabla v\right)\right]\mathrm{d}^{3}V%
=\underset{\mathcal{S}\quad}\oiint u\,\Q{v}{n}\,\,\mathrm{d}^{2}A
\]
The \emph{second theorem of Green} is:
\[
\underset{{\mathcal{G}\quad}}\iiint\!%
\left[u\nabla^{2}v-v\nabla^{2}u\right]\mathrm{d}^{3}V%
=\underset{\mathcal{S}\quad}\oiint%
\left(u\,\Q{v}{n}-v\,\Q{u}{n}\right)\mathrm{d}^{2}A
\]
They are both written with the \PIndex{esint} package%
\footnote{See section~\vref{sec:Integrals}.}, which gives nice integral symbols.
The \LaTeX{} code for the first equation is:
\begin{lstlisting}[xrightmargin=-\marginparwidth]
\[
\underset{\mathcal{G}\quad}\iiint\!%
\left[u\nabla^{2}v+\left(\nabla u,\nabla v\right)\right]\mathrm{d}^{3}V%
=\underset{\mathcal{S}\quad}\oiint u\,\Q{v}{n}\,\,\mathrm{d}^{2}A
\]
\end{lstlisting}
\noindent with the following definition in the preamble for the partial derivation:
\begin{lstlisting}
\def\Q#1#2{\frac{\partial#1}{\partial #2}}
\end{lstlisting}
\noindent which makes things easier to write.
%--------------------------------------------------------------------------
\section{Horizontal alignment}\label{sec:verticalAlignment}
%--------------------------------------------------------------------------
\subsection{Over more than one page}
%--------------------------------------------------------------------------
Sometimes it may be useful to have a vertical alignment over the whole page with a mix of %%% ----- Martin -----
formulas and text. Section \ref{sec:Text-in-math mode} shows the use of \CMD{intertext}.
There is another trick to get all formulas vertical aligned. Let's have the following
formulas distributed over the whole page:
%
\begin{align*}
f(x) &= a\\
g(x) &= x^2-4x\\
f(x)-g(x) &= x^2+x^3+x\\
g(x) &= x^2+x^3+x^4+x^5+b
\end{align*}
%
They all have a different length of the left and right side. Now we want to write some
text and other objects between them, but let the alignment untouched. We choose the
longest left and the longest right side and take them for scaling with the \CMD{hphantom}
command:
\begin{verbatim}
\hphantom{\mbox{$f(x)-g(x)$}} & \hphantom{\mbox{$= x^2+x^3+x^4+x^5+b$}}
\end{verbatim}
This is the first (empty) line in every equation where now all other lines are aligned to
this one. For example:
\bgroup
\medskip\noindent
\rule{\columnwidth}{1pt}
\newcommand{\x}{blah blah blah blah blah blah blah blah }
\addtolength\abovedisplayshortskip{-.5cm}% decrease the skip
\addtolength\abovedisplayskip{-.5cm}
\x\x\x
\begin{align}
\hphantom{\mbox{$f(x)-g(x)$}} & \hphantom{\mbox{$= x^2+x^3+x^4+x^5+b$}}\nonumber\\
f(x) &= a\\
g(x) &= x^2-4x
\end{align}
%
\x\x\x
\begin{align}
\hphantom{\mbox{$f(x)-g(x)$}} & \hphantom{\mbox{$= x^2+x^3+x^4+x^5+b$}}\nonumber\\
f(x)-g(x) &= x^2+x^3+x
\end{align}
\x\x\x
%
\begin{align}
\hphantom{\mbox{$f(x)-g(x)$}} & \hphantom{\mbox{$= x^2+x^3+x^4+x^5+b$}}\nonumber\\
g(x) &= x^2+x^3+x^4+x^5+b
\end{align}
\x\x\x
\noindent
\rule{\columnwidth}{1pt}
\egroup
\medskip
The phantom line is empty but leaves the vertical space for a line. This could be
corrected with decreasing the \CMD{abovedisplayshortskip} length and done all
inside a group.
\begin{lstlisting}[xrightmargin=-\marginparwidth]
\newcommand{\x}{blah blah blah blah blah blah blah blah }
\bgroup
\addtolength\abovedisplayshortskip{-0.5cm}% decrease the skip
\addtolength\abovedisplayskip{-0.5cm}
\x\x\x
\begin{align}
\hphantom{\mbox{$f(x)-g(x)$}} & \hphantom{\mbox{$= x^2+x^3+x^4+x^5+b$}}\nonumber\\
f(x) &= a\\
g(x) &= x^2-4x
\end{align}
%
\x\x\x
\begin{align}
\hphantom{\mbox{$f(x)-g(x)$}} & \hphantom{\mbox{$= x^2+x^3+x^4+x^5+b$}}\nonumber\\
f(x)-g(x) &= x^2+x^3+x
\end{align}
\x\x\x
%
\begin{align}
\hphantom{\mbox{$f(x)-g(x)$}} & \hphantom{\mbox{$= x^2+x^3+x^4+x^5+b$}}\nonumber\\
g(x) &= x^2+x^3+x^4+x^5+b
\end{align}
\x\x\x
\egroup
\end{lstlisting}
Another case of aligning equations inside an itemize environment is the following one.
With the \CIndex{makebox} macro one can have the same size on the left side of the
equal sign to get a vertical alignment.
\newsavebox\lW
\sbox\lW{$P_{3}+P_{2}-P_{1}$}% $
\begin{itemize}
\item first function \\
$\displaystyle\makebox[\wd\lW][r]{$P_1$}=\sum_a \in A$
\item but another one \\
$\makebox[\wd\lW][r]{$\sin\left(P_1\right)$}=blabla$
\item or perhaps \\
$P_{3}+P_{2}-P_{1}=blablub$
\end{itemize}
\begin{lstlisting}[xrightmargin=-\marginparwidth]
\newsavebox\lW
\sbox\lW{$P_{3}+P_{2}-P_{1}$}
\begin{itemize}
\item first function \\
$\displaystyle\makebox[\wd\lW][r]{$P_1$}=\sum_a \in A$
\item but another one \\
$\makebox[\wd\lW][r]{$\sin\left(P_1\right)$}=blabla$
\item or perhaps \\
$P_{3}+P_{2}-P_{1}=blablub$
\end{itemize}
\end{lstlisting}
%$
%--------------------------------------------------------------------------
\subsection{Special text columns}
%--------------------------------------------------------------------------
This one comes from Hartmut Henkel and offers a special form of placing
additional text between the equation and the \Index{equation number}. This makes only
sense when you load the documentclass with the option \verb+fleqn+. The example
places the additional text at \verb+0.5\textwidth+, changing this value is no
problem.
\clearpage
\medskip
\noindent\rule{\linewidth}{1pt}
\begingroup
\small
text text text text text text text text text text text text text text
text text text text text text text text text text text text text text
text text text text text text text text text text text text text text
text text text text text text text text text text text text text text
\makeatletter
\@fleqntrue
\let\old@mathmargin=\@mathmargin
\@mathmargin=-1sp
\let\oldmathindent=\mathindent
\let\mathindent=\@mathmargin
\newsavebox{\myendhook} % for the tabulars
\def\tagform@#1{{(\maketag@@@{\ignorespaces#1\unskip\@@italiccorr)}
\makebox[0pt][r]{% after the equation number
\makebox[0.5\textwidth][l]{\usebox{\myendhook}}}%
\global\sbox{\myendhook}{}% empty box
}}
\makeatother
\sbox{\myendhook}{%
\begin{footnotesize}%
\begin{tabular}{@{}ll}
$a_0$ & Bohrscher Radius ($\mathrm{= 0{,}53\,\mbox{\AA}}$)\\
$e$ & Elementarladung\\
$N_{si}$ & Anzahl der Siliziumatome\\
& pro Einheitsvolumen\\
$m$ & Atomgewicht\\
$Z$ & Kernladungszahl
\end{tabular}
\end{footnotesize}}
%
\begin{equation}
\varepsilon = \frac{E \cdot 4 \cdot \pi \cdot \varepsilon_{0}
\cdot a_0 \cdot \left( Z_i^{\frac{2}{3}} + Z_{Si}^{\frac{2}{3}}
\right)^{-\frac{1}{2}}} {Z_i \cdot Z_{Si} \cdot e2 \cdot \left( 1
+ \frac{m_i}{m_{Si}} \right)}\,;
\end{equation}
\sbox{\myendhook}{abc}
\begin{equation}
a2+b2=c2
\end{equation}
\begin{equation}
z = 9
\end{equation}
text text text text text text text text text text text text text text
text text text text text text text text text text text text text text
text text text text text text text text text text text text text text
text text text text text text text text text text text text text text
\endgroup
\noindent\rule{\linewidth}{1pt}
\medskip
This solution works only with \AmSmath{}, without you have to redefine the
\LaTeX{} macro, which creates the equation number.
\begin{lstlisting}[xrightmargin=-\marginparwidth]
\newsavebox{\myendhook} % for the tabulars
\def\tagform@#1{{(\maketag@@@{\ignorespaces#1\unskip\@@italiccorr)}
\makebox[0pt][r]{% after the equation number
\makebox[0.4\textwidth][l]{\usebox{\myendhook}}%
}%
\global\sbox{\myendhook}{}% clear box content
}}
[ ... ]
\sbox{\myendhook}{%
\begin{footnotesize}%
\begin{tabular}{@{}ll}
$a_0$ & Bohrscher Radius ($\mathrm{= 0{,}53\,\mbox{\AA}}$)\\
$e$ & Elementarladung\\
$N_{si}$ & Anzahl der Siliziumatome\\
& pro Einheitsvolumen\\
$m$ & Atomgewicht\\
$Z$ & Kernladungszahl
\end{tabular}
\end{footnotesize}}
%
\begin{equation}
\varepsilon = \frac{E \cdot 4 \cdot \pi \cdot \varepsilon_{0}
\cdot a_0 \cdot \left( Z_i^{\frac{2}{3}} + Z_{Si}^{\frac{2}{3}}
\right)^{-\frac{1}{2}}} {Z_i \cdot Z_{Si} \cdot e2 \cdot \left( 1
+ \frac{m_i}{m_{Si}} \right)}\,;
\end{equation}
%
\sbox{\myendhook}{abc}
%
\begin{equation} a2+b2=c2 \end{equation}
%
\begin{equation} z = 9 \end{equation}
\end{lstlisting}
%--------------------------------------------------------------------------
\subsection{Centered vertical dots}
%--------------------------------------------------------------------------
By default the vertical dots of \CMD{vdots} are aligned to the left of
the $=$ symbol and not centered.\index{vdots@\textbackslash vdots}
%
\bgroup
\newsavebox{\eqbox}% Heiko Bauke
\sbox{\eqbox}{$\null=\null$}
\newcommand{\Vdots}{\makebox[\wd\eqbox]{\vdots}}
%
\begin{align}
a_1 & = b_1 & c_1 & = d_1 \\
a_2 & = b_2 & c_2 & = d_2 \\
a & \Vdots b & & \Vdots \nonumber \\
a_n & = b_n & c_n & = d_n
\end{align}
\egroup
%
\begin{lstlisting}
\usepackage{amsmath}
...
\newsavebox{\eqbox}
\sbox{\eqbox}{$\null=\null$}
\newcommand{\Vdots}{\makebox[\wd\eqbox]{\vdots}}
\begin{align}
a_1 & = b_1 & c_1 & = d_1 \\
a_2 & = b_2 & c_2 & = d_2 \\
a & \Vdots b & & \Vdots \nonumber \\
a_n & = b_n & c_n & = d_n
\end{align}
\end{lstlisting}
%------------------------------------------------------------------------------
\section{Node connections}
%------------------------------------------------------------------------------
This is a typical application for PSTricks and it needs the package \verb+pst-node+
and doesn't work with \verb+pdflatex+. Use \verb+vlatex+, \verb+ps4pdf+ or \verb+ps2pdf+.
\medskip
\noindent\fbox{\includegraphics[width=\linewidth]{node}}
\iffalse
\noindent\fbox{\parbox{\linewidth-2\fboxsep-2\fboxrule}{%
\psset{nodesep=3pt}
\definecolor{lila}{rgb}{0.6,0.2,0.5}
\definecolor{darkyellow}{rgb}{1,0.9,0}
Die Bindungsenergie im Tr\"opfchenmodell setzt sich aus
folgenden Teilen zusammen:
\begin{itemize}
\item dem \rnode{b}{Oberfl\"achenanteil}
\item dem \rnode{a}{Volumenanteil},\\[0.75cm]
\def\xstrut{\vphantom{\frac{(A)^1}{(B)^1}}}
\begin{equation}
E =
\rnode[t]{ae}{\psframebox*[fillcolor=darkyellow,
linestyle=none]{\xstrut a_vA}} +
\rnode[t]{be}{\psframebox*[fillcolor=lightgray,
linestyle=none]{\xstrut -a_fA^{2/3}}} +
\rnode[t]{ce}{\psframebox*[fillcolor=green,
linestyle=none]{\xstrut -a_c\dfrac{Z(Z-1)}{A^{1/3}}}} +
\rnode[t]{de}{\psframebox*[fillcolor=cyan,
linestyle=none]{\xstrut -a_s\frac{(A-2Z)^2}{A}}} +
\rnode[t]{ee}{\psframebox*[fillcolor=yellow,
linestyle=none]{\xstrut E_p}}
\end{equation}\\
\item dem \rnode{c}{Coulomb-Anteil}
\item der \rnode{d}{Symmetrieenergie}
\item sowie einem \rnode{e}{Paarbildungsbeitrag}.
\end{itemize}
\nccurve[angleA=-90,angleB=90]{->}{a}{ae}
\nccurve[angleB=45]{->}{b}{be}
\nccurve[angleB=-90]{->}{c}{ce}
\nccurve[angleB=-90]{->}{d}{de}
\nccurve[angleB=-90]{->}{e}{ee}
}}
\fi
\medskip
\begin{lstlisting}[tabsize=4,xrightmargin=-\marginparwidth]
\psset{nodesep=3pt}
\definecolor{lila}{rgb}{0.6,0.2,0.5}
\definecolor{darkyellow}{rgb}{1,0.9,0}
Die Bindungsenergie im Tr\"opfchenmodell setzt sich aus
folgenden Teilen zusammen:
\begin{itemize}
\item dem \rnode{b}{Oberfl\"achenanteil}
\item dem \rnode{a}{Volumenanteil},\\[1cm]
\def\xstrut{\vphantom{\frac{(A)^1}{(B)^1}}}
\begin{equation}
E =
\rnode[t]{ae}{\psframebox*[fillcolor=darkyellow,
linestyle=none]{\xstrut a_vA}} +
\rnode[t]{be}{\psframebox*[fillcolor=lightgray,
linestyle=none]{\xstrut -a_fA^{2/3}}} +
\rnode[t]{ce}{\psframebox*[fillcolor=green,
linestyle=none]{\xstrut -a_c\frac{Z(Z-1)}{A^{1/3}}}} +
\rnode[t]{de}{\psframebox*[fillcolor=cyan,
linestyle=none]{\xstrut -a_s\frac{(A-2Z)^2}{A}}} +
\rnode[t]{ee}{\psframebox*[fillcolor=yellow,
linestyle=none]{\xstrut E_p}}
\end{equation}\\[0.25cm]
\item dem \rnode{c}{Coulomb-Anteil}
\item der \rnode{d}{Symmetrieenergie}
\item sowie einem \rnode{e}{Paarbildungsbeitrag}.
\end{itemize}
\nccurve[angleA=-90,angleB=90]{->}{a}{ae}
\nccurve[angleB=45]{->}{b}{be} \nccurve[angleB=-90]{->}{c}{ce}
\nccurve[angleB=-90]{->}{d}{de} \nccurve[angleB=-90]{->}{e}{ee}
\end{lstlisting}
%-----------------------------------------------------------------------------
\section[Special Placement]{Special placement of displayed equations}
%-----------------------------------------------------------------------------
%-----------------------------------------------------------------------------
\subsection{Formulas side by side}\label{sec:sidebyside}
%-----------------------------------------------------------------------------
Sometimes it may be useful to have numbered formulas side by side like the following ones:
%\begin{framed}
\begin{mtabular}{*{2}{m{0.35\linewidth}m{0.15\linewidth}}}
\begin{align*} \oint E ds=0 \end{align*} & \eqnCnt %
& \begin{align*} \nabla\cdot B=0 \end{align*} & \eqnCnt[\label{blah}]\\
\begin{align*} a =\frac{c}{d} \end{align*} & \eqnCnt %
& \begin{align*} b = 1 \end{align*} & \eqnCnt\\
\begin{align*} c =1 \end{align*} & \eqnCnt[\label{blub}]
& \begin{align*} \int 2x \,\mathrm{d}x = x^2+C \end{align*} & \eqnCnt
\end{mtabular}
%\end{framed}
And again a default display equation:
\begin{align}
F(x) &= \int_0^\infty\dfrac{1}{x}\,\mathrm{d}x
\end{align}
\begin{lstlisting}[tabsize=4,xrightmargin=-\marginparwidth]
\begin{mtabular}{*{2}{m{0.35\linewidth}m{0.15\linewidth}}}
\begin{align*} \oint E ds=0 \end{align*} & \eqnCnt %
& \begin{align*} \nabla\cdot B=0 \end{align*} & \eqnCnt[\label{blah}]\\
\begin{align*} a =\frac{c}{d} \end{align*} & \eqnCnt %
& \begin{align*} b = 1 \end{align*} & \eqnCnt\\
\begin{align*} c =1 \end{align*} & \eqnCnt[\label{blub}]
& \begin{align*} \int 2x \,\mathrm{d}x = x^2+C \end{align*} & \eqnCnt
\end{mtabular}
\end{lstlisting}
The new environment \verb|mtabular| has two arguments, one optional and one which is the same
as the one from the \verb|tabular| environment. With the option \verb|long| it is possible to have %%% ----- Martin -----
all the formulas in a \verb|longtable| environment, which allows a pagebreak. The new macro
\verb|\eqnCnt| controls the counting of these equations as subequations for one tabular
line. This macro can have an optional argument for a label. At least it counts
the equations. If the
equation number is not centered to the foregoing equation, then it needs some more horizontal
space in the tabular column.
\begin{verbatim}
\eqnCnt[<optional label>]
\end{verbatim}
The vertical space is controlled by the length \verb|mtabskip|, which
is by default \verb|-1.25cm| and can be modified in the usual way.
To define all these macros write into the preamble:
\begin{lstlisting}[tabsize=4,xrightmargin=-\marginparwidth]
\usepackage{amsmath}
\newcounter{subequation}
\newlength\mtabskip\mtabskip=-1.25cm
\newcommand\eqnCnt[1][]{%
\refstepcounter{subequation}%
\begin{align}#1\end{align}%
\addtocounter{equation}{-1}}
\def\mtabLong{long}
\makeatletter
\newenvironment{mtabular}[2][\empty]{%
\def\@xarraycr{%
\stepcounter{equation}%
\setcounter{subequation}{0}%
\@ifnextchar[\@argarraycr{\@argarraycr[\mtabskip]}}
\let\theoldequation\theequation%
\renewcommand\theequation{\theoldequation.\alph{subequation}}
\edef\mtabOption{#1}
\setcounter{subequation}{0}%
\tabcolsep=0pt
\ifx\mtabOption\mtabLong\longtable{#2}\else\tabular{#2}\fi%
}{%
\ifx\mtabOption\mtabLong\endlongtable\else\endtabular\fi%
\let\theequation\theoldequation%
\stepcounter{equation}}
\makeatother
\end{lstlisting}
As seen in equation~\ref{blub} and equation~\ref{blah}, everything of the table contents is
nonsense~\ldots And the following tabular is defined as a \Index{longtable} to enable pagebreaks.
%which is the reason for the following big skip, to show that it works.
%\vspace*{3cm}
%\begin{framed}
\begin{mtabular}[long]{*{2}{m{0.35\linewidth}m{0.15\linewidth}}}
\begin{align*} \oint E ds=0 \end{align*} & \eqnCnt %
& \begin{align*} \nabla\cdot B=0 \end{align*} & \eqnCnt\\
\begin{align*} a =\frac{c}{d} \end{align*} & \eqnCnt %
& \begin{align*} b = 1 \end{align*} & \eqnCnt\\
\begin{align*} c =1 \end{align*} & \eqnCnt
& \begin{align*} \int 2x \,\mathrm{d}x = x^2+C \end{align*} & \eqnCnt\\
\begin{align*} \oint E ds=0 \end{align*} & \eqnCnt %
& \begin{align*} \nabla\cdot B=0 \end{align*} & \eqnCnt\\
\begin{align*} a =\frac{c}{d} \end{align*} & \eqnCnt %
& \begin{align*} b = 1 \end{align*} & \eqnCnt\\
\begin{align*} c =1 \end{align*} & \eqnCnt
& \begin{align*} \int 2x \,\mathrm{d}x = x^2+C \end{align*} & \eqnCnt\\
\begin{align*} \oint E ds=0 \end{align*} & \eqnCnt %
& \begin{align*} \nabla\cdot B=0 \end{align*} & \eqnCnt[\label{blah2}]\\
\begin{align*} a =\frac{c}{d} \end{align*} & \eqnCnt %
& \begin{align*} b = 1 \end{align*} & \eqnCnt\\
\begin{align*} c =1 \end{align*} & \eqnCnt[\label{blub2}]
& \begin{align*} \int 2x \,\mathrm{d}x = x^2+C \end{align*} & \eqnCnt\\
\begin{align*} \oint E ds=0 \end{align*} & \eqnCnt %
& \begin{align*} \nabla\cdot B=0 \end{align*} & \eqnCnt\\
\begin{align*} a =\frac{c}{d} \end{align*} & \eqnCnt %
& \begin{align*} b = 1 \end{align*} & \eqnCnt\\
\begin{align*} c =1 \end{align*} & \eqnCnt
& \begin{align*} \int 2x \,\mathrm{d}x = x^2+C \end{align*} & \eqnCnt
\end{mtabular}
%\end{framed}
As seen in equation~\ref{blub2} and equation~\ref{blah2}, everything is nonsense ...
And again a default display equation:
\begin{align}
F(x) &= \int_0^\infty\dfrac{1}{x}\,\mathrm{d}x
\end{align}
\begin{lstlisting}[tabsize=4]
\begin{mtabular}[long]{*{2}{m{0.375\linewidth}m{0.125\linewidth}}}
\begin{align*} \oint E ds=0 \end{align*} & \eqnCnt %
& \begin{align*} \nabla\cdot B=0 \end{align*} & \eqnCnt\\
\begin{align*} a =\frac{c}{d} \end{align*} & \eqnCnt %
& \begin{align*} b = 1 \end{align*} & \eqnCnt\\
\begin{align*} c =1 \end{align*} & \eqnCnt
& \begin{align*} \int 2x \,\mathrm{d}x = x^2+C \end{align*} & \eqnCnt\\
[ ... ]
\end{lstlisting}
%-----------------------------------------------------------------------------
\subsection[Itemize environment]{Formulas inside an itemize enviroment}\label{sec:itemize}
%-----------------------------------------------------------------------------
Without any modification it is not possible to get a numbered equation
at the same height as the symbol of the itemize environment\index{itemize@\texttt{itemize}}. This depends on %%% ----- Martin -----
the \LIndex{abovedisplayskip}. The formula has to be raised up for exactly this length.
\begin{lstlisting}
\def\itemMath#1{%
\raisebox{-\abovedisplayshortskip}{%
\parbox{0.75\linewidth}{%
\begin{equation}#1\end{equation}}}}
%
\begin{itemize}
\item \itemMath{ f = l }
\item \itemMath{ g(x) = \int f(x)\,\mathrm{d}x }
\end{itemize}
\end{lstlisting}
\def\itemMath#1{%
\raisebox{-\abovedisplayshortskip}{%
\parbox{0.75\linewidth}{%
\begin{equation}#1\end{equation}}}}
%
\begin{itemize}
\item \itemMath{ f = l }
\item \itemMath{ g(x) = \int f(x)\,\mathrm{d}x }
\end{itemize}
\section{Roots}
There exists no special symbol for roots\index{Root} which are longer than one line. In such
cases the root should be split into two or more one, like $\sqrt{a\cdot b\cdot c}=\sqrt{a}\cdot\sqrt{a}\cdot\sqrt{b}\cdot\sqrt{c}$
if possible. If nothing helps one can use \CMD{overline}\cIndex{overline} for
following lines of the root. The following example uses the \verb+multline+ environment
to get only one equation number:
\begin{multline}
d(P,Q)|_{Stat.,Dependent}=\\
\sqrt{\left[a_{11}(x_{1}-y_{1})^{2}+a_{22}(x_{2}-y_{2})^{2}+
\ldots+a_{pp}(x_{p}-y_{p})^{2}\right]+} \\
\overline{\rule{0pt}{2.5ex}
\left[2a_{12}(x_{1}-y_{1})(x_{2}-y_{2})+2a_{13}
(x_{1}-y_{1})(x_{3}-y_{3}) + \right.}\\
\overline{\rule{0pt}{2.5ex}
\left.\ldots +2a_{p-1,p}(x_{p-1}-y_{p-1})(x_{p}-y_{p})\right]}
\end{multline}
\begin{lstlisting}
\begin{multline}
d(P,Q)|_{Stat.,Dependent}=\\
\sqrt{\left[a_{11}(x_{1}-y_{1})^{2}+a_{22}(x_{2}-y_{2})^{2}+
\ldots+a_{pp}(x_{p}-y_{p})^{2}\right]+} \\
\overline{\rule{0pt}{2.5ex}
\left[2a_{12}(x_{1}-y_{1})(x_{2}-y_{2})+2a_{13}
(x_{1}-y_{1})(x_{3}-y_{3}) + \right.}\\
\overline{\rule{0pt}{2.5ex}
\left.\ldots +2a_{p-1,p}(x_{p-1}-y_{p-1})(x_{p}-y_{p})\right]}
\end{multline}
\end{lstlisting}
Alternative:
\begin{multline}
d(P,Q)|_{Stat.,Dependent}=\\
\Big(\left[a_{11}(x_{1}-y_{1})^{2}+a_{22}(x_{2}-y_{2})^{2}+
\ldots+a_{pp}(x_{p}-y_{p})^{2}\right]+ \\
\left[2a_{12}(x_{1}-y_{1})(x_{2}-y_{2})+2a_{13}
(x_{1}-y_{1})(x_{3}-y_{3}) + \right.\\
\left.\ldots +2a_{p-1,p}(x_{p-1}-y_{p-1})(x_{p}-y_{p})\right]\Big)^{1/2}
\end{multline}
\begin{lstlisting}
\begin{multline}
d(P,Q)|_{Stat.,Dependent}=\\
\left\{\left[a_{11}(x_{1}-y_{1})^{2}+a_{22}(x_{2}-y_{2})^{2}+
\ldots+a_{pp}(x_{p}-y_{p})^{2}\right]+\right. \\
\left[2a_{12}(x_{1}-y_{1})(x_{2}-y_{2})+2a_{13}
(x_{1}-y_{1})(x_{3}-y_{3}) + \right.\\
\left.\left.\ldots +2a_{p-1,p}(x_{p-1}-y_{p-1})(x_{p}-y_{p})\right]\right\}^{1/2}
\end{multline}
\end{lstlisting}
\part{Lists, bibliography and index}
\bgroup
\lhead{}\rhead{}
\clearpage\phantomsection\addcontentsline{toc}{section}{List of Figures}
\listoffigures
\clearpage\phantomsection\addcontentsline{toc}{section}{List of Tables}
\listoftables
\clearpage\phantomsection\addcontentsline{toc}{section}{Bibliography}
{\nocite{*}
\raggedright
\bibliography{Mathmode}
\bibliographystyle{plain}
}
\clearpage\addcontentsline{toc}{section}{Index}
{\let\BSL\textbackslash
\renewcommand\textbackslash{{\ttfamily\BSL}}
\printindex{}
}
\egroup
\appendix
\section*{Appendix}
\section{Filelist}
This document was build with
\begin{lstlisting}[breaklines,xrightmargin=-\marginparwidth]
This is pdfTeXk, Version 3.1415926-1.40.9 (Web2C 7.5.7) (format=pdflatex 2008.10.24) 30 OCT 2008 10:19
\end{lstlisting}
and with the following file and package versions:
\begin{lstlisting}[breaklines,xrightmargin=-\marginparwidth]
*File List*
article.cls 2005/09/16 v1.4f Standard LaTeX document class
size11.clo 2005/09/16 v1.4f Standard LaTeX file (size option)
fixltx2e.sty 2006/03/24 v1.1n fixes to LaTeX
fontenc.sty
t1enc.def 2005/09/27 v1.99g Standard LaTeX file
inputenc.sty 2006/05/05 v1.1b Input encoding file
latin1.def 2006/05/05 v1.1b Input encoding file
bera.sty 2004/01/31 (WaS)
fontenc.sty
t1enc.def 2005/09/27 v1.99g Standard LaTeX file
textcomp.sty 2005/09/27 v1.99g Standard LaTeX package
ts1enc.def 2001/06/05 v3.0e (jk/car/fm) Standard LaTeX file
beraserif.sty 2004/01/30 (WaS)
keyval.sty 1999/03/16 v1.13 key=value parser (DPC)
t1fve.fd 2004/09/07 scalable font definitions for T1/fve.
berasans.sty 2004/01/30 (WaS)
beramono.sty 2004/01/31 (WaS)
ifpdf.sty 2007/12/12 v1.6 Provides the ifpdf switch (HO)
ifvtex.sty 2007/09/09 v1.3 Switches for detecting VTeX and its modes (HO)
comment.sty
graphicx.sty 1999/02/16 v1.0f Enhanced LaTeX Graphics (DPC,SPQR)
graphics.sty 2006/02/20 v1.0o Standard LaTeX Graphics (DPC,SPQR)
trig.sty 1999/03/16 v1.09 sin cos tan (DPC)
graphics.cfg 2007/01/18 v1.5 graphics configuration of teTeX/TeXLive
pdftex.def 2008/09/08 v0.04l Graphics/color for pdfTeX
varwidth.sty 2003/03/10 ver 0.9a; Variable-width minipages
array.sty 2005/08/23 v2.4b Tabular extension package (FMi)
delarray.sty 1994/03/14 v1.01 array delimiter package (DPC)
tabularx.sty 1999/01/07 v2.07 `tabularx' package (DPC)
amsmath.sty 2000/07/18 v2.13 AMS math features
amstext.sty 2000/06/29 v2.01
amsgen.sty 1999/11/30 v2.0
amsbsy.sty 1999/11/29 v1.2d
amsopn.sty 1999/12/14 v2.01 operator names
amssymb.sty 2002/01/22 v2.2d
amsfonts.sty 2001/10/25 v2.2f
bm.sty 2004/02/26 v1.1c Bold Symbol Support (DPC/FMi)
upgreek.sty 2003/02/12 v2.0 (WaS)
cancel.sty 2000/03/12 v2.1 Cancel math terms
amscd.sty 1999/11/29 v1.2d
accents.sty 2006/05/12 v1.3 Math Accent Tools
dsfont.sty 1995/08/01 v0.1 Double stroke roman fonts
multirow.sty
bigdelim.sty
framed.sty 2007/10/04 v 0.95: framed or shaded text with page breaks
longtable.sty 2004/02/01 v4.11 Multi-page Table package (DPC)
varioref.sty 2006/05/13 v1.4p package for extended references (FMi)
xcolor.sty 2007/01/21 v2.11 LaTeX color extensions (UK)
color.cfg 2007/01/18 v1.5 color configuration of teTeX/TeXLive
makeidx.sty 2000/03/29 v1.0m Standard LaTeX package
url.sty 2006/04/12 ver 3.3 Verb mode for urls, etc.
setspace.sty 2000/12/01 6.7 Contributed and Supported LaTeX2e package
empheq.sty 2007/12/03 v2.12 Emphasizing equations (MH)
mhsetup.sty 2007/12/03 v1.2 programming setup (MH)
mathtools.sty 2008/08/01 v1.06 mathematical typesetting tools (MH)
calc.sty 2005/08/06 v4.2 Infix arithmetic (KKT,FJ)
nicefrac.sty 1998/08/04 v0.9b Nice fractions
ifthen.sty 2001/05/26 v1.1c Standard LaTeX ifthen package (DPC)
exscale.sty 1997/06/16 v2.1g Standard LaTeX package exscale
relsize.sty 2003/07/04 ver 3.1
xspace.sty 2006/05/08 v1.12 Space after command names (DPC,MH)
eucal.sty 2001/10/01 v2.2d Euler Script fonts
footmisc.sty 2007/06/12 v5.4a a miscellany of footnote facilities
esint.sty
esvect.sty
remreset.sty
cool.sty 2006/12/29 v1.35 COntent Oriented LaTeX
coollist.sty 2007/10/06 v1.2 COntent Oriented LaTeX Lists
coolstr.sty 2007/01/08 v2.1 COntent Oriented LaTeX Strings
forloop.sty 2006/09/18 v3.0 For Loops for LaTeX
bbm.sty 1999/03/15 V 1.2 provides fonts for set symbols - TH
xypic.sty 1999/02/16 Xy-pic version 3.7
xy.sty
fancyhdr.sty
showexpl.sty 2007/02/03 v0.3h Typesetting example code (RN)
listings.sty 2007/02/22 1.4 (Carsten Heinz)
lstmisc.sty 2007/02/22 1.4 (Carsten Heinz)
listings.cfg 2007/02/22 1.4 listings configuration
lstmisc.sty 2007/02/22 1.4 (Carsten Heinz)
showexpl.cfg 2005/06/30 v0.02 Definitions for the showexpl package (hv)
lstlang1.sty 2004/09/05 1.3 listings language file
lstlang2.sty 2004/09/05 1.3 listings language file
lstlang3.sty 2004/09/05 1.3 listings language file
lstlang1.sty 2004/09/05 1.3 listings language file
lstlang2.sty 2004/09/05 1.3 listings language file
lstlang3.sty 2004/09/05 1.3 listings language file
lstlang1.sty 2004/09/05 1.3 listings language file
lstlang2.sty 2004/09/05 1.3 listings language file
lstlang3.sty 2004/09/05 1.3 listings language file
lstlang1.sty 2004/09/05 1.3 listings language file
lstlang2.sty 2004/09/05 1.3 listings language file
lstlang3.sty 2004/09/05 1.3 listings language file
lstmisc.sty 2007/02/22 1.4 (Carsten Heinz)
microtype.sty 2008/06/04 v2.3b Micro-typography with pdfTeX (RS)
microtype.cfg 2008/06/04 v2.3b microtype main configuration file (RS)
hyperref.sty 2008/09/29 v6.78l Hypertext links for LaTeX
ifxetex.sty 2008/09/18 v0.4 Provides ifxetex conditional
hycolor.sty 2008/09/08 v1.4 Code for color options of hyperref/bookmark (HO
)
xcolor-patch.sty 2008/09/08 xcolor patch
pd1enc.def 2008/09/29 v6.78l Hyperref: PDFDocEncoding definition (HO)
etexcmds.sty 2007/12/12 v1.2 Prefix for e-TeX command names (HO)
infwarerr.sty 2007/09/09 v1.2 Providing info/warning/message (HO)
hyperref.cfg 2002/06/06 v1.2 hyperref configuration of TeXLive
kvoptions.sty 2007/10/18 v3.0 Keyval support for LaTeX options (HO)
bitset.sty 2007/09/28 v1.0 Data type bit set (HO)
intcalc.sty 2007/09/27 v1.1 Expandable integer calculations (HO)
bigintcalc.sty 2007/11/11 v1.1 Expandable big integer calculations (HO)
pdftexcmds.sty 2007/12/12 v0.3 LuaTeX support for pdfTeX utility functions (
HO)
kvsetkeys.sty 2007/09/29 v1.3 Key value parser with default handler support
(HO)
atbegshi.sty 2008/07/31 v1.9 At begin shipout hook (HO)
hpdftex.def 2008/09/29 v6.78l Hyperref driver for pdfTeX
hypcap.sty 2008/09/08 v1.10 Adjusting anchors of captions (HO)
babel.sty 2008/07/06 v3.8l The Babel package
english.ldf 2005/03/30 v3.3o English support from the babel system
braket.sty
ts1cmr.fd 1999/05/25 v2.5h Standard LaTeX font definitions
supp-pdf.tex
nameref.sty 2007/05/29 v2.31 Cross-referencing by name of section
refcount.sty 2008/08/11 v3.1 Data extraction from references (HO)
Mathmode.out
Mathmode.out
Mathmode.tex
mt-cmr.cfg 2008/02/29 v1.9a microtype config. file: Computer Modern Roman
(RS)
umsa.fd 2002/01/19 v2.2g AMS font definitions
mt-msa.cfg 2006/02/04 v1.1 microtype config. file: AMS symbols (a) (RS)
umsb.fd 2002/01/19 v2.2g AMS font definitions
mt-msb.cfg 2005/06/01 v1.0 microtype config. file: AMS symbols (b) (RS)
mt-eur.cfg 2006/07/31 v1.1 microtype config. file: AMS Euler Roman (RS)
uesint.fd
uesvect.fd
ts1fve.fd 2004/09/07 scalable font definitions for TS1/fve.
t1fvm.fd 2004/09/07 scalable font definitions for T1/fvm.
images/styles.pdf
images/amsalign.pdf
t1fvs.fd 2004/09/07 scalable font definitions for T1/fvs.
images/family.pdf
images/EuScript.pdf
images/exscale.pdf
images/cm-crop.pdf
images/lm-crop.pdf
images/pazo-crop.pdf
images/pamath-crop.pdf
images/cmbright-crop.pdf
images/minionpro-crop.pdf
images/colArray.pdf
images/node.pdf
Mathmode.bbl
Mathmode.ind
\end{lstlisting}
%\clearpage
%\layout
|