1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
1892
1893
1894
1895
1896
1897
1898
1899
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
1928
1929
1930
1931
1932
1933
1934
1935
1936
1937
1938
1939
1940
1941
1942
1943
1944
1945
1946
1947
1948
1949
1950
1951
1952
1953
1954
1955
1956
1957
1958
1959
1960
1961
1962
1963
1964
1965
1966
1967
1968
1969
1970
1971
1972
1973
1974
1975
1976
1977
1978
1979
1980
1981
1982
1983
1984
1985
1986
1987
1988
1989
1990
1991
1992
1993
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
2027
2028
2029
2030
2031
2032
2033
2034
2035
2036
2037
2038
2039
2040
2041
2042
2043
2044
2045
2046
2047
2048
2049
2050
2051
2052
2053
2054
2055
2056
2057
2058
2059
2060
2061
2062
2063
2064
2065
2066
2067
2068
2069
2070
2071
2072
2073
2074
2075
2076
2077
2078
2079
2080
2081
2082
2083
2084
2085
2086
2087
2088
2089
2090
2091
2092
2093
2094
2095
2096
2097
2098
2099
2100
2101
2102
2103
2104
2105
2106
2107
2108
2109
2110
2111
2112
2113
2114
2115
2116
2117
2118
2119
2120
2121
2122
2123
2124
2125
2126
2127
2128
2129
2130
2131
2132
2133
2134
2135
2136
2137
2138
2139
2140
2141
2142
2143
2144
2145
2146
2147
2148
2149
2150
2151
2152
2153
2154
2155
2156
2157
2158
2159
2160
2161
2162
2163
2164
2165
2166
2167
2168
2169
2170
2171
2172
2173
2174
2175
2176
2177
2178
2179
2180
2181
2182
2183
2184
2185
2186
2187
2188
2189
2190
2191
2192
2193
2194
2195
2196
2197
2198
2199
2200
2201
2202
2203
2204
2205
2206
2207
2208
2209
2210
2211
2212
2213
2214
2215
2216
2217
2218
2219
2220
2221
2222
2223
2224
2225
2226
2227
2228
2229
2230
2231
2232
2233
2234
2235
2236
2237
2238
2239
2240
2241
2242
2243
2244
2245
2246
2247
2248
2249
2250
2251
2252
2253
2254
2255
2256
2257
2258
2259
2260
2261
2262
2263
2264
2265
2266
2267
2268
2269
2270
2271
2272
2273
2274
2275
2276
2277
2278
2279
2280
2281
2282
2283
2284
2285
2286
2287
2288
2289
2290
2291
2292
2293
2294
2295
2296
2297
2298
2299
2300
2301
2302
2303
2304
2305
2306
2307
2308
2309
2310
2311
2312
2313
2314
2315
2316
2317
2318
2319
2320
2321
2322
2323
2324
2325
2326
2327
2328
2329
2330
2331
2332
2333
2334
2335
2336
2337
2338
2339
2340
2341
2342
2343
2344
2345
2346
2347
2348
2349
2350
2351
2352
2353
2354
2355
2356
2357
2358
2359
2360
2361
2362
2363
2364
2365
2366
2367
2368
2369
2370
2371
2372
2373
2374
2375
2376
2377
2378
2379
2380
2381
2382
2383
2384
2385
2386
2387
2388
2389
2390
2391
2392
2393
2394
2395
2396
2397
2398
2399
2400
2401
2402
2403
2404
2405
2406
2407
2408
2409
2410
2411
2412
2413
2414
2415
2416
2417
2418
2419
2420
2421
2422
2423
2424
2425
2426
2427
2428
2429
2430
2431
2432
2433
2434
2435
2436
2437
2438
2439
2440
2441
2442
2443
2444
2445
2446
2447
2448
2449
2450
2451
2452
2453
2454
2455
2456
2457
2458
2459
2460
2461
2462
2463
2464
2465
2466
2467
2468
2469
2470
2471
2472
2473
2474
2475
2476
2477
2478
2479
2480
2481
2482
2483
2484
2485
2486
2487
2488
2489
2490
2491
2492
2493
2494
2495
2496
2497
2498
2499
2500
2501
2502
2503
2504
2505
2506
2507
2508
2509
2510
2511
2512
2513
2514
2515
2516
2517
2518
2519
2520
2521
2522
2523
2524
2525
2526
2527
2528
2529
2530
2531
2532
2533
2534
2535
2536
2537
2538
2539
2540
2541
2542
2543
2544
2545
2546
2547
2548
2549
2550
2551
2552
2553
2554
2555
2556
2557
2558
2559
2560
2561
2562
2563
2564
2565
2566
2567
2568
2569
2570
2571
2572
2573
2574
2575
2576
2577
2578
2579
2580
2581
2582
2583
2584
2585
2586
2587
2588
2589
2590
2591
2592
2593
2594
2595
2596
2597
2598
2599
2600
2601
2602
2603
2604
2605
2606
2607
2608
2609
2610
2611
2612
2613
2614
2615
2616
2617
2618
2619
2620
2621
2622
2623
2624
2625
2626
2627
2628
2629
2630
2631
2632
2633
2634
2635
2636
2637
2638
2639
2640
2641
2642
2643
2644
2645
2646
2647
2648
2649
2650
2651
2652
2653
2654
2655
2656
2657
2658
2659
2660
2661
2662
2663
2664
2665
2666
2667
2668
2669
2670
2671
2672
2673
2674
2675
2676
2677
2678
2679
2680
2681
2682
2683
2684
2685
2686
2687
2688
2689
2690
2691
2692
2693
2694
2695
2696
2697
2698
2699
2700
2701
2702
2703
2704
2705
2706
2707
2708
2709
2710
2711
2712
2713
2714
2715
2716
2717
2718
2719
2720
2721
2722
2723
2724
2725
2726
2727
2728
2729
2730
2731
2732
2733
2734
2735
2736
2737
2738
2739
2740
2741
2742
2743
2744
2745
2746
2747
2748
2749
2750
2751
2752
2753
2754
2755
2756
2757
2758
2759
2760
2761
2762
2763
2764
2765
2766
2767
2768
2769
2770
2771
2772
2773
2774
2775
2776
2777
2778
2779
2780
2781
2782
2783
2784
2785
2786
2787
2788
2789
2790
2791
2792
2793
2794
2795
2796
2797
2798
2799
2800
2801
2802
2803
2804
2805
2806
2807
2808
2809
2810
2811
2812
2813
2814
2815
2816
2817
2818
2819
2820
2821
2822
2823
2824
2825
2826
2827
2828
2829
2830
2831
2832
2833
2834
2835
2836
2837
2838
2839
2840
2841
2842
2843
2844
2845
2846
2847
2848
2849
2850
2851
2852
2853
2854
2855
2856
2857
2858
2859
2860
2861
2862
2863
2864
2865
2866
2867
2868
2869
2870
2871
2872
2873
2874
2875
2876
2877
2878
2879
2880
2881
2882
2883
2884
2885
2886
2887
2888
2889
2890
2891
2892
2893
2894
2895
2896
2897
2898
2899
2900
2901
2902
2903
2904
2905
2906
2907
2908
2909
2910
2911
2912
2913
2914
2915
2916
2917
2918
2919
2920
2921
2922
2923
2924
2925
2926
2927
2928
2929
2930
2931
2932
2933
2934
2935
2936
2937
2938
2939
2940
2941
2942
2943
2944
2945
2946
2947
2948
2949
2950
2951
2952
2953
2954
2955
2956
2957
2958
2959
2960
2961
2962
2963
2964
2965
2966
2967
2968
2969
2970
2971
2972
2973
2974
2975
2976
2977
2978
2979
2980
2981
2982
2983
2984
2985
2986
2987
2988
2989
2990
2991
2992
2993
2994
2995
2996
2997
2998
2999
3000
3001
3002
3003
3004
3005
3006
3007
3008
3009
3010
3011
3012
3013
3014
3015
3016
3017
3018
3019
3020
3021
3022
3023
3024
3025
3026
3027
3028
3029
3030
3031
3032
3033
3034
3035
3036
3037
3038
3039
3040
3041
3042
3043
3044
3045
3046
3047
3048
3049
3050
3051
3052
3053
3054
3055
3056
3057
3058
3059
3060
3061
3062
3063
3064
3065
3066
3067
3068
3069
3070
3071
3072
3073
3074
3075
3076
3077
3078
3079
3080
3081
3082
3083
3084
3085
3086
3087
3088
3089
3090
3091
3092
3093
3094
3095
3096
3097
3098
3099
3100
3101
3102
3103
3104
3105
3106
3107
3108
3109
3110
3111
3112
3113
3114
3115
3116
3117
3118
3119
3120
3121
3122
3123
3124
3125
3126
3127
3128
3129
3130
3131
3132
3133
3134
3135
3136
3137
3138
3139
3140
3141
3142
3143
3144
3145
3146
3147
3148
3149
3150
3151
3152
3153
3154
3155
3156
3157
3158
3159
3160
3161
3162
3163
3164
3165
3166
3167
3168
3169
3170
3171
3172
3173
3174
3175
3176
3177
3178
3179
3180
3181
3182
3183
3184
3185
3186
3187
3188
3189
3190
3191
3192
3193
3194
3195
3196
3197
3198
3199
3200
3201
3202
3203
3204
3205
3206
3207
3208
3209
3210
3211
3212
3213
3214
3215
3216
3217
3218
3219
3220
3221
3222
3223
3224
3225
3226
3227
3228
3229
3230
3231
3232
3233
3234
3235
3236
3237
3238
3239
3240
3241
3242
3243
3244
3245
3246
3247
3248
3249
3250
3251
3252
3253
3254
3255
3256
3257
3258
3259
3260
3261
3262
3263
3264
3265
3266
3267
3268
3269
3270
3271
3272
3273
3274
3275
3276
3277
3278
3279
3280
3281
3282
3283
3284
3285
3286
3287
3288
3289
3290
3291
3292
3293
3294
3295
3296
3297
3298
3299
3300
3301
3302
3303
3304
3305
3306
3307
3308
3309
3310
3311
3312
3313
3314
3315
3316
3317
3318
3319
3320
3321
3322
3323
3324
3325
3326
3327
3328
3329
3330
3331
3332
3333
3334
3335
3336
3337
3338
3339
3340
3341
3342
3343
3344
3345
3346
3347
3348
3349
3350
3351
3352
3353
3354
3355
3356
3357
3358
3359
3360
3361
3362
3363
3364
3365
3366
3367
3368
3369
3370
3371
3372
3373
3374
3375
3376
3377
3378
3379
3380
3381
3382
3383
3384
3385
3386
3387
3388
3389
3390
3391
3392
3393
3394
3395
3396
3397
3398
3399
3400
3401
3402
3403
3404
3405
3406
3407
3408
3409
3410
3411
3412
3413
3414
3415
3416
3417
3418
3419
3420
3421
3422
3423
3424
3425
3426
3427
3428
3429
3430
3431
3432
3433
3434
3435
3436
3437
3438
3439
3440
3441
3442
3443
3444
3445
3446
3447
3448
3449
3450
3451
3452
3453
3454
3455
3456
3457
3458
3459
3460
3461
3462
3463
3464
3465
3466
3467
3468
3469
3470
3471
3472
3473
3474
3475
3476
3477
3478
3479
3480
3481
3482
3483
3484
3485
3486
3487
3488
3489
3490
3491
3492
3493
3494
3495
3496
3497
3498
3499
3500
3501
3502
3503
3504
3505
3506
3507
3508
3509
3510
3511
3512
3513
3514
3515
3516
3517
3518
3519
3520
3521
3522
3523
3524
3525
3526
3527
3528
3529
3530
3531
3532
3533
3534
3535
3536
3537
3538
3539
3540
3541
3542
3543
3544
3545
3546
3547
3548
3549
3550
3551
3552
3553
3554
3555
3556
3557
3558
3559
3560
3561
3562
3563
3564
3565
3566
3567
3568
3569
3570
3571
3572
3573
3574
3575
3576
3577
3578
3579
3580
3581
3582
3583
3584
3585
3586
3587
3588
3589
3590
3591
3592
3593
3594
3595
3596
3597
3598
3599
3600
3601
3602
3603
3604
3605
3606
3607
3608
3609
3610
3611
3612
3613
3614
3615
3616
3617
3618
3619
3620
3621
3622
3623
3624
3625
3626
3627
3628
3629
3630
3631
3632
3633
3634
3635
3636
3637
3638
3639
3640
3641
3642
3643
3644
3645
3646
3647
3648
3649
3650
3651
3652
3653
3654
3655
3656
3657
3658
3659
3660
3661
3662
3663
3664
3665
3666
3667
3668
3669
3670
3671
3672
3673
3674
3675
3676
3677
3678
3679
3680
3681
3682
3683
3684
3685
3686
3687
3688
3689
3690
3691
3692
3693
3694
3695
3696
3697
3698
3699
3700
3701
3702
3703
3704
3705
3706
3707
3708
3709
3710
3711
3712
3713
3714
3715
3716
3717
3718
3719
3720
3721
3722
3723
3724
3725
3726
3727
3728
3729
3730
3731
3732
3733
3734
3735
3736
3737
3738
3739
3740
3741
3742
3743
3744
3745
3746
3747
3748
3749
3750
3751
3752
3753
3754
3755
3756
3757
3758
3759
3760
3761
3762
3763
3764
3765
3766
3767
3768
3769
3770
3771
3772
3773
3774
3775
3776
3777
3778
3779
3780
3781
3782
3783
3784
3785
3786
3787
3788
3789
3790
3791
3792
3793
3794
3795
3796
3797
3798
3799
3800
3801
3802
3803
3804
3805
3806
3807
3808
3809
3810
3811
3812
3813
3814
3815
3816
3817
3818
3819
3820
3821
3822
3823
3824
3825
3826
3827
3828
3829
3830
3831
3832
3833
3834
3835
3836
3837
3838
3839
3840
3841
3842
3843
3844
3845
3846
3847
3848
3849
3850
3851
3852
3853
3854
3855
3856
3857
3858
3859
3860
3861
3862
3863
3864
3865
3866
3867
3868
3869
3870
3871
3872
3873
3874
3875
3876
3877
3878
3879
3880
3881
3882
3883
3884
3885
3886
3887
3888
3889
3890
3891
3892
3893
3894
3895
3896
3897
3898
3899
3900
3901
3902
3903
3904
3905
3906
3907
3908
3909
3910
3911
3912
3913
3914
3915
3916
3917
3918
3919
3920
3921
3922
3923
3924
3925
3926
3927
3928
3929
3930
3931
3932
3933
3934
3935
3936
3937
3938
3939
3940
3941
3942
3943
3944
3945
3946
3947
3948
3949
3950
3951
3952
3953
3954
3955
3956
3957
3958
3959
3960
3961
3962
3963
3964
3965
3966
3967
3968
3969
3970
3971
3972
3973
3974
3975
3976
3977
3978
3979
3980
3981
3982
3983
3984
3985
3986
3987
3988
3989
3990
3991
3992
3993
3994
3995
3996
3997
3998
3999
4000
4001
4002
4003
4004
4005
4006
4007
4008
4009
4010
4011
4012
4013
4014
4015
4016
4017
4018
4019
4020
4021
4022
4023
4024
4025
4026
4027
4028
4029
4030
4031
4032
4033
4034
4035
4036
4037
4038
4039
4040
4041
4042
4043
4044
4045
4046
4047
4048
4049
4050
4051
4052
4053
4054
4055
4056
4057
4058
4059
4060
4061
4062
4063
4064
4065
4066
4067
4068
4069
4070
4071
4072
4073
4074
4075
4076
4077
4078
4079
4080
4081
4082
4083
4084
4085
4086
4087
4088
4089
4090
4091
4092
4093
4094
4095
4096
4097
4098
4099
4100
4101
4102
4103
4104
4105
4106
4107
4108
4109
4110
4111
4112
4113
4114
4115
4116
4117
4118
4119
4120
4121
4122
4123
4124
4125
4126
4127
4128
4129
4130
4131
4132
4133
4134
4135
4136
4137
4138
4139
4140
4141
4142
4143
4144
4145
4146
4147
4148
4149
4150
4151
4152
4153
4154
4155
4156
4157
4158
4159
4160
4161
4162
4163
4164
4165
4166
4167
4168
4169
4170
4171
4172
4173
4174
4175
4176
4177
4178
4179
4180
4181
4182
4183
4184
4185
4186
4187
4188
4189
4190
4191
4192
4193
4194
4195
4196
4197
4198
4199
4200
4201
4202
4203
4204
4205
4206
4207
4208
4209
4210
4211
4212
4213
4214
4215
4216
4217
4218
4219
4220
4221
4222
4223
4224
4225
4226
4227
4228
4229
4230
4231
4232
4233
4234
4235
4236
4237
4238
4239
4240
4241
4242
4243
4244
4245
4246
4247
4248
4249
4250
4251
4252
4253
4254
4255
4256
4257
4258
4259
4260
4261
4262
4263
4264
4265
4266
4267
4268
4269
4270
4271
4272
4273
4274
4275
4276
4277
4278
4279
4280
4281
4282
4283
4284
4285
4286
4287
4288
4289
4290
4291
4292
4293
4294
4295
4296
4297
4298
4299
4300
4301
4302
4303
4304
4305
4306
4307
4308
4309
4310
4311
4312
4313
4314
4315
4316
4317
4318
4319
4320
4321
4322
4323
4324
4325
4326
4327
4328
4329
4330
4331
4332
4333
4334
4335
4336
4337
4338
4339
4340
4341
4342
4343
4344
4345
4346
4347
4348
4349
4350
4351
4352
4353
4354
4355
4356
4357
4358
4359
4360
4361
4362
4363
4364
4365
4366
4367
4368
4369
4370
4371
4372
4373
4374
4375
4376
4377
4378
4379
4380
4381
4382
4383
4384
4385
4386
4387
4388
4389
4390
4391
4392
4393
4394
4395
4396
4397
4398
4399
4400
4401
4402
4403
4404
4405
4406
4407
4408
4409
4410
4411
4412
4413
4414
4415
4416
4417
4418
4419
4420
4421
4422
4423
4424
4425
4426
4427
4428
4429
4430
4431
4432
4433
4434
4435
4436
4437
4438
4439
4440
4441
4442
4443
4444
4445
4446
4447
4448
4449
4450
4451
4452
4453
4454
4455
4456
4457
4458
4459
4460
4461
4462
4463
4464
4465
4466
4467
4468
4469
4470
4471
4472
4473
4474
4475
4476
4477
4478
4479
4480
4481
4482
4483
4484
4485
4486
4487
4488
4489
4490
4491
4492
4493
4494
4495
4496
4497
4498
4499
4500
4501
4502
4503
4504
4505
4506
4507
4508
4509
4510
4511
4512
4513
4514
4515
4516
4517
4518
4519
4520
4521
4522
4523
4524
4525
4526
4527
4528
4529
4530
4531
4532
4533
4534
4535
4536
4537
4538
4539
4540
4541
4542
4543
4544
4545
4546
4547
4548
4549
4550
4551
4552
4553
4554
4555
4556
4557
4558
4559
4560
4561
4562
4563
4564
4565
4566
4567
4568
4569
4570
4571
4572
4573
4574
4575
4576
4577
4578
4579
4580
4581
4582
4583
4584
4585
4586
4587
4588
4589
4590
4591
4592
4593
4594
4595
4596
4597
4598
4599
4600
4601
4602
4603
4604
4605
4606
4607
4608
4609
4610
4611
4612
4613
4614
4615
4616
4617
4618
4619
4620
4621
4622
4623
4624
4625
4626
4627
4628
4629
4630
4631
4632
4633
4634
4635
4636
4637
4638
4639
4640
4641
4642
4643
4644
4645
4646
4647
4648
4649
4650
4651
4652
4653
4654
4655
4656
4657
4658
4659
4660
4661
4662
4663
4664
4665
4666
4667
4668
4669
4670
4671
4672
4673
4674
4675
4676
4677
4678
4679
4680
4681
4682
4683
4684
4685
4686
4687
4688
4689
4690
4691
4692
4693
4694
4695
4696
4697
4698
4699
4700
4701
4702
4703
4704
4705
4706
4707
4708
4709
4710
4711
4712
4713
4714
4715
4716
4717
4718
4719
4720
4721
4722
4723
4724
4725
4726
4727
4728
4729
4730
4731
4732
4733
4734
4735
4736
4737
4738
4739
4740
4741
4742
4743
4744
4745
4746
4747
4748
4749
4750
4751
4752
4753
4754
4755
4756
4757
4758
4759
4760
4761
4762
4763
4764
4765
4766
4767
4768
4769
4770
4771
4772
4773
4774
4775
4776
4777
4778
4779
4780
4781
4782
4783
4784
4785
4786
4787
4788
4789
4790
4791
4792
4793
4794
4795
4796
4797
4798
4799
4800
4801
4802
4803
4804
4805
4806
4807
4808
4809
4810
4811
4812
4813
4814
4815
4816
4817
4818
4819
4820
4821
4822
4823
4824
4825
4826
4827
4828
4829
4830
4831
4832
4833
4834
4835
4836
4837
4838
4839
4840
4841
4842
4843
4844
4845
4846
4847
4848
4849
4850
4851
4852
4853
4854
4855
4856
4857
4858
4859
4860
4861
4862
4863
4864
4865
4866
4867
4868
4869
4870
4871
4872
4873
4874
4875
4876
4877
4878
4879
4880
4881
4882
4883
4884
4885
4886
4887
4888
4889
4890
4891
4892
4893
4894
4895
4896
4897
4898
4899
4900
4901
4902
4903
4904
4905
4906
4907
4908
4909
4910
4911
4912
4913
4914
4915
4916
4917
4918
4919
4920
4921
4922
4923
4924
4925
4926
4927
4928
4929
4930
4931
4932
4933
4934
4935
4936
4937
4938
4939
4940
4941
4942
4943
4944
4945
4946
4947
4948
4949
4950
4951
4952
4953
4954
4955
4956
4957
4958
4959
4960
4961
4962
4963
4964
4965
4966
4967
4968
4969
4970
4971
4972
4973
4974
4975
4976
4977
4978
4979
4980
4981
4982
4983
4984
4985
4986
4987
4988
4989
4990
4991
4992
4993
4994
4995
4996
4997
4998
4999
5000
5001
5002
5003
5004
5005
5006
5007
5008
5009
5010
5011
5012
5013
5014
5015
5016
5017
5018
5019
5020
5021
5022
5023
5024
5025
5026
5027
5028
5029
5030
5031
5032
5033
5034
5035
5036
5037
5038
5039
5040
5041
5042
5043
5044
5045
5046
5047
5048
5049
5050
5051
5052
5053
5054
5055
5056
5057
5058
5059
5060
5061
5062
5063
5064
5065
5066
5067
5068
5069
5070
5071
5072
5073
5074
5075
5076
5077
5078
5079
5080
5081
5082
5083
5084
5085
5086
5087
5088
5089
5090
5091
5092
5093
5094
5095
5096
5097
5098
5099
5100
5101
5102
5103
5104
5105
5106
5107
5108
5109
5110
5111
5112
5113
5114
5115
5116
5117
5118
5119
5120
5121
5122
5123
5124
5125
5126
5127
5128
5129
5130
5131
5132
5133
5134
5135
5136
5137
5138
5139
5140
5141
5142
5143
5144
5145
5146
5147
5148
5149
5150
5151
5152
5153
5154
5155
5156
5157
5158
5159
5160
5161
5162
5163
5164
5165
5166
5167
5168
5169
5170
5171
5172
5173
5174
5175
5176
5177
5178
5179
5180
5181
5182
5183
5184
5185
5186
5187
5188
5189
5190
5191
5192
5193
5194
5195
5196
5197
5198
5199
5200
5201
5202
5203
5204
5205
5206
5207
5208
5209
5210
5211
5212
5213
5214
5215
5216
5217
5218
5219
5220
5221
5222
5223
5224
5225
5226
5227
5228
5229
5230
5231
5232
5233
5234
5235
5236
5237
5238
5239
5240
5241
5242
5243
5244
5245
5246
5247
5248
5249
5250
5251
5252
5253
5254
5255
5256
5257
5258
5259
5260
5261
5262
5263
5264
5265
5266
5267
5268
5269
5270
5271
5272
5273
5274
5275
5276
5277
5278
5279
5280
5281
5282
5283
5284
5285
5286
5287
5288
5289
5290
5291
5292
5293
5294
5295
5296
5297
5298
5299
5300
5301
5302
5303
5304
5305
5306
5307
5308
5309
5310
5311
5312
5313
5314
5315
5316
5317
5318
5319
5320
5321
5322
5323
5324
5325
5326
5327
5328
5329
5330
5331
5332
5333
5334
5335
5336
5337
5338
5339
5340
5341
5342
5343
5344
5345
5346
5347
5348
5349
5350
5351
5352
5353
5354
5355
5356
5357
5358
5359
5360
5361
5362
5363
5364
5365
5366
5367
5368
5369
5370
5371
5372
5373
5374
5375
5376
5377
5378
5379
5380
5381
5382
5383
5384
5385
5386
5387
5388
5389
5390
5391
5392
5393
5394
5395
5396
5397
5398
5399
5400
5401
5402
5403
5404
5405
5406
5407
5408
5409
5410
5411
5412
5413
5414
5415
5416
5417
5418
5419
5420
5421
5422
5423
5424
5425
5426
5427
5428
5429
5430
5431
5432
5433
5434
5435
5436
5437
5438
5439
5440
5441
5442
5443
5444
5445
5446
5447
5448
5449
5450
5451
5452
5453
5454
5455
5456
5457
5458
5459
5460
5461
5462
5463
5464
5465
5466
5467
5468
5469
5470
5471
5472
5473
5474
5475
5476
5477
5478
5479
5480
5481
5482
5483
5484
5485
5486
5487
5488
5489
5490
5491
5492
5493
5494
5495
5496
5497
5498
5499
5500
5501
5502
5503
5504
5505
5506
5507
5508
5509
5510
5511
5512
5513
5514
5515
5516
5517
5518
5519
5520
5521
5522
5523
5524
5525
5526
5527
5528
5529
5530
5531
5532
5533
5534
5535
5536
5537
5538
5539
5540
5541
5542
5543
5544
5545
5546
5547
5548
5549
5550
5551
5552
5553
5554
5555
5556
5557
5558
5559
5560
5561
5562
5563
5564
5565
5566
5567
5568
5569
5570
5571
5572
5573
5574
5575
5576
5577
5578
5579
5580
5581
5582
5583
5584
5585
5586
5587
5588
5589
5590
5591
5592
5593
5594
5595
5596
5597
5598
5599
5600
5601
5602
5603
5604
5605
5606
5607
5608
5609
5610
5611
5612
5613
5614
5615
5616
5617
5618
5619
5620
5621
5622
5623
5624
5625
5626
5627
5628
5629
5630
5631
5632
5633
5634
5635
5636
5637
5638
5639
5640
5641
5642
5643
5644
5645
5646
5647
5648
5649
5650
5651
5652
5653
5654
5655
5656
5657
5658
5659
5660
5661
5662
5663
5664
5665
5666
5667
5668
5669
5670
5671
5672
5673
5674
5675
5676
5677
5678
5679
5680
5681
5682
5683
5684
5685
5686
5687
5688
5689
5690
5691
5692
5693
5694
5695
5696
5697
5698
5699
5700
5701
5702
5703
5704
5705
5706
5707
5708
5709
5710
5711
5712
5713
5714
5715
5716
5717
5718
5719
5720
5721
5722
5723
5724
5725
5726
5727
5728
5729
5730
5731
5732
5733
5734
5735
5736
5737
5738
5739
5740
5741
5742
5743
5744
5745
5746
5747
5748
5749
5750
5751
5752
5753
5754
5755
5756
5757
5758
5759
5760
5761
5762
5763
5764
5765
5766
5767
5768
5769
5770
5771
5772
5773
5774
5775
5776
5777
5778
5779
5780
5781
5782
5783
5784
5785
5786
5787
5788
5789
5790
5791
5792
5793
5794
5795
5796
5797
5798
5799
5800
5801
5802
5803
5804
5805
5806
5807
5808
5809
5810
5811
5812
5813
5814
5815
5816
5817
5818
5819
5820
5821
5822
5823
5824
5825
5826
5827
5828
5829
5830
5831
5832
5833
5834
5835
5836
5837
5838
5839
5840
5841
5842
5843
5844
5845
5846
5847
5848
5849
5850
5851
5852
5853
5854
5855
5856
5857
5858
5859
5860
5861
5862
5863
5864
5865
5866
5867
5868
5869
5870
5871
5872
5873
5874
5875
5876
5877
5878
5879
5880
5881
5882
5883
5884
5885
5886
5887
5888
5889
5890
5891
5892
5893
5894
5895
5896
5897
5898
5899
5900
5901
5902
5903
5904
5905
5906
5907
5908
5909
5910
5911
5912
5913
5914
5915
5916
5917
5918
5919
5920
5921
5922
5923
5924
5925
5926
5927
5928
5929
5930
5931
5932
5933
5934
5935
5936
5937
5938
5939
5940
5941
5942
5943
5944
5945
5946
5947
5948
5949
5950
5951
5952
5953
5954
5955
5956
5957
5958
5959
5960
5961
5962
5963
5964
5965
5966
5967
5968
5969
5970
5971
5972
5973
5974
5975
5976
5977
5978
5979
5980
5981
5982
5983
5984
5985
5986
5987
5988
5989
5990
5991
5992
5993
5994
5995
5996
5997
5998
5999
6000
6001
6002
6003
6004
6005
6006
6007
6008
6009
6010
6011
6012
6013
6014
6015
6016
6017
6018
6019
6020
6021
6022
6023
6024
6025
6026
6027
6028
6029
6030
6031
6032
6033
6034
6035
6036
6037
6038
6039
6040
6041
6042
6043
6044
6045
6046
6047
6048
6049
6050
6051
6052
6053
6054
6055
6056
6057
6058
6059
6060
6061
6062
6063
6064
6065
6066
6067
6068
6069
6070
6071
6072
6073
6074
6075
6076
6077
6078
6079
6080
6081
6082
6083
6084
6085
6086
6087
6088
6089
6090
6091
6092
6093
6094
6095
6096
6097
6098
6099
6100
6101
6102
6103
6104
6105
6106
6107
6108
6109
6110
6111
6112
6113
6114
6115
6116
6117
6118
6119
6120
6121
6122
6123
6124
6125
6126
6127
6128
6129
6130
6131
6132
6133
6134
6135
6136
6137
6138
6139
6140
6141
6142
6143
6144
6145
6146
6147
6148
6149
6150
6151
6152
6153
6154
6155
6156
6157
6158
6159
6160
6161
6162
6163
6164
6165
6166
6167
6168
6169
6170
6171
6172
6173
6174
6175
6176
6177
6178
6179
6180
6181
6182
6183
6184
6185
6186
6187
6188
6189
6190
6191
6192
6193
6194
6195
6196
6197
6198
6199
6200
6201
6202
6203
6204
6205
6206
6207
6208
6209
6210
6211
6212
6213
6214
6215
6216
6217
6218
6219
6220
6221
6222
6223
6224
6225
6226
6227
6228
6229
6230
6231
6232
6233
6234
6235
6236
6237
6238
6239
6240
6241
6242
6243
6244
6245
6246
6247
6248
6249
6250
6251
6252
6253
6254
6255
6256
6257
6258
6259
6260
6261
6262
6263
6264
6265
6266
6267
6268
6269
6270
6271
6272
6273
6274
6275
6276
6277
6278
6279
6280
6281
6282
6283
6284
6285
6286
6287
6288
6289
6290
6291
6292
6293
6294
6295
6296
6297
6298
6299
6300
6301
6302
6303
6304
6305
6306
6307
6308
6309
6310
6311
6312
6313
6314
6315
6316
6317
6318
6319
6320
6321
6322
6323
6324
6325
6326
6327
6328
6329
6330
6331
6332
6333
6334
6335
6336
6337
6338
6339
6340
6341
6342
6343
6344
6345
6346
6347
6348
6349
6350
6351
6352
6353
6354
6355
6356
6357
6358
6359
6360
6361
6362
6363
6364
6365
6366
6367
6368
6369
6370
6371
6372
6373
6374
6375
6376
6377
6378
6379
6380
6381
6382
6383
6384
6385
6386
6387
6388
6389
6390
6391
6392
6393
6394
6395
6396
6397
6398
6399
6400
6401
6402
6403
6404
6405
6406
6407
6408
6409
6410
6411
6412
6413
6414
6415
6416
6417
6418
6419
6420
6421
6422
6423
6424
6425
6426
6427
6428
6429
6430
6431
6432
6433
6434
6435
6436
6437
6438
6439
6440
6441
6442
6443
6444
6445
6446
6447
6448
6449
6450
6451
6452
6453
6454
6455
6456
6457
6458
6459
6460
6461
6462
6463
6464
6465
6466
6467
6468
6469
6470
6471
6472
6473
6474
6475
6476
6477
6478
6479
6480
6481
6482
6483
6484
6485
6486
6487
6488
6489
6490
6491
6492
6493
6494
6495
6496
6497
6498
6499
6500
6501
6502
6503
6504
6505
6506
6507
6508
6509
6510
6511
6512
6513
6514
6515
6516
6517
6518
6519
6520
6521
6522
6523
6524
6525
6526
6527
6528
6529
6530
6531
6532
6533
6534
6535
6536
6537
6538
6539
6540
6541
6542
6543
6544
6545
6546
6547
6548
6549
6550
6551
6552
6553
6554
6555
6556
6557
6558
6559
6560
6561
6562
6563
6564
6565
6566
6567
6568
6569
6570
6571
6572
6573
6574
6575
6576
6577
6578
6579
6580
6581
6582
6583
6584
6585
6586
6587
6588
6589
6590
6591
6592
6593
6594
6595
6596
6597
6598
6599
6600
6601
6602
6603
6604
6605
6606
6607
6608
6609
6610
6611
6612
6613
6614
6615
6616
6617
6618
6619
6620
6621
6622
6623
6624
6625
6626
6627
6628
6629
6630
6631
6632
6633
6634
6635
6636
6637
6638
6639
6640
6641
6642
6643
6644
6645
6646
6647
6648
6649
6650
6651
6652
6653
6654
6655
6656
6657
6658
6659
6660
6661
6662
6663
6664
6665
6666
6667
6668
6669
6670
6671
6672
6673
6674
6675
6676
6677
6678
6679
6680
6681
6682
6683
6684
6685
6686
6687
6688
6689
6690
6691
6692
6693
6694
6695
6696
6697
6698
6699
6700
6701
6702
6703
6704
6705
6706
6707
6708
6709
6710
6711
6712
6713
6714
6715
6716
6717
6718
6719
6720
6721
6722
6723
6724
6725
6726
6727
6728
6729
6730
6731
6732
6733
6734
6735
6736
6737
6738
6739
6740
6741
6742
6743
6744
6745
6746
6747
6748
6749
6750
6751
6752
6753
6754
6755
6756
6757
6758
6759
6760
6761
6762
6763
6764
6765
6766
6767
6768
6769
6770
6771
6772
6773
6774
6775
6776
6777
6778
6779
6780
6781
6782
6783
6784
6785
6786
6787
6788
6789
6790
6791
6792
6793
6794
6795
6796
6797
6798
6799
6800
6801
6802
6803
6804
6805
6806
6807
6808
6809
6810
6811
6812
6813
6814
6815
6816
6817
6818
6819
6820
6821
6822
6823
6824
6825
6826
6827
6828
6829
6830
6831
6832
6833
6834
6835
6836
6837
6838
6839
6840
6841
6842
6843
6844
6845
6846
6847
6848
6849
6850
6851
6852
6853
6854
6855
6856
6857
6858
6859
6860
6861
6862
6863
6864
6865
6866
6867
6868
6869
6870
6871
6872
6873
6874
6875
6876
6877
6878
6879
6880
6881
6882
6883
6884
6885
6886
6887
6888
6889
6890
6891
6892
6893
6894
6895
6896
6897
6898
6899
6900
6901
6902
6903
6904
6905
6906
6907
6908
6909
6910
6911
6912
6913
6914
6915
6916
6917
6918
6919
6920
6921
6922
6923
6924
6925
6926
6927
6928
6929
6930
6931
6932
6933
6934
6935
6936
6937
6938
6939
6940
6941
6942
6943
6944
6945
6946
6947
6948
6949
6950
6951
6952
6953
6954
6955
6956
6957
6958
6959
6960
6961
6962
6963
6964
6965
6966
6967
6968
6969
6970
6971
6972
6973
6974
6975
6976
6977
6978
6979
6980
6981
6982
6983
6984
6985
6986
6987
6988
6989
6990
6991
6992
6993
6994
6995
6996
6997
6998
6999
7000
7001
7002
7003
7004
7005
7006
7007
7008
7009
7010
7011
7012
7013
7014
7015
7016
7017
7018
7019
7020
7021
7022
7023
7024
7025
7026
7027
7028
7029
7030
7031
7032
7033
7034
7035
7036
7037
7038
7039
7040
7041
7042
7043
7044
7045
7046
7047
7048
7049
7050
7051
7052
7053
7054
7055
7056
7057
7058
7059
7060
7061
7062
7063
7064
7065
7066
7067
7068
7069
7070
7071
7072
7073
7074
7075
7076
7077
7078
7079
7080
7081
7082
7083
7084
7085
7086
7087
7088
7089
7090
7091
7092
7093
7094
7095
7096
7097
7098
7099
7100
7101
7102
7103
7104
7105
7106
7107
7108
7109
7110
7111
7112
7113
7114
7115
7116
7117
7118
7119
7120
7121
7122
7123
7124
7125
7126
7127
7128
7129
7130
7131
7132
7133
7134
7135
7136
7137
7138
7139
7140
7141
7142
7143
7144
7145
7146
7147
7148
7149
7150
7151
7152
7153
7154
7155
7156
7157
7158
7159
7160
7161
7162
7163
7164
7165
7166
7167
7168
7169
7170
7171
7172
7173
7174
7175
7176
7177
7178
7179
7180
7181
7182
7183
7184
7185
7186
7187
7188
7189
7190
7191
7192
7193
7194
7195
7196
7197
7198
7199
7200
7201
7202
7203
7204
7205
7206
7207
7208
7209
7210
7211
7212
7213
7214
7215
7216
7217
7218
7219
7220
7221
7222
7223
7224
7225
7226
7227
7228
7229
7230
7231
7232
7233
7234
7235
7236
7237
7238
7239
7240
7241
7242
7243
7244
7245
7246
7247
7248
7249
7250
7251
7252
7253
7254
7255
7256
7257
7258
7259
7260
7261
7262
7263
7264
7265
7266
7267
7268
7269
7270
7271
7272
7273
7274
7275
7276
7277
7278
7279
7280
7281
7282
7283
7284
7285
7286
7287
7288
7289
7290
7291
7292
7293
7294
7295
7296
7297
7298
7299
7300
7301
7302
7303
7304
7305
7306
7307
7308
7309
7310
7311
7312
7313
7314
7315
7316
7317
7318
7319
7320
7321
7322
7323
7324
7325
7326
7327
7328
7329
7330
7331
7332
7333
7334
7335
7336
7337
7338
7339
7340
7341
7342
7343
7344
7345
7346
7347
7348
7349
7350
7351
7352
7353
7354
7355
7356
7357
7358
7359
7360
7361
7362
7363
7364
7365
7366
7367
7368
7369
7370
7371
7372
7373
7374
7375
7376
7377
7378
7379
7380
7381
7382
7383
7384
7385
7386
7387
7388
7389
7390
7391
7392
7393
7394
7395
7396
7397
7398
7399
7400
7401
7402
7403
7404
7405
7406
7407
7408
7409
7410
7411
7412
7413
7414
7415
7416
7417
7418
7419
7420
7421
7422
7423
7424
7425
7426
7427
7428
7429
7430
7431
7432
7433
7434
7435
7436
7437
7438
7439
7440
7441
7442
7443
7444
7445
7446
7447
7448
7449
7450
7451
7452
7453
7454
7455
7456
7457
7458
7459
7460
7461
7462
7463
7464
7465
7466
7467
7468
7469
7470
7471
7472
7473
7474
7475
7476
7477
7478
7479
7480
7481
7482
7483
7484
7485
7486
7487
7488
7489
7490
7491
7492
7493
7494
7495
7496
7497
7498
7499
7500
7501
7502
7503
7504
7505
7506
7507
7508
7509
7510
7511
7512
7513
7514
7515
7516
7517
7518
7519
7520
7521
7522
7523
7524
7525
7526
7527
7528
7529
7530
7531
7532
7533
7534
7535
7536
7537
7538
7539
7540
7541
7542
7543
7544
7545
7546
7547
7548
7549
7550
7551
7552
7553
7554
7555
7556
7557
7558
7559
7560
7561
7562
7563
7564
7565
7566
7567
7568
7569
7570
7571
7572
7573
7574
7575
7576
7577
7578
7579
7580
7581
7582
7583
7584
7585
7586
7587
7588
7589
7590
7591
7592
7593
7594
7595
7596
7597
7598
7599
7600
7601
7602
7603
7604
7605
7606
7607
7608
7609
7610
7611
7612
7613
7614
7615
7616
7617
7618
7619
7620
7621
7622
7623
7624
7625
7626
7627
7628
7629
7630
7631
7632
7633
7634
7635
7636
7637
7638
7639
7640
7641
7642
7643
7644
7645
7646
7647
7648
7649
7650
7651
7652
7653
7654
7655
7656
7657
7658
7659
7660
7661
7662
7663
7664
7665
7666
7667
7668
7669
7670
7671
7672
7673
7674
7675
7676
7677
7678
7679
7680
7681
7682
7683
7684
7685
7686
7687
7688
7689
7690
7691
7692
7693
7694
7695
7696
7697
7698
7699
7700
7701
7702
7703
7704
7705
7706
7707
7708
7709
7710
7711
7712
7713
7714
7715
7716
7717
7718
7719
7720
7721
7722
7723
7724
7725
7726
7727
7728
7729
7730
7731
7732
7733
7734
7735
7736
7737
7738
7739
7740
7741
7742
7743
7744
7745
7746
7747
7748
7749
7750
7751
7752
7753
7754
7755
7756
7757
7758
7759
7760
7761
7762
7763
7764
7765
7766
7767
7768
7769
7770
7771
7772
7773
7774
7775
7776
7777
7778
7779
7780
7781
7782
7783
7784
7785
7786
7787
7788
7789
7790
7791
7792
7793
7794
7795
7796
7797
7798
7799
7800
7801
7802
7803
7804
7805
7806
7807
7808
7809
7810
7811
7812
7813
7814
7815
7816
7817
7818
7819
7820
7821
7822
7823
7824
7825
7826
7827
7828
7829
7830
7831
7832
7833
7834
7835
7836
7837
7838
7839
7840
7841
7842
7843
7844
7845
7846
7847
7848
7849
7850
7851
7852
7853
7854
7855
7856
7857
7858
7859
7860
7861
7862
7863
7864
7865
7866
7867
7868
7869
7870
7871
7872
7873
7874
7875
7876
7877
7878
7879
7880
7881
7882
7883
7884
7885
7886
7887
7888
7889
7890
7891
7892
7893
7894
7895
7896
7897
7898
7899
7900
7901
7902
7903
7904
7905
7906
7907
7908
7909
7910
7911
7912
7913
7914
7915
7916
7917
7918
7919
7920
7921
7922
7923
7924
7925
7926
7927
7928
7929
7930
7931
7932
7933
7934
7935
7936
7937
7938
7939
7940
7941
7942
7943
7944
7945
7946
7947
7948
7949
7950
7951
7952
7953
7954
7955
7956
7957
7958
7959
7960
7961
7962
7963
7964
7965
7966
7967
7968
7969
7970
7971
7972
7973
7974
7975
7976
7977
7978
7979
7980
7981
7982
7983
7984
7985
7986
7987
7988
7989
7990
7991
7992
7993
7994
7995
7996
7997
7998
7999
8000
8001
8002
8003
8004
8005
8006
8007
8008
8009
8010
8011
8012
8013
8014
8015
8016
8017
8018
8019
8020
8021
8022
8023
8024
8025
8026
8027
8028
8029
8030
8031
8032
8033
8034
8035
8036
8037
8038
8039
8040
8041
8042
8043
8044
8045
8046
8047
8048
8049
8050
8051
8052
8053
8054
8055
8056
8057
8058
8059
8060
8061
8062
8063
8064
8065
8066
8067
8068
8069
8070
8071
8072
8073
8074
8075
8076
8077
8078
8079
8080
8081
8082
8083
8084
8085
8086
8087
8088
8089
8090
8091
8092
8093
8094
8095
8096
8097
8098
8099
8100
8101
8102
8103
8104
8105
8106
8107
8108
8109
8110
8111
8112
8113
8114
8115
8116
8117
8118
8119
8120
8121
8122
8123
8124
8125
8126
8127
8128
8129
8130
8131
8132
8133
8134
8135
8136
8137
8138
8139
8140
8141
8142
8143
8144
8145
8146
8147
8148
8149
8150
8151
8152
8153
8154
8155
8156
8157
8158
8159
8160
8161
8162
8163
8164
8165
8166
8167
8168
8169
8170
8171
8172
8173
8174
8175
8176
8177
8178
8179
8180
8181
8182
8183
8184
8185
8186
8187
8188
8189
8190
8191
8192
8193
8194
8195
8196
8197
8198
8199
8200
8201
8202
8203
8204
8205
8206
8207
8208
8209
8210
8211
8212
8213
8214
8215
8216
8217
8218
8219
8220
8221
8222
8223
8224
8225
8226
8227
8228
8229
8230
8231
8232
8233
8234
8235
8236
8237
8238
8239
8240
8241
8242
8243
8244
8245
8246
8247
8248
8249
8250
8251
8252
8253
8254
8255
8256
8257
8258
8259
8260
8261
8262
8263
8264
8265
8266
8267
8268
8269
8270
8271
8272
8273
8274
8275
8276
8277
8278
8279
8280
8281
8282
8283
8284
8285
8286
8287
8288
8289
8290
8291
8292
8293
8294
8295
8296
8297
8298
8299
8300
8301
8302
8303
8304
8305
8306
8307
8308
8309
8310
8311
8312
8313
8314
8315
8316
8317
8318
8319
8320
8321
8322
8323
8324
8325
8326
8327
8328
8329
8330
8331
8332
8333
8334
8335
8336
8337
8338
8339
8340
8341
8342
8343
8344
8345
8346
8347
8348
8349
8350
8351
8352
8353
8354
8355
8356
8357
8358
8359
8360
8361
8362
8363
8364
8365
8366
8367
8368
8369
8370
8371
8372
8373
8374
8375
8376
8377
8378
8379
8380
8381
8382
8383
8384
8385
8386
8387
8388
8389
8390
8391
8392
8393
8394
8395
8396
8397
8398
8399
8400
8401
8402
8403
8404
8405
8406
8407
8408
8409
8410
8411
8412
8413
8414
8415
8416
8417
8418
8419
8420
8421
8422
8423
8424
8425
8426
8427
8428
8429
8430
8431
8432
8433
8434
8435
8436
8437
8438
8439
8440
8441
8442
8443
8444
8445
8446
8447
8448
8449
8450
8451
8452
8453
8454
8455
8456
8457
8458
8459
8460
8461
8462
8463
8464
8465
8466
8467
8468
8469
8470
8471
8472
8473
8474
8475
8476
8477
8478
8479
8480
8481
8482
8483
8484
8485
8486
8487
8488
8489
8490
8491
8492
8493
8494
8495
8496
8497
8498
8499
8500
8501
8502
8503
8504
8505
8506
8507
8508
8509
8510
8511
8512
8513
8514
8515
8516
8517
8518
8519
8520
8521
8522
8523
8524
8525
8526
8527
8528
8529
8530
8531
8532
8533
8534
8535
8536
8537
8538
8539
8540
8541
8542
8543
8544
8545
8546
8547
8548
8549
8550
8551
8552
8553
8554
8555
8556
8557
8558
8559
8560
8561
8562
8563
8564
8565
8566
8567
8568
8569
8570
8571
8572
8573
8574
8575
8576
8577
8578
8579
8580
8581
8582
8583
8584
8585
8586
8587
8588
8589
8590
8591
8592
8593
8594
8595
8596
8597
8598
8599
8600
8601
8602
8603
8604
8605
8606
8607
8608
8609
8610
8611
8612
8613
8614
8615
8616
8617
8618
8619
8620
8621
8622
8623
8624
8625
8626
8627
8628
8629
8630
8631
8632
8633
8634
8635
8636
8637
8638
8639
8640
8641
8642
8643
8644
8645
8646
8647
8648
8649
8650
8651
8652
8653
8654
8655
8656
8657
8658
8659
8660
8661
8662
8663
8664
8665
8666
8667
8668
8669
8670
8671
8672
8673
8674
8675
8676
8677
8678
8679
8680
8681
8682
8683
8684
8685
8686
8687
8688
8689
8690
8691
8692
8693
8694
8695
8696
8697
8698
8699
8700
8701
8702
8703
8704
8705
8706
8707
8708
8709
8710
8711
8712
8713
8714
8715
8716
8717
8718
8719
8720
8721
8722
8723
8724
8725
8726
8727
8728
8729
8730
8731
8732
8733
8734
8735
8736
8737
8738
8739
8740
8741
8742
8743
8744
8745
8746
8747
8748
8749
8750
8751
8752
8753
8754
8755
8756
8757
8758
8759
8760
8761
8762
8763
8764
8765
8766
8767
8768
8769
8770
8771
8772
8773
8774
8775
8776
8777
8778
8779
8780
8781
8782
8783
8784
8785
8786
8787
8788
8789
8790
8791
8792
8793
8794
8795
8796
8797
8798
8799
8800
8801
8802
8803
8804
8805
8806
8807
8808
8809
8810
8811
8812
8813
8814
8815
8816
8817
8818
8819
8820
8821
8822
8823
8824
8825
8826
8827
8828
8829
8830
8831
8832
8833
8834
8835
8836
8837
8838
8839
8840
8841
8842
8843
8844
8845
8846
8847
8848
8849
8850
8851
8852
8853
8854
8855
8856
8857
8858
8859
8860
8861
8862
8863
8864
8865
8866
8867
8868
8869
8870
8871
8872
8873
8874
8875
8876
8877
8878
8879
8880
8881
8882
8883
8884
8885
8886
8887
8888
8889
8890
8891
8892
8893
8894
8895
8896
8897
8898
8899
8900
8901
8902
8903
8904
8905
8906
8907
8908
8909
8910
8911
8912
8913
8914
8915
8916
8917
8918
8919
8920
8921
8922
8923
8924
8925
8926
8927
8928
8929
8930
8931
8932
8933
8934
8935
8936
8937
8938
8939
8940
8941
8942
8943
8944
8945
8946
8947
8948
8949
8950
8951
8952
8953
8954
8955
8956
8957
8958
8959
8960
8961
8962
8963
8964
8965
8966
8967
8968
8969
8970
8971
8972
8973
8974
8975
8976
8977
8978
8979
8980
8981
8982
8983
8984
8985
8986
8987
8988
8989
8990
8991
8992
8993
8994
8995
8996
8997
8998
8999
9000
9001
9002
9003
9004
9005
9006
9007
9008
9009
9010
9011
9012
9013
9014
9015
9016
9017
9018
9019
9020
9021
9022
9023
9024
9025
9026
9027
9028
9029
9030
9031
9032
9033
9034
9035
9036
9037
9038
9039
9040
9041
9042
9043
9044
9045
9046
9047
9048
9049
9050
9051
9052
9053
9054
9055
9056
9057
9058
9059
9060
9061
9062
9063
9064
9065
9066
9067
9068
9069
9070
9071
9072
9073
9074
9075
9076
9077
9078
9079
9080
9081
9082
9083
9084
9085
9086
9087
9088
9089
9090
9091
9092
9093
9094
9095
9096
9097
9098
9099
9100
9101
9102
9103
9104
9105
9106
9107
9108
9109
9110
9111
9112
9113
9114
9115
9116
9117
9118
9119
9120
9121
9122
9123
9124
9125
9126
9127
9128
9129
9130
9131
9132
9133
9134
9135
9136
9137
9138
9139
9140
9141
9142
9143
9144
9145
9146
9147
9148
9149
9150
9151
9152
9153
9154
9155
9156
9157
9158
9159
9160
9161
9162
9163
9164
9165
9166
9167
9168
9169
9170
9171
9172
9173
9174
9175
9176
9177
9178
9179
9180
9181
9182
9183
9184
9185
9186
9187
9188
9189
9190
9191
9192
9193
9194
9195
9196
9197
9198
9199
9200
9201
9202
9203
9204
9205
9206
9207
9208
9209
9210
9211
9212
9213
9214
9215
9216
9217
9218
9219
9220
9221
9222
9223
9224
9225
9226
9227
9228
9229
9230
9231
9232
9233
9234
9235
9236
9237
9238
9239
9240
9241
9242
9243
9244
9245
9246
9247
9248
9249
9250
9251
9252
9253
9254
9255
9256
9257
9258
9259
9260
9261
9262
9263
9264
9265
9266
9267
9268
9269
9270
9271
9272
9273
9274
9275
9276
9277
9278
9279
9280
9281
9282
9283
9284
9285
9286
9287
9288
9289
9290
9291
9292
9293
9294
9295
9296
9297
9298
9299
9300
9301
9302
9303
9304
9305
9306
9307
9308
9309
9310
9311
9312
9313
9314
9315
9316
9317
9318
9319
9320
9321
9322
9323
9324
9325
9326
9327
9328
9329
9330
9331
9332
9333
9334
9335
9336
9337
9338
9339
9340
9341
9342
9343
9344
9345
9346
9347
9348
9349
9350
9351
9352
9353
9354
9355
9356
9357
9358
9359
9360
9361
9362
9363
9364
9365
9366
9367
9368
9369
9370
9371
9372
9373
9374
9375
9376
9377
9378
9379
9380
9381
9382
9383
9384
9385
9386
9387
9388
9389
9390
9391
9392
9393
9394
9395
9396
9397
9398
9399
9400
9401
9402
9403
9404
9405
9406
9407
9408
9409
9410
9411
9412
9413
9414
9415
9416
9417
9418
9419
9420
9421
9422
9423
9424
9425
9426
9427
9428
9429
9430
9431
9432
9433
9434
9435
9436
9437
9438
9439
9440
9441
9442
9443
9444
9445
9446
9447
9448
9449
9450
9451
9452
9453
9454
9455
9456
9457
9458
9459
9460
9461
9462
9463
9464
9465
9466
9467
9468
9469
9470
9471
9472
9473
9474
9475
9476
9477
9478
9479
9480
9481
9482
9483
9484
9485
9486
9487
9488
9489
9490
9491
9492
9493
9494
9495
9496
9497
9498
9499
9500
9501
9502
9503
9504
9505
9506
9507
9508
9509
9510
9511
9512
9513
9514
9515
9516
9517
9518
9519
9520
9521
9522
9523
9524
9525
9526
9527
9528
9529
9530
9531
9532
9533
9534
9535
9536
9537
9538
9539
9540
9541
9542
9543
9544
9545
9546
9547
9548
9549
9550
9551
9552
9553
9554
9555
9556
9557
9558
9559
9560
9561
9562
9563
9564
9565
9566
9567
9568
9569
9570
9571
9572
9573
9574
9575
9576
9577
9578
9579
9580
9581
9582
9583
9584
9585
9586
9587
9588
9589
9590
9591
9592
9593
9594
9595
9596
9597
9598
9599
9600
9601
9602
9603
9604
9605
9606
9607
9608
9609
9610
9611
9612
9613
9614
9615
9616
9617
9618
9619
9620
9621
9622
9623
9624
9625
9626
9627
9628
9629
9630
9631
9632
9633
9634
9635
9636
9637
9638
9639
9640
9641
9642
9643
9644
9645
9646
9647
9648
9649
9650
9651
9652
9653
9654
9655
9656
9657
9658
9659
9660
9661
9662
9663
9664
9665
9666
9667
9668
9669
9670
9671
9672
9673
9674
9675
9676
9677
9678
9679
9680
9681
9682
9683
9684
9685
9686
9687
9688
9689
9690
9691
9692
9693
9694
9695
9696
9697
9698
9699
9700
9701
9702
9703
9704
9705
9706
9707
9708
9709
9710
9711
9712
9713
9714
9715
9716
9717
9718
9719
9720
9721
9722
9723
9724
9725
9726
9727
9728
9729
9730
9731
9732
9733
9734
9735
9736
9737
9738
9739
9740
9741
9742
9743
9744
9745
9746
9747
9748
9749
9750
9751
9752
9753
9754
9755
9756
9757
9758
9759
9760
9761
9762
9763
9764
9765
9766
9767
9768
9769
9770
9771
9772
9773
9774
9775
9776
9777
9778
9779
9780
9781
9782
9783
9784
9785
9786
9787
9788
9789
9790
9791
9792
9793
9794
9795
9796
9797
9798
9799
9800
9801
9802
9803
9804
9805
9806
9807
9808
9809
9810
9811
9812
9813
9814
9815
9816
9817
9818
9819
9820
9821
9822
9823
9824
9825
9826
9827
9828
9829
9830
9831
9832
9833
9834
9835
9836
9837
9838
9839
9840
9841
9842
9843
9844
9845
9846
9847
9848
9849
9850
9851
9852
9853
9854
9855
9856
9857
9858
9859
9860
9861
9862
9863
9864
9865
9866
9867
9868
9869
9870
9871
9872
9873
9874
9875
9876
9877
9878
9879
9880
9881
9882
9883
9884
9885
9886
9887
9888
9889
9890
9891
9892
9893
9894
9895
9896
9897
9898
9899
9900
9901
9902
9903
9904
9905
9906
9907
9908
9909
9910
9911
9912
9913
9914
9915
9916
9917
9918
9919
9920
9921
9922
9923
9924
9925
9926
9927
9928
9929
9930
9931
9932
9933
9934
9935
9936
9937
9938
9939
9940
9941
9942
9943
9944
9945
9946
9947
9948
9949
9950
9951
9952
9953
9954
9955
9956
9957
9958
9959
9960
9961
9962
9963
9964
9965
9966
9967
9968
9969
9970
9971
9972
9973
9974
9975
9976
9977
9978
9979
9980
9981
9982
9983
9984
9985
9986
9987
9988
9989
9990
9991
9992
9993
9994
9995
9996
9997
9998
9999
10000
10001
10002
10003
10004
10005
10006
10007
10008
10009
10010
10011
10012
10013
10014
10015
10016
10017
10018
10019
10020
10021
10022
10023
10024
10025
10026
10027
10028
10029
10030
10031
10032
10033
10034
10035
10036
10037
10038
10039
10040
10041
10042
10043
10044
10045
10046
10047
10048
10049
10050
10051
10052
10053
10054
10055
10056
10057
10058
10059
10060
10061
10062
10063
10064
10065
10066
10067
10068
10069
10070
10071
10072
10073
10074
10075
10076
10077
10078
10079
10080
10081
10082
10083
10084
10085
10086
10087
10088
10089
10090
10091
10092
10093
10094
10095
10096
10097
10098
10099
10100
10101
10102
10103
10104
10105
10106
10107
10108
10109
10110
10111
10112
10113
10114
10115
10116
10117
10118
10119
10120
10121
10122
10123
10124
10125
10126
10127
10128
10129
10130
10131
10132
10133
10134
10135
10136
10137
10138
10139
10140
10141
10142
10143
10144
10145
10146
10147
10148
10149
10150
10151
10152
10153
10154
10155
10156
10157
10158
10159
10160
10161
10162
10163
10164
10165
10166
10167
10168
10169
10170
10171
10172
10173
10174
10175
10176
10177
10178
10179
10180
10181
10182
10183
10184
10185
10186
10187
10188
10189
10190
10191
10192
10193
10194
10195
10196
10197
10198
10199
10200
10201
10202
10203
10204
10205
10206
10207
10208
10209
10210
10211
10212
10213
10214
10215
10216
10217
10218
10219
10220
10221
10222
10223
10224
10225
10226
10227
10228
10229
10230
10231
10232
10233
10234
10235
10236
10237
10238
10239
10240
10241
10242
10243
10244
10245
10246
10247
10248
10249
10250
10251
10252
10253
10254
10255
10256
10257
10258
10259
10260
10261
10262
10263
10264
10265
10266
10267
10268
10269
10270
10271
10272
10273
10274
10275
10276
10277
10278
10279
10280
10281
10282
10283
10284
10285
10286
10287
10288
10289
10290
10291
10292
10293
10294
10295
10296
10297
10298
10299
10300
10301
10302
10303
10304
10305
10306
10307
10308
10309
10310
10311
10312
10313
10314
10315
10316
10317
10318
10319
10320
10321
10322
10323
10324
10325
10326
10327
10328
10329
10330
10331
10332
10333
10334
10335
10336
10337
10338
10339
10340
10341
10342
10343
10344
10345
10346
10347
10348
10349
10350
10351
10352
10353
10354
10355
10356
10357
10358
10359
10360
10361
10362
10363
10364
10365
10366
10367
10368
10369
10370
10371
10372
10373
10374
10375
10376
10377
10378
10379
10380
10381
10382
10383
10384
10385
10386
10387
10388
10389
10390
10391
10392
10393
10394
10395
10396
10397
10398
10399
10400
10401
10402
10403
10404
10405
10406
10407
10408
10409
10410
10411
10412
10413
10414
10415
10416
10417
10418
10419
10420
10421
10422
10423
10424
10425
|
\documentclass[12pt,a4paper,twoside]{report}
\usepackage{typebook}
\begin{document}
\title{Formatting information}
\subtitle{A beginner's introduction to typesetting with
\LaTeX{}}
\author{Peter Flynn}
\date{v.3.6 March 2005}
\legal{%
This document is Copyright © 1999\ndash{}2005 by
Silmaril Consultants under the terms of what is now the GNU
Free Documentation License (copyleft).
Permission is granted to copy, distribute and/or modify
this document under the terms of the GNU Free Documentation
License, Version 1.2 or any later version published by the
Free Software Foundation; with no Invariant Sections, no
Front-Cover Texts, and no Back-Cover Texts. A copy of the
license is included in the section entitled \titlecite{gnufdl}.
You are allowed to distribute, reproduce, and modify it
without fee or further requirement for consent subject to the
conditions in \S\thinspace\ref{gfdl-4}. The author has
asserted his right to be identified as the author of this
document. If you make useful modifications you are asked to
inform the author so that the master copy can be updated. See
the full text of the License in Appendix~\ref{gfdl}.
}\maketitle
\subsubsection*{Acknowledgments}
This edition of \textsl{Formatting
Information} was prompted by the generous help I
have received from \TeX{} users too numerous to mention
individually. Shortly after TUGboat published the November
2003 edition, I was reminded by a spate of email of the
fragility of documentation for a system like \LaTeX{} which is
constantly under development. There have been revisions to
packages; issues of new distributions, new tools, and new
interfaces; new books and other new documents; corrections to
my own errors; suggestions for rewording; and in one or two
cases mild abuse for having omitted package X which the author
felt to be indispensable to users.\par
I am grateful as always to the people who sent me
corrections and suggestions for improvement. Please keep them
coming: only this way can this booklet reflect what people
want to learn. The same limitation still applies, however: no
mathematics, as there are already a dozen or more excellent
books on the market\mdash{}as well as other online
documents\mdash{}dealing with mathematical typesetting in
\TeX{} and \LaTeX{} in finer and better detail than I am
capable of.\par
The structure remains the same, but I have revised and
rephrased a lot of material, especially in the earlier
chapters where a new user cannot be expected yet to have
acquired any depth of knowledge. Many of the screenshots have
been updated, and most of the examples and code fragments have
been retested.\par
As I was finishing this edition, I was asked to review
an article for \titlecite{practex}, which
grew out of the Practical \TeX{} Conference in 2004. The
author specifically took the writers of documentation to task
for failing to explain things more clearly, and as I read
more, I found myself agreeing, and resolving to clear up some
specific problems areas as far as possible. It is very
difficult for people who write technical documentation to
remember how they struggled to learn what has now become a
familiar system. So much of what we do is second nature, and a
lot of it actually has nothing to do with the software, but
more with the way in which we view and approach information,
and the general level of knowledge of computing. If I have
obscured something by making unreasonable assumptions about
\emph{your} knowledge, please let me know so
that I can correct it.\par
\par\vspace*{2pc}\noindent\ignorespaces
Peter Flynn is author of \titleof{htmlbook} and \titleof{sgmltools}, and editor of \titleof{xmlfaq}.
\par\vfill
\subsubsection*{Technical~note}
The text is written and
maintained in DocBook with a customization layer for
typographics. XSLT\index{XSLT@XSLT} is used to generate
HTML\index{HTML@HTML} (for the Web and plain-text
versions) and \LaTeX{} (for PDF\index{PDF@PDF} and
PostScript\index{PostScript}). The November 2003 edition
was published in \titlecite{tugboat}. This edition contains extensive
revisions and simplifications to the text, and many corrections
to the way in which the packages and their capabilities are
presented.\par\vfill
\renewcommand{\contentsname}{Contents}
\tableofcontents
\listofexercises
\listoftables
\prelim{Introduction}\label{intro}
This book originally accompanied a 2-day course on using the
\LaTeX{} typesetting system. It has been extensively revised and
updated and can now be used for self-study or in the classroom.
It is aimed at users of Linux, Macintosh, or Microsoft Windows
but it can be used with \LaTeX{} systems on any platform,
including other Unix workstations, mainframes, and even your
Personal Digital Assistant (PDA)\index{PDA@PDA|textbf}\index{Acronyms@\textbf{Acronyms}, defined!PDA@PDA|textbf}.
\subsection*{Who needs this book?}\addcontentsline{toc}{subsection}{Who needs this book?}
The audience for the original training course was assumed
to be computer-literate and composed of professional,
business, academic, technical, or administrative computer
users. The readers of the book (you) are mostly assumed to be
in a similar position, but may also come from many other
backgrounds, including hobbyists, students, and just people
interested in quality typesetting. You are expected to have
one or more of the following or similar objectives:
\begin{itemize}
\item
producing typesetter-quality formatting;
\item
formatting long, complex, highly-structured,
repetitive, or automatically-generated
documents;\footnote{\LaTeX{} can easily be used for once-off or short
and simple documents as well, but its real strengths
lie in consistency and automation.}
\item
saving time and effort by automating common
tasks;
\item
achieving or maintaining your independence from
specific makes or models of proprietary hardware,
software, or file formats (portability);
\item
using Open Source software (free of restrictions,
sometimes also free of charge).
\end{itemize}
\subsection*{Skills needed}\addcontentsline{toc}{subsection}{Skills needed}
\LaTeX{} is a very easy system to learn, and requires no
specialist knowledge, although literacy and some familiarity
with the publishing process is useful. It is, however, assumed
that you are completely fluent and familiar with using your
computer before you start. Specifically, effective use of this
document requires that you already know and understand the
following very thoroughly:
\begin{itemize}
\item
how to use a good plain-text
editor (\emph{not} a wordprocessor like
\product{OpenOffice},
\product{WordPerfect}, or Microsoft
\product{Word}, and
\emph{not} a toy like Microsoft
\product{Notepad});\marginal{
2.1.3
}
\item
where to find all 95 of the printable ASCII\index{ASCII@ASCII} characters on your keyboard and
what they mean, and how to type accents and symbols, if
you use them;\marginal{
3.2.1.2
}
\item
how to create, open, save,
close, rename, move, and delete files and folders
(directories);\marginal{
2.3
}
\item
how to use a Web browser and/or File
Transfer Protocol (FTP)\index{FTP@FTP|textbf}\index{Acronyms@\textbf{Acronyms}, defined!FTP@FTP|textbf} program to
download and save files from the Internet;\marginal{
7.3.1.6
}
\item
how to uncompress and unwrap (unzip or detar)
downloaded files.\marginal{
2.3.7
}
\end{itemize}
If you don't know how to do
these things yet, it's important to go and learn them
first. Trying to become familiar with the fundamentals of
using a computer \emph{at the same time} as
learning \LaTeX{} is not likely to be as effective as doing
them in order.
These are not specialist
skills\mdash{}they are all included in the European Computer Driving
Licence (ECDL)\index{ECDL@ECDL|textbf}\index{Acronyms@\textbf{Acronyms}, defined!ECDL@ECDL|textbf} and the relevant sections of the ECDL\index{ECDL@ECDL} syllabus are noted in the margin
above, so they are well within the capability of anyone who
uses a computer.
\subsection*{Objectives of this book}\addcontentsline{toc}{subsection}{Objectives of this book}
By the end of this book, you should be able to undertake
the following tasks:
\begin{itemize}
\item
use a plain-text editor to create and maintain your
documents;
\item
add \LaTeX{} markup to identify
your document structure and formatting
requirements;
\item
typeset \LaTeX{} documents, correct simple formatting
errors, and display or print the results;
\item
identify, install, and use additional packages (using
CTAN\index{CTAN@CTAN} for downloading where
necessary);
\item
recognise the limitations of procedural markup systems
and choose appropriate generic markup methods where
appropriate.
\end{itemize}
\subsection*{Synopsis}\addcontentsline{toc}{subsection}{Synopsis}
The original course covered the following topics as
separate sessions, which are represented in the book as
chapters:
\begin{enumerate}\item
Where to get and how to install
\LaTeX{} (\product{te\TeX{}},
\product{fp\TeX{}}, or
\product{pro\TeX{}t} from the
\TeX{} Collection disks);\index{texlive@ Live}\index{texcollection@ Collection}
\item
How to type \LaTeX{} documents:
using an editor to create files
(\product{WinShell},
\product{WinEdt},
\product{\TeX{}nicCenter}, or
\product{Emacs});
\item
Basic structures (the Document Class Declaration and
its layout options; the document environment with sections
and paragraphs);
\item
Typesetting, viewing, and printing;
\item
The use of packages and CTAN\index{CTAN@CTAN}
to adapt formatting using standard tools;
\item
Other document structures (lists, tables, figures,
images, and verbatim text);
\item
Textual tools (footnotes, marginal notes,
cross-references, indexes and glossaries, and
bibliographic citations);
\item
Typographic considerations (white-space and typefaces;
inline markup and font changes; extra font installation
and automation);
\item
Programmability and automation (macros and modifying
\LaTeX{}'s behaviour);
\item
Conversion and compatibility with other systems
(XML\index{XML@XML},
\product{Word}, etc.).
\end{enumerate}
A few changes have been made in the transition to printed
and online form, but the basic structure is the same, and the
document functions as a workbook for the course as well as a
standalone self-teaching guide.
\subsection*{Where's the math?}\addcontentsline{toc}{subsection}{Where's the math?}
It is important to note that
the document \emph{does not cover} mathematical
typesetting, complex tabular material, the design of
large-scale macros and document classes, or the finer points
of typography or typographic design, although it does refer to
these topics in passing on a few occasions.
\index{mathematics}
There are several other guides, introductions, and
`get-started' documents on the Web and
on CTAN\index{CTAN@CTAN} which cover these topics and
more. Among the more popular are:
\begin{itemize}
\item
\titlecite{begin}, where all
beginners should start;
\item
\titlecite{lshort} is a good
beginner's tutorial;
\item
\titlecite{gentle} is a classic
tutorial on Plain \TeX{};
\item
\titlecite{imported} shows you how
to do (almost) anything with graphics: side-by-side,
rotated, etc.;
\item
\titlecite{mathguide} gets you
started with the American Math Society's powerful
packages;
\item
\titlecite{symbol-list} shows over
2,500 symbols available.
\end{itemize}
This list was taken from the
CTAN\index{CTAN@CTAN} search page. There are also
lots of books published about \TeX{} and \LaTeX{}: the most
important of these for users of this document are listed in
the last paragraph of the Foreword on p.\thinspace\pageref{docs}.
\subsection*{Availability of \LaTeX{} systems}\addcontentsline{toc}{subsection}{Availability of \LaTeX{} systems}\label{availability}
Because the \TeX{} program (the
`engine' which actually does the
typesetting) is separate from whichever editor you choose,
\TeX{}-based systems are available in a variety of different
modes using different interfaces, depending on how you want to
use them.
\subsubsection*{Graphical interface}\addcontentsline{toc}{subsubsection}{Graphical interface}\label{gui}
The normal way to run \LaTeX{} is
to use a toolbar button (icon), a menu item, or a keystroke
in your editor. Click on it and your document gets saved and
typeset. All the other features of \LaTeX{} systems (the
typeset display, spellchecker, related programs like
\product{makeindex} and \BibTeX{}) are run
the same way. This works both in a normal Graphical User Interface (GUI)\index{GUI@GUI|textbf}\index{Acronyms@\textbf{Acronyms}, defined!GUI@GUI|textbf} as well as in
text-only interfaces.
In the popular \LaTeX{} editors like
\product{Emacs},
\product{\TeX{}shell},
\product{\TeX{}nicCenter},
\product{WinShell}, or
\product{WinEdt}, a record of the
typesetting process is shown in an adjoining window so that
you can see the progress of pages being typeset, and any
errors or warnings that may occur.\footnote{Recent versions of some editors hide this display by
default unless errors occur in the typesetting.}
\subsubsection*{Command-line interface}\addcontentsline{toc}{subsubsection}{Command-line interface}\label{cli}
However, the graphical interface
is useless if you want to run \LaTeX{} unattended, as part of an
automated system, perhaps in a web server or e-commerce
environment, where there is no direct connection between
user and program. The underlying \TeX{} engine does in fact
have a Command-Line Interface (CLI)\index{CLI@CLI|textbf}\index{Acronyms@\textbf{Acronyms}, defined!CLI@CLI|textbf},
that is, it can be used as a
`console' program which you run from
a standard Unix or Mac terminal or shell window (or from an
MS-DOS command window in Microsoft Windows systems) by
typing the command
\verb+latex+ followed by the name of your
document file (see Figure~\ref{clidemo} in \S\thinspace\ref{cmdwin} for an example).
Commands like these let you run \LaTeX{} in an automated
environment like a
Common Gateway Interface (CGI)\index{CGI@CGI|textbf}\index{Acronyms@\textbf{Acronyms}, defined!CGI@CGI|textbf} script
on a web server or a batch file on a document system. All
the popular distributions for Unix and Windows, both free
and commercial, include this interface as standard
(te\TeX{}, fp\TeX{}, MiK\TeX{}, pro\TeX{}t,
PC-\TeX{}, True\TeX{},
etc.).
\subsubsection*{Typeset displays}\addcontentsline{toc}{subsubsection}{Typeset displays}\label{displays}
\LaTeX{} usually displays your
typeset results in a separate window, redisplayed
automatically every time the document is reprocessed,
because the typesetting is done separately from the editing.
Some systems, however, can format the typesetting while you
type, at the expense of some flexibility.
\begin{description}
\item[\sffamily Asynchronous typographic displays]\label{async}
This method is called an \textbf{\textit{asynchronous typographic
display}}\label{asynchronous}\index{asynchronous typographic
display@\textbf{\textit{asynchronous typographic
display}}} because the typeset window only
updates \emph{after} you have typed
something and reprocessed it, not
\emph{while} you are still typing, as it
would with a wordprocessor.\footnote{Among other reasons, \TeX{} typesets whole
paragraphs at a time, not line-by-line as lesser
systems do, in order to get the hyphenation and
justification (H\amp J) right (see \S\thinspace\ref{handj}).
}
\item[\sffamily Synchronous typographic displays]\label{sync}
\label{synchro}%
Some distributions of \LaTeX{}
offer a \textbf{\textit{synchronous
typographic interface}}\label{synchronous}\index{synchronous
typographic interface@\textbf{\textit{synchronous
typographic interface}}}. In these, you type
directly into the typographic display, as with a
wordprocessor. Three popular examples are
\product{Textures},
\product{Scientific Word}, and
\product{V\TeX{}} (see table below).
At least one free version (\LyX{}, see Figure~\ref{lyxwin} in \S\thinspace\ref{editors})
offers a similar interface.
With a synchronous display
you get Instant Textual Gratification\texttrademark{}, but your
level of control is restricted to that of the GUI\index{GUI@GUI} you use, which cannot provide
access to everything that \LaTeX{} can do. For
complete control of the formatting
you may still need access to your normal source
(input) file in the same way as for asynchronous
implementations.
\item[\sffamily Near-synchronous displays]
There are several other
methods available free for Unix and some other systems
for close-to-synchronous updates of the typeset
display (including \person{Jonathan Fine}'s \product{Instant
Preview} and the \TeX{} daemon), and
for embedding typographic fragments from the typeset
display back into the editor window (\person{David Kastrup}'s \package{preview-latex}
package).
\end{description}
\subsubsection*{Commercial distributions}\addcontentsline{toc}{subsubsection}{Commercial distributions}\label{commercial}
Whatever method you choose, the
\TeX{} Collection CD and CTAN\index{CTAN@CTAN} are
not the only source of software. The vendors listed in Table~ offer excellent commercial
implementations of \TeX{} and \LaTeX{},
and if you are in a position where their enhanced support
and additional features are of benefit, I urge you to
support them. In most cases their companies, founders, and
staff have been good friends of the \TeX{} and \LaTeX{}
communities for many years.\index{commercial implementations}
\begin{table}\small \caption{\small Popular commercial implementations of \TeX{} systems}
\label{vendors}
\begin{center}
\begin{tabular}{@{}p{.65in}p{1in}>{\pbs{\raggedright}}p{.9in}l@{}}
\textbf{\sffamily\upshape Product}&\textbf{\sffamily\upshape Platform}&\textbf{\sffamily\upshape Company}&\textbf{\sffamily\upshape URI}\\[2pt]\hline\\[-1.5\baselineskip]
PC\TeX{}&MS-Windows&Personal \TeX{}, Inc&\url+www.pctex.com/+\\
True\TeX{}&MS-Windows&True \TeX{}&\url+truetex.com/+\\
Textures&Apple Mac&Blue Sky Research&\url+www.bluesky.com/+\\
Scientific Word&MS-Windows&Mackichan Software&\url+www.mackichan.com/+\\
V\TeX{}&MS-Windows, Linux, OS/2&MicroPress, Inc&\url+www.micropress-inc.com/+\\
\end{tabular}
\end{center}
\end{table}
\subsection*{Production note}\addcontentsline{toc}{subsection}{Production note}\label{prodnote}
This document is written and maintained in XML\index{XML@XML}, using a customized version of the
\product{DocBook} DTD\index{DTD@DTD}. Conversions were made to HTML\index{HTML@HTML} and \LaTeX{} using XSLT\index{XSLT@XSLT} scripts and \person{Michael Kay}'s \product{Saxon}
processor.
The complete source, with all ancillary files, is
available online at \url+http://www.ctan.org/tex-archive/info/beginlatex/src/+
but if you want to try processing it yourself you must install
\product{Java} (from Sun, IBM\index{IBM@IBM}, or a number of
others) and \product{Saxon} (from \url+http://saxon.sourceforge.net/+), in addition
to \LaTeX{}.
This document is published under the terms and conditions
of the GNU\index{GNU@GNU} Free Documentation
License. Details are in Appendix~\ref{gfdl}.
\clearpage\subsection*{Symbols and conventions}\addcontentsline{toc}{subsection}{Symbols and conventions}\label{symbols}
The following typographic notations are used:
\begingroup\small \begin{center}
\label{symboltable}
\begin{tabular}{@{}lp{3.5in}@{}}
\textbf{\sffamily\upshape Notation}&\textbf{\sffamily\upshape Meaning}\\[2pt]\hline\\[-1.5\baselineskip]
\command{command}&Control sequences which perform an
action, e.g. \command{newpage}\\
\length{length}&Control sequences which store a dimension
(measurement in units), e.g. \length{parskip}\\
\counter{counter}&Values used for counting (whole numbers, as
opposed to measuring in units), e.g. \counter{secnumdepth}\\
\textbf{\textit{term}}\label{term}\index{term@\textbf{\textit{term}}}&Defining instance of a
new term\\
\env{environment}&A \LaTeX{} formatting environment\\
\package{package}&A \LaTeX{} package (available from CTAN\index{CTAN@CTAN})\\
\product{product}&Program or product name\\
\verb+typewriter type+&Examples of source code (stuff you
type)\\
{\ttfamily{}\selectfont{}\uline{mybook}} or {\ttfamily{}\fontshape{sl}\selectfont{}value}&Mnemonic examples of
things you have to supply real-life values for\\
\key{x}&A key on your keyboard\\
\key{Ctrl}--\key{x}~&Two keys pressed together\\
\key{Esc}\thinspace{}\key{q}&Two keys pressed one after another\\
\guiicon{Submit}&On-screen button to click\\
\menuitem{Menu}{Item}&Drop-down menu with items\\
\end{tabular}
\end{center}
\endgroup
Examples of longer fragments of input are shown with a
border round them. Where necessary, the formatted output is
shown immediately beneath. Warnings are shown with a shaded
background. Exercises are shown with a double border.
\prelim{Foreword}\label{foreword}
As noted in the Introduction on p.\thinspace\pageref{intro},
this document accompanies a two-day introductory training course.
It became obvious from repeated questions in class and
afterwards, as well as from general queries on \url+comp.text.tex+ that many people do
not read the FAQ\index{FAQ@FAQ}s, do not use the
TUG\index{TUG@TUG} web site, do not buy the books and
manuals, do not use the newsgroups and mailing lists, and do not
download the free documentation. Instead, they try to get by
using the training technique known as `sitting by
Nelly', which involves looking over a
colleague's shoulder in the office, lab, library, pub, or
classroom, and absorbing all his or her bad habits.
In the summer of 2001 I presented a short proposal on the
marketing of \LaTeX{} to the annual conference of the \TeX{} Users
Group held at the University of Delaware, and showed an example
of a draft
brochure\footnote{\url+http://www.silmaril.ie/documents/latex-brochure/leaflet.pdf+} designed to persuade newcomers to try \LaTeX{}
for their typesetting requirements. As a result of questions and
suggestions, it was obvious that it needed to include a pointer
to some documentation, and I agreed to make available a revised
form of this document, expanded to be used outside the
classroom, and to include those topics on which I have had most
questions from users over the years.
It turned out to mean a significant
reworking of a lot of the material. Some of it appears in almost
every other manual and book on \LaTeX{} but it is essential to
the beginner and therefore bears repetition. Some of it appears
other forms elsewhere, and is included here because it needs
explaining better. And some of it appears nowhere else but this
document. I took the opportunity to revise the structure of the
training course in parallel with the book (expanding it from its
original one day to two days), and to include a more
comprehensive index. It is by no means perfect (in both senses),
and I would be grateful for comments and corrections to be sent
to me at the address given under the credits.
I had originally hoped that the \LaTeX{} version of the
document would be processable by any freshly-installed default
\LaTeX{} system, but the need to include font samples which go
well beyond the default installation, and to use some packages
which the new user is unlikely to have installed, means that
this document itself is not really a simple piece of \LaTeX{},
however simply it may describe the process itself.
However, as the careful reader will have already noticed,
the master source of the document is not maintained in \LaTeX{}
but in XML\index{XML@XML}. A future task is therefore
to compare the packages required with those installed by
default, and flag portions of the document requiring additional
features so that an abbreviated version can be generated which
can be guaranteed to process even with a basic \LaTeX{}
installation.
\label{docs}%
If you are just starting with \LaTeX{}, at an early
opportunity you should buy or borrow a copy of \titlecite{latexbook} which is the original
author's manual. More advanced users should get the
\titlecite{companion} or one of its
successors. In the same series there are also the \titlecite{graphicscomp} and the \titlecite{webcomp}. Mathematical users might want to
read \titlecite{mathguide}.
\prelim{Preface}\label{preface}
Many people discover \LaTeX{} after
years of struggling with wordprocessors and desktop publishing
systems, and are amazed to find that \TeX{} has been around for
over 25 years and they hadn't heard of it. It's not a
conspiracy, just `a well-kept secret known only to a few
million people', as one anonymous user has put
it.
Perhaps a key to why it has remained
so popular is that it removes the need to fiddle with the
formatting while you write. Although playing around with fonts
and formatting is attractive to the newcomer, it is completely
counter-productive for the serious author or editor who wants to
concentrate on \emph{writing}\mdash{}ask any
journalist or professional writer.
A few years ago a new \LaTeX{} user expressed concern on
the \url+comp.text.tex+ newsgroup about
`learning to write in \LaTeX{}'. Some
excellent advice\footnote{\url+news:comp.text.tex/MPG.18d82140d65ddc5898968c@news.earthlink.net+} was posted in response to this query,
which I reproduce with permission below [the bold text is my
emphasis]:
\begin{quotation}\small\begingroup \ttfamily\raggedright\setlength{\spaceskip}{.375em}\noindent
No, the harder part might be \emph{writing},
period. \TeX{}/\LaTeX{} is actually easy, once you relax and
stop worrying about appearance as a be-all-and-end-all. Many
people have become `Word Processing
Junkies' and \emph{\textbf{no longer
`write' documents, they
`draw' them}}, almost at the
same level as a pre-literate 3-year old child might pretend to
`write' a story, but is just creating a
sequence of pictures with a pad of paper and box of
\product{Crayola}s\mdash{}this is perfectly
normal and healthy in a 3-year old child who is being
creative, but is of questionable usefulness for, say, a grad
student writing a Master's or PhD thesis or a business
person writing a white paper, etc. For this reason,
\emph{I} strongly recommend
\emph{not} using any sort of fancy GUI\index{GUI@GUI} `crutch'.
Use a plain vanilla text editor and treat it like an
old-fashioned typewriter. Don't waste time playing with
your mouse.
Note: I am \emph{not} saying that you should
have no concerns about the appearance of your document, just
that you should \emph{write} the document
(completely) first and tweak the appearance
later\dots \emph{not} [spend time on] lots of
random editing in the bulk of the document itself.
\par\endgroup\smallskip\footnotesize\noindent [\citeauthortitleyear{heller}]\end{quotation}
Learning to write well can be hard, but authors shouldn't
have to make things even harder for themselves by using
manually-driven systems which break their concentration every
few seconds for some footling adjustment to the appearance,
simply because the software is incapable of doing it right by
itself.
\label{mathtex}%
\person{Don Knuth} originally wrote \TeX{} to typeset mathematics for
the second edition of his master-work \titlecite{aocs}, and it remains pretty much the only
typesetting program to include fully-automated mathematical
formatting done the way mathematicians want it. But he also
published a booklet called \titlecite{mathwrite} which shows how
important it is to think about what you write, and how the
computer should be able to help, not hinder.
And \TeX{} is much more than math:
it's a programmable typesetting system which can be used
for almost any formatting task, and \LaTeX{} has made it usable by
almost anyone. Professor Knuth generously placed the entire system in the
public domain, so for many years there was no publicity of the
commercial kind which would have got \TeX{} noticed outside the
technical field.
Nowadays, however, there are many companies
selling \TeX{} software or services,\footnote{See, for example, the list of \TeX{} vendors on p.\thinspace\pageref{vendors}, and the list of consultants
published by TUG\index{TUG@TUG}.} dozens
of publishers accepting \LaTeX{} documents for
publication, and hundreds of thousands of users using \LaTeX{}
for millions of documents.\footnote{A guesstimate. With free software it's impossible
to tell how many people are using it, but it's a
\emph{lot}.}
To count yourself as a \TeX{} or \LaTeX{} user, visit the
\TeX{} Users Group's
`\TeX{} Counter' web site\footnote{\url+http://www.tug.org/tex/counter/+}
(and get a nice certificate!).
There is occasionally some confusion among newcomers between
the two main programs, \TeX{} and \LaTeX{}:
\begin{itemize}
\item
\TeX{} is a typesetting program, originally written by
Prof Knuth at Stanford around 1978. It implements a
macro-driven typesetters' programming language of some
300 basic operations and it has formed the core of many
other desktop publishing (DTP)\index{DTP@DTP|textbf}\index{Acronyms@\textbf{Acronyms}, defined!DTP@DTP|textbf}
systems. Although it is still possible to write in the raw
\TeX{} language, you need to study it in depth, and you need
to be able to write macros (subprograms) to perform even the
simplest of repetitive tasks.
\item
\LaTeX{} is a user interface for \TeX{}, designed by
\person{Leslie Lamport} at Digital Equipment
Corporation (DEC)\index{DEC@DEC|textbf}\index{Acronyms@\textbf{Acronyms}, defined!DEC@DEC|textbf} in 1985 to automate all the common
tasks of document preparation. It provides a simple way for
authors and typesetters to use the power of \TeX{} without
having to learn the underlying language. \LaTeX{} is the
recommended system for all users except professional
typographic programmers and computer scientists who want to
study the internals of \TeX{}.
\end{itemize}
Both \TeX{} and \LaTeX{} have been
constantly updated since their inception. Knuth has now frozen
development of the \TeX{} engine so that users and developers
can have a virtually bug-free, rock-stable platform to work
with\footnote{Knuth still fixes bugs, although the chances of finding
a bug in \TeX{} these days approaches zero.}. Typographic programming development continues with
the New Typesetting System (NTS)\index{NTS@NTS|textbf}\index{Acronyms@\textbf{Acronyms}, defined!NTS@NTS|textbf}, planned
as a successor to \TeX{}. The \LaTeX{}3 project has taken over
development of \LaTeX{}, and the current version is
\LaTeXe{}, which is what we are concentrating on here. Details
of all developments can be had from the TUG\index{TUG@TUG} at \url+http://www.tug.org+
\begin{sidebar}\label{myths}
\subsection*{Debunking the mythology}
Naturally, over all the years, a few myths have grown up
around \LaTeX{}, often propagated by people who should know
better. So, just to clear up any potential
misunderstandings\dots
\begin{description}
\item[\sffamily MYTH: `\LaTeX{} has only got one
font']
Most \LaTeX{} systems can use any OpenType,
TrueType, Adobe (PostScript\index{PostScript})
Type1 or Type3, or \mf{} font. This is more than
most other known typesetting system.
\LaTeX{}'s default font is Computer Modern (based
on Monotype Series 8: see
the table on p.\thinspace\pageref{fontable-mf}), not Times Roman, and some
people get upset because it `looks
different' to Times. Typefaces differ:
that's what they're for\mdash{}get used to it.
\item[\sffamily MYTH: `\LaTeX{} isn't WYSIWYG\index{WYSIWYG@WYSIWYG}']
Simply not true. DVI\index{DVI@DVI}
and PDF\index{PDF@PDF} preview is better
WYSIWYG\index{WYSIWYG@WYSIWYG} than any wordprocessor
and most DTP\index{DTP@DTP} systems. What
people mean is that \LaTeX{}'s typographic display
is asynchronous with the edit window. This is only true
for the default CLI\index{CLI@CLI}
implementations. See the Introduction on p.\thinspace\pageref{synchro} for details of synchronous
versions.
\item[\sffamily MYTH: `\LaTeX{} is obsolete']
Quite the opposite: it's under constant
development, with new features being added almost
weekly. Check the \url+comp.text.tex+ for messages about recent
uploads to CTAN\index{CTAN@CTAN}. It's
arguably more up-to-date than most other systems:
\LaTeX{} had the Euro (\EUR{}) before anyone else, it had
Inuktitut typesetting before the Inuit got their own
province in Canada, and it still produces better
mathematics than anything else.
\end{description}
\end{sidebar}\begin{sidebar}\label{myths2}
\subsection*{More mythology}\begin{description}
\item[\sffamily MYTH: `\LaTeX{} is a Unix system']
People are also heard saying:
`\LaTeX{} is a Windows system',
`\LaTeX{} is a Mac system', etc.,
etc. \emph{ad nauseam}.
\TeX{} systems run on almost every computer in use, from
some of the biggest supercomputers down to handhelds
(PDA\index{PDA@PDA}s like the Sharp
\product{Zaurus}). That includes
Windows and Linux PCs, Macs, and all other Unix systems.
If you're using something \TeX{} doesn't run
on, it must be either incredibly new, incredibly old, or
unbelievably obscure.
\item[\sffamily MYTH: `\LaTeX{} is ``too
difficult''\thinspace']
This has been heard from
physicists who can split atoms; from mathematicians who
can explain why \(\pi\) exists; from business people who can
read a balance sheet; from historians who can grasp
Byzantine politics; from librarians who can understand
LoC and MARC; and from linguists who can decode Linear
`B'. It's nonsense: most people grasp
\LaTeX{} in 20 minutes or so. It's not rocket
science (or if it is, I know any number of unemployed
rocket scientists who will teach it to you).
\item[\sffamily MYTH: `\LaTeX{} is ``only for
scientists and
mathematicians''\thinspace']
Untrue. Although it grew up
in the mathematical and computer science fields, two of
its biggest growth areas are in the humanities and
business, especially since the rise of XML\index{XML@XML} brought new demands for automated
web-based typesetting.
\end{description}
\end{sidebar}\chapter{Installing \TeX{} and \LaTeX{}}
\label{get}
\pagenumbering{arabic}
\index{tetex@te}\index{fptex@fp}\index{texniccenter@nicCenter}\index{miktex@MiK}\index{Linux}\index{Unix}\index{Microsoft Windows}\index{Mac OS X}\index{Apple Mac}\index{OS X}
This course is based on using one of
the following distributions of \TeX{} on the 2004 \TeX{}
Collection DVD or the 2003 \TeX{} Live CD:
\begin{description}
\item[\sffamily te\TeX{}]
for Linux and other Unix-like systems, including Mac
OS\thinspace{}X (\person{Thomas Esser});
\item[\sffamily pro\TeX{}t]
for Microsoft Windows (\person{Thomas Feuerstack}), based on \person{Christian Schenk}'s
Mik\TeX{};
\item[\sffamily fp\TeX{}]
for Microsoft Windows (\person{Fabrice Popineau}) from the 2003 \TeX{} Live CD.
\end{description}
Many other implementations of \TeX{},
such as \person{Tom Kiffe}'s CMac\TeX{} for the Apple Macintosh, can be
downloaded from CTAN\index{CTAN@CTAN}. \LaTeX{} is
included with all modern distributions of \TeX{}.
The \TeX{} Collection CD is issued
annually on behalf of most of the local \TeX{} user groups
around the world (see \url+http://www.tug.org/lugs.html+ for addresses),
and edited by \person{Sebastian Rahtz}, \person{Karl Berry}, \person{Manfred Lotz}, and the authors of the software mentioned above.
These people give an enormous amount of their personal time and
energy to building and distributing these systems, and they
deserve the thanks and support of the user community for all
they do.
There are many other distributions of \LaTeX{} both free and
commercial, as described in the Introduction on p.\thinspace\pageref{intro}: they all process \LaTeX{} identically, but
there are some differences in size, speed, packaging, and (in
the case of commercial distributions) price, support, and extra
software provided.
One final thing before we start: publicly-maintained
software like \TeX{} is updated faster than commercial software,
so \emph{always check to see if there is a more recent
version of the installation}. See the list on p.\thinspace\pageref{latest} in \S\thinspace\ref{latest} for more details.
\section{Editing and display}
\label{editdis}
When you install \LaTeX{} you will
have the opportunity to decide \begin{inparaenum}[\itshape a\upshape)] \item which plain-text editor[s] you want to use to create
and maintain your documents; and \item which preview programs you want to use to see your
typesetting\end{inparaenum}. This isn't much use to you if you're
unfamiliar with editors and previewers, so have a look at the
table below, and maybe flip ahead to \S\thinspace\ref{editors} for a moment, where there are
descriptions and screenshots.
The best bet is probably to install more than one\mdash{}if
you've got the disk space\mdash{}or maybe all of them, because
you can always delete the ones you don't like.
\begin{description}
\item[\sffamily Editors]
There is a wide range of editors available: probably
no other piece of software causes more flame-wars in
Internet and other discussions than your choice of
editor. It's a highly personal choice, so feel free
to pick the one you like. My personal biases are
probably revealed below, so feel equally free to ignore
them.
\item[\sffamily Previewers]
For displaying your
typesetting before printing, you will need a previewer.
All systems come with a DVI\index{DVI@DVI}
previewer for standard \LaTeX{},
but if you are intending to produce industry-standard
PostScript\index{PostScript} or PDF\index{PDF@PDF} (Adobe Acrobat) files you will
need a previewer for those formats.
\product{GSview} displays both
PostScript\index{PostScript} and PDF\index{PDF@PDF} files;
\product{xpdf} and Adobe's own
\product{Acrobat Reader} just display
PDF\index{PDF@PDF} files.
\end{description}
For brief details of some of the most popular editors used
for \LaTeX{}, see \S\thinspace\ref{editors}.
\begin{warning}
\label{pdfurl}
\subsubsection*{Additional downloads}
For licensing reasons, the
\product{GSview} PostScript/PDF previewer,
the \product{Acrobat Reader} PDF previewer,
and the \product{WinEdt} editor could not
be distributed on the 2003 CDs. In those cases you have to
download and install them separately.
\begin{itemize}
\item
\product{GSview} is available for
all platforms from \url+http://www.ghostscript.com/gsview/index.htm+
(on Unix and VMS systems it's also available as
\product{GhostView} and
\product{gv}: see \url+http://www.cs.wisc.edu/~ghost/+)
\item
\product{Acrobat Reader} (all
platforms) can be downloaded from \url+http://www.adobe.com/products/acrobat/readstep2.html+
\item
\product{WinEdt} (Microsoft Windows
only) comes from \url+http://www.winedt.com+
\end{itemize}
\end{warning}
\section{Installation for Linux and Unix}
\label{lininst}
Make sure your system libraries and utilities are up to
date. If you are using Red Hat Linux, use
\product{yum} or
\product{up2date} to download and install
updates. For Debian and other distributions, use
\product{apt-get} or similar. On Red Hat
systems, remove any RPM version of te\TeX{} and associated
utilities which may have been
preinstalled, in order to avoid version conflicts.
If you are installing \TeX{} Live to a new partition, and
you have the opportunity to reformat the partition before use,
use \product{mkfs} with a granularity as
small as it will go (usually 1024 bytes). This avoids the
partition running out of inodes because \TeX{} uses very large
numbers of very small files.
Plan the installation carefully if you are installing for
multiple users (a shared machine): read \S\thinspace\ref{pkginst} for some comments on where to put additional
files downloaded later, and see the FAQ on the same topic at
\url+http://www.tex.ac.uk/cgi-bin/texfaq2html?label=wherefiles+
Above all, Read The Fine
Manual (RTFM)\index{RTFM@RTFM|textbf}\index{Acronyms@\textbf{Acronyms}, defined!RTFM@RTFM|textbf}. The documentation is in
\url+live.html+ and
\url+live.pdf+ on the disk in the directory
\url+texlive2004/texmf-doc/doc/english/texlive-en/+
\begin{figure}\small
\caption{\small \TeX{} Live installation manual}
\begin{center}
\includegraphics[width=0.75\textwidth]{tlcdoc}
\end{center}
\end{figure}
\begin{sourcecode}\begin{Verbatim}[fontsize=\small,commandchars=\\\{\}]
# cd /\textsl{\uline{mnt/cdrom}}/texlive2004
# sh install-tl.sh
\end{Verbatim}
\end{sourcecode}
The installer runs in a shell window, so it can be done
even from headless systems (those with no X Window client),
but it does need to be installed as root if you want to stick
with the default directory locations or install it system-wide
for multiple users. To install, just type the commands shown
above.
The options are mostly self-explanatory, and beginners
should pick the recommended scheme and leave all other
settings at their defaults. The character-driven interface
lets you browse around the settings changing things and
looking at options before you commit to installing
anything.
\begin{figure}\small
\caption{\small The Unix installation program}
\begin{sourcecode}\begin{Verbatim}[fontsize=\scriptsize]
==================> TeX Live installation procedure <=================
===> Note: Letters/digits in <angle brackets> indicate menu items <===
===> for commands or configurable options <===
Proposed platform: Intel x86 with GNU/Linux
<P> over-ride system detection and choose platform
<B> binary systems: 1 out of 10
<S> Installation scheme (scheme_recommended)
[customizing installation scheme:
<C> standard collections <L> language collections]
20 out of 75, disk space required: 246857 kB
<D> directories:
TEXDIR (The main TeX directory) : /usr/TeX
TEXMFLOCAL (Directory for local styles etc): /usr/TeX/texmf-local
VARTEXMF (Directory for local config) : /usr/TeX/texmf-var
<O> options:
[ ] alternate directory for generated fonts ()
[ ] create symlinks in standard directories
[ ] do not install macro/font doc tree
[ ] do not install macro/font source tree
<R> do not install files, set up to run off CD or DVD
<I> start installation
<H> help, <Q> quit
Enter command:
\end{Verbatim}
\end{sourcecode}
\end{figure}
`Collections' (the {\slshape\verb`C`} and
{\slshape\verb`L`} options) are groups of \LaTeX{} packages
that you can include or exclude. It's best to leave this
alone unless you know you need something specific. The only
options I sometimes set are under {\slshape\verb`O`}: the
`alternate directory for generated fonts' may
need to be on a different partition for performance reasons on
a shared system; and I always select `create symlinks in
standard directories' so that the system works
immediately after the post-installation configuration (after
installation, run \product{texconfig} to
adjust your local settings.
\begin{figure}\small
\caption{\small Running the post-installation program
\emph{texconfig}}
\begin{center}
\includegraphics[width=0.75\textwidth]{texconfig}
\end{center}
\end{figure}
Note that the Linux/Unix installation does not install any
editors: it is assumed you can do this yourself from your
distribution's standard package system (most likely
you will already be using \product{Emacs} or
\product{vi} anyway).
\section{Installation for Apple Mac}
\label{macinst}
This is exactly the same interface as for the Linux/Unix
installation. You need the \product{bash}
shell (see the warning in the manual for users of older systems).
There is a choice of graphical editors for the Mac: two
are included on the DVD, \product{\TeX{}Shop}
and \product{I\TeX{}Mac}, but they need to be
installed separately, after installing \TeX{}.
\section{Installation for Microsoft Windows}
\label{wininst}
\begin{figure}\small
\caption{\small \TeX{} Collection 2004 DVD}
\begin{center}
\includegraphics[width=0.75\textwidth]{tcdvddir}
\end{center}
\end{figure}
Before you install \TeX{}, make
sure you have enough disk space: the default installation
takes about 350Mb on a modern filesystem. The installation
assumes you have a fully updated version of Windows, so visit
the Microsoft Web site first (\url+http://www.microsoft.com/+) and click on
\product{Windows Update}. Select and install
all the relevant updates for your operating system (Windows
95, 98, ME, 2000, NT, or XP). You should be doing this
regularly anyway, to keep your system healthy. You may want to
run \product{ScanDisk} and give your hard
disks a full surface check. \TeX{} consists of a very large
number of quite small files, so it's important that your
disk is in good order.
When you insert the distribution
DVD or CD, it should start the setup program automatically. If
you have auto-run turned off, open \product{My
Computer}, double-click on the DVD or CD drive,
and then double-click \product{Autorun} to
start the setup program.\footnote{Some builds of Windows seem to have a bug that stops
\product{Autorun} starting the
installation. In that case (for the \TeX{} Collection 2004
DVD) double-click \url+Setup.exe+ instead,
or (for the \TeX{}
Collection 2003 CD) go to the \url+tpm+
folder and double-click on
\url+TeXSetup.exe+.}
\subsection{pro\TeX{}t (\TeX{} Collection 2004)}
For pro\TeX{}t from the \TeX{}
Collection DVD, follow the instructions in the PDF
documentation which opens automatically when you start
the setup.
\begin{figure}\small
\caption{\small pro\TeX{}t comes with its own installation
guide}
\begin{center}
\includegraphics[width=0.5\textwidth]{tcptpdf}
\end{center}
\end{figure}
The documentation contains links (in large blue type)
that you click on in sequence to run the installation
process. (This is actually very good: everything worked
first time when I did it on XP.) Basically, you need to
install \begin{inparaenum}[\itshape a\upshape)] \item \product{MIK\TeX{}}; \item either
\product{WinEdt} (with or without
some of its add-ons) or
\product{\TeX{}nicCenter}; and \item \product{GhostScript} and
\product{GSview}\end{inparaenum}.
\begin{warning}
You only need to install items step~\ref{nldi} in the procedure on p.\thinspace\pageref{nldi}
to step~\ref{td} in the procedure on p.\thinspace\pageref{td} if you install
\product{WinEdt}.
\end{warning}
\begin{figure}[b]\small
\caption{\small First document in
\emph{\TeX{}nicCenter}}
\label{tcpt1}
\begin{center}
\includegraphics[width=0.75\textwidth]{tcptfirstdoc}
\end{center}
\end{figure}
\begin{enumerate}
\item \textbf{Install \emph{MIK\TeX{}}}\\
\product{pro\TeX{}t} uses the
\product{MIK\TeX{}} distribution as its
core, a long-established and popular distribution for
Windows.
\item \textbf{Install \emph{WinEdt}}\\
This is optional: it's a good editor,
especially for the heavy user of a
\product{MIK\TeX{}}-based system. This is
a free month's trial\mdash{}after that it reminds you to cough
up and register.
\item \textbf{Install the \emph{WinEdt} New \LaTeX{} Document Interface}\\\label{nldi}%
Optional again, and only applicable if you installed
\product{WinEdt} anyway. It lets you
save commonly-used document settings for use in other
documents of the same type.
\item \textbf{Install the \emph{WinEdt}
Graphics Interface}\\
Another optional add-on for
\product{WinEdt} to provide drag-and-drop
graphics insertion.
\item \textbf{Install the \emph{WinEdt} Table
Designer}\\\label{td}%
Last optional add-on for
\product{WinEdt}, providing a new table editor.
\item \textbf{Install \emph{\TeX{}nicCenter}}\\
This is a free equivalent to
\product{WinEdt}. The interface is
slightly different (see Figure~\ref{tcpt1}) but it
is becoming very popular.
\item \textbf{Install \emph{GhostScript} and
\emph{GSview}}\\
These are essential for viewing the PostScript and
PDF output, especially if you don't have any other PDF
viewer installed.
\end{enumerate}
You get a choice of editors,
but the one which features in
\product{pro\TeX{}t} is
\product{\TeX{}nicCenter}. This is an
Integrated Development
Environment (IDE)\index{IDE@IDE|textbf}\index{Acronyms@\textbf{Acronyms}, defined!IDE@IDE|textbf} which lets you manage all the files
related to each document. In many cases, of course, you'll
only have one (the text itself) but if you are working with
anything beyond simple articles, you'll probably have
illustrations (images or diagrams), and possibly separate
chapter files for larger documents, plus indexes,
glossaries, bibliographies, etc. I recommend that you create
a new project for each new document, even if it's a
single-file article, as I did for the example in Figure~\ref{tcpt1}.
\subsection{\TeX{} Live (\TeX{} Collection 2003)}
\par\smallskip\noindent\textbf{\itshape Once the installation program is running:}
\begin{enumerate}
\item \textbf{\LaTeX{}}\\
Install \LaTeX{} itself from the
\menuitem{TeXLive Software}{Install on
Hard Disk} menu. If you're new to
\LaTeX{}, pick Quick Install on the following screen. This
gives you everything you need to get started, and
doesn't ask any questions, it just installs it all
straight away.
If you're installing under Windows NT, 2000, or
XP, you may want to click on the option to install for
all users if you have other users on your system.
If you want to use \product{Emacs}
as your editor, click the option for Xem\TeX{}
Support.\footnote{Note this unfortunate choice of name is nothing
to do with \person{Eberhard Matthes}' MS-DOS implementation of \TeX{}
called em\TeX{}\mdash{}the `Xem' is
short for \product{Xemacs}.}
\item \textbf{Emacs}\\
After installation, right-click and drag
\url+Xemacs.exe+ from the
\url+C:\Program Files\TeXLive\bin\win32+
folder out onto your desktop and let go, then pick
`Create Shortcut'. This places
\product{Emacs} on your desktop for
easy access.
\item \textbf{WinShell and WinEdt}\\
If you want to install
\product{WinShell}, run the installer
program in the \url+support/winshell+
directory. For \product{WinEdt} you
must go to their Web site (\url+http://www.winedt.com/+) for a
downloadable version.
You don't have to install just one editor: if
you've got the space, install them all so you can
try them out. You can always uninstall the ones you
don't want afterwards.
\item \textbf{GSView}\\
Ghostscript is installed automatically, but for
\product{GSView} you need to go to
\url+http://www.cs.wisc.edu/~ghost/gsview/+,
and download the most recent version.
If you use \product{GSView}, please
register your copy with Ghostgum, Pty. (\url+http://www.ghostgum.com.au/+).
\end{enumerate}
\begin{warning}
Please read the \TeX{} Live update pages at \url+http://www.tug.org/texlive/bugs.html+ for
details of any changes since the disks were released, and
download and install any additional software
required.
\end{warning}
\subsection{Installation problems}
It's always annoying when a program that's supposed to
install painlessly causes trouble, and none the more so when
everyone else seems to have been able to install it without
problems. I've installed \TeX{} hundreds of times and very
rarely had any difficulties, but these are a few of the
occasions when I did.
\begin{description}
\item[\sffamily Bad hard disks]
As recommended in \S\thinspace\ref{wininst}, run a
scan and defragmentation of your hard disk[s] before
you start. It should take under an hour on a modern
machine unless you have a very large disk, and it may
need overnight on an older machine. Clean your CD or DVD
drive if it's been in heavy use. \TeX{} uses a very
large number of very small files, so there is a lot of
disk activity during an installation. As also
recommended in \S\thinspace\ref{lininst}, if you have
the chance to reformat the hard disk, pick the
smallest granularity (cluster size) possible.
\item[\sffamily Registry errors]
This only affects Microsoft Windows users. The
Registry is where Microsoft want software companies
automatically to store details of all the programs you
install. Unfortunately the Registry is grossly abused
by marketing departments to try and foist undesirable
links on you, the user. You will see this with many
commercial programs, where a particular type of file
you've been able to double-click on for years suddenly
runs a different program. Some programs install
obsolete or broken copies of program libraries (DLL
files), overwriting ones which were working perfectly.
Worse, the viruses, trojans, and worms which typically
infect unprotected Windows systems can leave unwanted
links to web pages, or change some of the ways in
which Windows operates. The overall effect can be that
the whole machine slows down, or that files which are
expected to do one thing do another. The best
solution is a thorough Registry clean-out, using one
of the many programs available for the purpose.
\item[\sffamily Use the latest versions]\label{latest}
Before installing, check the CTAN\index{CTAN@CTAN} web site (\url+http://www.ctan.org/+ for any updated
copy of the installation program. This is called
\url+install-tl.sh+ for Linux and Mac
systems, and \url+Setup.exe+ for
Microsoft Windows (on the \TeX{} Collection 2003 CD it
was called \url+TeXSetup.exe+). Just
occasionally a bug slips through onto the production
CD or DVD, and although it's always fixed and notified
on \url+comp.text.tex+,
that's a high-volume newsgroup and even the sharpest
eyes may miss an announcement.
\item[\sffamily Stick to the defaults]
Unless you're a computer scientist or a software
engineer, I suggest you never change or fiddle with
the default directories for installation. I know some
of them look odd, but they're that way for a purpose,
especially when it comes to avoiding directories will
spaces in their names, like the notorious
\verb+C:\Program Files+. Although most
modern systems cope happily with spaces in filenames
and directory names, they are usually A Bad Design
Idea, and should be avoided like the plague (spaces
are forbidden in web addresses for the same reason:
the people who designed them knew the pitfalls). It
may look snazzier to put the installation in
\verb+My Cute Stuff+, but please
don't: you'll just make it harder to find, harder to
fix problems, and more embarrassing if you have to
explain it to someone else trying to help you.
\end{description}
\chapter[Using your editor to create documents]{Using your editor \newline{}to create documents}
\label{plaintext}
\LaTeX{} documents are all \textbf{\textit{plain-text}}\label{plain-text}\index{plain-text@\textbf{\textit{plain-text}}} files.\footnote{`Plain-Text'
originally meant just the 95 printable characters of the
American Standard Code for Information
Interchange (ASCII)\index{ASCII@ASCII|textbf}\index{Acronyms@\string\textbf{Acronyms}, defined!ASCII@ASCII|textbf}\mdash{}see Table~\ref{asciicodes}\mdash{}but now more commonly includes
both these \emph{and} the relevant 8-bit
characters from \emph{one} (only) character
set such as ISO-8859-1 (Western Latin\ndash{}1) or
ISO-8859-15 (Western Latin plus the Euro sign). These are
international standards which work everywhere: you should
avoid using manufacturers' proprietary character sets
like Microsoft Windows\ndash{}1252 or Apple Macintosh
Roman\ndash{}8, because they may make your documents unusable
on some other systems.} You can edit them with any editor, and transfer
them to any other computer system running \LaTeX{} and they will
format exactly the same. Because they are plain text they cannot
corrupt your system, as they cannot be used for hiding or
transporting virus infections as binary wordprocessor files can.
Everything you can see is in the file and everything in the file
is there for you to see: there is nothing hidden or secret and
there are no manufacturers' proprietary
`gotchas' like suddenly going out of date
with a new version.
\section{Markup}
\label{mark-up}
In a \LaTeX{} document, you type your text along with
\textbf{\textit{markup}}\label{markup}\index{markup@\textbf{\textit{markup}}} which identifies the
important parts of your document by name, for example
`title', `section',
`figure', etc. \LaTeX{} does all the formatting
for you automatically, using the markup to guide its internal
rules and external stylesheets for typesetting.
\begin{sidebar}\subsection*{Markup}
This is a term from printing, and originally meant the
notes on how to lay the document out, or the instructions
which a proofreader might add during correction. It now also
means instructions or descriptions added to a computer
document to act as guidelines for identification or
formatting. Markup has been around for
\emph{ages}.
\begingroup\small \begin{center}
\begin{tabular}{@{}l>{\pbs{\raggedright}}b{.75in}r@{}}
\vrule height4pt width0pt \includegraphics[width=2in]{55-1L-part}&\multicolumn{2}{l}{\titlecite{tain}}\\[4pt]
\includegraphics[width=2in]{23-part}&\multicolumn{2}{l}{\titlecite{varmints}}\\[4pt]
\verb+.h1 Interest Rates+&Runoff&\emph{c.}1970\\[4pt]
\verb+\section{Interest Rates}+&\LaTeX{}&1984\\[4pt]
\verb+<sec><ttl>Interest Rates</ttl>...+&SGML\index{SGML@SGML}&1985\\[4pt]
\verb+<H1>Interest Rates</H1>+&HTML\index{HTML@HTML}&1991\\[4pt]
\end{tabular}
\end{center}
\endgroup\end{sidebar}
You do not need to format any of your text \emph{in
your editor}, because \LaTeX{} does it
all by itself when it typesets. You can of course regularise
or neaten its appearance \emph{in your editor}
for ease of editing (for example, keeping each item in a list
on a separate line), but this is not required.
You will often hear \LaTeX{} markup referred to as
`commands' or sometimes `control
sequences' (the proper \TeX{}nical term for them).
For
all practical purposes these terms all mean the same
thing.
This course assumes that users have one of
\product{\TeX{}shell},
\product{\TeX{}nicCenter},
\product{WinShell}, or
\product{WinEdt} (Windows only), or
\product{Emacs} or \LyX{} (any platform)
installed. These are discussed briefly in \S\thinspace\ref{editors}, and the menus and toolbars for running
\LaTeX{} are explained in \chaptername~\ref{process}.
\section{Quick start for the impatient}
\label{quickstart}
If you already know all this stuff about editors and
plain-text files and running programs, and you know your system
is already correctly installed (including your editor),
you'd probably like to type something in and see \LaTeX{}
do its job. If you don't, then skip forward to \S\thinspace\ref{commands} and read a bit more about \LaTeX{}
first.
\begin{figure}\small
\caption{\small Sample document}
\label{sampledoc}
\begin{sourcecode}\begin{Verbatim}[fontsize=\footnotesize]
\documentclass[12pt]{article}
\usepackage{palatino,url}
\begin{document}
\section*{My first document}
This is a short example of a \LaTeX\ document I wrote
on \today. It shows a few simple features of automated
typesetting, including
\begin{itemize}
\item setting the default font size to 12pt;
\item specifying `article' type for formatting;
\item using the Palatino typeface;
\item adding special formatting for URIs;
\item formatting a heading in `section' style;
\item using the \LaTeX\ logo;
\item generating today's date;
\item formatting a list of items;
\item centering and italicizing;
\item autonumbering the pages.
\end{itemize}
\subsection*{More information}
This example was taken from `Formatting Information',
which you can download from
\url{http://www.ctan.org/tex-archive/info/beginlatex/}
and use as a teach-yourself guide.
\begin{center}
\textit{Have a nice day!}
\end{center}
\end{document}
\end{Verbatim}
\end{sourcecode}
\end{figure}
\par\smallskip\noindent\textbf{\itshape Up and running in a few minutes}
\begin{enumerate}
\item \textbf{Install the software}\\
Make sure you have a
properly-installed \LaTeX{} system and a copy of a
suitable editor.
\item \textbf{Create a sample document}\\\label{demodoc}%
Open your editor and type in
the text \emph{exactly} as shown in Figure~\ref{sampledoc}. Do \emph{not} make any
changes or miss anything out or add anything different at
this stage.
\item \textbf{Save the document}\\
Save the document as
\url+demo.tex+
\item \textbf{Run \LaTeX{} or \emph{pdf\LaTeX{}}}\\
Click on the \guiicon{\LaTeX{}} or
\guiicon{pdf\LaTeX{}} toolbar icon or the
\menuitem{\TeX{}}{\TeX{}
File} menu item; or type \verb+latex demo+ or \verb+pdflatex demo+ in a
command window.
\item \textbf{Preview the typesetting}\\
Click on the \guiicon{DVI} or
\guiicon{PDFview} toolbar icon or the
\menuitem{\TeX{}}{\TeX{}
View} menu item; or type your previewer
command in a terminal shell.
(Note that there may be a pause the first time you use
your DVI\index{DVI@DVI} viewer, while WYSIWYG\index{WYSIWYG@WYSIWYG} font files are
created.\footnote{DVI\index{DVI@DVI} previewers use their
own font files specially created from the font
outlines (TrueType, OpenType, PostScript, \mf{},
etc). The first time you use a font at a size not used
before, there will be a second or two's pause
while it gets created. The more you use \LaTeX{}, the
less this
happens.})
\item \textbf{Print it}\\
Click on the \guiicon{Print} toolbar icon
within the viewer, or use the
\menuitem{\TeX{}}{\TeX{} Print}
menu item, or type
\verb+dvips -f demo | lpr+
(Unix/Linux).
\end{enumerate}
If you encounter any errors, it means you
\emph{do} need to study this chapter after
all!
\section{Editors}
\label{editors}
\index{editors}
All the text of your documents can
be typed into your
\LaTeX{} document from a standard keyboard using any decent
plain-text editor. However, it is more convenient to use an
editor with special features to make using \LaTeX{} easier.
Some of the most popular are
\product{\TeX{}shell}\product{WinShell}, \product{\TeX{}nic
Center}, and \product{WinEdt}
(Windows only); and \product{Emacs} (all
platforms).
\subsection{\LyX{}}
\begin{figure}\small
\caption{\small The \LyX{} document editor}
\label{lyxwin}
\begin{center}
\includegraphics[width=0.75\textwidth]{lyx}
\end{center}
\end{figure}
The \LyX{} document editor (all platforms) is a special
case, as it uses the What You See Is
What You Mean (WYSIWYM)\index{WYSIWYM@WYSIWYM|textbf}\index{Acronyms@\textbf{Acronyms}, defined!WYSIWYM@WYSIWYM|textbf} model of synchronous typographic
editing as opposed to What You See Is
What You Get (WYSIWYG)\index{WYSIWYG@WYSIWYG|textbf}\index{Acronyms@\textbf{Acronyms}, defined!WYSIWYG@WYSIWYG|textbf}, and many users prefer this
interface (but see the reservations in the Introduction on p.\thinspace\pageref{sync}).
\LyX{} makes a strong case for using synchronous
typographical editing: it is possible to create even quite
large and complex documents without seeing a backslash very
often, although with math or complex macros there is
probably no way to avoid having to do some manual insertion
of
\LaTeX{} code.
The free availability on multiple platforms makes this a
clear answer to the myth of `having to edit like a
programmer', and as it is an Open Source project,
there is constant improvement, both to the facilities and to
the interface.
Probably the only real reservation is that it does not
save native \LaTeX{} files by default. It uses its own
internal format, and it can export \LaTeX{} for use in other
editors, but the exported files are not designed for human
legibility, only for \LaTeX{} processing. In a co-operative
environment this would be a serious drawback, but for the
individual user this interface is an excellent tool.
\subsection{\TeX{}shell}
\label{texshell}
\begin{figure}\small
\caption{\small The \TeX{}shell editor}
\label{texshellwin}
\begin{center}
\includegraphics[width=0.75\textwidth]{texshell}
\end{center}
\end{figure}
This is one of the simplest of all the plaintext Windows
editors, but it has most of the tools needed to begin with.
Sectioning, lists, and graphics can be inserted from the
menus, and there are buttons for running \LaTeX{} on the
open document and for previewing the typeset
document.
The syntactic highlighting distinguishes between
commands and your text, and it comes with options for
spellchecking (you need to install
\product{ispell}), and for adding math,
Greek (math), and some symbol characters from a pickchart.
The typeset display is done using your installed DVI\index{DVI@DVI} viewer (there is no provision for
PDF\index{PDF@PDF}, although as it is
configurable, that could probably be edited into the
menus).
Download the \url+.tar.gz+ file from CTAN\index{CTAN@CTAN} in the
\url+support/TeXshell/+ directory and unwrap
it into somewhere like \url+C:\Program
Files\TeXshell\+.\footnote{Yes, I know I said don't use directory names with
spaces in them\mdash{}and so you shouldn't, for your
\LaTeX{} documents\mdash{}but Windows programs are usually safe
enough in them.} There is a \product{tsconfig}
program in the same directory on CTAN\index{CTAN@CTAN}, which is designed to help with
reconfiguring \TeX{}shell.
\subsection{WinShell}
\label{winshell}
\begin{figure}\small
\caption{\small The WinShell editor}
\label{winshellwin}
\begin{center}
\includegraphics[width=0.75\textwidth]{winshell}
\end{center}
\end{figure}
This is another free Windows editor for beginners with
\LaTeX{}. Despite its simplicity, it is capable of a
considerable amount of document management and assistance
with editing. As well as handling stand-alone \LaTeX{}
files, you can create a `Project' for larger
documents, which helps you keep track of additional files
like separate chapters, illustrations, diagrams, indexes,
etc.
You run \LaTeX{} direct from the toolbar icons or with
F-key shortcuts. Both standard \LaTeX{} and
\product{pdf\LaTeX{}} are supported, as well
as creation and previewing of
PostScript\index{PostScript} and PDF\index{PDF@PDF} output. There are additional toolbars
for math characters, and there is a `Table
Wizard' for handling tables. The syntax
highlighting distinguishes between commands (in blue) and
delimiters (in red), leaving your text in black.
Download the
\texttt{WinShell\textsl{\uline{nn}}.exe}
program (self-contained setup: the
\textsl{nn} changes with the version) from
CTAN\index{CTAN@CTAN} in the
\url+systems/win32/winshell/+ directory and
double-click it to start the setup.
\subsection{\TeX{}nicCenter}
\label{texniccenter}
\begin{figure}\small
\caption{\small The \TeX{}nicCenter editor}
\label{texniccenterwin}
\begin{center}
\includegraphics[width=0.75\textwidth]{texniccenter}
\end{center}
\end{figure}
\product{\TeX{}nicCenter} is a powerful
Windows editor suitable both for the beginner and the more advanced
user. Its `Project' environment keeps track of
multiple files, and the processing function (the bit which
actually runs \LaTeX{}, here called
`Build') tries to ensure that all the files you
need for a large or complex document are in place before you
start typesetting, to avoid errors like missing
illustrations.
It's a much more wordprocessor-like control
interface, with configurable toolbars and button-controls
for lists, math, tables, and previewing options.
Download the
\texttt{TXCSetup\textsl{\uline{xxx}}.exe}
program (self-contained setup: the
\textsl{xxx} bit changes with the version)
from CTAN\index{CTAN@CTAN} in the
\url+systems/win32/TeXnicCenter/+ directory
and double-click it to start the setup.
\subsection{WinEdt}
\label{winedt}
\begin{figure}\small
\caption{\small The \emph{WinEdt} editor}
\label{winedtpic}
\begin{center}
\includegraphics[width=0.75\textwidth]{winedt}
\end{center}
\end{figure}
\product{WinEdt} is a highly
configurable plain-text editor for Windows. It comes with a
host of special functions and shortcuts for
\TeX{} and \LaTeX{}, based on the Mik\TeX{} distribution. It
is supplied on the \TeX{} Collection 2004 DVD and the
\product{pro\TeX{}t} CD. You can also
download it from \url+http://www.winedt.com+\mdash{}in either case
there's a 1-month free trial, then it reminds you to
buy it.
\product{WinEdt} uses a built-in
toolbar of configurable buttons, preset for use with
\LaTeX{}, and it provides syntactic coloring of
\LaTeX{} commands. Both the positioning and effect of the
buttons can be changed, using an editable file of icons and
a configuration panel. This flexibility lets you bind a
program and arguments (equivalent to a typed command) to a
particular icon.
There are default buttons on the toolbar for one-click
typesetting, previewing, and
PostScript\index{PostScript} or PDF\index{PDF@PDF} generation from \LaTeX{} documents,
and it manages multi-file document projects like most of the
other editors. \product{Winedt} is also
used by many people for normal plaintext file-editing tasks,
in preference to more limited programs like
\product{Notepad}. If you're using the
fp\TeX{} which came with the 2003 \TeX{}
Collection, some editing of the menus is required (explained
in the local installation document) because the default
setup is for
Mik\TeX{}/pro\TeX{}t.
\subsection{GNU Emacs}
\begin{figure}\small
\caption{\small Emacs editing \LaTeX{}}
\begin{center}
\includegraphics[width=0.75\textwidth]{emacs}
\end{center}
\end{figure}
\product{Emacs} is a product of the
GNU\index{GNU@GNU} Project.\footnote{`GNU's Not
Unix (GNU)\index{GNU@GNU|textbf}\index{Acronyms@\string\textbf{Acronyms}, defined!GNU@GNU|textbf}' is a project to make a
computing environment completely free of
restrictions.} Versions are available for all makes and models
of computer, and it has a \LaTeX{}-mode which provides
syntactic colouring (`fontification'
in \product{Emacs}-speak) and mouseclick
processing from a menu or toolbar.
\product{Emacs}
is a very large and powerful editor, with
`modes' (plug-ins) to handle almost
everything you do on a computer. Many users run
\product{Emacs} once on logging in, and
never leave it for the rest of the day\mdash{}or month. As
well as edit, you can use it to read your mail, browse the
Web, read Usenet news, do wordprocessing and spreadsheets,
compile programs, help you write in any computer
language\mdash{}including XML\index{XML@XML} and
\LaTeX{}\mdash{}and it provides a few games as well.
\product{Emacs}
knows about \LaTeX{} and how to process it, so it comes with
a menu full of \LaTeX{} operations to click on. If you are
editing complex documents with mathematics, there is a mode
(\product{AUC\TeX{}}) which has even more
functionality. \LaTeX{} support is well-developed, and there
is a hierarchy of newsgroups for
\product{Emacs} support.
Because \product{Emacs} runs on
Microsoft Windows, Macs, Linux, and most other platforms,
many \LaTeX{} users who have multiple machines (and those
who have multiple users to support) prefer it to other
editors because it provides the same environment regardless
of which platform they are using.
It's sometimes criticised for a steep learning
curve, but in fact it's no worse in this respect than
any other editor, given the power that it provides, and it
is significantly better than most which lack many of the
authorial tools available in Emacs.
\subsection{Mac editors}
Mac users will be disappointed that I haven't included
any of the Mac interfaces here. It's simple: I don't have a
Mac right now to try them out on. I hope to remedy this for a
future edition.
\section{\LaTeX{} commands}
\label{commands}
\label{bsol}%
\LaTeX{} commands all begin with a
\textbf{\textit{backslash}}\label{backslash}\index{backslash@\textbf{\textit{backslash}}}
(\verb+\+)\footnote{Do not confuse the backslash
with the forward slash (\url+/+). They are
two different characters. The forward slash is used on the
Web and on Unix systems to separate directory names and
filenames. The backslash is used in Microsoft Windows
(only) for the same purpose, and in \LaTeX{} to begin a
command.} and are usually made up of lowercase
letters only, for example:
\begin{sourcecode}\begin{Verbatim}[fontsize=\small]
\tableofcontents
\end{Verbatim}
\end{sourcecode}
The
\command{tableofcontents} command is an instruction
to \LaTeX{} to insert the Table of Contents at this point. You
would usually use this in a book or report (or perhaps a very
long article) somewhere close to the beginning. You don't have
to do anything else. Provided that you have used the
sectioning commands described in \S\thinspace\ref{sections},
all the formatting and numbering for the Table of Contents is
completely automated.
\subsection{Simple commands}
\label{simplecmd}
\label{swallow}%
Simple one-word commands like
\command{tableofcontents} must be separated from
any following text with \textbf{\textit{white-space}}\label{wsp}\index{white-space@\textbf{\textit{white-space}}}. This means a
normal space, or a newline [linebreak] or a TAB character.
For example either of these two forms will work:
\begin{sourcecode}\begin{Verbatim}[fontsize=\small]
\tableofcontents Thanks to Aunt Mabel for all her help
with this book.
\end{Verbatim}
\end{sourcecode}
\begin{sourcecode}\begin{Verbatim}[fontsize=\small]
\tableofcontents
Thanks to Aunt Mabel for all her help with this book.
\end{Verbatim}
\end{sourcecode}
If you forget the white-space, as in the following
example, \LaTeX{} will try to read it as a command
called \verb+\tableofcontentsThanks+. There's no
such command, of course, so \LaTeX{} will complain at you by
displaying an error message (see \S\thinspace\ref{undefcs}).
\begin{sourcecode}\begin{Verbatim}[fontsize=\small]
\tableofcontentsThanks to Aunt Mabel for all her help
with this book.
\end{Verbatim}
\end{sourcecode}
\LaTeX{} swallows any white-space which follows a command
ending in a letter. It does this automatically, so you
don't get unwanted extra space in your typeset output,
but it does mean that any simple command which ends in a
letter and has no arguments (see below) must be followed by
white-space before normal text starts again, simply to keep
it separate from the text.
\subsection{Commands with arguments}
\label{cmdargs}
Many \LaTeX{} commands are followed by one or more
\textbf{\textit{arguments}}\label{arguments}\index{arguments@\textbf{\textit{arguments}}}, a term from
the field of Computer Science, meaning information to be acted
upon. Here are two examples:
\begin{sourcecode}\begin{Verbatim}[fontsize=\small]
\chapter{Poetic Form}
\label{pform}
\end{Verbatim}
\end{sourcecode}
Such arguments always go in
\verb+{+\textbf{\textit{curly
braces}}\label{curly}\index{curly
braces@\textbf{\textit{curly
braces}}}\verb+}+ like
those\index{braces|see{curly braces}} shown above. Be careful not to confuse the
curly braces on your keyboard with round parentheses
\verb+( )+, square brackets
\verb+[ ]+, or angle brackets
\verb+< >+. They are all
different and they do different things.
With commands that take arguments you do
\emph{not} need to use extra white-space after
the command, because there is an argument following it
which will keep it separate from any normal text with
follows after that. The following is therefore perfectly
correct (although unusual because it's harder to edit:
normally you'd leave a blank line between the chapter title or
label and the start of the first paragraph).
\begin{sourcecode}\begin{Verbatim}[fontsize=\small]
\chapter{Poetic Form}\label{pform}The shape of poetry
when written or printed distinguishes it from prose.
\end{Verbatim}
\end{sourcecode}
\subsection{White-space in \LaTeX{}}
\label{white-space}
\index{white-space}
In \LaTeX{} documents, all \emph{multiple}
spaces, newlines (linebreaks), and TAB characters are
treated as if they were a \emph{single} space
or newline during typesetting. \LaTeX{} does its own spacing
and alignment using the instructions you give it, so you
have extremely precise control. You are therefore free to
use extra white-space in your editor for optical ease and
convenience when editing.
The following is therefore exactly equivalent to the example
in the preceding section:
\begin{sourcecode}\begin{Verbatim}[fontsize=\small]
\chapter {Poetic
Form}\label
{pform}
The shape of poetry when written or printed
distinguishes it from prose.
\end{Verbatim}
\end{sourcecode}
That is, it will get typeset exactly the same. In
general, just leave a blank line between paragraphs and a
single space between words and sentences. \LaTeX{} will take
care of the formatting.
\section{Special characters}
\label{specials}
\index{special characters}
There are ten keyboard characters which have special
meaning to \LaTeX{}, and cannot be used on their own except for
the following purposes:
\begingroup\small \begin{center}
\setlength{\tabcolsep}{1mm}
\begin{tabular}{clcc}
\textbf{\sffamily\upshape Key}&\textbf{\sffamily\upshape Meaning}&\multicolumn{1}{>{\bfseries\pbs{\centering}}b{1.5in}}{\normalfont\bfseries\upshape \emph{If you need the actual character itself,
type:}}&\textbf{\sffamily\upshape Character}\\[2pt]\hline\\[-1.5\baselineskip]
\key{$\backslash$}&The command character&\command{textbackslash}&$\backslash$\\
\key{\$}&Math typesetting delimiter&\command{\$}&\$\\
\key{\%}&The comment character&\command{\%}&\%\\
\key{{\char'136}}&Math superscript character&\command{{\char'136}}&{\char'136}\\
\key{\amp }&Tabular column separator&\command{\amp }&\amp \\
\key{{\ttfamily\char'137}}&Math subscript character&\command{{\ttfamily\char'137}}&\texttt{\_}\\
\key{{\char'176}}&Non-breaking space&\command{{\char'176}}&{\char'176}\\
\key{\#}&Macro parameter symbol&\command{\#}&\#\\
\key{{\ttfamily\char'173}}&Argument start delimiter&\texttt{\$}\command{{\ttfamily\char'173}}\texttt{\$}&$\{$\\
\key{{\ttfamily\char'175}}&Argument end delimiter&\texttt{\$}\command{{\ttfamily\char'175}}\texttt{\$}&$\}$\\
\end{tabular}
\end{center}
\endgroup
These characters were deliberately chosen, either because
they are rare in normal text, or (in the case of \$,
\#, \amp , and \%) they already had an
established special meaning on computers as \textbf{\textit{metacharacters}}\label{metacharacters}\index{metacharacters@\textbf{\textit{metacharacters}}} (characters
standing as symbols for something else) by the time \TeX{} was
written, and it would have been misleading to choose
others.
\subsection{Using the special characters}
We have already seen (the first paragraph of \S\thinspace\ref{bsol}) how
to use the backslash to start a command, and curly braces to
delimit an argument. The remaining special
characters are:
\begin{description}
\item[\sffamily \key{\$}]
Because of the special mathematical meaning
\LaTeX{} uses for the dollar-sign on its own, if you
want to print \$35.99 you type
\verb+\$35.99+
\item[\sffamily \key{\%}]
\label{comment}%
The \textbf{\textit{comment character}}\label{commentchar}\index{comment character@\textbf{\textit{comment character}}} makes
\LaTeX{} ignore the remainder of the line in your
document, so you can see it in your editor, but it
will never get typeset. For example \verb+Today's price per Kg is £22.70 % get Mike to update this+\\If you want to print 45\% you need
to type \verb+45\%+
\item[\sffamily \key{{\char'136}}]
The caret sign lets you type
\verb+\(E=mc^2\)+ to get \(E=mc^{2}\). If you need the circumflex accent
on a letter like ê, just type the letter or use the
symbolic notation \verb+\^e+.
\item[\sffamily \key{\amp }]
The ampersand is used in tables to separate
columns (see \S\thinspace\ref{tables}). If you want to
print AT\amp T you need to type
\verb+AT\&T+.
\item[\sffamily \key{{\ttfamily\char'137}}]
The underscore lets you type
\verb+\(r_2\)+ for \(r_{2}\). If you want to underline text
(extremely rare in typesetting) see the last paragraph of \S\thinspace\ref{uline}.
\item[\sffamily \key{{\char'176}}]\label{tilde}
The tilde prints as a space, but prevents a
linebreak ever occurring at that point. It's often
used between a person's initials and their surname, eg
\verb+Prof D.E.~Knuth+
\item[\sffamily \key{\#}]
If you want a
\textbf{\textit{hash mark}}\label{hash}\index{hash mark@\textbf{\textit{hash mark}}} (the
\textbf{\textit{octothorpe}}\label{octothorpe}\index{octothorpe@\textbf{\textit{octothorpe}}} or
American number or `pound' [weight] sign)
you type \verb+\#+. For a pound
(sterling)\index{pound@£}
sign £, now nearly obsolete except in the UK and
some of its former dependencies, use your
\key{£} key or type
\command{textsterling}.
\end{description}
While we're on the subject of money, an unusual but
interesting serif-font Euro\index{euro@\euro{}} sign {\rmfamily{}\selectfont{}\euro{}}
is got with the \command{texteuro} command from the
\package{textcomp} package. The standard
sans-serif {\sffamily{}\selectfont{}\EUR{}} needs the
\package{marvosym} package and is done with
the \command{EUR} command.\footnote{The European Commission has specified that everyone
use the sans-serif design, even in serif text, but this
is amazingly ugly and most designers rightly ignore
it.}
\section{Quotation marks}
\label{quotes}
\index{quotation marks}
Do \emph{not} use the unidirectional
typewriter keyboard \ttkey{"} key for quotation
marks. Correct typographic quotes are got with the \ttkey{\`{}} key and the \ttkey{'} key, doubled if you want double
quotes:
\begin{example}
\begin{sourcecode}\fontencoding{T1}\fontfamily{pcr}\selectfont\renewcommand{\ttdefault}{pcr}\begin{Verbatim}[fontsize=\small]
He said, ``I'm just going out.''
\end{Verbatim}
\end{sourcecode}\vspace*{-\baselineskip}\begin{quote}\fontencoding{T1}\fontfamily{cmr}\selectfont\def\sfdefault{cmss}\def\bfdefault{bf}\noindent
{\fontencoding{OT1}\fontfamily{cmr}\selectfont{}He said,
``I'm just going out.''}
\end{quote}\end{example}
This ensures you get real left-hand
and right-hand (opening and closing) quotes (usually shaped
like tiny
\textsuperscript{66} and \textsuperscript{99}
or as symmetrically-balanced strokes). If you are using
\product{Emacs} as your editor, the
\key{"} key is specially programmed in
\LaTeX{}-mode to think for itself and produce correct {\ttfamily{}\selectfont{}\`{}\`{}} and
\verb+''+ characters (so this is one occasion when
you \emph{can} use the \key{"}
key).
\begin{warning}
If you are reading this in a
browser, or if you have reprocessed the file using different
fonts, it may not show you real quotes (some old browser
fonts are defective) and the \command{thinspace}
below may be too wide. Download the typeset (PDF\index{PDF@PDF}) version of this document to see the
real effect.
\end{warning}
\label{thinspace}%
When typing one quotation inside another,
there is a special command \command{thinspace} which
provides just enough separation between double and single
quotes (a normal space is too much and could allow an unwanted
linebreak):
\begin{example}
\begin{sourcecode}\fontencoding{T1}\fontfamily{pcr}\selectfont\renewcommand{\ttdefault}{pcr}\begin{Verbatim}[fontsize=\small]
He said, `Her answer was ``never''\thinspace'.
\end{Verbatim}
\end{sourcecode}\vspace*{-\baselineskip}\begin{quote}\fontencoding{T1}\fontfamily{cmr}\selectfont\def\sfdefault{cmss}\def\bfdefault{bf}\noindent
He said, `Her answer was
``never''\thinspace{}'.
\end{quote}\end{example}
\section{Accents}
\label{accents}
\index{accents}
For accented letters in western
European languages\footnote{ISO 8859-1 (Latin\ndash{}1, Western European) to
8859-15 (includes the Euro).} or other Latin-alphabet character sets just use
the accented keys on your keyboard\mdash{}if you have the right
ones. You must also tell \LaTeX{} what character repertoire
(`input encoding') you are using. You
specify this by using the \package{inputenc}
package\footnote{We haven't covered the use of
packages yet. Don't worry, see \S\thinspace\ref{packages}
if you're curious.} in your preamble
with the relevant option. For example, to tell \LaTeX{} you
will be typing ISO Latin\ndash{}1 accented characters,
use:
\begin{sourcecode}\begin{Verbatim}[fontsize=\small]
\usepackage[latin1]{inputenc}
\end{Verbatim}
\end{sourcecode}
If you have a real Unicode editor, which lets you insert
any letter or symbol from any language on the planet (for
example, mixed European, Asian, and other languages), use
\verb+utf8+ instead of \verb+latin1+.
The encoding definitions that are available on your system are
in \url+/texmf/tex/latex/base+ (all files
ending in \url+.def+).
\begin{sidebar}\label{keystrokes}
\subsection*{If you don't have accented letters}
This is for users whose keyboards do not have native
accent characters on them. See your Operating System manual
for full details. Here are two common examples:
\begin{itemize}
\item
Under Linux systems the letter
é is usually got with
\key{AltGr}--\key{;}~\thinspace{}\key{e}. Refer to the
\product{xkeycaps} utility for a table
of key codes and combinations (get it from \url+http://www.jwz.org/xkeycaps/+).
\item
Under Microsoft Windows the letter é is got with
\key{Ctrl}--\ttkey{'}~\thinspace{}\key{e} or by holding down the
\thinspace{}\key{Alt} key and typing
\thinspace{}\key{0}\thinspace{}\key{1}\thinspace{}\key{3}\thinspace{}\key{0}
on the numeric keypad (\emph{not} the top
row of shifted numerals). Refer to the
\product{charmap} utility for a table
of key codes and combinations (find it in the
\url+C:\Windows+ folder).
\end{itemize}
\end{sidebar}
If you don't have accented letter keys on your
keyboard, you'll need to use your operating system's
standard keyboard \key{Ctrl} or
\key{Alt} key combinations to generate the
characters (see the panel `If you don't have accented letters' \testpage[above]{keystrokes}).
If you cannot generate accented characters from your
keyboard at all, or if you need additional accents or symbols
which are not in any of the keyboard tables, you can use the
symbolic notation in Table~\ref{accentcodes}. In fact,
this can be used to put any accent over any letter: if you
particularly want a \~g you can have one with the command
\command{{\char'176}}\verb+g+ (and Welsh
users can get \^w with
\command{{\char'136}}\verb+w+).
If you use this symbolic method only, you do not need to
use the \package{inputenc} package. Before the
days of keyboards and screens with their own real accented
characters, the symbolic notation was the
\emph{only} way to get accents, so you may come
across a lot of older documents (and users!) using this method
all the time: it does have the advantage in portability that
the \LaTeX{} file remains plain ASCII\index{ASCII@ASCII}, which will work on all machines
everywhere, regardless of their internal encoding, and even
with very old \TeX{} installations.\footnote{Remember not everyone is lucky enough to be able to
install new software: many users on corporate and academic
networks still have to use old versions of \TeX{} because
their system administrators are too busy to
install new ones.}
\begin{table}\small \caption{\small Built-in \LaTeX{} accents}
\label{accentcodes}
\begin{center}
\begin{tabular}{lcc}
\textbf{\sffamily\upshape Accent}&\textbf{\sffamily\upshape Example}&\textbf{\sffamily\upshape Characters to type}\\[2pt]\hline\\[-1.5\baselineskip]
Acute (fada)&é&\verb+\'e+\\
Grave&è&\verb+\`e+\\
Circumflex&ê&\verb+\^e+\\
Umlaut or diæresis&ë&\verb+\"e+\\
Tilde&ñ&\verb+\~n+\\
Macron&\=o&\verb+\=o+\\
Bar-under&{\b o}&\verb+\b o+\\
Dot-over (sé{\fontfamily{cmr}\selectfont\i}\.m{\fontfamily{cmr}\selectfont\i}ú)&{\.m}&\verb+\.m+\\
Dot-under&{\d s}&\verb+\d s+\\
Breve&\u u&\verb+\u u+\\
Há\v cek (caron)&\v u&\verb+\v u+\\
Long umlaut&\H o&\verb+\H o+\\
Tie-after&{\fontencoding{OT1}\fontfamily{cmr}\selectfont{}\t oo}&\verb+\t oo+\\
Cedilla&\c c&\verb+\c c+\\
O-E ligature&\oe , \OE &\verb+\oe+,
\verb+\OE+\\
A-E ligature&\ae , \AE &\verb+\ae+,
\verb+\AE+\\
A-ring&\aa , \AA &\verb+\aa+,
\verb+\AA+\\
O-slash& \o , \O &\verb+\o+,
\verb+\O+\\
Soft-l&{\fontencoding{T1}\fontfamily{cmr}\selectfont{}\l{}, \L{}}&\verb+\l+,
\verb+\L+\\
Ess-zet (scharfes-S)&\ss &\verb+\ss+\\
\end{tabular}
\end{center}
\end{table}
Irish and Turkish dotless-{\fontfamily{cmr}\selectfont\i} is done with the
special command \command{i}, so an {\fontfamily{cmr}\selectfont\'\i}-fada
(which is normally typed with \key{{\fontfamily{cmr}\selectfont\'\i}})
requires \verb+\'\i+ if you need to type it in
the long format, followed by a backslash-space or dummy pair of
curly braces if it comes at the end of a word and there is no
punctuation, because of the rule that \LaTeX{} control
sequences which end in a letter (see the first paragraph of \S\thinspace\ref{swallow}) always absorb any following space. So
what you might see as \textsl{Rí
Tea\.mra\.c} has to be \verb+R\'\i\ Tea\.mra\.c+ when typed in full (there are not
usually any keyboard keys for the dotless-{\fontfamily{cmr}\selectfont\i} or the
lenited characters). A similar rule applies to dotless-{\fontencoding{OT1}\fontfamily{cmr}\selectfont{}{\fontfamily{cmr}\selectfont\j}} and to uppercase
\'I.
\section{Dimensions, hyphenation, justification, and breaking}
\label{handj}
\index{dimensions}\index{hyphenation}\index{justification}\index{hj@H\amp J|see{hyphenation, justification}}
\LaTeX{}'s internal measurement system is
extraordinarily accurate. The underlying \TeX{} engine
conducts all its business in units smaller than the wavelength
of visible light, so if you ask for 15mm space, that's
what you'll get\mdash{}within the limitations of your
screen or printer, of course. Most screens cannot show
dimensions of less than
\(\frac{1}{96}\)$''$ without resorting to magnification
or scaling; and on printers, even at 600dpi, fine oblique
lines or curves can still sometimes be seen to stagger the
dots.
At the same time, many dimensions in \LaTeX{}'s
preprogrammed formatting are specially set up to be flexible:
so much space, plus or minus certain limits to allow the
system to make its own adjustments to accommodate variations
like overlong lines, unevenly-sized images, and non-uniform
spacing around headings.
\TeX{} uses a very sophisticated
justification algorithm to achieve a smooth, even texture to
normal paragraph text. The programming for this has been
borrowed by a large number of other DTP systems, and users of
these are often quite unaware that they are in fact using a
significant part of \TeX{} in their work.
Occasionally, however, you will need to hand-correct an
unusual word-break or line-break, and there are facilities for
doing this on individual occasions as well as throughout a
document.
\subsection{Specifying size units}
\label{dimensions}
\index{dimension}\index{units}
Most people in printing and publishing habitually use
points and picas and ems. Some designers use cm and mm. Many
English-language speakers still use inches. You can specify
lengths in \LaTeX{} in any of these units, plus some others
(see Table~\ref{units}).
\index{pt (points)}\index{points}\index{pc (picas)}\index{picas}\index{bp (big points)}\index{sp (scaled points)}\index{dd (Didot points)}\index{cc (Ciceros)}\index{em (relative measure)}\index{ex (relative measure)}\index{mm (millimeters)}\index{cm (centimeters)}\index{in (inches)}\begin{table}\small \caption{\small Units in \LaTeX{}}
\label{units}
\begin{center}
\begin{tabular}{@{}l>{\pbs{\raggedright}}p{4in}}
\textbf{\sffamily\upshape Unit}&\textbf{\sffamily\upshape Size}\\[2pt]\hline\\[-1.5\baselineskip]
\vrule height1.5em width0pt\bfseries\itshape &\vrule height1.5em width0pt\bfseries\itshape Printers' fixed measures\\[2pt]
pt&Anglo-American standard points (72.27 to the
inch)\\
pc&pica ems (12pt)\\
bp&Adobe `big' points (72
to the inch)\\
sp&\TeX{} `scaled' points
(65,536 to the pt)\\
dd&Didot (European standard) points (67.54 to the
inch)\\
cc&Ciceros (European pica ems, 12dd)\\
\vrule height1.5em width0pt\bfseries\itshape &\vrule height1.5em width0pt\bfseries\itshape Printers' relative measures\\[2pt]
em&ems of the current point size (historically the
width of a letter `M' but see
below)\\
ex&x-height of the current font (height of letter
`x')\\
\vrule height1.5em width0pt\bfseries\itshape &\vrule height1.5em width0pt\bfseries\itshape Other measures\\[2pt]
cm¢imeters (2.54 to the inch)\\
mm&millimeters (25.4 to the inch)\\
in&inches\\
\end{tabular}
\end{center}
\end{table}
The em can cause beginners some puzzlement because
it's based on the `point size'
of the type, which is itself misleading. The point size
refers to the depth of the metal body on which foundry type
was cast in the days of metal typesetting,
\emph{not} the printed height of the letters
themselves. Thus the letter-size of 10pt type in one face
can be radically different from 10pt type in another (look
at the table on p.\thinspace\pageref{fontable-adobe}, where all the examples are
10pt). An em is the height of the type-body in a specific size,
so 1em of 10pt type is 10pt and 1em of 24pt type is
24pt.
Another name for a 1em space is a
`quad', and \LaTeX{} has a command
\command{quad} for leaving exactly that much
horizontal space. A special name is given to the 12pt em, a
`pica' em, as it has become a fixed
measure in its own right.
If you are working with other DTP users, watch out for
those who think that Adobe points (bp) are the only ones.
The difference is only .27pt per inch, but in 10$''$ of
text (a full page of A4) that's 2.7pt, which is nearly
1mm, enough to be clearly visible if you're trying to
align one sample with another.
\subsection{Hyphenation}
\label{hyph}
\LaTeX{} hyphenates automatically according to the
language you use (see \S\thinspace\ref{langs}). To specify
different breakpoints for an individual word, you can insert
soft-hyphens\index{hyphens!soft} (discretionary hyphens, done with
\command{-}) wherever you need them, for
example:
\begin{sourcecode}\begin{Verbatim}[fontsize=\small]
When in Mexico, we visited Popoca\-tépetl by helicopter.
\end{Verbatim}
\end{sourcecode}
To specify hyphenation points for all occurrences of a
word, use the \command{hyphenation} command in your
preamble (see the panel `The Preamble' \testpage[below]{preamble}) with one or more
words in its argument, separated by spaces. This will even
let you break `helico-\linebreak pter' correctly. In this command
you use normal hyphens, not soft-hyphens.\index{hyphens!discretionary}
\begin{sourcecode}\begin{Verbatim}[fontsize=\small]
\hyphenation{helico-pter Popoca-tépetl
im-mer-sion}
\end{Verbatim}
\end{sourcecode}
If you have frequent hyphenation problems with long,
unusual, or technical words, ask an expert about changing
the value of \length{spaceskip},
which controls the flexibility of the space between words.
This is not something you would normally want to do, as it
can change the appearance of your document quite
significantly.
If you are using a lot of unbreakable text (see next
section and also \S\thinspace\ref{inlineverb}) it may also
cause justification problems. One possible solution to this
is shown in \S\thinspace\ref{macargs}.
\subsection{Unbreakable text}
To force \LaTeX{} to treat a word as unbreakable, use
the \command{mbox} command:
\verb+\mbox{pneumonoultramicroscopicsilicovolcanoconiosis}+.
This may have undesirable results, however, if
you change margins or the width of the text:
\mbox{pneumonoultramicroscopicsilicovolcanoconiosis}\dots
To tie two words together with an unbreakable
space\index{hard space}\index{white-space!hard} (hard space), use a tilde (\verb+~+)
instead of the space (see the list on p.\thinspace\pageref{tilde} in \S\thinspace\ref{tilde}). This
will print as a normal space but
\LaTeX{} will never break the line at that point. You should
make this standard typing practice for things like
people's initials followed by their surname, as in
Prof. D. E. Knuth:
\verb+Prof.\ D.~E.~Knuth+.
\begin{warning}
Note that a full point after a lowercase letter is
treated as the end of a sentence, and creates more space
before the next word. Here, after
`Prof.', it's
\emph{not} the end of a sentence, and the
backslash-space forces \LaTeX{} to insert just an ordinary
word-space because it's OK to break the line after
`Prof.', whereas it would look
wrong to have initials separated with Prof. D.E. Knuth broken over a line-end.
\end{warning}
\subsection{Dashes}
For a long dash\mdash{}what printers call an
`em rule' like this\mdash{}use three
hyphens typed together, \verb+like~--- this+,
and bind them to the preceding word with a tilde to avoid
the line being broken before the dash. It's also common
to see the dash printed without spaces---like that: the
difference is purely æsthetic. \emph{Never}
use a single hyphen for this purpose.
Between digits like page ranges (35\ndash{}47), it is
normal to use the short dash (what printers call an en-rule)
which you get by typing two hyphens together, as in
\verb+35--47+. If you want a minus sign, use math
mode (\S\thinspace\ref{math}).
\subsection{Justification}
The default mode for typesetting is justified (two
parallel margins, with word-spacing adjusted automatically
for the best optical fit). In justifying, \LaTeX{} will never
add space between letters, only between words. There is a
special package called \package{so}
(`space-out') if you need special
effects like letter-spacing, but these are best left to the
expert.
There are two commands
\command{raggedright} and
\command{raggedleft} which set ragged-right (ranged
left) and ragged-left (ranged right). Use them inside a
group (see the panel `Grouping' \testpage[below]{grouping}) to confine their
action to a part of your text.
{\raggedleft
These modes also exist as
`environments' (see the last paragraph of \S\thinspace\ref{environments}) called
\env{raggedright} and
\env{raggedleft} which are more convenient
when applying this formatting to a whole paragraph or more,
like this one.
\par}\begin{sourcecode}\begin{Verbatim}[fontsize=\small]
\begin{raggedleft}
These modes also exist as environments called raggedright
and raggedleft which is more convenient when applying this
formatting to a whole paragraph or more, like this one.
\end{raggedleft}
\end{Verbatim}
\end{sourcecode}
Ragged setting turns off hyphenation. There is a package
\package{ragged2e} which retains hyphenation
in ragged setting, useful when you have a lot of long
words.
\subsection{Languages}
\label{langs}
\LaTeX{} can typeset in the native manner for several
dozen languages. This affects hyphenation, word-spacing,
indentation, and the names of the parts of documents used as
headings (e.g. Table of Contents).
Most distributions of \LaTeX{} come with US English and
one or more other languages installed by default, but it is
easy to add the \package{babel} package and
specify any of the supported languages or variants, for
example:
\begin{sourcecode}\begin{Verbatim}[fontsize=\small]
\usepackage[frenchb]{babel}
...
\selectlanguage{frenchb}
\end{Verbatim}
\end{sourcecode}
Changing the language with
\package{babel} automatically changes the
names of the structural units and identifiers like
`Abstract',
`Index', etc. to their
translated version. For example, using French as above,
chapters will start with
`\emph{Chapitre}'.
\section{Mathematics}
\label{math}
\index{mathematics}
As explained in the Preface on p.\thinspace\pageref{mathtex}, \TeX{} was
originally written to automate the typesetting of books
containing mathematics. The careful reader will already have
noticed that mathematics is handled differently from normal
text, which is why it has to be typeset specially. This
document does not cover mathematical typesetting, which is
explained in detail in many other books and Web pages, so all
we will cover here is the existence of the math mode commands,
and some characters which have special meaning, so they
don't trip you up elsewhere.
In addition to the 10 special characters listed in \S\thinspace\ref{specials}, there are three more characters which
only have any meaning inside mathematics mode:\index{math characters}
\begingroup\small \begin{center}
\begin{tabular}{cl}
\textbf{\sffamily\upshape Key}&\textbf{\sffamily\upshape Meaning}\\[2pt]\hline\\[-1.5\baselineskip]
\key{$|$}&Vertical bar\\
\ttkey{<}&Less-than\\
\ttkey{>}&Greater-than\\
\end{tabular}
\end{center}
\endgroup
If you type any of these in normal text (ie outside math
mode), you will get very weird things happening and lots of
error messages. If you need to print these characters, you
\emph{must} type them using math mode, or use
their symbolic names from the \env{textcomp}
package (\command{textbrokenbar},
\command{textlangle}, and
\command{textrangle}).
The hyphen also has an extra meaning in math mode: it
typesets as a minus sign, so if you want to write about
negative numbers you need to type the number in math mode so
the minus sign and the spacing come out right.
To use math mode within a paragraph, enclose your math
expression in \command{(} and \command{)}
commands. You can get the much-quoted equation
\(E=mc^{2}\) by typing
\verb+\(E=mc^2\)+, and to get a temperature like
\ifmmode-\else$-$\fi{}30° you need to type
\verb+\(-30\)°+.\footnote{Bear in mind that the degree symbol is a non-ASCII\index{ASCII@ASCII} character, so you must specify
what input encoding you are using if you want to type it:
see the example of the \package{inputenc}
package in \S\thinspace\ref{accents}. If you don't
want to use non-ASCII\index{ASCII@ASCII} characters
(or if you are using a system which cannot generate them),
you can use the command \command{textdegree} to
get the degree sign.}
To typeset a math expression as `displayed
math' (centered between paragraphs), enclose it
in the commands \command{[} and
\command{]}.\footnote{You will also see dollar signs used for math mode.
This is quite common but deprecated: it's what plain
\TeX{} used in the days before \LaTeX{}, and the habit got
ingrained in many mathematicians. It still works as a
convenient shorthand like \url+$x=y$+, as do
double-dollars for display-mode math like
\url+$$E=mc^2$$+, but they are only mentioned
here to warn readers seeing them in other authors'
work that \command{(}\dots \command{)}
and \command{[}\dots \command{]} are
the proper \LaTeX{} commands.}
\begin{example}
\begin{sourcecode}\begin{Verbatim}[fontsize=\small]
\[\bar n^*_j(s)=\frac{\left\{s\sum_{i=1}^k
n_i(0)p^*{i,k+1}(s)+M^*(s)\right\}\sum_{i=1}^k
p_{0i}p^*{ij}(s)}{1-s\sum_{i=1}^kp_{0i}p^*_{i,
k+1}(s)}+\sum_{i=1}^kn_i(0)p^*_{ij}(s)[j=
1,2,\dots,k].\]
\end{Verbatim}
\end{sourcecode}\vspace*{-\baselineskip}\begin{quote}\fontencoding{T1}\fontfamily{cmr}\selectfont\def\sfdefault{cmss}\def\bfdefault{bf}\noindent
\(\bar n^*_j(s)=
\frac{\left\{s\sum^k_{i=1}n_i(0)p^*_{i,k+1}(s)+M^*(s)\right\}
\sum^k_{i=1}p_{0i}p^*{ij}(s)}{1-s\sum^k_{i=1}p_{0i}p^*_{i,k+1}(s)}
+\sum^k_{i=1}n_i(0)p^*_{ij}(s)\,\rlap{[j=1,2,\dots,k]}\)
\end{quote}\end{example}
Displayed equations can be auto-numbered with the
\env{equation} environment instead of the
\command{[} and \command{]} commands.
\chapter{Basic document structures}
\label{basic}
\index{sections}
\LaTeX{}'s approach to formatting is to aim for
consistency. This means that as long as you identify each
\textbf{\textit{element}}\label{element}\index{element@\textbf{\textit{element}}} of your document
correctly, it will be typeset in the same way as all the other
elements like it, so that you achieve a consistent finish with
minimum effort. Consistency helps make documents easier to read
and understand.
Elements are the component parts of a document, all the
pieces which make up the whole. Almost everyone who reads books,
newspapers, magazines, reports, articles, and other classes of
documents will be familiar with the popular structure of
chapters, sections, subsections, subsubsections, paragraphs,
lists, tables, figures, and so on, even if they don't
consciously think about it.
Consistency is also what publishers look for. They have a
house style, and often a reputation to keep, so they rightly
insist that if you do something a certain way once, you should
do it the same way each time.
To help achieve this consistency, every \LaTeX{} document
starts by declaring what \textbf{\textit{document
class}}\label{documentclass}\index{document
class@\textbf{\textit{document
class}}} it belongs to.
\section{The Document Class Declaration}
\label{docdecl}
\index{document class}
To tell \LaTeX{} what class of document you are going to
create, you type a special first line into your file which
identifies it.\footnote{Readers familiar with SGML\index{SGML@SGML},
HTML\index{HTML@HTML}, or XML\index{XML@XML} will recognize the concept as
similar to the Document Type
Declaration.} To start a report, for
example, you would type the \command{documentclass}
command like this as your first line:
\begin{sourcecode}\begin{Verbatim}[fontsize=\small]
\documentclass{report}
\end{Verbatim}
\end{sourcecode}
There are four built-in classes provided, and many others
that you can download (some may already be installed for
you):
\begin{description}
\item[\sffamily \package{report}]
for business, technical, legal, academic, or
scientific reports;
\item[\sffamily \package{article}]
for white papers, magazine or journal articles,
reviews, conference papers, or research notes;
\item[\sffamily \package{book}]
for books and theses;
\item[\sffamily \package{letter}]
for letters.\footnote{The built-in \package{letter}
class is rather idiosyncratic: there are much better
ones you can download, such as
the \package{memoir} and
\package{komascript} packages.}
\end{description}
The \package{article} class in particular
can be used (some would say `abused') for almost
any short piece of typesetting by simply omitting the titling
and layout (see below).
The built-in classes are intended as starting-points,
especially for drafts and for compatibility when exchanging
documents with other \LaTeX{} users, as they come with every
copy of \LaTeX{} and are therefore guaranteed to format
identically everywhere. \emph{They are \emph{\textbf{not}} intended as final-format
publication-quality layouts.} For most other
purposes, especially for publication, you use
add-in packages (\S\thinspace\ref{packages}) to extend
these classes to do what you need:
\begin{itemize}
\item
The \package{memoir} and
\package{komascript} packages contain
more sophisticated replacements for all the built-in
classes;
\item
Many academic and scientific publishers provide their
own special class files for articles and books (often on
their Web sites for download);
\item
Conference organisers may also provide class files for
authors to write papers for presentation;
\item
Many universities provide their own thesis document
class files in order to ensure exact fulfillment of their
formatting requirements;
\item
Businesses and other organizations can provide their
users with corporate classes on a central server and
configure \LaTeX{} installations to look there first for
packages, fonts, etc.
\end{itemize}
Books and journals are not usually printed on office-size
paper. Although \LaTeX{}'s layouts are designed to fit on
standard A4 or Letter stationery for draft purposes, it makes
them look odd: the margins are too wide, or the positioning is
unusual, or the font size is too small, because the finished
job will normally be trimmed to a different size
entirely\mdash{}try trimming the margins of the PDF\index{PDF@PDF} version of this book to 185mm by 235mm
(the same as \titlecite{companion} series)
and you'll be amazed at how it changes the appearance!
\subsection{Document class options}
\label{doclayout}
\index{paper sizes}
The default layouts are designed to fit as drafts on US
Letter size paper.\footnote{Letter size is 8½$''$$\times$11$''$, which is the
trimmed size of the old Demi Quarto, still in use in
North America. The other common US office size is
`Legal', which is
8½$''$$\times$14$''$, a bastard cutting close to
the old Foolscap (8¼$''$$\times$13¼$''$). ISO
standard `A',
`B', and
`C' paper sizes are still
virtually unknown in many parts of North America.} To create documents with the correct proportions
for standard A4 paper, you need to specify the paper size in
an optional argument in square brackets before the document
class name, e.g.
\begin{sourcecode}\begin{Verbatim}[fontsize=\small]
\documentclass[a4paper]{report}
\end{Verbatim}
\end{sourcecode}
The two most common options are \opt{a4paper}
and \opt{letterpaper}. However, many European
distributions of \TeX{} now come preset for A4, not Letter, and
this is also true of all distributions of
\product{pdf\LaTeX{}}.
The other default settings are for: \begin{inparaenum}[\itshape a\upshape)] \item 10pt type (all document classes); \item two-sided printing (books and reports) or
one-sided (articles and letters); and \item separate title page (books and reports
only)\end{inparaenum}. These can be modified with the following
document class options which you can add in the same set of
square brackets, separated by commas:
\index{fonts!sizes}\begin{description}
\label{docfontsize}
\item[\sffamily \opt{11pt}]
to specify 11pt type (headings, footnotes,
etc. get scaled up or down in
proportion);
\item[\sffamily \opt{12pt}]
to specify 12pt type (again, headings
scale);
\item[\sffamily \opt{oneside}]
to format one-sided printing for books and
reports;
\item[\sffamily \opt{twoside}]
to format articles for two-sided printing;
\item[\sffamily \opt{titlepage}]
to force articles to have a separate title
page;
\item[\sffamily \opt{draft}]
makes \LaTeX{} indicate hyphenation and
justification problems with a small square in the
right-hand margin of the problem line so they can be
located quickly by a human.
\end{description}
If you were using pdf\LaTeX{} for a report to be in 12pt
type on Letter paper, but printed one-sided in draft mode, you
would use:
\begin{sourcecode}\begin{Verbatim}[fontsize=\small]
\documentclass[12pt,letterpaper,oneside,draft]{report}
\end{Verbatim}
\end{sourcecode}
There are extra preset options for other type sizes
which can be downloaded separately, but 10pt, 11pt, and 12pt
between them cover probably 99\% of all document
typesetting. In addition there are the hundreds of add-in
packages which can automate other layout and formatting
variants without you having to program anything by hand or
even change your text.
\begin{exercise}
\label{firstline}
\addcontentsline{loe}{section}{\numberline{1}Create a new document}
\subsubsection*{Create a new document}\begin{enumerate}\item
Use your editor to create a new document.
\item
Type in a Document Class Declaration as shown
above.
\item
Add a font size option if you wish.
\item
In North America, omit the
\opt{a4paper} option or change it to
\opt{letterpaper}.
\item
Save the file (make up a name) ensuring the name
ends with \url+.tex+
\end{enumerate}
\end{exercise}
\section{The document environment}
\label{docenv}
After the Document Class Declaration, the text of your
document is enclosed between two commands which identify the
beginning and end of the actual document:
\begin{sourcecode}\begin{Verbatim}[fontsize=\small]
\documentclass[11pt,a4paper,oneside]{report}
\begin{document}
...
\end{document}
\end{Verbatim}
\end{sourcecode}
(You would put your text where the dots are.) The reason
for marking off the beginning of your text is that \LaTeX{}
allows you to insert extra setup specifications before it
(where the blank line is in the example above: we'll be
using this soon). The reason for marking off the end of your
text is to provide a place for \LaTeX{} to be programmed to do
extra stuff automatically at the end of the document, like
making an index.
A useful side-effect of marking the end of the document
text is that you can store comments or temporary text
underneath the \verb+\end{document}+ in the
knowledge that \LaTeX{} will never try to typeset them.
\begin{sourcecode}\begin{Verbatim}[fontsize=\small]
...
\end{document}
Don't forget to get the extra chapter from Jim!
\end{Verbatim}
\end{sourcecode}
\label{environments}%
This
\command{begin}\thinspace{}\dots \command{end}
pair of commands is an example of a common \LaTeX{} structure called an
\textbf{\textit{environment}}\label{environment}\index{environment@\textbf{\textit{environment}}}.
Environments enclose text which is to be handled in a particular
way. All environments start with
\verb+\begin{...}+ and end with
\verb+\end{...}+ (putting the name of the
environment in the curly braces).
\begin{exercise}
\addcontentsline{loe}{section}{\numberline{2}Adding the document environment}
\subsubsection*{Adding the document environment}\begin{enumerate}\item
Add the \env{document} environment to
your file.
\item
Leave a blank line between the Document Class
Declaration and the \verb+\begin{document}+
(you'll see why later).
\item
Save the file.
\end{enumerate}
\end{exercise}
\section{Titling}
\label{titling}
\index{titles}
The first thing you put in the
\env{document} environment is almost always the
document title, the author's name, and the date (except
in letters, which have a special set of commands for
addressing which we'll look at later). The title, author,
and date are all examples of \textbf{\textit{metadata}}\label{metadata}\index{metadata@\textbf{\textit{metadata}}} or \textbf{\textit{metainformation}}\label{metainformation}\index{metainformation@\textbf{\textit{metainformation}}} (information
\emph{about} information).
\begin{sourcecode}\begin{Verbatim}[fontsize=\small]
\documentclass[11pt,a4paper,oneside]{report}
\begin{document}
\title{Practical Typesetting}
\author{Peter Flynn\\Silmaril Consultants}
\date{December 2004}
\maketitle
\end{document}
\end{Verbatim}
\end{sourcecode}
The \command{title}, \command{author},
and \command{date} commands are
self-explanatory. You put the title, author name, and date in
curly braces after the relevant command. The title and author
are usually compulsory; if you omit the
\command{date} command, \LaTeX{} uses today's
date by default.
You always finish the metadata with the
\command{maketitle} command, which tells
\LaTeX{} that it's complete and it can typeset the titling
information at this point. If you omit
\command{maketitle}, the titling will never be
typeset. This command is reprogrammable so you can alter the
appearance of titles (like I did for the printed version of
this document).
The double backslash (\verb+\\+) is the
\LaTeX{} command for forced linebreak. \LaTeX{} normally decides by
itself where to break lines, and it's usually right, but
sometimes you need to cut a line short, like here, and start a
new one. I could have left it out and just used a comma, so my
name and my company would all appear on the one line, but I
just decided that I wanted my company name on a separate line.
In some publishers' document classes, they provide a special
\command{affiliation} command to put your company
or institution name in instead.
When this file is typeset, you get something like this
(I've cheated and done it in
colour (\S\thinspace\ref{colorpkg}) for fun\mdash{}yours will be in black and white
for the moment):
\begin{center}
\fbox{\includegraphics[width=\textwidth]{title}}
\end{center}
\begin{exercise}
\addcontentsline{loe}{section}{\numberline{3}Adding the metadata}
\subsubsection*{Adding the metadata}\begin{enumerate}\item
Add the \command{title},
\command{author}, \command{date}, and
\command{maketitle} commands to your
file.
\item
Use your own name, make up a title, and give a
date.
\end{enumerate}
The order of the first three commands is not important,
but the \command{maketitle} command must come
last.
\end{exercise}
The document isn't really ready for printing like this,
but if you're really impatient, look at \chaptername~\ref{process} to see how to typeset and display
it.
\section{Abstracts and summaries}
\label{abstracts}
\index{abstracts}\index{summaries}
In reports and articles it is normal for the author
to provide an Summary or Abstract, in which you describe
briefly what you have written about and explain its
importance. Abstracts in articles are usually only a few
paragraphs long. Summaries in reports can run to several
pages, depending on the length and complexity of the report
and the readership it's aimed at.
In both cases (reports and articles) the Abstract or
Summary is optional (that is, \LaTeX{} doesn't force you
to have one), but it's rare to omit it because readers want
and expect it. In practice, of course, you go back and type
the Abstract or Summary \emph{after} having
written the rest of the document, but for the sake of the
example we'll jump the gun and type it now.
\begin{sourcecode}\begin{Verbatim}[fontsize=\small]
\documentclass[11pt,a4paper,oneside]{report}
\usepackage[latin1]{inputenc}
\renewcommand{\abstractname}{Summary}
\begin{document}
\title{Practical Typesetting}
\author{Peter Flynn\\Silmaril Consultants}
\date{December 2004}
\maketitle
\begin{abstract}
This document presents the basic concepts of
typesetting in a form usable by non-specialists. It
is aimed at those who find themselves (willingly or
unwillingly) asked to undertake work previously sent
out to a professional printer, and who are concerned
that the quality of work (and thus their corporate
æsthetic) does not suffer unduly.
\end{abstract}
\end{document}
\end{Verbatim}
\end{sourcecode}
After the \command{maketitle} you use the
\env{abstract} environment, in which you simply
type your Abstract or Summary, leaving a blank line between
paragraphs if there's more than one (see \S\thinspace\ref{paragraphs} for this convention).
In business and technical documents, the Abstract is often
called a Management Summary, or Executive Summary, or Business
Preview, or some similar phrase. \LaTeX{} lets you change the
name associated with the \env{abstract}
environment to any kind of title you want, using the
\command{renewcommand} command to give the command
\command{abstractname} a new value:
\begin{sourcecode}\begin{Verbatim}[fontsize=\small]
\renewcommand{\abstractname}{Executive Summary}
\end{Verbatim}
\end{sourcecode}
\begin{exercise}
\addcontentsline{loe}{section}{\numberline{4}Using an Abstract or Summary}
\subsubsection*{Using an Abstract or Summary}\begin{enumerate}\item
Add the \command{renewcommand} as shown
above to your Preamble.
The Preamble is at the start of the document, in
that gap \emph{after} the
\command{documentclass} line but
\emph{before} the
\verb+\begin{document}+ (remember I said
we'd see what we left it blank for: see the panel `The Preamble' \testpage[below]{preamble}).
\item
Add an \env{abstract} environment
after the \command{maketitle} and type in a
paragraph or two of text.
\item
Save the file (no, I'm not paranoid, just
careful).
\end{enumerate}
\end{exercise}
Notice how the name of the command you are renewing (here,
\command{abstractname}) goes in the first set of
curly braces, and the new value you want it to have goes in
the second set of curly braces (this is an example of a
command with two arguments). The environment you use is still
called \env{abstract} (that is, you still type
\verb+\begin{abstract}+\dots \verb+\end{abstract}+).
What the \command{abstractname} does is change the
name that gets displayed and printed, not the name of the
environment you store the text in.
If you look carefully at the example document, you'll
see I sneakily added an extra command to the Preamble.
We'll see later what this means (Brownie points for
guessing it, though, if you read \S\thinspace\ref{accents}).
\begin{sidebar}\label{preamble}
\subsection*{The Preamble}
Modifications which you want to affect a whole document
go at the start of your \LaTeX{} file, immediately
after the \command{documentclass} line and before
the \verb+\begin{document}+ line:
\begin{sourcecode}\begin{Verbatim}[fontsize=\small]
\documentclass[11pt,a4paper,oneside]{report}
\renewcommand{\abstractname}{Sneak Preview}
\begin{document}
...
\end{document}
\end{Verbatim}
\end{sourcecode}
This position, between the Document Class Declaration
and the beginning of the \env{document}
environment, is called the \textbf{\textit{preamble}}\label{pre}\index{preamble@\textbf{\textit{preamble}}}, and it is used for small or
temporary modifications to the style and behaviour of the
document. Major or permanent modifications should go in a
\url+.sty+ file and be invoked with a
\command{usepackage} command.
\end{sidebar}\section{Sections}
\label{sections}
\index{sections}
In the body of your document, \LaTeX{} provides seven
levels of division or sectioning for you to use in structuring
your text. They are all optional: it is perfectly possible to
write a document consisting solely of paragraphs of
unstructured text. But even novels are normally divided into
chapters, although short stories are often made up solely of
paragraphs.
Two of these divisions, Parts and Chapters, are only
available in the \package{book} and
\package{report} document classes, because they
don't have any meaning in articles and letters.\footnote{It is arguable that chapters also have no place in
reports, either, as these are conventionally divided into
sections as the top-level division. \LaTeX{}, however,
assumes your reports have chapters, but this is only the
default, and can be changed very simply (see
\S\thinspace\ref{reprog}).\label{repchap}}
\begingroup\small \begin{center}
\label{secdepths}
\begin{tabular}{@{}clll@{}}
\textbf{\sffamily\upshape Depth}&\textbf{\sffamily\upshape Division}&\textbf{\sffamily\upshape Command}&\textbf{\sffamily\upshape Notes}\\[2pt]\hline\\[-1.5\baselineskip]
\(\ifmmode-\else$-$\fi{}1\)&Part&\command{part}&Books and reports\\
0&Chapter&\command{chapter}&Books and reports\\
1&Section&\command{section}&Not in letters\\
2&Subsection&\command{subsection}&Not in letters\\
3&Subsubsection&\command{subsubsection}&Not in letters\\
4&Titled paragraph&\command{paragraph}&Not in letters\\
5&Titled subparagraph&\command{subparagraph}&Not in letters\\
\end{tabular}
\end{center}
\endgroup
In each case the title of the part, chapter, section,
etc. goes in curly braces after the command. \LaTeX{}
automatically calculates the correct numbering and prints the
title in bold. You can turn section numbering off at a
specific depth: details in \S\thinspace\ref{secnum}.
\begin{sourcecode}\begin{Verbatim}[fontsize=\small]
\section{New recruitment policies}
...
\subsection{Effect on staff turnover}
...
\chapter{Business plan 2005--2007}
\end{Verbatim}
\end{sourcecode}
There are packages\footnote{Details of how to use \LaTeX{} packages are in \S\thinspace\ref{packages}.} to let you control the typeface, style, spacing,
and appearance of section headings: it's much easier to
use them than to try and reprogram the headings manually. Two
of the most popular are the \package{ssection}
and \package{sectsty} packages.
Headings also get put automatically into the Table of
Contents, if you specify one (it's optional). But if you
make manual styling changes to your heading, for example a
very long title, or some special line-breaks or unusual
font-play, this would appear in the Table of Contents as well,
which you almost certainly \emph{don't}
want. \LaTeX{} allows you to give an optional extra version of
the heading text which only gets used in the Table of Contents
and any running heads, if they are in effect (\S\thinspace\ref{runningheads}). This optional alternative
heading goes in [square brackets] before the curly
braces:
\begin{sourcecode}\begin{Verbatim}[fontsize=\small]
\section[Effect on staff turnover]{An analysis of the
effect of the revised recruitment policies on staff
turnover at divisional headquarters}
\end{Verbatim}
\end{sourcecode}
\begin{exercise}
\addcontentsline{loe}{section}{\numberline{5}Start your document text}
\subsubsection*{Start your document text}\begin{enumerate}\item
Add a \command{chapter} command after your
Abstract or Summary, giving the title of your first
chapter.
\item
If you're planning ahead, add a few more
\command{chapter} commands for
subsequent chapters. Leave a few blank lines between
them to make it easier to add paragraphs of text
later.
\item
By now I shouldn't need to tell you what to do
after making significant changes to your document
file.
\end{enumerate}
\end{exercise}
\subsection{Section numbering}
\label{secnum}
\index{section numbering}
All document divisions get numbered automatically. Parts
get Roman numerals (Part I, Part II, etc.);
chapters and sections get decimal numbering like this
document, and Appendixes (which are just a special case of
chapters, and share the same structure) are lettered (A, B,
C, etc.).
You can change the depth to which section numbering
occurs, so you can turn it off selectively. In this document
it is set
to \arabic{secnumdepth}.
If you only want parts, chapters, and sections numbered, not
subsections or subsubsections etc., you can change the
value of the \counter{secnumdepth}
counter using the the \command{setcounter} command,
giving the depth value from the table on p.\thinspace\pageref{secdepths}:
\begin{sourcecode}\begin{Verbatim}[fontsize=\small]
\setcounter{secnumdepth}{1}
\end{Verbatim}
\end{sourcecode}
A related counter is \counter{tocdepth}, which specifies what
depth to take the Table of Contents to. It can be reset in
exactly the same way as \counter{secnumdepth}. The current setting
for this document is \arabic{tocdepth}.
\begin{sourcecode}\begin{Verbatim}[fontsize=\small]
\setcounter{tocdepth}{3}
\end{Verbatim}
\end{sourcecode}
To get an \emph{unnumbered} section
heading which does \emph{not} go into the
Table of Contents, follow the command name with an asterisk
before the opening curly brace:
\begin{sourcecode}\begin{Verbatim}[fontsize=\small]
\subsection*{Shopping List}
\end{Verbatim}
\end{sourcecode}
All the divisional commands from
\command{part*} to \command{subparagraph*}
have this `starred' version which can
be used on special occasions for an unnumbered heading when
the setting of \counter{secnumdepth}
would normally mean it would be numbered.
\section{Ordinary paragraphs}
\label{paragraphs}
After section headings comes your text. Just type it and
leave a blank line between paragraphs. That's all
\LaTeX{} needs.
The blank line means `start a new paragraph
here': it does \emph{not} (repeat:
\emph{\textbf{not}}) mean you get a blank
line in the typeset output. Now read this paragraph
again and again until that sinks in.
The spacing between paragraphs is a separately definable
quantity, a \textbf{\textit{dimension}}\label{dimension}\index{dimension@\textbf{\textit{dimension}}} or
\textbf{\textit{length}}\label{length}\index{length@\textbf{\textit{length}}} called \length{parskip}. This is normally zero
(no space between paragraphs, because that's how books
are normally typeset), but you can easily set it to any size
you want with the \command{setlength} command in the
Preamble:
\begin{sourcecode}\begin{Verbatim}[fontsize=\small]
\setlength{\parskip}{1cm}
\end{Verbatim}
\end{sourcecode}
\label{paraspace}%
This will set the space between paragraphs
to 1cm. See \S\thinspace\ref{dimensions} for details of the
various size units \LaTeX{} can use. \emph{Leaving
multiple blank lines between paragraphs in your source
document achieves nothing}: all extra blank lines
get ignored by \LaTeX{} because the space between paragraphs
is
controlled only by the value of \length{parskip}.
White-space in \LaTeX{} can also be made flexible (what
\authorof{latexbook} calls
`rubber' lengths). This means that
values such as \length{parskip} can
have a default dimension plus an amount of expansion minus an
amount of contraction. This is useful on pages in complex
documents where not every page may be an exact number of
fixed-height lines long, so some give-and-take in vertical
space is useful. You specify this in a
\command{setlength} command like this:
\begin{sourcecode}\begin{Verbatim}[fontsize=\small]
\setlength{\parskip}{1cm plus4mm minus3mm}
\end{Verbatim}
\end{sourcecode}
Paragraph indentation can also be set with the
\command{setlength} command, although you would
always make it a fixed size, never a flexible one, otherwise
you would have very ragged-looking paragraphs.
\begin{sourcecode}\begin{Verbatim}[fontsize=\small]
\setlength{\parindent}{6mm}
\end{Verbatim}
\end{sourcecode}
By default, the first paragraph after a heading follows
the standard Anglo-American publishers' practice of
\emph{no} indentation. Subsequent paragraphs are
indented by the value of \length{parindent} (default
18pt).\footnote{Paragraph spacing and indentation are cultural
settings. If you are typesetting in a language other than
English, you should use the \package{babel}
package, which alters many things, including the spacing
and the naming of sections, to conform with the standards
of different countries and languages.} You can change this in the same way as any other
length.
In the printed copy of this document, the paragraph
indentation is set to \the\parindent and the space
between paragraphs is set to \the\parskip. These values do not
apply in the Web (HTML\index{HTML@HTML}) version because not all browsers are
capable of that fine a level of control, and because users can
apply their own stylesheets regardless of what this document
proposes.
\begin{exercise}
\addcontentsline{loe}{section}{\numberline{6}Start typing!}
\subsubsection*{Start typing!}\begin{enumerate}\item
Type some paragraphs of text. Leave a blank line
between each. Don't bother about line-wrapping or
formatting\mdash{}\LaTeX{} will take care of all
that.
\item
If you're feeling adventurous, add a
\command{section} command with the title of a
section within your first chapter, and continue typing
paragraphs of text below that.
\item
Add one or more \command{setlength}
commands to your Preamble if you want to experiment with
changing paragraph spacing and indentation.
\end{enumerate}
\end{exercise}
To turn off indentation completely, set it to zero (but
you still have to provide units: it's still a
measure!).
\begin{sourcecode}\begin{Verbatim}[fontsize=\small]
\setlength{\parindent}{0in}
\end{Verbatim}
\end{sourcecode}
If you do this, though, and leave \length{parskip} set to zero, your readers
won't be able to tell easily where each paragraph begins!
If you want to use the style of having no indentation with a
space between paragraphs, use the
\package{parskip} package, which does it for
you (and makes adjustments to the spacing of lists and other
structures which use paragraph spacing, so they don't get
too far apart).
\section{Table of contents}
\label{toc}
\index{table of contents!automated entries}
All auto-numbered headings get entered in the Table of
Contents (ToC) automatically. You don't have to print a
ToC, but if you want to, just add the command
\command{tableofcontents} at the point where you want
it printed (usually after the Abstract or Summary).
Entries for the ToC are recorded each time you process
your document, and reproduced the \emph{next}
time you process it, so you need to re-run \LaTeX{} one extra
time to ensure that all ToC page-number references
are correctly calculated.
We've already seen in \S\thinspace\ref{sections} how
to use the optional argument to the sectioning commands to add
text to the ToC which is slightly different from the one
printed in the body of the document. It is also possible to
add extra lines to the ToC, to force extra or unnumbered
section headings to be included.
\begin{exercise}
\addcontentsline{loe}{section}{\numberline{7}Inserting the table of contents}
\subsubsection*{Inserting the table of contents}\begin{enumerate}\item
Go back and add a \command{tableofcontents}
command after the \verb+\end{abstract}+ command
in your document.
\item
You guessed.
\end{enumerate}
\end{exercise}
\label{loflot}%
The commands \command{listoffigures}
and \command{listoftables} work in exactly the same
way as \command{tableofcontents} to automatically
list all your tables and figures. If you use them, they
normally go after the \command{tableofcontents}
command.
The \command{tableofcontents} command normally
shows only numbered section headings, and only down to the
level defined by the \counter{tocdepth} counter (see \S\thinspace\ref{secnum}), but you can add extra entries with the
\command{addcontentsline} command. For example if you
use an unnumbered section heading command to start a
preliminary piece of text like a Foreword or Preface, you can
write:\index{table of contents!adding manual entry}
\begin{sourcecode}\begin{Verbatim}[fontsize=\small]
\subsection*{Preface}
\addcontentsline{toc}{subsection}{Preface}
\end{Verbatim}
\end{sourcecode}
This will format an unnumbered ToC entry for
`Preface' in the
`subsection' style. You can use
the same mechanism to add lines to the List of Figures or List
of Tables by substituting \url+lof+ or
\url+lot+ for \url+toc+.
\chapter{Typesetting, viewing and printing}
\label{process}
\index{typesetting}\index{viewing}\index{printing}
We've now got far enough to typeset what you've
entered. I'm assuming at this stage that you have typed
some sample text in the format specified in the previous
chapter, and you've saved it in a plain-text file with a
filetype of
\verb+.tex+ and a name of your own choosing.
\index{filenames}\begin{exercise}
\addcontentsline{loe}{section}{\numberline{8}Saving your file}
\subsubsection*{Saving your file}
If you haven't already saved your file, do so now
(some editors and interfaces let you typeset the document
without saving it!).
Pick a sensible filename in a sensible directory. Names
should be short enough to display and search for, but
descriptive enough to make sense. See the panel `Picking suitable filenames' \testpage[below]{filenames} for more details.
\end{exercise}
\begin{sidebar}\label{filenames}
\subsection*{Picking suitable filenames}
Never, ever use directories (folders) or file names
which contain spaces. Although your operating system
probably supports them, some don't, and they will
only cause grief and tears with \TeX{}.
Make filenames as short or as long as you wish, but
strictly avoid spaces. Stick to upper- and lower-case
letters without accents (A\ndash{}Z and a\ndash{}z), the
digits 0\ndash{}9, the hyphen (\verb+-+), and
the full point or period (\verb+.+), (similar
to the conventions for a Web URI\index{URI@URI}): it will let you refer to \TeX{}
files over the Web more
easily and make your files more portable.
\end{sidebar}\section{Typesetting}
\label{setting}
Typesetting your document is usually done by clicking
on a button in a toolbar or an entry in a menu. Which one you
click on depends on what output you want\mdash{}there are two
formats available:
\begin{itemize}
\item
The standard (default) \LaTeX{} program produces a
device-independent (DVI)\index{DVI@DVI|textbf}\index{Acronyms@\textbf{Acronyms}, defined!DVI@DVI|textbf} file which
can be used with any \TeX{} previewer or printer driver on any
make or model of computer. There are dozens of these
available: at least one of each (previewer and printer
driver) should have been installed with your distribution
of \TeX{}.
\item
The \product{pdf\LaTeX{}} program
produces an Adobe Acrobat PDF\index{PDF@PDF}
file which can be used with any suitable previewer, such
as \product{GSview},
\product{PDFview},
\product{Xpdf}, the
\product{Opera} browser, or Adobe's
own \product{Acrobat Reader}.
\end{itemize}
Depending on which one you choose, you may have to
[re]configure your editor so that it runs the right program.
They can all do all of them, but they don't always come
pre-set with buttons or menus for every possible option,
because they can't guess which one you want.
\subsection{Standard \LaTeX{}}
There are also two ways of running \LaTeX{}: from the
toolbar or menu, or from the command line. Toolbars and
menus are most common in graphical systems, and are the
normal way to run \LaTeX{}. Command lines are used in
non-graphical systems and in automated processes where
\LaTeX{} is run
unattended (so-called `batch' or
`scripted' processing).
Whichever way you run \LaTeX{}, it will process your
file and display a log or record of what it's doing
(see Exercise~\ref{terminal}: it looks the
same no matter what system you use). This is to let you see
where (if!) there are any errors or problems.
\begin{exercise}
\addcontentsline{loe}{section}{\numberline{9}Running from the toolbar or menu}
\subsubsection*{Running \LaTeX{} from the toolbar or menu}
Run \LaTeX{} on your file according to which system
you're using:
\begin{itemize}
\item
In \product{WinEdt}, click the
\guiicon{\LaTeX{}} toolbar icon;
\item
In \product{Emacs}, click the
\menuitem{\TeX{}}{\TeX{}
File} menu item.
\end{itemize}
Your editor may suggest you save your file if you
haven't already done so. Do it.
\end{exercise}
If \LaTeX{} reports any errors\mdash{}easily identifiable
as lines in the log beginning with an exclamation mark
(!)\mdash{}\emph{don't panic!} Turn to \S\thinspace\ref{errmsg}, identify what went wrong, and fix it in
your input file. Then re-run \LaTeX{}. If there were no
errors, your file is ready for displaying or
printing.
\subsection{Running \LaTeX{} from a command window}
\label{cmdwin}
This is worth practising even if you normally use a
GUI\index{GUI@GUI}, so that you understand what it
does. See Figure~\ref{cliex} for an example.
\begin{exercise}
\label{terminal}
\addcontentsline{loe}{section}{\numberline{10}Running in a terminal or console
window}
\subsubsection*{Running \LaTeX{} in a terminal or console
window}\begin{itemize}
\item
Under graphical Unix-based systems (Linux and Mac)
you open a command (shell) window by clicking on the
shell or screen icon in the control panel at the
bottom of your screen.
\item
Under Microsoft Windows you open a command window
by clicking on the
\menuitem{Start}{Programs}[MS-DOS]
or
\menuitem{Start}{Command
Prompt} menu item.
\end{itemize}
When the command window appears, type
\begin{sourcecode}\begin{Verbatim}[fontsize=\small,commandchars=\\\{\}]
cd \textsl{\uline{documents}}
latex \textsl{\uline{mybook}}
\end{Verbatim}
\end{sourcecode}
Substitute the relevant directory and file name.
Remember to press the \key{Enter} key at the
end of each line.
\end{exercise}
\begin{figure}\small
\caption{\small Command-line usage}
\label{cliex}
\begin{center}
\label{clidemo}\includegraphics[width=0.75\textwidth]{terminal}
\end{center}
\end{figure}
\subsection{pdf\LaTeX{}}
If you have configured your system to generate PDF\index{PDF@PDF} files direct instead of DVI\index{DVI@DVI} files (by using the
\product{pdf\LaTeX{}} program instead of
standard \LaTeX{}), then you can click the
\guiicon{pdf\LaTeX{}} icon in
\product{WinEdt} or type the command
\verb+pdflatex+ instead of
\verb+latex+ in a terminal (console) window.
\product{Emacs} does not have a default
menu configured for
\product{pdf\LaTeX{}}.
\section{Errors and warnings}
\label{errmsg}
\LaTeX{} describes what it's typesetting while it does it,
and if it encounters something it doesn't understand or can't
do, it will display a message saying what's wrong. It may
also display warnings for less serious conditions.
\begin{center}
\includegraphics[width=0.5\textwidth]{dontpanic}
\end{center}
\emph{Don't panic if you see error
messages}: it's very common for beginners to
mistype or mis-spell commands, forget curly braces, type a
forward slash instead of a backslash, or use a special
character by mistake. Errors are easily spotted and easily
corrected in your editor, and you can then run \LaTeX{} again
to check you have fixed everything. Some of the most common
errors are described in \S\thinspace\ref{errmsg} with an
explanation of how to fix them.
\subsection{Error messages}
\label{errs}
The format of an error message is always the same. Error
messages begin with an exclamation mark at the start of the
line, and give a description of the error, followed by another
line starting with the number, which refers to the line-number
in your document file which \LaTeX{} was processing when the
error was spotted. Here's an example, showing that the user
mistyped the \command{tableofcontents}
command:
\begin{sourcecode}\begin{Verbatim}[fontsize=\small]
! Undefined control sequence.
l.6 \tableofcotnetns
\end{Verbatim}
\end{sourcecode}
When \LaTeX{} finds an error like this, it displays the
error message and pauses. You must type one of the following
letters to continue:
\begingroup\small \begin{center}
\begin{tabular}{cp{4in}}
\textbf{\sffamily\upshape Key}&\textbf{\sffamily\upshape Meaning}\\[2pt]\hline\\[-1.5\baselineskip]
\key{x}&Stop immediately and e\emph{\textbf{x}}it the program.\\
\key{q}&Carry on \emph{\textbf{q}}uietly as best you can and
don't bother me with any more error
messages.\\
\key{e}&Stop the program but re-position the text in my
\emph{\textbf{e}}ditor at the point
where you found the error.\tablefootnote{TF-1}\\
\key{h}&Try to give me more \emph{\textbf{h}}elp.\\
\key{i}&(followed by a correction) means \emph{\textbf{i}}nput the correction in
place of the error and carry on.\tablefootnote{TF-2}\\
\end{tabular}
\renewcommand{\theenumi}{\textit{\alph{enumi}}}\footnotesize\begin{enumerate*}\item This only works if you're using an editor
which \LaTeX{} can communicate with.\label{TF-1}\item This is only a temporary fix to get the file
processed. You still have to make that
correction in the editor.\label{TF-2}\end{enumerate*}\end{center}
\endgroup
Some systems (\product{Emacs} is one
example) run \LaTeX{} with a
`non-stop' switch turned on, so it
will always process through to the end of the file,
regardless of errors, or until a limit is reached.
\subsection{Warnings}
\label{warn}
Warnings don't begin with an exclamation mark: they are
just comments by \LaTeX{} about things you might want to look
into, such as
overlong or underrun lines (often caused by unusual hyphenations, for
example), pages running short or long, and other typographical
niceties (most of which you can ignore until later).
Unlike other systems, which try to hide unevennesses in
the text\mdash{}usually unsuccessfully\mdash{}by interfering
with the letter-spacing, \LaTeX{} takes the view that the
author or editor should be able to contribute. While it is
certainly possible to set \LaTeX{}'s parameters so that
the spacing is sufficiently sloppy that you will almost never
get a warning about badly-fitting lines or pages, you will
almost certainly just be delaying matters until you start to
get complaints from your readers or publishers.
\subsection{Examples}
Only a few common error messages are given here: those
most likely to be encountered by beginners. If you find
another error message not shown here, and it's not
clear what you should do, ask for help. Most error messages
are self-explanatory, but because some errors can only be
righted by humans who can read and understand what it's
supposed to mean, they don't get spotted by \LaTeX{}
until much later, leading to several
messages in a row.
Newcomers should remember to check the list of special
characters in (\S\thinspace\ref{specials}): a very large
number of errors when you are learning \LaTeX{} are due to
accidentally typing a special character when you didn't
mean to. This disappears after a few days as you get used to
them.
\subsubsection{Too many {\ttfamily\char'175}'s}
\label{toomany}
\index{Too many {\ttfamily\char'175}'s}\index{Error messages!Too many {\ttfamily\char'175}'s}\begin{sourcecode}\begin{Verbatim}[fontsize=\small]
! Too many }'s.
l.6 \date December 2004}
\end{Verbatim}
\end{sourcecode}
The reason \LaTeX{} thinks there are too many
\verb+}+'s here is that the opening curly
brace is missing after the \command{date} control
sequence and before the word \verb+December+,
so the closing curly brace is seen as one too many (which
it is!).
In fact, there are other things which can follow the
\command{date} command apart from a date in curly
braces, so \LaTeX{} cannot possibly guess that
you've missed out the opening curly brace\mdash{}until
it finds a closing one!
\subsubsection{Undefined control sequence}
\label{undefcs}
\index{Undefined control sequence}\index{Error messages!Undefined control sequence}\begin{sourcecode}\begin{Verbatim}[fontsize=\small]
! Undefined control sequence.
l.6 \dtae
{December 2004}
\end{Verbatim}
\end{sourcecode}
In this example, \LaTeX{} is complaining that it has
no such command (`control
sequence') as \verb+\dtae+.
Obviously it's been mistyped, but only a human can
detect that fact: all \LaTeX{} knows is
that \verb+\dtae+ is not a command it knows
about\mdash{}it's undefined.
\subsubsection{Runaway argument}
\label{runaway}
\index{Runaway argument}\index{Error messages!Runaway argument}\begin{sourcecode}\begin{Verbatim}[fontsize=\small]
Runaway argument?
{December 2004 \maketitle
! Paragraph ended before \date was complete.
<to be read again>
\par
l.8
\end{Verbatim}
\end{sourcecode}
In this error, the closing curly brace has been
omitted from the date. It's the opposite of the error in
\S\thinspace\ref{toomany}, and it results in
\command{maketitle} trying to format the title
page while \LaTeX{} is still expecting more text for the
date! As
\command{maketitle} creates new paragraphs on the
title page, this is detected and \LaTeX{} complains that
the
previous paragraph has ended but \command{date}
is not yet finished.
\subsubsection{Underfull hbox}
\label{underfull}
\index{Underfull hbox}\index{Error messages!Underfull hbox}\begin{sourcecode}\begin{Verbatim}[fontsize=\small]
Underfull \hbox (badness 1394) in paragraph
at lines 28--30
[][]\LY1/brm/b/n/10 Bull, RJ: \LY1/brm/m/n/10
Ac-count-ing in Busi-
[94]
\end{Verbatim}
\end{sourcecode}
This is a warning that \LaTeX{} cannot stretch the
line wide enough to fit, without making the spacing bigger
than its currently permitted maximum. The
\textbf{\textit{badness}}\label{badness}\index{badness@\textbf{\textit{badness}}} (0\ndash{}10,000) indicates
how severe this is (here you can probably ignore a badness
of 1394). It says what lines of your file it was
typesetting when it found this, and the number in square
brackets is the number of the page onto which the
offending line was printed.
The codes separated by slashes are the typeface and
font style and size used in the line. Ignore them for the
moment: details are in step~\ref{fdfiles} in the procedure on p.\thinspace\pageref{fdfiles} if you're
curious.
\subsubsection{Overfull hbox}
\label{overfull}
\index{Overfull hbox}\index{Error messages!Overfull hbox}\begin{sourcecode}\begin{Verbatim}[fontsize=\small]
[101]
Overfull \hbox (9.11617pt too wide) in paragraph
at lines 860--861
[]\LY1/brm/m/n/10 Windows, \LY1/brm/m/it/10 see
\LY1/brm/m/n/10 X Win-
\end{Verbatim}
\end{sourcecode}
And the opposite warning: this line is too
long by a shade over 9pt. The chosen hyphenation point
which minimises the error is shown at the end of the line
(\emph{Win-}). Line numbers and page numbers
are given as before. In this case, 9pt is too much to
ignore (over 3mm or more than \(\frac{1}{8}\)$''$), and a manual correction needs
making (such as a change to the hyphenation), or the
flexibility settings need changing (outside the scope of
this book).
\subsubsection{Missing package}
\label{nopkg}
\index{File not found}\index{Error messages!File not found}\begin{sourcecode}\begin{Verbatim}[fontsize=\small]
! LaTeX Error: File `paralisy.sty' not found.
Type X to quit or <RETURN> to proceed,
or enter new name. (Default extension: sty)
Enter file name:
\end{Verbatim}
\end{sourcecode}
When you use the \command{usepackage} command
to request \LaTeX{} to use a certain package, it will look
for a file with the specified name and the filetype
\url+.sty+. In this case the user has
mistyped the name of the \package{paralist}
package, so it's easy to fix. However, if you get the name
right, but the package is not installed on your machine,
you will need to download and install it before continuing
(see \chaptername~\ref{ctan}).
\section{Screen preview}
\label{dvi}
\index{preview}
Once the file has been processed without errors (or even
if there are still errors, but you want to see what it's
doing with them), standard \LaTeX{} will have created a
DVI\index{DVI@DVI} file with the same name as your
document but the filetype
\verb+.dvi+. If you're using
\product{pdf\LaTeX{}}, a PDF\index{PDF@PDF} file will have been created, and you
can skip to
\S\thinspace\ref{pdfview}.
\subsection{Previewing DVI output}
\label{dvipreview}
To see the typeset output, click on the
\menuitem{TeX}{TeX View}
menu item in \product{Emacs} or the
\guiicon{dvi} Preview toolbar icon in
\product{WinEdt}. A What You See Is What You Get (WYSIWYG)\index{WYSIWYG@WYSIWYG|textbf}\index{Acronyms@\textbf{Acronyms}, defined!WYSIWYG@WYSIWYG|textbf}
preview window will appear with your typeset display (see
Figure~\ref{dviview}).
\begin{warning}
\label{bitmappreview}
\subsubsection*{Bitmap preview fonts in DVI viewers}
The first time you display your DVI\index{DVI@DVI} output with a new installation of
\TeX{}, there may be a short pause if the previewer needs
to create the special bitmaps used for screen previews of
some fonts. These give greater accuracy on low-resolution
devices like screens. As you continue to work with
\LaTeX{} and your system accumulates these font files, the
pause for generating them will disappear. Recent versions
of \TeX{} work directly with Type 1 fonts, however,
and don't have this delay.
\end{warning}
\begin{figure}\small
\caption{\small DVI preview}
\label{dviview}
\begin{center}
\includegraphics[width=0.75\textwidth]{xdvi}
\end{center}
\end{figure}
Most previewers have a wide range of scaling, zooming,
and measuring functions, but remember this is a
\emph{picture} of your output: you cannot edit
the image. To change it, you always edit your source text
and reprocess the file.
With \product{xdvi} and its derivatives
like \product{dviview}, you can leave the
display window open, and after you've reprocessed your
document through \LaTeX{}, moving your mouse back into the
window will make the display update automatically (click
your mouse if your windowing system needs a
click to focus).
Figure~\ref{dviview} shows
\product{xdvi} displaying a page. With a
standard three-button mouse you get three levels of
micro-zoom to let you inspect fine details.
\subsection{Previewing with PostScript}
\label{makeps}
PostScript\index{PostScript} is a page description
language invented by Adobe and used in laser printers and
high-end typesetters. It's been the universal standard
for electronically-formatted print files for nearly two
decades, and all printers and publishers are accustomed to
using it. PDF\index{PDF@PDF} is a descendant of
PostScript, and is rapidly taking over, but
PostScript\index{PostScript} itself is still extremely
common, largely because it is very robust, and is usually an
ASCII\index{ASCII@ASCII} file, which makes it very
portable and easy to generate (it is actually a programming
language in its own right). The drawback is the large size
of PostScript\index{PostScript} files, especially if
they contain bitmapped graphics.
The \product{dvips} program which comes
with all \TeX{} systems is used to generate
PostScript\index{PostScript} files directly from your
DVI\index{DVI@DVI} output. These
\url+.ps+ files can be viewed, printed, sent
to a platemaker or filmsetter, or put online for
downloading.
DVI\index{DVI@DVI} viewers cannot render some
PostScript\index{PostScript} graphical manipulations
like rotating and deforming, so an alternative to viewing
the DVI file direct is to generate a
PostScript\index{PostScript} file and use a
PostScript\index{PostScript} viewer. You may have to to
do this for your publisher anyway, and many editors can be
configured to do this by default. Look for a
\guiicon{dvips} toolbar icon or menu entry and
click on it.
It's also very simple to do manually: let's
assume your \LaTeX{} file was called
\url+mydoc.tex+, so processing it has created
\url+mydoc.dvi+. Just type:
\begin{sourcecode}\begin{Verbatim}[fontsize=\small]
dvips -o mydoc.ps mydoc
\end{Verbatim}
\end{sourcecode}
\noindent in a command window (see Exercise~\ref{terminal} for how to use one)
and \product{dvips} will create
\url+mydoc.ps+ which can be used both for
previewing and printing.
To view a PostScript\index{PostScript} file, you
need a PostScript\index{PostScript} previewer like
\product{GSview}, which works with the
PostScript\index{PostScript} interpreter
\product{Ghostscript}, which should have
been installed automatically along with your \TeX{} system
(if not, install both now: \product{GSview}
is separately licensed and cannot legally be included in
some older \TeX{} distributions, so you may have to download
it yourself).
\product{GSview} can be set to watch
the PostScript\index{PostScript} file and automatically
update the display any time the file is changed, without you
even having to click on the window.
\subsection{Previewing with PDF}
\label{pdfview}
The Portable Document Format (PDF)\index{PDF@PDF|textbf}\index{Acronyms@\textbf{Acronyms}, defined!PDF@PDF|textbf}
is a derivative of PostScript\index{PostScript}.
Whereas PostScript\index{PostScript} is a programming
language in itself, PDF\index{PDF@PDF} is in effect
the \emph{result} of processing a document
through PostScript\index{PostScript}: it's a binary
file format, extremely compact, and well-supported on all
platforms.
If your system is configured to generate PDF\index{PDF@PDF} files direct instead of DVI\index{DVI@DVI} files, just open the
\url+.pdf+ file using any PDF\index{PDF@PDF} previewer or browser.
Most editors are configured to display a toolbar icon
which will pop up \product{Acrobat Reader}
or some other viewer with the current PDF\index{PDF@PDF} output file.
Adobe's \product{Acrobat Reader}
cannot automatically update the view if you reprocess your
document, in the way that \product{xdvi}
and \product{GSview} can. You
have to close the display with \key{Ctrl}--\key{W}~ and reload the file with \key{Alt}--\key{F}~\thinspace{}\key{1}.
\begin{warning}
\subsubsection*{Bitmap preview fonts in Acrobat Reader}
Acrobat Reader is extremely poor at rendering
Type 3 (bitmap) fonts. If you are using these (either
in an old \LaTeX{} installation which has not been
upgraded to Type 1, or with files using specialist
fonts only available in Type 3 format), you will see
a very fuzzy display at low magnifications. It will print
perfectly, but Acrobat Reader's display is
disappointing. The solution is to use a better previewer
or to upgrade to the Type 1 versions of the fonts
if possible, or both. If you need to
use Type 3 fonts in PDF\index{PDF@PDF}s,
you probably need to warn your readers to expect a fuzzy
display from Acrobat Reader (but good printout), and to
change to a better reader if they can.
\end{warning}
\section{Printer output}
\label{print}
\index{printing}
\TeX{} systems print on almost anything from the simplest
dot-matrix printers to the biggest phototypesetters, including
all the laser printers and a host of other devices in between.
\emph{How} you do it varies slightly according
to how you do your typesetting and previewing:
\begin{description}
\item[\sffamily If you are using DVI]
and you have a previewer which has a
\textbf{print} function configured for your
printer, you can use that. If not, create a
PostScript\index{PostScript} file and use
\product{GSview} instead.
\item[\sffamily If you are using PDF]
you can print directly from your PDF\index{PDF@PDF} viewer. Be careful about using
the `Fit to page' options, as they will
change the size of your document so all your
measurements will be different.
\item[\sffamily Non-PostScript\index{PostScript} printers]
You can create a PostScript\index{PostScript}
file with \product{dvips} (see \S\thinspace\ref{makeps}) and use
\product{GSview} to print it
(\product{GSview} can print
PostScript\index{PostScript} files to almost any
make or model of non-PostScript\index{PostScript}
printer).
\item[\sffamily If you have a real PostScript\index{PostScript}
printer]
or you are using a system with built-in
PostScript\index{PostScript} printing support (such
as Linux or Mac), you can create and send
PostScript\index{PostScript} output directly from
your editor to the printer without the need to open it
in a previewer first. In
\product{Emacs}, for example, this is
what happens when you use the
\menuitem{\TeX{}}{\TeX{}
Print} menu item.
\end{description}
Both the \product{dvips} program and all
the previewers that print tend to have facilities for printing
selected pages, printing in reverse, scaling the page size,
\index{page size!scaling}\index{printing!reverse order}\index{printing!selected pages} and printing only odd or even pages for two-sided
work. If you are using PostScript\index{PostScript} there
are programs for manipulating the output
(\product{pstops}), for example to perform
page imposition to get 4, 8, or 16 pages to a sheet for making
booklets (\product{psnup}).
\begin{exercise}
\addcontentsline{loe}{section}{\numberline{11}Print it!}
\subsubsection*{Print it!}
Show that you have understood the process of
typesetting, previewing, and printing, by displaying your
document and printing it.
\end{exercise}
If you need a
non-PostScript\index{PostScript}/\product{Ghostscript}
solution, install a separate \TeX{} print driver for your
printer. Some
may be supplied with your \TeX{} installation, and there are
dozens more on CTAN\index{CTAN@CTAN}. Their names all
start with \url+dvi+ and are followed by an
abbreviation for the printer make or model like
\product{dvieps} for Epson,
\product{dvihp} for Hewlett-Packard,
\product{dvialw} for Apple LaserWriters,
etc.. Configure the driver to print directly to the print
queue, or pipe it to the print queue manually. On Linux with
an HP printer, for example, this would be
\begin{sourcecode}\begin{Verbatim}[fontsize=\small]
dvihp mydoc | lpr
\end{Verbatim}
\end{sourcecode}
Microsoft Windows has no easy way to bypass the print
spool, but you can do it from an MS-DOS command window
with (using a HP printer as an example):
\begin{sourcecode}\begin{Verbatim}[fontsize=\small]
dvihp mydoc -o mydoc.hp
copy /b mydoc.hp LPT1:
\end{Verbatim}
\end{sourcecode}
Read the documentation for the driver, as the options and
defaults vary.
\chapter[CTAN, packages, and online help]{CTAN, packages, \newline{}and online help}
\label{ctan}
The Comprehensive \TeX{} Archive
Network (CTAN)\index{CTAN@CTAN|textbf}\index{Acronyms@\textbf{Acronyms}, defined!CTAN@CTAN|textbf} is a repository of Web and FTP\index{FTP@FTP} servers worldwide which contain copies of
almost every piece of free software related to \TeX{} and
\LaTeX{}.
CTAN\index{CTAN@CTAN} is based on three main
servers, and there are several online indexes available. There
are complete \TeX{} and \LaTeX{} systems for all platforms,
utilities for text and graphics processing, conversion programs
into and out of \LaTeX{}, printer drivers, extra typefaces, and
(possibly the most important) the \LaTeX{} packages. The three
main servers are:
\begin{itemize}
\item
\TeX{} Users Group: \url+http://www.ctan.org/+
\item
UK \TeX{} Users Group: \url+http://www.tex.ac.uk/+
\item
Deutschsprachige Anwendervereinigung \TeX{} e.V. (DANTE,
the German-speaking \TeX{} Users Group); \url+http://dante.ctan.org/+
\end{itemize}
\begin{sidebar}
CTAN\index{CTAN@CTAN} should
\emph{always} be your first port of call when
looking for a software update or a feature you want to use.
Please don't ask the network help
resources (\S\thinspace\ref{help}) until you have checked CTAN\index{CTAN@CTAN} and the FAQ\index{FAQ@FAQ} (\S\thinspace\ref{faq}).
\end{sidebar}\section{Packages}
\label{packages}
\index{packages!using}
Add-on features for \LaTeX{} are known as \textbf{\textit{packages}}\label{pack}\index{packages@\textbf{\textit{packages}}}. Dozens of these are
pre-installed with \LaTeX{} and can be used in your documents
immediately. They should all be stored in subdirectories of
\url+texmf/tex/latex+ named after each package.
To find out what other packages are available and what they
do, you should use the CTAN\index{CTAN@CTAN} search page\footnote{\url+http://www.ctan.org/search+} which includes a
link to Graham Williams' comprehensive package
catalogue.
A package is a file or collection of files containing
extra \LaTeX{} commands and programming which add new styling
features or modify those already existing. Installed package
files all end with \url+.sty+ (there may be
ancillary files as well).
When you try to typeset a document which requires a
package which is not installed on your system, \LaTeX{} will
warn you with an error message that it is missing (see \S\thinspace\ref{nopkg}), and you can
then download the package and install it using the
instructions in \S\thinspace\ref{pkginst}. You can also
download updates to packages you already have (both the ones
that were installed along with your version of \LaTeX{} as
well as ones you added).
There is no limit to the number of packages you can have
installed on your computer (apart from disk space!), but there
is probably a physical limit to the number that can be used
inside any one \LaTeX{} document at the same time, although it
depends on how big each package is. In practice there is no
problem in having even a couple of dozen packages active (the
style file for this document uses over 30).
\subsection{Using an existing package}
\label{colorpkg}
To use a package already installed on your system,
insert a \command{usepackage} command in your
document preamble with the package name in curly braces, as
we have already seen in earlier chapters. For example, to
use the \package{color} package, which lets
you typeset in colours (I warned you this was
coming!), you could type:
\begin{sourcecode}\begin{Verbatim}[fontsize=\small]
\documentclass[11pt,a4paper,oneside]{report}
\usepackage{color}
\begin{document}
...
\end{document}
\end{Verbatim}
\end{sourcecode}
You can include several package names in one
\command{usepackage} command by separating the
names with commas, and you can have more than one
\command{usepackage} command.
Some packages allow optional settings in square
brackets. If you use these, you must give the package its
own separate \command{usepackage} command, like
\package{geometry} shown below:
\begin{sourcecode}\label{oldtitle}\begin{Verbatim}[fontsize=\small]
\documentclass[11pt,a4paper,oneside]{report}
\usepackage{pslatex,palatino,avant,graphicx,color}
\usepackage[margin=2cm]{geometry}
\begin{document}
\title{\color{red}Practical Typesetting}
\author{\color{blue}Peter Flynn\\Silmaril Consultants}
\date{\color{green}December 2005}
\maketitle
\end{document}
\end{Verbatim}
\end{sourcecode}
(Incidentally, this is a rather crude way to do colours in
titling on a once-off basis: if it's for a repeatable
style we'll see in \chaptername~\ref{macros} how it can
be automated and kept out of the author's way.)
Many packages can have additional formatting
specifications in optional arguments in square brackets, in
the same way as \package{geometry}
does. Read the documentation for the package concerned to
find out what can be done.
\begin{exercise}
\label{geoex}
\addcontentsline{loe}{section}{\numberline{12}Add colour}
\subsubsection*{Add colour}
Use the \package{color} package to add
some colour to your document. Stick with primary colours
for the moment.
Use the \package{geometry}
package to change the margins.
Reprocess and print your document if you have a colour
printer (monochrome printers should print it in shades of
grey).
\end{exercise}
\subsection{Package documentation}
\label{packagedoc}
\index{packages!documentation}
To find out what commands a package provides (and thus
how to use it), you need to read the documentation. In the
\url+texmf/doc+ subdirectory of your
installation there should be directories full of
\url+.dvi+ files, one for every package
installed. These can be previewed or printed like any other
DVI\index{DVI@DVI} file (see
\S\thinspace\ref{dvipreview}). If your installation
procedure has not installed the documentation, the DVI\index{DVI@DVI} files can all be downloaded from
CTAN\index{CTAN@CTAN}.
Before using a package, you should read the
documentation carefully, especially the subsection usually
called `User Interface', which
describes the commands the package makes available. You
cannot just guess and hope it will work: you have to read it
and find out.
See the next section for details of how to create the
documentation \url+.dvi+ file for additional
packages you install yourself.
\begin{exercise}
\addcontentsline{loe}{section}{\numberline{13}Read all about it}
\subsubsection*{Read all about it}
Find and view (or print) the documentation on the
\package{geometry} package you used in
Exercise~\ref{geoex}.
Investigate some of the other package documentation
files in the directory.
\end{exercise}
\section{Downloading and installing packages}
\label{pkginst}
\index{packages!downloading}\index{packages!installing}
Once you have identified a package you need and
haven't already got (or you have got it and need to
update it), use the indexes on any CTAN\index{CTAN@CTAN} server to find the package you need
and the directory where it can be downloaded from.
\subsection{Downloading packages}
\label{downloadpkg}
What you need to look for is always \emph{two
files}, one ending in \url+.dtx+
and the other in \url+.ins+. The first is a
DOC\TeX{}\index{DOC} file, which combines the package program and its
documentation in a single file. The second is the
installation routine (much smaller). You \emph{must
always} download \emph{both}
files.
If the two files are not there, it means one of two
things:
\begin{itemize}
\item
\emph{Either} the package is part of a
much larger bundle which you shouldn't normally update
unless you change version of \LaTeX{};\footnote{For example, there is no
\url+color.dtx+ and
\url+color.ins+ for the
\package{color} package because it
forms part of the \package{graphics}
bundle, which is installed on all \LaTeX{} systems
anyway. Such packages change very rarely, as they
form part of the core of \LaTeX{} and are very
stable. In
general you should never try to update these
packages in isolation.}
\item
\emph{or} it's one of a few rare or
unusual packages still supplied as a single
\url+.sty+ file intended for the now
obsolete \LaTeX{}\thinspace{}2.09.\footnote{You can try to use these if you wish but they
are not guaranteed to work, and have now almost all
been replaced by \LaTeXe{} versions. Always look for
the
\url+.dtx+ and
\url+.ins+ pair of files
first.}
\end{itemize}
\label{packinst}%
Download both files to a \textbf{\textit{temporary directory}}\label{tempdir}\index{temporary directory@\textbf{\textit{temporary directory}}}. If you use
Windows, keep a folder like \url+C:\tmp+ or
\url+C:\temp+ for this; Mac and Linux systems
already have a \url+/tmp+ directory.
\subsection{Installing a package}
\label{installpkg}
There are four steps to installing a \LaTeX{}
package:
\index{packages!installing}\begin{enumerate}
\item \textbf{Extract the files}\\\label{extract}%
Run \LaTeX{} on the \url+.ins+ file.
That is, open the file in your editor and process it as
if it were a \LaTeX{} document (which is it), or if you
prefer, type \verb+latex+ followed by the
\url+.ins+ filename in a command window
in your temporary directory.
This will extract all the files needed from the
\url+.dtx+ file (which is why you must
have both of them present in the temporary directory).
Note down or print the names of the files created if
there are a lot of them (read the log file if you want
to see their names again).
\item \textbf{Create the documentation}\\\label{dtxdoc}%
Run \LaTeX{} on the \url+.dtx+ file
twice. This will create a \url+.dvi+ file
of documentation explaining what the package is for and
how to use it. Two passes through \LaTeX{} are needed in
order to resolve any internal crossreferences in the
text (a feature we'll come onto later). If you
prefer to create PDF\index{PDF@PDF} then run
\product{pdf\LaTeX{}} instead. View or
print this file in the usual manner (see \S\thinspace\ref{dvi}).
\item \textbf{Install the files}\\
While the documentation is printing, move or copy
the files created in step~\ref{extract}
from your temporary directory to the right place[s] in
your \TeX{} \emph{local} installation
directory tree\mdash{}always your `local'
directory tree, \begin{inparaenum}[\itshape a\upshape)] \item to prevent your new package accidentally
overwriting files in the main \TeX{}
directories; and \item to avoid your newly-installed files being
overwritten when you next update your version of
\TeX{}\end{inparaenum}.
\begin{table}\small \caption{\small Where to put files from packages}
\label{where}
\begin{center}
\begin{tabular}{@{}l>{\ttfamily}l>{\pbs{\raggedright}\footnotesize}p{1.5in}@{}}
\textbf{\sffamily\upshape Type}&\textbf{\sffamily\upshape Directory (under
\url+texmf-local/+)}&\textbf{\sffamily\upshape Description}\\[2pt]\hline\\[-1.5\baselineskip]
\url+.cls+&tex/latex/base&Document class file\\
\url+.sty+&tex/latex/\textsl{packagename}&Style file: the normal package
content\\
\url+.bst+&bibtex/bst/\textsl{packagename}&\BibTeX{} style\\
\url+.mf+&fonts/source/public/\textsl{typeface}&\mf{} outline\\
\url+.fd+&tex/latex/mfnfss&Font Definition files for \mf{} fonts\\
\url+.fd+&tex/latex/psnfss&Font Definition files for PostScript
Type 1 fonts\\
\url+.pfb+&/fonts/type1/\textsl{foundry}/\textsl{typeface}&PostScript Type 1 outline\\
\url+.afm+&/fonts/afm/\textsl{foundry}/\textsl{typeface}&Adobe Font Metrics for Type 1
fonts\\
\url+.tfm+&/fonts/tfm/\textsl{foundry}/\textsl{typeface}&\TeX{} Font Metrics for \mf{} and
Type 1 fonts\\
\url+.vf+&/fonts/vf/\textsl{foundry}/\textsl{typeface}&\TeX{} virtual fonts\\
\url+.dvi+&/doc&package documentation\\
\url+.pdf+&/doc&package documentation\\
others&tex/latex/\textsl{packagename}&other types of file unless instructed
otherwise\\
\end{tabular}
\end{center}
\end{table}
`The right place' sometimes causes
confusion, especially if your \TeX{} installation is old
or does not conform to the \TeX{}
Directory Structure (TDS)\index{TDS@TDS|textbf}\index{Acronyms@\textbf{Acronyms}, defined!TDS@TDS|textbf}. For a TDS\index{TDS@TDS}-conformant system, this is either
\begin{inparaenum}[\itshape a\upshape)] \item for \LaTeX{} packages, a suitably-named
subdirectory of
\url+texmf-local/tex/latex/+\footnote{See \S\thinspace\ref{rightplace} for how
to create a parallel structure in your local
directory if your installation didn't create
one for you.}; or \item a suitably-named subdirectory of
\url+texmf-local/+ for files like
\BibTeX{} styles which are not just for \LaTeX{} but can
be used in other \TeX{} systems\end{inparaenum}.
`Suitably-named' means sensible and
meaningful (and probably short). For a package like
\package{paralist}, for example, I'd call
the directory \url+paralist+.
Often there is just a \url+.sty+ file
to move but in the case of complex packages there may be
more, and they may belong in different locations. For
example, new \BibTeX{} packages or font packages will
typically have several files to install. This is why it
is a good idea to create a subdirectory for the package
rather than dump the files into
\url+misc+ along with other unrelated
stuff.
If there are configuration or other files, read the
documentation to find out if there is a special or
preferred location to move them to.
\item \textbf{Update your index}\\\label{texindex}%\index{packages!indexing}
Finally, run your \TeX{} indexer program to update
the package database. This program comes with every
modern version of \TeX{} and is variously called
\product{texhash},
\product{mktexlsr}, or even
\product{configure}, or it might just
be a mouse click on a button or menu in your editor.
Read the documentation that came with your installation
to find out which it is.
\end{enumerate}
\begin{warning}
This last step is \emph{utterly
essential}, otherwise nothing will
work.
\end{warning}
\begin{exercise}
\label{insttest}
\addcontentsline{loe}{section}{\numberline{14}Install a package}
\subsubsection*{Install a package}
Download and install the
\package{paralist} package (which
implements inline lists).
\end{exercise}
The reason this process has not been automated widely is
that there are still thousands of installations which do not
conform to the TDS\index{TDS@TDS}, such as old
shared Unix systems and some Microsoft Windows systems, so
there is no way for an installation program to guess where
to put the files: \emph{you} have to know
this. There are also systems where the owner, user, or
installer has chosen \emph{not} to follow the
recommended TDS\index{TDS@TDS} directory
structure, or is unable to do so for political or security
reasons (such as a shared system where she cannot write to a
protected directory).
The reason for having the
\url+texmf-local+ directory (called
\url+texmf.local+ on some systems) is to
provide a place for local modifications or personal updates,
especially if you are a user on a shared or managed system
(Unix, Linux, VMS, Windows NT/2000/XP, etc.) where you may
not have write-access to the main \TeX{}
installation directory tree. You can also have a personal
\url+texmf+ subdirectory in your own login
directory. Your installation must be configured to look in
these directories first, however, so that any updates to
standard packages will be found there
\emph{before} the superseded copies in the
main \url+texmf+ tree. All modern \TeX{}
installations should do this anyway, but if not, you can
edit \url+texmf/web2c/texmf.cnf+ yourself.
There is an example in Appendix~\ref{cnf}.
\subsection{Replicating the TDS}
\label{rightplace}
I find it useful to make the directory structure of
\url+texmf-local+ the same as that of
\url+texmf+. Examine the subdirectories of
\url+texmf/tex/latex/+ for examples. For
updates of packages which came with your \LaTeX{}
distribution (as distinct from new ones you are adding
yourself), you can then use the same subdirectory name and
position in \url+texmf-local/...+ as the
original used in \url+texmf/...+.
If you want to create the entire subdirectory structure
ready for use, you can do it under Unix with the following
commands:
\begin{sourcecode}\begin{Verbatim}[fontsize=\small]
cd /usr/TeX/texmf
find . -type d -exec mkdir -p /usr/TeX/texmf-local/{} \;
\end{Verbatim}
\end{sourcecode}
If you are using Microsoft Windows, you can download
\product{Cygwin}, which provides you with
the standard Unix tools in a shell window. The above command
should also work on a Mac running OS\thinspace{}X. In all cases,
if your installation directory is not
\url+/usr/TeX+, you need to substitute the
actual paths to your \url+texmf+ and
\url+texmf-local+ directories.
\section{Online help}
\label{help}
\index{help}
The indexes and documentation files on CTAN\index{CTAN@CTAN} are the primary online resource for
self-help on specific packages, and you should read these
carefully before asking questions about packages.
\subsection{The FAQ}
\label{faq}
For general queries you should read the Frequently-Asked Questions (FAQ)\index{FAQ@FAQ|textbf}\index{Acronyms@\textbf{Acronyms}, defined!FAQ@FAQ|textbf} document so
that you avoid wasting online time asking about things for
which there is already an easily-accessible answer.
The FAQ\index{FAQ@FAQ} is managed by the UK
\TeX{} Users Group and can be found at \url+http://www.tex.ac.uk/faq/+\thinspace{}.
\subsection{The \TeX{}hax mailing list}
Another support resource is the mailing list \url+texhax@tug.org+. Again, feel free to ask
questions, but again, try to answer the question yourself
first (and say what you've tried in your
message).
\subsection{Web sites}
The \TeX{} Users Group, as well as most local user
groups, maintains a web site (\url+http://tug.org+) with lots of information
about various aspects of the \TeX{}
system. See Appendix~\ref{tugform} for information on
joining TUG.
\subsection{News}
The Usenet newsgroup \url+comp.text.tex+ is the principal forum for other
questions and answers about \LaTeX{}. Feel free to ask
questions, but
please do not ask frequently-asked questions: read the
FAQ\index{FAQ@FAQ} instead. The people who answer
the questions do so voluntarily, unpaid, and in their own
time, so please don't treat this as a commercial
support service.
To access Usenet news, type the following URI\index{URI@URI} into your browser's
`Location' or
`Address' window:
\verb+news:comp.text.tex+ (if your browser
doesn't support Usenet news properly, change it for one
that does, like \product{Mozilla}\footnote{\url+http://www.mozilla.org/+}), or download one of the many free newsreaders.\footnote{Note that this means newsreaders for the Usenet News
(NNTP) service. It does \emph{not} mean
syndication readers for RSS, which are a different thing
entirely\mdash{}these are unfortunately also sometimes
referred to as `newsreaders'.}
\subsection{Commercial support}
If you need commercial levels of support, such as
24-hour phone contact, or macro-writing services, you can
buy one of the several excellent commercial versions of
\TeX{}, or contact a consultancy which deals with \TeX{}
(details on the TUG Web site).
\chapter{Other document structures}
\label{otherdoc}
It is perfectly possible to write whole documents using
nothing but section headings and paragraphs. As mentioned in
\S\thinspace\ref{sections}, novels, for example, usually consist
just of chapters divided into paragraphs. However, it's more
common to need other features as well, especially if the
document is technical in nature or complex in structure.
It's worth pointing out that
`technical' doesn't necessarily mean
`computer technical' or
`engineering technical': it just means it
contains a lot of $\tau\eta\chi\nu\epsilon$~(\emph{tekne}), the
specialist material or artistry of its field. A literary
analysis such as \titlecite{macnamara} (on the
marginal notes in the manuscripts of \authorof{bovary}'s novel) is every bit as
technical in the literary or linguistic field as the maintenance
manual for the Airbus 380 is in the aircraft engineering
field.
This chapter covers the most common features needed in
writing structured documents: lists, tables, figures (including
images), sidebars like boxes and panels, and verbatim text
(computer program listings). In \chaptername~\ref{texttools} we
will cover footnotes, cross-references, citations, and other
textual tools.
\section{A little think about structure}
\label{briefstruct}
It's very easy to sit down at a keyboard with a
traditional wordprocessor and just start typing. If it's
a very short document, or something transient or relatively
unimportant, then you just want to type it in and make it look
`right' by highlighting with the mouse
and clicking on font styles and sizes.
In doing so, you may achieve the effect you wanted, but
your actions have left no trace behind of
\emph{why} you made these changes. This is
usually unimportant for trivial or short-term documents, but
if you write longer or more complex documents, or if you often
write documents to a regular pattern, then making them
consistent by manual methods becomes a nightmare.
\LaTeX{}'s facilities for automation are based on you
providing this `why'
information.
If your documents have any of the features below, then you
have probably already started thinking about structure.
\begin{itemize}
\renewcommand{\labelitemi}{\raisebox{-.25ex}{\Square}}
\item
The document naturally divides into sections (parts,
chapters, etc.).
\item
The document is long.
\item
There is lots of repetitive formatting in the
document.
\item
The document is complex (intellectually or
visually).
\item
There are lots of figures or tables (or examples,
exercises, panels, sidebars, etc.).
\item
Accuracy is important in formatting the
document.
\item
A master copy is needed for future reference or
reprinting.
\item
This is a formal or official document needing special
care and attention.
\item
It's \emph{my} thesis, book,
leaflet, pamphlet, paper, article, etc.
\emph{That}'s why I care.
\item
The document (or part of it) may need ongoing or
occasional re-editing and republishing.
\end{itemize}
If you've got that far, you're over half-way
done. Using a structural editor\mdash{}even a simple
outliner\mdash{}can make a huge difference to the quality of
your thinking because you are consciously organising your
thoughts before setting them down. And it can make just as big
a difference to your formatting as well: more consistent,
better presented, easier for the reader to navigate through,
and more likely to be read and understood\mdash{}which is
presumably why you are writing the document in the first
place.
\section{Lists}
\label{lists}
\index{lists}
Lists are useful tools for arranging thoughts in a
digestible format, usually a small piece of information at a
time. There are four basic types of list, shown in Table~\ref{listtypes}.
\begin{table}\small \caption{\small Types of lists}
\label{listtypes}
\begin{center}
\begin{tabular}{@{}>{\pbs{\raggedright}}p{0.48\columnwidth}>{\pbs{\raggedright}}p{0.48\columnwidth}@{}}
\begin{description}\item[\sffamily Random or arbitrary lists](sometimes called
`itemized' or
`bulleted' lists) where the
order of items is unimportant. The
items are often prefixed with a bullet or other
symbol for clarity or decoration, but are
sometimes simply left blank, looking like
miniature paragraphs (when they are known as
`simple' or
`trivial' lists).\end{description}&\begin{description}\item[\sffamily Enumerated or sequential lists](sometimes called
`numbered' lists) where the
order of items is critical, such as sequences of
instructions or rankings of importance. The
enumeration can be numeric (Arabic or Roman), or
lettered (uppercase or lowercase), and can even be
programmed to be hierarchical (1.a.viii, 2.3.6,
etc.).\end{description}\\
\begin{description}\item[\sffamily Descriptive or labelled lists](sometimes called
`discussion' lists), which
are composed of subheadings or topic labels
(usually unnumbered but typographically distinct),
each followed by one or more indented paragraphs
of discussion or explanation.\end{description}&\begin{description}\item[\sffamily Inline lists]which are sequential in nature, just like
enumerated lists, but are
\begin{inparaenum}[\itshape a\upshape)] \item formatted \emph{within}
their paragraph; and \item usually labelled with letters,\end{inparaenum} like this example. The items
are often mutually inclusive or exclusive, with
the final item prefixed by
`and' or
`or' respectively.\end{description}\\
\end{tabular}
\end{center}
\end{table}
There are actually two other types, segmented lists and
reference lists, but these are much rarer, and outside the
scope of this document.
\index{environment}
The structure of lists in \LaTeX{} is identical for each
type, but with a different environment name. Lists are another
example of this \LaTeX{} technique (environments), where a pair
of matched commands surrounds some text which needs special
treatment.
Within a list environment, list items are always
identified by the command \command{item} (followed by
an item label in [square brackets] in the case of labelled
lists). You don't type the bullet or the number or the
formatting, it's all automated.
\subsection{Itemized lists}
\index{lists!itemized}\index{lists!bulleted}
To create an itemized list, use the the
\env{itemize} environment:
\begin{example}
\begin{sourcecode}\begin{Verbatim}[fontsize=\small]
\begin{itemize}
\item Itemized lists usually have a bullet;
\item Long items use `hanging indentation',
whereby the text is wrapped with a margin
which brings it clear of the bullet used in
the first line of each item;
\item The bullet can be changed for any other
symbol, for example from the \textsf{bbding}
or \textsf{pifont} package.
\end{itemize}
\end{Verbatim}
\end{sourcecode}\vspace*{-\baselineskip}\begin{quote}\fontencoding{T1}\fontfamily{cmr}\selectfont\def\sfdefault{cmss}\def\bfdefault{bf}\noindent
\begin{itemize}
\label{labelitem}
\renewcommand{\labelitemi}{\raisebox{-.25ex}{\raisebox{-.25ex}{\PencilRight}}}
\item
Itemized lists usually have a bullet;
\item
Long items use `hanging
indentation', whereby the text is
wrapped with a margin which brings it clear of the
bullet used in the first line of each item;
\item
The bullet can be changed for any other symbol,
for example from the \package{bbding}
or \package{pifont} package.
\end{itemize}
\end{quote}\end{example}
The default list bullet is round and solid\footnote{If your browser font doesn't show it, don't
worry: most don't. \LaTeX{} will.} (\textbullet{}) which is also available with the
command \command{textbullet} if you load the
\package{textcomp} package. See \S\thinspace\ref{bullets} for details of how to change the
settings for list item bullets.
\subsection{Enumerated lists}
\index{lists!numbered}\index{lists!enumerated}
To create an enumerated list, use the
\env{enumerate} environment:
\begin{example}
\begin{sourcecode}\begin{Verbatim}[fontsize=\small]
\begin{enumerate}
\item Enumerated lists use numbering on each
item (can also be letters or roman numerals);
\item Long items use `hanging indentation'
just the same as for itemized lists;
\item The numbering system can be changed for
any level.
\end{enumerate}
\end{Verbatim}
\end{sourcecode}\vspace*{-\baselineskip}\begin{quote}\fontencoding{T1}\fontfamily{cmr}\selectfont\def\sfdefault{cmss}\def\bfdefault{bf}\noindent
\begin{enumerate}\item
Enumerated lists use numbering on each
item (can also be letters or roman numerals);
\item
Long items use `hanging
indentation', just the same as for
itemized lists;
\item
The numbering system can be changed for any
level.
\end{enumerate}
\end{quote}\end{example}
See \S\thinspace\ref{numberschemes} for details of how
to change the numbering schemes for each level.
In standard \LaTeX{} document classes, the vertical
spacing between items, and above and below the lists as a
whole, is more than between paragraphs. If you want
tightly-packed lists, use the
\package{mdwlist} package, which provides
`starred' versions
(\env{itemize*},
\env{enumerate*}, etc).
\subsection{Description lists}
\label{desc}
\index{lists!description}\index{lists!discussion}
To create a description list, use the
\env{description} environment:
\begin{example}
\begin{sourcecode}\begin{Verbatim}[fontsize=\small]
\begin{description}
\item[Identification:] description lists
require a topic for each item given in
square brackets;
\item[Hanging indentation:] Long items use
this in the same way as all other lists;
\item[Reformatting:] Long topics can be
reprogrammed to fold onto multiple lines.
\end{description}
\end{Verbatim}
\end{sourcecode}\vspace*{-\baselineskip}\begin{quote}\fontencoding{T1}\fontfamily{cmr}\selectfont\def\sfdefault{cmss}\def\bfdefault{bf}\noindent
\begin{description}
\item[\sffamily Identification:]
description lists require a topic for each item
given in square brackets;
\item[\sffamily Hanging indentation:]
Long items use this in the same way as all other
lists;
\item[\sffamily Reformatting:]
Long topics can be reprogrammed to fold onto
multiple lines.
\end{description}
\end{quote}\end{example}
All three of these types of lists can have multiple
paragraphs per item: just type the additional paragraphs in
the normal way, with a blank line between each. So long as
they are still contained within the enclosing environment,
they will automatically be indented to follow underneath their
item.
\subsection{Inline lists}
\label{inlinelists}
\index{lists!inline}
Inline lists are a special case as they require the use
of the \package{paralist} package which
provides the \env{inparaenum} environment
(with an optional formatting specification in square
brackets):
\begin{example}
\begin{sourcecode}\begin{Verbatim}[fontsize=\small]
\usepackage{paralist}
...
\textbf{\itshape Inline lists}, which are
sequential in nature, just like enumerated
lists, but are \begin{inparaenum}[\itshape
a\upshape)]\item formatted within their
paragraph; \item usually labelled with
letters; and \item usually have the final
item prefixed with `and' or
`or'\end{inparaenum}, like this example.
\end{Verbatim}
\end{sourcecode}\vspace*{-\baselineskip}\begin{quote}\fontencoding{T1}\fontfamily{cmr}\selectfont\def\sfdefault{cmss}\def\bfdefault{bf}\noindent
\textbf{\textit{Inline lists}}\label{inlines}\index{Inline lists@\textbf{\textit{Inline lists}}},
which are sequential in nature, just like enumerated
lists, but are \begin{inparaenum}[\itshape a\upshape)] \item formatted within their paragraph; \item usually labelled with letters; and \item usually have the final
item prefixed with `and' or
`or'\thinspace\end{inparaenum}, like this example.
\end{quote}\end{example}
See \chaptername~\ref{typo} for details of the
font-changing commands used in the optional argument to
\env{inparaenum}.
\begin{exercise}
\addcontentsline{loe}{section}{\numberline{15}List practice}
\subsubsection*{List practice}
Add some lists to your document. Pick any two of the
ones described here to practise with.
If you successfully installed
\package{paralist} in Exercise~\ref{insttest} then you can use inline lists as
described in \S\thinspace\ref{inlinelists}.
\end{exercise}
\subsection{Reference lists and segmented lists}
Reference lists are visually indistinguishable from
numbered or lettered lists, but the numbering or lettering
does \emph{not} imply a sequence. The numbers
or letters are just used as labels so that the items can be
referred to from elsewhere in the text (as in `see
item 501(c)3'). In this sense they are really a
kind of sub-sectional division, and \LaTeX{}'s
\command{paragraph} or
\command{subparagraph} commands (with appropriate
renumbering) would probably be a far better solution than
using a list. Label them and refer to them with
\command{label} and \command{ref} as for
any other cross-reference (see \S\thinspace\ref{xrefs}).
Segmented lists are a highly specialised structure and
outside the scope of this document. For details of their
usage, see the the chapter `Segmentation and
Alignment' in \titlecite{teiguide}.
\subsection{Lists within lists}
\label{numberschemes}
You can start a new list environment within the item of
an existing list, so you can embed one list inside another
up to four deep. The lists can be of any type, so you can
have a description list containing an item in which there is
a numbered sub-list, within which there is an item
containing a bulleted sub-sub-list.
\begin{enumerate}\item
by default an outer enumerated list is numbered in
Arabic numerals;
\begin{enumerate}\item
an embedded enumerated list is lettered in
lowercase;
\begin{enumerate}\item
a third level is numbered in lowercase Roman
numerals;
\begin{enumerate}\item
the fourth level uses uppercase
alphabetic letters.
\end{enumerate}
\end{enumerate}
\end{enumerate}
\end{enumerate}
Multiple embedded lists automatically change the bullet
or numbering scheme so that the levels don't get
confused, and the spacing between levels is adjusted to
become fractionally tighter for more deeply nested
levels.
These are only defaults and can easily be changed by
redefining the relevant set of values. You could also add a
fifth and further levels, although I suspect that would mean
your document structure needed some careful analysis, as
lists embedded five deep will probably confuse your
readers.
The values for lists come in pairs: for each level there
is a counter to count the items and a command to produce the
label:\footnote{In fact, any time you define a counter in \LaTeX{},
you automatically get a command to reproduce its value.
So if you defined a new counter \counter{example} to use in a teaching
book, by saying \url+\newcounter{example}+,
that automatically makes available the command
\url+\theexample+ for use when you want to
display the current value of \counter{example}.}
\begingroup\small \begin{center}
\begin{tabular}{rcll}
\textbf{\sffamily\upshape Level}&\textbf{\sffamily\upshape Default}&\textbf{\sffamily\upshape Counter}&\textbf{\sffamily\upshape Label command}\\[2pt]\hline\\[-1.5\baselineskip]
1&digit.&\counter{enumi}&\command{theenumi}\\
2&(letter)&\counter{enumii}&\command{theenumii}\\
3&roman.&\counter{enumiii}&\command{theenumiii}\\
4&LETTER.&\counter{enumiv}&\command{theenumiv}\\
\end{tabular}
\end{center}
\endgroup
Note that each counter and command ends with the Roman
numeral value of its level (this is to overcome the rule
that \LaTeX{} commands can only be made of
letters\mdash{}digits wouldn't work here). To
change the format of a numbered list item counter, just
renew the meaning of its label:
\begin{sourcecode}\begin{Verbatim}[fontsize=\small]
\renewcommand{\theenumi}{\Alph{enumi}}
\renewcommand{\theenumii}{\roman{enumii}}
\renewcommand{\theenumiii}{\arabic{enumiii}}
\end{Verbatim}
\end{sourcecode}
\noindent \label{thecounter}%
This would make the
outermost list use uppercase letters, the second level use
lowercase roman, and the third level use ordinary Arabic
numerals. The fourth level would remain unaffected.
\begin{exercise}
\addcontentsline{loe}{section}{\numberline{16}Nesting}
\subsubsection*{Nesting}
Extend your use of lists by nesting one type inside a
different one.
\end{exercise}
\begin{warning}
\subsubsection*{Lists: a caution to the unwary}
Treat lists with care: people sometimes use tables for
labelled information which is really a list and would be
better handled as such. They often do this because their
wordprocessor has no way to do what they want (usually to
place the item label level with the description or
explanation) \emph{except} by using a table,
hence they are misled into believing that their text is
really a table when it's actually not.
\end{warning}
\section{Tables}
\label{tables}
\index{tables}
Tabular typesetting is the most complex and time-consuming
of all textual features to get right. This holds true whether
you are typing in plain-text form, using a wordprocessor,
using \LaTeX{}, using HTML\index{HTML@HTML} or
XML\index{XML@XML}, using a DTP\index{DTP@DTP} system, or some other text-handling
package. Fortunately, \LaTeX{} provides a
table model with a mixture of defaults and configurability to
let it produce very high quality tables with a minimum of
effort.
\begin{warning}
\subsubsection*{Terminology}
\LaTeX{}, in common with standard typesetting
practice, uses the word `Table' to
mean a formal textual feature, numbered and with a caption,
referred to from the text (as in `See
Table 5'). Sometimes you can get
`informal' tables, which simply occur
between two paragraphs, without caption or number.
The arrangement of information in rows and columns
\emph{within} either of these structures is
called a `tabulation' or
`tabular matter'.
It is important to keep this distinction firmly in mind
for this section.
\end{warning}
\subsection{Floats}
\label{floats}
\index{floats}
Tables and Figures are what printers refer to as
`floats'. This means they are not
part of the normal stream of text, but separate entities,
positioned in a part of the page to themselves (top, middle,
bottom, left, right, or wherever the designer specifies).
They always have a caption describing them and they are
always numbered so they can be referred to from elsewhere in
the text.
\LaTeX{} automatically floats Tables and Figures,
depending on how much space is left on the page at the point
that they are processed. If there is not enough room on the
current page, the float is moved to the top of the next
page. This can be changed by moving the Table or Figure
definition to an earlier or later point in the text, or by
adjusting some of the parameters which control automatic
floating.
Authors sometimes have many floats occurring in rapid
succession, which raises the problem of how they are
supposed to fit on the page and still leave room for text.
In this case, \LaTeX{} stacks them all up and prints them
together if possible, or leaves them to the end of the
chapter in protest. The skill is to space them out within
your text so that they intrude neither on the thread of your
argument or discussion, nor on the visual balance of the
typeset pages. But this is a skill few authors have, and
it's one point at which professional typographic advice
or manual intervention may be needed.
There is a \env{float} package which lets
you create new classes of floating object (perhaps Examples
or Exercises).
\subsection{Formal tables}
To create a \LaTeX{} Table, use the \env{table}
environment containing a \command{caption} command
where you type the caption, and a \command{label}
command to give the Table a label by which you can refer to
it.
\begin{sourcecode}\begin{Verbatim}[fontsize=\small]
\begin{table}
\caption{Project expenditure to year-end 2006}
\label{ye2006exp}
...
\end{table}
\end{Verbatim}
\end{sourcecode}
Numbering is automatic, but the \command{label}
command \emph{must follow} the
\command{caption} command, not precede it. The
numbering automatically includes the chapter number in
document classes where this is appropriate (but this can of
course be overridden). The \command{caption}
command has an optional argument to provide a short caption
if the full caption would be too long for the List of Tables (\S\thinspace\ref{loflot}):
\begin{sourcecode}\begin{Verbatim}[fontsize=\small]
\caption[Something short]{Some very long caption that
will only look reasonable in the full figure.}
\end{Verbatim}
\end{sourcecode}
\subsection{Tabular matter}
Within a Table, you can either typeset the tabular
matter using \LaTeX{}, or include a table captured as an
image from elsewhere. We will see how to include images in
\S\thinspace\ref{figures} on Figures, where they are more
common.
To typeset tabular matter, use the
\env{tabular} environment. The
\verb+\begin{tabular}+ command must be followed
by a compulsory second argument in curly braces giving the
alignment of the columns. These are specified for each
column using one of single letters \verb+l+,
\verb+c+, and \verb+r+ for
left-aligned, centered, or right-aligned text, or the letter
\verb+p+ followed by a width argument if you
want a long entry to wrap to several lines (a miniature
paragraph as a single cell on each row).
\TeX{}'s original tabular settings were designed
for classical numerical tabulations, where each cell
contains a single value. The \verb+p+
specification allows a cell to be a miniature paragraph set
to a specific width. These are \verb+p+ column
specifications are \emph{not} multi-row
entries, they are single cells which contain multiple lines
of typesetting: the distinction is very important.
Auto-adjusting cell sizes like you see in a Web browser (the
`Netscape' table model) are possible
with the \package{tabularx} package, but
these are often inelegant in print, however convenient they
may be in a Web browser.
The \package{array} package provides for
many other typographic variations such as left-aligned,
right-aligned, and centred multi-line columns, and other
packages provide decimal-aligned columns, row-spanning and
column-spanning, multi-page, and rotated (landscape format)
tables.
\begin{table}[b]\small \caption{\small Project expenditure to year-end 2006}
\label{ye2006exp}
\begin{center}
\begin{tabular}{clr}
\textbf{\sffamily\upshape }&\textbf{\sffamily\upshape Item}&\textbf{\sffamily\upshape \EUR{} Amount}\\[2pt]\hline\\[-1.5\baselineskip]
a)&Salaries (2 research assistants)&28,000\\
&Conference fees and travel expenses&14,228\\
&Computer equipment (5 workstations)&17,493\\
&Software&3,562\\
b)&Rent, light, heat, etc.&1,500\\
\cline{3-3}\vrule height1.1em width0pt \textbf{}&\textbf{Total}&\textbf{64,783}\\
\end{tabular}
\par\smallskip\footnotesize
The Institute also contributes to (a) and
(b).\end{center}
\end{table}
As an example, a tabular setting with three columns, the
first one centered, the second left-aligned, and the third
one right-aligned, would therefore be specified as
\verb+{clr}+, as in the example below. Note the
use of indentation to make the elements of the table clear
for editing, and note also how the typeset formatting is
unaffected by this (see Table~\ref{ye2006exp}).
\begin{sourcecode}\begin{Verbatim}[fontsize=\small]
\begin{table}
\caption{Project expenditure to year-end 2006}
\label{ye2006exp}
\begin{center}
\begin{tabular}{clr}
&Item&\EUR\ Amount\\
\hline
a)&Salaries (2 research assistants)&28,000\\
&Conference fees and travel expenses&14,228\\
&Computer equipment (5 workstations)&17,493\\
&Software&3,562\\
b)&Rent, light, heat, etc.&1,500\\\cline{3-3}
&Total&64,783
\end{tabular}
\par\medskip\footnotesize
The Institute also contributes to (a) and (b).
\end{center}
\end{table}
\end{Verbatim}
\end{sourcecode}
You do not need to format the tabular data in your
editor: \LaTeX{} does this for you when it typesets the
table, using the column specifications you provided. Extra
space is automatically added between columns, and can be
adjusted by changing the \length{tabcolsep} dimension.
\person{Takaaki Ota} provides an excellent Tables mode for
\product{Emacs} which provides a
spreadsheet-like interface and can generate \LaTeX{} table
source code (see Figure~\ref{tabmode}).
\begin{figure}\small
\caption{\small Tables mode for
\emph{Emacs}}
\label{tabmode}
\begin{center}
\includegraphics[width=0.75\textwidth]{table}
\end{center}
\end{figure}
It is conventional to centre the tabular setting within
the Table, using the \env{center} environment
(note US spelling) or the \command{centering}
command. The entries for each cell are separated by an
ampersand character (\verb+&+) and the end
of a row is marked by
the double-backslash (\verb+\\+).
The \command{hline} command draws a rule across
all columns and the \command{cline} command draws a
rule across a range of columns (here, under column three
only\mdash{}the argument needs a range). If used, these commands \emph{follow}
the
\verb+\\+ of the row they apply to. There are
some extra formatting commands after the tabular material in
the example. These are explained in
\chaptername~\ref{typo}.
If there is no data for a cell, just don't type
anything\mdash{}but you still need the
\verb+&+ separating it from the next
column's data. The astute reader will already have
deduced that for a table of
\(n\) columns, there must always be
\(n\ifmmode-\else$-$\fi{}1\) ampersands in each row. The exception to
this is when the \command{multicolumn} command is
used to create cells which span multiple columns. There is
also a package (\env{multirow}) to enable
cells to span multiple rows, but both of these techniques
are outside the scope of this document.
\subsection{Tabular techniques for alignment}
As mentioned earlier, it's also perfectly possible
to typeset tabular matter outside a formal Table, where you
want to lay out an informal tabulation between paragraphs
where a fully floating formal Table would be unnecessary
(these are usually quite short: there are several of them in
this document).
Tabular mode can also be used wherever you need to align
material side by side, such as in designing letterheads,
where you may want your company logo and address on one side
and some other information on the other.
By default, \LaTeX{} typesets
\env{tabular} environments inline to the
surrounding text, so if you want your alignment displayed by
itself, put it inside a positioning environment like
\env{center},
\env{flushright}, or
\env{flushleft}, or leave a blank line or
\command{par} before and after so it gets typeset
separately.
There is much more to tabular setting:
full details are in the manuals mentioned in
the last paragraph of the Foreword on p.\thinspace\pageref{docs}. One final note to remind you of the
automated crossreferencing features: because the example
table is labelled, it can be referenced from anywhere in the
document as Table~\ref{ye2006exp} just by using
\verb+\ref{ye2006exp}+, regardless of how much
the surrounding document or structure is moved or
edited.
\begin{exercise}
\addcontentsline{loe}{section}{\numberline{17}Create a tabulation}
\subsubsection*{Create a tabulation}
Create one of the following in your document:
\begin{itemize}
\item
a formal Table with a caption showing the number
of people in your class broken down by age and
sex;
\item
an informal tabulation showing the price for three
products;
\item
the logo \setlength{\fboxsep}{-3pt}\setlength{\fboxrule}{.4pt}
\fbox{\begin{tabular}{cc}\tiny YEAR\\[-.8em]\tiny 2
0 0 0\vrule depth1em
width0pt\end{tabular}} (hint: \S\thinspace\ref{fbox})
\end{itemize}
\end{exercise}
\section{Figures}
\label{figures}
\index{figures}\index{floats}
As explained in \S\thinspace\ref{floats}, Figures and
Tables float to a vacant part of the page, as they are not
part of the sequence of sentences making up your text, but
illustrative objects that you refer to.
Figures can contain text, diagrams, pictures, or any other
kind of illustration. To create a figure, use the
\env{figure} environment: like Tables, they
automatically get numbered, and must include a caption (with a
label after the caption, if needed, exactly the same as for
Tables)
\begin{sourcecode}\begin{Verbatim}[fontsize=\small]
\begin{figure}
\caption{Total variable overhead variance (after
\citeauthor[p.191]{bull}}
\label{workeff}
\begin{center}
\includegraphics[width=.75\columnwidth]{diagram}
\end{center}
\end{figure}
\end{Verbatim}
\end{sourcecode}
\begin{figure}\small
\caption{\small Total variable overhead variance (after \citeauthoryear{bull} \textsl{p.191})}
\label{workeff}
\begin{center}
\includegraphics[width=0.75\textwidth]{diagram}
\end{center}
\end{figure}
You can see that the structure is very similar to the
\env{table} environment, but in this case we
have a graphic included. Details of this command
(\command{includegraphics}) are in the next section.
Details of the bibliographic citation mechanism are in \S\thinspace\ref{bib}
The content of the Figure could of course also be textual,
in the form of a list or a text diagram. \LaTeX{} has a simple
drawing environment called \env{picture}, which
lets you create a limited set of lines and curves, but for a
diagram of any complexity, you should use a standard vector
drawing program (see \S\thinspace\ref{graphictypes}).
\section{Images}
\label{images}
\index{images}\index{graphics}
Images (graphics) can be included anywhere in a \LaTeX{}
document, although in most cases of formal documents they will
occur in Figures (see preceding section). To use graphics, you
need to use the \package{graphicx} package in
your preamble:
\verb+\usepackage{graphicx}+\footnote{You may find a lot of old files which use a package
called \package{epsf}. Don't use it.
It's obsolete.}
This enables the command
\command{includegraphics} which is used to insert an
image in the document. The command is followed by the name of
your graphics file \emph{without the filetype},
for example: \verb+\includegraphics{myhouse}+
(we'll see in a minute why you don't include the
filetype).
In most cases you should just make sure the image file is
in the same folder (directory) as the document you use it in.
This avoids a lot of messing around remembering where you put
the files. If you have images you want to use in several
different documents in different places on your disk, there is
a way to tell \LaTeX{} where to look (see \S\thinspace\ref{graphicsdir}).
For standard \LaTeX{} with
\product{dvips}, graphics files
\emph{must} be in Encapsulated
PostScript (EPS)\index{EPS@EPS|textbf}\index{Acronyms@\textbf{Acronyms}, defined!EPS@EPS|textbf} format: this has been the publishing
industry standard for portable graphics for many years, and no
other format will work portably in standard \LaTeX{}.\footnote{Some distributions of \TeX{} systems allow other
formats to be used, such as PNG\index{PNG@PNG},
Microsoft Bitmap (BMP)\index{BMP@BMP|textbf}\index{Acronyms@\string\textbf{Acronyms}, defined!BMP@BMP|textbf} files,
Hewlett-Packard's Printer Control
Language (PCL)\index{PCL@PCL|textbf}\index{Acronyms@\string\textbf{Acronyms}, defined!PCL@PCL|textbf} files, and others; but you cannot
send such documents to other \LaTeX{} users and expect
them to work if they don't have the same distribution
installed as you have. Stick to EPS\index{EPS@EPS}.}
All good graphics packages can save images as EPS\index{EPS@EPS}, but be very careful because some
packages, especially on Microsoft Windows platforms, use a
very poor quality driver, which creates very poor quality
EPS\index{EPS@EPS} files. If in doubt, check with
an expert. If you find an EPS\index{EPS@EPS}
graphic doesn't print, the chances are it's been
badly made by the graphics software. Download Adobe's own
PostScript driver from their Web site instead.
For \product{pdf\LaTeX{}}, graphics files
can be in Portable Network
Graphic (PNG)\index{PNG@PNG|textbf}\index{Acronyms@\textbf{Acronyms}, defined!PNG@PNG|textbf}, Joint Photographic
Experts Group (JPG)\index{JPG@JPG|textbf}\index{Acronyms@\textbf{Acronyms}, defined!JPG@JPG|textbf}, or PDF\index{PDF@PDF}
format, \emph{not} EPS\index{EPS@EPS}. This means if you want to use both
standard \LaTeX{} as well
as \product{pdf\LaTeX{}}, you need to keep
your graphics in two formats, EPS\index{EPS@EPS}
and one of the others. This is why you don't include the
filetype in the filename you give with
\command{includegraphics}: \LaTeX{} will assume
EPS\index{EPS@EPS} and
\product{pdf\LaTeX{}} will look for JPG\index{JPG@JPG}, PNG\index{PNG@PNG} or
PDF\index{PDF@PDF} files matching the name.
The \command{includegraphics} command can take
optional arguments within square brackets before the filename
to specify either the height or width, and the other dimension
will automatically change to scale. If you specify both, the
image will be distorted to fit. You can scale an image by a
factor instead of specifying height or width; clip it to
specified coordinates; and rotate it in either direction.
Multiple optional arguments are separated with commas.
\begin{example}
\begin{sourcecode}\begin{Verbatim}[fontsize=\small]
\begin{center}
\includegraphics[width=3cm]{twithcat}
\end{center}
\end{Verbatim}
\end{sourcecode}\vspace*{-\baselineskip}\begin{quote}\fontencoding{T1}\fontfamily{cmr}\selectfont\def\sfdefault{cmss}\def\bfdefault{bf}\noindent
\begin{center}
\includegraphics[width=3cm]{twithcat}
\end{center}
\end{quote}\end{example}
For details of all the arguments, see the documentation on
the \package{graphicx} package or a copy of the
\titlecite{companion}. This package also
includes commands to \raisebox{1ex}{\rotatebox{180}{rotate}},
\scalebox{-1}[1]{mirror}, and
\scalebox{2}[1]{scale} text.
\index{rotate}\index{mirror}\index{scale}
It is in fact possible to tell \LaTeX{} to generate the
right file format by itself, but this requires an external
command-line graphics converter, and as it gets done afresh
each time, it slows things down rather a lot.
EPS\index{EPS@EPS} files, especially bitmaps,
can be very large indeed, because they are stored in ASCII\index{ASCII@ASCII} format.
\person{Staszek Wawrykiewicz} has drawn my attention to a useful program to
overcome this, called \product{cep}
(`Compressed Encapsulated Postscript') available
from CTAN\index{CTAN@CTAN} in the
\url+support/pstools+ directory, which can
compress EPS\index{EPS@EPS} files to a fraction of
their original size. The original file can be replaced by the
new smaller version and still used directly with
\command{includegraphics}.
\subsection{Making images}
\label{graphictypes}
There are two types of image: bitmaps and
vectors.
\begin{description}
\item[\sffamily Bitmaps]
Bitmap images are made of coloured dots, so if you
enlarge them, they go jagged at the edges, and if you
shrink them, they go blurry. Bitmaps are fine for
photographs, where every dot is a different colour,
and no-one will notice if you don't shrink or enlarge
too much. Bitmaps for diagrams and drawings, however,
are almost always the wrong choice, and
often disastrously bad.
\item[\sffamily Vectors]
Vector drawings are made from instructions (eg
`draw this from here to here, using a line this
thick'). They can be enlarged or shrunk as
much as you like, and never lose accuracy, because
they \emph{get redrawn} automatically at
any size. You can't do photographs as vectors, but
it's the only acceptable method for drawings or
diagrams.
\end{description}
Vector graphic packages are also better suited for
saving your image directly in EPS\index{EPS@EPS}
or PDF\index{PDF@PDF} format (both of which use
vectors internally). All the major graphics-generating
packages in all disciplines output vector formats:
\product{AutoCAD},
\product{ChemDraw},
\product{MathCAD},
\product{Maple},
\product{Mathematica},
\product{ArcInfo}, and so on. EPS\index{EPS@EPS} is the universally-accepted format
for creating vector graphics for publication, with PDF\index{PDF@PDF} a close second. Most of the major
graphics (drawing) packages can also save as EPS\index{EPS@EPS}, such as
\product{PhotoShop}, \product{PaintShop
Pro}, Adobe
\product{Illustrator}, Corel
\product{Draw}, and
\product{GIMP}. There are also some free
vector plotting and diagramming packages available like
\product{tkPaint} and
\product{GNUplot} which do the same. Never,
ever (except in the direst necessity) save any
\emph{diagram} as a bitmap.
\begin{figure}\small
\caption{\small The diagram from Figure~\ref{workeff} shrunk and
enlarged}
\begin{center}
\fbox{\includegraphics[width=3.95cm]{diagram}}\quad\fbox{\includegraphics[scale=2,viewport=250 250 300 300,clip]{diagram}}
\end{center}
\end{figure}
Bitmap formats like JPG\index{JPG@JPG} and
PNG\index{PNG@PNG} are ideal for photographs, as
they are also able to compress the data substantially
without too much loss of quality. However, compressed
formats are bad for screenshots, if you are documenting
computer tasks, because too much compression makes them
blurry. The popular Graphics Interchange
Format (GIF)\index{GIF@GIF|textbf}\index{Acronyms@\textbf{Acronyms}, defined!GIF@GIF|textbf} is good for screenshots, but is not
supported by \TeX{}: use PNG\index{PNG@PNG}
instead, with the compression turned down to minimum. Avoid
uncompressible formats like BMP\index{BMP@BMP} as
they produce enormous and unmanageable files. The Tagged Image File Format (TIFF)\index{TIFF@TIFF|textbf}\index{Acronyms@\textbf{Acronyms}, defined!TIFF@TIFF|textbf}, popular with
graphic designers, should also be avoided because far too
many companies have designed and implemented non-standard,
conflicting, proprietary extensions to the format, making it
virtually useless for transfer between different types of
computers (except in faxes, where it's still used in a
much stricter version).
\begin{exercise}
\addcontentsline{loe}{section}{\numberline{18}Adding pictures}
\subsubsection*{Adding pictures}
Add \verb+\usepackage{graphicx}+ to the
preamble of your document, and copy or download an image
you want to include. Make sure it is a JPG\index{JPG@JPG}, PNG\index{PNG@PNG}, or
PDF\index{PDF@PDF} image if you use
\product{pdf\LaTeX{}}, or an EPS\index{EPS@EPS} image if you use standard
\LaTeX{}.
Add \command{includegraphics} and the
filename in curly braces (without the filetype), and
process the document and preview or print it.
Make it into a figure following the example in \S\thinspace\ref{figures}.
Be aware that some DVI\index{DVI@DVI}
previewers are not able to display all types of graphics,
and some cannot display colour. For best results, use
PDF\index{PDF@PDF} or
PostScript\index{PostScript} preview.
\end{exercise}
\subsection{Graphics storage}
\label{graphicsdir}
I mentioned earlier that there was a way to tell
\LaTeX{} where to look if you had stored images centrally
for use in many different documents. The answer is in a
command \command{graphicspath} which you supply
with an argument giving the name of an additional directory
path you want searched when a file uses the
\command{includegraphics} command, for
example:
\begin{sourcecode}\begin{Verbatim}[fontsize=\small]
\graphicspath{c:\mypict~1\camera}
\graphicspath{/var/lib/images}
\graphicspath{HardDisk:Documents:Reports:Pictures}
\end{Verbatim}
\end{sourcecode}
I've used the `safe'
(MS-DOS) form of the Windows \url+My
Pictures+ folder because it's A Bad Idea to
use directory names containing spaces (see the panel `Picking suitable filenames' \testpage[above]{filenames}). Using
\command{graphicspath} does make your file less
portable, though, because file paths tend to be specific
both to an operating system and to your computer, like the
examples above.
\section{Verbatim text}
\label{verbatim}
\index{verbatim text}
If you are documenting computer procedures, you probably
need fixed-width type for examples of programming or data
input or output. Even if you are writing about completely
non-computer topics, you may often want to quote a URI\index{URI@URI} or email address which needs to be
typeset specially. It is particularly important in these two
examples to avoid hyphenating them if they have to break over
a line-end, because the hyphen might be taken by the user as a
part of the address.
Standard \LaTeX{} includes two features for handling
fixed-format text, and there are many more available in
packages.
\subsection{Inline verbatim}
\label{inlineverb}
To specify a word or phrase as verbatim text in
typewriter type within a sentence, use the special command
\command{verb}, followed by your piece of text
surrounded by any suitable character which does
\emph{not} occur in the text itself. This is a
very rare exception to the rule that arguments go in curly
braces. I often use the plus sign for this, for example to
show a \LaTeX{} command, I type
\verb`\verb+\includegraphics[width=3in]{myhouse}+`
in order to display
\verb+\includegraphics[width=3in]{myhouse}+, but
sometimes I use the
\textbf{\textit{grave accent}}\label{grave}\index{grave accent@\textbf{\textit{grave accent}}} (\textbf{\textit{backtick}}\label{backtick}\index{backtick@\textbf{\textit{backtick}}} or open-quote) or the
vertical bar when the phrase already has a plus sign in it,
like \verb`\verb|\(y=a+2x^2\)|` when
illustrating the \LaTeX{} equation
\verb|\(y=a+x^2\)|.
This command has the advantage that it turns off all
special characters (see \S\thinspace\ref{specials}) except
the one you use as the delimiter, so you can easily quote
sequences of characters in any computer syntax without
problems. However, \LaTeX{} will never break the argument of
\command{verb} at a line-end when formatting a
paragraph, even if it contains spaces, so if it happens to
be long, and falls towards the end of a line, it will stick
out into the margin. See \S\thinspace\ref{hyph} for more
information on line-ends and hyphenation.
The \package{url} package avoids this by
providing the command \command{url} which works in
the same way as \command{verb}, with the argument
enclosed in a pair of characters, but performs a hyphenless
break at punctuation characters, as in \urlhttp://www.ucc.ie:8080/cocoon/cc/ docs/siteowner.xmlhttp://www.ucc.ie:8080/cocoon/cc/docs/siteowner.xmlhttp://www.ucc.ie:8080/cocoon/cc/ docs/siteowner.xml.
It was designed for Web URI\index{URI@URI}s,\footnote{The original term Uniform Resource
Locator (URL)\index{URL@URL|textbf}\index{Acronyms@\string\textbf{Acronyms}, defined!URL@URL|textbf} is now strongly deprecated in the Web
community in favour of the more accurate Uniform Resource Indicator (URI)\index{URI@URI|textbf}\index{Acronyms@\string\textbf{Acronyms}, defined!URI@URI|textbf}. For
details see \url+http://www.w3.org/Addressing/+.
Unfortunately the older term still persists, especially
in \LaTeX{} and XML\index{XML@XML}
markup.} so it understands their syntax and will never
break mid-way through an unpunctuated word, only at slashes
and full points. Bear in mind, however, that spaces are
forbidden in URI\index{URI@URI}s, so using spaces
in \command{url} arguments will fail, as will using
other non-URI\index{URI@URI}-valid
characters.
\subsection{Display verbatim}
For longer (multiline) chunks of fixed-format text, use
the \env{verbatim} environment:
\begin{sourcecode}\begin{Verbatim}[fontsize=\small]
\begin{verbatim}
\documentclass[11pt,a4paper,oneside]{report}
\begin{document}
\title{Practical Typesetting}
\author{Peter Flynn\\Silmaril Consultants}
\date{December 2004}
\maketitle
\end{document}
\end{verbatim}
\end{Verbatim}
\end{sourcecode}
Like \command{verb}, this turns off all special
characters, so you can include anything at all in the
verbatim text except the exact line
\verb+\end{verbatim}+
For more control over formatting, however, I recommend
the use of the \package{fancyvrb} package,
which provides a \env{Verbatim} environment
(note the capital letter) which lets you draw a rule round
the verbatim text, change the font size, and even have
typographic effects inside the \env{Verbatim}
environment. It can also be used in conjunction with the
\package{fancybox} package (see \S\thinspace\ref{fancybox}), and it can add reference line numbers
(useful for chunks of data or programming), and it can even
include entire external files.
\begin{exercise}
\addcontentsline{loe}{section}{\numberline{19}Try some fixed-format text}
\subsubsection*{Try some fixed-format text}
Add your email address and home page URI\index{URI@URI} using the \command{verb}
and \command{url} commands. You'll need to
\verb+\usepackage{url}+ for the latter.
If you know some programming, try a few lines enclosed
in \env{verbatim} and
\env{Verbatim} environments.
\end{exercise}
\section{Boxes, sidebars, and panels}
\label{boxes}
\index{boxes}\index{sidebars}\index{panels}
\LaTeX{}, like most typesetting systems, works by setting
text into boxes. The default box is the width of the current
page, and works like an old compositor's galley (tray)
from the days of metal type: it accumulates typeset text until
it's a bit longer than the specified page height. At this
stage \LaTeX{} works out how much of it really will fit on a
page, snips it off and ships it out to the DVI\index{DVI@DVI} or PDF\index{PDF@PDF} file,
and puts the rest back into the galley to accumulate towards
the following page.
\subsection{Boxes of text}
\label{boxtext}
Because of this `box' model,
\LaTeX{} can typeset any text into a box of any width
wherever on the page you need it.
The simplest command for small amounts of text is
\command{parbox}. This command needs two arguments
in curly braces: the first is the width you want the text
set to, and the second is the text itself, for
example:
\begin{example}
\begin{sourcecode}\begin{Verbatim}[fontsize=\small]
\parbox{1in}{Please make sure you send in your
completed forms by January 1st
next year, or the penalty clause
2(a) will apply}
\end{Verbatim}
\end{sourcecode}\vspace*{-\baselineskip}\begin{quote}\fontencoding{T1}\fontfamily{cmr}\selectfont\def\sfdefault{cmss}\def\bfdefault{bf}\noindent
\begingroup\small \begin{center}
\begin{tabular}{p{1in}}
Please make sure you send in your completed
forms by January 1st next year, or the penalty
clause 2(a) will apply\\
\end{tabular}
\end{center}
\endgroup\end{quote}\end{example}
The text is typeset to the required width, and the box
is extended downwards for as long as is required to fit the
text. Note that the baseline of a \command{parbox}
is set to the midpoint of the box; that is, if you include a
\command{parbox} in mid-sentence, the centre of the
box will be lined up with the line of type currently being
set.\parbox{1cm}{
{\scriptsize{}\selectfont{}Like
this small paragraph.\par}
} You can specify that it should be the top or
bottom by adding an optional \opt{t} or
\opt{b} in square brackets before the width. For
example,
\verb+\parbox[t]{1in}{...}+ will produce
\parbox[t]{1in}{
a box with the baseline aligned with the top line of
the text in the box.
}
Notice that when setting very narrow measures with type
that is too large, the spacing may become uneven and there
may be too much hyphenation. Either use
\command{raggedright} or reduce the type size, or
(in extreme cases) reword the text or break each line by
hand. It is rare for \LaTeX{} to need this: the example above
was deliberately chosen to be obtuse as an
illustration.
Where the contents is more extensive or more
complicated, you can use the \env{minipage}
environment.
Within this you can use virtually everything
that occurs in normal text (e.g. lists, paragraphs,
tabulations, etc.) with the exception of floats like
tables and figures. The \env{minipage}
environment has an argument just like
\command{parbox} does, and it means the same: the
width you want the text set to.
Note that in \env{minipage}s and
\command{parbox}es, the paragraph indentation
(\length{parindent}) is
reset to zero. If you need to change it, set it inside the
\env{minipage} or \command{parbox}
using the \command{setlength} command (see \S\thinspace\ref{paragraphs}).
\begin{example}
\begin{sourcecode}\begin{Verbatim}[fontsize=\small]
\begin{minipage}{3in}
Please make sure you send in your completed
forms by January 1st next year, or the
penalty clause 2(a) will apply.
\begin{itemize}
\item Incomplete forms will be returned to
you unprocessed.
\item Forms must be accompanied by the
correct fee.
\item There is no appeal. The adjudicators'
decision is final.
\end{itemize}
\end{minipage}
\end{Verbatim}
\end{sourcecode}\vspace*{-\baselineskip}\begin{quote}\fontencoding{T1}\fontfamily{cmr}\selectfont\def\sfdefault{cmss}\def\bfdefault{bf}\noindent
\begingroup\small \begin{center}
\begin{tabular}{p{3in}}
Please make sure you send in your
completed forms by January 1st next year, or the
penalty clause 2(a) will
apply.\begin{itemize}
\item
Incomplete forms will be returned to you
unprocessed.
\item
Forms must be accompanied by the correct
fee.
\item
There is no appeal. The
adjudicators' decision is final.
\end{itemize}
\\
\end{tabular}
\end{center}
\endgroup\end{quote}\end{example}
There are two other ways of typesetting text to widths
other than the normal text width: you can use a one-row,
one-cell \env{tabular} environment with the
\verb+p+ column type specification, or you
can use the \command{vbox} command, which is raw
\TeX{}, and outside the scope of this document.
\subsection{Framed boxes}
\label{fbox}
To put a frame round \fbox{some text}, use the
\command{fbox} command:
\verb+\fbox{some text}+. This works for a few
words in mid-line, but the framed box and its contents
won't break over the end of a line. To typeset
multiline text in a box, put it in a
\command{parbox}, or use a
\env{minipage} or
\env{tabular} environment as described above,
and enclose the whole thing in a
\command{fbox}.
\begin{example}
\begin{sourcecode}\begin{Verbatim}[fontsize=\small]
\fbox{\begin{minipage}{3in}
This multiline text is more flexible than
a tabular setting:
\begin{itemize}
\item it can contain any type of normal
\LaTeX{} typesetting;
\item it can be any specified width;
\item it can even have its own
footnotes\footnote{Like this}.
\end{itemize}
\end{minipage}}
\end{Verbatim}
\end{sourcecode}\vspace*{-\baselineskip}\begin{quote}\fontencoding{T1}\fontfamily{cmr}\selectfont\def\sfdefault{cmss}\def\bfdefault{bf}\noindent
\begin{center}\setlength{\fboxrule}{1pt}
\begin{minipage}{3in}
This multiline text is more flexible than a
tabular setting:
\begin{itemize}
\item
it can contain any type of normal \LaTeX{}
typesetting;
\item
it can be any specified width;
\item
it can even have its own footnotes.\footnote{Like this.}
\end{itemize}
\end{minipage}
\end{center}
\end{quote}\end{example}
The spacing between text and box is controlled by the
value of \length{fboxsep}, and
the thickness of the line by \length{fboxrule}. The following values
were used above:
\begin{sourcecode}\begin{Verbatim}[fontsize=\small]
\setlength{\fboxsep}{1em}
\setlength{\fboxrule}{2pt}
\end{Verbatim}
\end{sourcecode}
As we saw before, setting justified text in narrow
measures will produce poor spacing: either use the
\command{raggedright} command, or change the font
size, or add explicit extra hyphenation points.
Note the \verb+\begin{tabular}+ and
\verb+\begin{minipage}+ commands still need the
width specifying: in the case of the
\verb+\begin{tabular}+ by the use of the
\verb+p+ column type with its width
specification, and in the case of
\verb+\begin{minipage}+ by the second
argument.
\begin{example}
\begin{sourcecode}\begin{Verbatim}[fontsize=\small]
\fbox{\begin{tabular}{p{1in}}
Multiline text in a box typeset using
\textsf{tabular}
\end{tabular}}
\end{Verbatim}
\end{sourcecode}\vspace*{-\baselineskip}\begin{quote}\fontencoding{T1}\fontfamily{cmr}\selectfont\def\sfdefault{cmss}\def\bfdefault{bf}\noindent
\begingroup\small \begin{center}
\setlength{\tabcolsep}{6pt}
\begin{tabular}{|p{1in}|}\hline
Multiline text in a box typeset using
\package{tabular}\\
\hline
\end{tabular}
\end{center}
\endgroup\end{quote}\end{example}
\subsection{Sidebars and panels}
\label{fancybox}
The \package{fancybox} package lets you
extend the principle of \command{fbox} with
commands to surround text in square, oval (round-cornered),
and drop-shadow boxes (e.g. \command{ovalbox},
\command{shadowbox}, etc.: see the documentation
for details).
You can create panels of any size with these borders by
using the \env{minipage} environment to
typeset the text inside a special \env{Sbox}
environment which \package{fancybox} defines.
The \env{minipage} formats the text but the
\env{Sbox} `captures'
it, allowing you to put the frame round it as it
prints.
The printed version of this document uses this extensively and
there is a useful example shown in \S\thinspace\ref{macenv}.
\chapter{Textual tools}
\label{texttools}
\index{tools}
Every text-handling system needs to support a repertoire of
tools for doing things with text. \LaTeX{} implements many
dozens, of which a small selection of the most frequently used
is given here:
\begin{itemize}
\item
offset quotations (sometimes called `block
quotes');
\item
footnotes and end-notes;
\item
marginal notes;
\item
cross-references, both normal ones and bibliographic
citations;
\item
indexes and glossaries;
\item
typesetting in multiple columns.
\end{itemize}
\section{Quotations}
\label{quotations}
Direct speech and short quotes within a sentence
`like this' are done with simple
quotation marks as described in \S\thinspace\ref{quotes}. Sometimes, however, you may want longer
quotations set as a separate paragraph. Typically these are
indented from the surrounding text. \LaTeX{} has two
environments for doing this.
Such quotations are often set in a smaller size of type,
although this is not the default, hence the use of the
\command{small} command in the second example. The
inclusion of the bibliographic citation at the end is
optional: here it is done with a non-standard command
\command{citequote} which I invented for this example
(there is more about how to do things like this in \chaptername~\ref{macros}).
\begin{description}
\item[\sffamily The {\fontseries{m}\selectfont{}\package{quote}}
environment]
is for up to a line of text each per (short)
quotation, with the whole thing indented from the
previous paragraph but with no additional indentation on
each quote;
\begin{example}
\begin{sourcecode}[-\leftmargin]\begin{Verbatim}[fontsize=\small]
\begin{quote}
Do, Ronny, Do. \textit{Nancy Reagan}
Da Do Ron Ron. \textit{The Crystals}
\end{quote}
\end{Verbatim}
\end{sourcecode}\vspace*{-\baselineskip}\begin{quote}\fontencoding{T1}\fontfamily{cmr}\selectfont\def\sfdefault{cmss}\def\bfdefault{bf}\noindent
Do, Ronny, Do. {\fontshape{it}\selectfont{}Nancy
Reagan}
Da Do Ron Ron. {\fontshape{it}\selectfont{}The
Crystals}
\end{quote}\end{example}
\item[\sffamily The {\fontseries{m}\selectfont{}\package{quotation}}
environment]
is for longer passages (a paragraph or more) of a
single quotation, where not only is the block of text
indented, but each paragraph of it also has its own
extra indentation on the first line.
\begin{example}
\begin{sourcecode}[-\leftmargin]\begin{Verbatim}[fontsize=\small]
\begin{quotation}\small
At the turn of the century William Davy,
a Devonshire parson, finding errors in
the first edition of his \titleof{davy},
asked for a new edition to be printed.
His publisher refused and Davy purchased
a press, type, and paper. He harnessed
his gardener to the press and apprenticed
his housemaid to the typesetting. After
twelve years' work, a new edition
of fourteen sets of twenty-six volumes
was issued---which surely indicates that,
when typomania is coupled with religious
fervour, anything up to a miracle may be
achieved.\citequote[p.76]{ryder}
\end{quotation}
\end{Verbatim}
\end{sourcecode}\vspace*{-\baselineskip}\begin{quote}\fontencoding{T1}\fontfamily{cmr}\selectfont\def\sfdefault{cmss}\def\bfdefault{bf}\noindent
\begin{quotation}\small\begingroup
At the turn of the century William Davy, a
Devonshire parson, finding errors in the first
edition of his \titlecite{davy},
asked for a new edition to be printed. His publisher
refused and Davy purchased a press, type, and paper.
He harnessed his gardener to the press and
apprenticed his housemaid to the typesetting. After
twelve years' work, a new edition of fourteen
sets of twenty-six volumes was issued---which surely
indicates that, when typomania is coupled with
religious fervour, anything up to a miracle may be
achieved.
\par\endgroup\smallskip\footnotesize\noindent [\citeauthortitleyear{ryder}], p.76\end{quotation}
\end{quote}\end{example}
\end{description}
\section{Footnotes and end-notes}
\label{footnotes}
\index{footnotes}
The command \command{footnote}, followed by the
text of the footnote in curly braces, will produce an
auto-numbered footnote with a raised small number where you
put the command, and the numbered text automatically printed
at the foot of the page.\footnote{Like this.} The number is reset to 1 at the start of each
chapter (but you can override that and make them run
continuously throughout the document, or even restart at 1 on
each page or section).
\LaTeX{} automatically creates room for the footnote, and
automatically reformats it if you change your document in such
a way that the point of attachment and the footnote would move
to the next (or preceding) page.
Because of the way \LaTeX{} reads the whole footnote before
doing anything with it, you can't use
\command{verb} (\S\thinspace\ref{inlineverb}) alone
in footnotes: either precede it with
\command{protect} or use [abuse?] the
\command{url} command instead, which you should be
using for Web and email addresses in any case).
Footnotes inside minipages (see \S\thinspace\ref{boxes}) produce lettered notes instead of
numbered ones, and they get printed at the bottom of the
minipage, \emph{not} the bottom of the physical
page (but this too can be changed).
There is a package to hold over your footnotes and make
them print at the end of the chapter instead
(\package{endnote}) or at the end of the whole
document, and there is a package to print many short footnotes
in several columns so they take up less space
(\package{fnpara}). It is also possible to have
several separate series of footnotes active simultaneously,
which is useful in critical editions or commentaries: a
numbered series may be used to refer to an original
author's notes; a lettered series can be used for notes
by a commentator or authority; and a third series is available
for your own notes. It is also possible to format footnotes
within footnotes.
If your footnotes are few and far between, you may want to
use footnote symbols instead of numbers. You can do this by
redefining the output of the footnote counter to be the
\command{fnsymbol} command:
\begin{sourcecode}\begin{Verbatim}[fontsize=\small]
\renewcommand{\thefootnote{\fnsymbol{footnote}}
\end{Verbatim}
\end{sourcecode}
There are also ways to refer more than once to the
same footnote, and to defer the positioning of the footnote if
it occurs in a float like a Table or Figure, where it might
otherwise need to move to a different page.
\section{Marginal notes}
\label{marginals}
\index{marginal notes}
You can add marginal notes to your text\marginal{Like this.} instead of
(or as well as) footnotes. You need to make sure that you have
a wide-enough margin, of course: use the
\package{geometry} package (see \S\thinspace\ref{colorpkg}) to allocate enough space, otherwise
the notes will be too cramped. There are several packages to
help with formatting marginal notes, but the simplest way is
to define it yourself. Add this new command to your
preamble:
\begin{sourcecode}\begin{Verbatim}[fontsize=\small]
\newcommand{\marginal}[1]{%
\leavevmode\marginpar{\tiny\raggedright#1\par}}
\end{Verbatim}
\end{sourcecode}
Then you can use \verb+\marginal{Some text}+\marginal{Some text where you need
it.} Be careful, however, because marginal
notes are aligned with the line where the command starts, so a
very long one followed too closely by another will cause
\LaTeX{} to try and
adjust the position so they don't overlap.
We're jumping ahead a bit here, as we haven't
covered how to define your own commands yet. I won't even
try to explain it here, although the attentive reader can
probably deduce some of it by inspection. See \chaptername~\ref{macros} for more information about making up your
own commands.
\section{Cross-references}
\label{xrefs}
\index{cross-references}
This is one of the most powerful features of \LaTeX{}. You
can label any point in a document with a name you make up, and
then refer to it by that name from anywhere else in the
document, and \LaTeX{} will always work out the cross-reference
number for you, no matter how much you edit the text or move
it around.
A similar method is used to cite documents in a
bibliography or list of references, and there are packages to
sort and format these in the correct manner for different
journals.
\subsection{Normal cross-references}
\label{normalxref}
You label a place in your document by using the command
\command{label} followed by a short name you make
up, in curly braces:\footnote{This section is labelled
`\url+normalxref+',
for example.} we've already seen this done for labelling
Figures and Tables.
\begin{sourcecode}\begin{Verbatim}[fontsize=\small]
\section{New Research}
\label{newstuff}
\end{Verbatim}
\end{sourcecode}
You can then refer to this point from anywhere in the
same document with the command \command{ref}
followed by the name you used, e.g.
\begin{example}
\begin{sourcecode}\begin{Verbatim}[fontsize=\small]
In \S~\ref{newstuff} there is a list of recent
projects.
\end{Verbatim}
\end{sourcecode}\vspace*{-\baselineskip}\begin{quote}\fontencoding{T1}\fontfamily{cmr}\selectfont\def\sfdefault{cmss}\def\bfdefault{bf}\noindent
In \S\thinspace\ref{normalxref}
there is a list of recent projects.
\end{quote}\end{example}
(The \command{S} command produces a section
sign (\S) and the
\command{P} command produces a paragraph sign
(\P).)
If the label is in normal text, the reference will
provide the current chapter or section number or both
(depending on the current document
class).\footnote{Thus I can
refer here to
\url+\ref{normalxref}+ and get the
value \S\thinspace\ref{normalxref}.} If the label
was inside a Table or Figure, the reference provides the
Table number or Figure number prefixed by the chapter
number. A label in an enumerated list will provide a
reference to the item number. If there is no apparent
structure to this part of the document, the reference will
be null. Labels must be unique (that is, each value must
occur only \emph{once} as a label within a
single document), but you can have as many references to
them as you like.
Note the use of the unbreakable space
(\verb+~+) between the \command{ref}
and the word before it. This prints a space but prevents the
line ever breaking at that point, should it fall close to
the end of a line.
The command \command{pageref} followed by any
of your label values will provide the page number where the
label occurred, regardless of the document structure. This
makes it possible to refer to something by page number as
well as its \command{ref} number, which is useful
to readers in very long documents.
Unresolved references are printed as three question
marks, and also cause a warning message at the end of the
log file. There's never any harm in having
\command{label}s you don't refer to, but using
\command{ref} when you don't have a matching
\command{label} is an error.
\subsection{Bibliographic references}
\label{bib}
\index{bibliographies}\index{references}
The mechanism used for references to reading lists and
bibliographies is almost identical to that used for normal
cross-references. Although it is possible to type the
details of each citation manually, there is a companion
program to \LaTeX{} called \BibTeX{}, which manages
bibliographic references automatically. This reduces the time
needed to maintain and format them, and dramatically
improves accuracy. Using \BibTeX{} means you only ever have
to type the bibliographic details of a work once. You can
then cite it in any document you write, and it will get
formatted automatically to the style you specify.
\subsubsection{Citing references}
\label{citation}
\BibTeX{} works exactly the same way as other
bibliographic databases: you keep details of every
document you want to refer to in a separate file, using
\BibTeX{}'s own format (see example below). Many
writers make a habit of adding the details of every book
and article they read, so that when they write a document,
these entries are always available for reference. You give
each entry a short label, just like you do with normal
cross-references (see \S\thinspace\ref{normalxref}), and
it is this label you use to refer to in your own documents
when you cite the work using the \command{cite}
command:
\begin{sourcecode}\begin{Verbatim}[fontsize=\small]
...as has clearly been shown by Fothergill~\cite{fg}.
\end{Verbatim}
\end{sourcecode}
By default, this creates a cross-reference number in
square brackets [1] which is a common style in the
Natural Sciences (see \S\thinspace\ref{othercite} for
details of how to change this). There are dozens of
alternative citation formats in extra packages, including
the popular author/year format:
\begin{example}
\begin{sourcecode}\begin{Verbatim}[fontsize=\small]
...as has clearly been shown
by~\citeauthoryear{fg}.
\end{Verbatim}
\end{sourcecode}\vspace*{-\baselineskip}\begin{quote}\fontencoding{T1}\fontfamily{cmr}\selectfont\def\sfdefault{cmss}\def\bfdefault{bf}\noindent
\dots as has clearly been shown by \citeauthoryear{fg}.
\end{quote}\end{example}
Note that in this case you don't type the
author's name because it is automatically extracted
by \BibTeX{}. There are lots of variants on this technique
in many packages, allowing you to phrase your sentences
with references in as natural a way as possible, and rely
on \BibTeX{} to insert the right data. (If you examine the
source of this document you'll find I use some
homebrew commands like \command{authorof} and
\command{titleof} which I use for a similar
purpose.)
To print the bibliographic listing (usually called
`References' in articles and
`Bibliography' in books and
reports), add these two lines towards the end of your
document, or wherever you want it printed, substituting
the name of your own \BibTeX{} file and the name of your
chosen bibliography style:
\begin{sourcecode}\begin{Verbatim}[fontsize=\small]
\bibliographystyle{ieeetr}
\bibliography{mybib}
\end{Verbatim}
\end{sourcecode}
\begin{itemize}
\item
The \command{bibliography} command is
followed by the filename of your \BibTeX{} file
\emph{without} the
\url+.bib+ extension.
\item
The \command{bibliographystyle} command
is followed by the name of any of \LaTeX{}'s
supported bibliography styles, of which there are many
dozens available from CTAN\index{CTAN@CTAN}.\footnote{The style
shown in the example here provides formatting
according to the specifications for Transactions
of the IEEE (revised).}
\end{itemize}
The styles \opt{plain} and
\opt{alpha} are two common generic styles used
for drafts. The example above uses Transactions of the Institute of Electrical
and Electronics Engineers (IEEETR)\index{IEEETR@IEEETR|textbf}\index{Acronyms@\textbf{Acronyms}, defined!IEEETR@IEEETR|textbf}.
\subsubsection{Running \emph{bibtex}}
\label{bibtex}
When you run the \product{bibtex}
program, the details of every document you have cited will
be extracted from your database, formatted according to
the style you specify, and stored in a temporary
bibliographic (\url+.bbl+) file with a
label corresponding to the one you used in your citation,
ready for \LaTeX{} to use. This is entirely automatic: all
you do is cite your references in your \LaTeX{} document
using the labels you gave the entries in your \BibTeX{}
file, and run the \product{bibtex}
program.
After processing your file with \LaTeX{}, run \BibTeX{}
on it by clicking on the \guiicon{\BibTeX{}}
toolbar icon (\product{WinEdt}) or the
\menuitem{TeX}{BibTeX
File} menu entry
(\product{Emacs}) or by typing the
command \verb+bibtex+ followed by the name of
your document (without the \url+.tex+
extension). When you run \LaTeX{} again it uses the
\url+.bbl+ file to add the references where
you tell it to, and a subsequent run of \LaTeX{} will
format the correct citation numbers (or author/year, or
whatever format you are using).
\begin{sourcecode}\begin{Verbatim}[fontsize=\small]
$ latex mybook
$ bibtex mybook
$ latex mybook
$ latex mybook
\end{Verbatim}
\end{sourcecode}
Because of this three-stage process, you always get a
warning message about an `unresolved
reference' the first time you add a new
reference to a previously uncited work. This will
disappear after subsequent runs of
\product{bibtex} and \LaTeX{}.
In practice, authors tend to run \LaTeX{} from time to
time during writing anyway, so they can preview the
document. Just run \BibTeX{} after adding a new
\command{cite} command, and subsequent runs of
\LaTeX{} will incrementally incorporate all references
without you having to worry about it. You only need to
follow the full formal sequence (\LaTeX{}, \BibTeX{},
\LaTeX{}, \LaTeX{}) when you have finished writing and want
to ensure that all references have been resolved.
\subsubsection{\BibTeX{} format}
\label{bibspec}
The format for the \BibTeX{} file is specified in the
\BibTeX{} documentation (see \S\thinspace\ref{packagedoc}
for how to find and print it). You create a file with a
name ending in \url+.bib+, and add your
entries, for example:
\begin{sourcecode}\begin{Verbatim}[fontsize=\small]
@book{fg,
title = {{An Innkeeper's Diary}},
author = {John Fothergill},
edition = {3rd},
publisher = {Penguin},
year = 1929,
address = {London}
}
\end{Verbatim}
\end{sourcecode}
There is a prescribed set of fields for each of a
dozen or so types of document: book, article (in a
journal), article (in a collection), chapter (in a book),
thesis, report, paper (in a Proceedings), etc. Each entry
identifies the document type after the
`\verb+@+' sign,
followed by the entry label that you make up, and then
each field (in any order), using the format:
\begin{sourcecode}\begin{Verbatim}[fontsize=\small]
keyword = {value},
\end{Verbatim}
\end{sourcecode}
Most \TeX{}-sensitive editors have a \BibTeX{} mode
which understands these entries.
\product{Emacs} automatically uses its
\url+bibtex-mode+ whenever you open a
filename ending in \url+.bib+. When editing
\BibTeX{} databases, the rules are simple:
\begin{itemize}
\item
Omit the comma after the last field in the entry
(only\mdash{}eg after \verb+{London}+ in
the example).
\item
Titles may have their case changed in some styles:
to prevent this, enclose the title in double curly
braces as in the example.
\item
Values which are purely numeric (e.g. years)
may omit the curly braces.
\item
Fields can occur in any order but the format must
otherwise be strictly observed.
\item
Fields which are not used do not have to be
included (so if your editor automatically inserts them
as blank or prefixed by \verb+OPT+
[optional], you can safely delete them as unused
lines).
\end{itemize}
To help with this, there are several interfaces to
creating and maintaining \BibTeX{} files, such as
\product{tkbibtex} (see Figure~\ref{tkbibtex}), or
\product{pybliographic}.
\begin{figure}\small
\caption{\small tk\BibTeX{}, one of several graphical interfaces to
\BibTeX{} databases}
\label{tkbibtex}
\begin{center}
\includegraphics[width=0.75\textwidth]{tkbibtex}
\end{center}
\end{figure}
\subsubsection{Changing the layout}
\label{bibstyle}
To change the title printed over the reference
listing, just change the value of
\command{refname} (articles) or
\command{bibname} (books and reports) by adding a
line like this in your preamble:
\begin{sourcecode}\begin{Verbatim}[fontsize=\small]
\renewcommand{\bibname}{Reading List}
\end{Verbatim}
\end{sourcecode}
The formatting specifications (\BibTeX{} styles) are
based on standard settings for journals and books from
dozens of publishers: you just pick the one you want by
name. The \url+texmf/bib/bst+ subdirectory
of your installation contains the ones installed by
default, and you can search on CTAN\index{CTAN@CTAN}
for others (look for \url+.bst+ files).
Many of them are named after university press styles
(e.g. \product{harvard},
\product{oxford}) or the publisher or
journal which specified them (e.g.
\product{elsevier},
\product{kluwer}, etc.).
Some of them have an accompanying package
(\url+.sty+) file which
you need to include with the normal
\command{usepackage} command in your preamble. In
this case the format may be distributed as
\url+.dtx+ and \url+.ins+
files and will need installing in the same way as any
other package (see \S\thinspace\ref{pkginst}). Always read
the documentation, because most of the formats are very
specific to the journal they were designed for, and may have
fairly absolute requirements.
\begin{warning}
If you are writing for a specific publisher, you
should remember that the rules or formats are laid down
by the typographic designer of that journal or
publisher: you cannot arbitrarily change the format just
because you don't happen to like it: it's not
your choice!
\end{warning}
It is also possible to write your own \BibTeX{}
(\url+.bst+) style files, although it uses
a language of its own which really needs a computer
science background to understand. However, this is
rendered unnecessary in most cases: there is an extensive
program (actually written in \LaTeX{}) called
\product{makebst}, which makes
\url+.bst+ files by asking you a (long)
series of questions about exactly how you want your
citations formatted. Just type
\verb+latex makebst+ in a command window, but
give it a dummy run first, because some of the questions
are very detailed, so you need to have thought through how
you want your citations to appear before you start.
\subsubsection{Other modes of citation}
\label{othercite}
The method of citing a work by numeric reference is
common in the Natural Sciences but is not used in Law or
the Humanities. In these fields, citations are usually
done with short references (author/short-title/year) in a
numbered footnote. Sometimes they are actually called
`footnotes' to the exclusion of
ordinary footnotes, although they are really citations
which happen by convention to be
\emph{displayed} as footnotes: an important
distinction rarely appreciated by authors until they come
to need a normal footnote.
For these fields, the bibliography at the back of the
document is printed \emph{unnumbered} in
alphabetic order of author, or perhaps chronologically if
the time-frame is very large. This unnumbered format is
why it is conventionally called
`References' rather than
`Bibliography': a sufficient working
citation has already been provided in the footnote, and
the list at the back is for reference purposes only;
whereas in the Natural Sciences, the citation is just a
number, or possibly an author and year only, so the full
listing is called a Bibliography.
The \package{jurabib} package
(originally intended for German law articles but now
extended to other fields in the Humanities, and to other
languages) has extensive features for doing this style of
citation and is strongly recommended.
\section{Indexes and glossaries}
\label{indexes}
\index{indexes}\index{glossaries}
\LaTeX{} has a powerful, automated indexing facility which
uses the standard \product{makeindex}
program. To use indexing, use the package
\package{makeidx} and include the
\command{makeindex} command in your preamble:
\begin{sourcecode}\begin{Verbatim}[fontsize=\small]
\usepackage{makeidx}
\makeindex
\end{Verbatim}
\end{sourcecode}
When you want to index something, using the command
\command{index} followed by the entry in curly
braces, as you want it to appear in the index, using one of
the following formats:
\begin{description}
\item[\sffamily Plain entry]
Typing \verb+\index{beer}+ will create
an entry for `beer' with the
current page
number.\index{beer}
\item[\sffamily Subindex entry]
For an entry with a subentry use an exclamation mark
to separate them:
\verb+\index{beer!lite}+.\index{beer!lite} Subsubentries like
\verb+\index{beer!lite!American}+ work to
another level deep.\index{beer!lite!American}
\item[\sffamily Cross-references]
`See' entries are done with
the vertical bar (one of the rare times it does
\emph{not} get interpreted as a math
character):
\verb+\index{Microbrew|see{beer}}+\index{Microbrew|see{beer}}
\item[\sffamily Font changes]\label{indextypo}
To change the style of an entry, use the @-sign
followed by a font change command:
\begin{sourcecode}[-\leftmargin]\begin{Verbatim}[fontsize=\small]
\index{beer!Rogue!Chocolate
Stout@\textit{Chocolate Stout}}
\end{Verbatim}
\end{sourcecode}
\noindent This example\index{Chocolate Stout@\textit{Chocolate Stout}} indexes `\product{Chocolate
Stout}' and italicises it
at the same time. Any of the standard
\verb+\text...+ font-change commands work
here: see the table on p.\thinspace\pageref{fontcmds} for details.
You can also change the font of the index number on
its own, as for first-usage references, by using the
vertical bar in a similar way to the
`see' entries above, but
substituting a font-change command name
(\emph{without} a backslash) such as
\verb+textbf+ for bold-face text (see the
index)\index{Chocolate Stout|textbf}:
\begin{sourcecode}[-\leftmargin]\begin{Verbatim}[fontsize=\small]
\index{beer!Rogue!Chocolate Stout|textbf}
\end{Verbatim}
\end{sourcecode}
\item[\sffamily Out of sequence]
The same method can be used as for font changes,
but using the alternate index word instead of the font
command name, so
\verb+\index{Oregon Brewing Company@Rogue}+\index{Oregon Brewing Company@Rogue} will add an entry for
`Rogue' in the
`O' section of the index, as if
it was spelled `Oregon Brewing
Company'.
\end{description}
When the document has been processed through \LaTeX{} it
will have created a \url+.idx+ file, which you
run through the \product{makeindex} program
by typing (for example):
\begin{sourcecode}\begin{Verbatim}[fontsize=\small]
makeindex mythesis
\end{Verbatim}
\end{sourcecode}
Some editors may have a button or menu entry for this. The
program will look for the \url+.idx+ file and
output a \url+.ind+ file. This gets used by the
command \command{printindex} which you put at the end
of your document, where you want the index printed. The
default index format is two columns.
Glossaries are done in a similar manner using the command
\command{makeglossary} in the preamble and the
command \command{glossary} in the same way as
\command{index}. There are some subtle differences in
the way glossaries are handled: both the books by \citeauthoryear{latexbook} and by \citeauthoryear{companion} duck the issue, but
there is some documentation on \url+glotex+ on
CTAN\index{CTAN@CTAN}.
\section{Multiple columns}
\label{multicols}
\index{columns}
Use the \package{multicol} package: the
environment is called \env{multicols} (note the
plural form) and it takes the number of columns as a separate
argument in curly braces:
\begin{sourcecode}\begin{Verbatim}[fontsize=\small]
\usepackage{multicol}
...
\begin{multicols}{3}
...
\end{multicols}
\end{Verbatim}
\end{sourcecode}
\begin{multicols}{3}
\setlength{\parskip}{0pt}\footnotesize\noindent
\LaTeX{} has built-in support for two-column typesetting
via the \verb+twocolumn+ option in the standard
Document Class Declarations, but it is relatively inflexible
in that you cannot change from full-width to double-column
and back again on the same page, and the final page does not
balance the column heights. However, it does feature special
\env{figure*} and \env{table*}
environments which typeset full-width figures and tables
across a double-column setting.
The more extensive solution is the
\package{multicol} package, which will set up
to 10 columns, and allows the number of columns to be
changed or reset to one in mid-page, so that full-width
graphics can still be used. It also balances the height of
the final page so that all columns are the same
height\mdash{}if possible: it's not always
achievable\mdash{}and you can control the width of the gutter
by setting the \command{columnsep} length to a new
dimension.
Multi-column work needs some skill in typographic
layout, though: the narrowness of the columns makes
typesetting less likely to fit smoothly because it's hard to
hyphenate and justify well when there is little space to
man\oe uvre in.
\end{multicols}
\chapter{Fonts and layouts}
\label{typo}
\index{typographics}
This is the chapter that most users want first, because they
come to structured documents from a wordprocessing environment
where the \emph{only} way to convey different
types of information is to fiddle with the font and size
drop-down menus.
As I hope you have seen, this is normally completely
unnecessary in \LaTeX{}, which does most of the hard work for you
automatically. However, there are occasions when you need to
make manual typographic changes, and this chapter is about how
to do them.
\section{Changing layout}
\label{layouts}
The design of the page can be a very subjective matter,
and also rather a subtle one. Many organisations large and
small pay considerable sums to designers to come up with page
layouts to suit their purposes. Styles in page layouts change
with the years, as do fashions in everything else, so what may
have looked attractive in 1991 may look rather dated in
2011.
As with most aspects of typography, making the document
readable involves making it consistent, so the reader is not
interrupted or distracted too much by apparently random
changes in margins, widths, or placement of objects. However,
there are a number of different occasions where the layout
usually \emph{does} change, related to the
frequency with which the format appears.
\begin{itemize}
\item
The title page, the half-title, copyright page,
dedication, and other one-page preliminaries (if you use
them) are usually designed individually, as the information
on it only occurs once in that format anywhere in the
document.
\item
The table of contents and other related lists like
figures and tables all need to share one
design.
\item
The prelims like Foreword, Introduction, and Preface
should likewise follow the same format between
them.
\item
Chapter and Appendix start pages usually share a
layout.
\item
Other (normal) pages have a single layout, but it may
specify individual variations to handle tables, lists,
figures, sidebars, exercises, footnotes, etc.
\end{itemize}
If you are going to design a whole document, it's
probably a good idea to read a couple of books on layout
design first, to get a feel for the conventions which
contribute to making the reader comfortable reading.
While unusual or radical layouts have an important role in
attention-grabbing, or in making a socio-political statement
(\titlecite{wired} magazine is an obvious
recent example), they are usually out of place in business
reports, white papers, books, theses, and journals. In
ephemera, on the other hand, as in advertising, they are
probably critical.
\subsection{Spacing}
\label{spacing}
\index{page size!margins}\index{margins}
We mentioned in \S\thinspace\ref{marginals} and
elsewhere the existence of the
\package{geometry} package which lets you
change margins. It also lets you set the text-area height
and width and a lot of other layout settings: read the
documentation for details (see \S\thinspace\ref{packagedoc} for how to read package
documentation).
\begin{sourcecode}\begin{Verbatim}[fontsize=\small]
\usepackage[left=2cm,top=1cm,bottom=2cm,right=3cm,
nohead,nofoot]{geometry}
\end{Verbatim}
\end{sourcecode}
The spacing around the individual textual components
(headings, paragraphs, lists, footnotes, etc.) can
also be changed on a document-wide basis, as we saw with
paragraph spacing and indentation in \S\thinspace\ref{paraspace}.
Changing the spacing of section headings for the whole
document can be done with the
\package{sectsty} package, designed to let
you adjust section-head spacing without having to know about
the internal \LaTeX{} coding, which is quite complex.
The spacing for lists can be adjusted with the
\package{mdwlist} package. In both cases the
user with highly specific requirements such as a
publisher's Compositor's Specification should read
the relevant sections in the \titlecite{companion} or ask for expert help, as
there are many internal settings which can also be changed
to fine-tune your design, but which need some knowledge of
\LaTeX{}'s internals.
All the above are for automating changes so that they
occur every time in a consistent manner. You can also make
manual changes whenever you need:
\index{space|see{white-space}}\begin{description}
\item[\sffamily Flexible vertical space]\index{white-space!vertical!flexible}
There are three commands
\command{smallskip},
\command{medskip}, and
\command{bigskip}. These output flexible
(dynamic, or `rubber') space,
approximately 3pt, 6pt, and 12pt high respectively,
and they will automatically compress or expand a
little, depending on the demands of the rest of the
page (for example to allow one extra line to fit, or a
heading to be moved to the next page without anyone
except a typographer noticing the change). These
commands can only be used after a paragraph break (a
blank line or the command
\command{par}).
\item[\sffamily Fixed vertical space]\index{white-space!vertical!fixed}\index{white-space!vertical!disappearing}
For a fixed-height space which will
\emph{not} stretch or shrink, use the
command \command{vspace} followed by a length
in curly braces, e.g. \verb+\vspace{18pt}+
(again, this has to be after a paragraph break). Bear
in mind that extra space which ends up at a page-break
when the document is formatted \emph{will get
discarded entirely} to make the bottom and
top lines fall in the correct places. To force a
vertical space to remain and be taken into account
even after a page break (very rare), use the starred
variant \command{vspace*}, e.g.
\verb+\vspace*{19pt}+.
\item[\sffamily Double spacing]\index{white-space!double-spacing}\index{double-spacing}
Double-spacing normal lines of text is usually a
bad idea, as it looks very ugly. It is still
unfortunately a requirement in some universities for
thesis submission, a historical relic from the days of
typewriters. Nowadays, 1\Frac13 or 1½ line
spacing is considered acceptable, according to your
font size. If your institution still thinks they
should have double line spacing, they are probably
wrong, and just don't understand that the world has
moved on since the typewriter. Show them this
paragraph and explain that they need to enter the 21st
century and adapt to the features of computer
typesetting. If they still insist, use the
\package{setspace} package,which has
commands for double line-spacing and one-and-a-half
line spacing, but be prepared for some very ugly
output (so warn your supervisor and extern).
The space between lines is defined by the value of
the length variable \length{baselineskip} multiplied
by the value of the \command{baselinestretch}
command. In general, \emph{don't meddle with
\length{baselineskip} at
all}, and with
\command{baselinestretch} only if you know
what you are doing. (Both can, however, safely be used
as reference values in commands like
\verb+\vspace{\baselineskip}+ to leave a
whole line space.)
\index{spacing|see{white-space}}
The value of \length{baselineskip} changes with
the font size (see \S\thinspace\ref{fontsize}) but is conventionally set to
1.2 times the current nominal font size. This is a
value derived from long experience: only change it if
you understand what it means and what effect it will
have.
Quite separately, there are some perfectly genuine
and normal reasons for wanting wide line spacing,
\index{spacing|see{double-spacing}} for example when typesetting a proof of a
critical or variorum edition, where editors and
contributors are going to want to add notes manually
by writing between the lines, or where the text is
going to be overprinted by something else like
Braille, or in advertising or display text for special
effects.
\item[\sffamily Horizontal space]\index{white-space!horizontal}
There is a horizontal equivalent to the
\command{vspace} command:
\command{hspace}, which works in the same
way, so I can force a 1$''$ space like
this\hspace*{1in}in
mid-paragraph. There are also some predefined
(shorter) spaces available:
\begin{itemize}
\item
\command{thinspace} (\Frac1{12}em),
which we saw between single and double quotes in
the last paragraph of \S\thinspace\ref{thinspace}. It's also
sometimes used between the full point after
abbreviations and a following number, as in page
references like p.\thinspace{}199, where a word space
would look too big, and setting it solid would
look too tight.
\item
\command{enspace} (½em).
There is no direct equivalent predefined in
\LaTeX{} for mid and thick spaces as used by metal
typesetters, although it would be possible to
define them. The en as a unit is often used as the
width of a single digit in some fonts, as a
convenience so that tables of figures are easy to
line up.
\item
\command{quad} (1em).
\item
\command{qquad} (2em).
\end{itemize}
Beyond this, all horizontal space within
paragraphs is automatically flexible,
\index{tracking|see{letterspacing}}\index{letterspacing} as this is what
\LaTeX{} uses to achieve justification. Never be
tempted to try and change the spacing between letters
unless you have some professional training in
typography. Some systems use letterspacing
(incorrectly called `tracking') as an aid
to justification and it is almost always wrong to do
so (and looks it). While it \emph{is}
possible to change letterspacing (with the
\package{soul} package), it should only
be done by a typographer, and then only very rarely,
as the settings are very subtle and beyond the scope
of this book.
\end{description}
\subsection{Headers and footers}
\label{runningheads}
\LaTeX{} has built-in settings to control the page style
of its default page layouts. These are implemented with the
\command{pagestyle} command, which can take one of
the following arguments.
\begin{description}
\item[\sffamily \opt{plain}]
for a page number centered at the bottom;
\item[\sffamily \opt{empty}]
for nothing at all, not even a page number;
\item[\sffamily \opt{headings}]
for running heads based on the current chapter and
section;
\item[\sffamily \opt{myheadings}]
which lets you use your own reprogrammed
definitions of how \command{markright} and
\command{markboth} commands, which control
how chapter and section titles get into page
headers.
\end{description}
The command \command{thispagestyle} (taking the
same arguments) can be used to force a specific style for
the current page only.
However, the easiest way is to use the
\package{fancyhdr} package, which lets you
redefine the left-hand, centre, and right-hand page headers
and footers for both odd and even pages (twelve objects in
all). These areas can contain a page number, fixed text,
variable text (like the current chapter or section title, or
the catch-words of a dictionary), or even a small image.
They can also be used to do page backgrounds and frames, by
making one of them the top corner of an invisible box which
`hangs' text or images down over the whole
page.
The settings for the downloadable version of this
document can be used as an example: for the whole story you
have to read the documentation.
\begin{sourcecode}\begin{Verbatim}[fontsize=\small]
\pagestyle{fancy}\fancyhead{}
\renewcommand\headrulewidth{.1pt}
\fancyhead[LO,RE]{\footnotesize\sffamily\lite\leftmark}
\fancyhead[LE,RO]{\footnotesize\sffamily\lite\itshape
\rightmark}
\fancyfoot[C]{}
\fancyfoot[LE,RO]{\setlength{\fboxsep}{2pt}\ovalbox%
{\footnotesize\sffamily\thepage}}
\fancyfoot[LO,RE]{\footnotesize\sffamily\lite\@title}
\fancypagestyle{plain}{\fancyhf{}
\fancyfoot[R]{\setlength{\fboxsep}{2pt}\ovalbox{%
\footnotesize\sffamily\thepage}}
\fancyfoot[L]{\footnotesize\sffamily\lite\@title}
\renewcommand{\headrulewidth}{0pt}}
\end{Verbatim}
\end{sourcecode}
This is probably more complex than most documents, but
it illustrates some common requirements:
\begin{enumerate}\item
Settings are prefixed by making the
\command{pagestyle} `fancy'
and setting the \command{fancyhead} to
null to zap any predefined values.
\item
The thickness of the rule at the top of the page can
be changed (or set to 0pt to make it disappear).
\item
The header and footer settings are specified with L,
C, and R for left, centre, and right; and with O and E
for Odd and Even numbered pages. In each setting, the
typeface style, size, and font can be specified along
with macros which implement various dynamic texts (here,
the current chapter and section titles, which \LaTeX{}
stores in \command{rightmark} and
\command{leftmark}).
\item
The `plain' variant is used for chapter
starts, and resets some of the parameters
accordingly.
\end{enumerate}
\section{Using fonts}
\label{fontuse}
\index{fonts!in general}
The default typeface in \LaTeX{} is Computer Modern (CM)\index{CM@CM|textbf}\index{Acronyms@\textbf{Acronyms}, defined!CM@CM|textbf}. This typeface was
designed by Knuth for use with \TeX{} because it is a book
face, and he designed \TeX{} originally for typesetting books.
Because it is one of the very few book typefaces with a
comprehensive set of fonts, including a full suite of
mathematics, it has remained the default, rather than the
Times you find in wordprocessors, because until recently the
mathematical symbols for Times were a commercial product often
unavailable to users of free software.
\index{fonts!\mf{}}\index{fonts!Computer Modern}{\fontencoding{OT1}\fontfamily{cmr}\fontsize{12pt}{12pt}\selectfont{}Computer Modern is based on
a 19th-century book typeface from Monotype, which is why it
looks a little like an old-fashioned school book. This
paragraph is set in Computer Modern so you can see what it
looks like. The typeface was designed using \mf{}, the
font-drawing program made by Knuth to accompany \TeX{}
systems, but it is now also available in Type 1 and
TrueType formats.}
\begin{warning}
If you are reading this in a web browser, the above
paragraph is only a low-resolution copy because browsers
don't usually have the Computer Modern font available.
All the rest of this document is set in \rmfontfamilyname{}, with
\sffontfamilyname{} for some of the headings and \ttfontfamilyname{} for the
fixed-width type.
\end{warning}
In addition to CM\index{CM@CM}, there are
many other \mf{} fonts which can be downloaded from
CTAN\index{CTAN@CTAN}, including a large collection
of historical, symbol, initial, and non-Latin fonts. \LaTeX{}
also comes with the `Adobe 35'
typefaces which are built into laser printers and other
DTP\index{DTP@DTP} systems, and some more fonts
donated by the X Consortium. Plus, of course, standard
\LaTeX{} can use any of the thousands of
Type 1 fonts available, and
\product{pdf\LaTeX{}} can use any of the
thousands of TrueType fonts as well.
In the following lists, if there is a package available,
its name is given in parentheses after the name of the
typeface. The font-family name is shown on the right-hand
side. If a non-standard font-encoding is needed, its name is
shown before the font-family name.
\index{fonts!TrueType}\index{fonts!metafont@\mf{}}\index{fonts!PostScript}\index{fonts!Type 1}\begingroup\small \subsubsection*{Latin-alphabet typefaces (\mf{})}\label{fontable-mf}\addcontentsline{lot}{subsubsection}{Latin-alphabet typefaces (\mf{})}\par\smallskip\hrule height.2pt\par\noindent{\sffamily\scriptsize\lite\emstrut Computer Modern Roman\hfill\texttt{cmr}}\\{\fontencoding{OT1}\fontfamily{cmr}\selectfont
The quick brown fox jumps over the lazy dog}\strut
\hrule height.2pt\par\noindent{\sffamily\scriptsize\lite\emstrut Computer Modern Sans\hfill\texttt{cmss}}\\{\fontencoding{OT1}\fontfamily{cmss}\selectfont
The quick brown fox jumps over the lazy dog}\strut
\hrule height.2pt\par\noindent{\sffamily\scriptsize\lite\emstrut Computer Modern Typewriter\hfill\texttt{cmtt}}\\{\fontencoding{OT1}\fontfamily{cmtt}\selectfont
The quick brown fox jumps over the lazy dog}\strut
\hrule height.2pt\par\noindent{\sffamily\scriptsize\lite\emstrut Pandora\quad{\fontseries{m}\selectfont(\package{pandora})}\hfill\texttt{panr}}\\{\fontencoding{OT1}\fontfamily{panr}\selectfont
The quick brown fox jumps over the lazy dog}\strut
\hrule height.2pt\par\noindent{\sffamily\scriptsize\lite\emstrut Pandora Sans\hfill\texttt{pss}}\\{\fontencoding{OT1}\fontfamily{pss}\selectfont
The quick brown fox jumps over the lazy dog}\strut
\hrule height.2pt\par\noindent{\sffamily\scriptsize\lite\emstrut Pandora Typewriter\hfill\texttt{pntt}}\\{\fontencoding{OT1}\fontfamily{pntt}\selectfont
The quick brown fox jumps over the lazy dog}\strut
\hrule height.2pt\par\noindent{\sffamily\scriptsize\lite\emstrut Universal\hfill\texttt{uni}}\\{\fontencoding{OT1}\fontfamily{uni}\selectfont
The quick brown fox jumps over the lazy dog}\strut
\hrule height.2pt\par\noindent{\sffamily\scriptsize\lite\emstrut Concrete\quad{\fontseries{m}\selectfont(\package{ccr})}\hfill\texttt{ccr}}\\{\fontencoding{OT1}\fontfamily{ccr}\selectfont
The quick brown fox jumps over the lazy dog}\strut
\hrule height.2pt\par\noindent{\sffamily\scriptsize\lite\emstrut É{\fontfamily{cmr}\selectfont\i}reannach\quad{\fontseries{m}\selectfont(\package{eiad})}\hfill\texttt{eiad}}\\{\fontencoding{OT1}\fontfamily{eiad}\selectfont
N{\fontfamily{cmr}\selectfont\'\i}l aon tinteán mar do thinteán f\'ein}\strut
\hrule height.2pt\par\noindent{\sffamily\scriptsize\lite\emstrut Rustic\hfill\texttt{rust}}\\{\fontencoding{OT1}\fontfamily{rust}\selectfont
The quick brown fox jumps over the lazy dog}\strut
\hrule height.2pt\par\noindent{\sffamily\scriptsize\lite\emstrut Uncial\hfill\texttt{uncl}}\\{\fontencoding{OT1}\fontfamily{uncl}\selectfont
The quick brown fox jumps over the lazy dog}\strut
\hrule height.2pt\par\noindent{\sffamily\scriptsize\lite\emstrut Dürer\hfill\texttt{zdu}}\\{\fontencoding{OT1}\fontfamily{zdu}\selectfont
THE QUICK BROWN FOX JUMPS OVER THE LAZY DOG}\strut
\hrule height.2pt\par\noindent{\sffamily\scriptsize\lite\emstrut Fraktur\hfill\texttt{U\enspace yfrak}}\\{\fontencoding{U}\fontfamily{yfrak}\selectfont
Fuch\char'215 , Du hast die Gan\char'215 gestohlen, gib sie wieder her!}\strut
\hrule height.2pt\par\noindent{\sffamily\scriptsize\lite\emstrut Gothic\hfill\texttt{U\enspace ygoth}}\\{\fontencoding{U}\fontfamily{ygoth}\selectfont
Fuch\char'215 , Du hast die Gan\char'215 gestohlen, gib sie wieder her!}\strut
\hrule height.2pt\par\noindent{\sffamily\scriptsize\lite\emstrut Schwäbische\hfill\texttt{U\enspace yswab}}\\{\fontencoding{U}\fontfamily{yswab}\selectfont
Fuch\char'215 , Du hast die Gan\char'215 gestohlen, gib sie wieder her!}\strut
\hrule height.2pt \endgroup\begingroup\small \subsubsection*{Latin-alphabet typefaces (PostScript Type 1) from
Adobe}\label{fontable-adobe}\addcontentsline{lot}{subsubsection}{Latin-alphabet typefaces (PostScript Type 1) from
Adobe}\par\smallskip\hrule height.2pt\par\noindent{\sffamily\scriptsize\lite\emstrut Avant Garde\quad{\fontseries{m}\selectfont(\package{avant})}\hfill\texttt{pag}}\\{\fontencoding{OT1}\fontfamily{pag}\selectfont
The quick brown fox jumps over the lazy dog}\strut
\hrule height.2pt\par\noindent{\sffamily\scriptsize\lite\emstrut Bookman\footnote{Uses Avant Garde as the sans-serif and Courier for
monospace.}\quad{\fontseries{m}\selectfont(\package{bookman})}\hfill\texttt{pbk}}\\{\fontencoding{OT1}\fontfamily{pbk}\selectfont
The quick brown fox jumps over the lazy dog}\strut
\hrule height.2pt\par\noindent{\sffamily\scriptsize\lite\emstrut Courier\quad{\fontseries{m}\selectfont(\package{courier})}\hfill\texttt{pcr}}\\{\fontencoding{OT1}\fontfamily{pcr}\selectfont
The quick brown fox jumps over the lazy dog}\strut
\hrule height.2pt\par\noindent{\sffamily\scriptsize\lite\emstrut Helvetica\quad{\fontseries{m}\selectfont(\package{helvet})}\hfill\texttt{phv}}\\{\fontencoding{OT1}\fontfamily{phv}\selectfont
The quick brown fox jumps over the lazy dog}\strut
\hrule height.2pt\par\noindent{\sffamily\scriptsize\lite\emstrut New Century Schoolbook\footnote{Uses Helvetica as the sans-serif font and Courier
for monospace.}\quad{\fontseries{m}\selectfont(\package{newcent})}\hfill\texttt{pnc}}\\{\fontencoding{OT1}\fontfamily{pnc}\selectfont
The quick brown fox jumps over the lazy dog}\strut
\hrule height.2pt\par\noindent{\sffamily\scriptsize\lite\emstrut Palatino\footnote{Uses Avant Garde as the sans-serif and Courier for
monospace.}\quad{\fontseries{m}\selectfont(\package{palatino})}\hfill\texttt{ppl}}\\{\fontencoding{OT1}\fontfamily{ppl}\selectfont
The quick brown fox jumps over the lazy dog}\strut
\hrule height.2pt\par\noindent{\sffamily\scriptsize\lite\emstrut Symbol\hfill\texttt{U\enspace psy}}\\{\fontencoding{U}\fontfamily{psy}\selectfont
The quick brown fox jumps over the lazy dog}\strut
\hrule height.2pt\par\noindent{\sffamily\scriptsize\lite\emstrut Times New Roman\footnote{Uses Helvetica as the sans-serif font and Courier
for monospace. Mathematical symbols for Times are
available both free and commercially.}\quad{\fontseries{m}\selectfont(\package{times})}\hfill\texttt{ptm}}\\{\fontencoding{OT1}\fontfamily{ptm}\selectfont
The quick brown fox jumps over the lazy dog}\strut
\hrule height.2pt\par\noindent{\sffamily\scriptsize\lite\emstrut Zapf Chancery\quad{\fontseries{m}\selectfont(\package{zapfchan})}\hfill\texttt{pzc}}\\{\fontencoding{OT1}\fontfamily{pzc}\selectfont\itshape
The quick brown fox jumps over the lazy dog}\strut
\hrule height.2pt\par\noindent{\sffamily\scriptsize\lite\emstrut Zapf Dingbats\quad{\fontseries{m}\selectfont(\package{pifont})}\hfill\texttt{U\enspace pzd}}\\{\fontencoding{U}\fontfamily{pzd}\selectfont
The quick brown fox jumps over the lazy dog}\strut
\hrule height.2pt \endgroup\par\medskip
As mentioned in \S\thinspace\ref{print}, the
`Adobe 35' fonts can be used with any
printer, not just a laser printer or typesetter. The
\product{Ghostscript} interpreter and the
\product{GSview} viewer come with a large set
of printer drivers, so you just create PostScript output and
print from \product{GSview}.
Incidentally, the 35 refers to the total number of fonts
for the 10 typefaces, including their bold, italic, and
bold-italic variants.
Postscript Type 1 fonts have been the mainstay of the
graphic arts industries for many years, as they allow much
better definition of variance
(`hinting') than most other formats.
However, the font format remains proprietary to Adobe, even
though they have released it for public use, which means they
could change it without warning. A new format called
`OpenType' is designed to overcome
this, and some versions of \TeX{} are
already able to use OpenType fonts.
\begingroup\small \subsubsection*{Latin-alphabet fonts (PostScript Type 1) from the X
Consortium}\label{fontable-x}\addcontentsline{lot}{subsubsection}{Latin-alphabet fonts (PostScript Type 1) from the X
Consortium}\par\smallskip\hrule height.2pt\par\noindent{\sffamily\scriptsize\lite\emstrut Charter\quad{\fontseries{m}\selectfont(\package{charter})}\hfill\texttt{bch}}\\{\fontencoding{OT1}\fontfamily{bch}\selectfont
The quick brown fox jumps over the lazy dog}\strut
\hrule height.2pt\par\noindent{\sffamily\scriptsize\lite\emstrut Nimbus Roman\hfill\texttt{unm}}\\{\fontencoding{OT1}\fontfamily{unm}\selectfont
The quick brown fox jumps over the lazy dog}\strut
\hrule height.2pt\par\noindent{\sffamily\scriptsize\lite\emstrut Nimbus Sans\hfill\texttt{unms}}\\{\fontencoding{OT1}\fontfamily{unms}\selectfont
The quick brown fox jumps over the lazy dog}\strut
\hrule height.2pt\par\noindent{\sffamily\scriptsize\lite\emstrut URW Antiqua\hfill\texttt{uaq}}\\{\fontencoding{OT1}\fontfamily{uaq}\selectfont
The quick brown fox jumps over the lazy dog}\strut
\hrule height.2pt\par\noindent{\sffamily\scriptsize\lite\emstrut URW Grotesk\hfill\texttt{ugq}}\\{\fontencoding{OT1}\fontfamily{ugq}\selectfont\bfseries
The quick brown fox jumps over the lazy dog}\strut
\hrule height.2pt\par\noindent{\sffamily\scriptsize\lite\emstrut Utopia\footnote{Removed from recent distributions as it is not
free.}\quad{\fontseries{m}\selectfont(\package{utopia})}\hfill\texttt{put}}\\{\fontencoding{OT1}\fontfamily{put}\selectfont
The quick brown fox jumps over the lazy dog}\strut
\hrule height.2pt \endgroup\par\medskip \begingroup\small \subsubsection*{Non-Latin-alphabet typefaces (\mf{})}\label{fontable-nonlat}\addcontentsline{lot}{subsubsection}{Non-Latin-alphabet typefaces (\mf{})}\par\smallskip\hrule height.2pt\par\noindent{\sffamily\scriptsize\lite\emstrut BB Dingbats\hfill\texttt{U\enspace ding}}\\{\fontencoding{U}\fontfamily{ding}\selectfont
\fontsize{9}{0}\selectfont The quick brown fox jumps over the lazy dog}\strut
\hrule height.2pt\par\noindent{\sffamily\scriptsize\lite\emstrut Cypriot\hfill\texttt{cypr}}\\{\fontencoding{OT1}\fontfamily{cypr}\selectfont
\fontsize{8}{0}\selectfont The quick brown fox jumps over the lazy dog}\strut
\hrule height.2pt\par\noindent{\sffamily\scriptsize\lite\emstrut Etruscan\hfill\texttt{etr}}\\{\fontencoding{OT1}\fontfamily{etr}\selectfont
The quick brown fox jumps over the lazy dog}\strut
\hrule height.2pt\par\noindent{\sffamily\scriptsize\lite\emstrut Linear `B'\hfill\texttt{linb}}\\{\fontencoding{OT1}\fontfamily{linb}\selectfont
\fontsize{9}{0}\selectfont The quick brown fox jumps over the lazy dog}\strut
\hrule height.2pt\par\noindent{\sffamily\scriptsize\lite\emstrut Phoenician\hfill\texttt{phnc}}\\{\fontencoding{OT1}\fontfamily{phnc}\selectfont
The quick brown fox jumps over the lazy dog}\strut
\hrule height.2pt\par\noindent{\sffamily\scriptsize\lite\emstrut Runic\hfill\texttt{fut}}\\{\fontencoding{OT1}\fontfamily{fut}\selectfont
THE QUICK BROWN FOX JUMPS OVER THE LAZY DOG}\strut
\hrule height.2pt\par\noindent{\sffamily\scriptsize\lite\emstrut Bard\hfill\texttt{U\enspace zba}}\\{\fontencoding{U}\fontfamily{zba}\selectfont
The quick brown fox jumps over the lazy dog}\strut
\hrule height.2pt \endgroup\begin{warning}
Just to make it clear: standard \LaTeX{} uses only
\mf{} and PostScript\index{PostScript} Type 1
fonts. \product{pdf\LaTeX{}} can use TrueType
fonts as well.
\end{warning}
\subsection{Changing the default font family}
\index{fonts!changing the default}
\LaTeX{} expects to work with three font families as
defaults:
\index{fonts!families}\begingroup\small \begin{center}
\begin{tabular}{l>{\ttfamily}l}
\textbf{\sffamily\upshape Font family}&\textbf{\sffamily\upshape Code}\\[2pt]\hline\\[-1.5\baselineskip]
Roman (serif, with tails on the uprights), the
default&rm\\
\sffamily{}Sans-serif, with no tails on
the uprights&sf\\
\ttfamily{}Monospace (fixed-width or
typewriter)&tt\\
\end{tabular}
\end{center}
\endgroup
The start-up default for \LaTeX{} equates the
\verb+rm+ default with the
{\slshape\verb`cmr`} font-family (Computer Modern Roman),
\verb+sf+ with {\slshape\verb`cmss`}, and
\verb+tt+ with {\slshape\verb`cmtt`}. If you
use one of the packages listed in the tables on pp.\thinspace\pageref{fontable-mf}--\pageref{fontable-nonlat}, it will
replace the defaults of the same type: for example,
\verb+\usepackage{bookman}+ makes the default
\verb+rm+ font-family Bookman
({\slshape\verb`pbk`}), but leaves the sans-serif
(\verb+sf+) and monospace
(\verb+tt+) families untouched. Equally,
\verb+\usepackage{helvet}+ changes the default
sans-serif family to Helvetica but leaves the serif (Roman)
and monospace families untouched. Using both commands will
change both defaults because they operate
independently.
\emph{However}\dots as it is common to
want to change all three defaults at the same time, some of
the most common `suites' of typefaces
are provided as packages:
\begin{description}
\item[\sffamily \package{times}]
changes to Times/Helvetica/Courier.
\item[\sffamily \package{pslatex}]
same as \package{times} but uses a
specially narrowed Courier to save space (normal
Courier is rather inelegantly wide). This is the
preferred setting if you want Times.\footnote{The \package{pslatex} package
is also said to be outdated by some experts
because it implements rather long-windedly what
can now be done in three commands. However, until
these replace the current version, I recommend
continuing to use \package{pslatex}
when you want Times with Helvetica and narrow
Courier.}
\item[\sffamily \package{newcent}]
changes to New Century
Schoolbook/Helvetica/Courier.
\item[\sffamily \package{palatino}]
changes to Palatino/Avant Garde/Courier.
\item[\sffamily \package{palatcm}]
changes the roman to Palatino only, but with
CM\index{CM@CM} mathematics
\end{description}
Where no package name is given in the tables on pp.\thinspace\pageref{fontable-mf}--\pageref{fontable-nonlat}, it means the
font is rarely used as a default by itself except in special
cases like users' own homebrew packages. To use such a
font you have to specify it manually, or make a little macro
for yourself if you use it more than once.
\subsection{Changing the font-family temporarily}
\label{fontfam}
\index{fonts!changing temporarily}
To shift to another font family on a temporary basis,
use the commands \command{fontencoding} (if
needed), \command{fontfamily}, and
\command{selectfont}, and \emph{enclose the
commands \textbf{and} the text in curly
braces}. Note that this is a
\emph{different} way of using curly braces to
how we have used them before: it limits the effect of a
change to the material inside the braces.
\begin{example}
\begin{sourcecode}\begin{Verbatim}[fontsize=\small]
{\fontfamily{phv}\selectfont
Helvetica looks like this}:
{\fontencoding{OT1}\fontfamily{bch}\selectfont
Charter looks like this}.
\end{Verbatim}
\end{sourcecode}\vspace*{-\baselineskip}\begin{quote}\fontencoding{T1}\fontfamily{cmr}\selectfont\def\sfdefault{cmss}\def\bfdefault{bf}\noindent
{\fontfamily{phv}\selectfont{}Helvetica
looks like this}: {\fontencoding{OT1}\fontfamily{bch}\selectfont{}Charter looks like
this}.
\end{quote}\end{example}
In this example, the \command{fontencoding}
command has been used to ensure that the typeface will work
even if the sentence is used in the middle of something
typeset in a different encoding (like this
document).\footnote{Test for the observant reader: in what typeface will
the colon (:) in the example be set?}
\begin{sidebar}\label{grouping}
\subsection*{Grouping}\index{grouping}
Note carefully this use of curly braces to restrict
the scope of a change rather than delimit the argument to
a command. This is called
`grouping' and it makes the effect
any changes made \emph{inside} the braces
local, so that they do not interfere with the text
following. Any changes to fonts or other values made
within the curly braces cease when the closing curly brace
is processed.
\end{sidebar}
In a normal document, of course, random typeface changes
like this are rather rare. You select your typeface[s] once
at the start of the document, and stick with them.
Most cases where people want to do unusual typeface
changes involve things like special symbols on a repetitive
basis, and \LaTeX{} provides much easier programmable ways
to make these changes into shorthand commands (called
macros: see \chaptername~\ref{macros}). You could, for
example, make a macro called \command{product}
which would let you typeset product names in a distinct
typeface:
\begin{sourcecode}\begin{Verbatim}[fontsize=\small]
Andlinger, Inc., has replaced \product{Splosh} with
\product{SuperSplosh}.
\end{Verbatim}
\end{sourcecode}
This is one of \LaTeX{}'s most powerful features.
It means that if you needed to change your
\command{product} command at some later stage to
use a different font, you only have to change three
characters in the macro (the font-family name), and
you don't need to edit your document text at all!
What's more, a macro could do other things at the same time,
like add an entry to an index of products.
However, vastly more common are changes to type
\emph{style}, while staying with the same
font-family.
\subsection{Changing font style}
\index{fonts!styles}
Within each typeface or font family there are usually
several different `looks' to the type
design. \LaTeX{} distinguishes between font \textbf{\textit{family}}\label{family}\index{family@\textbf{\textit{family}}}, font \textbf{\textit{shape}}\label{shape}\index{shape@\textbf{\textit{shape}}}, and font \textbf{\textit{series}}\label{series}\index{series@\textbf{\textit{series}}}:
\begingroup\small \begin{center}
\begin{tabular}{@{}l>{\ttfamily}ll@{}}
\textbf{\sffamily\upshape Type style}&\textbf{\sffamily\upshape Command}&\textbf{\sffamily\upshape Example (using Computer Modern)}\\[2pt]\hline\\[-1.5\baselineskip]
Upright&\command{upshape}*&{\fontencoding{OT1}\fontfamily{cmr}\selectfont{}The quick brown fox jumps over the
lazy d}\\
Italic&\command{itshape}&{\fontencoding{OT1}\fontfamily{cmr}\fontshape{it}\selectfont{}\font\foo=cmti10
\foo The quick brown fox jumps over the lazy
dog}\\
Slanted&\command{slshape}*&{\fontencoding{OT1}\fontfamily{cmr}\fontshape{sl}\selectfont{}The quick brown fox
jumps over the lazy d}\\
Small Capitals&\command{scshape}*&{\fontencoding{OT1}\fontfamily{cmr}\fontshape{sc}\selectfont{}The quick brown fox
jumps over the}\\
Bold&\command{bfseries}*&{\fontencoding{OT1}\fontfamily{cmr}\fontseries{b}\selectfont{}The quick brown fox
jumps over the lazy d}\\
Bold Extended&\command{bfseries}\dag &{\fontencoding{OT1}\fontfamily{cmr}\fontseries{bx}\selectfont{}\font\foo=cmbx10
\foo The quick brown fox jumps over the
lazy}\\
Sans-serif&\command{sffamily}&{\fontencoding{OT1}\fontfamily{cmss}\selectfont{}The quick brown fox jumps over the
lazy dog}\\
Monospace&\command{ttfamily}&{\fontencoding{OT1}\fontfamily{cmtt}\selectfont{}The quick brown fox jumps over the
laz}\\
\end{tabular}
\par\smallskip\footnotesize
\begin{itemize*}
\item [\sffamily *] Not all typefaces have all
variants! Some only have bold and italics.
\item [\sffamily \dag ] Some typefaces do not have
both bold and bold extended: by default \LaTeX{} uses
\command{bfseries} for bold
extended.
\end{itemize*}
\end{center}
\endgroup
These `shape',
`series', and
`family' commands are \textbf{\textit{commutative}}\label{commutative}\index{commutative@\textbf{\textit{commutative}}}, so you can
combine a shape with a series and/or a family, without the
need to use \command{selectfont}:
\begin{sourcecode}\begin{Verbatim}[fontsize=\small]
This gives you {\bfseries\itshape\sffamily bold
italic sans-serif type}, but beware
\end{Verbatim}
\end{sourcecode}
This gives you {\sffamily{}\fontseries{b}\fontshape{it}\selectfont{}bold italic sans-serif type}, but
beware of pushing your fonts beyond their limits unless you
are a typographer. It is not normally meaningful to combine
one shape or series class with another of the same class,
such as trying to get slanted-italics. It's an
impossibility to combine one family with another (such as a
seriffed sans-serif typeface!). Slanted plus italics, for
example, doesn't make sense, as italics are already
slanted (although it is technically possible); and while
some typefaces may well possess italic small caps, they are
not in common use. Sans-serif and monospace (typewriter) are
different fonts, and often different typeface families
entirely.\footnote{Although if you're a typographer wanting to
experiment with typewriter typefaces with and without
serifs, you can use \mf{} to do exactly this kind
of thing. But that's way outside the scope of this
document.}
There is an alternative syntax for the most common type
shape and series commands which uses curly braces in the
normal `argument' manner:
\begingroup\small \begin{center}
\label{fontcmds}
\begin{tabular}{@{}l>{\ttfamily}ll@{}}
\textbf{\sffamily\upshape Type style}&\textbf{\sffamily\upshape Command}&\textbf{\sffamily\upshape Example}\\[2pt]\hline\\[-1.5\baselineskip]
Italic&\verb+\textit{text}+&puts {\fontshape{it}\selectfont{}text}
into italics\\
Slanted&\verb+\textsl{text}+&puts {\fontencoding{OT1}\fontfamily{cmr}\fontshape{sl}\selectfont{}text} into
slanted type*\\
Small Capitals&\verb+\textsc{text}+&puts {\fontshape{sc}\selectfont{}text} into
small caps\\
Bold&\verb+\textbf{text}+&puts {\fontseries{b}\selectfont{}text} into
bold type\\
Sans-serif&\verb+\textsf{text}+&puts {\sffamily{}\selectfont{}text}
into sans-serif type\\
Monospace&\verb+\texttt{text}+&puts {\ttfamily{}\selectfont{}text} into
typewriter type\\
\end{tabular}
\par\smallskip\footnotesize
\begin{itemize*}
\item [\sffamily *] If slanted is available separately
from italics.
\end{itemize*}
\end{center}
\endgroup
You can nest these inside one another too:
\begin{sourcecode}\begin{Verbatim}[fontsize=\small]
...\textbf{\itshape\textsf{bold italic
sans-serif type}}...
\end{Verbatim}
\end{sourcecode}
\label{uline}%
Underlining isn't a font, and it is extremely
rare in typography except for special purposes. If you think
you need it, use the \package{ulem} package
with the \verb+normalem+ option, and the
\command{uline} command.
\subsection{Font sizes}
\label{fontsize}
\index{fonts!sizes}
\LaTeX{} has built into its defaults a set of predefined
font size steps corresponding more or less to the
traditional sizes available to metal typesetters. This is
deliberate, as these sizes have grown up over 500 years of
printing as those which go best together for book-work,
which is where \TeX{} originated.
These sizes are also reflected in the size steps at
which Computer Modern was designed. It often comes as a
surprise to new users that many typefaces are not designed
as a single font and just scaled up or down, but specially
drawn at different sizes to make them more legible.
As an example, {\fontencoding{OT1}\fontfamily{cmr}\fontsize{12}{12}\selectfont{}here's 12pt Computer
Modern}, and {\font\cmbig=cmr5
at12pt\cmbig here's 5pt Computer Modern scaled up to
12pt}, and
{\font\cmsmall=cmr17 at12pt\cmsmall
here's 17pt Computer Modern scaled down to
12pt} so you can see there really is a
significant difference. In general, you probably don't
want to go scaling fonts too much beyond their design size
because they will start to look very odd.
The default sizes (and the commands that operate them)
are based on the use of a 10pt font, which is the normal
size for most texts. Using the larger defaults (11pt and
12pt) for the body font will scale these sizes up
approximately in proportion. The exact sizes used are listed
in the macros in the Class Option files
\url+size10.clo+,
\url+size11.clo+ and
\url+size12.clo+. \TeX{}'s default fonts
above 10pt are in fact scaled by a factor of 1.2, as shown
in the fourth column of the table below.
\begingroup\small \begin{center}
\begin{tabular}{@{}llrr@{}}
\textbf{\sffamily\upshape Command}&\textbf{\sffamily\upshape Example}&\multicolumn{1}{>{\bfseries\pbs{\raggedleft}}b{.6in}}{\normalfont\bfseries\upshape Nominal point
size}&\multicolumn{1}{>{\bfseries\pbs{\raggedleft}}b{.5in}}{\normalfont\bfseries\upshape Exact point
size}\\[2pt]\hline\\[-1.5\baselineskip]
\command{tiny}&{\fontencoding{OT1}\fontfamily{cmr}\fontsize{5}{5}\selectfont{}The quick brown fox
jumps over the lazy dog}&5&5\\
\command{scriptsize}&{\fontencoding{OT1}\fontfamily{cmr}\fontsize{7}{7}\selectfont{}The quick brown
fox jumps over the laz}&7&7\\
\command{footnotesize}&{\fontencoding{OT1}\fontfamily{cmr}\fontsize{8}{8}\selectfont{}The quick
brown fox jumps over the l}&8&8\\
\command{small}&{\fontencoding{OT1}\fontfamily{cmr}\fontsize{9}{9}\selectfont{}The quick brown fox
jumps over th}&9&9\\
\command{normalsize}&{\fontencoding{OT1}\fontfamily{cmr}\fontsize{10}{10}\selectfont{}The quick
brown fox jumps over}&10&10\\
\command{large}&{\fontencoding{OT1}\fontfamily{cmr}\fontsize{12}{12}\selectfont{}The quick brown fox
jumps}&12&12\\
\command{Large}&{\fontencoding{OT1}\fontfamily{cmr}\fontsize{14}{14}\selectfont{}The quick brown fox
ju}&14&14.40\\
\command{LARGE}&{\fontencoding{OT1}\fontfamily{cmr}\fontsize{18}{18}\selectfont{}The quick brown
fo}&18&17.28\\
\command{huge}&{\fontencoding{OT1}\fontfamily{cmr}\fontsize{20}{20}\selectfont{}The quick
brown}&20&20.74\\
\command{Huge}&{\fontencoding{OT1}\fontfamily{cmr}\fontsize{24}{24}\selectfont{}The quick
bro}&24&24.88\\
\end{tabular}
\end{center}
\endgroup
While these `shorthand' commands
relieve the beginner of having to worry about the
`right' size for a given task, when
you need a specific size there is the
\command{fontsize} command:
\begin{sourcecode}\begin{Verbatim}[fontsize=\small]
\fontsize{22}{28}\selectfont This is 22pt
type 6pt leaded
\end{Verbatim}
\end{sourcecode}
`Leading' comes from the old metal-type
practice of adding a lead strip between lines to increase the
spacing.
The \command{fontsize} command takes two
arguments: the point size and the baseline distance. The
above example gives you 22pt type on a 28pt baseline
(i.e. with 6pt extra space or
`leading' between the lines).
\begin{warning}
Computer Modern fonts (the default) come fixed at the
named size steps shown in the table, and if you try to use
an odd size in between, \LaTeX{} will pick the closest
step instead. If you really need to use CM\index{CM@CM} at arbitrary sizes there is a
package \package{type1cm} which lets you
override the default steps. If you use
PostScript\index{PostScript} (Type 1) fonts, the
step sizes do not apply and the font scaling is infinitely
variable.
\end{warning}
\subsection{Logical markup}
All this playing around with fonts is very pretty but
you normally only do it for a reason, even if that reason is
just to be decorative. Italics, for example, are used for
many things:
\begingroup\small \begin{center}
\begin{tabular}{l>{\itshape}l}
\textbf{\sffamily\upshape Cause}&\textbf{\sffamily\upshape Effect}\\[2pt]\hline\\[-1.5\baselineskip]
Foreign words&ex officio\\
Scientific names&Ranunculus ficaria\\
Emphasis&must not\\
Titles of documents&The \LaTeX{} Companion\\
Product names&{\upshape
Corel's} WordPerfect\\
Variables in maths&\(E=mc^{2}\)\\
Subtitles or headings&How to get started\\
Decoration&FREE UPGRADE!!!\\
\end{tabular}
\end{center}
\endgroup
Humans usually have no problem telling the difference
between these reasons, because they can read and understand
the meaning and context. Computers cannot (yet), so it has
become conventional to use descriptive names which make the
distinction explicit, even though the appearance may be the
same.
\LaTeX{} has some of these built in, like
\command{emph}, which provides
\emph{emphasis}. This has a special feature
because {\fontshape{it}\selectfont{}when the surrounding text is
already italic, \emph{emphasis}
automatically reverts to \emph{upright
type}}, which is the normal practice
for typesetting.
\begin{sourcecode}\begin{Verbatim}[fontsize=\small]
This has a special feature because {\itshape when the
surrounding text is already italic, \emph{emphasis}
automatically reverts to upright type, which is the
\end{Verbatim}
\end{sourcecode}
\label{emph}%
This sensitivity to logic is programmed into
the definition of \command{emph} and it's not
hard to make up other commands of your own which could do
the same, such as \command{foreign} or
\command{product}.
But why would you bother? In a short document it's
probably not important, but if you're writing a long
report, or a formal document like an article, a book, or a
thesis, it makes writing and editing hugely easier if you
can control whole groups of special effects with a single
command, such as italicising, indexing, or cross-referencing
to a glossary. If a format needs changing, you only have to
change the definition, and every occurrence automatically
follows suit.
\begin{warning}
Beware of this `vaine conceipt of simple men,
which judge things by ther effects, and not by ther
causes'. (Edmund Spenser, 1633) It's hugely
more efficient to have control of the cause than the
effect.
\end{warning}
It also makes it possible to find and act on groups of
meanings\mdash{}such as making an index of scientific names
or product names (as in this document)\mdash{}if they are
identified with a special command. Otherwise you'd
spend weeks hunting manually through every
\command{textit} command to find the ones you
wanted. This is the importance of automation: it can save
you time and money.
In \chaptername~\ref{macros} we will see how to make your
own simple commands like this.
\subsection{Colour}
\index{colour}\index{fonts!colour}
You can typeset anything in \LaTeX{} in any colour you
want using the \package{color} package.
First, you need to add the command
\verb+\usepackage{color}+ to your preamble (note
the US spelling of color!). This makes available a default
palette of primary colours: {\color{red}red}, {\color{green}green}, and {\color{blue}blue} for the RGB\index{RGB@RGB} colour model used for emitted light
(television screens), and {\color{cyan}cyan}, {\color{magenta}magenta}, {\color{yellow}yellow}, and black for the
CMYK\index{CMYK@CMYK} colour model used for
reflected light (printing).
For the occasional word or phrase in colour, use the
command \command{textcolor} with two arguments, the
colour name and the text: \verb+\textcolor{red}{like this}+. There is a \command{color}
command as well, for use within groups:
\begin{sourcecode}\begin{Verbatim}[fontsize=\small]
...{\color{blue}some text in blue}...
\end{Verbatim}
\end{sourcecode}
If you have the PostScript\index{PostScript}
printer driver \product{dvips} installed,
you also get a separate 64-colour palette of predefined
\textbf{\textit{color names}}\label{colornames}\index{color names@\textbf{\textit{color names}}}. These
represent approximately the colours in the big box of
\product{Crayola} colouring pencils much
favoured by artists and designers. This adds a new colour
model called `\verb+named+', so if
you want the \product{Crayola} colour
{\color[named]{FF00DD}RubineRed}, you can use the
\command{color} or \command{textcolor}
commands with a preceding optional argument
`\opt{named}':
\begin{sourcecode}\begin{Verbatim}[fontsize=\small]
\color[named]{RubineRed}
\textcolor[named]{RubineRed}{some red text}
\end{Verbatim}
\end{sourcecode}
As some of the `\verb+named+'
colour names are quite long, you can create a short name of
your own for colours you use frequently, using the
\command{definecolor} command:
\begin{sourcecode}\begin{Verbatim}[fontsize=\small]
\definecolor{mb}{named}{MidnightBlue}
\end{Verbatim}
\end{sourcecode}
The \command{definecolor} command needs three
arguments: your shorthand name, the name of the colour model,
and the colour specification. In the case of the
`\verb+named+' model, the last
argument is one of the 64 colour names. To
use these names with \product{pdf\LaTeX{}},
you need to use the \opt{pdftex} option to the
\package{color} package.
Using the \command{definecolor} command, you
can define any colour you want by giving it a name,
specifying which colour model, and providing the Red-Green-Blue (RGB)\index{RGB@RGB|textbf}\index{Acronyms@\textbf{Acronyms}, defined!RGB@RGB|textbf} or Cyan-Magenta-Yellow-Black (CMYK)\index{CMYK@CMYK|textbf}\index{Acronyms@\textbf{Acronyms}, defined!CMYK@CMYK|textbf} colour
values expressed as decimals, separated by commas. For
example, an RGB\index{RGB@RGB} shade given as
(37,125,224) in decimal (\#250FE0 in hexadecimal as used
on the Web) can be given as\begin{sourcecode}\begin{Verbatim}[fontsize=\small]
\definecolor{midblue}{rgb}{0.145,0.490,0.882}
\end{Verbatim}
\end{sourcecode}
(divide each value by 255, the maximum for
each of the hues in the Red-Green-Blue colour model). You
can then use \command{textcolor} with your new
colour name: {\color{midblue}the midblue looks like
this if you're reading in colour.}
The \package{color} package also provides
a colour version of \command{fbox} (see \S\thinspace\ref{fbox}) called
\command{colorbox}:
\begin{sourcecode}\begin{Verbatim}[fontsize=\small]
\colorbox{midblue}{\color{magenta}Magenta on midblue}
\end{Verbatim}
\end{sourcecode}
\colorbox{midblue}{\color{magenta}Magenta
on midblue}: you can
see how careful you need to be with colours!
\section{Installing new fonts}
\label{instfonts}
\index{fonts!installing}
Different fonts come in a variety of packagings: the three
most common used with \TeX{} systems are
PostScript\index{PostScript} fonts, TrueType fonts, and
\mf{} fonts. How you install them and where they go
depends on how you installed \LaTeX{}: all I can deal with here
are the standard locations within the TDS\index{TDS@TDS}.
Typefaces come supplied as one or more font
`outline' files and a number of
ancillary files:
\begin{description}
\item[\sffamily \mf{} typefaces]
have a number of \url+.mf+ source
(outline) files, possibly also some
\url+.fd+ (font definition) files and a
\url+.sty+ (style) file. The
\url+.tfm+ (\TeX{} font metric) files are
not needed, as they can be generated from the
outlines.
\item[\sffamily PostScript typefaces]
come as a pair of files: a \url+.pfb+
(PostScript font binary) or \url+.pfa+
(PostScript font ASCII\index{ASCII@ASCII})
outline, and an \url+.afm+ (Adobe font
metric) file. There may also be
\url+.inf+ and other files but these are
not needed for use with \TeX{} systems.
\item[\sffamily TrueType typefaces]
are a single \url+.ttf+ file, which
combines outline and metrics in one.
\end{description}
The instructions here assume the use of the New Font Selection Scheme (NFSS)\index{NFSS@NFSS|textbf}\index{Acronyms@\textbf{Acronyms}, defined!NFSS@NFSS|textbf} used in
\LaTeXe{}. If you are running the obsolete \LaTeX{} 2.09,
upgrade it now.
\subsection{Installing \mf{} fonts}
\label{mffonts}
This is the simplest installation. When you download
\mf{} fonts from CTAN\index{CTAN@CTAN},
you'll usually find a large number of Outline files
(\url+.mf+ files) and maybe some other types
as well (see below).
\begin{figure}\small
\caption{\small Creating a new subdirectory for a font}
\label{mkfontdir}
\begin{center}
\includegraphics[width=0.75\textwidth]{public}
\end{center}
\end{figure}
\begin{enumerate}
\item \label{newsub}%
Create a new subdirectory named after the typeface
you're installing in
\url+texmf-local/fonts/source/public/+:
\item
Copy all the \url+.mf+ (outline)
files to this directory.
\item
Copy the \url+.fd+ (Font Definition)
file[s] and the \url+.sty+ (style) file
to your \url+texmf/tex/latex/mfnfss+
directory.
\item
Run your \TeX{} indexer program (see step~\ref{texindex} in the procedure on p.\thinspace\pageref{texindex}).
\end{enumerate}
That's it. Unlike PostScript\index{PostScript}
fonts, \mf{} fonts can be used to generate the font
metric file (\url+.tfm+ files) automatically
on-the-fly the first time the typeface is used, so there
should be nothing else to install.
Now you can put a \command{usepackage} command
in your preamble with whatever name the
\verb+.sty+ file was called, and read the
documentation to see what commands it gives to use the font
(refer to the last paragraph of \S\thinspace\ref{packinst} and step~\ref{dtxdoc} in the procedure on p.\thinspace\pageref{dtxdoc}).
If the font came \emph{without}\url+.fd+ or \url+.sty+ files,
you'll need to find someone who can make them for you
(or follow the outline in \S\thinspace\ref{psfonts}, step~\ref{fdfiles} in the procedure on p.\thinspace\pageref{fdfiles}).
\subsubsection{Pre-generated metrics (optional)}
Some \mf{} fonts come with pre-generated
\url+.tfm+ files which you can install if
your system is slow at generating them itself:
\begin{enumerate}
\addtocounter{enumi}{\thehold}\item
Create a new subdirectory within
\url+texmf-local/fonts/tfm/public/+
named the same as the one you created for the
\url+.mf+ files above.
\item
Copy all the \url+.tfm+ files into
this subdirectory.
\item
Run your \TeX{} indexer program (see step~\ref{texindex} in the procedure on p.\thinspace\pageref{texindex}).
\end{enumerate}
\setcounter{hold}{\theenumi}\subsubsection{Pre-generated bitmaps (optional)}
In some rare cases, pre-generated packed bitmap fonts
(\url+.pk+ files) are also available from
CTAN\index{CTAN@CTAN} (normally your previewer
and print driver creates these automatically, but you can
use the pre-generated ones if you have a very slow
system). If you really want to install these, it's a
similar procedure to the \url+.tfm+
files:
\begin{enumerate}
\addtocounter{enumi}{\thehold}\item
Create a new subdirectory within
\url+texmf-local/fonts/pk/modeless/+
named the same as the one you created for the
\url+.mf+ and \url+.tfm+
files above.
\item
Copy all the \url+.nnnpk+ files
into this subdirectory (\(nnn\) is
a number reflecting the dot-density of the bitmap). On
Microsoft systems the files may just end in
\url+.pk+ and be kept in subdirectories
named after the dot-density, e.g.
\url+dpi360+.
\item
Run your \TeX{} indexer program (see step~\ref{texindex} in the procedure on p.\thinspace\pageref{texindex}).
\end{enumerate}
\setcounter{hold}{\theenumi}\subsection{Installing PostScript fonts}
\label{psfonts}
\index{fonts!PostScript}
Lots of people will tell you that
PostScript\index{PostScript} fonts and PostScript
output are dead and that TrueType or OpenType fonts and PDF
output are the way to go. While this is true for many cases,
standard \LaTeX{} does not work with TrueType fonts and does
not produce PDF\index{PDF@PDF} directly. Only
\product{pdf\LaTeX{}} does that, and there are
still many printers whose typesetters and platemakers use
PostScript\index{PostScript} rather than PDF\index{PDF@PDF}. In addition, operating system
support for scalable fonts is still very poor on Unix
systems (including Linux), despite the advances in recent
years, so in many cases it still makes sense to use
\TeX{}'s built-in support for PostScript.
Two files are needed for each font: the
\url+.afm+Adobe Font
Metric (AFM)\index{AFM@AFM|textbf}\index{Acronyms@\textbf{Acronyms}, defined!AFM@AFM|textbf} and the \url+.pfb+PostScript Font Binary (PFB)\index{PFB@PFB|textbf}\index{Acronyms@\textbf{Acronyms}, defined!PFB@PFB|textbf} files.
\emph{You must have both for each font before you
start.} If you only have the near-obsolete
\url+.pfa+PostScript Font
ASCII (PFA)\index{PFA@PFA|textbf}\index{Acronyms@\textbf{Acronyms}, defined!PFA@PFA|textbf} files, it may be possible to generate the
\url+.pfb+ files using the
\product{t1binary} program from the
\product{t1utils} suite (see \url+http://gnuwin32.sourceforge.net/packages/t1utils.htm+)
or the excellent \product{PFAedit} font
editor (from \url+http://pfaedit.sourceforge.net+). There are
unfortunately still some companies distributing Type 1
fonts in \url+.pfa+ format (Mathematica is
one reported recently).
\begin{warning}
The installation method I described in earlier
editions has worked perfectly for me for years, but I have
updated it here to use the facilities of the
\product{updmap} program (which comes
with your \TeX{} installation). This removes the need for
one of the steps I gave before, which required editing the
\url+psfonts.map+ file, as this is now
recreated by \product{updmap}. The
procedure below is \emph{not} the official
way (that's \product{fontinst}), but
it is the basis for a script I am working on called
\product{Gutta-Percha}\footnote{Yes, as in rubber.}, which automates the whole process.
\end{warning}
I'll repeat this: before you start, make sure you
have all the \url+.afm+ and
\url+.pfb+ files for the typeface you want.
In the example below, I'm going to use a single font
from an imaginary typeface called Foo, so I have
\verb+foo.afm+ and
\verb+foo.pfb+ files.
\begin{enumerate}
\item \textbf{Put the files in your temporary directory}\\
This is \url+/tmp+ on Linux, and
should be \url+C:\tmp+ or
\url+C:\temp+ or even
\url+C:\Windows\temp+ on Microsoft
Windows.
\item \textbf{Decide on the short font name to use
inside \LaTeX{}.}\\
This is \emph{not} the full
descriptive name (e.g. Baskerville Italic Bold
Extended) but an encoded font name in the format
\verb+fnnsseec+, devised by \person{Karl Berry}, which stores the same information in no
more than eight characters for compatibility with
systems which cannot handle long filenames. The letters
in the format above have the following meanings (see the
\product{fontname} documentation on
your computer for more details):
\begingroup\small \par\medskip\moveleft\itemindent\vbox{\begin{tabular}{@{}lll@{}}
\textbf{\sffamily\upshape Letter}&\textbf{\sffamily\upshape Meaning}&\textbf{\sffamily\upshape Examples}\\[2pt]\hline\\[-1.5\baselineskip]
\verb+f+&foundry&\verb+b+=Bitstream,
\verb+m+=Monotype,
\verb+p+=Adobe\\
\verb+nn+&typeface&\verb+ba+=Baskerville,
\verb+tm+=Times,
\verb+pl+=Palatino\\
\verb+ss+&series/shape&\verb+r+=roman,
\verb+bi+=bold italic, etc.\\
\verb+ee+&encoding&\verb+8a+=default 8-bit ANSI,
\verb+ly+=Y\amp Y's
\TeX{}'n'ANSI\\
{\fontseries{b}\selectfont{}\verb+c+}&[small]caps&(this is a literal
`c' character, used only
if needed)\\
\end{tabular}
}\endgroup
The \url+texmf/fontname+ directory in
your installation of \LaTeX{} has files for several
foundries giving fully-formed names like these for
common fonts (e.g. \verb+ptmr8a+ is [Adobe]
\uline{\textbf{P}}ost\-Script
\uline{\textbf{T}}i\uline{\textbf{m}}es
\uline{\textbf{R}}oman in an
\uline{\textbf{8}}\ndash{}bit \uline{\textbf{A}}NSI
encoding;
\verb+bgslly+ is \uline{\textbf{B}}itstream
\uline{\textbf{G}}ill \uline{\textbf{S}}ans
\uline{\textbf{L}}ight in Y\amp Y's
\TeX{}'n'ANSI encoding
[\uline{\textbf{LY}}1]).\footnote{Confusingly, Bitstream fonts (and others from
similar sources) mostly have different names from
the original fonts, so what they call Humanist 521
is actually Gill Sans. Until recently, US law only
allowed the \emph{names} of typefaces
to be copyrighted, not the font designs themselves,
leading to widespread piracy.} Read the documentation in \titlecite{fontname} to find out how to make up
your own short names if the foundry and font you want is
not shown in the \url+fontname+
directory.
In this example we'll call our mythical example
typeface `zork' (standing for
\uline{\textbf{Z}}fonts \uline{\textbf{Or}}dinary
Boo\uline{\textbf{k}}face, because
\verb+k+ is the letter used for Book
fonts, \verb+b+ being already the code
for bold) and we'll assume the font comes in the two
files \url+foo.afm+ and
\url+foo.pfb+ that I mentioned
above.
While the \product{fontname}
directories have ready-made lists of these names for
popular collections of typefaces, making them up
requires some knowledge of typographic terms and a
careful reading of the
\product{fontname}
documentation.
\item \textbf{Decide on your encoding}\\
This is what tripped me up the first few times until
someone pointed me at Y\amp Y's\footnote{Sadly, Y\amp Y, Inc has ceased trading and
their \TeX{} distribution is not longer available,
although there is email support at \url+http://lists.ucc.ie/lists/archives/yandytex.html+,
and their encoding files continue to be used.}\TeX{}'n'ANSI encoding which (to me) seems to
be the only one that includes the glyphs I want where I
want them.\footnote{The only one I still have problems with is
`ø', which for some weird
reason isn't catered for in this encoding.}\index{fonts!encoding} Your mileage may vary. This encoding is
referred to as \verb+LY1+ within \LaTeX{} and
the encoding file is in
\url+texmf/dvips/base/texnansi.enc+.
Encoding is needed because Adobe fonts store their
characters in different places to the \TeX{}
standard.
Copy this encoding file to the temporary directory
where you're doing all this stuff. If you're
using the 8a or 8r encoding (or some other encoding),
then copy that file instead
(\url+8a.enc+,
\url+8r.enc+).
\item \textbf{Convert \url+.afm+ files to
\url+.tfm+}\\\label{idfile}%
The \product{afm2tfm} program is a
standard utility in the \url+bin+
directory of your \TeX{} installation. If it's not,
update your installation.
In a command window, type:
\begin{sourcecode}[-\leftmargin]\begin{Verbatim}[fontsize=\footnotesize]
afm2tfm foo.afm -v zorkly.vpl -p texnansi.enc \
rzorkly.tfm >zork.id
\end{Verbatim}
\end{sourcecode}
(Here and elsewhere I have sometimes had to break
the line to fit it on the printed page. It's actually
all typed as one long line if you omit the
backslash.)
This creates a special `raw'\TeX{} Font Metric file (hence the special
\verb+r+ prefix) that \LaTeX{} can use, with
a list of all its properties encoded with LY1 (the
\url+.vpl+ or Virtual Property List
file). Many people will tell you that virtual fonts are
dead and that this is the wrong way to do it, but no-one
has ever shown me an alternative that works, so I stick
with it.
\item \textbf{Small caps (optional)}\\\label{sc}%
If you want a small caps variant faked up (perhaps
because the typeface family doesn't have a special
small-caps font), repeat the medicine like this:
\begin{sourcecode}[-\leftmargin]\begin{Verbatim}[fontsize=\footnotesize]
afm2tfm foo.afm -V zorklyc.vpl -p texnansi.enc \
rzorkly.tfm >>zork.id
\end{Verbatim}
\end{sourcecode}
Note the capital \verb+V+ option here.
Yes, it \emph{does} overwrite the
\url+rzorkly.tfm+ created in the first
command. Let it. And those are \emph{two}
of the `greater-than' signs
before the \url+zork.id+ filename because
we want to append to it, not overwrite it.
\item \textbf{Create the virtual font}\\
Turn the \url+.vpl+ files into
\url+.vf+ and \url+.tfm+
pairs. \LaTeX{} uses these to convert from Adobe's
encoding to its own.
\begin{sourcecode}[-\leftmargin]\begin{Verbatim}[fontsize=\small]
vptovf zorkly.vpl zorkly.vf zorkly.tfm
vptovf zorklyc.vpl zorklyc.vf zorklyc.tfm
\end{Verbatim}
\end{sourcecode}
Again, the \url+vptovf+ program is a
standard part of your \TeX{} distribution.
\item \textbf{Make directories to hold the files}\\\begin{figure}\small
\caption{\small Making subdirectories to hold the files}
\label{mksubdir}
\begin{center}
\includegraphics[width=0.75\textwidth]{fonts}
\end{center}
\end{figure}
Under your \url+texmf-local+
directory there should be a \url+fonts+
directory, and in there there should be
\url+afm+, \url+tfm+,
\url+type1+, and \url+vf+
directories. Create them if they do not already
exist.
In each of these four, create a directory for the
foundry, and within them create a directory for the
typeface (using a human-readable typeface name, not the
short \person{Karl Berry} fontname). In our example, this
means:
\begin{sourcecode}[-\leftmargin]\begin{Verbatim}[fontsize=\small]
cd /usr/TeX/texmf-local/fonts
mkdir -p afm/zfonts/ordinary
mkdir -p tfm/zfonts/ordinary
mkdir -p type1/zfonts/ordinary
mkdir -p vf/zfonts/ordinary
cd /tmp
\end{Verbatim}
\end{sourcecode}
Or if you're lazy like me:
\begin{sourcecode}[-\leftmargin]\begin{Verbatim}[fontsize=\small]
(cd /usr/TeX/texmf-local/fonts;\
for d in afm tfm type1 vf;\
do mkdir -p $d/zfonts/ordinary;done)
\end{Verbatim}
\end{sourcecode}
For Microsoft Windows users, the path before
\url+texmf-local+ may look something like
\verb+C:\Program Files\TeXLive\+, depending
on how and where you have installed your \TeX{}
system.
The \verb+-p+ is a Unix feature: it
automatically creates any missing intervening
subdirectories. If your directory-making command
doesn't do this, you'll have to make the
intervening directories by hand first.
\item \textbf{Copy the files to their rightful places}\\
Copy the four groups of files to the four new
directories:
\begin{sourcecode}[-\leftmargin]\begin{Verbatim}[fontsize=\small]
cp *.afm /usr/TeX/texmf/fonts/afm/zfonts/ordinary/
cp *.tfm /usr/TeX/texmf/fonts/tfm/zfonts/ordinary/
cp *.pfb /usr/TeX/texmf/fonts/type1/zfonts/ordinary/
cp *.vf /usr/TeX/texmf/fonts/vf/zfonts/ordinary/
\end{Verbatim}
\end{sourcecode}
You can of course do all this with a directory
window and mouse if you find it easier.
\item \textbf{Create a font map}\\
The font map is what tells
\product{dvips} which PFB\index{PFB@PFB} file to use for which font. The
configuration file for \product{dvips}
is \url+texmf/dvips/config/config.ps+ and
it gets its entries from the program
\product{updmap} which reads map files
for each typeface. The configuration file for
\product{updmap} is
\url+texmf-var/web2c/updmap.cfg+\footnote{There is another one of these at
\url+texmf/web2c/updmap.cfg+, but
that contains the map references for the fonts which
came with your distribution of \TeX{}, so you should
not interfere with it.}, so it needs an entry for our new font,
using the three-letter font family abbreviation (the
first three letters of the Berry fontname (here
`\verb+zor+'):
\begin{sourcecode}[-\leftmargin]\begin{Verbatim}[fontsize=\small]
Map zor.map
\end{Verbatim}
\end{sourcecode}
We also have to create this map file
(\url+zor.map+) in a subdirectory of
\url+texmf-local/dvips/config/+ named
after the foundry, so we need to create
\url+texmf-local/dvips/config/zfonts+ as
well.
\begin{enumerate}
\item
Open
\url+/usr/TeX/texmf-var/web2c/updmap.cfg+
in your editor.
\item
At the bottom, add the line:
\verb`Map zor.map`
\item
Save and close the file.
\end{enumerate}
The font entries in our
\verb+zor.map+ will be on a
\emph{single} line each, with no
line-wrapping. Each entry gives the short name of the
font, the long (Adobe) name, the
PostScript\index{PostScript} encoding parameters
(in quotes), and then two filenames prefixed by input
redirects (less-than signs): the encoding file and the
PostScript\index{PostScript} outline file.
\begin{enumerate}
\item
First create the directory if it doesn't already
exist:
\begin{sourcecode}[-\leftmargin]\begin{Verbatim}[fontsize=\small]
mkdir -p /usr/TeX/texmf-local/dvips/config/zfonts
\end{Verbatim}
\end{sourcecode}
\item
Use your editor to open (create) the file
\url+/usr/TeX/texmf-local/dvips/config/zfonts/zor.map+.
\item \label{fullname}%
Insert the line:
\begin{shiftedsourcecode}[-\leftmargin]\begin{Verbatim}[fontsize=\scriptsize]
rzorkly Ordinary-Blackface "TeXnANSIEncoding ReEncodeFont" <texnansi.enc <foo.pfb
\end{Verbatim}
\end{shiftedsourcecode}
\item
Save and close the file.
\end{enumerate}
You get the full font name (here,
`Ordinary-Blackface') from the
\verb+zork.id+ which was created back in
step~\ref{idfile} in the procedure on p.\thinspace\pageref{idfile} when we ran
\product{afm2tfm}. You must get this
exactly right, because it's the
`official' full name of the font,
and PostScript\index{PostScript} files using this
font need to match it.
\item \textbf{Create a style file}\\
\LaTeX{} needs a style file to implement the
interface to the font. Call it after the typeface or
something related; in this example we'll call it
\url+foozork.sty+. In it go some details
of the name and date we did this, what version of
\LaTeX{} it needs, and any other command necessary to
operate the font, like the font encoding and whether it
is to supersede the current default Roman font.
\begin{enumerate}
\item
Use your editor to open (create)
\url+foozork.sty+ in your
\url+texmf-local/tex/latex/psnfss+
directory.
\item
Insert the following lines:
\begin{sourcecode}[-\leftmargin]\begin{Verbatim}[fontsize=\small]
% foozork - created from foo for Zork
\def\fileversion{1.0}
\def\filedate{2002/12/03}
\def\docdate{2002/12/03}
\NeedsTeXFormat{LaTeX2e}
\ProvidesPackage{foozork}
[\filedate\space\fileversion\space
Zfonts Ordinary PSNFSS2e package]
\RequirePackage[LY1]{fontenc}
\renewcommand{\rmdefault}{zor}
\endinput
\end{Verbatim}
\end{sourcecode}
Note the following:
\begin{itemize}
\item
The first argument to
\command{ProvidesPackage}
\emph{must} be the same as this
style file name; and that the font family is
referred to as \verb+zor+, being the
foundry letter plus the fontname abbreviation.
This acts as a prefix for any/all font variants
(bold, italic, etc.).
\item
If you are not using Y\amp Y encoding,
omit the line referring to LY1 font
encoding.
\item
If this is a typewriter font, make the
renewed command \command{rmdefault}
into \command{ttdefault}.
\item
If it's a sans-serif font, make it
\command{sfdefault} instead.
\item
Omit the command completely if you
don't want the style file to supersede the
current defaults but simply to make the font
available. If you do this, you probably want to
write a new command or two to use it, typically
one for grouped use and one for argument
use:
\end{itemize}
\begin{sourcecode}[-\leftmargin]\begin{Verbatim}[fontsize=\footnotesize]
\newcommand{\zorkfamily}{\fontencoding{LY1}%
\fontfamily{zor}\selectfont}
\newcommand{\textzork}[1]{{\zorkfamily#1}}
\end{Verbatim}
\end{sourcecode}
\item
Save and close the file.
\end{enumerate}
\item \textbf{Create the Font Definition file}\\\label{fdfiles}%
The last file to create is the \textbf{\textit{font definition}}\label{fontdef}\index{font definition@\textbf{\textit{font definition}}}
(\url+.fd+) file. This is named
following the pattern \verb+eeefnn.fd+,
using the same conventions as before, by prepending the
(lowercase) encoding abbreviation to the foundry letter
and fontname abbreviation, so our example would be
\verb+ly1zor.fd+ for the LY1 encoding and
the \verb+zor+ short font name.
\begin{enumerate}
\item
Use your editor to open (create)
\url+texmf-local/tex/latex/psnfss/ly1zor.fd+
\item
Enter the following lines:
\begin{sourcecode}[-\leftmargin]\begin{Verbatim}[fontsize=\small]
\ProvidesFile{ly1zor.fd}[2002/03/03 v0.1 manual
font definitions for LY1/zor.]
\DeclareFontFamily{LY1}{zor}{}
\DeclareFontShape{LY1}{zor}{k}{n}{<-> zorkly}{}
\DeclareFontShape{LY1}{zor}{k}{sc}{<-> zorklyc}{}
\end{Verbatim}
\end{sourcecode}
\item
Save and close the file.
\end{enumerate}
FD files typically use one
\command{DeclareFontFamily} command which
specifies the encoding and the short font name. Then as
many pairs of \command{DeclareFontShape}
commands as you converted fonts (assuming you did both
normal and small caps for each font: see
step~\ref{sc} in the procedure on p.\thinspace\pageref{sc}; if you didn't, then only one
such command per font is needed here). The arguments to
the \command{DeclareFontShape} command to watch
are the 3rd (weight/width), 4th (shape), and 5th (font
outline name): the rest are static for each
\url+.fd+ file and simply identify the
encoding and the font family.
The codes to use are given on
pages 414\ndash{}15 of the \titlecite{companion} and should also be in
your copies of
\url+texmf/fontnames/weight.map+ and
\url+texmf/fontnames/width.map+. The
rules for combining weight and width need care: RTFM\index{RTFM@RTFM} for
\package{fontname}. There is no
\url+shape.map+ in
\package{fontname} because it's not
part of font file names, it's purely a \LaTeX{}
creation, so here's what the same book says:
\begingroup\small \begin{center}
\begin{tabular}{ll}
\textbf{\sffamily\upshape Character}&\textbf{\sffamily\upshape Meaning}\\[2pt]\hline\\[-1.5\baselineskip]
\verb+n+&normal (upright)\\
\verb+it+&italic\\
\verb+sl+&slanted\\
\verb+sc+&small caps\\
\verb+ui+&upright italic\\
\verb+ol+&outline\\
\end{tabular}
\end{center}
\endgroup
Add your own for other oddities, but be consistent:
I use \verb+cu+ for cursive (scripts), for
example, and \verb+k+ for blackletter faces
(not to be confused with \verb+k+ as a
\emph{width} for
`book').
The default fontspec
\verb+<->+ in the 5th argument
in the \command{DeclareFontShape} command means
that all sizes are to come from the same font outline
(remember if this was a \mf{} font with different
design sizes like CM\index{CM@CM} it would
be much more complex).
If the face has only a few variants, you can create
any other entries for bold, italic, slanted, etc. with
the relevant weight and width and shape values pointing
at the relevant outline file.
If you want one font to substitute for a missing one
(for example italics to substitute for slanted in a
typeface which has no slanted variant of its own) give
the
\verb+ssub+ (`silent
substitution') command in the fontspec:
for example to make all references to
\verb+sl+ (slanted) type use an existing
italic font, make the 5th argument like this:
\begin{sourcecode}[-\leftmargin]\begin{Verbatim}[fontsize=\small]
{<-> ssub * zor/m/it}
\end{Verbatim}
\end{sourcecode}
If you find the x-height of a font too big or too
small to sort well with another font you are using, you
can specify an \verb+s+
(`scale') factor in this argument
instead: this example will shrink the result to
80\% of normal:
\begin{sourcecode}[-\leftmargin]\begin{Verbatim}[fontsize=\small]
{<-> s * [0.8] zorkly}
\end{Verbatim}
\end{sourcecode}
\item \textbf{Update the index and the map files}\\
Run your \TeX{} indexer program (see step~\ref{texindex} in the procedure on p.\thinspace\pageref{texindex}) so that
\product{updmap} can find the files it
needs.
Then run \product{updmap} (just
type \verb+updmap+). This updates the
maps and runs the \TeX{} indexer program again
automatically.
\end{enumerate}
Now you can \verb+\usepackage{foozork}+ in
your \LaTeX{} file to make it the default font. To use the
font incidentally instead of as the default, you can
say:
\begin{sourcecode}\begin{Verbatim}[fontsize=\small]
This is {\zorkfamily ZORK} or \textzork{ZORK}
\end{Verbatim}
\end{sourcecode}
\subsection{Installing the Type 1 Computer Modern
fonts}
\label{type1cm}
Most new distributions of \LaTeX{} use the
PostScript\index{PostScript} Type 1 versions of
the Computer Modern fonts. If your \LaTeX{} installation
uses the \mf{} (bitmap) versions of CM\index{CM@CM}, you may want to switch to the
Type 1 version, especially if you are going to be using
\product{pdf\LaTeX{}} instead of standard
\LaTeX{}, because Acrobat Reader makes such a hames of
displaying Type3 fonts. \product{GSview}
and \product{pdfview} handle them
correctly.
To do this, install one of the sets of CM\index{CM@CM} PostScript fonts. There are several
available:
\begin{itemize}
\item
The fonts from BlueSky Research at \url+http://www.ctan.org/tex-archive/fonts/cm/ps-type1/bluesky/+
\item
\person{Basil K. Malyshev}'s `BaKoMa'
fonts at \url+http://www.ctan.org/tex-archive/fonts/cm/ps-type1/bakoma/+
\item
\person{Vladimir Volovich}'s CM-Super at \url+http://www.ctan.org/tex-archive/fonts/ps-type1/cm-super/+
\item
\person{Bogus\l{}aw Jackowski}'s Latin Modern at \url+ftp://cam.ctan.org/tex-archive/fonts/ps-type1/lm.tar.gz+
\end{itemize}
The BaKoMa fonts include the American
Mathematical Society (AMS)\index{AMS@AMS|textbf}\index{Acronyms@\textbf{Acronyms}, defined!AMS@AMS|textbf} fonts for extended
mathematics, but are more complex to install because they
come with a special set of TFM files.
The BlueSky fonts are just PFB\index{PFB@PFB}
and AFM files, and are a drop-in replacement requiring no
further changes, as they use the same TFM files as the
\mf{} version. Follow the \url+README+
file in the downloadable archive for installation
instructions.
The Latin Modern and CM-Super fonts are new and I
haven't tested them but they are well spoken of.
Feedback on this is very welcome.
The \TeX{} Live and \TeX{} Collection distributions use
Type 1 versions of Computer Modern by default. There
are more details in the FAQ at \url+http://www.tex.ac.uk/cgi-bin/texfaq2html?label=uselmfonts+\thinspace{}.
\chapter{Programmability (macros)}
\label{macros}
\index{macros}
We've touched several times on the ability of \LaTeX{}
to be reprogrammed. This is one of its central features, and one
that still, after nearly a quarter of a century, puts it well
above many other typesetting systems, even those with macro
systems of their own. It's also the one that needs most
foreknowledge, which is why this chapter is in this
position.
\LaTeX{} is in fact itself just a collection of
macros\mdash{}rather a big collection\mdash{}written in
\TeX{}'s internal typesetting language. These \textbf{\textit{macros}}\label{macs}\index{macros@\textbf{\textit{macros}}} are little program-like sets of
instructions with a name which can be used as shorthand for an
operation you wish to perform more than once.
Macros can be arbitrarily complex. Many of the ones used in
the standard \LaTeX{} packages are several pages long, but as we
will see, even short ones can very simply automate otherwise
tedious chores and allow the author to concentrate on
\emph{writing}.
\section{Simple replacement macros}
\label{replacement}
In its simplest form, a \LaTeX{} macro can just be a
straightforward text replacement of a phrase to avoid
misspelling something each time you need it, e.g.
\begin{sourcecode}\begin{Verbatim}[fontsize=\small]
\newcommand{\ef}{European Foundation for the
Improvement of Living and Working Conditions}
\end{Verbatim}
\end{sourcecode}
Put this in your preamble, and you can then use
\command{ef} in your document and it will typeset it
as the full text. Remember that after a command ending in a
letter you need to leave a space to avoid the next word
getting gobbled up as part of the command (see
the first paragraph of \S\thinspace\ref{swallow}). And when you want to force a space
to be printed, use a backslash followed by a space,
e.g.
\begin{sourcecode}\begin{Verbatim}[fontsize=\small]
The \ef\ is an institution of the Commission of the
European Union.
\end{Verbatim}
\end{sourcecode}
As you can see from this example, the
\command{newcommand} command takes two arguments:
\begin{inparaenum}[\itshape a\upshape)] \item the name you want to give the new command; and \item the expansion to be performed when you use it\end{inparaenum}, so there are always two sets of curly braces
after \command{newcommand}.
\section{Macros using information gathered previously}
\label{macinf}
A more complex example is the macro
\command{maketitle} which is used in almost every
formal document to format the title block. In the basic
document classes (book, report, and article) it performs small
variations on the layout of a centred block with the title
followed by the author followed by the date, as we saw in
\S\thinspace\ref{titling}.
If you inspect one of these document class files, such as
\url+texmf/tex/latex/base/report.cls+ you will
see \command{maketitle} defined (and several variants
called \command{@maketitle} for use in different
circumstances). It uses the values for the title, author, and
date which are assumed already to have been stored in the
internal macros \command{@title},
\command{@author}, and \command{@date} by
the author using the matching \command{title},
\command{author}, and \command{date}
commands in the document.
This use of one command to store the information in
another is a common way of gathering the information from the
user. The use of macros containing the
\verb+@+ character prevents their accidental
misuse by the user: in fact to use them in your preamble we
have to allow the \verb+@+ sign to become a
`letter' so it can be recognised in a
command name, and remember to turn it off again afterwards
(see item~\ref{makeat} below).
\begin{sourcecode}\label{newtitle}\begin{Verbatim}[fontsize=\small]
\makeatletter
\renewcommand{\maketitle}{%
\begin{flushleft}%
\sffamily
{\Large\bfseries\color{red}\@title\par}%
\medskip
{\large\color{blue}\@author\par}%
\medskip
{\itshape\color{green}\@date\par}%
\bigskip\hrule\vspace*{2pc}%
\end{flushleft}%
}
\makeatother
\end{Verbatim}
\end{sourcecode}
Insert this in the sample file on p.\thinspace\pageref{oldtitle} immediately before the
\verb+\begin{document}+ and remove the
\verb+\color{...}+ commands from the title,
author, and date. Re-run the file through \LaTeX{}, and you
should get something like this:
\begin{center}
\setlength{\fboxsep}{1cm}\includegraphics[width=0.75\textwidth]{newtitle}
\end{center}
In this redefinition of \command{maketitle},
we've done the following:
\begin{enumerate}\item\label{makeat}
Enclosed the changes in
\command{makeatletter} and
\command{makeatother} to allow us to use the
\verb+@+ sign in command names;\footnote{If you move all this preamble into a style file of
your own, you don't need these commands: the use
of \url+@+ signs in command names is
allowed in style and class files.}
\item
Used \command{renewcommand} and put
\command{maketitle} in curly braces after
it;
\item
Opened a pair of curly braces to hold the new
definition. The closing curly brace is immediately before
the \command{makeatother};
\item
Inserted a \env{flushleft} environment
so the whole title block is left-aligned;
\item
Used \command{sffamily} so the whole title
block is in the defined sans-serif typeface;
\item
For each of \command{@title},
\command{@author}, and \command{@date},
we have used some font variation and colour, and enclosed
each one in curly braces to restrict the changes just to
each command. The closing \command{par} makes
sure that multiline title and authors and dates get
typeset with the relevant line-spacing;
\item
Added some flexible space between the lines, and
around the \command{hrule} (horizontal rule) at
the end;
\end{enumerate}
Note the \verb+%+ signs after any line ending
in a curly brace, to make sure no intrusive white-space find
its way into the output. These aren't needed after simple
commands where there is no curly brace because excess
white-space gets gobbled up there anyway.
\section{Macros with arguments}
\label{macargs}
But macros are not limited to text expansion. They can
take arguments of their own, so you can define a command to do
something with specific text you give it. This makes them much
more powerful and generic, as you can write a macro to do
something a certain way, and then use it hundreds of times
with a different value each time.
We looked earlier (\S\thinspace\ref{emph}) at making new
commands to put specific classes of words into certain fonts,
such as product names into italics, keywords into bold, and so
on. Here's an example for a command
\command{product}, which also indexes the product
name and adds a trademark sign:
\begin{sourcecode}\begin{Verbatim}[fontsize=\small]
\newcommand{\product}[1]{%
\textit{#1}\texttrademark%
\index{#1@\textit{#1}}%
}
\end{Verbatim}
\end{sourcecode}
If I now type \verb+\tmproduct{Velcro}+ then I
get \product{Velcro}\texttrademark{} typeset, and if
you look in the index, you'll find this page referenced
under `{\fontshape{it}\selectfont{}Velcro}'. Let's
examine what this does:
\begin{enumerate}\item
The macro is specified as having one argument
(that's the \verb+[1]+ in the
definition). This will
be the product name you type in curly braces when you use
\command{product}. Macros can have up to nine
arguments.
\item
The expansion of the macro is contained in the second
set of curly braces, spread over several lines (see item~\ref{macrolines} for why).
\item
It prints the value of the first argument (that's
the \verb+#1+) in italics, which is
conventional for product names, and adds the
\command{texttrademark} command.
\item
Finally, it creates an index entry using the same
value (\verb+#1+), making sure that it's
italicised in the index (see the list on p.\thinspace\pageref{indextypo} in \S\thinspace\ref{indextypo} to remind yourself of how indexing
something in a different font works).
\item\label{macrolines}
Typing this macro over several lines makes it easier
for humans to read. I could just as easily have
typed
\begin{shiftedsourcecode}[-\leftmargin]\begin{Verbatim}[fontsize=\footnotesize]
\newcommand{\product}[1]{\textit{#1}\index{#1@\textit{#1}}}
\end{Verbatim}
\end{shiftedsourcecode}
but it wouldn't have been as clear what I was
doing.
One thing to notice is that to prevent unwanted spaces
creeping into the output when \LaTeX{} reads the macro, I
ended each line with a comment character
(\verb+%+). \LaTeX{} normally treats
newlines as spaces when formatting (remember item~\ref{comment}), so this stops the end of line
being turned into an unwanted space when the macro is
used. \LaTeX{} always ignores spaces at the
\emph{start} of macro lines anyway, so
indenting lines for readability is fine.
\end{enumerate}
In (\S\thinspace\ref{hyph}) we mentioned the problem
of frequent use of unbreakable text leading to poor
justification or to hyphenation problems. A solution is to
make a macro which puts the argument into an
\command{mbox} with the appropriate font change, but
precedes it all with a conditional
\command{linebreak} which will make it more
attractive to \TeX{} to start a new line.
\begin{sourcecode}\begin{Verbatim}[fontsize=\small]
\newcommand{\var}[1]{\linebreak[3]\mbox{\ttfamily#1}}
\end{Verbatim}
\end{sourcecode}
This only works effectively if you have a reasonably wide
setting and paragraphs long enough for the differences in
spacing elsewhere to get hidden. If you have to do this in
narrow journal columns, you may have to adjust wording and
spacing by hand occasionally.
\section{Nested macros}
\label{macnest}
Here's a slightly more complex example, where one
macro calls another. It's common in normal text to refer
to people by their forename and surname (in that order), for
example \person{Don Knuth}, but to have them indexed as \emph{surname,
forename}. This pair of macros,
\command{person} and \command{reindex},
automates that process to minimize typing and indexing.
\begin{sourcecode}\begin{Verbatim}[fontsize=\small]
\newcommand{\person}[1]{#1\reindex #1\sentinel}
\def\reindex #1 #2\sentinel{\index{#2, #1}}
\end{Verbatim}
\end{sourcecode}
\begin{enumerate}\item
The digit 1 in square brackets means that
\command{person} has one argument, so you put the
whole name in a single set of curly braces, e.g.
\verb+\person{Don Knuth}+.
\item
The first thing the macro does is output
\verb+#1+, which is the value of what you typed,
just as it stands, so the whole name gets typeset exactly
as you typed it.
\item
But then it uses a special feature of Plain \TeX{}
macros (which use \command{def} instead of
\LaTeX{}'s \command{newcommand}\footnote{Don't try this at home alone, children! This
one is safe enough, but you should strictly avoid
\command{def} for a couple of years. Stick to
\command{newcommand} for now.}): they too can have multiple arguments but you
can separate them with other characters (here a space) to
form a pattern which \TeX{} will recognise when reading the
arguments.
In this example (\command{reindex}) it's
expecting to see a string of characters
(\verb+#1+) followed by a space, followed by
another string of characters (\verb+#2+)
followed by a dummy command (\command{sentinel}).
In effect this makes it a device for splitting a name into
two halves on the space between them, so the two halves
can be handled separately. The \command{reindex}
command can now read the two halves of the name
separately.
\item
The \command{person} command invokes
\command{reindex} and follows it with the name
you typed plus the dummy command
\command{sentinel} (which is just there to signal
the end of the name). Because \command{reindex}
is expecting two arguments separated by a space and
terminated by a \command{sentinel}, it sees
`\verb+Don+ and
\verb+Knuth+' as two separate
arguments.
It can therefore output them using
\command{index} in reverse order, which is
exactly what we want.
\end{enumerate}
A book or report with a large number of personal names to
print and index could make significant use of this to allow
them to be typed as
\verb+\person{Leslie Lamport}+ and printed as
\person{Leslie Lamport}, but have them indexed as
`Lamport, Leslie' with virtually no effort
on the author's part at all.
\begin{exercise}
\addcontentsline{loe}{section}{\numberline{20}Other names}
\subsubsection*{Other names}
Try to work out how to make this
\command{person} feature work with names
like:
\begin{itemize*}
\item Blanca Maria Bartosova de Paul
\item Patricia Maria Soria de Miguel
\item Arnaud de la Villèsbrunne
\item Prince
\item Pope John Paul II
\end{itemize*}
Hints: the command \command{space} produces a
normal space, and one way around \LaTeX{}'s requirements
on spaces after command names ending with a letter is to
follow such commands with an empty set of curly braces
\verb+{}+.
\end{exercise}
\section{Macros and environments}
\label{macenv}
As mentioned in \S\thinspace\ref{fancybox}, it is possible
to define macros to capture text in an environment and reuse
it afterwards. This avoids any features of the subsequent use
affecting the formatting of the text.
One example of this uses the facilities of the
\package{fancybox} package, which defines a
variety of framed boxes to highlight your text, and a special
environment \env{Sbox} which
`captures' your text for use in these
boxes.
\begin{example}
\begin{sourcecode}\begin{Verbatim}[fontsize=\small]
\begin{Sbox}
\begin{minipage}{3in}
This text is formatted to the specifications
of the minipage environment in which it
occurs.
Having been typeset, it is held in the Sbox
until it is needed, which is after the end
of the minipage, where you can (for example)
align it and put it in a special framed box.
\end{minipage}
\end{Sbox}
\begin{flushright}
\shadowbox{\theSbox}
\end{flushright}
\end{Verbatim}
\end{sourcecode}\vspace*{-\baselineskip}\begin{quote}\fontencoding{T1}\fontfamily{cmr}\selectfont\def\sfdefault{cmss}\def\bfdefault{bf}\noindent
\begin{sidebar}
This text is formatted to the specifications of the
minipage environment in which it occurs.
Having been typeset, it is held in the Sbox until it
is needed, which is after the end of the minipage, where
you can (for example) centre it and put it in a special
framed box.
\end{sidebar}\end{quote}\end{example}
By putting the text (here in a
\env{minipage} environment because we want to
change the width) inside the \env{Sbox}
environment, it is typeset into memory and stored in the macro
\command{theSbox}. It can then be used afterwards as
the argument of the \command{shadowbox} command (and
in this example it has also been centred).
\section{Reprogramming \LaTeX{}'s internals}
\label{reprog}
\LaTeX{}'s internal macros can also be reprogrammed or
even rewritten entirely, although doing this can require a
considerable degree of expertise. Simple changes, however, are
easily done.
Recall that \LaTeX{}'s default document structure for
the Report document class uses Chapters as the main unit of
text, whereas in reality most reports are divided into
Sections, not Chapters (\S\thinspace\ref{repchap}). The result
of this is that if you start off your report with
\verb+\section{Introduction}+, it will print
as
{\Large{}\fontseries{b}\selectfont{}0.1\quad Introduction\emstrut}
\noindent which is not at all what you want. The zero is
caused by it not being part of any chapter. But this numbering
is controlled by macros, and you can redefine them. In this
case it's a macro called \verb+\thesection+
which reproduces the current section number counter (see the last paragraph of \S\thinspace\ref{thecounter}). It's redefined afresh in each
document class file, using the command
\command{renewcommand} (in this case in
\url+texmf/tex/latex/base/report.cls+):
\begin{sourcecode}\begin{Verbatim}[fontsize=\small]
\renewcommand \thesection
{\thechapter.\@arabic\c@section}
\end{Verbatim}
\end{sourcecode}
You can see it invokes \command{thechapter}
(which is defined elsewhere to reproduce the value of the
\counter{chapter} counter), and it
then prints a dot, followed by the Arabic value of the counter
called \counter{section} (that
\verb+\c@+ notation is \LaTeX{}'s internal way
of referring to counters). You can redefine this in your
preamble to simply leave out the reference to chapters:
\begin{sourcecode}\begin{Verbatim}[fontsize=\small]
\renewcommand{\thesection}{\arabic{section}}
\end{Verbatim}
\end{sourcecode}
I've used the more formal method of enclosing the
command being redefined in curly braces. For largely
irrelevant historical reasons these braces are often omitted
in \LaTeX{}'s internal code (as you may have noticed in
the example earlier). And I've also used the
`public' macro
\command{arabic} to output the value of \counter{section} (\LaTeX{}'s internals
use a `private' set of control
sequences containing \verb+@+-signs, designed to
protect
them against being changed accidentally).
Now the introduction to your report will start
with:
{\Large{}\fontseries{b}\selectfont{}1\quad Introduction\emstrut}
What's important is that you \emph{don't
ever} need to alter the original document class
file \url+report.cls+: you just copy the
command you need to change into your own document preamble,
and modify that instead. It will then override the
default.
\subsection{Changing list item bullets}
\label{bullets}
As mentioned earlier (\S\thinspace\ref{labelitem}),
here's how to redefine a bullet for an itemized list,
with a slight tweak:
\begin{sourcecode}\begin{Verbatim}[fontsize=\small]
\usepackage{bbding}
\renewcommand{\labelitemi}{%
\raisebox{-.25ex}{\PencilRight}}
\end{Verbatim}
\end{sourcecode}
Here we use the \package{bbding} package
which has a large selection of
`dingbats' or little icons, and we
make the label for top-level itemized lists print a
right-pointing pencil (the names for the icons are in the
package documentation: see \S\thinspace\ref{packagedoc} for
how to get it).
In this case, we are using the
\command{raisebox} command within the redefinition
because it turns out that the symbols in this font are
positioned slightly too high for the typeface we're
using. The \command{raisebox} command takes two
arguments: the first is a dimension, how much to raise the
object by (and a negative value means
`lower': there is no need for a
\verb+\lowerbox+ command); and the second is
the text you want to affect. Here, we are shifting the
symbol down by ¼ex (see \S\thinspace\ref{dimensions}
for a
list of dimensions \LaTeX{} can use).
There is a vast number of symbols available: see
\titlecite{symbol-list} for a
comprehensive list.
\chapter{Compatibility with other systems}
\label{compat}
As we saw in \chaptername~\ref{plaintext}, \LaTeX{} uses
plain-text files, so they can be read and written by any
standard application that can open text files. This helps
preserve your information over time, as the plain-text format
cannot be obsoleted or hijacked by any manufacturer or sectoral
interest, and it will always be readable on any computer, from
your handheld (yes, \LaTeX{} is available for some PDA\index{PDA@PDA}s, see Figure~\ref{zaurus}) to the
biggest supercomputer.
\begin{figure}\small
\caption{\small \LaTeX{} editing and processing on the Sharp Zaurus 5500
PDA}
\label{zaurus}
\begin{center}
\includegraphics[width=0.3\textwidth]{zedit}\quad\includegraphics[width=0.3\textwidth]{zlatex}\quad\includegraphics[width=0.3\textwidth]{qpdf}
\end{center}
\end{figure}
However, \LaTeX{} is intended as the last stage of the
editorial process: formatting for print or display. If you have
a requirement to re-use the text in some other
environment\mdash{}a database perhaps, or on the Web or a
CD-ROM\index{CD-ROM@CD-ROM} or DVD\index{DVD@DVD}, or in Braille or voice output\mdash{}then
it should probably be edited, stored, and maintained in
something neutral like the Extensible Markup
Language (XML)\index{XML@XML|textbf}\index{Acronyms@\textbf{Acronyms}, defined!XML@XML|textbf}, and only converted to \LaTeX{} when a
typeset copy is needed.
Although \LaTeX{} has many structured-document features in
common with SGML\index{SGML@SGML} and XML\index{XML@XML}, it can still only be processed by the
\LaTeX{} and \product{pdf\LaTeX{}} programs.
Because its macro features make it almost infinitely
redefinable, processing it requires a program which can unravel
arbitrarily complex macros, and \LaTeX{} and its siblings are
the only programs which can do that effectively. Like other
typesetters and formatters (Quark
\product{XPress},
\product{PageMaker},
\product{FrameMaker}, Microsoft
\product{Publisher}, \product[3]{3B2} etc.), \LaTeX{} is largely a
one-way street leading to typeset printing or display
formatting.
Converting \LaTeX{} to some other format therefore means you
will unavoidably lose some formatting, as \LaTeX{} has features
that others systems simply don't possess, so they cannot be
translated\mdash{}although there are several ways to minimise
this loss. Similarly, converting other formats into \LaTeX{}
often means editing back the stuff the other formats omit
because they only store appearances, not structure.
However, there are at least two excellent systems for
converting \LaTeX{} directly to HyperText
Markup Language (HTML)\index{HTML@HTML|textbf}\index{Acronyms@\textbf{Acronyms}, defined!HTML@HTML|textbf} so you can publish it on the web, as
we shall see in \S\thinspace\ref{latexto}.
\section{Converting into \LaTeX{}}
\label{tolatex}
There are several systems which will save their text in
\LaTeX{} format. The best known is probably the \LyX{} editor
(see Figure~\ref{lyxwin}), which is a wordprocessor-like
interface to \LaTeX{} for Windows and Unix. Both the
\product{AbiWord} and
\product{Kword} wordprocessors on Linux
systems have a very good \textbf{Save As}\dots \LaTeX{}
output, so they can be used to open Microsoft
\product{Word} documents and convert to
\LaTeX{}. Several maths packages like the
\product{EuroMath} editor, and the
\product{Mathematica} and
\product{Maple} analysis packages, can also
save material in \LaTeX{} format.
In general, most other wordprocessors and DTP systems
either don't have the level of internal markup
sophistication needed to create a \LaTeX{} file, or they lack
a suitable filter to enable them to output what they do have.
Often they are incapable of outputting any kind of structured
document, because they only store what the text looks like,
not why it's there or what role it fulfills. There are
two ways out of this:
\begin{itemize}
\item
Use the \menuitem{File}{Save
As\dots } menu item to save the
wordprocessor file as HTML\index{HTML@HTML},
rationalise the HTML\index{HTML@HTML} using
\person{Dave Raggett}'s \product{HTML
Tidy}\footnote{\url+http://tidy.sourceforge.net/+}, and convert the resulting
Extensible HyperText Markup
Language (XHTML)\index{XHTML@XHTML|textbf}\index{Acronyms@\textbf{Acronyms}, defined!XHTML@XHTML|textbf} to \LaTeX{} with any
of the standard XML\index{XML@XML} tools (see
below).
\item
Use a specialist conversion tool like EBT's
\product{DynaTag} (supposedly available
from Enigma, if you can persuade them they have a copy to
sell you; or you may still be able to get it from Red Bridge
Interactive\footnote{\url+http://www.rbii.com/+} in Providence, RI). It's
expensive and they don't advertise it, but for bulk
conversion of consistently-marked
\product{Word} files into XML it beats
everything else hands down. The
\product{Word} files
\emph{must} be consistent, though, and must
use named styles from a stylesheet, otherwise no system on
earth is going to be able to guess what it means.
\end{itemize}
There is of course a third way, suitable for large volumes
only: send it off to the Pacific Rim to be retyped into XML or
\LaTeX{}. There are hundreds of companies from India to
Polynesia who do this at high speed and low cost with very
high accuracy. It sounds crazy when the document is already in
electronic form, but it's a good example of the problem
of low quality of wordprocessor markup that this solution
exists at all.
You will have noticed that most of the solutions lead to
one place: SGML\index{SGML@SGML}\footnote{The Standard Generalized Markup
Language (SGML)\index{SGML@SGML|textbf}\index{Acronyms@\string\textbf{Acronyms}, defined!SGML@SGML|textbf} itself is little used now for new
projects, as the software support for its daughter
XML\index{XML@XML} is far greater, but there
are still hundreds of large document repositories in
SGML\index{SGML@SGML} still growing their collection by
adding documents.} or XML\index{XML@XML}. As explained
above and elsewhere, these formats are the only ones devised
so far capable of storing sufficient information in
machine-processable, publicly-accessible form to enable your
document to be recreated in multiple output formats. Once
your document is in XML\index{XML@XML}, there is a
large range of software available to turn it into other
formats, including \LaTeX{}. Processors in any of the common
SGML\index{SGML@SGML}/XML\index{XML@XML}
processing languages like the Document
Style Semantics and Specification Language (DSSSL)\index{DSSSL@DSSSL|textbf}\index{Acronyms@\textbf{Acronyms}, defined!DSSSL@DSSSL|textbf}, the
Extensible Stylesheet Language
[Transformations] (XSLT)\index{XSLT@XSLT|textbf}\index{Acronyms@\textbf{Acronyms}, defined!XSLT@XSLT|textbf},
\product{Omnimark},
\product{Metamorphosis},
\product{Balise}, etc. can easily be written
to output \LaTeX{}, and this approach is extremely
common.
Much of this will be simplified when wordprocessors
support native, arbitrary XML\index{XML@XML}/XSLT\index{XSLT@XSLT} as a
standard feature, because \LaTeX{} output will become much
simpler to produce.
\begin{itemize}
\item
Sun's \product{Star Office} and
its Open Source sister,
\product{OpenOffice}, have used XML as
their native file format for several years, and there is a
project at the Organisation for the
Advancement of Structured Information Systems (OASIS)\index{OASIS@OASIS|textbf}\index{Acronyms@\textbf{Acronyms}, defined!OASIS@OASIS|textbf}
for developing a common XML\index{XML@XML}
office file format based on those used by these two
packages, which has been proposed to the International Organization for
Standardization (ISO)\index{ISO@ISO|textbf}\index{Acronyms@\textbf{Acronyms}, defined!ISO@ISO|textbf} in Geneva as a candidate for
an International Standard.
\item
\product{WordPerfect} has also had a
native SGML\index{SGML@SGML} (and now XML\index{XML@XML}) editor for many years, which will
work with any Document Type
Definition (DTD)\index{DTD@DTD|textbf}\index{Acronyms@\textbf{Acronyms}, defined!DTD@DTD|textbf} (but not a Schema; and at the time
of writing (2005) it still used a proprietary stylesheet
format).
\item
Microsoft has had a half-hearted `Save
As\dots XML' for a while, using an
internal and formerly largely undocumented Schema (recently
published at last). The
`Professional' versions of
\product{Word} and
\product{Excel} in
\product{Office 11} (Office 2003 for
XP) now have full support for arbitrary Schemas and a real
XML\index{XML@XML} editor, albeit with a rather
primitive interface, but there is no conversion to or from
\product{Word}'s
\url+.doc+ format.\footnote{Which is silly, given that Microsoft used to make
one of the best
\product{Word}-to-SGML\index{SGML@SGML} converters ever, which was
bi-directional (yes, it could round-trip
\product{Word} to SGML\index{SGML@SGML} and back to
\product{Word} and back into SGML\index{SGML@SGML}). But they dropped it on the
floor when XML\index{XML@XML}
arrived.}
However, help comes in the shape of \person{Ruggero Dambra's
} \product{WordML2\LaTeX{}},
which is an XSLT\index{XSLT@XSLT} stylesheet to
transform an XML\index{XML@XML} document in
this internal Schema (WordML) into \LaTeXe{} format.
Download it from
any CTAN\index{CTAN@CTAN} server in
\url+/support/WordML2LaTeX+.
\item\label{rtf2latex2e}
Among the conversion programs on CTAN\index{CTAN@CTAN} is \person{Ujwal Sath\-yam}'s \product{rtf2latex2e},
which converts Rich Text
Format (RTF)\index{RTF@RTF|textbf}\index{Acronyms@\textbf{Acronyms}, defined!RTF@RTF|textbf} files (output by many wordprocessors)
to \LaTeXe{}. The package
description says it has support for figures and tables,
equations are read as figures, and it can the handle the
latest RTF\index{RTF@RTF} versions from
Microsoft Word 97/98/2000, StarOffice, and other
wordprocessors. It runs on Macs, Linux, other Unix
systems, and Windows.
\end{itemize}
When these efforts coalesce into generalised support for
arbitrary DTD\index{DTD@DTD}s and Schemas, it will
mean a wider choice of editing interfaces, and when they
achieve the ability to run XSLT\index{XSLT@XSLT}
conversion into
\LaTeX{} from within these editors, such as is done at the
moment with \product{Emacs} or
\product{XML Spy}, we will have full
convertability.
\subsection{Getting \LaTeX{} out of XML}
Assuming you can get your document out of its
wordprocessor format into XML\index{XML@XML} by
some method, here is a very brief example of how to turn it
into \LaTeX{}.
You can of course buy and install a fully-fledged
commercial XML\index{XML@XML} editor with
XSLT\index{XSLT@XSLT} support, and run this
application within it. However, this is beyond the reach of
many users, so to do this unaided you just need to install
three pieces of software: \product{Java}\footnote{\url+http://java.sun.com/j2se/1.4.2/download.html+},
\product{Saxon}\footnote{\url+http://saxon.sourceforge.net/+}
and the DocBook
4.2 DTD\footnote{\url+http://www.docbook.org/xml/4.2/index.html+} (URI\index{URI@URI}s are
correct at the time of writing). None of these has a visual
interface: they are run from the command-line in the same
way as is possible with \LaTeX{}.
As an example, let's take the above paragraph, as typed
or imported into \product{AbiWord} (see
Figure~\ref{abidoc}). This is stored as a single
paragraph with highlighting on the product names (italics),
and the names are also links to their Internet sources, just
as they are in this document. This is a convenient way to
store two pieces of information in the same place.
\begin{figure}\small
\caption{\small Sample paragraph in
\emph{AbiWord} converted to XML\index{XML@XML}}
\label{abidoc}
\begin{center}
\includegraphics[width=1\textwidth]{abiword}
\end{center}
\end{figure}
\product{AbiWord} can export in DocBook
format, which is an XML\index{XML@XML} vocabulary
for describing technical (computer) documents\ndash{}it's
what I use for this book. \product{AbiWord}
can also export \LaTeX{}, but we're going make our own
version, working from the XML\index{XML@XML}
(Brownie points for the reader who can guess why I'm not
just accepting the \LaTeX{} conversion output).
Although \product{AbiWord}'s default is
to output an XML\index{XML@XML} \texttt{book} document
type, we'll convert it to a \LaTeX{} article document class.
Notice that \product{AbiWord} has correctly
output the expected section and title markup empty, even
though it's not used. Here's the XML\index{XML@XML} output (I've changed the linebreaks
to keep it within the bounds of this page size):
\begin{sourcecode}\begin{Verbatim}[fontsize=\tiny]
<!DOCTYPE book PUBLIC "-//OASIS//DTD DocBook XML V4.2//EN"
"http://www.oasis-open.org/docbook/xml/4.2/docbookx.dtd">
<book>
<!-- ===================================================================== -->
<!-- This DocBook file was created by AbiWord. -->
<!-- AbiWord is a free, Open Source word processor. -->
<!-- You may obtain more information about AbiWord at www.abisource.com -->
<!-- ===================================================================== -->
<chapter>
<title></title>
<section role="unnumbered">
<title></title>
<para>You can of course buy and install a fully-fledged commercial XML
editor with XSLT support, and run this application within it. However, this
is beyond the reach of many users, so to do this unaided you just need to
install three pieces of software: <ulink
url="http://java.sun.com/j2se/1.4.2/download.html"><emphasis>Java</emphasis></ulink>,
<ulink
url="http://saxon.sourceforge.net"><emphasis>Saxon</emphasis></ulink>, and
the <ulink url="http://www.docbook.org/xml/4.2/index.html">DocBook 4.2 DTD</ulink>
(URIs are correct at the time of writing). None of these has a visual
interface: they are run from the command-line in the same way as is possible
with L<superscript>A</superscript>T<subscript>E</subscript>X.</para>
</section>
</chapter>
</book>
\end{Verbatim}
\end{sourcecode}
The XSLT\index{XSLT@XSLT} language lets us
create templates for each type of element in an XML\index{XML@XML} document. In our example, there are
only three which need handling, as we did not create chapter
or section titles (DocBook requires them to be present, but
they don't have to be used).
\begin{itemize}
\item
\texttt{para}, for the
paragraph[s];
\item
\texttt{ulink}, for the URIs;
\item
\texttt{emphasis}, for the
italicisation.
\end{itemize}
I'm going to cheat over the superscripting and
subscripting of the letters in the \LaTeX{} logo, and use my
editor to replace the whole thing with the
\command{LaTeX} command. In the other three cases,
we already know how \LaTeX{} deals with these, so we can
write our templates (see Figure~\ref{xslcode}).
\begin{figure}\small
\caption{\small XSLT\index{XSLT@XSLT} script to convert the
paragraph}
\label{xslcode}
\begin{sourcecode}\begin{Verbatim}[fontsize=\footnotesize]
<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="1.0">
<xsl:output method="text"/>
<xsl:template match="/">
<xsl:text>\documentclass{article}
\usepackage{url}</xsl:text>
<xsl:apply-templates/>
</xsl:template>
<xsl:template match="book">
<xsl:text>\begin{document}</xsl:text>
<xsl:apply-templates/>
<xsl:text>\end{document}</xsl:text>
</xsl:template>
<xsl:template match="para">
<xsl:apply-templates/>
<xsl:text>
</xsl:text>
</xsl:template>
<xsl:template match="ulink">
<xsl:apply-templates/>
<xsl:text>\footnote{\url{</xsl:text>
<xsl:value-of select="@url"/>
<xsl:text>}}</xsl:text>
</xsl:template>
<xsl:template match="emphasis">
<xsl:text>\emph{</xsl:text>
<xsl:apply-templates/>
<xsl:text>}</xsl:text>
</xsl:template>
</xsl:stylesheet>
\end{Verbatim}
\end{sourcecode}
\end{figure}
If you run this through
\product{Saxon}, which is an XSLT\index{XSLT@XSLT} processor, you can output a \LaTeX{}
file which you can process and view (see Figure~\ref{paraview}).
\begin{sourcecode}\begin{Verbatim}[fontsize=\scriptsize]
$ java -jar /usr/local/saxonb8-0/saxon8.jar -o para.ltx \
para.dbk para.xsl
$ latex para.ltx
This is TeX, Version 3.14159 (Web2C 7.3.7x)
(./para.ltx
LaTeX2e <2001/06/01>
Loading CZ hyphenation patterns: Pavel Sevecek, v3, 1995
Loading SK hyphenation patterns: Jana Chlebikova, 1992
Babel <v3.7h> and hyphenation patterns for english,
dumylang, nohyphenation, czech, slovak, german, ngerman,
danish, spanish, catalan, finnish, french, ukenglish, greek,
croatian, hungarian, italian, latin, mongolian, dutch,
norwegian, polish, portuguese, russian, ukrainian,
serbocroat, swedish, loaded.
(/usr/TeX/texmf/tex/latex/base/article.cls
Document Class: article 2001/04/21 v1.4e Standard LaTeX
document class (/usr/TeX/texmf/tex/latex/base/size10.clo))
(/usr/TeX/texmf/tex/latex/ltxmisc/url.sty) (./para.aux)
[1] (./para.aux) )
Output written on para.dvi (1 page, 1252 bytes).
Transcript written on para.log.
$ xdvi para &
\end{Verbatim}
\end{sourcecode}
\begin{figure}\small
\caption{\small Displaying the typeset paragraph}
\label{paraview}
\begin{center}
\includegraphics[width=0.6\textwidth]{para}
\end{center}
\begin{sourcecode}\begin{Verbatim}[fontsize=\scriptsize]
\documentclass{article}\usepackage{url}\begin{document}
You can of course buy and install a fully-fledged commercial
XML editor with XSLT support, and run this application within it.
However, this is beyond the reach of many users, so to do this
unaided you just need to install three pieces of software:
\emph{Java}\footnote{\url{http://java.sun.com/j2se/1.4.2/download.html}},
\emph{Saxon}\footnote{\url{http://saxon.sourceforge.net}}, and the
DocBook 4.2 DTD\footnote{\url{http://www.docbook.org/xml/4.2/index.html}}
(URIs are correct at the time of writing). None of these has a visual
interface: they are run from the command-line in the same way as is
possible with \LaTeX.
\end{document}
\end{Verbatim}
\end{sourcecode}
\end{figure}
Writing XSLT\index{XSLT@XSLT} is not hard, but
requires a little learning. The output method here is
\verb+text+, which is \LaTeX{}'s file format
(XSLT\index{XSLT@XSLT} can also output HTML\index{HTML@HTML} and other formats of XML).
\begin{enumerate}\item
The first template matches
`\verb+/+', which is
the document root (before the \texttt{book}
start-tag). At this stage we output the text
\verb+\documentclass{article}+ and
\verb+\usepackage{url}+. The
`\verb+apply-templates+'
instructions tells the processor to carry on processing,
looking for more matches. XML\index{XML@XML}
comments get ignored, and any elements which don't match
a template simply have their contents passed through
until the next match occurs.
\item
The \texttt{book} template outputs the
\verb+\begin{document}+ and the
\verb+\end{document}+ commands, and between
them to carry on processing.
\item
The \texttt{para} template just outputs
its content, but follows it with a linebreak (using the
hexadecimal character code \verb+x000A+ (see
the ASCII\index{ASCII@ASCII} chart in Table~\ref{asciicodes}).
\item
The \texttt{ulink} template outputs its
content but follows it with a footnote using the
\command{url} command to output the value of
the \texttt{url} attribute.
\item
The \texttt{emphasis} template surrounds
its content with \verb+\emph{+ and
\verb+}+.
\end{enumerate}
This is a relatively trivial example, but it serves to
show that it's not hard to output \LaTeX{} from XML\index{XML@XML}. In fact there is a set of templates
already written to produce \LaTeX{} from a DocBook file at
\url+http://www.dpawson.co.uk/docbook/tools.html#d4e2905+
\section{Converting out of \LaTeX{}}
\label{latexto}
This is much harder to do comprehensively. As noted
earlier, the \LaTeX{} file format really requires the \LaTeX{}
program itself in order to process all the packages and
macros, because there is no telling what complexities authors
have added themselves (what a lot of this book is
about!).
Many authors and editors rely on custom-designed or
homebrew converters, often written in the standard shell
scripting languages (Unix shells, Perl, Python, Tcl, etc).
Although some of the packages presented here are also written
in the same languages, they have some advantages and
restrictions compared with private conversions:
\begin{itemize}
\item
Conversion done with the standard utilities (eg awk,
tr, sed, grep, detex, etc) can be faster for
\emph{ad hoc} translations, but it
is easier to obtain consistency and a more sophisticated
final product using
\LaTeX{}2HTML\index{HTML@HTML} or
\TeX{}4ht\mdash{}or one of the other systems
available.
\item
Embedding additional non-standard control sequences in
\LaTeX{} source code may make it harder to edit and
maintain, and will definitely make it harder to port to
another system.
\item
Both the above methods (and others) provide a fast and
reasonable reliable way to get documents authored in
\LaTeX{} onto the Web in an acceptable\mdash{}if not
optimal\mdash{}format.
\item
\LaTeX{}2HTML\index{HTML@HTML} was written to
solve the problem of getting \LaTeX{}-with-mathematics
onto the Web, in the
days before MathML and math-capable browsers.
\TeX{}4ht was written to turn \LaTeX{} documents into Web
hypertext\mdash{}mathematics or not.
\end{itemize}
\subsection{Conversion to \emph{Word}}
There are several programs on CTAN\index{CTAN@CTAN} to do
\LaTeX{}-to-\product{Word} and similar
conversions, but they do not all handles everything \LaTeX{}
can throw at them, and some only handle a subset of the
built-in commands of default
\LaTeX{}. Two in particular, however, have a good
reputation, although I haven't used either of them (I stay
as far away from \product{Word} as
possible):
\begin{itemize}
\item
\product{latex2rtf} by \person{Wilfried Hennings}, \person{Fernando Dorner}, and \person{Andreas Granzer} translates
\LaTeX{} into RTF\index{RTF@RTF}\mdash{}the
opposite of the \product{rtf2latex2e}
mentioned in item~\ref{rtf2latex2e}the list on p.\thinspace\pageref{rtf2latex2e}. RTF\index{RTF@RTF} can be read by most
wordprocessors, and this program preserves layout and
formatting for most \LaTeX{} documents using standard
built-in commands.
\item
\person{Kirill Chikrii}'s \product[tex2word]{\TeX{}2Word} for
Microsoft Windows is a converter plug-in for
\product{Word} to let it open \TeX{}
and \LaTeX{} documents. The author's company claims that
`virtually any existing \TeX{}/\LaTeX{} package
can be supported by \product[tex2word]{\TeX{}2Word}'
because it is customisable.
\end{itemize}
One easy route into wordprocessing, however, is the
reverse of the procedures suggested in the preceding
section: convert \LaTeX{} to HTML\index{HTML@HTML},
which many wordprocessors read easily. The following
sections cover two packages for this.
\subsection{\emph{\LaTeX{}2HTML}}
As its name suggests, \LaTeX{}2HTML\index{HTML@HTML} is a system to convert \LaTeX{}
structured documents to HTML\index{HTML@HTML}. Its main task is to reproduce the
document structure as a set of interconnected HTML\index{HTML@HTML} files. Despite using Perl,
\LaTeX{}2HTML\index{HTML@HTML} relies very heavily
on standard Unix facilities like the
\product{NetPBM} graphics package and the
pipe syntax. Microsoft Windows is not well suited to this
kind of composite processing, although all the required
facilities are available for download in various forms and
should in theory allow the package to run\mdash{}but reports
of problems are common.
\begin{itemize}
\item
The sectional structure is preserved, and
navigational links are generated for the standard Next,
Previous, and Up directions.
\item
Links are also used for the cross-references,
citations, footnotes, ToC, and lists of figures and
tables.
\item
Conversion is direct for common elements like lists,
quotes, paragraph-breaks, type-styles, etc, where there
is an obvious HTML\index{HTML@HTML}
equivalent.
\item
Heavily formatted objects such as math and diagrams
are converted to images.
\item
There is no support for homebrew macros.
\end{itemize}
There is, however, support for arbitrary hypertext
links, symbolic cross-references between `evolving
remote documents', conditional text, and the
inclusion of raw HTML\index{HTML@HTML}. These are
extensions to
\LaTeX{}, implemented as new commands and
environments.
\LaTeX{}2HTML\index{HTML@HTML} outputs a
directory named after the input filename, and all the output
files are put in that directory, so the output is
self-contained and can be uploaded to a server as it
stands.
\subsection{\emph{\TeX{}4ht}}
\TeX{}4ht operates differently from
\LaTeX{}2HTML\index{HTML@HTML}: it uses the \TeX{}
program to process the file, and handles conversion in a set
of postprocessors for the common \LaTeX{} packages. It can
also output to XML\index{XML@XML}, including Text Encoding
Initiative (TEI)\index{TEI@TEI|textbf}\index{Acronyms@\textbf{Acronyms}, defined!TEI@TEI|textbf} and DocBook, and the OpenOffice and
WordXML formats, and it can create \TeX{}info format
manuals.
By default, documents retain the single-file structure
implied by the original, but there is again a set of
additional configuration directives to make use of the
features of hypertext and navigation, and to split files for
ease of use.
\subsection{Extraction from PS and PDF}
If you have the full version of Adobe
\product{Acrobat}, you can open a PDF\index{PDF@PDF} file created by
\product{pdf\LaTeX{}}, select and copy all the
text, and paste it into \product{Word} and
some other wordprocessors, and retain some common formatting
of headings, paragraphs, and lists. Both solutions still
require the wordprocessor text to be edited into shape, but
they preserve enough of the formatting to make it worthwhile
for short documents. Otherwise, use the
\product{pdftotext} program to extract
everything from the PDF\index{PDF@PDF} file as
plain (paragraph-formatted) text.
\subsection{Last resort: strip the markup}
At worst, the \product{detex} program
on CTAN\index{CTAN@CTAN} will strip a \LaTeX{} file
of all markup and leave just the raw unformatted text, which
can then be re-edited. There are also programs to extract
the raw text from DVI\index{DVI@DVI} and PostScript (PS)\index{PS@PS|textbf}\index{Acronyms@\textbf{Acronyms}, defined!PS@PS|textbf} files.
\appendix
\chapter{Configuring \TeX{} search paths}
\label{cnf}
\TeX{} systems run on a huge variety of platforms, and are
typically made up of a large number of rather small files. Some
computer operating systems have problems with packages like
this, as their built-in methods for searching for a file when
needed are poor.
To get around this, \TeX{} uses a technique borrowed from the
Unix world, based on a simple hash index for each directory they
need to look in. This is known as the ls-R database, from the
Unix command (\verb+ls -R+) which creates it. The
program which does this for \TeX{} is actually called after this
command: \product{mktexlsr}, although it may be
renamed \product{texhash} or something else on
your system. This is the program referred to in step~\ref{texindex} in the procedure on p.\thinspace\pageref{texindex}.
However, to know where to make these indexes, and thus where
to search, \TeX{} needs to be told about them. In a standard
\TeX{} installation this information is in
\url+texmf/web2c/texmf.cnf+. The file is similar
to a Unix shell script, but the only lines of significance for
the search paths are the following (this is how they appear in
the default Unix installation, omitting the comments):
\begin{sourcecode}\begin{Verbatim}[fontsize=\small]
TEXMFMAIN = /usr/TeX/texmf
TEXMFLOCAL = /usr/TeX/texmf-local
HOMETEXMF = $HOME/texmf
TEXMF = {$HOMETEXMF,!!$TEXMFLOCAL,!!$TEXMFMAIN}
SYSTEXMF = $TEXMF
VARTEXFONTS = /var/lib/texmf
TEXMFDBS = $TEXMF;$VARTEXFONTS
\end{Verbatim}
\end{sourcecode}
As you can see, this defines where the main \TeX{}/\mf{}
directory is, where the local one is, and where the user's
personal (home) one is. It then defines the order in which they
are searched, and makes this the system-wide list. A temporary
directory for bitmap fonts is set up, and added to the list,
defining the places in which \product{texhash}
or \product{mktexlsr} creates its
databases.
In some installations, the local directory is set up in
\url+/usr/local/share/texmf+ or
\url+/usr/share/texmf.local+ or similar
variations, so you would substitute this name for
\url+/usr/TeX/texmf-local+. Under Microsoft
Windows, the names will be full paths such as
\url+C:\Program Files\TeXLive\texmf+. On an Apple
Mac, it might be \url+Hard
Disk:TeX:texmf+.
If you edit plain-text configuration files with anything
other than a plain-text editor (e.g. a wordprocessor), or
if you edit them with a plain-text editor which has been set to
word-wrap long lines, make sure you turn line-wrapping
\emph{off} so that any long lines are preserved in
their correct format.
\chapter{\TeX{} Users Group membership}
\label{tugform}
The \TeX{} Users Group (TUG)\index{TUG@TUG|textbf}\index{Acronyms@\textbf{Acronyms}, defined!TUG@TUG|textbf} was
founded in 1980 for educational and scientific purposes: to
provide an organization for those who have an interest in
typography and font design, and are users of the \TeX{}
typesetting system invented by Donald Knuth.
TUG is run by and for its members and represents the interests
of \TeX{} users worldwide.
\subsection*{TUG membership benefits}\addcontentsline{toc}{subsection}{TUG membership benefits}
Members of TUG help to support and promote the use of
\TeX{}, \mf{}, and related systems worldwide. All members
receive \titlecite{tugboat},
the journal of the \TeX{} Users Group, the \TeX{} Live software
distribution (a runnable \TeX{} system), and the CTAN\index{CTAN@CTAN} software distribution (containing most
of the CTAN\index{CTAN@CTAN} archive).
In addition, TUG members vote in TUG elections, and
receive discounts on annual meeting fees, store purchases, and
TUG-sponsored courses. TUG membership (less benefits) is
tax-deductible, at least in the USA. See the TUG Web site for
details.
\subsection*{Becoming a TUG member}\addcontentsline{toc}{subsection}{Becoming a TUG member}
Please see the forms and information at \url+http://tug.org/join.html+. You can join
online, or by filling out a paper form. The NTG (Dutch) and
UKTUG (United Kingdom) \TeX{} user groups have joint membership
agreements with TUG whereby you can receive a discount for
joining both user groups. To do this, please join via \url+http://www.ntg.nl/newmember.html+ (the NTG
membership page) or \url+http://uk.tug.org/Membership/+ (the UKTUG
page), respectively, and select the option for joint
membership.
Each year's membership entitles you to the software and
TUGboat produced for that year (even if it is produced in a
subsequent calendar year, as is currently the case with
TUGboat). You can order older issues of TUGboat and \TeX{}
memorabilia through the TUG store (\url+http://tug.org/store+).
The current TUG membership fee is \$65 (US) per year
for individuals and \$35 for students and seniors. Add
\$10 to the membership fee after May 31 to cover
additional shipping and processing costs. The current rate for
non-voting subscription memberships (for libraries, for
example) is \$85. The current institutional rate is
\$500, which includes up to seven individual
memberships.
\subsection*{Privacy}\addcontentsline{toc}{subsection}{Privacy}
TUG uses your personal information only to mail you
products, publications, notices, and (for voting members)
official ballots. Also, if you give explicit agreement, we may
incorporate it into a membership directory which will be made
available only to TUG members.
TUG neither sells its membership list nor provides it to
anyone outside of its own membership.
\chapter{The ASCII character set}
\label{asciicharset}
The American Standard Code for Information Interchange was
invented in 1963, and after some redevelopment settled down in
1984 as standard X3.4 of American National
Standards Institute (ANSI)\index{ANSI@ANSI|textbf}\index{Acronyms@\textbf{Acronyms}, defined!ANSI@ANSI|textbf}. It represents the 95 basic
codes for the unaccented printable characters and punctuation of
the Latin alphabet, plus 33 internal `control
characters' originally intended for the control of
computers, programs, and external devices like printers and
screens.
Many other character sets (strictly speaking,
`character repertoires') have been standardised for
accented Latin characters and for all other non-Latin writing
systems, but these are intended for representing the symbols
people use when writing text on computers. Most programs and
computers use ASCII\index{ASCII@ASCII} internally for all
their coding, the exceptions being XML\index{XML@XML}-based languages like XSLT\index{XSLT@XSLT}, which are inherently designed to be
usable with any writing system, and a few specialist systems
like APL.
Although the \TeX{} and \LaTeX{} file formats can easily be
used with many other encoding systems (see the discussion of the
\package{inputenc} in \S\thinspace\ref{accents}), they are based on ASCII\index{ASCII@ASCII}. It is therefore important to know
where to find \emph{all} 95 of the printable
characters, as some of them are not often used in other
text-formatting systems. The following table shows all 128
characters, with their decimal, octal (base-8), and hexadecimal
(base-16) code numbers.
\begin{table}\small \caption{\small The ASCII characters}
\label{asciicodes}
\begin{center}
\setlength{\tabcolsep}{1mm}
\begin{tabular}{@{}>{$}r<{$\enspace}>{\ttfamily}>{\pbs{\centering}}p{1cm}>{\ttfamily}>{\pbs{\centering}}p{1cm}>{\ttfamily}>{\pbs{\centering}}p{1cm}>{\ttfamily}>{\pbs{\centering}}p{1cm}>{\ttfamily}>{\pbs{\centering}}p{1cm}>{\ttfamily}>{\pbs{\centering}}p{1cm}>{\ttfamily}>{\pbs{\centering}}p{1cm}>{\ttfamily}>{\pbs{\centering}}p{1cm}>{\enspace$}l<{$}@{}}
\mbox{\textbf{\sffamily\upshape Oct}}&\textbf{\sffamily\upshape 0}&\textbf{\sffamily\upshape 1}&\textbf{\sffamily\upshape 2}&\textbf{\sffamily\upshape 3}&\textbf{\sffamily\upshape 4}&\textbf{\sffamily\upshape 5}&\textbf{\sffamily\upshape 6}&\textbf{\sffamily\upshape 7}&\mbox{\textbf{\sffamily\upshape Hex}}\\[2pt]\hline\\[-1.5\baselineskip]
'00\UParrow&NUL&SOH&STX&ETX&EOT&ENQ&ACK&BEL&''0\UParrow\\[1mm]
'01\UParrow&BS&HT&LF&VT&FF&CR&SO&SI&''0\DOWNarrow\\[1mm]
'02\UParrow&DLE&DC1&DC2&DC3&DC4&NAK&SYN&ETB&''1\UParrow\\[1mm]
'03\UParrow&CAN&EM&SUB&ESC&FS&GS&RS&US&''1\DOWNarrow\\[1mm]
'04\UParrow&&!&"&\#&\$&\%&\amp &'&''2\UParrow\\[1mm]
'05\UParrow&(&)&*&+&,&-&.&/&''2\DOWNarrow\\[1mm]
'06\UParrow&0&1&2&3&4&5&6&7&''3\UParrow\\[1mm]
'07\UParrow&8&9&:&;&$<$&=&$>$&?&''3\DOWNarrow\\[1mm]
'10\UParrow&@&A&B&C&D&E&F&G&''4\UParrow\\[1mm]
'11\UParrow&H&I&J&K&L&M&N&O&''4\DOWNarrow\\[1mm]
'12\UParrow&P&Q&R&S&T&U&V&W&''5\UParrow\\[1mm]
'13\UParrow&X&Y&Z&[&$\backslash$&]&{\char'136}&{\ttfamily\char'137}&''5\DOWNarrow\\[1mm]
'14\UParrow&\`{}&a&b&c&d&e&f&g&''6\UParrow\\[1mm]
'15\UParrow&h&i&j&k&l&m&n&o&''6\DOWNarrow\\[1mm]
'16\UParrow&p&q&r&s&t&u&v&w&''7\UParrow\\[1mm]
'17\UParrow&x&y&z&{\ttfamily\char'173}&$|$&{\ttfamily\char'175}&{\char'176}&DEL&''7\DOWNarrow\\[1mm]
\\[-1em]\hline\vrule height1.2em width0pt \textbf{}&\textbf{8}&\textbf{9}&\textbf{A}&\textbf{B}&\textbf{C}&\textbf{D}&\textbf{E}&\textbf{F}&\textbf{}\\[1mm]
\end{tabular}
\end{center}
\end{table}
The index numbers in the first and last columns are for
finding the octal (base-8) and hexadecimal (base-16) values
respectively. Replace the arrow with the number or letter from
the top of the column (if the arrow points up) from the bottom
of the column(if the arrow points down).
Example: The Escape character (ESC) is octal '033 (03 for
the row, 3 for the number at the top of the column because the
arrow points up) or hexadecimal "1B (1 for the row, B for the
letter at the bottom of the column because the arrow points
down).
For the decimal value, multiply the Octal row number by
eight and add the column number from the top line (that makes
ESC 27).
\chapter[GNU Free Documentation License]{GNU Free Documentation License\\\LARGE\itshape Version 1.2, November 2002}
\label{gfdl}
\begin{multicols}{2}\small\gfdl
\begin{quotation}\small\begingroup
Copyright (C) 2000,2001,2002 Free Software Foundation,
Inc. 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not
allowed.
\par\endgroup\smallskip\footnotesize\noindent \end{quotation}
\setcounter{section}{-1}
\section{PREAMBLE}
\label{gfdl-0}
The purpose of this License is to make a manual, textbook,
or other functional and useful document `free' in
the sense of freedom: to assure everyone the effective freedom
to copy and redistribute it, with or without modifying it,
either commercially or noncommercially. Secondarily, this
License preserves for the author and publisher a way to get
credit for their work, while not being considered responsible
for modifications made by others.
This License is a kind of `copyleft', which
means that derivative works of the document must themselves be
free in the same sense. It complements the GNU General Public
License, which is a copyleft license designed for free
software.
We have designed this License in order to use it for
manuals for free software, because free software needs free
documentation: a free program should come with manuals
providing the same freedoms that the software does. But this
License is not limited to software manuals; it can be used for
any textual work, regardless of subject matter or whether it
is published as a printed book. We recommend this License
principally for works whose purpose is instruction or
reference.
\section{APPLICABILITY AND DEFINITIONS}
\label{gfdl-1}
\label{gfdl-doc}%
This License applies to any manual or other
work, in any medium, that contains a notice placed by the
copyright holder saying it can be distributed under the terms
of this License. Such a notice grants a world-wide,
royalty-free license, unlimited in duration, to use that work
under the conditions stated herein. The
`Document', below, refers to any such manual or
work. Any member of the public is a licensee, and is
addressed as `you'. You accept the license if
you copy, modify or distribute the work in a way requiring
permission under copyright law.
\label{gfdl-mod-ver}%
A `Modified Version' of the
Document means any work containing the Document or a portion
of it, either copied verbatim, or with modifications and/or
translated into another language.
\label{gfdl-secnd-sect}%
A `Secondary Section' is
a named appendix or a front-matter section of the Document
that deals exclusively with the relationship of the publishers
or authors of the Document to the Document's overall
subject (or to related matters) and contains nothing that
could fall directly within that overall subject. (Thus, if
the Document is in part a textbook of mathematics, a Secondary
Section may not explain any mathematics.) The relationship
could be a matter of historical connection with the subject or
with related matters, or of legal, commercial, philosophical,
ethical or political position regarding them.
\label{gfdl-inv-sect}%
The `Invariant Sections'
are certain Secondary Sections whose titles are designated, as
being those of Invariant Sections, in the notice that says
that the Document is released under this License. If a
section does not fit the above definition of Secondary then it
is not allowed to be designated as Invariant. The Document
may contain zero Invariant Sections. If the Document does not
identify any Invariant Sections then there are none.
\label{gfdl-cov-text}%
The `Cover Texts' are
certain short passages of text that are listed, as Front-Cover
Texts or Back-Cover Texts, in the notice that says that the
Document is released under this License. A Front-Cover Text
may be at most 5 words, and a Back-Cover Text may be at most
25 words.
\label{gfdl-transparent}%
A `Transparent' copy of
the Document means a machine-readable copy, represented in a
format whose specification is available to the general public,
that is suitable for revising the document straightforwardly
with generic text editors or (for images composed of pixels)
generic paint programs or (for drawings) some widely available
drawing editor, and that is suitable for input to text
formatters or for automatic translation to a variety of
formats suitable for input to text formatters. A copy made in
an otherwise Transparent file format whose markup, or absence
of markup, has been arranged to thwart or discourage
subsequent modification by readers is not Transparent. An
image format is not Transparent if used for any substantial
amount of text. A copy that is not `Transparent'
is called `Opaque'.
Examples of suitable formats for Transparent copies
include plain ASCII without markup, Texinfo input format,
LaTeX input format, SGML or XML using a publicly available
DTD, and standard-conforming simple HTML\index{HTML@HTML},
PostScript\index{PostScript} or PDF designed for human
modification. Examples of transparent image formats include
PNG, XCF and JPG. Opaque formats include proprietary formats
that can be read and edited only by proprietary word
processors, SGML or XML for which the DTD and/or processing
tools are not generally available, and the machine-generated
HTML\index{HTML@HTML}, PostScript\index{PostScript} or PDF produced by
some word processors for output purposes only.
\label{gfdl-title-page}%
The `Title Page' means,
for a printed book, the title page itself, plus such following
pages as are needed to hold, legibly, the material this
License requires to appear in the title page. For works in
formats which do not have any title page as such, `Title
Page' means the text near the most prominent
appearance of the work's title, preceding the beginning
of the body of the text.
\label{gfdl-entitled}%
A section `Entitled XYZ'
means a named subunit of the Document whose title either is
precisely XYZ or contains XYZ in parentheses following text
that translates XYZ in another language. (Here XYZ stands for
a specific section name mentioned below, such as
`Acknowledgements', `Dedications',
`Endorsements', or `History'.) To
`Preserve the Title' of such a section when you
modify the Document means that it remains a section
`Entitled XYZ' according to this
definition.
The Document may include Warranty Disclaimers next to the
notice which states that this License applies to the Document.
These Warranty Disclaimers are considered to be included by
reference in this License, but only as regards disclaiming
warranties: any other implication that these Warranty
Disclaimers may have is void and has no effect on the meaning
of this License.
\section{VERBATIM COPYING}
\label{gfdl-2}
You may copy and distribute the Document in any medium,
either commercially or noncommercially, provided that this
License, the copyright notices, and the license notice saying
this License applies to the Document are reproduced in all
copies, and that you add no other conditions whatsoever to
those of this License. You may not use technical measures to
obstruct or control the reading or further copying of the
copies you make or distribute. However, you may accept
compensation in exchange for copies. If you distribute a
large enough number of copies you must also follow the
conditions in section 3.
You may also lend copies, under the same conditions stated
above, and you may publicly display copies.
\section{COPYING IN QUANTITY}
\label{gfdl-3}
If you publish printed copies (or copies in media that
commonly have printed covers) of the Document, numbering more
than 100, and the Document's license notice requires
Cover Texts, you must enclose the copies in covers that carry,
clearly and legibly, all these Cover Texts: Front-Cover Texts
on the front cover, and Back-Cover Texts on the back cover.
Both covers must also clearly and legibly identify you as the
publisher of these copies. The front cover must present the
full title with all words of the title equally prominent and
visible. You may add other material on the covers in
addition. Copying with changes limited to the covers, as long
as they preserve the title of the Document and satisfy these
conditions, can be treated as verbatim copying in other
respects.
If the required texts for either cover are too voluminous
to fit legibly, you should put the first ones listed (as many
as fit reasonably) on the actual cover, and continue the rest
onto adjacent pages.
If you publish or distribute Opaque copies of the Document
numbering more than 100, you must either include a
machine-readable Transparent copy along with each Opaque copy,
or state in or with each Opaque copy a computer-network
location from which the general network-using public has
access to download using public-standard network protocols a
complete Transparent copy of the Document, free of added
material. If you use the latter option, you must take
reasonably prudent steps, when you begin distribution of
Opaque copies in quantity, to ensure that this Transparent
copy will remain thus accessible at the stated location until
at least one year after the last time you distribute an Opaque
copy (directly or through your agents or retailers) of that
edition to the public.
It is requested, but not required, that you contact the
authors of the Document well before redistributing any large
number of copies, to give them a chance to provide you with an
updated version of the Document.
\section{MODIFICATIONS}
\label{gfdl-4}
You may copy and distribute a Modified Version of the
Document under the conditions of sections 2 and 3 above,
provided that you release the Modified Version under precisely
this License, with the Modified Version filling the role of
the Document, thus licensing distribution and modification of
the Modified Version to whoever possesses a copy of it. In
addition, you must do these things in the Modified
Version:
\begin{enumerate}\renewcommand{\theenumi}{\Alph{enumi}}\item Use in the Title Page (and on the covers,
if any) a title distinct from that of the Document, and
from those of previous versions (which should, if there
were any, be listed in the History section of the
Document). You may use the same title as a previous
version if the original publisher of that version gives
permission.
\item List on the Title Page, as authors, one or
more persons or entities responsible for authorship of the
modifications in the Modified Version, together with at
least five of the principal authors of the Document (all
of its principal authors, if it has fewer than five),
unless they release you from this requirement.
\item State on the Title page the name of the
publisher of the Modified Version, as the
publisher.
\item Preserve all the copyright notices of the
Document.
\item Add an appropriate copyright notice for
your modifications adjacent to the other copyright
notices.
\item Include, immediately after the copyright
notices, a license notice giving the public permission to
use the Modified Version under the terms of this License,
in the form shown in the Addendum (\S\thinspace\ref{gfdl-addendum}) below.
\item Preserve in that license notice the full
lists of Invariant Sections and required Cover Texts given
in the Document's license
notice.
\item Include an unaltered copy of this License.
\item Preserve the section Entitled
`History', Preserve its Title, and add to it
an item stating at least the title, year, new authors, and
publisher of the Modified Version as given on the Title
Page. If there is no section Entitled
`History' in the Document, create one stating
the title, year, authors, and publisher of the Document as
given on its Title Page, then add an item describing the
Modified Version as stated in the previous sentence.
\item Preserve the network location, if any,
given in the Document for public access to a Transparent
copy of the Document, and likewise the network locations
given in the Document for previous versions it was based
on. These may be placed in the `History'
section. You may omit a network location for a work that
was published at least four years before the Document
itself, or if the original publisher of the version it
refers to gives permission.
\item For any section Entitled
`Acknowledgements' or
`Dedications', Preserve the Title of the
section, and preserve in the section all the substance and
tone of each of the contributor acknowledgements and/or
dedications given therein.
\item Preserve all the Invariant Sections of the
Document, unaltered in their text and in their titles.
Section numbers or the equivalent are not considered part
of the section titles.
\item Delete any section Entitled
`Endorsements'. Such a section may not be
included in the Modified Version.
\item Do not retitle any existing section to be
Entitled `Endorsements' or to conflict in
title with any Invariant Section.
\item Preserve any Warranty Disclaimers.
\end{enumerate}
If the Modified Version includes new front-matter sections
or appendices that qualify as Secondary Sections and contain
no material copied from the Document, you may at your option
designate some or all of these sections as invariant. To do
this, add their titles to the list of Invariant Sections in
the Modified Version's license notice. These titles must
be distinct from any other section titles.
You may add a section Entitled
`Endorsements', provided it contains nothing but
endorsements of your Modified Version by various parties--for
example, statements of peer review or that the text has been
approved by an organization as the authoritative definition of
a standard.
You may add a passage of up to five words as a Front-Cover
Text, and a passage of up to 25 words as a Back-Cover Text, to
the end of the list of Cover Texts in the Modified Version.
Only one passage of Front-Cover Text and one of Back-Cover
Text may be added by (or through arrangements made by) any one
entity. If the Document already includes a cover text for the
same cover, previously added by you or by arrangement made by
the same entity you are acting on behalf of, you may not add
another; but you may replace the old one, on explicit
permission from the previous publisher that added the old
one.
The author(s) and publisher(s) of the Document do not by
this License give permission to use their names for publicity
for or to assert or imply endorsement of any Modified
Version.
\section{COMBINING DOCUMENTS}
\label{gfdl-5}
You may combine the Document with other documents released
under this License, under the terms defined in section 4 (\S\thinspace\ref{gfdl-4}) above for modified
versions, provided that you include in the combination all of
the Invariant Sections of all of the original documents,
unmodified, and list them all as Invariant Sections of your
combined work in its license notice, and that you preserve all
their Warranty Disclaimers.
The combined work need only contain one copy of this
License, and multiple identical Invariant Sections may be
replaced with a single copy. If there are multiple Invariant
Sections with the same name but different contents, make the
title of each such section unique by adding at the end of it,
in parentheses, the name of the original author or publisher
of that section if known, or else a unique number. Make the
same adjustment to the section titles in the list of Invariant
Sections in the license notice of the combined work.
In the combination, you must combine any sections Entitled
`History' in the various original documents,
forming one section Entitled `History'; likewise
combine any sections Entitled `Acknowledgements',
and any sections Entitled `Dedications'. You
must delete all sections Entitled
`Endorsements'.
\section{COLLECTIONS OF DOCUMENTS}
\label{gfdl-6}
You may make a collection consisting of the Document and
other documents released under this License, and replace the
individual copies of this License in the various documents
with a single copy that is included in the collection,
provided that you follow the rules of this License for
verbatim copying of each of the documents in all other
respects.
You may extract a single document from such a collection,
and distribute it individually under this License, provided
you insert a copy of this License into the extracted document,
and follow this License in all other respects regarding
verbatim copying of that document.
\section{AGGREGATION WITH INDEPENDENT
WORKS}
\label{gfdl-7}
A compilation of the Document or its derivatives with
other separate and independent documents or works, in or on a
volume of a storage or distribution medium, is called an
`aggregate' if the copyright resulting from the
compilation is not used to limit the legal rights of the
compilation's users beyond what the individual works
permit. When the Document is included an aggregate, this
License does not apply to the other works in the aggregate
which are not themselves derivative works of the
Document.
If the Cover Text requirement of section 3 is applicable
to these copies of the Document, then if the Document is less
than one half of the entire aggregate, the Document's
Cover Texts may be placed on covers that bracket the Document
within the aggregate, or the electronic equivalent of covers
if the Document is in electronic form. Otherwise they must
appear on printed covers that bracket the whole
aggregate.
\section{TRANSLATION}
\label{gfdl-8}
Translation is considered a kind of modification, so you
may distribute translations of the Document under the terms of
section 4. Replacing Invariant Sections with translations
requires special permission from their copyright holders, but
you may include translations of some or all Invariant Sections
in addition to the original versions of these Invariant
Sections. You may include a translation of this License, and
all the license notices in the Document, and any Warranty
Disclaimers, provided that you also include the original
English version of this License and the original versions of
those notices and disclaimers. In case of a disagreement
between the translation and the original version of this
License or a notice or disclaimer, the original version will
prevail.
If a section in the Document is Entitled
`Acknowledgements', `Dedications',
or `History', the requirement (section 4) to
Preserve its Title (section 1) will typically require changing
the actual title.
\section{TERMINATION}
\label{gfdl-9}
You may not copy, modify, sublicense, or distribute the
Document except as expressly provided for under this License.
Any other attempt to copy, modify, sublicense or distribute
the Document is void, and will automatically terminate your
rights under this License. However, parties who have received
copies, or rights, from you under this License will not have
their licenses terminated so long as such parties remain in
full compliance.
\section{FUTURE REVISIONS OF THIS
LICENSE}
\label{gfdl-10}
The Free Software Foundation may publish new, revised
versions of the GNU Free Documentation License from time to
time. Such new versions will be similar in spirit to the
present version, but may differ in detail to address new
problems or concerns. See
http://www.gnu.org/copyleft/.
Each version of the License is given a distinguishing
version number. If the Document specifies that a particular
numbered version of this License `or any later
version' applies to it, you have the option of
following the terms and conditions either of that specified
version or of any later version that has been published (not
as a draft) by the Free Software Foundation. If the Document
does not specify a version number of this License, you may
choose any version ever published (not as a draft) by the Free
Software Foundation.
\section{ADDENDUM: How to use this License
for your documents}
\label{gfdl-addendum}
To use this License in a document you have written,
include a copy of the License in the document and put the
following copyright and license notices just after the title
page:
\begin{quotation}\small\begingroup
Copyright (c) YEAR YOUR NAME. Permission is granted to
copy, distribute and/or modify this document under the terms
of the GNU Free Documentation License, Version 1.2 or any
later version published by the Free Software Foundation;
with no Invariant Sections, no Front-Cover Texts, and no
Back-Cover Texts. A copy of the license is included in the
section entitled `GNU Free Documentation
License'.
\par\endgroup\smallskip\footnotesize\noindent \end{quotation}
If you have Invariant Sections, Front-Cover Texts and
Back-Cover Texts, replace the
`with\dots Texts.' line with this:
\begin{quotation}\small\begingroup
with the Invariant Sections being LIST THEIR TITLES, with
the Front-Cover Texts being LIST, and with the Back-Cover
Texts being LIST.
\par\endgroup\smallskip\footnotesize\noindent \end{quotation}
If you have Invariant Sections without Cover Texts, or
some other combination of the three, merge those two
alternatives to suit the situation.
If your document contains nontrivial examples of program
code, we recommend releasing these examples in parallel under
your choice of free software license, such as the GNU General
Public License, to permit their use in free software.
\end{multicols}
\renewcommand{\bibname}{References}
\bibliography{beginlatex}
\bibliographystyle{jurabib}
\begin{VerbatimOut}{beginlatex.bib}
@book{mathguide,
juraauthor = {AMS},
author = {{}},
title = {{Short Math Guide for \LaTeX{}}},
juratitle = {Short Math Guide},
publisher = {AMS},
address = {Providence, RI},
url = {http://www.ams.org/tex/short-math-guide.html},
year = {2001},
comment = {Written by XSLT}
}
@techreport{fontname,
author = {Karl Berry},
title = {{Fontname: Filenames for \TeX{} fonts}},
url = {http://www.ctan.org/tex-archive/info/fontname/},
organisation = {\TeX{} Users Group},
address = {Portland, OR},
year = {June 2001},
comment = {Written by XSLT}
}
@book{bull,
author = {RJ Bull},
title = {{Accounting in Business}},
publisher = {Butterworths},
address = {London},
year = {1972},
isbn = {0-406-70651-4},
comment = {Written by XSLT}
}
@techreport{teiguide,
author = {Lou Burnard and Michael Sperberg-McQueen},
title = {{Guidelines for the Text Encoding Initiative}},
juratitle = {TEI Guidelines},
organisation = {OUP},
address = {Oxford},
year = {1995},
comment = {Written by XSLT}
}
@book{davy,
author = {William Davy},
title = {{A System of Divinity}},
publisher = {Published by the author},
address = {Lustleigh, Devon},
year = {1806},
comment = {Written by XSLT}
}
@techreport{gentle,
author = {Michael Doob},
title = {{A Gentle Introduction to \TeX{}: A Manual for Self-Study}},
juratitle = {Gentle Intro},
organisation = {\TeX{} Users Group},
address = {Portland, OR},
year = {2002},
url = {http://www.ctan.org/tex-archive/info/gentle/},
comment = {Written by XSLT}
}
@book{bovary,
author = {Gustave Flaubert},
title = {{Madame Bovary}},
address = {Paris},
year = {1857},
comment = {Written by XSLT}
}
@book{htmlbook,
author = {Peter Flynn},
title = {{The HTML Handbook}},
juratitle = {The HTML Handbook},
publisher = {International Thompson Computer
Press},
address = {London},
isbn = {1-85032-205-8},
year = {1995},
comment = {Written by XSLT}
}
@book{sgmltools,
author = {Peter Flynn},
title = {{Understanding SGML and XML Tools}},
juratitle = {SGML \amp XML Tools},
publisher = {Kluwer},
address = {Boston},
isbn = {0-7923-8169-6},
year = {1998},
comment = {Written by XSLT}
}
@book{fg,
author = {John Fothergill},
title = {{An Innkeeper's Diary}},
publisher = {Penguin},
address = {London},
edition = {3rd},
year = {1929},
comment = {Written by XSLT}
}
@book{companion,
author = {Frank Mittelbach and Michel Goossens and Johannes Braams and David Carlisle and Chris Rowley},
title = {{The \LaTeX{} Companion}},
juratitle = {Companion},
publisher = {Addison-Wesley/Pearson Education},
address = {Boston, MA},
edition = {2},
isbn = {0-201-36299-6},
year = {2004},
comment = {Written by XSLT}
}
@book{graphicscomp,
author = {Michel Goossens and Sebastian Rahtz and Frank Mittelbach},
title = {{The \LaTeX{} Graphics Companion}},
juratitle = {Graphics Companion},
publisher = {Addison-Wesley},
address = {Reading, MA},
isbn = {0-201-85469-4},
year = {1997},
comment = {Written by XSLT}
}
@book{webcomp,
author = {Michel Goossens and Sebastian Rahtz and Ross Moore and Bob Sutor},
title = {{The \LaTeX{} Web Companion}},
juratitle = {Web Companion},
publisher = {Addison-Wesley},
address = {Reading, MA},
isbn = {0-201-43311-7},
year = {1999},
comment = {Written by XSLT}
}
@article{goreham-ctt,
author = {Anthony Goreham},
title = {{Re: Installing a new font: PFM, PFB}},
juratitle = {Installing a new font},
journal = {\texttt{comp.text.tex}},
number = {m3r8qj42o3.fsf@micawber.queens.ox.ac.uk},
pages = {(all pages)},
year = {28 November 2001},
comment = {Written by XSLT}
}
@article{heller,
author = {Robert Heller},
title = {{New To \LaTeX{}\dots Unlearning Bad Habits}},
juratitle = {Bad habits},
journal = {\texttt{comp.text.tex}},
number = {MPG.18d82140d65ddc5898968c@news.earthlink.net},
pages = {(all pages)},
year = {11 March 2003},
comment = {Written by XSLT}
}
@techreport{fontinst,
author = {Alan Jeffrey and Rowland McDonnell},
title = {{Font installation software for \TeX{}}},
juratitle = {Fontinst},
url = {http://www.tex.ac.uk/tex-archive/fonts/utilities/fontinst/},
organisation = {\TeX{} Users Group},
year = {30 June 1998},
comment = {Written by XSLT}
}
@book{aocs,
author = {Donald Ervin Knuth},
title = {{The Art of Computer Programming}},
publisher = {Addison-Wesley},
address = {Reading, MA},
edition = {2nd},
volume = {1},
isbn = {0-201-89685-0},
year = {1980},
comment = {Written by XSLT}
}
@book{latexbook,
author = {Leslie Lamport},
title = {{\LaTeX{}: A Document Preparation System}},
publisher = {Addison-Wesley},
address = {Reading, MA},
isbn = {0-201-52983-1},
edition = {2nd},
year = {1994},
comment = {Written by XSLT}
}
@book{macnamara,
author = {Matthew {Mac Namara}},
title = {{La Textualisation de \emph{Madame
Bovary}}},
publisher = {Rodopi},
address = {Amsterdam},
year = {2003},
comment = {Written by XSLT}
}
@techreport{lshort,
author = {Tobias Oetiker and Hubert Partl and Irene Hyna and Elisabeth Schlegl},
title = {{The (Not So) Short Guide to \LaTeXe{}: \LaTeXe{} in 131 Minutes}},
juratitle = {Short Guide},
organisation = {\TeX{} Users Group},
url = {http://www.ctan.org/tex-archive/info/lshort/},
year = {2001},
edition = {3.2},
comment = {Written by XSLT}
}
@techreport{symbol-list,
author = {Scott Pakin},
title = {{A comprehensive list of symbols in \TeX{}}},
juratitle = {Symbol list},
organisation = {\TeX{} Users Group},
url = {http://www.ctan.org/tex-archive/info/symbols/comprehensive/},
year = {2002},
comment = {Written by XSLT}
}
@techreport{begin,
juraauthor = {TUG},
author = {{}},
title = {{Getting Started with \TeX{}, \LaTeX{}, and friends}},
juratitle = {Getting Started},
organisation = {\TeX{} Users Group},
address = {Portland, OR},
url = {http://www.tug.org/begin.html},
year = {November 2003},
comment = {Written by XSLT}
}
@techreport{imported,
author = {Keith Reckdahl},
title = {{Using imported graphics in \LaTeXe{}}},
juratitle = {Imported graphics},
organisation = {\TeX{} Users Group},
url = {http://www.ctan.org/tex-archive/info/epslatex.pdf/},
year = {1997},
edition = {2.0},
comment = {Written by XSLT}
}
@incollection{tain,
author = {{}},
title = {{Táin bó Cúailnge}},
pages = {55},
booktitle = {Leabhar na h-Uidhri},
publisher = {Royal Irish Academy},
address = {Dublin},
year = {1100},
comment = {Written by XSLT}
}
@article{varmints,
author = {Marjorie Kinnan Rawlings},
title = {{Varmints}},
journal = {Scribner's Magazine},
year = {1936},
comment = {Written by XSLT}
}
@book{ryder,
author = {John Ryder},
title = {{Printing for Pleasure}},
publisher = {Bodley Head},
address = {London},
isbn = {0-370-10443-9},
year = {1976},
comment = {Written by XSLT}
}
@techreport{xmlfaq,
author = {Peter Flynn},
title = {{The XML FAQ}},
organisation = {University College Cork},
address = {Cork, Ireland},
url = {http://www.ucc.ie/xml/},
year = {January 2005},
comment = {Written by XSLT}
}
@techreport{gnufdl,
juraauthor = {FSF},
author = {{}},
title = {{The GNU Free Documentation License}},
juratitle = {GNU FDL},
organisation = {Free Software Foundation},
address = {Boston, MA},
url = {http://www.fsf.org/copyleft/fdl.html},
year = {2003/02/10
23:42:49},
comment = {Written by XSLT}
}
@proceedings{tugboat,
editor = {Barbara Beeton},
title = {{TUGboat}},
publisher = {\TeX{} Users Group},
address = {Portland, OR},
issn = {0896-3207},
year = {Since 1980},
comment = {Written by XSLT}
}
@proceedings{practex,
author = {Lance Carnes and Karl Berry},
title = {{The Prac\TeX{} Journal}},
publisher = {\TeX{} Users Group},
address = {Portland, OR},
url = {http://www.tug.org/pracjourn/},
year = {2004},
comment = {Written by XSLT}
}
@proceedings{wired,
editor = {Chris Anderson},
title = {{WIRED}},
publisher = {Cond\'e Nast},
address = {San Francisco, CA},
issn = {1059-1028},
year = {1993--},
comment = {Written by XSLT}
}
@book{mathwrite,
author = {Donald E Knuth and Tracey Larrabee and Paul M Roberts},
title = {{Mathematical Writing}},
publisher = {Mathematical Association of America},
address = {Washington, DC},
series = {MAA Notes 14},
isbn = {0-88385-063-X},
year = {1989},
comment = {Written by XSLT}
}
\end{VerbatimOut}
\renewcommand{\indexname}{Index}
\clearpage\section*{\indexname}
The same fonts are used here as in the text of the book
(see the Introduction on p.\thinspace\pageref{symbols}) to distinguish between different
meanings:
\begingroup\small \begin{center}
\begin{tabular}{@{}ll@{}}
\textbf{\sffamily\upshape Notation}&\textbf{\sffamily\upshape Meaning}\\[2pt]\hline\\[-1.5\baselineskip]
CTAN\index{CTAN@CTAN}&Acronyms (small caps in some typefaces)\\
\command{command}&\LaTeX{} control sequences (monospace font)\\
{\fontseries{b}\fontshape{it}\selectfont{}term}&Defining instance of a specialist term (bold
italics)\\
\product{product}&program or product name (italics)\\
\env{environment}&\LaTeX{} environment (sans-serif bold)\\
\package{package}&\LaTeX{} package (sans-serif; all available from
CTAN\index{CTAN@CTAN})\\
\opt{options}, \counter{variables}&options and variables (oblique)\\
\end{tabular}
\end{center}
\endgroup
In the online version, the entries below are all hyperlinked to
their source: for clarity the stylesheet recommends retaining
the traditional blue colour but removing the underlining which
most browsers use to indicate a link.
Page numbers in {\fontseries{b}\selectfont{}bold type}
indicate the defining instance.
\par\parfillskip=0pt plus.5fil
\multicolsep=1.5pc\printindex
\end{document}
|