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
|
%% Thanks for your interest in A Gentle Introduction to TeX.
%% Any comments on this manual would be appreciated. These may
%% be typesetting, English, or TeX criticisms. If you decide to
%% translate this document into another language, I'd appreciate
%% receiving a copy.
%%
%% This file is a complete TeX input file. Just run it
%% through TeX and print out the resulting "DVI" file. If you are
%% familiar with TeX, the macros at the top of the file have a few
%% switches which you may want to set. If you have problems or
%% can't run TeX at all, write to me and I'll send you a hard copy.
%% You can get a bound copy from the TeX Users Group at the address
%% given below.
%%
%% You should feel free to photocopy and/or distribute this manual.
%% My only request is that it remain in one piece and not be chopped
%% up. The only machine dependent section (#1.2) may need to be
%% rewritten for your local site, of course.
%%
%%% Michael Doob
%% Department of Mathematics
%% The University of Manitoba
%% Winnipeg, Manitoba R3T 2N2
%% Canada
%% mdoob@uofmcc (bitnet)
%% mdoob@ccu.umanitoba.ca (internet)
%%
%% Here is a character listing to check to be sure that no
%% unwanted translations took place within the bowels of the net.
%% Upper case letters: ABCDEFGHIJKLMNOPQRSTUVWXYZ
%% Lower case letters: abcdefghijklmnopqrstuvwxyz
%% round parentheses, square brackets, curly braces: () [] {}
%% Exclaim, at, sharp, dollar, percent: ! @ # $ %
%% Caret, ampersand, star, underscore, hyphen: ^ & * _ -
%% vertical bar, backslash, tilde, backprime, plus: | \ ~ ` +
%% plus, equal, prime, quote, colon: + = ' " :
%% less than, greater than, slash, question, comma: < > / ? ,
%% period, semicolon: . ;
%%
%%
%%
%% Now here come the macros used in this manual. If you are
%% already familiar with TeX, you may want to fiddle with them.
%% In particular, the hooks are left to generate a new control
%% word index and table of contents if you change section 1.2.
%%
%%
%%%%%%%% Here are the fonts other than the sixteen defined in %%%%%%%%
%%%%%%%%%%%%% plain.tex that are used %%%%%%%%%%%%%%%%%%
%%%% first, choose between amr or cmr fonts %%%
\newif \ifamrfonts
\amrfontsfalse % use this line if you use the cmr fonts
%\amrfontstrue % use this line if you use the old amr fonts
\ifamrfonts \font\brm=amr10 scaled \magstep1
\else \font\brm=cmr10 scaled \magstep1 \fi
\ifamrfonts \font\halfrm=amr10 scaled \magstephalf
\else \font\halfrm=cmr10 scaled \magstephalf \fi
\ifamrfonts \font\bbrm=amr10 scaled \magstep2
\else \font\bbrm=cmr10 scaled \magstep2 \fi
\ifamrfonts \font\bbbrm=amr10 scaled \magstep3
\else \font\bbbrm=cmr10 scaled \magstep3 \fi
\ifamrfonts \font\bbbbrm=amr10 scaled \magstep4
\else\font \bbbbrm=cmr10 scaled \magstep4 \fi
\ifamrfonts \font\bbbbbrm=amr10 scaled \magstep5
\else \font\bbbbbrm=cmr10 scaled \magstep5 \fi
\ifamrfonts \font\sf = amssmc10
\else \font\sf = cmss10 \fi
\ifamrfonts \font\chapfont=ambx10 scaled \magstep2
\else \font\chapfont=cmbx10 scaled \magstep2 \fi
\ifamrfonts \font\secfont=ambx10 scaled \magstep1
\else \font\secfont=cmbx10 scaled \magstep1 \fi
\ifamrfonts \font\sc= amcsc10
\else \font\sc= cmcsc10 \fi
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%\vbadness=10000 %%%%%% I don't want to hear about underfull vboxes
\raggedbottom %%%%% delete this line for aligned page bottoms
\hsize=5.5in
\vsize=7in
\voffset=.75in
\parskip=\baselineskip
\widowpenalty=1000 \clubpenalty=1000 %%% I hate widows and orphans! %%%
%%%%%%%%% choosing between Canadian and American spellings %%%%%%%%%
\newif \ifcanspell
\canspelltrue %%%% Canadian spelling
%\canspellfalse %%% use this line for American spelling
\def\aesthetic{\ifcanspell \ae{}sthetic\else esthetic\fi}
\def\analogue{\ifcanspell analogue\else analog\fi}
\let\analog=\analogue
\def\cancelled{\ifcanspell cancelled\else canceled\fi}
\let\canceled=\cancelled
\def\centimetre{\ifcanspell centimetre\else centimeter\fi}
\let\centimeter=\centimetre
\def\centre{\ifcanspell centre\else center\fi}
\let\center=\centre
\def\centred{\ifcanspell centred\else centered\fi}
\let\centered=\centred
\def\our{\ifcanspell our\else or\fi}
\def\postcode{\ifcanspell postalcode\else zipcode\fi}
\def\province{\ifcanspell province\else state\fi}
\def\theatre{\ifcanspell theatre\else theater\fi}
\let\theater=\theatre
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%% First check to see if using plain format %%%%%%%%%%%%%%%%%
\def\shouldbefmt{plain}
\ifx\shouldbefmt\fmtname
\else
\immediate\write16{}
\immediate\write16{***** WARNING WARNING WARNING *****}
\immediate\write16{You probably need to use the command}
\immediate\write16{tex \string<filename\string>}
\immediate\write16{to make your dvi file (not latex).}
\immediate\write16{***** WARNING WARNING WARNING *****}
\immediate\write16{}
\fi
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%% headline routines %%%%%%%%%%%%%%%%%%%%%%%%%%%%
\def\gentleheadline{%
\vbox {\hrule%
\line {\strut \vrule \quad \tenrm A \TeX{} intro
\ifcanspell (Canadian \else (U.S. \fi spelling)
\hfil
\ifnum \secnum > 0 Section \the\secnum: \fi \sectiontitle \quad
\vrule}%
\hrule}%
}
\newif \iftitlepage \titlepagetrue
\headline=
{\iftitlepage \hfil \global\titlepagefalse \else \gentleheadline \fi}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%% define contents and index files %%%%%%%%%%%%%%%%%%%%%%
%%% Normally the contents and index are hard coded into the input file. %%%
%% To generate new ones, use \writingcontentstrue and \writingindextrue. %%
\newif \ifwritingcontents
\newif \ifwritingindex
\newwrite\contents \newwrite\index
\writingcontentsfalse \writingindexfalse
%%% \writingcontentstrue %%% use this line to make the contents
%%% \writingindextrue %%% use this line to make the index
\ifwritingcontents \openout\contents=contents.tex \fi
\ifwritingindex \openout\index=index.tex
\def\toindex#1{\immediate\write\index{#1 \the\pageno}}
\else \def\toindex#1{} \fi
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%% determine whether answers are printed %%%%%%%%%%%%%%%%
\newif \ifwritinganswers
\writinganswersfalse %%% use this line to suppress answer section
\writinganswerstrue %%% use this line to include answer section
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%% footnote macro with counter %%%%%%%%%%%%
\newcount\footnotenum \footnotenum=0
\def\fnote#1{\advance \footnotenum by 1%
\footnote{$^{\the\footnotenum}$}{#1}}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%% exercise, section, and subsection macros %%%%%%%%%%%%
\newcount\exno %%%%%% counter for exercises %%%%%%%%
\newcount\secnum \secnum=0 %%%% counter for section numbers %%%%
\newcount\subsecnum
\def\section#1{
\vfill\eject %%%%% new section starts on a new page
%%%\ifodd\pageno \else\ \vfill\eject \fi %start on an odd page
\advance\secnum by 1 \subsecnum=0 \exno=0
\ifnum \secnum = 1 \pageno=1 \fi
\ifnum \secnum > 0
\leftline{\chapfont Section \the\secnum}
\vskip 3pt \fi
\leftline{\chapfont #1}
\def\sectiontitle{#1}
\vskip\baselineskip
\hrule
\vskip 1cm
\ifwritingcontents \write\contents{\string\line\string{#1
\string\dotfill{}
\ifnum \pageno < 0 \romannumeral-\pageno
\else \the\pageno \fi
\string}}\fi
\titlepagetrue}
\def\subsection#1{\advance\subsecnum by 1
\vskip 30pt
\leftline{\secfont \the\secnum .\the\subsecnum\ #1}
\nobreak
\ifwritingcontents
\write\contents{\string\line\string{\string\qquad{}#1
\string\dotfill{} \the\pageno\string}}\fi
}
\def\exercise{\global\advance \exno by 1
\vskip\baselineskip
\noindent $\triangleright$ Exercise \the\secnum.\the\exno\quad
}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% definitions of control sequences for characters in the typewriter font %%%
%%%% for short phrases this is easier than using a literal construction %%%%
\def\\{\char92{}} %%%%% backslash %%%%%
\def\lb{\char'173{}} %%%%% left brace %%%%%
\def\rb{\char'175{}} %%%%% right brace %%%%%
\def\sp{\char32{}} %%%%% special space symbol %%%%%
\def\beginliteral{
\vskip\baselineskip
\begingroup
\tt
\obeylines
%{\obeyspaces\global\let =\ }
\catcode`\@=0
\parskip=0pt\parindent=0pt
\catcode`\$=12\catcode`\&=12\catcode`\^=12\catcode`\#=12
\catcode`\_=12\catcode`\~=12
\def\par{\leavevmode\endgraf}
\catcode`\{=12\catcode`\}=12\catcode`\%=12\catcode`\\=12
}
\def\endliteral{\endgroup}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%% inhibit hyphenation of typewriter text %%%%%%%%%%%%%%
\hyphenchar\tentt=-1
%%%%%%%%%%%% grouping to make input listing in typewriter type %%%%%%%
\def\beginuser{\vskip\parskip
\everypar={\nobreak}
\begingroup
\tt \obeylines \parskip=0pt \parindent=0pt}
\def\enduser{\endgroup}
%%%%%%%%%%% macro to construct tables (easily) %%%%%%%%%%%%%%%%
%%% parameters: title goes between brackets, rest of the
%%% paragraph is the table
\def\maketable[#1]#2\par{
\setbox1=\vbox{#2}
$$\vbox{
\hbox to \wd1{\bf \hss #1 \hss}
\vskip 12pt
\box1
}
$$
}
%%%%%%%%%%% end of macro to construct tables %%%%%%%%%%%%%%%%
%%%%%%%%%%% macro to put a box around the text %%%%%%%%%%%%%%%%
\def\makebox#1#2#3% vsize, hsize, inserted text
{\hbox{\vrule
\vbox to #1{\hrule \vss
\hbox to #2{\hss#3\hss}\vss
\hrule}\vrule}}
\def\displaytext#1{$$\hbox{#1}$$}
\def\LaTeX{{\rm L\kern-.36em\raise.3ex\hbox{\sc a}\kern-.15em
T\kern-.1667em\lower.7ex\hbox{E}\kern-.125emX}}
\def\AMSTeX{{$\cal A$}\kern-.1667em\lower.5ex\hbox
{$\cal M$}\kern-.125em{$\cal S$}-\TeX}
%%%%%%%%%%%% macro to put TeX references in right margin %%%%%%%%
\newdimen\theight
\def \TeXref#1{%
\vadjust{\setbox0=\hbox{\sevenrm\quad\quad\TeX book: #1}%
\theight=\ht0
\advance\theight by \dp0 \advance\theight by \lineskip
\kern -\theight \vbox to \theight{\rightline{\rlap{\box0}}%
\vss}%
}}%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\def\version{1.1}
%%%%%%%%%%%% macro to write the date out the date and time %%%%%%%%%%%
%%%%%%%%%%%% TeXbook p. 406 for date %%%%%%%%%%%
\def\today{\ifcase\month\or January\or February\or March\or April\or
May\or June\or July\or August\or September\or October\or November\or
December\fi \space\number\day, \number\year}
\newcount\hour \newcount\minute
\hour=\time \divide \hour by 60
\minute=\time
\loop \ifnum \minute > 59 \advance \minute by -60 \repeat
\def\writetime{\ifnum \hour<13 \number\hour:% % supresses leading 0's
\ifnum \minute<10 0\fi% % so add it it
\number\minute
\ifnum \hour < 12 \ A.M. \else \ P.M. \fi
\else \advance \hour by -12 \number\hour:% % supresses leading 0's
\ifnum \minute<10 0\fi% % add it in
\number\minute \ P.M. \fi}
\def\datestamp{\vfill
\rightline{\sevenrm Gentle Intro \version{} run through \TeX{}
on \today{} at \writetime}}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\titlepagetrue
{\nopagenumbers
\def\sectiontitle{Introduction}
\topinsert \vskip 6 cm \endinsert
\centerline{\chapfont A Gentle Introduction to \TeX{}}
\vskip 15 pt
\centerline{\secfont A Manual for Self-study}
\vskip 3cm
\leftline{Michael Doob}
\leftline{Department of Mathematics}
\leftline{The University of Manitoba}
\leftline{Winnipeg, Manitoba, Canada R3T 2N2}
\vskip\baselineskip
\leftline{MDOOB@UOFMCC.BITNET}
\leftline{MDOOB@CCU.UMANITOBA.CA}
\vfill\eject
\titlepagetrue.
\vfill\eject
}
\secnum=-2 \pageno=-1
\section{Introduction}
First the bad news: \TeX{} is a large and complicated program that
goes to extraordinary lengths to produce attractive typeset material.
This very complication can cause unexpected things to happen at times.
Now the good news: straightforward text is very easy to typeset using
\TeX\null. So it's possible to start with easier text and work up to
more complicated situations.
The purpose of this manual is to start from the very beginning and
to move towards these more complicated situations. No previous knowledge
of \TeX{} is assumed. By proceeding a section at a time, greater
varieties of text can be produced.
Here are a few suggestions: there are some exercises in each
section. Be sure and do them! The only way to learn \TeX{} is
by using it. Better yet, experiment on your own; try to make
some variations on the exercises. There is no way that you can
damage the \TeX{} program with your experiments. You can find a
complete answer to most exercises by looking at the \TeX{} source
file that was used to produce this document. You'll notice that
there are references in the right margin to {\bf The \TeX
book}\fnote{Addison-Wesley, Reading,Massachusetts, 1984, ISBN
0-201-13488-9}\null. When you feel that you want more
information on a topic, that's where to look.
Incidentally, there are a few fibs that appear in this manual;
they are used to hide complications (I look at this as something
like poetic license). As you become more experienced at using
\TeX{}, you'll be able to find them.
\TeX{} is a public domain program that is available for no
license fee. It was developed by Donald Knuth at Stanford
University as a major project. In the profit-oriented market
place, the program would certainly cost many thousands of
dollars. The \TeX{} Users Group (TUG) is a nonprofit
organization which distributes copies of \TeX{}, this manual,
updates software, and gives information about new developments in
both hardware and software in its publications TUGboat and \TeX
niques. Joining this users group is inexpensive; please consider
doing so. The address is:
\vskip\baselineskip
\centerline{\TeX{} Users Group}
\centerline{P.O. Box 869}
\centerline{Santa Barbara, CA 93102}
\centerline{U.S.A.}
This manual would not have come into being without the aid of others.
In particular the proofreading and suggestions of the following
people have been invaluable:
\begingroup
\frenchspacing
Waleed A.~Al-Salam (University of Alberta),
Debbie L.~Alspaugh (University of California),
Nelson H.~F.~Beebe (University of Utah),
Barbara Beeton (American Mathematical Society),
Anne Br\"uggemann-Klein (University of Freiburg),
Bart Childs (Texas A.~\&~M\null. University),
Mary Coventry (University of Washington),
Dimitrios Diamantaras (Temple University),
Roberto Dominimanni (Naval Underwater Systems Center),
Lincoln Durst (Providence, RI),
Victor Eijkhout (University of Nijmegen),
Moshe Feder (St. Lawrence University),
Josep~M.~Font (Universidad Barcelona),
Jonas de Miranda Gomes
(Instituto de Matematica Pura e Aplicada - Brazil),
Rob Gross (Boston College),
Klaus Hahn (University of Marburg),
Anita Hoover (University of Delaware),
J\"urgen Koslowski (Macalester College),
Kees van der Laan (Rijksuniversiteit Groningen),
John Lee (Northrop Corporation),
Silvio Levy (Princeton University),
Robert Messer (Albion College),
Emily H.~Moore (Grinnell College),
Young Park (University of Maryland),
Craig Platt (University of Manitoba),
Kauko Saarinen (University of Jyv\"askyl\"a),
Jim Wright (Iowa State University),
and
Dominik Wujastyk (Wellcome Institute for the History of Medicine).
\endgroup
In addition several people have sent me parts or all of their local
manuals. I have received a few others on the rebound.
In particular
\begingroup
\frenchspacing
Elizabeth Barnhart (TV Guide),
Stephan v.~Bechtolsheim (Purdue University),
Nelson H.~F.~Beebe (University of Utah)
and Leslie Lamport (Digital Equipment Corporation),
Marie McPartland-Conn and Laurie Mann (Stratus Computer),
Robert Messer (Albion College),
Noel Peterson (Library of Congress),
Craig Platt (University of Manitoba),
Alan Spragens (Stanford Linear Accelerator Center, now of Apple Computers),
Christina Thiele (Carleton University),
and Daniel M.~Zirin (California Institute of Technology)
\endgroup
have written various types of lecture notes that have been most helpful.
\vfill \eject
\section{Contents}
\line{Introduction \dotfill{} i}
\line{Contents \dotfill{} iii}
\line{1.~Getting Started \dotfill{} 1}
\line{\qquad{}1.1 What \TeX{} is and what \TeX{} isn't \dotfill{} 1}
\line{\qquad{}1.2 From \TeX{} file to readable output,
the big set up \dotfill{} 2}
\line{\qquad{}1.3 Let's do it! \dotfill{} 4}
\line{\qquad{}1.4 \TeX{} has everything under control \dotfill{} 7}
\line{\qquad{}1.5 What \TeX{} won't do \dotfill{} 8}
\line{2.~All characters great and small \dotfill{} 9}
\line{\qquad{}2.1 Some characters are more special than others \dotfill{} 9}
\line{\qquad{}2.2 Typesetting with an accent \dotfill{} 10}
\line{\qquad{}2.3 Dots, dashes, quotes,
$\textfont0=\tenbf \mathinner {\ldotp \ldotp \ldotp }$ \dotfill{} 13}
\line{\qquad{}2.4 Different fonts \dotfill{} 15}
\line{3.~The shape of things to come \dotfill{} 19}
\line{\qquad{}3.1 Units, units, units \dotfill{} 19}
\line{\qquad{}3.2 Page shape \dotfill{} 20}
\line{\qquad{}3.3 Paragraph shape \dotfill{} 22}
\line{\qquad{}3.4 Line shape \dotfill{} 26}
\line{\qquad{}3.5 Footnotes \dotfill{} 27}
\line{\qquad{}3.6 Headlines and footlines \dotfill{} 28}
\line{\qquad{}3.7 Overfull and underfull boxes \dotfill{} 29}
\line{4.~$\Bigl\{$Groups, $\bigl\{$Groups, $\{$and More%
\setbox0=\hbox{$\biggl\{$} \vrule height \ht0 depth \dp0 width 0pt
Groups$\}\bigr\}\Bigr\}$ \dotfill{} 31}
\line{5.~No math anxiety here! \dotfill{} 33}
\line{\qquad{}5.1 Lots of new symbols \dotfill{} 33}
\line{\qquad{}5.2 Fractions \dotfill{} 37}
\line{\qquad{}5.3 Subscripts and superscripts \dotfill{} 38}
\line{\qquad{}5.4 Roots, square and otherwise \dotfill{} 39}
\line{\qquad{}5.5 Lines, above and below \dotfill{} 39}
\line{\qquad{}5.6 Delimiters large and small \dotfill{} 40}
\line{\qquad{}5.7 Those special functions \dotfill{} 41}
\line{\qquad{}5.8 Hear ye, hear ye! \dotfill{} 42}
\line{\qquad{}5.9 Matrices \dotfill{} 43}
\line{\qquad{}5.10 Displayed equations \dotfill{} 45}
\line{6.~All in a row \dotfill{} 48}
\line{\qquad{}6.1 Picking up the tab \dotfill{} 48}
\line{\qquad{}6.2 Horizontal alignment with more sophisticated patterns
\dotfill{} 51}
\line{7.~Rolling your own \dotfill{} 55}
\line{\qquad{}7.1 The long and short of it \dotfill{} 55}
\line{\qquad{}7.2 Filling in with parameters \dotfill{} 57}
\line{\qquad{}7.3 By any other name \dotfill{} 60}
\line{8.~To err is human \dotfill{} 62}
\line{\qquad{}8.1 The forgotten bye \dotfill{} 62}
\line{\qquad{}8.2 The misspelled or unknown control sequence \dotfill{} 62}
\line{\qquad{}8.3 The misnamed font \dotfill{} 64}
\line{\qquad{}8.4 Mismatched mathematics \dotfill{} 64}
\line{\qquad{}8.5 Mismatched braces \dotfill{} 65}
\line{9.~Digging a little deeper \dotfill{} 68}
\line{\qquad{}9.1 Big files, little files \dotfill{} 68}
\line{\qquad{}9.2 Larger macro packages \dotfill{} 69}
\line{\qquad{}9.3 Horizontal and vertical lines \dotfill{} 70}
\line{\qquad{}9.4 Boxes within boxes \dotfill{} 72}
\line{10.~Control word list \dotfill{} 77}
\ifwritinganswers
\line{11.~I get by with a little help\dotfill{} 80}
\fi
\section{Getting Started}
\subsection{What \TeX{} is and what \TeX{} isn't}
First of all, let's see what steps are necessary to produce a
document using \TeX\null. The first step is to type the file
that \TeX{} reads. This is usually called the \TeX{} file or the
input file, and it can be created using a simple text editor (in
fact, if you're using a fancy word processor, you have to be sure
that your file is saved in ASCII or nondocument mode without any
special control characters). The \TeX{} program then reads your
input file and produces what is called a DVI file (DVI stands for
DeVice Independent). This file is not readable, at least not by
humans. The DVI file is then read by another program (called a
device driver) that produces the output that is readable by
humans\TeXref{23}. Why the extra file? The same DVI file can be
read by different device drivers to produce output on a dot
matrix printer, a laser printer, a screen viewer, or a
phototypesetter. Once you have produced a DVI file that gives
the right output on, say, a screen viewer, you can be assured
that you will get exactly the same output on a laser printer
without running the \TeX{} program again.
The process may be thought of as proceeding in the following way:
$$
{\hbox{edit text\quad} \atop \longrightarrow}
\lower .6cm \makebox{1.5cm}{1.8cm}%
{\vbox{\hbox{\TeX{}}
\hbox{input}
\hbox{file}
}%
}%
{\hbox{\quad \TeX{} program\quad} \atop \longrightarrow}
\lower .6cm \makebox{1.5cm}{1.8cm}%
{\vbox{\hbox{DVI}
\hbox{file}}
}%
{\hbox{\quad device driver\quad} \atop \longrightarrow}
\lower .6cm \makebox{1.5cm}{1.8cm}%
{\vbox{\hbox{readable}
\hbox{output}}
}%
$$
This means that we don't see our output in its final form when it
is being typed at the terminal. But in this case a little
patience is amply rewarded, for a large number of symbols not
available in most word processing programs become available. In
addition, the typesetting is done with more precision, and the
input files are easily sent between different computers by
electronic mail or on a magnetic medium.
Our focus will be on the first step, that is, creating the \TeX{}
input file and then running the \TeX{} program to produce
appropriate results. There are two ways of running the \TeX{}
program; it can be run in batch mode or interactively. In
batch mode you submit your \TeX{} input file to your computer;
it then runs the \TeX{} program without further intervention and
gives you the result when it is finished. In interactive mode
the program can stop and get further input from the user, that
is, the user can interact with the program. Using \TeX{}
interactively allows some errors to be corrected by the user,
while the \TeX{} program makes the corrections in batch mode as
best it can. Interactive is the preferred mode, of course. All
personal computer and many mainframe implementations are
interactive. On some mainframes, however, the only practical
method of running \TeX{} is in batch mode.
\subsection{From \TeX{} file to readable output, the big set up}
\vskip\baselineskip
{\parskip = 0pt \noindent
[Note from MD:
{\sl This is the only system dependent section in the manual and
may be replaced by a local guide. No reference is made to it
outside of the section itself. The following local information
should be included:
\item{$\bullet$} What initial steps, if any, should be taken by the reader
to permit the running of \TeX{} and your local device driver(s).
\item{$\bullet$} How to run \TeX\null.
\item{$\bullet$} How to read the log file.
\item{$\bullet$} How to preview and/or print the dvi file.
The following sample is applicable here at the University of
Manitoba. We use a locally written editor (MANTES) on an
Amdahl running MVS; I'm fairly certain that it's the worst possible case.}]
}
In this section we'll see how to run \TeX{} at the University of
Manitoba. It is assumed that the reader is familiar with MANTES
and can create text files using it.
First, there are several things that must be done {\bf one time
only}. To start you must do the following (you type in the
material that looks like typewriter type):
\item{(1)} allocate the files that \TeX{} will use by typing the
following lines (while in MANTES):
\itemitem{} C: {\tt alloc da=source.tex format=vb,256,6144}
\itemitem{} C: {\tt alloc da=dvi format=fb,1024,6144}
\item{(2)} Create a file called RUNTEX in your MANTES aggregate
containing the following JCL:
\beginuser
// JOB ,'RUN TEX'
// EXEC TEXC
//SRC DD DSN=<userid>.SOURCE.TEX,DISP=SHR
//DVI DD DSN=<userid>.DVI,DISP=OLD
\enduser
The name {\tt <userid>} is replaced by your own user id, of
course. The use of upper case and the spaces must be followed
exactly.
\item{(3)} Create a file called PRINTTEX in your MANTES aggregate
containing the following JCL:
\beginuser
// JOB ,'PRINT TEX'
// EXEC TEXP
//DVIFILE DD DSN=<userid>.DVI,DISP=SHR
\enduser
Once you have completed these three steps, you are ready to run a
\TeX{} job. The files you have created will allow you to produce
about ten pages of ordinary text.
Here are the steps you use {\bf each time you run a job}.
\item{(1)} create a MANTES file containing your \TeX{} input.
\item{(2)} save and submit your file using the commands
\itemitem{} C: {\tt save f/l to da=source.tex noseq}
\itemitem{} C: {\tt submit runtex}
\item{(3)} when you get a message saying that your job is finished,
enter the command
\itemitem{} C: {\tt out <jobname>; list ttyout}
In this command, {\tt <jobname>} is replaced by your user id with
a dollar sign appended. This file listing will tell you of any
errors that might have occurred. It is an abbreviated version of
what is called the ``log file''; we will use the term ``log
file'' to refer to the ttyout file produced by \TeX\null.
If you want, you can check on the status of your job while it is
executing by using the command
\itemitem{} C: {\tt q <jobname>}
When you are finished looking at the log file, the command {\tt
end scratch} will throw away the log file while the command {\tt
end release} will send the log file to the printer, and it can
then be picked up with your \TeX{} output.
\item{(4)} when your output from RUNTEX program is error free, \TeX{}
will have created a legal DVI file. To print it, use the
command
\itemitem{} C: {\tt submit printtex nohold}
As in (3), you can check on the status of your job while it is
executing.
\item{(5)} Pick up your output at the I/O window, sixth floor
Engineering building. It usually takes about twenty minutes for the
output to be ready. Ask for it by ``{\tt <jobname>}''.
The files created are large enough for running \TeX{} jobs of about
10 pages. A job of that size will take about one second of CPU time
to run through \TeX\null. It will take about 15 seconds of CPU time to
print 10 pages on the Xerox 8600 using the current device driver.
You can print your own copy of this manual using the command
{\tt \%docu tex}. You can also find lots of other useful
online information about \TeX{} by using {\tt \%texinfo}.
\subsection{Let's do it!}
So, from our viewpoint, the name of the game is to create the \TeX{}
file that produces the right readable output. What does
a \TeX{} file look like? It consists of characters from an
ordinary terminal, that is, upper and lower case letters,
numbers, and the usual punctuation and accent characters (these
are the usual ASCII characters). Text, for the most part, is just
typed normally. Special instructions usually start with one of a
few special symbols such as {\tt \#} or {\tt \&} (these will be
described in more detail later). Here is an example of a \TeX{}
input file:
\beginuser
Here is my first \\TeX\\ sentence.
\\bye
\enduser
\toindex{TeX{} } \toindex{ }
First note that the characters in this example look like
typewriter type. We use these characters with all examples that
are meant to be typed from the computer terminal. Second, note
that the backslash appears three times in the text. We'll soon
see that this is one of the special symbols mentioned
previously, and it is used very frequently when making \TeX{}
documents. Make a file containing this example. Use the \TeX{}
program to make a DVI file and a device driver to see what you
have produced. If all goes well, you'll have a single page with
the following single sentence:
Here is my first \TeX\ sentence.
There will also be a page number at the bottom of the page. If
you've gotten this far, congratulations! Once you can produce one
\TeX{} document, it's just a matter of time before you can do
more complicated ones. Now let's compare what we typed in with
what we got out. The straightforward words were just typed in
normally, and \TeX{} set them in ordinary type. But the word ``\TeX'',
which can't be typed in on a terminal because the letters
aren't on the same line, is entered by using a word starting with
a backslash, and \TeX{} made the proper interpretation. Most
symbols that are not ordinary letters, numbers, or punctuation
are typeset by entering a word starting with a backslash. If we
look a little closer, we'll note that the word ``first'' is also
changed.
\TeXref{4}
The first two letters have been joined together and there isn't
a separate dot over the letter ``i''. This is standard
typesetting practice: certain letter combinations are joined up
to form what are called {\sl ligatures}. There is actually a good
\aesthetic{} reason for this. Compare the first two letters of
``first'' and ``{f}irst'' to see the difference. We note that
{\tt \\bye} appears in the input file with no corresponding word
in the final copy.
\toindex{bye}
This a typesetting instruction that tells \TeX{} that the input
is finished. We'll learn about lots of different typesetting
instructions as we go along.
Let's look at the log file that was created when we ran \TeX
\null. It may vary slightly at your site, but should look
something like this:
\beginuser
1.
2. This is TeX, MVS Version 2.9 (no format preloaded)
3. ** File PLAIN.FMT <-- DD=FMTLIB MEM=PLAIN
4.
5. ** File SRC.TEX <-- DD=SRC
6. (src.tex [1]
7. Output written on DVI (1 page, 256 bytes).
8. Transcript written on TEXLOG.
\enduser
This is the file that will contain any error messages. On line 6,
{\tt (src.tex\ } indicated that \TeX{} has started reading that
file. The appearance of {\tt [1]} indicates that page 1 has been
processed. If there were errors on page 1, they would be listed
at that point.
\vskip .5cm
\exercise Add a second sentence to your original \TeX{} file to get:
\beginuser
Here is my first \\TeX\\ sentence.
I was the one who typeset it!
\\bye
\enduser
Use \TeX{} and look at your output. Is the second sentence on a
new line?
\exercise Now add this line to the beginning of your file:
\beginuser
\\nopagenumbers
\enduser
\noindent
Guess what will happen when you run the new file through
\TeX\null. Now try it and see what happens.
\toindex{nopagenumbers}
\exercise Add three or four more sentences to your file.
Use letters, numbers, periods, commas, question marks,
and exclamation points, but don't use any other symbols.
\exercise Leave a blank line and add some more sentences.
You can now get new paragraphs.
\medskip
We have now seen a major principle concerning the preparation of
\TeX{} input files. The placement of the text on your computer
terminal does not necessarily correspond to the placement of the
text on your output. You can not, for example, add space between
words in your output by adding spaces in your input file. Several
consecutive spaces and one space will produce exactly the same
output. As would be expected, a word at the end of one line will
be separated from the first word of the following line. In fact,
sometimes when working on a file that will be heavily edited, it
is convenient to start each sentence on a separate line. Spaces
at the beginning of a line, however, are always ignored.
\exercise Add the following sentence as a new paragraph, and then
typeset it:
\beginuser
Congratulations! You received a grade of 100\% on your latest
examination.
\enduser
\noindent
The {\tt\%} sign is used for comments in your input file.
Everything on a line following this symbol is ignored. Notice
that even the space that normally separates the last word on one
line from the first word on the next line is lost. Now put a
backslash in front of the {\tt\%} sign to correct the
sentence. \toindex{\$} \toindex{\%}
\exercise Add the following sentence as a new paragraph:
\beginuser
You owe me \$10.00 and it's about time you sent it to me!
\enduser
\noindent
This will produce an error in your log file (if your
implementation of \TeX{} is interactive, that is, sends you
messages and waits for answers, just hit the carriage return or
enter key when you get the error message). You will get output,
but not what you might expect. Look at the log file and see
where the error messages are listed. Don't worry about the
actual messages. We'll have a lot more to say about errors
(including this one) later. Now fix the error by putting a
backslash in front of the {\tt \$} sign, and typeset the result
(there are a small number of characters like the per cent and
dollar signs that \TeX{} uses for its own purposes. A table of
these characters will be provided shortly).
\subsection{\TeX{} has everything under control}
We have seen that the backslash has a special role. Any word
starting with a backslash will be given a special interpretation
when \TeX{} reads it from your input file. Such a word is called
a {\sl control sequence}. There are, in fact, two types of
control sequences: a {\sl control word\/} is a backslash followed
by letters only (for example, {\tt \\TeX}) and a {\sl control
symbol\/} is a backslash followed by a single nonletter (for
example, {\tt \\\$})\null. Since a space is a nonletter, a
backslash followed by a space is a legitimate control symbol.
\TeXref{7--8}
When we want to emphasize that a space is present, we will use a
special symbol {\tt\sp} to indicate the space, as in the control
symbol {\tt\\\sp}. This convention is used in {\bf The \TeX
book} as well as in this manual.
When \TeX{} is reading your input file and comes to a backslash
followed by a letter, it knows that a control word is being
read. So it continues reading the name of the control word until
a nonletter is read. So if your file contains
\displaytext{\tt I like \\TeX!}
\noindent
the control word {\tt \\TeX} is terminated by the exclamation
point. But this presents a problem if you want to have a space
after a control word. If you have, for example, the sentence
\displaytext{\tt I like \\TeX and use it all the time.}
\noindent
in your input file, the control word {\tt\\TeX} is terminated by
the space (which is, of course, a nonletter). But then you won't
have a space between the words ``\TeX{}'' and ``and''; inserting
more spaces won't help, since \TeX{} doesn't distinguish between
one space and several consecutive spaces. But if you put the
control symbol {\tt\\\sp} after a control word, you will both
terminate the control word and insert a space. It's really easy
to forget to put in something like {\tt\\\sp} after a control
word. I promise you that you will do it at least once while
you're learning to use \TeX\null.
\exercise Make an input file that will produce the following
paragraph:
I like \TeX! Once you get the hang of it, \TeX{} is really easy
to use. You just have to master the \TeX nical aspects.
Most control words are named so as to give a hint of their uses.
You can use {\tt \\par} to make a new paragraph, for example,
instead of putting in a blank line.
\toindex{par}
\subsection{What \TeX{} won't do}
\TeX{} is very good at setting type, but there are things that \TeX{}
can't do well. One is making figures. Space can be left
to insert figures, but there are no graphic procedures built into
the language (at present). Some implementations allow graphic
instructions to be inserted using the {\tt \\special} control
word but these are exceptional and definitely site dependent.
\TeX{} sets type in horizontal straight lines and not in
straight lines at other angles. In particular, it is generally
not possible to make insertions in ``landscape mode'', that is,
with the text rotated so that the baseline is parallel with
the long edge of the paper, or to include text that has a curve for
a baseline. Perspective type (gradually increasing or
decreasing in height) is not handled well by \TeX\null.
We have seen that there is an ``edit, \TeX{}, driver'' cycle that
is necessary for each different copy of output. This is true
even when the output device is a terminal. In particular, it's
not possible to type the input file and see the results on the
screen immediately without going through the full cycle. Some
implementations have both text and graphics displays with
reasonably quick turnaround (a few seconds for a single page); as
hardware becomes less expensive and processors become faster, we
may see improvement.
\section{All characters great and small}
\subsection{Some characters are more special than others}
We saw in the last section that most text is entered at the
terminal as sentences of ordinary words just as when typing with
a typewriter. But we also saw that, in particular, the backslash
could be used for at least two different purposes. It can be
used for symbols (or combinations of symbols) that don't appear
on the keyboard such as typing {\tt \\TeX} to get \TeX\null. It
can also be used to give \TeX{} special instructions such as
typing {\tt \\bye} to indicate the end of the input file. In
general, a word starting with a backslash will be interpreted by
\TeX{} as one requiring special attention. There are several
hundred words that \TeX{} knows, and you can define more
yourself, and so the backslash is very important. We'll spend a
lot of time as we proceed learning some of these words;
fortunately we'll only need to use a small number of them most of
the time.
There are ten characters which, like the backslash, are used
by \TeX{} for special purposes, and we now want to give the
complete list.
\TeXref{37--38}What if we want to use a sentence with one of these
special characters in it? With this in mind we'll ask the following
questions:
\item{(1)} What are the different special characters?
\item{(2)} How do we use a special character if we really want to
typeset it in our text?
Here is a table of each special character, its purpose, and the
method of typesetting the special character itself if you need
it:
\maketable [Characters requiring special input]
\halign{
\strut \hfil#\hfil & \quad # \hfil & \quad\tt # \hfil\cr
\bf Character & \bf Purpose & \bf Input for literal output \cr
\noalign{\hrule} \noalign{\smallskip}
$\backslash$ & Special symbols and instructions & \$\\backslash\$ \cr
$\{$ & Open group & \$\\\lb\$ \cr
$\}$ & Close group & \$\\\rb\$ \cr
\% & Comments & \\\% \cr
\& & Tabs and table alignments & \\\& \cr
\~{} & Unbreakable space & \\\~{}\lb\rb \cr
\$ & Starting or ending math text & \\\$ \cr
\^{} & Math superscripts & \\\^{}\lb\rb \cr
\_{} & Math subscripts & \\\_{}\lb\rb \cr
\# & Defining replacement symbols & \\\# \cr
}
\toindex{\lb}
\toindex{\rb}
\toindex{\%}
\toindex{\&}
\toindex{\~{}}
\toindex{\$}
\toindex{\^{}}
\toindex{\_{}}
\toindex{\#}
\subsection{Typesetting with an accent}
Now we're going to start using some of \TeX{}'s goodies! So far
we've just been using \TeX{} to make our output look attractive,
but now we'll start to do things that are difficult or impossible
on the typewriter. In particular, we're going to look at accents
now. How do you produce an accent when the symbol doesn't appear on
the keyboard? Just as with the symbol \TeX{}, it is necessary to
enter a word starting with a backslash. For the word ``premi\`ere'',
as a first example, you need to type in {\tt premi\\`ere}
(you may have to hunt around to find the ``back prime''
or ``grave'' symbol {\tt `} on your keyboard, but it's there
somewhere\fnote{If you have a very old or obscure
keyboard and the back prime is {\it really\/} not there, you can
use {\tt \\lq\lb\rb} instead. Similarly {\tt \\rq\lb\rb} can be
used for the symbol {\tt '}. You can think of the symbols as
being abbreviations for ``left quote'' and ``right quote.'' In
addition, {\tt \\lq\\lq\lb\rb} and {\tt \\rq\\rq\lb\rb} give the
usual quotation marks. But this won't work as a method to produce
an accent over the following letter, so you're really better off
with a proper keyboard.}). In general, to put an accent
on a letter, the appropriate control sequence precedes the letter.
Here are some examples:
$$\vbox{
\halign{
\strut \hfil\tt # & \quad # \hfil\cr
\bf \TeX{} input & \bf \TeX{} output \cr
\noalign{\hrule} \noalign{\smallskip}
\\`a la mode & \`a la mode \cr
r\\'esum\\'e & r\'esum\'e \cr
soup\\c{\sp}con & soup\c con \cr
No\\"el & No\"el \cr
na\\"\\i{\sp}ve & na\"\i ve \cr
}
}$$
We see several principles illustrated by these examples. Most
accents are produced by using a control symbol with a similar
shape. A few of them are produced by control words containing a
single letter. Some care must be used in this case, for a space
must be used to terminate the control word. If you have {\tt
soup\\ccon} in your file, for example, \TeX{} will look for the
control word {\tt\\ccon}\fnote{We'll see that there is another
method when we look at the grouping concept in Section~4.}.
\TeXref{52--53}
Notice that there is a control word {\tt\\i} also. This produces
the letter ``i'' without the dot over it; this allows an accent
to be put over the lower part of the letter. There is an
analogous control word {\tt\\j} that produces a dotless ``j''
for accenting purposes.
\maketable [Accents that may be immediately followed by a letter]
\halign{
\strut \hfil # \hfil & \quad \hfil \tt # \hfil & \hfil \quad # \hfil\cr
\bf Name & \bf \TeX{} input & \bf \TeX{} output \cr
\noalign{\hrule} \noalign{\smallskip}
grave & \\`o & \`o \cr
acute & \\'o & \'o \cr
circumflex & \\\^{}o & \^o \cr
umlaut/dieresis/tr\'emat & \\"{}o & \"o \cr
tilde & \\\~{}o & \~o \cr
macron & \\={}o & \=o \cr
dot & \\\char'056{}o & \.o \cr
}
\toindex{`}
\toindex{'}
\toindex{\^{}}
\toindex{"}
\toindex{i}
\toindex{j}
\toindex{=}
\toindex{.}
\maketable [Accents requiring an intervening space]
\halign{
\strut \hfil # \hfil & \quad \hfil \tt # \hfil & \hfil \quad # \hfil\cr
\bf Name & \bf \TeX{} input & \bf \TeX{} output \cr
\noalign{\hrule} \noalign{\smallskip}
cedilla & \\c o & \c{o} \cr
underdot & \\d o & \d{o} \cr
underbar & \\b o & \b{o} \cr
h\'a\v{c}ek & \\v o & \v{o} \cr
breve & \\u o & \u{o} \cr
tie & \\t oo & \t oo \cr
Hungarian umlaut& \\H o & \H{o} \cr
}
\toindex{c}
\toindex{d}
\toindex{b}
\toindex{v}
\toindex{u}
\toindex{t}
\toindex{H}
\TeX{} also allows some letters from languages other than English to
be typeset.
\maketable [A\kern-1pt vailable foreign language symbols]
\halign{
\strut \hfil # \hfil & \quad \hfil \tt # \hfil & \hfil \quad # \hfil\cr
\bf Example& \bf \TeX{} input & \bf \TeX{} output \cr
\noalign{\hrule} \noalign{\smallskip}
\AE gean, \ae sthetics & \\AE, \\ae & \AE, \ae \cr
\OE uvres, hors d'\oe uvre & \\OE \\oe & \OE, \oe \cr
\AA ngstrom & \\AA, \\aa & \AA, \aa \cr
\O re, K\o benhavn & \\O, \\o & \O, \o \cr
\L odz, \l\'odka & \\L, \\l & \L, \l \cr
Nu\ss & \\ss & \ss \cr
?`Si? & {?}{`} & ?` \cr
!`Si! & {!}{`} & !` \cr
Se\~nor & \\\~{} & \~{} \cr
& \lb\\it\\\$\rb & {\it\$} \cr
}
\toindex{AE}
\toindex{ae}
\toindex{OE}
\toindex{oe}
\toindex{AA}
\toindex{aa}
\toindex{O}
\toindex{o}
\toindex{L}
\toindex{l}
\toindex{ss}
Typeset the sentence in each of the following exercises:
\exercise Does \AE schylus understand \OE dipus?
\exercise The smallest internal unit of \TeX{} is about 53.63\AA.
\exercise They took some honey and plenty of money wrapped up in a
{\it \$}5 note.
\exercise \'El\`eves, refusez vos le\c cons! Jetez vos cha\^\i nes!
\exercise Za\v sto tako polako pijete \v caj?
\exercise Mein Tee ist hei\ss.
\exercise Peut-\^etre qu'il pr\'ef\`ere le caf\'e glac\'e.
\exercise ?`Por qu\'e no bebes vino blanco? !`Porque est\'a avinagrado!
\exercise M\'\i\'\j n idee\"en worden niet be\"\i nvloed.
\exercise Can you take a ferry from \"Oland to \AA land?
\exercise T\"urk\c ce konu\c san ye\u genler nasillar?
\def\bdots{$\textfont0=\tenbf \ldots$} %%% boldface version of \ldots
\subsection{Dots, dashes, quotes, \bdots}
Typing has always been a compromise: the small number of keys
(compared to the number of typeset symbols available) has forced
some changes on the typist. When preparing material using \TeX{},
there is no need to be so restricted. In this section we'll look
at some differences between typing and using \TeX\null.
There are four types of dashes that are used. The hyphen is used
for combining words into one unit as with mother-in-law.
\TeXref{3--5}
The en-dash is used to indicate a sequence of page numbers, years
or such things. The em-dash is a grammatical symbol. The minus
sign is used for negative numbers. Here they are with their uses:
\maketable [Different types of dashes]
\halign{
\strut \hfil # \hfil & \quad \hfil \tt # \hfil & \hfil \quad # \hfil
& \hfil # \hfil\cr
\bf Name& \bf \TeX{} input & \bf \TeX{} output & \bf Example\cr
\noalign{\hrule} \noalign{\smallskip}
hyphen & - & - & The space is 3-dimensional. \cr
en-dash & {-}{-} & -- & Read pages 3--4. \cr
em-dash & {-}{-}{-} & --- & I saw them---there were 3 men alive. \cr
minus sign & \$-\$ & $-$ & The temperature dropped to $-$3 degrees. \cr
}
\exercise I entered the room and---horrors---I saw both my
father-in-law and my mother-in-law.
\exercise The winter of 1484--1485 was one of discontent.
\bigskip
Another difference between typing and using \TeX{} is the use of
quotation marks. Opening and closing quotation marks are the
same on a typewriter. They are produced in \TeX{} by using the
apostrophe or prime key {\tt '} and backprime key {\tt `}\null.
An open quote is produced by {\tt ``} and the
close quote by {\tt ''}\null.\TeXref{3} Similarly the
opening single quote is produced by {\tt `} and the closing
single quote by {\tt '}\null. Notice that there is no need
to use the usual typing quotation mark (it normally gives a close
quote, but don't count on it).
\exercise His ``thoughtfulness'' was impressive.
\exercise Frank wondered, ``Is this a girl that can't say `No!'?''
\bigskip
Sometimes ellipses (three dots) are used to indicate a passage
of time or missing material. Typing three periods will give
three dots very close together. The dots with proper spacing will
be produced by having {\tt \\dots} in your input file.
\TeXref{173}
\toindex{dots}
\exercise He thought, ``\dots and this goes on forever, perhaps to the
last recorded syllable.''
Another problem with dots is that the period after an
abbreviation normally has less space after it than does the
period at the end of a sentence. There are two ways to solve this
problem: the dot can be followed by either {\tt\\\sp} or {\tt\~{}}
to change the spacing.
\TeXref{91--92}
The second alternative will give an unbreakable space; when such
a space is between two words, these words must typeset on the
same line. The input {\tt Prof.\~{}Knuth} would cause those two
words to be typeset on one line. This is desirable for names
like Vancouver, B.~C. and Mr.~Jones so that ``Mr.'' and ``Jones''
do not end up on separate lines. Notice that no backslash is used
with the unbreakable space.
\exercise Have you seen Ms.~Jones?
\exercise Prof.~Smith and Dr.~Gold flew from
\ifcanspell
Halifax N.~S. to Montr\'eal, P.~Q. via Moncton, N.~B.
\else
L.~A. to Washington, D.~C., via Fargo, N.~D.
\fi
\subsection{Different fonts}
The most obvious difference between typewritten text and \TeX{}
output is undoubtedly the different fonts or types of symbols
used. When \TeX{} starts up it has sixteen fonts available. Some
of these are used for technical purposes, but even so there are
several different typefaces available as can be seen in the
following table. A complete list of the sixteen fonts is given in
Appendix F of {\bf The \TeX{}book}.
\TeXref{427--432}
Most of them are used automatically; a mathematical subscript,
for example, is put in smaller type by \TeX{} with no special
user intervention.
To change from the usual (roman) typeface to italic, the control
word {\tt \\it} is used. To change back to the usual roman
typeface, use {\tt \\rm}. For example, you could have the
following sentence: {\tt I started with roman type, \\it switched
to italic type, \\rm and returned to roman type}. This would give
the following: I started with roman type, \it switched to italic
type,\fnote{Notice that the comma and this footnote are in
italic type, and this looks a little funny. We'll see that there
is another method for changing fonts when we talk about grouping
in Section 4.}
\rm and returned to roman type.
Typefaces other than italic are also available. Those given below
are the ones most commonly used. They are available immediately
when \TeX{} starts. A little later we'll see how to use other
typefaces that aren't available when \TeX{} starts.
\global\advance\footnotenum by 1
\maketable [Font Samples]
\halign{
\strut \hfil # \hfil & \quad \hfil \tt # \hfil & \hfil \quad # \hfil\cr
\bf Font name & \bf \TeX{} switch sequence & \bf Sample of typeface \cr
\noalign{\hrule} \noalign{\smallskip}
Roman & \\rm & \rm This is roman type. \cr
Boldface & \\bf & \bf This is boldface type. \cr
Italic & \\it & \it This is italic type. \cr
Slanted & \\sl & \sl This is slanted type. \cr
Typewriter & \\tt & \tt This is typewriter type. \cr
Math symbol${}^\the\footnotenum$ & \\cal & $\cal SOME\hbox{\quad}SCRIPT
\hbox{\quad}LETTERS$\rm. \cr
}
\footnote{}{\llap{$^\the\footnotenum$}%
This example is cheating since you need to know a little about
mathematics input to use it, but I wanted to include it anyway.
You'll be able to use these letters after you study the use of
mathematical symbols.}
\nobreak
\toindex{it}
\toindex{rm}
\toindex{bf}
\toindex{sl}
\toindex{tt}
The slanted and italic fonts seem quite similar at first. It is
easy to see the difference between the letter ``a'' in each
sample. When changing from a slanted or italic font to a roman
font, the last letter in the first font will lean towards the
first letter of the roman font; this looks cramped, and to
compensate there is a little extra space that can be added called
the {\sl italic correction}. This is done using the control
symbol {\tt \\/}.
\toindex{/}
In the following sentence, there is no italic correction after
the first sequence of italic letters but there is after the
second sequence; see the difference: {\it If} the italic
correction is not used the letters are too close together, but
{\it if\/} the correction is used, the spacing is better. There
is no need for the italic correction when the italic characters
are followed by a comma or a period, but your text will
definitely look better if you use it before quotation marks or
parentheses.
It is possible to use fonts other than those initially defined in
\TeX{} when desired (assuming that they are available on
your computer system, of course). Different sizes can be used
with the aid of the control word {\tt \\magstep}. To define your
new font you will have to know its name on your computer system.
For example, the roman typeface is called ``cmr10'' on most
systems. If you use {\tt \\font\\bigrm = cmr10 scaled \\magstep
1}, you can then use {\tt\\bigrm} in exactly the same way as you
use {\tt\\it} or {\tt\\rm}.
\TeXref{13--17}
\toindex{magstep}
\toindex{font}
\toindex{scaled}
Switching via {\tt\\bigrm} will give roman type that is larger
than the usual by 20\%\null. {\tt \\font\\bigbigrm = cmr10
scaled \\magstep 2} will define a font that is about 44\% larger
than the usual roman typeface. The sizes {\tt \\magstep~0} to
{\tt \\magstep~5} are available. On most computers {\tt \\magstephalf}
is also available; this represents an enlargement of
about 9.5\%\null. Here are some samples at various sizes:
\maketable [Different Font Magnifications]
\halign{
\strut \tt # \hfil & \quad # \hfil \cr
\bf Magnification & \bf Sample \cr
\noalign{\hrule} \noalign{\smallskip}
\\magstep 0 & \rm Sample text at magstep 0. \cr
\\magstephalf & \halfrm Sample text at magstephalf. \cr
\\magstep 1 & \brm Sample text at magstep 1. \cr
\\magstep 2 & \bbrm Sample text at magstep 2. \cr
\\magstep 3 & \bbbrm Sample text at magstep 3. \cr
\\magstep 4 & \bbbbrm Sample text at magstep 4. \cr
\\magstep 5 & \bbbbbrm Sample text at magstep 5. \cr
}
\bigskip
It's also possible to use completely new typefaces. These
are dependent on system availability, of course. Many systems
have a file called CMSS10 which is a font that contains sans
serif letters. Using {\tt \\font\\sf = cmss10} will allow the
control word {\tt\\sf} to be used in the same manner as {\tt\\bf}.
Having made this definition, the input
\displaytext{\tt \\sf Here is a sample of our new Sans Serif font.}
will produce
\displaytext{\sf Here is a sample of our new Sans Serif font.}
\exercise What problem might have arisen if we had used {\tt \\ss}
instead of {\tt \\sf} to turn on the Sans Serif font? Hint: if
the answer doesn't occur to you at first, think about the German
alphabet and it will finally come to you.
\exercise Typeset a paragraph of magnified sans serif text.
The extra fonts available may vary from site to site. The ones
in the following table are available at most places.
\maketable [External Fonts Names]
\halign{
\strut \tt # \hfil & \quad \tt # \hfil & \quad \tt # \hfil
& \quad \tt # \hfil & \quad \tt # \hfil
& \quad \tt # \hfil \cr
\noalign{\hrule} \noalign{\smallskip}
CMBSY10 &CMBXSL10 &CMBXTI10 &CMBX10 &CMBX12 &CMBX5 \cr
CMBX6 &CMBX7 &CMBX8 &CMBX9 &CMB10 &CMCSC10 \cr
CMDUNH10 &CMEX10 &CMFF10 &CMFIB8 &CMFI10 &CMITT10 \cr
CMMIB10 &CMMI10 &CMMI12 &CMMI5 &CMMI6 &CMMI7 \cr
CMMI8 &CMMI9 &CMR10 &CMR12 &CMR17 &CMR5 \cr
CMR6 &CMR7 &CMR8 &CMR9 &CMSLTT10 &CMSL10 \cr
CMSL12 &CMSL8 &CMSL9 &CMSSBX10 &CMSSDC10 &CMSSI10 \cr
CMSSI12 &CMSSI17 &CMSSI8 &CMSSI9 &CMSSQI8 &CMSSQ8 \cr
CMSS10 &CMSS12 &CMSS17 &CMSS8 &CMSS9 &CMSY10 \cr
CMSY5 &CMSY6 &CMSY7 &CMSY8 &CMSY9 &CMTCSC10 \cr
CMTEX10 &CMTEX8 &CMTEX9 &CMTI10 &CMTI12 &CMTI7 \cr
CMTI8 &CMTI9 &CMTT10 &CMTT12 &CMTT8 &CMTT9 \cr
CMU10 &CMVTT10 \cr
}
\bigskip
Here's a little background about these names. The first two
letters {\tt CM} stands for Computer Modern, the name given to
this font family by the designer. The number at the end is the
point size: 10 point type is the normal size, 7 point is the
normal size for subscripts, and 5 point is the normal size for
subscripts of subscripts, 12 point is 20\% larger than 10 point,
etc. If the letters {\tt CM} are followed by {\tt B}, it is a
boldface type. Similarly {\tt R} indicates roman, {\tt I} is for
italics, {\tt CSC} is for small caps, {\tt SL} is for slanted,
{\tt SS} is for sans serif, {\tt SY} is for symbols,
and {\tt TT} is for typewriter type.
\exercise Find the fonts available on your system, and print out
all the letters and numbers in several of them.
\exercise The font {\tt CMR12} is 20\% larger than {\tt CMR10}.
Also {\tt \\magstep~1} magnifies the type by 20\%. Take some
text and print it using {\tt CMR12} then using {\tt CMR10} scaled
by {\tt \\magstep~1}. The results are quite different!
\section{The shape of things to come}
In this section we want to see how to make text have different
shapes or sizes. One may use \TeX{} with the default sizes, of
course, just as we have been doing so far. We'll now become more
creative with our output. In discussing the size of various
parts of a page of text, there are several units of measure we
can use.
\subsection{Units, units, units}
\TeX{} can measure length using many types of units. The most
common are the inch, the \centimeter, the point, the pica. The
abbreviations for these units are {\tt in}, {\tt cm}, {\tt pt},
and {\tt pc} respectively. The point is defined by the equation 1
inch = 72.27 points, and the pica by 1 pica = 12 points. Thus a
point is rather small and is about the size of a decimal point.
Here is a sample to give an idea of the comparative sizes:
\def\pip{\vrule height 4 true pt }
\TeXref{57}
$$ \hbox{1 inch: } \hbox to 1 true in{\pip\hrulefill\pip}$$
$$ \hbox{1 \centimeter: }\hbox to 1 true cm{\pip\hrulefill\pip}$$
$$ \hbox{20 points: }\hbox to 20 true pt{\pip\hrulefill\pip}$$
$$ \hbox{1 pica: } \hbox to 1 true pc{\pip\hrulefill\pip}$$
Thus points are used to make fine changes; a pica is about the
distance between the baselines of two consecutive lines of
(unmagnified) normal text. \TeX{} is quite exact about
dimensions; internally its smallest unit is less than one
four-millionth of an inch. Hence it is the resolution of the
output device that will determine the accuracy of the output.
There are two other units that are sometimes useful that have
different sizes in different fonts. The {\tt ex} is about the
height of a small ``x'' and the {\tt em} is a little smaller than
the width of a capital ``M''\null.
\TeXref{60}
The shape of the output is generally determined by control
words. There are many such words; these allow very fine control
of the resulting text. But most of the time only a small number
of them are necessary.
\subsection{Page shape}
The text on a page consists of three basic parts. There is the
headline above the main text; this often contains a chapter
title, section title, or a page number, and may differ on odd and
even pages. Below this is the main text, which includes any
footnotes. And finally there is the footline that might contain a
page number.
In the examples we have seen so far, the headline has been blank.
The footline has contained either a \centred{} number or, if {\tt
\\nopagenumbers} had been used, has also been blank. We'll have
more to say about headlines and footlines later in this section.
For the moment let's concentrate on the main text.
To finish one page and start a new one, {\tt \\vfill \\eject} can
be used. The control word {\tt \\eject} forces the completion of
the current page, while {\tt \\vfill} causes any left over
vertical space to be gathered at the bottom of the page (you might
try leaving out the {\tt \\vfill} as an experiment to see how the
vertical \analog{} of justified horizontal lines of text works).
\toindex{vfill}
\toindex{eject}
{\hsize=4in
The current horizontal width of the text on the page is described
by the control word {\tt \\hsize}. It can be changed, say to 4
inches, by {\tt \\hsize = 4 in\ } at any desired time using
methods to be described in the next few sections. The value of
{\tt \\hsize} in effect when the paragraph is completed
determines the width of the paragraph. As can be seen in this
paragraph, the text width can be changed (in this case to 4
inches) for a single paragraph. Because it represents the
current value of the horizontal width, expressions such as {\tt
\\hsize = 0.75\\hsize} can make a new value that is relative
to the old one. \par}
\toindex{hsize}
The vertical \analog{} of {\tt \\hsize} is {\tt \\vsize}, which
is the current height of the main text. It can be reset, just
like {\tt \\hsize}. Thus, {\tt \\vsize = 8 in\ } can be used to
change the vertical height of the main text. Note that {\tt \\vsize}
is the size of the text exclusive of any headline or
footline material.
\toindex{vsize}
Text can also be shifted across the page. The upper left corner
of the text is one inch down and one inch in from the upper left
corner of the page. The control words {\tt \\hoffset} and {\tt \\voffset}
are used to shift the text horizontally and
vertically. Thus {\tt \\hoffset = .75 in} and {\tt \\voffset =
-.5 in} would shift the text an additional .75 inches to the
right and .5 inches up. Most of the time you'll need to set {\tt
\\hoffset}, {\tt \\voffset}, and {\tt \\vsize} at the beginning
of your document only.
\TeXref{251}
\toindex{hoffset}
\toindex{voffset}
\global\advance\footnotenum by 1
\maketable [Control words for page sizes]
\halign{
\strut \hfil # & \quad \hfil \tt # \hfil & \hfil \quad # \hfil\cr
\bf Name & \bf \TeX{} Control Word & \bf \TeX{} default value (inches)\cr
\noalign{\hrule} \noalign{\smallskip}
horizontal width & \\hsize & 6.5 \cr
vertical width & \\vsize & 8.9 \cr
horizontal offset${}^\the\footnotenum$ & \\hoffset & 0 \cr
vertical offset${}^\the\footnotenum$ & \\voffset & 0 \cr
}
\footnote{}{\llap{$^\the\footnotenum$}The text is initially 1 inch
down and 1 inch in from upper left corner of the page.}
\nobreak
\exercise Enter a paragraph of text that is a few lines long.
Take several copies of your paragraph and put {\tt \\hsize = 5
in\ } before one and {\tt \\hsize = 10 cm\ } in front of a second
one. Try a few other values for {\tt \\hsize}.
\exercise Put {\tt \\hoffset = .5 in\ } and {\tt \\voffset = 1
in\ } before the first paragraph of your previous exercise.
\exercise Take your previous exercise and put {\tt \\vsize = 2
in\ } before the first paragraph.
\bigskip
In the previous section we saw that it is possible to use fonts
of larger size by using the {\tt \\magstep} control word. It's
also possible to magnify the entire document at once. If {\tt
\\magnification = \\magstep 1} appears at the top of your document,
then all of your output is magnified by 20\%\null. The other
values of {\tt \\magstep} can be used, too. {\bf It should be
emphasized that {\tt \\magnification} can only be used before
even a single character is typeset.} This magnification creates
a problem in units; if the document is to be magnified by 20\%
and {\tt \\hsize = 5 in} appears in the \TeX{} input file, should
the final output have an {\tt \\hsize} of 5 inches or should it
be magnified by 20\% to 6 inches? Unless told otherwise, all the
dimensions will be magnified so that, in this case, {\tt \\hsize}
would be 6 inches in the final output. This means that all the
dimensions will increase uniformly when {\tt \\magnification} is
used. But for some special situations it might not be desirable
for this to happen; for example, you might want to leave a space
of exactly 3 inches to insert a figure. In this case any unit
can be modified by {\tt true} so that {\tt \\hsize = 5 true in}
will always set the line width to 5 inches, regardless of
magnification. \TeXref{59--60} \toindex{magnification}
\exercise Put {\tt \\magnification = \\magstep 1} as the first
line in one of your input files and see how the output changes.
\subsection{Paragraph shape}
When \TeX{} is reading the text to be typeset from your input
file, it reads in a paragraph at a time and then typesets it.
This means that there is a lot of control over paragraph shapes,
but also that some care must be taken. We've already seen that
{\tt \\hsize} can be used to control the width of a single
paragraph. But suppose the following appeared as part of your
input file:
\beginuser
\\hsize = 5 in
Four score and seven years $\ldots$
$\vdots$
$\ldots$ from this earth.
\\hsize = 6.5 in
\enduser
What is the width of the paragraph? The {\tt \\hsize} was
changed at the start of the paragraph and again at the end.
Since the paragraph was not completed (by putting in a blank line
or {\tt \\par}) until after the second change, the paragraph
would be typeset with a width of 6.5 inches. However, if a blank
line were inserted before {\tt \\hsize = 6.5 in}, then the
paragraph would be typeset with a width of 5 inches. So, in
general, when a paragraph is set, the values of the parameters
that are in effect when the paragraph is completed are the ones
that are used.
Here is a table with some paragraph parameters:
\maketable [Some paragraph shape parameters]
\halign{
\strut \hfil # & \quad \hfil \tt # \hfil & \hfil \quad # \hfil\cr
\bf Function & \bf \TeX{} Control Word & \bf \TeX{} default\cr
\noalign{\hrule} \noalign{\smallskip}
width & \\hsize & 6.5 inches \cr
indentation on first line & \\parindent & 20 points\cr
distance between lines & \\baselineskip & 12 points\cr
distance between paragraphs & \\parskip & 0 points \cr
}
\toindex{parindent}
\toindex{parskip}
\toindex{baselineskip}
The control word {\tt \\noindent} may be used at the beginning of
a paragraph to avoid the automatic indentation on the first line.
This control word will only affect the paragraph being set when
it is invoked (of course {\tt \\parindent = 0 pt} will cause no
indentation for all paragraphs).
\toindex{noindent}
{\narrower
A more flexible way to control the width of a paragraph is to use
{\tt \\rightskip} and {\tt \\leftskip}. Setting {\tt \\leftskip
= 20 pt} causes the left margin of the paragraph to be moved in
an extra twenty points. Negative values may be assigned to {\tt
\\leftskip} to move the left margin out. The control word {\tt
\\rightskip} does the same to the right side of the paragraph.
The single control word {\tt \\narrower} is the equivalent of
setting both {\tt \\leftskip} and {\tt \\rightskip} equal to {\tt
\\parindent}. This is quite useful for long quotations, and
this paragraph is an example of its use. As with {\tt \\hsize},
the value of {\tt \\leftskip} and {\tt \\rightskip} in effect
when the paragraph is completed is the one which will apply to
the whole paragraph.
\TeXref{100}
}
\toindex{leftskip}
\toindex{rightskip}
\toindex{narrower}
\exercise Make two paragraphs with the following specifications:
the left margin of both paragraphs is indented by 1.5 inches,
the right margin of the first paragraph is indented by 0.75
inches, and the right margin of the second paragraph is indented
by 1.75 inches.
\bigskip
\def\hangparagraph{ Lines can be made with different lengths
within one paragraph by using {\tt \\hangindent} and {\tt
\\hangafter}. The amount of the indentation is determined by value
of {\tt \\hangindent}. If {\tt \\hangindent} is positive, the
indentation is made from the left, and if it is negative it is
made from the right. The lines on which the indentation occurs is
controlled by {\tt \\hangafter}. If {\tt \\hangafter} is
positive then it determines the number of lines at full width
before the indentation starts. Thus if {\tt \\hangindent = 1.75
in} and {\tt \\hangafter = 6}, then the first six lines will be
at full width and the rest will be indented by 1.75 inches from
the left. On the other hand if {\tt \\hangindent = \hbox{-1.75}
in} and {\tt \\hangafter = -6}, then the first six lines will be
indented by 1.75 inches from the right and the rest will be at
full width. \TeX{} resets to the default values {\tt \\hangindent
= 0 pt} and {\tt \\hangafter = 1} after each paragraph. These
control words are useful for paragraphs with ``hanging indents''
and for flowing a paragraph around space reserved for a figure.
\TeXref{355}The control word {\tt \\hang} at the beginning of the
paragraph will cause the first line to be of full width ({\tt
\\hangafter=1}) and the rest of the paragraph to be indented by
the current value of {\tt \\parindent}. But you do have to use
{\tt \\noindent} if you want the first line to extend all the way
to the left margin.
\TeXref{102}
\par}
\hangafter=6 \hangindent=1.75in
\hangparagraph
\toindex{hangindent}
\toindex{hangafter}
\toindex{hang}
Here is the previous paragraph repeated with {\tt \\hangafter = -6}
and {\tt \\hangindent = -1.75 in}.
\hangafter=-6 \hangindent=-1.75in \hangparagraph
The control word {\tt \\parshape} can be used to make paragraphs with
a greater variety of shapes.
\TeXref{101}
\toindex{parshape}
Another useful control word for setting paragraphs is {\tt \\item}.
It can be used to make various types of itemized lists,
and is invoked using the pattern {\tt \\item\lb$\ldots$\rb}\null.
This causes the next paragraph to be formed with every line
indented by {\tt \\parindent} and, in addition, the first line
labeled on the left by whatever is between the braces. It is
usually used with {\tt \\parskip = 0 pt}, since that control word
determines the vertical space between the different items. The control
word {\tt \\itemitem} is the same as {\tt \\item} except that the
indentation is twice as far, that is, twice the value of
{\tt \\parindent}.
\TeXref{102}Here is an example:
\toindex{item}
\toindex{itemitem}
\beginliteral
\parskip = 0pt \parindent = 30 pt
\noindent
Answer all the following questions:
\item{(1)} What is question 1?
\item{(2)} What is question 2?
\item{(3)} What is question 3?
\itemitem{(3a)} What is question 3a?
\itemitem{(3b)} What is question 3b?
@endliteral
\noindent
will produce
\vfill\eject
{\parskip = 0pt \parindent = 30 pt
\noindent
Answer all the following questions:
\item{(1)} What is question 1?
\item{(2)} What is question 2?
\item{(3)} What is question 3?
\itemitem{(3a)} What is question 3a?
\itemitem{(3b)} What is question 3b?
}
\exercise Make a paragraph several lines long and use it with
the {\tt \\item} control word to see the ``hanging indent.'' Now
take the same paragraph and use it with different values of {\tt
\\parindent} and {\tt \\hsize}.
\bigskip
Now let's see how to put space between paragraphs. The control
word {\tt \\parskip} is used to determine how much space is
normally left between paragraphs. So if you put {\tt \\parskip =
12 pt} at the beginning of your \TeX{} source file, there will be
12 points between paragraphs unless other instructions are
given. The control word {\tt \\vskip} can be used to insert extra
vertical space between paragraphs. If {\tt \\vskip 1 in} or {\tt
\\vskip 20 pt} appears between two paragraphs, then the extra
space is inserted.
There are a couple of peculiarities of {\tt \\vskip} that seem
quite strange at first. If you have {\tt \\vskip 3 in} and the
skip starts two inches from the bottom of the page, the rest of
the page is skipped, but the extra one inch is {\it not\/}
skipped at the top of the next page. In other words, {\tt \\vskip}
{\bf will not insert space across page boundaries}. In
fact, {\tt \\vskip~1~in} will have no effect at all if it happens
to appear at the top of a page! For many types of vertical
spacing this is quite appropriate. The space before a section
heading, for example, should not continue across page boundaries.
A similar phenomenon occurs at the beginning of your document.
If, for example, you want a title page with the title about half
way down the page, you can not insert the space at the top of the
page using {\tt \\vskip}.
But what if you really want some blank space at the top of a
page? You could start the page with {\tt\\\sp} but this in effect
typesets a one line paragraph containing a blank. So while
nothing is typeset, the extra space due to the values of {\tt
\\baselineskip} and {\tt \\parskip} will add extra space. An easier
method is to use {\tt \\vglue} instead of {\tt \\vskip} to get
the desired result. Thus {\tt \\vglue 1 in\ }will leave one inch
of blank space at the top of the page.\TeXref{352}
\toindex{vglue}
We can note in passing that there is another more general method
to put material at the top of a page using the control words {\tt
\\topinsert} and {\tt \\endinsert}. If {\tt \\topinsert $\ldots$
\\endinsert} is used within a page, the material between
{\tt \\topinsert} and {\tt \\endinsert} will appear at the top
of the page, if possible. For example:
\vbox{
\beginuser
\\topinsert
\\vskip 1 in
\\centerline\lb Figure 1\rb
\\endinsert
\enduser
}
\noindent
is useful for inserting figures of a prescribed size.
\TeXref{115}
\toindex{topinsert}
\toindex{endinsert}
There are also some special control words for making small
vertical skips. They are {\tt \\smallskip}, {\tt \\medskip}, and
{\tt \\bigskip}. Here is the size of each one:
\def\hrl{\hrule width .5 in}
\centerline{{\tt \\smallskip}: \vbox{\hrl \smallskip \hrl} \quad
{\tt \\medskip}: \vbox{\hrl \medskip \hrl} \quad
{\tt \\bigskip}: \vbox{\hrl \bigskip \hrl}
}
\toindex{smallskip}
\toindex{medskip}
\toindex{bigskip}
\subsection{Line shape}
For most material \TeX{} does a good job of breaking up a
paragraph into lines. But sometimes it's necessary to add
further instructions. It's possible to force a new line by
inserting {\tt \\hfill \\break} in your input file. It's also
possible to put some text on a line by itself using the control
word {\tt \\line\lb $\ldots$\rb}; then the material between the
braces will be restricted to one line (although the result will
be spread out over the whole line and may be horrible). The
control words {\tt \\leftline\lb $\ldots$\rb}, {\tt \\rightline\lb
$\ldots$\rb}, and {\tt \\centerline\lb $\ldots$\rb} will,
respectively, set the material between the braces on a single
line on the left margin, on the right margin, or \centred. Thus
\toindex{hfill}
\toindex{break}
\toindex{centerline}
\toindex{leftline}
\toindex{rightline}
\toindex{line}
\beginliteral
\leftline{I'm over on the left.}
\centerline{I'm in the @centre.}
\rightline{I'm on the right.}
\line{I just seem to be spread out all over the place.}
@endliteral
\noindent
produces the four lines:
\vskip\baselineskip
{
\hbadness = 10000
\leftline{I'm over on the left.}
\centerline{I'm in the \center.}
\rightline{I'm on the right.}
\line{I just seem to be spread out all over the place.}
Other types of spacing can be obtained by using the control word {\tt
\\hfil}. This causes all the extra space in the line to be
accumulated at the position where {\tt \\hfil} appears.
Thus if we alter our last example to
{\tt \\line\lb I just seem to be spread out \\hfil all over the place.\rb}
we will get \hfil\break
\medskip
\line{I just seem to be spread out \hfil all over the place.}
\medskip
If we have more than one {\tt \\hfil}, they will divide any extra
space among themselves equally. Hence
{\tt \\line\lb left text \\hfil \centre{} text \\hfil right text.\rb}
will produce
\medskip
\line{left text \hfil \centre{} text \hfil right text.}
\toindex{hfil}
}
\exercise Typeset the following line:
\line{left end \hfil left tackle \hfil left guard \hfil \centre{} \hfil
right guard \hfil right tackle \hfil right end}
\exercise Typeset the following line with twice as much space between
``left'' and ``right-\centre{}'' as between ``right-\centre{}'' and
``right'':
\line{left \hfil \hfil right-\centre{} \hfil right}
It's possible to move horizontally using {\tt \\hskip} in a
manner analogous with {\tt \\vskip}.
\toindex{hskip}
\exercise What happens with the following input:\hfil\break
{\tt \\line\lb\\hskip 1 in ONE \\hfil TWO \\hfil THREE\rb}
\bigskip
The right justification can be canceled by using the
control word {\tt \\raggedright}.
\toindex{raggedright}
\subsection{Footnotes}
The general pattern to make footnotes using \TeX{} is
{\tt \\footnote\lb$\ldots$\rb\lb$\ldots$\rb}\null.
The footnote mark goes in between the first set of braces. Some
available marks are {\tt \\dag (\dag)}, {\tt \\ddag (\ddag)}, {\tt \\S
(\S)}, and {\tt \\P (\P)}\null. The text of the footnote
goes between the second set of braces. The use of numbers as
marks is a little less straightforward. The footnote%
\footnote{${}^{21}$}{This is the footnote at the bottom of the page.}
at the bottom of the page was produced by using {\tt \\footnote\lb\$\lb
\rb\^{}\lb{21}\rb\$\rb\lb This is the footnote at the
bottom of the page.\rb} after the word ``footnote'' in the
text. This construction is somewhat complicated; we'll see why
it's this way when we know a little more about typesetting
mathematics. But for the moment we can look at it as a way of
getting the job done. You may want to use {\tt \\rm} within the
footnote to ensure that the right font appears. Usually you will
not want a space between the text and the control word {\tt
footnote}.\TeXref{117}
\toindex{footnote}
\toindex{ddag}
\toindex{S}
\toindex{P}
\exercise Make up a page with a relatively long footnote spanning
several lines.
\exercise Make up a page with two different footnotes on it.
\subsection{Headlines and Footlines}
\headline={\hfil \tenrm Page \the\pageno} %example for this section
The lines for title and page numbers that go above and below the
main text are produced by using {\tt \\headline=\lb$\dots$\rb}
and {\tt \\footline=\lb$\dots$\rb}\null.
\TeXref{252--253}
The principle is the same as using the control word {\tt \\line\lb
$\dots$\rb} within the usual text on the page. A helpful
control word is {\tt \\pageno} which represents the current page
number. Thus {\tt \\headline=\lb\\hfil \\tenrm Page \\the\\pageno\rb}
would cause the page number to appear in the upper
right corner preceded by the word ``Page'' (now look at the upper
right corner of this page). It is safer to explicitly name the
font that you want to use (in this case {\tt \\tenrm} to use the
10 point roman font), since you are never guaranteed that a
particular font will be in use when the headline or footline is
set. The control word {\tt \\the} takes the internal value of the
next word if it is an appropriate control word and prints it as
text. You can also use the control word {\tt \\folio} instead of
{\tt \\the \\pageno}. The difference is that {\tt \\folio} will
give roman numerals when {\tt \\pageno} is negative.
\toindex{headline}
\toindex{footline}
\toindex{pageno}
\toindex{the}
\toindex{folio}
You can also assign values to {\tt \\pageno} if you want your
document to use a different sequence of page numbers from the
usual. Roman numerals can be produced by using negative numbers;
{\tt \\pageno=-1} at the beginning of a document will cause page
numbers to be in roman numerals.
\TeXref{252}
Different headlines can be produced for even and odd pages in
the following manner:
{\tt
\\headline=\lb\\ifodd \\pageno \lb$\dots$\rb \\else \lb$\dots$\rb
\\fi\rb}
\noindent
where the material between the first set of braces is for the
right-hand pages and the material between the second set of
braces is for the left-hand pages.
\exercise Change the footline so that the page number is \centred{}
with an en-dash on either side.
\subsection{Overfull and underfull boxes}
One of the most frustrating experiences for the new \TeX{} user
is the occurrence of overfull and underfull boxes. They are duly
noted in the log file and are also written to the screen when \TeX{}
is being run interactively. Overfull boxes are also marked
on the output by a slug (a large filled-in black rectangle that
looks like this: \vrule width \overfullrule) in the right
margin. Various obscene terms are applied to this slug. It
appears even though there is nothing wrong with the \TeX{} input.
So why is the slug there and what can be done about it?
A good way to visualize the way \TeX{} organizes a page is to
think of the printed material as being put into boxes. There are
two types of boxes: {\sl hboxes\/} and {\sl vboxes}. Most of the
time these correspond to the organization of horizontal text
into lines and vertical paragraphs into pages. In particular, it
is the spacing of the words in a hbox corresponding to a line of
text that causes the slug to appear.
Recall that \TeX{} reads in the complete paragraph before
deciding how to break it up into lines. This is better than
working a line at a time, since a slight improvement in one line
might cause catastrophic changes farther down in the paragraph.
When words are gathered together to form a line, space is added
between the words to justify the right margin. Very large spaces
between words is obviously undesirable; the badness of the line
is a measure of how badly the words are spaced. An underfull
hbox means that there is too much space between words. More
specifically, the badness of any line is a number between 0
(perfect) and 10000 (horrible). There is a parameter called {\tt
\\hbadness} whose default value is 1000\null. Any line whose
badness is greater than {\tt \\hbadness} is reported as an
underfull hbox. If the value of {\tt \\hbadness} is increased,
then fewer underfull hboxes will be reported. In fact {\tt
\\hbadness = 10000} will suppress the reporting of underfull
hboxes altogether. Similarly, if the words must be squeezed into
a line so that the spaces are very small or even so the words
extend a little into the right margin, then an overfull hbox
results. \toindex{hbadness}
%%%%%%%%%%%%%% restore original headline %%%%%%%%%%%%%%%%%%%%%%%%
\headline={\iftitlepage \hfil \global\titlepagefalse
\else \gentleheadline \fi}
In a similar way, sometimes \TeX{} allows a line to be slightly
longer than {\tt \\hsize} in order to achieve a more balanced
appearance. The control word {\tt \\tolerance} determines when
this happens. If the badness of a line is greater than {\tt
\\tolerance}, \TeX{} will make the line longer by adding a new word
at the end of the line, even though it might exceed the value of
{\tt \\hsize}. A line which is only slightly longer is set
without being reported. The control word {\tt \\hfuzz} determines
how much excess is allowed; the default is {\tt \\hfuzz
=~0.1~pt}. A line that is more than slightly longer than {\tt \\hsize}
is obviously a serious problem; \TeX{} puts a slug in
the margin to make its point forcefully. It's possible to avoid
overfull hboxes altogether by increasing the value of {\tt \\tolerance}.
With {\tt \\tolerance = 10000} there will never be
overfull boxes or slugs. The default is {\tt \\tolerance = 200}\null.
\TeXref{29}
\toindex{hfuzz}
\toindex{tolerance}
The width of the slug is determined by the control word {\tt
\\overfullrule}. Including {\tt \\overfullrule = 0 pt} in your
file will delete any further printing of the slugs. The
overfull boxes will still be there, of course, and they will
probably be harder to spot.
\toindex{overfullrule}
So we see why overfull boxes and underfull boxes are reported; we
can also change the reporting by changing the values of {\tt
\\badness}, {\tt \\hfuzz}, and {\tt \\tolerance}. In addition, a
small value of {\tt \\hsize} obviously makes it more difficult to
set lines and causes more overfull and underfull hboxes to be
reported. These are warnings that you ignore at your own peril!
Adding new possibilities of hyphenation will sometimes eliminate
an overfull box. \TeX{} has automatic hyphenation and usually
finds good places to hyphenate a word; however, it's possible to
add hyphenations to let lines break at new places. For example,
the automatic hyphenation will never put a hyphen in the word
``database''. If you type in {\tt data\\-base}, it will allow a
hyphen to be inserted after the second letter ``a'' in the word.
More generally, if you put {\tt \\hyphenation\lb data-base\rb} in
the beginning of your input file, then all occurrences of the
word ``database'' will allow hyphenation after the letter ``a''.
\TeXref{28} The log file will show the possible hyphenations on
the line containing the overfull or underfull box. Sometimes the
best solution to an overfull or underfull hbox is a little
judicious editing of the original document.
\toindex{hyphenation}
Our discussion has involved the setting of type into lines, that is,
the horizontal page structure. There are several vertical \analog{}s.
Overfull and underfull hboxes indicate how well words are gathered
into lines. Similarly, overfull and underfull vboxes are reported
when paragraphs are gathered to form pages. A large table that
can't be broken in the middle, for example, can produce an underfull
vbox that is reported in the log file when the page being typeset is
completed. The control word {\tt \\vbadness} works for the vertical
placement of text in the same way as {\tt \\hbadness} works for
horizontal text.
\toindex{vbadness}
\exercise Take a few paragraphs and print them using various (small)
values of {\tt \\hsize} to see what kind of overfull boxes result.
Repeat with various values of {\tt \\hbadness}, {\tt \\hfuzz}, and
{\tt \\tolerance}.
\section{$\Bigl\{$Groups, $\bigl\{$Groups,
$\{$and More Groups$\}\bigr\}\Bigr\}$}
The concept of gathering text into groups allows \TeX{} input
files to be greatly simplified. A new group is started by the
character {\tt\lb} and terminated by the character {\tt \rb}\null.
Changes made within a group will lose their effect when the
group terminates. So, for example if {\tt \lb \\bf three
boldface words\rb} appears in your text, the opening brace starts
the group, the {\tt \\bf} control word changes to a boldface
font, and the closing brace finishes up the group. Upon
completion of the group the font being used is the one in effect
before the group started. This is the (easier) way of having a
few words in a different font. It's also possible to have groups
nested within groups.
As another example, size changes can be made in the text that are
only temporary. For example
\beginuser
\lb
\\hsize = 4 in
\\parindent = 0 pt
\\leftskip = 1 in
will produce a paragraph that is four
$\vdots$
(this is an easy mistake to make).
\\par
\rb
\enduser
{\hsize = 4 in
\parindent = 0 pt
\leftskip = 1 in
will produce a paragraph that is four inches wide with the text
offset into the paragraph by one inch regardless of the settings
in effect before the start of the group. This paragraph is set
with those values. After the end of the group, the old settings
are in effect again. Note that it is necessary to include
{\tt \\par} or to use a blank line before the closing brace to end
the paragraph, since otherwise the group will end and \TeX{} will
go back to the old parameters before the paragraph is actually
typeset (this is an easy mistake to make). \par}
When line-spacing control words (like {\tt \\centerline}) act on text
following it in braces, that text is implicitly in a group. Thus
{\tt \\centerline\lb\\bf A bold title\rb} will produce a \centred{}
boldface line, and the text following that line will be in
whatever font was in effect before the {\tt \\centerline} was
invoked.
The empty group {\tt\lb\rb} is useful. One use allows accents to be
typeset with no accompanying letter. For example, {\tt \\\~{}\lb\rb}
will print a tilde with no letter under it. It can also be used to
stop \TeX{} from eating up consecutive spaces. Hence {\tt I use
\\TeX\lb\rb{} all the time} will leave a space after ``\TeX'' in the
output. This is an alternative to using {\tt \\\sp} as we did in
Section~1.
\TeXref{19--21}
Grouping can also be used to avoid spaces in the middle of a word
when including accents. Either {\tt soup\\c\sp con} or {\tt
soup\\c\lb c\rb on} will produce the word soup\c{c}on.
\exercise Change the dimensions of one paragraph on a page using the
grouping idea.
\exercise Mathematicians sometime use the word ``i{f}f'' as an
abbreviation for ``if and only if''\null. In this case it looks
better if the first and second letter ``f'' are {\sl not\/}
joined as a ligature. How do you do this (there are several
solutions)?
It's really easy to forget to match braces properly. The effect
can be dramatic; if you get output that suddenly changes to an
italic font for the rest of the document, a mismatched brace is
probably the cause. If you have an extra {\tt \lb} \TeX{} will
give a message in the log file: {\tt (\\end occurred inside a
group at level 1)}. An extra {\tt\rb} will result in the message
\hbox{\tt! Too many \rb's.}
Here's a little hint to help you keep track of the braces in more
complicated groups: put the opening brace on a line by itself and
do the same for the closing brace. If there are braces nested
within the original ones, put them on separate lines also, but
indent them a few spaces. The text within the nested braces can
also be indented since \TeX{} ignores all spaces at the beginning
of a line. The matching braces will then stand out when you look
at your \TeX{} source file. In fact, if your editor is smart
enough, you can create the two lines with the braces first and
then insert the appropriate material within them with automatic
indenting.
\exercise In section 2 we changed fonts the following method:
{\tt I started with roman type, \\it switched to italic type,
\\rm and returned to roman type}. Get the same result using the
idea of grouping.
\section{No math anxiety here!}
\TeX{} is at its best when typesetting mathematics. The
conventions for doing this are many and complex, and the ability
of \TeX{} to take them into account makes the production of high
quality, attractive mathematical output possible. If you plan to
produce papers with mathematical symbols in them, this section
will give you all the basics necessary for creating beautiful
output in almost all circumstances; \TeX{} may be used without
any mathematics, of course, and if this is your goal, then the
following two subsections are probably sufficient for your needs.
\subsection{Lots of new symbols}
Mathematical text is inserted into normal text in two possible
ways: it can be {\sl in-line\/}, that is, as part of the usual
lines of text. It can also be {\sl displayed}, that is, \centred{}
in a gap between the usual text. The results in the spacing and
placement of symbols can be quite different in each case. The
in-line equation $\sum_{k=1}^{\infty} {1\over k^2} = {\pi^2\over6}$
is easily seen to be different from the same equation when
displayed:
$$\sum_{k=1}^{\infty} {1\over k^2} = {\pi^2\over6}.$$
Since the spacing and the fonts used for mathematics are quite
different from those of ordinary text, \TeX{} needs to be told
when mathematics rather than normal text is being typeset. This
is done using the {\tt\$} symbol. More specifically, mathematics
is typeset in-line by surrounding the symbols to be entered by
single dollar signs: {\tt \$$\ldots$\$}, and is typeset displayed
by surrounding the symbols to be entered by double dollar signs:
{\tt \$\$$\ldots$\$\$}\null. Hence {\tt \$x = y+1\$} will give
$x=y+1$ in-line while {\tt \$\$x = y+1.\$\$} will display
$$x=y+1.$$
The spacing for both in-line and displayed mathematics is
completely controlled by \TeX\null. Adding spaces to your input
has no effect at all. What if you need a space or some text in
the middle of some mathematics? You can insert text by inserting
it into an hbox (don't worry about the definition of an hbox for
now): {\tt \\hbox\lb$\ldots$\rb}\null. This is particularly
useful for displayed mathematics. Hence ``$x=y+1 \hbox{ whenever
} y=x-1$'' can be typeset using {\tt \$x=y+1 \\hbox\lb\ whenever
\rb y=x-1\$}. Note the spaces on either side of the word within
the braces. Usually it isn't necessary to insert spaces into
mathematical text, but here are the control sequences that do the
job.
\TeXref{167}
\maketable [Adding space to mathematical text]
\halign{
\strut \hfil # & \quad \hfil\tt# \hfil \quad
& \hbox to 2cm{\hrulefill\vrule height 8pt#\vrule height 8pt\hrulefill} \cr
Name & \rm Control Sequence & \hfil{}$\gets$Size$\to$\cr
\noalign{\hrule} \noalign{\smallskip}
Double quad & \\qquad &\qquad \cr
Quad & \\quad &\quad \cr
Space & \\\sp\ &\ \cr
Thick space & \\; &$\;$\cr
Medium space & \\> &$\>$\cr
Thin space & \\, &$\,$\cr
Negative thin space & \ \\!\ &$\!$\cr
}
\toindex{quad}
\toindex{qquad}
\toindex{\sp}
\toindex{;}
\toindex{>}
\toindex{,}
\toindex{!}
If you look closely at the negative thin space, you'll notice
that, unlike the other entries, the two arms overlap. This is
because the negative space is one in the opposite direction, that
is, while the other control sequences increase the amount of
space between two symbols being typeset, the negative thin space
decreases the space between them, even if it causes them to
overlap.
\exercise Typeset the following: $C(n,r) = n!/(r!\,(n-r)!)$\null. Note the
spacing in the denominator.
\bigskip
You shouldn't have any blank lines between the dollar signs
delimiting the mathematical text. \TeX{} assumes that all the
mathematical text being typeset is in one paragraph, and a blank
line starts a new paragraph; consequently, this will generate an
error message. This turns out to be useful, for one of the
easiest errors to make is to forget to put in the trailing dollar
sign(s) after the mathematical input (I promise that you'll do it
at least once while learning \TeX{}); if \TeX{} allowed more than
one paragraph to be between the dollars signs, then one omitted
trailing dollar sign might cause the rest of the document to be
typeset as mathematics.
Most mathematical text is entered in exactly the same way for
in-line typesetting as for displayed typesetting (except for the
surrounding dollar signs, of course). The exceptions, such as
aligning multiline displays and placing equation numbers at the
left or right margin will be discussed in the last part of this
section.
Many new symbols can appear when typesetting mathematics. Most
of the ones that actually appear on the keyboard can be used
directly. The symbols {\tt + - / * = ' | < > (} and {\tt )} are
all entered directly. Here they are as mathematics: $+ - / * =\>
'\> | <\> >\> ( \> )$.
\exercise Typeset the equation $a+b=c-d=xy=w/z$ as in-line and
displayed mathematical text.
\exercise Typeset the equation $(fg)' = f'g + fg'$ as in-line and
displayed mathematical text.
\bigskip
Many other symbols, as you would expect, are predefined control
words. All Greek letters are available. Here is a table of them:
\TeXref{434}
\maketable [Greek letters]
\halign{
\strut \hfil$#$ & \quad \tt# \hfil \qquad &\hfil$#$ & \quad \tt# \hfil \qquad
&\hfil$#$ & \quad \tt# \hfil \qquad &\hfil$#$ & \quad \tt# \hfil \cr
\noalign{\hrule} \noalign{\smallskip}
\alpha & \\alpha &\beta & \\beta &\gamma & \\gamma &\delta & \\delta \cr
\epsilon & \\epsilon & \varepsilon & \\varepsilon & \zeta & \\zeta &
\eta & \\eta \cr
\theta & \\theta & \vartheta & \\vartheta & \iota & \\iota & \kappa &
\\kappa \cr
\lambda & \\lambda & \mu & \\mu & \nu & \\nu & \xi & \\xi \cr
o & o & \pi & \\pi & \rho & \\rho & \varrho & \\varrho \cr
\sigma & \\sigma & \varsigma & \\varsigma & \tau & \\tau & \upsilon &
\\upsilon \cr
\phi & \\phi & \varphi & \\varphi & \chi & \\chi & \psi & \\psi \cr
\omega & \\omega & \Gamma & \\Gamma & \Delta & \\Delta & \Theta &
\\Theta \cr
\Lambda & \\Lambda & \Xi & \\Xi & \Pi & \\Pi & \Sigma & \\Sigma \cr
\Upsilon & \\Upsilon & \Phi & \\Phi & \Psi & \\Psi & \Omega & \\Omega \cr
}
\toindex{alpha}
\toindex{beta}
\toindex{gamma}
\toindex{delta}
\toindex{epsilon}
\toindex{varepsilon}
\toindex{zeta}
\toindex{eta}
\toindex{theta}
\toindex{vartheta}
\toindex{iota}
\toindex{kappa}
\toindex{lambda}
\toindex{mu}
\toindex{nu}
\toindex{xi}
\toindex{pi}
\toindex{rho}
\toindex{varrho}
\toindex{sigma}
\toindex{varsigma}
\toindex{tau}
\toindex{upsilon}
\toindex{phi}
\toindex{varphi}
\toindex{chi}
\toindex{psi}
\toindex{omega}
\toindex{Gamma}
\toindex{Delta}
\toindex{Theta}
\toindex{Lambda}
\toindex{Xi}
\toindex{Pi}
\toindex{Sigma}
\toindex{Upsilon}
\toindex{Phi}
\toindex{Psi}
\toindex{Omega}
\exercise Typeset $\alpha\beta=\gamma+\delta$ as in-line and displayed
mathematical text.
\exercise Typeset $\Gamma(n) = (n-1)!$ as in-line and displayed
mathematical text.
Sometimes accents are put above or below symbols. The control
words used for accents in mathematics are different from those
used for normal text. The normal text control words may not be
used for mathematics and vice-versa.
\TeXref{135--136}
\maketable [Mathematical accents]
\halign{
\strut \hfil$#$ & \quad \tt# \hfil \qquad &\hfil$#$ &
\quad \tt# \hfil \qquad &\hfil$#$ & \quad \tt# \hfil \qquad \cr
\noalign{\hrule} \noalign{\smallskip}
\hat o & \\hat o & \check o & \\check o & \tilde o & \\tilde o \cr
\acute o & \\acute o & \grave o & \\grave o & \dot o & \\dot o \cr
\ddot o & \\ddot o &\breve o & \\breve o & \bar o & \\bar o \cr
\vec o & \\vec o & \widehat {abc} & \\widehat \lb abc\rb
& \widetilde {abc} & \\widetilde \lb abc\rb\cr
}
\toindex{hat}
\toindex{check}
\toindex{tilde}
\toindex{acute}
\toindex{grave}
\toindex{dot}
\toindex{ddot}
\toindex{breve}
\toindex{bar}
\toindex{vec}
\toindex{widehat}
\toindex{widetilde}
Binary operators combine two mathematical objects to get another
object. Ordinary addition and multiplication, for example,
combine two numbers to get another number, and so they are binary
operators. When a binary operator such as $+$ or $\times$ is
typeset, a little extra space is put around it. Here is a list of
some of the available binary operators:
\TeXref{436}
\maketable [Binary operators]
\halign{
\strut \hfil$#$ & \quad \tt# \hfil \qquad &\hfil$#$ & \quad \tt# \hfil \qquad
&\hfil$#$ & \quad \tt# \hfil \qquad &\hfil$#$ & \quad \tt# \hfil \cr
\noalign{\hrule} \noalign{\smallskip}
\cdot & \\cdot &\times & \\times &\ast & \\ast &\star & \\star \cr
\circ & \\circ & \bullet & \\bullet & \div & \\div & \diamond & \\diamond \cr
\cap & \\cap & \cup & \\cup & \vee & \\vee & \wedge & \\wedge \cr
\oplus & \\oplus &\ominus & \\ominus & \otimes &\\otimes &\odot &\\odot \cr
}
\toindex{cdot}
\toindex{times}
\toindex{ast}
\toindex{star}
\toindex{circ}
\toindex{bullet}
\toindex{div}
\toindex{diamond}
\toindex{cap}
\toindex{cup}
\toindex{vee}
\toindex{wedge}
\toindex{oplus}
\toindex{ominus}
\toindex{otimes}
\toindex{odot}
Ellipses are commonly used with binary operators. The control
word {\tt \\cdots} will raise the dots so that they are level
with the binary operator. Thus {\tt \$a + \\cdots + z\$} will
produce $a + \cdots + z$. The control word {\tt \\ldots} will
put the dots on the baseline, and so {\tt \$1\\ldots n\$}
produces $1\ldots n$.
\toindex{cdots}
\toindex{ldots}
\exercise Typeset: $x\wedge (y\vee z) = (x\wedge y) \vee (x\wedge z)$.
\exercise Typeset: $2+4+6+\cdots +2n = n(n+1)$.
\bigskip
A relation indicates a property of two mathematical objects. We
already know how to show two objects equal, or how to show one
number less than or greater than another number (since these are
symbols on most terminal keyboards). To negate a relation, the
control word {\tt \\not} is put in front of the relation. Here
are some relations:
\TeXref{436}
\toindex{not}
\maketable [Relations ]
\halign{
\strut \hfil$#$ & \quad \tt# \hfil \qquad &\hfil$#$ & \quad \tt# \hfil \qquad
&\hfil$#$ & \quad \tt# \hfil \qquad &\hfil$#$ & \quad \tt# \hfil \cr
\noalign{\hrule} \noalign{\smallskip}
\leq & \\leq &\not\leq & \\not \\leq
& \geq & \\geq & \not\geq & \\not \\geq \cr
\equiv & \\equiv & \not\equiv & \\not \\equiv
& \sim & \\sim & \not\sim & \\not \\sim \cr
\simeq & \\simeq & \not\simeq & \\not \\simeq
& \approx & \\approx & \not\approx & \\not \\approx \cr
\subset & \\subset & \subseteq & \\subseteq
& \supset & \\supset & \supseteq & \\supseteq \cr
\in & \\in & \ni & \\ni & \parallel & \\parallel & \perp & \\perp \cr
}
\toindex{leq}
\toindex{geq}
\toindex{equiv}
\toindex{sim}
\toindex{simeq}
\toindex{approx}
\toindex{subset}
\toindex{subseteq}
\toindex{supset}
\toindex{supseteq}
\toindex{in}
\toindex{ni}
\toindex{parallel}
\toindex{perp}
\exercise
Typeset: $\vec x\cdot \vec y = 0$ if and only if $\vec x \perp \vec y$.
\exercise
Typeset: $\vec x\cdot \vec y \not= 0$ if and only if $\vec x \not\perp \vec y$.
Here are some other available mathematical symbols:\TeXref{435--438}
\maketable [Miscellaneous symbols ]
\halign{
\strut \hfil$#$ & \quad \tt# \hfil \qquad &\hfil$#$ & \quad \tt# \hfil \qquad
&\hfil$#$ & \quad \tt# \hfil \qquad &\hfil$#$ & \quad \tt# \hfil \cr
\noalign{\hrule} \noalign{\smallskip}
\aleph & \\aleph & \ell & \\ell & \Re & \\Re & \Im & \\Im \cr
\partial & \\partial & \infty & \\infty & \| & \\| & \angle & \\angle \cr
\nabla & \\nabla & \backslash &\\backslash & \forall & \\forall
& \exists & \\exists \cr
\neg & \\neg & \flat & \\flat & \sharp & \\sharp & \natural & \\natural \cr
}
\toindex{aleph}
\toindex{ell}
\toindex{Re}
\toindex{Im}
\toindex{partial}
\toindex{infty}
\toindex{|}
\toindex{angle}
\toindex{nabla}
\toindex{backslash}
\toindex{forall}
\toindex{exists}
\toindex{neg}
\toindex{flat}
\toindex{sharp}
\toindex{natural}
\exercise Typeset: $(\forall x\in \Re)(\exists y\in\Re)$ $y>x$.
\subsection{Fractions}
There are two methods of typesetting a fraction: it can be
typeset either in the form $1/2$ or in the form ${1\over2}$\null.
The first case is just entered with no special control sequences,
that is, {\tt \$1/2\$}\null. The second case uses the control
word {\tt \\over} and the following pattern: {\tt \lb
<numerator> \\over <denominator>\rb}\null. Hence {\tt \$\$\lb a+b
\\over c+d\rb.\$\$} gives \TeXref{139--140}
\toindex{over} $${a+b\over c+d}.$$
\exercise Typeset the following: ${a+b\over c}\quad {a\over b+c}
\quad {1\over a+b+c} \not= {1\over a}+{1\over b}+{1\over c}$.
\exercise Typeset: What are the points where
${\partial \over \partial x} f(x,y) = {\partial \over \partial y}
f(x,y) = 0$?
\subsection{Subscripts and superscripts}
Subscripts and superscripts are particularly easy to enter using
\TeX\null. The characters {\tt \_{}} and {\tt \^{}} are used to
indicate that the next character is a subscript or a superscript.
Thus {\tt \$x\^{}2\$} gives $x^2$ and {\tt \$x\_{}2\$} gives
$x_2$\null. To get several characters as a subscript or
superscript, they are grouped together within braces. Hence we
can use {\tt \$x\^{}\lb 21\rb\$} to get $x^{21}$ and {\tt \$x\_{}\lb
21\rb\$} to get $x_{21}$\null. Notice that the
superscripts and subscripts are automatically typeset in a
smaller type size. The situation is only slightly more
complicated for a second layer of subscripts or superscripts.
You can {\sl not\/} use {\tt \$x\_{}2\_{}3\$} since this could
have two possible interpretations, namely, {\tt \$x\_{}\lb 2\_{}3\rb\$}
or {\tt \$\lb x\_{}2\rb\_{}3\$}; this gives two
different results: $x_{2_3}$ and ${x_2}_3$, the first of which is
the usual mathematical subscript notation. Thus you must put in
the complete braces to describe multiple layers of subscripts and
superscripts. They may be done to any level.
\TeXref{128--130}
To use both subscripts and superscripts on one symbol, you use
both the {\tt \_{}} and {\tt \^{}} in either order. Thus either
{\tt \$x\_{}2\^{}1\$} or {\tt\$x\^{}1\_{}2\$} will give $x_2^1$.
\exercise
Typeset each of the following: $e^x \quad e^{-x} \quad
e^{i\pi}+1=0 \quad x_0 \quad x_0^2 \quad {x_0}^2 \quad 2^{x^x}$.
\exercise Typeset:
$\nabla^2 f(x,y) = {\partial^2 f \over\partial x^2}
+ {\partial^2 f \over\partial y^2}$.
\bigskip
A similar method is used for summations and integrals. The input
of {\tt \$\\sum\_{}\lb k=1\rb\^{}n k\^{}2\$} will give $\sum_{k=1}^n
k^2$, and {\tt \$\\int\_{}0\^{}x f(t) dt\$} will
give $\int_0^x f(t) dt$.
\TeXref{144--145}
\toindex{sum}
\toindex{int}
Another use of this type of input is for expressions
involving limits. You can use
{\tt \$\\lim\_\lb n\\to \\infty\rb (\lb n+1 \\over n\rb)\^{}n = e\$}
to get $\lim_{n\to \infty} ({n+1\over n})^n = e$.
\toindex{lim}
\exercise Typeset the following expression: $\lim_{x\to 0}
(1+x)^{1\over x}=e$.
\exercise Typeset: The cardinality of $(-\infty, \infty)$ is $\aleph_1$.
\exercise Typeset: $\lim_{x\to {0^+}} x^x = 1$.
\bigskip
Here's a hint to make integrals look a little nicer: look at the
difference between $\int_0^x f(t) dt$ and $\int_0^x f(t)\, dt$\null.
In the second case there is a little extra space after
$f(t)$, and it looks nicer; {\tt \\,} was used to add the
additional space.
\toindex{,}
\exercise Typeset the following integral: $\int_0^1 3x^2\,dx = 1$.
\subsection{Roots, square and otherwise}
To typeset a square root it is only necessary to use the construction
{\tt \\sqrt\lb$\ldots$\rb}\null. Hence {\tt \$\\sqrt\lb x\^{}2+y\^{}2\rb\$}
will give $\sqrt{x^2+y^2}$\null. Notice that \TeX{} takes care of the
placement of symbols and the height and length of the radical.
To make cube or other roots, the control words {\tt \\root} and {\tt
\\of} are used. You get $\root n \of {1+x^n}$ from the
input\TeXref{130--131} {\tt \$\\root n \\of \lb1+x\^{}n\rb\$}.
\toindex{root}
\toindex{sqroot}
A possible alternative is to use the control word {\tt \\surd}; the
input {\tt \$\\surd 2\$} will produce $\surd 2$.
\toindex{surd}
\exercise Typeset the following: $\sqrt2 \quad \sqrt {x+y\over x-y}
\quad \root 3 \of {10}$ \quad $e^{\sqrt x}$.
\exercise Typeset: $\|x\| = \sqrt{x\cdot x}$.
\exercise Typeset:
$\phi(t) = {1 \over \sqrt{2\pi}} \int_0^t e^{-x^2/2}\,dx$.
\subsection{Lines, above and below}
Use the constructions {\tt \\overline\lb$\ldots$\rb} and
{\tt \\underline\lb$\ldots$\rb} to put lines above or below mathematical
expressions. Hence {\tt \$\\overline\lb x+y\rb=\\overline x + \\overline
y\$} gives $\overline{x+y}=\overline x + \overline y$\null.
But notice that the lines over the letters are at
different heights, and so some care is necessary. The use of {\tt
\\overline\lb\\strut x\rb} will raise the height of the line
over\TeXref{130--131} $x$\null.
\toindex{overline}
\toindex{underline}
To underline non-mathematical text, use {\tt \\underbar\lb$\dots$\rb}.
\toindex{underbar}
\exercise Typeset the following: $\underline x \quad \overline y
\quad \underline{\overline{x+y}}$.
\subsection{Delimiters large and small}
The most commonly used mathematical delimiters are brackets,
braces, and parentheses. As we have seen, they may be produced
by using {\tt [ ] \\\lb\ \\\rb\ ( )} to get
$[\>]\>\{\>\}\>(\>)\>$. Sometimes larger delimiters increase the
clarity of mathematical expressions, as in
$$\bigl(a\times(b+c)\bigr) \bigl((a\times b)+c\bigr).$$ To make
larger left delimiters the control words {\tt \\bigl}, {\tt
\\Bigl}, {\tt \\biggl}, and {\tt \\Biggl} are used in front of
the delimiter; similarly, {\tt \\bigr}, {\tt \\Bigr}, {\tt
\\biggr}, and {\tt \\Biggr} are used\TeXref{145--147} for the
right delimiters. Hence {\tt \$\\Bigl[\$} and {\tt \$\\Bigr]\$}
will produce $\Bigl[$ and $\Bigr]$.
\toindex{bigl}
\toindex{Bigl}
\toindex{biggl}
\toindex{Biggl}
\toindex{bigr}
\toindex{Bigr}
\toindex{biggr}
\toindex{Biggr}
Here is a table to compare the size of some of the delimiters.
%% \everycr can add 4 points between lines in the following table %%
\everycr={\noalign{\vskip 4 pt}}
\maketable [Delimiters of various sizes]
\halign{
\strut \hfil$#$ & \quad \tt# \hfil \quad\qquad
&\hfil$#$ & \quad \tt# \hfil \quad\qquad
&\hfil$#$ & \quad \tt# \hfil \quad\qquad
&\hfil$#$ & \quad \tt# \hfil \cr
\noalign{\hrule} \noalign{\smallskip}
\{ & \\\lb & \} & \\\rb & ( & ( & ) & )\cr
\bigl\{ & \\bigl\\\lb & \bigr\} & \\bigr\\\rb & \bigl( & \\bigl( & \bigr) &
\\bigr)\cr
\Bigl\{ & \\Bigl\\\lb & \Bigr\} & \\Bigr\\\rb & \Bigl( & \\Bigl( & \Bigr) &
\\Bigr)\cr
\biggl\{ & \\biggl\\\lb & \biggr\} & \\biggr\\\rb & \biggl(
& \\biggl( & \biggr) & \\biggr) \cr
\Biggl\{ & \\Biggl\\\lb & \Biggr\} & \\Biggr\\\rb & \Biggl(
& \\Biggl( & \Biggr) & \\Biggr)\cr
}
\everycr={}
If you want, you can let \TeX{} choose the size of delimiter by
using the control words {\tt \\left} and {\tt \\right} before
your delimiters.
\TeXref{148}Thus {\tt \\left[$\ldots$\\right]} will cause the material
to be enclosed by brackets that are appropriately big. {\bf Note
well:} each use of a {\tt \\left} delimiter must have a matching
{\tt \\right} delimiter (although the delimiters themselves may be
different). Hence {\tt \$\$\\left|\lb a+b \\over
c+d\rb\\right|.\$\$} gives $$\left|{a+b \over c+d}\right|.$$
\maketable [Mathematical delimiters]
\halign{
\strut \hfill$#$ & \quad \tt # \qquad\qquad &
\hfill$#$ & \quad \tt # \qquad\qquad &
\hfill$#$ & \quad \tt # \cr
\noalign{\hrule} \noalign{\smallskip}
( & ( & ) & ) & [ & [ \cr
] & ] &\{ & \\\lb & \} & \\\rb \cr
\lfloor & \\lfloor &\rfloor &\\rfloor & \lceil & \\lceil \cr
\rceil & \\rceil &\langle & \\langle & \rangle & \\rangle \cr
/ & / & \backslash & \\backslash &| & | \cr
\| & \\| &\uparrow & \\uparrow & \Uparrow & \\Uparrow \cr
\downarrow & \\downarrow & \Downarrow & \\Downarrow
& \updownarrow & \\updownarrow \cr
\Updownarrow & \\Updownarrow \cr
}
\toindex{lfloor}
\toindex{rfloor}
\toindex{lceil}
\toindex{rceil}
\toindex{langle}
\toindex{rangle}
\toindex{|}
\toindex{uparrow}
\toindex{Uparrow}
\toindex{downarrow}
\toindex{Downarrow}
\toindex{updownarrow}
\toindex{Updownarrow}
\exercise Typeset $\bigl \lceil \lfloor x \rfloor \bigr \rceil
\leq \bigl \lfloor \lceil x \rceil \bigr \rfloor$.
\subsection{Those special functions}
There are several types of functions that appear frequently in
mathematical text. In an equation like ``$\sin^2x + \cos^2x =
1$'' the trigonometric functions ``sin'' and ``cos'' are in roman
rather than italic type. This is the usual mathematical
convention to indicate that it is a function being described and
not the product of three variables. The control words {\tt
\\sin} and {\tt \\cos} will use the right typeface automatically.
Here is a table of these and some other special functions:
\TeXref{162}
\maketable [Special mathematical functions]
\halign{
\strut \tt {\\}#\hfil && \quad \tt {\\}#\hfil \cr
\noalign{\hrule} \noalign{\smallskip}
sin & cos & tan & cot & sec & csc & arcsin & arccos \cr
arctan & sinh & cosh & tanh & coth & lim & sup & inf \cr
limsup & liminf & log & ln & lg & exp & det & deg \cr
dim & hom & ker & max & min & arg & gcd & Pr \cr
}
\toindex{sin}
\toindex{cos}
\toindex{tan}
\toindex{cot}
\toindex{sec}
\toindex{csc}
\toindex{arcsin}
\toindex{arccos}
\toindex{arctan}
\toindex{sinh}
\toindex{cosh}
\toindex{tanh}
\toindex{coth}
\toindex{lim}
\toindex{sup}
\toindex{inf}
\toindex{limsup}
\toindex{liminf}
\toindex{log}
\toindex{ln}
\toindex{lg}
\toindex{exp}
\toindex{det}
\toindex{deg}
\toindex{dim}
\toindex{hom}
\toindex{ker}
\toindex{max}
\toindex{min}
\toindex{arg}
\toindex{gcd}
\toindex{Pr}
\exercise Typeset: $\sin(2\theta) = 2\sin\theta\cos\theta \quad
\cos(2\theta) = 2\cos^2\theta - 1 $.
\exercise Typeset: $$\int \csc^2x\, dx = -\cot x+ C
\qquad \lim_{\alpha\to 0} {\sin\alpha \over \alpha} = 1
\qquad \lim_{\alpha\to \infty} {\sin\alpha \over \alpha} = 0.$$
\exercise Typeset: $$\tan(2\theta) = {2\tan\theta \over
1-\tan^2\theta}.$$
\subsection{Hear ye, hear ye!}
There is a particular macro that is used in almost every
mathematical paper, and is different enough to require a special
explanation. This is the {\tt \\proclaim} macro. It is used when
stating theorems, corollaries, propositions, and the like. The
paragraph following {\tt \\proclaim} is broken into two parts:
the first part goes up to and including the first period that is
followed by a space, and the second part is the rest of the
paragraph. \TeXref{202--203}The idea is that the first part
should be something like ``Theorem 1.'' or ``Corollary B.'' The
second part is the statement of the theorem or corollary. Here
is an example:
\toindex{proclaim}
\beginliteral
\proclaim Theorem 1 (H.~G.~Wells). In the country of the blind,
the one-eyed man is king.
@endliteral
\noindent gives
\proclaim Theorem 1 (H.~G.~Wells). In the country of the blind,
the one-eyed man is king.
The statement of the theorem may contain mathematical expressions, of
course.
\vfill\eject
\exercise Typeset:
\nobreak
\proclaim Theorem (Euclid). There exist an infinite number of
primes.
\exercise Typeset:
\proclaim Proposition 1.
$\root n \of {\prod_{i=1}^n X_i} \leq {1 \over n} \sum_{i=1}^n X_i$
with equality if and only if $X_1=\cdots=X_n$.
\subsection{Matrices}
Matrices are typeset using combinations of the alignment
character {\tt \&} and the control word {\tt \\cr} to indicate
the end of the line. Start with {\tt \$\$\\pmatrix\lb$\dots$\rb\$\$}.
Into the space between the braces go the rows of the matrix, each
one ended by {\tt \\cr}. The entries are separated by the
{\tt \&}\null. For example the input
\TeXref{176--178}
\beginliteral
$$\pmatrix{
a & b & c & d \cr
b & a & c+d & c-d \cr
0 & 0 & a+b & a-b \cr
0 & 0 & ab & cd \cr
}.$$
@endliteral
\noindent
gives as printed output
$$\pmatrix{
a & b & c & d \cr
b & a & c+d & c-d \cr
0 & 0 & a+b & a-b \cr
0 & 0 & ab & cd \cr
}.$$
\toindex{pmatrix}
The matrix entries in our examples have all been \centred{}
within their columns with a little space on each side. They can
be made flush right or flush left by inserting {\tt \\hfill}
before or after the entry. Notice the differences between the
following example and the previous one.
\beginliteral
$$\pmatrix{
a & b & c \hfill & \hfill d \cr
b & a & c+d & c-d \cr
0 & 0 & a+b & a-b \cr
0 & 0 & ab \hfill & \hfill cd \cr
}.$$
@endliteral
\noindent
gives as printed output
$$\pmatrix{
a & b & c \hfill & \hfill d \cr
b & a & c+d & c-d \cr
0 & 0 & a+b & a-b \cr
0 & 0 & ab \hfill & \hfill cd \cr
}.$$
\vbox{
\exercise Typeset
$$ I_4 = \pmatrix{ 1 &0 &0 &0 \cr
0 &1 &0 &0 \cr
0 &0 &1 &0 \cr
0 &0 &0 &1 \cr}$$
}
It's possible to have matrices that use other delimiters. Using
{\tt \\matrix} instead of {\tt \\pmatrix} will leave off the
parentheses, so the delimiters must be explicitly included using
{\tt \\left} and {\tt \\right}. Here is how we can change the
matrix of our first example.
\toindex{matrix}
\toindex{left}
\toindex{right}
\beginliteral
$$ \left |
\matrix{
a & b & c & d \cr
b & a & c+d & c-d \cr
0 & 0 & a+b & a-b \cr
0 & 0 & ab & cd \cr
}
\right | $$
@endliteral
\noindent
gives as printed output
$$ \left |
\matrix{
a & b & c & d \cr
b & a & c+d & c-d \cr
0 & 0 & a+b & a-b \cr
0 & 0 & ab & cd \cr
}
\right | $$
It's even possible to use {\tt \\left.} and {\tt \\right.} to
indicate that the opening or closing delimiter is deleted (note
the use of the period).
\exercise Use a matrix construction to typeset
$$ |x| = \left\{ \matrix{ x & x \ge 0 \cr
-x & x \le 0 \cr} \right.$$
This exercise and more general constructions of this type
may also be typeset using the {\tt \\cases} macro.
\TeXref{175}
Sometimes ellipses are used within matrices. The control words
{\tt \\cdots}, {\tt \\vdots}, and {\tt \\ddots} can be used to
insert horizontal, vertical, and diagonal dots.
Thus we can use
\beginliteral
$$ \left [
\matrix{
aa & \cdots & az \cr
\vdots & \ddots & \vdots \cr
za & \cdots & zz \cr
}
\right ] $$
@endliteral
\noindent
to get as printed output
$$ \left [
\matrix{
aa & \cdots & az \cr
\vdots & \ddots & \vdots \cr
za & \cdots & zz \cr
}
\right ] $$
Matrices may also be typeset in-line, but they are pretty ugly
unless they have a small number of rows.
\subsection{Displayed equations}
All of the mathematics covered so far has identical input whether
it is to be typeset in-line or displayed. At this point we'll
look at some situations that apply to displayed equations only.
The first is that of aligning multiline displays. This is done with
the alignment character {\tt \&} and the control words {\tt \\cr} and
{\tt \\eqalign}. Starting with {\tt \$\$\\eqalign\lb$\dots$\rb\$\$},
the equations to be aligned are entered with each one terminated by
{\tt \\cr}. In each equation there should be one alignment symbol
{\tt \&} to indicate where the alignment should take place. This is
usually done at the equal signs, although it is not necessary to do
so. For example
\TeXref{190--192}
\toindex{eqalign}
\beginliteral
$$\eqalign{
a+b &= c+d \cr
x &= w + y + z \cr
m + n + o + p &= q \cr
}$$
@endliteral
\noindent
yields
$$\eqalign{
a+b &= c+d \cr
x &= w + y + z \cr
m + n + o + p &= q \cr
}$$
Displayed equations can be numbered at either the right or left
margin. When the control word {\tt \\eqno} appears in a displayed
equation, everything after the control word is put at the right
margin. Hence {\tt \$\$ x+y=z. \\eqno (1)\$\$} yields
$$ x+y=z. \eqno (1)$$
To number an equation at the left margin, use {\tt \\leqno}
in place of {\tt \\eqno}.
\toindex{eqno}
\toindex{leqno}
It's possible to number aligned equations by using the control
word {\tt \\eqalignno}. The alignment character {\tt \&} is
used to separate the equation from the equation number.
\beginliteral
$$\eqalignno{
a+b &= c+d & (1) \cr
x &= w + y + z \cr
m + n + o + p &= q & * \cr
}$$
@endliteral
\noindent
yields
$$\eqalignno{
a+b &= c+d & (1) \cr
x &= w + y + z \cr
m + n + o + p &= q & * \cr
}$$
Use {\tt \\leqalignno} to put the equation numbers on the left.
\TeXref{192--193}
\toindex{eqalignno}
\toindex{leqalignno}
Finally, suppose some text needs to appear in the middle of a
displayed equation. This can be done by putting it in an hbox.
We will describe hboxes in more detail in the next section.
For now we want to use them to temporarily resume using ordinary
roman type and to also allow the insertion of space between
words (remember that all spaces are ignored when typesetting
mathematics). Hence
{\tt \$\$X=Y \\hbox\lb{} if and only if \rb x=y.\$\$} will give
$$X=Y \hbox{ if and only if } x=y.$$
Note carefully the spaces in the hbox.
\exercise Do some of the challenge problems on pages 180--181 of The
\TeX book.
\section{All in a row}
It's not uncommon to want to put a table in the middle of some
text. Fortunately \TeX{} makes it easy to do this. In fact there
are two separate methods of aligning text. The first is by using
the tabbing environment. This is similar to setting the tab
stops on a typewriter. Each line is handled individually,
according to set tab columns, but with greater flexibility than
that provided by a typewriter. The second is the horizontal
alignment environment which typesets the whole table at once
using a prescribed pattern.
\subsection{Picking up the tab}
To align material using the tabbing environment, you must first
set the tab positions using the {\tt \\settabs} control word.
Having done this, a line to use these tabs starts with the
control symbol {\tt \\+ } and ends with {\tt \\cr } (remember
that the actual spacing on lines in the input file in
unimportant). \toindex{settabs}
The easiest way to use the {\tt \\settabs} control word is to put
the text into equal columns.
\TeXref{231}
Using {\tt \\settabs 4 \\columns} will set the tabs that will
produce four equal columns. The tabbing is then done by using
the alignment character {\tt \&} to move to the next tab stop.
So, for example, \toindex{columns}
\beginliteral
\settabs 4 \columns
\+ British Columbia & Alberta & Saskatchewan & Manitoba \cr
\+ Ontario & Quebec & New Brunswick & Nova Scotia \cr
\+ & Prince Edward Island & Newfoundland \cr
@endliteral
\noindent
will produce the table
\vskip\baselineskip
\settabs 4 \columns
\+ British Columbia & Alberta & Saskatchewan & Manitoba \cr
\+ Ontario & Quebec & New Brunswick & Nova Scotia \cr
\+ & Prince Edward Island & Newfoundland \cr
Notice that it is possible to skip over some tab positions, and
it is not necessary to use all of the tabs in a given line. To
make the same table using five columns, it is only necessary to
use {\tt \\settabs 5 \\columns} to reset the tab stops; then the
same three lines from the last example will produce:
\vskip\baselineskip
\settabs 5 \columns
\+ British Columbia & Alberta & Saskatchewan & Manitoba \cr
\+ Ontario & Quebec & New Brunswick & Nova Scotia \cr
\+ & Prince Edward Island & Newfoundland \cr
In this example, the columns are smaller, of course. In fact
there are two overlapping entries in the last row. This is
because \TeX{} will tab to the next tab position even if (unlike
a typewriter) it means going backward on the page.
There is an interesting relationship between grouping and
tabbing. The {\tt \\settabs} values are only applicable to the
group in which it is defined, as would be expected. Thus it is
possible to temporarily change the tab settings by grouping
within braces. In addition, each table entry is in a group of
its own. Hence we may make a single entry boldface, for example,
by using {\tt \\bf} without braces. In addition, for any column
but the last one it is possible to \centre{} the entry or to
align it either on the left or on the right, or to fill a column
with a line or dots. Each entry has an implicit {\tt \\hfil} at
the end so that it will be at the left of the column by default.
Adding {\tt \\hfil} at the beginning of the entry will then cause
it to be \centred{}, just as with the {\tt \\line} control word.
Adding {\tt \\hfill} to the beginning will cause the entries to
be pushed to the right ({\tt \\hfill} acts just like {\tt \\hfil}
in that it absorbs excess space; when both {\tt \\hfil} and {\tt
\\hfill} appear, the {\tt \\hfill} takes precedence).
\toindex{hfill}
\beginliteral
\settabs 4 \columns
\+ \hfil British Columbia & \hfill Alberta \qquad & \bf Saskatchewan
@hskip 2.5in & Manitoba \cr
\+ \hfil Ontario & \hfill Quebec \qquad & \bf New Brunswick
@hskip 2.5in & Nova Scotia \cr
\+ \hfil --- & \hfill * \qquad & \bf Newfoundland
@hskip 2.5in & Prince Edward Island \cr
\+ \dotfill && \hrulefill & \cr
@endliteral
\noindent
will produce a table with the first column \centred{}, the second
column flush right with a {\tt \\qquad} of padding, and the third
column boldface. The control words {\tt \\dotfill} and {\tt \\hrulefill}
give alternative column entries.
\toindex{dotfill}
\toindex{hrulefill}
\vskip\baselineskip
\settabs 4 \columns
\+ \hfil British Columbia & \hfill Alberta \qquad & \bf Saskatchewan
& Manitoba \cr
\+ \hfil Ontario & \hfill Quebec \qquad & \bf New Brunswick
& Nova Scotia \cr
\+ \hfil --- & \hfill * \qquad & \bf Newfoundland &
Prince Edward Island \cr
\+ \dotfill && \hrulefill & \cr
\exercise Take the table of Canadian provinces above and \centre{} each
entry within its column.
The tab positions can be set with much more flexibility than just
in equal columns. The general pattern is to use a sample line of
the form {\tt \\settabs \\+ $\ldots$ \& $\ldots$ \& $\ldots$ \\cr}.
The spacing between the alignment characters {\tt \&}
determines the position of the tabs. For example, {\tt \\settabs
\\+ \\hskip 1 in \& \\hskip 2 in \& \\hskip 1.5 in \& \\cr} would
set the first tab one inch from the left margin, the next another
two inches further in, and the third 1.5 inches more. It's also
possible to use text to determine the distance between tabs. So,
for example, another possible sample line is
{\tt \\settabs \\+ \\quad Province \\quad \& \\quad Population \\quad
\& \\quad Area \\quad \& \\cr}.
The tab column would then be just wide enough to accept the headings
with a quad of space on each side. Here's a more complete example:
\beginuser \obeyspaces
\\settabs \\+ \\quad Year \\quad \& \\quad Price \\quad
\& \\quad Dividend \& \\cr
\\+ \\hfill Year \\quad \& \\quad Price \\quad \& \\quad Dividend \\cr
\\+ \\hfill 1971 \\quad \& \\quad 41--54 \\quad \& \\qquad \\\$2.60 \\cr
\\+ \\hfill 2 \\quad \& \\quad 41--54 \\quad \& \\qquad \\\$2.70 \\cr
\\+ \\hfill 3 \\quad \& \\quad 46--55 \\quad \& \\qquad \\\$2.87 \\cr
\\+ \\hfill 4 \\quad \& \\quad 40--53 \\quad \& \\qquad \\\$3.24 \\cr
\\+ \\hfill 5 \\quad \& \\quad 45--52 \\quad \& \\qquad \\\$3.40 \\cr
\enduser
\noindent
gives \TeXref{247}
\vskip\baselineskip
\settabs \+ \quad Year \quad & \quad Price \quad & \quad
Dividend \quad & \cr
\+ \hfill Year \quad & \quad Price \quad & \quad Dividend \cr
\+ \hfill 1971 \quad & \quad 41--54 \quad & \qquad \$2.60 \cr
\+ \hfill 2 \quad & \quad 41--54 \quad & \qquad \$2.70 \cr
\+ \hfill 3 \quad & \quad 46--55 \quad & \qquad \$2.87 \cr
\+ \hfill 4 \quad & \quad 40--53 \quad & \qquad \$3.24 \cr
\+ \hfill 5 \quad & \quad 45--52 \quad & \qquad \$3.40 \cr
\exercise Take the table given above and move it closer to the
\centre{} of the page.
\exercise One way to \centre{} a block of text, possibly several
lines long, is to use: {\tt \$\$\\vbox\lb$\ldots$\rb\$\$}. Use
this to \centre{} the table given above. Does the
{\tt \\settabs} line need to be included in the {\tt \\vbox}?
\exercise Improve your last result by putting a line under the
column heads. The control word {\tt \\hrule} will insert a
horizontal line if introduced between two rows of a table. Now
repeat with the control word {\tt \\strut} after the {\tt \\+ }
of the line containing the column heads. (A {\tt \\strut}
effectively makes the spacing between lines a little greater. The
size can be altered from the default.)\TeXref{82} Note the extra
space that results.
\toindex{strut}
\exercise Make the following table with decimal alignment, that
is, with the decimal points above each other (think of the dollar
figure as being right aligned and the cents figure as being left
aligned against the decimal point):
\medskip
\settabs \+ \hskip 2 in & \hskip .75in & \hskip 1cm& \cr
\+ &Plums &\hfill\$1&.22 \cr
\+ &Coffee &\hfill1&.78 \cr
\+ &Granola &\hfill1&.98 \cr
\+ &Mushrooms & &.63 \cr
\+ &{Kiwi fruit} & &.39 \cr
\+ &{Orange juice} &\hfill1&.09 \cr
\+ &Tuna &\hfill1&.29 \cr
\+ &Zucchini & &.64 \cr
\+ &Grapes &\hfill1&.69 \cr
\+ &{Smoked beef} & &.75 \cr
\+ &Broccoli &\hfill\underbar{\ \ 1}&\underbar{.09} \cr
\+ &Total &\hfill \$12&.55 \cr
\exercise Devise a method to make a rough table of contents by using
{\tt \\settabs} and having entries looking something like:\hfil\break
\leftline{\tt Getting Started \\dotfill \& \\hfill 1}
\leftline{\tt All Characters Great and Small \\dotfill \& \\hfill 9.}
\subsection{Horizontal alignment with more sophisticated patterns}
The {\tt \\settabs} environment is not difficult to use, and once
the pattern is set, it can be used repeatedly in different
portions of the text that follows. It does have some drawbacks,
however. For one, the column size must be set before the entries
are known. Also, even though in one case we wanted the third
column to be boldface, it had to be specified in each line.
These problems can be handled more easily by using the {\tt
\\halign} environment.
\TeXref{235--238}
\toindex{halign}
The general pattern in the {\tt \\halign} is as follows:
\beginuser
\\halign\lb{} <template line> \\cr
<first display line> \\cr
<second display line> \\cr
$\vdots$
<last display line> \\cr
\rb
\enduser
Both the template line and the display lines are divided into
sections by the alignment symbol {\tt \&}\null. In the template
line each section uses control words in the same manner as does
{\tt \\line\lb\rb}\null. The control word {\tt \\hfil}, for
example, can be used to display flush left, flush right, or \centred.
Fonts can be changed using {\tt \\bf}, {\tt \\it}, etc.
Text may also be entered in the template line. In addition the
special symbol {\tt \#} must appear once in each section. Each
display line is then set by substituting each section of the
display line into its corresponding section of the template line
at the occurrence of the {\tt \#}\null.
Consider the following example:
\beginuser
\\halign\lb\\hskip 2 in \$\#\$\& \\hfil \\quad \# \\hfil \& \\qquad \$\#\$
\hskip 3in \& \\hfil \\quad \# \\hfil \\cr
\\alpha \& alpha \& \\beta \& beta \\cr
\\gamma \& gamma \& \\delta \& delta \\cr
\\epsilon \& epsilon \& \\zeta \& zeta \\cr
\rb
\enduser
\noindent The template line indicates that the first section of
the typeset text will always be set two inches in from the left
and also be set as mathematics. The second section will be \centred{}
after adding a quad of space on the left. The third
and fourth sections are handled similarly. Here is the result:
\vskip\baselineskip
\halign{\hskip 2in $#$& \hfil\quad # \hfil & \qquad $#$
& \hfil\quad # \hfil\cr
\alpha & alpha & \beta & beta \cr
\gamma & gamma & \delta & delta \cr
\epsilon & epsilon & \zeta & zeta \cr
}
In this case the first display line is formed by substituting {\tt
\\alpha} for the first {\tt \#} in the template line, {\tt alpha} for
the second {\tt \#}, {\tt \\beta} for the third and {\tt beta} for
the fourth. The whole line is then saved for setting. This
continues until all the lines are accumulated, and then they are set
with each column being as wide as necessary to accept all of its
entries (an implication of this accumulation process is that a table
with too many entries could cause \TeX{} to run out of memory; it's
better not to set tables that are more than a page or so long).
Hence the template line establishes the pattern for the table entries
and the display lines insert the individual entries.
Sometimes horizontal and vertical lines are used to delimit
entries in a table. To put in horizontal lines, we use {\tt \\hrule},
just as we did in the {\tt \\settabs} environment.
However, we don't want the rule to be aligned according to the
template, so we use the control word {\tt \\noalign}. Hence
horizontal lines are inserted by putting {\tt \\noalign\lb\\hrule\rb};
vertical lines are inserted by putting {\tt \\vrule}
in either the template or the display line. But still all is not
completely straightforward. Suppose we take our last example and
change the template to get vertical lines and also insert
horizontal lines.
\toindex{noalign}
\beginuser
\\halign\lb\\hskip 2in\\vrule\\quad \$\#\$\\quad \& \\vrule \\hfil\\quad %
\# \\hfil
\hskip 2 in \& \\quad \\vrule \\quad \$\#\$\\quad
\hskip 2 in \& \\vrule\\hfil \\quad \# \\quad \\hfil \\vrule \\cr
\\noalign\lb\\hrule\rb
\\alpha \& alpha \& \\beta \& beta \\cr
\\noalign\lb\\hrule\rb
\\gamma \& gamma \& \\delta \& delta \\cr
\\noalign\lb\\hrule\rb
\\epsilon \& epsilon \& \\zeta \& zeta \\cr
\\noalign\lb\\hrule\rb
\rb
\enduser
\noindent
doesn't give exactly what we want.
\vskip\baselineskip
\halign{\hskip 2in\vrule\quad $#$\quad & \vrule \hfil\quad # \hfil
& \quad \vrule \quad $#$\quad & \vrule \hfil\quad # \quad \hfil
\vrule \cr
\noalign{\hrule}
\alpha & alpha & \beta & beta \cr
\noalign{\hrule}
\gamma & gamma & \delta & delta \cr
\noalign{\hrule}
\epsilon & epsilon & \zeta & zeta \cr
\noalign{\hrule}
}
There are several deficiencies: the most obvious is the extended
horizontal lines, but also the text looks somewhat squashed into
the boxes. In addition, the text has a little extra space on the
right rather than being perfectly \centred. As in the {\tt \\settabs}
environment, lines can be made taller by including the control
word {\tt \\strut} in the template.\TeXref{82} A further problem
can occur when the page is set since \TeX{} may spread lines
apart slightly to improve the appearance of the page. This would
leave a gap between the vertical lines, so we use the control
word {\tt \\offinterlineskip} within the {\tt \\halign} to avoid
this. Finally we can get rid of the lines sticking out on the
left by deleting the {\tt \\hskip 2 in} from the template line.
To move the table to the same position we use {\tt \\moveright}.
Finally, we can see how to \centre{} the text by noting that the
extra space occurs in the template line after the {\tt \#} where
the text is inserted.
Hence we can improve our result by using
\toindex{offinterlineskip}
\toindex{moveright}
\beginuser
\\moveright 2 in
\\vbox\lb\\offinterlineskip
\\halign\lb\\strut \\vrule \\quad \$\#\$\\quad \&\\vrule \\hfil \\quad %
\#\\quad \\hfil
\&\\vrule \\quad \$\#\$\\quad \&\\vrule \\hfil \\quad \#\\quad \\hfil %
\\vrule \\cr
\\noalign\lb\\hrule\rb
\\alpha \& alpha \& \\beta \& beta \\cr
\\noalign\lb\\hrule\rb
\\gamma \& gamma \& \\delta \& delta \\cr
\\noalign\lb\\hrule\rb
\\epsilon \& epsilon \& \\zeta \& zeta \\cr
\\noalign\lb\\hrule\rb
\rb\rb
\enduser
\noindent
to get
\vskip\baselineskip
\moveright 2 in
\vbox{\offinterlineskip
\halign{\strut \vrule \quad $#$\quad &\vrule \hfil \quad #\quad \hfil
&\vrule \quad $#$\quad &\vrule \hfil \quad #\quad \hfil
\vrule \cr
\noalign{\hrule}
\alpha & alpha & \beta & beta \cr
\noalign{\hrule}
\gamma & gamma & \delta & delta \cr
\noalign{\hrule}
\epsilon & epsilon & \zeta & zeta \cr
\noalign{\hrule}
}
}
In general, if we want to construct a table with boxed entries
that is \centred{} on the page, we can do so by putting the {\tt
\\vbox} within a {\tt \\centerline\lb\rb}\null. But here is a
trick that will produce a nicer result. If the {\tt \\vbox} is
put in between double dollar signs, it will be typeset as
displayed mathematics. Of course, there is no actual
mathematics being displayed, but \TeX{} will put in a little
extra space above and below the table as is appropriate for a
display. Hence a \centred{} table with this nice spacing may be
formed using the following four steps:
(1) put a {\tt \\vbox} between double dollar signs,
(2) put an {\tt \\offinterlineskip} and an {\tt \\halign} within
the {\tt \\vbox},
(3) in the {\tt \\halign} put a template line with a {\tt \\strut}
in the beginning, and a {\tt \\vrule} surrounding each entry,
(4) each row of the table should be preceded and followed by
{\tt \\noalign\lb\\hrule\rb}.
Here is the pattern to be followed:
\beginuser
\$\$\\vbox\lb
\\offinterlineskip
\\halign\lb
\\strut \\vrule \# \& \\vrule \# \& \dots \& \\vrule \# \\vrule \\cr
\\noalign\lb\\hrule\rb
<first column entry> \& <second column entry> \& \dots %
\& <last column entry> \\cr
\\noalign\lb\\hrule\rb
\dots
\\noalign\lb\\hrule\rb
<first column entry> \& <second column entry> \& \dots %
\& <last column entry> \\cr
\\noalign\lb\\hrule\rb
\rb
\rb\$\$
\enduser
\section{Rolling your own}
In this section we'll create new control words. The making of
these new definitions, also called macros, is one of the most
powerful techniques available in \TeX\null. For the first
application of this facility, we'll see how a new definition can
save a lot of typing by substituting short strings for long ones.
\subsection{The long and short of it}
The control word {\tt \\def} is used to define new control words.
The simplest form for doing this is {\tt \\def\\newname\lb$\ldots$\rb}.
Then whenever {\tt \\newname} appears in your
input file, it will be replaced by whatever is between the braces
in the definition. Of course {\tt \\newname} must satisfy the
convention for naming control sequences, that is, it must be a
control word (all letters) or a control symbol (exactly one
nonletter). So, for example, suppose you write a document that
contains the phrase ``University of Manitoba'' many times. Then
{\tt \\def\\um\lb University of Manitoba\rb} defines a new
control sequence {\tt \\um} which can then be used at any time.
The sentence {\tt I take courses at the \\um.}\ then makes
sense. If the control word exists, your new definition will
replace it (this includes the control words defined by \TeX{}, so
a little care must be taken in the choice of name). Any
definition is, however, local to the group in which it is
defined. For example, \toindex{def}
\beginuser
\\def\\um\lb University of Manitoba\rb
I took my first course at the \\um.
\lb
\\def\\um\lb Universit\\'e de Montr\\'eal\rb
Then I took my next course at the \\um.
\rb
Finally I took my last course at the \\um.
\enduser
\noindent gives \medskip
\def\um{University of Manitoba}
I took my first course at the \um.
{
\def\um{Universit\'e de Montr\'eal}
Then I took my next course at the \um.
}
Finally I took my last course at the \um.
Remember that all spaces after a control word are absorbed; this
includes the control words that you define. In the previous
example, any space after {\tt \\um} would be ignored. However,
the space after the first period and the space after the first
opening brace are different; if you look closely at the end of
the first sentence typeset using the example, you'll see some
extra space. This can be eliminated by putting a {\tt \%} after
the opening brace to make the rest of the line a comment. The
same holds for the line with the last closing brace. Careful
control of spaces often calls for the ``commenting out'' of the
end of lines in this manner.
Once a new control sequence has been defined, it may be used in
new definitions. This is one way of making simple form letters.
First let's define a simple letter.
\beginuser
\\def\\letter\lb
\\par \\noindent
Dear \\name,
\
This is a little note to let you know that your name is \\name.
\
\\hskip 2 in Sincerely yours,
\\vskip 2\\baselineskip
\\hskip 2 in The NameNoter
\\smallskip \\hrule
\rb
\enduser
\def\letter{
\par \noindent
Dear \name,
This is a little note to let you know that your name is \name.
\hskip 2 in Sincerely yours,
\vskip 2\baselineskip\nobreak
\hskip 2 in The NameNoter
\smallskip \hrule
}
Now this letter uses the control word {\tt \\name}, which is
undefined at this point. When {\tt \\letter} is used, the
current value of {\tt \\name} will appear in the body of the
letter. Hence
\beginuser
\\def\\name\lb Michael Bishop\rb
\\letter
\\def\\name\lb Michelle L\\'ev\\\^{}eque\rb
\\letter
\enduser
\noindent will produce two copies of the letter, each with the
correct name, followed by a horizontal rule:
\def\name{Michael Bishop}
\letter
\goodbreak
\def\name{Michelle L\'ev\^eque}
\letter
We could have put anything between the braces in
{\tt \\def\\name\lb$\ldots$\rb}; it could be several paragraphs
long and use other control sequences (although in this context it
would be a little strange). Of course it is possible to use {\tt
\\vfill \\eject} as part of the definition of {\tt \\letter} to
eject the page when the letter is completed.
\exercise Make a form letter that uses the control words {\tt \\name},
{\tt \\address}, {\tt \\city}, {\tt \\\province}, and {\tt
\\\postcode}.
\exercise An unnumbered list of items is often made
using {\tt \\item\lb\$\\bullet\$\rb}. Define a macro {\tt \\bitem}
that does this, and use it for several paragraphs. Now change
each bullet to a dash (note that a simple change in the macro
propagates all the necessary changes in all of the paragraphs).
\exercise Suppose that you are going to have to format several
paragraphs in a paper using {\tt \\hangindent = 30 pt}, {\tt \\hangafter
= 4}, and {\tt \\filbreak} (don't worry about what
these control sequences actually do; the only important thing
for now is that once they are set, they remain in effect for only
one paragraph). Define a single control sequence {\tt \\setpar}
which can then be put in front of each paragraph that needs to be
so formatted.
\subsection{Filling in with parameters}
It's possible to use macros in much greater generality by
allowing parameters to be passed. The idea is somewhat similar
to the template line in the {\tt \\halign} environment. First,
let's look at the case where there is one parameter. In this
case a control sequence is defined by {\tt \\def\\newword\#1\lb
$\ldots$\rb}\null. The symbol {\tt \#1} may appear between the
braces (several times) in the definition of {\tt \\newword}. The
material between the braces acts like a template. When {\tt
\\newword\lb$\ldots$\rb} appears in the text, it will use the
definition of {\tt \\newword} with the material between the
braces inserted into the template at every occurrence of {\tt
\#1} in the original definition. {\bf The spacing in the original
definition is crucial here; there must be no spaces before the
opening brace}.
As an example, we could use the form letter of the last section in
the following way:
\beginuser
\\def\\letter\#1\lb
\\par \\noindent
Dear \#1,
\vskip\baselineskip
This is a little note to let you know that your name is \#1.
\vskip\baselineskip
\\hskip 2 in Sincerely yours,
\\vskip 2\\baselineskip
\\hskip 2 in The NameNoter
\\smallskip \\hrule
\rb
\enduser
\def\letter#1{
\par \noindent
Dear #1,
This is a little note to let you know that your name is #1.
\hskip 2 in Sincerely yours,
\vskip 2\baselineskip
\hskip 2 in The NameNoter
\smallskip \hrule
}
Now we can use
\beginuser
\\letter\lb Michael Bishop\rb
\\letter\lb Michelle L\\'ev\\\^{}eque\rb
\enduser
\noindent to get \medskip
\letter{Michael Bishop}
\goodbreak
\letter{Michelle L\'ev\^eque}
\def\displaytext#1{$$\vbox{\hsize=12cm #1}$$}
\bigskip
\displaytext{
Now let's define
{\tt\\def\\displaytext\#1\lb \$\$\\vbox\lb\\hsize = 12 cm \#1\rb\$\$\rb}
as a new macro to display text.
Then {\tt \\displaytext\lb$\ldots$\rb} will cause the material
between the braces to be put in a paragraph with width 12 \centimetre
s and then \centred{} with some space added above and
below as is appropriate for a display. This paragraph was set
using this {\tt \\displaytext} macro.
}
The parameter of a macro can be no more than one paragraph long.
If a new paragraph is encountered as part of a parameter, an
error will be generated. This is a safety feature, for
otherwise the accidental omission of a closing brace would cause
\TeX{} to eat up the rest of the file as the parameter.
\exercise Define a macro {\tt \\yourgrade} so that {\tt
\\yourgrade\lb89\rb} will cause the following sentence to be
typeset: The grade you received is 89\%\null. It should be able
to work with any other percentage, of course.
\medbreak
It's not really any harder to use more than one parameter. The form
used to define a new control word with two parameters is
{\tt \\def\\newword\#1\#2\lb$\ldots$\rb}. The definition between the
braces may have {\tt \#1} and {\tt \#2} occurring in it, perhaps
several times. When {\tt \\newword\lb$\ldots$\rb\lb$\ldots$\rb}
appears in the text, the material between the first set of braces
replaces {\tt \#1} in the definition and the material between the
second set of braces replaces {\tt \#2} in the definition. Here is
an example followed by its result:
\beginuser
\\def\\talks\#1\#2\lb \#1 talks to \#2.\rb
\\talks\lb John\rb\lb Jane\rb
\\talks\lb Jane\rb\lb John\rb
\\talks\lb John\rb\lb me\rb
\\talks\lb She\rb\lb Jane\rb
\enduser
\def\talks#1#2{#1 talks to #2.}
\talks{John}{Jane}
\talks{Jane}{John}
\talks{John}{me}
\talks{She}{Jane}
\exercise In a manner similar to the previous exercise, define a
macro {\tt \\yourgrade} so that {\tt \\yourgrade\lb89\rb\lb85\rb}
causes the following sentence to be typeset: You received a grade
of 89\% on your first exam and a grade of 85\% on your second
exam.
\exercise Write a macro {\tt \\frac} so that {\tt \\frac\lb
a\rb\lb b\rb} will typeset the fraction ${a\over b}$.
\bigskip
It's important not to put any spaces before the first brace in
the definition. If you do, \TeX{} will interpret the definition
differently from the way described here. For more than two
parameters, the method of definition is similar. To define a
control word with three parameters, start with
{\tt \\def\\newword\#1\#2\#3\lb$\ldots$\rb}. Then {\tt \#1},
{\tt \#2} and {\tt \#3} may occur between the braces. When
{\tt \\newword\lb$\ldots$\rb\lb$\ldots$\rb\lb$\ldots$\rb}
appears in the text, the material between each set of braces
replaces its corresponding symbol in the definition of the
control word. The parameters may go up to {\tt \#9}.
\subsection{By any other name}
Sometimes it's convenient to be able to give a control word an
alternative name. For example, if you prefer a different spelling,
you might want to call the control word {\tt \\centerline} by the
name of {\tt \\centreline}. This can be done by using the {\tt
\\let} control word. The use of {\tt \\let \\centreline =
\\centerline} now makes a new (as well as the old) control word
available. This can also be used with mathematical names as with
{\tt \\let \\tensor = \\otimes}. It is then possible to use
\TeXref{206--207}
\toindex{let}
\toindex{centreline}
\toindex{tensor}
\let\tensor=\otimes
\beginuser
\$\$ (A \\tensor B) (C \\tensor D) = AC \\tensor BD. \$\$
\enduser
\noindent to get
$$ (A \tensor B) (C \tensor D) = AC \tensor BD. $$
\exercise Define control sequences {\tt \\ll}, {\tt \\cl}, and
{\tt \\rl} that are equivalent to {\tt \\leftline}, {\tt \\centerline},
and {\tt \\rightline}.
The {\tt \\let} control word allows users to name their own
control sequences. This allows a personalized set of control
sequences that may be used in place of the ones provided by \TeX{}
when desired.
\section{To err is human}
In some ways \TeX{} is not completely divine. \TeX{} will respond
to invalid input by giving an error message to the screen if you
are using it interactively and also to the log file. Because
\TeX{} is very complicated, the actual point where the error is
detected may be deep within the program, so a full report of the
error may be rather long and involved. Not only that, \TeX{}
will try to recover from errors, and will report what was done in
that process. For this reason the reading of error messages may
be a little difficult for the uninitiated. The key is to know
what is important from your perspective and what can be safely
ignored. So let's look at some typical errors and the messages
that they generate.
\subsection{The forgotten bye}
The first mistake that we'll look at is one that everyone makes
at some time, namely, the omission of {\tt \\bye} at the end of
the file. If you're using \TeX{} interactively, an asterisk \hfil
\break
\leftline{\tt *}
will be printed on the screen and nothing will happen since,
having not been told to finish up, \TeX{} is waiting for input
(from your keyboard). Whatever you type in will be appended to
whatever has been input from your files. The usual response is
to type {\tt \\bye<CR>}\fnote{{\tt <CR>} is the key
used to end a line of input. It might be called the carriage
return, enter, or simply the return key on your terminal.
Sometimes it is indicated by a large left arrow.} since that will
finish things up.
\subsection{The misspelled or unknown control sequence}
Using a misspelled or other control sequence unknown to \TeX{} is
a common error. If \TeX{} is being run as a batch job, an error
message is printed and the job goes on ignoring the control
sequence. When using \TeX{} interactively, it is possible to
repair errors (of course this does not change the original input
file, so that must be done when the \TeX{} job is completed).
Suppose we have a \TeX{} input file consisting of the following
two lines:
\beginuser
\\line\lb The left side \\hfli the right side\rb
\\bye
\enduser
The control word should be {\tt \\hfil}, of course. Here is the
message that would be sent to your terminal:
\beginuser
\obeyspaces
! Undefined control sequence.
l.1 \\line\lb The left side \\hfli
\ the right side\rb
?
\enduser
The first line starts with {\tt !} and gives the error message.
Next comes the line number on which the error occurred and the
part of the line that was read successfully. The next line gives
the continuation of the line after the error. At this point the
question mark means that \TeX{} is waiting for a response. There
are several legal ones:
\nobreak
\maketable [Responses to \TeX{} error messages]
\halign{
\strut \hfil # \hfil & \quad \hfil \tt # \hfil & # \hfil\cr
\bf Desired response & \bf Input to \TeX{} & \bf \hfil Result\cr
\noalign{\hrule} \noalign{\smallskip}
Help & h<CR>& Reason for stopping listed on terminal.\cr
Insert & i<CR>& Next line inserted into \TeX{} input file.\cr
Exit & x<CR>& Exit from \TeX\null. Completed pages to DVI file.\cr
Scroll & s<CR>& List message and continue after minor errors.\cr
Run & r<CR>& List message and continue after any errors.\cr
Quiet & q<CR>& All terminal listings suppressed.\cr
Carry on &<CR> & \TeX{} continues as best it can.\cr
}
In our last example a reasonable response might be to enter {\tt
h<CR>} to get a help message, then {\tt i<CR>} to insert more
text, (at which point \TeX{} responds with {\tt insert> } and
finally {\tt \\hfil} as the correct control word. Here is the
result:
\beginuser
? h <CR>
The control sequence at the end of the top line
of your error message was never \\def'ed. If you have
misspelled it (e.g., `\\hobx'), type `I' and the correct
spelling (e.g., `I\\hbox'). Otherwise just continue,
and I'll forget about whatever was undefined.
? i <CR>
insert>\\hfil
[1]
\enduser
The final {\tt [1]} means that the first (and only) page has
been completed and sent to the DVI file. The original input file
still needs to be fixed, of course.
\subsection{The misnamed font}
A misspelled font name is an error similar to the misspelled
control sequence. The error message is different and a little
confusing at first. Suppose for example the following appears in
your input file:
\leftline{\tt \\font\\sf = cmss01}
It should be {\tt cmss10}, that is, the numbers have been
transposed. Here are the error and help messages:
\beginuser \obeyspaces
! Font \\sf=cmss01 not loadable: Metric (TFM) file not found.
<to be read again>
\ \\par
\\bye ->\\par
\ \\vfill \\supereject \\end
l.2 \\bye
? h <CR>
I wasn't able to read the size data for this font,
so I will ignore the font specification.
[Wizards can fix TFM files using TFtoPL/PLtoTF.]
You might try inserting a different font spec;
e.g., type `I\\font<same font id>=<substitute font name>'.
\enduser
The TFM (\TeX{} font metric) file is an auxiliary file that is
used by \TeX\null. So this strange message is just telling you
that the font you defined doesn't exist on your computer system.
\subsection{Mismatched mathematics}
Another common error is to use {\tt \$} or {\tt \$\$} to start a
mathematical expression and then to forget the second {\tt \$}
or {\tt \$\$} when finished. The text that follows is then
treated as mathematics, and to make matters worse, if more
mathematics is started by a new {\tt \$} or {\tt \$\$}, it will
then be treated as ordinary text. Needless to say, error
messages galore may be generated. \TeX{} will attempt to correct
the problem by inserting a new {\tt \$} or {\tt \$\$}; in any
case, the problem is corrected by the end of the paragraph since
a new paragraph will automatically start as ordinary text.
Consider the following correct input and its output:
\beginuser
Since \$f(x) > 0\$, \$a<b\$, and \$f(x)\$ is continuous, we know that
\$\\int\_{}a\^{}b f(x)\\,dx >0\$.
\enduser
Since $f(x) > 0$, $a<b$, and $f(x)$ is continuous, we know that
$\int_a^b f(x)\,dx >0$.
If we now leave out the second dollar sign in {\tt \$f(x)\$} we
then get the following error and help messages:
\beginuser \obeyspaces
! Missing \$ inserted.
<inserted text>
\ \$
<to be read again>
\ \\intop
\\int ->\\intop
\ \\nolimits
l.2 \$\\int
\ \_{}a\^{}b f(x)\\,dx >0\$.
? h <CR>
I've inserted a begin-math/end-math symbol since I think
you left one out. Proceed, with fingers crossed.
?
\enduser
The line starting with {\tt !} tells us what has been done. The
line starting with {\tt l.2} shows us where we were in the input
file when the error occurred. As in our other examples, the part
of the line successfully read, that is, through {\tt \\int},
appears on one line, and the continuation appears on the next
line. The remaining material may seem somewhat obscure. These
intermediate messages show what was happening further in the guts
of the \TeX{} program when the error occurred. The newer user
may ignore them.
Here is what you get as output after \TeX{} tries to recover from
the error.
Since $f(x) > 0$, $a<b$, and $f(x) is continuous, we know that
\int_a^b f(x)\,dx >0$.
There is a stretch of text that is italic with no spacing. This
is typical for normal text being processed as mathematics; if you
see this in your output, you have almost certainly left out a
{\tt \$} or {\tt \$\$}.
\subsection{Mismatched braces}
It's easy to forget or mismatch the closing braces when making
groups. The result may be a relatively benign error, or it may
be catastrophic. Suppose, for example, you have {\tt \lb\\bf A
bold title } in your text with the closing right brace omitted.
The result will be the same as if no opening brace were there;
that is, the rest of the paper will be boldface if no other font
changes are made. You will get the following message at the end
of the file:
{\tt (\\end occurred inside a group at level 1)}
If you had made the same mistake twice, then there would be two
more opening braces than closing braces, and you would get the
message:
{\tt (\\end occurred inside a group at level 2)}
\TeX{} doesn't know that the closing brace is missing until it
reaches the end of the input file. Hence the message doesn't
tell you where you went wrong. If the location of the missing
brace isn't obvious, it's always possible to insert {\tt \\bye}
halfway through your document. Running \TeX{} again will cause
only the first half to be processed, and if the error message
persists, you will know that the error is in the first half of
the document. By moving the {\tt \\bye} to different places, the
error can be localized. Also, looking at the output often
reveals what has gone wrong.
Missing opening braces are much easier to spot. Here is a two
line input file and the resulting error and help messages:
\beginuser
\\bf Here is the start\rb, but there is the finish.
\\bye
\enduser
\beginuser \obeyspaces
! Too many \rb's.
l.1 \\bf Here is the start\rb
\ , but there is the finish.
? h <CR>
You've closed more groups than you opened.
Such booboos are generally harmless, so keep going.
\enduser
It's quite possible, of course, that the line that is supposed to
have the missing left brace will not be on the line where \TeX{}
catches the error.
A mismatched brace in the definition of a new control sequence
can cause a major error. Since such a definition may include
several paragraphs, it may not be caught by the end of a
paragraph, but, rather will just keep piling more and more text
into the unfinished definition. It's even possible for \TeX{} to
run out of memory as it keeps eating up more text! This is called
a ``runaway definition''.
\TeXref{206}
Here is a two line input file with a runaway definition:
\vbox{
\beginuser
\\def\\newword\lb the def
\\newword
\\bye
\enduser
}
Here are the resulting error and help messages:
\beginuser \obeyspaces
Runaway definition?
->the def
! Forbidden control sequence found while scanning definition of \\newword.
<inserted text>
\ \rb
<to be read again>
\ \\bye
l.3 \\bye
? h <CR>
I suspect you have forgotten a `\rb', causing me
to read past where you wanted me to stop.
I'll try to recover; but if the error is serious,
you'd better type `E' or `X' now and fix your file.
? <CR>
No pages of output.
\enduser
This is obviously a serious error. If it occurs at the beginning
of a file (as in the previous example), there will be no output
at all!
If a closing brace is left out while using a macro with
parameters, the runaway definition will be terminated at the end
of the paragraph. So if {\tt \\def\\newword\#1\lb$\ldots$\rb} has
been defined and you use {\tt \\newword\lb$\dots$ } without the
closing brace, then at most one paragraph will be ruined.
\TeXref{205}
In short, when an error occurs, make a note of the line number to
see how much of the input file has been read, and also the line
starting with an exclamation point to get a short description of
the error. If the error is still not clear, ask \TeX{} for more
information by typing {\tt h<CR>}. For small errors, \TeX{} can
carry on quite a way if you just keep hitting the {\tt <CR>}.
\section{Digging a little deeper}
In this section we look at a few topics that allow \TeX{} to be
used with greater flexibility or efficiency. As the documents
being produced get longer, different techniques can help make
their creation easier.
\subsection{Big files, little files}
\TeX{} can read and write files as it runs. This makes it
possible to use files that are smaller and more convenient to
handle by creating a master file that reads the smaller files in
the proper order. This document, for example, consists of ten
sections plus an introduction. In addition, there are macros
that are used for all sections. The macros can be put in a file
called, say, {\tt macros.tex}, the introduction can be put in {\tt
intro.tex}, and each section put in its own file. The control
word {\tt \\input} is then used to read in a file. In general,
{\tt \\input filename} will cause the file called {\tt
filename.tex} to be read in and processed immediately, just as if
the text of {\tt filename.tex} had been part of the file that
read it in. This file may input other files. In fact it's often
convenient to make a single file that reads in smaller pieces,
perhaps as follows:
\toindex{input}
\beginuser
\\input macros
\\input intro
\\input sec1
\\input sec2
\\input sec3
\\input sec4
\\input sec5
\\input sec6
\\input sec7
\\input sec8
\\input sec9
\\input sec10
\enduser
While the text is still being heavily edited, it's possible to
process only some of the files by putting a {\tt \%} at the
beginning of each line that contains a file to be skipped (this
is sometimes called ``commenting out'' the unwanted files).
The {\tt \\input} control word also allows the use of
predesigned macros. The macros for a memorandum, for example,
might be put in a file called {\tt memo.tex}. These macros might
set up the right {\tt \\hsize}, {\tt \\vsize} and other
parameters, and might stamp the time and date. Once this has
been set up, all memoranda may be started with {\tt \\input memo}
to make them come out with a common format.
Be sure that you don't have the control word {\tt \\bye} in your
input file or the \TeX{} program will stop at that point.
\exercise Make a \TeX{} input file that reads in a second file.
Try reading in the second file twice using the {\tt \\input}
control word twice.
\subsection{Larger macro packages}
Designing macros that can be used with many types of documents
is obviously useful. Most universities, for example, have
specific and often complicated format requirements for theses. A
collection of macros, that is, a macro package that meets all
these specifications could be somewhat time consuming to design
and could be quite long. It is possible to use the {\tt \\input}
command to use such a macro package, just as it is possible to
use it with your own macros. But \TeX{} has a better facility
for larger packages.
A macro package can be put in a special form that can be quickly
read by \TeX\null. This is called a {\sl format file}, and
the exact form is of technical interest only. The important
thing is it allows \TeX{} to be run with many new control
sequences predefined. Certain commands called {\sl primitives\/}
are part of the definition of \TeX\null.
What we have described in this manual is sometimes called {\sl
plain \TeX\/}, and consists of the \TeX{} primitives plus a set
of macros in a format file (that is usually included in \TeX{}
automatically) called {\tt plain.fmt}. For the curious, any
control word can be viewed using {\tt \\show}. The command {\tt
\\show\\centerline} will display
\beginliteral
> \centerline=macro:
#1->\line {\hss #1\hss }.
@endliteral
\noindent
on the screen and in the log file. You can use {\tt \\show} with
your own macros, too. If you end up using several macro
packages, you can use the {\tt \\show} command to see if a
particular macro is defined.
Many computer \centre{}s have the \LaTeX{} macro package. This
package allows the user to create an index, a table of contents,
and a bibliography automatically. It also has the ability to
insert some elementary graphic figures such as circles, ovals,
lines, and arrows. \LaTeX{} also uses special predefined files
called {\sl style files\/} to set up
specific page parameters. Many different style files are
available; some journals will accept papers on a magnetic medium
for direct processing if they are prepared using \LaTeX{} and a
designated style file. It is not difficult to shift from \TeX{}
to \LaTeX\null. A user's guide by the author of the macro
package, Leslie Lamport, is available:
{\bf \LaTeX{}: A document preparation system}%
\fnote{Addison-Wesley, Reading, Massachusetts, 1986,
ISBN 0-201-15790-X.}.
The American Mathematical Society uses the \AMSTeX{} macro
package for its journals. It is readily available from that
Society, and papers may be submitted to their journals on a
magnetic medium using \AMSTeX\null. A manual by Michael Spivak,
{\bf The Joy of \TeX{}}\fnote{American Mathematical
Society, 1986, ISBN 0-8218-2999-8}, is available from the
American Mathematical Society.
Other macro packages exist, and undoubtedly more will be
developed. They are usually of modest cost and can be very
effective in some circumstances. The \TeX{} Users Group
announces the existence of new macro packages in its
publications.
\subsection{Horizontal and vertical lines}
Making horizontal and vertical lines is easy using \TeX\null.
When typing in text, {\tt \\hrule } will cause the current
paragraph to end, will draw a horizontal line whose width is the
current value of {\tt \\hsize}, and then will continue on with a
new paragraph. It's possible to specify the width of the hrule
as, for example, with {\tt \\hrule width 5 cm}; also you can use
{\tt \\vskip} or {\tt \\bigskip} to put some space above or below
the hrule. Here is an example:
\beginuser
\\parindent = 0 pt \\parskip = 12 pt
Here is the text before the hrule.
\\bigskip
\\hrule width 3 in
And here is some text after the hrule.
\enduser
\noindent that produces
\vfill\eject
{
\parindent = 0 pt
Here is the text before the hrule.
\bigskip
\hrule width 3 in
And here is some text after the hrule.
}
In fact this hrule not only has width of three inches, but also
by default has a height (the amount by which the hrule extends
above the baseline on which the type is being set) of 0.4 points
and a depth (the amount by which the hrule extends below the
baseline on which the type is being set) of 0 points. Each of
these parameters can be individually set. Thus if we change the
last example to say
{\tt \\hrule width 3 in height 2 pt depth 3 pt } we get
{
\parindent = 0 pt
Here is the text before the hrule.
\bigskip
\hrule width 3 in height 2 pt depth 3 pt
And here is some text after the hrule.
}
The three parameters {\tt width}, {\tt height}, and {\tt depth} may
be given in any order.
\toindex{hrule}
\TeXref{221--222}
A vrule may be defined analogously to an hrule by specifying the
{\tt width}, {\tt height}, and {\tt depth} if desired.
\TeXref{221--222}
But, unlike the hrule, the vrule will not automatically start a
new paragraph when it appears. By default the vrule will be 0.4
points wide, and will be as high as the line on which it is being
set. Hence
\toindex{vrule}
\beginuser
Here is some text before the vrule
\\vrule\\
and this follows the vrule.
\enduser
\noindent will give
Here is some text before the vrule
\vrule\
and this follows the vrule.
\exercise Make three horizontal lines that are 15 points apart,
3 inches in length, and one inch in from the left margin.
Although we usually think of hrules and vrules as horizontal and
vertical lines, they need not necessarily be used that way. For
example:
\beginuser
\\noindent
Name: \\vrule height 0 pt depth 0.4 pt width 3 in
\enduser
\noindent will give
\noindent
Name: \vrule height 0 pt depth 0.4 pt width 3 in
\exercise Make the following grid (each box is 1 \centimetre{} square):
\medskip
\settabs \+ \hskip 1cm&\hskip 1 cm&\hskip 1 cm& \cr
\moveright 2 in
\vbox{
\hrule width 3 cm
\+ \vrule height 1 cm & \vrule height 1 cm & \vrule height 1 cm
& \vrule height 1 cm \cr
\hrule width 3 cm
\+ \vrule height 1 cm & \vrule height 1 cm & \vrule height 1 cm
& \vrule height 1 cm \cr
\hrule width 3 cm
\+ \vrule height 1 cm & \vrule height 1 cm & \vrule height 1 cm
& \vrule height 1 cm \cr
\hrule width 3 cm
}
\subsection{Boxes within boxes}
We have already seen (in our discussion of line shapes) that
vboxes and hboxes are objects that may be overfull or underfull.
In this section we will look at these boxes in a bit more detail.
They may be stacked or lined up to allow a variety of positions
for text on the page.
An hbox is formed by using {\tt \\hbox\lb $\ldots$\rb}\null.
Once the material between the braces has been put into an hbox,
it is set and can not be further split (this means that material
that must go on one line can be put into an hbox, and it will
then remain as one unit). It's possible to specify the size of
an hbox.\TeXref{64--66} Thus {\tt \\hbox to 5 cm\lb contents of
the box\rb } will produce an hbox exactly five \centimetre{}s
wide containing the typeset text ``contents of the box''.
It's easy to get an underfull or overfull box in this way. An
underfull box can be avoided by using {\tt \\hfil} to absorb the
extra space. When no dimension is given, an hbox is formed that
is just wide enough to hold the enclosed text.
\toindex{hbox}
Similarly, vboxes are formed using {\tt \\vbox\lb $\ldots$\rb}.
What makes these boxes interesting is that when a vbox contains
hboxes, these hboxes are stacked one above the other and set as a
unit. Similarly, an hbox can contain vboxes, which will be set in
a row. Suppose we take three hboxes and put them in a vbox:
\toindex{vbox}
\beginuser \obeyspaces
\\vbox\lb
\ \\hbox\lb{}Contents of box 1\rb
\ \\hbox\lb{}Contents of box 2\rb
\ \\hbox\lb{}Contents of box 3\rb
\ \rb
\enduser
\noindent gives
\vskip \baselineskip
\vbox{
\hbox{Contents of box 1}
\hbox{Contents of box 2}
\hbox{Contents of box 3}
}
Now suppose we take another vbox:
\beginuser \obeyspaces
\\vbox\lb
\ \\hbox\lb{}Contents of box 4\rb
\ \\hbox\lb{}Contents of box 5\rb
\ \rb
\enduser
These two vboxes can be put into an hbox; this will cause them to
be placed side by side. In other words
\beginuser \obeyspaces
\\hbox\lb
\ \\vbox\lb
\ \\hbox\lb{}Contents of box 1\rb
\ \\hbox\lb{}Contents of box 2\rb
\ \\hbox\lb{}Contents of box 3\rb
\ \rb
\ \\vbox\lb
\ \\hbox\lb{}Contents of box 4\rb
\ \\hbox\lb{}Contents of box 5\rb
\ \rb
\ \rb
\enduser
\noindent gives
\vskip \baselineskip
\hbox{
\vbox{
\hbox{Contents of box 1}
\hbox{Contents of box 2}
\hbox{Contents of box 3}
}
\vbox{
\hbox{Contents of box 4}
\hbox{Contents of box 5}
}
}
Notice that the two vboxes are aligned so that the bottoms are
level; also there is a little space at the beginning of each line
and also between the vboxes. Actually, the reason these spaces
appear is rather subtle. Unless a line ends in a control word,
there is always a space between the last entry in one line and
the first one in the next line. For this reason the space between
the vboxes comes from the end of the line containing the closing
brace of the first vbox. Similarly, the space at the beginning
of the line is caused by the space after the opening brace of the
hbox. These spaces can be avoided by ``commenting out'' the end of
the line, that is, by putting a {\tt \%} immediately after the
closing brace of the first vbox or the opening brace of the hbox.
If you try to put some vboxes together and accidentally get extra
space by forgetting to comment out the end of the line, you're in
good company. Some very able and experienced \TeX{} users have
done the same thing!
Extra space, say one \centimetre, can be added by putting an
{\tt \\hskip 1 cm } between the vboxes. They can be aligned so
that the tops are level by using {\tt \\vtop } instead of
{\tt \\vbox}. Making these two changes results in:
\toindex{vtop}
\vskip \baselineskip
\hbox{
\vtop{
\hbox{Contents of box 1}
\hbox{Contents of box 2}
\hbox{Contents of box 3}
}
\hskip 1 cm
\vtop{
\hbox{Contents of box 4}
\hbox{Contents of box 5}
}
}
We can combine vboxes, hboxes, vrules, and hrules to get boxed
text. How might we construct such a box? One way is to take the
material to be boxed and put it in an hbox preceded and followed
by a vrule. Then put this in a vbox with hrules above and below
it. This gives us:
\beginuser \obeyspaces
\\vbox\lb
\ \\hrule
\ \\hbox\lb\\vrule\lb\rb The text to be boxed \\vrule\rb
\ \\hrule
\ \rb
\enduser
\noindent which results in
\vskip \baselineskip
\vbox{
\hrule
\hbox{\vrule{} The text to be boxed \vrule}
\hrule
}
This produces boxed material, but there is no margin around it
and so it looks very cramped (of course \TeX{} is just giving us
what we asked for). We can improve the spacing by putting a {\tt
\\strut} at the beginning of the hbox to make it a little taller
and deeper. This gives us:
\vskip \baselineskip
\vbox{
\hrule
\hbox{\strut \vrule{} The text to be boxed \vrule}
\hrule
}
\def\boxtext#1{%
\vbox{%
\hrule
\hbox{\strut \vrule{} #1 \vrule}%
\hrule
}%
}
\exercise Why is it that we were forced to add extra space above
and below the text but not before and after it?
\exercise Use the method of boxing material to put text \centred{}
in a box which extends from the left to the right margin.
\exercise By stacking nine little boxes, make the following magic square:
\vskip\baselineskip
\moveright 2 in \vbox{\offinterlineskip
\hbox{\boxtext 6\boxtext 1\boxtext 8}
\hbox{\boxtext 7\boxtext 5\boxtext 3}
\hbox{\boxtext 2\boxtext 9\boxtext 4}
}
\exercise Notice that the magic square in the previous exercise
has internal lines that are twice as thick as the outside ones.
Also, there is a tiny space at the intersection of the internal
lines. Fix up the magic square so this doesn't happen.
\def\boxtext#1 {%
\vbox{%
\hrule
\hbox{\strut \vrule #1\vrule}%
\hrule
}
}
\exercise Write a macro { \tt \\boxtext\#1\lb$\ldots$\rb } which
will take the text between the braces and put a box around it. Test
your macro by making up a sentence with every other word boxed.
I'm \boxtext not quite \boxtext sure why \boxtext someone
would \boxtext do this \boxtext since the \boxtext result is \boxtext
pretty strange. Note how the baseline and the bottom of
the surrounding boxes align.
\def\boxtext#1 {%
\lower 3.5pt \hbox{%
\vbox{%
\hrule
\hbox{\strut \vrule #1\vrule}%
\hrule
}
}%
}
It's easy to move boxes up, down, left, or right on the page. A
{\tt \\vbox} can be moved to the right one inch by using {\tt
\\moveright 1 in \\vbox\lb\dots\rb}. To move it to the left,
use {\tt \\moveleft}. Similarly, an {\tt \\hbox} can be moved up
or down using {\tt \\raise} or {\tt \\lower}.
\toindex{moveright}
\toindex{moveleft}
\toindex{raise}
\toindex{lower}
\exercise Rewrite the {\tt \\boxtext} macro from the previous
exercise so that all of the text is aligned (hint: by default the
depth of a strut is 3.5 points). This would give a sentence like
the following: I'm \boxtext not quite \boxtext sure why \boxtext
someone would \boxtext do this \boxtext since the \boxtext result
is \boxtext pretty strange.
It's possible to fill a box with either an hrule or with dots.
The idea is to use {\tt \\hrulefill } or {\tt \\dotfill } in the
hbox.
\beginuser
\\hbox to 5 in\lb Getting Started\\hrulefill 1\rb
\\hbox to 5 in\lb All Characters Great and Small\\hrulefill 9\rb
\\hbox to 5 in\lb The Shape of Things to come\\hrulefill 17\rb
\\hbox to 5 in\lb No Math Anxiety Here!\\hrulefill 30\rb
\enduser
\noindent gives
\vskip \baselineskip
\hbox to 5 in{Getting Started\hrulefill 1}
\hbox to 5 in{All Characters Great and Small\hrulefill 9}
\hbox to 5 in{The Shape of Things to come\hrulefill 17}
\hbox to 5 in{No Math Anxiety Here!\hrulefill 30}
If {\tt \\hrulefill} is replaced by {\tt \\dotfill} we get
\vskip \baselineskip
\hbox to 5 in{Getting Started\dotfill 1}
\hbox to 5 in{All Characters Great and Small\dotfill 9}
\hbox to 5 in{The Shape of Things to come\dotfill 17}
\hbox to 5 in{No Math Anxiety Here!\dotfill 30}
\exercise Make a boxed headline appear at the top of the page
that is like the one used in this manual.
\section{Control word list}
Here is a list of the control words given in this manual.
If you want more detail about these words than is given here,
check the index of {\bf The \TeX book}.
\vskip 2\baselineskip
\centerline{Control symbols}
\vskip\baselineskip
\settabs \+ \hskip 1.5 in & \hskip 1.65in & \hskip 1.3in & \cr
{\tt
\+ \\\sp{} 4 & \\!\ 34 & \\" 11 & \\' 11 \cr
\+ \\, 34 & \\.\ 11 & \\/ 16 & \\; 34 \cr
\+ \\= 11 & \\> 34 & \\\# 10& \\\$ 6 \cr
\+ \\\% 6 & \\\& 10 & \\\char '173{} 10 & \\\char '175{} 10 \cr
\+ \\\underbar{ } 10 & \\` 11 & \\{\accent "7E } 10 & \\{\accent 94 } 10 \cr
\+ \\| 40 \cr
}
\vskip 2\baselineskip
\centerline{Control words}
\vskip\baselineskip
{\tt
\+ \\AA 12 & \\aa 12 & \\acute 36 & \\AE 12 \cr
\+ \\ae 12 & \\aleph 37 & \\alpha 35 & \\angle 37 \cr
\+ \\approx 37 & \\arccos 41 & \\arcsin 41 & \\arctan 41 \cr
\+ \\arg 41 & \\ast 36 & \\b 12 & \\backslash 37 \cr
\+ \\bar 36 & \\baselineskip 22 & \\beta 35 & \\bf 16 \cr
\+ \\biggl 40 & \\Biggl 40 & \\biggr 40 & \\Biggr 40 \cr
\+ \\bigl 40 & \\Bigl 40 & \\bigr 40 & \\Bigr 40 \cr
\+ \\bigskip 26 & \\break 26 & \\breve 36 & \\bullet 36 \cr
\+ \\bye 4 & \\c 12 & \\cap 36 & \\cdot 36 \cr
\+ \\centerline 26 & \\centreline 60 & \\check 36 & \\chi 35 \cr
\+ \\circ 35 & \\columns 48 & \\cos 41 & \\cosh 41 \cr
\+ \\cot 41 & \\coth 41 & \\csc 41& \\cup 36 \cr
\+ \\d 12 & \\ddag 27 & \\ddot 36 & \\def 55 \cr
\+ \\deg 41 & \\delta 35 & \\Delta 35 & \\det 41 \cr
\+ \\diamond 36 & \\dim 41 & \\div 36 & \\dot 36 \cr
\+ \\dotfill 49 & \\dots 14 & \\downarrow 41 & \\Downarrow 41 \cr
\+ \\eject 20 & \\ell 37 & \\endinsert 26 & \\epsilon 35 \cr
\+ \\eqalign 45 & \\eqalignno 46 & \\eqno 46 & \\equiv 37 \cr
\+ \\eta 35 & \\exists 37 & \\exp 41 & \\flat 37 \cr
\+ \\folio 28 & \\font 16 & \\footline 28 & \\footnote 27 \cr
\+ \\forall 37 & \\gamma 35 & \\Gamma 35 & \\gcd 41 \cr
\+ \\geq 37 & \\grave 36 & \\H 12 & \\halign 51 \cr
\+ \\hang 23 & \\hangafter 23 & \\hangindent 23 & \\hat 36 \cr
\+ \\hbadness 29 & \\hbox 72 & \\headline 28 & \\hfil 27 \cr
\+ \\hfill 26 & \\hfuzz 29 & \\hoffset 20 & \\hom 41 \cr
\+ \\hrule 71 & \\hrulefill 49 & \\hsize 20 & \\hskip 27 \cr
\+ \\hyphenation 30 & \\i 11 & \\Im 37 & \\in 37 \cr
\+ \\inf 41 & \\infty 37 & \\input 68 & \\int 38 \cr
\+ \\iota 35 & \\it 16 & \\item 24 & \\itemitem 24 \cr
\+ \\j 11 & \\kappa 35 & \\ker 41 & \\L 12 \cr
\+ \\l 12 & \\lambda 35 & \\Lambda 35 & \\langle 41 \cr
\+ \\lceil 41 & \\left 44 & \\leftline 26 & \\leftskip 23 \cr
\+ \\leq 37 & \\leqalignno 46 & \\leqno 46 & \\let 61 \cr
\+ \\lfloor 41 & \\lg 41 & \\lim 38 & \\liminf 41 \cr
\+ \\limsup 41 & \\line 26 & \\ln 41 & \\log 41 \cr
\+ \\lower 75 & \\magnification 21 & \\magstep 16 & \\matrix 44 \cr
\+ \\max 41 & \\medskip 26 & \\min 41 & \\moveleft 75 \cr
\+ \\moveright 75 & \\mu 35 & \\nabla 37 & \\narrower 23 \cr
\+ \\natural 37 & \\neg 37 & \\ni 37 & \\noalign 52 \cr
\+ \\noindent 22 & \\nopagenumbers 5 & \\not 36 & \\nu 35 \cr
\+ \\O 12 & \\o 12 & \\odot 36 & \\OE 12 \cr
\+ \\oe 12 & \\offinterlineskip 53 & \\omega 35 & \\Omega 35 \cr
\+ \\ominus 36 & \\oplus 36 & \\otimes 36 & \\over 37 \cr
\+ \\overfullrule 29 & \\overline 39 & \\P 27 & \\pageno 28 \cr
\+ \\par 7 & \\parallel 37 & \\parindent 23 & \\parshape 24 \cr
\+ \\parskip 22 & \\partial 37 & \\perp 37 & \\phi 35 \cr
\+ \\Phi 35 & \\pi 35 & \\Pi 35 & \\pmatrix 43 \cr
\+ \\Pr 41 & \\proclaim 42 & \\psi 35 & \\Psi 35 \cr
\+ \\qquad 34 & \\quad 34 & \\raggedright 27 & \\raise 75 \cr
\+ \\rangle 41 & \\rceil 41 & \\Re 37 & \\rfloor 41 \cr
\+ \\rho 35 & \\right 44 & \\rightline 26 & \\rightskip 23 \cr
\+ \\rm 16 & \\root 39 & \\S 27 & scaled 16 \cr
\+ \\sec 41 & \\settabs 48 & \\sharp 37 & \\sigma 35 \cr
\+ \\Sigma 35 & \\sim 37 & \\simeq 37 & \\sin 41 \cr
\+ \\sinh 41 & \\sl 16 & \\smallskip 26 & \\sqroot 39 \cr
\+ \\ss 12 & \\star 36 & \\strut 50 & \\subset 37 \cr
\+ \\subseteq 37 & \\sum 38 & \\sup 41 & \\supset 37 \cr
\+ \\supseteq 37 & \\surd 39 & \\t 12 & \\tan 41 \cr
\+ \\tanh 41 & \\tau 35 & \\tensor 60 & \\TeX{} 5 \cr
\+ \\tensor 60 & \\the 28 & \\theta 35 & \\Theta 35 \cr
\+ \\tilde 36 & \\times 36 & \\tolerance 29 & \\topinsert 26 \cr
\+ \\tt 16 & \\u 12 & \\underbar 39 & \\underline 39 \cr
\+ \\uparrow 41 & \\Uparrow 41 & \\updownarrow 41 & \\Updownarrow 41 \cr
\+ \\upsilon 35 & \\Upsilon 35 & \\v 12 & \\varepsilon 35 \cr
\+ \\varphi 35 & \\varrho 35 & \\varsigma 35 & \\vartheta 35 \cr
\+ \\vbadness 30 & \\vbox 71 & \\vec 36 & \\vee 36 \cr
\+ \\vfill 20 & \\vglue 25 & \\voffset 20 & \\vrule 71 \cr
\+ \\vsize 20 & \\vtop 74 & \\wedge 36 & \\widehat 36 \cr
\+ \\widetilde 36 & \\xi 35 & \\Xi 35 & \\zeta 35 \cr
}
\ifwritinganswers
\let\next=\relax
\else
\let\next=\endinput
\datestamp
\fi
\next
\def\beginliteral{
\vskip\baselineskip
\begingroup
\obeylines
\tt
\catcode`\@=0\catcode`\~=12
\catcode`\$=12\catcode`\&=12\catcode`\^=12\catcode`\#=12
\catcode`\_=12\catcode`\=12
\def\par{\leavevmode\endgraf}
\catcode`\{=12\catcode`\}=12\catcode`\%=12\catcode`\\=12
}
\def\endliteral{\nobreak \vskip 6pt \endgroup}
\section{I get by with a little help}
Many of the exercises can be answered in several ways. If you
like your way better than the way given below, by all means use
it!
\vskip 2\baselineskip
\parskip=0pt \parindent=0pt
\raggedright
\hbadness=10000
\hrule
\beginliteral
I like \TeX!
Once you get the hang of it, \TeX\ is really easy to use.
You just have to master the \TeX nical aspects.
@endliteral
I like \TeX! Once you get the hang of it, \TeX\ is really easy
to use. You just have to master the \TeX nical aspects.
\vskip \baselineskip \hrule
\goodbreak \vskip 2pt \hrule
\beginliteral
Does \AE schylus understand \OE dipus?
@endliteral
Does \AE schylus understand \OE dipus?
\vskip \baselineskip \hrule
\goodbreak \vskip 2pt \hrule
\beginliteral
The smallest internal unit of \TeX{} is about 53.63\AA.
@endliteral
The smallest internal unit of \TeX{} is about 53.63\AA.
\vskip \baselineskip \hrule
\goodbreak \vskip 2pt \hrule
\beginliteral
They took some honey and plenty of money wrapped up in a {\it \$}5 note.
@endliteral
They took some honey and plenty of money wrapped up in a {\it \$}5 note.
\vskip \baselineskip \hrule
\goodbreak \vskip 2pt \hrule
\beginliteral
\'El\`eves, refusez vos le\c cons! Jetez vos cha\^\i nes!
@endliteral
\'El\`eves, refusez vos le\c cons! Jetez vos cha\^\i nes!
\vskip \baselineskip \hrule
\goodbreak \vskip 2pt \hrule
\beginliteral
Za\v sto tako polako pijete \v caj?
@endliteral
Za\v sto tako polako pijete \v caj?
\vskip \baselineskip \hrule
\goodbreak \vskip 2pt \hrule
\beginliteral
Mein Tee ist hei\ss.
@endliteral
Mein Tee ist hei\ss.
\vskip \baselineskip \hrule
\goodbreak \vskip 2pt \hrule
\beginliteral
Peut-\^etre qu'il pr\'ef\`ere le caf\'e glac\'e.
@endliteral
Peut-\^etre qu'il pr\'ef\`ere le caf\'e glac\'e.
\vskip \baselineskip \hrule
\goodbreak \vskip 2pt \hrule
\def\`{\relax\lq}
\beginliteral
?@`Por qu\'e no bebes vino blanco? !@`Porque est\'a avinagrado!
@endliteral
?`Por qu\'e no bebes vino blanco? !`Porque est\'a avinagrado!
\vskip \baselineskip \hrule
\goodbreak \vskip 2pt \hrule
\beginliteral
M\'\i\'\j n idee\"en worden niet be\"\i nvloed.
@endliteral
M\'\i\'\j n idee\"en worden niet be\"\i nvloed.
\vskip \baselineskip \hrule
\goodbreak \vskip 2pt \hrule
\beginliteral
Can you take a ferry from \"Oland to \AA land?
@endliteral
Can you take a ferry from \"Oland to \AA land?
\vskip \baselineskip \hrule
\goodbreak \vskip 2pt \hrule
\beginliteral
T\"urk\c ce konu\c san ye\u genler nasillar?
@endliteral
T\"urk\c ce konu\c san ye\u genler nasillar?
\vskip \baselineskip \hrule
\goodbreak \vskip 2pt \hrule
\beginliteral
I entered the room and---horrors---I saw both my father-in-law and my
mother-in-law.
@endliteral
I entered the room and---horrors---I saw both my father-in-law and my
mother-in-law.
\vskip \baselineskip \hrule
\goodbreak \vskip 2pt \hrule
\beginliteral
The winter of 1484--1485 was one of discontent.
@endliteral
The winter of 1484--1485 was one of discontent.
\vskip \baselineskip \hrule
\goodbreak \vskip 2pt \hrule
\beginliteral
His ``thoughtfulness'' was impressive.
@endliteral
His ``thoughtfulness'' was impressive.
\vskip \baselineskip \hrule
\goodbreak \vskip 2pt \hrule
\beginliteral
Frank wondered, ``Is this a girl that can't say `No!'?''
@endliteral
Frank wondered, ``Is this a girl that can't say `No!'?''
\vskip \baselineskip \hrule
\goodbreak \vskip 2pt \hrule
\beginliteral
He thought, ``\dots and this goes on forever, perhaps to the last recorded
syllable.''
@endliteral
He thought, ``\dots and this goes on forever, perhaps to the last recorded
syllable.''
\vskip \baselineskip \hrule
\goodbreak \vskip 2pt \hrule
\beginliteral
Have you seen Ms.~Jones?
@endliteral
Have you seen Ms.~Jones?
\vskip \baselineskip \hrule
\goodbreak \vskip 2pt \hrule
\beginliteral
Prof.~Smith and Dr.~Gold flew from
Halifax N.~S. to Montr\'eal, P.~Q. via Moncton, N.~B.
@endliteral
Prof.~Smith and Dr.~Gold flew from
Halifax N.~S. to Montr\'eal, P.~Q. via Moncton, N.~B.
\vskip \baselineskip \hrule
\goodbreak \vskip 2pt \hrule
\beginliteral
\line{left end \hfil left tackle \hfil left guard \hfil @centre \hfil
right guard \hfil right tackle \hfil right end}
@endliteral
\line{left end \hfil left tackle \hfil left guard \hfil \centre{} \hfil
right guard \hfil right tackle \hfil right end}
\vskip \baselineskip \hrule
\goodbreak \vskip 2pt \hrule
\beginliteral
\line{left \hfil \hfil right-@centre \hfil right}
@endliteral
\line{left \hfil \hfil right-\centre{} \hfil right}
\vskip \baselineskip \hrule
\goodbreak \vskip 2pt \hrule
\beginliteral
\line{\hskip 1 in ONE \hfil TWO \hfil THREE}
@endliteral
\line{\hskip 1 in ONE \hfil TWO \hfil THREE}
\vskip \baselineskip \hrule
\goodbreak \vskip 2pt \hrule
\beginliteral
i{f}f if{}f if{f}
@endliteral
i{f}f if{}f if{f}
\vskip \baselineskip \hrule
\goodbreak \vskip 2pt \hrule
\beginliteral
I started with roman type {\it switched to italic type}, and
returned to roman type.
@endliteral
I started with roman type {\it switched to italic type}, and
returned to roman type.
\vskip \baselineskip \hrule
\goodbreak \vskip 2pt \hrule
\beginliteral
$C(n,r) = n!/(r!\,(n-r)!)$
@endliteral
$C(n,r) = n!/(r!\,(n-r)!)$
\vskip \baselineskip \hrule
\goodbreak \vskip 2pt \hrule
\beginliteral
$a+b=c-d=xy=w/z$
$$a+b=c-d=xy=w/z$$
@endliteral
$a+b=c-d=xy=w/z$
$$a+b=c-d=xy=w/z$$
\vskip \baselineskip \hrule
\goodbreak \vskip 2pt \hrule
\beginliteral
$(fg)' = f'g + fg'$
$$(fg)' = f'g + fg'$$
@endliteral
$(fg)' = f'g + fg'$
$$(fg)' = f'g + fg'$$
\vskip \baselineskip \hrule
\goodbreak \vskip 2pt \hrule
\beginliteral
$\alpha\beta=\gamma+\delta$
$$\alpha\beta=\gamma+\delta$$
@endliteral
$\alpha\beta=\gamma+\delta$
$$\alpha\beta=\gamma+\delta$$
\vskip \baselineskip \hrule
\goodbreak \vskip 2pt \hrule
\beginliteral
$\Gamma(n) = (n-1)!$
$$\Gamma(n) = (n-1)!$$
@endliteral
$\Gamma(n) = (n-1)!$
$$\Gamma(n) = (n-1)!$$
\vskip \baselineskip \hrule
\goodbreak \vskip 2pt \hrule
\beginliteral
$x\wedge (y\vee z) = (x\wedge y) \vee (x\wedge z)$
@endliteral
$x\wedge (y\vee z) = (x\wedge y) \vee (x\wedge z)$
\vskip \baselineskip \hrule
\goodbreak \vskip 2pt \hrule
\beginliteral
$2+4+6+\cdots +2n = n(n+1)$
@endliteral
$2+4+6+\cdots +2n = n(n+1)$
\vskip \baselineskip \hrule
\goodbreak \vskip 2pt \hrule
\beginliteral
$\vec x\cdot \vec y = 0$ if and only if $\vec x \perp \vec y$.
@endliteral
$\vec x\cdot \vec y = 0$ if and only if $\vec x \perp \vec y$.
\vskip \baselineskip \hrule
\goodbreak \vskip 2pt \hrule
\beginliteral
$\vec x\cdot \vec y \not= 0$ if and only if $\vec x \not\perp \vec y$.
@endliteral
$\vec x\cdot \vec y \not= 0$ if and only if $\vec x \not\perp \vec y$.
\vskip \baselineskip \hrule
\goodbreak \vskip 2pt \hrule
\beginliteral
$(\forall x\in \Re)(\exists y\in\Re)$ $y>x$.
@endliteral
$(\forall x\in \Re)(\exists y\in\Re)$ $y>x$.
\vskip \baselineskip \hrule
\goodbreak \vskip 2pt \hrule
\beginliteral
${a+b\over c}\quad {a\over b+c}\quad {1\over a+b+c} \not= {1\over a}+
{1\over b}+{1\over c}$.
@endliteral
${a+b\over c}\quad {a\over b+c}\quad {1\over a+b+c} \not= {1\over a}+
{1\over b}+{1\over c}$.
\vskip \baselineskip \hrule
\goodbreak \vskip 2pt \hrule
\beginliteral
What are the points where ${\partial \over \partial x} f(x,y) = {\partial \over
\partial y} f(x,y) = 0$?
@endliteral
What are the points where ${\partial \over \partial x} f(x,y) = {\partial \over
\partial y} f(x,y) = 0$?
\vskip \baselineskip \hrule
\goodbreak \vskip 2pt \hrule
\beginliteral
$e^x \quad e^{-x} \quad e^{i\pi}+1=0 \quad x_0 \quad x_0^2
\quad {x_0}^2 \quad 2^{x^x}$.
@endliteral
$e^x \quad e^{-x} \quad e^{i\pi}+1=0 \quad x_0 \quad x_0^2
\quad {x_0}^2 \quad 2^{x^x}$.
\vskip \baselineskip \hrule
\goodbreak \vskip 2pt \hrule
\beginliteral
$\nabla^2 f(x,y) = {\partial^2 f \over\partial x^2}+ {\partial^2 f \over
\partial y^2}$.
@endliteral
$\nabla^2 f(x,y) = {\partial^2 f \over\partial x^2}+ {\partial^2 f \over
\partial y^2}$.
\vskip \baselineskip \hrule
\goodbreak \vskip 2pt \hrule
\beginliteral
$\lim_{x\to 0} (1+x)^{1\over x}=e$.
@endliteral
$\lim_{x\to 0} (1+x)^{1\over x}=e$.
\vskip \baselineskip \hrule
\goodbreak \vskip 2pt \hrule
\beginliteral
The cardinality of $(-\infty, \infty)$ is $\aleph_1$.
@endliteral
The cardinality of $(-\infty, \infty)$ is $\aleph_1$.
\vskip \baselineskip \hrule
\goodbreak \vskip 2pt \hrule
\beginliteral
$\lim_{x\to {0^+}} x^x = 1$.
@endliteral
$\lim_{x\to {0^+}} x^x = 1$.
\vskip \baselineskip \hrule
\goodbreak \vskip 2pt \hrule
\beginliteral
$\int_0^1 3x^2\,dx = 1$.
@endliteral
$\int_0^1 3x^2\,dx = 1$.
\vskip \baselineskip \hrule
\goodbreak \vskip 2pt \hrule
\beginliteral
$\sqrt2 \quad \sqrt {x+y\over x-y} \quad \root 3 \of {10}$ \quad $e^{\sqrt x}$.
@endliteral
$\sqrt2 \quad \sqrt {x+y\over x-y} \quad \root 3 \of {10}$ \quad $e^{\sqrt x}$.
\vskip \baselineskip \hrule
\goodbreak \vskip 2pt \hrule
\beginliteral
$\|x\| = \sqrt{x\cdot x}$.
@endliteral
$\|x\| = \sqrt{x\cdot x}$.
\vskip \baselineskip \hrule
\goodbreak \vskip 2pt \hrule
\beginliteral
$\phi(t) = {1 \over \sqrt{2\pi}} \int_0^t e^{-x^2/2}\,dx$.
@endliteral
$\phi(t) = {1 \over \sqrt{2\pi}} \int_0^t e^{-x^2/2}\,dx$.
\vskip \baselineskip \hrule
\goodbreak \vskip 2pt \hrule
\beginliteral
$\underline x \quad \overline y \quad \underline{\overline{x+y}}$.
@endliteral
$\underline x \quad \overline y \quad \underline{\overline{x+y}}$.
\vskip \baselineskip \hrule
\goodbreak \vskip 2pt \hrule
\beginliteral
$\bigl \lceil \lfloor x \rfloor \bigr \rceil \leq \bigl \lfloor \lceil x \rceil
\bigr \rfloor$.
@endliteral
$\bigl \lceil \lfloor x \rfloor \bigr \rceil \leq \bigl \lfloor \lceil x \rceil
\bigr \rfloor$.
\vskip \baselineskip \hrule
\goodbreak \vskip 2pt \hrule
\beginliteral
$\sin(2\theta) = 2\sin\theta\cos\theta
\quad \cos(2\theta) = 2\cos^2\theta - 1 $.
@endliteral
$\sin(2\theta) = 2\sin\theta\cos\theta
\quad \cos(2\theta) = 2\cos^2\theta - 1 $.
\vskip \baselineskip \hrule
\goodbreak \vskip 2pt \hrule
\beginliteral
$$\int \csc^2x\, dx = -\cot x+ C
\qquad \lim_{\alpha\to 0} {\sin\alpha \over \alpha} = 1
\qquad \lim_{\alpha\to \infty} {\sin\alpha \over \alpha} = 0.$$
@endliteral
$$\int \csc^2x\, dx = -\cot x+ C
\qquad \lim_{\alpha\to 0} {\sin\alpha \over \alpha} = 1
\qquad \lim_{\alpha\to \infty} {\sin\alpha \over \alpha} = 0.$$
\vskip \baselineskip \hrule
\goodbreak \vskip 2pt \hrule
\beginliteral
$$\tan(2\theta) = {2\tan\theta \over 1-\tan^2\theta}.$$
@endliteral
$$\tan(2\theta) = {2\tan\theta \over 1-\tan^2\theta}.$$
\vskip \baselineskip \hrule
\goodbreak \vskip 2pt \hrule
\beginliteral
\proclaim Theorem (Euclid). There exist an infinite number of primes.
@endliteral
\proclaim Theorem (Euclid). There exist an infinite number of primes.
\vskip \baselineskip \hrule
\goodbreak \vskip 2pt \hrule
\beginliteral
\proclaim Proposition 1.
$\root n \of {\prod_{i=1}^n X_i} \leq
{1 \over n} \sum_{i=1}^n X_i$ with equality if and only if $X_1=\cdots=X_n$.
@endliteral
\proclaim Proposition 1.
$\root n \of {\prod_{i=1}^n X_i} \leq
{1 \over n} \sum_{i=1}^n X_i$ with equality if and only if $X_1=\cdots=X_n$.
\vskip \baselineskip \hrule
\goodbreak \vskip 2pt \hrule
\beginliteral
$$ I_4 = \pmatrix{
1 &0 &0 &0 \cr
0 &1 &0 &0 \cr
0 &0 &1 &0 \cr
0 &0 &0 &1 \cr}$$
@endliteral
$$ I_4 = \pmatrix{
1 &0 &0 &0 \cr
0 &1 &0 &0 \cr
0 &0 &1 &0 \cr
0 &0 &0 &1 \cr}$$
\vskip \baselineskip \hrule
\goodbreak \vskip 2pt \hrule
\beginliteral
$$ |x| = \left\{ \matrix{
x & x \ge 0 \cr
-x & x \le 0 \cr} \right.$$
@endliteral
$$ |x| = \left\{ \matrix{
x & x \ge 0 \cr
-x & x \le 0 \cr} \right.$$
\vskip \baselineskip \hrule
\goodbreak \vskip 2pt \hrule
\beginliteral
\settabs \+ \hskip 2 in & \hskip .75in & \hskip 1cm& \cr
\+ &Plums &\hfill\$1&.22 \cr
\+ &Coffee &\hfill1&.78 \cr
\+ &Granola &\hfill1&.98 \cr
\+ &Mushrooms & &.63 \cr
\+ &{Kiwi fruit} & &.39 \cr
\+ &{Orange juice} &\hfill1&.09 \cr
\+ &Tuna &\hfill1&.29 \cr
\+ &Zucchini & &.64 \cr
\+ &Grapes &\hfill1&.69 \cr
\+ &{Smoked beef} & &.75 \cr
\+ &Broccoli &\hfill\underbar{\ \ 1}&\underbar{.09} \cr
\+ &Total &\hfill \$12&.55 \cr
@endliteral
\settabs \+ \hskip 2 in & \hskip .75in & \hskip 1cm& \cr
\+ &Plums &\hfill\$1&.22 \cr
\+ &Coffee &\hfill1&.78 \cr
\+ &Granola &\hfill1&.98 \cr
\+ &Mushrooms & &.63 \cr
\+ &{Kiwi fruit} & &.39 \cr
\+ &{Orange juice} &\hfill1&.09 \cr
\+ &Tuna &\hfill1&.29 \cr
\+ &Zucchini & &.64 \cr
\+ &Grapes &\hfill1&.69 \cr
\+ &{Smoked beef} & &.75 \cr
\+ &Broccoli &\hfill\underbar{\ \ 1}&\underbar{.09} \cr
\+ &Total &\hfill \$12&.55 \cr
\vskip \baselineskip \hrule
\goodbreak \vskip 2pt \hrule
\beginliteral
\settabs \+ \hskip 4.5 in & \cr
\+Getting Started \dotfill &1 \cr
\+All Characters Great and Small \dotfill &9 \cr
@endliteral
\settabs \+ \hskip 4.5 in & \cr
\+Getting Started \dotfill &1 \cr
\+All Characters Great and Small \dotfill &9 \cr
\vskip \baselineskip \hrule
\goodbreak \vskip 2pt \hrule
\beginliteral
\settabs \+ \hskip 1cm&\hskip 1 cm&\hskip 1 cm& \cr
\moveright 2 in
\vbox{
\hrule width 3 cm
\+ \vrule height 1 cm & \vrule height 1 cm & \vrule height 1 cm
& \vrule height 1 cm \cr
\hrule width 3 cm
\+ \vrule height 1 cm & \vrule height 1 cm & \vrule height 1 cm
& \vrule height 1 cm \cr
\hrule width 3 cm
\+ \vrule height 1 cm & \vrule height 1 cm & \vrule height 1 cm
& \vrule height 1 cm \cr
\hrule width 3 cm
}
@endliteral
\settabs \+ \hskip 1cm&\hskip 1 cm&\hskip 1 cm& \cr
\moveright 2 in
\vbox{
\hrule width 3 cm
\+ \vrule height 1 cm & \vrule height 1 cm & \vrule height 1 cm
& \vrule height 1 cm \cr
\hrule width 3 cm
\+ \vrule height 1 cm & \vrule height 1 cm & \vrule height 1 cm
& \vrule height 1 cm \cr
\hrule width 3 cm
\+ \vrule height 1 cm & \vrule height 1 cm & \vrule height 1 cm
& \vrule height 1 cm \cr
\hrule width 3 cm
}
\vskip \baselineskip \hrule
\goodbreak \vskip 2pt \hrule
\beginliteral
\def\boxtext#1{%
\vbox{%
\hrule
\hbox{\strut \vrule{} #1 \vrule}%
\hrule
}%
}
\moveright 2 in \vbox{\offinterlineskip
\hbox{\boxtext{6}\boxtext{1}\boxtext {8}}
\hbox{\boxtext{7}\boxtext{5}\boxtext{3}}
\hbox{\boxtext{2}\boxtext{9}\boxtext{4}}
}
@endliteral
\def\boxtext#1{%
\vbox{%
\hrule
\hbox{\strut \vrule{} #1 \vrule}%
\hrule
}%
}
\moveright 2 in \vbox{\offinterlineskip
\hbox{\boxtext 6\boxtext 1\boxtext 8}
\hbox{\boxtext 7\boxtext 5\boxtext 3}
\hbox{\boxtext 2\boxtext 9\boxtext 4}
}
\vskip \baselineskip \hrule
\vfill
\datestamp
\eject
\parindent=20pt
This introduction is available for {\tt ftp} transfer on CTAN (Combined
\TeX{} Archive Network). Use an anonymous login to grab it from the
server nearest to you.
$$\vbox{
\halign{#\quad &#\cr
\bf Server & \bf file name \cr
ftp.tex.ac.uk (134.151.79.32) &
/tex-archive/documentation/gentle-introduction.tex\cr
ftp.uni-stuttgart.de (129.69.8.13) &
/tex-archive/documentation/gentle-introduction.tex\cr
ftp.shsu.edu (192.92.115.10) &
/tex-archive/documentation/gentle-introduction.tex\cr
}}
$$
\newdimen\squaredimen
\def\square#1{\setbox0=\hbox{#1}%
\dp0=.4ex \squaredimen=\ht0
\ifdim \wd0 > \ht0 \squaredimen=\wd0\fi
\advance \squaredimen by \dp0
\ht0=\squaredimen \advance \squaredimen by \dp0
\leavevmode
\lower .4ex \vbox{%
\hsize=\squaredimen
\hrule
\hbox to \squaredimen{\vrule\hfil\box0\hfil\vrule}%
\hrule height .4pt depth 0pt}}
Also, a somewhat expanded version of this introduction is available as a book:\
{\bf \TeX: Starting from \square1}. Springer-Verlag 1993
(ISBN 3-540-56441-1 or 0-387-56441-1).
\bye
|