summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/doc/generic/FAQ-en/faqbody.tex
blob: 1b35a31499353d5765f42d7616b6cd47227641a6 (plain)
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
10426
10427
10428
10429
10430
10431
10432
10433
10434
10435
10436
10437
10438
10439
10440
10441
10442
10443
10444
10445
10446
10447
10448
10449
10450
10451
10452
10453
10454
10455
10456
10457
10458
10459
10460
10461
10462
10463
10464
10465
10466
10467
10468
10469
10470
10471
10472
10473
10474
10475
10476
10477
10478
10479
10480
10481
10482
10483
10484
10485
10486
10487
10488
10489
10490
10491
10492
10493
10494
10495
10496
10497
10498
10499
10500
10501
10502
10503
10504
10505
10506
10507
10508
10509
10510
10511
10512
10513
10514
10515
10516
10517
10518
10519
10520
10521
10522
10523
10524
10525
10526
10527
10528
10529
10530
10531
10532
10533
10534
10535
10536
10537
10538
10539
10540
10541
10542
10543
10544
10545
10546
10547
10548
10549
10550
10551
10552
10553
10554
10555
10556
10557
10558
10559
10560
10561
10562
10563
10564
10565
10566
10567
10568
10569
10570
10571
10572
10573
10574
10575
10576
10577
10578
10579
10580
10581
10582
10583
10584
10585
10586
10587
10588
10589
10590
10591
10592
10593
10594
10595
10596
10597
10598
10599
10600
10601
10602
10603
10604
10605
10606
10607
10608
10609
10610
10611
10612
10613
10614
10615
10616
10617
10618
10619
10620
10621
10622
10623
10624
10625
10626
10627
10628
10629
10630
10631
10632
10633
10634
10635
10636
10637
10638
10639
10640
10641
10642
10643
10644
10645
10646
10647
10648
10649
10650
10651
10652
10653
10654
10655
10656
10657
10658
10659
10660
10661
10662
10663
10664
10665
10666
10667
10668
10669
10670
10671
10672
10673
10674
10675
10676
10677
10678
10679
10680
10681
10682
10683
10684
10685
10686
10687
10688
10689
10690
10691
10692
10693
10694
10695
10696
10697
10698
10699
10700
10701
10702
10703
10704
10705
10706
10707
10708
10709
10710
10711
10712
10713
10714
10715
10716
10717
10718
10719
10720
10721
10722
10723
10724
10725
10726
10727
10728
10729
10730
10731
10732
10733
10734
10735
10736
10737
10738
10739
10740
10741
10742
10743
10744
10745
10746
10747
10748
10749
10750
10751
10752
10753
10754
10755
10756
10757
10758
10759
10760
10761
10762
10763
10764
10765
10766
10767
10768
10769
10770
10771
10772
10773
10774
10775
10776
10777
10778
10779
10780
10781
10782
10783
10784
10785
10786
10787
10788
10789
10790
10791
10792
10793
10794
10795
10796
10797
10798
10799
10800
10801
10802
10803
10804
10805
10806
10807
10808
10809
10810
10811
10812
10813
10814
10815
10816
10817
10818
10819
10820
10821
10822
10823
10824
10825
10826
10827
10828
10829
10830
10831
10832
10833
10834
10835
10836
10837
10838
10839
10840
10841
10842
10843
10844
10845
10846
10847
10848
10849
10850
10851
10852
10853
10854
10855
10856
10857
10858
10859
10860
10861
10862
10863
10864
10865
10866
10867
10868
10869
10870
10871
10872
10873
10874
10875
10876
10877
10878
10879
10880
10881
10882
10883
10884
10885
10886
10887
10888
10889
10890
10891
10892
10893
10894
10895
10896
10897
10898
10899
10900
10901
10902
10903
10904
10905
10906
10907
10908
10909
10910
10911
10912
10913
10914
10915
10916
10917
10918
10919
10920
10921
10922
10923
10924
10925
10926
10927
10928
10929
10930
10931
10932
10933
10934
10935
10936
10937
10938
10939
10940
10941
10942
10943
10944
10945
10946
10947
10948
10949
10950
10951
10952
10953
10954
10955
10956
10957
10958
10959
10960
10961
10962
10963
10964
10965
10966
10967
10968
10969
10970
10971
10972
10973
10974
10975
10976
10977
10978
10979
10980
10981
10982
10983
10984
10985
10986
10987
10988
10989
10990
10991
10992
10993
10994
10995
10996
10997
10998
10999
11000
11001
11002
11003
11004
11005
11006
11007
11008
11009
11010
11011
11012
11013
11014
11015
11016
11017
11018
11019
11020
11021
11022
11023
11024
11025
11026
11027
11028
11029
11030
11031
11032
11033
11034
11035
11036
11037
11038
11039
11040
11041
11042
11043
11044
11045
11046
11047
11048
11049
11050
11051
11052
11053
11054
11055
11056
11057
11058
11059
11060
11061
11062
11063
11064
11065
11066
11067
11068
11069
11070
11071
11072
11073
11074
11075
11076
11077
11078
11079
11080
11081
11082
11083
11084
11085
11086
11087
11088
11089
11090
11091
11092
11093
11094
11095
11096
11097
11098
11099
11100
11101
11102
11103
11104
11105
11106
11107
11108
11109
11110
11111
11112
11113
11114
11115
11116
11117
11118
11119
11120
11121
11122
11123
11124
11125
11126
11127
11128
11129
11130
11131
11132
11133
11134
11135
11136
11137
11138
11139
11140
11141
11142
11143
11144
11145
11146
11147
11148
11149
11150
11151
11152
11153
11154
11155
11156
11157
11158
11159
11160
11161
11162
11163
11164
11165
11166
11167
11168
11169
11170
11171
11172
11173
11174
11175
11176
11177
11178
11179
11180
11181
11182
11183
11184
11185
11186
11187
11188
11189
11190
11191
11192
11193
11194
11195
11196
11197
11198
11199
11200
11201
11202
11203
11204
11205
11206
11207
11208
11209
11210
11211
11212
11213
11214
11215
11216
11217
11218
11219
11220
11221
11222
11223
11224
11225
11226
11227
11228
11229
11230
11231
11232
11233
11234
11235
11236
11237
11238
11239
11240
11241
11242
11243
11244
11245
11246
11247
11248
11249
11250
11251
11252
11253
11254
11255
11256
11257
11258
11259
11260
11261
11262
11263
11264
11265
11266
11267
11268
11269
11270
11271
11272
11273
11274
11275
11276
11277
11278
11279
11280
11281
11282
11283
11284
11285
11286
11287
11288
11289
11290
11291
11292
11293
11294
11295
11296
11297
11298
11299
11300
11301
11302
11303
11304
11305
11306
11307
11308
11309
11310
11311
11312
11313
11314
11315
11316
11317
11318
11319
11320
11321
11322
11323
11324
11325
11326
11327
11328
11329
11330
11331
11332
11333
11334
11335
11336
11337
11338
11339
11340
11341
11342
11343
11344
11345
11346
11347
11348
11349
11350
11351
11352
11353
11354
11355
11356
11357
11358
11359
11360
11361
11362
11363
11364
11365
11366
11367
11368
11369
11370
11371
11372
11373
11374
11375
11376
11377
11378
11379
11380
11381
11382
11383
11384
11385
11386
11387
11388
11389
11390
11391
11392
11393
11394
11395
11396
11397
11398
11399
11400
11401
11402
11403
11404
11405
11406
11407
11408
11409
11410
11411
11412
11413
11414
11415
11416
11417
11418
11419
11420
11421
11422
11423
11424
11425
11426
11427
11428
11429
11430
11431
11432
11433
11434
11435
11436
11437
11438
11439
11440
11441
11442
11443
11444
11445
11446
11447
11448
11449
11450
11451
11452
11453
11454
11455
11456
11457
11458
11459
11460
11461
11462
11463
11464
11465
11466
11467
11468
11469
11470
11471
11472
11473
11474
11475
11476
11477
11478
11479
11480
11481
11482
11483
11484
11485
11486
11487
11488
11489
11490
11491
11492
11493
11494
11495
11496
11497
11498
11499
11500
11501
11502
11503
11504
11505
11506
11507
11508
11509
11510
11511
11512
11513
11514
11515
11516
11517
11518
11519
11520
11521
11522
11523
11524
11525
11526
11527
11528
11529
11530
11531
11532
11533
11534
11535
11536
11537
11538
11539
11540
11541
11542
11543
11544
11545
11546
11547
11548
11549
11550
11551
11552
11553
11554
11555
11556
11557
11558
11559
11560
11561
11562
11563
11564
11565
11566
11567
11568
11569
11570
11571
11572
11573
11574
11575
11576
11577
11578
11579
11580
11581
11582
11583
11584
11585
11586
11587
11588
11589
11590
11591
11592
11593
11594
11595
11596
11597
11598
11599
11600
11601
11602
11603
11604
11605
11606
11607
11608
11609
11610
11611
11612
11613
11614
11615
11616
11617
11618
11619
11620
11621
11622
11623
11624
11625
11626
11627
11628
11629
11630
11631
11632
11633
11634
11635
11636
11637
11638
11639
11640
11641
11642
11643
11644
11645
11646
11647
11648
11649
11650
11651
11652
11653
11654
11655
11656
11657
11658
11659
11660
11661
11662
11663
11664
11665
11666
11667
11668
11669
11670
11671
11672
11673
11674
11675
11676
11677
11678
11679
11680
11681
11682
11683
11684
11685
11686
11687
11688
11689
11690
11691
11692
11693
11694
11695
11696
11697
11698
11699
11700
11701
11702
11703
11704
11705
11706
11707
11708
11709
11710
11711
11712
11713
11714
11715
11716
11717
11718
11719
11720
11721
11722
11723
11724
11725
11726
11727
11728
11729
11730
11731
11732
11733
11734
11735
11736
11737
11738
11739
11740
11741
11742
11743
11744
11745
11746
11747
11748
11749
11750
11751
11752
11753
11754
11755
11756
11757
11758
11759
11760
11761
11762
11763
11764
11765
11766
11767
11768
11769
11770
11771
11772
11773
11774
11775
11776
11777
11778
11779
11780
11781
11782
11783
11784
11785
11786
11787
11788
11789
11790
11791
11792
11793
11794
11795
11796
11797
11798
11799
11800
11801
11802
11803
11804
11805
11806
11807
11808
11809
11810
11811
11812
11813
11814
11815
11816
11817
11818
11819
11820
11821
11822
11823
11824
11825
11826
11827
11828
11829
11830
11831
11832
11833
11834
11835
11836
11837
11838
11839
11840
11841
11842
11843
11844
11845
11846
11847
11848
11849
11850
11851
11852
11853
11854
11855
11856
11857
11858
11859
11860
11861
11862
11863
11864
11865
11866
11867
11868
11869
11870
11871
11872
11873
11874
11875
11876
11877
11878
11879
11880
11881
11882
11883
11884
11885
11886
11887
11888
11889
11890
11891
11892
11893
11894
11895
11896
11897
11898
11899
11900
11901
11902
11903
11904
11905
11906
11907
11908
11909
11910
11911
11912
11913
11914
11915
11916
11917
11918
11919
11920
11921
11922
11923
11924
11925
11926
11927
11928
11929
11930
11931
11932
11933
11934
11935
11936
11937
11938
11939
11940
11941
11942
11943
11944
11945
11946
11947
11948
11949
11950
11951
11952
11953
11954
11955
11956
11957
11958
11959
11960
11961
11962
11963
11964
11965
11966
11967
11968
11969
11970
11971
11972
11973
11974
11975
11976
11977
11978
11979
11980
11981
11982
11983
11984
11985
11986
11987
11988
11989
11990
11991
11992
11993
11994
11995
11996
11997
11998
11999
12000
12001
12002
12003
12004
12005
12006
12007
12008
12009
12010
12011
12012
12013
12014
12015
12016
12017
12018
12019
12020
12021
12022
12023
12024
12025
12026
12027
12028
12029
12030
12031
12032
12033
12034
12035
12036
12037
12038
12039
12040
12041
12042
12043
12044
12045
12046
12047
12048
12049
12050
12051
12052
12053
12054
12055
12056
12057
12058
12059
12060
12061
12062
12063
12064
12065
12066
12067
12068
12069
12070
12071
12072
12073
12074
12075
12076
12077
12078
12079
12080
12081
12082
12083
12084
12085
12086
12087
12088
12089
12090
12091
12092
12093
12094
12095
12096
12097
12098
12099
12100
12101
12102
12103
12104
12105
12106
12107
12108
12109
12110
12111
12112
12113
12114
12115
12116
12117
12118
12119
12120
12121
12122
12123
12124
12125
12126
12127
12128
12129
12130
12131
12132
12133
12134
12135
12136
12137
12138
12139
12140
12141
12142
12143
12144
12145
12146
12147
12148
12149
12150
12151
12152
12153
12154
12155
12156
12157
12158
12159
12160
12161
12162
12163
12164
12165
12166
12167
12168
12169
12170
12171
12172
12173
12174
12175
12176
12177
12178
12179
12180
12181
12182
12183
12184
12185
12186
12187
12188
12189
12190
12191
12192
12193
12194
12195
12196
12197
12198
12199
12200
12201
12202
12203
12204
12205
12206
12207
12208
12209
12210
12211
12212
12213
12214
12215
12216
12217
12218
12219
12220
12221
12222
12223
12224
12225
12226
12227
12228
12229
12230
12231
12232
12233
12234
12235
12236
12237
12238
12239
12240
12241
12242
12243
12244
12245
12246
12247
12248
12249
12250
12251
12252
12253
12254
12255
12256
12257
12258
12259
12260
12261
12262
12263
12264
12265
12266
12267
12268
12269
12270
12271
12272
12273
12274
12275
12276
12277
12278
12279
12280
12281
12282
12283
12284
12285
12286
12287
12288
12289
12290
12291
12292
12293
12294
12295
12296
12297
12298
12299
12300
12301
12302
12303
12304
12305
12306
12307
12308
12309
12310
12311
12312
12313
12314
12315
12316
12317
12318
12319
12320
12321
12322
12323
12324
12325
12326
12327
12328
12329
12330
12331
12332
12333
12334
12335
12336
12337
12338
12339
12340
12341
12342
12343
12344
12345
12346
12347
12348
12349
12350
12351
12352
12353
12354
12355
12356
12357
12358
12359
12360
12361
12362
12363
12364
12365
12366
12367
12368
12369
12370
12371
12372
12373
12374
12375
12376
12377
12378
12379
12380
12381
12382
12383
12384
12385
12386
12387
12388
12389
12390
12391
12392
12393
12394
12395
12396
12397
12398
12399
12400
12401
12402
12403
12404
12405
12406
12407
12408
12409
12410
12411
12412
12413
12414
12415
12416
12417
12418
12419
12420
12421
12422
12423
12424
12425
12426
12427
12428
12429
12430
12431
12432
12433
12434
12435
12436
12437
12438
12439
12440
12441
12442
12443
12444
12445
12446
12447
12448
12449
12450
12451
12452
12453
12454
12455
12456
12457
12458
12459
12460
12461
12462
12463
12464
12465
12466
12467
12468
12469
12470
12471
12472
12473
12474
12475
12476
12477
12478
12479
12480
12481
12482
12483
12484
12485
12486
12487
12488
12489
12490
12491
12492
12493
12494
12495
12496
12497
12498
12499
12500
12501
12502
12503
12504
12505
12506
12507
12508
12509
12510
12511
12512
12513
12514
12515
12516
12517
12518
12519
12520
12521
12522
12523
12524
12525
12526
12527
12528
12529
12530
12531
12532
12533
12534
12535
12536
12537
12538
12539
12540
12541
12542
12543
12544
12545
12546
12547
12548
12549
12550
12551
12552
12553
12554
12555
12556
12557
12558
12559
12560
12561
12562
12563
12564
12565
12566
12567
12568
12569
12570
12571
12572
12573
12574
12575
12576
12577
12578
12579
12580
12581
12582
12583
12584
12585
12586
12587
12588
12589
12590
12591
12592
12593
12594
12595
12596
12597
12598
12599
12600
12601
12602
12603
12604
12605
12606
12607
12608
12609
12610
12611
12612
12613
12614
12615
12616
12617
12618
12619
12620
12621
12622
12623
12624
12625
12626
12627
12628
12629
12630
12631
12632
12633
12634
12635
12636
12637
12638
12639
12640
12641
12642
12643
12644
12645
12646
12647
12648
12649
12650
12651
12652
12653
12654
12655
12656
12657
12658
12659
12660
12661
12662
12663
12664
12665
12666
12667
12668
12669
12670
12671
12672
12673
12674
12675
12676
12677
12678
12679
12680
12681
12682
12683
12684
12685
12686
12687
12688
12689
12690
12691
12692
12693
12694
12695
12696
12697
12698
12699
12700
12701
12702
12703
12704
12705
12706
12707
12708
12709
12710
12711
12712
12713
12714
12715
12716
12717
12718
12719
12720
12721
12722
12723
12724
12725
12726
12727
12728
12729
12730
12731
12732
12733
12734
12735
12736
12737
12738
12739
12740
12741
12742
12743
12744
12745
12746
12747
12748
12749
12750
12751
12752
12753
12754
12755
12756
12757
12758
12759
12760
12761
12762
12763
12764
12765
12766
12767
12768
12769
12770
12771
12772
12773
12774
12775
12776
12777
12778
12779
12780
12781
12782
12783
12784
12785
12786
12787
12788
12789
12790
12791
12792
12793
12794
12795
12796
12797
12798
12799
12800
12801
12802
12803
12804
12805
12806
12807
12808
12809
12810
12811
12812
12813
12814
12815
12816
12817
12818
12819
12820
12821
12822
12823
12824
12825
12826
12827
12828
12829
12830
12831
12832
12833
12834
12835
12836
12837
12838
12839
12840
12841
12842
12843
12844
12845
12846
12847
12848
12849
12850
12851
12852
12853
12854
12855
12856
12857
12858
12859
12860
12861
12862
12863
12864
12865
12866
12867
12868
12869
12870
12871
12872
12873
12874
12875
12876
12877
12878
12879
12880
12881
12882
12883
12884
12885
12886
12887
12888
12889
12890
12891
12892
12893
12894
12895
12896
12897
12898
12899
12900
12901
12902
12903
12904
12905
12906
12907
12908
12909
12910
12911
12912
12913
12914
12915
12916
12917
12918
12919
12920
12921
12922
12923
12924
12925
12926
12927
12928
12929
12930
12931
12932
12933
12934
12935
12936
12937
12938
12939
12940
12941
12942
12943
12944
12945
12946
12947
12948
12949
12950
12951
12952
12953
12954
12955
12956
12957
12958
12959
12960
12961
12962
12963
12964
12965
12966
12967
12968
12969
12970
12971
12972
12973
12974
12975
12976
12977
12978
12979
12980
12981
12982
12983
12984
12985
12986
12987
12988
12989
12990
12991
12992
12993
12994
12995
12996
12997
12998
12999
13000
13001
13002
13003
13004
13005
13006
13007
13008
13009
13010
13011
13012
13013
13014
13015
13016
13017
13018
13019
13020
13021
13022
13023
13024
13025
13026
13027
13028
13029
13030
13031
13032
13033
13034
13035
13036
13037
13038
13039
13040
13041
13042
13043
13044
13045
13046
13047
13048
13049
13050
13051
13052
13053
13054
13055
13056
13057
13058
13059
13060
13061
13062
13063
13064
13065
13066
13067
13068
13069
13070
13071
13072
13073
13074
13075
13076
13077
13078
13079
13080
13081
13082
13083
13084
13085
13086
13087
13088
13089
13090
13091
13092
13093
13094
13095
13096
13097
13098
13099
13100
13101
13102
13103
13104
13105
13106
13107
13108
13109
13110
13111
13112
13113
13114
13115
13116
13117
13118
13119
13120
13121
13122
13123
13124
13125
13126
13127
13128
13129
13130
13131
13132
13133
13134
13135
13136
13137
13138
13139
13140
13141
13142
13143
13144
13145
13146
13147
13148
13149
13150
13151
13152
13153
13154
13155
13156
13157
13158
13159
13160
13161
13162
13163
13164
13165
13166
13167
13168
13169
13170
13171
13172
13173
13174
13175
13176
13177
13178
13179
13180
13181
13182
13183
13184
13185
13186
13187
13188
13189
13190
13191
13192
13193
13194
13195
13196
13197
13198
13199
13200
13201
13202
13203
13204
13205
13206
13207
13208
13209
13210
13211
13212
13213
13214
13215
13216
13217
13218
13219
13220
13221
13222
13223
13224
13225
13226
13227
13228
13229
13230
13231
13232
13233
13234
13235
13236
13237
13238
13239
13240
13241
13242
13243
13244
13245
13246
13247
13248
13249
13250
13251
13252
13253
13254
13255
13256
13257
13258
13259
13260
13261
13262
13263
13264
13265
13266
13267
13268
13269
13270
13271
13272
13273
13274
13275
13276
13277
13278
13279
13280
13281
13282
13283
13284
13285
13286
13287
13288
13289
13290
13291
13292
13293
13294
13295
13296
13297
13298
13299
13300
13301
13302
13303
13304
13305
13306
13307
13308
13309
13310
13311
13312
13313
13314
13315
13316
13317
13318
13319
13320
13321
13322
13323
13324
13325
13326
13327
13328
13329
13330
13331
13332
13333
13334
13335
13336
13337
13338
13339
13340
13341
13342
13343
13344
13345
13346
13347
13348
13349
13350
13351
13352
13353
13354
13355
13356
13357
13358
13359
13360
13361
13362
13363
13364
13365
13366
13367
13368
13369
13370
13371
13372
13373
13374
13375
13376
13377
13378
13379
13380
13381
13382
13383
13384
13385
13386
13387
13388
13389
13390
13391
13392
13393
13394
13395
13396
13397
13398
13399
13400
13401
13402
13403
13404
13405
13406
13407
13408
13409
13410
13411
13412
13413
13414
13415
13416
13417
13418
13419
13420
13421
13422
13423
13424
13425
13426
13427
13428
13429
13430
13431
13432
13433
13434
13435
13436
13437
13438
13439
13440
13441
13442
13443
13444
13445
13446
13447
13448
13449
13450
13451
13452
13453
13454
13455
13456
13457
13458
13459
13460
13461
13462
13463
13464
13465
13466
13467
13468
13469
13470
13471
13472
13473
13474
13475
13476
13477
13478
13479
13480
13481
13482
13483
13484
13485
13486
13487
13488
13489
13490
13491
13492
13493
13494
13495
13496
13497
13498
13499
13500
13501
13502
13503
13504
13505
13506
13507
13508
13509
13510
13511
13512
13513
13514
13515
13516
13517
13518
13519
13520
13521
13522
13523
13524
13525
13526
13527
13528
13529
13530
13531
13532
13533
13534
13535
13536
13537
13538
13539
13540
13541
13542
13543
13544
13545
13546
13547
13548
13549
13550
13551
13552
13553
13554
13555
13556
13557
13558
13559
13560
13561
13562
13563
13564
13565
13566
13567
13568
13569
13570
13571
13572
13573
13574
13575
13576
13577
13578
13579
13580
13581
13582
13583
13584
13585
13586
13587
13588
13589
13590
13591
13592
13593
13594
13595
13596
13597
13598
13599
13600
13601
13602
13603
13604
13605
13606
13607
13608
13609
13610
13611
13612
13613
13614
13615
13616
13617
13618
13619
13620
13621
13622
13623
13624
13625
13626
13627
13628
13629
13630
13631
13632
13633
13634
13635
13636
13637
13638
13639
13640
13641
13642
13643
13644
13645
13646
13647
13648
13649
13650
13651
13652
13653
13654
13655
13656
13657
13658
13659
13660
13661
13662
13663
13664
13665
13666
13667
13668
13669
13670
13671
13672
13673
13674
13675
13676
13677
13678
13679
13680
13681
13682
13683
13684
13685
13686
13687
13688
13689
13690
13691
13692
13693
13694
13695
13696
13697
13698
13699
13700
13701
13702
13703
13704
13705
13706
13707
13708
13709
13710
13711
13712
13713
13714
13715
13716
13717
13718
13719
13720
13721
13722
13723
13724
13725
13726
13727
13728
13729
13730
13731
13732
13733
13734
13735
13736
13737
13738
13739
13740
13741
13742
13743
13744
13745
13746
13747
13748
13749
13750
13751
13752
13753
13754
13755
13756
13757
13758
13759
13760
13761
13762
13763
13764
13765
13766
13767
13768
13769
13770
13771
13772
13773
13774
13775
13776
13777
13778
13779
13780
13781
13782
13783
13784
13785
13786
13787
13788
13789
13790
13791
13792
13793
13794
13795
13796
13797
13798
13799
13800
13801
13802
13803
13804
13805
13806
13807
13808
13809
13810
13811
13812
13813
13814
13815
13816
13817
13818
13819
13820
13821
13822
13823
13824
13825
13826
13827
13828
13829
13830
13831
13832
13833
13834
13835
13836
13837
13838
13839
13840
13841
13842
13843
13844
13845
13846
13847
13848
13849
13850
13851
13852
13853
13854
13855
13856
13857
13858
13859
13860
13861
13862
13863
13864
13865
13866
13867
13868
13869
13870
13871
13872
13873
13874
13875
13876
13877
13878
13879
13880
13881
13882
13883
13884
13885
13886
13887
13888
13889
13890
13891
13892
13893
13894
13895
13896
13897
13898
13899
13900
13901
13902
13903
13904
13905
13906
13907
13908
13909
13910
13911
13912
13913
13914
13915
13916
13917
13918
13919
13920
13921
13922
13923
13924
13925
13926
13927
13928
13929
13930
13931
13932
13933
13934
13935
13936
13937
13938
13939
13940
13941
13942
13943
13944
13945
13946
13947
13948
13949
13950
13951
13952
13953
13954
13955
13956
13957
13958
13959
13960
13961
13962
13963
13964
13965
13966
13967
13968
13969
13970
13971
13972
13973
13974
13975
13976
13977
13978
13979
13980
13981
13982
13983
13984
13985
13986
13987
13988
13989
13990
13991
13992
13993
13994
13995
13996
13997
13998
13999
14000
14001
14002
14003
14004
14005
14006
14007
14008
14009
14010
14011
14012
14013
14014
14015
14016
14017
14018
14019
14020
14021
14022
14023
14024
14025
14026
14027
14028
14029
14030
14031
14032
14033
14034
14035
14036
14037
14038
14039
14040
14041
14042
14043
14044
14045
14046
14047
14048
14049
14050
14051
14052
14053
14054
14055
14056
14057
14058
14059
14060
14061
14062
14063
14064
14065
14066
14067
14068
14069
14070
14071
14072
14073
14074
14075
14076
14077
14078
14079
14080
14081
14082
14083
14084
14085
14086
14087
14088
14089
14090
14091
14092
14093
14094
14095
14096
14097
14098
14099
14100
14101
14102
14103
14104
14105
14106
14107
14108
14109
14110
14111
14112
14113
14114
14115
14116
14117
14118
14119
14120
14121
14122
14123
14124
14125
14126
14127
14128
14129
14130
14131
14132
14133
14134
14135
14136
14137
14138
14139
14140
14141
14142
14143
14144
14145
14146
14147
14148
14149
14150
14151
14152
14153
14154
14155
14156
14157
14158
14159
14160
14161
14162
14163
14164
14165
14166
14167
14168
14169
14170
14171
14172
14173
14174
14175
14176
14177
14178
14179
14180
14181
14182
14183
14184
14185
14186
14187
14188
14189
14190
14191
14192
14193
14194
14195
14196
14197
14198
14199
14200
14201
14202
14203
14204
14205
14206
14207
14208
14209
14210
14211
14212
14213
14214
14215
14216
14217
14218
14219
14220
14221
14222
14223
14224
14225
14226
14227
14228
14229
14230
14231
14232
14233
14234
14235
14236
14237
14238
14239
14240
14241
14242
14243
14244
14245
14246
14247
14248
14249
14250
14251
14252
14253
14254
14255
14256
14257
14258
14259
14260
14261
14262
14263
14264
14265
14266
14267
14268
14269
14270
14271
14272
14273
14274
14275
14276
14277
14278
14279
14280
14281
14282
14283
14284
14285
14286
14287
14288
14289
14290
14291
14292
14293
14294
14295
14296
14297
14298
14299
14300
14301
14302
14303
14304
14305
14306
14307
14308
14309
14310
14311
14312
14313
14314
14315
14316
14317
14318
14319
14320
14321
14322
14323
14324
14325
14326
14327
14328
14329
14330
14331
14332
14333
14334
14335
14336
14337
14338
14339
14340
14341
14342
14343
14344
14345
14346
14347
14348
14349
14350
14351
14352
14353
14354
14355
14356
14357
14358
14359
14360
14361
14362
14363
14364
14365
14366
14367
14368
14369
14370
14371
14372
14373
14374
14375
14376
14377
14378
14379
14380
14381
14382
14383
14384
14385
14386
14387
14388
14389
14390
14391
14392
14393
14394
14395
14396
14397
14398
14399
14400
14401
14402
14403
14404
14405
14406
14407
14408
14409
14410
14411
14412
14413
14414
14415
14416
14417
14418
14419
14420
14421
14422
14423
14424
14425
14426
14427
14428
14429
14430
14431
14432
14433
14434
14435
14436
14437
14438
14439
14440
14441
14442
14443
14444
14445
14446
14447
14448
14449
14450
14451
14452
14453
14454
14455
14456
14457
14458
14459
14460
14461
14462
14463
14464
14465
14466
14467
14468
14469
14470
14471
14472
14473
14474
14475
14476
14477
14478
14479
14480
14481
14482
14483
14484
14485
14486
14487
14488
14489
14490
14491
14492
14493
14494
14495
14496
14497
14498
14499
14500
14501
14502
14503
14504
14505
14506
14507
14508
14509
14510
14511
14512
14513
14514
14515
14516
14517
14518
14519
14520
14521
14522
14523
14524
14525
14526
14527
14528
14529
14530
14531
14532
14533
14534
14535
14536
14537
14538
14539
14540
14541
14542
14543
14544
14545
14546
14547
14548
14549
14550
14551
14552
14553
14554
14555
14556
14557
14558
14559
14560
14561
14562
14563
14564
14565
14566
14567
14568
14569
14570
14571
14572
14573
14574
14575
14576
14577
14578
14579
14580
14581
14582
14583
14584
14585
14586
14587
14588
14589
14590
14591
14592
14593
14594
14595
14596
14597
14598
14599
14600
14601
14602
14603
14604
14605
14606
14607
14608
14609
14610
14611
14612
14613
14614
14615
14616
14617
14618
14619
14620
14621
14622
14623
14624
14625
14626
14627
14628
14629
14630
14631
14632
14633
14634
14635
14636
14637
14638
14639
14640
14641
14642
14643
14644
14645
14646
14647
14648
14649
14650
14651
14652
14653
14654
14655
14656
14657
14658
14659
14660
14661
14662
14663
14664
14665
14666
14667
14668
14669
14670
14671
14672
14673
14674
14675
14676
14677
14678
14679
14680
14681
14682
14683
14684
14685
14686
14687
14688
14689
14690
14691
14692
14693
14694
14695
14696
14697
14698
14699
14700
14701
14702
14703
14704
14705
14706
14707
14708
14709
14710
14711
14712
14713
14714
14715
14716
14717
14718
14719
14720
14721
14722
14723
14724
14725
14726
14727
14728
14729
14730
14731
14732
14733
14734
14735
14736
14737
14738
14739
14740
14741
14742
14743
14744
14745
14746
14747
14748
14749
14750
14751
14752
14753
14754
14755
14756
14757
14758
14759
14760
14761
14762
14763
14764
14765
14766
14767
14768
14769
14770
14771
14772
14773
14774
14775
14776
14777
14778
14779
14780
14781
14782
14783
14784
14785
14786
14787
14788
14789
14790
14791
14792
14793
14794
14795
14796
14797
14798
14799
14800
14801
14802
14803
14804
14805
14806
14807
14808
14809
14810
14811
14812
14813
14814
14815
14816
14817
14818
14819
14820
14821
14822
14823
14824
14825
14826
14827
14828
14829
14830
14831
14832
14833
14834
14835
14836
14837
14838
14839
14840
14841
14842
14843
14844
14845
14846
14847
14848
14849
14850
14851
14852
14853
14854
14855
14856
14857
14858
14859
14860
14861
14862
14863
14864
14865
14866
14867
14868
14869
14870
14871
14872
14873
14874
14875
14876
14877
14878
14879
14880
14881
14882
14883
14884
14885
14886
14887
14888
14889
14890
14891
14892
14893
14894
14895
14896
14897
14898
14899
14900
14901
14902
14903
14904
14905
14906
14907
14908
14909
14910
14911
14912
14913
14914
14915
14916
14917
14918
14919
14920
14921
14922
14923
14924
14925
14926
14927
14928
14929
14930
14931
14932
14933
14934
14935
14936
14937
14938
14939
14940
14941
14942
14943
14944
14945
14946
14947
14948
14949
14950
14951
14952
14953
14954
14955
14956
14957
14958
14959
14960
14961
14962
14963
14964
14965
14966
14967
14968
14969
14970
14971
14972
14973
14974
14975
14976
14977
14978
14979
14980
14981
14982
14983
14984
14985
14986
14987
14988
14989
14990
14991
14992
14993
14994
14995
14996
14997
14998
14999
15000
15001
15002
15003
15004
15005
15006
15007
15008
15009
15010
15011
15012
15013
15014
15015
15016
15017
15018
15019
15020
15021
15022
15023
15024
15025
15026
15027
15028
15029
15030
15031
15032
15033
15034
15035
15036
15037
15038
15039
15040
15041
15042
15043
15044
15045
15046
15047
15048
15049
15050
15051
15052
15053
15054
15055
15056
15057
15058
15059
15060
15061
15062
15063
15064
15065
15066
15067
15068
15069
15070
15071
15072
15073
15074
15075
15076
15077
15078
15079
15080
15081
15082
15083
15084
15085
15086
15087
15088
15089
15090
15091
15092
15093
15094
15095
15096
15097
15098
15099
15100
15101
15102
15103
15104
15105
15106
15107
15108
15109
15110
15111
15112
15113
15114
15115
15116
15117
15118
15119
15120
15121
15122
15123
15124
15125
15126
15127
15128
15129
15130
15131
15132
15133
15134
15135
15136
15137
15138
15139
15140
15141
15142
15143
15144
15145
15146
15147
15148
15149
15150
15151
15152
15153
15154
15155
15156
15157
15158
15159
15160
15161
15162
15163
15164
15165
15166
15167
15168
15169
15170
15171
15172
15173
15174
15175
15176
15177
15178
15179
15180
15181
15182
15183
15184
15185
15186
15187
15188
15189
15190
15191
15192
15193
15194
15195
15196
15197
15198
15199
15200
15201
15202
15203
15204
15205
15206
15207
15208
15209
15210
15211
15212
15213
15214
15215
15216
15217
15218
15219
15220
15221
15222
15223
15224
15225
15226
15227
15228
15229
15230
15231
15232
15233
15234
15235
15236
15237
15238
15239
15240
15241
15242
15243
15244
15245
15246
15247
15248
15249
15250
15251
15252
15253
15254
15255
15256
15257
15258
15259
15260
15261
15262
15263
15264
15265
15266
15267
15268
15269
15270
15271
15272
15273
15274
15275
15276
15277
15278
15279
15280
15281
15282
15283
15284
15285
15286
15287
15288
15289
15290
15291
15292
15293
15294
15295
15296
15297
15298
15299
15300
15301
15302
15303
15304
15305
15306
15307
15308
15309
15310
15311
15312
15313
15314
15315
15316
15317
15318
15319
15320
15321
15322
15323
15324
15325
15326
15327
15328
15329
15330
15331
15332
15333
15334
15335
15336
15337
15338
15339
15340
15341
15342
15343
15344
15345
15346
15347
15348
15349
15350
15351
15352
15353
15354
15355
15356
15357
15358
15359
15360
15361
15362
15363
15364
15365
15366
15367
15368
15369
15370
15371
15372
15373
15374
15375
15376
15377
15378
15379
15380
15381
15382
15383
15384
15385
15386
15387
15388
15389
15390
15391
15392
15393
15394
15395
15396
15397
15398
15399
15400
15401
15402
15403
15404
15405
15406
15407
15408
15409
15410
15411
15412
15413
15414
15415
15416
15417
15418
15419
15420
15421
15422
15423
15424
15425
15426
15427
15428
15429
15430
15431
15432
15433
15434
15435
15436
15437
15438
15439
15440
15441
15442
15443
15444
15445
15446
15447
15448
15449
15450
15451
15452
15453
15454
15455
15456
15457
15458
15459
15460
15461
15462
15463
15464
15465
15466
15467
15468
15469
15470
15471
15472
15473
15474
15475
15476
15477
15478
15479
15480
15481
15482
15483
15484
15485
15486
15487
15488
15489
15490
15491
15492
15493
15494
15495
15496
15497
15498
15499
15500
15501
15502
15503
15504
15505
15506
15507
15508
15509
15510
15511
15512
15513
15514
15515
15516
15517
15518
15519
15520
15521
15522
15523
15524
15525
15526
15527
15528
15529
15530
15531
15532
15533
15534
15535
15536
15537
15538
15539
15540
15541
15542
15543
15544
15545
15546
15547
15548
15549
15550
15551
15552
15553
15554
15555
15556
15557
15558
15559
15560
15561
15562
15563
15564
15565
15566
15567
15568
15569
15570
15571
15572
15573
15574
15575
15576
15577
15578
15579
15580
15581
15582
15583
15584
15585
15586
15587
15588
15589
15590
15591
15592
15593
15594
15595
15596
15597
15598
15599
15600
15601
15602
15603
15604
15605
15606
15607
15608
15609
15610
15611
15612
15613
15614
15615
15616
15617
15618
15619
15620
15621
15622
15623
15624
15625
15626
15627
15628
15629
15630
15631
15632
15633
15634
15635
15636
15637
15638
15639
15640
15641
15642
15643
15644
15645
15646
15647
15648
15649
15650
15651
15652
15653
15654
15655
15656
15657
15658
15659
15660
15661
15662
15663
15664
15665
15666
15667
15668
15669
15670
15671
15672
15673
15674
15675
15676
15677
15678
15679
15680
15681
15682
15683
15684
15685
15686
15687
15688
15689
15690
15691
15692
15693
15694
15695
15696
15697
15698
15699
15700
15701
15702
15703
15704
15705
15706
15707
15708
15709
15710
15711
15712
15713
15714
15715
15716
15717
15718
15719
15720
15721
15722
15723
15724
15725
15726
15727
15728
15729
15730
15731
15732
15733
15734
15735
15736
15737
15738
15739
15740
15741
15742
15743
15744
15745
15746
15747
15748
15749
15750
15751
15752
15753
15754
15755
15756
15757
15758
15759
15760
15761
15762
15763
15764
15765
15766
15767
15768
15769
15770
15771
15772
15773
15774
15775
15776
15777
15778
15779
15780
15781
15782
15783
15784
15785
15786
15787
15788
15789
15790
15791
15792
15793
15794
15795
15796
15797
15798
15799
15800
15801
15802
15803
15804
15805
15806
15807
15808
15809
15810
15811
15812
15813
15814
15815
15816
15817
15818
15819
15820
15821
15822
15823
15824
15825
15826
15827
15828
15829
15830
15831
15832
15833
15834
15835
15836
15837
15838
15839
15840
15841
15842
15843
15844
15845
15846
15847
15848
15849
15850
15851
15852
15853
15854
15855
15856
15857
15858
15859
15860
15861
15862
15863
15864
15865
15866
15867
15868
15869
15870
15871
15872
15873
15874
15875
15876
15877
15878
15879
15880
15881
15882
15883
15884
15885
15886
15887
15888
15889
15890
15891
15892
15893
15894
15895
15896
15897
15898
15899
15900
15901
15902
15903
15904
15905
15906
15907
15908
15909
15910
15911
15912
15913
15914
15915
15916
15917
15918
15919
15920
15921
15922
15923
15924
15925
15926
15927
15928
15929
15930
15931
15932
15933
15934
15935
15936
15937
15938
15939
15940
15941
15942
15943
15944
15945
15946
15947
15948
15949
15950
15951
15952
15953
15954
15955
15956
15957
15958
15959
15960
15961
15962
15963
15964
15965
15966
15967
15968
15969
15970
15971
15972
15973
15974
15975
15976
15977
15978
15979
15980
15981
15982
15983
15984
15985
15986
15987
15988
15989
15990
15991
15992
15993
15994
15995
15996
15997
15998
15999
16000
16001
16002
16003
16004
16005
16006
16007
16008
16009
16010
16011
16012
16013
16014
16015
16016
16017
16018
16019
16020
16021
16022
16023
16024
16025
16026
16027
16028
16029
16030
16031
16032
16033
16034
16035
16036
16037
16038
16039
16040
16041
16042
16043
16044
16045
16046
16047
16048
16049
16050
16051
16052
16053
16054
16055
16056
16057
16058
16059
16060
16061
16062
16063
16064
16065
16066
16067
16068
16069
16070
16071
16072
16073
16074
16075
16076
16077
16078
16079
16080
16081
16082
16083
16084
16085
16086
16087
16088
16089
16090
16091
16092
16093
16094
16095
16096
16097
16098
16099
16100
16101
16102
16103
16104
16105
16106
16107
16108
16109
16110
16111
16112
16113
16114
16115
16116
16117
16118
16119
16120
16121
16122
16123
16124
16125
16126
16127
16128
16129
16130
16131
16132
16133
16134
16135
16136
16137
16138
16139
16140
16141
16142
16143
16144
16145
16146
16147
16148
16149
16150
16151
16152
16153
16154
16155
16156
16157
16158
16159
16160
16161
16162
16163
16164
16165
16166
16167
16168
16169
16170
16171
16172
16173
16174
16175
16176
16177
16178
16179
16180
16181
16182
16183
16184
16185
16186
16187
16188
16189
16190
16191
16192
16193
16194
16195
16196
16197
16198
16199
16200
16201
16202
16203
16204
16205
16206
16207
16208
16209
16210
16211
16212
16213
16214
16215
16216
16217
16218
16219
16220
16221
16222
16223
16224
16225
16226
16227
16228
16229
16230
16231
16232
16233
16234
16235
16236
16237
16238
16239
16240
16241
16242
16243
16244
16245
16246
16247
16248
16249
16250
16251
16252
16253
16254
16255
16256
16257
16258
16259
16260
16261
16262
16263
16264
16265
16266
16267
16268
16269
16270
16271
16272
16273
16274
16275
16276
16277
16278
16279
16280
16281
16282
16283
16284
16285
16286
16287
16288
16289
16290
16291
16292
16293
16294
16295
16296
16297
16298
16299
16300
16301
16302
16303
16304
16305
16306
16307
16308
16309
16310
16311
16312
16313
16314
16315
16316
16317
16318
16319
16320
16321
16322
16323
16324
16325
16326
16327
16328
16329
16330
16331
16332
16333
16334
16335
16336
16337
16338
16339
16340
16341
16342
16343
16344
16345
16346
16347
16348
16349
16350
16351
16352
16353
16354
16355
16356
16357
16358
16359
16360
16361
16362
16363
16364
16365
16366
16367
16368
16369
16370
16371
16372
16373
16374
16375
16376
16377
16378
16379
16380
16381
16382
16383
16384
16385
16386
16387
16388
16389
16390
16391
16392
16393
16394
16395
16396
16397
16398
16399
16400
16401
16402
16403
16404
16405
16406
16407
16408
16409
16410
16411
16412
16413
16414
16415
16416
16417
16418
16419
16420
16421
16422
16423
16424
16425
16426
16427
16428
16429
16430
16431
16432
16433
16434
16435
16436
16437
16438
16439
16440
16441
16442
16443
16444
16445
16446
16447
16448
16449
16450
16451
16452
16453
16454
16455
16456
16457
16458
16459
16460
16461
16462
16463
16464
16465
16466
16467
16468
16469
16470
16471
16472
16473
16474
16475
16476
16477
16478
16479
16480
16481
16482
16483
16484
16485
16486
16487
16488
16489
16490
16491
16492
16493
16494
16495
16496
16497
16498
16499
16500
16501
16502
16503
16504
16505
16506
16507
16508
16509
16510
16511
16512
16513
16514
16515
16516
16517
16518
16519
16520
16521
16522
16523
16524
16525
16526
16527
16528
16529
16530
16531
16532
16533
16534
16535
16536
16537
16538
16539
16540
16541
16542
16543
16544
16545
16546
16547
16548
16549
16550
16551
16552
16553
16554
16555
16556
16557
16558
16559
16560
16561
16562
16563
16564
16565
16566
16567
16568
16569
16570
16571
16572
16573
16574
16575
16576
16577
16578
16579
16580
16581
16582
16583
16584
16585
16586
16587
16588
16589
16590
16591
16592
16593
16594
16595
16596
16597
16598
16599
16600
16601
16602
16603
16604
16605
16606
16607
16608
16609
16610
16611
16612
16613
16614
16615
16616
16617
16618
16619
16620
16621
16622
16623
16624
16625
16626
16627
16628
16629
16630
16631
16632
16633
16634
16635
16636
16637
16638
16639
16640
16641
16642
16643
16644
16645
16646
16647
16648
16649
16650
16651
16652
16653
16654
16655
16656
16657
16658
16659
16660
16661
16662
16663
16664
16665
16666
16667
16668
16669
16670
16671
16672
16673
16674
16675
16676
16677
16678
16679
16680
16681
16682
16683
16684
16685
16686
16687
16688
16689
16690
16691
16692
16693
16694
16695
16696
16697
16698
16699
16700
16701
16702
16703
16704
16705
16706
16707
16708
16709
16710
16711
16712
16713
16714
16715
16716
16717
16718
16719
16720
16721
16722
16723
16724
16725
16726
16727
16728
16729
16730
16731
16732
16733
16734
16735
16736
16737
16738
16739
16740
16741
16742
16743
16744
16745
16746
16747
16748
16749
16750
16751
16752
16753
16754
16755
16756
16757
16758
16759
16760
16761
16762
16763
16764
16765
16766
16767
16768
16769
16770
16771
16772
16773
16774
16775
16776
16777
16778
16779
16780
16781
16782
16783
16784
16785
16786
16787
16788
16789
16790
16791
16792
16793
16794
16795
16796
16797
16798
16799
16800
16801
16802
16803
16804
16805
16806
16807
16808
16809
16810
16811
16812
16813
16814
16815
16816
16817
16818
16819
16820
16821
16822
16823
16824
16825
16826
16827
16828
16829
16830
16831
16832
16833
16834
16835
16836
16837
16838
16839
16840
16841
16842
16843
16844
16845
16846
16847
16848
16849
16850
16851
16852
16853
16854
16855
16856
16857
16858
16859
16860
16861
16862
16863
16864
16865
16866
16867
16868
16869
16870
16871
16872
16873
16874
16875
16876
16877
16878
16879
16880
16881
16882
16883
16884
16885
16886
16887
16888
16889
16890
16891
16892
16893
16894
16895
16896
16897
16898
16899
16900
16901
16902
16903
16904
16905
16906
16907
16908
16909
16910
16911
16912
16913
16914
16915
16916
16917
16918
16919
16920
16921
16922
16923
16924
16925
16926
16927
16928
16929
16930
16931
16932
16933
16934
16935
16936
16937
16938
16939
16940
16941
16942
16943
16944
16945
16946
16947
16948
16949
16950
16951
16952
16953
16954
16955
16956
16957
16958
16959
16960
16961
16962
16963
16964
16965
16966
16967
16968
16969
16970
16971
16972
16973
16974
16975
16976
16977
16978
16979
16980
16981
16982
16983
16984
16985
16986
16987
16988
16989
16990
16991
16992
16993
16994
16995
16996
16997
16998
16999
17000
17001
17002
17003
17004
17005
17006
17007
17008
17009
17010
17011
17012
17013
17014
17015
17016
17017
17018
17019
17020
17021
17022
17023
17024
17025
17026
17027
17028
17029
17030
17031
17032
17033
17034
17035
17036
17037
17038
17039
17040
17041
17042
17043
17044
17045
17046
17047
17048
17049
17050
17051
17052
17053
17054
17055
17056
17057
17058
17059
17060
17061
17062
17063
17064
17065
17066
17067
17068
17069
17070
17071
17072
17073
17074
17075
17076
17077
17078
17079
17080
17081
17082
17083
17084
17085
17086
17087
17088
17089
17090
17091
17092
17093
17094
17095
17096
17097
17098
17099
17100
17101
17102
17103
17104
17105
17106
17107
17108
17109
17110
17111
17112
17113
17114
17115
17116
17117
17118
17119
17120
17121
17122
17123
17124
17125
17126
17127
17128
17129
17130
17131
17132
17133
17134
17135
17136
17137
17138
17139
17140
17141
17142
17143
17144
17145
17146
17147
17148
17149
17150
17151
17152
17153
17154
17155
17156
17157
17158
17159
17160
17161
17162
17163
17164
17165
17166
17167
17168
17169
17170
17171
17172
17173
17174
17175
17176
17177
17178
17179
17180
17181
17182
17183
17184
17185
17186
17187
17188
17189
17190
17191
17192
17193
17194
17195
17196
17197
17198
17199
17200
17201
17202
17203
17204
17205
17206
17207
17208
17209
17210
17211
17212
17213
17214
17215
17216
17217
17218
17219
17220
17221
17222
17223
17224
17225
17226
17227
17228
17229
17230
17231
17232
17233
17234
17235
17236
17237
17238
17239
17240
17241
17242
17243
17244
17245
17246
17247
17248
17249
17250
17251
17252
17253
17254
17255
17256
17257
17258
17259
17260
17261
17262
17263
17264
17265
17266
17267
17268
17269
17270
17271
17272
17273
17274
17275
17276
17277
17278
17279
17280
17281
17282
17283
17284
17285
17286
17287
17288
17289
17290
17291
17292
17293
17294
17295
17296
17297
17298
17299
17300
17301
17302
17303
17304
17305
17306
17307
17308
17309
17310
17311
17312
17313
17314
17315
17316
17317
17318
17319
17320
17321
17322
17323
17324
17325
17326
17327
17328
17329
17330
17331
17332
17333
17334
17335
17336
17337
17338
17339
17340
17341
17342
17343
17344
17345
17346
17347
17348
17349
17350
17351
17352
17353
17354
17355
17356
17357
17358
17359
17360
17361
17362
17363
17364
17365
17366
17367
17368
17369
17370
17371
17372
17373
17374
17375
17376
17377
17378
17379
17380
17381
17382
17383
17384
17385
17386
17387
17388
17389
17390
17391
17392
17393
17394
17395
17396
17397
17398
17399
17400
17401
17402
17403
17404
17405
17406
17407
17408
17409
17410
17411
17412
17413
17414
17415
17416
17417
17418
17419
17420
17421
17422
17423
17424
17425
17426
17427
17428
17429
17430
17431
17432
17433
17434
17435
17436
17437
17438
17439
17440
17441
17442
17443
17444
17445
17446
17447
17448
17449
17450
17451
17452
17453
17454
17455
17456
17457
17458
17459
17460
17461
17462
17463
17464
17465
17466
17467
17468
17469
17470
17471
17472
17473
17474
17475
17476
17477
17478
17479
17480
17481
17482
17483
17484
17485
17486
17487
17488
17489
17490
17491
17492
17493
17494
17495
17496
17497
17498
17499
17500
17501
17502
17503
17504
17505
17506
17507
17508
17509
17510
17511
17512
17513
17514
17515
17516
17517
17518
17519
17520
17521
17522
17523
17524
17525
17526
17527
17528
17529
17530
17531
17532
17533
17534
17535
17536
17537
17538
17539
17540
17541
17542
17543
17544
17545
17546
17547
17548
17549
17550
17551
17552
17553
17554
17555
17556
17557
17558
17559
17560
17561
17562
17563
17564
17565
17566
17567
17568
17569
17570
17571
17572
17573
17574
17575
17576
17577
17578
17579
17580
17581
17582
17583
17584
17585
17586
17587
17588
17589
17590
17591
17592
17593
17594
17595
17596
17597
17598
17599
17600
17601
17602
17603
17604
17605
17606
17607
17608
17609
17610
17611
17612
17613
17614
17615
17616
17617
17618
17619
17620
17621
17622
17623
17624
17625
17626
17627
17628
17629
17630
17631
17632
17633
17634
17635
17636
17637
17638
17639
17640
17641
17642
17643
17644
17645
17646
17647
17648
17649
17650
17651
17652
17653
17654
17655
17656
17657
17658
17659
17660
17661
17662
17663
17664
17665
17666
17667
17668
17669
17670
17671
17672
17673
17674
17675
17676
17677
17678
17679
17680
17681
17682
17683
17684
17685
17686
17687
17688
17689
17690
17691
17692
17693
17694
17695
17696
17697
17698
17699
17700
17701
17702
17703
17704
17705
17706
17707
17708
17709
17710
17711
17712
17713
17714
17715
17716
17717
17718
17719
17720
17721
17722
17723
17724
17725
17726
17727
17728
17729
17730
17731
17732
17733
17734
17735
17736
17737
17738
17739
17740
17741
17742
17743
17744
17745
17746
17747
17748
17749
17750
17751
17752
17753
17754
17755
17756
17757
17758
17759
17760
17761
17762
17763
17764
17765
17766
17767
17768
17769
17770
17771
17772
17773
17774
17775
17776
17777
17778
17779
17780
17781
17782
17783
17784
17785
17786
17787
17788
17789
17790
17791
17792
17793
17794
17795
17796
17797
17798
17799
17800
17801
17802
17803
17804
17805
17806
17807
17808
17809
17810
17811
17812
17813
17814
17815
17816
17817
17818
17819
17820
17821
17822
17823
17824
17825
17826
17827
17828
17829
17830
17831
17832
17833
17834
17835
17836
17837
17838
17839
17840
17841
17842
17843
17844
17845
17846
17847
17848
17849
17850
17851
17852
17853
17854
17855
17856
17857
17858
17859
17860
17861
17862
17863
17864
17865
17866
17867
17868
17869
17870
17871
17872
17873
17874
17875
17876
17877
17878
17879
17880
17881
17882
17883
17884
17885
17886
17887
17888
17889
17890
17891
17892
17893
17894
17895
17896
17897
17898
17899
17900
17901
17902
17903
17904
17905
17906
17907
17908
17909
17910
17911
17912
17913
17914
17915
17916
17917
17918
17919
17920
17921
17922
17923
17924
17925
17926
17927
17928
17929
17930
17931
17932
17933
17934
17935
17936
17937
17938
17939
17940
17941
17942
17943
17944
17945
17946
17947
17948
17949
17950
17951
17952
17953
17954
17955
17956
17957
17958
17959
17960
17961
17962
17963
17964
17965
17966
17967
17968
17969
17970
17971
17972
17973
17974
17975
17976
17977
17978
17979
17980
17981
17982
17983
17984
17985
17986
17987
17988
17989
17990
17991
17992
17993
17994
17995
17996
17997
17998
17999
18000
18001
18002
18003
18004
18005
18006
18007
18008
18009
18010
18011
18012
18013
18014
18015
18016
18017
18018
18019
18020
18021
18022
18023
18024
18025
18026
18027
18028
18029
18030
18031
18032
18033
18034
18035
18036
18037
18038
18039
18040
18041
18042
18043
18044
18045
18046
18047
18048
18049
18050
18051
18052
18053
18054
18055
18056
18057
18058
18059
18060
18061
18062
18063
18064
18065
18066
18067
18068
18069
18070
18071
18072
18073
18074
18075
18076
18077
18078
18079
18080
18081
18082
18083
18084
18085
18086
18087
18088
18089
18090
18091
18092
18093
18094
18095
18096
18097
18098
18099
18100
18101
18102
18103
18104
18105
18106
18107
18108
18109
18110
18111
18112
18113
18114
18115
18116
18117
18118
18119
18120
18121
18122
18123
18124
18125
18126
18127
18128
18129
18130
18131
18132
18133
18134
18135
18136
18137
18138
18139
18140
18141
18142
18143
18144
18145
18146
18147
18148
18149
18150
18151
18152
18153
18154
18155
18156
18157
18158
18159
18160
18161
18162
18163
18164
18165
18166
18167
18168
18169
18170
18171
18172
18173
18174
18175
18176
18177
18178
18179
18180
18181
18182
18183
18184
18185
18186
18187
18188
18189
18190
18191
18192
18193
18194
18195
18196
18197
18198
18199
18200
18201
18202
18203
18204
18205
18206
18207
18208
18209
18210
18211
18212
18213
18214
18215
18216
18217
18218
18219
18220
18221
18222
18223
18224
18225
18226
18227
18228
18229
18230
18231
18232
18233
18234
18235
18236
18237
18238
18239
18240
18241
18242
18243
18244
18245
18246
18247
18248
18249
18250
18251
18252
18253
18254
18255
18256
18257
18258
18259
18260
18261
18262
18263
18264
18265
18266
18267
18268
18269
18270
18271
18272
18273
18274
18275
18276
18277
18278
18279
18280
18281
18282
18283
18284
18285
18286
18287
18288
18289
18290
18291
18292
18293
18294
18295
18296
18297
18298
18299
18300
18301
18302
18303
18304
18305
18306
18307
18308
18309
18310
18311
18312
18313
18314
18315
18316
18317
18318
18319
18320
18321
18322
18323
18324
18325
18326
18327
18328
18329
18330
18331
18332
18333
18334
18335
18336
18337
18338
18339
18340
18341
18342
18343
18344
18345
18346
18347
18348
18349
18350
18351
18352
18353
18354
18355
18356
18357
18358
18359
18360
18361
18362
18363
18364
18365
18366
18367
18368
18369
18370
18371
18372
18373
18374
18375
18376
18377
18378
18379
18380
18381
18382
18383
18384
18385
18386
18387
18388
18389
18390
18391
18392
18393
18394
18395
18396
18397
18398
18399
18400
18401
18402
18403
18404
18405
18406
18407
18408
18409
18410
18411
18412
18413
18414
18415
18416
18417
18418
18419
18420
18421
18422
18423
18424
18425
18426
18427
18428
18429
18430
18431
18432
18433
18434
18435
18436
18437
18438
18439
18440
18441
18442
18443
18444
18445
18446
18447
18448
18449
18450
18451
18452
18453
18454
18455
18456
18457
18458
18459
18460
18461
18462
18463
18464
18465
18466
18467
18468
18469
18470
18471
18472
18473
18474
18475
18476
18477
18478
18479
18480
18481
18482
18483
18484
18485
18486
18487
18488
18489
18490
18491
18492
18493
18494
18495
18496
18497
18498
18499
18500
18501
18502
18503
18504
18505
18506
18507
18508
18509
18510
18511
18512
18513
18514
18515
18516
18517
18518
18519
18520
18521
18522
18523
18524
18525
18526
18527
18528
18529
18530
18531
18532
18533
18534
18535
18536
18537
18538
18539
18540
18541
18542
18543
18544
18545
18546
18547
18548
18549
18550
18551
18552
18553
18554
18555
18556
18557
18558
18559
18560
18561
18562
18563
18564
18565
18566
18567
18568
18569
18570
18571
18572
18573
18574
18575
18576
18577
18578
18579
18580
18581
18582
18583
18584
18585
18586
18587
18588
18589
18590
18591
18592
18593
18594
18595
18596
18597
18598
18599
18600
18601
18602
18603
18604
18605
18606
18607
18608
18609
18610
18611
18612
18613
18614
18615
18616
18617
18618
18619
18620
18621
18622
18623
18624
18625
18626
18627
18628
18629
18630
18631
18632
18633
18634
18635
18636
18637
18638
18639
18640
18641
18642
18643
18644
18645
18646
18647
18648
18649
18650
18651
18652
18653
18654
18655
18656
18657
18658
18659
18660
18661
18662
18663
18664
18665
18666
18667
18668
18669
18670
18671
18672
18673
18674
18675
18676
18677
18678
18679
18680
18681
18682
18683
18684
18685
18686
18687
18688
18689
18690
18691
18692
18693
18694
18695
18696
18697
18698
18699
18700
18701
18702
18703
18704
18705
18706
18707
18708
18709
18710
18711
18712
18713
18714
18715
18716
18717
18718
18719
18720
18721
18722
18723
18724
18725
18726
18727
18728
18729
18730
18731
18732
18733
18734
18735
18736
18737
18738
18739
18740
18741
18742
18743
18744
18745
18746
18747
18748
18749
18750
18751
18752
18753
18754
18755
18756
18757
18758
18759
18760
18761
18762
18763
18764
18765
18766
18767
18768
18769
18770
18771
18772
18773
18774
18775
18776
18777
18778
18779
18780
18781
18782
18783
18784
18785
18786
18787
18788
18789
18790
18791
18792
18793
18794
18795
18796
18797
18798
18799
18800
18801
18802
18803
18804
18805
18806
18807
18808
18809
18810
18811
18812
18813
18814
18815
18816
18817
18818
18819
18820
18821
18822
18823
18824
18825
18826
18827
18828
18829
18830
18831
18832
18833
18834
18835
18836
18837
18838
18839
18840
18841
18842
18843
18844
18845
18846
18847
18848
18849
18850
18851
18852
18853
18854
18855
18856
18857
18858
18859
18860
18861
18862
18863
18864
18865
18866
18867
18868
18869
18870
18871
18872
18873
18874
18875
18876
18877
18878
18879
18880
18881
18882
18883
18884
18885
18886
18887
18888
18889
18890
18891
18892
18893
18894
18895
18896
18897
18898
18899
18900
18901
18902
18903
18904
18905
18906
18907
18908
18909
18910
18911
18912
18913
18914
18915
18916
18917
18918
18919
18920
18921
18922
18923
18924
18925
18926
18927
18928
18929
18930
18931
18932
18933
18934
18935
18936
18937
18938
18939
18940
18941
18942
18943
18944
18945
18946
18947
18948
18949
18950
18951
18952
18953
18954
18955
18956
18957
18958
18959
18960
18961
18962
18963
18964
18965
18966
18967
18968
18969
18970
18971
18972
18973
18974
18975
18976
18977
18978
18979
18980
18981
18982
18983
18984
18985
18986
18987
18988
18989
18990
18991
18992
18993
18994
18995
18996
18997
18998
18999
19000
19001
19002
19003
19004
19005
19006
19007
19008
19009
19010
19011
19012
19013
19014
19015
19016
19017
19018
19019
19020
19021
19022
19023
19024
19025
19026
19027
19028
19029
19030
19031
19032
19033
19034
19035
19036
19037
19038
19039
19040
19041
19042
19043
19044
19045
19046
19047
19048
19049
19050
19051
19052
19053
19054
19055
19056
19057
19058
19059
19060
19061
19062
19063
19064
19065
19066
19067
19068
19069
19070
19071
19072
19073
19074
19075
19076
19077
19078
19079
19080
19081
19082
19083
19084
19085
19086
19087
19088
19089
19090
19091
19092
19093
19094
19095
19096
19097
19098
19099
19100
19101
19102
19103
19104
19105
19106
19107
19108
19109
19110
19111
19112
19113
19114
19115
19116
19117
19118
19119
19120
19121
19122
19123
19124
19125
19126
19127
19128
19129
19130
19131
19132
19133
19134
19135
19136
19137
19138
19139
19140
19141
19142
19143
19144
19145
19146
19147
19148
19149
19150
19151
19152
19153
19154
19155
19156
19157
19158
19159
19160
19161
19162
19163
19164
19165
19166
19167
19168
19169
19170
19171
19172
19173
19174
19175
19176
19177
19178
19179
19180
19181
19182
19183
19184
19185
19186
19187
19188
19189
19190
19191
19192
19193
19194
19195
19196
19197
19198
19199
19200
19201
19202
19203
19204
19205
19206
19207
19208
19209
19210
19211
19212
19213
19214
19215
19216
19217
19218
19219
19220
19221
19222
19223
19224
19225
19226
19227
19228
19229
19230
19231
19232
19233
19234
19235
19236
19237
19238
19239
19240
19241
19242
19243
19244
19245
19246
19247
19248
19249
19250
19251
19252
19253
19254
19255
19256
19257
19258
19259
19260
19261
19262
19263
19264
19265
19266
19267
19268
19269
19270
19271
19272
19273
19274
19275
19276
19277
19278
19279
19280
19281
19282
19283
19284
19285
19286
19287
19288
19289
19290
19291
19292
19293
19294
19295
19296
19297
19298
19299
19300
19301
19302
19303
19304
19305
19306
19307
19308
19309
19310
19311
19312
19313
19314
19315
19316
19317
19318
19319
19320
19321
19322
19323
19324
19325
19326
19327
19328
19329
19330
19331
19332
19333
19334
19335
19336
19337
19338
19339
19340
19341
19342
19343
19344
19345
19346
19347
19348
19349
19350
19351
19352
19353
19354
19355
19356
19357
19358
19359
19360
19361
19362
19363
19364
19365
19366
19367
19368
19369
19370
19371
19372
19373
19374
19375
19376
19377
19378
19379
19380
19381
19382
19383
19384
19385
19386
19387
19388
19389
19390
19391
19392
19393
19394
19395
19396
19397
19398
19399
19400
19401
19402
19403
19404
19405
19406
19407
19408
19409
19410
19411
19412
19413
19414
19415
19416
19417
19418
19419
19420
19421
19422
19423
19424
19425
19426
19427
19428
19429
19430
19431
19432
19433
19434
19435
19436
19437
19438
19439
19440
19441
19442
19443
19444
19445
19446
19447
19448
19449
19450
19451
19452
19453
19454
19455
19456
19457
19458
19459
19460
19461
19462
19463
19464
19465
19466
19467
19468
19469
19470
19471
19472
19473
19474
19475
19476
19477
19478
19479
19480
19481
19482
19483
19484
19485
19486
19487
19488
19489
19490
19491
19492
19493
19494
19495
19496
19497
19498
19499
19500
19501
19502
19503
19504
19505
19506
19507
19508
19509
19510
19511
19512
19513
19514
19515
19516
19517
19518
19519
19520
19521
19522
19523
19524
19525
19526
19527
19528
19529
19530
19531
19532
19533
19534
19535
19536
19537
19538
19539
19540
19541
19542
19543
19544
19545
19546
19547
19548
19549
19550
19551
19552
19553
19554
19555
19556
19557
19558
19559
19560
19561
19562
19563
19564
19565
19566
19567
19568
19569
19570
19571
19572
19573
19574
19575
19576
19577
19578
19579
19580
19581
19582
19583
19584
19585
19586
19587
19588
19589
19590
19591
19592
19593
19594
19595
19596
19597
19598
19599
19600
19601
19602
19603
19604
19605
19606
19607
19608
19609
19610
19611
19612
19613
19614
19615
19616
19617
19618
19619
19620
19621
19622
19623
19624
19625
19626
19627
19628
19629
19630
19631
19632
19633
19634
19635
19636
19637
19638
19639
19640
19641
19642
19643
19644
19645
19646
19647
19648
19649
19650
19651
19652
19653
19654
19655
19656
19657
19658
19659
19660
19661
19662
19663
19664
19665
19666
19667
19668
19669
19670
19671
19672
19673
19674
19675
19676
19677
19678
19679
19680
19681
19682
19683
19684
19685
19686
19687
19688
19689
19690
19691
19692
19693
19694
19695
19696
19697
19698
19699
19700
19701
19702
19703
19704
19705
19706
19707
19708
19709
19710
19711
19712
19713
19714
19715
19716
19717
19718
19719
19720
19721
19722
19723
19724
19725
19726
19727
19728
19729
19730
19731
19732
19733
19734
19735
19736
19737
19738
19739
19740
19741
19742
19743
19744
19745
19746
19747
19748
19749
19750
19751
19752
19753
19754
19755
19756
19757
19758
19759
19760
19761
19762
19763
19764
19765
19766
19767
19768
19769
19770
19771
19772
19773
19774
19775
19776
19777
19778
19779
19780
19781
19782
19783
19784
19785
19786
19787
19788
19789
19790
19791
19792
19793
19794
19795
19796
19797
19798
19799
19800
19801
19802
19803
19804
19805
19806
19807
19808
19809
19810
19811
19812
19813
19814
19815
19816
19817
19818
19819
19820
19821
19822
19823
19824
19825
19826
19827
19828
19829
19830
19831
19832
19833
19834
19835
19836
19837
19838
19839
19840
19841
19842
19843
19844
19845
19846
19847
19848
19849
19850
19851
19852
19853
19854
19855
19856
19857
19858
19859
19860
19861
19862
19863
19864
19865
19866
19867
19868
19869
19870
19871
19872
19873
19874
19875
19876
19877
19878
19879
19880
19881
19882
19883
19884
19885
19886
19887
19888
19889
19890
19891
19892
19893
19894
19895
19896
19897
19898
19899
19900
19901
19902
19903
19904
19905
19906
19907
19908
19909
19910
19911
19912
19913
19914
19915
19916
19917
19918
19919
19920
19921
19922
19923
19924
19925
19926
19927
19928
19929
19930
19931
19932
19933
19934
19935
19936
19937
19938
19939
19940
19941
19942
19943
19944
19945
19946
19947
19948
19949
19950
19951
19952
19953
19954
19955
19956
19957
19958
19959
19960
19961
19962
19963
19964
19965
19966
19967
19968
19969
19970
19971
19972
19973
19974
19975
19976
19977
19978
19979
19980
19981
19982
19983
19984
19985
19986
19987
19988
19989
19990
19991
19992
19993
19994
19995
19996
19997
19998
19999
20000
20001
20002
20003
20004
20005
20006
20007
20008
20009
20010
20011
20012
20013
20014
20015
20016
20017
20018
20019
20020
20021
20022
20023
20024
20025
20026
20027
20028
20029
20030
20031
20032
20033
20034
20035
20036
20037
20038
20039
20040
20041
20042
20043
20044
20045
20046
20047
20048
20049
20050
20051
20052
20053
20054
20055
20056
20057
20058
20059
20060
20061
20062
20063
20064
20065
20066
20067
20068
20069
20070
20071
20072
20073
20074
20075
20076
20077
20078
20079
20080
20081
20082
20083
20084
20085
20086
20087
20088
20089
20090
20091
20092
20093
20094
20095
20096
20097
20098
20099
20100
20101
20102
20103
20104
20105
20106
20107
20108
20109
20110
20111
20112
20113
20114
20115
20116
20117
20118
20119
20120
20121
20122
20123
20124
20125
20126
20127
20128
20129
20130
20131
20132
20133
20134
20135
20136
20137
20138
20139
20140
20141
20142
20143
20144
20145
20146
20147
20148
20149
20150
20151
20152
20153
20154
20155
20156
20157
20158
20159
20160
20161
20162
20163
20164
20165
20166
20167
20168
20169
20170
20171
20172
20173
20174
20175
20176
20177
20178
20179
20180
20181
20182
20183
20184
20185
20186
20187
20188
20189
20190
20191
20192
20193
20194
20195
20196
20197
20198
20199
20200
20201
20202
20203
20204
20205
20206
20207
20208
20209
20210
20211
20212
20213
20214
20215
20216
20217
20218
20219
20220
20221
20222
20223
20224
20225
20226
20227
20228
20229
20230
20231
20232
20233
20234
20235
20236
20237
20238
20239
20240
20241
20242
20243
20244
20245
20246
20247
20248
20249
20250
20251
20252
20253
20254
20255
20256
20257
20258
20259
20260
20261
20262
20263
20264
20265
20266
20267
20268
20269
20270
20271
20272
20273
20274
20275
20276
20277
20278
20279
20280
20281
20282
20283
20284
20285
20286
20287
20288
20289
20290
20291
20292
20293
20294
20295
20296
20297
20298
20299
20300
20301
20302
20303
20304
20305
20306
20307
20308
20309
20310
20311
20312
20313
20314
20315
20316
20317
20318
20319
20320
20321
20322
20323
20324
20325
20326
20327
20328
20329
20330
20331
20332
20333
20334
20335
20336
20337
20338
20339
20340
20341
20342
20343
20344
20345
20346
20347
20348
20349
20350
20351
20352
20353
20354
20355
20356
20357
20358
20359
20360
20361
20362
20363
20364
20365
20366
20367
20368
20369
20370
20371
20372
20373
20374
20375
20376
20377
20378
20379
20380
20381
20382
20383
20384
20385
20386
20387
20388
20389
20390
20391
20392
20393
20394
20395
20396
20397
20398
20399
20400
20401
20402
20403
20404
20405
20406
20407
20408
20409
20410
20411
20412
20413
20414
20415
20416
20417
20418
20419
20420
20421
20422
20423
20424
20425
20426
20427
20428
20429
20430
20431
20432
20433
20434
20435
20436
20437
20438
20439
20440
20441
20442
20443
20444
20445
20446
20447
20448
20449
20450
20451
20452
20453
20454
20455
20456
20457
20458
20459
20460
20461
20462
20463
20464
20465
20466
20467
20468
20469
20470
20471
20472
20473
20474
20475
20476
20477
20478
20479
20480
20481
20482
20483
20484
20485
20486
20487
20488
20489
20490
20491
20492
20493
20494
20495
20496
20497
20498
20499
20500
20501
20502
20503
20504
20505
20506
20507
20508
20509
20510
20511
20512
20513
20514
20515
20516
20517
20518
20519
20520
20521
20522
20523
20524
20525
20526
20527
20528
20529
20530
20531
20532
20533
20534
20535
20536
20537
20538
20539
20540
20541
20542
20543
20544
20545
20546
20547
20548
20549
20550
20551
20552
20553
20554
20555
20556
20557
20558
20559
20560
20561
20562
20563
20564
20565
20566
20567
20568
20569
20570
20571
20572
20573
20574
20575
20576
20577
20578
20579
20580
20581
20582
20583
20584
20585
20586
20587
20588
20589
20590
20591
20592
20593
20594
20595
20596
20597
20598
20599
20600
20601
20602
20603
20604
20605
20606
20607
20608
20609
20610
20611
20612
20613
20614
20615
20616
20617
20618
20619
20620
20621
20622
20623
20624
20625
20626
20627
20628
20629
20630
20631
20632
20633
20634
20635
20636
20637
20638
20639
20640
20641
20642
20643
20644
20645
20646
20647
20648
20649
20650
20651
20652
20653
20654
20655
20656
20657
20658
20659
20660
20661
20662
20663
20664
20665
20666
20667
20668
20669
20670
20671
20672
20673
20674
20675
20676
20677
20678
20679
20680
20681
20682
20683
20684
20685
20686
20687
20688
20689
20690
20691
20692
20693
20694
20695
20696
20697
20698
20699
20700
20701
20702
20703
20704
20705
20706
20707
20708
20709
20710
20711
20712
20713
20714
20715
20716
20717
20718
20719
20720
20721
20722
20723
20724
20725
20726
20727
20728
20729
20730
20731
20732
20733
20734
20735
20736
20737
20738
20739
20740
20741
20742
20743
20744
20745
20746
20747
20748
20749
20750
20751
20752
20753
20754
20755
20756
20757
20758
20759
20760
20761
20762
20763
20764
20765
20766
20767
20768
20769
20770
20771
20772
20773
20774
20775
20776
20777
20778
20779
20780
20781
20782
20783
20784
20785
20786
20787
20788
20789
20790
20791
20792
20793
20794
20795
20796
20797
20798
20799
20800
20801
20802
20803
20804
20805
20806
20807
20808
20809
20810
20811
20812
20813
20814
20815
20816
20817
20818
20819
20820
20821
20822
20823
20824
20825
20826
20827
20828
20829
20830
20831
20832
20833
20834
20835
20836
20837
20838
20839
20840
20841
20842
20843
20844
20845
20846
20847
20848
20849
20850
20851
20852
20853
20854
20855
20856
20857
20858
20859
20860
20861
20862
20863
20864
20865
20866
20867
20868
20869
20870
20871
20872
20873
20874
20875
20876
20877
20878
20879
20880
20881
20882
20883
20884
20885
20886
20887
20888
20889
20890
20891
20892
20893
20894
20895
20896
20897
20898
20899
20900
20901
20902
20903
20904
20905
20906
20907
20908
20909
20910
20911
20912
20913
20914
20915
20916
20917
20918
20919
20920
20921
20922
20923
20924
20925
20926
20927
20928
20929
20930
20931
20932
20933
20934
20935
20936
20937
20938
20939
20940
20941
20942
20943
20944
20945
20946
20947
20948
20949
20950
20951
20952
20953
20954
20955
20956
20957
20958
20959
20960
20961
20962
20963
20964
20965
20966
20967
20968
20969
20970
20971
20972
20973
20974
20975
20976
20977
20978
20979
20980
20981
20982
20983
20984
20985
20986
20987
20988
20989
20990
20991
20992
20993
20994
20995
20996
20997
20998
20999
21000
21001
21002
21003
21004
21005
21006
21007
21008
21009
21010
21011
21012
21013
21014
21015
21016
21017
21018
21019
21020
21021
21022
21023
21024
21025
21026
21027
21028
21029
21030
21031
21032
21033
21034
21035
21036
21037
21038
21039
21040
21041
21042
21043
21044
21045
21046
21047
21048
21049
21050
21051
21052
21053
21054
21055
21056
21057
21058
21059
21060
21061
21062
21063
21064
21065
21066
21067
21068
21069
21070
21071
21072
21073
21074
21075
21076
21077
21078
21079
21080
21081
21082
21083
21084
21085
21086
21087
21088
21089
21090
21091
21092
21093
21094
21095
21096
21097
21098
21099
21100
21101
21102
21103
21104
21105
21106
21107
21108
21109
21110
21111
21112
21113
21114
21115
21116
21117
21118
21119
21120
21121
21122
21123
21124
21125
21126
21127
21128
21129
21130
21131
21132
21133
21134
21135
21136
21137
21138
21139
21140
21141
21142
21143
21144
21145
21146
21147
21148
21149
21150
21151
21152
21153
21154
21155
21156
21157
21158
21159
21160
21161
21162
21163
21164
21165
21166
21167
21168
21169
21170
21171
21172
21173
21174
21175
21176
21177
21178
21179
21180
21181
21182
21183
21184
21185
21186
21187
21188
21189
21190
21191
21192
21193
21194
21195
21196
21197
21198
21199
21200
21201
21202
21203
21204
21205
21206
21207
21208
21209
21210
21211
21212
21213
21214
21215
21216
21217
21218
21219
21220
21221
21222
21223
21224
21225
21226
21227
21228
21229
21230
21231
21232
21233
21234
21235
21236
21237
21238
21239
21240
21241
21242
21243
21244
21245
21246
21247
21248
21249
21250
21251
21252
21253
21254
21255
21256
21257
21258
21259
21260
21261
21262
21263
21264
21265
21266
21267
21268
21269
21270
21271
21272
21273
21274
21275
21276
21277
21278
21279
21280
21281
21282
21283
21284
21285
21286
21287
21288
21289
21290
21291
21292
21293
21294
21295
21296
21297
21298
21299
21300
21301
21302
21303
21304
21305
21306
21307
21308
21309
21310
21311
21312
21313
21314
21315
21316
21317
21318
21319
21320
21321
21322
21323
21324
21325
21326
21327
21328
21329
21330
21331
21332
21333
21334
21335
21336
21337
21338
21339
21340
21341
21342
21343
21344
21345
21346
21347
21348
21349
21350
21351
21352
21353
21354
21355
21356
21357
21358
21359
21360
21361
21362
21363
21364
21365
21366
21367
21368
21369
21370
21371
21372
21373
21374
21375
21376
21377
21378
21379
21380
21381
21382
21383
21384
21385
21386
21387
21388
21389
21390
21391
21392
21393
21394
21395
21396
21397
21398
21399
21400
21401
21402
21403
21404
21405
21406
21407
21408
21409
21410
21411
21412
21413
21414
21415
21416
21417
21418
21419
21420
21421
21422
21423
21424
21425
21426
21427
21428
21429
21430
21431
21432
21433
21434
21435
21436
21437
21438
21439
21440
21441
21442
21443
21444
21445
21446
21447
21448
21449
21450
21451
21452
21453
21454
21455
21456
21457
21458
21459
21460
21461
21462
21463
21464
21465
21466
21467
21468
21469
21470
21471
21472
21473
21474
21475
21476
21477
21478
21479
21480
21481
21482
21483
21484
21485
21486
21487
21488
21489
21490
21491
21492
21493
21494
21495
21496
21497
21498
21499
21500
21501
21502
21503
21504
21505
21506
21507
21508
21509
21510
21511
21512
21513
21514
21515
21516
21517
21518
21519
21520
21521
21522
21523
21524
21525
21526
21527
21528
21529
21530
21531
21532
21533
21534
21535
21536
21537
21538
21539
21540
21541
21542
21543
21544
21545
21546
21547
21548
21549
21550
21551
21552
21553
21554
21555
21556
21557
21558
21559
21560
21561
21562
21563
21564
21565
21566
21567
21568
21569
21570
21571
21572
21573
21574
21575
21576
21577
21578
21579
21580
21581
21582
21583
21584
21585
21586
21587
21588
21589
21590
21591
21592
21593
21594
21595
21596
21597
21598
21599
21600
21601
21602
21603
21604
21605
21606
21607
21608
21609
21610
21611
21612
21613
21614
21615
21616
21617
21618
21619
21620
21621
21622
21623
21624
21625
21626
21627
21628
21629
21630
21631
21632
21633
21634
21635
21636
21637
21638
21639
21640
21641
21642
21643
21644
21645
21646
21647
21648
21649
21650
21651
21652
21653
21654
21655
21656
21657
21658
21659
21660
21661
21662
21663
21664
21665
21666
21667
21668
21669
21670
21671
21672
21673
21674
21675
21676
21677
21678
21679
21680
21681
21682
21683
21684
21685
21686
21687
21688
21689
21690
21691
21692
21693
21694
21695
21696
21697
21698
21699
21700
21701
21702
21703
21704
21705
21706
21707
21708
21709
21710
21711
21712
21713
21714
21715
21716
21717
21718
21719
21720
21721
21722
21723
21724
21725
21726
21727
21728
21729
21730
21731
21732
21733
21734
21735
21736
21737
21738
21739
21740
21741
21742
21743
21744
21745
21746
21747
21748
21749
21750
21751
21752
21753
21754
21755
21756
21757
21758
21759
21760
21761
21762
21763
21764
21765
21766
21767
21768
21769
21770
21771
21772
21773
21774
21775
21776
21777
21778
21779
21780
21781
21782
21783
21784
21785
21786
21787
21788
21789
21790
21791
21792
21793
21794
21795
21796
21797
21798
21799
21800
21801
21802
21803
21804
21805
21806
21807
21808
21809
21810
21811
21812
21813
21814
21815
21816
21817
21818
21819
21820
21821
21822
21823
21824
21825
21826
21827
21828
21829
21830
21831
21832
21833
21834
21835
21836
21837
21838
21839
21840
21841
21842
21843
21844
21845
21846
21847
21848
21849
21850
21851
21852
21853
21854
21855
21856
21857
21858
21859
21860
21861
21862
21863
21864
21865
21866
21867
21868
21869
21870
21871
21872
21873
21874
21875
21876
21877
21878
21879
21880
21881
21882
21883
21884
21885
21886
21887
21888
21889
21890
21891
21892
21893
21894
21895
21896
21897
21898
21899
21900
21901
21902
21903
21904
21905
21906
21907
21908
21909
21910
21911
21912
21913
21914
21915
21916
21917
21918
21919
21920
21921
21922
21923
21924
21925
21926
21927
21928
21929
21930
21931
21932
21933
21934
21935
21936
21937
21938
21939
21940
21941
21942
21943
21944
21945
21946
21947
21948
21949
21950
21951
21952
21953
21954
21955
21956
21957
21958
21959
21960
21961
21962
21963
21964
21965
21966
21967
21968
21969
21970
21971
21972
21973
21974
21975
21976
21977
21978
21979
21980
21981
21982
21983
21984
21985
21986
21987
21988
21989
21990
21991
21992
21993
21994
21995
21996
21997
21998
21999
22000
22001
22002
22003
22004
22005
22006
22007
22008
22009
22010
22011
22012
22013
22014
22015
22016
22017
22018
22019
22020
22021
22022
22023
22024
22025
22026
22027
22028
22029
22030
22031
22032
22033
22034
22035
22036
22037
22038
22039
22040
22041
22042
22043
22044
22045
22046
22047
22048
22049
22050
22051
22052
22053
22054
22055
22056
22057
22058
22059
22060
22061
22062
22063
22064
22065
22066
22067
22068
22069
22070
22071
22072
22073
22074
22075
22076
22077
22078
22079
22080
22081
22082
22083
22084
22085
22086
22087
22088
22089
22090
22091
22092
22093
22094
22095
22096
22097
22098
22099
22100
22101
22102
22103
22104
22105
22106
22107
22108
22109
22110
22111
22112
22113
22114
22115
22116
22117
22118
22119
22120
22121
22122
22123
22124
22125
22126
22127
22128
22129
22130
22131
22132
22133
22134
22135
22136
22137
22138
22139
22140
22141
22142
22143
22144
22145
22146
22147
22148
22149
22150
22151
22152
22153
22154
22155
22156
22157
22158
22159
22160
22161
22162
22163
22164
22165
22166
22167
22168
22169
22170
22171
22172
22173
22174
22175
22176
22177
22178
22179
22180
22181
22182
22183
22184
22185
22186
22187
22188
22189
22190
22191
22192
22193
22194
22195
22196
22197
22198
22199
22200
22201
22202
22203
22204
22205
22206
22207
22208
22209
22210
22211
22212
22213
22214
22215
22216
22217
22218
22219
22220
22221
22222
22223
22224
22225
22226
22227
22228
22229
22230
22231
22232
22233
22234
22235
22236
22237
22238
22239
22240
22241
22242
22243
22244
22245
22246
22247
22248
22249
22250
22251
22252
22253
22254
22255
22256
22257
22258
22259
22260
22261
22262
22263
22264
22265
22266
22267
22268
22269
22270
22271
22272
22273
22274
22275
22276
22277
22278
22279
22280
22281
22282
22283
22284
22285
22286
22287
22288
22289
22290
22291
22292
22293
22294
22295
22296
22297
22298
22299
22300
22301
22302
22303
22304
22305
22306
22307
22308
22309
22310
22311
22312
22313
22314
22315
22316
22317
22318
22319
22320
22321
22322
22323
22324
22325
22326
22327
22328
22329
22330
22331
22332
22333
22334
22335
22336
22337
22338
22339
22340
22341
22342
22343
22344
22345
22346
22347
22348
22349
22350
22351
22352
22353
22354
22355
22356
22357
22358
22359
22360
22361
22362
22363
22364
22365
22366
22367
22368
22369
22370
22371
22372
22373
22374
22375
22376
22377
22378
22379
22380
22381
22382
22383
22384
22385
22386
22387
22388
22389
22390
22391
22392
22393
22394
22395
22396
22397
22398
22399
22400
22401
22402
22403
22404
22405
22406
22407
22408
22409
22410
22411
22412
22413
22414
22415
22416
22417
22418
22419
22420
22421
22422
22423
22424
22425
22426
22427
22428
22429
22430
22431
22432
22433
22434
22435
22436
22437
22438
22439
22440
22441
22442
22443
22444
22445
22446
22447
22448
22449
22450
22451
22452
22453
22454
22455
22456
22457
22458
22459
22460
22461
22462
22463
22464
22465
22466
22467
22468
22469
22470
22471
22472
22473
22474
22475
22476
22477
22478
22479
22480
22481
22482
22483
22484
22485
22486
22487
22488
22489
22490
22491
22492
22493
22494
22495
22496
22497
22498
22499
22500
22501
22502
22503
22504
22505
22506
22507
22508
22509
22510
22511
22512
22513
22514
22515
22516
22517
22518
22519
22520
22521
22522
22523
22524
22525
22526
22527
22528
22529
22530
22531
22532
22533
22534
22535
22536
22537
22538
22539
22540
22541
22542
22543
22544
22545
22546
22547
22548
22549
22550
22551
22552
22553
22554
22555
22556
22557
22558
22559
22560
22561
22562
22563
22564
22565
22566
22567
22568
22569
22570
22571
22572
22573
22574
22575
22576
22577
22578
22579
22580
22581
22582
22583
22584
22585
22586
22587
22588
22589
22590
22591
22592
22593
22594
22595
22596
22597
22598
22599
22600
22601
22602
22603
22604
22605
22606
22607
22608
22609
22610
22611
22612
22613
22614
22615
22616
22617
22618
22619
22620
22621
22622
22623
22624
22625
22626
22627
22628
22629
22630
22631
22632
22633
22634
22635
22636
22637
22638
22639
22640
22641
22642
22643
22644
22645
22646
22647
22648
22649
22650
22651
22652
22653
22654
22655
22656
22657
22658
22659
22660
22661
22662
22663
22664
22665
22666
22667
22668
22669
22670
22671
22672
22673
22674
22675
22676
22677
22678
22679
22680
22681
22682
22683
22684
22685
22686
22687
22688
22689
22690
22691
22692
22693
22694
22695
22696
22697
22698
22699
22700
22701
22702
22703
22704
22705
22706
22707
22708
22709
22710
22711
22712
22713
22714
22715
22716
22717
22718
22719
22720
22721
22722
22723
22724
22725
22726
22727
22728
22729
22730
22731
22732
22733
22734
22735
22736
22737
22738
22739
22740
22741
22742
22743
22744
22745
22746
22747
22748
22749
22750
22751
22752
22753
22754
22755
22756
22757
22758
22759
22760
22761
22762
22763
22764
22765
22766
22767
22768
22769
22770
22771
22772
22773
22774
22775
22776
22777
22778
22779
22780
22781
22782
22783
22784
22785
22786
22787
22788
22789
22790
22791
22792
22793
22794
22795
22796
22797
22798
22799
22800
22801
22802
22803
22804
22805
22806
22807
22808
22809
22810
22811
22812
22813
22814
22815
22816
22817
22818
22819
22820
22821
22822
22823
22824
22825
22826
22827
22828
22829
22830
22831
22832
22833
22834
22835
22836
22837
22838
22839
22840
22841
22842
22843
22844
22845
22846
22847
22848
22849
22850
22851
22852
22853
22854
22855
22856
22857
22858
22859
22860
22861
22862
22863
22864
22865
22866
22867
22868
22869
22870
22871
22872
22873
22874
22875
22876
22877
22878
22879
22880
22881
22882
22883
22884
22885
22886
22887
22888
22889
22890
22891
22892
22893
22894
22895
22896
22897
22898
22899
22900
22901
22902
22903
22904
22905
22906
22907
22908
22909
22910
22911
22912
22913
22914
22915
22916
22917
22918
22919
22920
22921
22922
22923
22924
22925
22926
22927
22928
22929
22930
22931
22932
22933
22934
22935
22936
22937
22938
22939
22940
22941
22942
22943
22944
22945
22946
22947
22948
22949
22950
22951
22952
22953
22954
22955
22956
22957
22958
22959
22960
22961
22962
22963
22964
22965
22966
22967
22968
22969
22970
22971
22972
22973
22974
22975
22976
22977
22978
22979
22980
22981
22982
22983
22984
22985
22986
22987
22988
22989
22990
22991
22992
22993
22994
22995
22996
22997
22998
22999
23000
23001
23002
23003
23004
23005
23006
23007
23008
23009
23010
23011
23012
23013
23014
23015
23016
23017
23018
23019
23020
23021
23022
23023
23024
23025
23026
23027
23028
23029
23030
23031
23032
23033
23034
23035
23036
23037
23038
23039
23040
23041
23042
23043
23044
23045
23046
23047
23048
23049
23050
23051
23052
23053
23054
23055
23056
23057
23058
23059
23060
23061
23062
23063
23064
23065
23066
23067
23068
23069
23070
23071
23072
23073
23074
23075
23076
23077
23078
23079
23080
23081
23082
23083
23084
23085
23086
23087
23088
23089
23090
23091
23092
23093
23094
23095
23096
23097
23098
23099
23100
23101
23102
23103
23104
23105
23106
23107
23108
23109
23110
23111
23112
23113
23114
23115
23116
23117
23118
23119
23120
23121
23122
23123
23124
23125
23126
23127
23128
23129
23130
23131
23132
23133
23134
23135
23136
23137
23138
23139
23140
23141
23142
23143
23144
23145
23146
23147
23148
23149
23150
23151
23152
23153
23154
23155
23156
23157
23158
23159
23160
23161
23162
23163
23164
23165
23166
23167
23168
23169
23170
23171
23172
23173
23174
23175
23176
23177
23178
23179
23180
23181
23182
23183
23184
23185
23186
23187
23188
23189
23190
23191
23192
23193
23194
23195
23196
23197
23198
23199
23200
23201
23202
23203
23204
23205
23206
23207
23208
23209
23210
23211
23212
23213
23214
23215
23216
23217
23218
23219
23220
23221
23222
23223
23224
23225
23226
23227
23228
23229
23230
23231
23232
23233
23234
23235
23236
23237
23238
23239
23240
23241
23242
23243
23244
23245
23246
23247
23248
23249
23250
23251
23252
23253
23254
23255
23256
23257
23258
23259
23260
23261
23262
23263
23264
23265
23266
23267
23268
23269
23270
23271
23272
23273
23274
23275
23276
23277
23278
23279
23280
23281
23282
23283
23284
23285
23286
23287
23288
23289
23290
23291
23292
23293
23294
23295
23296
23297
23298
23299
23300
23301
23302
23303
23304
23305
23306
23307
23308
23309
23310
23311
23312
23313
23314
23315
23316
23317
23318
23319
23320
23321
23322
23323
23324
23325
23326
23327
23328
23329
23330
23331
23332
23333
23334
23335
23336
23337
23338
23339
23340
23341
23342
23343
23344
23345
23346
23347
23348
23349
23350
23351
23352
23353
23354
23355
23356
23357
23358
23359
23360
23361
23362
23363
23364
23365
23366
23367
23368
23369
23370
23371
23372
23373
23374
23375
23376
23377
23378
23379
23380
23381
23382
23383
23384
23385
23386
23387
23388
23389
23390
23391
23392
23393
23394
23395
23396
23397
23398
23399
23400
23401
23402
23403
23404
23405
23406
23407
23408
23409
23410
23411
23412
23413
23414
23415
23416
23417
23418
23419
23420
23421
23422
23423
23424
23425
23426
23427
23428
23429
23430
23431
23432
23433
23434
23435
23436
23437
23438
23439
23440
23441
23442
23443
23444
23445
23446
23447
23448
23449
23450
23451
23452
23453
23454
23455
23456
23457
23458
23459
23460
23461
23462
23463
23464
23465
23466
23467
23468
23469
23470
23471
23472
23473
23474
23475
23476
23477
23478
23479
23480
23481
23482
23483
23484
23485
23486
23487
23488
23489
23490
23491
23492
23493
23494
23495
23496
23497
23498
23499
23500
23501
23502
23503
23504
23505
23506
23507
23508
23509
23510
23511
23512
23513
23514
23515
23516
23517
23518
23519
23520
23521
23522
23523
23524
23525
23526
23527
23528
23529
23530
23531
23532
23533
23534
23535
23536
23537
23538
23539
23540
23541
23542
23543
23544
23545
23546
23547
23548
23549
23550
23551
23552
23553
23554
23555
23556
23557
23558
23559
23560
23561
23562
23563
23564
23565
23566
23567
23568
23569
23570
23571
23572
23573
23574
23575
23576
23577
23578
23579
23580
23581
23582
23583
23584
23585
23586
23587
23588
23589
23590
23591
23592
23593
23594
23595
23596
23597
23598
23599
23600
23601
23602
23603
23604
23605
23606
23607
23608
23609
23610
23611
23612
23613
23614
23615
23616
23617
23618
23619
23620
23621
23622
23623
23624
23625
23626
23627
23628
23629
23630
23631
23632
23633
23634
23635
23636
23637
23638
23639
23640
23641
23642
23643
23644
23645
23646
23647
23648
23649
23650
23651
23652
23653
23654
23655
23656
23657
23658
23659
23660
23661
23662
23663
23664
23665
23666
23667
23668
23669
23670
23671
23672
23673
23674
23675
23676
23677
23678
23679
23680
23681
23682
23683
23684
23685
23686
23687
23688
23689
23690
23691
23692
23693
23694
23695
23696
23697
23698
23699
23700
23701
23702
23703
23704
23705
23706
23707
23708
23709
23710
23711
23712
23713
23714
23715
23716
23717
23718
23719
23720
23721
23722
23723
23724
23725
23726
23727
23728
23729
23730
23731
23732
23733
23734
23735
23736
23737
23738
23739
23740
23741
23742
23743
23744
23745
23746
23747
23748
23749
23750
23751
23752
23753
23754
23755
23756
23757
23758
23759
23760
23761
23762
23763
23764
23765
23766
23767
23768
23769
23770
23771
23772
23773
23774
23775
23776
23777
23778
23779
23780
23781
23782
23783
23784
23785
23786
23787
23788
23789
23790
23791
23792
23793
23794
23795
23796
23797
23798
23799
23800
23801
23802
23803
23804
23805
23806
23807
23808
23809
23810
23811
23812
23813
23814
23815
23816
23817
23818
23819
23820
23821
23822
23823
23824
23825
23826
23827
23828
23829
23830
23831
23832
23833
23834
23835
23836
23837
23838
23839
23840
23841
23842
23843
23844
23845
23846
23847
23848
23849
23850
23851
23852
23853
23854
23855
23856
23857
23858
23859
23860
23861
23862
23863
23864
23865
23866
23867
23868
23869
23870
23871
23872
23873
23874
23875
23876
23877
23878
23879
23880
23881
23882
23883
23884
23885
23886
23887
23888
23889
23890
23891
23892
23893
23894
23895
23896
23897
23898
23899
23900
23901
23902
23903
23904
23905
23906
23907
23908
23909
23910
23911
23912
23913
23914
23915
23916
23917
23918
23919
23920
23921
23922
23923
23924
23925
23926
23927
23928
23929
23930
23931
23932
23933
23934
23935
23936
23937
23938
23939
23940
23941
23942
23943
23944
23945
23946
23947
23948
23949
23950
23951
23952
23953
23954
23955
23956
23957
23958
23959
23960
23961
23962
23963
23964
23965
23966
23967
23968
23969
23970
23971
23972
23973
23974
23975
23976
23977
23978
23979
23980
23981
23982
23983
23984
23985
23986
23987
23988
23989
23990
23991
23992
23993
23994
23995
23996
23997
23998
23999
24000
24001
24002
24003
24004
24005
24006
24007
24008
24009
24010
24011
24012
24013
24014
24015
24016
24017
24018
24019
24020
24021
24022
24023
24024
24025
24026
24027
24028
24029
24030
24031
24032
24033
24034
24035
24036
24037
24038
24039
24040
24041
24042
24043
24044
24045
24046
24047
24048
24049
24050
24051
24052
24053
24054
24055
24056
24057
24058
24059
24060
24061
24062
24063
24064
24065
24066
24067
24068
24069
24070
24071
24072
24073
24074
24075
24076
24077
24078
24079
24080
24081
24082
24083
24084
24085
24086
24087
24088
24089
24090
24091
24092
24093
24094
24095
24096
24097
24098
24099
24100
24101
24102
24103
24104
24105
24106
24107
24108
24109
24110
24111
24112
24113
24114
24115
24116
24117
24118
24119
24120
24121
24122
24123
24124
24125
24126
24127
24128
24129
24130
24131
24132
24133
24134
24135
24136
24137
24138
24139
24140
24141
24142
24143
24144
24145
24146
24147
24148
24149
24150
24151
24152
24153
24154
24155
24156
24157
24158
24159
24160
24161
24162
24163
24164
24165
24166
24167
24168
24169
24170
24171
24172
24173
24174
24175
24176
24177
24178
24179
24180
24181
24182
24183
24184
24185
24186
24187
24188
24189
24190
24191
24192
24193
24194
24195
24196
24197
24198
24199
24200
24201
24202
24203
24204
24205
24206
24207
24208
24209
24210
24211
24212
24213
24214
24215
24216
24217
24218
24219
24220
24221
24222
24223
24224
24225
24226
24227
24228
24229
24230
24231
\def\faqfileversion{3.18}    \def\faqfiledate{2008-06-20}
%
% The above line defines the file version and date, and must remain
% the first line with any `assignment' in the file, or things will
% blow up in a stupid fashion
%
% get lists of CTAN labels
%
% configuration for the lists, if we're going to need to generate urls
% for the files
\InputIfFileExists{archive.cfg}{}{}
%
% ... directories
\input{dirctan}
%
% ... files
\input{filectan}

\section{Introduction}

This is a set of Frequently Asked Questions (\acro{FAQ}) for
English-speaking users of \TeX{}.  The questions answered here cover a
wide range of topics, but the actual typesetting issues are mostly
covered from the viewpoint of a \LaTeX{} user.

You may use the \acro{FAQ}
\begin{itemize}
\item by reading a printed document, 
\item by viewing a \acro{PDF} file, with hyperlinks to assist
  browsing: copies are available formatted for printing on
  \CTANhref{faq-a4}{A4 paper} or on % ! line break
  \CTANhref{faq-letter}{North American ``letter'' paper}, or
\item by using the \acro{FAQ}'s web interface (base \acro{URL}:
  \URL{http://www.tex.ac.uk/faq}); this version provides simple search
  capabilities, as well as a link to Google for a more sophisticated
  search restricted to the \acro{FAQ} itself, or
\item via Scott Pakin's \CTANhref{visualFAQ}{Visual FAQ}.
\end{itemize}

\begin{htmlversion}
% pseudo-subsection here, because of limitations of latex->html translator
\textbf{Caveat: Acquiring files}

Most answers in this \acro{FAQ} provide links for downloading
software; a large proportion of these links direct you to entire
directories on the \acro{CTAN} archives.  Unfortunately, some browsers
issue a sequence of commands that causes \acro{CTAN} servers to deny
the existence of compressed archive files of the directory, that the
server would be happy to create ``on the fly''.  The \acro{FAQ}
therefore offers three possible links for downloading directories
(that aren't already designated ``browse only''): the links give you
\extension{zip} and \extension{tar.gz} archives, and a link for browsing
the directory.

Fortunately, \acro{CTAN} is switching to statically-generated
directory archive files; many directories mentioned in this \acro{FAQ}
will also exist as \extension{zip} files on the archives, and won't fall
foul of the browser problem.  Of course, if the \extension{zip} file
does not exist, and the browser is playing up, you will need to use
the ``browse'' link.
\end{htmlversion}

\htmlignore
\subsection*{Finding the Files}

Unless otherwise specified, all files mentioned in this \acro{FAQ} are
available from a \acro{CTAN} archive, or from one of their mirrors.
\Qref[Question]{}{Q-archives} % this one doesn't need anchor text
gives details of the \acro{CTAN} archives, and how to retrieve files from
them.  If you don't have access to the Internet, the
\Qref*{\texlive{} distribution}{Q-CD} offers off-line snapshots of
the archives.

The reader should also note that the first directory name of the path
name of every file on \acro{CTAN} has been elided from what follows, for the
simple reason that it's always the same (\path{tex-archive/}).

To avoid confusion, we've also elided the full stop
from the end of any sentence whose last item is a path name (such
sentences are rare, and only occur at the end of paragraphs).  Though
the path names are set in a different font from running text, it's not
easy to distinguish the font of a single dot!
\endhtmlignore

\latexhtml{\subsection*{Origins}}{\textbf{Origins}}

The \acro{FAQ} was originated by the Committee of the \acro{UK} \TeX{}
Users' Group (\acro{UK}~\acro{TUG}) as a development of a regular
posting to the \emph{Usenet} newsgroup \Newsgroup{comp.text.tex} that
was maintained for some time by Bobby Bodenheimer.  The first
\acro{UK} version was much re-arranged and corrected from the
original, and little of Bodenheimer's work now remains.

The following people (at least~--- there are almost certainly others
whose names weren't correctly recorded) have contributed help or
advice on the development of the \acro{FAQ}:
Donald Arseneau,
Rosemary Bailey, % lots of initial set of maths answers
Barbara Beeton, % one of first reviewers outside cttee
Karl Berry,
Giuseppe Bilotta,
Charles Cameron,
Damian Cugley,
Michael Dewey,
Michael Downes, % (RIP) on (ams)maths stuff
Jean-Pierre Drucbert, % corrected my interpretation of minitoc
Michael Ernst, % alert on confusing colloquialism
Thomas Esser,
Ulrike Fischer, % spotted boondoggle in q-tabcellalign
                % args like \section improvement; general typos
Anthony Goreham,
Norman Gray,
Eitan Gurari, % comparative html translators
William Hammond, % lots of work on xml-related answers
John Harper, % patient help with q-robust ;-)
John Hammond, % corrections to q-protect
Troy Henderson, % metapost tutorials update
Hartmut Henkel,
Stephan Hennig, % text about vc in Q-RCS
John Hobby,
Morten H\textoslash gholm, % eagle eyes in search for problems
Berthold Horn, % lots of stuff on fonts
Ian Hutchinson, % comparative html translators
Werner Icking, % (RIP) answer on tex-music
William Ingram, % extension of transcinit
Alan Jeffrey, % another founding father
Regnor Jernsletten,
David Kastrup, % inter alia, suggested mention of lilypond
Oleg Katsitadze, % revision of q-eplain
Isaac Khabaza, % kindersley book
Ulrich Klauer, % pointed out twaddle in TeXpronounce
Markus Kohm, % help with functionality of Koma-script
David Kraus, % help with tocbibind (spotted embarrassing typo  :-} )
Ryszard Kubiak, % comment about q-driver
Simon Law,
Daniel Luecking,
Aditya Mahajan, % rewrite of q-context
Sanjoy Mahajan,
Andreas Matthias,
Brooks Moses, % editorial suggestion
Iain Murray, % alternative solution in q-hyperdupdest
Vilar Camara Neto, % explain breakurl pkg, suggest use of numprint
Dick Nickalls, % now a member of the committee
Ted Nieland,
Hans Nordhaug,
Pat Rau,
Heiko Oberdiek,
Piet van Oostrum,
Scott Pakin,
Oren Patashnik,
Steve Peter, % comprehensive review, lots of typos etc
Sebastian Rahtz, % without whom there would be no...
Philip Ratcliffe, % help with a bibtex oddity
Chris Rowley, % founding father
Jos\'e Carlos Santos, % very assiduous reader of new versions
Walter Schmidt,
Hans-Peter Schr\"ocker,
Joachim Schrod,
Maarten Sneep, % summary of c.t.t thread for outszwrng, inter alia
Axel Sommerfeldt, % suggested rewrite of q-hyperdupdest
James Szinger, % who responded on c.t.t to request for answer
Ulrik Vieth,
Mike Vulis,
Chris Walker, % revtex alert, ite suggestion (q-labelfig)
Peter Wilson, % several, incl functionality of memoir
Rick Zaccone and
Reinhard Zierke.

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\section{The Background}

\Question[Q-whatTeX]{What is \TeX{}?}

\TeX{} is a typesetting system written by
\href{http://sunburn.stanford.edu/~knuth/}{Donald E. Knuth}, who
says in the Preface to his book on \TeX{}
(see \Qref[question]{books about TeX}{Q-books}) that it is
%% beware line wrap
``\emph{intended for the creation of beautiful books~--- and especially for books that contain a lot of mathematics}''.

Knuth is Emeritus Professor of the Art of Computer Programming at
Stanford University in California, \acro{USA}.  Knuth developed the
first version of \TeX{} in 1978 to deal with revisions to his series
``the Art of Computer Programming''.  The idea proved popular and
Knuth produced a second version (in 1982) which is the basis of what
we use today.

Knuth developed a system of % ! line breaks
`\Qref*{literate programming}{Q-lit}' to write \TeX{},
and he provides the literate (\acro{WEB}) source of \TeX{} free of charge,
together with tools for processing the |web| source into something
that can be compiled and something that can be printed; there's never
any mystery about what \TeX{} does.  Furthermore, the \acro{WEB} system
provides mechanisms to port \TeX{} to new operating systems and
computers; and in order that one may have some confidence in the ports,
Knuth supplied a \Qref*{test}{Q-triptrap} by
means of which one may judge the fidelity of a \TeX{} system.  \TeX{}
and its documents are therefore highly portable.

\TeX{} is a macro processor, and offers its users a powerful
programming capability.  For this reason, \TeX{} on its own is a
pretty difficult beast to deal with, so Knuth provided a package of
macros for use with \TeX{} called \plaintex{}; \plaintex{} is
effectively the minimum set of macros one can usefully employ with
\TeX{}, together with some demonstration versions of higher-level
commands (the latter are better regarded as models than used as-is).
When people say they're ``programming in \TeX{}'', they usually mean
they're programming in \plaintex{}.

\Question[Q-TeXpronounce]{How should I pronounce ``\TeX{}''?}

The `X' is ``really'' the Greek letter % ! line break
Chi\nothtml{ (\ensuremath{\chi}, in lower case)}, and is pronounced by
English-speakers either a bit like the `ch' in the Scots word `loch'
([x] in the IPA) or (at a pinch, if you can't do the Greek sound) like
`k'.  It definitely is not pronounced `ks' (the Greek letter with that
sound doesn't look remotely like the Latin alphabet `X').

This curious usage derives from Knuth's explanation in the \TeX{}book
that the name comes from the Greek word for `art' or `craft'
(`\latexhtml{\ensuremath{\tau\epsilon\chi\nu\eta}}{\emph{techni}}'),
which is the root of the English word `technology'.  Knuth's logo for \TeX{} is
merely the uppercase version of the first three (Greek) letters of the
word, jiggled about a bit; we don't use that logo (and logos like it)
in this \acro{FAQ} (see % ! line break
\Qref[question]{Typesetting \TeX{}-related logos}{Q-logos}).

\Question[Q-MF]{What is \MF{}?}

\MF{} was written by Knuth as a companion to \TeX{}; whereas \TeX{}
defines the layout of glyphs on a page, \MF{} defines the shapes of
the glyphs and the relations between them.  \MF{} details the sizes of
glyphs, for \TeX{}'s benefit, and details the rasters used to
represent the glyphs, for the benefit of programs that will produce
printed output as post processes after a run of \TeX{}.

\MF{}'s language for defining fonts permits the expression of several
classes of things: first (of course), the simple geometry of the
glyphs; second, the properties of the print engine for which the
output is intended; and third, `meta'-information which can
distinguish different design sizes of the same font, or the difference
between two fonts that belong to the same (or related) families.

Knuth (and others) have designed a fair range of fonts using \MF{},
but font design using \MF{} is much more of a minority skill than is
\TeX{} macro-writing.  The complete \TeX{}-user nevertheless needs to
be aware of \MF{}, and to be able to run \MF{} to generate personal
copies of Meta-fonts that come her way.

\Question[Q-MP]{What is \MP{}?}

The \MP{} system (by John Hobby) implements a picture-drawing language
very much like that of \MF{} except that it outputs Encapsulated \PS{}
files instead of run-length-encoded bitmaps.  \MP{} is a powerful
language for producing figures for documents to be printed on \PS{}
printers, either directly or embedded in \AllTeX{} documents. It
includes facilities for directly integrating \TeX{} text and
mathematics with the graphics. (Knuth tells us that he uses nothing
but \MP{} for diagrams in text that he is writing.)

Although \PDFLaTeX{} cannot ordinarily handle \PS{} graphics, the
output of \MP{} is sufficiently simple and regular that \PDFLaTeX{}
can handle it direct, using code borrowed from \CONTeXT{}~--- see
\Qref[question]{graphics in \PDFLaTeX{}}{Q-pdftexgraphics}.

Much of \MP{}'s source code was copied from \MF{}'s sources, with
Knuth's permission.

A mailing list discussing \MP{} is available;
\begin{narrowversion} % really non-hyper
  subscribe via the \acro{TUG} \ProgName{mailman} interface at
  \URL{http://lists.tug.org/metapost}
\end{narrowversion}
\begin{wideversion} % really hyper
  subscribe via the % ! line break
  \href{http://lists.tug.org/metapost}{\acro{TUG} \ProgName{mailman} interface}.
\end{wideversion}
The \acro{TUG} website also hosts a % ! line break
\href{http://tug.org/metapost.html}{\MP{} summary page}.

\Question[Q-triptrap]{How can I be sure it's really \TeX{}?}

\TeX{} (and \MF{} and \MP{}) are written in a
\begin{narrowversion} % really "non-hyper"
  `literate' programming language called Web (\Qref{}{Q-lit})
\end{narrowversion}
\begin{wideversion}
  \Qref{`literate' programming}{Q-lit} language called Web
\end{wideversion}
which is designed to be portable across a wide range of computer
systems.  How, then, is a new version of \TeX{} checked?

Of course, any sensible software implementor will have his own suite
of tests to check that his software runs: those who port \TeX{} and
its friends to other platforms do indeed perform such tests.

Knuth, however, provides a `conformance test' for both \TeX{}
(\texttt{trip}) and \MF{} (\texttt{trap}).
%%% Is there a similar one for \MP{}?
He characterises these as `torture tests': they are designed not to
check the obvious things that ordinary typeset documents, or font
designs, will exercise, but rather to explore small alleyways off the
main path through the code of \TeX{}.  They are, to the casual reader,
pretty incomprehensible!

Once an implementation of \TeX{} has passed its \texttt{trip} test, or an
implementation of \MF{} has passed its \texttt{trap} test, then it may
in principle be distributed as a working version.  (In practice, any
distributor would test new versions against ``real'' documents or
fonts, too; \texttt{trip} and \texttt{trap} don't actually test any
for real world problems.


\Question[Q-y2k]{Are \TeX{} and friends Y2K compliant?}

\begin{description}
\item[Crashing:] None of \TeX{}, \MF{} or \MP{} can themselves crash
  due to any change whatever in the date of any sort.
\item[Timestamps:] In the original sources, a 2-digit year was
  stored as the creation time for format files and that value is
  printed in log-files.  These items should not be of general concern,
  since the only use of the date format file is to produce the log
  output, and the log file is designed for human readers only.
  
  Knuth announced in 1998 that implementors could
  alter this code without fear of being accused of non-compliance.
  Nearly all implementations that are being actively maintained had
  been modified to generate 4-digit years in the format file and the
  log, by the end of 1998.  The original sources themselves have now
  been modified so that 4-digit year numbers are stored.
\item[The \csx{year} primitive:] Certification of a \TeX{}
  implementation (see \Qref[question]{trip/trap testing}{Q-triptrap})
  does not require that \csx{year} return a meaningful value (which
  means that \TeX{} can, in principle, be implemented on platforms
  that don't make the value of the clock available to user programs).
  The \emph{\TeX{}book} (see
  \Qref[question]{TeX-related books}{Q-books}) defines \csx{year} as
  ``the current year of our Lord'', which is the only correct meaning
  for \csx{year} for those implementations which can supply a
  meaningful value, which is to say nearly all of them.

  In short, \TeX{} implementations should provide a value in \csx{year}
  giving the 4-digit year Anno Domini, or the value 1776 if the
  platform does not support a date function.

  Note that if the system itself fails to deliver a correct date to
  \TeX{}, then \csx{year} will of course return an incorrect value.
  \TeX{} cannot be considered Y2K compliant, in this sense, on a
system that is not itself Y2K compliant.
\item[Macros:] \TeX{} macros can in principle perform calculations on
  the basis of the value of \csx{year}.
  The \Qref*{LaTeX suite}{Q-latex}
  performs such calculations in a small number of places; the
  calculations performed in the current (supported) version of \LaTeX{} are
  known to be Y2K compliant.

  Other macros and macro packages should be individually checked.
\item[External software:] Software such as \acro{DVI} translators
  needs to be individually checked.
\end{description}

\Question[Q-etex]{What is \eTeX{}?}

While Knuth has declared that \TeX{} will never % !line break
\Qref*{change in any substantial way}{Q-TeXfuture}, there remain
things that one might wish had been done differently, or indeed
implemented at all.

The \acro{NTS} project set out to produce an advanced replacement for
\TeX{}, to provide a basis for developing such modifications: this
``New Typesetting System'' would share Knuth's aims, but would
implement the work in a modern way taking account of the lessons
learned with \TeX{}.  While a first demonstrator \acro{NTS} did
appear, it wasn't practically useful, and the project seems no longer
active.

In parallel with its work on \acro{NTS} itself, the project developed
a set of extensions that can be used with a (``true'') \TeX{} system.
Such a modified system is known as an \eTeX{} system, and the concept
has proved widely successful.  Indeed, current \TeX{} distributions
are delivered with most formats built with an \eTeX{}-based system (for
those who don't want them, \eTeX{}'s extensions can be disabled, leaving
a functionally standard \TeX{} system).

The extensions range from the seemingly simple (increasing the number
of available registers from 256 to 32768) through to extremely subtle
programming support.

\Qref*{\CONTeXT{}}{Q-context} has required \eTeX{} for its operation
for some time.

Some \LaTeX{} packages already specify the use of \eTeX{}.  Some such
packages may not work at all on a non-\eTeX{} system; others will
work, but not as well as on an \eTeX{} system.  The % ! line break
\Qref*{\LaTeX{} team}{Q-LaTeX3} has announced that future \LaTeX{}
packages (specifically those from the team, as opposed to those
individually contributed) may require \eTeX{} for optimum performance.

\Question[Q-whatpdftex]{What is \PDFTeX{}?}

\PDFTeX{} has entered the main stream of \TeX{} distributions: most
\LaTeX{} and \CONTeXT{} users nowadays use \PDFTeX{} whether they know
it or not (more precisely, they use an amalgam of \PDFTeX{} and
\Qref*{\eTeX{}}{Q-etex}).  So what is \PDFTeX{}?

\PDFTeX{} is a development of \TeX{} that is capable of generating
typeset \acro{PDF} output in place of \acro{DVI}.  \PDFTeX{} has
other capabilities, most notably in the area of fine typographic
detail (for example, its support for % ! line break
\begin{wideversion}
  \Qref{optimising line breaks}{Q-overfull}),
\end{wideversion}
\begin{narrowversion}
  % ( <- dummy for paren balancing
  optimising line breaks~--- \Qref{}{Q-overfull}),
\end{narrowversion}
but its greatest impact to date has been in the area of
\acro{PDF} output.

\PDFTeX{} started as a topic for H\`an \The{} Th\`anh's Master's~thesis,
and seems first to have been published in \TUGboat{} 18(4), in 1997
(though it was certainly discussed at the \acro{TUG}'96 conference in
Russia).

While the world was making good use of ``pre-releases'' of \PDFTeX{},
Th\`anh used it as a test-bed for the micro-typography which was the
prime subject of his Ph.D. research.  Since Th\`anh was finally
awarded his Ph.D., day-to-day maintenance and development of
\PDFTeX{}~1.0 (and later) has been in the hands of a group of
\PDFTeX{} maintainers (which includes Th\`anh); the group has managed
to maintain a stable platform for general use.

Development of \PDFTeX{} has (in essence) stopped: the brave new world
is to be \Qref*{\LuaTeX{}}{Q-luatex}.

\Question[Q-latex]{What is \LaTeX{}?}

\LaTeX{} is a \TeX{} macro package, originally written by Leslie Lamport, that
provides a document processing system.  \LaTeX{} allows markup to
describe the structure of a document, so that the user
need not think about presentation. By using document classes and
add-on packages, the same document can be produced in a variety of
different layouts.

Lamport says that \LaTeX{}
``\emph{represents a balance between functionality and ease of use}''.
This shows itself as a continual conflict that leads to
the need for such things as \acro{FAQ}s: \LaTeX{} \emph{can} 
meet most user requirements, but finding out \emph{how} is often
tricky.

\Question[Q-latex2e]{What is \LaTeXe{}?}

Lamport's last version of \LaTeX{} (\LaTeXo{}, last updated in 1992)
was superseded in 1994 by a new version (\LaTeXe{}) provided by
\Qref*{the \LaTeX{} team}{Q-LaTeX3}.
\LaTeXe{} is now the only readily-available version of
\LaTeX{}, and draws together several threads of \LaTeX{} development
from the later days of \LaTeXo{}.

\LaTeXe{} has several enhancements over \LaTeXo{}, but they were all
rather minor, with a view to continuity and stability rather than the
``big push'' that some had expected from the team.  \LaTeXe{}
continues to this day to offer a compatibility mode in which most
files prepared for use with \LaTeXo{} will run (albeit with somewhat
reduced performance, and subject to bitter complaints in the log
file).  Differences between \LaTeXe{} and \LaTeXo{} are
outlined in a series of `guide' files that are available in every
\LaTeX{} distribution (the same directory also contains ``news'' about
each new release of \LaTeXe{}).
\begin{ctanrefs}
\item[\nothtml{\rmfamily}\LaTeX{} guides and news]\CTANref{latexdoc}
\end{ctanrefs}


\nothtml{\begingroup\ifboldmathavail\boldmath\fi}
\Question[Q-latexpronounce]{How should I pronounce ``\LaTeX{}(\twee{})''?}
\nothtml{\afterquestion}

Lamport never recommended how one should pronounce \LaTeX{}, but a lot
of people pronounce it `Lay \TeX{}' or perhaps `Lah \TeX{}' (with
\TeX{} pronounced as the program itself; see
\Qref[question]{the rules for TeX}{Q-TeXpronounce}).  It is definitely
\emph{not} to be pronounced in the same way as the rubber-tree gum.

The `epsilon' in `\LaTeXe{}' is supposed to be suggestive of a small
improvement over the old \LaTeXo{}.  Nevertheless, most people
pronounce the name as `\LaTeX{}-two-ee'.

\Question[Q-plainvltx]{Should I use \plaintex{} or \LaTeX{}?}

There's no straightforward answer to this question.  Many people swear
by \plaintex{}, and produce highly respectable documents using it
(Knuth is an example of this, of course).  But equally, many people
are happy to let someone else take the design decisions for them,
accepting a small loss of flexibility in exchange for a saving of
brain power.

The arguments around this topic can provoke huge amounts of noise and
heat, without offering much by way of light; your best bet is to find
out what those around you are using, and to go with the crowd.  Later
on, you can always switch your allegiance; don't bother about it.

If you are preparing a manuscript for a publisher or journal, ask them
what markup they want before you
develop your own; many big publishers have developed their own
\AllTeX{} styles for journals and books, and insist that authors stick
closely to their markup.

\Question[Q-LaTeXandPlain]{How does \LaTeX{} relate to \plaintex{}?}

\LaTeX{} is a program written in the programming language \TeX{}.  (In
the same sense, any \LaTeX{} document is also a program, which is
designed to run `alongside', or `inside' \LaTeX{}, whichever metaphor
you prefer.)

\plaintex{} is also a program written in the programming language
\TeX{}.

Both exist because writing your documents in `raw' \TeX{} would
involve much reinventing of wheels for every document.  They both
serve as convenient aids to make document writing more pleasant:
\LaTeX{} is a far more extensive aid.

\LaTeX{} is close to being a superset of \plaintex{}.  Many documents
designed for \plaintex{} will work with \LaTeX{} with no more than
minor modifications (though some will require substantial work).

Interpretation of any \AllTeX{} program involves some data-driven
elements, and \LaTeX{} has a wider range of such elements than does
\plaintex{}.  As a result, the mapping from \LaTeX{} to \plaintex{}
is far less clear than that in the other direction~--- see a later
answer about \Qref*{translating to \plaintex{}}{Q-LaTeXtoPlain}.

\Question[Q-context]{What is \CONTeXT{}?}

\href{http://www.pragma-ade.com/}{\CONTeXT{}} is a macro package
developed by Hans Hagen of Pragma-Ade.  \CONTeXT{} is a
document-production system based, like \LaTeX{}, on the \TeX{}
typesetting system.  Whereas \LaTeX{} insulates the writer from
typographical details, \CONTeXT{} takes a complementary approach by
providing structured interfaces for handling typography, including
extensive support for colors, backgrounds, hyperlinks, presentations,
figure-text integration, and conditional compilation.  It gives the
user extensive control over formatting while making it easy to create
new layouts and styles without learning the \TeX{} macro
language. \CONTeXT{}'s unified design avoids the package clashes that
can happen with \LaTeX{}.

\CONTeXT{} also integrates MetaFun, a superset of \MP{} and a powerful
system for vector graphics.  MetaFun can be used as a stand-alone
system to produce figures, but its strength lies in enhancing
\CONTeXT{} documents with accurate graphic elements.

\CONTeXT{} allows the users to specify formatting commands in English,
Dutch, German, French, or Italian, and to use different typesetting
engines (\PDFTeX{}, Xe\TeX{}, Aleph, and soon \LuaTeX{}) without
changing the user interface. \CONTeXT{} is developed rapidly, often in
response to requests from the user community.

%%% RF's original version
%% developed by Hans Hagen, originally to
%% serve the needs of his (Dutch) firm Pragma.  It was designed with the
%% same general-purpose aims as \LaTeX{}, but (being younger) reflects
%% much more recent thinking about the structure of markup, etc.  In
%% particular, \CONTeXT{} can customise its markup to an
%% author's language (customising modules for Dutch, English and German
%% are provided, at present).
%%
%% \CONTeXT{} is well integrated, in all of its structure,
%% with the needs of hypertext markup, and in particular with the
%% facilities offered by \Qref*{\PDFTeX{}}{Q-whatpdftex}.
%% The default installation employs a version of \PDFTeX{} built with the
%% \Qref*{\eTeX{} extensions}{Q-etex}, which allows further flexibility.

\CONTeXT{} doesn't yet have quite such a large developer community as
does \LaTeX{}, but those developers who are active seem to have
prodigious energy.  Support is available via a % ! line break
\href{http://contextgarden.net}{\acro{WIKI} site} and via the
\href{http://www.ntg.nl/mailman/listinfo/ntg-context}{mailing list}.
\begin{ctanrefs}
\item[\nothtml{\rmfamily}\CONTeXT{} distribution]\CTANref{context}
\end{ctanrefs}

\nothtml{\begingroup\ifboldmathavail\boldmath\fi}
\Question[Q-AMSpkg]{What are the \acro{AMS} packages (\AMSTeX{}, \emph{etc}.)?}
\nothtml{\afterquestion}

\AMSTeX{} is a \TeX{} macro package, originally written by Michael Spivak for
the American Mathematical Society (\acro{AMS}) during 1983--1985 and
is described in the book ``\Qref*{The Joy of \TeX{}}{Q-books}''.
It is based on \plaintex{}, and provides many
features for producing more professional-looking maths formulas with
less burden on authors.  It pays attention to the finer details of
sizing and positioning that mathematical publishers care about. The
aspects covered include multi-line displayed equations, equation
numbering, ellipsis dots, matrices, double accents, multi-line
subscripts, syntax checking (faster processing on initial
error-checking \TeX{} runs), and other things.

As \LaTeX{} increased in popularity, authors asked to submit papers to
the \acro{AMS} in \LaTeX{}, and so the \acro{AMS} developed
\AMSLaTeX{}, which is a
collection of \LaTeX{} packages and classes that offer authors most of
the functionality of \AMSTeX{}.
The \acro{AMS} no longer recommends the use of \AMSTeX{}, and urges
its users to use \AMSLaTeX{} instead.
\checked{RAB}{1994/11/12} % edited by RF; input from Michael Downes, too
\begin{ctanrefs}
\item[\nothtml{\rmfamily}\AMSTeX{} distribution]\CTANref{amstex}
\item[\nothtml{\rmfamily}\AMSLaTeX{} distribution]\CTANref{amslatex}
\end{ctanrefs}

\Question[Q-eplain]{What is \Eplain{}?}

The \href{http://tug.org/eplain}{\Eplain{}}
macro package expands on and extends the definitions in \plaintex{}.
\Eplain{} is not intended to provide ``generic typesetting
capabilities'', as do \LaTeX{} or \Qref*{Texinfo}{Q-texinfo}.  Instead, it
defines macro tools that should be useful whatever commands you choose
to use when you prepare your manuscript.

For example, \Eplain{} does not have a command \csx{section},
which would format section headings in an ``appropriate'' way, as
\LaTeX{}'s \csx{section} does.  The philosophy of \Eplain{} is that
some people will always need or want to go beyond the macro designer's
idea of ``appropriate''.  Such canned macros are fine~--- as long as you
are willing to accept the resulting output.  If you don't like the
results, or if you are trying to match a different format, you are out
of luck.

On the other hand, almost everyone would like capabilities such as
cross-referencing by labels, so that you don't have to put actual page
numbers in the manuscript.  The authors of \Eplain{} are not aware of
any generally available macro packages that do not force their
typographic style on an author, and yet provide such capabilities.

Another useful feature of \Eplain{} is the ability to create PDF files
with hyperlinks.  The cross-referencing macros can implicitly generate
hyperlinks for the cross-references, but you can also create explicit
hyperlinks, both internal (pointing to a destination within the
current document) and external (pointing to another local document or
a URL).

Several \LaTeX{} packages provide capabilities which \plaintex{}
users are lacking, most notably text colouring and rotation provided by
the \Package{graphics} bundle (packages \Package{color} and
\Package{graphics}).  Although the \Package{graphics} bundle provides
a \plaintex{} ``loader'' for some of the packages, it is not a
trivial job to pass options to those packages under \plaintex{}, and
much of the functionality of the packages is accessed through package
options.  \Eplain{} extends the loader so that options can be passed
to the packages just as they are in \LaTeX{}.  The following packages are
known to work with \Eplain{}:  \Package{graphics}, \Package{graphicx},
\Package{color}, \Package{autopict} (\LaTeX{} picture environment),
\Package{psfrag}, and \Package{url}.

\href{http://tug.org/docs/html/eplain}{\Eplain{} documentation} is
available online, and there's
also a mailing list~--- sign up, or browse the list archives, via
\URL{http://tug.org/mailman/listinfo/tex-eplain}
\begin{ctanrefs}
\item[\nothtml{\rmfamily}\Eplain{} distribution]\CTANref{eplain}
\end{ctanrefs}

\Question[Q-lollipop]{What is Lollipop?}

Lollipop is a macro package written by Victor Eijkhout; it was used in
the production of his book ``\emph{\TeX{} by Topic}'' (see
\Qref[question]{\AllTeX{} Tutorials}{Q-ol-books}).  The manual says of
it:
\begin{quote}
  Lollipop is `\TeX{} made easy'. Lollipop is a macro package that
  functions as a toolbox for writing \TeX{} macros.  It was my
  intention to make macro writing so easy that implementing a fully
  new layout in \TeX{} would become a matter of less than an hour for
  an average document, and that it would be a task that could be
  accomplished by someone with only a very basic training in \TeX{}
  programming.

  Lollipop is an attempt to make structured text formatting available
  for environments where previously only \WYSIWYG{} packages could be
  used because adapting the layout is so much more easy with them than
  with traditional \TeX{} macro packages.
\end{quote}

The manual goes on to talk of ambitions to ``capture some of the
\LaTeX{} market share''; it's a very witty package, but little sign of
\htmlignore
it taking over from \LaTeX{} is detectable\dots{}\@
\endhtmlignore
\begin{htmlversion}
it taking over from \LaTeX{} is detectable\dots{}
\end{htmlversion}
An article about Lollipop appeared in \TUGboat{} 13(3).
\begin{ctanrefs}
\item[\nothtml{\rmfamily}Lollipop distribution]\CTANref{lollipop}
\end{ctanrefs}

\Question[Q-texinfo]{What is Texinfo?}

Texinfo is a documentation system that uses one source file to produce
both on-line information and printed output.  So instead of writing
two different documents, one for the on-line help and the other for a
typeset manual, you need write only one document source file.  When
the work is revised, you need only revise one document.  By
convention, Texinfo source file names end with a \extension{texi} or
\extension{texinfo} extension.

Texinfo is a macro language, somewhat similar to \LaTeX{}, but with
slightly less expressive power.  Its appearance is of course rather
similar to any \TeX{}-based macro language, except that its macros
start with \texttt{@} rather than the |\| that's more commonly used in
\TeX{} systems.

You can write and format Texinfo files into Info files within \acro{GNU}
\ProgName{emacs}, and read them using the \ProgName{emacs} Info
reader.  You can also format Texinfo files into Info files using
\ProgName{makeinfo} and read them using \ProgName{info}, so you're not
dependent on \ProgName{emacs}.  The distribution includes a
\ProgName{Perl} script, \ProgName{texi2html}, that will convert
Texinfo sources into \acro{HTML}: the language is a far better fit to
\acro{HTML} than is \LaTeX{}, so that the breast-beating agonies of
\Qref*{converting \LaTeX{} to \acro{HTML}}{Q-LaTeX2HTML} are largely
avoided.

Finally, of course, you can also print the files, or convert them to
\acro{PDF} using \PDFTeX{}.
\begin{ctanrefs}
\item[\nothtml{\rmfamily}Texinfo distribution]\CTANref{texinfo}
\end{ctanrefs}

\Question[Q-whyfree]{If \TeX{} is so good, how come it's free?}

It's free because Knuth chose to make it so.  He is nevertheless
apparently happy
that others should earn money by selling \TeX{}-based services and
products. While several valuable \TeX{}-related tools and packages are
offered subject to restrictions imposed by the \acro{GNU} General Public
Licence (`Copyleft'), \TeX{} itself is not subject to Copyleft.

There are commercial versions of \TeX{} available; for some users,
it's reassuring to have paid support.  What is more, some of the
commercial implementations
have features that are not available in free versions.  (The
reverse is also true: some free implementations have features
not available commercially.)

This \acro{FAQ} concentrates on `free' distributions of \TeX{}, but we
do at least list the \Qref*{major vendors}{Q-commercial}.

\Question[Q-TeXfuture]{What is the future of \TeX{}?}

Knuth has declared that he will do no further development of \TeX{};
he will continue to fix any bugs that are reported to him (though
bugs are rare).  This decision was made soon after
\TeX{} version~3.0 was released; at each bug-fix release
the version number acquires one more digit, so that it tends to the
limit~\ensuremath{\pi} (at the time of writing, Knuth's latest release is version
3.141592).  Knuth wants \TeX{} to be frozen at version~\ensuremath{\pi} when he
dies; thereafter, no further changes may be made to Knuth's source.
(A similar rule is applied to \MF{}; its version number tends to the
limit~\ensuremath{e}, and currently stands at 2.71828.)

Knuth explains his decision, and exhorts us all to respect it, in a
paper originally published in \TUGboat{} 11(4) (and reprinted in the
% ! line break
\href{http://www.ntg.nl/maps/pdf/5_34.pdf}{NTG journal MAPS}).

There are projects (some of them long-term
projects: see, for example,
\Qref[question]{the LaTeX3 project}{Q-LaTeX3})
%\Qref[and]{and the SGML work}{Q-SGML})
to build substantial
new macro packages based on \TeX{}.  For the even longer term, there
are various projects to build a \emph{successor} to \TeX{}; see, for example,
the
\begin{narrowversion}
  \LuaTeX{}, Omega/Aleph and \ExTeX{} projects (questions
\end{narrowversion}
\Qref[\nothtml]{\LuaTeX}{Q-luatex},
\Qref[\nothtml]{Omega/Aleph}{Q-omegaleph} and
\Qref[\nothtml]{\ExTeX{}}{Q-extex}\narrowonly{).}
\begin{wideversion}
  projects.
\end{wideversion}

\Question[Q-readtex]{Reading \AllTeX{} files}

So you've been sent a \TeX{} file: what are you going to do with it?

You can, of course, ``just read it'', since it's a plain text file,
but the markup tags in the document may prove distracting.  Most of
the time, even \TeX{} experts will typeset a \TeX{} file before
attempting to read it.

So, you need to typeset the document.  The good news is that \TeX{}
systems are available, free, for most sorts of computer; the bad news
is that you need a pretty complete \TeX{} system even to read a single
file, and complete \TeX{} systems are pretty large.

\TeX{} is a typesetting system that arose from a publishing project (see
\wideonly{``}\Qref[question]{what is \TeX{}}{Q-whatTeX}\wideonly{''}),
and its basic source is available free from its author.  However, at
its root, it is \emph{just} a typesetting engine: even to view or to
print the typeset output, you will need ancillary programs.  In short,
you need a \TeX{} \emph{distribution}~--- a collection of
\TeX{}-related programs tailored to your operating system: for details
of the sorts of things that are available, see
% beware line break
\htmlonly{``}\Qref[question]{\TeX{} distributions}{Q-TeXsystems}\htmlonly{''}
or
% beware line break
\htmlonly{``}\Qref[\htmlonly]{commercial \TeX{} distributions}{Q-commercial}\latexhtml{ (for commercial distributions)}{''}.

But beware~--- \TeX{} makes no attempt to look like the sort of
\WYSIWYG{} system you're probably used to (see
% beware line wrap
\wideonly{``}\Qref[question]{why is \TeX{} not \WYSIWYG{}}{Q-notWYSIWYG}\wideonly{''}):
while many modern versions of \TeX{} have a compile--view cycle that
rivals the best commercial word processors in its responsiveness, what
you type is usually \emph{markup}, which typically defines a logical
(rather than a visual) view of what you want typeset.

So there's a balance between the simplicity of the original
(marked-up) document, which can more-or-less be read in \emph{any}
editor, and the really rather large investment needed to install a
system to read a document ``as intended''.

\Question[Q-notWYSIWYG]{Why is \TeX{} not a \WYSIWYG{} system?}

\WYSIWYG{} is a marketing term (``What you see is what you get'') for
a particular style of text processor.  \WYSIWYG{} systems are
characterised by two principal claims: that you type what you want to
print, and that what you see on the screen as you type is a close
approximation to how your text will finally be printed.

The simple answer to the question is, of course, that \TeX{} was
conceived long before the marketing term, at a time when the marketing
imperative wasn't perceived as significant.  However, that was a long
time ago: why has nothing been done with the ``wonder text processor''
to make it fit with modern perceptions?

There are two answers to this.  First, the simple ``things \emph{have}
been done'' (but they've not taken over the \TeX{} world); and second,
``there are philosophical reasons why the way \TeX{} has developed is
ill-suited to the \WYSIWYG{} style''.
Indeed, there is a fundamental problem with applying \WYSIWYG{} techniques
to \TeX{}: the complexity of \TeX{} makes it hard to get the
equivalent of \TeX{}'s output without actually running \TeX{}.

A celebrated early system offering ``\WYSIWYG{} using \TeX{}'' came from the
Vor\TeX{} project: a pair of (early) Sun workstations worked in
tandem, one handling the user interface while the other beavered away
in the background typesetting the result.  Vor\TeX{} was quite
impressive for its time, but the two workstations combined had hugely less
power than the average sub-thousand dollar Personal Computer
nowadays, and its code has not proved portable (it never even made the
last `great' \TeX{} version change, at the turn of the 1990s, to
\TeX{} version 3).  Modern systems that are similar in
their approach are Lightning Textures (an extension of
Blue Sky's original \TeX{} system for the Macintosh), and Scientific
Word (which can also cooperate with a computer algebra system); both
these systems are \Qref*{commercially available}{Q-commercial}.

The issue has of recent years started to attract attention from \TeX{}
developers, and several interesting projects addressing the
``\Qref*{\TeX{} document preparation environment}{Q-WYGexpts}''
are in progress.

Nevertheless, the \TeX{} world has taken a long time to latch onto the
idea of \WYSIWYG{}.
Apart from simple arrogance (``we're better, and have no need to
consider the petty doings of the commercial word processor market''),
there is a real conceptual difference between the word processor model
of the world and the model \LaTeX{} and \CONTeXT{} employ~--- the idea of
``markup''.  ``Pure'' markup expresses a logical model of a document,
where every object within the document is labelled according to what
it is rather than how it should appear: appearance is deduced from the
properties of the type of object.  Properly applied, markup can
provide valuable assistance when it comes to re-use of documents.

Established \WYSIWYG{} systems find the expression of this sort of
structured markup difficult; however, markup \emph{is} starting to
appear in the lists of the commercial world's requirements, for two
reasons.  First, an element of markup helps impose style on a
document, and commercial users are increasingly obsessed with
uniformity of style; and second, the increasingly pervasive use of
\acro{XML}-derived document archival formats demands it.  The same
challenges must needs be addressed by \TeX{}-based document
preparation support schemes, so we are
observing a degree of confluence of the needs of the two communities:
interesting times may be ahead of us.

\Question[Q-TUG*]{\TeX{} User Groups}

There has been a \TeX{} User Group since very near the time \TeX{}
first appeared.  That first group, \acro{TUG}, is still active and its
journal \textsl{TUGboat} continues in regular publication
with articles about \TeX{}, \MF{} and related technologies, and about
document design, processing and production.  \acro{TUG} holds a yearly
conference, whose proceedings are published in \textsl{TUGboat}.

\acro{TUG}'s \href{http://www.tug.org}{web site} is a valuable
resource for all sorts of
\TeX{}-related matters, such as details of \TeX{} software, and lists
of \TeX{} vendors and \TeX{} consultants.  Back articles from
\textsl{TUGboat} are slowly (subject to copyright issues, etc.\@)
making their way to the site, too.

Some time ago, \acro{TUG} established a ``technical council'', whose
task was to oversee the development of \TeX{}nical projects.  Most
such projects nowadays go on their way without any support from
\acro{TUG}, but \acro{TUG}'s web site lists its
\htmlignore
\ifpdf
\href{http://www.tug.org/twg.html}{Technical Working Groups (\acro{TWG}s)}.
\else
Technical Working Groups (\acro{TWG}s: see
\URL{http://www.tug.org/twg.html}).
\fi
\endhtmlignore
\begin{htmlversion}
\href{http://www.tug.org/twg.html}{Technical Working Groups (\acro{TWG}s)}.
\end{htmlversion}

\acro{TUG} has a reasonable claim to be considered a world-wide
organisation, but there are many national and regional user groups,
too; \acro{TUG}'s web site maintains a list of
\htmlignore
\ifpdf
\href{http://www.tug.org/lugs.html}{``Local User Groups'' (\acro{LUG}s)}.
\else
``local user groups'' (\acro{LUG}s: see
\URL{http://www.tug.org/lugs.html}).
\fi
\endhtmlignore
\begin{htmlversion}
\href{http://www.tug.org/lugs.html}{``local user groups'' (\acro{LUG}s)}.
\end{htmlversion}

Contact \acro{TUG} itself via:
\begin{quote}
  \TeX{} Users Group\\
  1466 NW Front Avenue, Suite 3141\\
  Portland, OR 97209\\
  \acro{USA}\\[.25\baselineskip]
  Tel: +1 503-223-9994\\
  Fax: +1 503-223-3960\\
  Email: \mailto{tug@mail.tug.org}\\
  Web: \URL{http://www.tug.org/}
\end{quote}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\section{Documentation and Help}

\Question[Q-books]{Books on \TeX{} and its relations}

While Knuth's book is the definitive reference for \TeX{}, there are
other books covering \TeX{}:
\begin{booklist}
\item[The \TeX{}book]by Donald Knuth (Addison-Wesley, 1984,
  \ISBN{0-201-13447-0}, paperback \ISBN{0-201-13448-9})
\item[A Beginner's Book of \TeX{}]by Raymond Seroul and Silvio Levy,
  (Springer Verlag, 1992, \ISBN{0-387-97562-4})
\item[\TeX{} by Example: A Beginner's Guide]by Arvind Borde 
  (Academic Press, 1992, \ISBN{0-12-117650-9}~--- now out of print)
\item[Introduction to \TeX{}]by Norbert Schwarz (Addison-Wesley,
  1989, \ISBN{0-201-51141-X}~--- now out of print)
\item[A \plaintex{} Primer]by Malcolm Clark (Oxford University
  Press, 1993, ISBNs~0-198-53724-7 (hardback) and~0-198-53784-0
  (paperback))
\item[A \TeX{} Primer for Scientists]by Stanley Sawyer and Steven
  Krantz (CRC Press, 1994, \ISBN{0-849-37159-7})
\item[\TeX{} by Topic]by Victor Eijkhout (Addison-Wesley, 1992,
  \ISBN{0-201-56882-9}~--- now out of print, but see
  \Qref[question]{online books}{Q-ol-books})
\item[\TeX{} for the Beginner]by Wynter Snow (Addison-Wesley, 1992,
  \ISBN{0-201-54799-6})
\item[\TeX{} for the Impatient]by Paul W.~Abrahams, Karl Berry and
  Kathryn A.~Hargreaves (Addison-Wesley, 1990,
  \ISBN{0-201-51375-7}~--- now out of print, but see
  \Qref[question]{online books}{Q-ol-books})
\item[\TeX{} in Practice]by Stephan von Bechtolsheim (Springer
  Verlag, 1993, 4 volumes, \ISBN{3-540-97296-X} for the set, or
% nos in brackets are for German distribution (Springer Verlag, Berlin)
  Vol.~1: \ISBN{0-387-97595-0}, % (3-540-97595-0)
  Vol.~2: \ISBN{0-387-97596-9}, % (3-540-97596-9)
  Vol.~3: \ISBN{0-387-97597-7}, and % (3-540-97597-7)
  Vol.~4: \ISBN{0-387-97598-5})% (3-540-97598-5)
\htmlignore
\item[\TeX{}: Starting from \sqfbox{1}\,\footnotemark]%
\footnotetext{That's `Starting from Square One'}%
\endhtmlignore
\begin{htmlversion}
\item[\TeX{}: Starting from Square One]
\end{htmlversion}
  by Michael Doob (Springer
  Verlag, 1993, \ISBN{3-540-56441-1}~--- now out of print)
\item[The Joy of \TeX{}]by Michael D.~Spivak (second edition,
  \acro{AMS}, 1990, \ISBN{0-821-82997-1})
\item[The Advanced \TeX{}book]by David Salomon (Springer Verlag, 1995,
  \ISBN{0-387-94556-3})
\end{booklist}
A collection of Knuth's publications about typography is also available:
\begin{booklist}
\item[Digital Typography]by Donald Knuth (CSLI and Cambridge
  University Press, 1999, \ISBN{1-57586-011-2}, paperback
  \ISBN{1-57586-010-4}).
\end{booklist}
\nothtml{\noindent}and in late 2000, a ``Millennium Boxed Set'' of all
5 volumes of Knuth's ``Computers and Typesetting'' series (about
\TeX{} and \MF{}) was published by Addison Wesley:
\begin{booklist}
\item[Computers \& Typesetting, Volumes A--E Boxed Set]by Donald Knuth
  (Addison-Wesley, 2001, \ISBN{0-201-73416-8}).
\end{booklist}
\checked{rf}{2000/02/12 -- http://cseng.aw.com/book/0,3828,0201734168,00.html}
For \LaTeX{}, see:
\begin{booklist}
\item[\LaTeX{}, a Document Preparation System]by Leslie Lamport
  (second edition, Addison Wesley, 1994, \ISBN{0-201-52983-1})
\item[Guide to \LaTeX{}]Helmut Kopka and Patrick W.~Daly (fourth
  edition, Addison-Wesley, 2004, \ISBN{0-321-17385-6})
\item[The \LaTeX{} Companion]by Frank Mittelbach, Michel Goossens,
  Johannes Braams, David Carlisle and Chris Rowley (second edition,
  Addison-Wesley, 2004, \ISBN*{0-201-36299-6}{978-0-201-36299-2})
\item[The \LaTeX{} Graphics Companion:]%
  \emph{Illustrating documents with \TeX{} and \PS{}} by Michel
  Goossens, Sebastian Rahtz, Frank Mittelbach, Denis Roegel and
  Herbert Vo\ss{} (second edition, Addison-Wesley, 2007,
  \ISBN*{0-321-50892-0}{978-0-321-50892-8})
\item[The \LaTeX{} Web Companion:]%
  \emph{Integrating \TeX{}, \acro{HTML} and \acro{XML}} by Michel
  Goossens and Sebastian Rahtz (Addison-Wesley, 1999, \ISBN{0-201-43311-7})
\item[\TeX{} Unbound:]%
  \emph{\LaTeX{} and \TeX{} strategies for fonts, graphics, and more}
  by Alan Hoenig (Oxford University Press, 1998, \ISBN{0-19-509685-1}
  hardback, \ISBN{0-19-509686-X} paperback)
\item[Math into \LaTeX{}:]\emph{An Introduction to \LaTeX{} and \AMSLaTeX{}}
  by George Gr\"atzer (third edition Birkh\"auser and Springer Verlag,
  2000, \ISBN{0-8176-4431-9}, \ISBN{3-7643-4131-9})
\checked{RF}{2001/01/16}
%% gr\"atzer's home page
%% http://www.maths.umanitoba.ca/homepages/gratzer.html/LaTeXBooks.html
\item[Digital Typography Using \LaTeX{}]Incorporating some
  multilingual aspects, and use of \Qref*{Omega}{Q-omegaleph}, by
  Apostolos Syropoulos, Antonis Tsolomitis and Nick Sofroniou
  (Springer, 2003, \ISBN{0-387-95217-9}).

  A list of errata for the first printing is available from:
  \URL{http://www.springer-ny.com/catalog/np/jan99np/0-387-98708-8.html}
\item[First Steps in \LaTeX{}]by George Gr\"atzer (Birkh\"auser, 1999,
  \ISBN{0-8176-4132-7}) 
\item[\LaTeX{}: Line by Line:]%
  \emph{Tips and Techniques for Document Processing}
  by Antoni Diller (second edition, John Wiley \& Sons,
  1999, \ISBN{0-471-97918-X})
\item[\LaTeX{} for Linux:]\emph{A Vade Mecum}
  by Bernice Sacks Lipkin (Springer-Verlag, 1999,
  \ISBN{0-387-98708-8}, second printing)
\end{booklist}
A sample of George Gr\"atzer's ``Math into \LaTeX{}'', in Adobe
Acrobat format, and example files
%for von Bechtolsheim's ``\TeX{} in Practice'', 
for the three \LaTeX{} Companions, and for
Gr\"atzer's ``First Steps in \LaTeX{}'', are all available on
\acro{CTAN}.

There's a nicely-presented list of of ``recommended books'' to be had
on the web: \URL{http://www.macrotex.net/texbooks/}

The list of \MF{} books is rather short:
\begin{booklist}
\item[The \MF{}book]by Donald Knuth (Addison Wesley, 1986,
  \ISBN{0-201-13445-4}, \ISBN{0-201-52983-1} paperback)
\end{booklist}
Alan Hoenig's `\textsl{\TeX{} Unbound}' includes some discussion and
examples of using \MF{}.

A book covering a wide range of topics (including installation and
maintenance) is:
\begin{booklist}
\item[Making \TeX{} Work]by Norman Walsh (O'Reilly and Associates,
  Inc, 1994, \ISBN{1-56592-051-1})
\end{booklist}
The book is decidedly dated, and is now out of print, but a copy is
available via \texttt{sourceforge} and on \acro{CTAN}, 
and we list it under ``\Qref*{online books}{Q-ol-books}''.


This list only covers books in English: notices of new books, or
warnings that books are now out of print are always welcome.  However,
this \acro{FAQ} does \emph{not} carry reviews of current published material.
\begin{ctanrefs}
\item[\nothtml{\rmfamily}Examples for \nothtml{\upshape}First Steps in \LaTeX{}]\CTANref{gfs}
\item[\nothtml{\rmfamily}Examples for \nothtml{\upshape}\LaTeX{} Companion]\CTANref{tlc2}
\item[\nothtml{\rmfamily}Examples for \nothtml{\upshape}\LaTeX{} Graphics Companion]\CTANref{lgc}
\item[\nothtml{\rmfamily}Examples for \nothtml{\upshape}\LaTeX{} Web Companion]\CTANref{lwc}
%\item[\nothtml{\rmfamily}Examples for \nothtml{\upshape}\TeX{} in Practice]\CTANref{tip}
\item[\nothtml{\rmfamily}Sample of \nothtml{\upshape}Math into \LaTeX{}]\CTANref{mil}
\end{ctanrefs}

\Question[Q-typebooks]{Books on Type}

    The following is a partial listing of books on typography in general.
Of these, Bringhurst seems to be the one most often recommended.
\begin{booklist}
\item[The Elements of Typographic Style]by Robert Bringhurst
  (Hartley \& Marks, 1992, \ISBN{0-88179-033-8})
\item[Finer Points in the Spacing \& Arrangement of Type]by Geoffrey Dowding
  (Hartley \& Marks, 1996, \ISBN{0-88179-119-9})
\item[The Thames \& Hudson Manual of Typography]by Ruari McLean
  (Thames \& Hudson, 1980, \ISBN{0-500-68022-1})
\item[The Form of the Book]by Jan Tschichold
  (Lund Humphries, 1991, \ISBN{0-85331-623-6})
\item[Type \& Layout]by Colin Wheildon
  (Strathmore Press, 2006, \ISBN{1-875750-22-3})
\item[The Design of Books]by Adrian Wilson
  (Chronicle Books, 1993, \ISBN{0-8118-0304-X})
\item[Optical Letter Spacing]by David Kindersley and Lida Cardozo Kindersley 
  % ! line break
  (\href{http://www.kindersleyworkshop.co.uk/}{The Cardozo Kindersley Workshop}
  2001, \ISBN{1-874426-139})
\end{booklist}

    There are many catalogues of type specimens but the following books provide
a more interesting overall view of types in general and some of their history.
\begin{booklist}
\item[Alphabets Old \& New]by Lewis F.~Day
  (Senate, 1995, \ISBN{1-85958-160-9})
\item[An Introduction to the History of Printing Types]by Geoffrey Dowding
  (British Library, 1998, UK \ISBN{0-7123-4563-9}; USA \ISBN{1-884718-44-2})
\item[The Alphabet Abecedarium]by Richard A.~Firmage
  (David R.~Godine, 1993, \ISBN{0-87923-998-0})
\item[The Alphabet and Elements of Lettering]by Frederick Goudy
  (Dover, 1963, \ISBN{0-486-20792-7})
\item[Anatomy of a Typeface]by Alexander Lawson
  (David R.~Godine, 1990, \ISBN{0-87923-338-8})
\item[A Tally of Types]by Stanley Morison
  (David R.~Godine, 1999, \ISBN{1-56792-004-7})
\item[Counterpunch]by Fred Smeijers
  (Hyphen, 1996, \ISBN{0-907259-06-5})
\item[Treasury of Alphabets and Lettering]by Jan Tschichold
  (W.~W.~Norton, 1992, \ISBN{0-393-70197-2})
\item[A Short History of the Printed Word]by Warren Chappell and
  Robert Bringhurst (Hartley \& Marks, 1999, \ISBN{0-88179-154-7})
\end{booklist}

    The above lists are limited to books published in English. Typographic 
styles are somewhat language-dependent, and similarly the `interesting' fonts
depend on the particular writing system involved.

\Question[Q-whereFAQ]{Where to find \acro{FAQ}s}

Bobby Bodenheimer's article, from which this \acro{FAQ} was developed, used
to be posted (nominally monthly) to newsgroup
\Newsgroup{comp.text.tex}. The (long
obsolete) last posted copy of that article is kept on \acro{CTAN} for
auld lang syne.

\begin{pdfversion}
A version of the \href{http://www.tex.ac.uk/faq}{present \acro{FAQ}}
may be browsed via the World-Wide Web, and its sources
\end{pdfversion}
\begin{dviversion}
A version of the present \acro{FAQ} may be browsed via the World-Wide Web, at
\acro{URL} \URL{http://www.tex.ac.uk/faq}, and its sources
\end{dviversion}
\begin{htmlversion}
The sources of the present \acro{FAQ}
\end{htmlversion}
are available from \acro{CTAN}.

This \acro{FAQ} and others are regularly mentioned, on
\Newsgroup{comp.text.tex} and elsewhere, in a ``pointer \acro{FAQ}''
which is also saved at \URL{http://tug.org/tex-ptr-faq}

A 2006 innovation from Scott Pakin is the ``visual'' \LaTeX{} \acro{FAQ}.
This is a document with (mostly rubbish) text formatted so as to
highlight things we discuss here, and providing Acrobat hyper-links to
the relevant answers in this \acro{FAQ} on the Web.  The visual
\acro{FAQ} is provided in \acro{PDF} format, on \acro{CTAN}; it works
best using Adobe Acrobat Reader 7 (or later); some features are
missing with other readers, or with earlier versions of Acrobat Reader

Another excellent information source, available in English, is the
\href{http://tex.loria.fr}{\AllTeX{} navigator}.

Both the Francophone \TeX{} user group Gutenberg and the Czech/Slovak
user group CS-TUG have published translations of this \acro{FAQ}, with
extensions appropriate to their languages.

Herbert Vo\ss{}'s excellent % beware line break
\href{http://texnik.de/}{\LaTeX{} tips and tricks}
provides excellent advice on most topics one might imagine (though
it's not strictly a \acro{FAQ})~--- highly recommended for most
ordinary mortals' use.

The Open Directory Project (\acro{ODP}) maintains a list of sources of
\AllTeX{} help, including \acro{FAQ}s.  View the \TeX{} area at
\URL{http://dmoz.org/Computers/Software/Typesetting/TeX/}

Other non-English \acro{FAQ}s are available (off-\acro{CTAN}):
\begin{booklist}
\item[German]Posted regularly to \Newsgroup{de.comp.tex}, and archived
  on \acro{CTAN}; the \acro{FAQ} also appears at
  \URL{http://www.dante.de/faq/de-tex-faq/}
\item[French]An interactive (full-screen!) FAQ may be found at
  \URL{http://www.frenchpro6.com/screen.pdf/FAQscreen.pdf}, and a copy
  for printing at \URL{http://frenchle.free.fr/FAQ.pdf};
  A FAQ used to be posted regularly to
  \Newsgroup{fr.comp.text.tex}, and is archived on \acro{CTAN}~---
  sadly, that effort seems to have fallen by the wayside.
\item[Spanish]See \URL{http://apolo.us.es/CervanTeX/FAQ/}
\item[Czech]See \URL{http://www.fi.muni.cz/cstug/csfaq/}
\end{booklist}

Resources available on \acro{CTAN} are:
\begin{ctanrefs}
\item[\nothtml{\rmfamily}Dante \acro{FAQ}]\CTANref{dante-faq}
\item[\nothtml{\rmfamily}French \acro{FAQ}]\CTANref{french-faq}
\item[\nothtml{\rmfamily}Sources of this \acro{FAQ}]\CTANref{faq}
\item[\nothtml{\rmfamily}Obsolete \texttt{comp.text.tex} \acro{FAQ}]%
  \CTANref{TeX-FAQ}
\item[\nothtml{\rmfamily}The visual \acro{FAQ}]\CTANref{visualFAQ}
\end{ctanrefs}

\Question[Q-gethelp]{How to get help}

So you've looked at all relevant \Qref*{\acro{FAQ}s}{Q-whereFAQ} you
can find, you've looked in any \Qref*{books}{Q-books} you have, and
scanned relevant \Qref*{tutorials}{Q-tutorials*}\dots{} and still you
don't know what to do.

If you are seeking a particular package or program, look on your own
system first: you might already have it~--- the better \TeX{}
distributions contain a wide range of supporting material.  The
\acro{CTAN} Catalogue can also help: you can
\href{http://www.tex.ac.uk/search}{search it}, or you can browse it
% !!!! line break
``\href{http://www.tex.ac.uk/tex-archive/help/Catalogue/bytopic.html}{by topic}''.
A catalogue entry has a brief description of the package, and links to
any known documentation on the net.  In fact, a large proportion of
\acro{CTAN} package directories now include documentation, so it's
often worth looking at the catalogue entry for a package you're considering
using.

Failing all that, look to see if anyone else has had the problem
before; there are two places where people ask: browse or search the
newsgroup \Newsgroup{comp.text.tex} via
\href{http://groups.google.com/group/comp.text.tex}{Google groups},
and the mailing list \texttt{texhax} via its
\href{http://tug.org/pipermail/texhax/}{archive}

If those ``back question'' searches fail, you'll have to ask the world
at large.  To ask a question on \Newsgroup{comp.text.tex}, you can use
your own news client (if you have one), or use the ``start a new
topic'' button on \URL{http://groups.google.com/group/comp.text.tex}.
To ask a question on \texttt{texhax}, you may simply send mail to
\mailto{texhax@tug.org}, but it's probably better to subscribe to the
list (via \URL{http://tug.org/mailman/listinfo/texhax}) % ! no ~ on this line
first~--- not everyone will answer to you as well as to the list.

Do \textbf{not} try mailing the % ! line break
\Qref*{\LaTeX{} project team}{Q-LaTeX3} or the maintainers of these
\acro{FAQ}s for help; while both addresses reach experienced \AllTeX{}
users, no small group can possibly have expertise in every area of
usage so that the ``big'' lists are a far better bet.

\Question[Q-maillists*]{Specialist mailing lists}

The previous question, ``\Qref*{getting help}{Q-gethelp}'', talked of
the two major forums in which \AllTeX{}, \MF{} and \MP{} are
discussed; however, these aren't the only ones available.

The \acro{TUG} web site offers many mailing lists other than just
\texttt{texhax} via its % ! line break
\href{http://tug.org/mailman/listinfo}{mail list management page}.

The French national \TeX{} user group, Gutenberg, offers a \MF{} (and,
de facto, \MP{}) mailing list, \mailto{metafont@ens.fr}: subscribe to
it by sending a message
\begin{quote}
\begin{verbatim}
subscribe metafont
\end{verbatim}
\end{quote}
to \mailto{sympa@ens.fr}

(Note that there's also a \MP{}-specific mailing list available via the
\acro{TUG} lists; in fact there's little danger of becoming confused
by subscribing to both.)

Announcements of \TeX{}-related installations on the \acro{CTAN}
archives are sent to the mailing list \texttt{ctan-ann}.  Subscribe
to the list via its \ProgName{MailMan} web-site
\URL{https://lists.dante.de/mailman/listinfo/ctan-ann}; list archives
are available at the same address.  The list archives may also be
browsed via \URL{http://www.mail-archive.com/ctan-ann@dante.de/}, and
an \acro{RSS} feed is also available:
\URL{http://www.mail-archive.com/ctan-ann@dante.de/maillist.xml}

\Question[Q-askquestion]{How to ask a question}

You want help from the community at large; you've decided where you're
going to \Qref*{ask your question}{Q-gethelp}, but how do you
phrase it?

Excellent ``general'' advice (how to ask questions of anyone) is
contained in
%beware line break
\href{http://catb.org/~esr/faqs/smart-questions.html}{Eric Raymond's article on the topic}.
Eric's an extremely self-confident person, and this comes through in
his advice; but his guidelines are very good, even for us in the
un-self-confident majority.  It's important to remember that you don't
have a right to advice from the world, but that if you express
yourself well, you will usually find someone who will be pleased to
help.

So how do you express yourself in the \AllTeX{} world?  There aren't
any comprehensive rules, but a few guidelines may help in the
application of your own common sense.
\begin{itemize}
\item Make sure you're asking the right people.  Don't ask in a \TeX{}
  forum about printer device drivers for the \ProgName{Foobar}
  operating system.  Yes, \TeX{} users need printers, but no, \TeX{}
  users will typically \emph{not} be \ProgName{Foobar} systems
  managers.

  Similarly, avoid posing a question in a language that the majority
  of the group don't use: post in Ruritanian to
  \Newsgroup{de.comp.text.tex} and you may have a long wait before a
  German- and Ruritanian-speaking \TeX{} expert notices your
  question.
\item If your question is (or may be) \TeX{}-system-specific, report
  what system you're using, or intend to use: ``I can't install
  \TeX{}'' is as good as useless, whereas ``I'm trying to install the
  \ProgName{mumbleTeX} distribution on the \ProgName{Grobble}
  operating system'' gives all the context a potential respondent
  might need.  Another common situation where this information is
  important is when you're having trouble installing something new in
  your system: ``I want to add the \Package{glugtheory} package to my
  \ProgName{mumbleTeX v12.0} distribution on the \ProgName{Grobble 2024}
  operating system''.
\item If you need to know how to do something, make clear what your
  environment is: ``I want to do \emph{x} in \plaintex{}'', or ``I
  want to do \emph{y} in \LaTeX{} running the \Class{boggle}
  class''.  If you thought you knew how, but your attempts are
  failing, tell us what you've tried: ``I've already tried installing
  the \Package{elephant} in the \Package{minicar} directory, and it
  didn't work, even after refreshing the filename database''.
\item If something's going wrong within \AllTeX{}, pretend you're
  \Qref*{submitting a \LaTeX{} bug report}{Q-latexbug},
  and try to generate a \Qref*{minimum failing example}{Q-minxampl}.
  If your example 
  needs your local \Class{xyzthesis} class, or some other resource
  not generally available, be sure to include a pointer to how the
  resource can be obtained.
\item Be as succinct as possible.  Your helpers don't usually need to
  know \emph{why} you're doing something, just \emph{what} you're
  doing and where the problem is.
\end{itemize}

\Question[Q-minxampl]{How to make a ``minimum example''}

\Qref[Question]{Our advice on asking questions}{Q-askquestion}
suggests that you prepare a ``minimum example'' (also commonly known
as a ``\emph{minimal} example'') of failing behaviour,
as a sample to post with your question.  If you have a problem in a
two hundred page document, it may be unclear how to proceed from this
problem to a succinct demonstration of your problem.

There are two valid approaches to this task: building up, and hacking
down.

% ! line break
\latexhtml{The ``building up'' process}{\textbf{\emph{Building up}}} starts
with a basic document structure
(for \LaTeX{}, this would have \csx{documentclass},
\cmdinvoke{begin}{document}, \cmdinvoke{end}{document}) and adds
things.  First to add is a paragraph or so around the actual point
where the problem occurs.  (It may prove difficult to find the actual
line that's provoking the problem.  If the original problem is an
error, reviewing % ! line break
\Qref[the answer to question]{``the structure of \TeX{} errors''}{Q-errstruct}
may help.)

Note that there are things that can go wrong in one part of the
document as a result of something in another part: the commonest is
problems in the table of contents (from something in a section title,
or whatever), or the list of \meta{something} (from something in a
\csx{caption}).  In such a case, include the section title or caption
(the caption probably needs the \environment{figure} or
\environment{table} environment around it, but it \emph{doesn't} need
the figure or table itself).

If this file you've built up shows the problem already, then you're done.
Otherwise, try adding packages; the optimum is a file with only one
package in it, but you may find that the guilty package won't even load
properly unless another package has been loaded.  (Another common case
is that package \Package{A} only fails when package \Package{B} has been
loaded.)

% ! line break
\latexhtml{The ``hacking down'' route}{\textbf{\emph{Hacking down}}} starts
with your entire document, and
removes bits until the file no longer fails (and then of course
restores the last thing removed).  Don't forget to hack out any
unnecessary packages, but mostly, the difficulty is choosing what to
hack out of the body of the document; this is the mirror of the
problem above, in the ``building up'' route.

If you've added a package (or more than one), add \csx{listfiles} to
the preamble too: that way, \LaTeX{} will produce a list of the
packages you've used and their version numbers.  This information may
be useful evidence for people trying to help you.

What if your document simply doesn't fail in any of these cut-down
scenarios?  Whatever you do, don't post the whole of the document: if
you can, it may be useful to make a copy available on the web
somewhere: people will probably understand if it's impossible~\dots{}\ 
or inadvisable, in the case of something confidential.

If the whole document is necessary, it could be that it's an overflow
of some sort; the best you can do is to post the code ``around'' the
error, and (of course) the full text of the error.

It may seem that all this work is rather excessive for preparing a
simple post.  There are two responses to that, both based on the
relative inefficiency of asking a question on the internet.

First, preparing a minimum document very often leads \emph{you} to the
answer, without all the fuss of posting and looking for responses.

Second, your prime aim is to get an answer as quickly as possible; a
well-prepared example stands a good chance of attracting an answer
``in a single pass'': if the person replying to your post finds she
needs more information, you have to find that request, post again, and
wait for your benefactor to produce a second response.

All things considered, a good example file can save you a day, for
perhaps half an hour's effort invested.

The above advice, differently phrased, may also be read on the web at
\URL{http://www.minimalbeispiel.de/mini-en.html}; source of that
article may be found at \URL{http://www.minimalbeispiel.de/}, in
both German and English.

\Question[Q-tutorials*]{\AllTeX{} Tutorials, etc.}

From a situation where every \AllTeX{} user \emph{had} to buy a book
if she was not to find herself groping blindly along, we now have what
almost amounts to an embarrassment of riches of online documentation.
The following answers attempt to create lists of sources ``by topic''.

First we have introductory manuals, for
\Qref*{\plaintex{}}{Q-man-tex} and \Qref*{\LaTeX{}}{Q-man-latex}.

Next comes a selection of
\Qref*{``specialised'' \AllTeX{} tutorials}{Q-tutbitslatex},
each of which concentrates on a single \LaTeX{} topic.

A couple of reference documents (it would be good to have more) are
listed in an \Qref*{answer of their own}{Q-ref-doc}.

Next comes the (rather new) field of % ! line break
\Qref*{\TeX{}-related WIKIs}{Q-doc-wiki}.

A rather short list gives us a % ! line break
\Qref*{Typography style tutorial}{Q-typo-style}.

Finally, we have a set of links to
\Qref*{Directories of \AllTeX{} information}{Q-doc-dirs}, and details
of some ``\Qref*{books}{Q-ol-books}'' that were once published
conventionally, but are now available on-line.

\Question[Q-man-tex]{Online introductions: \plaintex{}}

Michael Doob's splendid `Gentle Introduction' to \plaintex{}
(available on \acro{CTAN}) has been stable for a very long time.

Another recommendable document is D. R.~Wilkins `Getting started with \TeX{}',
available on the web at \URL{http://www.ntg.nl/doc/wilkins/pllong.pdf}
\begin{ctanrefs}
\item[\nothtml{\rmfamily}Gentle Introduction]\CTANref{gentle}
\end{ctanrefs}

\Question[Q-man-latex]{Online introductions: \LaTeX{}}

Tobias Oetiker's `(Not so) Short Introduction to \LaTeXe{}', is
regularly updated, as people suggest better ways of explaining things,
etc.  The introduction is available on \acro{CTAN}, together with
translations into a rather large set of languages.

Peter Flynn's ``Beginner's \LaTeX{}'' (which also started as course
material) is a pleasing read.  A complete copy may be found on
\acro{CTAN}, but it may also be browsed over the web
(\URL{http://www.tex.ac.uk/tex-archive/info/beginlatex/html/}).

Harvey Greenberg's `Simplified Introduction to \LaTeX{}' was written
for a lecture course, and is also available on \acro{CTAN} (in \PS{}
only, unfortunately).

The fourth edition of George Gr\"atzer's book ``Math into \LaTeX{}''
contains a ``short course'' in \LaTeX{} itself, and that course has
been made publicly available on \acro{CTAN}.

Edith Hodgen's % beware line break
\href{http://www.mcs.vuw.ac.nz/~david/latex/notes.pdf}{\LaTeX{}, a Braindump}
starts you from the ground up~--- giving a basic tutorial in the use
of \ProgName{Linux} to get you going (rather a large file\dots{}).
Its parent site, David Friggens' % ! line break
\href{http://www.mcs.vuw.ac.nz/~david/latex/}{documentation page} is a
useful collection of links in itself.

% ! line break
\href{http://www.andy-roberts.net/misc/latex/}{Andy Roberts' introductory material}
is a pleasing short introduction to the use of \AllTeX{}; some of the
slides for \emph{actual} tutorials are to be found on the page, as
well.

Chris Harrison's % ! line break
\href{http://www.chrisharrison.co.uk/xophbook/mybooks/tex/index.html}{TeX book}
presents basic \LaTeX{} with useful hints for extensions

Nicola Talbot's % ! line break
\href{http://theoval.cmp.uea.ac.uk/~nlct/latex/novices/}{\LaTeX{} for complete novices}
does what it claims: the author teaches \LaTeX{} at the University of
East Anglia.  That is one of several of Nicola's % ! line break
\href{http://theoval.cmp.uea.ac.uk/~nlct/latex/}{introductory tutorials},
which include exercises (with solutions).  Other tutorials include
those for writing theses/dissertations with \LaTeX{}, and for using
\LaTeX{} in administrative work.  (The page seems to be an adjunct to
her \LaTeX{} courses~--- fortunate people, the people of \acro{UEA}!).

An interesting (and practical) tutorial about what \emph{not} to do is
\Package{l2tabu}, or ``A list of sins of \LaTeXe{} users'' by Mark
Trettin, translated into English by J\"urgen Fenn.  The
tutorial is available from \acro{CTAN} as a \acro{PDF} file (though
the source is also available).
\begin{ctanrefs}
\item[\nothtml{\rmfamily}Beginner's \LaTeX{}]\CTANref{beginlatex-pdf}
\item[\nothtml{\rmfamily}Not so Short Introduction]\CTANref{lshort}
  (in English, you may browse for sources and other language versions at
  \CTANref{lshort-parent})
\item[\nothtml{\rmfamily}Simplified \LaTeX{}]\CTANref{simpl-latex}
\item[\nothtml{\rmfamily}Short Course in \LaTeX{}]\CTANref{mil-short}
% ! line break
\item[\nothtml{\rmfamily}The sins of \LaTeX{} users]\CTANref{l2tabuen};
  source also available: \CTANref{l2tabuen.src}
\end{ctanrefs}

\Question[Q-tutbitslatex]{Specialised \AllTeX{} tutorials}

The \acro{AMS} publishes a ``Short Math Guide for \LaTeX{}'', which is
available (in several formats) via
\URL{http://www.ams.org/tex/short-math-guide.html}

Herbert Vo\ss{} is developing a parallel document, that is also very
useful; it's part of his ``\Qref*{tips and tricks}{Q-doc-dirs}'' and
a copy is maintained on \acro{CTAN}.
%\URL{http://www.perce.de/LaTeX/math/Mathmode-TeX.pdf}

Two documents written more than ten years apart about font usage in
\TeX{} are worth reading: % ! line breaks, next 3 lines
\href{href='http://www.tug.org/TUGboat/Articles/tb14-2/tb39rahtz-nfss.pdf}{Essential NFSS}
by Sebastian Rahtz, and
\href{http://tug.org/pracjourn/2006-1/schmidt/schmidt.pdf}{Font selection in LaTeX},
cast in the form of an \acro{FAQ}, by Walter Schmidt.  A general
compendium of font information (including the two above) may be found
on the \href{http://www.tug.org/fonts/}{TUG web site}.

Peter Smith's
\begin{narrowversion}
  ``\LaTeX{} for Logicians''
  (\URL{http://www.phil.cam.ac.uk/teaching_staff/Smith/LaTeX/})
\end{narrowversion}
\begin{wideversion}
  % ! line break
  ``\href{http://www.phil.cam.ac.uk/teaching_staff/Smith/LaTeX/}{\LaTeX{} for Logicians}''
\end{wideversion}
covers a rather smaller subject area, but is similarly comprehensive
(mostly by links to documents on relevant topics, rather than as a
monolithic document).

Keith Reckdahl's ``Using Imported Graphics in \LaTeXe{}'' is an
excellent introduction to graphics use.  It's available on
\acro{CTAN}, but the sources aren't available (promised ``some time
soon'').

Kjell Magne Fauske offers a set of examples of the use of the drawing
packages % ! line break
\Qref*{\acro{PGF} and \acro{T}ik\acro{Z}}{Q-drawing}; the % ! line break
\href{http://www.fauskes.net/pgftikzexamples/}{examples catalogue}
includes examples (with output) from the package documentation as well
as code written by the author himself.

Vincent Zoonekynd provides a set of excellent (and graphic) tutorials
on the programming of % !line breaks, ...
\href{http://zoonek.free.fr/LaTeX/LaTeX_samples_title/0.html}{title page styles},
\href{http://zoonek.free.fr/LaTeX/LaTeX_samples_chapter/0.html}{chapter heading styles}
and
\href{http://zoonek.free.fr/LaTeX/LaTeX_samples_section/0.html}{section heading styles}.
In each file, there is a selection of graphics representing an output
style, and for each style, the code that produces it is shown.

An invaluable step-by-step setup guide for establishing a ``work
flow'' through your \AllTeX{} system, so that output appears at the
correct size and position on standard-sized paper, and that the print
quality is satisfactory, is Mike Shell's \Package{testflow}.  The
tutorial consists of a large plain text document, and there is a
supporting \LaTeX{} file together with correct output, both in \PS{} and
\acro{PDF}, for each of \acro{A}4 and ``letter'' paper sizes.  The
complete kit is available on \acro{CTAN} (distributed with the
author's macros for papers submitted for \acro{IEEE} publications).
The issues are also covered in a later % ! line break
\Qref{\acro{FAQ} answer}{Q-dvips-pdf}.

Documentation of Japanese \TeX{} use appears at least twice on the web:
Haruhiko Okumura's page on
% ! line break
\href{http://oku.edu.mie-u.ac.jp/~okumura/texfaq/japanese/}{typesetting Japanese with Omega}
(the parent page is in Japanese, so out of the scope of this
\acro{FAQ}).

One ``Tim'' documents p\TeX{} (a \TeX{} system widely used in Japan)
in his
\begin{narrowversion}
  ``English notes on p\TeX{}'' (see
  \url{http://www.users.waitrose.com/~nihilist/English_Notes_on_pTex.pdf}).
\end{narrowversion}
\begin{wideversion}
  % ! line break
  ``\href{http://www.users.waitrose.com/~nihilist/English_Notes_on_pTex.pdf}{English notes on p\TeX{}}''.
\end{wideversion}

Some university departments make their local documentation available
on the web.  Most straightforwardly, there's the simple translation of
existing documentation into \acro{HTML}, for example the \acro{INFO}
documentation of the \AllTeX{} installation, of which a sample is the
\LaTeX{} documentation available at
\URL{http://www.tac.dk/cgi-bin/info2www?(latex)}

More ambitiously, some university departments have enthusiastic
documenters who 
make public record of their \AllTeX{} support.  For example, Tim Love
(of Cambridge University Engineering Department) maintains his
deparment's pages at
\URL{http://www-h.eng.cam.ac.uk/help/tpl/textprocessing/}
%%  and Mimi
%% Burbank (of the School of Computer Science \& Information Technology
%% at the University of Florida) manages her department's at
%% \URL{http://www.csit.fsu.edu/~mimi/tex/}\nobreakspace--- both sets are fine
%% examples of good practice.
\begin{ctanrefs}
\item[\nothtml{\rmfamily}Graphics in \LaTeXe{}]the
  document is available in \PS{} and \acro{PDF} formats as
  \CTANref{epslatex_ps} and \CTANref{epslatex_pdf} respectively
\item[testflow]\CTANref{testflow}
\item[\nothtml{\rmfamily}Herbert Vo\ss{}'s Maths tutorial]\CTANref{voss-mathmode}
\end{ctanrefs}

\Question[Q-ref-doc]{Reference documents}

For \TeX{} primitive commands a rather nice % ! line break
\href{http://www.nmt.edu/tcc/help/pubs/texcrib.pdf}{quick reference booklet},
by John W.~Shipman, is available; it's arranged in the same way as the
\TeX{}book.  By contrast, you can view David Bausum's % ! line break
\href{http://www.tug.org/utilities/plain/cseq.html}{list of \TeX{} primitives}
alphabetically or arranged by ``family''.  Either way, the list has a
link for each control sequence, that leads you to a detailed
description, which includes page references to the \TeX{}book.

There doesn't seem to be a reference that takes in \plaintex{} as
well as the primitive commands.

Similarly, there's no completely reliable command-organised reference
to \LaTeX{}, but the NASA % ! line break
\href{http://www.giss.nasa.gov/latex/}{Hypertext Help with LaTeX} is
recently much improved.  It still talks in \LaTeXo{}-isms in places,
but it's been updated for current \LaTeX{}; there are a number of
mirrors of the site, and it may be worth choosing a ``local'' one if
you're going to use it a lot.

\Question[Q-doc-wiki]{WIKI pages for \TeX{} and friends}

The \emph{WIKI} concept can be a boon to everyone, if used sensibly.
The ``general'' WIKI allows \emph{anyone} to add stuff, or to edit
stuff that someone else has added: while there is obvious potential
for chaos, there is evidence that a strong user community can keep a
WIKI under control.

Following the encouraging performance of the % ! line break
\href{http://contextgarden.net/}{\CONTeXT{} WIKI}, both a
\href{http://en.wikibooks.org/wiki/TeX}{(Plain) \TeX{} WIKI} and a
\href{http://en.wikibooks.org/wiki/LaTeX}{\LaTeX{} WIKI} have been
established.  Both seem rather sparse, as yet, and the \LaTeX{} WIKI
contains some suggestions that go counter to established advice (e.g.,
the \LaTeX{} WIKI has details on the % ! line break
\Qref*{use of the \environment{eqnarray} environment}{Q-eqnarray});
however one may hope that both will become useful resources in the
longer term.

\Question[Q-typo-style]{Typography tutorials}

There's also (at least one) typographic style tutorial available on
the Web, the excellent % ! line break
``\href*{http://www.nbcs.rutgers.edu/~hedrick/typography/typography.janson-syntax.107514.pdf}{Guidelines for Typography in NBCS}''.
In fact, its % !!
\href*{http://www.nbcs.rutgers.edu/~hedrick/typography/index.html}{parent page}
is also worth a read: among other things, it provides copies of the
``guidelines'' document in a wide variety of primary fonts, for
comparison purposes.  The author is careful to explain that he has no
ambition to supplant such excellent books as
\Qref*{Bringhurst's}{Q-typebooks}, but the document (though it does
contain its Rutgers-local matter) is a fine introduction to the issues
of producing readable documents.

Peter Wilson's manual for his \Class{memoir} class has a lengthy
introductory section on typographic considerations, which is a fine
tutorial, written by someone who is aware of the issues as they apply
to \AllTeX{} users.
\begin{ctanrefs}
\item[memoir \nothtml{\rmfamily}distribution]\CTANref{memoir}
\end{ctanrefs}

\Question[Q-doc-dirs]{Directories of \AllTeX{} information}

T\acro{UG} India is developing a series of online \LaTeX{} tutorials
which can be strongly recommended: select single chapters at a time
from \URL{http://www.tug.org.in/tutorials.html}\nobreakspace--- the
set comprises two parts, ``Text'' and ``Graphics'', so far.

Herbert Vo\ss{}'s excellent % beware line break
\href{http://texnik.de/}{\LaTeX{} tips and tricks} is an excellent
source of small articles on the use of \LaTeX{}.

\Question[Q-ol-books]{Freely available \AllTeX{} books}

People have long argued for \AllTeX{} books to be made available on
the web, and until relatively recently this demand went un-answered.

The first to appear was Victor Eijkhout's excellent ``\TeX{} by
Topic'' in 2001 (it had been published by Addison-Wesley, but was long
out of print).  The book is now available on \acro{CTAN}; it's not a
beginner's tutorial but it's a fine reference.

Addison-Wesley have also released the copyright of ``\TeX{} for the
Impatient'' by Paul W.~Abrahams, Karl Berry and Kathryn A.~Hargreaves,
another book whose unavailability many have lamented.  The authors
have re-released the book under the \acro{GNU} Free Documentation
Licence, and it is available from \acro{CTAN}.

Norm Walsh's ``Making \TeX{} Work'' (originally published by O'Reilly)
is also available (free) on the Web, at
\URL{http://makingtexwork.sourceforge.net/mtw/}; the sources of the
Web page are on \acro{CTAN}.  The book was an excellent resource in
its day, but while it is now somewhat dated, it still has its uses,
and is a welcome addition to the list of on-line resources.  A project
to update it is believed to be under way.
\begin{ctanrefs}
\item[\nothtml{\rmfamily}Making \TeX{} Work]\CTANref{mtw}
\item[\nothtml{\rmfamily}\TeX{} by Topic]\CTANref{texbytopic}
\item[\nothtml{\rmfamily}\TeX{} for the Impatient]\CTANref{TftI}
\end{ctanrefs}

\Question[Q-pkgdoc]{Documentation of packages}

These \acro{FAQ}s regularly suggest packages that will ``solve''
particular problems.  In some cases, the answer provides a recipe for
the job.  In other cases, or when the solution needs elaborating, how
is the poor user to find out what to do?

If you're lucky, the package you need is already in your installation.
If you're particularly lucky, you're using a distribution that gives
access to package documentation and the documentation is available in
a form that can easily be shown.  For example, on many current
distributions, the \ProgName{texdoc} command often helps, as in: 
\begin{quote}
\begin{verbatim}
texdoc footmisc
\end{verbatim}
\end{quote}
which opens a \acro{DVI} viewer window showing documentation of the
\Package{footmisc} package.  According to the type of file
\ProgName{texdoc} finds, it will launch a \acro{DVI} or \PS{} viewer
or a \acro{PDF} reader.

If \ProgName{texdoc} can't find any documentation, it may launch a Web
browser to look at its copy of the \acro{CTAN} catalogue.  The
catalogue has an entry for package documentation, and since the
\acro{CTAN} team asks authors documentation of their packages (and
members of the team even occasionally generate documentation that
seems useful), you will more often than not find documentation that
way.

If your luck (as defined above) doesn't hold out, you've got to find
documentation by other means.  This is where you need to exercise your
intelligence: you have to find the documentation for yourself.  What
follows offers a range of possible techniques.

The commonest form of documentation of \LaTeX{} add-ons is within the
\extension{dtx} file in which the code is distributed (see
\Qref[answer]{documented \LaTeX{} sources}{Q-dtx}).  Such files
are supposedly processable by \LaTeX{} itself, but there are
occasional hiccups on the way to readable documentation.  Common
problems are that the package itself is needed to process its own
documentation (so must be unpacked before processing), and that the
\extension{dtx} file will \emph{not} in fact process with \LaTeX{}.  In the
latter case, the \extension{ins} file will usually produce a
\extension{drv} (or similarly-named) file, which you process with
\LaTeX{} instead.  (Sometimes the package author even thinks to
mention this wrinkle in a package \texttt{README} file.)

Another common form is the separate documentation file; particularly
if a package is ``conceptually large'' (and therefore needs a lot of
documentation), the documentation would prove a cumbersome extension
to the \extension{dtx} file.  Examples of such cases are the \Class{memoir}
class (whose documentation, \File{memman}, is widely praised as an
introduction to typesetting concepts), the \Class{KOMA-script} bundle
(whose developers take the trouble to produce detailed documentation
in both German and English), and the \Package{fancyhdr} package (whose
documentation derives from a definitive tutorial in a mathematical
journal).  Even if the documentation is not separately identified in a
\texttt{README} file, it should not be too difficult to recognise its
existence.

Documentation within the package itself is the third common form.
Such documentation ordinarily appears in comments at the head of the
file, though at least one eminent author regularly places it after the
\csx{endinput} command in the package.  (This is desirable, since
\csx{endinput} is a `logical' end-of-file, and \AllTeX{} doesn't read
beyond it: thus such documentation does not `cost' any package loading time.)

The above suggestions cover most possible ways of finding
documentation.  If, despite your best efforts, you can't find
it in any of the above places, there's the awful possibility that the
author didn't bother to document his package (on the ``if it was hard
to write, it should be hard to use'' philosophy).  Most ordinary
mortals will seek support from some more experienced user at this
stage, though it \emph{is} possible to proceed in the way that the original
author apparently expected\dots{}by reading his code.

\Question[Q-writecls]{Learning to write \LaTeX{} classes and packages}

There's nothing particularly magic about the commands you use when
writing a package, so you can simply bundle up a set of \LaTeX{}
\csx{(re)newcommand} and \csx{(re)newenvironment} commands, put them in
a file \File{package.sty} and you have a package.

However, any but the most trivial package will require rather more
sophistication.  Some details of \LaTeX{} commands for the job are to
be found in `\LaTeXe{} for class and package writers'
(\File{clsguide}, part of the \LaTeX{} documentation distribution).
Beyond this, a good knowledge of \TeX{} itself is valuable: thus books
such as the \Qref*{\TeX{}book}{Q-books} or % ! line break
\Qref*{\TeX{} by topic}{Q-ol-books} are relevant.  With good \TeX{}
knowledge it is possible to use the documented source of \LaTeX{} as
reference material (dedicated authors will acquaint themselves with the
source as a matter of course).  A complete set of the documented
source of \LaTeX{} may be prepared by processing the file
\File{source2e.tex} in the \LaTeX{} distribution, but individual files
in the distribution may be processed separately with \LaTeX{}, like
any well-constructed \Qref*{\extension{dtx} file}{Q-dtx}.

Writing good classes is not easy; it's a good idea to read some
established ones (\File{classes.dtx}, for example, is the documented
source of the standard classes other than \Class{Letter}, and may
itself be formatted with \LaTeX{}).  Classes that are not part of the
distribution are commonly based on ones that are, and start by loading
the standard class with \csx{LoadClass}~--- an example of this
technique may be seen in \Package{ltxguide.cls}

An % !! line break
\href{http://tug.org/TUGboat/Articles/tb28-1/tb88flynn.pdf}{annotated version of \Class{article}},
as it appears in \File{classes.dtx}, was published in
\TUGboat{} 28(1).  The article, by Peter Flynn, which is some help in
understanding \File{classes.dtx}
\begin{ctanrefs}
\item[classes.dtx]\CTANref{latex-classes}
\item[clsguide.pdf]\CTANref{clsguide}
\item[ltxguide.cls]\CTANref{ltxguide}
\item[\nothtml{\rmfamily}\LaTeX{} documentation]\CTANref{latexdoc}
\item[source2e.tex]\CTANref{latex-source}
\end{ctanrefs}

\Question[Q-mfptutorials]{\MF{} and \MP{} Tutorials}

Apart from Knuth's book, there seems to be only one publicly-available
\href{http://metafont.tutorial.free.fr/}{tutorial for \MF{}}, by
Christophe Grandsire (a copy in \acro{PDF} form may be downloaded).
Geoffrey Tobin's \textit{\MF{} for Beginners} % !! line break
(see \Qref[question]{using \MF{}}{Q-useMF}) describes how the \MF{}
system works and how to avoid some of the potential pitfalls.

There is also an article on how to run both \MF{} and \MP{} (the
programs).  Peter Wilson's % !! line break
\textit{Some Experiences in Running \MF{} and \MP{}}
offers the benefit of Peter's experience (he has designed a number of
`historical' fonts using \MF{}).  For \MF{} the article is geared
towards testing and installing new \MF{} fonts, while its \MP{}
section describes how to use \MP{} illustrations in \LaTeX{} and
\PDFLaTeX{} documents, with an emphasis on how to use appropriate
fonts for any text or mathematics.

% Hans Hagen (of \CONTeXT{} fame) offers a \MP{} tutorial called
% MetaFun (which admittedly concentrates on the use of \MP{} within
% \CONTeXT{}).  It may be found on his company's % ! line break
% \href{http://www.pragma-ade.com/metapost.htm}{\MP{} page}.

Other \MP{} tutorials that have appeared are two in English by % ! line breaks
\href{http://remote.science.uva.nl/~heck/Courses/mptut.pdf}{Andr\'e Heck}
and \href{http://www.tlhiv.org/MetaPost/tutorial/}{Urs Oswald},
and one in French (listed here because it's clearly enough written
that even this author understands it), by
\href{http://pauillac.inria.fr/~cheno/metapost/metapost.pdf}{Laurent Ch\'eno};
both have been recommended for inclusion in the \acro{FAQ}

Urs Oswald's tutorial is accompanied by a super tool (by Troy
Henderson) for testing little bits of \MP{}, which is an invaluable
aid to the learner: \URL{http://www.tlhiv.org/mppreview}

Vincent Zoonekynd's massive set of example \MP{} files is available on
\acro{CTAN}; the set includes a \ProgName{Perl} script to convert the
set to html, and the set may be % beware line break
\href{http://zoonek.free.fr/LaTeX/Metapost/metapost.html}{viewed on the web}.
While these examples don't exactly constitute a ``tutorial'', they're
most certainly valuable learning material.  Urs Oswald presents a
\href{http://www.ursoswald.ch/metapost/tutorial.pdf}{similar document},
written more as a document, and presented in \acro{PDF}.
\begin{ctanrefs}
\item[\nothtml{\rmfamily}Beginners' guide]\CTANref{mf-beginners}
\item[\nothtml{\rmfamily}Peter Wilson's ``experiences'']\CTANref{metafp-pdf}
  (\acro{PDF} format) 
\item[\nothtml{\rmfamily}Vincent Zoonekynd's examples]\CTANref{zoon-mp-eg}
\end{ctanrefs}

\Question[Q-BibTeXing]{\BibTeX{} Documentation}

\BibTeX{}, a program originally designed to produce bibliographies in
conjunction with \LaTeX{}, is explained in Section~4.3 and Appendix~B
of Leslie Lamport's \LaTeX{} manual.
The document ``\BibTeX{}ing'', contained in the file \File{btxdoc.tex},
expands on the chapter in Lamport's book.  \emph{The \LaTeX{} Companion}
also has information on \BibTeX{} and writing \BibTeX{} style files.
(See \Qref[question]{TeX-related books}{Q-books} for details of both
books.)

The document ``Designing \BibTeX{} Styles'', contained in the file
\File{btxhak.tex}, explains the postfix stack-based language used to
write \BibTeX{} styles (\File{.bst} files). The file \File{btxbst.doc}
is the template for the four standard styles (\Package{plain},
\Package{abbrv}, \Package{alpha}, and \Package{unsrt}). It also
contains their documentation.  The complete \BibTeX{} documentation
set (including all the files above) is available on \acro{CTAN}.

A useful tutorial of the whole process of using \BibTeX{} is Nicolas
Markey's ``\emph{Tame the BeaST (The B to X of \BibTeX{})}'', which
may also be found on \acro{CTAN}.  A summary and \acro{FAQ}
(\File{btxFAQ}), by Michael Shell and David Hoadley, is also to be
recommended.
\begin{ctanrefs}
\item[\nothtml{\rmfamily}\BibTeX{} documentation]\CTANref{bibtex-doc}
\item[\nothtml{\rmfamily}\BibTeX{} documentation, in \acro{PDF}]%
  \CTANref{bibtex-doc-pdf}
\item[btxFAQ.pdf]\CTANref{bibtex-faq}
\item[\nothtml{\rmfamily}Tame the BeaST]\CTANref{ttb-pdf}
\end{ctanrefs}

\Question[Q-symbols]{Where can I find the symbol for\,\dots{}}
\keywords{assignment circular integral degrees diagonal dots Fourier transform}
\keywords{Laplace greater less complex integer natural real}
\keywords{cent euro}

There is a wide range of symbols available for use with \TeX{}, most
of which are not shown (or even mentioned) in \AllTeX{} books.
\emph{The Comprehensive \LaTeX{} Symbol List} (by Scott Pakin
% beware line wrap
\emph{et al.}\@) illustrates over 2000 symbols, and details the
commands and packages needed to produce them.

Other questions in this \acro{FAQ} offer specific help on kinds of
symbols:
\begin{itemize}
\item \Qref*{Script fonts for mathematics}{Q-scriptfonts}
\item \Qref*{Fonts for the number sets}{Q-numbersets}
\item \Qref*{Typesetting the principal value integral}{Q-prinvalint}
\end{itemize}
\begin{ctanrefs}
\item[Symbol List]Browse \CTANref{symbols}; there are processed
  versions in both \PS{} and \acro{PDF} forms for both A4 and
  letter paper.
\end{ctanrefs}

\Question[Q-docpictex]{The \PiCTeX{} manual}

\PiCTeX{} is a set of macros by Michael Wichura for drawing diagrams
and pictures. The
macros are freely available; however, the
\PiCTeX{} manual itself is not free.
Unfortunately, \acro{TUG} is no longer able to supply copies of the
manual (as it once did), and it is now available only through Personal
\TeX{} Inc, the vendors of PC\TeX{} (\URL{http://www.pctex.com/}).  The
manual is \emph{not} available electronically.

However, there \emph{is} a summary of \PiCTeX{} commands available on
\acro{CTAN}, which is a great aide-memoire for those who basically
know the package to start with.
\begin{ctanrefs}
\item[pictex]\CTANref{pictex}
\item[PiCTeX summary]\CTANref{pictex-summary}
\end{ctanrefs}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\section{Bits and pieces of \AllTeX{}}

\Question[Q-dvi]{What is a \acro{DVI} file?}

A \acro{DVI} file (that is, a file with the type or extension
\extension{dvi}) is \TeX{}'s main output file, using \TeX{} in its
broadest sense to include \LaTeX{}, etc.  `\acro{DVI}' is supposed to
be an acronym for \acro{D}e\acro{V}ice-\acro{I}ndependent, meaning
that the file can be printed on most
kinds of typographic output device.  The \acro{DVI} file is designed to be
read by a driver (\Qref{DVI drivers}{Q-driver}) to produce
further output designed specifically for a particular printer (e.g., a
LaserJet) or to be used as input to a previewer for display on a
computer screen.  \acro{DVI} files use \TeX{}'s internal coding; a \TeX{}
input file should produce the same \acro{DVI} file regardless of which
implementation of \TeX{} is used to produce it.

A \acro{DVI} file contains all the information that is needed for printing 
or previewing except for the actual bitmaps or outlines of fonts, and 
possibly material to be introduced by means of
\Qref*{\csx{special} commands}{Q-specials}.

The canonical reference for the structure of a \acro{DVI} file is the
source of Knuth's program \ProgName{dvitype} (whose original purpose,
as its name implies, was to view the content of a \acro{DVI} file).
\begin{ctanrefs}
\item[dvitype]\CTANref{dvitype}
\end{ctanrefs}

\Question[Q-driver]{What is a \acro{DVI} driver?}

A \acro{DVI} driver is a program that takes as input a \acro{DVI} file
(\Qref{\acro{DVI} files}{Q-dvi})  and
(usually) produces a file that can be sent to a typographic
output device (which we will call a printer, for short), or to another
format.

A driver will usually be specific to a particular printer,
although any \PS{} printer ought to be able to print
the output from a \PS{} driver.
% (these are also called \PS{} conversion programs).

As well as the \acro{DVI} file, the driver also needs font information.
Font information may be held as bitmaps or as outlines, or simply as a
set of pointers into the fonts that the printer itself `has'.
Each driver will expect the font information in
a particular form.  For more information on the forms of fonts,
see \Qref[questions]{\acro{PK} files}{Q-pk},
% ! line break
\Qref[]{\acro{TFM} files}{Q-tfm},
\Qref[]{virtual fonts}{Q-virtualfonts}
and \Qref[]{Using \PS{} fonts with \TeX{}}{Q-usepsfont}.

\Question[Q-pk]{What are \acro{PK} files?}

\acro{PK} files (packed raster) contain font bitmaps.  The output
from \Qref*{\MF{}}{Q-useMF} includes a generic font (\acro{GF}) file
and the utility \ProgName{gftopk} produces the \acro{PK} file from
that.  There are a lot of \acro{PK} files, as one is needed for each
font, that is each magnification (size) of each design (point) size
for each weight for each family.  Further, since the \acro{PK} files
for one printer do not necessarily work well for another, the whole
set needs to be duplicated for each printer type at a site.  In a
modern \TeX{} distribution, files are arranged according to the \TeX{}
directory structure \Qref*{\acro{TDS}}{Q-tds}, which has provision for
all this variety.

\Question[Q-tfm]{What are \acro{TFM} files?}

\acro{TFM} stands for \TeX{} Font Metrics; \acro{TFM} files hold
information about the sizes of the characters of the font in question,
and about ligatures and kerns within that font.  One \acro{TFM} file is
needed for each font used by \TeX{}, that is for each design (point)
size for each weight for each family; each \acro{TFM} file serves for all
magnifications of `its' font, so that there are (typically) fewer
\acro{TFM} files than there are \acro{PK} files.  \TeX{} (\LaTeX{}, etc.\@)
itself needs only to know about the sizes of characters and their
interactions with each other, but not what characters look like.  By
contrast, \acro{TFM} files are not, in principle, needed by the
\acro{DVI} driver, which only needs to know about the glyphs that each
character selects, so as to print or display them.

\Question[Q-virtualfonts]{Virtual fonts}

Virtual fonts provide a means of collecting bits and pieces together
to make the glyphs of a font: the bits and pieces may be other glyphs,
rules and other ``basic'' typesetting commands, and the positioning
information that specifies how everything comes together.

Things that match the concept of virtual fonts for \TeX{} were first
implemented by David Fuchs in the very early days.  However, for practical
purposes for the rest of us, virtual fonts date from when Knuth
specified a format and wrote some support software, in 1989 (he
published an article in \textsl{TUGboat} at the time, and a plain text
copy is available on \acro{CTAN}).

Virtual fonts provide a way of telling \TeX{} about something more
complicated than just a one-to-one character mapping. The entities you
define in a virtual font look like characters to \TeX{} (they appear
with their sizes in a \acro{TFM} file), but the \acro{DVI} processor may
expand them to something quite different.

From the virtual font file, the \acro{DVI} processor learns
details of what is in the virtual font, so as to know ``what to draw,
where''.   The virtual font may contain commands:
\begin{itemize}
\item just to remap the glyphs of a single font,
\item to make a composite font with glyphs drawn from several
  different fonts, or
\item to build up an effect in arbitrarily complicated ways (since a
  virtual font may contain anything which is legal in a \acro{DVI}
  file).
\end{itemize}

% !this has to be generated as a new paragraph by the translator, so
% leave the blank line in place
In practice, the most common use of virtual fonts is to remap
Adobe Type 1 fonts (see \Qref[question]{font metrics}{Q-metrics}),
though there has also been useful useful work building `fake' maths
fonts (by bundling glyphs from several fonts into a single virtual
font).  Virtual Computer Modern fonts, making a % ! line break
\Qref*{Cork encoded}{Q-ECfonts} font from Knuth's originals by using
remapping and fragments of \acro{DVI} for single-glyph `accented
characters', were the first ``Type~1 format'' Cork-encoded Computer
Modern fonts available.

Virtual fonts are normally created in a single \acro{ASCII}
\acro{VPL} (Virtual Property List) file, which includes both sets of
information. The \ProgName{vptovf} program is then used to the create
the binary \acro{TFM} and \acro{VF} files.

A ``how-to'' document, explaining how to generate a \acro{VPL},
describes the endless hours of fun that may be had, doing the job by
hand.  Despite the pleasures to be had of the manual method, the
commonest way (nowadays) of generating \acro{VPL} files is to use the
\ProgName{fontinst} package, which is described in detail
\htmlonly{together with the discussion of}
\Qref[in answer]{\PS{} font metrics}{Q-metrics}.
\Package{Qdtexvpl} is another utility for creating ad-hoc virtual
fonts (it uses \TeX{} to parse a description of the virtual font, and
\ProgName{qdtexvpl} itself processes the resulting \acro{DVI} file).
\begin{ctanrefs}
\item[fontinst]\CTANref{fontinst}
\item[\nothtml{\rmfamily}Knuth on virtual fonts]\CTANref{vf-knuth}
\item[\nothtml{\rmfamily}Virtual fonts ``how to'']\CTANref{vf-howto}
\item[qdtexvpl]\CTANref{qdtexvpl}
\end{ctanrefs}

\Question[Q-specials]{\csx{special} commands}

\TeX{} provides the means to express things that device drivers can
do, but about which \TeX{} itself knows nothing.  For example, \TeX{}
itself knows nothing about how to include \PS{} figures into
documents, or how to set the colour of printed text; but some device
drivers do.

Instructions for such things are introduced to your document by means
of \csx{special} commands; all that \TeX{} does with these commands is
to expand their 
arguments and then pass the command to the \acro{DVI} file.  In most
cases, there are macro packages provided (often with the driver) that
provide a human-friendly interface to the \csx{special}; for example,
there's little point including a figure if you leave no gap for it in
your text, and changing colour proves to be a particularly fraught
operation that requires real wizardry.  \LaTeXe{}
has standard graphics and colour packages that make figure inclusion,
rotation and scaling, and colour typesetting relatively
straightforward, despite the rather daunting \csx{special} commands
involved.  (\CONTeXT{} provides similar support, though not by way of
packages.)

The allowable arguments of \csx{special} depend on the device driver
you're using.  Apart from the examples above, there are \csx{special}
commands in the em\TeX{} drivers (e.g., \ProgName{dvihplj}, \ProgName{dviscr},
\emph{etc}.)~that will draw lines at arbitrary orientations, and
commands in \ProgName{dvitoln03} that permit the page to be set in
landscape orientation.

Note that \csx{special} provides rather different facilities in \PDFTeX{}
operation: since there is no device driver around, in this context.
In \PDFTeX{}, \csx{special} is only needed to generated \acro{PDF} for
which there is no existing defined \PDFTeX{} operation.

\Question[Q-hyphen]{How does hyphenation work in \TeX{}?}

Everyone knows what hyphenation is: we see it in most books we read,
and (if we're alert) will spot occasional ridiculous mis-hyphenation
(at one time, British newspapers were a fertile source).

Hyphenation styles are culturally-determined, and the same language
may be hyphenated differently in different countries~--- for example,
British and American styles of hyphenation of English are very
different.  As a result, a typesetting system that is not restricted
to a single language at a single locale needs to be able to change its
hyphenation rules from time to time.

\TeX{} uses a pretty good system for hyphenation (originally designed
by Frank Liang), and while it's capable of missing ``sensible''
hyphenation points, it seldom selects grossly wrong ones.  The
algorithm matches candidates for hyphenation against a set of
``hyphenation patterns''.  The candidates for hyphenation must be
sequences of letters (or other single characters that \TeX{} may be
persuaded to think of as letters)~--- things such as \TeX{}'s
\csx{accent} primitive interrupt hyphenation.

Sets of hyphenation patterns are usually derived from analysis of
a list of valid hyphenations (the process of derivation, using a tool
called \Package{patgen}, is not ordinarily a participatory sport).

The patterns for the languages a \TeX{} system is going to deal with
may only be loaded when the system is installed.  To change the set of
languages, a \Qref*{partial reinstallation}{Q-newlang} is necessary.

\TeX{} provides two ``user-level'' commands for control of
hyphenation: \csx{language} (which selects a hyphenation style), and
\csx{hyphenation} (which gives explicit instructions to the hyphenation
engine, overriding the effect of the patterns).

The ordinary \LaTeX{} user need not worry about \csx{language}, since
it is very thoroughly managed by the \Package{babel} package; use of
\csx{hyphenation} is discussed in
\begin{wideversion}
  the context of
\end{wideversion}
% beware line wrap
\Qref[question]{hyphenation failure}{Q-nohyph}.

\Question[Q-clsvpkg]{What are \LaTeX{} classes and packages?}

Current \LaTeX{} makes a distinction between the macros that define the
overall layout of a document, and the macros that tweak that layout
(to one extent or another) to provide what the author \emph{really}
wants.

The distinction was not very clear in \LaTeXo{}, and after some
discussion (in the later stages of development of current \LaTeX{})
the names ``class'' and ``package'' were applied to the two concepts.

The idea is that a document's \emph{class} tells \LaTeX{} what sort of
document it's dealing with, while the \emph{packages} the document
loads ``refine'' that overall specification.

On the disc, the files only appear different by virtue of their name
``extension''~--- class files are called \texttt{*.cls} while package
files are called \texttt{*.sty}.  Thus we find that the \LaTeX{}
standard \Class{article} class is represented on disc by a file called
\File{article.cls}, while the \Package{footmisc} package (which
refines \Class{article}'s definition of footnotes) is represented on
disc by a file called \File{footmisc.sty}.

The user defines the class of his document with the
\csx{documentclass} command (typically the first command in a
document), and loads packages with the \csx{usepackage} command.  A
document may have several \csx{usepackage} commands, but it may have
only one \csx{documentclass} command.  (Note that there are
programming-interface versions of both commands, since a class may
choose to load another class to refine its capabilities, and both
classes and packages may choose to load other packages.)

\Question[Q-dtx]{Documented \LaTeX{} sources (\extension{dtx} files)}

\LaTeXe{}, and most contributed macro packages, are now written in a
\Qref*{literate programming style}{Q-lit}, with source and
documentation in the
same file.  This format, known as `doc', in fact originated before the
days of the \LaTeX{} project as one of the ``Mainz'' series of
packages. A documented source file conventionally has the suffix
\extension{dtx}, and will normally be `stripped' before use with
\LaTeX{}; an installation file (\extension{ins}) is normally provided,
to automate this process of removing comments for speed of loading.
To read the comments, you can run \LaTeX{} on the
\extension{dtx} file to produce a nicely formatted version of the
documented code.  Several
packages can be included in one \extension{dtx} file (they're sorted
out by the \extension{ins} file), with conditional
sections, and there are facilities for indexes of macros, etc.

Anyone can write \extension{dtx} files; the format is explained in
\Qref*{The \LaTeX{} Companion}{Q-books}, and a tutorial is available
from \acro{CTAN} (which comes with skeleton \extension{dtx} and
\extension{ins} files).

Composition of \extension{dtx} files is supported in \ProgName{emacs} by
\Qref*{\acro{AUC}-\TeX{}}{Q-editors}.

Another useful way of generating \extension{dtx} files is to write the
documentation and the code separately, and then to combine them using
the \ProgName{makedtx} system.  This technique has particular value in
that the documentation file can be used separately to generate
\acro{HTML} output; it is often quite difficult to make % ! line break
\Qref*{\LaTeX{} to \acro{HTML} conversion}{Q-LaTeX2HTML} tools deal
with \extension{dtx} files, since they use an unusual class file.

The \extension{dtx} files are not used by \LaTeX{} after they have been
processed to produce \extension{sty} or \extension{cls} (or whatever)
files.  They need not be kept with the working system; however, for
many packages the \extension{dtx} file is the primary source of
documentation, so you may want to keep \extension{dtx} files elsewhere.

An interesting sideline to the story of \extension{dtx} files is the
\Package{docmfp} package, which extends the model of the \Package{doc}
package to
\begin{narrowversion}
  \MF{} and \MP{} (\Qref[see questions]{}{Q-MF} and \Qref[\nothtml]{}{Q-MP})
\end{narrowversion}
\begin{wideversion}
  \Qref{\MF{}}{Q-MF} and \Qref{\MP{}}{Q-MP},
\end{wideversion}
thus permitting documented distribution of bundles containing code for
\MF{} and \MP{} together with related \LaTeX{} code.
\begin{ctanrefs}
\item[clsguide.pdf]\CTANref{clsguide}
\item[docmfp.sty]\CTANref{docmfp}
\item[docstrip.tex]Part of the \LaTeX{} distribution
\item[DTX tutorial]\CTANref{dtxtut}
\item[makedtx]\CTANref{makedtx}
\end{ctanrefs}

\Question[Q-whatenc]{What are encodings?}

Let's start by defining two concepts, the \emph{character} and the
\emph{glyph}.
The character is the abstract idea of the `atom' of a
language or other dialogue: so it might be a letter in an alphabetic
language, a syllable in a syllabic language, or an ideogram in an
ideographic language.  The glyph is the mark created on screen or
paper which represents a character.  Of
course, if reading is to be possible, there must be some agreed
relationship between the glyph and the character, so while the precise
shape of the glyph can be affected by many other factors, such as the
capabilities of the writing medium and the designer's style, the
essence of the underlying character must be retained.

Whenever a computer has to represent characters, someone has to define
the relationship between a set of numbers and the characters they
represent.  This is the essence of an encoding: it is a mapping
between a set of numbers and a set of things to be represented.

\TeX{} of course deals in encoded characters all the time: the
characters presented to it in its input are encoded, and it emits
encoded characters in its \acro{DVI} (or \acro{PDF}) output.  These
encodings have rather different properties.

The \TeX{} input stream was pretty unruly back in the days when Knuth
first implemented the language.  Knuth himself prepared documents on
terminals that produced all sorts of odd characters, and as a result
\TeX{} contains some provision for translating the input encoding to
something regular.  Nowadays, 
the operating system translates keystrokes into a code appropriate for
the user's language: the encoding used is often a national or
international standard, though many operating systems use ``code
pages'' defined by Microsoft.  These standards and code pages often
contain characters that can't appear in the \TeX{} system's input
stream.  Somehow, these characters have to be dealt with~--- so
an input character like ``\'e'' needs to be interpreted by \TeX{} in
a way that that at least mimics the way it interprets ``\csx{'}\texttt{e}''.  

The \TeX{} output stream is in a somewhat different situation:
characters in it are to be used to select glyphs from the fonts to be
used.  Thus the encoding of the output stream is notionally a font
encoding (though the font in question may be a
% beware line break (twice)
\nothtml{virtual one~--- see }%
\Qref[question]{virtual font}{Q-virtualfonts}).  In principle, a
fair bit of what appears in the output stream could be direct
transcription of what arrived in the input, but the output stream
also contains the product of commands in the input, and translations
of the input such as ligatures like %
\texttt{fi}\nothtml{\ensuremath\Rightarrow``fi''}.

Font encodings became a hot topic when the
\Qref*{Cork encoding}{Q-ECfonts}
appeared, because of the possibility of suppressing
\csx{accent} commands in the output stream (and hence improving the
quality of the hyphenation of text in inflected languages, which is
interrupted by the \csx{accent} commands~--- see
% beware line break
\Qref[question]{``how does hyphenation work''}{Q-hyphen}).
To take advantage of the diacriticised characters represented in the
fonts, it is necessary to arrange that whenever the
command sequence ``\csx{'}\texttt{e}'' has been input
(explicitly, or implicitly via the sort of mapping of input mentioned
above), the character that codes the position of the ``\'e'' glyph is
used.

Thus we could have the odd arrangement that the diacriticised character in
the \TeX{} input stream is translated into \TeX{} commands that would
generate something looking like the input character; this sequence of
\TeX{} commands is then translated back again into a single
diacriticised glyph as the output is created.  This is in fact
precisely what the \LaTeX{} packages \Package{inputenc} and
\Package{fontenc} do, if operated in tandem on (most) characters in
the \acro{ISO}~Latin-1 input encoding and the \acro{T}1 font encoding.
At first sight, it seems eccentric to have the first package do a thing, and
the second precisely undo it, but it doesn't always happen that way:
most font encodings can't match the corresponding input encoding
nearly so well, and the two packages provide the sort of symmetry the
\LaTeX{} system needs.

\Question[Q-ECfonts]{What are the \acro{EC} fonts?}

A font consists of a number of \emph{glyphs}.  In order that the
glyphs may be printed, they are \Qref*{\emph{encoded}}{Q-whatenc}, and
the encoding is used as an index into tables within the font.  For
various reasons, Knuth chose deeply eccentric encodings for his
Computer Modern family of fonts; in particular, he chose different
encodings for different fonts, so that the application using the fonts
has to remember which font of the family it's using before selecting a
particular glyph.

When \TeX{} version 3 arrived, most of the excuses for the
eccentricity of Knuth's encodings went away, and at \acro{TUG}'s Cork
meeting, an encoding for a set of 256 glyphs, for use in \TeX{} text,
was defined.  The intention was that these glyphs should cover `most'
European languages that use Latin alphabets, in the sense of including
all accented letters needed.  (Knuth's \acro{CMR} fonts missed things
necessary for Icelandic and Polish, for example, but the Cork
fonts have them.  Even Cork's coverage isn't complete: it misses
letters from Romanian, Eastern and Northern Sami, and Welsh, at
least.  The Cork encoding does contain ``\acro{NG}'' glyphs that
allows it to support Southern Sami.)  \LaTeX{} refers to the
Cork encoding as \acro{T}1, and
provides the means to use fonts thus encoded to avoid problems with
the interaction of accents and hyphenation % ! line break
(see \Qref[question]{hyphenation of accented words}{Q-hyphenaccents}).

The only \MF{}-fonts that conform to the Cork encoding are the
\acro{EC} fonts.  They look \acro{CM}-like, though their metrics
differ from \acro{CM}-font metrics in several areas.  The fonts are
now regarded as `stable' (in the same sense that the \acro{CM} fonts
are stable: their metrics are unlikely ever to change).  Their serious
disadvantages for the casual user are their size (each \acro{EC} font
is roughly twice the size of the corresponding \acro{CM} font), and
there are far more of them than there are \acro{CM} fonts.  The simple
number of fonts has acted as a disincentive to the production of Adobe
Type~1 versions of the fonts, but several commercial suppliers offer
\acro{EC} or
\acro{EC}-equivalent fonts in type~1 or TrueType form~--- see
% beware line fill
\Qref[question]{commercial suppliers}{Q-commercial}.  Free 
\Qref{auto-traced versions}{Q-textrace} (the \acro{CM}-super
and the \acro{LGC} fonts), and the Latin Modern series (rather
directly generated from \MF{} sources), are available.

%% Unfortunately, until corresponding fonts for mathematics are produced,
%% the \acro{CM} fonts must be retained, since some mathematical symbols
%% are drawn from text fonts in the \acro{CM} encodings.
Note that the Cork encoding doesn't cover mathematics (and neither do
``\acro{T}1-encoded'' font families, of course).  If you're using
Computer-Modern-alike fonts, this doesn't actually matter: your system
will have the original Computer Modern fonts, which cover `basic'
\TeX{} mathematics; more advanced mathematics are likely to need
separate fonts anyway.  Suitable mathematics fonts for use with other
font families are discussed in % ! line break
``\Qref{choice of scalable fonts}{Q-psfchoice}''.

The \acro{EC} fonts are distributed with a
set of `Text Companion' (\acro{TC}) fonts that provide glyphs for
symbols commonly used in text.  The \acro{TC} fonts are encoded
according to the \LaTeX{} \acro{TS}1 encoding, and are not viewed as
`stable' in the same way as are the \acro{EC} fonts are.

The Cork encoding is also implemented by virtual fonts provided in the
\Qref*{\acro{PSNFSS} system}{Q-usepsfont},
for Adobe Type~1 fonts, and also by the \Package{txfonts} and
\Package{pxfonts} font packages
% beware line wrap
(see \Qref[question]{``choice of scalable fonts''}{Q-psfchoice}).
\begin{ctanrefs}
\item[CM-super fonts]\CTANref{cm-super}
\item[CM-LGC fonts]\CTANref{cm-lgc}
\item[EC and TC fonts]\CTANref{ec}
\item[Latin Modern fonts]\CTANref{lm}
\end{ctanrefs}

\Question[Q-tds]{What is the \acro{TDS}?}

    \acro{TDS} stands for the \TeX{} Directory Structure, which is a standard
way of organising all the \TeX{}-related files on a computer system. 

    Most modern distributions conform to the \acro{TDS}, which
provides for both a `standard' and a (set of) `local' hierarchies of
directories containing \TeX{}-related files. The
\acro{TDS} reserves the name \texttt{texmf} as the name of the root directory
(folder) of the hierarchies.  Files supplied as part of the
distribution are put into the standard hierarchy. The location of the
standard hierarchy is system dependent, but on a Unix system it might
be at 
\path{/usr/local/texmf}, or
\path{/usr/local/share/texmf}, or
\path{/opt/texmf}, or
a similar location, but in each case the \TeX{} files will be under the 
\path{/texmf} subdirectory. 

There may be more than on `local' hierarchy in which additional files
can be stored. In the extreme an installation can have a local
hierarchy and each user can also have an individual local hierarchy. The
location of any local hierarchy is not only system dependent but also user
dependent. Again, though, all files should be put under a local \path{/texmf}
directory.

The \acro{TDS} is published as the output of a \acro{TUG} % beware line wrap
\Qref*{Technical Working Group}{Q-TUG*}.
You may browse an \href{http://tug.org/tds/}{on-line version} of the
standard, and copies in several other formats (including source) are
available on \acro{CTAN}.
\begin{ctanrefs}
\item[\nothtml{\rmfamily}\acro{TDS} specification]\CTANref{tds}
\end{ctanrefs}

\Question[Q-eps]{What is ``Encapsulated \PS{}'' (``\acro{EPS}'')}

\PS{} has been for many years a \emph{lingua franca} of powerful
printers (modern high-quality printers now tend to require some
constrained form of Adobe Acrobat, instead); since \PS{} is also a
powerful graphical programming language, it is commonly used as an
output medium for drawing (and other) packages.

However, since \PS{} \emph{is} such a powerful language, some
rules need to be imposed, so that the output drawing may be included
in a document as a figure without ``leaking'' (and thereby destroying
the surrounding document, or failing to draw at all).

Appendix \acro{H} of the \PS{} Language Reference Manual (second
and subsequent editions), specifies a set of rules for \PS{} to
be used as figures in this way.  The important features are:
\begin{itemize}
\item certain ``structured comments'' are required; important ones are
  the identification of the file type, and information about the
  ``bounding box'' of the figure (i.e., the minimum rectangle
  enclosing it);
\item some commands are forbidden~--- for example, a \texttt{showpage}
  command will cause the image to disappear, in most \TeX{}-output
  environments; and
\item ``preview information'' is permitted, for the benefit of things
  such as word processors that don't have the ability to draw
  \PS{} in their own right~--- this preview information may be in
  any one of a number of system-specific formats, and any viewing
  program may choose to ignore it.
\end{itemize}
A \PS{} figure that conforms to these rules is said to be in
``Encapsulated \PS{}'' (\acro{EPS}) format.  Most \AllTeX{} packages for
including \PS{} are structured to use Encapsulated \PS{};
which of course leads to much hilarity as exasperated \AllTeX{} users
struggle to cope with the output of drawing software whose authors
don't know the rules.

\Question[Q-adobetypen]{Adobe font formats}
\keywords{type1 type3}

Adobe has specified a number of formats for files to represent fonts
in \PS{} files; this question doesn't attempt to be encyclopaedic, so
we only discuss the two formats most commonly encountered in the
\AllTeX{} context, types~1 and 3.  In particular, we don't discuss the
OpenType format, whose has many advantages are somewhat ahead of the
\TeX{} world's mainstream (at time of writing).

Adobe Type~1 format specifies a means to represent outlines of the glyphs
in a font.  The `language' used is closely restricted, to ensure that
the font is rendered as quickly as possible.  (Or rather, as quickly
as possible with Adobe's technology at the time the specification was
written: the structure could well be different if it were specified
now.)  The format has long been the basis of the digital type-foundry
business, though nowadays most new fonts are released in OpenType format.

%% Type~1 fonts are directly supported by some operating system software,
%% and at least one \TeX{} system, the commercial % line break!
%% \Qref*{\YandY{} system}{Q-commercial}, bases its entire
%% operation on the use of Type~1 fonts.

In the \AllTeX{} context, Type~1 fonts are extremely important.  Apart
from their simple 
availability (there are thousands of commercial Type~1 text fonts around), the
commonest reader for \acro{PDF} files has long (in effect) \emph{insisted} on
their use (see below).

Type~3 fonts have a more forgiving specification.  A wide range of
\PS{} operators is permissible, including bitmap specifiers.  Type~3
is therefore the natural format to be used for programs such as
\ProgName{dvips} when they auto-generate something to represent
\MF{}-generated fonts in a \PS{} file.  It's Adobe Acrobat Viewer's
treatment of bitmap Type~3 fonts that has made direct \MF{} output
increasingly unattractive, in recent years.  If you have a \acro{PDF}
document in which the text looks fuzzy and uneven in Acrobat Reader,
ask Reader for the \texttt{File}\arrowhyph{}%
\texttt{Document Properties}\arrowhyph{}%
\texttt{Fonts ...}, and it will likely show some font or other as
``Type~3'' (usually with encoding ``Custom'').  The problem has
disappeared with version 6 of Acrobat Reader.  See % line break
\Qref[question]{\acro{PDF} quality}{Q-dvips-pdf} for a discussion of
the issue, and for ways of addressing it.

Type~3 fonts should not entirely be dismissed, however.  Acrobat
Reader's failure with them is entirely derived from its failure to use
the anti-aliasing techniques common in \TeX{}-ware.  Choose a
different set of \PS{} graphical operators, and you can make pleasing
Type~3 fonts that don't ``annoy'' Reader.  For example, you may not
change colour within a Type~1 font glyph, but there's no such
restriction on a Type~3 font, which opens opportunities for some
startling effects.

\Question[Q-resolns]{What are ``resolutions''}

``Resolution'' is a word that is used with little concern for its
multiple meanings, in computer equipment marketing.  The word suggests
a measure of what an observer (perhaps the human eye) can resolve; yet
we regularly see advertisements for printers whose resolution is
1200dpi~--- far finer than the unaided human eye can distinguish.  The
advertisements are talking about the precision with which the printer
can place spots on the printed image, which affects the fineness of
the representation of fonts, and the accuracy of the placement of
glyphs and other marks on the page.

In fact, there are two sorts of ``resolution'' on the printed page
that we need to consider for \AllTeX{}'s purposes:
\begin{itemize}
\item the positioning accuracy, and
\item the quality of the fonts.
\end{itemize}
In the case where \AllTeX{} output is being sent direct to a printer,
in the printer's ``native'' language, it's plain that the \acro{DVI}
processor must know all such details, and must take detailed account
of both types of resolution.

In the case where output is being sent to an intermediate distribution
format, that has potential for printing (or displaying) we know not
where, the final translator, that connects to directly to the printer
or display, has the knowledge of the device's properties: the
\acro{DVI} processor need not know, and should not presume to guess.

Both \PS{} and \acro{PDF} output are in this category.  While \PS{} is
used less frequently for document distribution nowadays, it is
regularly used as the source for distillation into \acro{PDF}; and
\acro{PDF} is the workhorse of an enormous explosion of document
distribution.

Therefore, we need \acro{DVI} processors that will produce
``resolution independent'' \PS{} or \acro{PDF} output; of course, the
independence needs to extend to both forms of independence outlined
above.

Resolution-independence of fonts was for a  long time forced upon the
world by the feebleness of Adobe's \ProgName{Acrobat}
\ProgName{Reader} at dealing with bitmap files: a sequence of answers
starting with one aiming at the % ! line break
\Qref*{quality of \acro{PDF} from \PS{}}{Q-dvips-pdf} addresses
the problems that arise.

Resolution-independence of positioning is more troublesome:
\ProgName{dvips} is somewhat notorious for insisting on positioning to
the accuracy of the declared resolution of the printer.
One commonly-used approach is to declare a resolution of 8000 (``better
than any device''), and this is reasonably successful though it does
have its \Qref*{problems}{Q-8000}.

\Question[Q-fontname]{What is the ``Berry naming scheme''}

In the olden days, \AllTeX{} distributions were limited by the
feebleness of file systems' ability to represent long names.  (The
\MSDOS{} file system was a particular bugbear: fortunately any current
Microsoft system allows rather more freedom to specify file names.
Sadly, the ISO~9660 standard for the structure of \CDROM{}s has a
similar failing, but that too has been modified by various extension
mechanisms.)

One area in which this was a particular problem was that of file names
for Type~1 fonts.  These fonts are distributed by their vendors with
pretty meaningless short names, and there's a natural ambition to
change the name to something that identifies the font somewhat
precisely.  Unfortunately, names such as ``BaskervilleMT'' are
already far beyond the abilities of the typical feeble file system,
and add the specifier of a font shape or variant, and the difficulties
spiral out of control.

Thus arose the Berry naming scheme.

The basis of the scheme is to encode the meanings of the various parts
of the file's specification in an extremely terse way, so that enough
font names can be expressed even in impoverished file name-spaces.  The
encoding allocates one letter to the font ``foundry'', two to the
typeface name, one to the weight, and so on.  The whole scheme is
outlined in the \Package{fontname} distribution, which includes
extensive documentation and a set of tables of fonts whose names have
been systematised.
\begin{ctanrefs}
\item[fontname distribution]\CTANref{fontname}
\end{ctanrefs}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\section{Acquiring the Software}

\Question[Q-archives]{Repositories of \TeX{} material}

To aid the archiving and retrieval of of \TeX{}-related files, a
\acro{TUG} working group developed the Comprehensive \TeX{} Archive
Network (\acro{CTAN}).  Each \acro{CTAN} site has identical material,
and maintains authoritative versions of its material.  These
collections are extensive; in particular, almost everything mentioned
in this \acro{FAQ}
is archived at the \acro{CTAN} sites (see the lists of software at the
end of each answer).

\begin{narrowversion} % non-hyper
  The \acro{CTAN} sites are in Germany, the UK and the USA; the
  directory layout is the same on each of the sites, starting from a
  tree root of \path{tex-archive/} The sites are
  \texttt{dante.ctan.org} (Dante, Germany), \texttt{cam.ctan.org}
  (Cambridge, UK) and \texttt{tug.ctan.org} (TUG, USA).
\end{narrowversion}
\begin{wideversion} % hyper
  The \acro{CTAN} sites are
  \href{ftp://dante.ctan.org/tex-archive}{Dante (Germany)},
  \href{ftp://cam.ctan.org/tex-archive}{Cambridge (UK)} and
  \href{ftp://tug.ctan.org/tex-archive}{TUG (USA)}; the links are to
  the root of the \acro{CTAN} tree, above which the layout is
  identical at each site.
\end{wideversion}

The \TeX{} files at each \acro{CTAN} node may also be accessed via
the Web at \acro{URL}s \URL{http://www.dante.de/tex-archive},
\URL{http://www.tex.ac.uk/tex-archive} and
\URL{http://www.ctan.org/tex-archive} respectively, but not all
\acro{CTAN} mirrors are Web-accessible.

As a matter of course, to reduce network load,
please use the \acro{CTAN} site
or mirror closest to you.  A complete and current list of \acro{CTAN} sites
and known mirrors is available as file \CTANref{CTAN-sites} on the
archives themselves.

Better still, the script behind \URL{http://mirror.ctan.org/} will
cunningly choose a ``nearby'' mirror for you, using information from
the database `behind' \CTANref{CTAN-sites}; at present it uses
\texttt{ftp} protocol for transfers, but the intention is to convert
it to using \texttt{http} (web) protocol in the near future.

To access a particular thing through the \texttt{mirror.ctan.org}
mechanism, simply place the \acro{CTAN} path after the base
\acro{URL}; so
\URL{http://mirror.ctan.org/macros/latex/contrib/footmisc/} will
connect you to the \Package{footmisc} directory~--- note that the
\File{tex-archive} part of the \acro{CTAN} path isn't needed.

For details of how to find files at \acro{CTAN} sites, see
``\Qref*{finding \AllTeX{} files}{Q-findfiles}''.

The \TeX{} user who has no access to any sort of
network may buy a copy of the archive as part of the
\Qref*{\texlive{} distribution}{Q-CD}.

\Question[Q-tds-zip]{Prebuilt installation files on the archive}

The \Qref*{\acro{TDS}}{Q-tds} is a simple structure, and almost all
files can be installed simply by putting them in the ``right'' place,
and updating a single index.  (Note, this simple idea typically
doesn't work for fonts, unless they're distributed as \MF{} source.)

The CTAN network is therefore acquiring ``\acro{TDS-ZIP}'' files,
which have a built-in directory structure that matches the \acro{TDS}.
These files have to be built, and the \acro{CTAN} team has asked that
package authors supply them (the team will advise, of course, if the
author has trouble).  Everyone hopes that the extra work involved will
contrinute to happier lives for package users, which in turn must
surely help keep the TeX community lively and active.

Use of the files is discussed in % ! line break
``\Qref*{installing using preformatted \acro{ZIP} files}{Q-inst-tds-zip}''.

\Question[Q-nonfree]{What's the \acro{CTAN} \texttt{nonfree} tree?}

When \acro{CTAN} was founded, in the 1990s, it was unusual to publish
the terms under which a \TeX{}-related package was distributed (or, at
any rate, to publish those terms formally).

With the advent of the \TeX{} \emph{distributions}, however, people
started to realise the need for such information, to protect those who
create, distribute or sell the discs that hold the packages, etc.
With the licence information available, the distributors can decide
which packages may be distributed.

The \acro{CTAN} team decided that it would be useful for users (and
distributors, not to say package authors) to separate packages that
were candidates for distribution, and those that were in some sense
``not free''.  Thus was the \texttt{nonfree} tree born.

From the start, the \texttt{nonfree} tree was controversial: the terms
under which a package would be placed on the tree were hotly
contested, and the \acro{CTAN} team were only able slowly to populate
the tree.  It is now obvious to the team that the project would never
be completed.

The \acro{CTAN} catalogue now records the nature of the licences of a
good proportion of the packages it describes (though there remain
several for which the licence is unknown, which is as good, for the
distributors, as a licence forbidding distribution).  Since the
catalogue's coverage of \acro{CTAN} is good (and slowly improving),
the general rule for distributors has become
\begin{quote}
``if the package is listed in the catalogue, check there to see
whether you should distribute; if the package is not listed in the
catalogue, don't think of distributing it''.
\end{quote}

(The catalogue only has a modest % ! line break
\CTANhref{cat-licences}{list of licences}, but it covers the set used
by packages on \acro{CTAN}, with a wild-card ``\texttt{other-free}''
which covers packages that the \acro{CTAN} administrators believe to
be free even though the authors haven't used a standard licence.)

In the light of the above, the \texttt{nonfree} tree is being
dismantled, and its contents moved to the main \acro{CTAN} tree.  So
the answer to the question is, now, ``the nonfree tree is a part of
\acro{CTAN}, and is now being merged with the main tree''.


% The \acro{CTAN} archives are currently restructuring their holdings
% so that files that are `not free' are held in a separate tree.  The
% definition of what is `free' (for this purpose) is influenced by, but
% not exactly the same as the 
% \begin{narrowversion} % really non-hyper version
%   Debian Free Software Guidelines (\acro{DFSG}: see
%   \URL{http://www.debian.org/social_contract#guidelines}).
% \end{narrowversion}
% \begin{wideversion}
% % don't let the line wrap...
% \href{http://www.debian.org/social_contract#guidelines}{Debian Free Software Guidelines (\acro{DFSG})}.
% \end{wideversion}

% Material is placed on the \texttt{nonfree} tree if it is not
% freely-usable (e.g., if the material is shareware, commercial, or if
% its usage is not permitted in certain domains at all, or without
% payment).  Users of the archive should check that they are entitled to
% use material they have retrieved from the \texttt{nonfree} tree.

% The Catalogue (one of the prime sources for finding \TeX{}-related
% material via \nothtml{web search~--- }%
% \Qref{web search}{Q-findfiles}) lists the licence details in each
% entry in its lists.
% For details of the licence categories, see its % !line break
% \href{http://www.tex.ac.uk/tex-archive/help/Catalogue/licenses.html}{list of licences}.

\Question[Q-uploads]{Contributing a file to the archives}

You have something to submit to the archive~--- great!  Before we even
start, here's a check-list of things to sort out:
\begin{enumerate}
\item Licence: in the spirit of \TeX{}, we hope for free software; in
  the spirit of today's lawyer-enthralled society, \acro{CTAN}
  provides a % ! line break
  \href{http://www.tex.ac.uk/tex-archive/help/Catalogue/licenses.html}{list of ``standard'' licence statements}.
\item Documentation: it's good for users to be able to browse
  documentation before downloading a package.  You need at least a
  plain text \File{README} file (exactly that name); in addition a
  \acro{PDF} file of the package documentation, prepared for screen
  reading, is highly desirable.
\item Name: endless confusion is caused by name clashes.  If your
  package has the same name as one already on \acro{CTAN}, or if your
  package installation generates files of the same name as something
  in a ``normal'' distribution, the \acro{CTAN} team will delay
  installation while they check that you're doing the right thing:
  they may nag you to change the name, or to negotiate a take-over
  with the author of the original package. % beware line break
  \Qref*{Browse the archive}{Q-findfiles} to ensure uniqueness.
  
  The name you choose should also (as far as possible) be somewhat
  descriptive of what your submission actually \emph{does}; while
  ``descriptiveness'' is to some extent in the eye of the beholder,
  it's clear that names such as \File{mypackage} or \File{jiffy}
  aren't suitable.
\end{enumerate}

If you are able to use anonymous \ProgName{ftp}, you can upload that
way.  The file \File{README.uploads} on \acro{CTAN} tells you
where to upload, what to upload, and how to notify the \acro{CTAN}
management about what you want doing with your upload.

You may also upload via the Web: each of the principal \acro{CTAN}
sites offers an upload page~--- choose from
\URL{http://www.ctan.org/upload.html},
\URL{http://www.dante.de/CTAN/upload.html} or
\URL{http://www.tex.ac.uk/upload.html}; the pages lead you through the
process, showing you the information you need to supply.  This method
enforces one file per upload: if you had intended to upload lots of
files, you need to bundle them into an `archive' file of some sort;
acceptable formats are \extension{zip} and \extension{tar.gz} (or
\extension{tar.bz2}).

If you can use neither of these methods, or if you find something
confusing, ask advice of the
\begin{narrowversion} % really non-hyper version
  \acro{CTAN} management (\mailto{ctan@dante.de}):
\end{narrowversion}
\begin{wideversion}
  \href{mailto:ctan@dante.de}{\acro{CTAN} management}:
\end{wideversion}
if the worst comes to the worst, it may be possible to mail a
contribution.  This really is a last-resort route: none of the
\acro{CTAN} sites is anyone's regular workstation, so if you mail to
one of the maintainers, that maintainer then has to upload to
\acro{CTAN}.
  
If it's appropriate (if your package is large, or regularly updated),
the \acro{CTAN} management can arrange to \ProgName{mirror} your
contribution direct into the archive.  At present this may only be
done if your contribution is available via \ProgName{ftp}, and of
course the directory structure on your repository must `fit'.
\begin{ctanrefs}
\item[README.uploads]\CTANref{CTAN-uploads}
\end{ctanrefs}

\Question[Q-findfiles]{Finding \AllTeX{} files}

Modern \TeX{} distributions contain a huge array of support files of
various sorts, but sooner or later most people need to find something
that's not in their present system (if nothing else, because they've
heard that something has been updated).

But how to find the files?

Some sources, such as these \acro{FAQ} answers, provide links to
files: so if you've learnt about a package here, you should be able to
retrieve it without too much fuss.

Otherwise, the \acro{CTAN} sites provide searching facilities, via the web.
The simplest search, locating files by name, is to be found on the
Dante \acro{CTAN}
at \URL{http://www.dante.de/cgi-bin/ctan-index}; the script scans a
list of files (\File{FILES.byname}~--- see below) and returns a list
of matches, arranged very neatly as a series of links to directories
and to individual files.

The \href{http://www.tex.ac.uk/search}{\acro{UK}} and
\href{http://www.ctan.org/search.html}{\acro{USA}} \acro{CTAN}s offer a
search page that provides
\begin{itemize}
\item a file-name search similar to the Dante machine's (above);
\item a keyword search of the archive catalogue (see below): this is a
  pretty powerful tool: the results include links to the catalogue
  ``short descriptions'', so you can assure yourself that the package
  you've found is the one you want; and
\item a search form that allows you to use \ProgName{Google} to search
  \acro{CTAN}.
\end{itemize}

An alternative way to scan the catalogue is to use the catalogue's
% ! line break
\href{http://www.tex.ac.uk/tex-archive/help/Catalogue/bytopic.html}{``by topic'' index};
this lists a series of topics, and \AllTeX{} projects that are worth
considering if you're working on matters related to the topic.  

In fact, \ProgName{Google}, and other search engines, can be useful
tools.  Enter your search keywords, and you may pick up a package that
the author hasn't bothered to submit to \acro{CTAN}.  If you're using
\ProgName{Google}, you can restrict your search to \acro{CTAN} by
entering
\begin{quote}
  \texttt{site:ctan.org tex-archive \meta{search term(s)}}
\end{quote}
in \ProgName{Google}'s ``search box''.  You can also enforce the
restriction using \ProgName{Google}'s ``advanced search'' mechanism;
other search engines (presumably) have similar facilities.

Many people avoid the need to go over the network at all, for their
searches, by downloading the file list that the archives' web
file searches use.  This file, \File{FILES.byname},
presents a unified listing of the archive (omitting directory names and
cross-links).  Its companion \File{FILES.last07days} is also useful, to
keep an eye on the changes on the archive.  Since these files are
updated only once a day, a nightly automatic download (perhaps using
\ProgName{rsync}) makes good sense.
\begin{ctanrefs}
\item[FILES.byname]\CTANref{f-byname}
\item[FILES.last07days]\CTANref{f-last7}
\end{ctanrefs}

\Question[Q-findfont]{Finding new fonts}

A comprehensive list of \MF{} fonts used to be posted to
\Newsgroup{comp.fonts} and to \Newsgroup{comp.text.tex}, roughly
every six weeks, by Lee Quin.
Nowadays, authors of new material in \MF{} are few and far between
(and mostly designing highly specialised things with limited appeal to
ordinary users); as a result, no-one has taken over maintenance of the
list of fonts.  If you need a font for some esoteric purpose, it may
be worth \Qref*{searching \acro{CTAN}}{Q-findfiles} using your purpose
as a search keyword.

Most new fonts that appear are prepared in some scalable outline form
or other, and a large proportion is distributed under commercial
terms.  However, once you have acquired such a font, converting it to
a form usable by your \AllTeX{} distribution is not (in principle) a
serious problem.

The answer ``\Qref*{choice of scalable fonts}{Q-psfchoice}'' discusses
fonts that are configured for general (both textual and mathematical)
use with \AllTeX{}.  The list of such fonts is sufficiently short that
they \emph{can} all be discussed in one answer here.
\begin{ctanrefs}
\item[\nothtml{\rmfamily}\MF{} font list]\CTANref{mf-list}
\end{ctanrefs}

\Question[Q-CD]{The \TeX{} collection}

If you don't have access to the Internet, there are obvious
attractions to \TeX{} collections on a disc.  Even those with net
access will find large quantities of \TeX{}-related files to hand a
great convenience.

The \TeX{} collection provides this, together with
ready-to-run \TeX{} systems for various architectures.  Contents of
the collection are:
\begin{itemize}
\item The \texlive{} installation disc (a \acro{CD}) provides \TeX{}
  systems for use on \acro{GNU}-Linux, MacOS/X and Win-32
  architectures;
\item The \texlive{} `Live' disc (a \acro{DVD}) providing \TeX{} for
  a wider range of architectures;
\item Mac\TeX{}: an easy to install \TeX{} system for MacOS/X, based
  on \texlive{}, and including the % ! line break
  \href{http://www.uoregon.edu/~koch/texshop/}{texshop front-end}
  and other tools;
\item Pro\TeX{}t: an easy to install \TeX{} system for Windows, based
  on \miktex{}, and including an `active' document to guide
  installation; and
\item A snapshot of \acro{CTAN}.
\end{itemize}
A fair number of national \TeX{} User Groups, as well as \acro{TUG},
distribute copies to their members at no extra charge.  Some user
groups are also able to sell additional copies:
contact your local user group or \Qref*{\acro{TUG}}{Q-TUG*}.

You may also download disc images from \acro{CTAN}; the installation
disc, Pro\TeX{}t and Mac\TeX{} are all separately available.  Beware:
they are all pretty large downloads.

More details of the collection are available from its own
\begin{wideversion} % this really ought to be "hyperversion" or summat
  \href{http://www.tug.org/texcollection/}{web page}
  on the \acro{TUG} site.
\end{wideversion}
\begin{narrowversion} % and non-hyperversion?
  web page on the
  \acro{TUG} site \URL{http://www.tug.org/texcollection/}
\end{narrowversion}
\begin{ctanrefs}
\item[Mac\TeX{}]\CTANref{mactex}
\item[Pro\TeX{}t]\CTANref{protext}
\item[\TeX{}live install image]\CTANref{texlive}
\end{ctanrefs}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\section{\TeX{} Systems}

\Question[Q-TeXsystems]{\AllTeX{} for different machines}
\keywords{windows,macintosh,macos,ms-dos,os/2,unix,linux}

We list here the free or shareware packages;
\htmlignore
see \Qref{}{Q-commercial} for details of commercial packages.
\endhtmlignore
\begin{htmlversion}
  another question addresses
  \Qref{commercial \TeX{} vendors'}{Q-commercial} products.
\end{htmlversion}
\begin{description}
\item[Unix] The only current distribution of \TeX{} for Unix systems
  (including \acro{GNU}/Linux and other free Unix-like systems) is
  \texlive{}, which is distributed as part of the % ! line break
  \Qref*{\TeX{} collection}{Q-CD}.

  Members of many \TeX{} user groups receive copies of the collection
  (on \acro{CD} and \acro{DVD}), as part of their membership of the
  groups.

  MacOS/X is also a Unix-based system; however users should refer to
  the information below, under item ``Mac''.
  \begin{ctanrefs}
  \item[texlive]Browse \CTANref{texlive}
  \end{ctanrefs}
\item[Linux] GNU/Linux users are supported by \texlive{} (as noted
  above).

  A free version of the commercial 
  \Qref*{V\TeX{} extended \TeX{} system}{Q-commercial} is available
  for use under Linux, which among other things specialises in direct
  production of \acro{PDF} from \AllTeX{} input.  Sadly, it's no
  longer supported, and the ready-built images are made for use with a
  rather ancient Linux kernel.
  \begin{ctanrefs}
  \item[texlive]Browse \CTANref{texlive}
  \item[vtex]\CTANref{vtex-linux}
  \item[vtex \nothtml{\rmfamily}required common files]\CTANref{vtex-common}
  \end{ctanrefs}
\item[\acro{PC}: Windows post-95]
  \miktex{}, by Christian Schenk, is a comprehensive distribution.  It has
  its own previewer, \acro{YAP}, which is itself capable of printing,
  though the distribution also includes a port of \ProgName{dvips}.
  The current version is available for file-by-file download (the
  \acro{HTML} files in the directory offer hints
  on what you need to get going).  The \miktex{} developers provide a
  ready-to-run copy of the distribution, on \acro{CD} (for purchase) via the
  \href{http://www.miktex.org/cd/}{\miktex{} web site}; otherwise the
  \File{setup} executable is available on \acro{CTAN}, together with
  all the optional packages.
  
  \href{http://tug.org/protext/}{Pro\TeX{}t}, part of the \TeX{}
  collection by Thomas Feuerstack, is
  a further option for installing \miktex{}.  It bundles a \miktex{}
  setup with some further useful utilities, together with a \acro{PDF}
  file which contains clickable links for the various installation
  steps, along with explanations.

  Windows users are also supported directly by the \texlive{}
  distribution; a system is provided on the installation disc of the
  \TeX{} collection (and it can, with some difficulty, be run ``from
  the disc'' without installing \emph{anything}).

  \href{http://foundry.supelec.fr/projects/xemtex/}{XEm\TeX{}}, by
  Fabrice Popineau (he who created the excellent, but now defunct,
  fp\TeX{} distribution), is an integrated distribution of \TeX{}, \LaTeX{},
  \CONTeXT{}, \ProgName{XEmacs} and friends for Windows.  All programs
  have been compiled natively to take the best advantage of the
  Windows environment.  Configuration is provided so that the
  resulting set of programs runs out-of-the-box.

  The (Japanese) \acro{W}32\acro{TEX} distribution was motivated by
  the needs of Japanese users (Japanese won't fit in a ``simple''
  character set like \acro{ASCII}, but \TeX{} is based on a version of
  \acro{ASCII}).  Despite its origins, \acro{W}32\acro{TEX} is said to
  be a good bet for Western users, notably those whose disks are short
  of space: the minimum documented download is as small as
  95\,MBytes.  Investigate the distribution at
  \URL{http://www.fsci.fuk.kindai.ac.jp/kakuto/win32-ptex/web2c75-e.html}

  A further (free) option arises from the
  \href{http://www.cygwin.com}{CygWin bundle}, which presents a
  Unix-like environment over the Win32 interface; an X-windows server
  is available.  If you run CygWin on your Windows machine, you have
  the option of using \texlive{}, too (you will need the X-server, to
  run \ProgName{xdvi}).  Of course, \texlive{} components will look like
  Unix applications (of course, that's presumably what you wanted),
  but \TeX{} under CygWin also reputedly somewhat slower than native
  Win32 implementations such as \miktex{} or XEm\TeX{}.  The (now
  obsolete) te\TeX{} distribution is provided as part of the CygWin
  distribution, and but you can build your own copy of \texlive{} from
  the current sources.

  BaKoMa \TeX{}, by Basil Malyshev, is a comprehensive (shareware)
  distribution, which focuses on support of Acrobat.  The distribution
  comes with a bunch of Type~1 fonts packaged to work with BaKoMa
  \TeX{}, which further the focus.
  \begin{ctanrefs}
  \item[bakoma]\CTANref{bakoma-tex}
  \item[miktex]Acquire \CTANref{miktex-setup} (also available from the
    \miktex{} web site), and read installation instructions from %
                                % ! line break
    \href{http://www.miktex.org/2.5/Setup.aspx}{the \miktex{} installation page}
  \item[protext.exe]\CTANref{protext}
  \item[tetex]\CTANref{tetex}
  \end{ctanrefs}
\item[\acro{PC}: \MSDOS{} or \acro{OS/}2] Em\TeX{}, by Eberhard Mattes,
  includes \LaTeX{}, \BibTeX{}, previewers, and drivers, and is
  available  as a series of zip archives.  Documentation is
  available in both German and English.  Appropriate memory managers
  for using em\TeX{} with 386 (and better) processors and under
  Windows, are included in the distribution.  Em\TeX{} will operate
  under Windows, but Windows users are better advised to use a
  distribution tailored for the Windows environment.

  A version of em\TeX{}, packaged to use a
  % beware line break
  \Qref*{TDS directory structure}{Q-tds}, is separately available as
  an em\TeX{} `contribution'.  Note that neither em\TeX{} itself, nor
  em\TeX{}\acro{TDS}, is maintained.  Most users of Microsoft
  operating systems, who want an up-to-date \AllTeX{} system, need to
  migrate to Win32-based systems.
  \begin{ctanrefs}
  \item[emtex]\CTANref{emtex}
  \item[emtexTDS]\CTANref{emtextds}
  \end{ctanrefs}
\item[\acro{PC}: \MSDOS{}] The most recent \MSDOS{} offering is a
  port of the Web2C~7.0 implementation, using the \acro{GNU}
  \ProgName{djgpp} compiler.  While this package is more recent than
  em\TeX{}, it still implements a rather old instance of \AllTeX{}.
  \begin{ctanrefs}
  \item[djgpp]\CTANref{djgpp}
  \end{ctanrefs}
\item[\acro{PC}: \acro{OS/}2] Em\TeX{}, by Eberhard Mattes (see
  above), was actually developed under \acro{OS/}2, and lives happily
  in that environment.

  \acro{OS/}2 users may also use a free version of the
  commercial \Qref*{V\TeX{}}{Q-commercial}, which specialises
  in direct production of \acro{PDF} from \AllTeX{} input.  (This
  version is, like the Linux version, unfortunately no longer supported.)
  \begin{ctanrefs}
  \item[emtex]\CTANref{emtex}
  \item[emtexTDS]\CTANref{emtextds}
  \item[vtex]\CTANref{vtex-os2}
  \item[vtex \nothtml{\rmfamily}required common files]\CTANref{vtex-common}
  \end{ctanrefs}
%% \item[Windows \acro{NT}, other platforms] Ports of \miktex{} for
%%   \acro{NT} on Power \acro{PC} and \acro{AXP} are available.  Neither
%%   version has been updated for version~1.2 (or later) of
%%   \miktex{}~--- they may not be satisfactory.
%%   \begin{ctanrefs}
%%   \item[miktex for AXP]\CTANref{miktex-AXP}
%%   \item[miktex for Power PC]\CTANref{miktexppc}
%%   \end{ctanrefs}
\item[Mac] \href{http://www.trevorrow.com/oztex/}{Oz\TeX{}}, by Andrew
  Trevorrow, is a shareware version of
  \TeX{} for the Macintosh.  A \acro{DVI} previewer and \PS{}
  driver are also included.  (Members of \acro{UK}~\acro{TUG} may
  acquire the software without further payment, as part of a
  membership deal.)  Oz\TeX{} does not run, natively, under MacOS/X,
  but will run with a sufficiently recent CarbonLib (see
  \URL{http://www.trevorrow.com/oztex/ozosx.html}).
  Other questions about Oz\TeX{} itself may be directed to
  \mailto{oztex@midway.uchicago.edu}

  Another partly shareware program is
  \href{http://www.kiffe.com/cmactex.html}{CMac\TeX{}} , put together
  by Tom Kiffe.  CMac\TeX{} is much closer than Oz\TeX{} to the Unix
  \TeX{} model of things (it uses \ProgName{dvips}, for instance).
  CMac\TeX{} runs natively under  includes a port of a version of
  \Qref*{Omega}{Q-omegaleph}.

  Both Oz\TeX{} and \acro{CM}ac\TeX{} run on either MacOS/X or on a
  sufficiently recent MacOS with CarbonLib 
  (v1.3~for Oz\TeX{}, v1.4~for CMac\TeX{}).
  % beware line wrap

  From its 2005 release, the \Qref*{\texlive{} disc set}{Q-CD}
  includes Mac\TeX{}.  Details (and a downloadable distribution set)
  may be found on the % ! line break
  \href{http://tug.org/mactex}{\acro{TUG} web site}; the distribution
  is also on \acro{CTAN}.

\begin{narrowversion} % really, non-hyper version
  A useful resource for Mac users is to be found at
  \URL{http://www.esm.psu.edu/mac-tex/}; it has a news and `help'
  section, as well as details of systems and tools.
\end{narrowversion}
\begin{wideversion}
  A useful
  \href{http://www.esm.psu.edu/mac-tex/}{resource for Mac users}
  has a news and `help' section, as well as details of systems and
  tools.
\end{wideversion}
  The Mac\TeX{}-on-OSX mailing list is a useful resource for users;
  mail \mailto{MacOSX-TeX-on@email.esm.psu.edu} to subscribe.
\begin{ctanrefs}
  \item[cmactex]\CTANref{cmactex}
  \item[mactex]\CTANref{mactex}
  \item[oztex]\CTANref{oztex}
\end{ctanrefs}
\item[Open\acro{VMS}] \TeX{} for Open\acro{VMS} is available, though
  it seems unlikely that the version on \acro{CTAN} is the latest
  available.  
  \begin{ctanrefs}
  \item[OpenVMS]\CTANref{OpenVMSTeX}
  \end{ctanrefs}
\item[Atari] \TeX{} for the Atari \acro{ST} is available from \acro{CTAN}.
  \begin{ctanrefs}
  \item[Atari TeX]\CTANref{atari}
  \end{ctanrefs}
\item[Amiga] Full implementations of \TeX{} 3.1 (Pas\TeX{}) and \MF{}
  2.7 are available.
  \begin{ctanrefs}
  \item[PasTeX]\CTANref{amiga}
  \end{ctanrefs}
\item[\acro{TOPS}-20] \TeX{} was originally written on a \acro{DEC}-10
  under \acro{WAITS},
  and so was easily ported to \acro{TOPS}-20. A distribution that runs on
  \acro{TOPS}-20 is available via anonymous \texttt{ftp} from
  \FTP{ftp.math.utah.edu} in \path{pub/tex/pub/web}
  \checked{RF}{2001/03/01}
\end{description}

\Question[Q-editors]{\TeX{}-friendly editors and shells}

There are good \TeX{}-writing environments and editors for most
operating systems; some are described below, but this is only a
personal selection:
\begin{description}
\item[Unix] Try
  \href{http://www.gnu.org/software/emacs/emacs.html}{\acro{GNU}\nobreakspace\ProgName{emacs}}
  or \href{http://www.xemacs.org/}{\ProgName{XEmacs}}, and
  the \acro{AUC}-\TeX{}
  bundle (available from \acro{CTAN}).  \acro{AUC}-\TeX{} provides menu
  items and control sequences for common constructs, checks syntax,
  lays out markup nicely, lets you call \TeX{} and drivers from
  within the editor, and everything else like this that you can think
  of.  Complex, but very powerful.

  Many who consider the versions of \ProgName{emacs} spawn of the devil, prefer
  \href{http://vim.sourceforge.net}{\ProgName{vim}}, a highly configurable
  editor (also available for Windows and Macintosh systems).  Many
  plugins are available to support the needs of the \AllTeX{} user,
  including syntax highlighting, calling \TeX{} programs,
  auto-insertion and -completion of common \AllTeX{} structures, and
  browsing \LaTeX{} help.  The scripts \File{auctex.vim} and
  \File{bibtex.vim} seem to be the most common recommendations.

  The editor \href{http://nedit.org/}{\ProgName{NEdit}} is also free
  and programmable, and is available for Unix systems.  An
  \acro{AUC}-\TeX{}-alike set of extensions for \ProgName{NEdit} is available
  from \acro{CTAN}.

  \ProgName{LaTeX4Jed} provides much enhanced \LaTeX{} support for the
  \href{http://www.jedsoft.org/jed/}{\ProgName{jed}} editor.
  \ProgName{LaTeX4Jed} is similar to \acro{AUC}-\TeX{}: menus,
  shortcuts, templates, syntax highlighting, document outline,
  integrated debugging, symbol completion, full integration with
  external programs, and more. It was designed with both the beginner
  and the advanced LaTeX user in mind.

  The \ProgName{Kile} editor that is provided with the \acro{KDE}
  window manager provides \acro{GUI} ``shell-like'' facilities, in a
  similar way to the widely-praised \ProgName{Winedt} (see below);
  details (and downloads) are available from the project's
  \href{http://kile.sourceforge.net/}{home on SourceForge}.  A newer
  system (by \ProgName{Kile}'s original author),
  \href{http://www.xm1math.net/texmaker/}{\ProgName{texmaker}} doesn't
  rely on \acro{KDE}'s facilities, and so may be more easily portable.
\item[\MSDOS{}] \TeX{}shell is a simple,
  easily-customisable environment, which can be used with the editor
  of your choice.

  You can also use \acro{GNU}~\ProgName{emacs} and \acro{AUC}-\TeX{}
  under \MSDOS{}.
\item[Windows '9x, NT, etc.]\ProgName{TeXnicCenter} is a (free)
  \TeX{}-oriented development system, uniting a powerful platform for
  executing \AllTeX{} and friends with a configurable editor.
  
  \ProgName{Winedt}, a shareware package, is also highly spoken of.
  It too provides a shell for the use of \TeX{} and related programs,
  as well as a powerful and well-configured editor.  The editor can
  generate its output in \acro{UTF}-8 (to some extent), which is
  useful when working with \Qref*{\xetex{}}{Q-xetex} (and other
  ``next-generation'' \AllTeX{} applications).

  Both \ProgName{emacs} and \ProgName{vim} are available in versions
  for Windows systems.
\item[\acro{OS/}2] \ProgName{epmtex}  offers an \acro{OS/}2-specific shell.
\item[Macintosh] The commercial Textures provides an excellent integrated
  Macintosh environment with its own editor.  More powerful still (as an
  editor) is the shareware \ProgName{Alpha} which is
  extensible enough to let you perform almost any \TeX{}-related job. It
  works well with Oz\TeX{}.  From release 2.2.0 (at least), Textures
  works with MacOS~X.

  For MacOS~X users, the free tool of choice appears to be
  \href{http://www.uoregon.edu/~koch/texshop/texshop.html}{TeXShop}, which
  combines an editor and a shell with a coherent philosophy of dealing
  with \AllTeX{} in the OS~X environment.  TeXShop is distributed as
  part of the MacTeX system, and will therefore be available out of
  the box on machines on which MacTeX has been installed.

  \ProgName{Vim} is also available for use on Macintosh systems.
\end{description}
Atari, Amiga and \acro{N}e\acro{XT} users also have nice
environments. \LaTeX{} users looking for \ProgName{make}-like
facilities should review the answer on
\Qref*{Makefiles for \LaTeX{} documents}{Q-make}.

While many \AllTeX{}-oriented editors can support work on \BibTeX{}
files, there are many systems that provide specific ``database-like''
access to your \BibTeX{} files~---
\begin{wideversion}
  see ``\Qref{creating a bibliography file}{Q-buildbib}''.
\end{wideversion}
\begin{narrowversion}
  these are discussed in % ! line break
  ``\Qref*{creating a bibliography file}{Q-buildbib}''.
\end{narrowversion}
\begin{ctanrefs}
\item[alpha]\CTANref{alpha}
\item[auctex]\CTANref{auctex}
\item[epmtex]\CTANref{epmtex}
\item[LaTeX4Jed]\CTANref{latex4jed}
\item[Nedit LaTeX support]\CTANref{nedit-latex}
\item[TeXnicCenter]\CTANref{texniccenter}
\item[TeXshell]\CTANref{texshell}
\item[TeXtelmExtel]\CTANref{TeXtelmExtel}
\item[winedt]\CTANref{winedt}
\end{ctanrefs}

\Question[Q-commercial]{Commercial \TeX{} implementations}
\keywords{windows,macintosh,commercial}

There are many commercial implementations of \TeX{}. The first
appeared not long after \TeX{} itself appeared.

What follows is probably an incomplete list.  Naturally, no warranty or
fitness for purpose is implied by the inclusion of any vendor in this
list.  The source of the information is given to provide some clues to
its currency.

In general, a commercial implementation will come `complete', that is,
with suitable previewers and printer drivers.  They normally also have
extensive documentation (\emph{i.e}., not just the \TeX{}book!) and some
sort of support service.  In some cases this is a toll free number
(probably applicable only within the \acro{USA} and or Canada), but others
also have email, and normal telephone and fax support.
\begin{description}
\item[\acro{PC}; True\TeX{}] Runs on all versions of Windows.
  \begin{quote}
    Richard J. Kinch\\
    TrueTeX Software\\
    7890 Pebble Beach Court\\
    Lake Worth \acro{FL} 33467\\
    \acro{USA}\\[.25\baselineskip]
    Tel: +1 561-966-8400\\
    Email: \mailto{kinch@truetex.com}\\
    Web: \URL{http://www.truetex.com/}
  \end{quote}
  Source: Mail from Richard Kinch, August 2004.
%% \item[\acro{PC}; \YandY{} \TeX{}] ``Bitmap free \TeX{} for Windows.''
%%   \begin{quote}
%%     \YandY{}, Inc.\\
%%     106 Indian Hill, \acro{MA} 01741-1747\\
%%     \acro{USA}\\[.25\baselineskip]
%%     Tel: 800-742-4059 (within North America)\\
%%     Tel: +1 978-371-3286\\
%%     Fax: +1 978-371-2004\\
%%     Email: \mailto{sales-help@YandY.com} and
%%     \nothtml{\\ \hphantom{Email: }}%
%%     \mailto{tech-help@YandY.com}\\
%%     Web: \URL{http://www.YandY.com/}
%%   \end{quote}
%%   Source: Confirmed with \YandY{}, February 2003
\item[pc\TeX{}] Long-established: pc\TeX{}32 is a Windows implementation.
  \begin{quote}
    Personal \TeX{} Inc\\
    725 Greenwich Street, Suite 210 \\
    San Francisco, \acro{CA} 94133\\
    \acro{USA}\\[.25\baselineskip]
    Tel: 800-808-7906 (within the \acro{USA})\\
    Tel: +1 415-296-7550\\
    Fax: +1 415-296-7501\\
    Email: \mailto{sales@pctex.com}\\
    Web: \URL{http://www.pctex.com/}
  \end{quote}
  Source: Personal \TeX{} Inc web site, December 2004
\item[\acro{PC}; V\TeX{}] \acro{DVI}, \acro{PDF} and \acro{HTML}
  backends, Visual Tools and Type 1 fonts
  \begin{quote}
    MicroPress Inc\\
    68-30 Harrow Street\\
    Forest Hills, \acro{NY} 11375\\
    \acro{USA}\\[.25\baselineskip]
    Tel: +1 718-575-1816\\
    Fax: +1 718-575-8038\\
    Email: \mailto{support@micropress-inc.com}\\
    Web: \URL{http://www.micropress-inc.com/}
  \end{quote}
  Source: Mail from MicroPress, Inc., July 1999
\item[\acro{PC}; Scientific Word] Scientific Word and Scientific Workplace
  offer a mechanism for near-\WYSIWYG{} input of \LaTeX{} documents; they
  ship with True\TeX{} from Kinch (see above).  Queries within the \acro{UK}
  and Ireland should be addressed to Scientific Word Ltd., others should be
  addressed directly to the publisher, MacKichan Software Inc.
  \begin{quote}
    Dr Christopher Mabb\\
    Scientific Word Ltd.\\
    990 Anlaby Road,\\
    Hull,\\
    East Yorkshire,\\
    \acro{HU}4 6\acro{AT}\\
    \acro{UK}\\[0.25\baselineskip]
    Tel: 0845 766\,0340 (within the \acro{UK}) \\
    Fax: 0845 603\,9443 (within the \acro{UK}) \\
    Email: \mailto{christopher@sciword.demon.co.uk} \\
    Web: \URL{http://www.sciword.demon.co.uk}
  \end{quote}
  \begin{quote}
    MacKichan Software Inc.\\
    19307 8th Avenue, Suite C\\
    Poulsbo \acro{WA} 98370-7370\\
    \acro{USA}\\[0.25\baselineskip]
    Tel: +1 360 394\,6033\\
    Tel: 877 724\,9673 (within the \acro{USA})
    Fax: +1  360 394\,6039\\
    Email: \mailto{info@mackichan.com}\\
    Web: \URL{http://www.mackichan.com}
  \end{quote}
  Source: Mail from Christopher Mabb, August 2007
\item[Macintosh; Textures] ``A \TeX{} system `for the rest of
  us'\,''.  A beta release of Textures for MacOS/X is
  available \URL{http://www.bluesky.com/news/220b.html}

  (Blue Sky also gives away a \MF{} implementation and some
  font manipulation tools for Macs.)
  \begin{quote}
    Blue Sky Research\\
    PO Box 80424\\
    Portland, \acro{OR} 97280\\
    \acro{USA}\\[.25\baselineskip]
    Tel: 800-622-8398 (within the \acro{USA})\\
    Tel/Fax: +1 503-222-9571\\
    Fax: +1 503-246-4574\\
    Email: \mailto{sales@bluesky.com}\\
    Web: \URL{http://www.bluesky.com/}
  \end{quote}
  Source: Mail from Gordon Lee, April 2007
\item[Amiga\TeX{}] A full implementation for the Commodore Amiga,
  including full, on-screen and printing support for all \PS{}
  graphics and fonts, IFF raster graphics, automatic font generation,
  and all of the standard macros and utilities.
  \begin{quote}
    Radical Eye Software\\
    \acro{PO} Box 2081\\
    Stanford, \acro{CA} 94309\\
    \acro{USA}
  \end{quote}
  Source: Mail from Tom Rokicki, November 1994
\end{description}
\checked{mc}{1994/11/09}%
\checked{RF}{1994/11/24}%

Note that the company \YandY{} has gone out of business, and \YandY{}
\TeX{} (and support for it) is therefore no longer available.  Users
of \YandY{} systems may care to use the self-help
\href*{http://tug.org/pipermail/yandytex/}{mailing list}
that was established in 2003; the remaining usable content of
\YandY{}'s web site is available at \URL{http://www.tug.org/yandy/}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\section{\acro{DVI} Drivers and Previewers}

\Question[Q-dvips]{\acro{DVI} to \PS{} conversion programs}

The best public domain \acro{DVI} to \PS{} conversion program, which
runs under many operating systems, is Tom Rokicki's \ProgName{dvips}.
\ProgName{dvips} is written in \acro{C} and ports easily.  All current
development is in the context of Karl Berry's \ProgName{kpathsea}
library, and sources are available from the \texlive{} repository,
and versions are available in all \TeX{} distributions that recognise
the use of \PS{}.

An \acro{VMS} versions is available as part of the \acro{CTAN}
distribution of \TeX{} for \acro{VMS}.

A precompiled version to work with em\TeX{} is available on \acro{CTAN}.
\begin{ctanrefs}
\item[\nothtml{\rmfamily}\MSDOS{} and \latexhtml{\acro{OS/}}{OS/}2]%
  \CTANref{dvips-pc}
\item[\nothtml{\rmfamily}VMS distribution]\CTANref{OpenVMSTeX}
\end{ctanrefs}

\Question[Q-HPdrivers]{\acro{DVI} drivers for \acro{HP} LaserJet}

The em\TeX{} distribution (see \Qref[question]{\TeX{} systems}{Q-TeXsystems})
contains a driver for the LaserJet, \ProgName{dvihplj}.

Version 2.10 of the Beebe drivers supports the LaserJet. These drivers
will compile under Unix, \acro{VMS}, and on the Atari ST and
\acro{DEC}-20s.

For Unix systems, Karl Berry's \ProgName{dviljk} uses the same
path-searching library as \ProgName{web2c}.
\begin{ctanrefs}
\item[\nothtml{\rmfamily}Beebe drivers]\CTANref{beebe}
\item[dviljk]\CTANref{dviljk}
\end{ctanrefs}

\Question[Q-otherprinters]{Output to ``other'' printers}

In the early years of \TeX{}, there were masses of \acro{DVI} drivers
for any (then) imaginable kind of printer, but the steam seems rather
to have gone out of the market for production of drivers for
printer-specific formats.  There are several reasons for this, but the
primary one is that few formats offer the flexibility available
through \PS{}, and \ProgName{ghostscript} is \emph{so} good, and
has \emph{such} a wide range of printer drivers (perhaps this is where
the \acro{DVI} output driver writers have all gone?).

The general advice, then, is to \Qref*{generate \PS{}}{Q-dvips}, and
to process that with \ProgName{ghostscript} set to generate the format
for the printer you actually have.  If you are using a Unix system of
some sort, it's generally quite easy to insert \ProgName{ghostscript}
into the print spooling process.
\begin{ctanrefs}
\item[ghostscript]Browse \CTANref{ghostscript}
\end{ctanrefs}

\Question[Q-previewers]{\acro{DVI} previewers}

Em\TeX{} for \acro{PC}s running \MSDOS{} or \acro{OS/}2, \miktex{} and
XEm\TeX{} for \acro{PC}s running Windows and Oz\TeX{} for the Macintosh, all
come with previewers that can be used on those platforms. Em\TeX{}'s
previewer can also be run under Windows~3.1.

Commercial \acro{PC} \TeX{} packages (see % ! line break
\Qref[question]{commercial vendors}{Q-commercial})
have good previewers for \acro{PC}s running Windows, or for Macintoshes.

For Unix systems, there is one `canonical' viewer, \ProgName{xdvi}.
\ProgName{Xdvik} is a version of \ProgName{xdvi} using the
\ProgName{web2c} libraries; it is now built from the same distribution
as \ProgName{xdvi}.  The \texlive{} distributions for Unix systems
include a version of \ProgName{xdvik}.

Alternatives to previewing include
\begin{itemize}
\item conversion to `similar' \acro{ASCII} text (see
  \Qref[question]{converting to \acro{ASCII}}{Q-toascii}) and using a
  conventional text viewer to look at that,
\item generating a \PS{} version of your document and viewing it
  with a \ProgName{Ghostscript}-based previewer (see
  \Qref[question]{previewing \PS{} files}{Q-PSpreview}), and
\item generating  \acro{PDF} output, and viewing that with
  \ProgName{Acrobat} \ProgName{Reader} or one of the substitutes for that.
\end{itemize}
\begin{ctanrefs}
\item[xdvi]\CTANref{xdvi}
\end{ctanrefs}

\Question[Q-dvi-bmp]{Generating bitmaps from \acro{DVI}}

In the last analysis, any \acro{DVI} driver or previewer is generating
bitmaps: bitmaps for placing tiny dots on paper via a laser- or
inkjet-printer, or bitmaps for filling some portion of your screen.
However, it's usually difficult to extract any of those bitmaps any
way other than by screen capture, and the resolution of \emph{that} is
commonly lamentable.

Why would one want separate bitmaps?  Most often, the requirement is for
something that can be included in \acro{HTML} generated from \AllTeX{}
source~--- not everything that you can write in \AllTeX{} can be
translated to \acro{HTML} (at least, portable \acro{HTML} that may be
viewed in `most' browsers), so the commonest avoiding action is to
generate a bitmap of the missing bit.  Examples are maths (a maths
extension to the |*|\acro{ML} family is available but not widely
used), and `exotic' typescripts (ones that you cannot guarantee your
readers will have available).  Other common examples are generation of
sample bitmaps, and generation for insertion into some other
application's display~--- to insert equations into Microsoft
PowerPoint, or to support the enhanced-\ProgName{emacs} setup called
\Qref*{\ProgName{preview}-\ProgName{latex}}{Q-WYGexpts}.

In the past, the commonest way of generating bitmaps was to generate a
\PS{} file of the \acro{DVI} and then use \ProgName{ghostscript} to
produce the required bitmap format (possibly by way of \acro{PNM}
format or something similar).  This is an undesirable procedure (it is
very slow, and requires two or three steps) but it has served for a
long time.

\AllTeX{} users may now take advantage of two bitmap `drivers'.  The
longer-established, \ProgName{dvi2bitmap}, will generate \acro{XBM} and
\acro{XPM} formats, the long-deprecated \acro{GIF} format (which is
now obsolescent, but has finally been relieved of the patent
protection of the \acro{LZW} compression it uses), and also
the modern (\acro{ISO}-standardised) \acro{PNG} format.

Dvipng started out as a PNG renderer; from version 1.2 it can also
render to the GIF format. It is designed for speed, in environments that
generate large numbers of \acro{PNG} files: the \File{README} mentions
\ProgName{preview}-\ProgName{latex}, \ProgName{LyX}, and a few
web-oriented environments. Note that \ProgName{dvipng} gives
high-quality output even though its internal operations are optimised
for speed.
\begin{ctanrefs}
\item[dvi2bitmap]\CTANref{dvi2bitmap}
\item[dvipng]\CTANref{dvipng}
\end{ctanrefs}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\section{Support Packages for \TeX{}}

\Question[Q-fig]{Fig, a \AllTeX{}-friendly drawing package}

\ProgName{(X)Fig} is a menu driven tool that allows you to
draw objects on the screen of an \acro{X} workstation; \ProgName{transfig}
is a set of tools which translate the code \ProgName{fig}.  The list
of export formats is very long, and includes \MF{} and \MP{},
Encapsulated \PS{} and \acro{PDF}, as well as combinations that wrap
a graphics format in a \LaTeX{} import file.

There's no explicit port of \ProgName{xfig} to windows (although it is
believed to work under \ProgName{cygwin} with their X-windows system).
However, the program % ! line break
\href{http://tech-www.informatik.uni-hamburg.de/applets/javafig/}{\ProgName{jfig}}
is thought by many to be an acceptable substitute, written in Java.
\begin{ctanrefs}
\item[xfig]\CTANref{xfig}
\item[transfig]\CTANref{transfig}
\end{ctanrefs}

\Question[Q-texcad]{\TeX{}\acro{CAD}, a drawing package for \LaTeX{}}

\TeX{}\acro{CAD} is a program for the \acro{PC} which enables the user to draw diagrams
on screen using a mouse or arrow keys, with an on-screen menu of available 
picture-elements. Its output is code for the \LaTeX{}
\environment{picture} environment. 
Optionally, it can be set to include lines at all angles using 
the em\TeX{} driver-family
\htmlignore
\csx{special}s (\Qref{}{Q-specials}).
\endhtmlignore
\begin{htmlversion}
\Qref{\csx{special}s}{Q-specials}.
\end{htmlversion}
\TeX{}\acro{CAD} is part of the em\TeX{} distribution.

A Unix port of the program (\ProgName{xtexcad}) has been made.
\begin{ctanrefs}
\item[emtex]\CTANref{emtex}
\item[xtexcad]\CTANref{xtexcad}
\end{ctanrefs}

\Question[Q-spell]{Spelling checkers for work with \TeX{}}

For Unix, \ProgName{ispell} was long the program of choice; it is well
integrated with \ProgName{emacs}, and deals with some \TeX{} syntax.
However, it has more-or-less been replaced everywhere, by
\ProgName{aspell}, which was designed as a successor, and certainly
performs better on most metrics; there remains some question as to its
performance with \AllTeX{} sources.

For Windows, there is a good spell checker incorporated into many of
the \Qref*{shell/editor}{Q-editors} combinations that are available.
The spell checker from the (now defunct) 4All\TeX{} shell remains
available as a separate package, \ProgName{4spell}.

For the Macintosh, \ProgName{Excalibur} is the program of choice.  It
will run in native mode on both sorts of Macintosh.  The distribution
comes with dictionaries for several languages.

The \acro{VMS} Pascal program \ProgName{spell} makes special cases of
some important features of \LaTeX{} syntax.

For \MSDOS{}, there are several programs.  \ProgName{Amspell} can be
called from within an editor, and \ProgName{jspell} is an extended
version of \ProgName{ispell}.
\begin{ctanrefs}
\item[4spell]\CTANref{4spell}
\item[amspell]\CTANref{amspell}
\item[aspell]Browse \CTANref{aspell}~--- choose just those language
  dictionaries (under subdirectory \File{dict/}) that you need.
\item[excalibur]\CTANref{Excalibur}
\item[ispell]\CTANref{ispell}
\item[jspell]\CTANref{jspell}
\item[\nothtml{\bgroup\rmfamily}\acro{VMS}\nothtml{\egroup} spell]%
  \CTANref{vmspell}
\item[winedt]\CTANref{winedt}
\end{ctanrefs}

\Question[Q-wordcount]{How many words have you written?}

One often has to submit a document (e.g., a paper or a dissertation)
under some sort of constraint about its size.  Sensible people set a
constraint in terms of numbers of pages, but there are some that
persist in limiting the numbers of words you type.

A simple solution to the requirement can be achieved following a
simple observation: the powers that be are unlikely to count all the
words of a document submitted to them.  Therefore, a statistical
method can be employed: find how many words there are on a full page;
find how many full pages there are in the document (allowing for
displays of various sorts, this number will probably not be an
integer); multiply the two.  However, if the document to be submitted
is to determine the success of the rest of one's life, it takes a
brave person to thumb their nose at authority quite so
comprehensively\dots{}

The simplest method is to strip out the \AllTeX{} markup, and to count
what's left.  On a  Unix-like system, this may be done using
\ProgName{detex} and the built-in \ProgName{wc}:
\begin{verbatim}
  detex <filename> | wc -w
\end{verbatim}
The \ProgName{latexcount} script does the same sort of job, in one
``step''; being a \ProgName{perl} script, it is in principle rather
easily configured (see documentation inside the script).
\ProgName{Winedt} (see \Qref[question]{editors and shells}{Q-editors})
provides this functionality direct in the Windows environment.

Simply stripping \AllTeX{} markup isn't entirely reliable, however:
that markup itself may contribute typeset words, and this could be a
problem.  The \Package{wordcount} package
contains a Bourne shell (i.e., typically Unix) script for running a
\LaTeX{} file with a special piece of supporting \TeX{} code, and then
counting word indications in the log file.  This is probably as
accurate automatic counting as you can get.
\begin{ctanrefs}
\item[detex]\CTANref{detex}
\item[wordcount]\CTANref{wordcount}
\end{ctanrefs}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\section{Literate programming}

\Question[Q-lit]{What is Literate Programming?}

Literate programming is the combination of documentation and source
together in a fashion suited for reading by human beings. 
In general, literate programs combine source
and documentation in a single file.  Literate programming tools then
parse the file to produce either readable documentation or compilable
source.  The \acro{WEB} style of literate programming was created by
D.~E.~Knuth during the development of \TeX{}.

\htmlignore
The ``documented \LaTeX{}'' style of programming (\Qref{}{Q-dtx})
\endhtmlignore
\begin{htmlversion}
  The ``\Qref{documented \LaTeX{}}{Q-dtx}'' style of programming
\end{htmlversion}
is regarded by some as a form of literate programming, though it only
contains a subset of the constructs Knuth used.

Discussion of literate programming is conducted in the newsgroup
\Newsgroup{comp.programming.literate}, whose \acro{FAQ} is stored on
\acro{CTAN}.  Another good source of information is
\URL{http://www.literateprogramming.com/}
\begin{ctanrefs}
\item[\nothtml{\rmfamily}Literate Programming \acro{FAQ}]%
  \CTANref{LitProg-FAQ}
\end{ctanrefs}

\Question[Q-webpkgs]{\acro{WEB} systems for various languages}

\TeX{} is written in the programming language \acro{WEB}; \acro{WEB}
is a tool to implement the concept of ``literate programming''.
Knuth's original implementation will be in any respectable
distribution of \TeX{}, but the sources of the two tools
(\ProgName{tangle} and \ProgName{weave}), together with a manual
outlining the programming techniques, may be had from \acro{CTAN}.

\acro{\ProgName{CWEB}}, by Silvio Levy, is a \acro{WEB} for \acro{C} programs.

Spidery \acro{WEB}, by Norman Ramsey, supports many 
languages including Ada, \texttt{awk}, and \acro{C}
and, while not in the public domain, is usable without charge.  It is
now superseded by \ProgName{noweb} (also by Norman Ramsay) which
incorporates the lessons learned in implementing spidery \acro{WEB},
and which is a simpler, equally powerful, tool.

\acro{\ProgName{FWEB}}, by John Krommes, is a version for Fortran,
Ratfor, and \acro{C}. 

\ProgName{Scheme}\acro{\ProgName{WEB}}, by John Ramsdell, is a Unix filter that
translates Scheme\acro{WEB} into \LaTeX{} source or Scheme source.

\acro{\ProgName{APLWEB}} is a version of \acro{WEB} for \acro{APL}.

\ProgName{FunnelWeb} is a version of \acro{WEB} that is language independent.

Other language independent versions of \acro{WEB} are \ProgName{nuweb} (which
is written in \acro{ANSI} \acro{C}).

\ProgName{Tweb} is a \acro{WEB} for \plaintex{} macro files, using
\ProgName{noweb}.
\begin{ctanrefs}
\item[aplweb]\CTANref{aplweb}
\item[cweb]\CTANref{cweb}
\item[funnelweb]\CTANref{funnelweb}
\item[fweb]\CTANref{fweb}
\item[noweb]\CTANref{noweb}
\item[nuweb]\CTANref{nuweb}
\item[schemeweb]\CTANref{schemeweb}
\item[spiderweb]\CTANref{spiderweb}
\item[tangle]\CTANref{web}
\item[tweb]\CTANref{tweb}
\item[weave]\CTANref{web}
\end{ctanrefs}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\section{Format conversions}

\Question[Q-toascii]{Conversion from \AllTeX{} to plain text}

The aim here is to emulate the Unix \ProgName{nroff}, which formats
text as best it can for the screen, from the same
input as the Unix typesetting program \ProgName{troff}.

Converting \acro{DVI} to plain text is the basis of many of these
techniques; sometimes the simple conversion provides a good enough
response.  Options are:
\begin{itemize}
\item \ProgName{dvi2tty} (one of the earliest),
\item \ProgName{crudetype} and
\item \ProgName{catdvi}, which is capable of generating Latin-1
  (ISO~8859-1) or \acro{UTF}-8 encoded output.  \ProgName{Catdvi} was
  conceived as a replacement for \ProgName{dvi2tty}, but can't (quite)
  be recommended as a complete replacement yet.
\end{itemize}
A common problem is the hyphenation that \TeX{} inserts when
typesetting something: since the output is inevitably viewed using
fonts that don't match the original, the hyphenation usually looks
silly.

Ralph Droms provides a \Package{txt} bundle of things in support of
\acro{ASCII} generation,
but it doesn't do a good job with tables and mathematics.  An
alternative is the \Package{screen} package.

Another possibility is to
use the \LaTeX{}-to-\acro{ASCII} conversion program, \ProgName{l2a},
although this is really more of a de-\TeX{}ing program.

The canonical de-\TeX{}ing program is \ProgName{detex}, which removes
all comments and control sequences 
from its input before writing it to its output.  Its original purpose
was to prepare input for a dumb spelling checker, and it's only usable
for preparing useful \acro{ASCII} versions of a document in highly
restricted circumstances.

\ProgName{Tex2mail} is slightly more than a de-TeX{}er~--- it's a
\ProgName{Perl} script that converts \TeX{} files into
plain text files, expanding various mathematical symbols
(sums, products, integrals, sub/superscripts, fractions, square
roots, \dots{}\@) into ``\acro{ASCII} art'' that spreads over
multiple lines if necessary. The result is more readable to human
beings than the flat-style \TeX{} code.

Another significant possibility is to use one of the
\Qref*{\acro{HTML}-generation solutions}{Q-LaTeX2HTML},
and then to use a browser such as \ProgName{lynx} to dump the resulting
\acro{HTML} as plain text.
\begin{ctanrefs}
\item[catdvi]\CTANref{catdvi}
\item[crudetype]\CTANref{crudetype}
\item[detex]\CTANref{detex}
\item[dvi2tty]\CTANref{dvi2tty}
\item[l2a]\CTANref{l2a}
\item[screen.sty]\CTANref{screensty}
\item[tex2mail]\CTANref{tex2mail}
\item[txt]\CTANref{txtdist}
\end{ctanrefs}

\Question[Q-SGML2TeX]{Conversion from \acro{SGML} or \acro{HTML} to \protect\TeX{}}

\acro{SGML} is a very important system for document storage and interchange,
but it has no formatting features; its companion \acro{ISO} standard
\acro{DSSSL}
(see \URL{http://www.jclark.com/dsssl/}) is designed for writing
transformations and formatting,
but this has not yet been widely implemented. Some \acro{SGML} authoring
systems (e.g., SoftQuad \ProgName{Author/Editor}) have formatting
abilities, and
there are high-end specialist \acro{SGML} typesetting systems (e.g., Miles33's
\ProgName{Genera}).  However, the majority of \acro{SGML} users probably transform
the source to an existing typesetting system when they want to print. 
\TeX{} is a good candidate for this. There are three approaches to writing a
translator:
\begin{enumerate}
\item Write a free-standing translator in the traditional way, with
  tools like \ProgName{yacc} and \ProgName{lex}; this is hard, in
  practice, because of the complexity of \acro{SGML}.
\item Use a specialist language designed for \acro{SGML} transformations; the
  best known are probably \ProgName{Omnimark} and \ProgName{Balise}.
  They are expensive, but powerful, incorporating \acro{SGML} query and
  transformation abilities as well as simple translation.
\item Build a translator on top of an existing \acro{SGML} parser.  By far
  the best-known (and free!) parser is James Clark's
  \ProgName{nsgmls}, and this produces a much simpler output format,
  called \acro{ESIS}, which can be parsed quite straightforwardly (one also
  has the benefit of an \acro{SGML} parse against the \acro{DTD}). Two
  good public domain packages use this method:
  \begin{itemize}
  \item
\begin{narrowversion} % really non-hyper
      David Megginson's \ProgName{sgmlspm}, written in \ProgName{Perl}
      5, which is available from 
      \URL{http://www.perl.com/CPAN/modules/by-module/SGMLS}
\end{narrowversion}
\begin{wideversion}
      David Megginson's
      \href{http://www.perl.com/CPAN/modules/by-module/SGMLS}{\ProgName{sgmlspm}},
      written in \ProgName{Perl} 5.
\end{wideversion}
    \item
\begin{narrowversion} % really non-hyper
      Joachim Schrod and Christine Detig's \ProgName{STIL}
      (`\acro{SGML} Transformations in Lisp'), which is available from
      \URL{ftp://ftp.tu-darmstadt.de/pub/text/sgml/stil}
\end{narrowversion}
\begin{wideversion}
      Joachim Schrod and Christine Detig's
      \href{ftp://ftp.tu-darmstadt.de/pub/text/sgml/stil}{\ProgName{STIL}},
       (`\acro{SGML} Transformations in Lisp').
\end{wideversion}
  \end{itemize}
  Both of these allow the user to write `handlers' for every \acro{SGML}
  element, with plenty of access to attributes, entities, and
  information about the context within the document tree.

  If these packages don't meet your needs for an average \acro{SGML}
  typesetting job, you need the big commercial stuff.
\end{enumerate}

Since \acro{HTML} is simply an example of \acro{SGML}, we do not need a specific
system for \acro{HTML}.  However, Nathan Torkington developed
% (\Email{Nathan.Torkington@vuw.ac.nz}) 
\ProgName{html2latex} from the \acro{HTML} parser in \acro{NCSA}'s
Xmosaic package.
The program takes an \acro{HTML} file and generates a \LaTeX{} file from it.
The conversion code is subject to \acro{NCSA} restrictions, but the whole
source is available on \acro{CTAN}.

Michel Goossens and Janne Saarela published a very useful summary of
\acro{SGML}, and of public domain tools for writing and manipulating it, in
\TUGboat{} 16(2).
\begin{ctanrefs}
\item[html2latex \nothtml{\rmfamily}source]\CTANref{html2latex}
\end{ctanrefs}

\Question[Q-LaTeX2HTML]{Conversion from \AllTeX{} to \acro{HTML}}

\TeX{} and \LaTeX{} are well suited to producing electronically publishable
documents. However, it is important to realize the difference
between page layout and functional markup. \TeX{} is capable of
extremely detailed page layout; \acro{HTML} is not, because \acro{HTML} is a
functional markup language not a page layout language. \acro{HTML}'s exact
rendering is not specified by the document that is published but is, to
some degree, left to the discretion of the browser. If you require your
readers to see an exact replication of what your document looks like
to you, then you cannot use \acro{HTML} and you must use some other
publishing format such as \acro{PDF}. That is true for any \acro{HTML}
authoring tool.

\TeX{}'s excellent mathematical capabilities remain a challenge in the
business of conversion to \acro{HTML}.  There are only two generally
reliable techniques for generating mathematics on the web: creating
bitmaps of bits of typesetting that can't be translated, and using
symbols and table constructs.  Neither technique is entirely
satisfactory.  Bitmaps lead to a profusion of tiny files, are slow to
load, and are inaccessible to those with visual disabilities.  The
symbol fonts offer poor coverage of mathematics, and their use
requires configuration of the browser.  The future of mathematical
browsing may be brighter~--- see
% beware line break
\Qref[question]{future Web technologies}{Q-mathml}.

For today, possible packages are:
\begin{description}
\item[\ProgName{LaTeX2HTML}]a \ProgName{Perl} script package that
  supports \LaTeX{} only, and generates mathematics (and other
  ``difficult'' things) using bitmaps.  The original version was
  written by Nikos Drakos for Unix systems, but the package now sports
  an illustrious list of co-authors and is also available for Windows
  systems.  Michel Goossens and Janne Saarela published a detailed
  discussion of \ProgName{LaTeX2HTML}, and how to tailor it, in
  \TUGboat{} 16(2).

  A mailing list for users may be found via
  \URL{http://tug.org/mailman/listinfo/latex2html}
\item[\ProgName{TtH}]a compiled program that supports either \LaTeX{}
  or \plaintex{}, and uses the font/table technique for representing
  mathematics.  It is written by Ian Hutchinson, using
  \ProgName{flex}.  The distribution consists of a single \acro{C}
  source (or a compiled executable), which is easy to install and very
  fast-running.
\item[\ProgName{Tex4ht}]a compiled program that supports either
  \LaTeX{} or \plaintex{}, by processing a \acro{DVI} file; it uses
  bitmaps for mathematics, but can also use other technologies where
  appropriate.  Written by Eitan Gurari, it parses the \acro{DVI}
  file generated when you run \AllTeX{} over your file with
  \ProgName{tex4ht}'s macros included.  As a result, it's pretty
  robust against the macros you include in your document, and it's
  also pretty fast.
\item[\ProgName{TeXpider}] a commercial program from
  \Qref*{Micropress}{Q-commercial}, which is
  described on \URL{http://www.micropress-inc.com/webb/wbstart.htm};
  it uses bitmaps for equations.
\item[\ProgName{Hevea}] a compiled program that supports \LaTeX{}
  only, and uses the font/table technique for equations (indeed its
  entire approach is very similar to \ProgName{TtH}).  It is written
  in Objective \acro{CAML} by Luc Maranget.  \ProgName{Hevea} isn't
  archived on \acro{CTAN}; details (including download points) are
  available via \URL{http://pauillac.inria.fr/~maranget/hevea/}
\end{description}
An interesting set of samples, including conversion of the same text
by the four free programs listed above, is available at
\URL{http://www.mayer.dial.pipex.com/samples/example.htm}; a linked
page gives lists of pros and cons, by way of comparison.

The World Wide Web Consortium maintains a list of ``filters'' to
\acro{HTML}, with sections on \AllTeX{} and \BibTeX{}~--- see
\URL{http://www.w3.org/Tools/Word_proc_filters.html}
\begin{ctanrefs}
\item[latex2html]Browse \CTANref{latex2html}
\item[tex4ht]\CTANref{tex4ht}
\item[tth]\CTANref{tth}
\end{ctanrefs}

\Question[Q-fmtconv]{Other conversions to and from \AllTeX{}}

\begin{description}
\item[troff]\ProgName{Tr2latex}, assists in the translation of a
  \ProgName{troff} document into \LaTeXo{} format.  It recognises most
  |-ms| and |-man| macros, plus most \ProgName{eqn} and some
  \ProgName{tbl} preprocessor commands.  Anything fancier needs to be
  done by hand. Two style files are provided. There is also a man page
  (which converts very well to \LaTeX{}\dots{}).
  \ProgName{Tr2latex} is an enhanced version of the earlier
  \ProgName{troff-to-latex} (which is no longer available).

% The \acro{DECUS} \TeX{} distribution (see
% \Qref[question]{sources of software}{Q-archives})
% also contains a program which converts \ProgName{troff} to \TeX{}.

%\item[Scribe] Mark James (\Email{jamesm@dialogic.com}) has a copy of
%  \ProgName{scribe2latex} he has been unable to test but which he will
%  let anyone interested have. The program was written by Van Jacobson
%  of Lawrence Berkeley Laboratory.%
%  \checked{RF}{1994/11/18}
  
\item[WordPerfect] \ProgName{wp2latex} is actively maintained, and is
  available either for \MSDOS{} or for Unix systems.
\item[\acro{RTF}] \ProgName{Rtf2tex}, by Robert Lupton, is for
  converting Microsoft's Rich Text Format to \TeX{}.  There is also a
  converter to \LaTeX{} by Erwin Wechtl, called \ProgName{rtf2latex}.
  The latest converter, by Ujwal Sathyam and Scott Prahl, is
  \ProgName{rtf2latex2e}; this system seems rather good already, and
  is still being improved.

  Translation \emph{to} \acro{RTF} may be done (for a somewhat
  constrained set of \LaTeX{} documents) by \TeX{}2\acro{RTF}, which
  can produce ordinary \acro{RTF}, Windows Help \acro{RTF} (as well as
  \acro{HTML}, \Qref{conversion to HTML}{Q-LaTeX2HTML}).
  \TeX{}2\acro{RTF} is supported on various Unix platforms and under
  Windows~3.1
\item[Microsoft Word] A rudimentary (free) program for converting
  MS-Word to \LaTeX{} is \ProgName{wd2latex}, which runs on \MSDOS{}.
  \ProgName{Word2}\emph{\TeX{}} and \emph{\TeX{}}\ProgName{2Word} are 
  shareware translators from % beware line break
  \href{http://www.chikrii.com/}{Chikrii Softlab}; users' reports are
  very positive.

  The excellent \ProgName{tex4ht} will generate OpenOffice \acro{ODT}
  format, which can be used as an intermediate to producing Word
  format files.

  If cost is a constraint, the best bet is probably to use an
  intermediate format such as \acro{RTF} or \acro{HTML}.
  \ProgName{Word} outputs and reads both, so in principle this route
  may be useful.

  You can also use \acro{PDF} as an intermediate format: Acrobat Reader
  for Windows (version 5.0 and later) will output rather feeble
  \acro{RTF} that \ProgName{Word} can read.
\item[Excel] \ProgName{Excel2Latex} converts an \ProgName{Excel} file
  into a \LaTeX{} \environment{tabular} environment; it comes as a
  \extension{xls} file which defines some \ProgName{Excel} macros to produce
  output in a new format.
\item[runoff] Peter Vanroose's \ProgName{rnototex}
  conversion program is written in \acro{VMS} Pascal.
  The sources are distributed with a \acro{VAX} executable.
\item[refer/tib] There are a few programs for converting bibliographic
  data between \BibTeX{} and \ProgName{refer}/\ProgName{tib} formats.
  The collection includes a shell script converter from \BibTeX{} to
  \ProgName{refer} format as well. The collection
  is not maintained.
\item[\acro{PC}-Write]\ProgName{pcwritex.arc} is a
  print driver for \acro{PC}-Write that ``prints'' a \acro{PC}-Write
  V2.71 document to a \TeX{}-compatible disk file.  It was written by Peter
  Flynn at University College, Cork, Republic of Ireland.
\end{description}

% beware line breaks
\href{http://www.tug.org/utilities/texconv/index.html}{Wilfried Hennings' \acro{FAQ}},
which deals specifically with conversions between \TeX{}-based formats
and word processor formats, offers much detail as well as tables that
allow quick comparison of features.

A group at Ohio State University (\acro{USA}) is working on
a common document format based on \acro{SGML}, with the ambition that any
format could be
translated to or from this one.  \ProgName{FrameMaker} provides
``import filters'' to aid translation from alien formats
(presumably including \TeX{}) to \ProgName{FrameMaker}'s own.
\begin{ctanrefs}
\item[excel2latex]\CTANref{excel2latex}
\item[pcwritex.arc]\CTANref{pcwritex}
\item[refer and tib tools]\CTANref{refer-tools}
\item[rnototex]\CTANref{rnototex}
\item[rtf2latex]\CTANref{rtf2latex}
\item[rtf2latex2e]\CTANref{rtf2latex2e}
\item[rtf2tex]\CTANref{rtf2tex}
\item[tex2rtf]\CTANref{tex2rtf}
\item[tr2latex]\CTANref{tr2latex}
\item[wd2latex]\CTANref{wd2latex}
\item[wp2latex]\CTANref{wp2latex}
\item[\nothtml{\rmfamily}Word processor \acro{FAQ} (source)]%
  \CTANref{texcnvfaq}
\end{ctanrefs}

\Question[Q-readML]{Using \TeX{} to read \acro{SGML} or \acro{XML} directly}

This can nowadays be done, with a certain amount of clever macro
programming.  David Carlisle's \Package{xmltex} is the prime example;
it offers a practical solution to typesetting
\acro{XML} files.

One use of a \TeX{} that can typeset \acro{XML} files is as a backend
processor for \acro{XSL} formatting objects, serialized as \acro{XML}.
Sebastian Rahtz's Passive\TeX{} uses \Package{xmltex} to
achieve this end.
\begin{ctanrefs}
\item[xmltex]\CTANref{xmltex}
\item[passivetex]\CTANref{passivetex}
\end{ctanrefs}

\Question[Q-recovertex]{Retrieving \AllTeX{} from \acro{DVI}, etc.}

The job just can't be done automatically: \acro{DVI}, \PS{} and
\acro{PDF} are ``final'' formats, supposedly not susceptible to
further editing~--- information about where things came from has been
discarded.  So if you've lost your \AllTeX{} source (or never
had the source of a document you need to work on) you've a serious job
on your hands.  In many circumstances, the best strategy is to retype
the whole document, but this strategy is to be tempered by
consideration of the size of the document and the potential typists'
skills.

If automatic assistance is necessary, it's unlikely that any more than
text retrieval is going to be possible; the \AllTeX{} markup that
creates the typographic effects of the document needs to be recreated
by editing.

If the file you have is in \acro{DVI} format, many of the techniques
for \Qref*{converting \AllTeX{} to \acro{ASCII}}{Q-toascii} are
applicable.  Consider \ProgName{dvi2tty}, \ProgName{crudetype} and
\ProgName{catdvi}.  Remember that there are likely to be problems
finding included material (such as included \PS{} figures, that
don't appear in the \acro{DVI} file itself), and mathematics is
unlikely to convert easily.

To retrieve text from \PS{} files, the
\ProgName{ps2ascii} tool (part of the  \ProgName{ghostscript}
distribution) is available.  One could try applying this tool to
\PS{} derived from an \acro{PDF} file using \ProgName{pdf2ps} (also
from the \ProgName{ghostscript} distribution), or \ProgName{Acrobat}
\ProgName{Reader} itself; an alternative is \ProgName{pdftotext},
which is distributed with \ProgName{xpdf}.

Another avenue available to those with a \acro{PDF} file they want to
process is offered by Adobe \ProgName{Acrobat} (version 5 or later):
you can tag the \acro{PDF} file into an estructured document, output
thence to well-formed \acro{XHTML}, and import the results into
Microsoft \ProgName{Word} (2000 or later).  From there, one may
convert to \AllTeX{} using one of the techniques discussed in
% beware line break
\htmlonly{``}\Qref[question]{converting to and from \AllTeX{}}{Q-fmtconv}\htmlonly{''}.

The result will typically (at best) be poorly marked-up.  Problems may
also arise from the oddity of typical \TeX{} font encodings (notably
those of the maths fonts), which \ProgName{Acrobat} doesn't know how
to map to its standard Unicode representation.
\begin{ctanrefs}
\item[catdvi]\CTANref{catdvi}
\item[crudetype]\CTANref{crudetype}
\item[dvi2tty]\CTANref{dvi2tty}
\item[ghostscript]Browse \CTANref{ghostscript}
\item[xpdf]Browse \CTANref{xpdf}
\end{ctanrefs}

\Question[Q-LaTeXtoPlain]{Translating \LaTeX{} to \plaintex{}}

Unfortunately, no ``general'', simple, automatic process is likely to
succeed at this task.  See % ! line break
``\Qref*{How does \LaTeX{} relate to \plaintex{}}{Q-LaTeXandPlain}''
for further details.

Translating a document designed to work with \LaTeX{} into one
designed to work with \plaintex{} is likely to amount to carefully
including (or otherwise re-implementing) all those parts of \LaTeX{},
beyond the provisions of \plaintex{}, which the document uses.

Some of this work is has (in a sense) been done, in the port of the
\LaTeX{} graphics package to \plaintex{}.  However, while
\Package{graphics} is available, other complicated packages (notably
\Package{hyperref}) are not.  The aspiring translator may find the
\Qref*{\Eplain{}}{Q-eplain} system a useful source of code.  (In fact,
a light-weight system such as \Eplain{} might reasonably be adopted as
an alternative target of translation, though it undoubtedly gives the
user more than the ``bare minimum'' that \plaintex{} is designed to
offer.)
\begin{ctanrefs}
\item[\latexhtml{\textrm{The}}{The} eplain \nothtml{\rmfamily}system]%
  \CTANref{eplain}
\item[\latexhtml{\textrm{`\plaintex{}'}}{\plaintex{}} graphics]%
  \CTANref{graphics-plain}
\end{ctanrefs}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\section{Installing \AllTeX{} files}

\Question[Q-installthings]{Installing things on a \AllTeX{} system}
\AliasQuestion{Q-instpackages}

Installing (or replacing) things on your \AllTeX{} system has the
potential to be rather complicated; the following questions attempt to
provide a step-by-step approach, starting from the point where you've
decided what it is that you want to install:
\begin{itemize}
\item You must \Qref*{find the file you need}{Q-install-find};
\item If you are going to install a \LaTeX{} package, you may need to
  \Qref*{unpack the distributed files}{Q-install-unpack};
\item It may be necessary to % ! line break
  \Qref*{generate some documentation to read}{Q-install-doc};
\item You need to % ! line break
  \Qref*{decide where to install the files}{Q-install-where};
\item You must now \Qref*{install the files}{Q-inst-wlcf}; and
  finally
\item You may need to \Qref*{tidy up}{Q-inst-tidy} after the installation.
\end{itemize}

\Question[Q-install-find]{Finding packages to install}

How did you learn about the package?

If the information came from these \acro{FAQ}s, you should already
have a link to the file (there are lists at the end of each answer):
\begin{narrowversion}
  copy that link into a browser,
\end{narrowversion}
\begin{wideversion}
  click on that link,
\end{wideversion}
and you can get the file, one way or another.

If you heard about the file somewhere else, it's possible that the
source told you where to look; if not, try the \acro{CTAN} searching
facilities, such as \URL{http://www.tex.ac.uk/search/}.  That (rather
simple) search engine can return data from a search of the CTAN
catalogue (which covers most useful packages), or data from a search
of the names of files on the archive.

Packages come in a variety of different styles of distribution; the
very simplest will actually offer just \File{package.sty}~--- in this
case, just download the file and % ! line break
\Qref*{get on with installation}{Q-inst-wlcf}.

Normally, though, you will want \File{foo.sty} but that file is distributed
in a \LaTeX{} documented source file \File{foo.dtx}; thus you should
search just for \emph{foo}~--- \File{foo.sty} won't be visible
anywhere on the archive or in the catalogue.

Since most packages are distributed in this
\extension{dtx}/\extension{ins} way, they usually occupy their own
directory on the archive.  Even if that directory contains other
packages, you should download everything in the directory: as often as
not, packages grouped in this way depend on each other, so that you
really \emph{need} the other ones.

Having acquired the package distribution, % ! line break
``\Qref*{unpacking \LaTeX{} packages}{Q-install-unpack}'' outlines
your next step.

\Question[Q-install-unpack]{Unpacking \LaTeX{} packages}

As discussed \Qref*{elsewhere}{Q-dtx}, the `ordinary' way to
distribute a \LaTeX{} package is as a pair of files \File{package.dtx}
and \File{package.ins}.  If you've acquired such a pair, you simply
process \File{package.ins} with \LaTeX{}, and the files will appear,
ready for installation.

Other sorts of provision should ordinarily be accompanied by a
\File{README} file, telling you what to do; we list a few example
configurations.

Sometimes, a directory comes with a bunch of \extension{dtx} files, but
fewer (often only one) \extension{ins} files (\LaTeX{} itself comes
looking like this).  If there is more than one \extension{ins} file,
and in the absence of any instruction in the \File{README} file, simply
process the \extension{ins} file(s) one by one.

If you're missing the \File{package.ins} altogether, you need to play
around until something works.  Some \extension{dtx} files are
``self-extracting''~--- they do without an \extension{ins} file, and once
you've processed the \File{package.dtx}, \File{package.sty} has
automagically appeared.  Various other oddities may appear, but the
archivists aim to have \File{README} file in every package, which
should document anything out of the ordinary with the distribution.

\Question[Q-install-doc]{Generating package documentation}

We are faced with a range of ``normal'' provision, as well as several
oddities.  One should note that documentation of many packages is
available on \acro{CTAN}, without the need of any further effort by
the user~--- such documentation can usually be browsed \emph{in situ}.

However, if you find a package that does not offer documentation on
the archive, or if you need the documentation in some other format
than the archive offers, you can usually generate the documentation
yourself from what you download from the archive.

The standard mechanism, for \LaTeX{} packages, is simply to run
\LaTeX{} on the \File{package.dtx} file, as you would any ordinary
\LaTeX{} file (i.e., repeatedly until the warnings go away).

A variant is that the unpacking process provides a file
\File{package.drv}; if such a thing appears, process it in preference
to the \File{package.dtx} (it seems that when the documented \LaTeX{}
source mechanism was first discussed, the \File{.drv} mechanism was
suggested, but it's not widely used nowadays).

Sometimes, the \LaTeX{} run will complain that it can't find
\File{package.ind} (the code line index) and/or \File{package.gls}
(the list of change records, not as you might imagine, a glossary).
Both types of file are processed with special \ProgName{makeindex}
style files; appropriate commands are:
\begin{quote}
\begin{verbatim}
makeindex -s gind package
makeindex -s gglo -o package.gls package.glo
\end{verbatim}
\end{quote}
This author finds that the second (the change record) is generally of
limited utility when reading package documentation; it is, however,
valuable if you're part of the package development team.  If you don't
feel you need it, just leave out that step

Another common (and reasonable) trick performed by package authors is
to provide a separate file \File{package-doc.tex} or even simply
\File{manual.tex}; if the file \File{package.dtx} doesn't help, simply
look around for such alternatives.  The files are treated in the same
way as any ``ordinary'' \LaTeX{} file.

\Question[Q-inst-wlcf]{Installing files ``where \AllTeX{} can find them''}
\AliasQuestion{Q-wherefiles}

In the past, package documentation used always to tell you to put your
files ``where \LaTeX{} can find them''; this was always unhelpful~---
if you knew where that \emph{was}, you didn't need telling, but if you
\emph{didn't} know, you were completely stuck.

It was from this issue that the whole idea of the \acro{TDS} sprang;
``where to put'' questions now come down to ``where's the \acro{TDS}
tree?''.

We therefore answer the question by considering:
\begin{itemize}
\item \Qref*{what tree to use}{Q-what-TDS}, and
\item \Qref*{where in the tree to put the files}{Q-install-where}.
\end{itemize}

Once we know the answer to both questions, and we've created any
directories that are needed, we simply copy files to their rightful
location.

This has done what the old requirement specified: \LaTeX{} (or
whatever) \emph{can} (in principle) find the files.  However, in order
that the software \emph{will} find the files, we need to update an
index file.

On a \miktex{} system, open the window
  \texttt{Start}\arrowhyph{}%
  \texttt{All Programs}\arrowhyph{}%
  \texttt{\miktex{} \meta{version}}\arrowhyph{}%
  \texttt{Settings},
and click on \texttt{Refresh FNDB}.
The job may also be done in a command window, using the command:
\begin{quote}
\begin{verbatim}
initexmf --update-fndb
\end{verbatim}
\end{quote}
The % ! line break
\href{http://docs.miktex.org/manual/initexmf.html}{\miktex{} documentation}
gives further details about \texttt{initexmf}.

On a te\TeX{} or \texlive{}-based system, use the command
\texttt{texhash} (or if that's not available, \texttt{mktexlsr}~---
they ought to be different names for the same program).

Having done all this, the new package will be available for use.

\Question[Q-what-TDS]{Which tree to use}

In almost all cases, new material that you install should go into the
``local'' tree of your \AllTeX{} installation.  (A discussion of
reasons \emph{not} to use the local tree appears below.)

On a Unix(-alike) system, using te\TeX{} or \texlive{}, the root
directory will be named something like \path{/usr/share/texmf-local/}
or \path{/usr/local/share/texmf/}
You can ask such a system where it believes a local tree should be:
\begin{quote}
\begin{verbatim}
kpsewhich -expand-var "\$TEXMFLOCAL"
\end{verbatim}
\end{quote}
the output being the actual path, for example (on the workstation the
author is using today):
\begin{quote}
\begin{verbatim}
/usr/local/share/texmf
\end{verbatim}
\end{quote}

In a \miktex{} installation, the location will in fact typically be
something you specified yourself when you installed \miktex{} in the
first place, but you may find you need to create one.  The \miktex{}
``Settings'' window (%
  \texttt{Start}\arrowhyph{}%
  \texttt{Programs}\arrowhyph{}%
  \texttt{\miktex{}}\arrowhyph{}%
  \texttt{Settings})
has a tab ``\texttt{Roots}''; that tab gives a list of current
\acro{TDS} roots (they're typically not called
\texttt{texmf}-anything).  If there's not one there with
``\texttt{local}'' in its name, create an appropriate one (see below),
and register it using the window's
``\texttt{Add}'' button.

The % ! line break
\href{http://docs.miktex.org/faq/maintenance.html}{\miktex{} \acro{FAQ}}
suggests that you should create % ! line break
``\texttt{C:\textbackslash Local TeX Files}'', which is good if you
manage your own machine, but often not even possible in corporate, or
similar, environments~­-- in such situations, the user may have no
control over the hard disc of the computer, at all.

So the real criterion is that your local tree should be somewhere that
\emph{you}, rather than the system, control.  Restrictive systems often
provide a ``home directory'' for each user, mounted as a network
drive; this is a natural home for the user's local tree.  Other (often
academic) environments assume the user is going to provide a memory
stick, and will assign it a defined drive letter~­-- another good
candidate location.  Note that the semantics of such a tree are
indistinguishable from those of a % ! line break
\Qref*{``home'' \acro{TEXMF} tree}{Q-privinst}.

There are circumstances when you might not wish to use the `local' tree:
\begin{itemize}
\item if the package, or whatever, is ``personal'' (for example,
  something commercial that has been licensed to you alone, or
  something you're developing yourself), the package should go in your
  \Qref*{``home'' \acro{TEXMF} tree}{Q-privinst};
\item if you \emph{know} that the package you are installing is a
  replacement for the copy on the \acro{TEXMF} tree of your \AllTeX{}
  distribution, you should replace the existing copy in the
  \acro{TEXMF} tree.
\end{itemize}
The reason one would put things on a local tree is to avoid their
disappearance if the system is upgraded (or otherwise re-installed).

The reason one might place upgrades the distribution's main tree is to
avoid confusion.  Suppose you were to place the file on the local
tree, and then install a new version of the distribution~--- you might
have an effect like:
\begin{itemize}
\item distribution comes with package version \ensuremath{n};
\item you install package version \ensuremath{n+1} on the local tree; and
\item the updated distribution comes with package version \ensuremath{n+2}.
\end{itemize}
In such a situation, you will find yourself using version
\ensuremath{n+1} (from the local tree) \emph{after} the new
distribution has been installed.

If you install in the local tree, the only way to avoid such problems
is to carefully purge the local tree when installing a new
distribution.  This is tedious, if you're maintaining a large
installation.

\Question[Q-install-where]{Where to install packages}

We assume here that you have decided what tree to put your files in,
after reading % ! line break
``\Qref*{choosing a \acro{TDS} tree}{Q-what-TDS}''.  We will therefore
write \texttt{\$TEXMF} for it, and you need to substitute the tree
you decided on.

The basic idea is to imitate the directory structure in your
existing tree(s). Here are some examples of where various sorts of
files should go:
\begin{quote}
\begin{verbatim}
.sty, .cls or .fd: $TEXMF/tex/<format>/<package>/
.mf:   $TEXMF/fonts/source/<supplier>/<font>/
.tfm:  $TEXMF/fonts/tfm/<supplier>/<font>/
.vf:   $TEXMF/fonts/vf/<supplier>/<font>/
.afm:  $TEXMF/fonts/afm/<supplier>/<font>/
.pfb:  $TEXMF/fonts/type1/<supplier>/<font>/
.ttf:  $TEXMF/fonts/truetype/<supplier>/<font>/
.otf:  $TEXMF/fonts/opentype/<supplier>/<font>/
.pool, .fmt, .base or .mem: $TEXMF/web2c
\end{verbatim}
\end{quote}
and for modern systems (those distributed in 2005 or later, using \acro{TDS}
v1.1 layouts):
\begin{quote}
\begin{verbatim}
.map:  $TEXMF/fonts/map/<syntax>/<bundle>/
.enc:  $TEXMF/fonts/enc/<syntax>/<bundle>/
\end{verbatim}
\end{quote}
(Map and encoding files went to directories under
\File{$TEXMF/dvips/}, in earlier distributions.)

In the lists above \meta{format} identifies the format the macros
are designed for~--- it can be things such as \texttt{plain},
\texttt{generic} (i.e., any format), \texttt{latex} or
\texttt{context} (or several less common formats).

For fonts, \meta{font} refers to the font family (such as \texttt{cm}
for Knuth's Computer Modern, \texttt{times} for Adobe's Times Roman).
The supplier is usually obvious~--- the supplier
``public'' is commonly used for free fonts.

The \meta{syntax} (for \extension{map} and \extension{enc} files) is a
categorisation based on the way the files are written; candidates are
names of programs such as \ProgName{dvips} or \ProgName{pdftex}.

``Straight'' \AllTeX{} input can take other forms than the
\extension{sty}, \extension{cls} or \extension{fd} listed above, too
(apart from the `obvious' \extension{tex}).  Examples are (the
obvious) \extension{tex}, \extension{lfd} for \Package{babel} language
definitions, \extension{sto} and \extension{clo} for package and class
options, \extension{cfg} for configuration information,
\extension{def} for variants (such as the types of devices
\Package{graphics} drives).  The \File{README} of the package should
tell you of any others, though sometimes that information is printed
when the package's \Qref*{comments are stripped}{Q-install-unpack}.
All of these files should live together with the main package files.

Note that \meta{font} may stand for a single font or an entire family:
for example, files for all of Knuth's Computer Modern fonts are to be
found in \texttt{.../public/cm}, with various prefixes as appropriate.

The font ``supplier'' \emph{public} is a sort of hold-all for
``free fonts produced for use with \AllTeX{}'': as well as Knuth's
fonts, \emph{public}'s directory holds fonts designed by others
(originally, but no longer exclusively, in \MF{}).

Documentation for each package should all go, undifferentiated, into a
directory on the \path{doc/} subtree of the \acro{TDS}.  The layout of
the subtree is slightly different: \path{doc/latex} hosts all
\LaTeX{} documentation directories, but more fundamental things are
covered, e.g., by \path{doc/etex} or \path{doc/xetex}.

\Question[Q-inst-tidy]{Tidying up after installation}

There's not usually a lot to do after you've completed the steps
above~--- indeed, if you're merely installed files direct from the
archive, or whatever, there will be precisely nothing left, by way of
debris.

Things you might care to clean up are:
\begin{itemize}
\item the archive file, if you retrieved your data from the archive
  as a \extension{zip} file, or the like;
\item the \extension{dtx} and \extension{ins} files, if you chose not
  to install them with the documentation; and
\item the \extension{aux}, \extension{log}, \extension{idx}, etc.,
  from building the documentation.
\end{itemize}
A simple way of achieving all this is to download to a working
directory that was created for the purpose, and then to delete that
directory and all its contents after you've finished installing.

\Question[Q-inst-scut]{Shortcuts to installing files}
\AliasQuestion{Q-inst-miktex}

There are circumstances in which most of the fuss of installation can
be bypassed:
\begin{itemize}
\item If you are a \miktex{} user, the 
\begin{wideversion}
  \Qref{\miktex{} package management system}{Q-inst-miktex*}
  can usually help;
\end{wideversion}
\begin{narrowversion}
  \miktex{} package management system can usually help
  (\Qref{}{Q-inst-miktex*});
\end{narrowversion}
\item The package you want may already exist as a \acro{ZIP} file
\begin{wideversion}
  formatted for \Qref{direct installation}{Q-inst-tds-zip}.
\end{wideversion}
\begin{narrowversion}
  formatted for direct installation (\Qref{}{Q-inst-tds-zip}).
\end{narrowversion}
\end{itemize}

\Question[Q-inst-miktex*]{Installation using \miktex{} package manager}

Packages for use with \miktex{} are maintained very efficiently by the
project managers (new packages and updates on \acro{CTAN} ordinarily
make their way to the \miktex{} package repository within a week).
Thus it makes sense for the \miktex{} user to take advantage of the
system rather than grinding through the steps of installation.

\miktex{} maintains a database of packages it ``knows about'',
together with (coded) installation instructions that enable it to
install the packages with minimal user intervention; you can update
the database over the internet.

If \miktex{} does know about a package you need installed, it's worth
using the system:
first, open the \miktex{} packages window: click on
  \texttt{Start}\arrowhyph{}%
  \texttt{Programs}\arrowhyph{}%
  \texttt{MiKTeX}\arrowhyph{}%
  \texttt{MiKTeX Options}, and select the
  \texttt{Packages} tab.
  
On the tab, there is an Explorer-style display of packages.
Right-click on the root of the tree, ``\texttt{MiKTeX Packages}'',
and select ``\texttt{Search}'': enter the name of the package you're
interested in, and press the ``\texttt{Search}'' button.  If
\miktex{} knows about your package, it will open up the tree to show
you a tick box for your package: check that box.

If you prefer a command-line utility, there's \ProgName{mpm}.  Open a
command shell, and type:
\begin{quote}
\begin{verbatim}
mpm --install=<package>
\end{verbatim}
\end{quote}
(which of course assumes you know the name by which \miktex{} refers to
your package).

\Question[Q-inst-tds-zip]{Installing using preformatted \acro{ZIP} files}

Installing packages, as they (``traditionally'') appear on
\acro{CTAN}, involves:
\begin{itemize}
\item identifying where to put the various files on an \acro{TDS}
  tree,
\item installing them, and
\item a few housekeeping operations.
\end{itemize}
Most people, for most packages, find the first two steps onerous, the
last being easy (unless it is forgotten!).

Preformatted \acro{ZIP} files (also known as % ! line break
\Qref{\acro{TDS} \acro{ZIP} files}{Q-tds-zip}) are designed to lighten
the load of performing the first two steps of installation: they
contain all the files that are that's to be installed for a given
package, in their ``correct'' locations in a % ! line break
\Qref*{\acro{TDS} tree}{Q-tds}.

To install such a file on a Unix system (we assume that you'll install
into the local \acro{TEXMF} tree):
\begin{quote}
\begin{verbatim}
cd $TEXMFLOCAL
unzip $package.tds.zip
\end{verbatim}
\end{quote}

On a Windows system that is modern enough that it has a built-in
\acro{ZIP} unpacker, simply double-click on the file, and browse to
where it's to be unpacked.  (We trust that those using earlier
versions of Windows will already have experience of using
\ProgName{WinZIP} or the like.)

Having unpacked the \extension{zip} archive, in most cases the only
remaining chore is to update the file indexes~--- as in % ! line break
\Qref*{normal installation instructions}{Q-inst-wlcf}.  However, if
the package provides a font, you also need to enable the font's map,
which is discussed in % ! line break
``\Qref*{Installing a Type~1 font}{Q-instt1font}''

At the time of writing, there are rather few \extension{tds.zip}
files (by comparison with the huge number of packages that are
available).  As packages are updated, the number of files is
steadily increasing, but it will be a long time before the whole set
is covered.

\Question[Q-tempinst]{``Temporary'' installation of \AllTeX{} files}

Operating systems and applications need to know where to find files:
many files that they need are ``just named''~--- the user doesn't
necessarily know \emph{where} they are, but knows to ask for them.
The commonest case, of course, is the commands whose names you type to
a shell (yes, even Windows' ``\MSDOS{} prompt'') are using a shell to read what
you type: many of the commands simply involve loading and executing a
file, and the \texttt{PATH} variable tells the shell where to find those files.

Modern \TeX{} implementations come with a bunch of search paths
built in to them.  In most circumstances these paths are adequate, but
one sometimes needs to extend them to pick up files in strange
places: for example, we may wish to try a new bundle of packages
before \Qref*{installing them `properly'}{Q-installthings}.  To do
this, we need to change the relevant path as \TeX{} perceives it.
However, we don't want to throw away \TeX{}'s built-in path (all of a
sudden, \TeX{} won't know how to deal with all sorts of things).

To \emph{extend} a \TeX{} path, we define an operating system
environment variable in `path format', but leaving a gap which \TeX{}
will fill with its built-in value for the path.  The commonest case is
that we want to place our extension in front of the path, so that our
new things will be chosen in preference, so we leave our `gap to be
filled' at the end of the environment variable.  The syntax is simple
(though it depends which shell you're actually using): so on a
Unix-like system, using the \ProgName{bash} shell, the job might be
done like:
\begin{verbatim}
  export TEXINPUTS=/tmp:
\end{verbatim}
while in a Windows system, within a \MSDOS{} window, it would be:
\begin{verbatim}
  set TEXINPUTS=C:/temp;
\end{verbatim}
In either case, we're asking \TeX{} to load files from the root disc
temporary files directory; in the Unix case, the ``empty slot'' is
designated by putting the path separator `|:|' on its own at the end
of the line, while in the Windows case, the technique is the same, but
the path separator is `|;|'.

Note that in either sort of system, the change will only affect
instances of \TeX{} that are started from the shell where the
environment variable was set.  If you run \TeX{} from another window,
it will use the original input path.  To make a change of input path
that will ``stick'' for all windows, set the environment variable in
your login script or profile (or whatever) in a Unix system and log
out and in again, or in \File{autoexec.bat} in a Windows system, and
reboot the system.

While all of the above has talked about where \TeX{} finds its macro
files, it's applicable to pretty much any sort of file any
\TeX{}-related program reads~--- there are lots of these paths, and of
their corresponding environment variables.  In a
\ProgName{web2c}-based system, the copious annotations in the
\File{texmf.cnf} system configuration file help you to learn which
path names correspond to which type of file.

\Question[Q-privinst]{``Private'' installations of files}

It sometimes happens that you need a new version of some macro package
or font, but that the machine you use is maintained by someone who's
unwilling to update and won't give you privileges to do the job
yourself.  A \Qref*{``temporary'' installation}{Q-tempinst} is
sometimes the correct approach, but if there's the slightest chance
that the installation will be needed on more than one project,
temporary installations aren't right.

In circumstances where you have plenty of quota on backed-up media, or
adequate local scratch space, the correct approach is to create a
private installation of \AllTeX{} which includes the new stuff you
need; this is the ideal, but is not generally possible.

So, since you can't install into the public \texttt{texmf} tree, you
have to install into a \File{texmf} tree of your own; fortunately, the
\acro{TDS} standard allows for this, and modern distributions allow
you to do it.  The most modern distributions refer to the tree as
\texttt{\$TEXMFHOME}, but it used to be called \texttt{\$HOMETEXMF};
so to check that your \TeX{} system does indeed support the mechanism
you should start with
\begin{verbatim}
kpsewhich -expand-var "\$TEXMFHOME"
\end{verbatim}

If you can confirm that the technique does indeed work, install your
new package (or whatever) in the \Qref*{correct place}{Q-install-where}
in a tree based on \File{$HOME/texmf}, and generate an index of that
tree
\begin{quote}
\begin{verbatim}
texhash $HOME/texmf
\end{verbatim}
\end{quote}
(the argument specifies which tree you are indexing: it's necessary
since you don't, by hypothesis, have access to the main tree, and
\ProgName{texhash} without the argument would try to write the main
tree.

There are two wrinkles to this simple formula: first, the installation
you're using may \emph{not} define a home TEXMF directory, and second,
there may be some obstruction to using \File{$HOME/texmf} as the
default name.  In either case, a good solution is to have your own
\File{texmf.cnf}~--- an idea that sounds more frightening that it
actually is.  The installation's existing file may be located with the
command:
\begin{quote}
\begin{verbatim}
kpsewhich texmf.cnf
\end{verbatim}
\end{quote}
Take a copy of the file and put it into a directory of your own; this
could be any directory, but an obvious choice is the \File{web2c}
directory of the tree you want to create, i.e.,
\File{$HOME/texmf/web2c} or the like.  Make an environment variable to
point to this directory:
\begin{quote}
\begin{verbatim}
TEXMFCNF=$HOME/texmf/web2c
export TEXMFCNF
\end{verbatim}
\end{quote}
(for a Bourne shell style system), or
\begin{quote}
\begin{verbatim}
setenv TEXMFCNF $HOME/texmf/web2c
\end{verbatim}
\end{quote}
(for a C-shell style system).  Now edit the copy of \File{texmf.cnf}

There will be a line in the existing file that defines the tree where
everything searches; the simplest form of the line is:
\begin{quote}
\begin{verbatim}
TEXMF = !!$TEXMFMAIN
\end{verbatim}
\end{quote}
but, there are likely to be several alternative settings behind
comment markers (``\texttt{\textpercent}''), and the person who 
installed your system may have left them there.  Whatever, you need to
modify the line that's in effect: change the above to three lines:
\begin{quote}
\begin{verbatim}
HOMETEXMF = $HOME/texmf
TEXMF = {$HOMETEXMF,!!$TEXMFMAIN}
% TEXMF = !!$TEXMFMAIN
\end{verbatim}
\end{quote}
the important point being that \texttt{\$HOMETEXMF} must come before
whatever was there before, inside the braces.  For example, if the
original was
\begin{quote}
\begin{verbatim}
TEXMF = {!!$LOCALTEXMF,!!$TEXMFMAIN}
\end{verbatim}
\end{quote}
it should be converted to:
\begin{quote}
\begin{narrowversion}
\begin{verbatim}
HOMETEXMF = $HOME/texmf
TEXMF = {$HOMETEXMF,!!$LOCALTEXMF,
                     !!$TEXMFMAIN}
% TEXMF = {!!$LOCALTEXMF,!!$TEXMFMAIN}
\end{verbatim}
{\small Note that the \texttt{TEXMF} line is only wrapped to make it
  fit in the column; there should be no line break or space between
  the final comma on the line and the \texttt{!!} on the next line.\par
}%
\end{narrowversion}
\begin{wideversion}
\begin{verbatim}
HOMETEXMF = $HOME/texmf
TEXMF = {$HOMETEXMF,!!$LOCALTEXMF,!!$TEXMFMAIN}
% TEXMF = {!!$LOCALTEXMF,!!$TEXMFMAIN}
\end{verbatim}
\end{wideversion}
\end{quote}
(retaining the original, as a comment, is merely an aide-memoir in
case you need to make another change, later).  The \texttt{!!} signs
tell the file-searching library that it should insist on a
\ProgName{texhash}-ed directory tree; if you can count on yourself
remembering to run \ProgName{texhash} on your new tree every time you
change it, then it's worth adding the marks to your tree:
\begin{quote}
\begin{narrowversion}
\begin{verbatim}
TEXMF = {!!$HOMETEXMF,!!$LOCALTEXMF,
                       !!$TEXMFMAIN}
\end{verbatim}
{\small Note that the line is only wrapped to make it
  fit in the column; there should be no line break or space between
  the final comma on the line and the \texttt{!!} on the next line.\par
}%
\end{narrowversion}
\begin{wideversion}
\begin{verbatim}
TEXMF = {!!$HOMETEXMF,!!$LOCALTEXMF,!!$TEXMFMAIN}
\end{verbatim}
\end{wideversion}
\end{quote}
as this will make \AllTeX{} find its files marginally faster.

Having made all these changes, \AllTeX{} should ``just use'' files in
your new tree, in preference to anything in the main tree~--- you can
use it for updates to packages in the main tree, as well as for
installing new versions of things.

\Question[Q-instfont]{Installing a new font}

Fonts are really ``just another package'', and so should be installed
in the same sort of way as packages.  However, fonts tend to be more
complicated than the average package, and as a result it's sometimes
difficult to see the overall structure.

Font files may appear in any of a large number of different formats;
each format has a different function in a \TeX{} system, and each is
stored in a directory its own sub-tree in the installation's
\acro{TDS} tree; all these sub-trees have the directory
\File{$TEXMF/fonts} as their root.  A sequence of answers%
\nothtml{, below,} describes the installation of fonts\latexhtml{.}{:}
\begin{htmlversion}
follow the list through the ``next question'' links at the bottom of
this answer to view them all.
\end{htmlversion}
Other answers discuss specific font families~--- for example,
% ! line break
``\Qref*{using the concrete fonts}{Q-concrete}''.

\Question[Q-instmffont]{Installing a font provided as \MF{} source}

Metafont fonts are (by comparison with other sorts of font) rather
pleasingly simple.  Nowadays, they are mostly distributed just as the
\MF{} source, since modern \TeX{} distributions are able to produce
everything the user needs ``on the fly''; however, if the distribution
\emph{does} include \acro{TFM} files, install them too, since they
save a little time and don't occupy much disc space.  Always distrust
distributions of \acro{PK} font bitmap files: there's no way of
learning from them what printer they were generated for, and naming
schemes under different operating systems are another source of
confusion.

``\Qref*{Where to install files}{Q-install-where}''
specifies where the files should go.

Further confusion is introduced by font families whose authors devise rules
for automatic generation of \MF{} sources for generating fonts at
particular sizes; the installation has to know about the rules, as
otherwise it cannot generate font files.

\Question[Q-instprinterfont]{Installing a \PS{} printer built-in font}

There is a ``standard'' set of fonts that has appeared in every \PS{}
printer since the second generation of the type.  These fonts
(8~families of four text fonts each, and three special-purpose fonts)
are of course widely used, because of their simple availability.  The
set consists of:
\begin{itemize}
\item \FontName{Times} family (4 fonts)
\item \FontName{Palatino} family (4 fonts)
\item \FontName{New} \FontName{Century} \FontName{Schoolbook} family (4 fonts)
\item \FontName{Bookman} family (4 fonts)
\item \FontName{Helvetica} family (4 fonts)
\item \FontName{Avant} \FontName{Garde} (4 fonts)
\item \FontName{Courier} family (4 fonts)
\item \FontName{Utopia} family (4 fonts)
\item Zapf \FontName{Chancery} (1 font)
\item Zapf \FontName{Dingbats} (1 font)
\item \FontName{Symbol} (1 font)
\end{itemize}
All these fonts are supported, for \LaTeX{} users, by the
\Package{psnfss} set of metrics and support files in the file
\File{lw35nfss.zip} on \acro{CTAN}.  Almost any remotely modern \TeX{}
system will have some version of \Package{psnfss} installed, but
users should note that the most recent version has much improved
coverage of maths with \FontName{Times} (see package
\Package{mathptmx}) and with \FontName{Palatino} (see package
\Package{mathpazo}, as well as a more reliable set of font metrics.

The archive \File{lw35nfss.zip} is laid out according to the
\acro{TDS}, so in principle, installation consists simply of
``unzipping'' the file at the root of a \path{texmf} tree.

Documentation of the \Package{psnfss} bundle is provided in
\File{psnfss2e.pdf} in the distribution.
\begin{ctanrefs}
\item[mathpazo.sty]Part of the \Package{psnfss} bundle
\item[mathptmx.sty]Part of the \Package{psnfss} bundle
\item[psnfss \nothtml{\rmfamily}bundle]\CTANref{psnfss}
\end{ctanrefs}

\Question[Q-inst1cm]{Installing the Bluesky versions of the CM~fonts}

This is a specialised case of \Qref*{installing a font}{Q-instfont},
but it comes easier
than most, since the font metrics are installed in every \AllTeX{}
system before you even start.  Indeed, most recent systems will have
the Type~1 fonts themselves already installed, so that the job is
already done, and all you need is to start using them:
so the first thing to do is to just try it.  On a system that uses
\ProgName{dvips} (most systems nowadays do), try the sequence:
\begin{verbatim}
  latex sample2e
  dvips -Pcmz -Pamz -o sample2e.ps sample2e
\end{verbatim}
at a ``command prompt'' (\ProgName{shell}, in a Unix-style system,
``\acro{DOS} box'' in a Windows system).

If the command works at all, the console output of the command will
include a sequence of Type~1 font file names, listed as
\texttt{<cmr10.pfb>} and so on;
this is \ProgName{dvips} telling you it's including the Type~1 font,
and you need do no more.

If the test has failed, you need to install your own set of the fonts.

The \acro{CTAN} directories listed below contain compressed archives of
the Type~1 
files for various architectures, both for the Computer Modern fonts
and for the \acro{AMS} fonts of mathematical and other useful things.
Download the archives that are appropriate for your architecture, and
extract the files~--- you only actually need the contents of the
\File{pfb} directories, since you already have the fonts
installed in the ``ordinary'' way, so that the \acro{TFM} files are
already present.  (You don't need the \PS{} font metric~--- \acro{AFM}
and \acro{PFM}~--- files in any case.)

The files should go into your local \texttt{texmf} tree (\File{texmf.local},
\File{texmf-local}, \File{localtexmf}, or whatever).  Create
directories at offsets \path{fonts/type1/bluesky/cm} and
\path{fonts/type1/bluesky/ams}, and copy the \extension{pfb} files into them.

Now you need to tell \ProgName{dvips}, \PDFTeX{}, etc., that the fonts
are available.  This is done by use of a \emph{map file}, which lists
\emph{font name} (as \TeX{} understands it), \emph{font name} (as it
appears in the type~1 file itself), and where the program will find
the file.  Map files are provided in the download bundles for the
\acro{AMS} fonts; for the \acro{CM} fonts, map files are available
separately.

The set of map files includes files \texttt{config.*}; each of these contains
an instruction to load a single map file.  For ordinary use, you
instruct \ProgName{dvips} to load the ``detailed'' map of the
\acro{CM} fonts by use of the command:
\begin{verbatim}
  dvips -Pcmz myfile
\end{verbatim}
The same can be done with the \acro{AMS} fonts, and you may invoke
both sets of fonts with:
\begin{verbatim}
  dvips -Pcmz -Pamz myfile
\end{verbatim}
Alternatively, the contents of \File{config.cmz} and \File{config.amz}
could be combined into a single file, perhaps \File{config.bluesky},
loaded by the command
\begin{verbatim}
  dvips -Pbluesky myfile
\end{verbatim}

Remember, after all such changes, the % beware line breaks
\Qref*{file-name database must be refreshed}{Q-inst-wlcf}.
\begin{ctanrefs}
\item[AMS fonts]Browse \CTANref{ams-AMStype1}
\item[CM fonts]Browse \CTANref{bluesky}
\item[CM font maps]\CTANref{bluesky-maps}
\end{ctanrefs}

\Question[Q-prept1font]{Preparing a Type~1 font}

The process of installing a Type~1 font set is rather convoluted, but
it may be separated into a modest set of operations.

The two basic stages are to prepare the font(s) for installation (this
question) and installing the result (see % ! line break
\Qref[question]{installing a Type~1 font}{Q-instt1font}).  Each of
these basic stages

Many fonts are supplied in \AllTeX{} ready form: such fonts need no
preparation, and may be \Qref*{installed immediately}{Q-instt1font}.
However, if you purchase a font from a Type foundry (either direct or
via one of the web stores), you are likely to need to `prepare' it for
use with \AllTeX{}.  The rest of this answer discusses this preparation.
\begin{itemize}
\item Acquire the font.  A very small set of Type~1 fonts is installed
  in most \PS{} printers you will encounter.  For those few (whose use
  is covered by the basic \acro{PSNFSS} package), you don't need the
  Type~1 font itself, to be able to print using the font.

  For all the myriad other Type~1 fonts, to be able to print using
  the font you need the Type~1 file itself.  Some of these are
  available for free (they've either been donated to the public
  domain, or were developed as part of a free software project), but
  the vast majority are commercial products, requiring you to spend
  real money.
\item Acquire the fonts' \acro{AFM} files.  \acro{AFM} files contain
  information from the font foundry, about the sizes of the characters
  in the font, and how they fit together.  One measure of the quality
  of a font-supplier is that they provide the \acro{AFM} files by
  default: if the files are not available, you are unlikely to be able
  to use the font with \AllTeX{}.
\item Rename the \acro{AFM} files and the Type~1 files to match the
  \Qref*{Berry font naming scheme}{Q-fontname}.
\item Generate \TeX{} metric files from the \acro{AFM} files.  The
  commonest tool for this task is \Package{fontinst}; the package
  documentation helps, but other guides are available (see below).
  The simplest possible script to pass to \Package{fontinst} is:
  \begin{quote}
\begin{verbatim}
\latinfamily{xyz}{}
\bye
\end{verbatim}
  \end{quote}
  where \texttt{xyz} is the Berry name of the font family.  This
  simple script is adequate for most purposes: its output covers the
  font family in both \acro{T}1 and \acro{OT}1 font encodings.  Nevertheless,
  with fancier fonts, more elaborate things are possible with
  \Package{fontinst}: see its documentation for details.

  \Package{Fontinst} also generates map files, and \LaTeX{} font
  definition (\extension{fd}) files.
\end{itemize}
Having traversed this list, you have a set of font files ready for
installation.

\Question[Q-instt1font]{Installing a Type~1 font}

Once you have a prepared Type~1 font, either direct from \acro{CTAN}
or the like, or having \Qref*{`prepared' it yourself}{Q-prept1font},
you can get on with installation.

The procedure is merely an extension of that for packages, etc., so
much of what follows will be familiar:
\begin{itemize}
\item Install the files, in your \texttt{texmf} tree.  All the
  strictures about installing non-standard things apply here: be sure
  to put the files in the local tree.  The list gives reasonable
  destinations for the various files related to a font family \meta{fname}:
\begin{verbatim}
.pfb,
.pfa  .../fonts/type1/<foundry>/<fname>
.tfm  .../fonts/tfm/<foundry>/<fname>
.vf   .../fonts/vf/<foundry>/<fname>
.sty,
.fd   .../tex/latex/<fname>
.map  .../fonts/map/dvips/<foundry>
\end{verbatim}
  but if you are lucky, you will be starting from a distribution from
  \acro{CTAN} and can make use of the corresponding
  \extension{tds.zip} file, and not care about how to place your files
  in the \acro{TDS} tree.
\item Regenerate the file indexes (as described in
  \Qref[question]{package installation}{Q-inst-wlcf}).
\item Update the \ProgName{dvips}, \PDFTeX{} and other maps:
  \begin{itemize}
  \item On any current \texlive{}-based system, or a te\TeX{} v3.0
    system, execute the command
    \begin{quote}
\begin{verbatim}
updmap-sys --enable Map <fname>.map
\end{verbatim}
    \end{quote}
    as root.  (You \emph{can} use plain \ProgName{updmap}, but you
    will be in danger of creating confusion with different map sets
    for different users thereby.)
  \item On a current \miktex{} system, update the system file
    \File{updmap.cfg}, using the shell command
    \begin{quote}
\begin{verbatim}
initexmf --edit-config-file updmap
\end{verbatim}
    \end{quote}
    adding a line at the end:
    \begin{quote}
\begin{verbatim}
Map <fname>.map
\end{verbatim}
    \end{quote}
    for each font family \meta{fname} you are adding to the system.
    Now generate revised maps with the shell command
    \begin{quote}
\begin{verbatim}
initexmf --mkmaps
\end{verbatim}
    \end{quote}
    This, and other matters, are described in \miktex{} % beware line break
    \href{http://docs.miktex.org/manual/advanced.html}{''advanced'' documentation}.
  \end{itemize}
\end{itemize}
Both processes (preparing and installing a font) are very well (and
thoroughly) described in Philipp Lehman's guide to font installation,
which may be found on \acro{CTAN}.
\begin{ctanrefs}
\item[fontinst.sty]\CTANref{fontinst}
\item[\nothtml{\rmfamily}Type 1 installation guide]\CTANref{T1instguide}
\end{ctanrefs}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\section{Fonts}

\subsection{\MF{} fonts}

\Question[Q-useMF]{Getting \MF{} to do what you want}

\MF{} allows you to create your own fonts, and most \TeX{} users
will never need to use it. \MF{}, unlike \TeX{}, requires some
customisation: each output device for which you will be generating
fonts needs a mode associated with it. Modes are defined using the
|mode_def| convention described on page~94 of \emph{The \MF{}book}
(see \Qref[question]{\TeX{}-related books}{Q-books}). You will need
a file, which conventionally called \File{local.mf}, containing all the
|mode_def|s you will be using. If \File{local.mf} doesn't already
exist, Karl Berry's collection of modes (\File{modes.mf})
is a good starting point 
(it can be used as a `\File{local.mf}' without modification in a `big
enough' implementation of \MF{}). Lists of
settings for various output devices are also published periodically in
\textsl{TUGboat} (see \Qref[question]{\acro{TUG}}{Q-TUG*}). Now create
a \texttt{plain} base
file using \ProgName{inimf}, \texttt{plain.mf}, and \texttt{local.mf}:
\begin{htmlversion}
\begin{verbatim}
   % inimf
   This is METAFONT...
   **plain # you type plain
   (output)
   *input local # you type this
   (output)
   *dump # you type this
   Beginning to dump on file plain...
   (output)
\end{verbatim}
\end{htmlversion}
\htmlignore
\par\vspace{\topsep}
%\begin{tabular}{@{}l@{}l@{}}
%|% inimf|\\
%This is METAFONT\dots{}\\{}
%**|plain|& you type `|plain|'\\{}
%(output)\\{}
%*|input local|& you type this\\{}
%(output)\\{}
%*|dump|& you type this\\{}
%Beginning to dump on file plain\dots{}\\{}
%(output)\\{}
%\end{tabular}\par
\begin{list}{}{}\item\relax
  |% inimf|\\
  This is METAFONT\dots{}\\{}
  \fullline{**\texttt{plain}\hss you type `\texttt{plain}'}
  (\emph{output})\\{}
  \fullline{*\texttt{input local}\hss you type this}
  (\emph{output})\\{}
  \fullline{*\texttt{dump}\hss you type this}
  Beginning to dump on file plain\dots{}\\{}
  (\emph{output})
\end{list}\par
\endhtmlignore
This will create a base file named \File{plain.base} (or something
similar; for example, it will be
\htmlignore
\acro{\File{PLAIN.BAS}}
\endhtmlignore
\begin{htmlversion}
  \File{PLAIN.BAS}
\end{htmlversion}
on \MSDOS{} systems) which should be moved to the directory containing
the base files on your system (note that some systems have two or more
such directories, one for each `size' of \MF{} used).

Now you need to make sure \MF{} loads this new base when it starts up. If
\MF{} loads the \texttt{plain} base by default on your system, then you're
ready to go. Under Unix (using the default \ProgName{web2c}
distribution%
\begin{footnoteenv}
  The \ProgName{command_name} is symbolically linked to
  \ProgName{virmf}, and \ProgName{virmf} loads \File{command_name.base}
\end{footnoteenv})
this does indeed happen, but we could for instance define a command
\ProgName{mf} which executes \texttt{virmf \&plain} loading the
\texttt{plain} base file.

The usual way to create a font with \texttt{plain} \MF{} is to start 
it with the
\begin{narrowversion}
  lines
  \begin{quote}
    \csx{mode}\texttt{=<mode name>;}\\
    \texttt{mag=<magnification>;}\\
    \texttt{input <font file name>}
  \end{quote}
\end{narrowversion}
\begin{wideversion}
line
\begin{verbatim}
\mode=<mode name>; mag=<magnification>; input <font file name>
\end{verbatim}
\end{wideversion}
in response to the `\texttt{**}' prompt or on the \MF{} command line. (If
\texttt{<mode name>} is unknown or omitted, the mode defaults to `proof' and
\MF{} will produce an output file called
% beware!! -- argument of \File naturally breaks across line end
\File{<font file name>.2602gf})
The \texttt{<magnification>} is a floating point number or
`magstep' (magsteps are defined in \emph{The \MF{}book} and
\emph{The \TeX{}book}).
If \texttt{mag=<magnification>} is omitted, then the default
is 1 (magstep 0).  For example, to generate cmr10 at 12pt for an epson
printer you would type
\begin{verbatim}
  mf \mode=epson; mag=magstep 1; input cmr10
\end{verbatim}
Note that under Unix the \texttt{\textbackslash } and \texttt{;}
characters must usually be quoted or escaped, so this would typically
look something like
\begin{verbatim}
 mf '\mode=epson; mag=magstep 1; input cmr10'
\end{verbatim}

If you don't have \ProgName{inimf} or need a special mode that isn't
in the base, you can put its commands in a file (\emph{e.g.},
\File{ln03.mf}) and invoke it on the fly with the \csx{smode} command.
For example, to create \File{cmr10.300gf} for an \acro{LN}03 printer, using
the file
\begin{verbatim}
   % This is ln03.mf as of 1990/02/27
   % mode_def courtesy of John Sauter
   proofing:=0;
   fontmaking:=1;
   tracingtitles:=0;
   pixels_per_inch:=300;
   blacker:=0.65;
   fillin:=-0.1;
   o_correction:=.5;
\end{verbatim}
(note the absence of the \texttt{mode\_def} and \texttt{enddef}
commands), you would type
\begin{verbatim}
   mf \smode="ln03"; input cmr10
\end{verbatim}
This technique isn't one you should regularly use, but it may
prove useful if you acquire a new printer and want to experiment with
parameters, or for some other reason are regularly editing the
parameters you're using.  Once you've settled on an appropriate set of
parameters, you should use them to rebuild the base file that you use.

Other sources of help are mentioned in % beware line break
\Qref[question]{\MF{} and \MP{} Tutorials}{Q-mfptutorials}.
\begin{ctanrefs}
\item[modes.mf]\CTANref{modes-file}
\end{ctanrefs}

\Question[Q-keepfonts]{Which font files should be kept}

\MF{} produces from its run three files, a metrics (\acro{TFM}) file, a
generic font (\acro{GF}) file, and a log file; all of these files have the
same base name as does the input (\emph{e.g.}, if the input file was
\File{cmr10.mf}, the outputs will be \File{cmr10.tfm},
\File{cmr10.nnngf}%
\begin{footnoteenv}
  Note that the file name may be transmuted by such operating systems
  as \MSDOS{}, which don't permit long file names
\end{footnoteenv}
and \File{cmr10.log}).

For \TeX{} to use the font, you need a \acro{TFM} file, so you need
to keep that.  However, you are likely to generate the same font
at more than one magnification, and each time you do so you'll
(incidentally) generate another \acro{TFM} file; these files are
all the same, so you only need to keep one of them.

To preview or to produce printed output, the \acro{DVI} processor will need a
font raster file; this is what the \acro{GF} file provides.  However, while
there used (once upon a time) to be \acro{DVI} processors that could use
\acro{GF} files, modern processors use packed raster (\acro{PK}) files.
Therefore, you need to generate a \acro{PK} file from the \acro{GF} file; the
program \ProgName{gftopk} does this for you, and once you've done that you
may throw the \acro{GF} file away.

The log file should never need to be used, unless there was some sort
of problem in the \MF{} run, and need not be ordinarily kept.

\Question[Q-getbitmap]{Acquiring bitmap fonts}

When \acro{CTAN} was young, most people would start using \TeX{}
with a 300 dots-per-inch (dpi) laser printer, and sets of Computer
Modern bitmap fonts for this resolution are available on \acro{CTAN}.
(There are separate sets for write-black and write-white printers, as
well as sets at 120~dpi and 240~dpi.)

Over the years, there have been regular requests that \acro{CTAN} should hold
a wider range of resolutions, but they were resisted for two reasons:
\begin{itemize}
\item The need to decide which printers to generate fonts for.  The
  broad-brush approach taken for 300~dpi printers was (more or less)
  justified back then, given the dominance of certain printer
  `engines', but nowadays one could not make any such assumption.
\item Given the above, justifying the space taken up by a huge array
  of bitmap fonts.
\end{itemize}
Fortunately, \AllTeX{} distribution technology has put a stop to these
arguments: most (if not all) current distributions generate bitmap
fonts as needed, and cache them for later re-use.  The impatient
user, who is determined that all bitmap fonts should be created once
and for all, may be supported by scripts such as \ProgName{allcm}
(distributed with \texlive{}, at least; otherwise such a
person should consult ``\Qref*{the use of \MF{}}{Q-useMF})''.

If your output is to a \PS{}-capable device, or if your output is
destined to be converted to \acro{PDF}, you should switch to
using Type~1 versions of the \acro{CM} fonts.  Two free
sets are available; the older (\Package{bakoma}) is
somewhat less well produced than the \Package{bluesky} fonts, which were
originally professionally produced and sold, but were then donated to
the public domain by their originators \YandY{} and Bluesky Research,
in association with the \acro{AMS}.  The two sets contain slightly
different ranges of fonts, but you are advised to use the
\Package{bluesky} set except when \Package{bakoma} is for some reason
absolutely unavoidable.  In recent years, several other `\MF{}' fonts
have been converted to Type~1 format; it's common never to need to
generate bitmap fonts for any purpose other than previewing (see
% beware of line wrap
\Qref*{``previewing documents with Type~1 fonts''}{Q-PSpreview}),
if even then.

More modern fonts may be used in place of the Computer Modern set.  The
\Qref*{\acro{EC} fonts}{Q-ECfonts} and the % ! line break
\Qref*{Latin Modern fonts}{Q-uselmfonts} are both close relatives of
Computer Modern with wider ranges of glyphs to offer.
\begin{ctanrefs}
\item[\nothtml{\rmfamily}BaKoMa fonts]\CTANref{bakoma}
\item[\nothtml{\rmfamily}Bluesky fonts]Browse \CTANref{bluesky}
\item[\nothtml{\rmfamily}CM fonts (write-black printers)]\CTANref{pk300}
\item[\nothtml{\rmfamily}CM fonts (write-white printers)]\CTANref{pk300w}
\item[\nothtml{\rmfamily}EC fonts (Type 1 format)]\CTANref{cm-super}
\item[\nothtml{\rmfamily}Latin Modern fonts]\CTANref{lm}
\end{ctanrefs}

\subsection{Adobe Type~1 (``\PS{}'') fonts}

\Question[Q-usepsfont]{Using \PS{} fonts with \protect\TeX{}}

In order to use \PS{} fonts, \TeX{} needs
\emph{metric} (called \acro{TFM}) files. Several sets of metrics are
available from the archives; for mechanisms for generating new ones,
see \Qref[question]{metrics for \PS{} fonts}{Q-metrics}.  You
also need the fonts themselves; \PS{} printers come with a set of
fonts built in, but to extend your repertoire you almost invariably
need to buy from one of the many commercial font vendors (see, for
example, \Qref[question]{``choice of fonts''}{Q-psfchoice}).

If you use \LaTeXe{}, the best way to get \PS{} fonts into your
document is to use the \acro{PSNFSS} package maintained by Walter
Schmidt.  The \LaTeX{}3 project team declare that \acro{PSNFSS} is
``required'', and bug reports may be submitted via the % line break
\Qref*{\LaTeX{} bugs system}{Q-latexbug}. 
\acro{PSNFSS} gives you a set of packages for changing the default
roman, sans-serif and typewriter fonts; \emph{e.g}., the
\Package{mathptmx} package will set up \FontName{Times}
\FontName{Roman} as the main text font (and introduces mechanisms to
typeset mathematics using \FontName{Times} and various more-or-less
matching fonts),  while package \Package{avant} changes the sans-serif
family to \FontName{AvantGarde}, and \Package{courier} changes the
typewriter font to \FontName{Courier}.  To go with these
packages, you need the font metric files
and font description (\File{.fd}) files for each font family you
want to use.  For convenience,
metrics for the `common 35' \PS{} fonts found in most \PS{} printers
are provided with \acro{PSNFSS}, packaged as the ``Laserwriter set''.

For older versions of \LaTeX{} there are various schemes, of which the
simplest to use is probably the \acro{PS}\LaTeX{} macros distributed with
\ProgName{dvips}.

For \plaintex{}, you load whatever fonts you like; if the encoding of
the fonts is not the same as Computer Modern it will be up to you to
redefine various macros and accents, or you can use the font
re-encoding mechanisms available in many drivers and in
\ProgName{ps2pk} and \ProgName{afm2tfm}.

Victor Eijkhout's \Qref*{Lollipop package}{Q-lollipop}
supports declaration of font families and styles in a similar way to
\LaTeX{}'s \acro{NFSS}, and so is easy to use with \PS{} fonts.

Some common problems encountered are discussed elsewhere
(see \Qref[question]{problems with \acro{PS} fonts}{Q-psfontprob}).
\begin{ctanrefs}
\item[Metrics for the `Laserwriter' set of 35 fonts]\CTANref{lw35nfss-zip}
\item[lollipop]\CTANref{lollipop}
\item[psnfss]\CTANref{psnfss}
\end{ctanrefs}

\Question[Q-PSpreview]{Previewing files using Type 1 fonts}

Until recently, free \TeX{} previewers have only been capable of
displaying bitmap \acro{PK} fonts, but current versions of
\ProgName{xdvi} sport a Type~1 font renderer.
%% \YandY{}'s commercial
%% previewer \Qref*{\acro{DVIW}indo}{Q-commercial} has in the past used
%% \ProgName{Adobe} \ProgName{Type} \ProgName{Manager} to display Type~1
%% fonts directly and now uses the system-provided font renderer
%% available in Windows~2000 and~XP.

Other (free) previewers of the current generation offer automatic
generation of the requisite \acro{PK} files (using \ProgName{gsftopk},
or similar, behind the scenes).  If your previewer isn't capable of
this, you have three options:
\begin{itemize}
\item Convert the \acro{DVI} file to \PS{} and use a
  \PS{} previewer.  Some systems offer this capability as
  standard, but most people will need to use a separate previewer such
  as \ProgName{ghostscript} or \ProgName{ghostscript}-based viewers
  such as \ProgName{ghostview} or shareware offering \ProgName{GSview}.
\item Under Windows on a \acro{PC}, or on a Macintosh, let Adobe Type Manager
  display the fonts (textures, on the Macintosh, works like this).
%%   , and under
%%   Windows you can use \YandY{}'s \ProgName{dviwindo} for bitmap-free
%%   previewing.
\begin{narrowversion} % really hyper
  (See \Qref[question]{}{Q-commercial} for details of these
  suppliers.)
\end{narrowversion}
%\typeout{after narrowversion, before wideversion}
\begin{wideversion}
  (See \Qref{commercial suppliers}{Q-commercial} for details.)
\end{wideversion}
%\typeout{after wideversion}
\item If you have the \PS{} fonts in Type~1 format,
  use \ProgName{ps2pk} or \ProgName{gsftopk}
  (designed for use with the \ProgName{ghostscript} fonts) to make
  \acro{PK} bitmap fonts which your previewer 
  will understand. This can produce excellent results, also suitable
  for printing with non-\PS{} devices. Check the legalities of
  this if you have purchased the fonts.
\end{itemize}
\begin{ctanrefs}
\item[ghostscript]Browse \CTANref{ghostscript}
\item[ghostview]Browse \CTANref{ghostview}
\item[gsftopk]\CTANref{gsftopk}
\item[GSview]Browse \CTANref{gsview}
\item[ps2pk]\CTANref{ps2pk}
\item[xdvi]\CTANref{xdvi}
\end{ctanrefs}

\Question[Q-metrics]{\protect\TeX{} font metric files for \PS{} fonts}

Reputable font vendors such as Adobe supply metric files for each
font, in \acro{AFM} (Adobe Font Metric) form; these can be converted
to \acro{TFM} (\TeX{} Font Metric) form. Most modern distributions have
prebuilt metrics which will be more than enough for many people; but you may
need to do the conversion yourself if you have special needs or
acquire a new font. One important question is the \emph{encoding} of
(Latin character) fonts; while we all more or less agree about the
position of about 96 characters in fonts (the basic \acro{ASCII} set), the
rest of the (typically) 256 vary. The most obvious problems are with
floating accents and special characters such as the `pounds sterling'
sign. There are three ways of dealing with this: either you change the
\TeX{} macros which reference the characters (not much fun, and
error-prone); or you change the encoding of the font (easier than you
might think); or you use \Qref*{virtual fonts}{Q-virtualfonts} to
\emph{pretend} to \TeX{} that the encoding is the same as it is used to.
\LaTeXe{} has facilities for dealing with fonts in different
encodings; read the \Qref*{\emph{\LaTeX{} Companion}}{Q-books} for
more details.  In practice, if you do much non-English (but Latin
script) typesetting, you are strongly recommended to use the
\Package{fontenc} package with option `\pkgoption{T1}' to select
\Qref*{`Cork'}{Q-ECfonts} encoding.
A useful alternative is \YandY{}'s ``private'' \acro{LY}1 encoding,
which is designed to sit well with ``Adobe standard'' encoded fonts.
Basic support of \acro{LY1} is available on \acro{CTAN}: note that the
``relation with Adobe's encoding'' means that there are no
virtual fonts in the \acro{LY}1 world.

Alan Jeffrey's \ProgName{fontinst} package is an \acro{AFM} to
\acro{TFM} converter written in \TeX{}; it is used to generate the
files used by \LaTeXe{}'s \acro{PSNFSS} package to support use of
\PS{} fonts. It is a sophisticated package, not for the faint-hearted,
but is powerful enough to cope with most needs.  Much of its power
relies on the use of \Qref*{virtual fonts}{Q-virtualfonts}.

For slightly simpler problems, Rokicki's \ProgName{afm2tfm},
distributed with \ProgName{dvips}, is fast and
efficient; note that the metrics and styles that come with
\ProgName{dvips} are \emph{not} currently \LaTeXe{} compatible.

For the Macintosh (classic), there is a program called
\ProgName{EdMetrics} which does the job (and more).
\ProgName{EdMetrics} comes with the (commercial)
\Qref*{Textures}{Q-commercial} distribution, but is itself free
software, and is available on \acro{CTAN}.
%% \par
%% Windows users can buy \Qref*{\YandY{}'s}{Q-commercial}
%% Font Manipulation Tools package which includes a powerful
%% \ProgName{afmtotfm} program among many other goodies.
\begin{ctanrefs}
\item[dvips]\CTANref{dvips}
\item[EdMetrics]\CTANref{edmetrics}
\item[fontinst]\CTANref{fontinst}
\item[LY1 support]\CTANref{ly1}
\end{ctanrefs}

\Question[Q-psfontprob]{Deploying Type 1 fonts}

For the \LaTeX{} user trying to use the
\Qref*{\acro{PSNFSS}}{Q-usepsfont} package, three questions may arise.

First, you have to declare to the \acro{DVI} driver that you are using
\PS{} fonts; in the case of \ProgName{dvips}, this means adding
lines to the \File{psfonts.map} file, so that \ProgName{dvips} will know
where the proper fonts are, and won't try to find \acro{PK} 
files.  If the font isn't built into the printer, you have to acquire
it (which may mean that you need to purchase the font files).

Second, your previewer must know what to do with the fonts: see
\Qref[question]{previewing type 1 fonts}{Q-PSpreview}.

Third, the stretch and shrink between words is a function of the
font metric; it is not specified in \acro{AFM} files, so different converters
choose different values. The \PS{} metrics that come with \acro{PSNFSS} 
used to produce quite tight setting, but they were revised in mid 1995
to produce a compromise between American and European practice. 
Sophisticated users may not find even the new the values to their taste, and
want to override them. Even the casual user may find  more
hyphenation or overfull boxes than Computer Modern produces; but \acro{CM}
is extremely generous. 

\Question[Q-psfchoice]{Choice of scalable outline fonts}

If you are interested in text alone, you can in principle use any of
the huge numbers of text fonts in Adobe Type~1, TrueType or OpenType
formats.  The constraint is, of course, that your previewer and
printer driver should support such fonts (\TeX{} itself \emph{only}
cares about metrics, not the actual character programs).

If you also need mathematics, then you are severely limited by the
demands that \TeX{} makes of maths fonts (for details, see the papers
by
\begin{wideversion}
% !! line break !!
  \href{http://tug.org/TUGboat/Articles/tb14-3/tb40horn.pdf}{B.K.P. Horn in \TUGboat{} 14(3)},
  or by % ! line break
  \href{http://tug.org/TUGboat/Articles/tb19-2/tb59bouc.pdf}{Thierry Bouche in \TUGboat{} 19(2)}).
\end{wideversion}
\begin{narrowversion}
  B.K.P. Horn in \TUGboat{} 14(3) or by Thierry Bouche in \TUGboat{}
  19(2), available as
  \URL{http://tug.org/TUGboat/Articles/tb14-3/tb40horn.pdf} or
  \URL{http://tug.org/TUGboat/Articles/tb19-2/tb59bouc.pdf}, respectively).
\end{narrowversion}
For mathematics, then, there are relatively few choices (though the list is
at last growing).  There are several font families available that are
based on Knuth's original designs, and some that complement other
commercial text font designs; one set (MicroPress's `informal math')
stands alone.  ``Free'' font families that will support \TeX{}
mathematics include:
\begin{booklist}
\item[Computer Modern](75 fonts~--- optical scaling) Donald E. Knuth\\
  The \acro{CM} fonts were originally designed in \MF{}, but are also
  now available in scalable outline form.  There are commercial as
  well as public domain versions, and there are both Adobe Type~1 and
  TrueType versions.  A set of outline versions of the fonts was
  developed as a commercial venture by \YandY{} and Blue Sky Research;
  they have since assigned the copyright to the \acro{AMS}, and the
  fonts are now freely available from \acro{CTAN}.  Their quality is
  such that they have become the \emph{de facto} standard for Type~1
  versions of the fonts.
\item[\acro{AMS} fonts](52 fonts, optical scaling) The \acro{AMS}\\
  This set of fonts offers adjuncts to the \acro{CM} set, including
  two sets of symbol fonts (\FontName{msam} and \FontName{msbm}) and
  Euler text fonts.
  These are not a self-standing family, but merit discussion here (not
  least because several other families mimic the symbol fonts).
  Freely-available Type~1 versions of the fonts are available on
  \acro{CTAN}.  The \Package{eulervm} package permits use
  of the Euler maths alphabet in conjunction with text fonts that do
  not provide maths alphabets of their own (for instance, Adobe
  Palatino or Minion).
\item[mathpazo version 1.003](5 fonts) Diego Puga\\
  The Pazo Math fonts are a family of type~1 fonts suitable for
  typesetting maths in combination with the Palatino family of text
  fonts.  Four of the five fonts of the distribution are maths
  alphabets, in upright and italic shapes, medium and bold weights;
  the fifth font contains a small selection of ``blackboard bold''
  characters (chosen for their mathematical significance).  Support
  under \LaTeXe{} is available in 
  \Qref*{\acro{PSNFSS}}{Q-usepsfont}; the fonts are
  licensed under the \acro{GPL}, with legalese permitting the use of
  the fonts in published documents.
\item[Fourier/Utopia](15 fonts) Michel Bovani\\
  \FontName{Fourier} is a family built on Adobe \FontName{Utopia}
  (which has been released for usage free of charge by Adobe).  The
  fonts provide the basic Computer Modern set of mathematical symbols,
  and add many of the \acro{AMS} mathematical symbols (though you are
  expected to use some from the \acro{AMS} fonts themselves).  There
  are also several other mathematical and decorative symbols.  The
  fonts come with a \Package{fourier} package for use with \LaTeX{};
  text support of \acro{OT}1 encoding is not provided~--- you are
  expected to use \acro{T}1.

  For a sample, see \url{http://www.tug.dk/FontCatalogue/utopia/}
\item[Fourier/New Century Schoolbook]Michael Zedler\\
  \FontName{Fouriernc} is a configuration using the Fourier fonts in
  the context of New Century Schoolbook text fonts.

  For a sample, see \url{http://www.tug.dk/FontCatalogue/newcent/}
\item[KP-fonts]The Johannes Kepler project\\
  The \FontName{kp-fonts} family provides a comprehensive set of text
  and maths fonts.  The set includes replacement fixed-width and sans
  fonts (though some reports have suggested that these are less
  successful, and their use may be suppressed when loading the fonts'
  \Package{kpfonts} \LaTeX{} support package).

  For an example, see \url{http://www.tug.dk/FontCatalogue/kpserif/}
\item[MathDesign](4 entire families\dots{}so far) Paul Pichaureau\\
  This set so far offers mathematics fonts to match Adobe Utopia, URW
  Garamond, Bitstream Charter (all of which are separately available,
  on \acro{CTAN}, in Type~1 format) and Fontsite Garamond
  (which is a commercial font, available from the % ! line wrap (twice)
\begin{wideversion}
  \href{FontSite Web shop}{http://www.fontsite.com/Pages/FFDownloads.html}).
\end{wideversion}
\begin{narrowversion}
  FontSite Web shop, \URL{http://www.fontsite.com/Pages/FFDownloads.html}).
\end{narrowversion}
  There has been a little comment on these fonts, but none
  from actual users posted to the public forums.  Users, particularly
  those who are willing to discuss their experiences, would obviously
  be welcome.  Browse the \acro{CTAN} directory and see which you
  want: there is a wealth of documentation and examples.

  For samples of the free variants, see
  \url{http://www.tug.dk/FontCatalogue/charter/} for URW Charter,
  \url{http://www.tug.dk/FontCatalogue/garamond/} for URW Garamond and
  \url{http://www.tug.dk/FontCatalogue/utopia-md/} for Adobe Utopia.
\item[Belleek](3 fonts) Richard Kinch\\
  Belleek is the upshot of Kinch's thoughts on how \MF{} might be used
  in the future: they were published simultaneously as \MF{} source,
  as Type~1 fonts, and as TrueType fonts.  The fonts act as ``drop-in''
  replacements for the basic MathTime set (as an example of ``what might
  be done'').

  The paper outlining Kinch's thoughts, proceeding from considerations
  of the `intellectual' superiority of \MF{} to evaluations of why its
  adoption is so limited and what might be done about the problem, is
  to be found at \URL{http://truetex.com/belleek.pdf} (the paper is a
  good read, but is set with Bitmap fonts, and can be difficult
  on-screen in Acrobat reader 5 or earlier).
\item[mathptmx]Alan Jeffrey, Walter Schmidt and others.\\
  This set contains maths italic, symbol, extension, and roman virtual
  fonts, built from Adobe Times, Symbol, Zapf Chancery, and the
  Computer Modern fonts.  The resulting mixture is not  entirely
  acceptable, but can pass in many circumstances.  The real advantage
  is that the mathptm fonts are (effectively) free, and the resulting
  \PS{} files can be freely exchanged.  Support under \LaTeXe{}
  is available in \Qref*{\acro{PSNFSS}}{Q-usepsfont}.

  For a sample, see \url{http://www.tug.dk/FontCatalogue/times/}
\item[Computer Modern Bright]Free scalable outline versions of these
  fonts do exist; they are covered below together with their
  commercial parallels.
\end{booklist}
The excellent \emph{font catalogue} keeps an % ! line break
\href{http://www.tug.dk/FontCatalogue/mathfonts.html}{up-to-date list}
which describes the fonts by giving names and short examples, only.
(At the time of writing~--- June 2008~--- the list has several that
are only scheduled for inclusion here.

Another useful document is Stephen Hartke's ``Free maths font
survey'', which is available on \acro{CTAN} in both \acro{PDF} and
\acro{HTML} formats.  The survey covers most of the fonts mentioned in
the font catalogue, but also mentions some (such as \Package{Belleek}
that the catalogue omits.

Fonts capable of setting \TeX{} mathematics, that are available
commercially, include:
\begin{booklist}
\item[BA Math](13 fonts) MicroPress Inc.\\
  BA Math is a family of serif fonts, inspired by the elegant
  and graphically perfect font design of John Baskerville.  BA
  Math comprises the fonts necessary for mathematical typesetting
  (maths italic, math symbols and extensions) in normal and bold
  weights.  The family also includes all \acro{OT}1 and \acro{T}1
  encoded text fonts of various shapes, as well as fonts with most
  useful glyphs of the \acro{TS}1 encoding.  Macros for using the
  fonts with \plaintex{}, \LaTeXo{} and current \LaTeX{} are
  provided.

  \nothtml{\bgroup\raggedwithindent}
  For further details (including samples) see\\
  \URL{http://www.micropress-inc.com/fonts/bamath/bamain.htm}
  \nothtml{\par\egroup}
\item[CH Math](15 fonts) MicroPress Inc.\\
  CH Math is a family of slab serif fonts, designed as a maths
  companion for Bitstream Charter.  (The distribution includes
  four free Bitstream text fonts, in addition to the 15 hand-hinted
  MicroPress fonts.)
  \nothtml{\bgroup\raggedwithindent}
  For further details (including samples) see\\
  \URL{http://www.micropress-inc.com/fonts/chmath/chmain.htm}
  \nothtml{\par\egroup}
\item[Computer Modern Bright](62 fonts~--- optical scaling) Walter
  Schmidt\\
  \acro{CM} Bright is a family of sans serif fonts, based on Knuth's
  \acro{CM} fonts.  It comprises the fonts necessary for mathematical
  typesetting, including \acro{AMS} symbols, as well as text and text
  symbol fonts of various shapes.  The collection comes with its own
  set of files for use with \LaTeX{}.  The \acro{CM} Bright fonts are
  supplied in Type~1 format by MicroPress, Inc.   The
  \Package{hfbright} bundle offers free Type~1 fonts for text using
  the \acro{OT}1 encoding~--- the \Package{cm-super} set for
  use with \acro{T}1 texts doesn't (yet) offer support for mathematics.

  \nothtml{\bgroup\raggedwithindent}
  For further details of Micropress' offering (including samples) see\\
  \URL{http://www.micropress-inc.com/fonts/brmath/brmain.htm}
  \nothtml{\par\egroup}
\item[Concrete Math](25 fonts~--- optical scaling) Ulrik Vieth\\
  The Concrete Math font set was derived from the Concrete Roman
  typefaces designed by Knuth.  The set provides a collection of math
  italics, math symbol, and math extension fonts, and fonts of
  \acro{AMS} symbols that fit with the Concrete set, so that Concrete
  may be used as a complete replacement for Computer Modern.  Since
  Concrete is considerably darker than \acro{CM}, the family may
  particularly attractive for use in low-resolution printing or in
  applications such as posters or transparencies.  Concrete Math
  fonts, as well as Concrete Roman fonts, are supplied in Type 1
  format by MicroPress, Inc.

  \nothtml{\bgroup\raggedwithindent}
  For further information (including samples) see\\
  \URL{http://www.micropress-inc.com/fonts/ccmath/ccmain.htm}
  \nothtml{\par\egroup}
\item[HV Math](14 fonts) MicroPress Inc.\\
  HV Math is a family of sans serif fonts, inspired by the
  Helvetica (\acro{TM}) typeface.  HV Math comprises the fonts
  necessary for mathematical typesetting (maths italic, maths symbols
  and extensions) in normal and bold weights.  The family also
  includes all \acro{OT}1 and \acro{T}1 encoded text fonts of various
  shapes, as well as fonts with most useful glyphs of the \acro{TS}1
  encoding.  Macros for using the fonts with \plaintex{}, \LaTeXo{}
  and current \LaTeX{} are provided.  Bitmapped copies of the fonts
  are available free, on \acro{CTAN}.

  \nothtml{\bgroup\raggedwithindent}
  For further details (and samples) see\\
  \URL{http://www.micropress-inc.com/fonts/hvmath/hvmain.htm}
  \nothtml{\par\egroup}
\item[Informal Math](7 outline fonts) MicroPress Inc.\\
  Informal Math is a family of fanciful fonts loosely based on the
  Adobe's Tekton (\acro{TM}) family, fonts which imitate handwritten
  text.  Informal Math comprises the fonts necessary for
  mathematical typesetting (maths italic, maths symbols and extensions)
  in normal weight, as well as \acro{OT}1 encoded text fonts in
  upright and oblique shapes.  Macros for using the fonts with
  \plaintex{}, \LaTeXo{} and current \LaTeX{} are provided.

  \nothtml{\bgroup\raggedwithindent}
  For further details (including samples) see\\
  \URL{http://www.micropress-inc.com/fonts/ifmath/ifmain.htm}
  \nothtml{\par\egroup}
\item[Lucida Bright \emph{with} Lucida New Math](25 fonts) Chuck Bigelow and
  Kris Holmes\\
  Lucida is a family of related fonts including seriffed, sans serif,
  sans serif fixed width, calligraphic, blackletter, fax, Kris Holmes'
  connected handwriting font, \emph{etc}; they're not as `spindly' as
  Computer Modern, with a large x-height, and include a larger set of
  maths symbols, operators, relations and delimiters than \acro{CM}
  (over 800 instead of 384: among others, it also includes the
  \acro{AMS} \FontName{msam} and \FontName{msbm} symbol sets).  `Lucida
  Bright Expert' 
  (14 fonts) adds seriffed fixed width, another handwriting font,
  smallcaps, bold maths, upright `maths italic', \emph{etc}., to the
  set.  Support under \LaTeX{} is available under the auspices of the
  \acro{PSNFSS}, and pre-built metrics are also provided.

  \nothtml{\bgroup\raggedwithindent}
  \acro{TUG} has the right to distribute these fonts; the web site
\begin{narrowversion}
    \href{http://tug.org/lucida/}{``Lucida and TUG''}
\end{narrowversion}
\begin{wideversion}
    ``\href{http://tug.org/lucida/}{Lucida and TUG}''
\end{wideversion}
  has details.
  \nothtml{\par\egroup}
\item[Adobe Lucida, LucidaSans \emph{and} LucidaMath](12 fonts)\\
  Lucida and LucidaMath are generally considered to be a bit heavy.
  The three maths fonts contain only the glyphs in the \acro{CM} maths
  italic, symbol, and extension fonts.  Support for using LucidaMath
  with \TeX{} is not very good; you will need to do some work
  reencoding fonts \emph{etc}.  (In some sense this set is the
  ancestor of the LucidaBright plus LucidaNewMath font set, which are
  not currently available.)
\item[MathTime Pro2]Publish or Perish (Michael Spivak)\\
  This latest instance of the MathTime family covers all the weights
  (medium, bold and heavy) and symbols of previous versions of
  MathTime.  In addition it has a much extended range of symbols, and
  many typographic improvements that make for high-quality documents.
  The fonts are supported under both \plaintex{} and \LaTeXe{}, and
  are exclusively available for purchase from
  \Qref*{Personal \TeX{} Inc}{Q-commercial}.
  \par{}
  \nothtml{\bgroup\raggedwithindent}
  For further details and samples and fliers, see
  \URL{http://www.pctex.com/mtpro2.html}
  \nothtml{\par\egroup}
\item[Minion Pro and MnSymbol]Adobe, \LaTeX{} support and packaging by
  Achim Blumensath \emph{et al}.\\
  \FontName{Minion Pro} derives from the widely-available commercial
  OpenType font of the same name by Adobe; scripts are provided to
  convert relevant parts of it to Adobe Type~1 format.  The
  \Package{MinionPro} package will set up text and maths support using
  \FontName{Minion Pro}, but a separate (free) font set
  \FontName{MnSymbol} greatly extends the symbol coverage.
\item[PA Math] PA~Math is a family of serif fonts
  loosely based on the Palatino (\acro{TM}) typeface.  PA~Math
  comprises the fonts necessary for mathematical typesetting (maths
  italics, maths, calligraphic and oldstyle symbols, and extensions)
  in normal and bold weights. The family also includes all \acro{OT}1,
  \acro{T}1 encoded text fonts of various shapes, as well as fonts
  with the most useful glyphs of the \acro{TS}1 encoding.  Macros for
  using the fonts with \plaintex{}, \LaTeXo{} and current \LaTeX{}
  are provided.

  \nothtml{\bgroup\raggedwithindent}
  For further details (and samples) see\\
  \URL{http://www.micropress-inc.com/fonts/pamath/pamain.htm} 
  \nothtml{\par\egroup}
\item[TM Math](14 fonts) MicroPress Inc.\\
  TM Math is a family of serif fonts, inspired by the Times
  (\acro{TM}) typeface.  TM Math comprises the fonts necessary for
  mathematical typesetting (maths italic, maths symbols and extensions)
  in normal and bold weights. The family also includes all \acro{OT}1
  and \acro{T}1 encoded text fonts of various shapes, as well as fonts
  with most useful glyphs of the \acro{TS}1 encoding.  Macros for
  using the fonts with \plaintex{}, \LaTeXo{} and current \LaTeX{}
  are provided.  Bitmapped copies of the fonts are available free, on
  \acro{CTAN}.

  \nothtml{\bgroup\raggedwithindent}
  For further details (and samples) see\\
  \URL{http://www.micropress-inc.com/fonts/tmmath/tmmain.htm} 
  \nothtml{\par\egroup}
\end{booklist}
Two other font sets should be mentioned, even though they don't
currently produce satisfactory output~--- their author is no longer
working on them, and several problems have been identified:
\begin{booklist}
\item[pxfonts set version 1.0](26 fonts) by Young Ryu\\
  The \FontName{pxfonts} set consists of
  \begin{itemize}
  \item virtual text fonts using \FontName{Adobe} \FontName{Palatino} (or the \acro{URW}
    replacement used by \ProgName{ghostscript}) with modified plus,
    equal and slash symbols;
  \item maths alphabets using \FontName{Palatino};
  \item maths fonts of all symbols in the computer modern maths fonts
    (\FontName{cmsy}, \FontName{cmmi}, \FontName{cmex} and the Greek
    letters of \FontName{cmr}) 
  \item maths fonts of all symbols corresponding to the \acro{AMS}
    fonts (\FontName{msam} and \FontName{msbm});
  \item additional maths fonts of various symbols.
  \end{itemize}
  The text fonts are available in \acro{OT}1, \acro{T}1 and \acro{LY}1
  encodings, and \acro{TS} encoded symbols are also available.  The
  sans serif and monospaced fonts supplied with the \FontName{txfonts}
  set (see below) may be used with \FontName{pxfonts}; the
  \FontName{txfonts} set should be installed whenever \FontName{pxfonts}
  are.  \LaTeX{}, \ProgName{dvips} and \PDFTeX{} support files are
  included.
\begin{narrowversion} % really non-hyper version
  Documentation 
  (\URL{http://www.tex.ac.uk/tex-archive/fonts/pxfonts/doc/pxfontsdocA4.pdf})
\end{narrowversion}
\begin{wideversion}
  \href{http://www.tex.ac.uk/tex-archive/fonts/pxfonts/doc/pxfontsdocA4.pdf}{Documentation}
\end{wideversion}
  is readily available.

  The fonts are licensed under the \acro{GPL}; use in published
  documents is permitted.
\item[txfonts set version 3.1](42 fonts) by Young Ryu\\
  The \FontName{txfonts} set consists of
  \begin{itemize}
  \item virtual text fonts using \FontName{Adobe} \FontName{Times} (or the \acro{URW}
    replacement used by \ProgName{ghostscript}) with modified plus,
    equal and slash symbols;
  \item matching sets of sans serif and monospace (`typewriter')
    fonts (the sans serif set is based on \FontName{Adobe} \FontName{Helvetica});
  \item maths alphabets using \FontName{Times};
  \item maths fonts of all symbols in the computer modern maths fonts
    (\FontName{cmsy}, \FontName{cmmi}, \FontName{cmex} and the Greek letters of \FontName{cmr})
  \item maths fonts of all symbols corresponding to the \acro{AMS}
    fonts (\FontName{msam} and \FontName{msbm});
  \item additional maths fonts of various symbols.
  \end{itemize}
  The text fonts are available in \acro{OT}1, \acro{T}1 and \acro{LY}1
  encodings, and \acro{TS} encoded symbols are also available.
\begin{narrowversion} % really non-hyper version
  Documentation
  (\URL{http://www.tex.ac.uk/tex-archive/fonts/txfonts/doc/txfontsdocA4.pdf})
\end{narrowversion}
\begin{wideversion}
  \href{http://www.tex.ac.uk/tex-archive/fonts/txfonts/doc/txfontsdocA4.pdf}{Documentation}
\end{wideversion}
  is readily available.

  The fonts are licensed under the \acro{GPL}; use in published
  documents is permitted.
\end{booklist}
Finally, one must not forget:
\begin{booklist}
\item[Proprietary fonts]Various sources.\\
  Since having a high quality font set in scalable outline form that
  works with \TeX{} can give a publisher a real competitive advantage,
  there are some publishers that have paid (a lot) to have such font
  sets made for them.  Unfortunately, these sets are not available on
  the open market, despite the likelihood that they're more complete
  than those that are.
\end{booklist}
We observe a very limited selection of commercial maths font sets; a
maths font has to be explicitly designed for use with \TeX{}, which is
an expensive business, and is of little appeal in other markets.
Furthermore, the \TeX{} market for commercial fonts is minute by
comparison with the huge sales of other font sets.

Text fonts in Type~1 format are available from many vendors including
Adobe, Monotype and Bitstream.  However, be careful with cheap font
``collections''; many of them dodge copyright restrictions by removing
(or crippling) parts of the font programs such as hinting.  Such
behaviour is both unethical and bad for the consumer.
The fonts may not render well (or at all, under \acro{ATM}), may not have the
`standard' complement of 228 glyphs, or may not include metric files
(which you need to make \acro{TFM} files).

TrueType remains the ``native'' format for Windows.  Some \TeX{}
implementations such as \Qref*{True\TeX{}}{Q-commercial} use TrueType
versions of Computer Modern and Times Maths fonts to render \TeX{}
documents in Windows without the need for additional system software like
\acro{ATM}.  (When used on a system running Windows~XP, True\TeX{} can
also use Type~1 fonts.)

When choosing fonts, your own system environment may not be the only one of
interest.  If you will be sending your finished documents to others for
further use, you should consider whether a given font format will introduce
compatibility problems.  Publishers may require TrueType exclusively because
their systems are Windows-based, or Type~1 exclusively, because their systems
are based on the early popularity of that format in the publishing industry.
Many service bureaus don't care as long as you present them with a finished
print file (\PS{} or \acro{PDF}) for their output device.
\begin{ctanrefs}
\item[CM \nothtml{\normalfont}family collection]%
  Browse \CTANref{cm-AMStype1}
\item[AMS \nothtml{\normalfont}font collection]%
  Browse \CTANref{ams-AMStype1}
\item[Belleek \nothtml{\normalfont}fonts]%
  \CTANref{belleek}
\item[CM-super \nothtml{\normalfont}collection]\CTANref{cm-super}
\item[eulervm.sty \nothtml{\normalfont}and supporting metrics]%
  \CTANref{eulervm}
\item[fourier \nothtml{\normalfont}(including metrics and other support for \nothtml{\itshape}utopia]%
  \CTANref{fourier}
\item[fouriernc]\CTANref{fouriernc}
\item[hfbright \nothtml{\normalfont}collection]\CTANref{hfbright}
\item[hvmath \nothtml{\normalfont\itshape}(free bitmapped version)]%
  \CTANref{hvmath}
\item[kpfonts \nothtml{\normalfont}family]\CTANref{kpfonts}
\item[Lucida Bright/Math metrics]\CTANref{lucida}
\item[Lucida PSNFSS support]\CTANref{lucida-psnfss}
\item[MathDesign \nothtml{\normalfont}collection]\CTANref{mathdesign}
\item[\nothtml{\normalfont}Maths Font Survey]\CTANref{mathsurvey.pdf}
  (\acro{PDF}) or \CTANref{mathsurvey.html} (\acro{HTML})
\item[Minion Pro support]\CTANref{minionpro}
\item[MnSymbol \nothtml{\normalfont}family]\CTANref{mnsymbol}
\item[pxfonts]\CTANref{pxfonts}
\item[tmmath \nothtml{\normalfont\itshape}(free bitmapped version)]%
  \CTANref{tmmath}
\item[txfonts]\CTANref{txfonts}
\item[utopia \nothtml{\normalfont}fonts]\CTANref{utopia}
\end{ctanrefs}

\Question[Q-charshift]{Weird characters in \ProgName{dvips} output}
\keywords{fi ligature pound pounds sterling elephants}

You've innocently generated output, using \ProgName{dvips}, and there
are weird transpositions in it: for example, the \texttt{fi} ligature has
appeared as a \textsterling{} symbol.
This is an unwanted side-effect of the precautions
outlined in \Qref*{generating \PS{} for PDF}{Q-dvips-pdf}.
The \texttt{-G1} switch discussed in that question is appropriate for
Knuth's text fonts, but doesn't work with text fonts that don't follow
Knuth's patterns (such as fonts supplied by Adobe).

If the problem arises, suppress the \texttt{-G1} switch: if you were using it
explicitly, \emph{don't}; if you were using \texttt{-Ppdf}, add \texttt{-G0} to
suppress the implicit switch in the pseudo-printer file.

The problem has been corrected in \ProgName{dvips} v~5.90 (and later
versions), which should be available in any recent \TeX{} distribution.

\subsection{Macros for using fonts}

\Question[Q-fonts-pln]{Using non-standard fonts in \plaintex{}}

\plaintex{} (in accordance with its description) doesn't do anything
fancy with fonts: it sets up the fonts that Knuth found he needed when
writing the package, and leaves you to do the rest.

To use something other than Knuth's default, the default mechanism is
to use the \csx{font} primitive:
\begin{quote}
\begin{verbatim}
\font\foo=nonstdfont
...
\foo
Text set using nonstdfont ...
\end{verbatim}
\end{quote}
The name you use (\texttt{nonstdfont}, above) is the name of the
\extension{tfm} file for the font you want.

If you want to use an italic version of \csx{foo}, you need to use
\csx{font} again:
\begin{quote}
\begin{verbatim}
\font\fooi=nonstdfont-italic
...
\fooi
Text set using nonstdfont italic...
\end{verbatim}
\end{quote}

This is all very elementary stuff, and serves for simple use of fonts.
However, there are wrinkles, the most important of which is the matter
of \Qref*{font encodings}{Q-whatenc}.  Unfortunately, many fonts that
have appeared recently simply don't come in versions using Knuth's
eccentric font encodings~--- but those encodings are built into
\plaintex{}, so that some macros of \plaintex{} need to be changed to
use the fonts.  \LaTeX{} gets around all these problems by using a
``font selection scheme''~--- this `\acro{NFSS}' (`\acro{N}' for
`new', as opposed to what \LaTeXo{} had) carries around with it
separate information about the fonts you use, so the changes to
encoding-specific commands happen automagically.

If you only want to use the \Qref*{\acro{EC} fonts}{Q-ECfonts}, you
can in principle use the \Package{ec-plain} bundle, which gives you a version
of \plaintex{} which you can run in the same way that you run
\plaintex{} using the original \acro{CM} fonts, by invoking
\ProgName{tex}.  (\Package{Ec-plain} also extends the \acro{EC} fonts,
for reasons which aren't immediately clear, but which might cause
problems if you're hoping to use Type 1 versions of the fonts.)

The \Package{font_selection} package provides a sort of halfway house:
it provides font face and size, but not family selection.  This gives
you considerable freedom, but leaves you stuck with the original
\acro{CM} fonts.  It's a compact solution, within its restrictions.

Other \plaintex{} approaches to the problem (packages
\Package{plnfss}, \Package{fontch} and \Package{ofs}) break out of the
\plaintex{} model, towards the sort of font selection provided by
\CONTeXT{} and \LaTeX{}~--- font selection that allows you to change
family, as well as size and face.  The remaining packages all make
provision for using encodings other than Knuth's \acro{OT}1.

\Package{Plnfss} has a rather basic set of font family details;
however, it is capable of using font description (\extension{fd}) files
created for \LaTeX{}.  (This is useful, since most modern mechanisms
for integrating outline fonts with \TeX{} generate \extension{fd} files
in their process.)

\Package{Fontch} has special provision for \acro{T}1 and \acro{TS}1
encodings, which you select by arcane commands, such as:
\begin{quote}
\begin{verbatim}
\let\LMTone\relax
\input fontch.tex
\end{verbatim}
\end{quote}
for \acro{T}1.

\Package{Ofs} seems to be the most thoroughly thought-through of the
alternatives, and can select more than one encoding: as well as
\acro{T}1 it covers the encoding \acro{IL}2, which is favoured in the
Czech Republic and Slovakia.  \Package{Ofs} also covers mathematical fonts,
allowing you the dubious pleasure of using fonts such as the % ! line break
\Qref*{\FontName{pxfonts} and \FontName{txfonts}}{Q-psfchoice}.

The \Package{pdcmac} \plaintex{} macro package aims to be a complete
document preparation environment, like \Qref*{\Eplain{}}{Q-eplain}.  One
of its components is a font selection scheme, \Package{pdcfsel}, which
is rather simple but adequately powerful for many uses.  The package
doesn't preload fonts: the user is required to declare the fonts the
document is going to use, and the package provides commands to select
fonts as they're needed.  The distribution includes a configuration to
use Adobe `standard' fonts for typesetting text.  (\Eplain{} itself
seems not to offer a font selection scheme.)
\begin{ctanrefs}
\item[ec-plain]\CTANref{ec-plain}
\item[fontch]\CTANref{fontch}
\item[font_selection]\CTANref{font_selection}
\item[ofs]\CTANref{ofs}
\item[pdcmac]\CTANref{pdcmac}
\item[plnfss]\CTANref{plnfss}
\end{ctanrefs}

\subsection{Particular font families}

\Question[Q-concrete]{Using the ``Concrete'' fonts}

The Concrete Roman fonts were designed by Don Knuth for a book called
``Concrete Mathematics'', which he wrote with Graham and Patashnik
(\emph{the} Patashnik, of \BibTeX{} fame).  Knuth
only designed text fonts, since the book used the Euler fonts for
mathematics.  The book was typeset using \plaintex{}, of course, with
additional macros that may be viewed in a file \File{gkpmac.tex},
which is available on \acro{CTAN}.

The packages \Package{beton}, \Package{concmath}, and
\Package{ccfonts} are \LaTeX{} packages that change the default text
fonts from Computer Modern to Concrete.  Packages \Package{beton} and
\Package{ccfonts} also slightly increase the default value of
\csx{baselineskip} to account for the rather heavier weight of the
Concrete fonts.  If you wish to use the \FontName{Euler} fonts for
mathematics, as Knuth did, there's the \Package{euler} package which
has been developed from Knuth's own \plaintex{}-based set: these
macros are currently deprecated (they clash with many things, including
\AMSLaTeX{}).  The independently-developed \Package{eulervm}
bundle is therefore preferred to the \Package{euler} package.  (Note
that installing the \Package{eulervm} bundle involves installing a
series of virtual fonts.  While most modern distributions seem to have
the requisite files installed by default, you may find you have to
install them.  If so, see the file \File{readme} in the
\Package{eulervm} distribution.)

A few years after Knuth's original design, Ulrik Vieth
designed the Concrete Math fonts.  Packages
\Package{concmath}, and \Package{ccfonts} also change the default math
fonts from Computer Modern to Concrete and use the Concrete versions
of the \acro{AMS} fonts (this last behaviour is optional in the case
of the \Package{concmath} package).

There are no bold Concrete fonts, but it is generally accepted that
the Computer Modern Sans Serif demibold condensed fonts are an
adequate substitute.  If you are using \Package{concmath} or
\Package{ccfonts} and you want to follow this suggestion, then use the
package with \pkgoption{boldsans} class option (in spite of the fact
that the \Package{concmath} documentation calls it
\pkgoption{sansbold} class option). If you are using \Package{beton},
add
\begin{quote}
  \cmdinvoke{renewcommand}{\csx{bfdefault}}{sbc}
\end{quote}
to the preamble of your document.

Type~1 versions of the fonts are available.  For \acro{OT}1 encoding,
they are available from \Qref*{MicroPress}{Q-psfchoice}.  The
\Qref*{CM-Super fonts}{Q-textrace} contain Type~1 versions
of the Concrete fonts in \acro{T}1 encoding.
\begin{ctanrefs}
\item[beton.sty]\CTANref{beton}
\item[ccfonts.sty]\CTANref{ccfonts}
\item[\nothtml{\rmfamily}CM-Super fonts]\CTANref{cm-super}
\item[concmath.sty]\CTANref{concmath}
\item[\nothtml{\rmfamily}Concmath fonts]\CTANref{concmath-f}
\item[\nothtml{\rmfamily}Concrete fonts]\CTANref{concrete}
\item[euler.sty]\CTANref{euler-latex}
\item[eulervm \nothtml{\rmfamily}bundle]\CTANref{eulervm}
\item[gkpmac.tex]\CTANref{gkpmac}
\end{ctanrefs}

\Question[Q-uselmfonts]{Using the Latin Modern fonts}

The \Package{lm} fonts are an exciting addition to
the armoury of the \AllTeX{} user: high quality outlines of fonts that
were until recently difficult to obtain, all in a free and
relatively compact package.  However, the spartan information file
that comes with the fonts remarks ``It is presumed that a potential
user knows what to do with all these files''.  This answer aims to
fill in the requirements: the job is really not terribly difficult.

Note that te\TeX{} distributions, from version~3.0, already have the
\Package{lm} fonts: all you need do is use them.  The fonts may also
be installed via the package manager, in a current \miktex{} system.
The remainder of this answer, then, is for people who don't use such
systems.

The font (and related) files appear on \acro{CTAN} as a set of
single-entry \Qref*{\acro{TDS} trees}{Q-tds}~---
\File{fonts}, \File{dvips}, \File{tex} and \File{doc}.  The \File{doc}
subtree really need not be copied (it's really a pair of sample
files), but copy the other three into your existing Local
\texttt{\$TEXMF} tree, and
% beware line break
\Qref*{update the filename database}{Q-inst-wlcf}.

Now, incorporate the fonts in the set searched by \PDFLaTeX{},
\ProgName{dvips}, \ProgName{dvipdfm}, your previewers and
Type~1-to-\acro{PK} conversion programs, by
\begin{itemize}
\item On a te\TeX{} system earlier than version~2.0, edit the file
  \File{$TEXMF/dvips/config/updmap} and insert an absolute path for
  the \File{lm.map} just after the line that starts
  \texttt{extra\_modules="} (and before the closing quotes).
\item On a te\TeX{} version~2.0 (or later), execute the command
\begin{verbatim}
  updmap --enable Map lm.map
\end{verbatim}
\item On a \miktex{} system earlier than version~2.2, the ``Refresh
  filename database'' operation, which you performed after installing
  files, also updates the system's ``\PS{} resources database''.
\item On a \miktex{} system, version~2.2 or later, update
  \File{updmap.cfg} as described in the \miktex{} % beware line break
  \href{http://docs.miktex.org/manual/psfonts.html#chgupdmapcfg}{online documentation}.
  Then execute the command \texttt{initexmf -\relax-mkmaps}, and the
  job is done.
\end{itemize}

To use the fonts in a \LaTeX{} document, you should
\begin{quote}
  \cmdinvoke{usepackage}{lmodern}
\end{quote}
this will make the fonts the default
for all three \LaTeX{} font families (``roman'', ``sans-serif'' and
``typewriter'').  You also need 
\begin{quote}
  \cmdinvoke{usepackage}[T1]{fontenc}
\end{quote}
for text, and 
\begin{quote}
  \cmdinvoke{usepackage}{textcomp}
\end{quote}
if you want to use any of the \acro{TS}1-encoding symbols.  There is
no support for using fonts according to the \acro{OT}1 encoding.
\begin{ctanrefs}
\item[\nothtml{\rmfamily}Latin Modern fonts]\CTANref{lm}
\end{ctanrefs}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\section{Hypertext and \acro{PDF}}

\Question[Q-hyper]{Making hypertext documents from \TeX{}}

If you want on-line hypertext with a \AllTeX{} source, probably on the
World Wide Web, there are four technologies to consider:
\begin{itemize}
\item Direct \Qref{\AllTeX{} conversion to \acro{HTML}}{Q-LaTeX2HTML};
% beware line break
\item Use \Qref*{\Package{Texinfo}}{Q-texinfo},
  and use the \ProgName{info} viewer, or convert the \Package{texinfo}
  to \acro{HTML};
\item Use Adobe Acrobat, which will preserve your typesetting
  perfectly
  \Qref*{Making Acrobat \acro{PDF} documents from \LaTeX{}}{Q-acrobat};
\item The hyper\TeX{} conventions (standardised \csx{special}
  commands); there are supporting macro packages for \plaintex{} and
  \LaTeX{}).
\end{itemize}

The Hyper\TeX{} project extended the functionality of all the
\LaTeX{} cross-referencing commands (including the table of contents)
to produce \csx{special} commands which are parsed by \acro{DVI} processors
conforming to the Hyper\TeX{} guidelines;
it provides general hypertext links, including those
to external documents.

The Hyper\TeX{} specification says that conformant viewers/translators
must recognize the following set of \csx{special} commands:
\begin{description}
\item[href:] |html:<a href = "href_string">|
\item[name:] |html:<a name = "name_string">|
\item[end:] |html:</a>|
\item[image:] |html:<img src = "href_string">|
\item[base\_name:] |html:<base href = "href_string">|
\end{description}

The \emph{href}, \emph{name} and \emph{end} commands are used to do
the basic hypertext operations of establishing links between sections
of documents. 

Further details are available on \URL{http://arXiv.org/hypertex/}; there
are two commonly-used implementations of the specification, a
modified \ProgName{xdvi} and (recent releases of)
\ProgName{dvips}. Output from the latter may be used in recent
releases of \ProgName{ghostscript} or Acrobat Distiller.

\Question[Q-acrobat]{Making Acrobat \acro{PDF} documents from \AllTeX{}}

There are three general routes to \acro{PDF} output: Adobe's original
`distillation' route (via \PS{} output), conversion of a
\acro{DVI} file, and the use of a direct \acro{PDF} generator such as
\Qref*{\PDFTeX{}}{Q-whatpdftex}) or
MicroPress's V\TeX{} (which comes both as a % ! line break
\Qref*{commercial version}{Q-commercial} for Windows PCs, and as a
\Qref*{`free' version)}{Q-TeXsystems} for \acro{OS}/2 and Linux systems).

For simple documents (with no hyper-references), you can either
\begin{itemize}
\item process the document in the normal way, produce \PS{}
  output and distill it;
\item (on a Windows or Macintosh machine with the appropriate Adobe
  tools installed) pass the output through the
  \acro{PDF}writer in place of a printer driver (this route is a dead
  end: the \acro{PDF}writer cannot create hyperlinks);
\item process the document in the normal way and generate \acro{PDF}
  direct from the \acro{DVI} using
  \ProgName{dvipdfm}/\ProgName{dvipdfmx}; or 
\item process the document direct to \acro{PDF} with \PDFTeX{} or
  V\TeX{}.  \PDFTeX{} has
  the advantage of availability for a wide range of platforms, V\TeX{}
  (available commercially for Windows, or free of charge, but
  unsupported, for Linux or \acro{OS/}2) has wider graphics
  capability, dealing with encapsulated \PS{} and some in-line \PS{}.
\end{itemize}

To translate all the \LaTeX{} cross-referencing into Acrobat
links, you need a \LaTeX{} package to suitably redefine
the internal commands.  There are two of these for \LaTeX{}, both
capable of conforming to the
\Qref{Hyper\TeX{} specification}{Q-hyper}:
Heiko Oberdiek's \Package{hyperref}, and Michael Mehlich's
\Package{hyper}.  (In practice, almost everyone uses
\Package{hyperref}; \Package{hyper} hasn't been updated since 2000.)
\Package{Hyperref} can often determine how it should generate
hypertext from its environment, but there is a wide set of
configuration options you can give via \csx{usepackage}.  The package
can operate using \PDFTeX{} primitives, the hyper\TeX{}
\csx{special}s, or \acro{DVI} driver-specific \csx{special} commands.
Both \ProgName{dvips} and \YandY{}'s \acro{\ProgName{DVIPSONE}} can
translate the \acro{DVI} with these \csx{special} commands into
\PS{} acceptable to Distiller, and \ProgName{dvipdfm} has \csx{special}
commands of its own.

If you use \plaintex{}, the \Qref*{\Eplain{} macros}{Q-eplain} can
help you create \acro{PDF} documents with hyper-references.
It can operate using \PDFTeX{} primitives, or \csx{special} commands
for the \ProgName{dvipdfm} \acro{DVI} driver.

While there is no free implementation of all of \ProgName{Adobe}
\ProgName{Distiller}'s
functionality, any but the very oldest versions of \ProgName{Ghostscript}
provide pretty reliable distillation (but beware of the problems with
\Qref*{\ProgName{dvips} output for distillation}{Q-dvips-pdf}).

For viewing (and printing) the resulting files, Adobe's
\ProgName{Acrobat} \ProgName{Reader} is available for a fair range of
platforms; for those for which Adobe's reader is unavailable, remotely
current versions of \ProgName{ghostscript} combined with
\ProgName{gv}, \ProgName{GSview} (or even the unsupported
\ProgName{ghostview}) can display and print \acro{PDF} files, as can
\ProgName{xpdf}.

In many circumstances, \ProgName{Ghostscript} combined with a viewer
application is actually preferable to Acrobat Reader.  For example, on
Windows Acrobat Reader locks the \extension{pdf} file it's displaying: this
makes the traditional (and highly effective) \AllTeX{} development
cycle of ``Edit\arrowhyph{}Process\arrowhyph{}Preview'' become
rather clumsy~--- \ProgName{GSview} doesn't make the same
mistake.
\begin{ctanrefs}
\item[\nothtml{\rmfamily}Acrobat Reader]browse
  \URL{ftp://ftp.adobe.com/pub/adobe/acrobatreader}
\item[dvipdfm]\CTANref{dvipdfm}
\item[dvipdfmx]\CTANref{dvipdfmx}
\item[ghostscript]Browse \CTANref{ghostscript}
\item[ghostview]Browse \CTANref{ghostview}
\item[GSview]Browse \CTANref{gsview}
\item[gv]\CTANref{gv}
\item[hyper.sty]\CTANref{hyper}
\item[hyperref.sty]\CTANref{hyperref}
\end{ctanrefs}

\Question[Q-dvips-pdf]{Quality of \acro{PDF} from \PS{}}
\keywords{blurry fuzzy crippled}

Any reasonable \PS{}, including any output of \ProgName{dvips}, may be
converted to \acro{PDF}, using (for example) a sufficiently recent
version of \ProgName{ghostscript}, Frank Siegert's (shareware)
\href{http://www.pstill.com/}{\ProgName{PStill}}, or Adobe's (commercial)
\ProgName{Distiller}.

But, although the job may (almost always) be done, the results are
often not acceptable: the most frequent problem is bad presentation of
the character glyphs that make up the document.  The following answers
offer solutions to this (and other) problems of bad presentation.
Issues covered are:
\begin{itemize}
\item \Qref*{Wrong type of fonts used}{Q-fuzzy-type3}, which is
  the commonest cause of fuzzy text.
\item \Qref*{\ProgName{Ghostscript} too old}{Q-fuzzy-gs},
  which can also result in fuzzy text.
% beware line breaks
\item \Qref*{Switching to font encoding \acro{T}1 encoding}{Q-fuzzy-T1},
  which is yet another possible cause of fuzzy text.
\item Another problem~--- missing characters~--- arises from an
  % beware line breaks
  \Qref*{aged version of \ProgName{Adobe}~\ProgName{Distiller}}{Q-distill-prob}.
\item Finally, there's the common confusion that arises from using the
  \ProgName{dvips} configuration file \texttt{-Ppdf}, the % ! line br
  \Qref*{weird characters}{Q-charshift}.
\end{itemize}
It should be noted that \ProgName{Adobe} % \ProgName{Acrobat} no longer
                                         % part of the name
\ProgName{Reader}~6 (released in mid-2003, and later versions) does
not exhibit the ``fuzziness'' that so many of the answers below
address.  This is of course good news: however, it will inevitably be
a long time before every user in the world has this (or later)
versions, so the remedies below are going to remain for some time to
come.

The problems are also discussed, with practical examples, in Mike
Shell's \Package{testflow} package, which these FAQs recommend as a
``\Qref*{specialised tutorial}{Q-tutbitslatex}.
\begin{ctanrefs}
\item[testflow]\CTANref{testflow}
\end{ctanrefs}

\Question[Q-fuzzy-type3]{The wrong type of fonts in \acro{PDF}}
\keywords{crippled blurry}

This is far the commonest problem: the symptom is that text in the
document looks ``fuzzy''.

Most people use \ProgName{Adobe} \ProgName{Acrobat} \ProgName{Reader}
to view their \acro{PDF}: \ProgName{Reader} is distributed free of
charge, and is widely available, for all its faults.  One of those
faults is its failure to deal with bitmap fonts (at least, in all
versions earlier than the recently released version~6).

So we don't want bitmap fonts in our \PS{}: with them, characters show
up in \ProgName{Reader}'s display as blurred blobs which are often not
recognisable as the original letter, and are often not properly placed
on the line.  Nevertheless, even now, most \TeX{} systems have
\ProgName{dvips} configured to use
\Qref*{\extension{pk} files}{Q-pk} in its output.  Even
\PDFTeX{} will use \extension{pk} files if it can see no alternative for
a font in the document it is processing.

Our remedy is to use
``\Qref*{Adobe Type~1}{Q-adobetypen}''
versions of the fonts we need.  Since Adobe are in the
business of selling Type~1 fonts, \ProgName{Reader} was of course made
to deal with them really rather well, from the very beginning.

Of course, if your document uses nothing but fonts that came from
Adobe in the first place~--- fonts such as \FontName{Times} that
appear in pretty much every \PS{} printer, or such as Adobe
\FontName{Sabon} that you pay extra for~--- then there's no problem.

But most people use \FontName{Computer} \FontName{Modern} to start
with, and even those relative sophisticates who use something as
exotic as \ProgName{Sabon} often find themselves using odd characters
from \acro{CM} without really intending to do so.  Fortunately, rather
good versions of the \acro{CM} fonts are available from the \acro{AMS}
(who have them courtesy of % ! line break
\Qref{Blue Sky Research}{Q-commercial} and \YandY{}).

Most modern systems have the fonts installed ready to use; and any
system installed less than 3~years ago has a \ProgName{dvips}
configuration file `\texttt{pdf}' that signals the use of the
\acro{CM} fonts, and also sets a few other parameters to improve
\ProgName{dvips}' output.  Use this configuration as:
\begin{verbatim}
  dvips -Ppdf myfile -o myfile.ps
\end{verbatim}
This may produce a warning message about failing to find the
configuration file:
\begin{verbatim}
  dvips: warning: no config file for `pdf'
\end{verbatim}
or something similar, or about failing to find a font file:
\begin{verbatim}
  dvips: ! Couldn't find header file cmr10.pfb
\end{verbatim}
Either of these failures signals that your
system doesn't have the fonts in the first place.

A way of using the fonts that doesn't involve the sophistication of
the \texttt{-Ppdf} mechanism is simply to load maps:
\begin{verbatim}
  dvips -Pcmz -Pamz myfile -o myfile.ps
\end{verbatim}
You may encounter the same warning messages as listed above.

If your system does not have the fonts, it won't have the
configuration file either; however, it might have the configuration
file without the fonts.  In either case, you need to
\Qref*{install the fonts}{Q-inst1cm}.

\Question[Q-fuzzy-gs]{Fuzzy fonts because \ProgName{Ghostscript} too old}
\keywords{crippled blurry}

So you've done everything the \acro{FAQ} has told you that you need,
correct fonts properly installed and appearing in the \ProgName{dvips}
output, but \emph{still} you get fuzzy character output after
distilling with \ProgName{ghostscript}.

The problem could arise from too old a version of
\ProgName{ghostscript}, which you may be using directly, or via a
script such as \ProgName{ps2pdf} (distributed with
\ProgName{ghostscript} itself), \ProgName{dvipdf}, or similar.
Though \ProgName{ghostscript} was capable of distillation from
version~5.50, that version could only produce bitmap Type~3 output of
any font other than the fundamental 35~fonts (\FontName{Times},
\FontName{Helvetica}, etc.).  Later versions added `complete'
distillation, but it wasn't until version~6.50 that one could rely on
it for everyday work.

So, if your \acro{PDF}  output still looks fuzzy in \ProgName{Acrobat}
\ProgName{Reader}, upgrade \ProgName{ghostscript}.  The new version
should be at least version~6.50, of course, but it's usually good
policy to go to the most recent version (version~8.12 at the time of
writing~--- 2003).

\Question[Q-fuzzy-T1]{Fonts go fuzzy when you switch to \acro{T}1}
\keywords{crippled blurry}

You've been having problems with hyphenation, and someone has
suggested that you should use ``\cmdinvoke{usepackage}[T1]{fontenc}''
to help sort them out.  Suddenly you find that your final \acro{PDF}
has become fuzzy.  The problem may arise whether you are using \PS{}
output and then distilling it, or you are using \PDFTeX{} for the
whole job.

In fact, this is the same problem as most others about the
\Qref*{quality of \acro{PDF}}{Q-dvips-pdf}: you've abandoned
your previous setup using Type~1 versions of the \acro{CM} fonts, and
\ProgName{dvips} has inserted Type~3 versions of the \acro{EC} fonts
into your document output.  (See % beware line break
``\Qref*{Adobe font types}{Q-adobetypen}
for details of these font types; also, note that the font
\emph{encoding}~\acro{T}1
has nothing directly to do with the font \emph{format}~Type~1).

However, as noted in % beware line break
\htmlonly{``}\Qref[question]{8-bit Type~1 fonts}{Q-type1T1}\htmlonly{''},
Type~1 versions of \acro{CM}-like fonts in \acro{T}1 (or equivalent) encoding
are now available, both as ``real'' fonts, and as virtual font sets.
One solution, therefore, is to use one of these alternatives.

The alternative is to switch font family altogether, to something like
\FontName{Times} (as a no-thought default) or one of the many more pleasing
Adobe-encoded fonts.  The default action of \Package{fontinst}, when
creating metrics for such a font, is to create settings for both \acro{OT}1
and \acro{T}1 encodings, so there's little change in what goes on (at the
user level) even if you have switched to \acro{T}1~encoding when using the
fonts.

\Question[Q-distill-prob]{Characters missing from \acro{PDF} output}

If you're using \ProgName{Acrobat} \ProgName{Distiller} to create your
\acro{PDF} output, you may find
characters missing.  This may manifest
itself as messed-up maths equations (missing
``\latexhtml{\ensuremath{-}}{-}'' signs, for example), or bits missing
from large symbols.  Early versions of \ProgName{Distiller} used to
ignore character positions 0--31 and 128--159 of every font: Adobe's
fonts never use such positions, so why should \ProgName{Distiller}?

Well, the answer to this question is ``because Adobe don't produce all
the world's fonts''~--- fonts like \FontName{Computer}
\FontName{Modern} were around before Adobe came on the scene, and
\emph{they} use positions 0--31.  Adobe don't react to complaints like
that in the previous sentence, but they do release new versions of
their programs; and \ProgName{Distiller}, since at least version~4.0,
\emph{has} recognised the font positions it used to shun.

Meanwhile, \TeX{} users with old versions of \ProgName{Distiller} need
to deal with their fonts.  \ProgName{Dvips} comes to our aid: the
switch \texttt{-G1} (``remap characters''), which moves the offending
characters out of the way.  The \acro{PDF} configuration file
(\texttt{-Ppdf}), recommended % beware line break
\latexhtml{above}{in ``\Qref{the wrong type of fonts}{Q-fuzzy-type3}''},
includes the switch.

The switch is not without its problems; pre-2003 versions of
\ProgName{dvips} will apply it to Adobe fonts as well, causing
\Qref*{havoc}{Q-charshift}, but fortunately
that problem is usually soluble.  However, a document using both
\acro{CM} and Adobe-specified fonts is stuck.  The only real solution
is either to upgrade \ProgName{dvips}, or to spend money to upgrade
\ProgName{Distiller}.

\Question[Q-type1T1]{Finding `8-bit' Type~1 fonts}
\keywords{eight}

Elsewhere, answers to these \acro{FAQ}s recommend that you use an
`8-bit' font to permit % line break!!
\Qref*{accentuation of inflected languages}{Q-hyphenaccents},
and also recommend the use of Type~1 fonts to ensure that
you get \Qref*{good quality \acro{PDF}}{Q-fuzzy-type3}.  These
recommendations used to be contradictory: one could not just
``switch'' from the free \acro{CM} fonts to free Cork- (or similarly)
encoded Type~1 fonts.  The first approach that started to alleviate
these problems, was the development of virtual fonts that make
a good approach to the Cork encoding (see below).  Now, however, we
have ``true'' Type~1 fonts available: as always, we have an
embarrassment of riches with three free alternatives, and one
commercial and one shareware version.

\Package{CM-super} is an
auto-traced set which encompasses all of the \acro{T}1 and \acro{TS}1
encodings as well as the \acro{T}2* series (the family of encodings
that cover languages based on Cyrillic alphabets).  These fonts are
pretty easy to install (the installation instructions are clear), but
they are huge: don't try to install them if you're short of disc
space.

\Package{CM-LGC} is a similar ``super-font'' set, but of much more
modest size; it covers \acro{T}1, \acro{TS}1 and \acro{T}2{A}
encodings (as does \Package{CM-super}, and also covers the \acro{LGR}
encoding (for typesetting Greek, based on Claudio Beccari's \MF{}
sources).  \Package{CM-LGC} manages to be small by going to the
opposite extreme from \Package{CM-super}, which includes fonts at all
the sizes supported by the original \acro{EC} (a huge range);
\Package{CM-LGC} has one font per font shape, getting other sizes by
scaling.  There is an inevitable loss of quality inherent in this
approach, but for the disc-space-challenged machine, \Package{CM-LGC}
is an obvious choice.

\Package{Tt2001} is a simple scan of the \acro{EC} and \acro{TC}
fonts, and has some virtues~--- it's noticeably smaller than
\Package{CM-super} while being less stark than \Package{CM-LGC}.

\Package{Latin} \Package{Modern} is produced using the
program \Qref*{\ProgName{MetaType1}}{Q-textrace}.  The
\Package{Latin} \Package{Modern} set comes with \acro{T}1, \acro{TS}1
\acro{LY}1 encoded variants (as well as a variant using the Polish
\acro{QX} encoding); for the glyph set it covers, its outlines seem
rather cleaner than those of \Package{CM-super}.  \Package{Latin}
\Package{Modern} is more modest in its disc space demands than is
\Package{CM-super}, while not being nearly as stark in its range of
design sizes as is \Package{CM-LGC}~---  \Package{Latin}
\Package{Modern}'s fonts are offered in the same set of sizes as the
original \Package{CM} fonts.  It's hard to argue with the choice:
Knuth's range of sizes has stood the test of time, and is one of the
bases on which the excellence of the \TeX{} system rests.

\Qref*{Virtual fonts}{Q-virtualfonts} help us deal with the problem,
since they allow us to map ``bits of \acro{DVI} file'' to single
characters in the virtual font; so we can create an ``\'e'' character
by recreating the \acro{DVI} commands that would result from the code
``\csx{'}\texttt{e}''.  However, since this involves two characters being
selected from a font, the arrangement is sufficient to fool
\ProgName{Acrobat} \ProgName{Reader}: you can't use the program's
facilities for searching for text that contains inflected characters,
and if you \emph{cut} text from a window that contains such a
character, you'll find something unexpected (typically the accent and
the `base' characters separated by a space) when you \ProgName{paste}
the result.  However, if you can live with this difficulty, virtual
fonts are a useful and straightforward solution to the problem.

There are two virtual-font offerings of \acro{CM}-based 8-bit
fonts~--- the \Package{ae} (``almost \acro{EC}'') and
\Package{zefonts} sets; the \Package{zefonts} set has wider coverage
(though the \Package{ae} set may be extended to offer guillemets by
use of the \Package{aeguill} package).  Neither offers characters such
as \texttt{eth} and \texttt{thorn} (used in, for example, in
Icelandic), but the \Package{aecompl} package works with the
\Package{ae} fonts to provide the missing characters from the
\acro{EC} fonts (i.e., as bitmaps).

The sole remaining commercial \acro{CM}-like 8-bit font comes from
Micropress, who offer the complete \acro{EC} set
in Type~1 format, as part of their range of outline versions of fonts
that were originally distributed in \MF{} format.  See
\Qref[question]{``commercial distributions''}{Q-commercial}.

The shareware % ! line break
\Qref*{BaKoMa \TeX{} distribution}{Q-TeXsystems} offers a
set of Type~1 \acro{EC} fonts, as an extra shareware option.  (As far
as the present author can tell, these fonts are \emph{only} available
to users of BaKoMa \TeX{}: they are stored in an archive format that
seems not to be publicly available.)

Finally, you can use one of the myriad text fonts available in Type~1
format (with appropriate \acro{PSNFSS} metrics for \acro{T}1 encoding,
or metrics for some other 8-bit encoding such as \acro{LY}1).  However,
if you use someone else's text font (even something as simple as
Adobe's Times family) you have to find a matching family of
mathematical fonts, which is a non-trivial undertaking~---
\htmlonly{see }\Qref{``choice of scalable fonts''}{Q-psfchoice}.
\begin{ctanrefs}
\item[\nothtml{\rmfamily}ae fonts]\CTANref{ae}
\item[aecompl.sty]Distributed with \CTANref{ae}
\item[aeguill.sty]\CTANref{aeguill}
\item[\nothtml{\rmfamily}BaKoMa fonts]Browse \CTANref{bakoma-texfonts}
\item[\nothtml{\rmfamily}CM-LGC fonts]\CTANref{cm-lgc}
\item[\nothtml{\rmfamily}CM-super fonts]\CTANref{cm-super} (beware:
  very large download)
\item[\nothtml{\rmfamily}Latin Modern fonts]\CTANref{lm}
\item[\nothtml{\rmfamily}tt2001 fonts]\CTANref{tt2001}
\item[\nothtml{\rmfamily}zefonts]\CTANref{zefonts}
\end{ctanrefs}

\Question[Q-pkfix]{Replacing Type 3 fonts in \PS{}}

One often comes across a \PS{} file generated by
\ProgName{dvips} which contains embedded \acro{PK} fonts; if you try
to generate \acro{PDF} from such a file, the quality will be poor.

Of course, the proper solution is to regenerate the \PS{} file,
but if neither the sources nor the \acro{DVI} file are available, one
must needs resort to some sort of patching to replace the bitmap fonts
in the file by outline fonts.

The program \ProgName{pkfix} (by Heiko Oberdiek) will do this
patching, for files created by ``not too old versions'' of
\ProgName{dvips}: it finds the fonts to be replaced by examining the
\PS{} comments \ProgName{dvips} has put in the file.  For each
font, \ProgName{pkfix} puts appropriate \TeX{} commands in a file,
which it then processes and runs through \ProgName{dvips} (with switch
\texttt{-Ppdf}) to acquire an appropriate copy of the font; these copies are
then patched back into the original file.

If your source file is older than \ProgName{pkfix} can deal with,
there's still a modicum of hope: \ProgName{pkfix-helper} examines the
bitmap fonts in a document, compares them with the metric
(\extension{tfm}) fonts on your system and comes to a view of which
font might be which.  The program reports on ``poor'' matches, and
there are options for confirming, or replacing, its guesses.  The
technique (which sounds implausible) is successful enough to be worth
a try.

A further option is Frank Siegert's (shareware)
\href{http://www.pstill.com}{PStill}, which is capable of processing
the \PS{} it is distilling, and one option is to replace bitmap fonts
in the file with Type~1 versions.
\begin{ctanrefs}
\item[pkfix]\CTANref{pkfix}
\item[pkfix-helper]\CTANref{pkfix-helper}
\end{ctanrefs}

\Question[Q-pdfpagelabels]{\Package{Hyperref} and repeated page numbers}

The \Class{book} class (and its friends and relations) automatically
changes the display of page numbers in the frontmatter of the document
to lower-case roman.  This is fine for human readers, but it confuses
\Package{hyperref} since there are pages which seem (to
\Package{hyperref}) to have the same page number.  Fortunately, there are
configuration options to make \Package{hyperref} ``do the right
thing''.

The two options in question are:
\begin{description}
\item[\pkgoption{plainpages=false}] Make page anchors using the
  formatted form of the page number.  With this option,
  \Package{hyperref} writes different anchors for pages `ii' and `2'.
  (If the option is set `\texttt{true}'~--- the default~---
  \Package{hyperref} writes page anchors as the arabic form of the
  absolute page number, rather than the formatted form.)
\item[\pkgoption{pdfpagelabels}] Set \acro{PDF} page labels; i.e.,
  write the value of \csx{thepage} to the \acro{PDF} file so that
  \Package{Acrobat Reader} can display the page number as (say) `ii (4
  of 40)' rather than simply `4 of 40'.
\end{description}
The two should be used whenever page numbering is not just
`1\texttt{..}\ensuremath{n}'; they may be used independently, but usually are not.

The recipe isn't perfect: it relies on \csx{thepage} being different
for every page in the document.  A common problem arises when there is
an unnumbered title page, after which page numbers are reset: the
\PDFTeX{} warning of ``\Qref*{duplicate destinations}{Q-hyperdupdest}''
will happen in this case, regardless of the options.
\begin{ctanrefs}
\item[hyperref.sty]\CTANref{hyperref}
\end{ctanrefs}

\Question[Q-srchpdf]{Searching \acro{PDF} files}

In principle, you can search a \acro{PDF} file: the text of the file
is available to the viewer, and at least some viewers provide a search
facility.  (It's not the fastest thing in the world, but it does help
in some circumstances.)

However, there is a problem: the viewer wants to look at Unicode text,
but no ordinary \TeX{}-based system deals in Unicode text.
Fortunately for us Anglophones, this is is hardly ever a problem for
our text, since even Knuth's ``\acro{OT}1'' encoding matches ASCII (and hence
the lowest 128 characters of Unicode) for most things printable.
However, using the inflected characters of Continental European
languages, or anything that doesn't use a Latin alphabet, there is
potential for problems, since \TeX{}'s view of what a font is doesn't
map \acro{PDF}'s and the reader won't understand\dots{}

\dots{} Unless you use the \Package{cmap} package with \PDFLaTeX{},
that is.  The package will instruct \PDFTeX{} to load character
maps into your \acro{PDF} for output fonts encoded according to the \acro{T}1
(Western European Languages), T2A, T2B, or T2C (Cyrillic Languages),
or T5 (Vietnamese) encodings.  If your document uses such encodings,
viewers that can search will use the maps to interpret what they find
in the file.

Unfortunately, the package only works with fonts that are directly
encoded, such as the \FontName{cm-super} distribution.  Fonts like Adobe
Times Roman (which are encoded for \AllTeX{} use via virtual fonts)
are not amenable to this treatment.
\begin{ctanrefs}
\item[cmap.sty]\CTANref{cmap}
\item[cm-super \nothtml{\rmfamily}fonts]\CTANref{cm-super}
\end{ctanrefs}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\section{Graphics}

\Question[Q-impgraph]{How to import graphics into \AllTeX{} documents}

Knuth, when designing the current version of \TeX{} back in the early
1980s, could discern no ``standard'' way of expressing graphics in
documents.  He reasoned that this state could not persist for ever,
but that it would be foolish for him to define \TeX{} primitives that
allowed the import of graphical image definitions.  He therefore
deferred the specification of the use of graphics to the writers of
\acro{DVI} drivers; \TeX{} documents would control the drivers by
means of \nothtml{\csx{special} commands (}% beware line breaks
\Qref{\csx{special} commands}{Q-specials}\nothtml{)}.

There is therefore a straightforward way for anyone to import graphics
into their document: read the specification of the \csx{special}
commands your driver uses, and `just' code them.  This is the
hair-shirt approach: it definitely works, but it's not for everyone.

Over the years, therefore, ``graphics inclusion'' packages have sprung
up; most were designed for inclusion of
\nothtml{Encapsulated \PS{} graphics (}% beware line break
\Qref{Encapsulated \PS{} graphics}{Q-eps}\nothtml{)}\nobreakspace---
which has become the \emph{lingua franca} of graphics inclusion over
the last decade or so.

Notable examples are the \Package{epsf} package (distributed with
\ProgName{dvips}) and the \Package{psfig} package.  (Both of these
packages were designed to work well with both \plaintex{} and
\LaTeXo{}; they are both still available.)  All such packages were
tied to a particular \acro{DVI} driver (\ProgName{dvips}, in
the above two cases), but their code could be configured for others.

The obvious next step was to make the code configurable dynamically.
The \LaTeX{} standard \Package{graphics} package and its derivatives
made this step: it is strongly preferred for all current work.  It can
also be used (with the help of the \Package{miniltx} ``\LaTeX{}
emulator'' and the \Package{graphicx.tex} front-end) in documents
written in \plaintex{}.

The \Package{graphics} package takes a variety of ``driver
options''~--- package options that select code to generate the
commands appropriate to the \acro{DVI} driver in use.  In most cases,
your \AllTeX{} distribution will provide a \File{graphics.cfg} file
that will select the correct driver for what you're doing (for
example, a distribution that provides both \LaTeX{} and \PDFLaTeX{}
will usually provide a configuration file that determines whether
\PDFLaTeX{} is running, and selects the definitions for it if so).

The \Package{graphics} package provides a toolkit of commands (insert
graphics, scale a box, rotate a box), which may be composed to provide
most facilities you need; the basic command, \csx{includegraphics},
takes one optional argument, which specifies  the bounding box of the
graphics to be included.

The \Package{graphicx} package uses the facilities of of
\Package{graphics} behind a rather more sophisticated command syntax
to provide a very powerful version of the \csx{includegraphics}
command.  \Package{graphicx}'s version can combine scaling and
rotation, viewporting and clipping, and many other things.  While this
is all a convenience (at some cost of syntax), it is also capable of
producing noticeably more efficient \PS{}, and some of its
combinations are simply not possible with the \Package{graphics}
package version.

The \Package{epsfig} package provides the same facilities as
\Package{graphicx}, but via a \csx{psfig} command (also known as
\csx{epsfig}), capable of emulating
the behaviour (if not the bugs) the old \Package{psfig} package.
\Package{Epsfig} also supplies homely support for former users of the
\Package{epsf} package.  However, there's a support issue: if you
declare you're using \Package{epsfig}, any potential mailing list or
usenet helper has to clear out of the equation the possibility that
you're using ``old'' \Package{epsfig}, so that support is slower
coming than it would otherwise be.

There is no rational reason to stick with the old packages, which have
never been entirely satisfactory in the \LaTeX{} context. (One
irrational reason to leave them behind is that their replacement's
name tends not to imply that it's exclusively related to \PS{}
graphics.  The reasoning also excludes \Package{epsfig}, of course.)

A wide variety of detailed techniques and tricks have been developed
over the years, and Keith Reckdahl's \Package{epslatex} outlines them
in compendious detail: this highly recommendable document is available
from \acro{CTAN}.  An invaluable review of the practicalities of
exchanging graphics between sites,
% beware multiple line break problems
\begin{wideversion} % hyperversion
``\href{http://silas.psfc.mit.edu/elec_fig/elec_figures.pdf}{Graphics for Inclusion in Electronic Documents}''
\end{wideversion}
\begin{narrowversion} % non-hyper
\href{http://silas.psfc.mit.edu/elec_fig/elec_figures.pdf}%
     {``Graphics for Inclusion in Electronic Documents''}
\end{narrowversion}
has been written by Ian Hutchinson; the document isn't on \acro{CTAN},
but may also be
% beware line breaks
\href{http://silas.psfc.mit.edu/elec_fig/}{browsed on the Web}.
\begin{ctanrefs}
\item[epsf.tex]\CTANref{epsf}
\item[epsfig.sty]Part of the \CTANref{graphics} bundle
\item[epslatex.pdf]\CTANref{epslatex_pdf}; the document is also available
  in \PS{} format as \CTANref{epslatex_ps}
\item[graphics.sty]\CTANref{graphics}
\item[graphicx.sty]Part of the \CTANref{graphics} bundle
\item[miniltx.tex]\CTANref{graphics-plain}
\item[psfig.sty]\CTANref{psfig}
\end{ctanrefs}

\Question[Q-dvipsgraphics]{Imported graphics in \ProgName{dvips}}

\ProgName{Dvips}, as originally conceived, can only import a single
graphics format: \nothtml{encapsulated \PS{} (\extension{eps} files, }%
\Qref{encapsulated \PS{}}{Q-eps}\htmlonly{ (\extension{eps} files}).
\ProgName{Dvips} also deals with the slightly eccentric \acro{EPS} that is
created by \Qref*{\MP{}}{Q-MP}.

Apart from the fact that a depressing proportion of drawing
applications produce corrupt \acro{EPS} when asked for such output,
this is pretty satisfactory for vector graphics work.

To include bitmap graphics, you need some means of converting them to
\PS{}; in fact many standard image manipulators (such as
\ProgName{ImageMagick}'s \ProgName{convert}) make a good job of
creating \acro{EPS} files (but be sure to ask for output at \PS{}
level~2 or higher).  (\ProgName{Unix} users should beware of
\ProgName{xv}'s claims: it has a tendency to downsample your bitmap to
your screen resolution.)

Special purpose applications \ProgName{jpeg2ps} (which converts
\acro{JPEG} files using \PS{} level 2 functionality),
\ProgName{bmeps} (which converts both \acro{JPEG} and \acro{PNG}
files) and \ProgName{a2ping}/\ProgName{sam2p} (which convert a
bewildering array of bitmap formats to \acro{EPS} or \acro{PDF} files;
\ProgName{sam2p} is one of the engines that \ProgName{a2ping} uses)
are also considered ``good bets''.

\ProgName{Bmeps} comes with patches to produce your own version of
\ProgName{dvips} that can cope with \acro{JPEG} and \acro{PNG} direct,
using \ProgName{bmeps}'s conversion library.  \ProgName{Dvips}, as
distributed by \miktex{}, comes with those patches built-in, but
assuming that capability destroys portability, and is only
recommendable if you are sure you will never want to share your
document.
\begin{ctanrefs}
\item[a2ping]\CTANref{a2ping}
\item[bmeps]\CTANref{bmeps}
\item[jpeg2ps]\CTANref{jpeg2ps}
\item[sam2p]\CTANref{sam2p}
\end{ctanrefs}

\Question[Q-pdftexgraphics]{Imported graphics in \PDFLaTeX{}}

\PDFTeX{} itself has a rather wide range of formats that it can
``natively'' incorporate into its output \acro{PDF} stream:
\acro{JPEG} (\extension{jpg} files) for photographs and similar images,
\acro{PNG} files for artificial bitmap images, and \acro{PDF} for
vector drawings.  Old versions of \PDFTeX{} (prior to version~1.10a)
supported \acro{TIFF} (\extension{tif} files) format as an alternative
to \acro{PNG} files; don't rely on this facility, even if you
\emph{are} running an old enough version of \PDFTeX{}\dots{}

In addition to the `native' formats, the standard \PDFLaTeX{}
\Package{graphics} package setup causes Hans Hagen's \File{supp-pdf}
macros to be loaded: these macros are capable of translating the
output of \MP{} to \acro{PDF} ``on the fly''; thus \MP{} output
(\extension{mps} files) may also be included in \PDFLaTeX{} documents.

The commonest problem users encounter, when switching from \TeX{}, is
that there is no straightforward way to include \acro{EPS} files:
since \PDFTeX{} is its own ``driver'', and since it contains no means
of converting \PS{} to \acro{PDF}, there's no direct way the job can
be done.

The simple solution is to convert the \acro{EPS} to an appropriate
\acro{PDF} file.  The \ProgName{epstopdf} program will do this: it's
available either as a Windows executable or as a \ProgName{Perl}
script to run on Unix and other similar systems.  A \LaTeX{} package,
\Package{epstopdf}, can be used to generate the requisite \acro{PDF}
files ``on the fly''; this is convenient, but requires that you
suppress one of \TeX{}'s security checks: don't allow its use in files
from sources you don't entirely trust.

A similar package, \Package{pst-pdf}, permits other things than `mere'
graphics files in its argument.  \Package{Pst-pdf} operates (the
authors suggest) ``like \BibTeX{}''~--- you process your file using
\PDFLaTeX{}, then use \LaTeX{}, \ProgName{dvips} and \ProgName{ps2pdf}
in succession, to produce a secondary file to input to your next
\PDFLaTeX{} run.  (Scripts are provided to ease the production of the
secondary file.)

An alternative solution is to use \ProgName{purifyeps}, a
\ProgName{Perl} script which uses the good offices of
\ProgName{pstoedit} and of \MP{} to convert your Encapsulated \PS{} to
``Encapsulated \PS{} that comes out of \MP{}'', and can therefore be
included directly.  Sadly, \ProgName{purifyeps} doesn't work for all
\extension{eps} files.

Good coverage of the problem is to be found in Herbert Vo\ss{}'
\href{http://pstricks.tug.org/main.cgi?file=pdf/pdfoutput}{\acro{PDF} support page},
which is targeted at the use of \Package{pstricks} in
\PDFLaTeX{}, and also covers the \Package{pstricks}-specific package
\Package{pdftricks}.
\begin{ctanrefs}
\item[epstopdf]Browse \CTANref{epstopdf}
\item[epstopdf.sty]Distributed with Heiko Oberdiek's packages
  \CTANref{oberdiek}
\item[pdftricks.sty]\CTANref{pdftricks}
\item[pst-pdf.sty]\CTANref{pst-pdf}
\item[pstoedit]\CTANref{pstoedit}
\item[purifyeps]\CTANref{purifyeps}
\end{ctanrefs}

\Question[Q-dvipdfmgraphics]{Imported graphics in \ProgName{dvipdfm}}

\ProgName{Dvipdfm} translates direct from \acro{DVI} to \acro{PDF}
(all other available routes produce \PS{} output using
\ProgName{dvips} and then convert that to \acro{PDF} with
\ProgName{ghostscript} or \ProgName{Acrobat} \ProgName{Distiller}).

\ProgName{Dvipdfm} is a particularly flexible application.  It will
permit the inclusion of bitmap and \acro{PDF} graphics, as does
\Qref*{\PDFTeX{}}{Q-pdftexgraphics}, but is also capable of employing
\ProgName{ghostscript} ``on the fly'' so as to be able to permit the
inclusion of encapsulated \PS{} (\extension{eps}) files by translating
them to \acro{PDF}.  In this way, \ProgName{dvipdfm} combines the good
qualities of \ProgName{dvips} and of \PDFTeX{} as a means of
processing illustrated documents.

Unfortunately, ``ordinary'' \LaTeX{} can't deduce the bounding box of
a binary bitmap file (such as \acro{JPEG} or \acro{PNG}), so you have
to specify the bounding box.  This may be done explicitly, in the
document:
\begin{quote}
\begin{verbatim}
\usepackage[dvipdfm]{graphicx}
...
\includegraphics[bb=0 0 540 405]{photo.jpg}
\end{verbatim}
\end{quote}
It's usually not obvious what values to give the ``\texttt{bb}'' key,
but the program \ProgName{ebb} will generate a file
containing the information; the above numbers came from an
\ProgName{ebb} output file \File{photo.bb}:
\begin{quote}
\begin{verbatim}
%%Title: /home/gsm10/photo.jpg
%%Creator: ebb Version 0.5.2
%%BoundingBox: 0 0 540 405
%%CreationDate: Mon Mar  8 15:17:47 2004
\end{verbatim}
\end{quote}
However, if such a file is available, you may abbreviate the inclusion
code, above, to read:
\begin{quote}
\begin{verbatim}
\usepackage[dvipdfm]{graphicx}
...
\includegraphics{photo}
\end{verbatim}
\end{quote}
which makes the operation feel as simple as does including
\extension{eps} images in a \LaTeX{} file for processing with
\ProgName{dvips}; the \Package{graphicx} package knows to look for a
\extension{bb} file if no bounding box is provided in the
\csx{includegraphics} command.

The one place where usage isn't quite so simple is the need to quote
\ProgName{dvipdfm} explicitly, as an option when loading the
\Package{graphicx} package: if you are using \ProgName{dvips}, you
don't ordinarily need to specify the fact, since the default graphics
configuration file (of most distributions) ``guesses'' the
\texttt{dvips} option if you're using \TeX{}.
\begin{ctanrefs}
\item[dvipdfm]\CTANref{dvipdfm}
\item[ebb]Distributed as part of \CTANref{dvipdfm}
\end{ctanrefs}

\Question[Q-graphicspath]{Importing graphics from ``somewhere else''}

By default, graphics commands like \csx{includegraphics} look
``wherever \TeX{} files are found'' for the graphic file they're being
asked to use.  This can reduce your flexibility if you choose to hold
your graphics files in a common directory, away from your \AllTeX{}
sources.

The simplest solution is to patch \TeX{}'s path, by changing the
default path.  On most systems, the default path is taken from the
environment variable \texttt{TEXINPUTS}, if it's present; you can adapt that
to take in the path it already has, by setting the variable to
\begin{quote}
\begin{verbatim}
TEXINPUTS=.:<graphics path(s)>:
\end{verbatim}
\end{quote}
on a Unix system; on a Windows system the separator will be ``\texttt{;}''
rather than ``\texttt{:}''.  The ``\texttt{.}'' is there to ensure
that the current directory is searched first; the trailing
``\texttt{:}'' says ``patch in the value of \texttt{TEXINPUTS} from
your configuration file, here''.

This method has the merit of efficiency (\AllTeX{} does \emph{all} of
the searches, which is quick), but it's always clumsy and may prove
inconvenient to use in Windows setups (at least).

The alternative is to use the \Package{graphics} package command
\csx{graphicspath}; this command is of course also available to users
of the \Package{graphicx} and the \Package{epsfig} packages.  The
syntax of \csx{graphicspath}'s one argument is slightly odd: it's a
sequence of paths (typically relative paths), each of which is
enclosed in braces.  A slightly odd sample, given in the
\Package{graphics} bundle documentation, is:
\begin{quote}
\begin{verbatim}
\graphicspath{{eps/}{tiff/}}
\end{verbatim}
\end{quote}
however, if the security checks on your \AllTeX{} system allow, the
path may be anything you choose (rather than strictly relative, like
those above); note that the trailing ``\texttt{/}'' \emph{is} required.

Be aware that \csx{graphicspath} does not affect the operations of
graphics macros other than those from the graphics bundle~--- in
particular, those of the outdated \Package{epsf} and
\Package{psfig} packages are immune.

The disadvantage of the \csx{graphicspath} method is inefficiency.  The
package will call \AllTeX{} once for each entry in the list, which is
itself slows things.  More seriously, \TeX{} remembers the file name,
thus effectively losing memory, every time it's
asked to look up a file, so a document that uses a huge number of
graphical inputs could be embarrassed by lack of memory.

If your document is split into a variety of directories, and each
directory has its associated graphics, the \Package{import} package
may well be the thing for you; see the discussion % beware line break
\latexhtml{of ``bits of document in other directories'' (}{in the question ``}%
\Qref{bits of document in other directories}{Q-docotherdir}%
\latexhtml{)}{''}.
\begin{ctanrefs}
\item[graphics \nothtml{\rmfamily}bundle]\CTANref{graphics}
\item[import.sty]\CTANref{import}
\end{ctanrefs}

\Question[Q-graph-pspdf]{Portable imported graphics}

A regular need is a document to be distributed in more than
one format: commonly both \PS{} and \acro{PDF}.  The
following advice is based on a post by one with much experience of
dealing with the problem of dealing with \acro{EPS} graphics in this
case.
\begin{itemize}
\item Don't specify a driver when loading loading whichever version of
  the \Package{graphics} package you use.  The scheme relies on the
  distribution's ability to decide which driver is going to be used:
  the choice is between \ProgName{dvips} and \PDFTeX{}, in this case.
  Be sure to exclude options \pkgoption{dvips}, \pkgoption{pdftex} and
  \pkgoption{dvipdfm} (\ProgName{dvipdfm} is not used in this scheme,
  but the aspirant \acro{PDF}-maker may be using it for his output,
  before switching to the scheme).
\item Use \cmdinvoke{includegraphics}[...]{filename} without
  specifying the extension (i.e., neither \extension{eps} nor
  \extension{pdf}).
\item For every \extension{eps} file you will be including, produce a
  \extension{pdf} version, as described in % beware line break
  \Qref[question]{Graphics in \PDFLaTeX{}}{Q-pdftexgraphics}.  Having
  done this, you will have two copies of each graphic (a \extension{eps}
  and a \extension{pdf} file) in your directory.
\item Use \PDFLaTeX{} (rather than
  \LaTeX{}--\ProgName{dvips}--distillation or
  \LaTeX{}--\ProgName{dvipdfm}) to produce your \acro{PDF} output.
\end{itemize}
\ProgName{Dvipdfm}'s charms are less than attractive here: the
document itself needs to be altered from its default
(\ProgName{dvips}) state, before \ProgName{dvipdfm} will process it.

\Question[Q-repeatgrf]{Repeated graphics in a document}

A logo or ``watermark'' image, or any other image that is repeated in
your document, has the potential to make the processed version of the
document unmanageably large.  The problem is, that the default
mechanisms of graphics usage add the image at every point it's to be
used, and when processed, the image appears in the output file at each
such point.

Huge \PS{} files are embarrassing; explaining \emph{why} such a file
is huge, is more embarrassing still.

The \Qref*{\File{epslatex} graphics tutorial}{Q-tutbitslatex}
describes a technique for avoiding the problem: basically, one
converts the image that's to be repeated into a \PS{} subroutine, and
load that as a \ProgName{dvips} prologue file.  In place of the image,
you load a file (with the same bounding box as the image) containing
no more than an invocation of the subroutine defined in the prologue.

The \File{epslatex} technique is tricky, but does the job.  Trickier
still is the neat scheme of converting the figure to a one-character
Adobe Type~3 outline font.  While this technique is for the ``real
experts'' only (the author of this answer has never even tried it), it has
potential for the same sort of space saving as the \File{epslatex}
technique, with greater flexibility in actual use.

More practical is Hendri Adriaens' \Package{graphicx-psmin}; you load
this \emph{in place} of \Package{graphicx}, so rather than:
\begin{quote}
\begin{verbatim}
\usepackage[<options>]{graphicx}
\end{verbatim}
\end{quote}
you will write:
\begin{quote}
\begin{verbatim}
\usepackage[<options>]{graphicx-psmin}
\end{verbatim}
\end{quote}
and at the start of your document, you write:
\begin{quote}
\begin{verbatim}
\loadgraphics[<bb>]{<list of graphics>}
\end{verbatim}
\end{quote}
and each of the graphics in the list is converted to an ``object'' for
use within the resulting \PS{} output.  (This is, in essence, an
automated version of the \File{epslatex} technique described above.)

Having loaded the package as above, whenever you use
\csx{includegraphics}, the command checks if the file you've asked for
is one of the graphics in \csx{loadgraphics}' list.  If so, the
operation is converted into a call to the ``object'' rather than a new
copy of the file; the resulting \PS{} can of course be \emph{much} smaller.

Note that the package requires a recent \ProgName{dvips}, version
5.95b (this version isn't~--- yet~--- widely distributed).

If your \PS{} is destined for conversion to \acro{PDF}, either by a
\ProgName{ghostscript}-based mechanism such as \ProgName{ps2pdf} or by
(for example) \ProgName{Acrobat} \ProgName{Distiller}, the issue isn't
so pressing, since the distillation mechanism will amalgamate graphics
objects whether or not the \PS{} has them amalgamated.  \PDFTeX{} does
the same job with graphics, automatically converting multiple uses
into references to graphics objects.
\begin{ctanrefs}
\item[graphicx-psmin.sty]\CTANref{graphicx-psmin}
\end{ctanrefs}

\Question[Q-grmaxwidth]{Limit the width of imported graphics}

Suppose you have graphics which may or may not be able to fit within
the width of the page; if they will fit, you want to set them at their
natural size, but otherwise you want to scale the whole picture so
that it fits within the page width.

You do this by delving into the innards of the graphics package (which
of course needs a little \LaTeX{} internals programming):
\begin{quote}
\begin{verbatim}
\makeatletter
\def\maxwidth{%
  \ifdim\Gin@nat@width>\linewidth
    \linewidth
  \else
    \Gin@nat@width
  \fi
}
\makeatother
\end{verbatim}
\end{quote}
This defines a ``variable'' width which has the properties you want.
Replace \csx{linewidth} if you have a different constraint on the width
of the graphic.

Use the command as follows:
\begin{quote}
\begin{verbatim}
\includegraphics[width=\maxwidth]{figure}
\end{verbatim}
\end{quote}

\Question[Q-topgraph]{Top-aligning imported graphics}

When \TeX{} sets a line of anything, it ensures that the base-line of
each object in the line is at the same level as the base-line of the
final object.  (Apart, of course, from \csx{raisebox} commands\dots{})

Most imported graphics have their base-line set at the bottom of the
picture.  When using packages such as \Package{subfig}, one often
wants to align figures by their tops.  The following odd little bit of
code does this:
\begin{quote}
\begin{verbatim}
\vtop{%
  \vskip0pt
  \hbox{%
    \includegraphics{figure}%
  }%
}
\end{verbatim}
\end{quote}
The \csx{vtop} primitive sets the base-line of the resulting object to
that of the first ``line'' in it; the \csx{vskip} creates the illusion
of an empty line, so \csx{vtop} makes the very top of the box into the
base-line.

In cases where the graphics are to be aligned with text, there is a
case for making the base-line one ex-height below the top of the box,
as in:
\begin{quote}
\begin{verbatim}
\vtop{%
  \vskip-1ex
  \hbox{%
    \includegraphics{figure}%
  }%
}
\end{verbatim}
\end{quote}
A more \LaTeX{}-y way of doing the job (somewhat inefficiently) uses
the \Package{calc} package:
\begin{quote}
\begin{verbatim}
\usepackage{calc}
...
\raisebox{1ex-\height}{\includegraphics{figure}}
\end{verbatim}
\end{quote}
(this has the same effect as the text-align version, above).

The fact is, \emph{you} may choose where the base-line ends up.  This
answer merely shows you sensible choices you might make.

\Question[Q-mpprologues]{Displaying \MP{} output in \ProgName{ghostscript}}

\MP{} ordinarily expects its output to be included in some context
where the `standard' \MF{} fonts (that you've specified) are already
defined~--- for example, as a figure in \TeX{} document.  If you're
debugging your \MP{} code, you may want to view it in
\ProgName{ghostscript} (or some other \PS{} previewer).  However,
the \PS{} `engine' in \ProgName{ghostscript} \emph{doesn't}
ordinarily have the fonts loaded, and you'll experience an error such
as
\begin{quote}
\begin{verbatim}
Error: /undefined in cmmi10
\end{verbatim}
\end{quote}
There is provision in \MP{} for avoiding this problem: issue the
command \texttt{prologues := 2;} at the start of the \extension{mp} file.

Unfortunately, the \PS{} that \MP{} inserts in its output,
following this command, is incompatible with ordinary use of the
\PS{} in inclusions into \AllTeX{} documents, so it's best to
make the \texttt{prologues} command optional.  Furthermore, \MP{} takes a
very simple-minded approach to font encoding: since \TeX{} font
encodings regularly confuse sophisticated minds, this can prove
troublesome.  If you're suffering such problems (the symptom is that
characters disappear, or are wrongly presented) the only solution is
to view the `original' \MP{} output after processing through
\LaTeX{} and \ProgName{dvips}.

Conditional compilation may be done either
by inputting \File{MyFigure.mp} indirectly from a simple wrapper
\File{MyFigureDisplay.mp}:
\begin{quote}
\begin{verbatim}
prologues := 2;
input MyFigure
\end{verbatim}
\end{quote}
or by issuing a shell command such as
\begin{quote}
\begin{verbatim}
mp '\prologues:=2; input MyFigure'
\end{verbatim}
\end{quote}
(which will work without the quote marks if you're not using a Unix
shell).

A suitable \LaTeX{} route would involve processing
\File{MyFigure.tex}, which contains:
\begin{quote}
\begin{verbatim}
\documentclass{article}
\usepackage{graphicx}
\begin{document}
\thispagestyle{empty}
\includegraphics{MyFigure.1}
\end{document}
\end{verbatim}
\end{quote}
Processing the resulting \acro{DVI} file with the \ProgName{dvips}
command
\begin{quote}
\begin{verbatim}
dvips -E -o MyFigure.eps MyFigure
\end{verbatim}
\end{quote}
would then give a satisfactory Encapsulated \PS{} file.  This
procedure may be automated using the \ProgName{Perl} script
\ProgName{mps2eps}, thus saving a certain amount of tedium.

The \plaintex{} user may use an adaptation of a jiffy of Knuth's, by
Dan Luecking.  Dan's version \Package{mpsproof.tex} will work under
\TeX{} to produce a \acro{DVI} file for use with \ProgName{dvips}, or
under \PDFTeX{} to produce a \acro{PDF} file, direct.  The output is
set up to look like a proof sheet.

A script application, \ProgName{mptopdf}, is available in recent
\AllTeX{} distributions: it seems fairly reliably to produce
\acro{PDF} from \MP{}, so may reasonably be considered an answer to
the question\dots{}
\begin{ctanrefs}
\item[mps2eps]\CTANref{mps2eps}
\item[mpsproof.tex]\CTANref{mpsproof}
\item[mptopdf]Part of \CTANref{pdftex-graphics}
\end{ctanrefs}

\Question[Q-drawing]{Drawing with \TeX{}}

There are many packages to do pictures in \AllTeX{} itself (rather than
importing graphics created externally), ranging from simple use of
\LaTeX{} \environment{picture} environment, through enhancements like
\ProgName{epic}, to 
sophisticated (but slow) drawing with \PiCTeX{}. Depending on your type
of drawing, and setup, here are a few systems you may consider:
\begin{itemize}
\item \Package{pict2e}; this was advertised in % !line break
  \Qref*{the \LaTeX{} manual}{Q-books}, but didn't appear for nearly
  ten years after publication of the book!  It removes all the petty
  niggles that surround the use of the \environment{picture}
  environment.  It therefore suffers \emph{only} from the rather
  eccentric drawing language of the environment, and is a far more
  useful tool than the original environment has ever been.  (Note that
  \Package{pict2e} supersedes David Carlisle's stop-gap
  \Package{pspicture}.)
\item \Package{PSTricks}; this gives you access to all the power of
  \PS{} from \TeX{} itself, by sophisticated use of
  \Qref*{\csx{special} commands}{Q-specials}.  Since \PS{} is itself a
  pretty powerful programming language, many  astounding things can in
  principle be achieved using \Package{PSTricks}.
  \Package{pstricks}' \csx{special}s are
  by default specific to \ProgName{dvips}, but V\TeX{} (both in its
  commercial and in its free versions) understands them.  \PDFTeX{}
  users may use \Package{pst-pdf}, which (like
  \Package{epstopdf}~--- see % ! line break
  \Qref[question]{\PDFLaTeX{} graphics}{Q-pdftexgraphics}) generates
  \acro{PDF} files using an auxiliary program, from \Package{PSTricks}
  commands (\Package{pst-pdf} also requires a recent installation of
  the \Package{preview} package).

  There is a \Package{PSTricks} mailing list
  (\mailto{pstricks@tug.org}) which you may
  \href{http://tug.org/mailman/listinfo/pstricks}{join}, or you may
  just browse the % ! line break
  \href{http://tug.org/pipermail/pstricks/}{list archives}.
\item \Package{pgf}: while \Package{pstricks} is very powerful and
  convenient, using it with \PDFLaTeX{} is an awful fidget: if you
  simply want the graphical capabilities, \Package{pgf}, together with
  its rather pleasing ``user-oriented'' interface \Package{tikz}, may be a good
  bet for you.  While \acro{PDF} has (in essence) the same graphical
  capabilities as \PS{}, it isn't programmable; \Package{pgf} provides
  common \LaTeX{} commands that will utilise the graphical
  capabilities of both \PS{} and \acro{PDF} equally.
\item \MP{}; you liked \MF{}, but never got to grips with font files?
  Try \Qref*{\MP{}}{Q-MP}~---
  all the power of \MF{}, but it generates \PS{} figures; \MP{}
  is nowadays part of most serious \AllTeX{} distributions.  Knuth
  uses it for all his work\dots{}
\item \ProgName{Mfpic}; you liked \MF{}, but can't understand the
  language?  The package makes up \MF{} or \MP{} code for you
  within using familiar-looking \TeX{} macros.  Not \emph{quite} the
  full power of \MP{}, but a friendlier interface; of course, with
  \MP{} output, the results can be used equally well in either
  \LaTeX{} or \PDFLaTeX{}.
\item You liked \PiCTeX{} but don't have enough memory or time?  Look
  at Eitan Gurari's \Package{dratex}, which is as powerful as most
  other \TeX{} drawing packages, but is an entirely new
  implementation, which is not as hard on memory, is much more
  readable (and is fully documented).
\end{itemize}
\begin{ctanrefs}
\item[dratex.sty]\CTANref{dratex}
\item[mfpic]\CTANref{mfpic}
\item[preview.sty]\CTANref{preview}
\item[pspicture.sty]\CTANref{pspicture}
\item[pst-pdf.sty]\CTANref{pst-pdf}
\item[pgf.sty]\CTANref{pgf}
\item[pict2e.sty]\CTANref{pict2e}
\item[pstricks]\CTANref{pstricks}
\item[tikz.sty]Distributed with \CTANref{pgf}
\end{ctanrefs}

\Question[Q-drawFeyn]{Drawing Feynman diagrams in \LaTeX{}}

Michael Levine's \Package{feynman} bundle for drawing the diagrams in
\LaTeXo{} is still available.

Thorsten Ohl's \Package{feynmf} is designed for use with current
\LaTeX{}, and works in
combination with \MF{} (or, in its \Package{feynmp} incarnation, with
\MP{}).  The \ProgName{feynmf} or
\ProgName{feynmp} package reads a description of the diagram written
in \TeX{}, and writes out code.  \MF{} (or \MP{}) can then produce a
font (or \PS{} file) for use in a subsequent \LaTeX{} run.  For
new users, who have access to \MP{}, the \PS{} version is
probably the better route, for document portability and other reasons.
% checked rf 2001/03/22

Jos Vermaseren's \Package{axodraw} is mentioned as an alternative in
the documentation of \Package{feynmf}, but it is written entirely in
terms of \ProgName{dvips} \csx{special} commands, and is thus rather
imperfectly portable.

An alternative approach is implemented by Norman Gray's \Package{feyn}
package.  Rather than creating complete diagrams as postscript images,
\Package{feyn} provides a font (in a variety of sizes) containing
fragments, which you can compose to produce complete diagrams.  It
offers fairly simple diagrams which look good in equations, rather
than complicated ones more suitable for display in figures.
\begin{ctanrefs}
\item[axodraw]\CTANref{axodraw}
\item[feyn \nothtml{\rmfamily}font bundle]\CTANref{feyn}
\item[feynman bundle]\CTANref{feynman}
\item[feynmf/feynmp bundle]\CTANref{feynmf}
\end{ctanrefs}

\Question[Q-labelfig]{Labelling graphics}

``Technical'' graphics (such as graphs and diagrams) are often
labelled with quite complex mathematical expressions: there are few
drawing or graphing tools that can do such things (the honourable
exception being \MP{}, which allows you to program the labels, in
\AllTeX{}, in the middle of specifying your graphic).

Labels on graphics produced by all those \emph{other} tools is where
the \Package{psfrag} package can help.  Place an unique
text in your graphic, using the normal text features of your tool, and
you can ask \Package{psfrag} to replace the text with arbitrary
\AllTeX{} material.  \Package{Psfrag}'s ``operative'' command is
\cmdinvoke{psfrag}{\emph{PS text}}{\emph{Repl text}}, which instructs
the system to replace the original (``\texttt{PS}'') text with the
\TeX{}-typeset replacement text.  Optional
arguments permit adjustment of position, scale and rotation; full
details may be found in \File{pfgguide} in the distribution.

Since \Package{psfrag} works in terms of (encapsulated) \PS{} files,
it needs extra work for use with \PDFLaTeX{}.  The % ! line break
\Qref*{\Package{pst-pdf} package}{Q-pdftexgraphics} can support such
usage.  In fact, the \Package{pst-pdf} support package
\Package{auto-pst-pdf} offers a configuration setting precisely for
use with \Package{psfrag}.

On the other hand,
\begin{narrowversion}
  V\TeX{}'s GeX processor (\Qref{}{Q-commercial})
\end{narrowversion}
\begin{wideversion}
  \Qref*{V\TeX{}}{Q-commercial}'s GeX processor
\end{wideversion}
explicitly deals with \Package{psfrag}, both in its free and
commercial instances.

The \Package{psfragx} package goes one step further than
\Package{psfrag}: it provides a means whereby you can put the
\Package{psfrag} commands into the preamble of your \acro{EPS} file
itself.  \Package{Psfrag} has such a command itself, but deprecates
it; \Package{psfragx} has cleaned up the facility, and provides a
script \ProgName{laprint} for use with \ProgName{Matlab} to produce
appropriately tagged output.  (In principle, other graphics
applications could provide a similar facility, but apparently none does.)

\ProgName{Emacs} users may find the embedded editor \ProgName{iTe} a
useful tool for placing labels: it's a \AllTeX{}-oriented graphical
editor written in \ProgName{Emacs Lisp}.  You create
\environment{iteblock} environments containing graphics and text, and
may then invoke \ProgName{iTe} to arrange the elements relative to one
another.

Another useful approach is \Package{overpic}, which overlays a
\environment{picture} environment on a graphic included by use of
\csx{includegraphics}.  This treatment lends itself to ready placement
of texts and the like on top of a graphic.  The package can draw a
grid for planning your ``attack''; the distribution comes with simple
examples.

\Package{Pstricks} can of course do everything that \Package{overpic}
can, with all the flexibility of \PS{} programming that it offers
The \Package{pstricks} web site has a page with several % ! line break
\href{http://pstricks.tug.org/main.cgi?file=Examples/overlay}{examples of labelling}
which will get you started; if \Package{pstricks} is % ! line break
\Qref*{an option for you}{Q-drawing}, this route is worth a try.

The confident user may, of course, do the whole job in a picture
environment which itself includes the graphic.  I would recommend
\Package{overpic} or the \Package{pstricks} approach, but such things
are plainly little more than a convenience over what is achievable
with the do-it-yourself approach.
\begin{ctanrefs}
\item[auto-pst-pdf.sty]\CTANref{auto-pst-pdf}
\item[iTe]\CTANref{ite}
\item[laprint]Distributed with \CTANref{psfragx}
\item[overpic.sty]\CTANref{overpic}
\item[psfrag.sty]\CTANref{psfrag}
\item[psfragx.sty]\CTANref{psfragx}
\item[pstricks.sty]\CTANref{pstricks}
\item[pst-pdf.sty]\CTANref{pst-pdf}
\end{ctanrefs}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\section{Bibliographies and citations}

\subsection{Creating bibliographies}

\Question[Q-buildbib]{Creating a \BibTeX{} bibliography file}

A \BibTeX{} bibliography file may reasonably be compared to a small
database, the entries in which are references to literature that may
be called up by citations in a document.

Each entry in the bibliography has a \emph{type} and a unique
\emph{key}.  The bibliography is read, by \BibTeX{}, using the details
specified in a \emph{bibliography style}.  From the style, \BibTeX{}
finds what entry types are permissible, what \emph{fields} each entry
type has, and how to format the whole entry.

The type specifies the type of document you're making reference to; it
may run all the way from things like ``\environment{Book}'' and
``\environment{Proceedings}'' (which may even contain other citations
of type ``\environment{InBook}'' or  ``\environment{InProceedings}'')
through dissertation styles like  ``\environment{PhdThesis}'' to
otherwise-uncategorisable things such as ``\environment{Misc}''.  The
unique key is something you choose yourself: it's what you use when
you want to \Qref*{cite an entry in the file}{Q-usebibtex}.  People
commonly create a key that combines the (primary) author's name and
the year of publication, possibly with a marker to distinguish
publications in the same year.  So, for example, the Dyson, Eddington,
Davidson paper about deflection of starlight appears in my
experimental \extension{bib} file as \texttt{Dyson20.1}.

So, noting the rules of the style, you have `simply' to write a
bibliography database.  Fortunately, there are several tools to help
in this endeavour:
\begin{itemize}
\item Most of the better \Qref*{\AllTeX{}-oriented editors}{Q-editors}
  have ``\BibTeX{} modes''.
\item If you have an existing \environment{thebibliography}
  environment, the \ProgName{Perl} script \ProgName{tex2bib} will
  probably help.
\item There are a number of \BibTeX{} bibliography management systems
  available, some of which permit a graphical user interface to the
  task.  Sadly, none seems to be available with the ordinary \TeX{}
  distributions.
  
  Tools such as \ProgName{Xbibfile} (a graphical user interface),
  \ProgName{ebib} (a database application written to run `inside'
  \ProgName{emacs}) and 
  \ProgName{btOOL} (a set of \ProgName{perl} tools for building 
  \BibTeX{} database handlers) are available from \acro{CTAN}.

  Other systems, such as
  \href{http://refdb.sourceforge.net/}{\ProgName{RefDB}},
  \href{http://www.nongnu.org/biborb}{BibORB},
  \href{http://bibdesk.sourceforge.net/}{\ProgName{BibDesk}},
  \href{http://pybliographer.org}{\ProgName{pybliographer}} and the
  \ProgName{Java}-based
  \href{http://freshmeat.net/projects/bibkeeper/}{\ProgName{Bibkeeper}}
  and \href{http://jabref.sourceforge.net}{\ProgName{JabRef}} (which
  claims to supersede \ProgName{Bibkeeper})
  are only available from their development sites.
% review of web database offerings in textex_368
\item Some commercial citation-management systems will export in
  \BibTeX{} format; an example is
  \href{http://www.endnote.com/}{EndNote}.
\item Data from on-line citation databases may often be translated to
  \BibTeX{} format by utilities to be found on \acro{CTAN}.  For
  example, the \ProgName{Perl} script \ProgName{isi2bibtex} will
  translate citations from \acro{ISI} ``Web of knowledge'' (a
  subscription service, available to \acro{UK} academics via
  \acro{BIDS}).  UK academics may translate \acro{BIDS} downloads
  using \ProgName{bids.to.bibtex}
\end{itemize}
\begin{ctanrefs}
\item[bids.to.bibtex]\CTANref{bidstobibtex}
\item[btOOL]\CTANref{btOOL}
\item[ebib]\CTANref{ebib}
\item[isi2bibtex]\CTANref{isi2bibtex}
\item[tex2bib]\CTANref{tex2bib}
\item[tex2bib.readme]\CTANref{tex2bib-doc}
\item[xbibfile]\CTANref{xbibfile}
\end{ctanrefs}

\Question[Q-custbib]{Creating a bibliography style}

It \emph{is} possible to write your own: the standard bibliography
styles are distributed in a commented form, and there is a description
of the language (see
% beware line-wrap
\Qref[question]{BibTeX documentation}{Q-BibTeXing}).
However, it must be admitted that the language in which \BibTeX{}
styles are written is pretty obscure, and one would not recommend
anyone who's not a confident programmer to write their own, though
minor changes to an existing style may be within the grasp of many.

If your style isn't too `far out', you can probably generate it by
using the facilities of the \Package{custom-bib} bundle.  This
contains a file \File{makebst.tex}, which runs you through a text menu
to produce a file of instructions, with which you can generate your
own \extension{bst} file.  This technique doesn't offer entirely new styles
of document, but the system's ``master \BibTeX{} styles'' already
offer significantly more than the \BibTeX{} standard set.
\begin{ctanrefs}
\item[\nothtml{\normalfont}\BibTeX{} documentation]\CTANref{bibtex-doc}
\item[makebst.tex]Distributed with \CTANref{custom-bib}
\end{ctanrefs}

\Question[Q-capbibtex]{Capitalisation in \BibTeX{}}

The standard \BibTeX{} bibliography styles impose fixed ideas about
the capitalisation of titles of things in the bibliography.  While
this is not unreasonable by \BibTeX{}'s lights (the rules come from
the \emph{Chicago Manual of Style}) it can be troublesome, since
\BibTeX{} fails to recognise special uses (such as acronyms, chemical
formulae, etc.).

The solution is to enclose the letter or letters, whose capitalisation
\BibTeX{} should not touch, in braces, as:
\begin{quote}
\begin{verbatim}
title = {The {THE} operating system},
\end{verbatim}
\end{quote}
Sometimes you find \BibTeX{} changing the case of a single letter
inappropriately.  No matter: the technique can be applied to single
letters, as in:
\begin{quote}
\begin{verbatim}
title = {Te{X}niques and tips},
\end{verbatim}
\end{quote}
If your document design specification requires a different style of
capitalisation, you should acquire a bibliography style that doesn't
enforce \BibTeX{}'s default rules.  It is definitely \emph{not} a good
idea to enclose an entire title in braces, as in
\begin{quote}
\begin{verbatim}
title = {{TeXniques and tips}},
\end{verbatim}
\end{quote}
though that does ensure that the capitalisation is not changed.  Your
\BibTeX{} database should be a general-purpose thing, not something
tuned to the requirements of a particular document, or to the way you
are thinking today.

There's more on the subject in the
% beware line wrap
\Qref*{\BibTeX{} documentation}{Q-BibTeXing}.

\Question[Q-bibaccent]{Accents in bibliographies}

\BibTeX{} not only has a tendency (by default) to mess about with the
% line wrap
\Qref*{case of letters in your bibliography}{Q-capbibtex},
also makes a hash of accent commands:
``\texttt{ma}\csx{\textasciitilde}\texttt{nana}'' comes out as ``ma
nana'' (!).  The solution is similar that of the letter case problem:
enclose the troublesome sequence in braces, as
``\texttt{\{}\csx{\textasciitilde}\texttt{n\}}'', in this example.

\Question[Q-bibstrtl]{`String too long' in \BibTeX{}}

The \BibTeX{} diagnostic ``Warning--you've exceeded 1000, the
\texttt{global-string-size}, for entry \texttt{foo}'' usually arises
from a very large abstract or annotation included in the database.
The diagnostic usually arises because of an infelicity in the coding of
\File{abstract.bst}, or styles derived from it.  (One doesn't
ordinarily output annotations in other styles.)

The solution is to make a copy of the style file (or get a clean copy
from \acro{CTAN}~--- \CTANref{abstract-bst}), and rename it (e.g., on a
long file-name system, to \File{abstract-long.bst}).  Now edit it: find
function \texttt{output.nonnull} and
\begin{itemize}
\item change its first line (line 60 in the version on \acro{CTAN})
  from
  \begin{quote}
\begin{verbatim}
{ 's :=
\end{verbatim}
  \end{quote}
to
  \begin{quote}
\begin{verbatim}
{ swap$
\end{verbatim}
  \end{quote}
  Finally,
\item delete the function's last line, which just says ``\texttt{s}
  (line 84 in the version on \acro{CTAN}).
\end{itemize}
Finally, change your \csx{bibliographystyle} command to refer to the
name of the new file.

This technique applies equally to any bibliography style: the same
change can be made to any similar \texttt{output.nonnull} function.

If you're reluctant to make this sort of change, the only way forward
is to take the entry out of the database, so that you don't encounter
\BibTeX{}'s limit, but you may need to retain the entry because it
will be included in the typeset document.  In such cases, put the body
of the entry in a separate file:
\begin{quote}
\begin{verbatim}
@article{long.boring,
  author =    "Fred Verbose",
  ...
  abstract =  "{\input{abstracts/long.tex}}"
}
\end{verbatim}
\end{quote}
In this way, you arrange that all \BibTeX{} has to deal with is the
file name, though it will tell \TeX{} (when appropriate) to include
all the long text.

\Question[Q-manyauthor]{\BibTeX{} doesn't understand lists of names}

\BibTeX{} has a strict syntax for lists of authors' (or editors')
names in the \BibTeX{} data file; if you write the list of names in a
``natural''-seeming way, the chances are you will confuse \BibTeX{},
and the output produced will be quite different from what you had
hoped.

Names should be expressed in one of the forms
\begin{quote}
\begin{verbatim}
First Last
Last, First
Last, Suffix, First
\end{verbatim}
\end{quote}
and lists of names should be separated with ``\texttt{and}''.
For example:
\begin{quote}
\begin{verbatim}
AUTHOR = {Fred Q. Bloggs, John P. Doe \&
          Another Idiot}
\end{verbatim}
\end{quote}
falls foul of two of the above rules: a syntactically significant
comma appears in an incorrect place, and `\csx{\&}' is being used as a
name separator.  The output of the above might be something like:
\begin{quote}
\begin{wideversion}
\begin{verbatim}
John P. Doe \& Another Idiot Fred Q. Bloggs
\end{verbatim}
\end{wideversion}
\begin{narrowversion}
\begin{verbatim}
John P. Doe \& Another Idiot
                        Fred Q. Bloggs
\end{verbatim}
\end{narrowversion}
\end{quote}
because ``John P. Doe \& Another Idiot has become the `first name',
while ``Fred Q. Bloggs'' has become the `last name' of a single
person.  The example should have been written:
\begin{quote}
\begin{narrowversion}
\begin{verbatim}
AUTHOR = {Fred Q. Bloggs and
          John P. Doe and
          Another Idiot}
\end{verbatim}
\end{narrowversion}
\begin{wideversion}
\begin{verbatim}
AUTHOR = {Fred Q. Bloggs and John P. Doe and
          Another Idiot}
\end{verbatim}
\end{wideversion}
\end{quote}
Some bibliography styles implement clever acrobatics with very long
author lists.  You can force truncation by using the pseudo-name
``\texttt{others}'', which will usually translate to something like
``\emph{et al}'' in the typeset output.  So, if Mr.~Bloggs wanted to
distract attention from his co-authors, he would write:
\begin{quote}
\begin{verbatim}
AUTHOR = {Fred Q. Bloggs and others}
\end{verbatim}
\end{quote}

\Question[Q-citeURL]{\acro{URL}s in \BibTeX{} bibliographies}

There is no citation type for \acro{URL}s, \emph{per se}, in the
standard \BibTeX{} styles, though Oren Patashnik (the author of
\BibTeX{}) is believed to be considering developing one such for use
with the long-awaited \BibTeX{} version~1.0.

The actual information that need be available in a citation of an
\acro{URL} is discussed at some length in the publicly available
on-line 
\begin{narrowversion}
  extracts of \acro{ISO}~690--2, available via
  \URL{http://www.nlc-bnc.ca/iso/tc46sc9/standard/690-2e.htm};
  % checked 2004-01-15
\end{narrowversion}
\begin{wideversion}
\href{http://www.nlc-bnc.ca/iso/tc46sc9/standard/690-2e.htm}{extracts of \acro{ISO}\nobreakspace690--2};
\end{wideversion}
the techniques below do \emph{not} satisfy all the requirements of
\acro{ISO}~690--2, but they offer a solution that is at least
available to users of today's tools.

Until the new version of \BibTeX{} arrives, the simplest technique is
to use the \texttt{howpublished} field of the standard styles' \texttt{@misc}
function.  Of course, the strictures
about \Qref*{typesetting \acro{URL}s}{Q-setURL} still apply, so the
entry will look like:
\begin{quote}
\begin{verbatim}
@misc{...,
  ...,
  howpublished = "\url{http://...}"
}
\end{verbatim}
\end{quote}
A possible alternative approach is to use \BibTeX{} styles other than
the standard ones, that already have \acro{URL} entry types.
Candidates are:
\begin{itemize}
\item The \Package{natbib} styles (\Package{plainnat},
  \Package{unsrtnat} and \Package{abbrevnat}), which are extensions of
  the standard styles, principally for use with \Package{natbib}
  itself.  However, they've acquired \acro{URL}s and other ``modern''
  entries along the way.  The same author's \Package{custom-bib} is
  also capable of generating styles that honour \acro{URL} entries.
\item The \Package{babelbib} bundle, which offers % ! line break
  \Qref*{multilingual bibliographies}{Q-i18nbib}, similarly provides a
  set of standard-style equivalents that have \acro{URL} entries.
\item More modern styles such as the \Package{harvard} package (if the
  citation styles are otherwise satisfactory for you).
  \Package{Harvard} bibliography styles all include a ``\texttt{url}''
  field in their specification; however, the typesetting offered is
  somewhat feeble (though it does recognise and use
  \ProgName{LaTeX2HTML} macros if they are available, to create
  hyperlinks).
\end{itemize}
You can also acquire new \BibTeX{} styles by use of Norman Gray's
\Package{urlbst} system, which is based on a \ProgName{Perl} script
that edits an existing \BibTeX{} style file to produce a new
style. The new style thus generated has a \texttt{webpage} entry type, and
also offers support for \texttt{url} and \texttt{lastchecked} fields
in the other entry types.  The \ProgName{Perl} script comes with a set
of converted versions of the standard bibliography styles.

Another possibility is that some conventionally-published paper,
technical report (or even book) is also available on the Web.  In such
cases, a useful technique is something like:
\begin{quote}
\begin{wideversion}
\begin{verbatim}
@techreport{...,
  ...,
  note = "Also available as \url{http://...}"
}
\end{verbatim}
\end{wideversion}
\begin{narrowversion}
\begin{verbatim}
@techreport{...,
  ...,
  note = "Also available as 
                       \url{http://...}"
}
\end{verbatim}
\end{narrowversion}
\end{quote}
There is good reason to use the \Package{url} or \Package{hyperref}
packages in this context: \BibTeX{} has a habit of splitting
lines it considers excessively long, and if there are no space
characters for it to use as `natural' breakpoints, \BibTeX{} will
insert a comment (`\texttt{\textpercent}') character~\dots{}\@ which
is an acceptable character in an \acro{URL}.  Any current version of the
\Package{url} or \Package{hyperref} package detects this
``\texttt{\textpercent}--end-of-line'' structure in its argument, and
removes it.
\begin{ctanrefs}
\item[babelbib \nothtml{\rmfamily}bundle]\CTANref{babelbib}
\item[custom-bib \nothtml{\rmfamily}bundle]\CTANref{custom-bib}
\item[harvard.sty]\CTANref{harvard}
\item[hyperref.sty]\CTANref{hyperref}
\item[natbib \nothtml{\rmfamily}styles]\CTANref{natbib}
\item[url.sty]\CTANref{url}
\item[urlbst]\CTANref{urlbst}
\end{ctanrefs}

\Question[Q-bibplain]{Using \BibTeX{} with \plaintex{}}

The file \File{btxmac.tex} (which is part of the \Eplain{} system)
contains macros and documentation for using \BibTeX{} with
\plaintex{}, either directly or with \Qref*{\Eplain{}}{Q-eplain}.  See
\Qref[question]{the use of \BibTeX{}}{Q-BibTeXing} for more
information about \BibTeX{} itself.
\begin{ctanrefs}
\item[btxmac.tex]\CTANref{btxmactex}
\item[eplain \nothtml{\rmfamily}system]\CTANref{eplain}
\end{ctanrefs}

\Question[Q-makebib]{Reconstructing \extension{bib} files}

Perhaps you've lost the \extension{bib} file you generated your document from,
or have been sent a document without one.  Or even, you've realised
the error of building a substantial document without the benefit of
\BibTeX{}\dots{}

The \ProgName{Perl} script, \Package{tex2bib} makes a reasonable job
of regenerating \extension{bib} files from \environment{thebibliography}
environments, provided that the original (whether automatically or
manually generated) doesn't deviate too far from the ``standard''
styles.

You are well-advised to check the output of the script.  While it will
not usually destroy information, it can quite reasonably mislabel it.

Documentation of the script is to be found in the file \File{tex2bib.readme}
\begin{ctanrefs}
\item[tex2bib]\CTANref{tex2bib}
\item[tex2bib.readme]\CTANref{tex2bib-doc}
\end{ctanrefs}

\Question[Q-bibprefixsort]{\BibTeX{} sorting and name prefixes}

\BibTeX{} recognises a bewildering array of name prefixes (mostly
those deriving from European language names); it ignores the prefixes
when sorting the bibliography~--- you want ``Ludwig van Beethoven''
sorted under ``Beethoven'', not under ``van''.  (Lamport made a witty
deliberate mistake with Beethoven's name, in the first edition of his
\LaTeX{} manual.)

However, a recurring issue is the desire to quote Lord Rayleigh's
publications (``Lord'' isn't an acceptable prefix), or names from
languages that weren't considered when \BibTeX{} was designed such as
``al-Wakil'' (transcribed from the Arabic).  What's needed is a
separate ``sort key'', but \BibTeX{} only allows such a thing in
citations of items that have no author or editor.

The solution is to embed the sort key in the author's name, but to
prevent it from being typeset.  Patashnik recommends a command
\csx{noopsort} (no-output-sortkey), which is defined and used as
follows:
\begin{quote}
\begin{wideversion}
\begin{verbatim}
@PREAMBLE{ {\providecommand{\noopsort}[1]{}} }
...
@ARTICLE{Rayleigh1,
AUTHOR = "{\noopsort{Rayleigh}}{Lord Rayleigh}",
...
}
\end{verbatim}
\end{wideversion}
\begin{narrowversion}
\begin{verbatim}
@PREAMBLE{
    {\providecommand{\noopsort}[1]{}}
}
...
@ARTICLE{Rayleigh1,
AUTHOR = 
   "\noopsort{Rayleigh}{Lord Rayleigh}",
...
}
\end{verbatim}
\end{narrowversion}
\end{quote}
Note that this \csx{noopsort} applies to the last name in this kind of
construct, so an author with an Arabic name might be rendered:
\begin{wideversion}
\begin{quote}
\begin{verbatim}
...
AUTHOR = "Ali {\noopsort{Hadiidii}}{al-Hadiidii}",
...
\end{verbatim}
\end{quote}
\end{wideversion}
\begin{narrowversion}
\begin{quote}
\begin{verbatim}
...
AUTHOR = 
   "Ali {\noopsort{Hadiidii}}{al-Hadiidii}",
...
\end{verbatim}
\end{quote}
\end{narrowversion}
A further use might deal with word order games, as in the famous
Vietnamese name:
\begin{wideversion}
\begin{quote}
\begin{verbatim}
...
AUTHOR = "\noopsort{Thanh Han The}{Han The Thanh}",
...
\end{verbatim}
\end{quote}
\end{wideversion}
\begin{narrowversion}
\begin{quote}
\begin{verbatim}
...
AUTHOR =
   "\noopsort{Thanh Han The}{Han The Thanh}",
...
\end{verbatim}
\end{quote}
\end{narrowversion}
though that author seems well-acquainted with Western confusion about
the significance of the parts of his name (even to the extent of
missing out the accentuation, as above\dots{}).

\Question[Q-bibtranscinit]{`Multi-letter' initials in \BibTeX{}}
\keywords{compound initials, transcribed initials}

If your bibliographic style uses initials~+ surname, you may encounter
a problem with some transcribed names (for example, Russian ones).
Consider the following example from the real world:
\begin{quote}
\begin{narrowversion}
\begin{verbatim}
@article{epifanov1997,
   author = {Epifanov, S. Yu. and
             Vigasin, A. A.},
   title  = ...
}
\end{verbatim}
\end{narrowversion}
\begin{wideversion}
\begin{verbatim}
@article{epifanov1997,
   author = {Epifanov, S. Yu. and Vigasin, A. A.},
   title  = ...
}
\end{verbatim}
\end{wideversion}
\end{quote}
Note that the ``Yu'' is the initial, not a complete name. However,
\BibTeX{}'s algorithms will leave you with a citation~--- 
slightly depending on the bibliographic style~--- that reads:
``S. Y. Epifanov and A. A. Vigasin, \dots{}''. instead of the intended
``S. Yu. Epifanov and A. A. Vigasin, \dots{}''.

One solution is to replace each affected initial by a command that 
prints the correct combination.  To keep your bibliography portable,
you need to add that command to your bibliography with the
\texttt{@preamble} directive:
\begin{quote}
\begin{narrowversion}
\begin{verbatim}
@preamble{ {\providecommand{\BIBYu}{Yu} } }

@article{epifanov1997,
   author   = {Epifanov, S. {\BIBYu}. and
               Vigasin, A. A.},
   title    = ...
}
\end{verbatim}
\end{narrowversion}
\begin{wideversion}
\begin{verbatim}
@preamble{ {\providecommand{\BIBYu}{Yu} } }

@article{epifanov1997,
   author   = {Epifanov, S. {\BIBYu}. and Vigasin, A. A.},
   title    = ...
}
\end{verbatim}
\end{wideversion}
\end{quote}
If you have many such commands, you may want to put them in a separate
file and \csx{input} that \LaTeX{} file in a \texttt{@preamble}
directive.

An alternative is to make the transcription look like an accent, from
\BibTeX{}'s point of view.  For this we need a control sequence that
does nothing:
\begin{wideversion}
\begin{quote}
\begin{verbatim}
@article{epifanov1997,
   author   = {Epifanov, S. {\relax Yu}. and Vigasin, A. A.},
   title    = ...
}
\end{verbatim}
\end{quote}
\end{wideversion}
\begin{narrowversion}
\begin{quote}
\begin{verbatim}
@article{epifanov1997,
   author   = {Epifanov, S. {\relax Yu}. and
               Vigasin, A. A.},
   title    = ...
}
\end{verbatim}
\end{quote}
\end{narrowversion}
Like the solution by generating extra commands, this involves tedious
extra typing; which of the two techniques is preferable for a given
bibliography will be determined by the names in it.  It should be
noted that a preamble that introduces lots of odd commands is usually
undesirable if the bibliography is a shared one.

``Compound'' initials (for single names made up of two or more words)
may be treated in the same way, so one can enter Forster's rather
complicated name as:
\begin{wideversion}
\begin{quote}
\begin{verbatim}
@article{forster2006,
  author   = {Forster, P.M. {\relax de F.} and Collins, M.},
  title    = ...
\end{verbatim}
\end{quote}
\end{wideversion}
\begin{narrowversion}
\begin{quote}
\begin{verbatim}
@article{forster2006,
  author   = {Forster, P.M. {\relax de F.} and
              Collins, M.},
  title    = ...
\end{verbatim}
\end{quote}
\end{narrowversion}
The same trick can be played if you're entering whole names:
\begin{quote}
\begin{verbatim}
...
  author   = {Epifanov, Sasha {\relax Yu}ri and
...
\end{verbatim}
\end{quote}
(though no guarantee, that either of those names is right, is
offered!)
However, if you're typing the names in the ``natural'' (Western) way,
with given names first, the trick:
\begin{quote}
\begin{verbatim}
...
  author   = {P.M. {\relax de F.} Forster and
...
\end{verbatim}
\end{quote}
doesn't work~--- ``de F. Forster'' is treated as a compound family
names.


\subsection{Creating citations}

\Question[Q-usebibtex]{``Normal'' use of \BibTeX{} from \LaTeX{}}

To create a bibliography for your document, you need to perform a
sequence of steps, some of which seem a bit odd.  If you choose to use
\BibTeX{}, the sequence is:

First: you need a \BibTeX{} bibliography file (a \extension{bib} file)~--- see
\nothtml{``creating a \BibTeX{} file'' (\Qref[question]{}{Q-buildbib}).}
\begin{htmlversion}
``\Qref[question]{creating a \BibTeX{} file}{Q-buildbib}''.
\end{htmlversion}

Second: you must write your \LaTeX{} document to include a declaration
of the `style' of bibliography, citations, and a reference to the
bibliography file mentioned in the step 1.  So we may have a \LaTeX{}
file containing:
\begin{quote}
\begin{verbatim}
\bibliographystyle{plain}
...
Pooh is heroic~\cite{Milne:1926}.
...
Alice struggles~\cite{Carroll:1865}.
...
\bibliography{mybooks}
\end{verbatim}
\end{quote}
Note: we have bibliography style \Package{plain}, above, which is
nearly the simplest of the lot: a sample text, showing the sorts of
style choices available, can be found on Ken Turner's web site:
\URL{http://www.cs.stir.ac.uk/~kjt/software/latex/showbst.html}

Third: you must process the file.
\begin{quote}
\begin{verbatim}
latex myfile
\end{verbatim}
\end{quote}
As \LaTeX{} processes the file, the \csx{bibliographystyle} command
writes a note of the style to the \extension{aux} file; each
\csx{cite} command writes a note of the citation to the
\extension{aux} file, and the \csx{bibliography} command writes a note
of which \extension{bib} file is to be used, to the \extension{aux} file.

Note that, at this stage, \LaTeX{} isn't ``resolving'' any of the
citations: at every \csx{cite} command, \LaTeX{} will warn you of the
undefined citation, and when the document finishes, there will be a
further warning of undefined references.

%Some bibliography styles are designed to work with particular
%packages...

Fourth: you must run \BibTeX{}:
\begin{quote}
\begin{verbatim}
bibtex myfile
\end{verbatim}
\end{quote}
Don't try to tell \BibTeX{} anything but the file name: say
\texttt{bibtex myfile.aux} (because you know it's going to read the
\extension{aux} file) and \BibTeX{} will blindly attempt to process
\texttt{myfile.aux.aux}.

\BibTeX{} will scan the \extension{aux} file; it will find which bibliography
style it needs to use, and will ``compile'' that style; it will note
the citations; it will find which bibliography files it needs, and
will run through them matching citations to entries in the
bibliography; and finally it will sort the entries that have been
cited (if the bibliography style specifies that they should be
sorted), and outputs the resulting details to a \extension{bbl} file.

Fifth: you run \LaTeX{} again.  It warns, again, that each citation is
(still) undefined, but when it gets to the \csx{bibliography} command,
it finds a \extension{bbl} file, and reads it.  As it encounters each
\csx{bibitem} command in the file, it notes a definition of the
citation.

Sixth: you run \LaTeX{} yet again.  This time, it finds values for all
the citations, in its \extension{aux} file.  Other things being equal, you're
done\dots{} until you change the file.

If, while editing, you change any of the citations, or add new ones,
you need to go through the process above from steps 3 (first run of
\LaTeX{}) to 6, again, before the document is once again stable.
These four mandatory runs of \LaTeX{} make processing a document with
a bibliography even more tiresome than the normal two runs required to
resolve labels.

To summarise: processing to resolve citations requires: \LaTeX{};
\BibTeX{}; \LaTeX{}; \LaTeX{}.

\Question[Q-whatbst]{Choosing a bibliography style}

A large proportion of people are satisfied with one of Patashnik's
original ``standard'' styles, \Package{plain}, \Package{unsrt},
\Package{abbrv} and \Package{alpha}.  However, no style in that set
supports the ``author-date'' citation style that is popular in many
fields; but there are a very large number of contributed styles
available, that \emph{do} support the format.

(Note that author-date styles arose because the simple and clear
citation style that \Package{plain} produces is so awkward in a
traditional manuscript preparation scenario.  However, \TeX{}-based
document production does away with all those difficulties, leaving us
free once again to use the simple option.)

Fortunately, help is at hand, on the Web, with this problem:
\begin{itemize}
\item a sample text, showing the sorts of style choices available, can
  be found on 
\begin{narrowversion}
  Ken Turner's web site:
  \URL{http://www.cs.stir.ac.uk/~kjt/software/latex/showbst.html};
\end{narrowversion}
\begin{wideversion}
  % ! line break
  \href{http://www.cs.stir.ac.uk/~kjt/software/latex/showbst.html}{Ken Turner's web site};
\end{wideversion}
\item an excellent survey, that lists a huge variety of styles,
  sorted into their nominal topics as well as providing a good range
  of examples, is the Reed College % ! line break
\begin{narrowversion}
  ``Choosing a \BibTeX{} style''
  (\URL{http://web.reed.edu/cis/help/LaTeX/bibtexstyles.html}).
\end{narrowversion}
\begin{wideversion}
  % ! line break
  ``\href{http://web.reed.edu/cis/help/LaTeX/bibtexstyles.html}{Choosing a \BibTeX{} style}''.
\end{wideversion}
\end{itemize}

Of course, these pages don't cover everything; the problem the
inquisitive user faces, in fact, is to find what the various available
styles actually do.  This is best achieved (if the links above don't
help) by using \Package{xampl.bib} from the \BibTeX{} documentation
distribution: one can get a pretty good feel for any style one has to
hand using this ``standard'' bibliography.  For style
\Package{my-style.bst}, the simple \LaTeX{} document:
\begin{quote}
\begin{verbatim}
\documentclass{article}
\begin{document}
\bibliographystyle{my-style}
\nocite{*}
\bibliography{xampl}
\end{document}
\end{verbatim}
\end{quote}
will produce a representative sample of the citations the style will
produce.  (Because \Package{xampl.bib} is so extreme in some of its
``examples'', the \BibTeX{} run will also give you an interesting
selection of \BibTeX{}'s error messages\dots{})
\begin{ctanrefs}
\item[xampl.bib]\CTANref{xampl-bib}
\end{ctanrefs}

\Question[Q-chapbib]{Separate bibliographies per chapter?}

A separate bibliography for each `chapter' of a document can be provided
with the package \Package{chapterbib} (which comes with a bunch of
other good bibliographic things).  The package allows you a
different bibliography for each \csx{include}d file (i.e., despite the
package's name, the availability of bibliographies is related to the
component source files of the document rather than to the chapters that
logically structure the document).

The package \Package{bibunits} ties bibliographies to logical units
within the document: the package will deal with chapters and sections
(as defined by \LaTeX{} itself) and also defines a \environment{bibunit}
environment so that users can select their own structuring.
\begin{ctanrefs}
\item[chapterbib.sty]\CTANref{cite}
\item[bibunits.sty]\CTANref{bibunits}
\end{ctanrefs}

\Question[Q-multbib]{Multiple bibliographies?}

If you're thinking of multiple bibliographies tied to some part of
your document (such as the chapters within the document), please see
\Qref[question]{bibliographies per chapter}{Q-chapbib}.

For more than one bibliography, there are three options.

The \Package{multibbl} package offers a very simple interface: you use
a command \csx{newbibliography} to define a bibliography ``tag''.  The package
redefines the other bibliography commands so that each time you use any one
of them, you give it the tag for the bibliography where you want the
citations to appear.  The \csx{bibliography} command itself also takes
a further extra argument that says what title to use for the resulting
section or chapter (i.e., it patches
\nothtml{\csx{refname} and \csx{bibname}~---}
\Qref{\csx{refname} and \csx{bibname}}{Q-fixnam}\nothtml{~---} in a
\Package{babel}-safe way).  So one might write:
\begin{narrowversion}
\begin{quote}
\begin{verbatim}
\usepackage{multibbl}
\newbibliography{bk}
\bibliographystyle{bk}{alpha}
\newbibliography{art}
\bibliographystyle{art}{plain}
...
\cite[pp.~23--25]{bk}{milne:pooh-corner}
...
\cite{art}{einstein:1905}
...
\bibliography{bk}{book-bib}%
             {References to books}
\bibliography{art}{art-bib}%
             {References to articles}
\end{verbatim}
\end{quote}
\end{narrowversion}
\begin{wideversion}
\begin{quote}
\begin{verbatim}
\usepackage{multibbl}
\newbibliography{bk}
\bibliographystyle{bk}{alpha}
\newbibliography{art}
\bibliographystyle{art}{plain}
...
\cite[pp.~23--25]{bk}{milne:pooh-corner}
...
\cite{art}{einstein:1905}
...
\bibliography{bk}{book-bib}{References to books}
\bibliography{art}{art-bib}{References to articles}
\end{verbatim}
\end{quote}
\end{wideversion}
(Note that the optional argument of \csx{cite} appears \emph{before} the
new tag argument, and that the \csx{bibliography} commands may list
more than one \extension{bib} file~--- indeed all \csx{bibliography} commands
may list the same set of files.)

The \csx{bibliography} data goes into files whose names are
\meta{tag-name}\emph{.aux}, so you will need to run
\begin{quote}
\begin{verbatim}
bibtex bk
bibtex art
\end{verbatim}
\end{quote}
after the first run of \LaTeX{}, to get the citations in the correct
place.

The \Package{multibib} package allows you to define a series of
``additional topics'', each of which comes with its own series of
bibliography commands.  So one might write:
\begin{quote}
\begin{verbatim}
\usepackage{multibib}
\newcites{bk,art}%
         {References from books,%
          References from articles}
\bibliographystylebk{alpha}
\bibliographystyleart{plain}
...
\citebk[pp.~23--25]{milne:pooh-corner}
...
\citeart{einstein:1905}
...
\bibliographybk{book-bib}
\bibliographyart{art-bib}
\end{verbatim}
\end{quote}
Again, as for \Package{multibbl}, any \csx{bibliography...} command may
scan any list of \extension{bib} files.

\BibTeX{} processing with \Package{multibib} is much like that with
\Package{multibbl}; with the above example, one needs:
\begin{quote}
\begin{verbatim}
bibtex bk
bibtex art
\end{verbatim}
\end{quote}
Note that, unlike \Package{multibbl}, \Package{multibib} allows a
simple, unmodified bibliography (as well as the ``topic'' ones).  

The \Package{bibtopic} package allows you separately to cite several
different bibliographies.  At the appropriate place in your document,
you put a sequence of \environment{btSect} environments (each of which
specifies a bibliography database to scan) to typeset the separate
bibliographies.  Thus, one might have a file \File{diss.tex} containing:
\begin{quote}
\begin{verbatim}
\usepackage{bibtopic}
\bibliographystyle{alpha}
...
\cite[pp.~23--25]{milne:pooh-corner}
...
\cite{einstein:1905}
...
\begin{btSect}{book-bib}
\section{References from books}
\btPrintCited
\end{btSect}
\begin{btSect}[plain]{art-bib}
\section{References from articles}
\btPrintCited
\end{btSect}
\end{verbatim}
\end{quote}
Note the different way of specifying a bibliographystyle: if you want
a different style for a particular bibliography, you may give it as an
optional argument to the \environment{btSect} environment.

Processing with \BibTeX{}, in this case, uses \extension{aux} files whose names
are derived from the name of the base document.  So in this example
you need to say:
\begin{quote}
\begin{verbatim}
bibtex diss1
bibtex diss2
\end{verbatim}
\end{quote}

There is also a command \csx{btPrintNotCited}, which gives the rest of
the content of the database (if nothing has been cited from the
database, this is equivalent to \LaTeX{} standard \cmdinvoke{nocite}{*}).

However, the \emph{real} difference from \Package{multibbl} and
\Package{multibib} is that selection of what appears in each
bibliography section is determined in \Package{bibtopic} by what's in
the \extension{bib} files.

An entirely different approach is taken by the \Package{splitbib}
package.  You provide a \environment{category} environment, in the
preamble of your document, for each category you want a separate
citation list for.  In each environment, you list the \csx{cite} keys
that you want listed in each category.  The \csx{bibliography} command
(or, more precisely, the \environment{thebibliography} environment it
uses) will sort the keys as requested.  (Keys not mentioned in a
\environment{category} appear in a ``misc'' category created in the
sorting process.)  A code example appears in the package documentation
(a \acro{PDF} file in the \acro{CTAN} directory,
\begin{htmlversion}
  which you can browse to, from the link, below).
\end{htmlversion}
\htmlignore
  see the file list, below).
\endhtmlignore
\begin{ctanrefs}
\item[bibtopic.sty]\CTANref{bibtopic}
\item[multibbl.sty]\CTANref{multibbl}
\item[multibib.sty]\CTANref{multibib}
\item[splitbib.sty]\CTANref{splitbib}
\end{ctanrefs}


\Question[Q-bibinline]{Putting bibliography entries in text}

This is a common requirement for journals and other publications in
the humanities.  Sometimes the requirement is for the entry to appear
in the running text of the document, while other styles require that
the entry appear in a footnote.

Options for entries in running text are
\begin{itemize}
\item The package \Package{bibentry}, which puts slight restrictions
  on the format of entry that your \extension{bst} file generates, but is
  otherwise undemanding of the bibliography style.
\item The package \Package{inlinebib}, which requires that you use its
  \File{inlinebib.bst}.  \Package{Inlinebib} was actually designed for
  footnote citations: its \emph{expected} use is that you place a
  citation inline as the argument of a \csx{footnote} command.
\item The package \Package{jurabib}, which was originally designed for
  German law documents, and has comprehensive facilities for the
  manipulation of citations.  The package comes with four bibliography
  styles that you may use: \File{jurabib.bst}, \File{jhuman.bst} and
  two Chicago-like ones.
\end{itemize}

Options for entries in footnotes are
\begin{itemize}
\item The package \Package{footbib}, and
\item Packages \Package{jurabib} and \Package{inlinebib}, again.
\end{itemize}
Note that \Package{jurabib} does the job using \LaTeX{}'s standard
footnotes, whereas \Package{footbib} creates its own sequence of
footnotes.  Therefore, in a document which has other footnotes, it may
be advisable to use \Package{jurabib} (or of course
\Package{inlinebib}), to avoid confusion of footnotes and foot-citations.
\begin{ctanrefs}
\item[bibentry.sty]\emph{Distributed with} \CTANref{natbib}
\item[footbib.sty]\CTANref{footbib}
\item[inlinebib.sty]\CTANref{inlinebib}
\item[jurabib.sty]\CTANref{jurabib}
\end{ctanrefs}

\Question[Q-citesort]{Sorting and compressing citations}

If you give \LaTeX{}
\cmdinvoke{cite}{fred,joe,harry,min}, its default commands could give
something like ``[2,6,4,3]'';
this looks awful.  One can of course get the things in order by
rearranging the keys in the \csx{cite} command, but who wants to do
that sort of thing for no more improvement than ``[2,3,4,6]''?

The \Package{cite} package sorts the numbers and detects consecutive
sequences, so creating ``[2--4,6]''.  The \Package{natbib} package,
with the \texttt{numbers} and \texttt{sort\&compress} options, will
do the same when working with its own numeric bibliography styles
(\File{plainnat.bst} and \File{unsrtnat.bst}).

If you might need to make hyperreferences to your citations,
\Package{cite} isn't adequate.  If you add the \Package{hypernat}
package:
\begin{verbatim}
  \usepackage[...]{hyperref}
  \usepackage[numbers,sort&compress]{natbib}
  \usepackage{hypernat}
  ...
  \bibliographystyle{plainnat}
\end{verbatim}
the \Package{natbib} and \Package{hyperref} packages will interwork.
\begin{ctanrefs}
\item[cite.sty]\CTANref{cite}
\item[hypernat.sty]\CTANref{hypernat}
\item[hyperref.sty]\CTANref{hyperref}
\item[plainnat.bst]Distributed with \CTANref{natbib}
\item[unsrtnat.bst]Distributed with \CTANref{natbib}
\end{ctanrefs}

\Question[Q-mcite]{Multiple citations}

A convention sometimes used in physics journals is to ``collapse'' a group of
related citations into a single entry in the bibliography.  \BibTeX{},
by default, can't cope with this arrangement, but the \Package{mcite}
package deals with the problem.

The package overloads the \csx{cite} command to recognise a
``\texttt{*}'' at the start of a key, so that citations of the form
\begin{quote}
\begin{verbatim}
\cite{paper1,*paper2}
\end{verbatim}
\end{quote}
appear in the document as a single citation, and appear arranged
appropriately in the bibliography itself.  You're not limited to
collapsing just two references.  You can mix ``collapsed'' references
with ``ordinary'' ones, as in
\begin{quote}
\begin{verbatim}
\cite{paper0,paper1,*paper2,paper3}
\end{verbatim}
\end{quote}
Which will appear in the document as 3~citations ``[4,7,11]''
(say)~--- citation `4' will refer to paper~0, `7' will refer to a
combined entry for paper~1 and paper~2, and `11' will refer to
paper~3.

You need to make a small change to the bibliography style
(\extension{bst}) file you use; the \Package{mcite} package
documentation tells you how to do that.

Unfortunately, the \Class{revtex} system doesn't play with
\Package{mcite}.  As a result, for that (primarily physics-targeted
system) you need to play silly games like:
\begin{quote}
\begin{verbatim}
\cite{paper0,paper1,paper3}
\nocite{paper2}
\end{verbatim}
\end{quote}
and then edit the \extension{bbl} file to merge the two citations, to
achieve the effects of \Package{mcite}.
\begin{ctanrefs}
\item[mcite.sty]\CTANref{mcite}
\item[revtex \nothtml{\rmfamily}bundle]\CTANref{revtex}
\end{ctanrefs}

\Question[Q-backref]{References from the bibliography to the citation}

A link (or at least a page reference), from the bibliography to the
citing command, is often useful in large documents.

Two packages support this requirement, \Package{backref} and
\Package{citeref}.  \Package{Backref} is part of the
\Package{hyperref} bundle, and supports hyperlinks back to the citing
command.  \Package{Citeref} is the older, and seems to rely on rather
simpler (and therefore possibly more stable) code.  Neither collapses
lists of pages (``\texttt{5, 6, 7}'' comes out as such, rather than as
``\texttt{5--7}''), but neither package repeats the reference to a page that
holds multiple citations.  (The failure to collapse lists is of course
forgiveable in the case of the \Package{hyperref}-related
\Package{backref}, since the concept of multiple hyperlinks from the
same anchor is less than appealing.)
\begin{ctanrefs}
\item[backref.sty]Distributed with \CTANref{hyperref}
\item[citeref.sty]\CTANref{citeref}
\end{ctanrefs}

\Question[Q-sortbib]{Sorting lists of citations}

\BibTeX{} has a sorting function, and most \BibTeX{} styles sort the
citation list they produce; most people find this desirable.

However, it is perfectly possible to write a
\environment{thebibliography} environment that \emph{looks} as if it
came from \BibTeX{}, and many people do so (in order to save time in
the short term).

The problem arises when \environment{thebibliography}-writers decide
their citations need to be sorted.  A common misapprehension is to
insert \cmdinvoke{bibliographystyle}{alpha} (or similar) and expect
the typeset output to be sorted in some magical way.  \BibTeX{}
doesn't work that way!~--- if you write \environment{thebibliography},
you get to sort its contents.  \BibTeX{} will only sort the contents
of a \environment{thebibliography} environment when it creates it, to
be inserted from a \extension{bbl} file by a \csx{bibliography} command.

\Question[Q-compactbib]{Reducing spacing in the bibliography}

Bibliographies are, in fact, implemented as lists, so all the
confusion about \Qref*{reducing list item spacing}{Q-complist} also
applies to bibliographies.

If the \Package{natbib} package `works' for you (it may not if you are using
some special-purpose bibliography style), the solution is relatively
simple~--- add
\begin{quote}
\begin{verbatim}
\usepackage{natbib}
\setlength{\bibsep}{0.0pt}
\end{verbatim}
\end{quote}
to the preamble of your document.

Otherwise, one is into unseemly hacking of something or other.  The
\Package{mdwlist} package actually does the job, but it doesn't work
here, because it makes a different-named list, while the name
``\environment{thebibliography}'' is built into \LaTeX{} and
\BibTeX{}.  Therefore, we need to % ! line break
\Qref*{patch the underlying macro}{Q-patch}:
\begin{quote}
\begin{verbatim}
\let\oldbibliography\thebibliography
\renewcommand{\thebibliography}[1]{%
  \oldbibliography{#1}%
  \setlength{\itemsep}{0pt}%
}
\end{verbatim}
\end{quote}
The \Package{savetrees} package performs such a patch, among a
plethora of space-saving measures: you can, in principle, suppress all
its other actions, and have it provide you a compressed bibliography
\emph{only}.
\begin{ctanrefs}
\item[mdwlist.sty]Distributed as part of \CTANref{mdwtools}
\item[natbib.sty]\CTANref{natbib}
\item[savetrees.sty]\CTANref{savetrees}
\end{ctanrefs}

\Question[Q-bibtocorder]{Table of contents rearranges ``\Package{unsrt}'' ordering}

If you're using the \Package{unsrt} bibliography style, you're
expecting that your bibliography will \emph{not} be sorted, but that
the entries will appear in the order that they first appeared in your
document.

However, if you're unfortunate enough to need a citation in a section
title, and you also have a table of contents, the citations that now
appear in the table of contents will upset the ``natural'' ordering
produced by the \Package{unsrt} style.  Similarly, if you have
citations in captions, and have a list of figures (or tables).

There's a pretty simple ``manual'' method for dealing with the
problem~--- when you have the document stable:
\begin{enumerate}
\item Delete the \extension{aux} file, and any of \extension{toc},
  \extension{lof}, \extension{lot} files.
\item Run \LaTeX{}.
\item Run \BibTeX{} for the last time.
\item Run \LaTeX{} often enough that things are stable again.
\end{enumerate}
Which is indeed simple, but it's going to get tedious when you've
found errors in your ``stable'' version, often enough.

The package \Package{notoccite} avoids the kerfuffle, and suppresses
citations while in the table of contents, or lists of figures, tables
(or other floating things: the code is quite general).
\begin{ctanrefs}
\item[notoccite.sty]\CTANref{notoccite}
\end{ctanrefs}

\Question[Q-i18nbib]{Non-english bibliographies}

Like so much of early \AllTeX{} software, \BibTeX{}'s assumptions were
firmly rooted in what its author knew well, viz., academic papers in
English (particularly those with a mathematical bent).  \BibTeX{}'s
standard styles all address exactly that problem, leaving the user who
writes in another language (or who deal with citations in the style of
other disciplines than maths) to strike out into contributed software.

For the user whose language is not English, there are several
alternatives.  The simplest is to provide translations of \BibTeX{}
styles into the required language: the solitary \Package{finplain.bst}
does that for Finnish; others one can find are for Danish
(\Package{dk-bib}), French (\Package{bib-fr}), German
(\Package{bibgerm}), Norwegian (\Package{norbib}) and Swedish
(\Package{swebib}) bundles (of which the \Package{bib-fr} set is the
most extensive).  The \Package{spain} style implements a traditional
Spanish citation style.

These static approaches solve the problem, for the languages that have
been covered by them.  Unfortunately, with such an approach, a lot of
work is needed for every language involved.  Two routes to a solution
of the ``general'' problem are available~--- that offered by
\Package{babelbib}, and the % ! line break
\Qref*{\Package{custom-bib} mechanism for generating styles}{Q-custbib}.

\Package{Babelbib} (which is a development of the ideas of the
\Package{bibgerm} package) co-operates with \Package{babel} to control
the language of presentation of citations (potentially at the level of
individual items).  The package has a built-in set of languages it
`knows about', but the documentation includes instructions on defining
commands for other languages.  \Package{Babelbib} comes with its own
set of bibliography styles, which could be a restriction if there
wasn't also a link from \Package{custom-bib}.

The \Package{makebst} menu of \Package{custom-bib} allows you to
choose a language for the \BibTeX{} style you're generating (there are
14 languages to choose; it looks as if \Package{spain.bst}, mentioned
above, was generated this way).  If, however, you opt not to specify a
language, you are asked whether you want the style to interact with
\Package{babelbib}; if you do so, you're getting the best of both
worlds~--- formatting freedom from \Package{custom-bib} and linguistic
freedom via the extensibility of \Package{babelbib}
\begin{ctanrefs}
\item[babelbib.sty]\CTANref{babelbib}
\item[bib-fr \nothtml{\rmfamily\upshape}bundle]\CTANref{bib-fr}
\item[bibgerm \nothtml{\rmfamily\upshape}bundle]\CTANref{bibgerm}
\item[custom-bib \nothtml{\rmfamily\upshape}bundle]\CTANref{custom-bib}
\item[finplain.bst]\CTANref{finplain}
\item[norbib \nothtml{\rmfamily\upshape}bundle]\CTANref{norbib}
\item[spain]\CTANref{spain}
\item[swebib \nothtml{\rmfamily\upshape}bundle]\CTANref{swebib}
\end{ctanrefs}

\Question[Q-formbiblabel]{Format of numbers in the bibliography}

By default, \LaTeX{} makes entries in the bibliography look like:
\begin{quote}
  [1] Doe, Joe et al.  Some journal.  2004.\\ {}
  [2] Doe, Jane et al. Some journal. 2003.
\end{quote}
while many documents need something like:
\begin{quote}
  1. Doe, Joe et al.  Some journal.  2004.\\
  2. Doe, Jane et al. Some journal. 2003.
\end{quote}

This sort of change may be achieved by many of the ``general''
citation packages; for example, in \Package{natbib}, it's as simple as:
\begin{quote}
\begin{verbatim}
\renewcommand{\bibnumfmt}[1]{#1.}
\end{verbatim}
\end{quote}
but if you're not using such a package, the following internal
\LaTeX{} commands, in the preamble of your document, will do the job:
\begin{quote}
\begin{verbatim}
\makeatletter
\renewcommand*{\@biblabel}[1]{\hfill#1.}
\makeatother
\end{verbatim}
\end{quote}
\begin{ctanrefs}
\item[natbib.sty]\CTANref{natbib}
\end{ctanrefs}

\subsection{Manipulating whole bibliographies}

\Question[Q-nocite*]{Listing all your \BibTeX{} entries}

\LaTeX{} and \BibTeX{} co-operate to offer special treatment of this
requirement.  The command \cmdinvoke{nocite}{*} is specially treated,
and causes \BibTeX{} to generate bibliography entries for every entry
in each \extension{bib} file listed in your \csx{bibliography} statement, so
that after a \LaTeX{}--\BibTeX{}--\LaTeX{} sequence, you have a
document with the whole thing listed.

Note that \LaTeX{} \emph{doesn't} produce
% beware line breaks
``\texttt{Citation ... undefined}'' or
``\texttt{There were undefined references}'' warnings in respect of
\cmdinvoke{nocite}{*}.  This isn't a problem if you're running
\LaTeX{} ``by hand'' (you \emph{know} exactly how many times you have
to run things), but the lack might confuse automatic processors that
scan the log file to determine whether another run is necessary.

A couple of packages are available, that aim to reduce the impact of
\cmdinvoke{nocite}{*} of a large citation database.  \Package{Biblist}
was written for use under \LaTeXo{}, but seems to work well enough;
\Package{listbib} is more modern.  Both provide their own
\extension{bst} files.  (The impact of large databases was significant
in the old days of \LaTeX{} systems with very little free memory; this
problem is less significant now than it once was.)
\begin{ctanrefs}
\item[biblist.sty]\CTANref{biblist}
\item[listbib.sty]\CTANref{listbib}
\end{ctanrefs}

\Question[Q-htmlbib]{Making \acro{HTML} of your Bibliography}

A neat solution is offered by the \Package{noTeX} bibliography style.
This style produces a \extension{bbl} file which is in fact a series of
\acro{HTML} `\texttt{P}' elements of class \texttt{noTeX}, and which
may therefore be included in an \acro{HTML} file.  Provision is made
for customising your bibliography so that its content when processed by
\Package{noTeX} is different from that presented when it is processed
in the ordinary way by \AllTeX{}.

A thorough solution is offered by \Package{bib2xhtml}; using it, you
make use of one of its modified versions of many common \BibTeX{}
styles, and post-process the output so produced using a
\ProgName{perl} script.

A more conventional translator is the \ProgName{awk} script
\ProgName{bbl2html}, which translates the \extension{bbl} file you've generated:
a sample of the script's output may be viewed on the web, at
\URL{http://rikblok.cjb.net/lib/refs.html}
\begin{ctanrefs}
\item[bbl2html.awk]\CTANref{bbl2html}
\item[bib2xhtml]\CTANref{bib2xhtml}
\item[noTeX.bst]\CTANref{noTeX}
\end{ctanrefs}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\section{Adjusting the typesetting}

\subsection{Alternative document classes}

\Question[Q-replstdcls]{Replacing the standard classes}

People are forever concocting classes that replace the standard ones:
the present author produced an \Class{ukart} class that used the
\Package{sober} package, and a few British-specific things (such as
appear in the \Package{babel} package's British-english
specialisation) in the 1980s, which is still occasionally used.

Similar public efforts were available well back in the days of
\LaTeXo{}: a notable example, whose pleasing designs seem not to have
changed much over all that time, is the \Class{ntgclass} bundle.
Each of the standard classes is replaced by a selection of classes,
named in Dutch, sometimes with a single numeric digit attached.  So we
have classes \Class{artikel2}, \Class{rapport1}, \Class{boek3} and
\Class{brief}.  These classes are moderately well documented in
English.

The \Class{KOMA-script} bundle (classes named \Class{scr...}) are a
strong current contender.  They are actively supported, are
comprehensive in their coverage of significant typesetting issues,
produce good-looking output and are well documented in both English
and German (\Package{scrguien} in the distribution for English,
\Package{scrguide} for German).

The other comparable class is \Class{memoir}.  This aims to replace
\Class{book} and \Class{report} classes directly, and (like
\Class{KOMA-script}) is comprehensive in its coverage of small issues.
\Class{Memoir}'s documentation (\Package{memman}) is very highly
spoken of, and its lengthy introductory section is regularly
recommended as a tutorial on typesetting.
\begin{ctanrefs}
\item[\nothtml{\rmfamily}KOMA-script bundle]\CTANref{koma-script}
\item[memoir.cls]\CTANref{memoir}
\item[\nothtml{\rmfamily}NTGclass bundle]\CTANref{ntgclass}
\item[sober.sty]\CTANref{sober}
\end{ctanrefs}

\Question[Q-slidecls]{Producing slides}

Lamport's original \LaTeX{} had a separate program (Sli\TeX{}) for
producing slides; it dates from the age when colour effects were
produced by printing separate slides in different-coloured inks, and
overlaying them, and was just about acceptable back then.  When
\LaTeXe{} came along, the reason Sli\TeX{} had to be a separate
program went away, and its functionality was supplied by the
\Class{slides} class.  While this makes life a little easier for
system administrators, it does nothing for the inferior functionality
of the class: no-one ``who knows'' uses \Class{slides} nowadays.

The `classic' alternatives have been \Class{seminar} and \Class{foils}
(originally known as Foil\TeX{}).  Both were originally designed to
produce output on acetate foils, though subsequent work has provided
environments in which they can be used with screen projectors (see
below).

The advent of Microsoft \ProgName{PowerPoint} (feeble though early
versions of it were) has created a demand for ``dynamic'' slides~---
images that develop their content in a more elaborate fashion than by
merely replacing one foil with the next in the way that was the norm
when \Class{slides}, \Class{foils} and \Class{seminar} were designed.

The \Class{prosper} class builds on \Class{seminar} to provide dynamic
effects and the like; it retains the ability to provide \acro{PDF} for
a projected presentation, or to print foils for a foil-based
presentation.  The add-on package \Package{ppr-prv} adds ``preview''
facilities (that which is commonly called ``hand-out printing'').  The
\Package{HA-prosper} package, which you load with \Class{prosper},
mends a few bugs, and adds several facilities and slide design styles.
The (relatively new) \Class{powerdot} class is designed as a
replacement for \Class{prosper} and \Package{HA-prosper}, co-authored
by the author of \Package{HA-prosper}.

\Class{Beamer} is a relatively easy-to-learn, yet powerful, class that
(as its name implies) was designed for use with projection displays.
It needs the \Package{pgf} package (for graphics support), which in
turn requires \Package{xcolor}; while this adds to the tedium of
installing \Class{beamer} ``from scratch'', both are good additions to
a modern \LaTeX{} installation.  \Class{Beamer} has reasonable
facilities for producing printed copies of slides.

\Class{Talk} is another highly functional, yet easy-to-learn class
which claims to differ from the systems mentioned above, such as
\Class{beamer}, in that it doesn't impose a slide style on you.  You
get to specify a bunch of slide styles, and you can switch from one to
the other between slides, as you need.  (The class itself provides
just the one style, in the package \Package{greybars}: the author
hopes users will contribute their own styles, based on
\Package{greybars}.)

\ProgName{Ppower4} (commonly known as \ProgName{pp4}) is a
\ProgName{Java}-based support program that will postprocess
\acro{PDF}, to `animate' the file at places you've marked with
commands from one of the \ProgName{pp4} packages.  The commands don't
work on \acro{PDF} that has come from \ProgName{dvips} output; they
work with \acro{PDF} generated by \PDFLaTeX{}, V\TeX{} \LaTeX{}, or
\ProgName{dvipdfm} running on \LaTeX{} output.

\Package{Pdfscreen} and \Package{texpower} are add-on packages that
permit dynamic effects in documents formatted in ``more modest''
classes; \Package{pdfscreen} will even allow you to plug
``presentation effects'' into an \Class{article}-class document.

% ifmslide
%\noindent ifmslide: a few slides extolling virtues in \File{doc/ifmman.pdf}

A more detailed examination of the alternatives (including examples
of code using many of them) may be found at Michael Wiedmann's fine
\URL{http://www.miwie.org/presentations/presentations.html}

\CONTeXT{} users will find that much (if not all) of what they need is
already in \CONTeXT{} itself; there's a useful summary of what's
available, with examples, in
\URL{http://wiki.contextgarden.net/Presentation_Styles}
% 
\begin{ctanrefs}
\item[beamer.cls]Download all of \CTANref{beamer}
\item[foils.cls]\CTANref{foiltex}
\item[greybars.sty]distributed with \CTANref{talk}
\item[HA-prosper.sty]\CTANref{ha-prosper}
%\item[ifmslide.sty]\CTANref{ifmslide}
\item[seminar.cls]\CTANref{seminar}
\item[pgf.sty]\CTANref{pgf}
\item[powerdot.cls]\CTANref{powerdot}
\item[pp4]\CTANref{ppower4}
\item[ppr-prv.sty]\CTANref{ppr-prv}
\item[prosper.cls]\CTANref{prosper}
\item[talk.cls]\CTANref{talk}
\item[texpower]\CTANref{texpower}
\item[xcolor.sty]\CTANref{xcolor}
\end{ctanrefs}

\Question[Q-poster]{Creating posters with \LaTeX{}}

There is no complete ``canned solution'' to creating a poster (as, for
example, classes like \Class{seminar}, \Class{powerdot} and
\Class{beamer} serve for creating presentations in a variety of
styles).

The nearest approach to the complete solution is the \Class{sciposter}
class, which provides the means to produce really rather good posters
according to the author's required style.  A complete worked example
is provided with the distribution

Otherwise, there is a range of tools, most of which are based on the
\Class{a0poster} class, which sets up an appropriately-sized piece of
paper, sets font sizes appropriately, and leaves you to your own
devices.

Having used \Class{a0poster}, you can of course slog it out, and write
all your poster as an unadorned \LaTeX{} document (presumably in
multiple columns, using the \Package{multicol} package), but it's not really
necessary: the (straightforward) \Package{textpos} package provides a
simple way of positioning chunks of text, or tables or figures, on the
poster page.

More sophisticated is the \Package{flowfram} package, whose basic aim
in life is flowing text from one box on the page to the next.  One of
the package's design aims seems to have been the production of
posters, and a worked example is provided.  The author of
\Package{flowfram} has an experimental tool called
\href{http://theoval.cmp.uea.ac.uk/~nlct/jpgfdraw/}{JpgfDraw}, which
allows you to construct the outline of frames for use with
\Package{flowfram}.

Despite the relative shortage of tools, there are a fair few web pages
that explain the process (mostly in terms of the \Class{a0poster}
route):
\begin{itemize}
\item from Norman Gray,
  \href{http://nxg.me.uk/docs/posters/}{Producing posters using \LaTeX{}};
\item from Nicola Talbot, % ! line break
  \href{http://theoval.sys.uea.ac.uk/~nlct/latex/posters/index.html}{Creating technical posters with \LaTeX{}}
\item from ``\emph{awf}'' and ``\emph{capes}'' % ! line break
  \href{http://www.robots.ox.ac.uk/~awf/latex-posters/}{Preparing conference posters in \LaTeX{}}
  (the page discusses a sample, which you can download);
\item From Rob Clark % ! line break
  \href{http://homepages.inf.ed.ac.uk/robert/posters/advanced.html}{Advanced LaTeX Posters}
  (which has links to code samples);
\item from Brian Wolven,
  \URL{http://fuse.pha.jhu.edu/~wolven/posters.html} (this page also
  provides macros and other support suggestions); and
\item from ``\emph{pjh}'' % ! line break
  \href{http://www.phys.ufl.edu/~pjh/posters/poster_howto_UF.html}{Making and printing a poster with \LaTeX{}},
  which covers the specific issue of dealing with University of
  Florida styled poster (offering supporting material as necessary),
  but has hints which are generally useful.
\end{itemize}
\begin{ctanrefs}
\item[a0poster.cls]\CTANref{a0poster}
\item[flowfram.sty]\CTANref{flowfram}
\item[multicol.sty]Distributed as part of \CTANref{2etools}
\item[sciposter.cls]\CTANref{sciposter}
\item[textpos.sty]\CTANref{textpos}
\end{ctanrefs}

\Question[Q-thesis]{Formatting a thesis in \LaTeX{}}

Thesis styles are usually very specific to your University, so it's
usually not profitable to ask around for a package outside your own
University.  Since many Universities (in their eccentric way) still
require double-spacing, you may care to refer to
\Qref[question]{the relevant question}{Q-linespace}.
If you want to write your own, a good place to start is the University
of California style, but it's not worth going to a lot of trouble. (If
officials won't allow standard typographic conventions, you won't be
able to produce an \ae{}sthetically pleasing document anyway!)
\begin{ctanrefs}
\item[UC thesis style]\CTANref{ucthesis}
\end{ctanrefs}

\Question[Q-journalpaper]{Setting papers for journals}

Publishers of journals have a wide range of requirements for the
presentation of papers, and while many publishers do accept electronic
submissions in \AllTeX{}, they don't often submit recommended macros to
public archives.

Nevertheless, there are considerable numbers of macros of one sort or
another available on \acro{CTAN}; searching for your journal name in
the CTAN catalogue (see % ! line wrap
\Qref[question]{searching \acro{CTAN}}{Q-findfiles})
may well turn up what you're seeking.

Failing that, you may be well advised to contact the prospective
publisher of your paper; many publishers have macros on their own web
sites, or otherwise available only upon application.

Check that the publisher is offering you macros suitable to an
environment you can use: a few still have no macros for current
\LaTeX{}, for example, claiming that \LaTeXo{} is good enough\dots{}

Some publishers rekey anything sent them anyway, so that it doesn't
really matter what macros you use.  Others merely encourage you to use
as few extensions of a standard package as possible, so that they will
find it easy to transform your paper to their own internal form.

\Question[Q-multidoc]{A `report' from lots of `article's}

This is a requirement, for example, if one is preparing the
proceedings of a conference whose papers were submitted in \LaTeX{}.

The nearest things to canned solutions are Peter Wilson's
\Class{combine} and Federico Garcia's \Class{subfiles} classes.

\Class{Combine} defines the means to `\csx{import}' entire documents,
and provides means of specifying significant features of the layout of
the document, as well as a global table of contents, and so on.  An
auxiliary package, \Package{combinet}, allows use of the \csx{title}s
and \csx{author}s (etc.\@) of the \csx{import}ed documents to appear in
the global table of contents.

\Class{Subfiles} is used in the component files of a multi-file
project, and the corresponding \Package{subfiles} is used in the
master file; arrangements may be made so that the component files will
be typeset using different page format, etc., parameters than those
used when they are typeset as a part of the main file.

A more `raw' toolkit is offered by Matt Swift's \Package{includex} and
\Package{newclude} packages, both part of the \Package{frankenstein}
bundle.  Note that Matt believes \Package{includex} is obsolete
(though it continues to work for this author); furthermore, its
replacement, \Package{newclude} remains ``in development'', as it has
been since 1999.

Both \Package{includex} and \Package{newclude} enable you to
`\csx{includedoc}' complete articles (in the way that you
`\csx{include}' chapter files in an ordinary report).  The preamble
(everything up to \cmdinvoke{begin}{document}), and everything after
\cmdinvoke{end}{document}, is ignored by both packages.  Thus the
packages don't ``do the whole job'' for you, though: you need to
analyse the package use of the individual papers, and ensure that a
consistent set is loaded in the preamble of the main report.  (Both
packages require \Package{moredefs}, which is also part of the bundle.)

A completely different approach is to use the \Package{pdfpages}
package, and to include articles submitted in \acro{PDF} format into a
a \acro{PDF} document produced by \PDFLaTeX{}.  The package
defines an \csx{includepdf} command, which takes arguments similar to
those of the \csx{includegraphics} command.  With keywords in the
optional argument of the command, you can specify which pages you want
to be included from the file named, and various details of the layout
of the included pages.
\begin{ctanrefs}
\item[combine.cls]\CTANref{combine}
\item[combinet.sty]\CTANref{combine}
\item[includex.sty]Distributed in the ``unsupported'' part of
  \CTANref{frankenstein}
\item[moredefs.sty]Distributed as part of \CTANref{frankenstein}
\item[newclude.sty]Distributed as part of \CTANref{frankenstein}
\item[pdfpages.sty]\CTANref{pdfpages}
\item[subfiles.cls, etc.]\CTANref{subfiles}
\end{ctanrefs}

\Question[Q-cv]{\emph{Curriculum Vitae} (R\'esum\'e)}

Andrej Brodnik's class, \Class{vita}, offers a framework for producing
a \emph{curriculum vitae}.  The class may be customised both for
subject (example class option files support both computer scientists
and singers), and for language (both the options provided are
available for both English and Slovene).  Extensions may be written by
creating new class option files, or by using macros defined in the
class to define new entry types, etc.

Didier Verna's class, \Class{curve}, is based on a model in which
the \acro{CV} is made of a set of \emph{rubrics} (each one dealing
with a major item that you want to discuss, such as `education', `work
experience', etc).  The class's documentation is supported by a couple
of example files, and an emacs mode is provided.

Xavier Danaux offers a class \Class{moderncv} which supports
typesetting modern \emph{curricula vitarum}, both in a classic and in a
casual style. It is fairly customizable, allowing you to define your
own style by changing the colours, the fonts, etc.

The European Commission has recommended a format for % ! line break
\emph{curricula vitarum} within Europe, and Nicola Vitacolonna has
developed a class \Class{europecv} to produce it.  While (by his own
admission) the class doesn't solve all problems, it seems well-thought
out and supports all current official EU languages (together with a
few non-official languages, such as Catalan, Galician and Serbian).

The alternative to using a separate class is to impose a package on
one of the standard classes.  An example,
Axel Reichert's \Package{currvita} package, has been recommended to the
\acro{FAQ} team.  Its output certainly looks good.

There is also a \LaTeXo{} package \Package{resume}, which comes with
little but advice \emph{against} trying to use it.
\begin{ctanrefs}
\item[currvita.sty]\CTANref{currvita}
\item[curve.cls]\CTANref{curve}
\item[europecv.cls]\CTANref{europecv}
\item[moderncv.cls]\CTANref{moderncv}
\item[resume.sty]\CTANref{resume}
\item[vita.cls]\CTANref{vita}
\end{ctanrefs}

\Question[Q-letterclass]{Letters and the like}

\LaTeX{} itself provides a \Class{letter} document class, which is
widely disliked; the present author long since gave up trying with
it.  If you nevertheless want to try it, but are irritated by its way
of vertically-shifting a single-page letter, try the following hack:
\begin{verbatim}
\makeatletter
\let\@texttop\relax
\makeatother
\end{verbatim}
in the preamble of your file.

Doing-it-yourself is a common strategy; Knuth (for use with
\plaintex{}, in the \TeX{}book), and Kopka and Daly (in their Guide to
\LaTeX{}) offer worked examples.

Nevertheless, there \emph{are} contributed alternatives~--- in fact
there are an awfully large number of them: the following list, of
necessity, makes but a small selection.

The largest, most comprehensive, class is \Class{newlfm}; the \texttt{lfm}
part of the name implies that the class can create letters, faxes and
memoranda.  The documentation is voluminous, and the package seems
very flexible.

Axel Kielhorn's \Class{akletter} class is the only other one,
recommended for inclusion in this \acro{FAQ}, whose documentation is
available in English.

The \Class{dinbrief} class, while recommended, is only documented in
German.

There are letter classes in each of the excellent
\Class{KOMA-script} (\Class{scrlttr2}: documentation is available in
English) and \Package{ntgclass} (\Class{brief}: documentation in Dutch
only) bundles.  While these are probably good (since the bundles
themselves inspire trust) they've not been specifically recommended by
any users.
\begin{ctanrefs}
\item[akletter.cls]\CTANref{akletter}
\item[brief.cls]Distributed as part of \CTANref{ntgclass}
\item[dinbrief.cls]\CTANref{dinbrief}
\item[newlfm.cls]\CTANref{newlfm}
\item[scrlttr2.cls]Distributed as part of \CTANref{koma-script}
\end{ctanrefs}

\Question[Q-extsizes]{Other ``document font'' sizes?}

The \LaTeX{} standard classes have a concept of a (base) ``document
font'' size; this size is the basis on which other font sizes (those
from \csx{tiny} to \csx{Huge}) are determined.  The classes are designed
on the assumption that they won't be used with sizes other than the
set that \LaTeX{} offers by default (10--12pt), but people regularly
find they need other sizes.  The proper response to such a requirement
is to produce a new design for the document, but many people don't
fancy doing that.

A simple solution is to use the \Package{extsizes} bundle.  This
bundle offers ``extended'' versions of the article, report, book and
letter classes, at sizes of 8, 9, 14, 17 and 20pt as well as the
standard 10--12pt.  Since little has been done to these classes other
than to adjust font sizes and things directly related to them, they
may not be optimal~--- but they're certainly practical.

More satisfactory are the \emph{\acro{KOMA}-script} classes, which are
designed to work properly with the class option files that come with
\Package{extsizes}, and the \Class{memoir} class that has its own
options for document font sizes 9pt, 14pt and 17pt.
\begin{ctanrefs}
\item[extsizes bundle]\CTANref{extsizes}
\item[\nothtml{\rmfamily}KOMA script bundle]\CTANref{koma-script}
\item[memoir.cls]\CTANref{memoir}
\end{ctanrefs}

\subsection{Document structure}

\Question[Q-titlsty]{The style of document titles}

The \Package{titling} package provides a number of facilities that
permit manipulation of the appearance of a \csx{maketitle} command, the
\csx{thanks} commands within it, and so on.  The package also defines a
\environment{titlingpage} environment, that offers something in between the
standard classes' \pkgoption{titlepage} option and the \environment{titlepage}
environment, and is itself somewhat configurable.

The memoir class includes all the functionality of the
\Package{titling} package, while the \Class{KOMA-script} classes have
their own range of different titling styles.

Finally, the indefatigable Vincent Zoonekynd supplies examples of how
to program alternative % don't let this \href suffer a line-break
\href{http://zoonek.free.fr/LaTeX/LaTeX_samples_title/0.html}{title styles}.
The web page is not useful to users unless they are willing to do
their own \LaTeX{} programming.
\begin{ctanrefs}
\item[\nothtml{\rmfamily}KOMA script bundle]\CTANref{koma-script}
\item[memoir.cls]\CTANref{memoir}
\item[titling.sty]\CTANref{titling}
\end{ctanrefs}

\Question[Q-secthead]{The style of section headings}

Suppose that the editor of your favourite journal has specified that section
headings must be centred, in small capitals, and subsection headings ragged 
right in italic, but that you don't want to get involved in the sort of
programming described in section 2.2 of \emph{The \LaTeX{} Companion}
\begin{narrowversion} % really non-hyper
  (\Qref{}{Q-books}; the programming itself is discussed in
  \Qref[question]{}{Q-atsigns}).
\end{narrowversion}
\begin{wideversion} % really hyper
  (see \Qref{\TeX{}-related books}{Q-books}; the
  \Qref{programming}{Q-atsigns} itself is discussed elsewhere in this
  \acro{FAQ}).
\end{wideversion}
The following hack will 
probably satisfy your editor. Define yourself new commands
\begin{quote}
\begin{wideversion}
\begin{verbatim}
\newcommand{\ssection}[1]{%
  \section[#1]{\centering\normalfont\scshape #1}}
\newcommand{\ssubsection}[1]{%
  \subsection[#1]{\raggedright\normalfont\itshape #1}}
\end{verbatim}
\end{wideversion}
\begin{narrowversion} % really non-hyper
\begin{verbatim}
\newcommand{\ssection}[1]{%
  \section[#1]{\centering
               \normalfont\scshape #1}}
\newcommand{\ssubsection}[1]{%
  \subsection[#1]{\raggedright
                  \normalfont\itshape #1}}
\end{verbatim}
\end{narrowversion}
\end{quote}
and then use \csx{ssection} and \csx{ssubsection} in place of
\csx{section} and \csx{subsection}. This isn't perfect: section numbers
remain in bold, and starred forms need a separate redefinition.

The \Package{titlesec} package offers a structured approach to the
problem, based on redefinition of the sectioning and chapter commands
themselves.  This approach allows it to offer radical adjustment: its
options provide (in effect) a toolbox for designing your own
sectioning commands' output.

The \Package{sectsty} package provides a more simply structured set of
tools; while it is less powerful than is \Package{titlesec}, it is
perhaps preferable for minor adjustments, since you can use it after
having read a smaller proportion of the manual.

The \Package{fncychap} package provides a nice collection of customised
chapter heading designs.  The \Package{anonchap} package provides a
simple means of typesetting chapter headings ``like section headings''
(i.e., without the ``Chapter'' part of the heading); the
\Package{tocbibind} package provides the same commands, in pursuit of
another end.  Unfortunately, \Package{fncychap} is not attuned to the
existence of front- and backmatter in \Class{book} class documents.

The \Class{memoir} class includes facilities that match
\Package{sectsty} and \Package{titlesec}, as well as a bundle of
chapter heading styles (including an \Package{anonchap}-equivalent).
The \Class{KOMA-script} classes also have sets of tools that provide
equivalent functionality, notably formatting specifications \csx{partformat},
\csx{chapterformat}, \csx{sectionformat}, \dots{}, as well as several
useful overall formatting specifications defined in class options.

Finally, the indefatigable Vincent Zoonekynd supplies examples of how
to program alternative % don't let these \href suffer line-breaks
\href{http://zoonek.free.fr/LaTeX/LaTeX_samples_chapter/0.html}{chapter heading styles}
and
\href{http://zoonek.free.fr/LaTeX/LaTeX_samples_section/0.html}{section heading styles}.
The web pages are not useful to users unless they are willing to do
their own \LaTeX{} programming.
\begin{ctanrefs}
\item[anonchap.sty]\CTANref{anonchap}
\item[fncychap.sty]\CTANref{fncychap}
\item[\nothtml{\rmfamily}KOMA script bundle]\CTANref{koma-script}
\item[memoir.cls]\CTANref{memoir}
\item[sectsty.sty]\CTANref{sectsty}
\item[titlesec.sty]\CTANref{titlesec}
\item[tocbibind.sty]\CTANref{tocbibind}
\end{ctanrefs}

\Question[Q-appendix]{Appendixes}

\LaTeX{} provides an exceedingly simple mechanism for appendixes: the
command \csx{appendix} switches the document from generating sections
(in \Class{article} class) or chapters (in \Class{report} or
\Class{book} classes) to producing appendixes.  Section or chapter
numbering is restarted and the representation of the counter switches
to alphabetic.  So:
\begin{quote}
\begin{verbatim}
\section{My inspiration}
...

\section{Developing the inspiration}
...

\appendix
\section{How I became inspired}
...
\end{verbatim}
\end{quote}
would be typeset (in an \Class{article} document) something like:
\begin{quote}
\textbf{1~~My inspiration}

\dots{}

\textbf{2~~Developing the inspiration}

\dots{}

\textbf{A~~How I became inspired}

\dots{}
\end{quote}
which is quite enough for many ordinary purposes.  Note that, once
you've switched to typesetting appendixes, \LaTeX{} provides you with
no way back~--- once you've had an appendix, you can no longer have an
``ordinary'' \csx{section} or \csx{chapter}.

The \Package{appendix} provides several ways of elaborating on this
simple setup.  Straightforward use of the package allows you to have a
separate heading, both in the body of the document and the table of
contents; this would be achieved by
\begin{quote}
\begin{verbatim}
\usepackage{appendix}
...
\appendix
\appendixpage
\addappheadtotoc
\end{verbatim}
\end{quote}
The \csx{appendixpage} command adds a separate title ``Appendices''
above the first appendix, and \csx{addappheadtotoc} adds a similar
title to the table of contents.  These simple modifications cover many
people's needs about appendixes.

The package also provides an \environment{appendices} environment,
which provides for fancier use.  The environment is best controlled by
package options; the above example would be achieved by
\begin{quote}
\begin{verbatim}
\usepackage[toc,page]{appendix}
...
\begin{appendices}
...
\end{appendices}
\end{verbatim}
\end{quote}
The great thing that the \environment{appendices} environment gives
you, is that once the environment ends, you can carry on with sections
or chapters as before~--- numbering isn't affected by the intervening
appendixes.

The package provides another alternative way of setting appendixes, as
inferior divisions in the document.  The \environment{subappendices}
environment allows you to put separate appendixes for a particular
section, coded as \csx{subsection}s, or for a particular chapter, coded
as \csx{section}s.  So one might write:
\begin{quote}
\begin{verbatim}
\usepackage{appendix}
...
\section{My inspiration}
...
\begin{subappendices}
\subsection{How I became inspired}
...
\end{subappendices}

\section{Developing the inspiration}
...
\end{verbatim}
\end{quote}
Which will produce output something like:
\begin{quote}
\textbf{1~~My inspiration}

\dots{}

\textbf{1.A~~How I became inspired}

\dots{}

\textbf{2~~Developing the inspiration}

\dots{}
\end{quote}

There are many other merry things one may do with the package; the
user is referred to the package documentation for further details.

The \Class{memoir} class includes the facilities of the
\Package{appendix} package.  The \Class{KOMA-script} classes offer a
\csx{appendixprefix} command for manipulating the appearance of appendixes.
\begin{ctanrefs}
\item[appendix.sty]\CTANref{appendix}
\item[\nothtml{\rmfamily}KOMA script bundle]\CTANref{koma-script}
\item[memoir.cls]\CTANref{memoir}
\end{ctanrefs}

\Question[Q-secindent]{Indent after section headings}

\LaTeX{} implements a style that doesn't indent the first paragraph
after a section heading.  There are coherent reasons for this, but not
everyone likes it.
The \Package{indentfirst} package
suppresses the mechanism, so that the first paragraph is
indented.
\begin{ctanrefs}
\item[indentfirst.sty]Distributed as part of \CTANref{2etools}
\end{ctanrefs}

\Question[Q-subsubsub]{How to create a \csx{subsubsubsection}}

\LaTeX{}'s set of ``sections'' stops at the level of
\csx{subsubsection}.  This reflects a design decision by Lamport~---
for, after all, who can reasonably want a section with such huge
strings of numbers in front of it?

In fact, \LaTeX{} standard classes \emph{do} define ``sectioning''
levels lower than \csx{subsubsection}, but they don't format them like
sections (they're not numbered, and the text is run-in after the
heading).  These deeply inferior section commands are \csx{paragraph}
and \csx{subparagraph}; you can (if you \emph{must}) arrange that these
two commands produce numbered headings, so that you can use them as
\csx{subsubsubsection}s and lower.

The \Package{titlesec} allows you to adjust the definitions of the
sectioning macros, and it may be used to
transform a \csx{paragraph}'s typesetting so that it looks like that
of a \csx{section}.

If you want to program the change yourself, you'll find that the
commands (\csx{section} all the way down to \csx{subparagraph}) are
defined in terms of the internal \csx{@startsection} command, which
takes 6~arguments.  Before attempting this sort of work, you are well
advised to read the \LaTeX{} sources (\File{ltsect.dtx} in the
\LaTeX{} distribution) and the source of the standard packages
(\File{classes.dtx}).  The \Qref*{\LaTeX{} Companion}{Q-books}
discusses use of \csx{@startsection} for this sort of thing.
\begin{ctanrefs}
\item[\nothtml{\rmfamily}\LaTeX{} source]\CTANref{latex}
\item[titlesec.sty]\CTANref{titlesec}
\end{ctanrefs}

\Question[Q-captsty]{The style of captions}

Changes to the style of captions may be made by redefining the commands
that produce the caption.  So, for example, \csx{fnum@figure} (which
produces the float number for figure floats) may be redefined, in a
package of your own, or between
\Qref*{\csx{makeatletter}--\csx{makeatother}}{Q-atsigns}:
\begin{quote}
\begin{wideversion}
\begin{verbatim}
\renewcommand{\fnum@figure}{\textbf{Fig.~\thefigure}}
\end{verbatim}
\end{wideversion}
\begin{narrowversion}
\begin{verbatim}
\renewcommand{\fnum@figure}%
  {\textbf{Fig.~\thefigure}}
\end{verbatim}
\end{narrowversion}
\end{quote}
which will cause the number to be typeset in bold face.  (Note that
the original definition used \nothtml{\csx{figurename}~--- }%
\Qref{\csx{figurename}}{Q-fixnam}.)  More elaborate changes can be
made by patching the \csx{caption} command, but since there are
packages to do the job, such changes (which can get rather tricky)
aren't recommended for ordinary users.

The \Package{float} package provides some control of the appearance of
captions, though it's principally designed for the creation of
non-standard floats.  The \Package{caption} and \Package{ccaption}
(note the double ``\emph{c}'') packages provide a range of different
formatting options.

\Package{ccaption} also provides `continuation' captions and captions
that can be placed outside of float environments.  The (very simple)
\Package{capt-of} package also allows captions outside a float
environment.  Note that care is needed when doing things that assume
the sequence of floats (as in continuation captions), or potentially
mix non-floating captions with floating ones.

The \Class{memoir} class includes the facilities of the
\Package{ccaption} package; the \Class{KOMA-script} classes also
provide a wide range of caption-formatting commands.

The documentation of \Package{caption} is available by processing a
file \File{manual.tex}, which is created when you unpack
\File{caption.dtx}

Note that the previously-recommended package \Package{caption2} has
now been overtaken again by \Package{caption}; however,
\Package{caption2} remains available for use in older documents.
\begin{ctanrefs}
\item[caption.sty]\CTANref{caption}
\item[capt-of.sty]\CTANref{capt-of}
\item[ccaption.sty]\CTANref{ccaption}
\item[float.sty]\CTANref{float}
\item[\nothtml{\rmfamily}KOMA script bundle]\CTANref{koma-script}
\item[memoir.cls]\CTANref{memoir}
\end{ctanrefs}

\Question[Q-fancyhdr]{Alternative head- and footlines in \LaTeX{}}

The standard \LaTeX{} document classes define a small set of `page
styles' which specify head- and footlines for your document (though
they can be used for other purposes, too).  The standard set is very
limited, but \LaTeX{} is capable of much more.  The internal
\LaTeX{} coding needed to change page styles is not particularly
challenging, but there's no need~--- there are packages that provide
useful abstractions that match the way we typically think about these
things.

The \Package{fancyhdr} package provides
simple mechanisms for defining pretty much every head- or footline
variation you could want; the directory also contains some
documentation and one or two smaller packages.  \Package{Fancyhdr} 
also deals with the tedious behaviour of the standard styles with
\Qref*{initial pages}{Q-ps@empty}, by enabling you to define
different page styles for initial and for body pages.

While \Package{fancyhdr} will work with \Class{KOMA-script} classes,
an alternative package, \Package{scrpage2}, eases integration with the
classes.  \Package{Scrpage2} may also be used as a \Package{fancyhdr}
replacement, providing similar facilities.  The \Class{KOMA-script}
classes themselves permit some modest redefinition of head- and
footlines, without the use of the extra package.

\Class{Memoir} also contains the functionality of \Package{fancyhdr},
and has several predefined styles.

Documentation of \Package{fancyhdr} is distributed with the package,
in a separate file; documentation of \Package{scrpage2} is integrated
with the \File{scrgui*} documentation files that are distributed with
the \Class{KOMA-script} classes.
\begin{ctanrefs}
\item[fancyhdr.sty]\CTANref{fancyhdr}
\item[\nothtml{\rmfamily}KOMA script bundle]\CTANref{koma-script}
\item[memoir.cls]\CTANref{memoir}
\end{ctanrefs}

\Question[Q-widefigs]{Wide figures in two-column documents}

Floating figures and tables ordinarily come out the same width as the
page, but in two-column documents they're restricted to the width of
the column.  This is sometimes not good enough; so there are alternative
versions of the float environments~--- in two-column documents,
\texttt{figure*} provides a floating page-wide figure (and \texttt{table*} a
page-wide table) which will do the necessary.

The ``\texttt{*}''ed float environments can only appear at the top of a page,
or on a whole page~--- \texttt{h} or \texttt{b} float placement directives are
simply ignored.

Unfortunately, page-wide equations can only be accommodated inside
float environments.  You should include them in \texttt{figure} environments,
or use the \Package{float} or \Package{ccaption}package to define a
new float type. 
\begin{ctanrefs}
\item[ccaption.sty]\CTANref{ccaption}
\item[float.sty]\CTANref{float}
\end{ctanrefs}

\Question[Q-onecolabs]{1-column abstract in 2-column document}

One often requires that the abstract of a paper should appear across
the entire page, even in a two-column paper.  The required trick is:
\begin{quote}
\begin{verbatim}
\documentclass[twocolumn]{article}
...
\begin{document}
... % \author, etc
\twocolumn[
  \begin{@twocolumnfalse}
    \maketitle
    \begin{abstract}
      ...
    \end{abstract}
  \end{@twocolumnfalse}
  ]
\end{verbatim}
\end{quote}
Unfortunately, with the above \csx{thanks} won't work in the
\csx{author} list.  If you need such specially-numbered footnotes, you
can make them like this:
\begin{quote}
\begin{verbatim}
\title{Demonstration}
\author{Me, You\thanks{}}
\twocolumn[
  ... as above ...
]
{
  \renewcommand{\thefootnote}%
    {\fnsymbol{footnote}}
  \footnotetext[1]{Thanks for nothing}
}
\end{verbatim}
\end{quote}
and so on.

As an alternative, among other facilities the \Package{abstract} package 
provides a
\csx{saythanks} command and a \environment{onecolabstract} environment
which remove the need to fiddle with the \csx{thanks} and
footnoting. They can be used like this:
\begin{quote}
\begin{verbatim}
\twocolumn[
  \maketitle             % full width title
  \begin{onecolabstract} % ditto abstract
    ... text
  \end{onecolabstract}
]
\saythanks            % typeset any \thanks
\end{verbatim}
\end{quote}
The \Class{memoir} class offers all the facilities of \Package{abstract}.
\begin{ctanrefs}
\item[abstract.sty]\CTANref{abstract}
\item[memoir.cls]\CTANref{memoir}
\end{ctanrefs}

\Question[Q-reallyblank]{Really blank pages between chapters}

\Class{Book} (by default) and \Class{report} (with \pkgoption{openright} class
option) ensure that each chapter starts on a right-hand (recto) page;
they do this by inserting a \csx{cleardoublepage} command between
chapters (rather than a mere \csx{clearpage}).  The empty page thus
created gets to have a normal running header, which some people don't
like.

The (excellent) \Package{fancyhdr} manual covers this issue, basically
advising the creation of a command \csx{clearemptydoublepage}:
\begin{quote}
\begin{verbatim}
\let\origdoublepage\cleardoublepage
\newcommand{\clearemptydoublepage}{%
  \clearpage
  {\pagestyle{empty}\origdoublepage}%
}
\end{verbatim}
\end{quote}
The ``obvious'' thing is then to use this command to replace
\csx{cleardoublepage} in a patched version of the \csx{chapter} command.
(Make a package of your own containing a copy 
of the command out of the class.)  This isn't particularly difficult,
but you can instead simply subvert \csx{cleardoublepage} (which isn't
often used elsewhere):
\begin{quote}
\begin{verbatim}
\let\cleardoublepage\clearemptydoublepage
\end{verbatim}
\end{quote}
Note: this command works because \csx{clearemptydoublepage} uses a copy
of \csx{cleardoublepage}: instructions on macro programming
% beware line break
\Qref*[question]{patching techniques}{Q-patch} explain the problem and
why this is a solution.

Note that the \emph{\acro{KOMA}-Script} replacements for the
\Class{book} and \Class{report} classes (\Class{scrbook} and
\Class{scrreprt} offers class options \pkgoption{cleardoubleempty},
\pkgoption{cleardoubleplain} and \pkgoption{cleardoublestandard}
(using the running page style, as normal) that control the appearance
of these empty pages.  The classes also offer do-it-yourself commands
\csx{cleardoubleempty} (etc.\@).

The \Class{memoir} class (and the \Package{nextpage} package)
provide commands \csx{cleartooddpage} and \csx{cleartoevenpage},
which both take an optional argument (the first, with no argument,
being an equivalent of \csx{cleardoublepage}).  One can achieve
`special' effects by putting commands in the optional argument: the
\csx{clearemptydoublepage} we're after would be achieved by
\csx{cleartooddpage[}\cmdinvoke{thispagestyle}{empty}\texttt{]}.  The
commands will also serve if you want the surreal effect of ``This page
intentionally left blank'' in the centre of an otherwise empty page.
\begin{ctanrefs}
\item[fancyhdr]\CTANref{fancyhdr}
\item[memoir.cls]\CTANref{memoir}
\item[nextpage.sty]\CTANref{nextpage}
\item[scrbook.cls, scrrept.cls]Part of \CTANref{koma-script}
\end{ctanrefs}

\Question[Q-balance]{Balancing columns at the end of a document}

The \Package{twocolumn} option of the standard classes causes
\LaTeX{} to set the text of a document in two columns.  However, the last
page of the document typically ends up with columns of different
lengths~--- such columns are said to be ``unbalanced''.  Many (most?)
people don't like unbalanced columns.

The simplest solution to the problem is to use the \Package{multicol}
package in place of the \Package{twocolumn} option, as
\Package{multicol} balances the columns on the final page by default.
However, the use of \Package{multicol} does come at a cost: its
special output routine disallows the use of in-column floats, though
it does still permit full-width (e.g., \environment{figure*}
environment) floats. 

As a result, there is a constant push for a means of balancing columns
at the end of a \Package{twocolumn} document.  Of course, the job can
be done manually: \csx{pagebreak} inserted at the appropriate place on
the last page can often produce the right effect, but this seldom
appeals, and if the last page is made up of automatically-generated
text (for example, bibliography or index) inserting the command will
be difficult.

The \Package{flushend} package offers a solution to this problem.  It's a
somewhat dangerous piece of macro code, which patches one of the most
intricate parts of the \LaTeX{} kernel without deploying any of the
safeguards discussed in \Qref[question]{patching commands}{Q-patch}.
The package only changes the behaviour at end document (its
\csx{flushend} command is enabled by default), and one other command
permits adjustment of the final balance; other packages in the bundle
provide means for insertion of full width material in two-column
documents.

The \Package{balance} package also patches the output routine
(somewhat more carefully than \Package{flushend}).

The user should be aware that any of these packages are liable to
become confused in the presence of floats: if problems arise, manual
adjustment of the floats in the document is likely to be necessary.
It is this difficulty (what's required in any instance can't really be
expressed in current \LaTeX{}) that led the author of
\Package{multicol} to suppress single-column-wide floats.
\begin{ctanrefs}
\item[balance.sty]Distributed as part of \CTANref{preprint}
\item[flushend.sty]Distributed as part of \CTANref{sttools}
\item[multicol.sty]Distributed as part of \CTANref{2etools}

\end{ctanrefs}

\Question[Q-runheadtoobig]{My section title is too wide for the page header}

By default, \LaTeX{} sectioning commands make the chapter or section
title available for use by page headers and the like.  Page headers
operate in a rather constrained area, and it's common for titles too
be too big to fit: the \LaTeX{} sectioning commands therefore take an
optional argument:
\begin{quote}
\begin{verbatim}
\section[short title]{full title}
\end{verbatim}
\end{quote}
If the \meta{short title} is present, it is used both for the table of
contents and for the page heading.  The usual answer to people who
complain that their title is too big for the running head is to
suggest that they the optional argument.

However, using the same text for the table of contents as for the
running head may also be unsatisfactory: if your chapter titles are
seriously long (like those of a Victorian novel), a valid and rational
scheme is to have a shortened table of contents entry, and a really
terse entry in the running head.

One of the problems is the tendency of page headings to be set in
capitals (which take up more space); so why not set headings as written
for ``ordinary'' reading?  It's not possible to do so with unmodified
\LaTeX{}, but the \Package{fancyhdr} package provides a command
\csx{nouppercase} for use in its header (and footer) lines to suppress
\LaTeX{}'s uppercasing tendencies.  Classes in the \Class{KOMA-script}
bundle don't uppercase in the first place.

In fact, the sectioning commands use `mark' commands to pass
information to the page headers.  For example, \csx{chapter} uses
\csx{chaptermark}, \csx{section} uses \csx{sectionmark}, and so on.  With
this knowledge, one can achieve a three-layer structure for chapters:
\begin{quote}
\begin{verbatim}
\chapter[middling version]{verbose version}
\chaptermark{terse version}
\end{verbatim}
\end{quote}
which should supply the needs of every taste.

Chapters, however, have it easy: hardly any book design puts a page
header on a chapter start page.  In the case of sections, one has
typically to take account of the nature of the \csx{*mark} commands:
the thing that goes in the heading is the first mark on the page (or,
failing any mark, the last mark on any previous page).  As a result
the recipe for sections is more tiresome:
\begin{quote}
\begin{verbatim}
\section[middling version]{verbose version%
              \sectionmark{terse version}}
\sectionmark{terse version}
\end{verbatim}
\end{quote}
(the first \csx{sectionmark} deals with the header of the page the
\csx{section} command falls on, and the second deal with subsequent
pages; note that here, you need the optional argument to \csx{section},
even if ``\emph{middling version}'' is in fact the same text as
``\emph{long version''}.)

A similar arrangement is necessary even for chapters if the class
you're using is odd enough that it puts a page header on a chapter's
opening page.

Note that the \Package{titlesec} package manages the running heads in
a completely different fashion; users of that package should refer to
the documentation.

The \Class{memoir} class avoids all the silliness by providing an
extra optional argument for chapter and sectioning commands, for
example:
\begin{quote}
\begin{narrowversion}
\begin{verbatim}
\section[middling version][terse version]%
        {verbose version}
\end{verbatim}
\end{narrowversion}
\begin{wideversion}
\begin{verbatim}
\section[middling version][terse version]{verbose version}
\end{verbatim}
\end{wideversion}
\end{quote}
As a result, it is always possible for users of \Class{memoir} to
tailor the header text to fit, with very little trouble.
\begin{ctanrefs}
\item[fancyhdr.sty]\CTANref{fancyhdr}
\item[\nothtml{\rmfamily}KOMA script bundle]\CTANref{koma-script}
\item[memoir.cls]\CTANref{memoir}
\item[titlesec.sty]\CTANref{titlesec}
\end{ctanrefs}

\nothtml{\begingroup\boldmath}
\Question[Q-nofm]{Page numbering ``\meta{n} of \meta{m}''}
\nothtml{\afterquestion}

Finding the page number of the last page of a document, from within
the document, is somewhat tricky.  The \Package{lastpage} package is
therefore supplied to make life easy for us all; it defines a label
\texttt{LastPage} whose number is \emph{right} (after sufficiently many
passes through \LaTeX{}, of course).  The \Class{memoir} class also
defines a ``last page'' label.

The documentation of the \Package{fancyhdr} package spells out exactly
how one might actually use this information to produce page numbering
as suggested in the question.
\begin{ctanrefs}
\item[\nothtml{\rmfamily}fancyhdr documentation]\CTANref{fancyhdr}
\item[lastpage.sty]\CTANref{lastpage}
\end{ctanrefs}

\Question[Q-pagebychap]{Page numbering by chapter}

When I was a young man, a common arrangement for loose bound technical
manuals is to number pages by chapter.  (It's quite a good scheme, in
those situations: even if your corrections add a whole page to the
chapter, the most you have to redistribute is that chapter.)

The problem, at first sight, seems pretty much the same as that in
another answer on
% beware line break
\Qref*{running numbers within a chapter}{Q-running-nos},
and the basic technique is indeed pretty similar.

However, tidying-up loose ends, making sure the page number gets reset
to the correct value at the start of each chapter, and so on, is
slightly more challenging.  This is why the \Package{chappg} package
was written: it does the obvious things, and more.

Users have been known to ask for running page numbers within a
section, but this really doesn't make sense: you need to run page
numbers within document objects that always start on a fresh page.

Documentation of \Package{chappg} is to be found in the package file.
\begin{ctanrefs}
\item[chappg.sty]\CTANref{chappg}
\end{ctanrefs}

\subsection{Page layout}

\Question[Q-papersize]{The size of printed output}

The final product of a \AllTeX{} run is something for a person to
read.  Often, nowadays, that product will be read ``on-screen'', but
the printed page remains a principal output form.

When we come to print our output, it is important that the output fits
on the paper; in some cases, for the output to ``fit'' is good enough.
However, there are circumstances where the actual size of the printed
output, on the page, is crucial to the acceptance of the output.
(This might happen when the output is a book to be published, or when
it's a dissertation which must match the fancies of some bureaucrat
even to be considered.)

Sadly, we often find that the printed output doesn't conform to our
expectations\dots{}

The check-list for such problems has two entries:
\begin{itemize}
\item Your output is generated via Adobe \ProgName{Reader} (or
  possibly ``\ProgName{Acrobat Reader}''~--- older versions of the
  program had the qualified name).  In this case, it may be that
  \ProgName{Reader} is willfully changing the size of your output:
  read \Qref*{\ProgName{Reader} antics}{Q-acroantics}.
\item Something in your \TeX{} system is producing the wrong size (or
  shape) of output: read \Qref*{paper geometry}{Q-papergeom}.
\end{itemize}

An alternative approach is to use the (excellent) \Package{testflow}
suite, that provides a detailed outline of the potential problems
together with a sample document and prototype outputs.
\begin{ctanrefs}
\item[\nothtml{\rmfamily}testflow bundle]\CTANref{testflow}
\end{ctanrefs}

\Question[Q-acroantics]{Adobe \ProgName{Reader} messing with print size}

Printing from Adobe \ProgName{Reader} shrinks the page ``to fit''
(\emph{by default}).  Unfortunately, its calculation doesn't consider
the existing margins of the document, so that it shrinks what it
believes is your whole page onto what it believes is its output page.
The effect typically looks as if your margins have expanded.

Solve this problem by adjusting the \ProgName{Reader}'s default in the
print dialogue; unfortunately, this dialogue varies from one version
to the next.  On \ProgName{Reader} version 7, there are two entries to
check:
\begin{quote}
   Page Scaling (default: ``Fit to printer margins'')~--- change to
   ``None'', and\\
   Scale (default 95\textpercent {} of Normal size)~--- change to
   ``100\textpercent''.
% NB the space after \textpercent seems to be necessary for the health
% of sanitize.pl :-(
\end{quote}

\Question[Q-papergeom]{Getting the right paper geometry from \AllTeX{}}

If your output is the wrong size, and you've checked that it's not due
to the \Qref*{ministrations of Adobe \ProgName{Reader}}{Q-acroantics},
the problem is probably that your \AllTeX{} system is producing output
that specifies the wrong paper size.  Paper sizes can be a pain:
they're a forgotten backwater~--- Knuth seems not to have considered
paper size as something the \TeX{} engine needs to know about.  As a
result, there is no \acro{DVI} command to specify the paper on which
the document should be printed, which has led a dichotomy where macros
shape the text according to the needs of the author's chosen paper
size, and device drivers' choice happens independently of the macros'
ideas.

In practice, one usually finds that macro packages (such as \plaintex{} and
\LaTeX{}) assume American ``letter'' paper size, by default; and since
most distributions nowadays originate in Europe, the drivers usually
default to \acro{ISO} ``A4'' paper size.

This is (of course) pretty unsatisfactory.  Users may select a
different paper size for their document (current \LaTeX{} offers a
range of sizes as options in the standard classes), pretty easily.
Nevertheless, the user also has to be sure that each time
\ProgName{xdvi}, \ProgName{dvips} (or whatever) runs, it uses the
paper size the document was designed for.

The default paper size for \acro{DVI} drivers may be changed by a
distribution management command (\ProgName{texconfig} for \texlive{},
the \ProgName{Options} application for \miktex{}), but this still
doesn't provide for people using the ``wrong'' sort of paper for some
reason.

A different issue arises for users of \PDFTeX{}~--- the
\acro{PDF} format \emph{does} have the means of expressing paper size
and \PDFTeX{} has system variables \csx{pdfpagewidth} and
\csx{pdfpageheight}, that are written into the output \acro{PDF} file.
Unfortunately, most of the core software predates \PDFTeX{}, so not even
\PDFLaTeX{} sets the correct values into those variables, to match the
paper size specified in a \csx{documentclass} option.

The \acro{DVI} drivers \ProgName{dvips} and \ProgName{dvipdfm} define
\csx{special} commands for the document to specify its own paper size;
so in those cases, as when \PDFTeX{} or V\TeX{} is being used, the
paper size can be programmed by the document.  Users who wish to, may
of course consult the manuals of the various programs to write the
necessary code.

The \Package{geometry} package (whose main business is defining
typeset page areas), also takes notice the size of the paper that the
document is going to be printed on, and can issue the commands
necessary to ensure the correct size of paper is used.  If
\Package{geometry} is used when a document is being processed by
\PDFLaTeX{}, it can set the necessary dimensions ``in the output''.
If the document is being processed by \LaTeX{} on a \TeX{} or \eTeX{}
engine, there are package options which instruct \Package{geometry}
which \csx{special} commands to use.  (Note that the options are
ignored if you are using either \PDFLaTeX{} or V\TeX{}.)

So, the resolution of the problem is to add
\begin{quote}
\begin{verbatim}
\usepackage[dvixxx,...]{geometry}
\end{verbatim}
\end{quote}
(where \pkgoption{dvixxx} is your current favourite \acro{DVI}
driver~--- \Package{geometry} knows about \pkgoption{dvips} and
\pkgoption{dvipdfm}), and the document will run correctly with
\LaTeX{}.  If you're using \PDFLaTeX{}, load with
\begin{quote}
\begin{verbatim}
\usepackage[pdftex,...]{geometry}
\end{verbatim}
\end{quote}

Needless to say, both the ``big'' classes (\Class{koma-script} and
\Class{memoir}) provide their own ways to get the paper size
``right''.

The \Package{typearea} package is the \Class{Koma-script}
distribution's way of providing page layout functionality.  Load it
with the \pkgoption{pagesize} option and it will ensure the correct
paper is selected, for \acro{PDF} output from \PDFLaTeX{}, and for
\PS{} output from \LaTeX{} via \ProgName{dvips}.

\Class{Memoir} has the standard classes' paper-size selections
(\pkgoption{a4paper}, \pkgoption{letterpaper} and so on), but also
permits the user to choose an arbitrary paper size, by setting the
length registers \csx{stockheight} and \csx{stockwidth}.  The commands
\csx{fixdvipslayout} (for \LaTeX{} processing), and \csx{fixpdflayout}
(for \PDFLaTeX{} processing) then instruct the processor to produce
output that specifies the necessary paper size.
\begin{ctanrefs}
\item[geometry.sty]\CTANref{geometry}
\item[memoir.cls]\CTANref{memoir}
\item[typearea.sty]Distributed as part of \CTANref{koma-script}
\end{ctanrefs}

\Question[Q-changemargin]{Changing the margins in \LaTeX{}}

Changing the layout of a document's text on the page involves several
subtleties not often realised by the beginner.  There are interactions
between fundamental \TeX{} constraints, constraints related to the
design of \LaTeX{}, and good typesetting and design practice, that
mean that any change must be very carefully considered, both to ensure
that it ``works'' and to ensure that the result is pleasing to the
eye.

\LaTeX{}'s defaults sometimes seem excessively conservative,
but there are sound reasons behind how Lamport designed the layouts
themselves, whatever one may feel about his overall design.  For
example, the common request for ``one-inch margins all round on A4
paper'' is fine for 10- or 12-pitch typewriters, but not for 10pt (or
even 11pt or 12pt) type because readers find such wide, dense, lines
difficult to read.  There should ideally be no more than 75 characters
per line (though the constraints change for two-column text).

So Lamport's warning to beginners in his section on `Customizing the
Style'~--- ``don't do it''~--- should not lightly be ignored.

This set of \acro{FAQ}s recommends that you use a package to establish
consistent settings of the parameters: the interrelationships are
taken care of in the established packages, without you needing to
think about them, but 

The following answers deal with the ways one may choose to proceed:
\begin{itemize}
\item \Qref*{Choose which package to use}{Q-marginpkgs}.
\item \Qref*{Find advice on setting up page layout by hand}{Q-marginmanual}.
\end{itemize}
There is a related question~--- how to change the layout
temporarily~--- and there's an answer that covers that, too:
\begin{itemize}
\item \Qref*{Change the margins on the fly}{Q-chngmargonfly}.
\end{itemize}

\Question[Q-marginpkgs]{Packages to set up page designs}

The `ultimate' tool for adjusting the dimensions and position of the
printed material on the page is the \Package{geometry} package; a very
wide range of adjustments of the layout may be relatively
straightforwardly programmed, and package documentation is good and
comprehensive.

As is usual, users of the \Class{memoir} class have built-in
facilities for this task, and users of the \Class{KOMA-script} classes
are recommended to use an alternative package, \Package{typearea}.  In
either case it is difficult to argue that users should go for
\Package{geometry}: both alternatives are good.

The documentation of \Package{geometry} is a bit overwhelming, and
learning all its capabilities may be more than you ever need.
Somewhat simpler to use is the \Package{vmargin} package, which has a
canned set of paper sizes (a superset of that provided in \LaTeXe{}),
provision for custom paper, margin adjustments and provision for
two-sided printing.
\begin{ctanrefs}
\item[geometry.sty]\CTANref{geometry}
\item[\nothtml{\rmfamily}KOMA script bundle]\CTANref{koma-script}
\item[layout.sty]Distributed as part of \CTANref{2etools}
\item[memoir.cls]\CTANref{memoir}
\item[typearea.sty]Distributed as part of \CTANref{koma-script}
\item[vmargin.sty]\CTANref{vmargin}
\end{ctanrefs}

\Question[Q-marginmanual]{How to set up page layout ``by hand''}

So you're eager to do it yourself, notwithstanding the cautions
\begin{narrowversion}
  outlined above (\Qref{}{Q-changemargin}).
\end{narrowversion}
\begin{wideversion}
  outlined in ``\Qref{changing margins}{Q-changemargin}''.
\end{wideversion}

It's important that you first start by familiarising yourself
with LaTeX's page layout parameters. For example, see section C.5.3 of the
\LaTeX{} manual (pp.~181-182), or corresponding sections in many of the other
good \LaTeX{} manuals (see \Qref[question]{\LaTeX{} books}{Q-books}). 

\LaTeX{} controls the page layout with a number of parameters, which
allow you to change the distance from the edges of a page to the left
and top edges of your typeset text, the width and height of the text,
and the placement of other text on the page.  However, they are
somewhat complex, and it is easy to get their interrelationships wrong
when redefining the page layout. The layout package defines a
\csx{layout} command which draws a diagram of your existing page
layout, with the dimensions (but not their interrelationships) shown.

Even changing the text height and width, \csx{textheight} and
\csx{textwidth}, requires more care than you might expect: the height
should be set to fit a whole number of text lines (in terms of
multiples of \csx{baselinskip}), and the width should be constrained
by the number of characters per line, as mentioned in % ! line break
``\Qref*{changing margins}{Q-changemargin}''.

Margins are controlled by two parameters: \csx{oddsidemargin} and
\csx{evensidemargin}, whose names come from the convention that
odd-numbered pages appear on the right-hand side (`recto') of a
two-page spread and even-numbered pages on the left-hand side
(`verso').  Both parameters actually refer to the left-hand margin of
the relevant pages; in each case the right-hand margin is specified by
implication, from the value of \csx{textwidth} and the width of the
paper.  (In a one-sided document, which is the default in many
classes, including the standard \Class{article} and \Class{report}
classes, \csx{oddsidemargin} stands for both.)

The
``origin'' (the zero position) on the page is one inch from the top of
the paper and one inch from the left side; positive horizontal
measurements extend right across the page, and positive vertical
measurements extend down the page. Thus, the parameters
\csx{evensidemargin}, \csx{oddsidemargin} and \csx{topmargin}, should
be set to be 1~inch less than the true margin; for margins closer to
the left and top edges of the page than 1~inch, the margin parameters
must be set to negative values.

\Question[Q-chngmargonfly]{Changing margins ``on the fly''}

One of the surprises characteristic of \TeX{} use is that you cannot
change the width or height of the text within the document, simply by
modifying the text size parameters; \TeX{} can't change the text width
on the fly, and \LaTeX{} only ever looks at text height when starting
a new page.

So the simple rule is that the parameters should only be
changed in the preamble of the document, i.e., before the
\cmdinvoke{begin}{document} statement (so before any typesetting has
happened.

To adjust text width within a document we define an environment:
\begin{quote}
\begin{verbatim}
\newenvironment{changemargin}[2]{%
  \begin{list}{}{%
    \setlength{\topsep}{0pt}%
    \setlength{\leftmargin}{#1}%
    \setlength{\rightmargin}{#2}%
    \setlength{\listparindent}{\parindent}%
    \setlength{\itemindent}{\parindent}%
    \setlength{\parsep}{\parskip}%
  }%
  \item[]}{\end{list}}
\end{verbatim}
\end{quote}
The environment takes two arguments, and will indent the left and
right margins, respectively, by the parameters' values. Negative
values will cause the margins to be narrowed, so
\cmdinvoke{begin}{changemargin}{-1cm}{-1cm} narrows the left and right
margins by 1 centimetre.

Given that \TeX{} can't do this, how does it work?~--- well, the
environment (which is a close relation of the \LaTeX{}
\environment{quote} environment) \emph{doesn't} change the text width
as far as \TeX{} is concerned: it merely moves text around inside the
width that \TeX{} believes in.

The \Package{changepage} package provides ready-built commands to do the
above; it includes provision for changing the shifts applied to your
text according to whether you're on an odd (\emph{recto}) or an even
(\emph{verso}) page of a two-sided document.

The (earlier) package \Package{chngpage} provides the same facilities,
but it uses rather different syntax.  \Package{Changepage}'s structure
matches that of the \Class{memoir} class, and it should be used for
any new work.

Changing the vertical dimensions of a page is more clumsy still: the
\LaTeX{} command \csx{enlargethispage} adjusts the size of the current
page by the size of its argument.  Common uses are
\begin{quote}
\begin{verbatim}
\enlargethispage{\baselineskip}
\end{verbatim}
\end{quote}
to make the page one line longer, or
\begin{quote}
\begin{verbatim}
\enlargethispage{-\baselineskip}
\end{verbatim}
\end{quote}
to make the page one line shorter.
\begin{ctanrefs}
\item[changepage.sty]\CTANref{changepage}
\item[chngpage.sty]\CTANref{chngpage}
\end{ctanrefs}

\Question[Q-nopageno]{How to get rid of page numbers}

The package \Package{nopageno} will suppress page numbers in a whole
document.

To suppress page numbers from a single page, use
\cmdinvoke{thispagestyle}{empty} somewhere within the text of the
page.  (Note that \csx{maketitle} and \csx{chapter} both use
\csx{thispagestyle} internally, so you need to call it after you've
called them.)

To suppress page numbers from a sequence of pages, you may use
\cmdinvoke{pagestyle}{empty} at the start of the sequence, and restore
the original page style at the end.  Unfortunately, you still have to
use \csx{thispagestyle} after any \csx{maketitle} or \csx{chapter}
command.

In the \Class{memoir} class, the troublesome commands (\csx{maketitle},
\csx{chapter}, etc.\@) invoke their own page style
(\environment{title}, \environment{chapter}, etc.\@), which you may
redefine using the class's own techniques to be equivalent to
``\environment{empty}''.  The \Class{KOMA-script} classes have
commands that contain the page style to be used, so one might say:
\begin{quote}
\begin{verbatim}
\renewcommand*{\titlepagestyle}{empty}
\end{verbatim}
\end{quote}

An alternative (in all classes) is to use the rather delightful
\cmdinvoke{pagenumbering}{gobble}; this has the simple effect that any
attempt to print a page number produces nothing, so there's no issue
about preventing any part of \LaTeX{} from printing the number.
However, the \csx{pagenumbering} command does have the side effect that
it resets the page number (to 1), which may be undesirable.

The \Package{scrpage2} package separates out the representation from
the resetting; so one can say
\begin{quote}
\begin{verbatim}
\renewcommand*{\pagemark}{}
\end{verbatim}
\end{quote}
to have the same effect as the \texttt{gobble} trick, without
resetting the page number.
\begin{ctanrefs}
\item[nopageno]\CTANref{nopageno}
\item[\nothtml{\rmfamily}KOMA script bundle]\CTANref{koma-script}
\item[memoir.cls]\CTANref{memoir}
\item[scrpage2.sty]Distributed as part of \CTANref{koma-script}
\end{ctanrefs}

\Question[Q-ps@empty]{\psatempty{} on first page in \LaTeX{}}

If you use \cmdinvoke{pagestyle}{empty}, but the first page is numbered
anyway, you are probably using the \csx{maketitle} command too. The
behaviour is not a bug but a feature.  The standard \LaTeX{} classes are
written so that initial pages (pages containing a \csx{maketitle},
\csx{part}, or \csx{chapter}) have a different page style from the rest
of the document; to achieve this, the commands internally issue
\cmdinvoke{thispagestyle}{plain}. This is usually not acceptable
behaviour if the surrounding page style is `empty'.

Possible workarounds include:
\begin{itemize}
\item Put \csx{thispagestyle{empty}} immediately after the
  \csx{maketitle} command, with no blank line between them.
\item Use the \Package{fancyhdr} or \Package{scrpage2} packages, which
  allow you to customise the style for initial pages independently of
  that for body pages.

  For example, use \Package{fancyhdr} commands:
\begin{verbatim}
\fancypagestyle{plain}{%
  \fancyhf{}%
  \renewcommand{\headrulewidth}{0pt}%
  \renewcommand{\footrulewidth}{0pt}%
}
\end{verbatim}
  and the ``\texttt{empty}'' page style (invoked by \csx{chapter}
  commands and title pages) will have no header or footer.
\item If you are using either the \Class{memoir} class or a
  \Class{KOMA-script} class, use the techniques outlined for them in
  ``\Qref*[question]{no page numbers}{Q-nopageno}''.
\end{itemize}
\begin{ctanrefs}
\item[fancyhdr.sty]\CTANref{fancyhdr}
\item[\nothtml{\rmfamily}KOMA script bundle]\CTANref{koma-script}
\item[memoir.cls]\CTANref{memoir}
\item[nopageno.sty]\CTANref{nopageno}
\item[scrpage2.sty]Distributed as part of \CTANref{koma-script}
\end{ctanrefs}

\Question[Q-crop]{How to create crop marks}

If you're printing something that's eventually to be reproduced in
significant quantities, and bound, it's conventional to print on paper
larger than your target product, and to place ``crop marks'' outside
the printed area.  These crop marks are available to the production
house, for lining up reproduction and trimming machines.

You can save yourself the (considerable) trouble of programming these
marks for yourself by using the package \Package{crop}, which has
facilities to satisfy any conceivable production house.  Users of the
\Class{memoir} class don't need the package, since \Class{memoir} has
its own facilities for programming crop marks.
\begin{ctanrefs}
\item[crop.sty]\CTANref{crop}
\item[memoir.cls]\CTANref{memoir}
\end{ctanrefs}

\Question[Q-watermark]{`Watermarks' on every page}

It's often useful to place some text (such as `DRAFT') in the
background of every page of a document.  For \LaTeX{} users, this can
be achieved with the \Package{draftcopy} package.  This can deal with
many types of \acro{DVI} processors (in the same way that the graphics
package does) and knows translations for the word `DRAFT' into a wide
range of languages (though you can choose your own word, too).
Unfortunately, however, the package relies on \PS{} specials, and will
therefore fail if you are viewing your document with \ProgName{xdvi},
and won't even compile if you're using \PDFLaTeX{}.  (\PDFLaTeX{}
users need one of the other solutions below.)

The \Package{wallpaper} package builds on \Package{eso-pic} (see
below).  Apart from the single-image backdrops described above
(``wallpapers'', of course, to this package), the package provides
facilities for tiling images.  All its commands come in pairs: one for
``general'' use, and one applying to the current page only.

The \Package{draftwatermark} package uses the same author's
\Package{everypage} package to provide a simple interface for adding
textual (`DRAFT'-like) watermarks.

More elaborate watermarks may be achieved using the \Package{eso-pic}
package, which in turn uses the package \Package{everyshi}, or by
using \Package{everypage}.  \Package{Eso-pic} attaches a
\environment{picture} environment to every page as it is shipped out;
you can put things into that environment.  The package provides
commands for placing things at certain useful points (like ``text
upper left'' or ``text centre'') in the picture, but you're at liberty
to do what you like.

\Package{Everypage} allows you to add ``something'' to every page, or
to a particular page; you therefore need to construct your own
apparatus for anything complicated.
\begin{ctanrefs}
\item[draftcopy.sty]\CTANref{draftcopy}
\item[draftwatermark.sty]\CTANref{draftwatermark}
\item[eso-pic.sty]\CTANref{eso-pic}
\item[everypage.sty]\CTANref{everypage}
\item[everyshi.sty]Distributed as part of \CTANref{ms}
\item[wallpaper.sty]\CTANref{wallpaper}
\end{ctanrefs}

\Question[Q-landscape]{Typesetting things in landscape orientation}

It's often necessary to typeset part of a document in landscape
orientation; to achieve this, one needs not only to change the page
dimensions, but also to instruct the output device to print the
strange page differently.

There are two ``ordinary'' mechanisms for doing two slight variations
of landscape typesetting:
\begin{itemize}
\item If you have a single floating object that is wider than it is
  deep, and will only fit on the page in landscape orientation, use
  the \Package{rotating} package; this defines
  \environment{sidewaysfigure} and \environment{sidewaystable}
  environments which create floats that occupy a whole page.

  Note that \Package{rotating} has problems in a document that also
  loads the \Package{float} package, which recommended in other
  answers in these \acro{FAQ}s, for example that on
  \Qref*{float placement}{Q-floats}.  The \Package{rotfloat} package
  loads \Package{rotating} for you, and smooths the interaction with
  \Package{float}.
\item If you have a long sequence of things that need to be typeset in
  landscape (perhaps a code listing, a wide \environment{tabbing}
  environment, or a huge table typeset using \Package{longtable} or
  \Package{supertabular}), use the \Package{lscape} package (or
  \Package{pdflscape} if you're generating \acro{PDF} output, whether
  using \PDFLaTeX{} or \ProgName{dvips} and generating \acro{PDF} from
  that).  Both packages define an environment \environment{landscape}, which
  clears the current page and restarts typesetting in landscape
  orientation (and clears the page at the end of the environment
  before returning to portrait orientation).
\end{itemize}
No currently available package makes direct provision for typesetting
in both portrait and landscape orientation on the same page (it's not
the sort of thing that \TeX{} is well set-up to do).  If such
behaviour was an absolute necessity, one might use the techniques
described in
% beware line-wrap
\Qref[question]{"flowing text around figures"}{Q-textflow}, and would
rotate the landscape portion using the rotation facilities of the
\Package{graphics} package.  (Returning from landscape to portrait
orientation would be somewhat easier: the portrait part of the page
would be a bottom float at the end of the landscape section, with its
content rotated.)

To set an entire document in landscape orientation, one might use
\Package{lscape} around the whole document.  A better option is the
\pkgoption{landscape} option of the \Package{geometry} package; if you
also give it \pkgoption{dvips} or \pkgoption{pdftex} option,
\Package{geometry} also emits the rotation instructions to cause the
output to be properly oriented.  The \Class{memoir} class has the same
facilities, in this respect, as does \Package{geometry}.

A word of warning: most current \TeX{} previewers do not honour
rotation requests in \acro{DVI} files.
%% (the exception is
%% (the exceptions are the
%% \begin{htmlversion}
%%   (\Qref{commercial}{Q-commercial}) \YandY{} previewer
%%   \ProgName{dviwindo},
%% \end{htmlversion}
%% \htmlignore
%% (commercial) \YandY{} previewer \ProgName{dviwindo}
%% (\Qref{}{Q-commercial}),
%% \endhtmlignore
%% and
%% the fp\TeX{} previewer Win\acro{DVI}).  If your previewer is not
%% capable of rotation, 
Your best bet is to convert your output to \PS{} or to \acro{PDF}, and
to view these `final' forms with an appropriate viewer.
\begin{ctanrefs}
\item[geometry.sty]\CTANref{geometry}
\item[graphics.sty]Distributed as part of \CTANref{graphics}
\item[longtable.sty]Distributed as part of \CTANref{2etools}
\item[lscape.sty]Distributed as part of \CTANref{graphics}
\item[memoir.cls]\CTANref{memoir}
\item[pdflscape.sty]Distributed with Heiko Oberdiek's packages
  \CTANref{oberdiek}
\item[rotating.sty]\CTANref{rotating}
\item[rotfloat.sty]\CTANref{rotfloat}
\item[supertabular.sty]\CTANref{supertabular}
\end{ctanrefs}

\Question[Q-abspos]{Putting things at fixed positions on the page}

\TeX{}'s model of the world is (broadly speaking) that the author
writes text, and \TeX{} and its macros decide how it all fits on the
page.  This is not good news for the author who has, from whatever
source, a requirement that certain things go in exactly the right
place on the page.

There \emph{are} places on the page, from which things may be hung,
and two \LaTeX{} packages allow you position things relative to such
points, thus providing a means of absolute positioning.

The \Package{textpos} package aids the construction of pages from
``blobs'', dotted around over the page (as in a poster); you give it
the location, and it places your typeset box accordingly.

The \Package{eso-pic} defines a ``shipout picture'' that covers the
page.  The user may add \environment{picture}-mode commands to this
picture, which of course can include box placements as well as the
other rather stilted commands of \environment{picture}-mode.
(\Package{Eso-pic} requires the services of \Package{everyshi}, which
must therefore also be available.)
%
% Fortunately, in the \LaTeX{} world at least, there \emph{is} a fixed
% point on every page, to whit the page header.  The package
% \Package{textpos} latches bits of typesetting to locations you
% specify, by fixing them to the page header, and thereby solves the
% problem.
\begin{ctanrefs}
\item[eso-pic.sty]\CTANref{eso-pic}
\item[everyshi.sty]Distributed as part of \CTANref{ms}
\item[textpos.sty]\CTANref{textpos}
\end{ctanrefs}

\Question[Q-nopagebrk]{Preventing page breaks between lines}

One commonly requires that a block of typeset material be kept on the
same page; it turns out to be surprisingly tricky to arrange this.

\LaTeX{} provides a \environment{samepage} environment which claims it
does this sort of thing for you.  It proceeds by setting infinite
penalties for all sorts of page-break situations; but in many
situations where you want to prevent a page break,
\environment{samepage} doesn't help.  If you're trying to keep running
text together, you need to end the paragraph inside the environment
(see \Qref[question]{preserving paragraph parameters}{Q-paraparam}).
Also, if the things you are trying to keep together insert their own
pagebreak hints, \environment{samepage} has no power over them: a good
example is list items~--- they suggest page breaks between them.  Even
if \environment{samepage} \emph{does} work, it's likely to leave stuff
jutting out at the bottom of the page.

A convenient trick is to set all the relevant stuff in a \csx{parbox}
(or a \environment{minipage} if it contains things like verbatim text
that may not be in the argument of a \csx{parbox}).  The resulting box
certainly \emph{won't} break between pages, but that's not to say that
it will actually do what you want it to do: again, the box may be left
jutting out at the bottom of the page.

Why do neither of these obvious things work?  Because \TeX{} can't
really distinguish between infinitely awful things.
\environment{Samepage} will make any possible break point ``infinitely
bad'' and boxes don't even offer the option of breaks, but if the
alternative is the leave an infinitely bad few centimetres of blank
paper at the bottom of the page, \TeX{} will take the line of least
resistance and do nothing.

This problem still arises even if you have \csx{raggedbottom} in
effect: \TeX{} doesn't notice the value of \emph{that} until it starts
actually shipping a page out.  One approach is to set:
\begin{quote}
\begin{verbatim}
\raggedbottom
\addtolength{\topskip}{0pt plus 10pt}
\end{verbatim}
\end{quote}
The \texttt{10pt} offers a hint to the output routine that the column is
stretchable; this will cause \TeX{} to be more tolerant of the need to
stretch while building the page.  If you're doing this as a temporary
measure, cancel the change to \csx{topskip} by:
\begin{quote}
\begin{verbatim}
\addtolength{\topskip}{0pt plus-10pt}
\end{verbatim}
\end{quote}
as well as resetting \csx{flushbottom}.  (Note that the \texttt{10pt} never
actually shows up, because it is overwhelmed when the page is shipped
out by the stretchability introduced by \csx{raggedbottom}; however, it
could well have an effect if \csx{flushbottom} was in effect.)

An alternative (which derives from a suggestion by Knuth in the
\TeX{}book) is the package \Package{needspace} or the \Class{memoir} class,
which both define a command \csx{needspace} whose argument tells it
what space is needed.  If the space isn't available, the current page
is cleared, and the matter that needs to be kept together will be
inserted on the new page.  For example, if 4~lines of text need to be
kept together, the sequence
\begin{quote}
\begin{verbatim}
\par
\needspace{4\baselineskip}
% the stuff that must stay together
<text generating lines 1-4>
% now stuff we don't mind about
\end{verbatim}
\end{quote}
Yet another trick by Knuth is useful if you have a sequence of small
blocks of text that need, individually, to be kept on their own page.
Insert the command \csx{filbreak} before each small block, and the
effect is achieved.  The technique can be used in the case of
sequences of \LaTeX{}-style sections, by incorporating \csx{filbreak}
into the definition of a command (as in % beware line break
\Qref[question]{patching commands}{Q-patch}).  A simple and effective
patch would be:
\begin{quote}
\begin{verbatim}
\let\oldsubsubsection=\subsubsection
\renewcommand{\subsubsection}{%
  \filbreak
  \oldsubsubsection
}
\end{verbatim}
\end{quote}
While the trick works for consecutive sequences of blocks, it's
slightly tricky to get out of such sequences unless the sequence is
interrupted by a forced page break (such as \csx{clearpage}, which may
be introduced by a \csx{chapter} command, or the end of the document).
If the sequence is not interrupted, the last block is likely to be
forced onto a new page, regardless of whether it actually needs it.

If one is willing to accept that not everything can be accomplished
totally automatically, the way to go is to typeset the document and to
check for things that have the potential to give trouble.  In such a
scenario (which has Knuth's authority behind it, if one is to believe
the rather few words he says on the subject in the \TeX{}book) one can
decide, case by case, how to deal with problems at the last
proof-reading stage.  The alternatives are to insert \csx{clearpage}
commands as necessary, or to use \csx{enlargethispage}.  Supposing you
have a line or two that stray: issue the command
\cmdinvoke{enlargethispage}{2\csx{baselineskip}} and two lines are
added to the page you're typesetting.  It depends on the document
whether this looks impossibly awful or entirely acceptable, but the
command remains a useful item in the armoury.
\begin{ctanrefs}
\item[memoir.cls]\CTANref{memoir}
\item[needspace.sty]\CTANref{needspace}
\end{ctanrefs}

\Question[Q-parallel]{Parallel setting of text}

It's commonly necessary to present text in two languages `together' on a
page, or on a two-page spread.  For this to be satisfactory, one usually
needs some sort of alignment between the two texts.

The \Package{parallel} package satisfies the need, permitting
typesetting in two columns (not necessarily of the same width) on one
page, or on the two opposing pages of a two-page spread.  Use can be
as simple as
\begin{quote}
\begin{verbatim}
\usepackage{parallel}
...
\begin{Parallel}{<left-width>}{<right-width}
  \ParallelLText{left-text}
  \ParallelRText{right-text}
  \ParallelPar
  ...
\end{Parallel}
\end{verbatim}
\end{quote}
\Package{Parallel} can get terribly confused with colour changes, in
\PDFTeX{}; the indefatigable Heiko Oberdiek has a patch for this
issue~--- the \Package{pdfcolparallel}, which maintains separate
colour stacks for the columns.

The \Package{parcolumns} package can (in principle) deal with any
number of columns: the documentation shows its use with three
columns.  Usage is rather similar to that of \Package{parallel},
though there is of course a ``number of columns to specify'':
\begin{quote}
\begin{verbatim}
\usepackage{parcolumns}
...
\begin{parcolumns}[<options>]{3}
  \colchunk{<Column 1 text>}
  \colchunk{<Column 2 text>}
  \colchunk{<Column 3 text>}
  \colplacechunks
  ...
\end{parcolumns}
\end{verbatim}
\end{quote}
The \meta{options} can specify the widths of the columns, whether to
place rules between the columns, whether to set the columns sloppy, etc.

The \Package{ledpar} package is distributed with (and integrated with)
the \Qref{\Package{ledmac} package}{Q-linenos}.  It provides parallel
setting carefully integrated with the needs of a scholarly text,
permitting translation, or notes, or both, to be set in parallel with
the `base' text of the document.
\begin{ctanrefs}
\item[ledpar.sty]Distributed with \CTANref{ledmac}
\item[parallel.sty]\CTANref{parallel}
\item[parcolumns.sty]Distributed as part of \CTANref{sauerj}
\item[pdfcolparallel.sty]Distributed as part of \CTANref{oberdiek}
\end{ctanrefs}

\Question[Q-epigraph]{Typesetting epigraphs}

Epigraphs are those neat quotations that authors put at the start of
chapters (or even at the end of chapters: Knuth puts things at the
ends of chapters of the \TeX{}book).

Typesetting them is a bit of a fiddle, but not impossible to do for
yourself.  Fortunately, there are two packages that do the job, to
some extent; there are also facilities in the two ``big'' classes
(\Class{memoir} and \Class{koma-script}.

The \Package{epigraph} package defines an \csx{epigraph} command, for
creating a single 
epigraph (as at the top of a chapter):
\begin{quote}
\begin{verbatim}
\chapter{The Social Life of Rabbits}
\epigraph{Oh!  My ears and whiskers!}%
         {Lewis Carroll}
\end{verbatim}
\end{quote}
and an epigraphs environment, for entering more than one epigraph
consecutively, in a sort of list introduced by \csx{qitem} commands:
\begin{quote}
\begin{verbatim}
\begin{epigraphs}
\qitem{What I tell you three times is true}%
      {Lewis Carroll}
\qitem{Oh listen do, I'm telling you!}%
      {A.A. Milne}
\end{epigraphs}
\end{verbatim}
\end{quote}
The \csx{epigraphhead} command enables you to place your epigraph
\emph{above} a chapter header:
\begin{quote}
\begin{verbatim}
\setlength{\unitlength}{1pt}
...
\chapter{The Social Life of Rabbits}
\epigraphhead[<distance>]{%
  \epigraph{Oh!  My ears and whiskers!}%
           {Lewis Carroll}%
}
\end{verbatim}
\end{quote}
The \meta{distance} says how far above the chapter heading the
epigraph is to go; it's expressed in terms of the \csx{unitlength}
that's used in the \environment{picture} environment; the package's
author recommends \texttt{70pt}.

The package also offers various tricks for adjusting the layout of
chapter header (necessary if you've found a hugely long quotation for
an \csx{epigraphhead}), for patching the bibliography, for patching
\csx{part} pages, and so on.  (Some of these suggested patches lead you
through writing your own package\dots{})

The \Package{quotchap} package redefines chapter headings (in a
moderately striking way), and provides an environment
\environment{savequotes} in which you can provide one (or more)
quotations to use as epigraphs.  The facilities seem not as flexible
as those of \Package{epigraph}, but it's probably easier to use.

The \Class{memoir} class offers all the facilities of the
\Package{epigraph} package.  The \Class{Koma-script} classes have
commands \csx{setchapterpreamble} and \csx{dictum} to provide these
facilities.
\begin{ctanrefs}
\item[epigraph.sty]\CTANref{epigraph}
\item[\nothtml{\rmfamily}KOMA script bundle]\CTANref{koma-script}
\item[memoir.cls]\CTANref{memoir}
\item[quotchap.sty]\CTANref{quotchap}
\end{ctanrefs}

\Question[Q-outszwrng]{\AllTeX{} \acro{PDF} output prints at wrong size}

Having got everything \emph{else} right, you should be aware that the
problem may have nothing to do with \AllTeX{} and everything to do
with the program you use for printing.  A regular cause for such
problems lies with Acrobat Reader, which by default enables its option
to scale pages to fit on the printable area of the paper.  Since a
printer can rarely print right to the edge, this means that pdf-files
will be shrunk by some (small) factor (even if the pdf-file is
formatted for A4, and your paper size is set to A4 as well).

Correcting this silliness is not very hard, but the exact details
depend on the version of Acrobat Reader (or "Adobe Reader" from
version 6.0 onwards) you have installed:
\begin{itemize}
\item  Mac OS X, Adobe Reader 6:\\
  in the print dialogue, on the ``copies \& pages'' pane, you'll find a
  popup menu titled ``Page Scaling''. Make sure that the menu reads
  ``None''.
\item Windows, Adobe Reader 6:\\
  in the print dialogue, select ``None'' from the drop-down list
  ``Page Scaling''.
\item Windows, Linux Acrobat (Reader) 5.0:\\
  In the print dialog, make sure the ``Shrink oversized pages to fit''
  checkbox is unchecked.  It may also be useful to uncheck the
  ``Expand small pages to fit paper size'' checkbox as well.
\end{itemize}

\subsection{Spacing of characters and lines}

\Question[Q-linespace]{Double-spaced documents in \LaTeX{}}

A quick and easy way of getting inter-line space for copy-editing is
to change \csx{baselinestretch}~--- \cmdinvoke{linespread}{1.2} (or,
equivalently \cmdinvoke{renewcommand}{\csx{baselinestretch}}{1.2}) may
be adequate.  Note that \csx{baselinestretch} changes don't take
effect until you select a new font, so make the change in the preamble
before any font is selected.  Don't try changing \csx{baselineskip}:
its value is reset at any size-changing command so that results will
be inconsistent.

For preference (and certainly for a production document, such as a
dissertation or an article submission), use a line-spacing package.
The only one currently supported is \Package{setspace} (do \emph{not}
be tempted by \Package{doublespace}~--- its performance under current
\LaTeX{} is at best problematical).  \Package{Setspace} switches off
double-spacing at places where even the most die-hard official would
doubt its utility (footnotes, figure captions, and so on); it's very
difficult to do this consistently if you're manipulating
\csx{baselinestretch} yourself.

Of course, the real solution (other than for private copy editing) is
\emph{not} to use double-spacing at all.  Universities, in particular,
have no excuse for specifying double-spacing in submitted
dissertations: \LaTeX{} is a typesetting system, not a
typewriter-substitute, and can (properly used) make single-spaced text
even more easily readable than double-spaced typewritten text.  If you
have any influence on your university's system (for example, through
your dissertation supervisor), it may be worth attempting to get the
rules changed (at least to permit a ``well-designed book'' format).

Double-spaced submissions are also commonly required when submitting
papers to conferences or journals.  Fortunately (judging by the
questions from users in this author's department), this demand is
becoming less common.

Documentation of \Package{setspace} appears as \TeX{} comments in the
package file itself.
\begin{ctanrefs}
\item[setspace.sty]\CTANref{setspace}
\end{ctanrefs}

\Question[Q-letterspace]{Changing the space between letters}

A common technique in advertising copy (and other text whose actual
content need not actually be \emph{read}) is to alter the space
between the letters (otherwise known as the tracking).  As a general
rule, this is a very bad idea: it detracts from legibility, which is
contrary to the principles of typesetting (any respectable font you
might be using should already have optimum tracking built into it).

The great type designer, Eric Gill, is credited with saying ``he who
would letterspace lower-case text, would steal sheep''.  (The
attribution is probably apocryphal: others are also credited with the
remark.  Stealing sheep was, in the 19th century, a capital offence in
Britain.)  As the remark suggests, though, letterspacing of upper-case
text is less awful a crime; the technique used also to be used for
emphasis of text set in Fraktur (or similar) fonts.

Straightforward macros (usable, in principle, with any \TeX{} macro
package) may be found in \Package{letterspacing} (which is the name of
the \extension{tex} file).

%%% the package has a serious bug in it, so suppress mention pro tem
%The \Package{tracking} package has similar facilities.

A more comprehensive solution is to be found in the \Package{soul}
package (which is optimised for use with \LaTeX{}, but also works with
\plaintex{}).  Soul also permits hyphenation of letterspaced text;
Gill's view of such an activity is not (even apocryphally) recorded.
(Spacing-out forms part of the name of \Package{soul}; the other half
is described in \Qref[question]{another question}{Q-underline}.)

Possibly the `ultimate' in this field is the \Package{microtype},
which uses the micro-typography capabilities of current \PDFTeX{} to
provide a \csx{textls} command, which operates according to parameters
declared in a \csx{SetTracking} command.  \Package{Microtype}'s
`tracking' facility expands the natural spacing font itself, rather
than inserting space between characters.  Ordinarily, letter-spacing
will destroy ligatures; however, this is \emph{wrong} if the font is
of a fraktur style, and the package provides a means of protecting the
ligatures in a letter-spaced text.
\begin{ctanrefs}
\item[letterspacing.tex]\CTANref{letterspacing}
\item[microtype.sty]\CTANref{microtype}
\item[soul.sty]\CTANref{soul}
%\item[tracking.sty]\CTANref{tracking}
\end{ctanrefs}

\Question[Q-ragright]{Setting text ragged right}

The trick with typesetting ragged right is to be sure you've told the
\TeX{} engine ``make this paragraph ragged, but never \emph{too}
ragged''.  The \LaTeX{} \csx{raggedright} command (and the
corresponding \environment{flushleft} environment) has a tendency to
miss the ``never'' part, and will often create ridiculously short
lines, for some minor benefit later in the paragraph.  The
\plaintex{} version of the command doesn't suffer this failing, but
is rather conservative: it is loath to create too large a gap at the
end of the line, but in some circumstances~--- such as where
\Qref*{hyphenation is suppressed}{Q-hyphoff}~--- painfully large gaps
may sometimes be required.

Martin Schr\"oder's \Package{ragged2e} package offers the best of both
worlds: it provides raggedness which is built on the \plaintex{}
model, but which is easily configurable.  It defines easily-remembered
command (e.g., \csx{RaggedRight}) and environment (e.g.,
\environment{FlushLeft}) names that are simply capitalised
transformations of the \LaTeX{} kernel originals.  The documentation
discusses the issues and explains the significance of the various
parameters of \Package{ragged2e}'s operation.
\begin{ctanrefs}
\item[ragged2e.sty]Distributed as part of \CTANref{ms}
\end{ctanrefs}

\Question[Q-flushboth]{Cancelling \csx{ragged} commands}

\LaTeX{} provides commands \csx{raggedright} and \csx{raggedleft}, but
none to cancel their effect.  The \csx{centering} command is
implemented in the same way as the \csx{ragged*} commands, and suffers
in the same way.

The following code (to be inserted in a package of your own, or as
\nothtml{internal \LaTeX{} code~---}% beware line break
\Qref{internal \LaTeX{} code}{Q-atsigns}) defines a command that
restores flush justification at both margins:
\begin{verbatim}
\def\flushboth{%
  \let\\\@normalcr
  \@rightskip\z@skip \rightskip\@rightskip
  \leftskip\z@skip
  \parindent 1.5em\relax}
\end{verbatim}
There's a problem with the setting of \csx{parindent} in the code: it's
necessary because both the \csx{ragged} commands set \csx{parindent} to
zero, but the setting isn't a constant of nature: documents using a
standard \LaTeX{} class with \pkgoption{twocolumn} option will have
\texttt{1.0em} by default, and there's no knowing what you (or some
other class) will have done.

Any but a really old copy of Martin Schr\"oder's \Package{ragged2e}
package has a \csx{justifying} command to match its % ! line break
\Qref*{versions of the \LaTeX{} `ragged' commands}{Q-ragright}.  The
package also provides a \environment{justify} environment, which
permits areas of justified text in a larger area which is ragged.
\begin{ctanrefs}
\item[ragged2e.sty]Distributed as part of \CTANref{ms}
\end{ctanrefs}
% this package hasn't materialised, for some reason i don't now
% remember...
%% Donald Arseneau's \Package{flushboth} package provides this code, and
%% preserves a sensible value for \csx{parindent} (at begin document).
%% This still doesn't protect it against any change you might make to
%% \csx{parindent} within the body of your document.
%% \begin{ctanrefs}
%% \item[flushboth.sty]\CTANref{flushboth}
%% \end{ctanrefs}

\subsection{Typesetting specialities}

\Question[Q-verbfile]{Including a file verbatim in \LaTeX{}}

A good way is to use Rainer Sch\"opf's \Package{verbatim} package,
which provides a command \csx{verbatiminput} that takes a file name as
argument:
\begin{quote}
\begin{verbatim}
\usepackage{verbatim}
...
\verbatiminput{verb.txt}
\end{verbatim}
\end{quote}
Another way is to use the \environment{alltt} environment, which
requires the \Package{alltt} package.  The environment interprets its
contents `mostly' verbatim, but executes any \AllTeX{} commands it
finds:
\begin{quote}
\begin{verbatim}
\usepackage{alltt}
...
\begin{alltt}
\input{verb.txt}
\end{alltt}
\end{verbatim}
\end{quote}
of course, this is little use for inputting \AllTeX{} source
code\dots{}

The \Package{moreverb} package extends the \Package{verbatim} package,
providing a \environment{listing} environment and a \csx{listinginput}
command, which line-number the text of the file.  The package also has
a \csx{verbatimtabinput} command, that honours \acro{TAB} characters in
the input (the package's \environment{listing} environment and the
\csx{listinginput} command also both honour \acro{TAB}).

The \Package{sverb} package provides verbatim input (without recourse
to the facilities of the \Package{verbatim} package):
\begin{quote}
\begin{verbatim}
\usepackage{sverb}
...
\verbinput{verb.txt}
\end{verbatim}
\end{quote}

The \Package{fancyvrb} package offers configurable implementations of
everything \Package{verbatim}, \Package{sverb} and \Package{moreverb}
have, and more besides.  It is nowadays the package of choice for the
discerning typesetter of verbatim text, but its wealth of facilities
makes it a complex beast and study of the documentation is strongly
advised.

The \Class{memoir} class includes the relevant functionality of the
\Package{verbatim} and \Package{moreverb} packages.
\begin{ctanrefs}
\item[alltt.sty]Part of the \LaTeX{} distribution.
\item[fancyvrb.sty]\CTANref{fancyvrb}
\item[memoir.cls]\CTANref{memoir}
\item[moreverb.sty]\CTANref{moreverb}
\item[sverb.sty]Distributed as part of \CTANref{mdwtools}
\item[verbatim.sty]Distributed as part of \CTANref{2etools}
\end{ctanrefs}

\Question[Q-linenos]{Including line numbers in typeset output}

For general numbering of lines, there are two packages for use with
\LaTeX{}, \Package{lineno} (which permits labels attached to
individual lines of typeset output) and \Package{numline}.

Both of these packages play fast and loose with the \LaTeX{} output
routine, which can cause problems: the user should beware\dots{}

If the requirement is for numbering verbatim text, \Package{moreverb},
\Class{memoir} or \Package{fancyvrb} (see % beware line break
\Qref[question]{including files verbatim}{Q-verbfile}) may be used.

One common use of line numbers is in critical editions of texts, and
for this the \Package{edmac} package offers comprehensive support;
\Package{ledmac} is a \LaTeX{} port of \Package{edmac}.

The \Package{vruler} package sidesteps many of the problems associated
with line-numbering, by offering (as its name suggests) a rule that
numbers positions on the page.  The effect is good, applied to
even-looking text, but is poor in texts that involve breaks such as
interpolated mathematics or figures.  Documentation of the package, in
the package itself, is pretty tough going, though there is an example
(also inside the package file).
\begin{ctanrefs}
\item[edmac]\CTANref{edmac}
\item[fancyvrb.sty]\CTANref{fancyvrb}
\item[ledmac.sty]\CTANref{ledmac}
\item[lineno.sty]\CTANref{lineno}
\item[memoir.cls]\CTANref{memoir}
\item[moreverb.sty]\CTANref{moreverb}
\item[numline.sty]\CTANref{numline}
\item[vruler.sty]\CTANref{vruler}
\end{ctanrefs}

\Question[Q-codelist]{Code listings in \LaTeX{}}

`Pretty' code listings are sometimes considered worthwhile by the
``ordinary'' programmer, but they have a serious place in
the typesetting of dissertations by computer science and other
students who are expected to write programs.  Simple verbatim listings
of programs are commonly useful, as well.

\begin{wideversion} % really hyper
  \Qref{Verbatim listings}{Q-verbfile} are dealt with elsewhere,
\end{wideversion}
\begin{narrowversion}
  Verbatim listings are dealt with elsewhere (\Qref{}{Q-verbfile}),
\end{narrowversion}
as is the problem of % ! line break
\Qref*{typesetting algorithm specifications}{Q-algorithms}.

The \Package{listings} package is widely regarded as the best bet for
formatted output (it is capable of parsing program source, within the
package itself), but there are several well-established packages that
rely on a pre-compiler of some sort.  You may use \Package{listings}
to typeset snippets that you include within your source:
\begin{quote}
\begin{verbatim}
\usepackage{listings}
\lstset{language=C}
...
\begin{document}
\begin{lstlisting}
#include <stdio.h>

int main(int argc, char ** argv)
{
  printf("Hello world!\n");
  return 0;
}
\end{lstlisting}
\end{document}
\end{verbatim}
\end{quote}
or you can have it typeset whole files:
\begin{quote}
\begin{verbatim}
\usepackage{listings}
\lstset{language=C}
...
\begin{document}
\lstinputlisting{main.c}
\end{document}
\end{verbatim}
\end{quote}
These very simple examples may be decorated in a huge variety of ways,
and of course there are other languages in the package's vocabulary
than just \ProgName{C}\dots{}

Most people, advising others on \AllTeX{} lists, seem to regard
\Package{listings} as the be-all and end-all on this topic.  But there
\emph{are} alternatives, which may be worth considering, in some
situations.

\ProgName{Highlight} is attractive if you need more than one output
format for your program: as well as \AllTeX{} output,
\ProgName{highlight} will produce (\acro{X})\acro{HTML}, \acro{RTF}
and \acro{XSL}-\acro{FO} representations of your program listing.
Documentation is available on the % ! line break
\href{http://www.andre-simon.de/}{\ProgName{highlight} project site}.

The \ProgName{lgrind} system is another well-established pre-compiler,
with all the facilities one might need and a wide repertoire of
languages; it is derived from the very long-established
\ProgName{tgrind}, whose output is based on \plaintex{}

The \ProgName{tiny_c2l} system is more recent: users are encouraged to
generate their own driver files for languages it doesn't already deal
with.

The \ProgName{C++2LaTeX} system comes with strong recommendations for
use with \acro{C} and \acro{C}++.

An extremely simple system is \ProgName{c2latex}, for which you write
\LaTeX{} source in your \acro{C} program comments.  The program then
converts your program into a \LaTeX{} document for processing.  The
program (implicitly) claims to be ``self-documenting''.
\begin{ctanrefs}
\item[c2latex]\CTANref{c2latex}
\item[C++2LaTeX]\CTANref{c++2latex}
\item[highlight]\CTANref{highlight}
\item[lgrind]\CTANref{lgrind}
\item[listings.sty]\CTANref{listings}
\item[tgrind]\CTANref{tgrind}
\item[tiny\_c2l]\CTANref{tiny_c2l}
\end{ctanrefs}

\Question[Q-algorithms]{Typesetting pseudocode in \LaTeX{}}

There is no consensus on the `right' way to typeset pseudocode.
Consequently, there are a variety of \LaTeX{} packages to choose from
for producing \ae{}sthetically pleasing pseudocode listings.

Pseudocode differs from actual program listings in that it lacks
strict syntax and semantics.  Also, because pseudocode is supposed to
be a clear expression of an algorithm it may need to incorporate
mathematical notation, figures, tables, and other \LaTeX{} features
that do not appear in conventional programming languages.
\begin{wideversion} % hyper?
  \Qref{Typesetting program listings}{Q-codelist} is described
  elsewhere.
\end{wideversion}
\begin{narrowversion} % non-hyper
  Typesetting program listings is described elsewhere
  (\Qref{}{Q-codelist}).
\end{narrowversion}

You can certainly create your own environment for typesetting
pseudocode using, for example, the \environment{tabbing} or
\environment{list} environments~--- it's not difficult, but it may
prove boring.  So it's worth trying the following packages, all
designed specifically for typesetting pseudocode.

The \Package{algorithms} bundle (which contains packages
\Package{algorithm} and \Package{algorithmic}, both of which are
needed for ordinary use) has a simple interface and produces fairly
nice output.  It provides primitives for statements, which can contain
arbitrary \LaTeX{} commands, comments, and a set of iterative and
conditional constructs.  These primitives can easily be redefined to
produce different text in the output.  However, there is no support
for adding new primitives.  Typesetting the pseudocode itself is
performed in \Package{algorithmic}; the \Package{algorithms} package
uses the facilities of the \Package{float} package to number
algorithms sequentially, enable algorithms to float like figures or
tables, and support including a List of Algorithms in a document's
front matter.

Packages in the \Package{algorithmicx} bundle are similar both in
concept and output form to \Package{algorithmic} but additionally
provide support for adding new keywords and altering the formatting.
It provides the \Package{algpseudocode} package which is (almost) a
drop-in replacement for \Package{algorithmic}.  Another package in the
bundle, \Package{algpascal}, uses Pascal-like keywords, indents
differently from \Package{algpseudocode}, and puts command arguments
in maths mode instead of text mode.  There is no floating environment
but \Package{algorithmicx}, like \Package{algorithmic}, is compatible
with the \Package{algorithm} package.

The \Package{alg} package, like \Package{algorithms}, offers a
floating algorithm environment with all of the ensuing niceties.
\Package{alg}, however, can caption its floats in a variety of
(natural) languages.  In addition, \Package{alg} unlike
\Package{algorithms}, makes it easy to add new constructs.

The \Package{newalg} package has a somewhat similar interface to
\Package{algorithms}, but its output is designed to mimic the rather
pleasant typesetting used in the book ``\emph{Introduction to Algorithms}''
by Corman, Leiserson, Rivest and Stein. Unfortunately,
\Package{newalg} does not support a floating environment or any
customisation of the output.

``\emph{Bona fide}'' use of the style of ``Introduction to
Algorithms'' may be achieved with Cormen's own \Package{clrscode}:
this is the package as used in the second edition of the book.

Similarly, the style of % ! line break
``\emph{Combinatorial Algorithms: Generation, Enumeration and Search}''
is supported by the \Package{pseudocode} package, written by the
authors of the book.  It has the common `Pascal-like' style, and has
some interesting constructs for what one thinks of as Pascal blocks.

The \Package{algorithm2e} is of very long standing, and is widely used
and recommended.  It loads the \Package{float} package to provide the
option of floating algorithm descriptions, but you can always use the
``\texttt{H}'' option of \Package{float} to have the algorithm appear
``where you write it''.

The usage of the \Package{program} package is a little different from
that of the other packages.  It typesets programs in maths mode
instead of text mode; and linebreaks are significant.
\Package{program} lacks a floating environment but does number
algorithms like \Package{alg} and \Package{algorithms}.  Customisation
and extension are not supported.  Documentation of the
\Package{program} package (such as it is) appears in a file
\File{program.msg} in the distribution.

None of the above are perfect.  The factors that should influence your
choice of package include the output style you prefer, how much you
need to extend or modify the set of keywords, and whether you require
algorithms to float like figures and tables.
%%
%% Documentation availability:
%% \begin{description}
%% \item[\Package{algorithms} bundle] is provided in \File{algorithms.ps}
%%   (also available as LaTeX{} source).  The documentation speaks as if
%%   the two packages of the bundle were indeed one, called
%%   \Package{algorithms}.
%% \item[\Package{program} package] (such as it is) appears in a file
%%   \File{program.msg}.
%% \item[\Package{clrscode} package] is to be found in
%%   \File{clrscode.pdf} in the distribution.
%% \item[\Package{algorithm2e} package] is to be found in
%%   \File{algorithm2e.tex} in the distribution (it needs the package
%%   itself when you process it).
%% \end{description}
\begin{ctanrefs}
\item[algorithm2e.sty]\CTANref{algorithm2e}
\item[algorithmicx\nothtml{\rmfamily} bundle]\CTANref{algorithmicx}
\item[algorithms\nothtml{\rmfamily} bundle]\CTANref{algorithms}
\item[alg.sty]\CTANref{alg}
\item[clrscode.sty]\CTANref{clrscode}
\item[float.sty]\CTANref{float}
\item[newalg.sty]\CTANref{newalg}
\item[program.sty]\CTANref{program}
\item[pseudocode.sty]\CTANref{pseudocode}
\end{ctanrefs}

\Question[Q-makeindex]{Generating an index in \AllTeX{}}

Making an index is not trivial; what to index, and how to index it, is
difficult to decide, and uniform implementation is difficult to
achieve.  You will need to mark all items to be indexed in your text
(typically with \csx{index} commands).

It is not practical to sort a large index within \TeX{}, so a
post-processing program is used to sort the output of one \TeX{} run,
to be included into the document at the next run.

The following programs are available:
\begin{description}
\item[makeindex] Comes with most distributions~--- a good workhorse,
  but is not well-arranged to deal with other sort orders than the
  canonical \acro{ASCII} ordering.
  
  The \Package{makeindex} documentation is a good source of
  information on how to create your own index. \Package{Makeindex} can
  be used with some \TeX{}
  macro packages other than \LaTeX{}, such as \nothtml{\Eplain\ (}%
  \Qref{Eplain}{Q-eplain}\nothtml{)}, and \TeX{} (whose macros can
  be used independently with \plaintex{}).
\item[idxtex] for \LaTeX{} under \acro{VMS}, which comes with a
  glossary-maker called \Package{glotex}.
\item[texindex] A witty little shell/\ProgName{sed}-script-based
  utility for \LaTeX{} under Unix.
  
  The \Qref*{Texinfo}{Q-texinfo} system also uses a program
  \ProgName{texindex}, whose source is to be found in the
  \ProgName{texinfo} distribution.  The \Package{ltxindex} package
  provides macros to allow \LaTeX{} users to use \emph{this}
  \ProgName{texindex}.
\item[xindy] arose from frustration at the difficulty of making a
  multi-language version of \ProgName{makeindex}.  It is designed to
  be a successor to \ProgName{makeindex}, by a team that included the
  then-current maintainer of \ProgName{makeindex}.  It successfully
  addresses many of \ProgName{makeindex}'s shortcomings, including
  difficulties with collation order in different languages, and it is
  highly flexible.  Sadly, its take-up is proving rather slow.
\end{description}
\begin{ctanrefs}
\item[idxtex]\CTANref{glo+idxtex}
\item[ltxindex.sty]\CTANref{ltxindex}
\item[makeindex]\CTANref{makeindex}
\item[makeindex (Macintosh)]\CTANref{macmakeindex}
\item[texindex \nothtml{\upshape\rmfamily}(the script)]\CTANref{texindex}
\item[texindex \nothtml{\upshape\rmfamily}(the program)]Distributed
  with \CTANref{texinfo}
\item[texsis (system)]\CTANref{texsis}
\item[texsis (makeindex support)]\CTANref{texsis-index}
\item[xindy]\CTANref{xindy}
\end{ctanrefs}

\Question[Q-setURL]{Typesetting \acro{URL}s}

\acro{URL}s tend to be very long, and contain characters that would
naturally prevent them being hyphenated even if they weren't typically
set in \csx{ttfamily}, verbatim.  Therefore, without special treatment,
they often produce wildly overfull \csx{hbox}es, and their typeset
representation is awful.

There are three packages that help solve this problem:
\begin{itemize}
\item The \Package{path} package, which defines a \csx{path} command.
  The command defines each potential break character as a
  \csx{discretionary}, and offers the user the opportunity of
  specifying a personal list of potential break characters.  Its chief
  disadvantage is fragility in \LaTeX{} moving arguments.  The
% beware line breaks
  \Qref*{\Eplain{} macros}{Q-eplain}~--- define a similar \csx{path} command.
  
  \Package{Path}, though it works in simple situations, makes no
  attempt to work with \LaTeX{} (it is irremediably fragile).  Despite
  its long and honourable history, it is no longer recommended for
  \LaTeX{} use.
\item The \Package{url} package, which defines an \csx{url} command
  (among others, including its own \csx{path} command).  The command
  gives each potential break character a maths-mode `personality', and
  then sets the \acro{URL} itself (in the user's choice of font) in
  maths mode.  It can produce (\LaTeX{}-style) `robust' commands
  % beware line break within paren 
  (\htmlonly{see }\Qref{use of \csx{protect}}{Q-protect}) for use
  within moving arguments.  Note that, because the operation is
  conducted in maths mode, spaces within the \acro{URL} argument are
  ignored unless special steps are taken.
  
  It is possible to use the \Package{url} package in \plaintex{},
  with the assistance of the \Package{miniltx} package (which was
  originally developed for using the \LaTeX{} graphics package in
  \plaintex{}).  A small patch is also necessary: the required
  sequence is therefore:
\begin{narrowversion}
\begin{verbatim}
\input miniltx
\expandafter\def\expandafter\+%
                \expandafter{\+}
\input url.sty
\end{verbatim}
\end{narrowversion}
\begin{wideversion}
\begin{verbatim}
\input miniltx
\expandafter\def\expandafter\+\expandafter{\+}
\input url.sty
\end{verbatim}
\end{wideversion}
\item The \Package{hyperref} package, which uses the typesetting code
  of \Package{url}, in a context where the typeset text forms the
  anchor of a link.
\end{itemize}

The author of this answer prefers the (rather newer) \Package{url}
package (directly or indirectly); both \Package{path} and
\Package{url} work well with \plaintex{} (though of course, the fancy
\LaTeX{} facilities of \Package{url} don't have much place there).
(\Package{hyperref} isn't available in a version for use with \plaintex{}.)

Note that neither \csx{path} (from package \Package{path}) nor \csx{url} (from
package \Package{url}) is robust (in the \LaTeX{} sense).  If you need
a \acro{URL} to go in a moving argument, you need the command
\csx{urldef} from the \Package{url} package.  So one might write:
\begin{quote}
\begin{verbatim}
\urldef\faqhome\url{http://www.tex.ac.uk/faq}
\end{verbatim}
\end{quote}
after which, \csx{faqhome} is robust.

Documentation of both package \Package{path} and package \Package{url}
is in the package files.
\begin{ctanrefs}
\item[hyperref.sty]\CTANref{hyperref}
\item[miniltx.tex]Distributed as part of \CTANref{graphics-plain}
\item[path.sty]\CTANref{path}
\item[url.sty]\CTANref{url}
\end{ctanrefs}

\Question[Q-music]{Typesetting music in \TeX{}}

In the early days, a simple music package called Mu\TeX{} was
written by Angelika Schofer and Andrea Steinbach, which demonstrated
that music typesetting was possible; the package was very limited, and is
hardly ever used nowadays.  Daniel Taupin took up the baton, and
developed Music\TeX{}, which allows the typesetting of polyphonic and
other multiple-stave music; Music\TeX{} remains available, but is most
definitely no longer recommended.

Music\TeX{} has been superseded by its successor MusiX\TeX{}, which is
a three-pass system (with a processor program that computes values for
the element spacing in the music), and achieves finer control than is
possible in the unmodified \TeX{}-based mechanism that Music\TeX{}
uses.  Daniel Taupin's is the only version of MusiX\TeX{} currently
being developed (the original author, Andreas Egler, had an
alternative version, but he is now working on a different package
altogether).

Input to Musix\TeX{} is extremely tricky stuff, and Don Simons'
preprocessor \ProgName{pmx} is the preferred method of creating input
for Taupin's version.  \ProgName{Pmx} greatly eases use of
Musix\TeX{}, but it doesn't support the full range of Musix\TeX{}'s
facilities directly; however, it does allow in-line Musix\TeX{} code
in \ProgName{pmx} sources.

Dirk Laurie's \ProgName{M-Tx} allows preparation of music with lyrics;
it operates ``on top of'' \ProgName{pmx}

Another simple notation is supported by \ProgName{abc2mtex}; this is a
package designed to notate tunes stored in an \acro{ASCII} format
(\texttt{abc} notation). It was designed primarily for folk and traditional
tunes of Western European origin (such as Irish, English and Scottish)
which can be written on one stave in standard classical notation, and
creates input intended for Music\TeX{}.  However, it should be
extendable to many other types of music.

Digital music fans can typeset notation for their efforts by using
\ProgName{midi2tex}, which translates \acro{MIDI} data files into
Music\TeX{} source code.

There is a mailing list (\Email{TeX-music@icking-music-archive.org})
for discussion of typesetting music in \TeX{}; it mostly covers
Musix\TeX{} and related systems.  To subscribe, use
\URL{http://icking-music-archive.org/mailman/listinfo/tex-music/}

An alternative (free) means of embedding music examples into \AllTeX{}
documents is \href{http://www.lilypond.org}{Lilypond}.  Lilypond is
(at heart) a batch music typesetting system with plain text input that
does most of its work without TeX.  Lilypond's input syntax is far
less cryptic than is Musix\TeX{}'s, and it handles much more stuff
automatically, yielding the same or better quality with less effort.
Lilypond can also produce basic \acro{MIDI} output.
\begin{ctanrefs}
\item[abc2mtex]\CTANref{abc2mtex}
\item[M-Tx]\CTANref{mtx}
\item[midi2tex]\CTANref{midi2tex}
\item[musictex]\CTANref{musictex}
% ! line breaks
\item[musixtex \nothtml{\rmfamily}(Taupin's version)]\CTANref{musixtex-taupin}
\item[musixtex \nothtml{\rmfamily}(Egler's version)]\CTANref{musixtex-egler}
\item[mutex]\CTANref{mutex}
\item[pmx]\CTANref{pmx}
\end{ctanrefs}

\Question[Q-parskip]{Zero paragraph indent}

The conventional way of typesetting running text has no separation
between paragraphs, and the first line of each paragraph in a block of
text indented.

In contrast, one common convention for typewritten text was to have no
indentation of paragraphs; such a style is often required for
``brutalist'' publications such as technical manuals, and in styles
that hanker after typewritten manuscripts, such as
officially-specified dissertation formats.

Anyone can see, after no more than a moment's thought, that if the
paragraph indent is zero, the paragraphs must be separated by blank
space: otherwise it is sometimes going to be impossible to see the
breaks between paragraphs.

The simple-minded approach to zero paragraph indentation is thus:
\begin{verbatim}
  \setlength{\parindent}{0pt}
  \setlength{\parskip}{\baselineskip}
\end{verbatim}
and in the very simplest text, it's a fine solution.

However, the non-zero \csx{parskip} interferes with lists and the like,
and the result looks pretty awful.  The \Package{parskip} package
patches things up to look reasonable; it's not perfect, but it deals
with most problems.

The Netherlands Users' Group's set of classes includes an
\Class{article} equivalent (\Class{artikel3}) and a \Class{report}
equivalent (\Class{rapport3}) whose design incorporates zero paragraph
indent and non-zero paragraph skip.
\begin{ctanrefs}
\item[\nothtml{\rmfamily}\acro{NTG} classes]\CTANref{ntgclass}
\item[parskip.sty]\CTANref{parskip}
\end{ctanrefs}

\Question[Q-dropping]{Big letters at the start of a paragraph}

A common style of typesetting, now seldom seen except in newspapers,
is to start a paragraph (in books, usually the first of a chapter)
with its first letter set large enough to span several lines.

This style is known as ``dropped capitals'', or (in French)
\latexhtml{``lettrines''}{«lettrines»}, and \TeX{}'s primitive
facilities for hanging indentation make its (simple) implementation
pretty straightforward.

The \Package{dropping} package does the job simply, but has a curious
attitude to the calculation of the size of the font to be used for the
big letters.  Examples appear in the package documentation, so before
you process the \extension{dtx}, the package itself must already be installed.
Unfortunately, \Package{dropping} has an intimate relation to the set
of device drivers available in an early version of the \LaTeX{}
graphics package, and it cannot be trusted to work with recent
offerings like \PDFTeX{}, V\TeX{} or \acro{DVI}pdfm.

On such occasions, the more recent \Package{lettrine} package is more
likely to succeed.  It has a well-constructed array of options, and
the examples (a pretty impressive set) come as a separate file in the
distribution (also available in \PS{}, so that they can be viewed
without installing the package itself).
\begin{ctanrefs}
\item[dropping]\CTANref{dropping}
\item[lettrine]\CTANref{lettrine}
\end{ctanrefs}

\Question[Q-dec_comma]{The comma as a decimal separator}

\TeX{} embodies the British/American cultural convention of using a
period as the separator between the whole number and the decimal
fraction part of a decimal number.  Other cultures use a comma as
separator, but if you use a comma in maths mode you get a small space
after it; this space makes a comma that is used as a decimal separator
look untidy.

A simple solution to this problem, in maths mode, is to type
\texttt{3}\marg{,}\texttt{14} in place of \texttt{3,14}.  While such a
technique may produce the right results, it is plainly not a
comfortable way to undertake any but the most trivial amounts of
typing numbers.

Therefore, if you need to use commas as decimal separator, you will
probably welcome macro support.  There are two packages that
can help relieve the tedium: \Package{icomma} and \Package{ziffer}.

\Package{Icomma} ensures that there will be no extra space after a
comma, unless you type a space after it (as in \texttt{f(x, y)}~--- in
the absence of the package, you don't need that space), in which case
the usual small space after the comma appears.  \Package{Ziffer} is
specifically targeted at the needs of those typesetting German, but
covers the present need, as well as providing the double-minus sign
used in German (and other languages) for the empty `cents' part of an
amount of currency.

The \Package{numprint} package provides a command
\cmdinvoke*{numprint}{number} that prints its argument according to
settings you give it, or according to settings chosen to match the
language you have selected in \Package{babel}.  The formatting works
equally well in text or maths.  The command is very flexible (it can also
group the digits of very `long' numbers), but is inevitably less
convenient than \Package{icomma} or \Package{ziffer} if you are typing a
lot of numbers.
\begin{ctanrefs}
\item[icomma.sty]Distributed as part of \CTANref{was}
\item[numprint.sty]\CTANref{numprint}
\item[ziffer.sty]\CTANref{ziffer}
\end{ctanrefs}

\Question[Q-breakbox]{Breaking boxes of text}

\AllTeX{} boxes may not be broken, in ordinary usage: once you've
typeset something into a box, it will stay there, and the box will jut
out beyond the side or the bottom of the page if it doesn't fit in the
typeset area.

If you want a substantial portion of your text to be framed (or
coloured), the restriction starts to seem a real imposition.
Fortunately, there are ways around the problem.

The \Package{framed} package provides \environment{framed} and
\environment{shaded} environments; both put their content into
something which looks like a framed (or coloured) box, but which
breaks as necessary at page end.  The environments ``lose'' footnotes,
marginpars and head-line entries, and will not work with
\Package{multicol} or other column-balancing macros.  The
\Class{memoir} class includes the functionality of the
\Package{framed} package.

The \Package{boites} package provides a \environment{breakbox}
environment; examples of its use may be found in the distribution, and
the package's \File{README} file contains terse documentation.  The
environments may be nested, and may appear inside
\environment{multicols} environments; however, floats, footnotes and
marginpars will be lost.

For \plaintex{} users, the facilities of the \Package{backgrnd}
package may be useful; this package subverts the output routine to
provide vertical bars to mark text, and the macros are clearly marked
to show where coloured backgrounds may be introduced (this requires
\Package{shade}, which is distributed as tex macros and
device-independent \MF{} for the shading).  The author of
\Package{backgrnd} claims that the package works with \LaTeXo{}, but
there are reasons to suspect that it may be unstable working with
current \LaTeX{}.
\begin{ctanrefs}
\item[backgrnd.tex]\CTANref{backgrnd}
\item[boites.sty]\CTANref{boites}
\item[framed.sty]\CTANref{framed}
\item[memoir.cls]\CTANref{memoir}
\item[shade.tex]\CTANref{shade}
\end{ctanrefs}

\Question[Q-overstrike]{Overstriking characters}

This may be used, for example, to indicate text deleted in the course
of editing.  Both the \Package{ulem} and the \Package{soul} packages
provide the necessary facilities.

Overstriking for % beware line break
\Qref*{cancellation in maths expressions}{Q-cancellation} is achieved
by a different mechanism.

Documentation of \Package{ulem} is in the package file.
\begin{ctanrefs}
\item[soul.sty]\CTANref{soul}
\item[ulem.sty]\CTANref{ulem}
\end{ctanrefs}

\Question[Q-upquot]{Realistic quotes for verbatim listings}

The \texttt{cmtt} font has ``curly'' quotes\nothtml{ (\texttt{`thus'})},
which are pleasing on the eye, but don't really tally with what one
sees on a modern % beware line break
\ProgName{xterm}\nothtml{ (which look like \texttt{\textasciigrave this\textquotesingle})}.

The appearance of these quotes is critical in program listings,
particularly in those of Unix-like shell scripts.  The
\Package{upquote} package modifies the behaviour of the
\environment{verbatim} environment so that the output is a clearer
representation of what the user must type.
\begin{ctanrefs}
\item[upquote.sty]\CTANref{upquote}
\end{ctanrefs}

\Question[Q-time]{Printing the time}

\TeX{} has a primitive register that contains ``the number of minutes
since midnight''; with this knowledge it's a moderately simple
programming job to print the time (one that no self-respecting
\plaintex{} user would bother with anyone else's code for).

However, \LaTeX{} provides no primitive for ``time'', so the
non-programming \LaTeX{} user needs help.

Two packages are available, both providing ranges of ways of printing
the date, as well as of the time: this question will concentrate on
the time-printing capabilities, and interested users can investigate
the documentation for details about dates.

The \Package{datetime} package defines two time-printing functions:
\csx{xxivtime} (for 24-hour time), \csx{ampmtime} (for 12-hour time) and
\csx{oclock} (for time-as-words, albeit a slightly eccentric set of
words).

The \Package{scrtime} package (part of the compendious
\Class{KOMA-Script} bundle) takes a package option (\pkgoption{12h} or
\pkgoption{24h}) to specify how times are to be printed.  The command
\csx{thistime} then prints the time appropriately (though there's no
\emph{am} or \emph{pm} in \pkgoption{12h} mode).  The \csx{thistime}
command also takes an optional argument, the character to separate the
hours and minutes: the default is of course \texttt{:}.
\begin{ctanrefs}
\item[datetime.sty]\CTANref{datetime}
\item[scrtime.sty]Distributed as part of \CTANref{koma-script}
\end{ctanrefs}

\Question[Q-the-commands]{Redefining counters' \csx{the-}commands}

Whenever you request a new \LaTeX{} counter, \LaTeX{} creates a bunch
of behind-the-scenes commands, as well as defining the counter
itself.

Among other things, \cmdinvoke*{newcounter}{fred} creates a command
\csx{the}\texttt{\emph{fred}}, which expands to ``the value of
\texttt{\emph{fred}}'' when you're typesetting.

The definition of \csx{the}\texttt{\emph{fred}} should express the
value of the counter: it is almost always always a mistake to use the
command to produce anything else.  The value may reasonably be
expressed as an arabic, a roman or a greek number, as an alphabetic
expression, or even as a sequence (or pattern of) symbols.  If you
need a decision process on whether to re-define
\csx{the}\texttt{\emph{fred}}, consider what might happen when you do
so.

So, for example, if you want your section numbers to be terminated by
a period, you could make \csx{thesection} expand with a terminating
period.  However, such a change to \csx{thesection} makes the
definition of \csx{thesubsection} look distinctly odd: you are going to
find yourself redefining things left, right and centre.  Rather, use
the standard techniques for % beware line break
\Qref*{adjusting the presentation of section numbers}{Q-seccntfmt}. 

Or, suppose you want the page number to appear at the bottom of each
page surrounded by dashes (as in
``\texttt{-}{}\texttt{-\textasciitilde}\texttt{nnn\textasciitilde-}{}\texttt{-}'').
If you try to achieve this by redefining \csx{thepage}, problems will
arise from the use of the page number in the table of contents (each
number will have the dashes attached), and \csx{pageref} references
will be oddly modified.  In this case, the change of appearance is
best done by redefining the page style itself, perhaps using
\Qref*{package \Package{fancyhdr}}{Q-fancyhdr}.

\subsection{Tables of contents and indexes}

\Question[Q-tocloft]{The format of the Table of Contents, etc.}

The formats of entries in the table of contents (\acro{TOC}) are
controlled by a number of internal commands (discussed in section~2.3
of \Qref*{\emph{The \LaTeX{} Companion}}{Q-books}.  The commands
\csx{@pnumwidth}, \csx{@tocrmarg} and \csx{@dotsep} control the space
for page numbers, the indentation of the right-hand margin, and the
separation of the dots in the dotted leaders, respectively.  The
series of commands named \csx{l@\emph{xxx}}, where \texttt{\emph{xxx}}
is the name of a sectional heading (such as \texttt{chapter} or
\texttt{section}, \dots{}\@) control the layout of the corresponding
heading, including the space for section numbers.  All these internal
commands may be individually redefined to give the effect that you
want.

Alternatively, the package \Package{tocloft} provides a set of
user-level commands that may be used to change the \acro{TOC}
formatting.  Since exactly the same mechanisms are used for the List
of Figures and List of Tables, the layout of these sections may be
controlled in the same way.

The \Class{KOMA-Script} classes provides an optional variant structure
for the table of contents, and calculates the space needed for the
numbers automatically.  The \Class{memoir} class includes the functionality
of \Package{tocloft}.
\begin{ctanrefs}
\item[\nothtml{\rmfamily}KOMA script bundle]\CTANref{koma-script}
\item[memoir.cls]\CTANref{memoir}
\item[tocloft.sty]\CTANref{tocloft}
\end{ctanrefs}

\Question[Q-secnumdep]{Unnumbered sections in the Table of Contents}

The way the relevant parts of sectioning commands work is exemplified
by the way the \csx{chapter} command uses the counter \texttt{secnumdepth}
(described in Appendix~C of the \LaTeX{} manual):
\begin{enumerate}
\item put something in the \extension{aux} file, which will appear in
  the \extension{toc};
\htmlignore 
\item if \ensuremath{\texttt{secnumdepth} \geq 0},
\endhtmlignore
\begin{htmlversion}
\item if the \texttt{secnumdepth} counter is greater than or equal to
  zero,
\end{htmlversion}
  increase the counter for the chapter and write it out.
\item write the chapter title.
\end{enumerate}
Other sectioning commands are similar, but with other values used in
the test.

So a simple way to get headings of funny `sections' such as prefaces
in the table of contents is to use the counter:
\begin{quote}
\begin{verbatim}
\setcounter{secnumdepth}{-1}
\chapter{Preface}
\end{verbatim}
\end{quote}
Unfortunately, you have to set \texttt{secnumdepth} back to its usual
value (which is~2 in the standard styles) before you do any `section'
which you want to be numbered.

Similar settings are made, automatically, in the \LaTeX{} book class by
the \csx{frontmatter} and \csx{backmatter} commands.

The value of the counter \texttt{tocdepth} controls which headings
will be finally printed in the table of contents.  This normally has
to be set in the preamble and is a constant for the document.  The
package \Package{tocvsec2} package provides a convenient interface to
allow you to change the \texttt{secnumdepth} and/or the
\texttt{tocdepth} counter values at any point in the body of the
document; this provides convenient independent controls over the
sectional numbering and the table of contents.

The package \Package{abstract} (see % line break!
\Qref[question]{one-column abstracts}{Q-onecolabs}) includes an option
to add the \texttt{abstract} to the table of contents, while the
package \Package{tocbibind} has options to include the table of
contents itself, the \texttt{bibliography}, \texttt{index}, etc., to
the table of contents.

The \Class{KOMA-Script} classes have commands \csx{addchap} and
\csx{addled}, which work like \csx{chapter} and \csx{section} but
aren't numbered.  The \Class{memoir} class incorporates the facilities
of all three of the \Package{abstract}, \Package{tocbibind} and
\Package{tocvsec2} packages.
\begin{ctanrefs}
\item[abstract.sty]\CTANref{abstract}
\item[\nothtml{\rmfamily}KOMA script bundle]\CTANref{koma-script}
\item[memoir.cls]\CTANref{memoir}
\item[tocbibind.sty]\CTANref{tocbibind}
\item[tocvsec2.sty]\CTANref{tocvsec2}
\end{ctanrefs}

\Question[Q-tocbibind]{Bibliography, index, etc., in \acro{TOC}}

The standard \LaTeX{} classes (and many others) use \csx{section*} or
\csx{chapter*} for auto-generated parts of the document (the tables of
contents, lists of figures and tables, the bibliography and the index).  As a
result, these items aren't numbered (which most people don't mind),
and (more importantly) they don't appear in the table of contents.

The correct solution (as always) is to have a class of your own that
formats your document according to your requirements.  The macro to do
the job (\csx{addcontentsline}) is fairly simple, but there is always
an issue of ensuring that the contents entry quotes the correct page.
Supposing that our the document is chapter-based (class \Class{report}
or \Class{book}, for example), the text:
\begin{quote}
\begin{verbatim}
\bibliography{frooble}
\addcontentsline{toc}{chapter}{Bibliography}
\end{verbatim}
\end{quote}
will produce the \emph{wrong} answer if the bibliography is more than
one page long.  Instead, one should say:
\begin{quote}
\begin{verbatim}
\cleardoublepage
\addcontentsline{toc}{chapter}{Bibliography}
\bibliography{frooble}
\end{verbatim}
\end{quote}
(Note that \csx{cleardoublepage} does the right thing, even if your
document is single-sided~--- in that case, it's a synonym for
\csx{clearpage}).  Ensuring that the entry refers to the right place is
trickier still in a \csx{section}-based class.

If you are using \Package{hyperref} (which will link entries in the
table of contents to the relevant place in the file), a slight
adjustment is necessary:
\begin{quote}
\begin{verbatim}
\cleardoublepage
\phantomsection
\addcontentsline{toc}{chapter}{Bibliography}
\bibliography{frooble}
\end{verbatim}
\end{quote}
The extra command (\csx{phantomsection}) gives \Package{hyperref}
something to ``hold on to'' when making the link.

The common solution, therefore, is to use the \Package{tocbibind}
package, which provides many facilities to control the way these
entries appear in the table of contents.

Classes of the \Class{KOMA-script} bundle provide this functionality
as a set of class options (e.g., \pkgoption{bibtotoc} to add the
bibliography to the table of contents); the \Class{memoir} class includes
\Package{tocbibind} itself.
\begin{ctanrefs}
\item[hyperref.sty]\CTANref{hyperref}
\item[\nothtml{\rmfamily}KOMA script bundle]\CTANref{koma-script}
\item[memoir.cls]\CTANref{memoir}
\item[tocbibind.sty]\CTANref{tocbibind}
\end{ctanrefs}

\Question[Q-minitoc]{Table of contents, etc., per chapter}

The common style, of a ``small'' table of contents for each part,
chapter, or even section, is supported by the \Package{minitoc}
package.  The package also supports mini-lists of tables and figures;
but, as the documentation observes, mini-bibliographies are a
different problem~--- see
\Qref[question]{bibliographies per chapter}{Q-chapbib}.

The package's basic scheme is to generate a little \extension{aux} file for
each chapter, and to process that within the chapter.  Simple usage
would be:
\begin{quote}
\begin{verbatim}
\usepackage{minitoc}
...
\begin{document}
...
\dominitoc \tableofcontents
\dominilof \listoffigures
...
\chapter{blah blah}
\minitoc \mtcskip \minilof
...
\end{verbatim}
\end{quote}
though a lot of elaborations are possible (for example, you don't need
a \csx{minitoc} for every chapter).

\Package{Babel} doesn't know about \Package{minitoc}, but
\Package{minitoc} makes provision for other document languages than
English~--- a wide variety is available.  Fortunately, the current
version of the \Package{hyperref} package does know about
\Package{minitoc} and treats \csx{minitoc} tables in the
same way as ``real'' tables of contents.
\begin{ctanrefs}
\item[babel.sty]\CTANref{babel}
\item[hyperref.sty]\CTANref{hyperref}
\item[minitoc.sty]\CTANref{minitoc}
\end{ctanrefs}

\Question[Q-multind]{Multiple indexes}

\LaTeX{}'s standard indexing capabilities (those provided by the
\Package{makeidx} package) only provide for one index in your
document; even quite modest documents can be improved by indexes for
separate topics.

The \Package{multind} package provides simple and straightforward
multiple indexing.  You tag each \csx{makeindex}, \csx{index} and
\csx{printindex} command with a file name, and indexing commands are
written to (or read from) the name with the appropriate (\extension{idx} or
\extension{ind}) extension appended.  The \csx{printindex} command is modified
from the \LaTeX{} standard so that it doesn't create its own chapter
or section heading; you therefore decide what names (or sectioning
level, even) to use for the indexes, and
\Qref*{\csx{indexname}}{Q-fixnam} is completely ignored.

To create a ``general'' and an ``authors'' index, one might write:
\begin{quote}
\begin{verbatim}
\usepackage{multind}
\makeindex{general}
\makeindex{authors}
...
\index{authors}{Another Idiot}
...
\index{general}{FAQs}
...
\printindex{general}{General index}
\printindex{authors}{Author index}
\end{verbatim}
\end{quote}
To complete the job, run \LaTeX{} on your file enough times that
labels, etc., are stable, and then execute the commands
\begin{quote}
\begin{verbatim}
makeindex general
makeindex authors
\end{verbatim}
\end{quote}
before running \LaTeX{} again.  Note that the names of the index files
to process are not necessarily related to the name of the \LaTeX{}
file you're processing, at all.  (There's no documentation that comes
with the package: what you see above is as good as you will
get\dots{})

The \Package{index} package provides a comprehensive set of indexing
facilities, including a \csx{newindex} command that allows the
definition of new styles of index.  \csx{newindex} takes a `tag' (for
use in indexing commands), replacements for the \extension{idx} and
\extension{ind} file extensions, and a title for the index when it's
finally printed; it can also change the item that's being indexed
against (for example, one might have an index of artists referenced by
the figure number where their work is shown).

Using \Package{index}, to create an author index together with a
``normal'' index, one would start with preamble commands:
\begin{quote}
\begin{verbatim}
\usepackage{index}
\makeindex
\newindex{aut}{adx}{and}{Name Index}
\end{verbatim}
\end{quote}
which load the package, define a ``main'' (original-style) index, and
then define an author index.  Then, in the body of the document, we
might find commands like:
\begin{quote}
\begin{verbatim}
\index[aut]{Another Idiot}
...
\index{FAQs}
\end{verbatim}
\end{quote}
Which place an entry in the author index, and then one in the main
index.  At the end of the document, we have two commands:
\begin{quote}
\begin{verbatim}
\printindex
\printindex[aut]
\end{verbatim}
\end{quote}
Which will print the main index and then the author index.  Supposing
this lot to be in \File{myfile.tex}, after enough runs through
\LaTeX{} that labels are stable, execute the following commands
(Unix-style shell commands shown here, but the principle is the same
whatever system you're using):
\begin{quote}
\begin{verbatim}
makeindex myfile
makeindex myfile.adx -o myfile.and
\end{verbatim}
\end{quote}
and rerun \LaTeX{}.  The \ProgName{makeindex} commands process
\File{myfile.idx} to \File{myfile.ind} (the default action), and then
\File{myfile.adx} to \File{myfile.and}, the two files needed as input
by the two \csx{printindex} commands in \File{myfile.tex}.

The \Package{splitidx} package can operate in the same way as the
others: load the package with the \pkgoption{split} option, and
declare each index with a \csx{newindex} command:
\begin{quote}
  \cmdinvoke{newindex}[\meta{index name}]{\meta{shortcut}}
\end{quote}
and \Package{splitidx} will generate a file
\csx{jobname}\texttt{.\meta{shortcut}} to receive index entries
generated by commands like \cmdinvoke{sindex}[\meta{shortcut}]{\meta{item}}.
As with the other packages, this method is limited by \TeX{}'s total
number of output files.  However, \Package{splitindex} also comes with
a small executable \ProgName{splitindex} (available for a variety of
operating systems); if you use this auxiliary program (and don't use
\pkgoption{split}), there's no limit to the number of indexes.  Apart
from this trick, \Package{splitidx} supports the same sorts of things
as does \Package{index}.  An example of use appears in
the documentation.

The \Class{memoir} class has its own multiple-index functionality (as
well as its own index layout options, which other packages delegate to
the index style used by \ProgName{makeindex}).
\begin{ctanrefs}
\item[index.sty]\CTANref{index}
\item[makeidx.sty]Part of the \LaTeX{} distribution
\item[memoir.cls]\CTANref{memoir}
\item[multind.sty]\CTANref{multind}
\item[splitidx.sty \bgroup\nothtml{\normalfont}and \egroup splitindex]%
  \CTANref{splitindex}
\end{ctanrefs}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\subsection{Labels and references}

\Question[Q-nameref]{Referring to things by their name}

\LaTeX{}'s labelling mechanism is designed for the impersonal world of
the academic publication, in which everything has a number: an
extension is necessary if we are to record the \emph{name} of things
we've labelled.  The two packages available extend the \LaTeX{}
sectioning commands to provide reference by the name of the section.

The \Package{titleref} package is a simple extension which provides
the command \csx{titleref}; it is a stand-alone package~--- don't use it
in a document in which you also need to use \Package{hyperref}.

The \Package{byname} package is part of the \Package{smartref} bundle
and works well with \Package{smartref}, and works (to an extent) with
\Package{hyperref}, but the links it defines are not hyperlinks.

The \Class{memoir} class incorporates the functionality of
\Package{titleref}, but doesn't work with \Package{byname} (though a
search of \Newsgroup{comp.text.tex} on \URL{groups.google.com} will
find a patch to \Package{byname} to remedy the problem).

The \Package{hyperref} bundle includes a package \Package{nameref},
which will work standing alone (i.e., without \Package{hyperref}: of
course, in this mode its references are not hyperlinked).  If you load
\Package{hyperref} itself, \Package{nameref} is automatically loaded.
\Class{Memoir} requires the \Package{memhfixc} when running with
\Package{hyperref}; following the sequence:
\begin{quote}
\begin{verbatim}
\documentclass[...]{memoir}
...
\usepackage[...]{hyperref}
\usepackage{memhfixc}
\end{verbatim}
\end{quote}
\Package{nameref} commands may be used in a \Class{memoir} document.

\Package{Zref} defines a proposed replacement for all of the \LaTeX{}
reference mechanisms, and among other things provides
name-referencing mechanisms:
\begin{quote}
\begin{verbatim}
\usepackage[user,titleref]{zref}
...
\section{hello}\zlabel{sec:one}
The section name is: \ztitleref{sec:one}.
\end{verbatim}
\end{quote}
(One might hope that something of this sort would be the ``way of the
future'', but things move slowly in the \LaTeX{} world: don't hold
your breath.) 

Each of \Package{titleref}, \Package{byname} and \Package{nameref}
defines a reference command with the same name as the package:
\csx{titleref}, \csx{byname} and \csx{nameref}. The \Package{nameref}
package also defines a command \csx{byshortnameref}, which uses the
optional `short' title argument to the chapter and section commands.
(Although it comes from the same author, \Package{zref} \emph{doesn't}
define a short-name variant.)
\begin{ctanrefs}
\item[byname.sty]Distributed with \CTANref{smartref}
\item[hyperref.sty]\CTANref{hyperref}
\item[memoir.cls]\CTANref{memoir}
\item[nameref.sty]Distributed with \CTANref{hyperref}
\item[smartref.sty]\CTANref{smartref}
\item[titleref.sty]\CTANref{titleref}
\item[zref.sty]Distributed as part of \CTANref{oberdiek}
\end{ctanrefs}

\Question[Q-extref]{Referring to labels in other documents}

When producing a set of inter-related documents, you'll often want to
refer to labels in another document of the set; but \LaTeX{}, of its
own accord, doesn't permit this.

So the package \Package{xr} was written: if you say
\begin{quote}
\begin{verbatim}
\usepackage{xr}
\externaldocument{volume1}
\end{verbatim}
\end{quote}
will load all the references from \File{volume1} into your present
document.

But what if the documents both have a section labelled
``\environment{introduction}'' (likely enough, after all)?  The
package provides a means to transform all the imported labels, so you
don't have to change label names in either document.  For example:
\begin{quote}
\begin{verbatim}
\usepackage{xr}
\externaldocument[V1-]{volume1}
\end{verbatim}
\end{quote}
loads the references from \File{volume1}, but prefixes every one with
the string \texttt{V1-}.  So you would refer to the introduction to volume~1
as:
\begin{narrowversion}
\begin{quote}
\begin{verbatim}
\usepackage{xr}
\externaldocument[V1-]{volume1}
...
... the introduction to volume1
               (\ref{V1-introduction})...
\end{verbatim}
\end{quote}
\end{narrowversion}
\begin{wideversion}
\begin{quote}
\begin{verbatim}
\usepackage{xr}
\externaldocument[V1-]{volume1}
...
... the introduction to volume1 (\ref{V1-introduction})...
\end{verbatim}
\end{quote}
\end{wideversion}
To have the facilities of \Package{xr} working with
\Package{hyperref}, you need \Package{xr-hyper}.  For simple
hyper-cross-referencing (i.e., to a local \acro{PDF} file you've just
compiled), write:
\begin{quote}
\begin{verbatim}
\usepackage{xr-hyper}
\usepackage{hyperref}
\externaldocument[V1-]{volume1}
...
... the \nameref{V1-introduction})...
\end{verbatim}
\end{quote}
and the name reference will appear as an active link to the
``introduction'' chapter of \File{volume1.pdf}.

To link to a \acro{PDF} document on the Web, for which you happen to
have the .aux file, write:
\begin{quote}
\begin{wideversion}
\begin{verbatim}
\usepackage{xr-hyper}
\usepackage{hyperref}
\externaldocument[V1-]{volume1}[http://mybook.com/volume1.pdf]
...
... the \nameref{V1-introduction})...
\end{verbatim}
\end{wideversion}
\begin{narrowversion}
\begin{verbatim}
\usepackage{xr-hyper}
\usepackage{hyperref}
\externaldocument[V1-]{volume1}%
    [http://mybook.com/volume1.pdf]
...
... the \nameref{V1-introduction})...
\end{verbatim}
\end{narrowversion}
\end{quote}
\begin{ctanrefs}
\item[xr.sty]Distributed as part of \CTANref{2etools}
\item[xr-hyper.sty]Distributed with \CTANref{hyperref}
\end{ctanrefs}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\section{How do I do\dots{}?}

\subsection{Mathematics}

\Question[Q-proof]{Proof environment}

It has long been thought impossible to make a \environment{proof}
environment which automatically includes an `end-of-proof' symbol.
Some proofs end in displayed maths; others do not.  If the input file
contains
% beware line break
\texttt{...\csx{]} }\cmdinvoke{end}{proof} then \LaTeX{} finishes off
the displayed maths and gets ready for a new line before it reads any
instructions connected with ending the proof, so the code is very
tricky.  You \emph{can} insert the symbol by hand, but the
\Package{ntheorem} package now solves the problem for \LaTeX{} users:
it does indeed provide an automatic way of signalling the end of a
proof.

The \AMSLaTeX{} package \Package{amsthm} also provides a
\environment{proof} environment that does the job; though you need to
insert a \csx{qedhere} command if the proof ends with a displayed
equation:
\begin{quote}
\begin{verbatim}
\begin{proof}
  text...
  \begin{equation*}
    maths... \tag*{\qedhere}
  \end{equation*}
\end{proof}
\end{verbatim}
\end{quote}
The \cmdinvoke{tag*}{\csx{qedhere}} construction may be used in any of
\AMSLaTeX{}'s numbering environments.
\begin{ctanrefs}
\item[amsthm.sty]Distributed as part of the \AMSLaTeX{} bundle
  \CTANref{amslatex}
\item[ntheorem.sty]\CTANref{ntheorem}
\end{ctanrefs}

\Question[Q-theoremfmt]{Theorem bodies printed in a roman font}

If you want to take advantage of the powerful \csx{newtheorem} command
without the constraint that the contents of the theorem is in a sloped
font (for example, you may want to use it to create remarks, examples, proofs,
\dots{}) then you can use the \AMSLaTeX{} \Package{amsthm} package
(which now supersedes the \Package{theorem} package previously
recommended in these answers).
Alternatively, the following sets up an environment
\environment{remark} whose content is in the default roman font.
\begin{quote}
\begin{narrowversion}
\begin{verbatim}
\newtheorem{preremark}{Remark}
\newenvironment{remark}%
  {\begin{preremark}\upshape}%
  {\end{preremark}}
\end{verbatim}
\end{narrowversion}
\begin{wideversion}
\begin{verbatim}
\newtheorem{preremark}{Remark}
\newenvironment{remark}%
  {\begin{preremark}\upshape}{\end{preremark}}
\end{verbatim}
\end{wideversion}
\end{quote}
The \Package{ntheorem} package provides control of the fonts used by
theorems, directly.
\begin{ctanrefs}
\item[amsthm.sty]Distributed as part of \CTANref{amslatex}
\item[ntheorem.sty]\CTANref{ntheorem}
\item[theorem.sty]Distributed as part of \CTANref{2etools}
\end{ctanrefs}

\Question[Q-newfunction]{Defining a new log-like function in \LaTeX{}}

Use the \csx{mathop} command, as in:
\begin{quote}
\begin{verbatim}
\newcommand{\diag}{\mathop{\mathrm{diag}}}
\end{verbatim}
\end{quote}

Subscripts and superscripts on \csx{diag} will be placed below and
above the function name, as they are on
\csx{lim}.  If you want your subscripts and superscripts always placed
to the right, do:
\begin{quote}
\begin{narrowversion}
\begin{verbatim}
\newcommand{\diag}%
  {\mathop{\mathrm{diag}}\nolimits}
\end{verbatim}
\end{narrowversion}
\begin{wideversion}
\begin{verbatim}
\newcommand{\diag}{\mathop{\mathrm{diag}}\nolimits}
\end{verbatim}
\end{wideversion}
\end{quote}

\AMSLaTeX{} (in its \Package{amsopn} package, which is automatically
loaded by \Package{amsmath}) provides a command
\csx{DeclareMathOperator} that takes does the same job as the first
definition above.  To create our original \csx{diag} command, one would
say:
\begin{quote}
\begin{verbatim}
\DeclareMathOperator{\diag}{diag}
\end{verbatim}
\end{quote}
\csx{DeclareMathOperator*} declares the operator always to have its
sub- and superscripts in the % ! line break
``\Qref*{\csx{limits} position}{Q-limits}''.

The \Package{amsopn} command \csx{operatorname} allows you to
introduce \emph{ad hoc} operators into your mathematics, so
\begin{quote}
  \csx{[} \cmdinvoke{operatorname}{foo}\texttt{(bar)} \csx{]}
\end{quote}
typesets the same as
\begin{quote}
\begin{verbatim}
\DeclareMathOperator{\foo}{foo}
...
\[ \foo(bar) \]
\end{verbatim}
\end{quote}
As with \csx{DeclareMathOperator} there's a starred version
\csx{operatorname*} for sub- and superscripts in the limits position.

(It should be noted that ``log-like'' was reportedly a \emph{joke} on
Lamport's part; it is of course clear what was meant.)
\begin{ctanrefs}
\item[amsopn.sty]In the \AMSLaTeX{} distribution \CTANref{amslatex}
\end{ctanrefs}

\Question[Q-braket]{Set specifications and Dirac brackets}

One of the few glaring omissions from \TeX{}'s mathematical
typesetting capabilities is a means of setting separators in the
middle of mathematical expressions.  \TeX{} provides primitives called
\csx{left} and \csx{right}, which can be used to modify brackets (of
whatever sort) around a mathematical expression, as in:
% beware line wrap
\csx{left(}\texttt{ <expression> }\csx{right)}~--- the size of the
parentheses is matched to the vertical extent of the expression.

However, in all sorts of mathematical enterprises one may find oneself
needing a \csx{middle} command, to be used in expressions like
\begin{quote}
\begin{wideversion}
\begin{verbatim}
\left\{ x \in \mathbb{N} \middle| x \mbox{ even} \right\}
\end{verbatim}
\end{wideversion}
\begin{narrowversion}
\begin{verbatim}
\left\{ x\in \mathbb{N} \middle| 
                 x \mbox{ even} \right\}
\end{verbatim}
\end{narrowversion}
\end{quote}
to specify the set of even natural numbers.  The % ! line break
\Qref*{\eTeX{} system}{Q-etex}
defines just such a command, but users of Knuth's original need some
support.  Donald Arseneau's \Package{braket} package provides commands
for set specifications (as above) and for Dirac brackets (and bras and
kets).  The package uses the \eTeX{} built-in command if it finds
itself running under \eTeX{}.
\begin{ctanrefs}
\item[braket.sty]\CTANref{braket}
\end{ctanrefs}

\Question[Q-cancellation]{Cancelling terms in maths expressions}

A technique used when explaining the behaviour of expressions or
equations (often for pedagogical purposes).  The \Package{cancel}
package provides several variants of cancellation marks
(``\texttt{\textbackslash }'', ``\texttt{/}'' and ``\texttt{X}''), and
a means of cancelling `to' a particular value.

Documentation of \Package{cancel} is in the package file.
\begin{ctanrefs}
\item[cancel.sty]\CTANref{cancel}
\end{ctanrefs}

\Question[Q-mathsize]{Adjusting maths font sizes}

In \plaintex{}, when you introduce a new font size you must also
declare what size fonts are to be used in mathematics with it.  This
is done by declaring \csx{textfont}, \csx{scriptfont} and
\csx{scriptscriptfont} for the maths families you're using; all such
things are described in chapter~17 of the % line wrap!
\Qref*{\TeX{}book}{Q-books} and in other books and
\Qref*{tutorials}{Q-man-tex} that discuss \plaintex{} in sufficient
detail.

In \LaTeX{}, of course, all this stuff is automated: there is a scheme
that, for each (text) font size, determines what maths font sizes are
to be used.  The scheme first checks a set of ``known'' text sizes,
for each of which maths sizes are declared in advance.  If the text
size isn't ``known'', the script- and scriptscriptfont sizes are
calculated as fixed ratios of the tex font size.  (The values used are
\csx{defaultscriptratio}\ensuremath{=}0.7, and
\csx{defaultscriptscriptratio}\ensuremath{=}0.5.)

The fixed-ratio formula is capable of producing inconvenient results
(particularly if you are using fonts which \LaTeX{} believes are only
available in a fixed set of sizes).  You may also want to replace
\LaTeX{}'s ideas altogether, for example by setting maths noticeably
larger or smaller than its surrounding text.  For this purpose, the
\LaTeX{} command
\cmdinvoke{DeclareMathSizes}{\meta{tfs}}{\meta{ts}}{\meta{ss}}{\meta{sss}}
may be used (this is the same command that \LaTeX{} itself uses to
define its own set of sizes).  This establishes (or re-establishes)
the maths font sizes to be used when the surrounding text font size is
\texttt{\meta{tfs}}; (\texttt{\meta{ts}} being the size used for
\csx{textfont}, \texttt{\meta{ss}} for \csx{scriptfont} and
\texttt{\meta{sss}} for \csx{scriptscriptfont}).

For example, you might want to use a font with a smaller body height
than Computer Modern, but still prefer \acro{CM} math to any of the
alternatives.  In this case, you might use:
\begin{quote}
\begin{verbatim}
\DeclareMathSizes{10}{9}{7}{5}
\end{verbatim}
\end{quote}
to get 9pt maths when the surrounding body text is (nominal) 10pt.

\csx{DeclareMathSizes} may only be used in the preamble of the
document: only one association is available for each text font size
for the whole document.  The default settings are specified in
\File{fontdef.dtx} in the latex distribution, and are compiled into
\File{fontmath.ltx}; the arguments to the command are just numbers
(`\texttt{pt}' is assumed), but some of them are written using
\Qref*{\LaTeX{} abbreviations}{Q-ltxabbrv} for standard font sizes.
Beware simply copying (parts of) the \LaTeX{} definitions~--- since
they contain those internal abbreviations, they need to be treated as
\Qref{internal commands}{Q-atsigns}.
\begin{ctanrefs}
\item[fontdef.dtx]\CTANref{fontdef}
\item[fontmath.ltx]\CTANref{fontmath}
\end{ctanrefs}

\Question[Q-mathlips]{Ellipses}
\keywords{\csx{dots} \csx{cdots} \csx{vdots} \csx{ddots}}

Ellipses are commonly required, and \LaTeX{} natively supplies a fair
range (\csx{dots}, \csx{cdots}, \csx{vdots} and \csx{ddots}).  By using
the \Package{graphics} package, one can change the slope of the
\csx{ddots} command, as in
\begin{verbatim}
  $ ... \reflectbox{$\ddots$} ... $
\end{verbatim}
While this works, it is not a recommended way of achieving the desired
result (see below).  Moreover, \LaTeX{}'s range is not adequate to
everyone's requirements, and at least three packages provide
extensions to the set.

The \AMSLaTeX{} bundle provides a range of ``semantically-named''
ellipses, for use in different situations: \csx{dotsb} for use between
pairs of binary operators, \csx{dotsc} for use between pairs of commas,
and so on.

The \Package{yhmath} package defines an \csx{adots} command, which is
the analogue of \csx{ddots}, sloping forwards rather than backwards.
The \Package{yhmath} package comes with a rather interesting font that
extends the standard \Package{cmex}; details are in the documentation.
The disadvantage of this setup is, that although \csx{adots} is merely
a macro, the package tries to load its own font and produces a
``missing font'' substitution warning message if you haven't installed
the font.

The \Package{mathdots} package (besides fixing up the behaviour of
\AllTeX{} \csx{ddots} and \csx{vdots} when the font size changes)
provides an ``inverse diagonal'' ellipsis \csx{iddots} (doing the same
job as \Package{yhmath}'s \csx{adots}, but better).

Documentation of \Package{yhmath} appears, processed, in the
distribution (thus saving you the bother of installing the package
before being able to read the documentation).  Documentation of
\Package{mathdots} appears at the end the package file itself.
\begin{ctanrefs}
\item[amslatex]\CTANref{amslatex}
\item[graphics.sty]Part of the \CTANref{graphics} bundle
\item[mathdots.sty]\CTANref{mathdots}
\item[yhmath \nothtml{\rmfamily}(fonts)]\CTANref{yhmath-fonts}
\item[yhmath \nothtml{\rmfamily}(macros)]\CTANref{yhmath-macros}
\end{ctanrefs}

\Question[Q-limits]{Sub- and superscript positioning for operators}

The commonest hand-written style for expressions is to place the limit
expressions on operators such as \csx{sum} and \csx{int} physically
above and below the operator.  In \AllTeX{}, we write these limit
expressions using sub- and superscripts applied to the operator, but
they don't always appear in the ``handwritten'' way in \TeX{}'s
output.

The reason is, that when an expression appears in non-display maths,
in running text (and is therefore in \TeX{} \csx{textstyle}), placing
the limits thus could lead to ragged line spacing (and hence
difficult-to-read text).  It is therefore common (in \csx{textstyle})
to place the limits as one would sub- and superscripts of variables.

This is not universally satisfactory, so the primitive \csx{limits} is
provided:
\begin{quote}
\begin{verbatim}
$\sum\limits_{n=1}^{m} ...$
\end{verbatim}
\end{quote}
which will place the limits right above and below the symbol (and be
blowed to the typography\dots{}).

Contrariwise, you may wish to change the arrangement of the limits
when in \csx{displaystyle}.  For this purpose, there's a corresponding
\csx{nolimits}:
\begin{quote}
\begin{verbatim}
\[\sum\nolimits_{n=1}^{m} ...\]
\end{verbatim}
\end{quote}
which will place the limits as they would be in \csx{textstyle}.

Alternatively, one can manipulate the
\csx{textstyle}/\csx{displaystyle} state of the mathematics.  To get
``\csx{limits} placement'' in inline maths,
\begin{quote}
\begin{verbatim}
$\displaystyle\sum_{n=1}^{m} ...$
\end{verbatim}
\end{quote}
and for ``\csx{nolimits} placement'' in display maths,
\csx{nolimits}:
\begin{quote}
\begin{verbatim}
\[\textstyle\sum_{n=1}^{m} ...\]
\end{verbatim}
\end{quote}
will serve.  Either of these forms may have effects other than on the
operator you're considering, but there are still those who prefer this
formulation.

Remember, if you're % ! line break
\Qref*{declaring a special operator of your own}{Q-newfunction}, the
\AMSLaTeX{} functions (that you ought to be using) allow you to choose
how limits are displayed, at definition time.

(Note that the macro \csx{int} normally has \csx{nolimits} built in to
its definition.  There is an example in the \TeX{}book to show how odd
\csx{int}\csx{limits} looks when typeset.)

\Question[Q-mathstext]{Text inside maths}

When we type maths in \AllTeX{}, the letters from which we make up
ordinary text assume a special significance: they all become
single-letter variable names.  The letters appear in italics, but it's
not the same sort of italics that you see when you're typing ordinary
text: a run of maths letters (for example ``here'') looks oddly
``lumpy'' when compared with the word written in italic text.  The
difference is that the italic text is kerned to make the letters fit
well together, whereas the maths is set to look as if you're
multiplying \emph{h} by \emph{e} by \emph{r} by \emph{e}.  The other
way things are odd in \TeX{} maths typing is that spaces are ignored:
at best we can write single words in this oddly lumpy font.

So, if we're going to have good-looking text in amongst maths we're
writing, we have to take special precautions.  If you're using
\LaTeX{}, the following should help.

The simplest is to use \csx{mbox} or \csx{textrm}:
\begin{quote}
\begin{verbatim}
$e = mc^2 \mbox{here we go again}$
\end{verbatim}
\end{quote}
The problem is that, with either, the size of the text remains firmly
at the surrounding text size, so that
\begin{quote}
\begin{verbatim}
$z = a_{\mbox{other end}}$
\end{verbatim}
\end{quote}
looks quite painfully wrong.

The other simple technique, \csx{textrm}, is more promising:
\begin{quote}
\begin{verbatim}
$z = a_{\textrm{other end}}$
\end{verbatim}
\end{quote}
is definitely right.  However, the surrounding text may not be in your
roman font; if you care about matching text, you need to choose
between \csx{textrm}, \csx{textsf}, and so on.

(The maths-mode instance of your roman font (\csx{mathrm}) gets the
size right, but since it's intended for use in maths, its spaces get
ignored~--- use \csx{mathrm} for upright roman alphabetic variable
names, but not otherwise.)

You can correct these problems with size selectors in the text, as:
\begin{quote}
\begin{verbatim}
$z = a_{\mbox{\scriptsize other end}}$
\end{verbatim}
\end{quote}
which works if your surrounding text is at default document size, but
gives you the wrong size otherwise.

These short cuts are (just about) \acro{OK} for the ``occasional''
mathematician, but serious mathematics calls for a technique that
relieves the typist of the sort of thought required.  As usual, the
\AMSLaTeX{} system provides what's necessary~--- the \csx{text}
command.  The command is actually provided by the \Package{amstext}
package, but the ``global'' \Package{amsmath} package loads it, so
anyone using \AMSLaTeX{} proper has the command available, so even
joke mathematicians can write:
\begin{quote}
\begin{verbatim}
\usepackage{amsmath}
...
$z = a_{\text{other end}}$
\end{verbatim}
\end{quote}
and the text will be at the right size, and in the same font as
surrounding text.

\AMSLaTeX{} also makes provision for interpolated comments in the
middle of one of its multi-line display structures, through the
\csx{intertext} command.  For example:
\begin{quote}
\begin{narrowversion}
\begin{verbatim}
\begin{align}
  A_1&=N_0(\lambda;\Omega')-
    \phi(\lambda;\Omega'),\\
  A_2&=\phi(\lambda;\Omega')-
    \phi(\lambda;\Omega),\\
\intertext{and}
  A_3&=\mathcal{N}(\lambda;\omega).
\end{align}
\end{verbatim}
\end{narrowversion}
\begin{wideversion}
\begin{verbatim}
\begin{align}
  A_1&=N_0(\lambda;\Omega')-\phi(\lambda;\Omega'),\\
  A_2&=\phi(\lambda;\Omega')-\phi(\lambda;\Omega),\\
  \intertext{and} A_3&=\mathcal{N}(\lambda;\omega).
\end{align}
\end{verbatim}
\end{wideversion}
\end{quote}
places the text ``and'' on a separate line before the last line of the
display.  If the interjected text is short, or the equations
themselves are light-weight, you may find that \csx{intertext} leaves
too much space.  Slightly more modest is the \csx{shortintertext}
command from the \Package{mathtools} package:
\begin{quote}
\begin{verbatim}
\begin{align}
  a =& b
  \shortintertext{or}
  c =& b
\end{align}
\end{verbatim}
\end{quote}
To have the text on the same line as the second equation, one can use
the \environment{flalign} environment (from \Package{amsmath})
with lots of dummy equations (represented by the double \texttt{\&}
signs):
\begin{quote}
\begin{verbatim}
\begin{flalign}
            && a =& b && \\
  \text{or} && c =& b &&
\end{flalign}
\end{verbatim}
\end{quote}

Comprehensive documentation of \AMSLaTeX{} is to be found in
\File{amsldoc}, in the distribution; it is also available on the web
at \URL{ftp://ftp.ams.org/pub/tex/doc/amsmath/amsldoc.pdf}
\begin{ctanrefs}
\item[amsldoc.tex]Distributed as part of \AMSLaTeX{}
  \CTANref{amslatex}
\item[amsmath.sty]Distributed as part of \AMSLaTeX{}
  \CTANref{amslatex}
\item[amstext.sty]Distributed as part of \AMSLaTeX{}
  \CTANref{amslatex}
\item[mathtools.sty]Distributed as part of the \Package{mh} bundle
  \CTANref{mh}
\end{ctanrefs}

\Question[Q-reuseq]{Re-using an equation}

To repeat an existing equation, one wants not only to have the same
mathematics in it, one also wants to re-use the original label it had.
The \Package{amsmath} package comes to our help, here:
\begin{quote}
\begin{verbatim}
\usepackage{amsmath}
...
\begin{equation}
  a=b
  \label{eq1}
\end{equation}
...
Remember that
\begin{equation}
  a=b
  \tag{\ref{eq1}}
\end{equation}
\end{verbatim}
\end{quote}
Here, the second instance of \ensuremath{a=b} will be
typeset with a copy, made by the \csx{tag} command, of the label of the
first instance.

Comprehensive documentation of \AMSLaTeX{} is to be found in
\File{amsldoc}, in the distribution; it is also available on the web
at \URL{ftp://ftp.ams.org/pub/tex/doc/amsmath/amsldoc.pdf}
\begin{ctanrefs}
\item[amsldoc.tex]Distributed as part of \AMSLaTeX{}
  \CTANref{amslatex}
\item[amsmath.sty]Distributed as part of \AMSLaTeX{}
  \CTANref{amslatex}
\end{ctanrefs}

\Question[Q-brkinline]{Line-breaking in in-line maths}

\TeX{}, by default, allows you to split a mathematical expression at
the end of the line; it allows breaks at relational operators (like
``='', ``\textless'', etc.) and at binary operators (like ``+'',
``-'', etc.).  In the case of large expressions, this can sometimes be
a life-saver.

However, in the case of simple expressions like \ensuremath{a=b+c}, a
break can be really disturbing to the reader, and one would like to
avoid it.

Fortunately, these breaks are controllable: there are ``penalties''
associated with each type of operator: the penalty 
 says how
undesirable a break at each point is.  Default values are:
\begin{quote}
\begin{verbatim}
\relpenalty   = 500
\binoppenalty = 700
\end{verbatim}
\end{quote}
You make the break progressively less attractive by increasing these
values.  You can actually forbid all breaks, everywhere, by:
\begin{quote}
\begin{verbatim}
\relpenalty   = 10000
\binoppenalty = 10000
\end{verbatim}
\end{quote}
If you want just to prevent breaks in a single expression, write:
\begin{quote}
\begin{verbatim}
{%
  \relpenalty   = 10000
  \binoppenalty = 10000
  $a=b+c$
}
\end{verbatim}
\end{quote}
and the original values will remain undisturbed outside the braces.
This is tedious: there is often value in an alternative approach,
in which you say which parts of the expression may not break whatever
happens, and fortunately this is surprisingly easy.  Suppose we want
to defer a break until after the equality, we could write:
\begin{quote}
\begin{verbatim}
${a+b+c+d} = z+y+x+w$
\end{verbatim}
\end{quote}
The braces say ``treat this subformula as one atom'' and (in \TeX{} at
least) atoms don't get split: not a \csx{binoppenalty} change in sight.

\Question[Q-mathonlyref]{Numbers for referenced equations only}

There are those who consider that papers look untidy with numbers on
every equation; there is also a school of thought that claims that
there should be numbers everywhere, in case some reader wants to make
reference an equation to which the author made no cross-reference.

If you hold to the ``only cross-referenced'' school of thought, you
can (using the \csx{nonumber} command on the relevant equations, or by
using the \AMSLaTeX{} unnumbered environments such as
\environment{equation*}) mark those of your equations to which you
make no reference.  In a long or complex paper, this procedure could
well become deeply tedious.

Fortunately, help is at hand: the \Package{mh} bundle's
\Package{mathtools} package offers a `\pkgoption{showonlyrefs}'
switch through its \csx{mathtoolsset} command; when that's in
operation, only those equations to which you make reference will be
numbered in the final output.  See the package's documentation for
details of how to make references when the switch is in effect.
\begin{ctanrefs}
\item[mathtools.sty]Distributed as part of \CTANref{mh}
\end{ctanrefs}

\subsection{Lists}

\Question[Q-enumerate]{Fancy enumeration lists}

The \Package{enumerate} package allows you to control the display of
the enumeration counter.  The package adds an optional parameter to
the \environment{enumerate} environment, which is used to specify the
layout of the labels.  The layout parameter contains an enumeration
type (`\texttt{1}' for arabic numerals, `\texttt{a}' or `\texttt{A}'
for alphabetic enumeration, and `\texttt{i}' or `\texttt{I}' for Roman
numerals), and things to act as decoration of the enumeration.  So,
for example
\begin{quote}
\begin{verbatim}
\usepackage{enumerate}
...
\begin{enumerate}[(a)]
\item ...  ...
\end{enumerate}
\end{verbatim}
\end{quote}
starts a list whose labels run (a), (b), (c), \dots{}; while
\begin{quote}
\begin{verbatim}
\usepackage{enumerate}
...
\begin{enumerate}[I/]
\item ...  ...
\end{enumerate}
\end{verbatim}
\end{quote}
starts a list whose labels run I/, II/, III/, \dots{}

The \Package{paralist} package, whose primary purpose is % beware line break
\Qref*{compaction of lists}{Q-complist}, provides the same facilities
for its \environment{enumerate}-like environments.

If you need non-stereotyped designs, the \Package{enumitem} package
gives you most of the flexibility you might want to design your own.
The silly roman example above could be achieved by:
\begin{quote}
\begin{verbatim}
\usepackage{enumitem}
...
\begin{enumerate}[label=\Roman{*}/]
\item ...  ...
\end{enumerate}
\end{verbatim}
\end{quote}
Note that the `\texttt{*}' in the key value stands for the list
counter at this level.  You can also manipulate the format of
references to list item labels:
\begin{quote}
\begin{narrowversion}
\begin{verbatim}
\usepackage{enumitem}
...
\begin{enumerate}[label=\Roman{*}/,
  ref=(\roman{*})]
\item ...  ...
\end{enumerate}
\end{verbatim}
\end{narrowversion}
\begin{wideversion}
\begin{verbatim}
\usepackage{enumitem}
...
\begin{enumerate}[label=\Roman{*}/, ref=(\roman{*})]
\item ...  ...
\end{enumerate}
\end{verbatim}
\end{wideversion}
\end{quote}
to make references to the list items format appear as (i), (ii),
(iii), etc.

The \Class{memoir} class includes functions that match those in the
\Package{enumerate} package, and has similar functionality for
\environment{itemize} lists.
%% It is possible (if not particularly convenient) to do the same thing
%% yourself.  Suppose you want your top-level \environment{enumerate}s to
%% be labelled I/, II/, III/, \dots{}, then give these commands:
%% \begin{verbatim}
%%    \renewcommand{\theenumi}{\Roman{enumi}}
%%    \renewcommand{\labelenumi}{\theenumi/}
%% \end{verbatim}
%% The possible styles of numbering are given in Section~6.3 of Lamport's
%% book (see \Qref[question]{\TeX{}-related books}{Q-books}).  Both
%% \csx{theenumi} and \csx{labelenumi} must be changed, since
%% \csx{theenumi} is used in cross-references to the list.
%%
%% For lower level \environment{enumerate}s, replace |enumi| by |enumii|,
%% |enumiii| or |enumiv|, according to the level.  If your label is much
%% larger than the default, you should also change \csx{leftmargini},
%% \csx{leftmarginii}, \emph{etc}.
\begin{ctanrefs}
\item[enumerate.sty]Distributed as part of \CTANref{2etools}
\item[enumitem.sty]\CTANref{enumitem}
\item[memoir.cls]\CTANref{memoir}
\item[paralist.sty]\CTANref{paralist}
\end{ctanrefs}

\Question[Q-complist]{How to adjust list spacing}

\Qref*{Lamport's book}{Q-books} lists various
parameters for the layout of list (things like \csx{topsep},
\csx{itemsep} and \csx{parsep}), but fails to mention that they're set
automatically within the list itself.  This happens because each list
executes a command \csx{@list}\texttt{\meta{depth}} (the depth
appearing as a lower-case roman numeral); what's more, the top-level
\csx{@listi} is usually reset when the font size is changed.  As a
result, it's rather tricky for 
the user to control list spacing.  Of course, the real answer is to use
a document class designed with more modest list spacing, but we all
know such things are hard to come by.  The \Class{memoir} class wasn't
designed for more compact lists \emph{per se}, but offers the user
control over the list spacing.

There are packages that provide some control of list spacing, but they
seldom address the separation from surrounding text (defined by
\csx{topsep}).  The \Package{expdlist} package, among its many controls
of the appearance of \environment{description} lists, offers a
compaction parameter (see the documentation); the \Package{mdwlist}
package offers a \csx{makecompactlist} command for users' own list
definitions, and uses it to define compact lists
\environment{itemize*}, \environment{enumerate*} and
\environment{description*}.  In fact, you can write lists such as
these commands define pretty straightforwardly~--- for example:
\begin{quote}
\begin{verbatim}
\newenvironment{itemize*}%
  {\begin{itemize}%
    \setlength{\itemsep}{0pt}%
    \setlength{\parskip}{0pt}}%
  {\end{itemize}}
\end{verbatim}
\end{quote}
The \Package{paralist} package provides several approaches to list
compaction:
\begin{itemize}
\item its \environment{asparaenum} environment formats each item as if
  it were a paragraph introduced by the enumeration label (which saves
  space if the item texts are long);
\item its \environment{compactenum} environment is the same sort of
  compact list as is provided in \Package{expdlist} and
  \Package{mdwlist}; and
\item its \environment{inparaenum} environment produces a list ``in
  the paragraph'', i.e., with no line break between items, which is a
  great space-saver if the list item texts are short.
\end{itemize}
The package will manipulate its \environment{enumerate} environment
labels just like the \Qref*{\Package{enumerate} package}{Q-enumerate}
does.

\Package{Paralist} also provides \environment{itemize} equivalents
(\environment{asparaitem}, etc.), and \environment{description}
equivalents (\environment{asparadesc}, etc.).

The \Package{multenum} package offers a more regular form of
\Package{paralist}'s \environment{inparaenum}; you define a notional
grid on which list entries are to appear, and list items will always
appear at positions on that grid.  The effect is somewhat like that of
the `tab' keys on traditional typewriters; the package was designed
for example sheets, or lists of answers in the appendices of a book.

The ultimate in compaction (of every sort) is offered by the
\Package{savetrees} package; compaction of lists is included.  The
package's prime purpose is to save space at every touch and turn:
don't use it if you're under any design constraint whatever!

The \Package{expdlist}, \Package{mdwlist} and \Package{paralist}
packages all offer other facilities for list configuration: you should
probably not try the ``do-it-yourself'' approaches outlined below if
you need one of the packages for some other list configuration
purpose.

For ultimate flexibility (including manipulation of \csx{topsep}), the
\Package{enumitem} package permits adjustment of list parameters using
a ``\emph{key}\latexhtml{\ensuremath{=}}{=}\meta{value}'' format.
For example, one might write
\begin{quote}
\begin{verbatim}
\usepackage{enumitem}
...
\begin{enumerate}[topsep=0pt, partopsep=0pt]
\item ...
\item ...
\end{enumerate}
\end{verbatim}
\end{quote}
to suppress all spacing above and below your list, or
\begin{quote}
\begin{verbatim}
\usepackage{enumitem}
...
\begin{enumerate}[itemsep=2pt,parsep=2pt]
\item ...
\item ...
\end{enumerate}
\end{verbatim}
\end{quote}
to set spacing between items and between paragraphs within items.
\Package{Enumitem} also permits manipulation of the label format in a
more ``basic'' (and therefore more flexible) manner than the % ! line break
\Qref*{\Package{enumerate} package}{Q-enumerate} does.
\begin{ctanrefs}
\item[enumerate.sty]Distributed as part of \CTANref{2etools}
\item[enumitem.sty]\CTANref{enumitem}
\item[expdlist.sty]\CTANref{expdlist}
\item[memoir.cls]\CTANref{memoir}
\item[mdwlist.sty]Distributed as part of \CTANref{mdwtools}
\item[multenum.sty]\CTANref{multenum}
\item[paralist.sty]\CTANref{paralist}
\item[savetrees.sty]\CTANref{savetrees}
\end{ctanrefs}

\Question[Q-interruptlist]{Interrupting enumerated lists}

It's often convenient to have commentary text, `outside' the list,
between successive entries of a list.  In the case of
\environment{itemize} lists this is no problem, since there's never
anything to distinguish successive items, while in the case of
\environment{description} lists, the item labels are under the user's
control so there's no automatic issue of continuity.

For \environment{enumerate} lists, the labels are generated
automatically, and are context-sensitive, so the context (in this
case, the state of the enumeration counter) needs to be preserved.

The belt-and-braces approach is to remember the state of the
enumeration in your own counter variable, and then restore it when
restarting enumerate:
\begin{quote}
\begin{verbatim}
\newcounter{saveenum}
 ...
\begin{enumerate}
  ...
  \setcounter{saveenum}{\value{enumi}}
\end{enumerate}
<Commentary text>
\begin{enumerate}
  \setcounter{enumi}{\value{saveenum}}
  ...
\end{enumerate}
\end{verbatim}
\end{quote}

This is reasonable, in small doses\dots{} Problems (apart from sheer
verbosity) are getting the level right (``should I use counter
\texttt{enumi}, \texttt{enumii}, \dots{}'') and remembering not to
nest the interruptions (i.e., not to have a separate list, that is
itself interrupted) in the ``commentary text'').

The \Package{mdwlist} package defines commands \csx{suspend} and
\csx{resume} that simplify the process:
\begin{quote}
\begin{verbatim}
\begin{enumerate}
  ...
\suspend{enumerate}
<Commentary text>
\resume{enumerate}
  ...
\end{enumerate}
\end{verbatim}
\end{quote}
The package allows an optional name (as in
\cmdinvoke{suspend}[id]{enumerate}) to allow you to identify a
particular suspension, and hence provide a handle for manipulating
nested suspensions.

If you're suspending a \Qref*{fancy-enumeration list}{Q-enumerate},
you need to 
re-supply the optional ``item label layout'' parameters required by
the \Package{enumerate} package when resuming the list, whether by the
belt-and-braces approach, or by the \Package{mdwlist}
\cmdinvoke{resume}{enumerate} technique.  The task is a little tedious
in the \Package{mdwlist} case, since the optional argument has to be
encapsulated, whole, inside an optional argument to \csx{resume},
which requires use of extra braces:
\begin{quote}
\begin{verbatim}
\begin{enumerate}[\textbf{Item} i]
  ...
\suspend{enumerate}
<comment>
\resume{enumerate}[{[\textbf{Item} i]}]
...
\end{enumerate}
\end{verbatim}
\end{quote}
\nothtml{\noindent}The \Package{enumitem} package, in its most recent
release, will also allow you to resume lists:
\begin{quote}
\begin{verbatim}
\begin{enumerate}
...
\end{enumerate}
<comment>
\begin{enumerate}[resume]
...
\end{enumerate}
\end{verbatim}
\end{quote}
which feels just as ``natural'' as the \Package{mdwtools} facility,
and has the advantage of playing well with the other excellent
facilities of \Package{enumitem}.

\Package{Enumitem} also allows multi-level suspension and resumption
of lists:
\begin{quote}
\begin{verbatim}
\begin{enumerate}
\item outer item 1
\end{enumerate}
<comment>
\begin{enumerate}[resume]
\item outer item 2
% nested enumerate
\begin{enumerate}
\item inner item 1
\end{enumerate}
<nested comment>
% resume nested enumerate
\begin{enumerate}[resume]
\item inner item 2
\end{enumerate}
\item outer item 3
% end outer enumerate
\end{enumerate}
\end{verbatim}
However, the comment interpolated in the nested enumeration appears as
if it were a second paragraph to ``outer item 2'', which is hardly
satisfactory.
\end{quote}
\begin{ctanrefs}
\item[enumerate.sty]Distributed as part of \CTANref{2etools}
\item[enumitem.sty]\CTANref{enumitem}
\item[mdwlist.sty]Distributed as part of \CTANref{mdwtools}
\end{ctanrefs}

\subsection{Tables, figures and diagrams}

\Question[Q-destable]{The design of tables}

In recent years, several authors have argued that the examples, set
out by Lamport in his \Qref*{\LaTeX{} manual}{Q-books}, have cramped
authors' style and have led to extremely poor table design.  It is in
fact difficult even to work out what many of the examples in Lamport's
book ``mean''.

The criticism focuses on the excessive use of rules (both horizontal
and vertical) and on the poor vertical spacing that Lamport's macros
offer.

The problem of vertical spacing is plain for all to see, and is
addressed in several packages~--- see % beware line breaks
``\Qref*[question]{spacing of lines in tables}{Q-struttab}''.

The argument about rules is presented in the excellent essay that
prefaces the documentation of Simon Fear's \Package{booktabs} package,
which (of course) implements Fear's scheme for `comfortable' rules.
(The same rule commands are implemented in the \Class{memoir} class.)

Lamport's \LaTeX{} was also inflexibly wrong in ``insisting'' that
captions should come at the bottom of a table.  Since a table may
extend over several pages, traditional typography places the caption
at the top of a table float.  The \csx{caption} command will get its
position wrong (by \texttt{10pt}) if you simply write:
\begin{quote}
\begin{verbatim}
\begin{table}
  \caption{Example table}
  \begin{tabular}{...}
    ...
  \end{tabular}
\end{table}
\end{verbatim}
\end{quote}
The \Package{topcapt} package solves this problem:
\begin{quote}
\begin{verbatim}
\usepackage{topcaption}
...
\begin{table}
  \topcaption{Example table}
  \begin{tabular}{...}
    ...
  \end{tabular}
\end{table}
\end{verbatim}
\end{quote}
The \Class{KOMA-script} classes provide a similar command
\csx{captionabove}; they also have a class option
\pkgoption{tablecaptionabove} which arranges that \csx{caption}
\emph{means} \csx{captionabove}, in table environments.  The
\Package{caption} (from the release of 23 January, 2004) may be loaded
with an option that has the same effect:
\begin{quote}
\begin{verbatim}
\usepackage[tableposition=top]{caption}
\end{verbatim}
\end{quote}

Doing the job yourself is pretty easy: \Package{topcapt} switches the
values of the \LaTeXe{} parameters \csx{abovecaptionskip} (default
value \texttt{10pt}) and \csx{belowcaptionskip} (default value
\texttt{0pt}), so:
\begin{quote}
\begin{verbatim}
\begin{table}
  \setlength{\abovecaptionskip}{0pt}
  \setlength{\belowcaptionskip}{10pt}
  \caption{Example table}
  \begin{tabular}{...}
    ...
  \end{tabular}
\end{table}
\end{verbatim}
\end{quote}
does the job.  (The package itself is very slightly more elaborate\dots{})
\begin{ctanrefs}
\item[booktabs.sty]\CTANref{booktabs}
\item[\nothtml{\rmfamily}KOMA script bundle]\CTANref{koma-script}
\item[memoir.cls]\CTANref{memoir}
\item[topcapt.sty]\CTANref{topcapt}
\end{ctanrefs}

\Question[Q-fixwidtab]{Fixed-width tables}

There are two basic techniques for making fixed-width tables in
\LaTeX{}: you can make the gaps between the columns stretch, or you
can stretch particular cells in the table.

Basic \LaTeX{} can make the gaps stretch: the \environment{tabular*}
environment takes an extra argument (before the \texttt{clpr} layout one)
which takes a length specification: you can say things like ``\texttt{15cm}''
or ``\csx{columnwidth}'' here.  You must also have an \csx{extracolsep}
command in the \texttt{clpr} layout argument, inside an \texttt{@\{\}}
directive.  So, for example, one might have
\begin{wideversion}
\begin{verbatim}
\begin{tabular*}{\columnwidth}{@{\extracolsep{\fill}}lllr}
\end{verbatim}
\end{wideversion}
\begin{narrowversion}
\begin{verbatim}
\begin{tabular*}{\columnwidth}%
                {@{\extracolsep{\fill}}lllr}
\end{verbatim}
\end{narrowversion}
The \csx{extracolsep} applies to all inter-column gaps to its right as
well; if you don't want all gaps stretched, add
\cmdinvoke{extracolsep}{0pt} to cancel the original.

The \Package{tabularx} package defines an extra \texttt{clpr} column
specification, \texttt{X}; \texttt{X} columns behave as \texttt{p}
columns which expand to fill the space available.  If there's more
than one \texttt{X} column in a table, the spare space is distributed
between them.

The \Package{tabulary} package (by the same author) provides a way of
``balancing'' the space taken by the columns of a table.  The package
defines column specifications \texttt{C}, \texttt{L}, \texttt{R} and
\texttt{J}, giving, respectively, centred, left, right and
fully-justified versions of space-sharing columns.  The package
examines how long each column would be ``naturally'' (i.e., on a piece of paper of unlimited width), and
allocates space to each column accordingly.  There are ``sanity
checks'' so that really large entries don't cause everything else to
collapse into nothingness (there's a ``maximum width'' that any column
can exert), and so that tiny entries can't get smaller than a
specified minimum.  Of course, all this work means that the package
has to typeset each row several times, so things that leave
``side-effects'' (for example, a counter used to produce a row-number
somewhere) are inevitably unreliable, and should not even be tried.

The \Package{ltxtable} package combines the features of the
\Package{longtable} and \Package{tabularx} packages.  It's important
to read the documentation, since usage is distinctly odd; the
distribution contains no more than a file \File{ltxtable.tex}, which you
should process using \LaTeX{}.  Processing will give you a \File{.sty}
file as well as the \File{.dvi} or \File{.pdf} output containing the
documentation.
\begin{ctanrefs}
\item[ltxtable.sty]Distributed as part of \CTANref{carlisle}
\item[tabularx.sty]Distributed as part of \CTANref{2etools}
\item[tabulary.sty]\CTANref{tabulary}
\end{ctanrefs}

\Question[Q-varwidcol]{Variable-width columns in tables}

This is a slightly different take on the problem addressed in
``\Qref*[question]{fixed-width tables}{Q-fixwidtab}''~--- here we have
a column whose size we can't absolutely predict when we design the
document.

While the basic techniques (the \Package{tabularx}, \Package{tabulary}
and \Package{ltxtable} packages) are the same for this problem as for the
fixed-width \emph{table} problem, there's one extra tool that we can
call to our aid, which may be preferable in some situations.

Suppose we have data in one column which we read from an external
source, and the source itself isn't entirely predictable.  The data in
the column may end up pretty narrow in every row of the table, or it
may be wide enough that the table would run over the edge of the page;
however, we don't want to make the column as wide as possible ``just
in case'', by defining a fixed size for the table.  We would like the
column to be as small as possible, but have the possibility to spread
to a maximum width and (if even that width is exceeded) turn into a
\texttt{p}-style column.

The \Package{varwidth} package, discussed in % ! line break
``\Qref*[question]{automatic sizing of minipages}{Q-varwidth}'', provides
a solution.  If you load it together with the \LaTeX{} ``required''
\Package{array} package, i.e.:
\begin{quote}
\begin{verbatim}
\usepackage{array}
\usepackage{varwidth}
\end{verbatim}
\end{quote}
\Package{varwidth} defines a new column-type ``\texttt{V}'', which you
can use as follows:
\begin{quote}
\begin{verbatim}
\begin{tabular}{l V{3.5cm} r}
  foo & blah      & bar \\
  foo & blah blah & bar \\
\end{tabular}
\end{verbatim}
\end{quote}
when the second column ends up less than 3.5cm wide;
or you can use it as follows:
\begin{quote}
\begin{verbatim}
\begin{tabular}{l V{3.5cm} r}
  foo & blah      & bar \\
  foo & blah blah & bar \\
  foo & blah blah blah blah blah blah
                  & bar \\
\end{tabular}
\end{verbatim}
\end{quote}
where the second column will end up noticeably wider, and will wrap to
a second line in the third row.
\begin{ctanrefs}
\item[array.sty]Distributed as part of \CTANref{2etools}
\item[varwidth.sty]\CTANref{varwidth}
\end{ctanrefs}

\Question[Q-struttab]{Spacing lines in tables}

\AllTeX{} mechanisms for maintaining the space between lines (the
``\emph{leading}'') rely on \TeX{}'s paragraph builder, which compares
the shape of consecutive lines and adjusts the space between them.

These mechanisms can't work in exactly the same way when \AllTeX{} is
building a table, because the paragraph builder doesn't get to see the
lines themselves.  As a result, tables sometimes typeset with lines
uncomfortably close together (or occasionally ridiculously far apart).

Traditional (moving metal type) typographers would adjust the spacing
between lines of a table by use of a ``\emph{strut}'' (a metal
spacer).  A \TeX{} user can do exactly the same thing: most macro
packages define a \csx{strut} command, that defines a space appropriate
to the current size of the text; placing a \csx{strut} command at the
end of a troublesome row is the simplest solution to the problem~---
if it works.  Other solutions below are \LaTeX{}-specific, but some
may be simply translated to \plaintex{} commands.

If your table exhibits a systematic problem (i.e., every row is wrong
by the same amount) use \csx{extrarowheight}, which is defined by the
\Package{array} package:
\begin{quote}
\begin{verbatim}
\usepackage{array}% in the preamble
...
\setlength{\extrarowheight}{length}
\begin{tabular}{....}
\end{verbatim}
\end{quote}

To correct a single row whose maladjustment isn't corrected by a
\csx{strut} command, you can define your own, using
\cmdinvoke{rule}{0pt}{length}~--- which is a near approximation to the
command that goes inside a \csx{strut}.  The \Package{bigstrut} package
defines a strut command that you can use for this purpose:
\csx{bigstrut} on its own opens up both above and below the current
line; \cmdinvoke{bigstrut}[t] opens up above the line,
\cmdinvoke{bigstrut}[b] opens up below the line.

General solutions are available, however.  The \Package{tabls} package
automatically generates an appropriately-sized strut at the end of
each row.  Its disadvantages are that it's really rather slow in
operation (since it gets in the way of everything within tables) and
its (lack of) compatibility with other packages.

The \Package{cellspace} package does a (possibly inferior) job by
defining a new table/array column type ``S'', which you apply to each
column specification.  So, for example,
\begin{quote}
\begin{verbatim}
\cmdinvoke{begin}{tabular}{l l l p{3cm}}
\end{verbatim}
\end{quote}
would become
\begin{quote}
\begin{verbatim}
\cmdinvoke{begin}{tabular}{Sl Sl Sl Sp{3cm}}
\end{verbatim}
\end{quote}
and so on.  This technique shows
promise of not interfering so much with other packages, but this
author has heard of no reports from the field.

The \Package{booktabs} package comes with a thought-provoking essay
about how tables should be designed.  Since table row-spacing problems
most often appear in collisions with rules, the author's thesis,
that \LaTeX{} users tend too often to rule their tables, is
interesting.  The package provides rule commands to support the
author's scheme, but deals with inter-row spacing too.  The most
recent release of \Package{booktabs} sports compatibility with
packages such as \Package{longtable}.

Documentation of both \Package{bigstrut} and \Package{tabls} may be
found as comments in the package files themselves.
\begin{ctanrefs}
\item[array.sty]Distributed as part of \CTANref{2etools}
\item[bigstrut.sty]Distributed as part of \CTANref{multirow}
\item[booktabs.sty]\CTANref{booktabs}
\item[cellspace.sty]\CTANref{cellspace}
\item[tabls.sty]\CTANref{tabls}
\end{ctanrefs}

\Question[Q-longtab]{Tables longer than a single page}

Tables are, by default, set entirely in boxes of their own: as a
result, they won't split over a page boundary.  Sadly, the world keeps
turning up tables longer than a single page that we need to typeset.

For simple tables (whose shape is highly regular), the simplest
solution may well be to use the \environment{tabbing} environment,
which is slightly tedious to set up, but which doesn't force the whole alignment
onto a single page.

The \Package{longtable} package builds the whole table (in chunks), in
a first pass, and then uses information it has written to the \extension{aux}
file during later passes to get the setting ``right'' (the package
ordinarily manages to set tables in just two passes).  Since the
package has overview of the whole table at the time it's doing
``final'' setting, the table is set ``uniformly'' over its entire
length, with columns matching on consecutive pages.
\Package{longtable} has a reputation for failing to interwork with
other packages, but it does work with \Package{colortbl}, and its
author has provided the \Package{ltxtable} package to provide (most
of) the facilities of \Package{tabularx} (see
% beware line wrap
\Qref[question]{fixed-width tables}{Q-fixwidtab}) for long tables:
beware of its rather curious usage constraints~--- each long table
should be in a file of its own, and included by
\cmdinvoke*{LTXtable}{width}{file}.  Since \Package{longtable}'s
multiple-page tables can't possibly live inside floats, the package
provides for captions within the \environment{longtable} environment
itself.

A seeming alternative to \Package{ltxtable} is \Package{ltablex}; but
it is outdated and not fully functional.  Its worst problem is its
strictly limited memory capacity (\Package{longtable} is not so
limited, at the cost of much complication in its code);
\Package{ltablex} can only deal with relatively small tables, it doesn't seem
likely that support is available; but its user interface is much
simpler than \Package{ltxtable}, so if its restrictions aren't a
problem for you, it may be worth a try.

The \Package{supertabular} package starts and stops a
\environment{tabular} environment for each page of the table.  As a
result, each `page worth' of the table is compiled independently, and
the widths of corresponding columns may differ on successive pages.
However, if the correspondence doesn't matter, or if your columns are
fixed-width, \Package{supertabular} has the great advantage of doing
its job in a single run.

Both \Package{longtable} and \Package{supertabular} allow definition
of head- and footlines for the table; \Package{longtable} allows
distinction of the first and last head and foot.

The \Package{xtab} package fixes some infelicities of
\Package{supertabular}, and also provides a ``last head'' facility
(though this, of course, destroys \Package{supertabular}'s advantage
of operating in a single run).

The \Package{stabular} package provides a simple-to-use ``extension to
\environment{tabular}'' that allows it to typeset tables that run over
the end of a page; it also has usability extensions, but doesn't have
the head- and footline capabilities of the major packages.

Documentation of \Package{ltablex} is to be found in the package file.
\begin{ctanrefs}
\item[longtable.sty]Distributed as part of \CTANref{2etools}
\item[ltablex.sty]\CTANref{ltablex}
\item[ltxtable.sty]Generate by running \CTANref{ltxtable}
\item[stabular.sty]Distributed as part of \CTANref{sttools}
\item[supertabular.sty]\CTANref{supertabular}
\item[xtab.sty]\CTANref{xtab}
\end{ctanrefs}

\Question[Q-tabcellalign]{How to alter the alignment of tabular cells}

One often needs to alter the alignment of a tabular \texttt{p} (`paragraph')
cell, but problems at the end of a table row are common.  With a
\texttt{p} cell that looks like:
\begin{quote}
\begin{verbatim}
... & \centering blah ... \\
\end{verbatim}
\end{quote}
one is liable to encounter errors that complain about a ``misplaced
\csx{noalign}'' or ``\Qref*{extra alignment tab}{Q-altabcr}'', or the like.
The problem is that the command \texttt{\bsbs } means different things in
different circumstances: the \environment{tabular} environment
switches the meaning to a value for use in the table, and
\csx{centering}, \csx{raggedright} and \csx{raggedleft} all change the
meaning to something incompatible.  Note that the problem only
arises in the last cell of a row: since each cell is set into a box,
its settings are lost at the \texttt{\&} (or \texttt{\bsbs }) that
terminates it. 


The technique using \csx{PBS} was developed in the days of \LaTeXo{}
because the actual value of \texttt{\bsbs } that the \environment{tabular}
environment uses was only available as an internal command.  Nowadays,
the value is a public command, and you can in principle use it
explicitly:
\begin{quote}
\begin{verbatim}
... & \centering blah ... \tabularnewline
\end{verbatim}
\end{quote}

The \Package{array} package provides a command \csx{arraybackslash}
which restores \texttt{\bsbs } to its correct (within table) meaning;
the command may be used in \Package{array}'s ``field format'' preamble
specifications:
\begin{quote}
\begin{narrowversion}
\begin{verbatim}
\begin{tabular}{...%
        >{\centering\arraybackslash}%
                             p{50mm}}
...
\end{verbatim}
\end{narrowversion}
\begin{wideversion}
\begin{verbatim}
\begin{tabular}{... >{\centering\arraybackslash}p{50mm}}
...
\end{verbatim}
\end{wideversion}
\end{quote}

The \csx{tabularnewline} and \csx{arraybackslash} commands are
(somewhat) modern additions to \LaTeX{} and the \Package{array}
package, respectively.  If neither is available, the user may try the
(old) solution which preserves the meaning of \texttt{\bsbs }:
\begin{quote}
\begin{verbatim}
\newcommand\PBS[1]{\let\temp=\\%
  #1%
  \let\\=\temp
}
\end{verbatim}
\end{quote}
which one uses within a table as:
\begin{quote}
\begin{verbatim}
... & \PBS\centering blah ... \\
\end{verbatim}
\end{quote}
or in the preamble as:
\begin{quote}
\begin{verbatim}
\begin{tabular}{...>{\PBS\centering}p{5cm}}
\end{verbatim}
\end{quote}
\begin{ctanrefs}
\item[array.sty]Distributed as part of \CTANref{2etools}
\end{ctanrefs}
\nothtml{\vskip 0pt plus 4ex}

\Question[Q-rulethk]{The thickness of rules in \LaTeX{} tables}

The rules in a \LaTeX{} table are by default \texttt{0.4pt} thick;
this is in fact a default built in at the lowest level, and applies to
all rules (including those separating blocks of running text).

Sometimes, however, we look at a table and find we want the rules to
stand out~--- perhaps to separate the text from the rest of the body
text, or to make the sections of the table stand out from one another.
However, a quick review of any \LaTeX{} manual will reveal no
technique for making any one rule stand out, and a little
experimentation shows that it is indeed pretty difficult to prevent
a change ``bleeding'' out to affect other rules in the same table.

If you look at what we have to say on the % ! line break
\Qref*{design of tables}{Q-destable}, elsewhere
among these \acro{FAQ}s, and you may sense that the design of \LaTeX{}
simply skipped the issues surrounding table design: \emph{that's}
presumably why there's no facilities to help you.

Specifically, the length \csx{arrayrulewidth} affects the thickness of
the rules (both horizontal and vertical) within both
\environment{tabular} and \environment{array} environments.  If you
change from the default (see above) only as far as
\begin{quote}
\begin{verbatim}
\setlength{\arrayrulewidth}{1pt}
\end{verbatim}
\end{quote}
the change is remarkably striking.  However, really quite subtle user
level programming proves incapable of changing just \emph{one} rule:
it's necessary to delve into the (rather tricky) code of \csx{hline}
and \csx{cline} themselves.

Fortunately, this job has already been done for the community: the
\Package{booktabs} package defines three different classes of rule
(\csx{toprule}, \csx{midrule} and \csx{bottomrule}), and the package
documentation offers hints on how to use them.  You are
\emph{strongly} advised to read the documentation pretty carefully.

The \Class{memoir} class includes the \Package{booktabs} package, and
repeats the documentation in its compendious manual.

Note that none of the above mentions the issue of the weight of
vertical rules (except in passing).  For the reasons, see the
documentation of the \Package{booktabs} package (again); vertical
rules in tables are in any case even more trickily coded than are
horizontal rules, and if their lack of configurability makes them
still less attractive, so much the better for the design of your
document.
\begin{ctanrefs}
\item[booktabs.sty]\CTANref{booktabs}
\item[memoir.cls]\CTANref{memoir}
\end{ctanrefs}

\Question[Q-textflow]{Flowing text around figures in \LaTeX{}}

There are several \LaTeX{} packages that purport to do this, but they
all have their limitations because the \TeX{} machine isn't really
designed to solve this sort of problem.  Piet van Oostrum has
conducted a survey of the available packages; he recommends:
\begin{description}
\item[\texttt{floatflt}] \Package{floatflt} is an improved version
  (for \LaTeXe{}) of \File{floatfig.sty}, and its syntax is:
\begin{wideversion}
\begin{quote}
\begin{verbatim}
\begin{floatingfigure}[options]{width of figure}
  figure contents
\end{floatingfigure}
\end{verbatim}
\end{quote}
\end{wideversion}
\begin{narrowversion}
  \begin{quote}
    \cmdinvoke{begin}{floatingfigure}[\emph{options}]{\emph{figure width}}\\
    \mbox{}\qquad\emph{figure contents}\\
    \cmdinvoke{end}{floatingfigure}
  \end{quote}
\end{narrowversion}
There is a (more or less similar) \environment{floatingtable}
environment.

The tables or figures can be set left or right, or alternating on
even/odd pages in a double-sided document.

The package works with the \texttt{multicol} package, but doesn't work well
in the neighbourhood of list environments (unless you change your
\LaTeX{} document).
\item[\texttt{wrapfig}] \Package{wrapfig} has syntax:
\begin{wideversion}
\begin{quote}
\begin{verbatim}
\begin{wrapfigure}[height of figure in lines]{l,r,...}[overhang]{width}
  figure, caption, etc.
\end{wrapfigure}
\end{verbatim}
\end{quote}
\end{wideversion}
\begin{narrowversion}
  \begin{quote}
  \cmdinvoke{begin}{wrapfigure}\texttt{\%}\\
  \mbox{}%
  \qquad\qquad\texttt{[\emph{figure height in lines}]\%}\\
  \mbox{}%
  \qquad\qquad\texttt{\{l,r,\emph{etc}\}[\emph{overhang}]\{\emph{width}\}}\\
  \mbox{}\qquad\emph{figure, caption, etc.}\\
  \cmdinvoke{end}{wrapfigure}
  \end{quote}
\end{narrowversion}    
    The syntax of the \environment{wraptable} environment is similar.
    
    Height can be omitted, in which case it will be calculated by the
    package; the package will use the greater of the specified and the
    actual width.  The \texttt{\{l,r,\emph{etc}.\}} parameter may
    also be specified as \texttt{i}\emph{(nside)} or
    \texttt{o}\emph{(utside)} for two-sided documents, and uppercase
    may be used to indicate that the picture should float.  The
    overhang allows the figure to be
    moved into the margin.  The figure or table will entered into the
    list of figures or tables if you use the \csx{caption} command.
    
    The environments do not work within list environments that end
    before the figure or table has finished, but can be used in a
    parbox or minipage, and in twocolumn format.
  \item[\texttt{picins}] \Package{Picins} is part of a large bundle
    that allows inclusion of pictures (e.g., with shadow boxes,
    various \MSDOS{} formats, etc.).  The command for inserting a
    picture at the start of a paragraph is:
\begin{wideversion}
  \begin{quote}
    \csx{parpic}\texttt{(width,height)(x-off,y-off)[Options][Position]\{Picture\}}\\
    \emph{Paragraph text}
  \end{quote}
\end{wideversion}
\begin{narrowversion}
  \begin{quote}
    \cmdinvoke*{picins}(width,height)(x-off,y-off)\texttt{\%}\\
    \mbox{\qquad\qquad}\texttt{[\emph{options}][\emph{position}]\%}\\
    \mbox{\qquad\qquad}\texttt{\{\emph{Picture}\}}\\
    \emph{Paragraph text}
  \end{quote}
\end{narrowversion}  
  All parameters except the \emph{Picture} are optional.  The picture
  can be positioned left or right, boxed with a rectangle, oval,
  shadowbox, dashed box, and a caption can be given which will be
  included in the list of figures.

  Unfortunately (for those of us whose understanding of German is not
  good), the documentation is in German.  Piet van Oostrum has written
  a summary in English.
\end{description}
\begin{ctanrefs}
\item[floatflt.sty]\CTANref{floatflt}
\item[picins.sty]\CTANref{picins}
\item[picins \nothtml{\rmfamily}documentation summary]\CTANref{picins-summary}
\item[wrapfig.sty]\CTANref{wrapfig}
\end{ctanrefs}

\Question[Q-slashbox]{Diagonal separation in corner cells of tables}
\keywords{tabular}

You want to label both the top or bottom row and the left- or
rightmost column, somewhere at the corner of the table where the row
and column meet.  A simple way to achieve the result is to construct
the table with an arrangement of rules (and possibly \csx{multicolumn}
entries), to look like:
\begin{quote}
\begin{verbatim}
-----------------
x  y
   --------------
   1  2  3  4  5
-----------------
1
2
3
4
5
-----------------
\end{verbatim}
\end{quote}
However, this doesn't satisfy everyone: many want the labelling in a
single cell at the top left of the table.  It sounds a simple enough
requirement, yet it calls for some slightly tricky \LaTeX{} coding.
The \Package{slashbox} package does the job for you: it defines
commands \csx{slashbox} and \csx{backslashbox}, each taking the two
labels as arguments.  It draws a picture with the two labels on either
side of a slanting line; the command (and hence the picture) may be
placed in the corner cell, where the labelled row and column meet.

The package isn't the world's neatest: it uses \LaTeX{}
\environment{picture} mode to draw its line, and picture mode has many
tedious restrictions (and doesn't, in all honesty, produce
particularly good pictures).  Load slashbox with the \Package{pict2e}
package, and at least the picture quality will be improved.

Documentation of \Package{slashbox} is less than satisfactory: a
\LaTeX{} source file of rather startling starkness accompanies the
package file in the distribution.  It does, however, process to a
\acro{DVI} file that gives some idea of how the \csx{slashbox} may be
expected to look.  (The third example in the file shows the effect of
\environment{picture} mode's restrictions: the dividing line doesn't
go from corner to corner in the box: to correct this requires revision
of \Package{slashbox}~--- \Package{pict2e} alone doesn't help in this
regard.)
\begin{ctanrefs}
\item[slashbox.sty]\CTANref{slashbox}
\end{ctanrefs}

\Question[Q-wholerow]{How to change a whole row of a table}

Each cell of a table is set in a box, so that a change of font style
(or whatever) only lasts to the end of the cell.  If one has a
many-celled table, or a long one which needs lots of rows emphasising,
putting a font style change command in every cell will be impossibly
tedious.

With the \Package{array} package, you can define column modifiers
which will change the font style for a whole \emph{column}.  However,
with a bit of subtlety, one can make such modifiers affect rows rather
than columns.  So, we set things up by:
\begin{quote}
\begin{narrowversion}
\begin{verbatim}
\usepackage{array}
\newcolumntype{$}{>{%
  \global\let\currentrowstyle\relax}%
}
\newcolumntype{^}{>{\currentrowstyle}}
\newcommand{\rowstyle}[1]{%
  \gdef\currentrowstyle{#1}%
  #1\ignorespaces
}
\end{verbatim}
\end{narrowversion}
\begin{wideversion}
\begin{verbatim}
\usepackage{array}
\newcolumntype{$}{>{\global\let\currentrowstyle\relax}}
\newcolumntype{^}{>{\currentrowstyle}}
\newcommand{\rowstyle}[1]{\gdef\currentrowstyle{#1}%
  #1\ignorespaces
}
\end{verbatim}
\end{wideversion}
\end{quote}
Now, we put `\texttt{\$}' before the first column specifier; and we
put `\texttt{\textasciicircum}'
before the modifiers of subsequent ones.  We then use \csx{rowstyle} at
the start of each row we want to modify:
\begin{quote}
\begin{verbatim}
\begin{tabular}{|$l|^l|^l|}   \hline
  \rowstyle{\bfseries}
  Heading & Big and & Bold \\ \hline
  Meek & mild & entry      \\
  Meek & mild & entry      \\
  \rowstyle{\itshape}
  Strange & and & italic   \\
  Meek & mild & entry      \\ \hline
\end{tabular}
\end{verbatim}
\end{quote}
The \Package{array} package works with several other
\environment{tabular}-like environments from other packages (for
example \environment{longtable}), but unfortunately this trick won't
always work.
\begin{ctanrefs}
\item[array.sty]Distributed as part of \CTANref{2etools}
\end{ctanrefs}

\Question[Q-multirow]{Merging cells in a column of a table}

It's easy to come up with a table design that requires a cell that
spans several rows.  An example is something where the left-most
column labels the rest of the table; this can be done (in simple
cases) by using % beware line break
\Qref*{diagonal separation in corner cells}{Q-slashbox}, but that
technique rather strictly limits what can be used as the content of
the cell.

The \Package{multirow} package enables you to construct such multi-row
cells, in a very simple manner.  For the simplest possible use, one
might write:
\begin{quote}
\begin{verbatim}
\begin{tabular}{|c|c|}
\hline
\multirow{4}{*}{Common g text} 
      & Column g2a\\
      & Column g2b \\
      & Column g2c \\
      & Column g2d \\
\hline
\end{tabular}
\end{verbatim}
\end{quote}
and \Package{multirow} will position ``Common g text'' at the vertical
centre of the space defined by the other rows.  Note that the rows
that don't contain the ``multi-row'' specification must have empty
cells where the multi-row is going to appear.

The ``\texttt{*}'' may be replaced by a column width specification.  In this
case, the argument may contain forced line-breaks:
\begin{quote}
\begin{verbatim}
\begin{tabular}{|c|c|}
\hline
\multirow{4}{25mm}{Common\\g text} 
      & Column g2a\\
      & Column g2b \\
      & Column g2c \\
      & Column g2d \\
\hline
\end{tabular}
\end{verbatim}
\end{quote}
A similar effect (with the possibility of a little more
sophistication) may be achieved by putting a smaller table that lines
up the text into a \texttt{*}-declared \csx{multirow}.

The \csx{multirow} command may also used to write labels vertically
down one or other side of a table (with the help of the
\Package{graphics} or \Package{graphicx} package, which provide the
\csx{rotatebox} command):
\begin{quote}
\begin{verbatim}
\begin{tabular}{|l|l|}
\hline
\multirow{4}{*}{\rotatebox{90}{hi there}}
      & Column g2a\\
      & Column g2b \\
      & Column g2c \\
      & Column g2d \\
\hline
\end{tabular}
\end{verbatim}
\end{quote}
(which gives text going upwards; use angle \texttt{-90} for text going
downwards, of course).

To make a \csx{multicolumn} multi-row ``cell'' in a table, you have to
enclose a \csx{multirow} inside a \csx{multicolumn}~--- the other way
around does not work, so:
\begin{quote}
\begin{wideversion}
\begin{verbatim}
\begin{tabular}{|c|c|c|}\hline
\multicolumn{2}{|c|}{\multirow{2}{*}{combined cells}}
     &top right\\ \cline{3-3}
\multicolumn{2}{|c|}{}
     &middle right\\ \hline
bottom left
     &bottom center
     &bottom right\\ \hline
\end{tabular}
\end{verbatim}
\end{wideversion}
\begin{narrowversion}
\begin{verbatim}
\begin{tabular}{|c|c|c|}\hline
\multicolumn{2}{|c|}{\multirow{2}{*}%
                           {combined cells}}
     &top right\\ \cline{3-3}
\multicolumn{2}{|c|}{}
     &middle right\\ \hline
bottom left
     &bottom center
     &bottom right\\ \hline
\end{tabular}
\end{verbatim}
\end{narrowversion}
\end{quote}
\Package{Multirow} is set up to interact with the \Package{bigstrut}
package (which is also discussed in the answer to % beware line break
\Qref[question]{spacing lines in tables}{Q-struttab}).  You use an
optional argument to the \csx{multirow} command to say how many of the
rows in the multi-row have been opened up with \csx{bigstrut}.

The documentation of both \Package{multirow} and \Package{bigstrut} is
to be found, as comments, in the package files themselves.
\begin{ctanrefs}
\item[bigstrut.sty]Distributed as part of \CTANref{multirow}
\item[multirow.sty]\CTANref{multirow}
\end{ctanrefs}

\subsection{Floating tables, figures, etc.}

\Question[Q-floatpages]{Floats on their own on float pages}

It's sometimes necessary to force a float to live on a page by itself.
(It's sometimes even necessary for \emph{every} float to live on a
page by itself.)  When the float fails to `set', and waits for the end
of a chapter or of the document, the natural thing to do is to declare
the float as
\begin{quote}
  \cmdinvoke{begin}{figure}[p!]
\end{quote}
but the overriding \texttt{!} modifier has no effect on float page floats; so
you have to make the float satisfy the parameters.
\Qref[Question]{Moving tables and figures}{Q-floats} offers some
suggestions, but doesn't solve the one-float-per-page question.

The `obvious' solution, using the counter \texttt{totalnumber}
(``total number of floats per page'') doesn't work:
\texttt{totalnumber} only applies to floats on `text' pages (pages
containing text as well as one or more float).  So, to allow any
size float to take a whole page, set \csx{floatpagefraction} really
small, and to ensure that no more than one float occupies a page, make
the separation between floats really big:
\begin{quote}
\begin{verbatim}
\renewcommand\floatpagefraction{.001}
\makeatletter
\setlength\@fpsep{\textheight}
\makeatother
\end{verbatim}
\end{quote}

\Question[Q-vertspacefloat]{Extra vertical space in floats}

A common complaint is that extra vertical space has crept into
\environment{figure} or \environment{table} floating environments.
More common still are users who post code that introduces this extra
space, and \emph{haven't noticed the problem}!

The trouble arises from the fact that the \environment{center}
environment (and its siblings \environment{flushleft} and
\environment{flushright}) are actually based on \LaTeX{}'s
list-handling code; and lists always separate themselves from the
material around them.  Meanwhile, there are parameters provided to
adjust the spacing between floating environments and their
surroundings; so if we have:
\begin{quote}
\begin{verbatim}
\begin{figure}
 \begin{center}
   \includegraphics{...}
   \caption{...}
 \end{center}
\end{figure}
\end{verbatim}
\end{quote}
\nothtml{\noindent}or worse still:
\begin{quote}
\begin{verbatim}
\begin{figure}
 \begin{center}
   \includegraphics{...}
 \end{center}
 \caption{...}
\end{figure}
\end{verbatim}
\end{quote}
unwarranted vertical space is going to appear.

The solution is to let the float and the objects in it position
themselves, and to use ``generic'' layout commands rather than their
list-based encapsulations.
\begin{quote}
\begin{verbatim}
\begin{figure}
  \centering
  \includegraphics{...}
  \caption{...}
\end{figure}
\end{verbatim}
\end{quote}
(which even involves less typing).

This alternative code will work with any \LaTeX{} package.  It will
not work with obsolete (pre-\LaTeXe{}) packages such as
\Package{psfig} or \Package{epsf}~--- see % beware line break
\Qref[question]{graphics inclusion}{Q-impgraph} for discussion of the
genesis of \csx{includegraphics}.

\Question[Q-2colfloat]{Placing two-column floats at bottom of page}

You specified placement `\texttt{[htbp]}' for your full-width figure or
table, but they always get placed at the top of the page\dots{}  Well,
it \emph{is} what the documentation says: \LaTeX{}, unadorned, only
allows full-width floats at the top of a page, or occupying (part of) a
float page.

The \Package{stfloats} package ameliorates the situation somewhat, and
makes \LaTeX{} honour `[b]' placement as well; the
\Package{dblfloatfix} package combines a tidied version of the changes
made in \Package{stfloats} with the
\begin{narrowversion} % non-hyper
  float ordering corrections defined in \Package{fixltx2e}
  (\Qref{}{Q-2colfltorder}).
\end{narrowversion}
\begin{wideversion} % hyper
  \Qref{float ordering corrections}{Q-2colfltorder} defined in
  \Package{fixltx2e}.
\end{wideversion}

A particular problem with \Package{stfloats} and \Package{dblfloatfix}
is that the float will appear, at its earliest, on the page after it
is specified.  This has two undesirable side-effects: first, there may
be no bottom float on the first page of a document, and second, float
numbers may become ``entangled'' (particularly if you're using
\Package{dblfloatfix} that ensures that the early-specified bottom
float is set \emph{before} any single column floats).

(The \acro{FAQ} team doesn't know of any package that will make
\LaTeX{} honour `[h]' placement of double-column floats, but the
\Package{midfloat} package can be pressed into service to provide
something approximating the effect it would have.)
\begin{ctanrefs}
\item[dblfloatfix.sty]\CTANref{dblfloatfix}
\item[stfloats.sty, midfloat.sty]Distributed as part of
  \CTANref{sttools}
\end{ctanrefs}

\Question[Q-mcfloat]{Floats in multicolumn setting}

If you use
\begin{quote}
\begin{verbatim}
\begin{figure}
  ...
\end{figure}
\end{verbatim}
\end{quote}
in a \environment{multicols} environment, the figure won't appear.  If
instead you use
\begin{quote}
\begin{verbatim}
\begin{figure*}
  ...
\end{figure*}
\end{verbatim}
\end{quote}
the figure will stretch right across the page (just the same as a
\environment{figure*} in standard \LaTeX{}'s \pkgoption{twocolumn} option).

It's possible to have single-column figures and tables with captions,
using the `\texttt{[H]}' placement option introduced by the \Package{float}
package but you might have to fiddle with the placement because they
won't `float', and exhibit other strange behaviours (such as silently
running off the end of the column at the end of the
\environment{multicols} environment).
\begin{ctanrefs}
\item[float.sty]\CTANref{float}
\item[multicol.sty]Distributed as part of \CTANref{2etools}
\end{ctanrefs}

\Question[Q-dpfloat]{Facing floats on 2-page spread}

If a pair of floats are to be forced to form a 2-page spread (in a
book, or whatever), the first must lie on the left side of the spread,
on an even-numbered page.  The \Package{dpfloat} package provides for
this: the construction to use is:
\begin{quote}
\begin{verbatim}
\begin{figure}[p]
  \begin{leftfullpage}
    <left side figure>
  \end{leftfullpage}
\end{figure}
\begin{figure}[p]
  \begin{fullpage}
    <right side figure>
  \end{fullpage}
\end{figure}
\end{verbatim}
\end{quote}
The construction has no effect unless the standard class option
\pkgoption{twoside} is in effect.

Full documentation of the package (such as it is) is to be found in
\File{README.dpfloat}
\begin{ctanrefs}
\item[dpfloat.sty]\CTANref{dpfloat}
\end{ctanrefs}

\Question[Q-vertposfp]{Vertical layout of float pages}

By default, \LaTeX{} vertically centres the floats on a float page;
the present author is not alone in not liking this arrangement.
Unfortunately, the control of the positioning is ``buried'' in
\LaTeX{}-internal commands, so some care is needed to change the
layout.

Float pages use three \LaTeX{} lengths (i.e., \TeX{} skips) to define
their layout:
\begin{description}
\item[\nothtml{\normalfont}\csx{@fptop}] defines the distance from the
  top of the page to the top of the first float,
\item[\nothtml{\normalfont}\csx{@fpsep}] defines the separation between
  floats, and
\item[\nothtml{\normalfont}\csx{@fpbot}] defines the distance from the
  bottom of the last float on the page to the bottom of the page.
\end{description}
(In fact, the output routine places a skip of \csx{@fpsep} above each float, so
the \csx{@fptop} skip is always followed by a correction for that.)


The \LaTeX{} defaults are:
\begin{quote}
  \csx{@fptop} = \texttt{0pt + 1fil}\\
  \csx{@fpsep} = \texttt{8pt + 2fil}\\
  \csx{@fpbot} = \texttt{0pt + 1fil}\\
\end{quote}
so that the gaps expand to fill the space not occupied by floats, but
if there is more than one float on the page, the gap between them will
expand to twice the space at top and bottom.

Those who understand this stuff will be able to play elaborate games,
but the commonest requirement, that the floats start at the top of the
page, is a simple thing to do:
\begin{quote}
\begin{verbatim}
\makeatletter
\setlength{\@fptop}{0pt}
\makeatother
\end{verbatim}
\end{quote}
Surprisingly, you may find this setting leaves your floats too high on
the page.  One can justify a value of \texttt{5pt} (in place of
\texttt{0pt})~--- it's roughly the difference between \csx{topskip}
and the height of normal (\texttt{10pt}) text.

Note that this is a ``global'' setting (best established in a class
file, or at worst in the document preamble); making the change for a
single float page is likely (at the least) to be rather tricky.

\Question[Q-figurehere]{Figure (or table) \emph{exactly} where I want it}

This is of course a contradiction: \environment{figure} and
\environment{table} are \emph{designed} to float, and will always have
the potential to appear away from where you asked for them.  Therefore
you have to find a means of getting the caption and other effects
without allowing the figure or table to float.

The most straightforward way is to use the \Package{float} package; it
gives you a \texttt{[H]} float placement option that prevents
floating:
\begin{quote}
\begin{verbatim}
\begin{figure}[H]
  \centering
  \includegraphics{foo}
  \caption{caption text}
  \label{fig:nonfloat}
\end{figure}
\end{verbatim}
\end{quote}
As the example shows, these \texttt{[H]} figures (and correspondingly,
tables) offer all you need to cross-reference as well as typeset.

However, you don't actually \emph{have} to use \Package{float} since
it is, in fact, doing rather little for you.  You can place your
figure as you please, with a sequence like
\begin{quote}
\begin{verbatim}
\begin{center}
  \includegraphics{foo}
  \captionof{figure}{caption text}
  \label{fig:nonfloat}
\end{center}
\end{verbatim}
\end{quote}
which relies on the \csx{captionof} command to place a caption in
ordinary running text.  That command may be had from the extremely
simple-minded package \Package{capt-of} or from the highly
sophisticated \Package{caption} package.

Using either method, you have to deal with the possibility of the
figure or table being too large for the page.  (Floating objects will
float away in this circumstance; ``doing it by hand'', like this, you
take upon yourself the responsibility for avoiding % ! line break
`\textit{Overfull \csx{vbox}}' errors.

A further problem is the possibility that such ``fixed floats'' will
overtake ``real floats'', so that the numbers of figures will be out
of order: figure 6 could be on page 12, while figure 5 had floated to
page 13.  It's best, therefore, either to stay with floating figures
throughout a document, or to use fixed figures throughout.
\begin{ctanrefs}
\item[capt-of.sty]\CTANref{capt-of}
\item[caption.sty]\CTANref{caption}
\item[float.sty]\CTANref{float}
\end{ctanrefs}

\subsection{Footnotes}

\Question[Q-footintab]{Footnotes in tables}

The standard \LaTeX{} \csx{footnote} command doesn't work in tables; the table
traps the footnotes and they can't escape to the bottom of the page.

If your table is floating, your best bet is (unfortunately) to put the
table in a \environment{minipage} environment and to put the notes
underneath the table, or to use Donald Arseneau's package
\Package{threeparttable} (which implements ``table notes'' proper).

The \Package{ctable} package extends the model of
\Package{threeparttable}, and also uses the ideas of the
\Package{booktabs} package.  The \csx{ctable} command does the complete
job of setting the table, placing the caption, and defining the
notes.  The ``table'' may consist of diagrams, and a parameter in
\csx{ctable}'s optional argument makes the float that is created a
``figure'' rather than a ``table''.

Otherwise, if your table is not floating (it's just a
`\texttt{tabular}' in the middle of some text), there are several
things you can do to fix the problem.
\begin{itemize}
\item Use \csx{footnotemark} to position the little marker
  appropriately, and then put in \csx{footnotetext} commands to fill in
  the text once you've closed the \environment{tabular} environment.
  This is described in Lamport's book, but it gets messy if there's
  more than one footnote.
\item Stick the table in a \texttt{minipage} anyway.  This provides all the
  ugliness of footnotes in a minipage with no extra effort.
\item Use \Package{threeparttable} anyway; the package is intended for
  floating tables, and the result might look odd if the table is not
  floating, but it will be reasonable.
\item Use \Package{tabularx} or \Package{longtable} from the \LaTeX{}
  tools distribution; they're noticeably less efficient than the
  standard \environment{tabular} environment, but they do allow
  footnotes.
\item Use \Package{footnote}, which provides an
  \environment{savenotes} which collects all footnotes and emits them
  at the end of the environment; thus if you put your
  \environment{tabular} environment inside the environment, the
  footnotes will appear as needed.  Alternatively, you may use
  \cmdinvoke{makesavenoteenv}{tabular} in the preamble of your
  document, and tables will all behave as if they were inside a
  \environment{savenotes} environment.
\item Use \Package{mdwtab} from the same bundle; it will handle
  footnotes properly, and has other facilities to increase the beauty
  of your tables.  Unfortunately, it may be incompatible with other
  table-related packages, though not those in the standard `tools'
  bundle.
\end{itemize}

The documentation of \Package{threeparttable} appears in the package
file itself; that of \Package{ctable} is distributed as a \acro{PDF}
file (for convenience's sake).
\begin{ctanrefs}
\item[ctable.sty]\CTANref{ctable}
\item[footnote.sty]Distributed as part of \CTANref{mdwtools}
\item[longtable.sty]Distributed as part of \CTANref{2etools}
\item[mdwtab.sty]Distributed as part of \CTANref{mdwtools}
\item[threeparttable.sty]\CTANref{threeparttable}
\item[tabularx.sty]Distributed as part of \CTANref{2etools}
\end{ctanrefs}

\Question[Q-ftnsect]{Footnotes in \LaTeX{} section headings}

The \csx{footnote} command is fragile, so that simply placing the
command in \csx{section}'s arguments isn't satisfactory.  Using
\csx{protect}\csx{footnote} isn't a good idea either: the arguments of a
section command are used in the table of contents and (more
dangerously) potentially also in page headers.  While footnotes will
work in the table of contents, it's generally not thought a ``good
thing'' to have them there; in the page header, footnotes will simply
fail.  Whatever the desirability of the matter, there's no mechanism
to suppress the footnote in the page header while allowing it in the table
of contents, so the footnote may only appear in the section heading itself.

To suppress the footnote in headings and table of contents:
\begin{itemize}
\item Take advantage of the fact that the mandatory argument doesn't
  `move' if the optional argument is present:

  \cmdinvoke{section}[title]%
    \texttt{\{title}\cmdinvoke{footnote}{title ftnt}\texttt{\}}
\item Use the \Package{footmisc} package, with package option
  \texttt{stable}~--- this modifies footnotes so that they softly and
  silently vanish away if used in a moving argument.  With this, you
  simply need:
\begin{verbatim}
% in the document preamble
\usepackage[stable]{footmisc}
...
% in the body of the document
\section{title\footnote{title ftnt}}
\end{verbatim}
\end{itemize}
\begin{ctanrefs}
\item[footmisc.sty]\CTANref{footmisc}
\end{ctanrefs}

\Question[Q-ftncapt]{Footnotes in captions}

Footnotes in captions are especially tricky: they present problems of
their own, on top of the problems one experiences with
\Qref*{footnotes in section titles}{Q-ftnsect} and with % ! line break
\Qref*{footnotes in tables}{Q-footintab}.  Fortunately, the
requirement for footnotes in captions is extremely rare: if you are
experiencing problems, it is worth reviewing what you are trying to
say by placing this footnote.  Note that the \Package{threeparttable}
scheme (see, again, % ! line break
\Qref[question]{footnotes in tables}{Q-footintab}) also applies
to notes in captions, and may very well be preferable to whatever you
were thinking of.

If you \emph{are} going to proceed:
\begin{itemize}
\item use an optional argument in your \csx{caption} command, that
  doesn't have the footnote in it; this prevents the footnote
  appearing in the ``List of \dots{}'', and
\item put your whole float in a \environment{minipage} so as to keep
  the footnotes with the float.
\end{itemize}
so we have:
\begin{quote}
\begin{verbatim}
\begin{figure}
  \begin{minipage}{\textwidth}
    ...
    \caption[Caption for LOF]%
      {Real caption\footnote{blah}}
  \end{minipage}
\end{figure}
\end{verbatim}
\end{quote}
However, \emph{as well as} all of the above, one \emph{also} has to
deal with the tendency of the \csx{caption} command to produce the
footnote's text twice.  For this last problem, there is no tidy
solution this author is aware of.

If you're suffering the problem, a well-constructed \csx{caption}
command in a \environment{minipage} environment within a float (as
in the example above) can produce \emph{two} copies of the footnote
body ``blah''. (In fact, the effect only occurs with captions that are
long enough to require two lines to be typeset, and so wouldn't appear
with such a short caption.)

The documentation of the \Package{ccaption} package describes a really
rather awful work-around.
\begin{ctanrefs}
\item[ccaption.sty]\CTANref{ccaption}
\item[threeparttable.sty]\CTANref{threeparttable}
\end{ctanrefs}

\Question[Q-repfootnote]{Footnotes whose texts are identical}

If the \emph{same} footnote turns up at several places within a
document, it's often inappropriate to repeat the footnote in its
entirety over and over again.  We can avoid repetition by
semi-automatic means, or by simply labelling footnotes that we know
we're going to repeat and then referencing the result.  There is no
completely automatic solution (that detects and suppresses repeats)
available.

If you know you only have one footnote, which you want to repeat, the
solution is simple: merely use the optional argument of
\csx{footnotemark} to signify the repeats:
\begin{quote}
\begin{verbatim}
...\footnote{Repeating note}
...
...\footnotemark[1]
\end{verbatim}
\end{quote}
\dots{}\@ which is very easy, since we know there will only ever be a
footnote number 1.  A similar technique can be used once the footnotes
are stable, reusing the number that \LaTeX{} has allocated.  This can
be tiresome, though, as any change of typesetting could change the
relationships of footnote and repeat: labelling is inevitably better.

Simple hand-labelling of footnotes is possible, using a counter dedicated
to the job:
\begin{quote}
\begin{verbatim}
\newcounter{fnnumber}
...
...\footnote{Text to repeat}%
\setcounter{fnnumber}{\thefootnote}%
...
...\footnotemark[\thefnnumber]
\end{verbatim}
\end{quote}
but this is somewhat tedious.  \LaTeX{}'s labelling mechanism can be
summoned to our aid, but there are ugly error messages before the
\csx{ref} is resolved on a second run through \LaTeX{}:
\begin{quote}
\begin{verbatim}
...\footnote{Text to repeat\label{fn:repeat}}
...
...\footnotemark[\ref{fn:repeat}]
\end{verbatim}
\end{quote}
Alternatively, one may use the \csx{footref} command, which has the
advantage of working even when the footnote mark isn't expressed as a
number.  The command is defined in the \Package{footmisc} package and
in the \Class{memoir} class (at least); \csx{footref} reduces the above
example to:
\begin{quote}
\begin{verbatim}
...\footnote{Text to repeat\label{fn:repeat}}
...
...\footref{fn:repeat}
\end{verbatim}
\end{quote}
This is the cleanest simple way of doing the job.  Note that the
\csx{label} command \emph{must} be inside the argument of
\csx{footnote}.

The \Package{fixfoot} package takes away some of the pain of the
matter: you declare footnotes you're going to reuse, typically in the
preamble of your document, using a \csx{DeclareFixedFoot} command, and
then use the command you've `declared' in the body of the document:
\begin{quote}
\begin{verbatim}
\DeclareFixedFootnote{\rep}{Text to repeat}
...
...\rep{}
...\rep{}
\end{verbatim}
\end{quote}
The package ensures that the repeated text appears at most once per
page: it will usually take more than one run of \LaTeX{} to get rid of
the repeats.
\begin{ctanrefs}
\item[fixfoot.sty]\CTANref{fixfoot}
\item[footmisc.sty]\CTANref{footmisc}
\item[memoir.cls]\CTANref{memoir}
\end{ctanrefs}

\Question[Q-multfoot]{More than one sequence of footnotes}

The need for more than one series of footnotes is common in critical
editions (and other literary criticism), but occasionally arises in
other areas.

Of course, the canonical critical edition package, \Package{edmac},
offers the facility, as does its \LaTeX{} port, the \Package{ledmac}
package.

Multiple ranges of footnotes are offered to \LaTeX{} users by the
\Package{manyfoot} package.  The package provides a fair array of
presentation options, as well.  Another critical edition
\Package{ednotes} package is built upon a basis that includes
\Package{manyfoot}, as its mechanism for multiple sets of footnotes.

The \Package{bigfoot} package also uses \Package{manyfoot} as part of
its highly sophisticated structure of footnote facilities, which was
also designed to support typesetting critical editions.
\begin{ctanrefs}
\item[bigfoot]\CTANref{bigfoot}
\item[edmac]\CTANref{edmac}
\item[ednotes]\CTANref{ednotes}
\item[ledmac]\CTANref{ledmac}
\item[manyfoot.sty]Distributed as part of the \CTANref{ncctools}
  bundle
\end{ctanrefs}

\Question[Q-footnpp]{Footnotes numbered ``per page''}

The obvious solution is to make the footnote number reset whenever the
page number is stepped, using the % ! line break
\Qref*{\LaTeX{} internal mechanism}{Q-addtoreset}.  Sadly, the place
in the document where the page number is stepped is unpredictable, not
(``tidily'') at the end of the printed page; so the link only ever
works by luck.

As a result, resetting footnotes is inevitably a complicated process,
using labels of some sort.  It's nevertheless important, given the
common requirement for footnotes marked by symbols (with painfully
small symbol sets).  There are three packages that manage it, one way
or another.

The \Package{perpage} package provides a general mechanism for
resetting counters per page, so can obviously be used for this task.
The interface is pretty simple: \cmdinvoke{MakePerPage}{footnote} will
do the job.  If you want to restart the counter at something other
than~1 (for example to avoid something in the \LaTeX{} footnote symbol
list), you can use: \cmdinvoke{MakePerPage}[2]{footnote}.  It's a
first-rate package, small and efficient

The \Package{footmisc} package provides a variety of means of
controlling footnote appearance, among them a package option
\pkgoption{perpage} that adjusts the numbering per page; if you're
doing something else odd about footnotes, it means you may only need
the one package to achieve your ends.

The \Package{footnpag} package also does per-page footnotes (and
nothing else).  With the competition from \Package{perpage}, it's
probably not particularly useful any more.  (Documentation is
\File{footnpag-user.pdf} in the distribution.)
\begin{ctanrefs}
\item[footmisc.sty]\CTANref{footmisc}
\item[footnpag.sty]\CTANref{footnpag}
\item[perpage.sty]Distributed as part \CTANref{bigfoot}
\end{ctanrefs}

\Question[Q-run-fn-nos]{Not resetting footnote numbers per chapter}

Some classes (for example, \Class{book} and \Class{report}) set up a
different set of footnotes per chapter, by resetting the footnote
number at the start of the chapter.  This is essentially the same
action as that of % ! line break
\Qref*{equation, figure and table numbers}{Q-running-nos},
except that footnote numbers don't get ``decorated'' with the chapter
number, as happens with those other numbers.

The solution is the same: use the \Package{chngcntr} package; since the
numbers aren't ``decorated'' you can use the \csx{counterwithout*}
variant; the code:
\begin{quote}
\begin{verbatim}
\counterwithout*{footnote}{chapter}
\end{verbatim}
\end{quote}
is all you need
\begin{ctanrefs}
\item[chngcntr.sty]\CTANref{chngcntr}
\end{ctanrefs}

\subsection{Document management}

\Question[Q-filename]{What's the name of this file}

One might want this so as to automatically generate a page header or
footer recording what file is being processed.  It's not easy\dots{}

\TeX{} retains what it considers the name of the \emph{job}, only, in
the primitive \csx{jobname}; this is the name of the file first
handed to \TeX{}, stripped of its directory name and of any extension
(such as \extension{tex}).  If no file was passed (i.e., you're using
\TeX{} interactively), \csx{jobname} has the value \texttt{texput}
(the name that's given to \extension{log} files in this case).

This is fine, for the case of a small document, held in a single file;
most significant documents will be held in a bunch of files, and
\TeX{} makes no attempt to keep track of files input to the
\emph{job}.  So the user has to keep track, himself~--- the only way
is to patch the input commands and cause them to retain details of the
file name.  This is particularly difficult in the case of \plaintex{},
since the syntax of the \csx{input} command is so peculiar.

In the case of \LaTeX{}, the input commands have pretty regular
syntax, and the simplest \Qref*{patching techniques}{Q-patch} can be
used on them.

If you're not inputting things from a file that's already been input,
the job is almost trivial:
\begin{quote}
\begin{verbatim}
\def\ThisFile{\jobname}
\let\OldInput\input
\renewcommand{\input}[1]{%
  \renewcommand{\ThisFile}{#1}%
  \OldInput{#1}%
}
\end{verbatim}
\end{quote}
With that, the macro \csx{ThisFile} always contains the last thing
input: it starts pointing at the base file of your document
(\csx{jobname}), and thereafter changes every time you use
\cmdinvoke*{input}{file}.

Most ordinary users will quickly become irritated with the simplicity
of of the \csx{ThisFile} mechanism above.  The following code is more
cunning: it maintains details of the files you've `come through' to
get to where you are, and it restores \csx{ThisFile} to what the
previous file was before returning.
\begin{quote}
\begin{verbatim}
\def\ThisFile{\jobname}
\newcounter{FileStack}
\let\OrigInput\input
\renewcommand{\input}[1]{%
  \stackinput{#1}{\OrigInput}%
}
\newcommand{\stackinput}[2]{%
  \stepcounter{FileStack}%
  \expandafter\let
    \csname NameStack\theFileStack\endcsname
    \ThisFile
  \def\ThisFile{#1}%
  #2{#1}%
  \expandafter\let\expandafter
    \ThisFile
    \csname NameStack\theFileStack\endcsname
  \addtocounter{FileStack}{-1}%
}
\end{verbatim}
\end{quote}
To do the same for \csx{include}, we need the simple addition:
\begin{quote}
\begin{verbatim}
\let\OrigInclude\include
\renewcommand{\include}[1]{%
  \stackinput{#1}{\OrigInclude}%
}
\end{verbatim}
\end{quote}
Both examples of patching \csx{input} assume you always use
\LaTeX{} syntax, i.e., always use braces around the argument.

The \Package{FiNK} (``File Name Keeper'') package provides a
regular means of keeping track of the current file name (with its
extension), in a macro \csx{finkfile}.  If you need the unadorned file
name (without its `\extension{tex}'), use the commands:
\begin{quote}
\begin{verbatim}
\def\striptexext#1.tex{#1}
...
\edef\ThisFile{\expandafter\stripext\finkfile}
\end{verbatim}
\end{quote}
The \Package{FiNK} bundle includes a \File{fink.el} that provides
support under \ProgName{emacs} with \acro{AUC}-\TeX{}.
\begin{ctanrefs}
\item[fink.sty]\CTANref{fink}
\end{ctanrefs}

\Question[Q-filesused]{All the files used by this document}

When you're sharing a document with someone else (perhaps as part of a
co-development cycle) it's as well to arrange that both correspondents
have the same set of auxiliary files, as well as the document in
question.  Your correspondent obviously needs the same set of files
(if you use the \Package{url} package, she has to have \Package{url}
too, for example).  But suppose you have a bug-free version of the
\Package{shinynew} package but her copy is still the unstable
original; until you both realise what is happening, such a situation
can be very confusing.

The simplest solution is the \LaTeX{} \csx{listfiles} command.  This
places a list of the files used and their version numbers in the log
file.  If you extract that list and transmit it with your file, it can
be used as a check-list in case that problems arise.

Note that \csx{listfiles} only registers things that are input by the
``standard'' \LaTeX{} mechanisms (\csx{documentclass}, \csx{usepackage},
\csx{input}, \csx{include}, \csx{includegraphics} and so on).  But if you
use \TeX{} primitive syntax, as in
\begin{verbatim}
  \input mymacros
\end{verbatim}
\File{mymacros.tex} \emph{won't} be listed by \csx{listfiles}, since
you've bypassed the mechanism that records its use.

The \Package{snapshot} package helps the owner of a \LaTeX{} document
obtain a list of the external dependencies of the document, in a form
that can be embedded at the top of the document.  The intended use of
the package is the creation of archival copies of documents, but it
has application in document exchange situations too.

The \ProgName{bundledoc} system uses the \Package{snapshot} to produce an
archive (e.g., \extension{tar.gz} or \extension{zip}) of the files needed by your
document; it comes with configuration files for use with
\ProgName{teTeX} and \ProgName{\miktex{}}.  It's plainly useful when
you're sending the first copy of a document.
\begin{ctanrefs}
\item[bundledoc]\CTANref{bundledoc}
\item[snapshot.sty]\CTANref{snapshot}
\end{ctanrefs}

\Question[Q-changebars]{Marking changed parts of your document}

One often needs clear indications of how a document has changed, but
the commonest technique, ``change bars'' (also known as ``revision
bars''), requires surprisingly much
trickery of the programmer (the problem being that \TeX{} `proper'
doesn't provide the programmer with any information about the
``current position'' from which a putative start- or end-point of a
bar might be calculated; \PDFTeX{} \emph{does} provide the
information, but we're not aware yet of any programmer taking
advantage of the fact to write a \PDFTeX{}-based changebar package).

The simplest package that offers change bars is Peter Schmitt's
\Package{backgrnd.tex}; this was written as a \plaintex{} application
that patches the output routine, but it appears to work at least on
simple \LaTeX{} documents.  Wise \LaTeX{} users will be alerted by the
information that \Package{backgrnd} patches their output routine, and
will watch its behaviour very carefully (patching the \LaTeX{} output
routine is not something to undertake lightly\dots{}).

The longest-established \LaTeX{}-specific solution is the
\Package{changebar} package,
which uses \csx{special} commands supplied by the driver you're using.
You need therefore to tell the package which driver to generate
\csx{special}s for (in the same way that you need to tell the
\Package{graphics} package); the list of available drivers is pretty
wide, but does not include \ProgName{dvipdfm}.  The package comes with
a shell script \ProgName{chbar.sh} (for use on Unix machines) that
will compare two documents and generate a third which is marked-up
with \Package{changebar} macros to highlight changes.  The
shareware \ProgName{WinEDT} editor has a macro that will generate
\Package{changebar} (or other) macros to show differences from an
earlier version of your file, stored in an
\ProgName{RCS}-controlled repository~--- see
\URL{http://www.winedt.org/Macros/LaTeX/RCSdiff.php}

The \Package{vertbars} package uses the techniques of the
\Package{lineno} package (which it loads, so the \Package{lineno}
itself must be installed); it's thus the smallest of the packages for
change bar marking, since it leaves all the trickery to another
package.  \Package{Vertbars} defines a \environment{vertbar}
environment to create changebars.

The \Package{framed} package is
another that provides bars as a side-effect of other desirable
functionality: its \environment{leftbar} environment is simply a
stripped-down frame (note, though, that the environment makes a
separate paragraph of its contents, so it is best used when the
convention is to mark a whole changed paragraph.

Finally, the \Class{memoir} class allows marginal editorial comments,
which you can obviously use to delimit areas of changed text.

An even more comprehensive way to keep track of changes is employed by
some word-processors~--- to produce a document that embodies both
``old'' and ``new'' versions.

To this end, the package \Package{changes} allows the user to manually
markup changes of text, such as additions, deletions, or replacements.
Changed text is shown in a different colour; deleted text is crossed
out.  The package allows you to define additional authors and their
associated colour; it also allows you to define a markup for authors
or annotations.  The documentation (very clearly) demonstrates how the
various functions work.

The \ProgName{Perl} script \ProgName{latexdiff} may also be used to
generate such markup for \LaTeX{} documents; you feed it the two
documents, and it produces a new \LaTeX{} document in which the
changes are very visible.  An example of the output is embedded in the
documentation,
\begin{narrowversion} % actually non-hyperversion
  \File{latexdiff-man.pdf}, in the distribution.
\end{narrowversion}
\begin{wideversion} % actually hyperversion
  \href{http://www.tex.ac.uk/tex-archive/support/latexdiff/latexdiff-man.pdf}{latexdiff-man.pdf}
  (part of the distribution).
\end{wideversion}
A rudimentary revision facility is provided by another
\ProgName{Perl} script, \ProgName{latexrevise}, which accepts or rejects
all changes.  Manual editing of the difference file can be used to 
accept or reject selected changes only.
\begin{ctanrefs}
\item[backgrnd.tex]\CTANref{backgrnd}
\item[changebar.sty]\CTANref{changebar}
\item[changes.sty]\CTANref{changes}
\item[framed.sty]\CTANref{framed}
\item[latexdiff, latexrevise]\CTANref{latexdiff}
\item[lineno.sty]\CTANref{lineno}
\item[memoir.cls]\CTANref{memoir}
\item[vertbars.sty]\CTANref{vertbars}
\end{ctanrefs}

\Question[Q-conditional]{Conditional compilation and ``comments''}

While \LaTeX{} (or any other \TeX{}-derived package) isn't really like a
compiler, people regularly want to do compiler-like things using it.
Common requirements are conditional `compilation' and `block
comments', and several \LaTeX{}-specific means to this end are available.

The simple \cmdinvoke{newcommand}{\csx{gobble}}[1]\texttt{\{}\texttt{\}} 
and \csx{iffalse}\texttt{ ... }\csx{fi} aren't really satisfactory (as
a general solution) for comments, since the matter being skipped is
nevertheless scanned by \TeX{}, not always as you would expect.  The
scanning imposes restrictions on what you're allowed to skip; this may
not be a problem in \emph{today's} job, but could return to bite you
tomorrow.  For an example of surprises that may come to bite you,
consider the following example (derived from real user experience):
\begin{quote}
\begin{verbatim}
\iffalse % ignoring this bit
consider what happens if we
use \verb+\iftrue+ -- a surprise
\fi
\end{verbatim}
\end{quote}
The \csx{iftrue} is spotted by \TeX{} as it scans, ignoring the
\csx{verb} command; so the \csx{iffalse} isn't terminated by the
following \csx{fi}.  Also, \csx{gobble} is pretty inefficient at
consuming anything non-trivial, since all the matter to be skipped is
copied to the argument stack before being ignored.

If your requirement is for a document from which whole chapters (or
the like) are missing, consider the \LaTeX{}
\csx{include}/\csx{includeonly} system.  If you `\csx{include}' your
files (rather than \csx{input} them~--- see % line wrap!
\Qref[question]{What's going on in my \csx{include} commands?}{Q-include}),
\LaTeX{} writes macro traces of what's going on at the end of each
chapter to the \extension{aux} file; by using \csx{includeonly}, you can give
\LaTeX{} an exhaustive list of the files that are needed.  Files that
don't get \csx{include}d are skipped entirely, but the document
processing continues as if they \emph{were} there, and page, footnote,
and other numbers are not disturbed.  Note that you can choose which
sections you want included interactively, using the
\Package{askinclude} package.

The inverse can be done using the \Package{excludeonly} package: this
allows you to exclude a (list of) \csx{include}d files from your
document, by means of an \csx{excludeonly} command.

If you want to select particular pages of your document, use Heiko
Oberdiek's \Package{pagesel} or the \Package{selectp} packages.  You
can do something similar with an existing \acro{PDF} document (which
you may have compiled using \ProgName{pdflatex} in the first place),
using the \Package{pdfpages} package.  The job is then done with a
document looking like:
\begin{quote}
\begin{verbatim}
\documentclass{article}
\usepackage[final]{pdfpages}
\begin{document}
\includepdf[pages=30-40]{yoursource.pdf}
\end{document}
\end{verbatim}
\end{quote}
(To include all of the document, you write
\begin{quote}
\begin{verbatim}
\includepdf[pages=-]{yoursource.pdf}
\end{verbatim}
\end{quote}
omitting the start and end pages in the optional argument.)

If you want flexible facilities for including or excluding small
portions of a file, consider the \Package{comment}, \Package{version} or
\Package{optional} packages.

The \Package{comment} package allows you to declare areas of a document to be
included or excluded; you make these declarations in the preamble of
your file.  The command \cmdinvoke*{includecomment}{version-name}
declares an environment \environment{version-name} whose content will
be included in your document, while
\cmdinvoke*{excludecomment}{version-name} defines an environment whose
content will be excluded from the document.  The package uses a method
for exclusion that is pretty robust, and can cope with ill-formed
bunches of text (e.g., with unbalanced braces or \csx{if} commands).

These FAQs employ the \Package{comment} package to alter layout
between the printed (two-column) version and the \acro{PDF} version
for browsing; there are \environment{narrowversion} and
\environment{wideversion} for the two versions of the file.

\Package{version} offers similar facilities to \File{comment.sty}
(i.e., \csx{includeversion} and \csx{excludeversion} commands);
it's far ``lighter weight'', but is less robust (and in particular,
cannot deal with very large areas of text being included/excluded).

A significant development of \Package{version}, confusingly called
\Package{versions} (i.e., merely a plural of the old package name).
\Package{Versions} adds a command
\cmdinvoke*{markversion}{version-name} which defines an environment
that prints the included text, with a clear printed mark around it.

\Package{optional} defines a command \csx{opt}; its first argument is
an `inclusion flag', and its second is text to be included or
excluded.  Text to be included or excluded must be well-formed
(nothing mismatched), and should not be too big~--- if a large body of
text is needed, \csx{input} should be used in the argument.
The documentation (in the package file itself) tells you
how to declare which sections are to be included: this can be done in
the document preamble, but the documentation also suggests ways in
which it can be done on the command line that invokes \LaTeX{}, or
interactively.

And, not least of this style of conditional compilation,
\Package{verbatim} (which should be available in any distribution)
defines a \environment{comment} environment, which enables the
dedicated user of the source text editor to suppress bits of a
\LaTeX{} source file.  The \Class{memoir} class offers the same
environment.

An interesting variation is the \Package{xcomment} package.  This
defines an environment whose body is all excluded, apart from
environments named in its argument.  So, for example:
\begin{quote}
\begin{verbatim}
\begin{xcomment}{figure,table}
  This text is not included
  \begin{figure}
    This figure is included
  \end{figure}
  This is not included, either
  \begin{table}
    This table also included
  \end{table}
  ...
\end{xcomment}
\end{verbatim}
\end{quote}

A further valuable twist is offered by the \Package{extract} package.
This allows you to produce a ``partial copy'' of an existing document:
the package was developed to permit production of a ``book of
examples'' from a set of lecture notes.  The package documentation
shows the following usage:
\begin{quote}
\begin{verbatim}
\usepackage[
  active,
  generate=foobar,
  extract-env={figure,table},
  extract-cmd={chapter,section}
]{extract}
\end{verbatim}
\end{quote}
which will cause the package to produce a file \File{foobar.tex}
containing all the \environment{figure} and \environment{table}
environments, and the \csx{chapter} and \csx{section} commands, from
the document being processed.  The new file \File{foobar.tex} is
generated in the course of an otherwise ordinary run on the `master'
document.  The package provides a good number of other facilities,
including (numeric or labelled) ranges of environments to extract, and
an \environment{extract} environment which you can use to create complete
ready-to-run \LaTeX{} documents with stuff you've extracted.
\begin{ctanrefs}
\item[askinclude.sty]Distributed with Heiko Oberdiek's packages~---
  \CTANref{oberdiek}
\item[comment.sty]\CTANref{comment}
\item[excludeonly.sty]\CTANref{excludeonly}
\item[extract.sty]\CTANref{extract}
\item[memoir.cls]\CTANref{memoir}
\item[optional.sty]\CTANref{optional}
\item[pagesel.sty]Distributed with Heiko Oberdiek's packages~---
  \CTANref{oberdiek}
\item[pdfpages.sty]\CTANref{pdfpages}
\item[selectp.sty]\CTANref{selectp}
\item[verbatim.sty]Distributed as part of \CTANref{2etools}
\item[version.sty]\CTANref{version}
\item[versions.sty]\CTANref{versions}
\item[xcomment.sty]Distributed as part of \CTANref{seminar}
\end{ctanrefs}

\Question[Q-docotherdir]{Bits of document from other directories}

A common way of constructing a large document is to break it into a
set of files (for example, one per chapter) and to keep everything
related to each of these subsidiary files in a subdirectory.

Unfortunately, \TeX{} doesn't have a changeable ``current directory'',
so that all files you refer to have to be specified relative to the
same directory as the main file.  Most people find this
counter-intuitive.

It may be appropriate to use the ``path extension'' technique
% beware line break
\Qref[of question]{used in temporary installations}{Q-tempinst} to deal with
this problem.  However, if there several files with the same name in
your document, such as \File{chapter1/fig1.eps} and
\File{chapter2/fig1.eps}, you're not giving \TeX{} any hint as to
which you're referring to when in the main chapter file you say
\cmdinvoke{input}{sect1}; while this is readily soluble in the case of
human-prepared files (just don't name them all the same),
automatically produced files have a way of having repetitious names,
and changing \emph{them} is a procedure prone to error.

The \Package{import} package comes to your help here: it defines an
\csx{import} command that accepts a full path name and the name of a
file in that directory, and arranges things to ``work properly''.
So, for example, if \File{/home/friend/results.tex} contains
\begin{quote}
\begin{verbatim}
Graph: \includegraphics{picture}
\input{explanation}
\end{verbatim}
\end{quote}
then \cmdinvoke{import}{/home/friend/}{results} will include both
graph and explanation as one might hope.  A \csx{subimport} command
does the same sort of thing for a subdirectory (a relative path rather
than an absolute one), and there are corresponding \csx{includefrom}
and \csx{subincludefrom} commands.

The \Package{chapterfolder} package provides commands to deal with its
(fixed) model of file inclusion in a document.  It provides commands
\csx{cfpart}, \csx{cfchapter}, \csx{cfsection} and \csx{cfsubsection},
each of which takes directory and file arguments, e.g.:
\begin{quote}
\begin{verbatim}
\cfpart[pt 1]{Part One}{part1}{part}
\end{verbatim}
\end{quote}
which command will issue a `normal' command % ! line break
\cmdinvoke{part}[pt 1]{Part One} and then input the file
\File{part1/part.tex}, remembering that \File{part1/} is now the
``current folder''.  There are also commands of the form
\csx{cfpartstar} (which corresponds to a \csx{part*} command).

Once you're ``in'' a \Package{chapterfolder}-included document, you
may use \csx{cfinput} to input something relative to the ``current
folder'', or you may use \csx{input}, using \csx{cfcurrentfolder} to
provide a path to the file.  (There are also
\csx{cfcurrentfolderfigure} for a \path{figure/} subdirectory and
\csx{cfcurrentfolderlistings} for a \path{listings/} subdirectory.)

Documentation of \Package{chapterfolder} is in French, but the
\File{README} in the directory is in English.
\begin{ctanrefs}
\item[chapterfolder.sty]\CTANref{chapterfolder}
\item[import.sty]\CTANref{import}
\end{ctanrefs}

\Question[Q-RCS]{Version control using \acro{RCS}, \acro{CVS} or the like}

If you use \acro{RCS}, \acro{CVS}, \ProgName{Subversion},
\ProgName{Bazaar} or \ProgName{Git} to maintain
your \AllTeX{} documents under version control, you may need some
mechanism for including the version details in your document, in such
a way that they can be typeset (that is, rather than just hiding them
inside a comment).

The most complete solution for \acro{RCS} and \acro{CVS} is to use the
(\LaTeX{}) package \Package{rcs}, which allows you to parse and
display the contents of \acro{RCS} keyword fields in an extremely
flexible way.  The package \Package{rcsinfo} is simpler, but does most
of what you want, and some people prefer it; it is explicitly
compatible with \ProgName{LaTeX2HTML}.

If, however, you need a solution which works without using external
packages, or which will work in \plaintex{}, then you can use the
following minimal solution:
\begin{quote}
\begin{wideversion}
\begin{verbatim}
\def\RCS$#1: #2 ${\expandafter\def\csname RCS#1\endcsname{#2}}
\RCS$Revision: 1.548 $ % or any RCS keyword
\RCS$Date: 2008/06/20 13:37:44 $
...
\date{Revision \RCSRevision, \RCSDate}
\end{verbatim}
\end{wideversion}
\begin{narrowversion}
\begin{verbatim}
\def\RCS$#1: #2 ${\expandafter
  \def\csname RCS#1\endcsname{#2}%
}
\RCS$Revision: 1.548 $ % or any RCS keyword
\RCS$Date: 2008/06/20 13:37:44 $
...
\date{Revision \RCSRevision, \RCSDate}
\end{verbatim}
\end{narrowversion}
\end{quote}

If you've entered the brave new world of \ProgName{Subversion}, the
package \Package{svn} may be for you.  It has explicit cleverness
about dealing with dates:
\begin{quote}
\csx{documentclass}\texttt{\{\meta{foo}\}}\\
\texttt{...}\\
\cmdinvoke{usepackage}{svn}\\
\csx{SVNdate}\texttt{ \$Date\$}\\
\cmdinvoke{author}{...}\\
\cmdinvoke{title}{...}\\
\texttt{...}\\
\cmdinvoke{begin}{document}\\
\csx{maketitle}\\
\texttt{...}\\
\cmdinvoke{end}{document}
\end{quote}
will (once \ProgName{subversion} has committed a copy of the document)
cause \csx{maketitle} use the date that has been written into the
\texttt{\$Date\$} keyword.

Another alternative for \ProgName{Subversion} users is the
\Package{svninfo} package, which has much the same mechanisms as does
\Package{svn} but with a rather different focus.  \Package{Svninfo}
does the date trick that \Package{svn} performs (controlled by a
package option), and can set up page foot-lines using % ! line break
\Qref*{package \Package{fancyhdr}}{Q-fancyhdr}.  There isn't much to
choose between the two packages: you should read the packages'
documentation to see which suits you best.

An alternative script-based approach to version control has been taken
by the \Package{vc} bundle, that in certain situations might work more
reliably than any of the packages mentioned above.  The \Package{vc}
bundle supports \ProgName{Bazaar}, \ProgName{Git} and
\ProgName{Subversion} usage and works with both \LaTeX{} and
\plaintex{}.  Note that \Package{vc} is the only option that
currently claims to support \ProgName{Bazaar}- and
\ProgName{Git}-controlled repositories.
\begin{ctanrefs}
\item[rcs.sty]\CTANref{rcs}
\item[rcsinfo.sty]\CTANref{rcsinfo}
\item[svn.sty]\CTANref{svn}
\item[svninfo.sty]\CTANref{svninfo}
\item[vc]\CTANref{vc}
\end{ctanrefs}

\Question[Q-make]{Makefiles for \LaTeX{} documents}

\LaTeX{} is a tricky beast for running \ProgName{make} on: the need to
instruct \LaTeX{} to run several times for essentially different
reasons (for example, ``get the table of contents stable'', ``get the
labels stable'', ``add the bibliography'', ``add the index'') is
actually rather difficult to express in the `ordinary' sort of
dependency graph that one constructs for \ProgName{make}.

For this reason, the only \ProgName{make}-like package on \acro{CTAN}
(for a long time) was \ProgName{latexmk}, which is a \ProgName{Perl}
script that analyses your \LaTeX{} source for its dependencies, runs
\BibTeX{} or \ProgName{makeindex} as and when it notices that those
programs' input (parts of the \extension{aux} file, or the
\extension{idx} file, respectively) has changed, and so on.
\ProgName{Latexmk} is a fine 
solution (and was used in generating printable versions of these
\acro{FAQ}s for a long time); it has recently been upgraded and has
many bells and whistles that allow it to operate as if it were a poor
man's \WYSIWYG{} system.

Apparently along the same lines, and currently (2007) under active
development, is Auto\LaTeX{}.  The \File{README} of the distribution is
actual a Unix-type man-page output, and shows great attention to the
details of the document production process.

Windows users of the \miktex{} system may use that systems
\ProgName{texify} application.  \ProgName{Texify} deals with basic
\LaTeX{} features, including generating a bibliography and an index;
it makes no claim to deal with other things (such as multiple
bibliographies or indexes, or lists of terminology, etc.), which
Auto\LaTeX{} can be configured to process.

The \Qref*{\Package{texinfo} system}{Q-texinfo} comes with a similar
utility called \ProgName{texi2dvi}, which is capable of ``converting''
either \LaTeX{} or \Package{texinfo} files into \acro{DVI} (or into
\acro{PDF}, using \PDFTeX{}).

A later contribution is the bundle \Package{latexmake}, which
offers a set of \ProgName{make} rules that invoke \ProgName{texi2dvi}
as necessary.

The curious may examine the rules employed to run the present
\acro{FAQ} through \LaTeX{}: we don't present them as a complete
solution, but some of the tricks employed are surely re-usable.
\begin{ctanrefs}
\item[\nothtml{\rmfamily}AutoLaTeX]\CTANref{autolatex}
\item[\nothtml{\rmfamily}\acro{FAQ} distribution]\CTANref{faq}
\item[\nothtml{\rmfamily}latexmake]\CTANref{latexmake}
\item[latexmk]\CTANref{latexmk}
\item[texi2dvi]Distributed as part of \CTANref{texinfo}
\end{ctanrefs}

\Question[Q-howmanypp]{How many pages are there in my document?}

Simple documents (those that start at page 1, and don't have any
breaks in their page numbering until their last page) present no
problem to the seeker after this truth.  The number of pages is
reported by the \Package{lastpage} package in its \texttt{LastPage} label.

For more complicated documents (most obviously, books with frontmatter
in a different series of page numbers) this simple approach will not
do.

The \Package{count1to} package defines a label \texttt{TotalPages}; this is
the value of its copy of \csx{count1} (a reserved \TeX{} count
register) at the end of the document.

Package \Package{totpages} defines a label \texttt{TotPages}, but it also
makes the register it uses available as a \LaTeX{} counter,
\texttt{TotPages}, which you can also reference via \csx{theTotPages}.  Of
course, the counter |TotPages| is asynchronous in the same way that
page numbers are, but snapshots may safely be taken in the output
routine.

The \Class{memoir} class defines two counters \texttt{lastpage} and
\texttt{lastsheet}, which are set (after the first run of a document)
to the equivalent of the \texttt{LastPage} label and the
\texttt{TotalPages} labels.

Both \Package{count1to} and \Package{totpages} need the support of
the \Package{everyshi} package.
\begin{ctanrefs}
\item[count1to.sty \nothtml{\bgroup\rmfamily}and\nothtml{\egroup} everyshi.sty]% line break!!
  Distributed in \CTANref{ms}
\item[lastpage.sty]\CTANref{lastpage}
\item[memoir.cls]\CTANref{memoir}
\item[totpages.sty]\CTANref{totpages}
\end{ctanrefs}

\Question[Q-inclplain]{Including \plaintex{} files in \LaTeX{}}

\LaTeX{}, though originally \Qref*{based on \plaintex{}}{Q-LaTeXandPlain}, does not
contain all of \plaintex{}'s commands.  Worse, some \plaintex{}
command names appear in \LaTeX{}, with different semantics.  As a
result, special measures need to be taken to allow general \plaintex{}
documents (or parts of documents) to be typeset within \LaTeX{}.

The truly reliable way is to translate the \plaintex{} commands, to
produce an equivalent of the original's semantics.  However, this is
not practical in many circumstances, and for those occasions, the
\Package{plain} package will often come to your aid.  The package
defines a \environment{plain} environment, in which a \plaintex{}
document may be processed:
\begin{quote}
\begin{verbatim}
\begin{plain}
  \input{plain-doc}
\end{plain}
\end{verbatim}
\end{quote}
The package is known to fail, for example, with documents that use
\AMSTeX{}; no doubt it would also fail if asked to load \Eplain{}.
All these things can be overcome (although it's not often easy), but
the environment saves a lot of work on many occasions.
\begin{ctanrefs}
\item[plain.sty]Distributed as part of \CTANref{carlisle}
\end{ctanrefs}

\subsection{Hyphenation}

\Question[Q-nohyph]{My words aren't being hyphenated}

Let's assume you've selected the right \TeX{} `language'~--- as
explained in \Qref[question]{``how hyphenation works''}{Q-hyphen},
you're not likely to get the correct results typesetting one language
using the hyphenation rules of another.  (Select the proper language,
using \Package{babel} if you're a \LaTeX{} user.  This may reveal that
you need another set of hyphenation patterns; see
% beware line wrap
\Qref[question]{``using a new language''}{Q-newlang} for advice on how
to install it.)

So what else can go wrong?
\begin{itemize}
\item Since \TeX{} version~3.0, the limits on how near to either end
  of a word hyphenation may take place have been programmable (see
  \Qref[question]{``weird hyphenation''}{Q-weirdhyphen}), and for some
  reason the values in question may have been corrupted in some macros
  you are using.  \TeX{} won't hyphenate less than \csx{lefthyphenmin}
  characters after the start of a word, nor less than
  \csx{righthyphenmin} before the end of a word; thus it won't
  hyphenate a word shorter than the sum of the two minima, at all.
  For example, since the minima are 2 and 3 for English, \TeX{} won't
  hyphenate a word shorter than 5 letters long, if it believes the
  word to be English.
\item \TeX{} won't hyphenate a word that's already been hyphenated.
  For example, the (caricature) English surname Smyth-Postlethwaite
  wouldn't hyphenate, which could be troublesome.  This is correct
  English typesetting style (it may not be correct for other
  languages), but if needs must, you can replace the hyphen in the
  name with a \csx{hyph} command, defined
\begin{quote}
\begin{verbatim}
\def\hyph{-\penalty0\hskip0pt\relax}
\end{verbatim}
\end{quote}
  This is \emph{not} the sort of thing this \acro{FAQ} would
  ordinarily recommend\dots{} The \Package{hyphenat} package defines a
  bundle of such commands (for introducing hyphenation points at
  various punctuation characters).
\item There may be accents in the word.  The causes of and remedies
  for this effect are discussed in
  % beware line break
  \Qref[question]{accents and hyphens}{Q-hyphenaccents}.
\item The hyphenation may simply not have been spotted; while \TeX{}'s
  algorithm is good, it's not infallible, and it does miss perfectly
  good hyphenations in some languages.  When this happens, you need to
  give \TeX{} \emph{explicit} instructions on how to hyphenate.
\end{itemize}
The \csx{hyphenation} command allows you to give explicit instructions.
Provided that the word will hyphenate at all (that is, it is not
prevented from hyphenating by any of the other restrictions above),
the command will override anything the hyphenation patterns might
dictate.  The command takes one or more hyphenated words as
argument~--- \cmdinvoke{hyphenation}{ana-lysis pot-able}; note that
(as here, for analysis) you can use the command to overrule \TeX{}'s
choice of hyphenation (ana-lysis is the British etymological
hyphenation; some feel the American hyphenation feels
`unfortunate'\dots{}).
\begin{ctanrefs}
\item[hyphenat.sty]\CTANref{hyphenat}
\end{ctanrefs}

\Question[Q-weirdhyphen]{Weird hyphenation of words}

If your words are being h-yphenated, like this, with jus-t single
letters at the 
beginning or the end of the word, you may have a version mismatch
problem. \TeX{}'s hyphenation system changed between version~2.9
and~3.0, and macros written for use with version~2.9 can have this
effect with a version~3.0 system.  If you are using \plaintex{}, make
sure your \File{plain.tex} file has a version number which is at
least~3.0, and rebuild your format.  If you are using \LaTeXo{} your
best plan is to upgrade to \LaTeXe{}.  If for some reason you can't,
the last version of \LaTeXo{} (released on 25 March 1992) is still
available (for the time being at least) and ought to solve this
problem.

If you're using \LaTeXe{}, the problem probably arises from your
|hyphen.cfg| file, which has to be created if you're using a
multi-lingual version.

A further source of oddity can derive from the 1995 release of
\Qref*{Cork-encoded fonts}{Q-ECfonts},
which introduced an alternative hyphen character.  The \LaTeXe{}
configuration files in the font release specified use of the
alternative hyphen, and this could produce odd effects with words
containing an explicit hyphen.  The font configuration files in the
December 1995 release of \LaTeXe{} do \emph{not} use the alternative
hyphen character, and therefore removed this source of problems; the
solution, again, is to upgrade your \LaTeX{}.
\begin{ctanrefs}
\item[\nothtml{\rmfamily}\LaTeXo{}]\CTANref{latex209-base}
\item[plain.tex]\CTANref{plain}
\end{ctanrefs}

\Question[Q-oddhyphen]{(Merely) peculiar hyphenation}

You may have found that \TeX{}'s famed automatic word-division does
not produce the break-points recommended by your dictionary. This may be
because \TeX{} is set up for American English, whose rules for word
division (as specified, for example, in Webster's Dictionary) are
completely different from the British ones (as specified, for example,
in the Oxford Dictionaries). This problem is being addressed by the \acro{UK}
\TeX{} User community (see \BV{}, issue~4.4) but an entirely
satisfactory solution will take time; the current status is to be
found on \acro{CTAN} (see
% beware line-wrap
\Qref[question]{``using a new language''}{Q-newlang} for instructions
on adding this new ``language'').
\begin{ctanrefs}
\item[UK patterns]\CTANref{ukhyph}
\end{ctanrefs}

\Question[Q-hyphenaccents]{Accented words aren't hyphenated}

\TeX{}'s algorithm for hyphenation gives up when it encounters an
\csx{accent} command; there are good reasons for this, but it means
that quality typesetting in non-English languages can be difficult.

For \TeX{} macro packages, you can avoiding the effect by using an
appropriately encoded font (for example, a Cork-encoded font~--- see
\Qref[question]{the \acro{EC} fonts}{Q-ECfonts}) which contains accented
letters as single glyphs.  \LaTeX{} users can achieve this end simply
by adding the command
\begin{verbatim}
  \usepackage[T1]{fontenc}
\end{verbatim}
to the preamble of their document.  Other encodings (notably
\acro{LY}1, once promoted by \YandY{} inc) may be used
in place of \acro{T}1.  Indeed, most current 8-bit \TeX{} font
encodings will `work' with the relevant sets of hyphenation patterns. 

One might hope that, with the many aspirant successors to \TeX{} such
as
\begin{wideversion}
  \Qref{Omega}{Q-omegaleph}, \Qref{\LuaTeX{}}{Q-luatex} and
  \Qref{Ex\TeX{}}{Q-extex},
\end{wideversion}
\begin{narrowversion}
  Omega, \LuaTeX{} and Ex\TeX{}
  (\Qref[see questions]{}{Q-omegaleph}\Qref[,]{}{Q-luatex}
  \Qref[and]{}{Q-extex}),
\end{narrowversion}
all of which base their operations on Unicode, that the whole basis of
encodings will change.

\Question[Q-newlang]{Using a new language with Babel}

\Package{Babel} is capable of working with a large range of
languages, and a new user often wants to use a language that her
\TeX{} installation is not set up to employ.  Simply asking Babel to
use the language, with the command
\begin{verbatim}
  \usepackage[catalan]{babel}
\end{verbatim}
provokes the warning message
\begin{wideversion}
\begin{verbatim}
Package babel Warning: No hyphenation patterns were loaded for
(babel)                the language `Catalan'
(babel)                I will use the patterns loaded for \language=0 instead.
\end{verbatim}
\end{wideversion}
\begin{narrowversion}
\begin{verbatim}
Package babel Warning: No hyphenation patterns
                                 were loaded for
(babel)                the language `Catalan'
(babel)                I will use the patterns
                 loaded for \language=0 instead.
\end{verbatim}
(The first and third lines above have been wrapped to fit in the
column.)
\end{narrowversion}

The problem is that your \TeX{} system doesn't know how to hyphenate
Catalan text: you need to tell it how before Babel can do its work
properly.  To do this, for \LaTeX{} installations, one needs to change
\File{language.dat} (which is part of the Babel installation); it will
contain a line
\begin{verbatim}
%catalan         cahyphen.tex
\end{verbatim}
which, if you remove the comment marker, is supposed to instruct
\LaTeX{} to load Catalan hyphenation patterns when you tell it to build
a new format.

Unfortunately, in many Babel distributions, the line just isn't
right~--- you need to check the name of the file containing the
patterns you're going to use.  As you can see, in the author's system,
the name is supposed to be \File{cahyphen.tex}; however the file
actually present on the system is \File{cahyph.tex}~--- fortunately,
the error should prove little more than an inconvenience (most of the
files are in better distributions anyway, but an elusive one
may be found on \acro{CTAN}; if you have to retrieve
a new file, ensure that it's correctly installed, for which see
\Qref[question]{installing a new package}{Q-inst-wlcf}).

Finally, you need to regenerate the formats used (in fact, most users
of Babel are using it in their \LaTeX{} documents, so regenerating the
\LaTeX{}-related formats will ordinarily be enough; however, the
author always generates the lot, regardless).
\begin{description}
\item[te\TeX{}]It's possible to do the whole operation in one go, by
  using the \ProgName{texconfig} command:
\begin{verbatim}
texconfig hyphen latex
\end{verbatim}
  which first enters an editor for you to edit \File{language.dat},
  and then regenerates the format you specify (\ProgName{latex} in
  this case).

  Otherwise, to regenerate all formats, do: \\
  \texttt{fmtutil -\relax-all}
  
  If you're willing to think through what you're doing (this is
  \emph{not} for the faint-hearted), you can select a sequence of
  formats and for each one, run: \\
  \texttt{fmtutil -\relax-byfmt \meta{formatname}}\\
  where \emph{\texttt{formatname}} is something like `\texttt{latex}',
  or: \\
  \texttt{fmtutil -\relax-byhyphen \meta{hyphenfile}}\\
  where \emph{\texttt{hyphenfile}} is the file specifying hyphenation
  to the format~--- usually \texttt{language.dat}
\item[\miktex{}] On a \Package{\miktex{}} distribution earlier than v2.0, do: \\
  \texttt{Start}\arrowhyph{}%
  \texttt{Programs}\arrowhyph{}%
  \texttt{\miktex{}}\arrowhyph{}%
  \texttt{Maintenance}\arrowhyph{}%
  \texttt{Create all format files}
% this sequence suggested for miktex 1.20e, 2000/12/22, by Giuseppe Bilotta

  or get a DOS window and run:\\
  \texttt{initexmf -\relax-dump}
  
  On a \Package{\miktex{}} distribution v2.0 or later, the whole
  procedure can be done via the \acro{GUI}.  To select the new
  language, do:\\
  \texttt{Start}\arrowhyph{}%
  \texttt{Programs}\arrowhyph{}%
  \texttt{\miktex{} 2}\arrowhyph{}%
  \texttt{\miktex{} Options}, and select the \texttt{Languages} tab.
  Select your language from the list, press the \texttt{Apply} button,
  and then the \texttt{OK} button.  Then select the \texttt{General}
  tab and press the \texttt{Update Now} button.
  
  Otherwise, edit the \File{language.dat} file (as outlined above),
  and then run:\\
  \texttt{initexmf -\relax-dump}\\
  just as for a pre-v2.0 system.
\end{description}

\nothtml{\noindent}\textbf{\emph{Caveat}:} It is (just) possible that
your \TeX{} system may run out of ``pattern memory'' while generating
the new format.  Most \TeX{} implementations have fixed-size arrays
for storing the details of hyphenation patterns, but although their
size is adjustable in most modern distributions, actually changing the
size is a fiddle.  If you \emph{do} find you've run out of memory,
it may be worth scanning the list of languages in your
\File{language.dat} to see whether any could reasonably be removed.
\begin{ctanrefs}
\item[babel]\CTANref{babel}
\item[hyphenation patterns]\CTANref{hyphenation}
\end{ctanrefs}

\Question[Q-hyphoff]{Stopping all hyphenation}

It may seem an odd thing to want to do (after all, one of \TeX{}'s
great advertised virtues is the quality of its hyphenation) but it's
sometimes necessary.  The real problem is, that the quality of
\TeX{}'s output is by default largely dependent on the presence of
hyphenation; if you want to abandon hyphenation, something has to
give.

\TeX{} (slightly confusingly) offers four possible mechanisms for
suppressing hyphenation (there were only two prior to the extensions
that arrived with \TeX{} version~3).

First, one can set the hyphenation penalties \csx{hyphenpenalty} and
\csx{exhyphenpenalty} to an `infinite' value (that is to say, 10000).
This means that all hyphenations will sufficiently penalise the line
that would contain them, that the hyphenation won't happen.  The
disadvantage of this method is that \TeX{} will re-evaluate any
paragraph for which hyphenations might help, which will slow \TeX{}
down.

Second, one can select a language for which no hyphenation patterns
exist.  Some distributions create a language \texttt{nohyphenation},
and the \Package{hyphenat} package uses this technique for its
\csx{nohyphens} command which sets its argument without any
hyphenation.  You can load \Package{hyphenat} with the command
\begin{quote}
  \cmdinvoke{usepckage}[none]{hyphenat}
\end{quote}
to prevent any hyphenation in a single-language document.  The
technique cannot work in a document in which \Package{babel} controls
language selection, since \Package{babel} incorporates hyphenation
change into its language change facilities.

Third, one can set \csx{left-} and/or \csx{righthyphenmin} to a
sufficiently large value that no hyphenation could possibly succeed,
since the minimum is larger than the length of the longest word
\TeX{} is willing to hyphenate (the appropriate value is 62).

Fourth, one can suppress hyphenation for all text using the current
font by the command
\begin{quote}
\begin{verbatim}
\hyphenchar\font=-1
\end{verbatim}
\end{quote}
This isn't a particularly practical way for users to suppress
hyphenation~--- the command has to be issued for every font the
document uses~--- but it's how \LaTeX{} itself suppresses hyphenation
in \texttt{tt} and other fixed-width fonts.

Which of the techniques you should use depends on what you actually
want to do.  If the text whose hyphenation is to be suppressed runs
for less than a paragraph, your only choice is the no-hyphens
language: the language value is preserved along with the text (in the
same way that the current font is); the values for penalties and
hyphen minima active at the end of a paragraph are used when
hyphenation is calculated.

Contrariwise, if you are writing a multilanguage document using the
\Package{babel} package, you \emph{cannot} suppress hyphenation
throughout using either the no-hyphens language or the hyphen minima:
all those values get changed at a \Package{babel} language switch: use
the penalties instead.

If you simply switch off hyphenation for a good bit of text, the
output will have a jagged edge (with many lines seriously overfull),
and your \AllTeX{} run will bombard you with warnings about overfull
and underfull lines.  To avoid this you have two options.

The simplest route is to use \csx{sloppy} (or its environment version
\environment{sloppypar}), and have \TeX{} stretch what would otherwise
be underfull lines to fill the space offered, while prematurely
wrapping overfull lines and stretching the remainder.  

Alternatively, you may set the text \Qref*{ragged right}{Q-ragright},
and at least get rid of the overfull lines; this technique is
`traditional' (in the sense that typists do it) and may be expected to
appeal to the specifiers of eccentric document layouts (such as those
for dissertations), but for once their sense conforms with typographic
style.  (Or at least, style constrained in this curious way.)
\begin{ctanrefs}
\item[hyphenat.sty]\CTANref{hyphenat}
\end{ctanrefs}

\Question[Q-wdnohyph]{Preventing hyphenation of a particular word}

It's quite possible for (\emph{any}) hyphenation of a particular word
to seem ``completely wrong'', so that you want to prevent it being
hyphenated.

If the word occurs in just one place, put it in a box:
\begin{quote}
\begin{verbatim}
\mbox{oddword}
\end{verbatim}
\end{quote}
(\plaintex{} users should use \csx{hbox}, and take care at the start
of paragraphs.)  However, boxing the word is not really advisable
unless you are sure it only occurs once.

If the word occurs commonly, the best choice is to assert a
non-hyphenation for it:
\begin{quote}
\begin{verbatim}
\hyphenation{oddword}
\end{verbatim}
\end{quote}
This hyphenation exception (with no break points) will be used in
preference to what \TeX{}'s hyphenation algorithm may come up with.

In a multilingual document, repeat the exception specification for
each language the word may appear in.  So:
\begin{quote}
\begin{verbatim}
\usepackage[french,english]{babel}
\selectlanguage{english}
\hyphenation{oddword}
\selectlanguage{french}
\hyphenation{oddword}
\end{verbatim}
\end{quote}
(note that \Package{babel} will select the default language for the
document~--- English, in this case~--- at \cmdinvoke{begin}{document}.)

A particular instance of this requirement is avoiding the hyphenation
of acronyms; a general rule for those that concoct acronyms seems to
be to make the capital-letter sequence read as near as is possible
like a ``real'' word, but hyphenating an acronym often looks silly.
The \TeX{} flag \csx{uchyph} is designed for suppressing such
behaviour:
\begin{quote}
\begin{verbatim}
\uchyph=0
\end{verbatim}
\end{quote}
will stop hyphenation of upper-case words.  (Note that \plaintex{}
syntax is needed here: there's no \LaTeX{} alternative for setting
this value.)

\Question[Q-hyphexcept]{Hyphenation exceptions}

While \TeX{}'s hyphenation rules are good, they're not infallible: you
will occasionally find words \TeX{} just gets \emph{wrong}.  So for
example, \TeX{}'s default hyphenation rules (for American English) don't
know the word ``\emph{manuscript}'', and since it's a long word you
may find you need to hyphenate it.  You \emph{can} ``write the
hyphenation out'' each time you use the word:
\begin{quote}
\begin{verbatim}
... man\-u\-script ...
\end{verbatim}
\end{quote}
Here, each of the \csx{-} commands is converted to a hyphenated break,
if (\emph{and only if}) necessary.

That technique can rapidly become tedious: you'll probably only accept
it if there are no more than one or two wrongly-hyphenated words in
your document.  The alternative is to set up hyphenations in the
document preamble.  To do that, for the hyphenation above, you would
write:
\begin{quote}
\begin{verbatim}
\hyphenation{man-u-script}
\end{verbatim}
\end{quote}
and the hyphenation would be set for the whole document.  Barbara
Beeton publishes articles containing lists of these ``hyphenation
exceptions'', in \textsl{TUGboat}; the hyphenation `man-u-script'
comes from one of those articles.

What if you have more than one language in your document?  Simple:
select the appropriate language, and do the same as above:
\begin{quote}
\begin{verbatim}
\usepackage[french]{babel}
\selectlanguage{french}
\hyphenation{re-cher-cher}
\end{verbatim}
\end{quote}
(nothing clever here: this is the ``correct'' hyphenation of the word,
in the current tables).  However, there's a problem here: just as
words with accents in them won't break, so \csx{hyphenation} commands
with accents in them produce an error:
\begin{quote}
\begin{verbatim}
\usepackage[french]{babel}
\selectlanguage{french}
\hyphenation{r\'e-f\'e-rence}
\end{verbatim}
\end{quote}
tells us that the hyphenation is ``improper'', and that it will be ``flushed''.
But, just as hyphenation of words is enabled by selecting an 8-bit
font encoding, so \csx{hyphenation} commands are rendered proper again
by selecting that same 8-bit font encoding.  For the hyphenation
patterns provided in the usual distributions, the encoding is
\Qref*{Cork}{Q-ECfonts}, so the complete sequence is:
\begin{quote}
\begin{verbatim}
\usepackage[T1]{fontenc}
\usepackage[french]{babel}
\selectlanguage{french}
\hyphenation{r\'e-f\'e-rence}
\end{verbatim}
\end{quote}

The same sort of performance goes for any language for which 8-bit
fonts and corresponding hyphenation patterns are available.  Since you
have to select both the language and the font encoding to have your
document typeset correctly, it should not be a great imposition to do
the selections before setting up hyphenation exceptions.

\subsection{Odds and ends}

\Question[Q-logos]{Typesetting all those \TeX{}-related logos}

Knuth was making a particular point about the capabilities of \TeX{}
when he defined the logo.  Unfortunately, many believe, he thereby
opened floodgates to give the world a whole range of rather silly
`bumpy road' logos such as \AMSTeX{}, \PiCTeX{}, \BibTeX{}, and so on,
produced in a flurry of different fonts, sizes, and baselines~--- indeed,
everything one might hope to cause them to obstruct the reading process.
In particular, Lamport invented \LaTeX{}
\htmlignore
(silly enough in itself)
\endhtmlignore
\begin{htmlversion}
  (silly enough in itself, with a raised small `A' and a lowered `E')
\end{htmlversion}
and marketing input from Addison-Wesley led to the even
stranger current logo
\htmlignore
\LaTeXe{}.
\endhtmlignore
\begin{htmlversion}
  \LaTeXe{}, which appends a lowered single-stroke Greek letter
  epsilon.
\end{htmlversion}

Sensible users don't have to follow this stuff wherever it goes,
but, for those who insist, a large collection of logos is defined in
the \Package{texnames} package (but note that this set of macros isn't
entirely reliable in \LaTeXe{}).
The \MF{} and \MP{} logos can be set in fonts that \LaTeXe{}
knows about (so that they scale with the surrounding text) using the
\Package{mflogo} package; but be aware that booby-traps surround the
use of the Knuthian font for \MP{} (you might get
\htmlignore
\textlogo{META\hphantom{P}O\hphantom{S}T}).
\endhtmlignore
% the following htmlversion stuff seems to do roughly what's required,
% which is nice, given the feebleness of representing all these silly
% logos in html otherwise...
\begin{htmlversion}
  something like `META&nbsp;O&nbsp;T').
\end{htmlversion}
You needn't despair, however~--- the author himself uses just `MetaPost'.

For those who don't wish to acquire the `proper' logos, the canonical
thing to do is to say \texttt{AMS-}\cmdinvoke{TeX}{}
\htmlignore
(\acro{AMS}-\TeX{})
\endhtmlignore
for \AMSTeX{}, \texttt{Pic}\cmdinvoke{TeX}{}
\htmlignore
(Pic\TeX{})
\endhtmlignore
for \PiCTeX{}, \texttt{Bib}\cmdinvoke{TeX}{}
\htmlignore
(Bib\TeX{})
\endhtmlignore
for \BibTeX{}, and so on.
\begin{ctanrefs}
\item[mflogo.sty]\CTANref{mflogo}
\item[texnames.sty]\CTANref{texnames}
\end{ctanrefs}

\Question[Q-bold-extras]{How to do bold-tt or bold-sc}

\LaTeX{}, as delivered, offers no means of handling bold ``teletype''
or small-caps fonts.  There's a practical reason for this (Knuth never
designed such fonts), but there are typographical considerations too
(the ``medium weight'' \texttt{cmtt} font is already pretty bold (by
comparison with other fixed-width fonts), and bold small-caps is not
popular with many professional typographers).

There's a set of ``extra'' \MF{} files on \acro{CTAN} that provide bold
versions of both \texttt{cmtt} and \texttt{cmcsc} (the small caps font).  With
modern \TeX{} distributions, one may bring these fonts into use simply
by placing them in an % ! line break
\Qref*{appropriate place in the \emph{texmf} tree}{Q-install-where}
(these are \AllTeX{}-specific files, so the ``\emph{public}'' supplier
would be an appropriate place).  Once you've % ! line break, again
\Qref*{rebuilt the file indexes as necessary}{Q-inst-wlcf},
\TeX{} (and friends) will automatically build whatever font files they
need when you first make reference to them.  There's a jiffy package
\Package{bold-extra} that builds the necessary font data structures
so that you can use the fonts within \LaTeX{}.

Another alternative is to use the \Qref*{\acro{EC} fonts}{Q-ECfonts},
which come with bold variants of the small-caps fonts.

If you need to use Type~1 fonts, you can't proceed with Knuth-style
fonts, since there are no Type~1 versions of the \Package{mf-extra}
set.  There are, however, Type~1 distributions of the EC~fonts, so you
can switch to EC and use them; alternatives are discussed in
\Qref[question]{8-bit Type~1 fonts}{Q-type1T1}.

Of course, commercial fixed-width fonts (even the default
\FontName{Courier}) almost always come with a bold variant, so that's
not a problem.  Furthermore \Qref*{\acro{PSNFSS}}{Q-usepsfont}
will usually provide ``faked'' small caps fonts, and has no
compunctions about providing them in a bold form.  \FontName{Courier}
is (as we all know, to our cost) freely available; a far more
presentable monospace font is \FontName{LuxiMono}, which is also
freely available (monospace text in the typeset version of this
\acro{FAQ} uses \FontName{LuxiMono}, with the metrics and \LaTeX{}
support available on the archive.
\begin{ctanrefs}
\item[bold-extra.sty]\CTANref{bold-extra}
\item[bold tt and small caps fonts]\CTANref{bold}
\item[\nothtml{\rmfamily}LuxiMono fonts]\CTANref{luximono}
\end{ctanrefs}

\Question[Q-varwidth]{Automatic sizing of \environment{minipage}}

The \environment{minipage} environment requires you to specify the
width of the ``page'' you're going to create.  This is sometimes
inconvenient: you would like to occupy less space, if possible, but
\environment{minipage} sets a box that is exactly the width you
specified.

The \Package{pbox} package defines a \csx{pbox} whose width is exactly
that of the longest enclosed line, subject to a maximum width that you
give it.  So while \cmdinvoke{parbox}{2cm}{Hello\bsbs world!} produces a
box of width exactly \texttt{2cm},
\cmdinvoke{pbox}{2cm}{Hello\bsbs world!} produces one whose width is
\texttt{1.79cm} (if one's using the default \FontName{cmr} font for the
text, at least).  The package also provides a
\cmdinvoke*{settominwidth}[min]{length}{text} (which looks (almost)
like the standard \csx{settowidth} command), and a \csx{widthofpbox}
function analogous to the \csx{widthof} command for use with the
\Package{calc} package.

The \Package{eqparbox} package extends \Package{pbox}'s idea, by
allowing you to set a series of boxes, all with the same (minimised)
width.  (Note that it doesn't accept a limiting maximum width
parameter.)  The package documentation shows the following example
drawn from a joke \emph{curriculum vitae}:
\begin{quote}
\begin{narrowversion}
\begin{verbatim}
\noindent%
\eqparbox{place}%
    {\textbf{Widgets, Inc.}}
        \hfill
\eqparbox{title}%
    {\textbf{Senior Widget Designer}}
        \hfill
\eqparbox{dates}{\textbf{1/95--present}}

...

\noindent%
\eqparbox{place}%
    {\textbf{Thingamabobs, Ltd.}}
        \hfill
\eqparbox{title}%
    {\textbf{Lead Engineer}}
        \hfill
\eqparbox{dates}{\textbf{9/92--12/94}}
\end{verbatim}
\end{narrowversion}
\begin{wideversion}
\begin{verbatim}
\noindent%
\eqparbox{place}{\textbf{Widgets, Inc.}} \hfill
\eqparbox{title}{\textbf{Senior Widget Designer}} \hfill
\eqparbox{dates}{\textbf{1/95--present}}

...

\noindent%
\eqparbox{place}{\textbf{Thingamabobs, Ltd.}} \hfill
\eqparbox{title}{\textbf{Lead Engineer}} \hfill
\eqparbox{dates}{\textbf{9/92--12/94}}
\end{verbatim}
\end{wideversion}
\end{quote}
The code makes the three items on each of the heading lines have
exactly the same width, so that the lines as a whole produce a regular
pattern down the page.  A command \csx{eqboxwidth} allows you to use
the measured width of a group: the documentation shows how the command
may be used to produce sensible-looking columns that mix \texttt{c}-,
\texttt{r}- or \texttt{l}-rows, with the equivalent of a |p{...}|
entry, by making the fixed-width rows an \Package{eqparbox} group, and
making the last from a \csx{parbox} using the width that's been
measured for the group.

The \Package{varwidth} package defines a \environment{varwidth}
environment which sets the content of the box to match a ``narrower
natural width'' if it finds one.  (You give it the same parameters as
you would give \environment{minipage}: in effect, it is a `drop-in'
replacement.)  \Package{Varwidth} provides its own ragged text command:
\csx{narrowragged}, which aims to make narrower lines and to put more
text in the last line of the paragraph (thus producing lines with more
nearly equal lengths than typically happens with \csx{raggedright}
itself).

The documentation (in the package file) lists various restrictions and
things still to be done, but the package is already proving useful for
a variety of jobs.
\begin{ctanrefs}
\item[eqparbox.sty]\CTANref{eqparbox}
\item[pbox.sty]\CTANref{pbox}
\item[varwidth.sty]\CTANref{varwidth}
\end{ctanrefs}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\section{Symbols, etc.}

\Question[Q-numbersets]{Symbols for the number sets}

It is a good idea to have commands such as \csx{R} for the real numbers and
other standard number sets. Traditionally these were typeset in bold.
Because, in the ordinary course of events, mathematicians do not have
access to bold chalk, they invented the special symbols that are now
often used for \csx{R}, \csx{C}, \emph{etc}.  These symbols are known
as ``blackboard bold''.  Before insisting on using them, consider
whether going back to the old system of ordinary bold might not be
acceptable (it is certainly simpler).

A set of blackboard bold capitals is available in the \acro{AMS}
\FontName{msbm} fonts (\FontName{msbm} is available at a range of
design sizes, with names such as \FontName{msbm10}). The pair of font
families (the other is called \FontName{msam}) have a large number of
mathematical symbols to supplement the ones in the standard \TeX{}
distribution, and are available in Type~1 format with most modern
distributions. Support files for using the fonts, both under
\plaintex{} and \LaTeX{} (packages \Package{amssymb} and
\Package{amsfonts}), are available.  The font shape is a rather
austere sans, which many people don't like (though it captures the
essence of quickly-chalked writing rather well).

The \FontName{bbold} family is set of blackboard bold fonts written in
\MF{}.  This set offers blackboard bold forms of lower-case letters;
the font source directory also contains sources for a \LaTeX{} package
that enables use of the fonts.  The fonts are not available in Type~1 format.

The \FontName{bbm} family claims to provide
`blackboard' versions of most of the \FontName{cm} fonts~\dots{} including
the bold and bold-extended series.  Again, the fonts are designed in
\MF{} and are not available in Type~1 format.  \LaTeX{} macro support
comes from a package by Torsten Hilbrich.

The \FontName{doublestroke} family comes in just roman
and sans shapes, at a single weight, and is available both as \MF{}
sources and as Type~1; the font covers the uppercase latin letters,
lowercase `h' and 'k', and the digit `1'.

An alternative source of Type~1 fonts with blackboard bold characters
may be found in the steadily increasing set of complete families, both
commercial and free, that have been prepared for use with \AllTeX{}
(see % beware line break
\htmlonly{``}\Qref[question]{choice of outline fonts}{Q-psfchoice}\htmlonly{''}).
Of the free sets, the \FontName{txfonts} and \FontName{pxfonts} families
both come with replicas of \FontName{msam} and \FontName{msbm}
(though, as noted elsewhere, there are other reasons not to use these
fonts).  The \FontName{mathpazo} family includes a ``mathematically
significant'' choice of blackboard bold characters, and the
\FontName{fourier} fonts contain blackboard bold upper-case letters,
the digit `1', and lower-case `k'.

The ``lazy person's'' blackboard bold macros:
\begin{quote}
\begin{verbatim}
\newcommand{\R}{{\sf R\hspace*{-0.9ex}%
  \rule{0.15ex}{1.5ex}\hspace*{0.9ex}}}
\newcommand{\N}{{\sf N\hspace*{-1.0ex}%
  \rule{0.15ex}{1.3ex}\hspace*{1.0ex}}}
\newcommand{\Q}{{\sf Q\hspace*{-1.1ex}%
  \rule{0.15ex}{1.5ex}\hspace*{1.1ex}}}
\newcommand{\C}{{\sf C\hspace*{-0.9ex}%
  \rule{0.15ex}{1.3ex}\hspace*{0.9ex}}}
\end{verbatim}
\end{quote}
are almost acceptable at normal size if the surrounding text is
\FontName{cmr10}.  However, they are not part of a proper maths font,
and so do not work in sub- and superscripts.  Moreover, the size and
position of the vertical bar can be affected by the font of the
surrounding text.  As we've seen, there are plenty of alternatives:
don't try the macros, or anything similar using capital `I' (which
looks even worse!).
\begin{ctanrefs}
\item[AMS support files (Plain)]\CTANref{amsfonts-plain}
\item[AMS support files (LaTeX)]\CTANref{amsfonts-latex}
\item[AMS symbol fonts]\CTANref{amsfonts-symbols}
\item[AMS symbol fonts in Type~1 format]Browse \CTANref{ams-AMStype1}
\item[bbm fonts]\CTANref{bbm}
\item[bbm macros]\CTANref{bbm-macros}
\item[bbold fonts]\CTANref{bbold}
\item[doublestroke fonts]\CTANref{doublestroke}
\item[fourier fonts]\CTANref{fourier}
\item[mathpazo fonts]\CTANref{mathpazo}
\item[pxfonts]\CTANref{pxfonts}
\item[txfonts]\CTANref{txfonts}
\end{ctanrefs}

\Question[Q-scriptfonts]{Better script fonts for maths}

The font selected by \csx{mathcal} is the only script font `built
in'. However, there are other useful calligraphic fonts included with
modern \TeX{} distributions.
\begin{description}
\item[Euler] The \Package{eucal} package (part of most sensible \TeX{}
  distributions; the fonts are part of the \acro{AMS} font set) gives
  a slightly curlier font than the default. The package changes the
  font that is selected by \csx{mathcal}.
  
  Type 1 versions of the fonts are available in the \acro{AMS} fonts
  distribution.
\item[RSFS] The \Package{mathrsfs} package uses a really fancy script
  font (the name stands for ``Ralph Smith's Formal Script'') which is
  already part of most modern \TeX{} distributions.  The package
  creates a new command \csx{mathscr}.
  
  Type 1 versions of the font have been made available by Taco
  Hoekwater.
\item[Zapf Chancery] is the standard \PS{} calligraphic font.  There
  is no package but you can easily make it available by means of the
  command
\begin{verbatim}
\DeclareMathAlphabet{\mathscr}{OT1}{pzc}%
                                 {m}{it}
\end{verbatim}
  in your preamble.  You may find the font rather too big; if so, you
  can use a scaled version of it like this:
\begin{verbatim}
\DeclareFontFamily{OT1}{pzc}{}
\DeclareFontShape{OT1}{pzc}{m}{it}%
             {<-> s * [0.900] pzcmi7t}{}
\DeclareMathAlphabet{\mathscr}{OT1}{pzc}%
                                 {m}{it}
\end{verbatim}
  
  Adobe Zapf Chancery (which the above examples use) is distributed in
  any but the most basic \PS{} printers.  A substantially identical
  font (to the extent that the same metrics may be used) is
  available from \acro{URW} and is distributed with
  \ProgName{ghostscript}.
\end{description}
Examples of the available styles are available on \acro{CTAN}.
\begin{ctanrefs}
\item[eucal.sty]\CTANref{eucal}
\item[euler fonts]\CTANref{amsfonts-euler}
\item[euler fonts, in Type 1 format]\CTANref{ams-AMStype1}
\item[ghostscript]Browse \CTANref{ghostscript}
\item[mathrsfs.sty]Distributed as part of \CTANref{jknappen-macros}
\item[rsfs fonts]\CTANref{rsfs}
\item[rsfs fonts, in Type 1 format]\CTANref{rsfs-type1}
\item[Script font examples]\CTANref{mathscript}
\end{ctanrefs}

\Question[Q-boldgreek]{Setting bold Greek letters in \LaTeX{}}

The issue here is complicated by the fact that \csx{mathbf} (the
command for setting bold \emph{text} in \TeX{} maths) affects a select
few mathematical symbols (the uppercase Greek letters).  However
lower-case Greek letters behave differently from upper-case Greek
letters (due to Knuth's esoteric font encoding decisions).  However,
\csx{mathbf} \emph{can't} be used even for upper-case Greek letters in
the \AMSLaTeX{} \Package{amsmath} package, which
disables this font-switching and you must use one of the techniques
outlined below.

The \plaintex{} solution \emph{does} work, in a limited way:
\begin{quote}
\begin{verbatim}
{\boldmath$\theta$}
\end{verbatim}
\end{quote}
but \csx{boldmath} may not be used in maths mode, so this `solution'
requires arcana such as:
\begin{quote}
\begin{verbatim}
$... \mbox{\boldmath$\theta$} ...$
\end{verbatim}
\end{quote}
which then causes problems in superscripts, etc.

These problems may be addressed by using a bold mathematics package.
\begin{itemize}
\item The \Package{bm} package, which is part of the \LaTeX{} tools
  distribution, defines a command \csx{bm} which may be used anywhere
  in maths mode.
\item The \Package{amsbsy} package (which is part of \AMSLaTeX{})
  defines a command \csx{boldsymbol}, which (though slightly less
  comprehensive than \csx{bm}) covers almost all common cases.
\end{itemize}

All these solutions cover all mathematical symbols, not merely Greek
letters.
\begin{ctanrefs}
\item[bm.sty]Distributed as part of \CTANref{2etools}
\item[amsbsy.sty]Distributed as part of \AMSLaTeX{} \CTANref{amslatex}
\item[amsmath.sty]Distributed as part of \AMSLaTeX{}
  \CTANref{amslatex}
\end{ctanrefs}

\Question[Q-prinvalint]{The Principal Value Integral symbol}

This symbol (an integral sign, `crossed') does not appear in any of
the fonts ordinarily available to \AllTeX{} users, but it can be
created by use of the following macros:
\begin{wideversion}
\begin{verbatim}
\def\Xint#1{\mathchoice
   {\XXint\displaystyle\textstyle{#1}}%
   {\XXint\textstyle\scriptstyle{#1}}%
   {\XXint\scriptstyle\scriptscriptstyle{#1}}%
   {\XXint\scriptscriptstyle\scriptscriptstyle{#1}}%
   \!\int}
\def\XXint#1#2#3{{\setbox0=\hbox{$#1{#2#3}{\int}$}
     \vcenter{\hbox{$#2#3$}}\kern-.5\wd0}}
\def\ddashint{\Xint=}
\def\dashint{\Xint-}
\end{verbatim}
\end{wideversion}
\begin{narrowversion}
\begin{verbatim}
\def\Xint#1{\mathchoice
   {\XXint\displaystyle\textstyle{#1}}%
   {\XXint\textstyle\scriptstyle{#1}}%
   {\XXint\scriptstyle\scriptscriptstyle{#1}}%
   {\XXint\scriptscriptstyle
                      \scriptscriptstyle{#1}}%
   \!\int}
\def\XXint#1#2#3{{%
     \setbox0=\hbox{$#1{#2#3}{\int}$}
     \vcenter{\hbox{$#2#3$}}\kern-.5\wd0}}
\def\ddashint{\Xint=}
\def\dashint{\Xint-}
\end{verbatim}
\end{narrowversion}
\csx{dashint} gives a single-dashed integral sign, \csx{ddashint} a
double-dashed one.

\Question[Q-underscore]{How to use the underscore character}

The underscore character `\texttt{\_}' is ordinarily used in
\TeX{} to indicate a subscript in maths mode; if you type
\texttt{\_}, on its own, in the course of ordinary text, \TeX{} will
complain.  If you're writing a document which will contain a large
number of underscore characters, the prospect of typing
\csx{\_} (or, worse, \csx{textunderscore}) for every one of
them will daunt most ordinary people.

Moderately skilled macro programmers can readily generate a quick hack
to permit typing `\texttt{\_}' to mean `text underscore'.
However, the code \emph{is} somewhat tricky, and more importantly
there are significant points where it's easy to get it wrong.  There
is therefore a package \Package{underscore} which provides a general
solution to this requirement.

There is a problem, though: \acro{OT}1 text fonts don't contain an
underscore character, unless they're in the typewriter version of the
encoding (used by fixed-width fonts such as \texttt{cmtt}).  So either
you must ensure that your underscore characters only occur in text set
in a typewriter font, or you must use a more modern encoding, such as
\acro{T}1, which has the same layout for every font, and thus an
underscore in every font.

If the requirement is only for occasional uses of underscores, it may
be acceptable to use the following construct:
\begin{quote}
\begin{verbatim}
\def\us{\char`\_}
...
\texttt{create\us process}
\end{verbatim}
\end{quote}
The construction isn't in the least robust (in the normal English
sense of the word), but it \emph{is} robust under expansion (i.e., the
\LaTeX{} sense of the word); so use it with care, but don't worry
about section headings and the like.
\begin{ctanrefs}
\item[underscore.sty]\CTANref{underscore}
\end{ctanrefs}

\Question[Q-atsign]{How to type an `@' sign?}

Long ago, some packages used to use the `@' sign as a command, so that
special measures were needed to type it.  While those packages are
still in principle available, few people use them, and those that do
use them have ready access to rather good documentation.

Ordinary people (such as the author of this \acro{FAQ}) need only type
`@'.

\Question[Q-euro]{Typesetting the Euro sign}

The European currency ``Euro'' is represented by a symbol of somewhat
dubious design, but it's an important currency and \AllTeX{} users
need to typeset it.

Note that the Commission of the European Community at first deemed
that the Euro symbol should always be set in a sans-serif font;
fortunately, this eccentric ruling has now been rescinded, and one may
apply best typesetting efforts to making it appear at least slightly
``respectable'' (typographically).

The \acro{TS}1-encoded \acro{TC} fonts provided as part of the \acro{EC} font
distribution provide Euro glyphs.  The fonts are called Text Companion
(\acro{TC}) fonts, and offer the same range
of faces as do the \acro{EC} fonts themselves.  The
\Package{textcomp} package provides a \csx{texteuro} command for
accessing the symbol, which selects a symbol to match the surrounding
text.  The design of the symbol in the \acro{TC} fonts is not
universally loved\dots{}
Nevertheless, use the \acro{TC} font version of the symbol if you are
producing documents using Knuth's Computer Modern Fonts.

The \Package{latin9} input encoding defined by the \Package{inputenc}
package has a euro character defined (character position 164, occupied
in other \acro{ISO} Latin character sets by the ``currency symbol'').
The encoding uses the command \csx{texteuro} for the character; at
present that command is \emph{only} available from the
\Package{textcomp} package.  There is a Microsoft code page position,
too, but standardisation of such things proceeds via rather different
routes and the \LaTeX{} project hasn't yet been given details of the
change.

Outline fonts which contain nothing but Euro symbols are available
(free) from
\href{ftp://ftp.adobe.com/pub/adobe/type/win/all/eurofont.exe}{Adobe}\nobreakspace---
the file is packaged as a \ProgName{Windows} self-extracting
executable, but it may be decoded as a \extension{zip} format archive
on other operating systems.
The \Package{euro} bundle contains metrics, \ProgName{dvips} map
files, and macros (for \plaintex{} and \LaTeX{}), for using these
fonts in documents.  \LaTeX{} users will find two packages in the
bundle: \Package{eurosans} only offers the sans-serif version (to
conform with the obsolete ruling about sans-serif-only symbols; the
package provides the
command \csx{euro}), whereas \Package{europs} matches the Euro symbol
with the surrounding text (providing the command \csx{EUR}).  To use
either package
with the \Package{latin9} encoding, you need to define \csx{texteuro}
as an alias for the euro command the package defines.

The Adobe fonts are probably the best bet for use in non-Computer
Modern environments.  They are apparently designed to fit with Adobe
Times, Helvetica and Courier, but can probably fit with a wider range
of modern fonts.

The \Package{eurofont} package provides a compendious analysis of the
``problem of the euro symbol'' in its documentation, and offers macros
for configuring the source of the glyphs to be used; however, it seems
rather large for everyday use.

The \Package{euro-ce} bundle is a rather pleasing \MF{}-only design
providing Euro symbols in a number of shapes.  The file
\File{euro-ce.tex}, in the distribution, offers hints as to how a
\plaintex{} user might make use of the fonts.

Euro symbols are found in several other places, which we list here for
completeness.

The \Package{marvosym} fonts contain a Euro symbol among many other
good things.
%% ; the font on \acro{CTAN} is not Adobe \ProgName{ATM}
%% compatible, but a compatible version is available free from
%% \href{http://www.YandY.com/download/marvosym.zip}{\YandY{}}.  The font
%% on \acro{CTAN} comes with a set of macros to typeset all the symbols
%% it contains.

Other \MF{}-based bundles containing Euro symbols are to be found in
\Package{china2e} (whose primary aim is Chinese dates and suchlike
matters) and the \Package{eurosym} fonts.
\begin{ctanrefs}
\item[china2e bundle]\CTANref{china2e}
\item[EC fonts]\CTANref{ec}
\item[euro fonts]\CTANref{euro-fonts}
\item[euro-ce fonts]\CTANref{euro-ce}
\item[eurofont.sty]\CTANref{eurofont}
\item[eurosym fonts]\CTANref{eurosym}
\item[marvosym fonts]\CTANref{marvosym-fonts}
\item[textcomp.sty]Part of the \LaTeX{} distribution.
\end{ctanrefs}

\Question[Q-tradesyms]{How to get copyright, trademark, etc.}

The ``\nothtml{Comprehensive symbol list'' (}% beware line break
\Qref{Comprehensive symbol list}{Q-symbols}\latexhtml{)}{''}, lists
the symbol commands \csx{textcopyright},
\csx{textregistered} and \csx{texttrademark}, which are available in
\acro{TS}1-encoded fonts, and which are enabled using the
\Package{textcomp} package.

In fact, all three commands are enabled in default \LaTeX{}, but the
glyphs you get aren't terribly beautiful.  In particular,
\csx{textregistered} behaves oddly when included in bold text (for
example, in a section heading), since it is composed of a small-caps
letter, which typically degrades to a regular shape letter when asked
to set in a bold font.  This means that the glyph becomes a circled
``r'', whereas the proper symbol is a circled ``R''.

This effect is of course avoided by use of \Package{textcomp}.

Another problem arises if you want \csx{textregistered} in a
superscript position (to look similar to \csx{texttrademark}).
Using a maths-mode superscript to do this provokes lots of pointless
errors: you \emph{must} use
\begin{quote}
\begin{verbatim}
\textsuperscript{\textregistered}
\end{verbatim}
\end{quote}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\section{Macro programming}

\subsection{``Generic'' macros and techniques}

\Question[Q-findwidth]{Finding the width of a letter, word, or phrase}

Put the word in a box, and measure the width of the box. For example,
\begin{quote}
\begin{verbatim}
\newdimen\stringwidth
\setbox0=\hbox{hi}
\stringwidth=\wd0
\end{verbatim}
\end{quote}
Note that if the quantity in the \csx{hbox} is a phrase, the actual
measurement only approximates the width that the phrase will occupy in
running text, since the inter-word glue can be adjusted in paragraph
mode.

The same sort of thing is expressed in \LaTeX{} by:
\begin{quote}
\begin{verbatim}
\newlength{\gnat}
\settowidth{\gnat}{\textbf{small}}
\end{verbatim}
\end{quote}
This sets the value of the length command |\gnat| to the width of ``small''
in bold-face text.

\Question[Q-patch]{Patching existing commands}

In the general case (possibly sticking something in the middle of an
existing command) this is difficult.  However, the common requirement,
to add some code at the beginning or the end of an existing command,
is conceptually quite easy.  Suppose we want to define a version of a
command that does some small extension of its original definition: we
would naturally write:
\begin{quote}
\begin{verbatim}
\renewcommand{\splat}{\mumble\splat}
\end{verbatim}
\end{quote}
However, this would not work: a call to \csx{splat} would execute
\csx{mumble}, and the call the redefined \csx{splat} again; this is an
infinite recursive loop, that will quickly exhaust \TeX{}'s memory.

Fortunately, the \TeX{} primitive \csx{let} command comes to our
rescue; it allows us to take a ``snapshot'' of the current state of a
command, which we can then use in the redefinition of the command.
So:
\begin{quote}
\begin{verbatim}
\let\OldSmooth\smooth
\renewcommand{\smooth}{\mumble\OldSmooth}
\end{verbatim}
\end{quote}
effects the required patch, safely.  Adding things at the end of a
command works similarly.  If \csx{smooth} takes arguments, one must
pass them on:
\begin{quote}
\begin{wideversion}
\begin{verbatim}
\renewcommand{\smooth}[2]{\mumble\OldSmooth{#1}{#2}}
\end{verbatim}
\end{wideversion}
\begin{narrowversion}
\begin{verbatim}
\renewcommand{\smooth}[2]%
             {\mumble\OldSmooth{#1}{#2}}
\end{verbatim}
\end{narrowversion}
\end{quote}

The general case may be achieved in two ways.  First, one can use the
\LaTeX{} command \csx{CheckCommand}; this compares an existing command
with the definition you give it, and issues a warning if two don't
match.  Use is therefore:
\begin{quote}
  |\CheckCommand{\complex}{|\meta{original definition}|}|\\
  |\renewcommand{\complex}{|\meta{new definition}|}|
\end{quote}
This technique is obviously somewhat laborious, but if the original
command comes from a source that's liable to change under the control
of someone else, it does at least warn you that your patch is in
danger of going wrong.

Otherwise, \LaTeX{} users may use one of the \Package{patchcmd},
\Package{ted} or \Package{etoolbox} packages.

The \Package{patchcmd} package addresses a slightly simpler task, by
restricting the set of commands that you may patch; you mayn't patch
any command that has an optional argument, though it does deal with
the case of commands defined with \csx{DeclareRobustCommand}.  The
package defines a \csx{patchcommand} command, that takes three
arguments: the command to patch, stuff to stick at the front of its
definition, and stuff to stick on the end of its definition.  So,
after
\begin{quote}
\begin{verbatim}
\def\b{b}
\patchcmd\b{a}{c}
\end{verbatim}
\end{quote}
we will have a new version of \csx{b} defined as ``\texttt{abc}''.

The \Package{ted} package is a `token list editor', and provides a
command \csx{Substitute*} which will patch the contents of a macro,
putting the result in a token-list, or (optionally) using the result
to (re)define a macro.  The package may also be used as a powerful
debugging tool.

The \Package{etoolbox} (which provides user access to \eTeX{}'s
programming facilities) provides a command \csx{patchcmd} which will
perform a ``string substitution'' in a macro's definition.  The
package also provides commands that prepend (\csx{pretocmd}) or append
(\csx{apptocmd}) to the definition of a command.

Finally, we'll briefly consider a package that is (just about)
usable, but not really recommendable.  \Package{Patch} gives you an
ingenious (and difficult to understand) mechanism, and comes as an
old-style \LaTeX{} documented macro file, which can no longer be
processed (as in
\begin{narrowversion}
  generating documentation for a new package~--- \Qref{}{Q-install-doc}).
\end{narrowversion}
\begin{wideversion}
  \Qref{generating documentation for a new package}{Q-install-doc}).
\end{wideversion}
Fortunately, the file (\File{patch.doc}) may be input directly, and
``documentation'' may found by reading the source of the package.
Roughly speaking, one gives the command a set of instructions
analogous to \ProgName{sed} substitutions, and it regenerates the
command thus amended.  Unless you can't do your job any other way, you
had probably best avoid \Package{Patch}.
\begin{ctanrefs}
\item[etoolbox.sty]\CTANref{etoolbox}
\item[patch.doc]\CTANref{patch}
\item[patchcommand.sty]\CTANref{patchcmd}
\item[ted.sty]\CTANref{ted}
\end{ctanrefs}

\Question[Q-compjobnam]{Comparing the ``job name''}

The token \csx{jobname} amusingly produces a sequence of characters
whose category code is 12 (`other'), regardless of what the characters
actually are.  Since one inevitably has to compare a macro with the
contents of another macro (using \csx{ifx}, somewhere) one needs to
create a macro whose expansion looks the same as the expansion of
\csx{jobname}.  We find we can do this with \csx{meaning}, if we strip
the ``\csx{show} command'' prefix.

The full command looks like:
\begin{quote}
\begin{wideversion}
\begin{verbatim}
\def\StripPrefix#1>{}
\def\jobis#1{FF\fi
  \def\predicate{#1}%
  \edef\predicate{\expandafter\StripPrefix\meaning\predicate}%
  \edef\job{\jobname}%
  \ifx\job\predicate
}
\end{verbatim}
\end{wideversion}
\begin{narrowversion}
\begin{verbatim}
\def\StripPrefix#1>{}
\def\jobis#1{FF\fi
  \def\predicate{#1}%
  \edef\predicate{\expandafter\StripPrefix
                    \meaning\predicate}%
  \edef\job{\jobname}%
  \ifx\job\predicate
}
\end{verbatim}
\end{narrowversion}
\end{quote}
And it's used as:
\begin{quote}
\begin{verbatim}
\if\jobis{mainfile}%
  \message{YES}%
\else
  \message{NO}%
\fi
\end{verbatim}
\end{quote}
Note that the command \csx{StripPrefix} need not be defined if you're
using \LaTeX{}~--- there's already an % line break!
\Qref*{internal command}{Q-atsigns} \csx{strip@prefix} that you can
use.

\Question[Q-isitanum]{Is the argument a number?}

\TeX{}'s own lexical analysis doesn't offer the macro programmer
terribly much support: while category codes will distinguish letters
(or what \TeX{} currently thinks of as letters) from everything else,
there's no support for analysing numbers.

The simple-minded solution is to compare numeric characters with the
characters of the argument, one by one, by a sequence of direct tests,
and to declare the argument ``not a number'' if any character fails
all comparisons:
\begin{quote}
\begin{verbatim}
\ifx1#1
\else\ifx2#1
...
\else\ifx9#1
\else\isanumfalse
\fi\fi...\fi
\end{verbatim}
\end{quote}
which one would then use in a tail-recursing macro to gobble an
argument.  One could do slightly better by assuming (pretty safely)
that the digits' character codes are consecutive:
\begin{quote}
\begin{verbatim}
\ifnum`#1<`0 \isanumfalse
\else\ifnum`#1>`9 \isanumfalse
     \fi
\fi
\end{verbatim}
\end{quote}
again used in tail-recursion.  However, these forms aren't very
satisfactory: getting the recursion ``right'' is troublesome (it has a
tendency to gobble spaces in the argument), and in any case \TeX{}
itself has mechanisms for reading numbers, and it would be nice to use
them.

Donald Arseneau's \Package{cite} package offers the following test
for an argument being a strictly positive integer:
\begin{quote}
\begin{verbatim}
\def\IsPositive#1{%
  TT\fi
  \ifcat_\ifnum0<0#1 _\else A\fi
}
\end{verbatim}
\end{quote}
which can be adapted to a test for a non-negative integer thus:
\begin{quote}
\begin{verbatim}
\def\IsNonNegative{%
  \ifcat_\ifnum9<1#1 _\else A\fi
}
\end{verbatim}
\end{quote}
or a test for any integer:
\begin{quote}
\begin{verbatim}
\def\gobbleminus#1{\ifx-#1\else#1\fi}
\def\IsInteger#1{%
  TT\fi
  \ifcat_\ifnum9<1\gobbleminus#1 _\else A\fi
}
\end{verbatim}
\end{quote}
but this surely stretches the technique further than is reasonable.

If we don't care about the sign, we can use \TeX{} to remove the
entire number (sign and all) from the input stream, and then look at
what's left:
\begin{quote}
\begin{narrowversion}
\begin{verbatim}
\def\testnum#1{\afterassignment\testresult
               \count255=#1 \end}
\def\testresult#1\end{\ifx\end#1\end}
\def\IsInteger#1{TT\fi \testnum{#1}}
\end{verbatim}
\end{narrowversion}
\begin{wideversion}
\begin{verbatim}
\def\testnum#1{\afterassignment\testresult\count255=#1 \end}
\def\testresult#1\end{\ifx\end#1\end\isanumtrue\else\isanumfalse\fi}
\end{verbatim}
\end{wideversion}
\end{quote}
(which technique is due to David Kastrup); this can provoke errors.
In a later thread on the same topic, Michael Downes offered:
\begin{quote}
\begin{wideversion}
\begin{verbatim}
\def\IsInteger#1{%
  TT\fi
  \begingroup \lccode`\-=`\0 \lccode`+=`\0
    \lccode`\1=`\0 \lccode`\2=`\0 \lccode`\3=`\0
    \lccode`\4=`\0 \lccode`\5=`\0 \lccode`\6=`\0
    \lccode`\7=`\0 \lccode`\8=`\0 \lccode`\9=`\0
  \lowercase{\endgroup
    \expandafter\ifx\expandafter\delimiter
    \romannumeral0\string#1}\delimiter
}
\end{verbatim}
\end{wideversion}
\begin{narrowversion}
\begin{verbatim}
\def\IsInteger#1{%
  TT\fi
  \begingroup \lccode`\-=`\0 \lccode`+=`\0
    \lccode`\1=`\0 \lccode`\2=`\0
    \lccode`\3=`\0 \lccode`\4=`\0
    \lccode`\5=`\0 \lccode`\6=`\0
    \lccode`\7=`\0 \lccode`\8=`\0
    \lccode`\9=`\0
  \lowercase{\endgroup
    \expandafter\ifx\expandafter\delimiter
    \romannumeral0\string#1}\delimiter
}
\end{verbatim}
\end{narrowversion}
\end{quote}
which relies on \csx{romannumeral} producing an empty result if its
argument is zero.  Sadly, this technique has the unfortunate property
that it accepts simple expressions such as `\texttt{1+2-3}'; this
could be solved by an initial \csx{gobbleminus}-like construction.

All the complete functions above are designed to be used in \TeX{}
conditionals written ``naturally''~--- for example:
\begin{quote}
\begin{verbatim}
\if\IsInteger{<subject of test>}%
  <deal with integer>%
\else
  <deal with non-integer>%
\fi
\end{verbatim}
\end{quote}
The \LaTeX{} \Class{memoir} class has an internal command of its own,
\cmdinvoke*{checkifinteger}{num}, that sets the conditional command
\csx{ifinteger} according to whether the argument was an integer.

Of course, all this kerfuffle would be (essentially) void if there was
a simple means of ``catching'' \TeX{} errors.  Imagining an
error-catching primitive \csx{ifnoerror}, one might write:
\begin{quote}
\begin{verbatim}
\def\IsInteger#1{%
  TT%
  \ifnoerror
    \tempcount=#1\relax
% carries on if no error
    \expandafter\iftrue
  \else
% here if there was an error
    \expandafter\iffalse
  \fi
}
\end{verbatim}
\end{quote}
thus using \TeX{}'s own integer-parsing code to do the check.  It's a
pity that such a mechanism was never defined (it could be that it's
impossible to program within \TeX{}!).
\begin{ctanrefs}
\item[memoir.cls]\CTANref{memoir}
\end{ctanrefs}

\Question[Q-hash]{Defining macros within macros}

The way to think of this is that |##| gets replaced by |#| in just the
same way that |#1| gets replaced by `whatever is the first argument'.

So if you define a macro and use it as:
\begin{quote}
\begin{verbatim}
\def\a#1{+++#1+++#1+++#1+++}  \a{b}
\end{verbatim}
\end{quote}
the macro expansion produces `+++b+++b+++b+++',
which people find normal.  However, if we now replace part of the macro:
\begin{quote}
\begin{verbatim}
\def\a#1{+++#1+++\def\x #1{xxx#1}}
\end{verbatim}
\end{quote}
\cmdinvoke{a}{b} will expand to `+++b+++|\def\x b{xxxb}|'.  This
defines \csx{x} to be a macro \emph{delimited} by |b|, and taking no
arguments, which people may find strange, even though it is just a
specialisation of the example above.  If you want \csx{a} to
define \csx{x} to be a macro with one argument, you need to write:
\begin{quote}
\begin{verbatim}
\def\a#1{+++#1+++\def\x ##1{xxx##1}}
\end{verbatim}
\end{quote}
and \csx{a{b}} will expand to 
`+++b+++|\def\x #1{xxx#1}|', because |#1| gets replaced by `b'
and |##| gets replaced by |#|.

To nest a definition inside a definition inside a definition then
you need |####1|, as at each stage |##| is replaced by
|#|.  At the next level you need 8~|#|s each time, and so on.

\Question[Q-spinmacro]{Spaces in macros}

It's very easy to write macros that produce space in the typeset
output where it's neither desired nor expected.  Spaces introduced by
macros are particularly insidious because they don't amalgamate with
spaces around the macro (unlike consecutive spaces that you
type), so your output can have a single bloated space that proves
to be made up of two or even more spaces that haven't amalgamated.
And of course, your output can also have a space where none was wanted
at all.

Spaces are produced, inside a macro as elsewhere, by space or tab
characters, or by end-of-line characters.  There are two basic rules
to remember when writing a macro: first, the rules for ignoring spaces
when you're typing macros are just the same as the rules that apply
when you're typing ordinary text, and second, rules for ignoring
spaces do \emph{not} apply to spaces produced while a macro is being
obeyed (``expanded'').

Spaces are ignored in vertical mode (between paragraphs), at the
beginning of a line, and after a command name.  Since sequences of
spaces are collapsed into one, it `feels as if' spaces are ignored if
they follow another space.  Space can have syntactic meaning after
certain sorts of non-braced arguments (e.g., \emph{count} and
\emph{dimen} variable assignments in \plaintex{}) and after certain
control words (e.g., in \csx{hbox} |to|, so again we have instances
where it `feels as if' spaces are being ignored when they're merely
working quietly for their living.

Consider the following macro, fairly faithfully adapted from one that
appeared on \Newsgroup{comp.text.tex}:
\begin{narrowversion}
\begin{quote}
\begin{verbatim}
\newcommand{\stline}[1]
  { \bigskip \makebox[2cm]{ \textbf{#1} } }
\end{verbatim}
\end{quote}
(the original appeared on a single line: it's wrapped here to fit in
the printed \acro{FAQ}'s narrow columns).

\noindent
\end{narrowversion}
\begin{wideversion}
\begin{quote}
\begin{verbatim}
\newcommand{\stline}[1]{ \bigskip \makebox[2cm]{ \textbf{#1} } }
\end{verbatim}
\end{quote}
\end{wideversion}
The macro definition contains five spaces:
\begin{itemize}
\item after the opening |{| of the macro body; this space will be
  ignored, not because ``because the macro appears at the start of a
  line'', but rather because the macro was designed to operate between
  paragraphs
\item after \csx{bigskip}; this space will be ignored (while the macro
  is being defined) because it follows a command name
\item after the |{| of the mandatory argument of \csx{makebox}; even
  though this space will inevitably appear at the start of an output
  line, it will \emph{not} be ignored
\item after the |}| closing the argument of \csx{textbf}; this space
  will not be ignored, but may be overlooked if the argument is well
  within the |2cm| allowed for it
\item after the |}| closing the mandatory argument of \csx{makebox};
  this space will not be ignored
\end{itemize}
The original author of the macro had been concerned that the starts of
his lines with this macro in them were not at the left margin, and
that the text appearing after the macro wasn't always properly
aligned.  These problems arose from the space at the start of the
mandatory argument of \csx{makebox} and the space immediately after the
same argument.  He had written his macro in that way to emphasise the
meaning of its various parts; unfortunately the meaning was rather
lost in the problems the macro caused.

The principal technique for suppressing spaces is the use of
\texttt{\textpercent} characters: everything after a
\texttt{\textpercent} is ignored, even the end of line itself (so
that not even the end of line can contribute an unwanted space).  The
secondary technique is to ensure that the end of line is preceded by a
command name (since the end of line behaves like a space, it will be
ignored following a command name).  Thus the above command would be
written (by an experienced programmer with a similar eye to
emphasising the structure):
\begin{quote}
\begin{verbatim}
\newcommand{\stline}[1]{%
  \bigskip
  \makebox[2cm]{%
    \textbf{#1}\relax
  }%
}
\end{verbatim}
\end{quote}
Care has been taken to ensure that every space in the revised
definition is ignored, so none appears in the output.  The revised
definition takes the ``belt and braces'' approach, explicitly dealing
with every line ending (although, as noted above, a space introduced
at the end of the first line of the macro would have been ignored in
actual use of the macro.  This is the best technique, in fact~--- it's
easier to blindly suppress spaces than to analyse at every point
whether you actually need to.  Three techniques were used to suppress
spaces:
\begin{itemize}
\item placing a \texttt{\textpercent} character at the end of a line
  (as in the 1st, 3rd and 5th lines),
\item ending a line `naturally' with a control sequence, as in line 2,
  and
\item ending a line with an `artificial' control sequence, as in line
  4; the control sequence in this case (\csx{relax}) is a no-op in many
  circumstances (as here), but this usage is deprecated~--- a
  \texttt{\textpercent} character would have been better.
\end{itemize}
Beware of the (common) temptation to place a space \emph{before} a
\texttt{\textpercent} character: if you do this you might as well omit
the \texttt{\textpercent} altogether.

In ``real life'', of course, the spaces that appear in macros are far
more cryptic than those in the example above.  The most common spaces
arise from unprotected line ends, and this is an error that
occasionally appears even in macros written by the most accomplished
programmers.

\Question[Q-moren9]{How to break the 9-argument limit}

If you think about it, you will realise that Knuth's command
definition syntax:
\begin{quote}
\begin{verbatim}
\def\blah#1#2 ... #9{<macro body>}
\end{verbatim}
\end{quote}
is intrinsically limited to just 9 arguments.  There's no direct way
round this: how would you express a 10th argument?~--- and ensure that
the syntax didn't gobble some other valid usage?

If you really must have more than 9 arguments, the way to go is:
\begin{quote}
\begin{verbatim}
\def\blah#1#2 ... #9{%
  \def\ArgI{{#1}}%
  \def\ArgII{{#2}}%
  ...
  \def\ArgIX{{#9}}%
  \BlahRelay
}
\def\BlahRelay#1#2#3{%
  % arguments 1-9 are now in
  %   \ArgI-\ArgIX
  % arguments 10-12 are in
  %   #1-#3
  <macro body>%
}
\end{verbatim}
\end{quote}
This technique is easily extendible by concert pianists of the \TeX{}
keyboard, but is really hard to recommend.

\LaTeX{} users have the small convenience of merely giving a number of
arguments in the \csx{newcommand} that defines each part of the
relaying mechanism: Knuth's restriction applies to \csx{newcommand}
just as it does to \csx{def}.  However, \LaTeX{} users also have the
way out of such barbarous command syntax: the \Package{keyval}
package.  With \Package{keyval}, and a bit of programming, one can
write really quite sophisticated commands, whose invocation might look
like:
\begin{quote}
\begin{verbatim}
\flowerinstance{species=Primula veris,
  family=Primulaceae,
  location=Coldham's Common,
  locationtype=Common grazing land,
  date=1995/04/24,
  numplants=50,
  soiltype=alkaline
}
\end{verbatim}
\end{quote}
The merit of such verbosity is that it is self-explanatory: the typist
doesn't have to remember that argument twelve is |soiltype|, and so
on: the commands may be copied from field notes quickly and
accurately.
\begin{ctanrefs}
\item[keyval.sty]Distributed as part of \CTANref{graphics}
\end{ctanrefs}

\Question[Q-activechars]{Defining characters as macros}

Single characters can act as macros (defined commands), and both
\plaintex{} and \LaTeX{} define the character
``\texttt{\textasciitilde}'' as a ``non-breakable space''.  A
character is made definable, or ``active'', by setting its
\emph{category code} (catcode) to be \csx{active} (13):
|\catcode`_=\active|.

Any character could, in principle, be activated this way and defined
as a macro (\csx{def}\texttt{\_\{}\csx{\_}\texttt{\}}~--- the simple answer to
% beware line break
\Qref[question]{using underscores}{Q-underscore}), but you must be
wary: whereas people expect an active tilde, other active characters
may be unexpected and interact badly with other macros.  Furthermore,
by defining an active character, you preclude the character's use for
other purposes, and there are few characters ``free'' to be subverted
in this way.

To define the character ``|z|'' as a command, one would say something
like:
\begin{quote}
\begin{verbatim}
\catcode`\z=\active
\def z{Yawn, I'm tired}%
\end{verbatim}
\end{quote}
and each subsequent ``|z|'' in the text would become a yawn. This would be
an astoundingly bad idea for most documents, but might have special
applications. (Note that, in ``|\def z|'', ``|z|'' is no longer interpreted as
a letter; the space is therefore not necessary~--- ``|\defz|'' would do; we
choose to retain the space, for what little clarity we can manage.)
Some \LaTeX{} packages facilitate such definitions. For example, the
\Package{shortvrb} package with its \csx{MakeShortVerb} command.

\TeX{} uses category codes to interpret characters as they are read 
from the input.
% beware line break
\emph{Changing a catcode value will not affect characters that have already been read}.
Therefore, it is best if characters have fixed category codes for the
duration of a document.  If catcodes are changed for particular
purposes (the \csx{verb} command does this), then the altered
characters will not be interpreted properly when they  appear in the
argument to another command (as, for example, in
% beware line-break
\htmlonly{``}\Qref[question]{\csx{verb} in command arguments}{Q-verbwithin}\htmlonly{''}).
An exemplary case is the \Package{doc} package, which processes .dtx
files using the \Package{shortvrb} package to define
\texttt{\textbar\dots{}\textbar} as a shorthand for
\csx{verb}\texttt{\textbar\dots{}\textbar}. But \texttt{\textbar} is
also used in the preambles of tabular environments, so that tables in
\extension{dtx} files can only have vertical line separation between
columns by employing special measures of some sort.

Another consequence is that catcode assignments made
in macros often don't work as expected % beware linebreak
(\htmlonly{see ``}\Qref{Active characters in command arguments}{Q-actinarg}\htmlonly{''}).
For example, the definition
\begin{quote}
\begin{verbatim}
\def\mistake{%
\catcode`_=\active
\def_{\textunderscore\-}%
}
\end{verbatim}
\end{quote}
does not work because it attempts to define an ordinary |_| character:
When the macro is used, the category change does not apply to the 
underscore character already in the macro definition.  Instead, one may
use:
\begin{quote}
\begin{verbatim}
\begingroup
\catcode`_=\active
\gdef\works{%    note the global \gdef
  \catcode`_=\active
  \def_{\textunderscore\-}%
}
\endgroup
\end{verbatim}
\end{quote}
The alternative (``tricksy'') way of creating such an isolated
definition depends on the curious properties of \csx{lowercase}, which
changes characters without altering their catcodes.  Since there is
always \emph{one} active character (``\texttt{\textasciitilde}''), we
can fool \csx{lowercase} into patching up a definition without ever
explicitly changing a catcode:
\begin{quote}
\begin{verbatim}
\begingroup
  \lccode`\~=`\_
  \lowercase{\endgroup
    \def~{\textunderscore\-}%
  }%
\end{verbatim}
\end{quote}
The two definitions have the same overall effect (the character is
defined as a command, but the character does not remain active),
except that the first defines a \csx{global} command.

For active characters to be used only in maths mode, it is much better
to leave the character having its ordinary catcode, but assign it a
special active \emph{maths code}, as with
\begin{quote}
\begin{verbatim}
\begingroup
  \lccode`~=`x
  \lowercase{\endgroup
    \def~{\times}%
  }%
\mathcode`x="8000
\end{verbatim}
\end{quote}
The special character does not need to be redefined whenever it is
made active~--- the definition of the command persists even if the
character's catcode reverts to its original value; the definition
becomes accessible again if the character once again becomes active.
\begin{ctanrefs}
\item[doc.sty]Distributed as part of the source of \LaTeX{}, \CTANref{latex}
\item[shortvrb.sty]Distributed as part of \CTANref{2etools}
\end{ctanrefs}


\Question[Q-actinarg]{Active characters in command arguments}

Occasionally, it's nice to make one or two characters active in the
argument of a command, to make it easier for authors to code the
arguments.

Active characters \emph{can} be used safely in such situations; but
care is needed.

An example arose while this answer was being considered: an aspirant
macro writer posted to \Newsgroup{comp.text.tex} asking for help to
make |#| and |b| produce musical sharp and flat signs, respectively,
in a macro for specifying chords.

The first problem is that both |#| and |b| have rather important uses
elsewhere in \TeX{} (to say the least!), so that the characters can
only be made active while the command is executing.

Using the techniques discussed in % beware line break, next line
\htmlonly{``}\Qref[question]{characters as commands}{Q-activechars}\htmlonly{''},
we can define:
\begin{quote}
\begin{verbatim}
\begingroup
  \catcode`\#=\active
  \gdef#{$\sharp$}
\endgroup
\end{verbatim}
\end{quote}
and:
\begin{quote}
\begin{verbatim}
\begingroup
  \lccode`\~=`\b
  \lowercase{\endgroup
    \def~{$\flat$}%
  }
\end{verbatim}
\end{quote}
The second problem is one of timing: the command has to make each
character active \emph{before} its arguments are read: this means that
the command can't actually ``have'' arguments itself, but must be
split in two.  So we write:
\begin{quote}
\begin{verbatim}
\def\chord{%
  \begingroup
    \catcode`\#=\active
    \catcode`\b=\active
    \Xchord
}
\def\Xchord#1{%
    \chordfont#1%
  \endgroup
}
\end{verbatim}
\end{quote}
and we can use the command as \cmdinvoke{chord}{F\#} or
\cmdinvoke{chord}{Bb minor}.

Two features of the coding are important:
\begin{itemize}
\item \csx{begingroup} in \csx{chord} opens a group that is closed by
  \csx{endgroup} in \csx{Xchord}; this group limits the change of
  category codes, which is the \emph{raison d'\^etre} of the whole
  exercise.
\item Although |#| is active while \csx{Xchord} is executed, it's
  \emph{not} active when it's being defined, so that the use of |#1|
  doesn't require any special attention.
\end{itemize}

Note that the technique used in such macros as \csx{chord}, here, is
analogous to that used in such commands as \csx{verb}; and, in just the
same way as \csx{verb} (see
% beware breaking long line
\htmlonly{``}\Qref[question]{\csx{verb} doesn't work in arguments}{Q-verbwithin}\htmlonly{''}),
\csx{chord} won't work inside the argument of another command (the
error messages, if they appear at all, will probably be rather odd).


\Question[Q-csname]{Defining a macro from an argument}

It's common to want a command to create another command: often one
wants the new command's name to derive from an argument.  \LaTeX{}
does this all the time: for example, \csx{newenvironment} creates
start- and end-environment commands whose names are derived from the
name of the environment command.

The (seemingly) obvious approach:
\begin{quote}
\begin{verbatim}
\def\relay#1#2{\def\#1{#2}}
\end{verbatim}
\end{quote}
doesn't work (the \TeX{} engine interprets it
as a rather strange redefinition of |\#|).  The trick is to use
\csx{csname}, which is a \TeX{} primitive for generating command names
from random text, together with \csx{expandafter}.  The definition
above should read:
\begin{quote}
\begin{verbatim}
\def\relay#1#2{%
  \expandafter\def\csname #1\endcsname{#2}%
}
\end{verbatim}
\end{quote}
With this definition, \cmdinvoke{relay}{blah}{bleah} is equivalent to
\csx{def}\cmdinvoke{blah}{bleah}.

Note that the definition of \csx{relay} omits the braces round the
`command name' in the \csx{newcommand} it executes.  This is
because they're not necessary (in fact they seldom are), and in this
circumstance they make the macro code slightly more tedious.

The name created need not (of course) be \emph{just} the argument:
\begin{quote}
\begin{narrowversion}
\begin{verbatim}
\def\newrace#1#2#3{\expandafter\def
    \csname start#1\endcsname{%
      #2%
  }%
  \expandafter\def
    \csname finish#1\endcsname{%
      #3%
  }%
}
\end{verbatim}
\end{narrowversion}
\begin{wideversion}
\begin{verbatim}
\def\newrace#1#2#3{%
  \expandafter\def\csname start#1\endcsname{%
    #2%
  }%
  \expandafter\def\csname finish#1\endcsname{%
    #3%
  }%
}
\end{verbatim}
\end{wideversion}
\end{quote}
With commands
\begin{quote}
\begin{verbatim}
\def\start#1{\csname start#1\endcsname}
\def\finish#1{\csname finish#1\endcsname}
\end{verbatim}
\end{quote}
these `races' could behave a bit like \LaTeX{} environments.

\Question[Q-cvtlatex]{Transcribing \LaTeX{} command definitions}

At several places in this \acro{FAQ}, questions are answered in terms
of how to program a \LaTeX{} macro.  Sometimes, these macros might
also help users of \plaintex{} or other packages; this answer
attempts to provide a rough-and-ready guide to transcribing such macro
definitions for use in other packages.

The reason \LaTeX{} has commands that replace \csx{def}, is that
there's a general philosophy within \LaTeX{} that the user should be
protected from himself: the user has different commands according to
whether the command to be defined exists (\csx{renewcommand}) or not
(\csx{newcommand}), and if its status proves not as the user expected,
an error is reported.  A third definition command,
\csx{providecommand}, only defines if the target is not already
defined; \LaTeX{} has no direct equivalent of \csx{def}, which ignores
the present state of the command.  The final command of this sort is
\csx{DeclareRobustCommand}, which creates a command which is ``robust''
(i.e., will not expand if subjected to \LaTeX{} ``protected
expansion''); from the \plaintex{} user's point of view,
\csx{DeclareRobustCommand} should be treated as a non-checking version
of \csx{newcommand}.

\LaTeX{} commands are, by default, defined \csx{long}; an optional \texttt{*}
between the \csx{newcommand} and its (other) arguments specifies that
the command is \emph{not} to be defined \csx{long}.  The \texttt{*} is
detected by a command \csx{@ifstar} which uses \csx{futurelet} to switch
between two branches, and gobbles the \texttt{*}: \LaTeX{} users are
encouraged to think of the \texttt{*} as part of the command name.

\LaTeX{}'s checks for unknown command are done by \csx{ifx} comparison
of a \csx{csname} construction with \csx{relax}; since the command name
argument is the desired control sequence name, this proves a little
long-winded.  Since \texttt{\#1} is the requisite argument, we have:
\begin{quote}
\begin{narrowversion}
\begin{verbatim}
\expandafter\ifx
  \csname
    \expandafter\@gobble\string#1%
  \endcsname
  \relax
    ...
\end{verbatim}
\end{narrowversion}
\begin{wideversion}
\begin{verbatim}
\expandafter\ifx
  \csname\expandafter\@gobble\string#1\endcsname
  \relax
    ...
\end{verbatim}
\end{wideversion}
\end{quote}
(\csx{@gobble} simply throws away its argument).

The arguments of a \LaTeX{} command are specified by two optional
arguments to the defining command: a count of arguments (0--9: if the
count is 0, the optional count argument may be omitted), and a default
value for the first argument, if the defined command's first argument
is to be optional.  So:
\begin{quote}
\begin{verbatim}
\newcommand\foo{...}
\newcommand\foo[0]{...}
\newcommand\foo[1]{...#1...}
\newcommand\foo[2][boo]{...#1...#2...}
\end{verbatim}
\end{quote}
In the last case, \csx{foo} may be called as \cmdinvoke{foo}{goodbye},
which is equivalent to \cmdinvoke{foo}[boo]{goodbye} (employing the
default value given for the first argument), or as
\cmdinvoke{foo}[hello]{goodbye} (with an explicit first argument).

Coding of commands with optional arguments is exemplified by the
coding of the last \csx{foo} above:
\begin{quote}
\begin{verbatim}
\def\foo{\futurelet\next\@r@foo}
\def\@r@foo{\ifx\next[%
    \let\next\@x@foo
  \else
    \def\next{\@x@foo[boo]}%
  \fi
  \next
}
\def\@x@foo[#1]#2{...#1...#2...}
\end{verbatim}
\end{quote}

\Question[Q-empty]{Detecting that something is empty}

Suppose you need to know that the argument of your command is empty:
that is, to distinguish between \cmdinvoke{cmd}{\relax} % \relax doesn't print
and \cmdinvoke{cmd}{blah}.  This is pretty simple:
\begin{quote}
\begin{verbatim}
\def\cmd#1{%
  \def\tempa{}%
  \def\tempb{#1}%
  \ifx\tempa\tempb
    <empty case>
  \else
    <non-empty case>
  \fi
}
\end{verbatim}
\end{quote}
The case where you want to ignore an argument that consists of nothing
but spaces, rather than something completely empty, is more tricky.
It's solved in the code fragment \Package{ifmtarg}, which defines
commands \csx{@ifmtarg} and \csx{@ifnotmtarg}, which examine their
first argument, and select (in opposite directions) their second or
third argument.  The package's code also appears in the \LaTeX{}
\Class{memoir} class.

\Package{Ifmtarg} makes challenging reading; there's also a discussion of the
issue in number two of the ``around the bend'' articles by the late
lamented Mike Downes.
\begin{ctanrefs}
\item[\nothtml{\rmfamily}Around the bend series]\CTANref{aro-bend}
\item[ifmtarg.sty]\CTANref{ifmtarg}
\item[memoir.cls]\CTANref{memoir}
\end{ctanrefs}

\Question[Q-ifpdf]{Am I using \PDFTeX{}?}

It's often useful to know whether your macros are operating within
\PDFTeX{} or within (``normal'') \TeX{}; getting the right answer is
surprisingly tricky.

Suppose you need to test whether your output will be \acro{PDF} or
\acro{DVI}.  The natural thing is to check whether you have access to
some \PDFTeX{}-only primitive; a good one to try (not least because it
was present in the very first releases of \PDFTeX{}) is
\csx{pdfoutput}.  So you try
\begin{quote}
\begin{verbatim}
\ifx\pdfoutput\undefined
  <not running PDFTeX>
\else
  <running PDFTeX>
\fi
\end{verbatim}
\end{quote}
Except that neither branch of this conditional is rock-solid.  The
first branch can be misleading, since the ``awkward'' user could have
written:
\begin{quote}
\begin{verbatim}
\let\pdfoutput\undefined
\end{verbatim}
\end{quote}
so that your test will falsely choose the first alternative.  While
this is a theoretical problem, it is unlikely to be a major one.

More important is the user who loads a package that uses
\LaTeX{}-style testing for the command name's existence (for example,
the \LaTeX{} \Package{graphics} package, which is useful even to the
\plaintex{} user).  Such a package may have gone ahead of you, so the
test may need to be elaborated:
\begin{quote}
\begin{verbatim}
\ifx\pdfoutput\undefined
  <not running PDFTeX>
\else
  \ifx\pdfoutput\relax
    <not running PDFTeX>
  \else
    <running PDFTeX>
  \fi
\fi
\end{verbatim}
\end{quote}
If you only want to know whether some \PDFTeX{} extension (such as
marginal kerning) is present, you can stop at this point: you know as
much as you need.

However, if you need to know whether you're creating \acro{PDF}
output, you also need to know about the value of \csx{pdfoutput}:
\begin{quote}
\begin{verbatim}
\ifx\pdfoutput\undefined
  <not running PDFTeX>
\else
  \ifx\pdfoutput\relax
    <not running PDFTeX>
  \else
    <running PDFTeX, with...>
    \ifnum\pdfoutput>0
      <...PDF output>
    \else
      <...DVI output>
    \fi
  \fi
\fi
\end{verbatim}
\end{quote}
The above is, in essence, what Heiko Oberdiek's \Package{ifpdf}
package does; the reasoning is the \acro{FAQ}'s interpretation of
Heiko's explanation.
\begin{ctanrefs}
\item[ifpdf.sty]Distributed with Heiko Oberdiek's packages \CTANref{oberdiek}
\end{ctanrefs}

\Question[Q-subverttoks]{Subverting a token register}

A common requirement is to ``subvert'' a token register that other
macros may use.  The requirement arises when you want to add something
to a system token register (\csx{output} or \csx{every*}), but know
that other macros use the token register, too.  (A common requirement
is to work on \csx{everypar}, but \LaTeX{} changes \csx{everypar} at
every touch and turn.)

The following technique, due to David Kastrup, does what you need, and
allows an independent package to play the exact same game:
\begin{quote}
\begin{wideversion}
\begin{verbatim}
\let\mypkg@@everypar\everypar
\newtoks\mypkg@everypar
\mypkg@everypar\expandafter{\the\everypar}
\mypkg@@everypar{\mypkgs@ownstuff\the\mypkg@everypar}
\def\mypkgs@ownstuff{%
  <stuff to do at the start of the token register>%
}
\let\everypar\mypkg@everypar
\end{verbatim}
\end{wideversion}
\begin{narrowversion}
\begin{verbatim}
\let\mypkg@@everypar\everypar
\newtoks\mypkg@everypar
\mypkg@everypar\expandafter{\the\everypar}
\mypkg@@everypar{\mypkgs@ownstuff
                      \the\mypkg@everypar}
\def\mypkgs@ownstuff{%
  <stuff to do at the start of
                      the token register>%
}
\let\everypar\mypkg@everypar
\end{verbatim}
\end{narrowversion}
\end{quote}
As you can see, the package (\Package{mypkg})
\begin{itemize}
\item creates an alias for the existing ``system'' \csx{everypar}
  (which is frozen into any surrounding environment, which will carry
  on using the original);
\item creates a token register to subvert \csx{everypar} and
  initialises it with the current contents of \csx{everypar};
\item sets the ``old'' \csx{everypar} to execute its own extra code,
  as well as the contents of its own token register;
\item defines the macro for the extra code; and
\item points the token \csx{everypar} at the new token register.
\end{itemize}
and away we go.

The form \csx{mypkg@...} is (sort of) blessed for \LaTeX{} package
internal names, which is why this example uses macros of that form.

\Question[Q-isdef]{Is this command defined?}

Macro sets from the earliest days of \TeX{} programming may be
observed to test whether commands exist by using
\begin{quote}
\csx{ifx} \csx{}\texttt{\emph{command}} \csx{undefined} \meta{stuff} \dots{}
\end{quote}
(which of course actually tests that the command \emph{doesn't}
exist).  \LaTeX{} programmers can make use of the internal command
\begin{quote}
  \cmdinvoke*{@ifundefined}{cmd name}{action1}{action2}
\end{quote}
which executes \texttt{action1} if the command is undefined, and
\texttt{action2} if it is defined
(\emph{cmd name} is the command name only, omitting the `|\|' character).

The \csx{@ifundefined} command is based on the sequence
\begin{quote}
\begin{narrowversion}
\begin{verbatim}
\expandafter
    \ifx\csname cmd name\endcsname\relax
\end{verbatim}
\end{narrowversion}
\begin{wideversion}
\begin{verbatim}
\expandafter \ifx \csname cmd name\endcsname \relax
\end{verbatim}
\end{wideversion}
\end{quote}
which relies on the way \csx{csname} works: if the command doesn't
exist, it simply creates it as an alias for \csx{relax}.

So: what is wrong with these techniques?

Using \csx{undefined} blithely assumes that the command is indeed not
defined.  This isn't entirely safe; one could make the name more
improbable, but that may simply make it more difficult to spot a
problem when things go wrong.  \LaTeX{} programmers who use the
technique will typically employ \csx{@undefined}, adding a single
level of obscurity.

The \csx{@ifundefined} mechanism has the unfortunate property of
polluting the name space: each test that turns out undefined adds a
name to the set \TeX{} is holding, and often all those ``\csx{relax}''
names serve no purpose whatever.  Even so (sadly) there are places in
the code of \LaTeX{} where the existence of the \csx{relax} is relied
upon, after the test, so we can't get away from \csx{@ifundefined}
altogether.

David Kastrup offers the (rather tricky)
\begin{quote}
\begin{wideversion}
\begin{verbatim}
{\expandafter}\expandafter\ifx \csname cmd name\endcsname\relax ...
\end{verbatim}
\end{wideversion}
\begin{narrowversion}
\begin{verbatim}
{\expandafter}\expandafter
    \ifx \csname cmd name\endcsname \relax ...
\end{verbatim}
\end{narrowversion}
\end{quote}
which ``creates'' the \csx{relax}-command inside the group of the first
\csx{expandafter}, therefore forgets it again once the test is done.
The test is about as good as you can do with macros.

The \Qref*{\eTeX{} system}{Q-etex} system comes to our help here: it
defines two new primitives:
\begin{itemize}
\item \csx{ifdefined}, which tests whether a thing is defined (the
  negative of comparing with \csx{undefined}, as it were), and
\item \csx{ifcsname} \texttt{cmd name}\csx{endcsname}, which does the
  negative of \csx{@ifundefined} without the \csx{relax}-command
  side-effect.
\end{itemize}
So, in an \eTeX{}-based system, the following two conditional clauses do
the same thing:
\begin{quote}
\begin{verbatim}
\ifdefined\foo
  \message{\string\foo\space is defined}%
\else
  \message{no command \string\foo}%
\fi
%
\ifcsname foo\endcsname
  \message{\string\foo\space is defined}%
\else
  \message{no command \string\foo}%
\fi
\end{verbatim}
\end{quote}
However, after using the \LaTeX{}
\cmdinvoke{@ifundefined}{foo}\dots{}, the conditionals will detect the
command as ``existing'' (since it has been \csx{let} to \csx{relax});
so it is important not to mix mechanisms for detecting the state of a
command.

Since most distributions nowadays use \eTeX{} as their base executable
for most packages, these two primitives may be expected appear widely
in new macro packages.

\subsection{\LaTeX{} macro tools and techniques}

\Question[Q-plninltx*]{Using Plain or primitive commands in \LaTeX{}}

It's well-known that \LaTeX{} commands tend to be more complex, and to
run more slowly than, any \plaintex{} (or primitive) command that they
replace.  There is therefore great temptation not to use \LaTeX{}
commands when macro programming.  Nevertheless, the general rule is
that you should use \LaTeX{} commands, if there are seeming
equivalents.  The exception is when you are sure you know the
differences between the two commands and you know that you need the
\plaintex{} version.  So, for example, use \csx{mbox} in place of \csx{hbox}
unless you know that the extras that \LaTeX{} provides in \csx{mbox}
would cause trouble in your application.  Similarly, use
\csx{newcommand} (or one of its relatives) unless you need one of the
constructs that cannot be achieved without the use of \csx{def} (or friends).

As a general rule, any \LaTeX{} text command will start a new
paragraph if necessary; this isn't the case with \plaintex{}
commands, a fact which has a potential to confuse.

The commands \csx{smallskip}, \csx{medskip} and \csx{bigskip} exist both
in \plaintex{} and \LaTeX{}, but behave slightly differently: in
\plaintex{} they terminate the current paragraph, but in \LaTeX{} they 
don't.  The command \csx{line} is part of picture mode in \LaTeX{},
whereas it's defined as ``\csx{hbox}\texttt{ to }\csx{hsize}'' in
\plaintex{}. (There's no equivalent for users of the \plaintex{} command in
\LaTeX{}: an equivalent appears as the internal command \csx{@@line}).

Maths setting shows a case where the \LaTeX{} version \emph{is}
essentially equivalent to the \TeX{} primitive commands: the \LaTeX{}
\csx{(}\texttt{\ ...\ }\csx{)} does essentially no different to the
\TeX{} \texttt{\$\ ...\ \$}
(except for checking that you're not attempting to open a maths
environment when you're already in one, or vice versa).  % ! line break
However, \csx{[}\texttt{\ ...\ }\csx{]} \emph{isn't} the same as 
\texttt{\$\$\ ...\ \$\$}: the \TeX{} version, used
in \LaTeX{}, can miss the effect of the class option \pkgoption{fleqn}.

Font handling is, of course, wildly different in \plaintex{} and
\LaTeX{}.  \plaintex{}'s font loading command
(\csx{font}\csx{foo=}\meta{fontname}) and its \LaTeX{} equivalent
(\csx{newfont}) should be avoided wherever possible.  They are only
safe in the most trivial contexts, and are potential sources of great
confusion in many circumstances.   Further discussion of this issue
may be found in ``\Qref*{What's wrong with \csx{newfont}?}{Q-newfont*}''.
%%
%% Consider \csx{vskip} (or \plaintex{} users of it like \csx{medskip})
%% \emph{vs}.\nothtml{\@} \csx{vspace} or \csx{vspace*}, but most
%% especially \csx{addvspace}.
%% \begin{ctanrefs}
%% \item[fntguide.pdf]\CTANref{fntguide.pdf}
%% \item[fntguide.tex]Distributed with \CTANref{latex}
%% \end{ctanrefs}

\Question[Q-atsigns]{\csx{@} and \texttt{@} in macro names}

Macro names containing \texttt{@} are \emph{internal} to \LaTeX{}, and
without special treatment just don't work in ordinary use.  A nice
example of the problems caused is discussed in % ! beware line break
\Qref*{\csx{@} in vertical mode}{Q-atvert}''.

The problems users see are caused by copying bits of a class
(\extension{cls} file) or 
package (\extension{sty} file) into a document, or by including a class or
package file into a \LaTeX{} document by some means other than
\csx{documentclass} or \csx{usepackage}.  \LaTeX{} defines internal
commands whose names contain the character \texttt{@} to
avoid clashes between its internal names and names that we would
normally use in our documents.  In order that these commands may work
at all, \csx{documentclass} and \csx{usepackage} play around with the
meaning of \texttt{@}.

If you've included a file some other way (for example, using
\csx{input}), you can probably solve the problem by using the correct
command.

If you're using a fragment of a package or class, you may well feel
confused: books such as the first edition of the % ! line break
\Qref*{The \LaTeX{} Companion}{Q-books} 
are full of fragments of packages as examples for you to employ.
The second edition of the \emph{Companion} makes clearer how you
should use these fragments, and in addition, the code of
all the examples is now available on \acro{CTAN}.
To see the technique in practice, look at the example below, from file
\File{2-2-7.ltx} in the \emph{Companion} examples directory:
\begin{quote}
\begin{verbatim}
\makeatletter
\renewcommand\subsection{\@startsection
  {subsection}{2}{0mm}%name, level, indent
  {-\baselineskip}%             beforeskip
  {0.5\baselineskip}%            afterskip
  {\normalfont\normalsize\itshape}}% style
\makeatother
\end{verbatim}
\end{quote}
(That example appears on page 29 of \emph{The \LaTeX{} Companion},
second edition.)

The alternative is to treat all these fragments as a package proper,
bundling them up into a \extension{sty} file and including them with
\csx{usepackage}; this way you hide your \LaTeX{} internal code somewhere
that \LaTeX{} internal code is expected, which often looks `tidier'.
\begin{ctanrefs}
\item[\nothtml{\rmfamily}Examples from the Companion]\CTANref{tlc2}
\end{ctanrefs}

\Question[Q-protect]{What's the reason for `protection'?}

Sometimes \LaTeX{} saves data it will reread later. These data are
often the argument of some command; they are the so-called moving
arguments.  (`Moving' because data are moved around.)  Candidates
are all arguments that may go into table of contents, list of figures,
\emph{etc}.; namely, data that are written to an auxiliary file and
read in later.  Other places are those data that might appear in head-
or footlines.  Section headings and figure captions are the most
prominent examples; there's a complete list in Lamport's book
(see \Qref[question]{\TeX{}-related books}{Q-books}).

What's going on really, behind the scenes? The commands in moving
arguments are normally expanded to their internal structure during the
process of saving. Sometimes this expansion results in invalid \TeX{}
code, which shows either during expansion or when the code is
processed again. Protecting a command, using
``\csx{protect}\csx{cmd}'' tells \LaTeX{} to save \csx{cmd} as
\csx{cmd}, without expanding it at all.

So, what is a `fragile command'?~--- it's a command that expands into
illegal \TeX{} code during the save process.

What is a `robust command'?~--- it's a command that expands into legal
\TeX{} code during the save process.

Lamport's book says in its description of every LaTeX command whether
it is `robust' or `fragile'; it also says that every command with an
optional argument is fragile.  The list isn't reliable, and neither
is the assertion about optional arguments; the statements may have
been true in early versions of \LaTeXe{} but are not any longer
necessarily so:
\begin{itemize}
\item Some fragile commands, such as \csx{cite}, have been made robust
  in later revisions of \LaTeX{}.
\item Some commands, such as \csx{end} and \csx{nocite}, are fragile
  even though they have no optional arguments.
\item The ``user's way'' of creating a command with an optional
  argument (using \csx{newcommand} or \csx{newcommand*}) now always
  creates a robust command (though macros without optional arguments
  may still be fragile if they do things that are themselves fragile).
\item There is no reason that a package author should not also make
  robust commands with optional arguments as part of the package.
\item Some robust commands are redefined by certain packages to be
  fragile (the \csx{cite} command commonly suffers this treatment).
\end{itemize}
Further, simply ``hiding'' a fragile command in another command, has
no effect on fragility.  So, if \csx{fred} is fragile, and you write:
\begin{quote}
\begin{verbatim}
\newcommand{\jim}{\fred}
\end{verbatim}
\end{quote}
then \csx{jim} is fragile too.  There is, however, the
\csx{newcommand}-replacement \csx{DeclareRobustCommand}, which
\emph{always} creates a robust command (whether or not it has optional
arguments).  The syntax of \csx{DeclareRobustCommand} is substantially
identical to that of \csx{newcommand}, and if you do the wrapping
trick above as:
\begin{quote}
\begin{verbatim}
\DeclareRobustCommand{\jim}{\fred}
\end{verbatim}
\end{quote}
then \csx{jim} is robust.

Finally, we have the \Package{makerobust} package, which  defines
\csx{MakeRobustCommand} to convert a command to be robust.  With the
package, the ``wrapping'' above can simply be replaced by:
\begin{quote}
\begin{verbatim}
\MakeRobustCommand\fred
\end{verbatim}
\end{quote}
Whereafter, \csx{fred} is robust.  Using the package may be reasonable
if you have lots of fragile commands that you need to use in moving
arguments.

In short, the situation is confusing.  No-one believes this is
satisfactory; the \LaTeX{} team have removed the need for
protection of some things, but the techniques available in 
current \LaTeX{} mean that this is an expensive exercise.  It remains
a long-term aim of the team to remove all need for \csx{protect}ion.
\begin{ctanrefs}
\item[makerobust.sty]Distributed with Heiko Oberdiek's packages
  \CTANref{oberdiek}
\end{ctanrefs}

\Question[Q-edef]{\csx{edef} does not work with \csx{protect}}

Robust \LaTeX{} commands are either ``naturally robust''~--- meaning that
they never need \csx{protect}, or ``self-protected''~--- meaning that
they have \csx{protect} built in to their definition in some
way.  Self-protected commands, and fragile commands with
\csx{protect}ion are only robust in a context where the \csx{protect}
mechanism is properly handled.  The body of an \csx{edef} definition
doesn't handle \csx{protect} properly, since \csx{edef} is a \TeX{}
primitive rather than a \LaTeX{} command.

This problem is resolved by a \LaTeX{} internal command
\csx{protected@edef}, which does the job of \csx{edef} while keeping the
\csx{protect} mechanism working.  There's a corresponding
\csx{protected@xdef} which does the job of \csx{xdef}.

Of course, these commands need to be tended carefully, since they're
% beware line break on next line
internal: see \Qref[question]{'@' in control sequence names}{Q-atsigns}.

\Question[Q-ltxcmds]{The definitions of \LaTeX{} commands}

There are several reasons to want to know the definitions of \LaTeX{}
commands: from the simplest ``idle curiosity'', to the pressing need
to patch something to make it ``work the way you want it''.  None of
these are \emph{pure} motives, but knowledge and expertise seldom
arrive through the purest of motives.

The simple answer is to try \csx{show}, in a run of \LaTeX{} that is
taking commands from the terminal:
\begin{quote}
\begin{verbatim}
*\makeatletter
*\show\protected@edef
> \protected@edef=macro:
->\let \@@protect \protect
  \let \protect \@unexpandable@protect
  \afterassignment \restore@protect \edef .
\end{verbatim}
\end{quote}
(I've rearranged the output there, from the rather confused version
\TeX{} itself produces.)  We may perhaps, now, wonder about
\csx{@unexpandable@protect}:
\begin{quote}
\begin{verbatim}
*\show\@unexpandable@protect
> \@unexpandable@protect=macro:
->\noexpand \protect \noexpand .
\end{verbatim}
\end{quote}
and we're starting to see how one part of the \csx{protect}ion
mechanism works (one can probably fairly safely guess what
\csx{restore@protect} does).

Many kernel commands are declared robust:
\begin{quote}
\begin{verbatim}
*\show\texttt
> \texttt=macro:
->\protect \texttt  .
\end{verbatim}
\end{quote}
so that \csx{show} isn't much help.  Define a command \csx{pshow} as
shown below, and use that instead:
\begin{quote}
\begin{verbatim}
*\def\pshow#1{{\let\protect\show #1}}
*\pshow\texttt
> \texttt =\long macro:
#1->\ifmmode \nfss@text {\ttfamily #1}%
    \else \hmode@bgroup \text@command {#1}%
          \ttfamily \check@icl #1\check@icr
    \expandafter \egroup \fi .
\end{verbatim}
\end{quote}
Note that the command name that is protected is the `base' command,
with a space appended.  This is cryptically visible, in a couple of
places above.  (Again, the output has been sanitised.)

If one has a malleable text editor, the same investigation may more
comfortably be conducted by examining the file \File{latex.ltx} (which
is usually to be found, in a \acro{TDS} system, in directory
\path{tex/latex/base}).

In fact, \File{latex.ltx} is the product of a \ProgName{docstrip}
process on a large number of \Qref*{\extension{dtx} files}{Q-dtx}, and
you can refer to those instead.  The \LaTeX{} distribution includes a file
\File{source2e.tex}, and most systems retain it, again in
\path{tex/latex/base}.  \File{Source2e.tex} may be processed to
provide a complete source listing of the \LaTeX{} kernel (in fact the
process isn't entirely straightforward, but the file produces messages
advising you what to do).  The result is a huge document, with a
line-number index of control sequences the entire kernel and a
separate index of changes recorded in each of the files since the
\LaTeX{} team took over.

The printed kernel is a nice thing to have, but it's unwieldy and sits
on my shelves, seldom used.  One problem is that the comments are
patchy: the different modules range from well and lucidly documented,
through modules documented only through an automatic process that
converted the documentation of the source of \LaTeXo{}, to modules
that hardly had any useful documentation even in the \LaTeXo{} original.

In fact, each kernel module \extension{dtx} file will process separately
through \LaTeX{}, so you don't have to work with the whole of
\File{source2e}.  You can easily determine which module defines the
macro you're interested in: use your ``malleable text editor'' to find
the definition in \File{latex.ltx}; then search backwards from that
point for a line that starts % ! line break
\texttt{\textpercent\textpercent\textpercent\ From File:}~--- that line
tells you which \extension{dtx} file contains the definition you are interested
in.  Doing this for \csx{protected@edef}, we find:
\begin{quote}
\begin{verbatim}
%%% From File: ltdefns.dtx
\end{verbatim}
\end{quote}
When we come to look at it, \File{ltdefns.dtx} proves to contain
quite a dissertation on the methods of handling \csx{protect}ion; it
also contains some automatically-converted \LaTeXo{} documentation.

And of course, the kernel isn't all of \LaTeX{}: your command may be
defined in one of \LaTeX{}'s class or package files.  For example, we
find a definition of \csx{thebibliography} in \Class{article}, but
there's no \File{article.dtx}.  Some such files are generated from
parts of the kernel, some from other files in the distribution.  You
find which by looking at the start of the file: in \File{article.cls},
we find:
\begin{quote}
\begin{verbatim}
%% This is file `article.cls',
%% generated with the docstrip utility.
%%
%% The original source files were:
%%
%% classes.dtx  (with options: `article')
\end{verbatim}
\end{quote}
so we need to format \File{classes.dtx} to see the definition in
context.

All these .dtx files are on \acro{CTAN} as part of the main \LaTeX{}
distribution.
\begin{ctanrefs}
\item[\nothtml{\rmfamily}\LaTeX{} distribution]\CTANref{latex}
\end{ctanrefs}

\Question[Q-oarglikesect]{Optional arguments like \csx{section}}

Optional arguments, in macros defined using \csx{newcommand}, don't
quite work like the optional argument to \csx{section}.  The default
value of \csx{section}'s optional argument is the value of the
mandatory argument, but \csx{newcommand} requires that you `know' the
value of the default beforehand.

The requisite trick is to use a macro in the optional argument:
\begin{quote}
\begin{verbatim}
\documentclass{article}
\newcommand\thing[2][\DefaultOpt]{%
  \def\DefaultOpt{#2}%
  optional arg: #1,  mandatory arg: #2%
}
\begin{document}
\thing{manda}% #1=#2

\thing[opti]{manda}% #1="opti"
\end{document}
\end{verbatim}
\end{quote}
\LaTeX{} itself has a trickier (but less readily understandable)
method, using a macro \csx{@dblarg}; inside \LaTeX{}, the example
above would have been programmed:
\begin{quote}
\begin{verbatim}
\newcommand\thing{\@dblarg\@thing}
\newcommand\@thing[2][\@error]{%
  optional arg: #1,  mandatory arg: #2%
}
\end{verbatim}
\end{quote}
In that code, \csx{@thing} is only ever called with an optional and a
mandatory argument; if the default from the \csx{newcommand} is
invoked, a bug in user code has bitten\dots{}

\Question[Q-twooptarg]{More than one optional argument}

If you've already read % ! line break
``\Qref*[question]{breaking the 9-argument limit}{Q-moren9}''.
you can probably guess the ``simple'' solution to this problem:
command relaying.

\LaTeX{} allows commands with a single optional argument thus:
\begin{verbatim}
  \newcommand{\blah}[1][Default]{...}
\end{verbatim}

You may legally call such a command either with its optional argument
present, as
\cmdinvoke{blah}[nonDefault] or without, as \csx{blah}; in the latter
case, the code of \csx{blah} will have an argument of |Default|.

To define a command with two optional arguments, we use the relaying
technique, as follows:
\begin{verbatim}
  \newcommand{\blah}[1][Default1]{%
    \def\ArgI{{#1}}%
    \BlahRelay
  }
  \newcommand\BlahRelay[1][Default2]{%
    % the first optional argument is now in
    %   \ArgI
    % the second is in #1
    ...%
  }
\end{verbatim}
Of course, \csx{BlahRelay} may have as many mandatory arguments as are
allowed, after allowance for the one taken up with its own
optional argument~--- that is, 8.

Variants of \csx{newcommand} (and friends), with names like
\csx{newcommandtwoopt}, are available in the \Package{twoopt} package.
However, if you can, it's probably better to learn to write the commands
yourself, just to see why they're not even a good idea from the
programming point of view.

A command with two optional arguments strains the limit of what's
sensible: obviously you can extend the technique to provide as many
optional arguments as your fevered imagination can summon.  However,
see the comments on the use of the \Package{keyval} package, in 
``\Qref*[question]{breaking the 9-argument limit}{Q-moren9}'',
which offers an alternative way forward.

If you must, however, consider the \Package{optparams} or
\Package{xargs} packages.  \Package{Optparams}
provides a \csx{optparams} command that you use as an intermediate in
defining commands with up to nine optional arguments.  The
documentation shows examples of commands with four optional arguments
(and this from an author who has his own key-value package!).

The \Package{xargs} package uses a key-value package
(\Package{xkeyval}) to \emph{define} the layout of the optional
arguments.  Thus
\begin{quote}
\begin{verbatim}
\usepackage{xargs}
...
\newcommandx{\foo}[3][1=1, 3=n]{...}
\end{verbatim}
\end{quote}
defines a command \csx{foo} that has an optional first argument
(default 1), a mandatory second argument, and an optional third
argument (default n).

An alternative approach is offered by Scott Pakin's
\ProgName{newcommand} program, which takes a command name and a
definition of a set of command arguments (in a fairly
readily-understood language), and emits \AllTeX{} macros which enable
the command to be defined.  The command requires that a
\ProgName{Python} interpreter (etc.\@) be installed on your computer.
\begin{ctanrefs}
\item[newcommand.py]\CTANref{newcommand}
\item[optparams.sty]Distributed as part of \CTANref{sauerj}
\item[twoopt.sty]Distributed as part of \CTANref{oberdiek}
\item[xargs.sty]\CTANref{xargs}
\item[xkeyval.sty]\CTANref{xkeyval}
\end{ctanrefs}

\Question[Q-cmdstar]{Commands defined with * options}

\LaTeX{} commands commonly have ``versions'' defined with an asterisk
tagged onto their name: for example \csx{newcommand} and
\csx{newcommand*} (the former defines a \csx{long} version of the
command).

The simple-minded way for a user to write such a command involves use
of the \Package{ifthen} package:
\begin{wideversion}
\begin{quote}
\begin{verbatim}
\newcommand{\mycommand}[1]{\ifthenelse{\equal{#1}{*}}%
  {\mycommandStar}%
  {\mycommandNoStar{#1}}%
}
\newcommand{\mycommandStar}{starred version}
\newcommand{\mycommandNoStar}[1]{normal version}
\end{verbatim}
\end{quote}
\end{wideversion}
\begin{narrowversion}
\begin{quote}
\begin{verbatim}
\newcommand{\mycommand}[1]{%
  \ifthenelse{\equal{#1}{*}}%
    {\mycommandStar}%
    {\mycommandNoStar{#1}}%
}
\newcommand{\mycommandStar}%
                {starred version}
\newcommand{\mycommandNoStar}[1]%
                 {normal version}
\end{verbatim}
\end{quote}
\end{narrowversion}
This does the trick, for sufficiently simple commands, but it has
various tiresome failure modes, and it requires \csx{mycommandnostar}
to take an argument.

Of course, the \LaTeX{} kernel has something slicker than this:
\begin{quote}
\begin{wideversion}
\begin{verbatim}
\newcommand{\mycommand}{\@ifstar
                     \mycommandStar%
                     \mycommandNoStar%
}
\newcommand{\mycommandStar}[2]{starred version}
\newcommand{\mycommandNoStar}[1]{normal version}
\end{verbatim}
\end{wideversion}
\begin{narrowversion}
\begin{verbatim}
\newcommand{\mycommand}{\@ifstar
                     \mycommandStar%
                     \mycommandNoStar%
}
\newcommand{\mycommandStar}[2]{starred version}
\newcommand{\mycommandNoStar}[1]{normal version}
\end{verbatim}
\end{narrowversion}
\end{quote}
(Note that arguments to \csx{mycommandStar} and \csx{mycommandNoStar}
are independent~--- either can have their own arguments, unconstrained
by the technique we're using, unlike the trick described above.)
The \csx{@ifstar} trick is all very well, is fast and efficient, but
it requires the definition to be % ! line break
\Qref*{\csx{makeatletter} protected}{Q-atsigns}.

A pleasing alternative is the \Package{suffix} package.  This elegant
piece of code allows you to define variants of your commands:
\begin{narrowversion}
\begin{quote}
\begin{verbatim}
\newcommand\mycommand{normal version}
\WithSuffix\newcommand\mycommand*%
                     {starred version}
\end{verbatim}
\end{quote}
\end{narrowversion}
\begin{wideversion}
\begin{quote}
\begin{verbatim}
\newcommand\mycommand{normal version}
\WithSuffix\newcommand\mycommand*{starred version}
\end{verbatim}
\end{quote}
\end{wideversion}
The package needs \Qref*{\elatex{}}{Q-etex}, but any new enough
distribution defines \LaTeX{} as \elatex{} by default.  Command
arguments may be specified in the normal way, in both command
definitions (after the ``\texttt{*}'' in the \csx{WithSuffix}
version).  You can also use the \TeX{} primitive commands, creating a
definition like:
\begin{quote}
\begin{verbatim}
\WithSuffix\gdef\mycommand*{starred version}
\end{verbatim}
\end{quote}
\begin{ctanrefs}
\item[ifthen.sty]Part of the \LaTeX{} distribution
\item[suffix.sty]Distributed as part of \CTANref{bigfoot}
\end{ctanrefs}

\nothtml{\hrule height 0pt \nobreak\vskip0pt plus2.5in\vskip 0pt\relax}
\Question[Q-ltxabbrv]{\LaTeX{} internal ``abbreviations'', etc.}

In the deeps of time, when \TeX{} first happened, computers had
extremely limited memory, and were (by today's standards) painfully
slow.  When \LaTeX{} came along, things weren't much better, and even
when \LaTeXe{} appeared, there was a strong imperative to save memory
space (and to a lesser extent) \acro{CPU} time.

From the very earliest days, Knuth used shortcut macros to speed
things up.  \LaTeX{}, over the years, has extended Knuth's list by a
substantial amount.  An interesting feature  of the ``abbreviations'' is
that on paper, they may look longer than the thing they stand for;
however, to \AllTeX{} they \emph{feel} smaller\dots{}

The table at the end of this answer lists the commonest of these
``abbreviations''.  It is not complete; as always, if the table
doesn't help, try the \LaTeX{} source.  The table lists each
abbreviation's \emph{name} and its \emph{value}, which provide most of
what a user needs to know.  The table also lists the abbreviation's
\emph{type}, which is a trickier concept: if you need to know, the
only real confusion is that the abbreviations labelled `defn' are
defined using an \csx{\emph{xxx}def} command.

\begin{tabular}{lll}
Name \tbamp Type \tbamp Value \tbeol
\tbhline
\csx{m@ne} \tbamp count \tbamp \ensuremath{-1} \tbeol
\csx{p@}  \tbamp dimen \tbamp 1pt \tbeol
\csx{z@}  \tbamp dimen \tbamp 0pt \tbeol
\csx{z@skip} \tbamp skip \tbamp 0pt plus 0pt minus 0pt \tbeol
\tbhline
\csx{@ne} \tbamp defn \tbamp 1 \tbeol
\csx{tw@} \tbamp defn \tbamp 2\tbeol
\csx{thr@@} \tbamp defn \tbamp 3 \tbeol
\csx{sixt@@n} \tbamp defn \tbamp 16 \tbeol
\csx{@cclv} \tbamp defn \tbamp 255 \tbeol
\csx{@cclvi} \tbamp defn \tbamp 256 \tbeol
\csx{@m} \tbamp defn \tbamp 1000 \tbeol
\csx{@M} \tbamp defn \tbamp 10000 \tbeol
\csx{@MM} \tbamp defn \tbamp 20000 \tbeol
\tbhline
\csx{@vpt} \tbamp macro \tbamp 5 \tbeol
\csx{@vipt} \tbamp macro \tbamp 6 \tbeol
\csx{@viipt} \tbamp macro \tbamp 7 \tbeol
\csx{@viiipt} \tbamp macro \tbamp 8 \tbeol
\csx{@ixpt} \tbamp macro \tbamp 9 \tbeol
\csx{@xpt} \tbamp macro \tbamp 10 \tbeol
\csx{@xipt} \tbamp macro \tbamp 10.95 \tbeol
\csx{@xiipt} \tbamp macro \tbamp 12 \tbeol
\csx{@xivpt} \tbamp macro \tbamp 14.4 \tbeol
\csx{@xviipt} \tbamp macro \tbamp 17.28 \tbeol
\csx{@xxpt} \tbamp macro \tbamp 20.74 \tbeol
\csx{@xxvpt} \tbamp macro \tbamp 24.88 \tbeol
\tbhline
\csx{@plus} \tbamp macro \tbamp ``\texttt{plus}'' \tbeol
\csx{@minus} \tbamp macro \tbamp ``\texttt{minus}'' \tbeol
%\csx{hb@xt@} \tbamp macro \tbamp ``\csx{hbox} \texttt{to}''
\end{tabular}

\Question[Q-ltxhash]{Defining \LaTeX{} commands within other commands}

\LaTeX{} command definition is significantly different from the \TeX{}
primitive form discussed in an % ! line break
\Qref*[\htmlonly]{earlier question}{Q-hash} about definitions within
macros.

In most ways, the \LaTeX{} situation is simpler (at least in part
because it imposes more restrictions on the user); however, defining a
command within a command still requires some care.

The earlier question said you have to double the |#| signs in command
definitions: in fact, the same rule holds, except that \LaTeX{}
already takes care of some of the issues, by generating argument lists
for you.

The basic problem is that:
\begin{quote}
\begin{verbatim}
\newcommand{\abc}[1]{joy, oh #1!%
  \newcommand{\ghi}[1]{gloom, oh #1!}%
}
\end{verbatim}
\end{quote}
followed by a call:
\begin{quote}
\begin{verbatim}
\cmdinvoke{abc}{joy}
\end{verbatim}
\end{quote}
typesets ``joy, oh joy!'', but defines a command \csx{ghi} that takes
one parameter, which it ignores; \cmdinvoke{ghi}{gloom} will expand to
``gloom, oh joy!'', which is presumably not what was expected.

And (as you will probably guess, if you've read the earlier question)
the definition:
\begin{quote}
\begin{verbatim}
\newcommand{\abc}[1]{joy, oh #1!%
  \newcommand{\ghi}[1]{gloom, oh ##1!}%
}
\end{verbatim}
\end{quote}
does what is required, and \cmdinvoke{ghi}{gloom} will expand to
``gloom, oh gloom!'', whatever the argument to \csx{abc}.

The doubling is needed whether or not the enclosing command has an
argument, so:
\begin{quote}
\begin{verbatim}
\newcommand{\abc}{joy, oh joy!%
  \newcommand{\ghi}[1]{gloom, oh ##1!}%
}
\end{verbatim}
\end{quote}
is needed to produce a replica of the \csx{ghi} we defined earlier.

\subsection{\LaTeX{} macro programming}

\Question[Q-fixnam]{How to change \LaTeX{}'s ``fixed names''}

\LaTeX{} document classes define several typographic operations that
need `canned text' (text not supplied by the user).  In the earliest
days of \LaTeXo{} these bits of text were built in to the body of
\LaTeX{}'s macros and were rather difficult to change, but ``fixed
name'' macros were introduced for the benefit of those wishing to use
\LaTeX{} in languages other than English.
For example, the special section produced by the \csx{tableofcontents}
command is always called \csx{contentsname} (or rather, what
\csx{contentsname} is defined to mean).
Changing the canned text is now one of the easiest customisations a
user can do to \LaTeX{}.

The canned text macros are all of the form
\csx{\meta{thing}name}, and changing them is simplicity
itself.  Put:
\begin{quote}
\cmdinvoke{renewcommand}{\csx{\meta{thing}name}}{Res minor}
\end{quote}
in the preamble of your document, and the job is done.
(However, beware of the \Package{babel} package, which requires you to
use a different mechanism: be sure to check
% beware line wrap
\Qref[question]{changing \Package{babel} names}{Q-latexwords} if
you're using it.)

The names that are defined in the standard \LaTeX{} classes (and the
\Package{makeidx} package) are listed
below.  Some of the names are only defined in a subset of the classes
(and the \Class{letter} class has a set of names all of its own);
the list shows the specialisation of each name, where appropriate.

\nothtml{\noindent}\begin{tabular}{@{}ll}
\csx{abstractname} \tbamp Abstract\tbeol
\csx{alsoname} \tbamp see also (\Package{makeidx} package)\tbeol
\csx{appendixname} \tbamp Appendix\tbeol
\csx{bibname} \tbamp Bibliography (\Class{report},\Class{book})\tbeol
\csx{ccname} \tbamp cc (\Class{letter})\tbeol
\csx{chaptername} \tbamp Chapter (\Class{report},\Class{book})\tbeol
\csx{contentsname} \tbamp Contents\tbeol
\csx{enclname} \tbamp encl (\Class{letter})\tbeol
\csx{figurename} \tbamp Figure (for captions)\tbeol
\csx{headtoname} \tbamp To (\Class{letter})\tbeol
\csx{indexname} \tbamp Index\tbeol
\csx{listfigurename} \tbamp List of Figures\tbeol
\csx{listtablename} \tbamp List of Tables\tbeol
\csx{pagename} \tbamp Page (\Class{letter})\tbeol
\csx{partname} \tbamp Part\tbeol
\csx{refname} \tbamp References (\Class{article})\tbeol
\csx{seename} \tbamp see (\Package{makeidx} package)\tbeol
\csx{tablename} \tbamp Table (for caption)
\end{tabular}

\Question[Q-latexwords]{Changing the words \Package{babel} uses}

\LaTeX{} uses symbolic names for many of the automatically-generated
text it produces (special-purpose section headings, captions, etc.).
As noted in \Qref[question]{``\LaTeX fixed names''}{Q-fixnam} (which
includes a list of the names themselves),
this enables the user to change the
names used by the standard classes, which is particularly useful if
the document is being prepared in some language other than \LaTeX{}'s
default English.  So, for example, a Danish author may wish that her
table of contents was called ``Indholdsfortegnelse'', and so 
would expect to place a command
\begin{verbatim}
\renewcommand{\contentsname}%
    {Indholdsfortegnelse}
\end{verbatim}
in the preamble of her document.

However, it's natural for a user of a non-English language to use
\Package{babel}, because it offers many conveniences and typesetting
niceties for those preparing documents in those languages.  In
particular, when \Package{babel} is selecting a new language, it
ensures that \LaTeX{}'s symbolic names are translated appropriately
for the language in question.  Unfortunately, \Package{babel}'s choice
of names isn't always to everyone's choice, and there is still a need
for a mechanism to replace the `standard' names.

Whenever a new language is selected, \Package{babel} resets all the
names to the settings for that language.  In particular,
\Package{babel} selects the document's main language when
\cmdinvoke{begin}{document} is executed, which immediately destroys
any changes to these symbolic names made in the prologue of a document
that uses \Package{babel}. 

Therefore, babel defines a command to enable users to change the
definitions of the symbolic names, on a per-language basis:
\csx{addto}\csx{captions}\texttt{\meta{language}} is the thing
(\texttt{\meta{language}} being the language option you gave to
\Package{babel} in the first place).  For example:
\begin{verbatim}
\addto\captionsdanish{%
  \renewcommand{\contentsname}%
    {Indholdsfortegnelse}%
}
\end{verbatim}

\Question[Q-running-nos]{Running equation, figure and table numbering}

Many \LaTeX{} classes (including the standard \Class{book} class)
number things per chapter; so figures in chapter 1 are numbered 1.1,
1.2, and so on.  Sometimes this is not appropriate for the user's
needs.

Short of rewriting the whole class, one may use the \Package{chngctr}
package, which provides commands \csx{counterwithin} (which
establishes this nested numbering relationship) and
\csx{counterwithout} (which undoes it).

So if you have figures numbered by chapter as 1.1, 1.2, 2.1, \dots{},
the command 
\begin{quote}
\begin{verbatim}
\counterwithout{figure}{chapter}
\end{verbatim}
\end{quote}
will convert them to figures 1, 2, 3, \dots{}.  (Note that the command
has also removed the chapter number from the counter's definition.)

More elaborate use could change things numbered per section to things
numbered per chapter:
\begin{quote}
\begin{verbatim}
\counterwithout{equation}{section}
\counterwithin{equation}{chapter}
\end{verbatim}
\end{quote}
(assuming there was a class that did such a thing in the first place...)

The \Package{chngcntr} approach doesn't involve much programming, and
the enthusiastic \LaTeX{} programmer might choose to try the technique
that we had to use before the advent of \Package{chngcntr}.  Each of
the packages \Package{removefr} and \Package{remreset} defines a
\csx{@removefromreset} command, and having included the package one
writes something like:
\begin{quote}
\begin{verbatim}
\makeatletter
\@removefromreset{figure}{chapter}
\makeatother
\end{verbatim}
\end{quote}
and the automatic renumbering stops.  You may then need to redefine the
way in which the figure number (in this case) is printed:
\begin{quote}
\begin{verbatim}
\makeatletter
\renewcommand{\thefigure}{\@arabic\c@figure}
\makeatother
\end{verbatim}
\end{quote}
(remember to do the whole job, for every counter you want to
manipulate, within \csx{makeatletter} \dots{}\@ \csx{makeatother}).

This technique, too, may be used to change where in a multilevel
structure a counter is reset.  Suppose your class numbers figures as
\meta{chapter}.\meta{section}.\meta{figure}, and you want figures
numbered per chapter, try:
\begin{quote}
\begin{wideversion}
\begin{verbatim}
\makeatletter
\@removefromreset{figure}{section}
\@addtoreset{figure}{chapter}
\renewcommand{\thefigure}{\thechapter.\@arabic\c@figure}
\makeatother
\end{verbatim}
\end{wideversion}
\begin{narrowversion}
\begin{verbatim}
\makeatletter
\@removefromreset{figure}{section}
\@addtoreset{figure}{chapter}
\renewcommand{\thefigure}%
             {\thechapter.\@arabic\c@figure}
\makeatother
\end{verbatim}
\end{narrowversion}
\end{quote}
(the command \csx{@addtoreset} is a part of \LaTeX{} itself).
\begin{ctanrefs}
\item[chngcntr.sty]\CTANref{chngcntr}
\item[memoir.cls]\CTANref{memoir}
\item[removefr.tex]\CTANref{removefr} (note, this is constructed as a
  ``fragment'' for use within other packages: load by
  \cmdinvoke{input}{removefr})
\item[remreset.sty]Distributed as part of \CTANref{carlisle}
\end{ctanrefs}

\Question[Q-labelctr]{Making labels from a counter}

Suppose we have a \LaTeX{} counter, which we've defined with
\cmdinvoke{newcounter}{foo}.  We can increment the value of the counter
by \cmdinvoke{addtocounter}{foo}{1}, but that's pretty clunky for an
operation that happens so often \dots{}~so there's a command
\cmdinvoke{stepcounter}{foo} that does this special case of
increasing-by-one.

There's an internal \LaTeX{} variable, the ``current label'', that
remembers the last `labellable' thing that \LaTeX{} has processed.
You could (if you were to insist) set that value by the relevant
\TeX{} command (having taken the necessary precautions to ensure that
the internal command worked)~--- but it's not necessary.  If, instead
of either of the stepping methods above, you say
\cmdinvoke{refstepcounter}{foo}, the internal variable is set to the
new value, and (until something else comes along), \csx{label} will
refer to the counter.

\Question[Q-oddpage]{Finding if you're on an odd or an even page}

\Qref[Question]{Another question}{Q-marginparside} discusses the issue
of getting \csx{marginpar} commands to put their output in the correct
margin of two-sided documents.  This is an example of the general
problem of knowing where a particular bit of text lies: the output
routine is asynchronous, and \AllTeX{} will usually process quite a
bit of the ``next'' page before deciding to output any page.  As a
result, the |page| counter (known internally in \LaTeX{} as
\csx{c@page}) is normally only reliable when you're actually \emph{in}
the output routine.

The solution is to use some version of the \csx{label} mechanism to
determine which side of the page you're on; the value of the page
counter that appears in a \csx{pageref} command has been inserted in
the course of the output routine, and is therefore safe.

However, \csx{pageref} itself isn't reliable: one might hope that
\begin{verbatim}
\ifthenelse{\isodd{\pageref{foo}}}{odd}{even}
\end{verbatim}
would do the necessary, but both the \Package{babel} and
\Package{hyperref} packages have been known to interfere with the
output of \csx{pageref}; be careful!

The \Package{changepage} package needs to provide this functionality for
its own use, and therefore provides a command \csx{checkoddpage}; this
sets a private-use label, and the page reference part of that label is
then examined (in a \Package{hyperref}-safe way) to set a conditional 
\csx{ifoddpage} true if the command was issued on an odd page.  The
\Class{memoir} class has the same command setting a conditional
\csx{ifoddpage}.  Of course, the \csx{label} contributes to \LaTeX{}'s
``Rerun to get cross-references right'' error messages\dots{}

The (older) \Package{chngpage} provides the same facilities (though it
provides a \csx{ifcpoddpage} command; \Package{changepage} (whose
functions are extracted from the author's \Class{memoir} class) is the
designated successor to \Package{chngpage}.

The Koma-Script classes have an \environment{addmargin*} environment
that also provides the sorts of facilities that the \Package{chngpage}
offers.  Koma-Script's supporting command is % !line break
\cmdinvoke{ifthispageodd}{<true>}{<false>} executes different things
depending on the page number.
\begin{ctanrefs}
\item[changepage.sty]\CTANref{changepage}
\item[chngpage.sty]\CTANref{chngpage}
\item[\nothtml{\rmfamily}KOMA script bundle]\CTANref{koma-script}
\item[memoir.cls]\CTANref{memoir}
\end{ctanrefs}

\Question[Q-labelformat]{How to change the format of labels}

By default, when a label is created, it takes on the appearance of the
counter labelled, so the label appears as
\csx{the}\texttt{\meta{counter}}~--- what would be used if you
asked to typeset the counter in your text.  This isn't always what you
need: for example, if you have nested enumerated lists with the outer
numbered and the inner labelled with letters, one might expect to want
to refer to items in the inner list as ``2(c)''.   (Remember, you can
\nothtml{change the structure of list items~--- }%
\Qref{change the structure of list items}{Q-enumerate}.)
The change is of course
possible by explicit labelling of the parent and using that label to
construct the typeset result~--- something like
\begin{quote}
\begin{verbatim}
\ref{parent-item}(\ref{child-item})
\end{verbatim}
\end{quote}
which would be both tedious and error-prone.  What's more, it would be
undesirable, since you would be constructing a visual representation
which is inflexible (you couldn't change all the references to elements
of a list at one fell swoop).

\LaTeX{} in fact has a label-formatting command built into every label
definition; by default it's null, but it's available for the user to
program.  For any label \meta{counter} there's a \LaTeX{} internal
command \csx{p@}\meta{\texttt{counter}}; for example, a label definition
on an inner list item is supposedly done using the command
\cmdinvoke{p@enumii}{\csx{theenumii}}.  Unfortunately, the internal
workings of this aren't quite right, and you need to patch the
\csx{refstepcounter} command:
\begin{quote}
\begin{narrowversion}
\begin{verbatim}
\renewcommand*\refstepcounter[1]{%
  \stepcounter{#1}%
  \protected@edef\@currentlabel{%
    \csname p@#1\expandafter\endcsname
      \csname the#1\endcsname
  }%
}
\end{verbatim}
\end{narrowversion}
\begin{wideversion}
\begin{verbatim}
\renewcommand*\refstepcounter[1]{\stepcounter{#1}%
  \protected@edef\@currentlabel{%
    \csname p@#1\expandafter\endcsname
      \csname the#1\endcsname
  }%
}
\end{verbatim}
\end{wideversion}
\end{quote}
With the patch in place you can now, for example, change the labels on
all inner lists by adding the following code in your preamble:
\begin{quote}
\begin{verbatim}
\makeatletter
\renewcommand{\p@enumii}[1]{\theenumi(#1)}
\makeatother
\end{verbatim}
\end{quote}
This would make the labels for second-level enumerated lists appear as
``1(a)'' (and so on).  The analogous change works for any counter that
gets used in a \csx{label} command.

In fact, the \Package{fncylab} package does all the above (including
the patch to \LaTeX{} itself).  With the package, the code above is
(actually quite efficiently) rendered by the command:
\begin{quote}
\begin{verbatim}
\labelformat{enumii}{\theenumi(#1)}
\end{verbatim}
\end{quote}
In fact, the above example, which we can do in several different ways,
has been rendered obsolete by the appearance of the \Package{enumitem}
package, which is discussed in the answer about % ! line break
\Qref*{decorating enumeration lists}{Q-enumerate}.
\begin{ctanrefs}
\item[enumitem.sty]\CTANref{enumitem}
\item[fncylab.sty]\CTANref{fncylab}
\end{ctanrefs}

\Question[Q-seccntfmt]{Adjusting the presentation of section numbers}

The general issues of adjusting the appearance of section headings are
pretty complex, and are covered in % beware line breaks (2 lines)
\latexhtml{question}{the question on}
\Qref[\htmlonly]{the style of section headings}{Q-secthead}.

However, people regularly want merely to change the way the section
number appears in the heading, and some such people don't mind writing
out a few macros.  This answer is for \emph{them}.

The section number is typeset using the
\begin{narrowversion}
  \LaTeX{} internal
\end{narrowversion}
\begin{wideversion}
  \Qref{\LaTeX{} internal}{Q-atsigns}
\end{wideversion}
\csx{@seccntformat} command, which is given the ``name'' (section,
subsection, \dots{}) of the heading, as argument.  Ordinarily,
\csx{@seccntformat} 
merely outputs the section number, and then a \csx{quad} of space.
Suppose you want to put a stop after every section (subsection,
subsubsection, \dots{}) number, a trivial change may be implemented by
simple modification of the command:
\begin{quote}
\begin{verbatim}
\renewcommand*{\@seccntformat}[1]{%
  \csname the#1\endcsname.\quad
}
\end{verbatim}
\end{quote}

Many people (for some reason) want a stop after a section number, but
not after a subsection number, or any of the others.
To do this, one must make \csx{@seccntformat} switch according to its
argument.  The following technique for doing the job is slightly
wasteful, but is efficient enough for a relatively rare operation:
\begin{wideversion}
\begin{quote}
\begin{verbatim}
\let\@@seccntformat\@seccntformat
\renewcommand*{\@seccntformat}[1]{%
  \expandafter\ifx\csname @seccntformat@#1\endcsname\relax
    \expandafter\@@seccntformat
  \else
    \expandafter
      \csname @seccntformat@#1\expandafter\endcsname
  \fi
    {#1}%
}
\end{verbatim}
\end{quote}
\end{wideversion}
\begin{narrowversion}
\begin{quote}
\begin{verbatim}
\let\@@seccntformat\@seccntformat
\renewcommand*{\@seccntformat}[1]{%
  \expandafter\ifx
      \csname @seccntformat@#1\endcsname
      \relax
    \expandafter\@@seccntformat
  \else
    \expandafter
      \csname @seccntformat@#1\expandafter
      \endcsname
  \fi
    {#1}%
}
\end{verbatim}
\end{quote}
\end{narrowversion}
which looks to see if a second-level command has been defined, and
uses it if so; otherwise it uses the original.  The second-level
command to define stops after section numbers (only) has the same
definition as the original ``all levels alike'' version:
\begin{quote}
\begin{verbatim}
\newcommand*{\@seccntformat@section}[1]{%
  \csname the#1\endcsname.\quad
}
\end{verbatim}
\end{quote}
Note that all the command definitions of this answer are dealing in
\Qref*{\LaTeX{} internal commands}{Q-atsigns}, so the above
code should be in a package file, for preference.

The \Class{Koma-script} classes have different commands for specifying
changes to section number presentation: \csx{partformat},
\csx{chapterformat} and \csx{othersectionlevelsformat}, but otherwise
their facilities are similar to those of ``raw'' \LaTeX{}.
\begin{ctanrefs}
\item[\nothtml{\rmfamily}KOMA script bundle]\CTANref{koma-script}
\end{ctanrefs}

\Question[Q-spaftend]{There's a space added after my environment}

You've written your own environment \environment{env}, and it works
except that a space appears at the start of the first line of typeset
text after \cmdinvoke{end}{env}.  This doesn't happen with similar
\LaTeX{}-supplied environments.

You could impose the restriction that your users always put a
``\texttt{\textpercent}'' sign after the environment~\dots{}\nothtml{\@} but
\LaTeX{} environments don't require that, either.

The \LaTeX{} environments' ``secret'' is an internal flag which causes
the unwanted spaces to be ignored.  Fortunately, you don't have to use
the internal form: since 1996, \LaTeX{} has had a user command
\csx{ignorespacesafterend}, which sets the internal flag.

\Question[Q-labundef]{Finding if a label is undefined}

People seem to want to know (at run time) if a label is undefined (I
don't actually understand \emph{why}, particularly: it's a transient
state, and \LaTeX{} deals with it quite well).

A resolved label is simply a command:
\csx{r@}\texttt{\meta{label-name}}; determining if the label is set is
then simply a matter of detecting if the command exists.  The usual
\LaTeX{} internal way of doing this is to use the command
\csx{@ifundefined}:
\begin{quote}
  \cmdinvoke*{@ifundefined}{\textup{r@}label-name}{undef-cmds}{def-cmds}
\end{quote}
In which, \meta{label-name} is exactly what you would use in
a \csx{label} command, and the remaining two arguments are command
sequences to be used if the label is undefined
(\meta{undef-cmds}) or if it is defined
(\meta{def-cmds}).

Note that any command that incorporates \csx{@ifundefined} is naturally
fragile, so remember to create it with \csx{DeclareRobustCommand} or to
use it with \csx{protect} in a moving argument.

If you're into this game, you may well not care about \LaTeX{}'s
warning about undefined labels at the end of the document; however,
if you are, include the command \csx{G@refundefinedtrue} in
\meta{\texttt{undef-cmds}}.

And of course, remember you're dealing in internal commands, and pay
attention to the \Qref*{at-signs}{Q-atsigns}.

All the above can be avoided by using the \Package{labelcas} package:
it provides commands that enable you to switch according to the state
of a single label, or the states of a list of labels.  The package's
definition is a bit complicated, but the package itself is pretty
powerful.
\begin{ctanrefs}
\item[labelcas.sty]\CTANref{labelcas}
\end{ctanrefs}

\Question[Q-addtoreset]{Master and slave counters}

It's common to have things numbered ``per chapter'' (for example, in
the standard \Class{book} and \Class{report} classes, figures, tables
and footnotes are all numbered thus).  The process of resetting is
done automatically, when the ``master'' counter is stepped (when the
\csx{chapter} command that starts chapter \meta{n} happens, the
\texttt{chapter} counter is stepped, and all the dependent counters are set
to zero).

How would you do that for yourself?  You might want to number
algorithms per section, or corollaries per theorem, for example.  If
you're defining these things by hand, you declare the relationship
when you define the counter in the first place:
\begin{quote}
\cmdinvoke*{newcounter}{new-name}[master]
\end{quote}
says that every time counter \meta{master} is stepped, counter
\meta{new-name} will be reset.

But what if you have an uncooperative package, that defines the
objects for you, but doesn't provide a programmer interface to make
the counters behave as you want?

The \csx{newcounter} command uses a \LaTeX{} internal command, and you
can also use it:
\begin{quote}
\cmdinvoke*{@addtoreset}{new-name}{master}
\end{quote}
(but remember that it needs to be between \csx{makeatletter} and
\csx{makeatother}, or in a package of your own).

The \Package{chngcntr} package encapsulates the \csx{@addtoreset}
command into a command \csx{counterwithin}.  So:
\begin{quote}
\begin{verbatim}
\counterwithin*{corrollary}{theorem}
\end{verbatim}
\end{quote}
will make the corollary counter slave to theorem counters.  The
command without its asterisk:
\begin{quote}
\begin{verbatim}
\counterwithin{corrollary}{theorem}
\end{verbatim}
\end{quote}
will do the same, and also redefine \csx{thecorollary} as % line brk!
\meta{theorem number}.\meta{corollary number}, which is a good scheme
if you ever want to refer to the corollaries~--- there are potentially
many ``corollary~1'' in any document, so it's as well to tie its number
to the counter of the theorem it belongs to.  This is true of pretty
much any such counter-within-another; if you're not using the
\Package{chngcntr}, refer to the answer to % line break!
\Qref*{redefining counters' \csx{the-}commands}{Q-the-commands} for
the necessary techniques.

Note that the technique doesn't work if the master counter is |page|,
the number of the current page.  The |page| counter is stepped deep
inside the output routine, which usually gets called some time after
the text for the new page has started to appear: so special
techniques are required to deal with that.  One special case is dealt
with elsewhere: \Qref*{footnotes numbered per page}{Q-footnpp}.  One
of the techniques described there, using package \Package{perpage},
may be applied to any counter.  The command:
\begin{quote}
\cmdinvoke*{MakePerPage}{counter}
\end{quote}
will cause \meta{counter} to be reset for each page.  The package uses
a label-like mechanism, and may require more than one run of \LaTeX{}
to stabilise counter values~--- \LaTeX{} will generate the usual
warnings about labels changing.
\begin{ctanrefs}
\item[chngcntr.sty]\CTANref{chngcntr}
\item[perpage.sty]Distributed as part \CTANref{bigfoot}
\end{ctanrefs}

\Question[Q-fontsize]{Fonts at arbitrary sizes}

Almost all fonts, nowadays, are provided with \LaTeX{} control
(\extension{fd}) files, so the temptation to risk the
\Qref*{problems of \csx{newfont}}{Q-newfont*} is usually easy to
resist.

However, one temptation remains, arising from the way that \LaTeX{}
restricts the sizes of fonts.  In fact, the restriction only
significantly applies to the default (Computer Modern) and the
Cork-encoded (\acro{T}1) EC fonts, but it is widely considered to be
anomalous, nowadays.  In recognition of this problem, there is a
package \Package{fix-cm} which will allow you to use the fonts, within
\LaTeX{}, at any size you choose.  If you're not using scaleable
versions of the fonts, most modern distributions will just generate an
appropriate bitmap for you.

So, suppose you want to use Computer Modern Roman at 30 points, you
might be tempted to write:
\begin{quote}
\begin{verbatim}
\newfont{\bigfont}{cmr10 at 30pt}
\begin{center}
  \bigfont Huge text
\end{center}
\end{verbatim}
\end{quote}
which will indeed work, but will actually produce a worse result than
\begin{quote}
\begin{verbatim}
\usepackage{fix-cm}
...
\begin{center}
  \fontsize{30}{36}\selectfont
  Huge text
\end{center}
\end{verbatim}
\end{quote}
Note that the \Package{fix-cm} package was not distributed until the
December 2003 edition of \LaTeX{}; if you have an older distribution,
the packages \Package{type1cm} (for \acro{CM} fonts) and
\Package{type1ec} (for \acro{EC} fonts) are available.
\begin{ctanrefs}
\item[fix-cm.sty]Distributed as part of \CTANref{latex} (an unpacked
  version is available at \CTANref{fix-cm})
\item[type1cm.sty]\CTANref{type1cm}
\item[type1ec.sty]\CTANref{type1ec} (the package is actually part of
  the \CTANref{cm-super} distribution, but it works happily in
  the absence of the scaled fonts)
\end{ctanrefs}

\Question[Q-latexqual]{The quality of your \LaTeX{}}

The \Package{l2tabu} tutorial (mentioned in % ! line break
\Qref[question]{online introductions}{Q-man-latex}) is undoubtedly a
good read.

However, it's always difficult to remember the things you should
\emph{not} do, when there are so many things to remember that you
really must do: some automation is needed\dots{}.

The nicely-named \Package{nag} allows you to apply a configurable set
of checks to your document, as you run it through \LaTeX{}; you get
messages like:
\begin{quote}
\begin{wideversion}
\begin{verbatim}
Package nag Warning: Command \bf is an old LaTeX 2.09 command. 
(nag)                Use \bfseries or \textbf instead on input line 30.
\end{verbatim}
\end{wideversion}
\begin{narrowversion}
\begin{verbatim}
Package nag Warning: Command \bf is an old
                          LaTeX 2.09 command. 
(nag)                Use \bfseries or \textbf
                    instead on input line 30.
\end{verbatim}
\end{narrowversion}
\end{quote}
\begin{wideversion}
  (the package provides a demo file which contains most of the sorts
  of errors you might make~--- this is one of them).
\end{wideversion}
\begin{narrowversion}
  (the two error lines both wrapped above; the package provides a demo
  file which contains most of the sorts of errors you might make~---
  this is one of them).
\end{narrowversion}

There's also a web site
\href{http://www.kohm.name/markus/texidate.html}{TeXidate}
which will do a static analysis of your document (unfortunately, you
have to paste your document source into a text window).  The site
doesn't seem as comprehensive as \Package{nag}, but it allows you to
download its script, which you can then juggle with to make it more
draconian.
\begin{ctanrefs}
\item[l2tabu]Browse \CTANref{l2tabu} for a copy in a language that's
  convenient for you
\item[nag.sty]\CTANref{nag}
\end{ctanrefs}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\section{Things are Going Wrong\dots{}}

\subsection{Getting things to fit}
\Question[Q-enlarge]{Enlarging \TeX{}}

The \TeX{} error message `capacity exceeded' covers a multitude of
problems.  What has been exhausted is listed in brackets after the
error message itself, as in:
\begin{quote}
\begin{verbatim}
! TeX capacity exceeded, sorry
...              [main memory size=263001].
\end{verbatim}
\end{quote}
Most of the time this error can be fixed
\emph{without} enlarging \TeX{}. The most common causes are unmatched braces,
extra-long lines, and poorly-written macros. Extra-long lines are
often introduced when files are transferred incorrectly between
operating systems, and line-endings are not preserved properly (the
tell-tale sign of an extra-long line error is the complaint
that the `|buf_size|' has overflowed).

If you really need to extend your \TeX{}'s capacity, the proper method
depends on your installation.  There is no need (with modern \TeX{}
implementations) to change the defaults in Knuth's \acro{WEB} source;
but if you do need to do so, use a change file to modify the values set in
module 11, recompile your \TeX{} and regenerate all format files.

Modern implementations allow the sizes of the various bits of \TeX{}'s
memory to be changed semi-dynamically.  Some (such as em\TeX{}) allow
the memory parameters to be changed in command-line switches when
\TeX{} is started; most frequently, a configuration file is read which
specifies the size of the memory.  On \ProgName{web2c}-based systems,
this file is called \File{texmf.cnf}: see the documentation that comes
with the distribution for other implementations.  Almost invariably,
after such a change, the format files need to be regenerated after
changing the memory parameters.

\Question[Q-usepictex]{Why can't I load \PiCTeX{}?}

\PiCTeX{} is a resource hog; fortunately, most modern \TeX{}
implementations offer generous amounts of space, and most modern
computers are pretty fast, so users aren't too badly affected by its
performance.

However, \PiCTeX{} has the further unfortunate tendency to fill up
\TeX{}'s fixed-size arrays~--- notably the array of 256 `dimension'
registers.  This is a particular problem when you're using
\File{pictex.sty} with \LaTeX{} and some other packages that also need
dimension registers.  When this happens, you will see the \TeX{} error
message:
\begin{quote}
\begin{verbatim}
! No room for a new \dimen.
\end{verbatim}
\end{quote}
There is nothing that can directly be done about this error: you
can't extend the number of available \csx{dimen} registers without
extending \TeX{} itself.
\begin{wideversion} % hyper
  \Qref{\eTeX{}}{Q-etex} and \Qref{Omega}{Q-omegaleph} both do this, as
  does \Qref{MicroPress Inc's V\TeX{}}{Q-commercial}.
\end{wideversion}
\begin{narrowversion}
  \eTeX{} and \ensuremath{\Omega}~--- \Qref[see questions]{}{Q-etex}
  \Qref[and]{}{Q-omegaleph} respectively~--- both do this, as does
  MicroPress Inc's V\TeX{}~--- \Qref{}{Q-commercial}.
\end{narrowversion}

It's actually quite practical (with most modern distributions) to use
\eTeX{}'s extended register set: use package \Package{etex} (which
comes with \eTeX{} distributions) and the allocation mechanism is
altered to cope with the larger register set: \PiCTeX{} will now load.

If you're in some situation where you can't use \eTeX{}, you need to change
\PiCTeX{}; unfortunately \PiCTeX{}'s author is no longer active in the
\TeX{} world, so one must resort to patching.  There are two solutions
available.

The \CONTeXT{} module \File{m-pictex.tex} (for \plaintex{} and
variants) or the corresponding \LaTeX{} \Package{m-pictex} package provide
an ingenious solution to the problem based on hacking the code of
\csx{newdimen} itself.

Alternatively, Andreas Schell's \Package{pictexwd} and related
packages replace \PiCTeX{} with a version that uses 33 fewer
\csx{dimen} registers; so use \Package{pictexwd} in place of
\Package{pictex} (either as a \LaTeX{} package, or as a file to read
into \plaintex{}).

And how does one use \PiCTeX{} anyway, given that the
manual is so \Qref*{hard to come by}{Q-docpictex}?
Fortunately for us all, the \ProgName{MathsPic}
system may be used to translate a somewhat different language into
\PiCTeX{} commands; and the \ProgName{MathsPic} manual is free (and
part of the distribution).  \ProgName{MathsPic} is available either as
a \ProgName{Basic} program for \acro{DOS}, or as a \ProgName{Perl}
program for other systems (including Windows, nowadays).
\begin{ctanrefs}
\item[m-pictex.sty]Distributed as part of \CTANref{context-tmf}
\item[m-pictex.tex]Distributed as part of \CTANref{context-tmf}
\item[MathsPic]\CTANref{mathspic}
\item[pictexwd.sty]Distributed as part of \CTANref{pictex-addon}
\end{ctanrefs}

\subsection{Making things stay where you want them}

\Question[Q-floats]{Moving tables and figures in \LaTeX{}}

Tables and figures have a tendency to surprise, by \emph{floating}
away from where they were specified to appear.  This is in fact
perfectly ordinary document design; any professional typesetting
package will float figures and tables to where they'll fit without
violating the certain typographic rules.  Even if you use the
placement specifier~\texttt{h} for `here', the figure or table will not be
printed `here' if doing so would break the rules; the rules themselves
are pretty simple, and are given on page~198, section~C.9 of the
\LaTeX{} manual.  In the worst case, \LaTeX{}'s rules can cause the
floating items to pile up to the extent that you get an error message
saying \Qref*{``Too many unprocessed floats''}{Q-tmupfl}.
What follows is a simple checklist of things to do to solve these
problems (the checklist talks throughout about figures, but applies
equally well to tables, or to ``non-standard'' floats defined by the
\Package{float} or other packages).
\begin{itemize}
\item Do your figures need to float at all?  If not, look at the
  recommendations for ``\Qref*{non-floating floats}{Q-figurehere}''
\item Are the placement parameters on your figures right?  The
  default (\texttt{tbp}) is reasonable, but you can reasonably change it (for
  example, to add an \texttt{h}).  Whatever you do, \emph{don't}
  omit the `\texttt{p}': doing so could cause \LaTeX{} to believe that if you
  can't have your figure \emph{here}, you don't want it
  \emph{anywhere}.  (\LaTeX{} does try hard to avoid being confused in
  this way\dots{})
\item \LaTeX{}'s own float placement parameters could be preventing
  placements that seem entirely ``reasonable'' to you~--- they're
  notoriously rather conservative.  To encourage \LaTeX{} not to move
  your figure, you need to loosen its demands.  (The most important
  ones are the ratio of text to float on a given page, but it's
  sensible to have a fixed set that changes the whole lot, to meet
  every eventuality.)
\begin{verbatim}
\renewcommand{\topfraction}{.85}
\renewcommand{\bottomfraction}{.7}
\renewcommand{\textfraction}{.15}
\renewcommand{\floatpagefraction}{.66}
\renewcommand{\dbltopfraction}{.66}
\renewcommand{\dblfloatpagefraction}{.66}
\setcounter{topnumber}{9}
\setcounter{bottomnumber}{9}
\setcounter{totalnumber}{20}
\setcounter{dbltopnumber}{9}
\end{verbatim}
  The meanings of these
  parameters are described on pages~199--200, section~C.9 of the
  \LaTeX{} manual.
\item Are there places in your document where you could `naturally'
  put a \csx{clearpage} command?  If so, do: the backlog of floats is
  cleared after a \csx{clearpage}.  (Note that the \csx{chapter}
  command in the standard \Class{book} and \Class{report} classes
  implicitly executes \csx{clearpage}, so you can't float past
  the end of a chapter.)
\item Try the \Package{placeins} package: it defines a
  \csx{FloatBarrier} command beyond which floats may not pass.  A
  package option allows you to declare that floats may not pass a
  \csx{section} command, but you can place \csx{FloatBarrier}s wherever
  you choose.
\item If you are bothered by floats appearing at the top of the page
  (before they are specified in your text), try the \Package{flafter}
  package, which avoids this problem by insisting that floats should
  always appear after their definition.
\item Have a look at the \LaTeXe{} \Package{afterpage} package.
  Its documentation gives as an example the idea
  of putting \csx{clearpage} \emph{after} the current page (where it
  will clear the backlog, but not cause an ugly gap in your text), but
  also admits that the package is somewhat fragile.  Use it as a last
  resort if the other possibilities below don't help.
\item If you would actually \emph{like} great blocks of floats at the
  end of each of your chapters, try the \Package{morefloats} package;
  this `simply' increases the number of floating inserts that \LaTeX{}
  can handle at one time (from~18 to~36).
\item If you actually \emph{wanted} all your figures to float to the
  end (\emph{e.g}., for submitting a draft copy of a paper), don't
  rely on \LaTeX{}'s mechanism: get the \Package{endfloat} package to do
  the job for you.
\end{itemize}
\begin{ctanrefs}
\item[afterpage.sty]Distributed as part of \CTANref{2etools}
\item[endfloat.sty]\CTANref{endfloat}
\item[flafter.sty]Part of the \LaTeX{} distribution
\item[float.sty]\CTANref{float}
\item[morefloats.sty]\CTANref{morefloats}
\item[placeins.sty]\CTANref{placeins}
\end{ctanrefs}

\Question[Q-underline]{Underlined text won't break}

Knuth made no provision for underlining text: he took the view that
underlining is not a typesetting operation, but rather one that
provides emphasis on typewriters, which typically offer but one
typeface.  The corresponding technique in typeset text is to switch
from upright to italic text (or vice-versa): the \LaTeX{} command
\csx{emph} does just that to its argument.

Nevertheless, typographically illiterate people (such as those that
specify double-spaced
\nothtml{thesis styles~--- }\Qref{thesis styles}{Q-linespace})
continue to require underlining of us, so \LaTeX{} as distributed
defines an \csx{underline} command that applies the mathematical
`underbar' operation to text.  This technique is not entirely
satisfactory, however: the text gets stuck into a box, and won't break
at line end.

Two packages are available that solve this problem.  The
\Package{ulem} package redefines the
\csx{emph} command to underline its argument; the underlined text thus
produced behaves as ordinary emphasised text, and will break over the
end of a line.  (The package is capable of other peculiar effects,
too: read its documentation, contained within the file itself.)
The \Package{soul} package defines an \csx{ul} command (after which the
package is, in part, named) that underlines running text.

Beware of \Package{ulem}'s default behaviour, which is to convert the
\csx{emph} command into an underlining command; this can be avoided by
loading the package with:
\begin{verbatim}
  \usepackage[normalem]{ulem}
\end{verbatim}
Documentation of \Package{ulem} is in the package itself.
\begin{ctanrefs}
\item[ulem.sty]\CTANref{ulem}
\item[soul.sty]\CTANref{soul}
\end{ctanrefs}

\Question[Q-widows]{Controlling widows and orphans}

Widows (the last line of a paragraph at the start of a page) and
orphans (the first line of paragraph at the end of a page) interrupt
the reader's flow, and are generally considered ``bad form'';
\AllTeX{} takes some precautions to avoid them, but completely
automatic prevention is often impossible.  If you are typesetting your
own text, consider whether you can bring yourself to change the
wording slightly so that the page break will fall differently.

The page maker, when forming a page, takes account of
\csx{widowpenalty} and \csx{clubpenalty} (which relates to orphans!).
These penalties are usually set to the moderate value of \texttt{150}; this
offers mild discouragement of bad breaks.  You can increase the values
by saying (for example) \csx{widowpenalty}\texttt{=500}; however, vertical
lists (such as pages are made of) typically have rather little
stretchability or shrinkability, so if the page maker has to balance
the effect of stretching the unstretchable and being penalised, the
penalty will seldom win.  Therefore, for typical layouts, there are
only two sensible settings for the penalties: finite (150 or 500, it
doesn't matter which) to allow widows and orphans, and infinite (10000
or greater) to forbid them.

The problem can be avoided by allowing
the pagemaker to run pages short, by using the \csx{raggedbottom}
directive; however, many publishers insist on the default
\csx{flushbottom}; it is seldom acceptable to introduce stretchability
into the vertical list, except at points (such as section headings)
where the document design explicitly permits it.

Once you've exhausted the automatic measures, and have a final draft
you want to ``polish'', you should proceed to manual measures.  To
get rid of an orphan is simple: precede the paragraph with
\csx{clearpage} and the paragraph can't start in the wrong place.

Getting rid of a widow can be more tricky.  If the paragraph is a long
one, it may be possible to set it `tight': say \csx{looseness}\texttt{=-1}
immediately after the last word of the paragraph.  If that doesn't
work, try adjusting the page size:
\cmdinvoke{enlargethispage}{\csx{baselineskip}} may do the job, and
get the whole paragraph on one page.  Reducing the size of the page by
\cmdinvoke{enlargethispage}{-\csx{baselineskip}} may produce a
(more-or-less) acceptable ``two-line widow''.  (Note:
\csx{looseness}\texttt{=1},
increasing the line length by one, seldom seems to work~--- the looser
paragraph typically has a one-word final line, which doesn't look much
better than the straight widow.)

\subsection{Things have ``gone away''}

\Question[Q-oldfontnames]{Old \LaTeX{} font references such as \csx{tenrm}}

\LaTeXo{} defined a large set of commands for access to the fonts
that it had built in to itself.  For example, various flavours of
|cmr| could be found as \csx{fivrm}, \csx{sixrm}, \csx{sevrm},
\csx{egtrm}, \csx{ninrm}, \csx{tenrm}, \csx{elvrm}, \csx{twlrm},
\csx{frtnrm}, \csx{svtnrm}, \csx{twtyrm} and \csx{twfvrm}.
These commands were never documented, but certain packages
nevertheless used them to achieve effects they needed.

Since the commands weren't public, they weren't included in \LaTeXe{};
to use the unconverted \LaTeXo{} packages under \LaTeXe{}, you need
also to include the \Package{rawfonts} package (which is part of the
\LaTeXe{} distribution).

\Question[Q-misssymb]{Missing symbol commands}

You're processing an old document, and some symbol commands such as
\csx{Box} and \csx{lhd} appear no longer to exist.  These commands were
present in the core of \LaTeXo{}, but are not in current \LaTeX{}.
They are available in the \Package{latexsym} package (which is part of
the \LaTeX{} distribution), and in the \Package{amsfonts} package
(which is part of the \acro{AMS} distribution, and requires \acro{AMS}
symbol fonts).
\begin{ctanrefs}
\item[amsfonts.sty]\CTANref{amsfonts-latex}
\item[AMS symbol fonts]\CTANref{amsfonts-symbols}
\end{ctanrefs}

\Question[Q-msxy]{Where are the \texttt{msx} and \texttt{msy} fonts?}

The \FontName{msx} and \FontName{msy} fonts were designed by the
American Mathematical Society in the very early days of \TeX{}, for
use in typesetting papers for mathematical journals.  They were
designed using the `old' \MF{}, which wasn't portable and is no longer
available; for a long time they were only available in 300dpi versions
which only imperfectly matched modern printers.  The \acro{AMS} has
now redesigned the fonts, using the current version of \MF{}, and the
new versions are called the \FontName{msa} and \FontName{msb}
families.

Nevertheless, \FontName{msx} and \FontName{msy} continue to turn up to
plague us.  There are, of course, still sites that haven't got around
to upgrading; but, even if everyone upgraded, there would still be the
problem of old documents that specify them.

If you have a \extension{tex} source that requests \FontName{msx} and
\FontName{msy}, the best technique is to edit it so that it requests
\FontName{msa} and \FontName{msb} (you only need to change the single
letter in the font names).

If you have a \acro{DVI} file that requests the fonts, there is a package
of \Qref*{virtual fonts}{Q-virtualfonts} to map the old to the new series.
\begin{ctanrefs}
\item[msa and msb fonts]\CTANref{amsfonts-symbols}
\item[virtual font set]\CTANref{msx2msa}
\end{ctanrefs}

%%%???%%% spell-checked to here....zzzyx

\Question[Q-amfonts]{Where are the \texttt{am} fonts?}

One \emph{still} occasionally comes across a request for the \FontName{am}
series of fonts.  The initials stood for `Almost [Computer] Modern',
and they were the predecessors of the Computer Modern fonts that we
all know and love (or hate)%
\begin{footnoteenv}
  The fonts acquired their label `Almost' following the realisation
  that their first implementation in \MF{}79 still wasn't quite right;
  Knuth's original intention had been that they were the final answer.
\end{footnoteenv}.
There's not a lot one can do with these
fonts; they are (as their name implies) almost (but not quite) the
same as the \FontName{cm} series; if you're faced with a document that requests
them, all you can reasonably do is to edit the document.  The
appearance of \acro{DVI} files that request them is sufficiently rare that
no-one has undertaken the mammoth task of creating a translation of
them by means of virtual fonts; however, most drivers let you have a
configuration file in which you can specify font substitutions. If you
specify that every \FontName{am} font should be replaced by its corresponding
\FontName{cm} font, the output should be almost correct.

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\section{Why does it \emph{do} that?}

\subsection{Common errors}

\Question[Q-crossref]{\LaTeX{} gets cross-references wrong}

Sometimes, however many times you run \LaTeX{}, the cross-references
are just wrong. Remember that
the \csx{label} command must come \emph{after} the \csx{caption} command, or
be part of it. For example,
\htmlignore
\par\noindent
\begin{tabular}{@{}lll}
|  \begin{figure}|     &    & |\begin{figure}|\\
|  \caption{A Figure}| & or & |\caption{A Figure%| \\
|  \label{fig}|        &    & |      \label{fig}}| \\
|  \end{figure}|       &    & |\end{figure}| \\
\end{tabular}
\endhtmlignore
\begin{htmlversion}
\begin{verbatim}
  \begin{figure}          \begin{figure}
  \caption{A Figure}  or  \caption{A Figure%
  \label{fig}                   \label{fig}}
  \end{figure}            \end{figure}
\end{verbatim}
\end{htmlversion}

You can, just as effectively, shield the \csx{caption} command from its
associated \csx{label} command, by enclosing the caption in an
environment of its own.  For example, people commonly seek help after:
\begin{quote}
\begin{verbatim}
\begin{center}
  \caption{A Figure}
\end{center}
\label{fig}
\end{verbatim}
\end{quote}
has failed to label correctly.  If you really need this centring (and
those in the know commonly reject it), code it as:
\begin{quote}
\begin{verbatim}
\begin{center}
  \caption{A Figure}
  \label{fig}
\end{center}
\end{verbatim}
\end{quote}

\Question[Q-newlineargs]{Start of line goes awry}
\keywords{asterisk square bracket start line}

This answer concerns two sorts of problems: errors of the form
\begin{quote}
\begin{verbatim}
! Missing number, treated as zero.
<to be read again> 
                   g
<*> [grump]
\end{verbatim}
\end{quote}
and those where a single asterisk at the start of a line mysteriously
fails to appear in the output.

Both problems arise because |\|{}|\| takes optional arguments.  The
command |\|{}|\*| means ``break the line here, and inhibit page break
following the line break''; the command |\|{}|\[|\meta{dimen}|]|
means ``break the line here and add \meta{dimen} extra vertical space
afterwards''.

So why does |\|{}|\| get confused by these things at the start of a
line?  It's looking for the first non-blank thing, and in the test it
uses ignores the end of the line in your input text.

The solution is to enclose the stuff at the start of the new line in
braces:
\begin{quote}
\begin{verbatim}
{\ttfamily
  /* C-language comment\\
  {[grump]} I don't like this format\\
  {*}/
}
\end{verbatim}
\end{quote}
(The above text derives from an actual post to
\Newsgroup{comp.text.tex}; this particular bit of typesetting could
plainly also be done using the \environment{verbatim} environment.)

The problem also appears in maths mode, in arrays and so on.  In this
case, large-scale bracketing of things is \emph{not} a good idea; the
\TeX{} primitive \csx{relax} (which does nothing except to block
searches of this nature) may be used.  From another
\Newsgroup{comp.text.tex} example:
\begin{quote}
\begin{verbatim}
\begin{eqnarray}
  [a] &=& b \\
  \relax[a] &=& b
\end{eqnarray}
\end{verbatim}
\end{quote}
which is a usage this \acro{FAQ} would not recommend, anyway: refer
to the \Qref*{reason not to use \environment{eqnarray}}{Q-eqnarray}.

Note that the \Package{amsmath} package modifies the behaviour of
\texttt{\bsbs } in maths.  With \Package{amsmath}, the \environment{eqnarray}
example doesn't need any special measures.

\Question[Q-verbwithin]{Why doesn't verbatim work within\,\dots{}?}

The \LaTeX{} verbatim commands work by changing category codes.  Knuth
says of this sort of thing ``Some care is needed to get the timing
right\dots{}'', since once the category code has been assigned to a
character, it doesn't change.  So \csx{verb} and
\cmdinvoke{begin}{verbatim} have to assume that they are getting the
first look at the parameter text; if they aren't, \TeX{} has already
assigned category codes so that the verbatim command doesn't have a
chance.  For example:
\begin{quote}
\begin{verbatim}
\verb+\error+
\end{verbatim}
\end{quote}
will work (typesetting `\csx{error}'), but
\begin{quote}
\begin{verbatim}
\newcommand{\unbrace}[1]{#1}
\unbrace{\verb+\error+}
\end{verbatim}
\end{quote}
will not (it will attempt to execute \csx{error}).  Other errors one
may encounter are `\csx{verb} ended by end of line', or even the
rather more helpful `\csx{verb} illegal in command argument'.  The
same sorts of thing happen with \cmdinvoke{begin}{verbatim} \dots{}
\cmdinvoke{end}{verbatim}:
\begin{quote}
\begin{quoteverbatim}
\ifthenelse{\boolean{foo}}{%
\begin{verbatim}
foobar
\end{verbatim}
}{%
\begin{verbatim}
barfoo
\end{verbatim}
}
\end{quoteverbatim}
\end{quote}
provokes errors like `File ended while scanning use of
\csx{@xverbatim}', as \cmdinvoke{begin}{verbatim} fails to see its
matching \cmdinvoke{end}{verbatim}.

This is why the \LaTeX{} book insists that verbatim
commands must not appear in the argument of any other command; they
aren't just fragile, they're quite unusable in any command parameter,
regardless of \Qref*{\csx{protect}ion}{Q-protect}.  (The \csx{verb}
command tries hard to detect if you're misusing it; unfortunately, it
can't always do so, and the error message is therefore not a reliable
indication of problems.)

The first question to ask yourself is: ``is \csx{verb} actually
necessary?''.
\begin{itemize}
\item If \cmdinvoke{texttt}{\emph{your text}} produces the same result
  as \csx{verb}\texttt{+\emph{your text}+}, then there's no need of
  \csx{verb} in the first place.
\item If you're using \csx{verb} to typeset a \acro{URL} or email
  address or the like, then the \csx{url} command from the
  \Package{url} will help: it doesn't suffer from all the problems of
  \csx{verb}, though it's still not robust; % ! line break
  ''\Qref*{typesetting \acro{URL}s}{Q-setURL}'' offers advice here.
\item If you're putting \csx{verb} into the argument of a boxing
  command (such as \csx{fbox}), consider using the \environment{lrbox}
  environment:
\begin{quote}
\begin{verbatim}
\newsavebox{\mybox}
...
\begin{lrbox}{\mybox}
  \verb!VerbatimStuff!
\end{lrbox}
\fbox{\usebox{\mybox}}
\end{verbatim}
\end{quote}
\end{itemize}

Otherwise, there are three partial solutions to the problem.
\begin{itemize}
\item Some packages have macros which are designed to be responsive
  to verbatim text in their arguments.  For example,
  the \Package{fancyvrb} package defines a command
  \csx{VerbatimFootnotes}, which redefines the \csx{footnotetext} (and
  hence the \csx{footnote}) commands in such a way that you can include
  \csx{verb} commands in its argument.  This approach could in
  principle be extended to the arguments of other commands, but it can
  clash with other packages: for example, \csx{VerbatimFootnotes}
  interacts poorly with the |para| option to the \Package{footmisc}
  package.

  The \Class{memoir} class defines its \csx{footnote} command so that
  it will accept verbatim in its arguments, without any supporting package.
\item The \Package{fancyvrb} package defines a command \csx{SaveVerb},
  with a corresponding \csx{UseVerb} command, that allow you to save
  and then to reuse the content of its argument; for details of this
  extremely powerful facility, see the package documentation.

  Rather simpler is the \Package{verbdef} package, which defines a
  (robust) command which expands to the verbatim argument given.
\item If you have a single character that is giving trouble (in
  its absence you could simply use \csx{texttt}), consider using
  \csx{string}.  \cmdinvoke{texttt}{my\csx{string}\_name}
  typesets the same as 
  |\verb+my_name+|, and will work in the argument of a command.  It
  won't, however, work in a moving argument, and no amount of
  \Qref*{\csx{protect}ion}{Q-protect} will make it work in
  such a case.

  A robust alternative is:
  \begin{quote}
\begin{verbatim}
\chardef\us=`\_
...
\section{... \texttt{my\us name}}
\end{verbatim}
  \end{quote}
  Such a definition is `naturally' robust; the construction
  ``\meta{back-tick}\csx{\meta{char}}'' may be used for any
  troublesome character (though it's plainly not necessary for things
  like percent signs for which \AllTeX{} already provides
  robust macros).
\end{itemize}
Documentation of both \Package{url} and \Package{verbdef} is in the
package files.
\begin{ctanrefs}
\item[fancyvrb.sty]\CTANref{fancyvrb}
\item[memoir.cls]\CTANref{memoir}
\item[url.sty]\CTANref{url}
\item[verbdef.sty]\CTANref{verbdef}
\end{ctanrefs}

\Question[Q-noline]{No line here to end}

The error
\begin{quote}
\begin{wideversion}
\begin{verbatim}
! LaTeX Error: There's no line here to end.

See the LaTeX manual or LaTeX Companion for explanation.
\end{verbatim}
\end{wideversion}
\begin{narrowversion}
\begin{verbatim}
! LaTeX Error: There's no line here to end.

See the LaTeX manual or LaTeX Companion
...                           for explanation.
\end{verbatim}
\end{narrowversion}
\end{quote}
comes in reaction to you giving \LaTeX{} a |\|{}|\| command at a time
when it's not expecting it.  The commonest case is where you've
decided you want the label of a list item to be on a line of its own,
so you've written (for example):
\begin{quote}
\begin{verbatim}
\begin{description}
\item[Very long label] \\
  Text...
\end{description}
\end{verbatim}
\end{quote}
|\|{}|\| is actually a rather bad command to use in this case (even if
it worked), since it would force the `paragraph' that's made up of the
text of the item to terminate a line which has nothing on it but the
label.  This would lead to an ``|Underfull \hbox|'' warning message
(usually with `infinite' badness of 10000); while this message doesn't
do any actual harm other than slowing down your \LaTeX{} run, any
message that doesn't convey any information distracts for no useful
purpose.

The proper solution to the problem is to write a new sort of
\environment{description} environment, that does just what you're after.  (The
\nothtml{\emph{\LaTeX{} Companion}~--- see }% ! line wrap
\Qref[question]{\emph{\LaTeX{} Companion}}{Q-books}\nothtml{~---} offers a
rather wide selection of variants of these things.)

The quick-and-easy solution, which avoids the warning, is to write:
\begin{quote}
\begin{verbatim}
\begin{description}
\item[Very long label] \hspace*{\fill} \\
  Text...
\end{description}
\end{verbatim}
\end{quote}
which fills out the under-full line before forcing its closure.  The
\Package{expdlist} package provides the same functionality with its
\csx{breaklabel} command, and \Package{mdwlist} provides it via its
\csx{desclabelstyle} command.

The other common occasion for the message is when you're using the
\texttt{center} (or \environment{flushleft} or \environment{flushright})
environment, and have decided you need extra separation between lines
in the environment:
\begin{quote}
\begin{verbatim}
\begin{center}
  First (heading) line\\
  \\
  body of the centred text...
\end{center}
\end{verbatim}
\end{quote}
The solution here is plain: use the \texttt{\bsbs } command in the way it's
supposed to be used, to provide more than just a single line break
space.  \texttt{\bsbs } takes an optional argument, which specifies
how much extra space to add; the required effect in the text above can
be had by saying:
\begin{quote}
\begin{verbatim}
\begin{center}
  First (heading) line\\[\baselineskip]
  body of the centred text...
\end{center}
\end{verbatim}
\end{quote}
\begin{ctanrefs}
\item[expdlist.sty]\CTANref{expdlist}
\item[mdwlist.sty]Distributed as part of \CTANref{mdwtools}
\end{ctanrefs}

% other instances: \[no]linebreak in vertical mode

\Question[Q-2colfltorder]{Two-column float numbers out of order}

When \LaTeX{} can't place a float immediately, it places it on one of
several ``defer'' lists.  If another float of the same type comes
along, and the ``defer'' list for that type still has something in it,
the later float has to wait for everything earlier in the list.

Now, standard \LaTeX{} has different lists for single-column floats,
and double-column floats; this means that single-column figures can
overtake double-column figures (or vice-versa), and you observe later
figures appear in the document before early ones.  The same is true,
of course, for tables, or for any user-defined float.

The \LaTeX{} team recognise the problem, and provides a package
(\Package{fixltx2e}) to deal with it.  \Package{Fixltx2e} amalgamates
the two defer lists, so that floats don't get out of order.

For those who are still running an older \LaTeX{} distribution, the
package \Package{fix2col} should serve.  This package (also by a
member of the \LaTeX{} team) was the basis of the relevant part of
\Package{fixltx2e}.  The functionality has also been included in
\Package{dblfloatfix}, which also has code to place full-width floats
at \Qref*{\texttt{[b]} placement}{Q-2colfloat}.

Once you have loaded the package, no more remains to be done: the
whole requirement is to patch the output routine; no extra commands
are needed.
\begin{ctanrefs}
\item[dblfloatfix.sty]\CTANref{dblfloatfix}
\item[fix2col.sty]Distributed as part of \CTANref{carlisle}
\item[fixltx2e.sty]Part of the \LaTeX{} distribution
\end{ctanrefs}

\Question[Q-tabacc]{Accents misbehave in \environment{tabbing}}

So you are constructing a \environment{tabbing} environment, and you
have the need of some diacriticised text~--- perhaps something as simple
as \cmdinvoke{'}{e}~--- and the accent disappears because it has been
interpreted as a \environment{tabbing} command, and everything goes
wrong.

This is really a rather ghastly feature of the \environment{tabbing}
environment; in order to type accented characters you need to use the
\csx{a} kludge: so \cmdinvoke{a'}{e} inside \environment{tabbing} for
\cmdinvoke{'}{e} outside, and similarly \csx{a`} for \csx{`} and \csx{a=}
for \csx{=}.  This whole procedure is of course hideous and
error-prone.

The simplest alternative is to type in an encoding that has the
diacriticised characters in it, and to use an appropriate encoding
definition file in the \Package{inputenc} package.  So for example,
type:
\begin{quote}
  \cmdinvoke{usepackage}[latin1]{inputenc}\\
  \texttt{...}\\
  \cmdinvoke{begin}{tabbing}\\
  \texttt{...}\\
  \texttt{...} \csx{>} \texttt{voil\`a} \csx{>} \texttt{...}
\end{quote}
for:
\begin{quote}
  \dots{}\quad voil\`a\quad \dots{}
\end{quote}
and the internal mechanisms of the \Package{inputenc} package will put
the right version of the accent command in there.

A witty reversal of the r\^oles is introduced by the package
\Package{Tabbing} (note the capital ``T''): it provides a
\environment{Tabbing} environment which duplicates
\environment{tabbing}, but all the single-character commands become
complicated objects.  So \environment{tabbing}'s \csx{>} becomes
\csx{TAB>}, \csx{=} becomes \csx{TAB=}, and so on.  The above trivial
example would therefore become:
\begin{quote}
\begin{verbatim}
\usepackage{Tabbing}
...
\begin{Tabbing}
  ...  ... \TAB> voil\`a \TAB> ...
\end{verbatim}
\end{quote}
\begin{ctanrefs}
\item[Tabbing.sty]\CTANref{Tabbing}
\end{ctanrefs}

\Question[Q-alreadydef]{Package reports ``command already defined''}

You load a pair of packages, and the second reports that one of the
commands it defines is already present.  For example, both the
\Package{txfonts} and \Package{amsmath} define a command \csx{iint}
(and \csx{iiint} and so on); so
\begin{quote}
\begin{verbatim}
...
\usepackage{txfonts}
\usepackage{amsmath}
\end{verbatim}
\end{quote}
produces a string of error messages of the form:
\begin{quote}
\begin{wideversion}
\begin{verbatim}
! LaTeX Error: Command \iint already defined.
               Or name \end... illegal, see p.192 of the manual.
\end{verbatim}
\end{wideversion}
\begin{narrowversion}
\begin{verbatim}
! LaTeX Error: Command \iint already
   defined.  Or name \end... illegal,
   see p.192 of the manual.
\end{verbatim}
\end{narrowversion}
\end{quote}
As a general rule, things that \Package{amsmath} defines, it defines
well; however, there is a good case for using the \Package{txfonts}
version of \csx{iint}~--- the associated \FontName{tx} fonts have a
double integral symbol that doesn't need to be ``faked'' in the way
\Package{amsmath} does.  In the case that you are loading several
symbol packages, every one of which defines the same symbol, you are
likely to experience the problem in a big way (\csx{euro} is a common
victim).

There are similar cases where one package redefines another's command,
but no error occurs because the redefining package doesn't use
\csx{newcommand}.  Often, in such a case, you only notice the change
because you assume the definition given by the first package.  The
\Package{amsmath}--\Package{txfonts} packages are just such a pair;
\Package{txfonts} doesn't provoke errors.

You may deal with the problem by saving and restoring the command.
Macro programmers may care to do this for themselves; for the rest of
us, there's the package \Package{savesym}.  The sequence:
\begin{quote}
\begin{verbatim}
\usepackage{savesym}
\usepackage{amsmath}
\savesymbol{iint}
\usepackage{txfonts}
\restoresymbol{TXF}{iint}
\end{verbatim}
\end{quote}
does the job; restoring the \Package{amsmath} version of the command,
and making the \Package{txfonts} version of the command available as
\csx{TXFiint}.

Documentation of \Package{savesym} doesn't amount to much: the only
commands are \csx{savesymbol} and \csx{restoresymbol}, as noted above.
\begin{ctanrefs}
\item[amsmath.sty]Part of \CTANref{amslatex}
\item[savesym.sty]\CTANref{savesym}
\item[txfonts.sty]Part of \CTANref{txfonts}
\end{ctanrefs}

\Question[Q-zerochap]{Why are my sections numbered 0.1\,\dots{}?}

This happens when your document is using the standard \Class{book} or
\Class{report} class (or one similar), and you've got a \csx{section}
before your first \csx{chapter}.

What happens is, that the class numbers sections as % ! line break
``\meta{chapter no}.\meta{section no}'', and until the first
chapter has appeared, the chapter number is 0.

If you're doing this, it's quite likely that the \Class{article} class
is for you; try it and see.  Otherwise, give your sections a
`superior' chapter, or do away with section numbering by using
\csx{section*} instead.  An alternative way of avoiding numbering is
discussed in % ! line break
``\Qref*{unnumbered sections in the table of contents}{Q-secnumdep}''.

\Question[Q-breaklinks]{Link text doesn't break at end line}
\keywords{hyperref overfull link}

When using the \Package{hyperref} package, you make a block of text
``active'' when you define a hyper-link (when the user clicks on
that text, the reader program will divert to the \emph{target} of the
link).

The \Package{hyperref} package uses a \emph{driver} (in the same way
as the \Package{graphics} package does), to determine how to implement
all that hyper-stuff.

If you use the driver for \ProgName{dvips} output (presumably you want
to distill the resulting \PS{}), limitations in the way \ProgName{dvips}
deals with the \csx{special} commands mean that \Package{hyperref}
must prevent link anchors from breaking at the end of lines.  Other
drivers (notably those for \PDFTeX{} and for \ProgName{dvipdfm}) don't
suffer from this problem.

The problem may occur in a number of different circumstances.  For a
couple of them, there are work-arounds:

First, if you have an \acro{URL} which is active (so that clicking on
it will activate your web browser to ``go to'' the \acro{URL}).  In
this case \Package{hyperref} employs the \Package{url} package to
split up the \acro{URL} (as described in % ! line break
\Qref[question]{typesetting \acro{URL}s}{Q-setURL}), but the
\ProgName{dvips} driver then suppresses the breaks.  The way out is
the \Package{breakurl} package, which modifies the \csx{url} command
to produce several smaller pieces, between each of which a line break
is permitted.  Each group of pieces, that ends up together in one
line, is converted to a single clickable link.

Second, if you have a table of contents, list of figure or tables, or
the like, \Package{hyperref} will ordinarily make the titles in the
table of contents, or captions in the lists, active.  If the title or
caption is long, it will need to break within the table, but the
\ProgName{dvips} driver will prevent that.  In this case, load
\Package{hyperref} with the option \pkgoption{linktocpage}, and only
the page number will be made active.

Otherwise, if you have a lengthy piece of text that you want active,
you have at present no simple solution: you have to rewrite your text,
or to use a different \acro{PDF} generation mechanism.
\begin{ctanrefs}
\item[breakurl.sty]\CTANref{breakurl}
\end{ctanrefs}

\Question[Q-wrongpn]{Page number is wrong at start of page}

This is a long story, whose sources are deep inside the workings of
\TeX{} itself; it all derives from the \TeX{}'s striving to generate
the best possible output.

The page number is conventionally stored in \csx{count0}; \LaTeX{}
users see this as the counter \texttt{page}, and may typeset its value
using \csx{thepage}.

The number (that is to say, \csx{count0}) is only updated when \TeX{}
actually outputs a page.  \TeX{} only even tries to do this when it
detects a hint that it may be a good thing to do.  From \TeX{}'s point
of view, the end of a paragraph is a good time to consider outputting
a page; it will output a page if it has \emph{more} than a page's
worth of material to output.  (Ensuring it always has something in
hand makes some optimisations possible.)  As a result, \csx{count0}
(\csx{thepage}) is almost always wrong in the first paragraph of a
page (the exception is where the page number has been ``forcibly''
changed, either by changing its value directly, or by breaking the
page where \TeX{} wouldn't necessarily have chosen to break).

\LaTeX{} provides a safe way of referring to the page number, by using
label references.  So, rather than writing:
\begin{quote}
\begin{verbatim}
Here is page \thepage{}.
\end{verbatim}
\end{quote}
you should write:
\begin{quote}
\begin{verbatim}
Here is page \pageref{here}\label{here}.
\end{verbatim}
\end{quote}
(note: no space between the \csx{pageref} and the \csx{label}, since
that could potentially end up as a page-break space itself, which
rather defeats the purpose of the exercise!).

\Question[Q-matchbrak]{My brackets don't match}

\AllTeX{} has a low-level mechanism for matching braces in document
text.  This means you can type something like:
\begin{quote}
\begin{verbatim}
\section{All \emph{OK} now.}
\end{verbatim}
\end{quote}
and know that the first brace (for the argument of \csx{section}) will
be matched with the last brace, and the internal pair of braces (for
the argument of \csx{emph}) will be matched with each other.  It's all
very simple.

However, \LaTeX{} has a convention of enclosing optional arguments in
brackets, as in:
\begin{quote}
\begin{verbatim}
\section[OK]{All \emph{OK} now.}
\end{verbatim}
\end{quote}
These brackets are not matched by \TeX{} mechanisms, despite the
superficial similarity of their use.  As a result,
straightforward-looking usages like:
\begin{quote}
\begin{verbatim}
\section[All [OK] now]{All \emph{OK} now.}
\end{verbatim}
\end{quote}
aren't \acro{OK} at all~--- the optional argument comes to consist of
``All [OK'', and \csx{section} takes the single character ``n'' (of
the first ``now'') as its argument.

Fortunately, \TeX{}'s scanning mechanisms helps us by accepting the
syntax ``\texttt{\{]\}}'' to `hide' the closing bracket from the
scanning mechanism that \LaTeX{} uses.  In practice, the commonest way
to use this facility is:
\begin{quote}
\begin{verbatim}
\section[All {[OK]} now]{All \emph{OK} now.}
\end{verbatim}
\end{quote}
since bracing the bracket on its own ``looks odd''.

\LaTeX{} has another argument syntax, even less regular, where the
argument is enclosed in parentheses, as in:
\begin{quote}
\begin{verbatim}
\put(1,2){foo}
\end{verbatim}
\end{quote}
(a picture environment command).

This mechanism is also prone to problems with matching closing
parentheses, but the issue seldom arises since such arguments rarely
contain text.  If it were to arise, the same solution (enclosing the
confused characters in braces) would solve the problem.

\subsection{Common misunderstandings}

\Question[Q-include]{What's going on in my \csx{include} commands?}

The original \LaTeX{} provided the \csx{include} command to address the
problem of long documents: with the relatively slow computers of the
time, the companion \csx{includeonly} facility was a boon.  With the
vast increase in computer speed, \csx{includeonly} is less valuable
(though it still has its place in some very large projects).
Nevertheless, the facility is retained in current \LaTeX{}, and causes
some confusion to those who misunderstand it.

In order for \csx{includeonly} to work, \csx{include} makes a separate
\extension{aux} file for each included file, and makes a `checkpoint' of
important parameters (such as page, figure, table and footnote
numbers); as a direct result, it \emph{must} clear the current page
both before and after the \csx{include} command.  What's more, this
mechanism doesn't work if a \csx{include} command appears in a file
that was \csx{include}d itself: \LaTeX{} diagnoses this as an error.

So, we can now answer the two commonest questions about \csx{include}:
\begin{itemize}
\item Why does \LaTeX{} throw a page before and after \csx{include}
  commands?

  Answer: because it has to.  If you don't like it, replace the
  \csx{include} command with \csx{input}~--- you won't be able to use
  \csx{includeonly} any more, but you probably don't need it anyway, so
  don't worry.
\begin{htmlversion}

\end{htmlversion}
\item Why can't I nest \csx{include}d files?~--- I always used to be
  able to under \LaTeXo{}.

  Answer: in fact, you couldn't, even under \LaTeXo{}, but the failure
  wasn't diagnosed.  However, since you were happy with the behaviour
  under \LaTeXo{}, replace the \csx{include} commands with \csx{input}
  commands (with \csx{clearpage} as appropriate).
\end{itemize}


\Question[Q-paraparam]{Why does it ignore paragraph parameters?}

When \TeX{} is laying out text, it doesn't work from word to word, or
from line to line; the smallest complete unit it formats is the
paragraph.  The paragraph is laid down in a buffer, as it appears, and
isn't touched further until the end-paragraph marker is processed.
It's at this point that the paragraph parameters have effect; and it's
because of this sequence that one often makes mistakes that lead to
the paragraph parameters not doing what one would have hoped (or
expected).

Consider the following sequence of \LaTeX{}:
\begin{quote}
\begin{verbatim}
{\raggedright % declaration for ragged text
Here's text to be ranged left in our output,
but it's the only such paragraph, so we now
end the group.}

Here's more that needn't be ragged...
\end{verbatim}
\end{quote}
\TeX{} will open a group, and impose the ragged-setting parameters within
that group; it will then save a couple of sentences of text and
close the group (thus restoring the previous value of the
parameters that \csx{raggedright} set).  Then \TeX{} encounters a blank
line, which it knows to treat as a \csx{par} token, so it typesets the
two sentences; but because the enclosing group has now been closed,
the parameter settings have been lost, and the paragraph will be
typeset normally.

The solution is simple: close the paragraph inside the group, so that
the setting parameters remain in place.  An appropriate way of doing
that is to replace the last three lines above with:
\begin{quote}
\begin{verbatim}
end the group.\par}
Here's more that needn't be ragged...
\end{verbatim}
\end{quote}
In this way, the paragraph is completed while \csx{raggedright}'s
parameters are still in force within the enclosing group.

Another alternative is to define an environment that does the
appropriate job for you.  For the above example, \LaTeX{} already
defines an appropriate one:
\begin{quote}
\begin{verbatim}
\begin{flushleft}
Here's text to be ranged left...
\end{flushleft}
\end{verbatim}
\end{quote}

In fact, there are a number of parameters for which \TeX{} only
maintains one value per paragraph.  A tiresome one is the set of upper
case/lower case translations, which (oddly enough) constrains
hyphenation of mutilingual texts.  Another that regularly creates
confusion is \Qref*{\csx{baselineskip}}{Q-baselinepar}.

\Question[Q-casechange]{Case-changing oddities}

\TeX{} provides two primitive commands \csx{uppercase} and
\csx{lowercase} to change the case of text; they're not much used, but
are capable creating confusion.

The two commands do not expand the text that is their parameter~---
the result of \cmdinvoke{uppercase}{abc} is `\texttt{ABC}', but
\cmdinvoke{uppercase}{\csx{abc}} is always `\csx{abc}', whatever the
meaning of \csx{abc}.  The commands are simply interpreting a table of
equivalences between upper- and lowercase characters.
They have (for example) no mathematical sense, and
\begin{quote}
\begin{verbatim}
\uppercase{About $y=f(x)$}
\end{verbatim}
\end{quote}
will produce
\begin{quote}
\begin{verbatim}
ABOUT $Y=F(X)$
\end{verbatim}
\end{quote}
which is probably not what is wanted.

In addition, \csx{uppercase} and \csx{lowercase} do not deal very well
with non-American characters, for example
\cmdinvoke{uppercase}{\csx{ae}} is the same as \csx{ae}.

\LaTeX{} provides commands \csx{MakeUppercase} and \csx{MakeLowercase}
which fixes the latter problem.  These commands are used in the
standard classes to produce upper case running heads for chapters
and sections.

Unfortunately \csx{MakeUppercase} and \csx{MakeLowercase} do not solve
the other problems with \csx{uppercase}, so for example a section
title containing \cmdinvoke{begin}{tabular} \dots{}
\cmdinvoke{end}{tabular} will produce a running head containing
\cmdinvoke{begin}{TABULAR}.  The simplest solution to this problem is
using a user-defined command, for example: 
\begin{quote}
\begin{verbatim}
\newcommand{\mytable}{\begin{tabular}...
  \end{tabular}}
\section{A section title \protect\mytable{}
  with a table}
\end{verbatim}
\end{quote}
Note that \csx{mytable} has to be protected, otherwise it will be
expanded and made upper case; you can achieve the same result by
declaring it with \csx{DeclareRobustCommand}, in which case the
\csx{protect} won't be necessary.

David Carlisle's \Package{textcase} package
addresses many of these problems in a transparent way.  It defines
commands \csx{MakeTextUppercase} and \csx{MakeTextLowercase} which do
upper- or lowercase, with the fancier features of the \LaTeX{}
standard \csx{Make*}-commands but without the problems
mentioned above.  Load the package with
\cmdinvoke{usepackage}[overload]{textcase}, and it will redefine the \LaTeX{}
commands (\emph{not} the \TeX{} primitive commands \csx{uppercase} and
\csx{lowercase}), so that section headings and the like don't produce
broken page headings.
\begin{ctanrefs}
\item[textcase.sty]\CTANref{textcase}
\end{ctanrefs}

\Question[Q-splitfoot]{Why does \LaTeX{} split footnotes across pages?}

\LaTeX{} splits footnotes when it can think of nothing better to do.
Typically, when this happens, the footnote mark is at the bottom of
the page, and the complete footnote would overfill the page.  \LaTeX{}
could try to salvage this problem by making the page short of both the
footnote and the line with the footnote mark, but its priorities told
it that splitting the footnote would be preferable.

As always, the best solution is to change your text so that the
problem doesn't occur in the first place.  Consider whether the text
that bears the footnote could move earlier in the current page, or on
to the next page.

If this isn't possible, you might want to change \LaTeX{}'s perception
of its priorities: they're controlled by
\csx{interfootnotelinepenalty}~--- the larger it is, the less willing
\LaTeX{} is to split footnotes.

Setting
\begin{quote}
\begin{verbatim}
\interfootnotelinepenalty=10000
\end{verbatim}
\end{quote}
inhibits split footnotes altogether, which will cause `\texttt{Underfull}
\csx{vbox}' messages unless you also specify \csx{raggedbottom}.  The
default value of the penalty is \texttt{100}, which is rather mild.

An alternative technique is to juggle with the actual size of the
pages.  \csx{enlargethispage} changes the size of the current page by
its argument (for example, you might say
\cmdinvoke{enlargethispage}{\csx{baselineskip}} to add a single line
to the page, but you can use any ordinary \TeX{} length such as
\texttt{15mm} or \texttt{-20pt} as argument).  Reducing the size of
the current page could force the offending text to the next page;
increasing the size of the page may allow the footnote to be included
in its entirety.  It may be necessary to change the size of more than
one page.

The \Package{fnbreak} package detects (and generates warnings about)
split footnotes.
\begin{ctanrefs}
\item[fnbreak.sty]\CTANref{fnbreak}
\end{ctanrefs}

\Question[Q-marginparside]{Getting \csx{marginpar} on the right side}

In an ideal world, marginal notes would be in ``analogous'' places on
every page: notes on an even-side page would be in the left margin,
while those on an odd-side page would be in the right margin.  A
moment's thought shows that a marginal note on the left needs to be
typeset differently from a marginal note on the right.  The \LaTeX{}
\csx{marginpar} command therefore takes two arguments in a
\texttt{twoside} documents: % beware line break
\cmdinvoke*{marginpar}[left text]{right text}.  \LaTeX{} uses the
``obvious'' test to
get the \csx{marginpar}s in the correct margin, but a booby-trap arises
because \TeX{} runs its page maker asynchronously.  If a
\csx{marginpar} is processed while page \ensuremath{n} is being built, but
doesn't get used until page \ensuremath{n}+1, then the \csx{marginpar} will turn
up on the wrong side of the page.  This is an instance of a general
problem: see
% beware line break
``\Qref*{finding if you're on an odd or an even page}{Q-oddpage}''.

The solution to the problem is for \LaTeX{} to `remember' which side
of the page each \csx{marginpar} \emph{should} be on.  The
\Package{mparhack} package does this, using label-like marks stored in
the \extension{aux} file; the \Class{memoir} class does likewise.
\begin{ctanrefs}
\item[memoir.cls]\CTANref{memoir}
\item[mparhack.sty]\CTANref{mparhack}
\end{ctanrefs}

\Question[Q-misschar]{Where have my characters gone?}

You've typed some apparently reasonable text and processed it, but the
result contains no sign of some of the characters you typed.  A likely
reason is that the font you selected just doesn't have a
representation for the character in question.

For example, if I type ``that will be \pounds{}44.00'' into an ordinary
\AllTeX{} document, or if I select the font |rsfs10| (which contains
uppercase letters only) and type pretty much anything, the \pounds{}
sign, or any lowercase letters or digits will not appear in the
output.  There's no actual error message, either: you have to read the
log file, where you'll find cryptic little messages like
\begin{quote}
\begin{wideversion}
\begin{verbatim}
Missing character: There is no ^^a3 in font cmr10!
Missing character: There is no 3 in font rsfs10!
\end{verbatim} 
\end{wideversion}
\begin{narrowversion}
\begin{verbatim}
Missing character:
           There is no ^^a3 in font cmr10!
Missing character:
             There is no 3 in font rsfs10!
\end{verbatim} 
\end{narrowversion}
\end{quote}
(the former demonstrating my \TeX{}'s unwillingness to deal in characters
which have the eighth bit set, while the \texttt{rsfs10} example shows that
\TeX{} will log the actual character in error, if it thinks it's
possible).

Somewhat more understandable are the diagnostics you may get from
\Package{dvips} when using the \acro{OT}1 and \acro{T}1 versions of
fonts that were supplied in Adobe standard encoding:
\begin{quote}
\begin{verbatim}
dvips: Warning: missing glyph `Delta'
\end{verbatim}
\end{quote}
The process that generates the metrics for using the fonts generates
an instruction to \Package{dvips} to produce these diagnostics, so
that their non-appearance in the printed output is less surprising
than it might be.  Quite a few glyphs provided in Knuth's text
encodings and in the Cork encoding are not available in the Adobe
fonts.  In these cases, there \emph{is} a typeset sign of the
character: \ProgName{dvips} produces a black rectangle of whatever
size the concocted font file has specified.

\Question[Q-rerun]{``Rerun'' messages won't go away}

The \LaTeX{} message ``Rerun to get crossreferences right'' is
supposed to warn the user that the job needs to be processed again,
since labels seem to have changed since the previous run.  (\LaTeX{}
compares the labels it has created this time round with what it found
from the previous run when it started; it does this comparison at
\cmdinvoke{end}{document}.)

Sometimes, the message won't go away: however often you reprocess your
document, \LaTeX{} still tells you that ``Label(s) may have
changed''.  This can sometimes be caused by a broken package: both
\Package{footmisc} (with the |perpage| option) and \Package{hyperref}
have been known to give trouble, in the past: if you are using either,
check you have the latest version, and upgrade if possible.

However, there \emph{is} a rare occasion when this error can happen
as a result of pathological structure of the document itself.  Suppose
you have pages numbered in roman, and you add a reference to a label
on page ``ix'' (9).  The presence of the reference pushes the thing
referred to onto page ``x'' (10), but since that's a shorter reference
the label moves back to page ``ix'' at the next run.  Such a sequence
can obviously not terminate.

The only solution to this problem is to make a small change to your
document (something as small as adding or deleting a comma will often
be enough).
\begin{ctanrefs}
\item[footmisc.sty]\CTANref{footmisc}
\item[hyperref.sty]\CTANref{hyperref}
\end{ctanrefs}

\Question[Q-xspace]{Commands gobble following space}

People are forever surprised that simple commands gobble the space
after them: this is just the way it is.  The effect arises from the
way \TeX{} works, and Lamport describes a solution (place a pair of braces
after a command's invocation) in the description of \LaTeX{} syntax.
Thus the requirement is in effect part of the definition of \LaTeX{}.

This \acro{FAQ},
for example, is written with definitions that \emph{require} one to
type \cmdinvoke{fred}{\relax} % the \relax prevents {} being gobbled
                              % in html production (sigh)
for almost all macro invocations, regardless
of whether the following space is required: however, this \acro{FAQ}
is written by highly dedicated (and, some would say, eccentric)
people.  Many users find all those braces become very tedious very
quickly, and would really rather not type them all.

An alternative structure, that doesn't violate the design of \LaTeX{},
is to say \csx{fred}\csx{ }~--- the \csx{ } command is ``self
terminating'' (like |\|{}|\|) and you don't need braces after
\emph{it}.  Thus one can reduce to one the extra characters one needs
to type.

If even that one character is too many, the package \Package{xspace}
defines a command \csx{xspace} that guesses whether there should have
been a space after it, and if so introduces that space.  So
% beware line wrap
``\texttt{fred\csx{xspace} jim}'' produces ``fred jim'', while
``\texttt{fred\csx{xspace}.\@ jim}'' produces ``fred. jim''.  Which
usage would of course be completely pointless; but you can incorporate
\csx{xspace} in your own macros:
\begin{quote}
\begin{wideversion}
\begin{verbatim}
\usepackage{xspace}
...
\newcommand{\restenergy}{\ensuremath{mc^2}\xspace}
...
and we find \restenergy available to us...
\end{verbatim}
\end{wideversion}
\begin{narrowversion}
\begin{verbatim}
\usepackage{xspace}
...
\newcommand{\restenergy}%
           {\ensuremath{mc^2}\xspace}
...
and we find \restenergy available to us...
\end{verbatim}
\end{narrowversion}
\end{quote}
The \csx{xspace} command must be the last thing in your macro
definition (as in the example); it's not completely foolproof, but it
copes with most obvious situations in running text.

The \Package{xspace} package doesn't save you anything if you only use
a modified macro once or twice within your document.  In any case, be
careful with usage of \csx{xspace}~--- it changes your input syntax,
which can be confusing, notably to a collaborating author
(particularly if you create some commands which use it and some which
don't).  Of course, no command built into \LaTeX{} or into any
``standard'' class or package will use \csx{xspace}.
\begin{ctanrefs}
\item[xspace.sty]Distributed as part of \CTANref{2etools}
\end{ctanrefs}

\Question[Q-overfull]{\AllTeX{} makes overfull lines}

When \TeX{} is building a paragraph, it can make several attempts to
get the line-breaking right; on each attempt it runs the same
algorithm, but gives it different parameters.  You can affect the way
\TeX{}'s line breaking works by adjusting the parameters: this answer
deals with the ``tolerance'' and stretchability parameters.  The other
vital `parameter' is the set of hyphenations to be applied: see
``\Qref*[question]{my words aren't being hyphenated}{Q-nohyph}''
(and the questions it references) for advice.

If you're getting an undesired ``overfull box'', what has happened is
that \TeX{} has given up: the parameters you gave it don't allow it to
produce a result that \emph{doesn't} overfill.  In this circumstance,
Knuth decided the best thing to do was to produce a warning, and to
allow the user to solve the problem.  (The alternative, silently to go
beyond the envelope of ``good taste'' defined for this run of \TeX{},
would be distasteful to any discerning typographer.)  The user can
almost always address the problem by rewriting the text that's
provoking the problem~--- but that's not always possible, and in some
cases it's impossible to solve the problem without adjusting the
parameters.  This answer discusses the approaches one might take to
resolution of the problem, on the assumption that you've got the
hyphenation correct.

The simplest case is where a `small' word fails to break at the end of
a line; pushing the entire word to a new line isn't going to make much
difference, but it might make things just bad enough that \TeX{} won't
do it by default.  In such a case on can \emph{try} the \LaTeX{}
\csx{linebreak} command: it may solve the problem, and if it does, it
will save an awful lot of fiddling.  Otherwise, one needs to adjust
parameters: to do that we need to recap the details of \TeX{}'s line
breaking mechanisms.

\TeX{}'s first attempt at breaking lines is performed without even
trying hyphenation: \TeX{} sets its ``tolerance'' of line breaking
oddities to the internal value \csx{pretolerance}, and sees what
happens.  If it can't get an acceptable break, \TeX{} adds the
hyphenation points allowed by the current patterns, and tries again
using the internal \csx{tolerance} value.  If this pass also fails, and
the internal \csx{emergencystretch} value is positive, \TeX{} will try
a pass that allows \csx{emergencystretch} worth of extra stretchability
to the spaces in each line.

In principle, therefore, there are three parameters (other than
hyphenation) that you can change: \csx{pretolerance}, \csx{tolerance}
and \csx{emergencystretch}.  Both the \texttt{tolerance} values are
simple numbers, and should be set by \TeX{} primitive count
assignment~--- for example
\begin{quote}
\begin{verbatim}
\pretolerance=150
\end{verbatim}
\end{quote}
For both, an ``infinite'' tolerance is represented by the value
|10|\nothtml{\,}|000|, but infinite tolerance is rarely
appropriate, since it can lead to very bad line breaks indeed.

\csx{emergencystretch} is a \TeX{}-internal `dimen' register, and can
be set as normal for dimens in \plaintex{}; in \LaTeX{}, use
\csx{setlength}~--- for example:
\begin{quote}
\begin{verbatim}
\setlength{\emergencystretch}{3em}
\end{verbatim}
\end{quote}

The choice of method has time implications~--- each of the
passes takes time, so adding a pass (by changing
\csx{emergencystretch}) is less desirable than suppressing one (by
changing \csx{pretolerance}).  However, it's unusual nowadays to find a
computer that's slow enough that the extra passes are really
troublesome.

In practice, \csx{pretolerance} is rarely used other than to manipulate
the use of hyphenation; \plaintex{} and \LaTeX{} both set its value
to |100|.  To suppress the first scan of paragraphs, set
\csx{pretolerance} to |-1|.

\csx{tolerance} is often a good method for adjusting spacing;
\plaintex{} and \LaTeX{} both set its value to |200|.  \LaTeX{}'s
\csx{sloppy} command sets it to |9999|, as does the
\environment{sloppypar} environment.  This value is the largest
available, this side of infinity, and can allow pretty poor-looking
breaks (this author rarely uses \csx{sloppy} ``bare'', though he does
occasionally use \environment{sloppypar}~--- that way, the change of
\csx{tolerance} is confined to the environment).  More satisfactory is
to make small changes to \csx{tolerance}, incrementally, and then to look to
see how the change affects the result; very small increases can often
do what's necessary.  Remember that \csx{tolerance} is a paragraph
parameter, so you need to ensure it's actually applied~--- see
``\Qref*[question]{ignoring paragraph parameters}{Q-paraparam}''.
\LaTeX{} users could use an environment like:
\begin{quote}
\begin{verbatim}
\newenvironment{tolerant}[1]{%
  \par\tolerance=#1\relax
}{%
  \par
}
\end{verbatim}
\end{quote}
enclosing entire paragraphs (or set of paragraphs) in it.

The value of \csx{emergencystretch} is added to the assumed
stretchability of each line of a paragraph, in a further run of the
paragraph formatter in case that the paragraph can't be made to look
right any other way.  (The extra scan happens if
\csx{emergencystretch\textgreater0pt}~--- if it's zero or negative, no gain
could be had from rerunning the paragraph setter.)  The example above
set it to \texttt{3em}; the Computer Modern fonts ordinarily fit three
space skips to the \texttt{em}, so the change would allow anything up
to the equivalent of nine extra spaces in each line.  In a line with
lots of spaces, this could be reasonable, but with (say) only three
spaces on the line, each could stretch to four times its natural
width.  It is therefore clear that \csx{emergencystretch} needs to be
treated with a degree of caution.

More subtle (but more tricky to manage) are the microtypographic
extensions provided by \PDFTeX{}.  Since \PDFTeX{} is the default
`engine' for \LaTeX{} and \CONTeXT{} work in all distributions,
nowadays, the extensions are available to all.  There are two
extensions, margin kerning and font expansion; margin kerning only
affects the visual effect of the typeset page, and has little effect
on the ability of the paragraph setter to ``get things right''.
Font expansion works like a subtler version of the trick that
\csx{emergencystretch} plays: \PDFTeX{} `knows' that your current font
may be stretched (or shrunk) to a certain extent, and will do that
``on the fly'' to optimise the setting of a paragraph.  This is a
powerful tool in the armoury of the typesetter.

As mentioned above, the microtypographic extensions are tricky beasts
to control; however, the \Package{microtype} package relieves the user
of the tedious work of specifying how to perform margin adjustments
and how much to scale each font~\dots{}\@ for the fonts the package
knows about; it's a good tool, and users who can take on the
specification of adjustments for yet more fonts are always welcome.
\begin{ctanrefs}
\item[microtype.sty]\CTANref{microtype}
\end{ctanrefs}

\Question[Q-exscale]{Maths symbols don't scale up}

By default, the ``large'' maths symbols stay at the same size
regardless of the font size of the text of the document.  There's good
reason for this: the \FontName{cmex} fonts aren't really designed to
scale, so that \TeX{}'s maths placement algorithms don't perform as
well as they might when the fonts are scaled.

However, this behaviour confounds user expectations, and can lead to
slightly odd-looking documents.  If you want the fonts to scale,
despite the warning above, use the \Package{exscale} package~--- just
loading it is enough.
%%
%% (Note: if you are using bitmap versions of the \FontName{cmex} fonts,
%% you will find extra bitmaps are generated.  The extended sizes are not
%% ordinarily generated for any other purpose.)
\begin{ctanrefs}
\item[exscale.sty]Part of the \LaTeX{} distribution.
\end{ctanrefs}

\Question[Q-linespread]{Why doesn't \csx{linespread} work?}

The command \cmdinvoke*{linespread}{factor} is supposed to multiply
the current \csx{baselineskip} by \meta{factor}; but, to all
appearances, it doesn't.

In fact, the command is equivalent to
\cmdinvoke{renewcommand}{\csx{baselinestretch}}{factor}: written that
way, it somehow feels less surprising that the effect isn't immediate.
The \csx{baselinestretch} factor is only used when a font is selected;
a mere change of \csx{baselinestretch} doesn't change the font, any
more than does the command
\cmdinvoke*{fontsize}{size}{baselineskip}~--- you have to follow
either command with \csx{selectfont}.  So:
\begin{quote}
\begin{verbatim}
\fontsize{10}{12}%
\selectfont
\end{verbatim}
\end{quote}
or:
\begin{quote}
\begin{verbatim}
\linespread{1.2}%
\selectfont
\end{verbatim}
\end{quote}
Of course, a package such as \Package{setspace}, whose job is to
manage the baseline, will deal with all this stuff~--- see
``\Qref*[question]{managing double-spaced documents}{Q-linespace}''.  If
you want to avoid \Package{setspace}, beware the behaviour of
linespread changes within a paragraph: read % ! line break
``\Qref*[question]{\csx{baselineskip} is a paragraph parameter}{Q-baselinepar}''.
\begin{ctanrefs}
\item[setspace.sty]\CTANref{setspace}
\end{ctanrefs}

\Question[Q-baselinepar]{Only one \csx{baselineskip} per paragraph}

The \csx{baselineskip} is not (as one might hope) a property of a
line, but of a paragraph.  As a result, in a \texttt{10pt} (nominal)
document (with a default \csx{baselineskip} of \texttt{12pt}), a
single character with a larger size, as:
\begin{quote}
\begin{verbatim}
{\Huge A}
\end{verbatim}
\end{quote}
will be squashed into the paragraph: \TeX{} will make sure it doesn't
scrape up against the line above, but won't give it ``room to
breathe'', as it does the text at standard size; that is, its size
(\texttt{24.88pt}) is taken account of, but its \csx{baselineskip}
(\texttt{30pt}) isn't.  Similarly
\begin{quote}
\begin{verbatim}
Paragraph text ...
{\footnotesize Extended interjection ...
   ... into the paragraph.}
      ... paragraph continues ...
\end{verbatim}
\end{quote}
will look silly, since the \texttt{8pt} interjection will end up set
on the \texttt{12pt} \csx{baselineskip} of the paragraph, rather than
its preferred \texttt{8.5pt}.  Finally, something like
\begin{quote}
\begin{verbatim}
Paragraph text ...
  ... paragraph body ends.
{\footnotesize Short comment on paragraph.}

Next paragraph starts...
\end{verbatim}
\end{quote}
will set the body of the first paragraph on the constricted
\csx{baselineskip} of the \csx{footnotesize} comment.

So, how to deal with these problems?  The oversized (short) section is
typically corrected by a \emph{strut}: this word comes from movable
metal typography, and refers to a spacer that held the boxes (that
contained the metal character shapes) apart.  Every time you change
font size, \LaTeX{} redefines the command \csx{strut} to provide the
equivalent of a metal-type strut for the size chosen.  So for the
example above, we would type
\begin{quote}
\begin{verbatim}
Paragraph text ...
   {\Huge A\strut}
   ... paragraph continues ...
\end{verbatim}
\end{quote}
However, more extended insertions (whether of larger or smaller text)
are always going to cause problems; while you can strut larger text,
ensuring that you strut every line will be tiresome, and there's no
such thing as a ``negative strut'' that pulls the lines together for
smaller text.

The only satisfactory way to deal with an extended insertion at a
different size is to set it off as a separate paragraph.  A
satisfactory route to achieving this is the \environment{quote}
environment, which sets its text modestly inset from the enclosing
paragraph:
\begin{quote}
\begin{verbatim}
Paragraph text ...
\begin{quote}
  \footnotesize This is an inset account
  of something relevant to the enclosing
  paragraph...
\end{quote}
... paragraph continues ...
\end{verbatim}
\end{quote}
Such quote-bracketing also deals with the problem of a trailing
comment on the paragraph.

\Question[Q-tocloftwrong]{Numbers too large in table of contents, etc.}

\LaTeX{} constructs the table of contents, list of figures, tables,
and similar tables, on the basis of a layout specified in the class.
As a result, they do \emph{not} react to the sizes of things in them,
as they would if a \environment{tabular} environment (or something
similar) was used.

This arrangement can provoke problems, most commonly with deep section
nesting or very large page numbers: the numbers in question just don't
fit in the space allowed for them in the class.

A separate answer discusses % ! line break
\nothtml{re-designing the tables ---} % ! line break
\Qref{re-designing the tables}{Q-tocloft}\nothtml{ ---}
and those techniques can be employed to make the numbers fit.

\Question[Q-gutter]{Why is the inside margin so narrow?}

If you give the standard classes the \pkgoption{twoside} option, the
class sets the margins narrow on the left of odd-numbered pages, and
on the right of even-numbered pages.  This is often thought to look
odd, but it is quite right.

The idea is that the typographic urge for symmetry should also apply
to margins: if you lay an even numbered page to the left of an
odd-numbered one, you will see that you've three equal chunks of
un-printed paper: the left margin of the even page, the right margin
of the odd page, and the two abutting margins together.

This is all very fine in the abstract, but in practical book(let)
production it only works ``sometimes''.

If your booklet is produced on double-width paper and stapled, the
effect will be good; if your book(let) is produced using a so-called
``perfect'' binding, the effect will again be good.

However, almost any ``quality'' book-binder will need some of your
paper to grab hold of, and a book bound in such a way won't exhibit
the treasured symmetry unless you've done something about the margin
settings.

The packages recommended in % ! line break
``\Qref*{setting up margins}{Q-marginpkgs}'' mostly have provision for
a ``binding offset'' or a ``binding correction''~--- search for
``binding'' in the manuals (\Package{vmargin} doesn't help, here).

If you're doing the job by hand (see % ! line break
\Qref[question]{manual margin setup}{Q-marginmanual}), the trick is to
calculate your page and margin dimensions as normal, and then:
\begin{itemize}
\item subtract the binding offset from \csx{evensidemargin}, and
\item add the binding offset to \csx{oddsidemargin}.
\end{itemize}
which can be achieved by:
\begin{quote}
\begin{verbatim}
\addtolength{\evensidemargin}{-offset}
\addtolength{\oddsidemargin}{offset}
\end{verbatim}
\end{quote}
(substituting something sensible like ``\texttt{5mm}'' for
``\texttt{offset}'', above).

The above may not be the best you can do: you may well choose to
change the \csx{textwidth} in the presence of the binding offset; but
the changes do work for constant \csx{textwidth}.

\subsection{Why shouldn't I?}

\Question[Q-t1enc]{Why use \Package{fontenc} rather than \Package{t1enc}?}

In the very earliest days of \LaTeXe{}, the only way to use the
\acro{T}1 encoding was \Package{t1enc}; with the summer 1994
``production'' release, the \Package{fontenc} package appeared, and
provided comprehensive support for use of the encoding.

Nevertheless, the \Package{t1enc} package remains (as part of the
\LaTeXo{} compatibility code), but it does very little: it merely
selects font encoding \acro{T}1, and leaves to the user the business
of generating the character codes required.

Generating such character codes could be a simple matter, \emph{if}
the \acro{T}1 encoding matched any widely-supported encoding standard,
since in that case, one might expect one's keyboard to generate the
character codes.  However, the \acro{T}1 encoding is a mix of several
standard encodings, and includes code points in areas of the table
which standard encodings specifically exclude, so no \acro{T}1
keyboards have been (or ever will be) manufactured.

By contrast, the \Package{fontenc} package generates the \acro{T}1
code points from ordinary \LaTeX{} commands (e.g., it generates the
\texttt{\'e} character codepoint from the command |\'|{}|e|).  So, unless you
have program-generated \acro{T}1 input, use
\cmdinvoke{usepackage}[T1]{fontenc} rather than
\cmdinvoke{usepackage}{t1enc}.

\Question[Q-why-inp-font]{Why bother with \Package{inputenc} and \Package{fontenc}?}

The standard input encoding for Western Europe (pending the arrival of
Unicode) is \acro{ISO}~8859--1 (commonly known by the standard's
subtitle `Latin-1').  Latin-1 is remarkably close, in the codepoints
it covers, to the \AllTeX{} \acro{T}1 encoding.

In this circumstance, why should one bother with \Package{inputenc}
and \Package{fontenc}?  Since they're pretty exactly mirroring each
other, one could do away with both, and use just \Package{t1enc},
despite its \Qref*{shortcomings}{Q-t1enc}.

One doesn't do this for a variety of small reasons:
\begin{description}
\item[Confusion] You've been happily working in this mode, and for
  some reason find you're to switch to writing in German: the effect
  of using ``\texttt{\ss}'' is somewhat startling, since \acro{T}1
  and Latin-1 treat the codepoint differently.
\item[Compatibility] You find yourself needing to work with a
  colleague in Eastern Europe: their keyboard is likely to be set to
  produce Latin-2, so that the simple mapping doesn't work.
\item[Traditional \LaTeX{}] You lapse and write something like
  |\'|{}|e| rather than typing \texttt{\'e}; only \Package{fontenc}
  has the means to convert this \LaTeX{} sequence into the \acro{T}1
  character, so an \csx{accent} primitive slips through into the
  output, and hyphenation is in danger.
\end{description}
The \Package{inputenc}--\Package{fontenc} combination seems slow and
cumbersome, but it's safe.

\Question[Q-eqnarray]{Why not use \environment{eqnarray}?}

The environment \environment{eqnarray} is attractive for the
occasional user of mathematics in \LaTeX{} documents: it seems to
allow aligned systems of equations.  Indeed it \emph{does} supply such
things, but it makes a serious mess of spacing.  In the system:
\begin{quote}
\begin{verbatim}
\begin{eqnarray}
  a & = & b + c \\
  x & = & y - z
\end{eqnarray}
\end{verbatim}
\end{quote}
the spacing around the ``='' signs is \emph{not} that defined in the
metrics for the font from which the glyph comes~--- it's
\csx{arraycolsep}, which may be set to some very odd value for reasons
associated with real arrays elsewhere in the document.

The user is far better served by the \AMSLaTeX{} bundle, which
provides an \environment{align} environment, which is designed with
the needs of mathematicians in mind (as opposed to the convenience of
\LaTeX{} programmers).  For this simple case (align is capable of far
greater things), code as:
\begin{quote}
\begin{verbatim}
\begin{align}
  a & = b + c \\
  x & = y - z
\end{align}
\end{verbatim}
\end{quote}
\begin{ctanrefs}
\item[AMSLaTeX]\CTANref{amslatex}
\end{ctanrefs}

\Question[Q-dolldoll]{Why use \csx{[}\,\dots{}\csx{]} in place of \texttt{\$\$}\,\dots{}\texttt{\$\$}?}

\LaTeX{} defines inline- and display-maths commands, apparently
analogous to those that derive from the \TeX{} primitive maths
sequences bracketing maths commands with single dollar signs (or pairs
of dollar signs).

As it turns out, \LaTeX{}'s inline maths grouping, % !line break
\csx{(}\texttt{ ... }\csx{)}, has precisely the same effect as the
\TeX{} primitive version \texttt{\$ ... \$}.  (Except that
the \LaTeX{} version checks to ensure you don't put \csx{(} and
\csx{)} the wrong way round.)

In this circumstance, one often finds \LaTeX{} users, who have some
experience of using \plaintex{}, merely assuming that \LaTeX{}'s
display maths grouping \csx{[}\texttt{ ... }\csx{]} may be replaced by
the \TeX{} primitive display maths \texttt{\$\$ ... \$\$}.

Unfortunately, they are wrong: if \LaTeX{} code is going to patch display
maths, it can only do so by patching \csx{[} and \csx{]}.  The most
obvious way this turns up, is that the class option \pkgoption{fleqn}
simply does not work for equations coded using % beware line break
\texttt{\$\$ ... \$\$}, whether you're using the standard classes
alone, or using package \Package{amsmath}.  Also, the \csx{[} and
\csx{]} has code for rationalising vertical spacing in some extreme
cases; that code is not available in \texttt{\$\$ ... \$\$}, so if you
use the non-standard version, you may occasionally observe
inconsistent vertical spacing .

There are more subtle effects (especially with package
\Package{amsmath}), and the simple rule is % ! line break
\csx{[}\texttt{ ... }\csx{]} whenever
unadorned displayed maths is needed in \LaTeX{}.

\Question[Q-2letterfontcmd]{What's wrong with \csx{bf}, \csx{it}, etc.?}

The font-selection commands of \LaTeXo{} were \csx{rm}, \csx{sf},
\csx{tt}, \csx{it}, \csx{sl}, \csx{em} and \csx{bf}; they were modal
commands, so you used them as:
\begin{quote}
\begin{verbatim}
{\bf Fred} was {\it here\/}.
\end{verbatim}
\end{quote}
with the font change enclosed in a group, so as to limit its effect;
note the italic correction command \csx{/} that was necessary at the
end of a section in italics.

At the release of \LaTeXe{} in summer 1994, these simple commands were
deprecated, but recognising that their use is deeply embedded in the
brains of \LaTeX{} users, the commands themselves remain in \LaTeX{},
\emph{with their \LaTeXo{} semantics}.  Those semantics were part of
the reason they were deprecated: each |\|\emph{\texttt{xx}} overrides
any other font settings, keeping only the size.  So, for example,
\begin{quote}
\begin{verbatim}
{\bf\it Here we are again\/}
\end{verbatim}
\end{quote}
ignores \csx{bf} and produces text in italic, medium weight (and the
italic correction has a real effect), whereas
\begin{quote}
\begin{verbatim}
{\it\bf happy as can be\/}
\end{verbatim}
\end{quote}
ignore \csx{it} and produces upright text at bold weight (and the
italic correction has nothing to do).  The same holds if you mix
\LaTeXe{} font selections with the old style commands:
\begin{quote}
\begin{verbatim}
\textbf{\tt all good friends}
\end{verbatim}
\end{quote}
ignores the \csx{textbf} that encloses the text, and produces
typewriter text at medium weight.

So why are these commands deprecated?~--- it is because of confusions
such as that in the last example.  The alternative (\LaTeXe{})
commands are discussed in the rest of this answer.

\LaTeXe{}'s font commands come in two forms: modal commands and
text-block commands.  The default set of modal commands offers weights
\csx{mdseries} and \csx{bfseries}, shapes \csx{upshape},
\csx{itshape}, \csx{scshape} and \csx{slshape}, and families
\csx{rmfamily}, \csx{sffamily} and \csx{ttfamily}.  A font selection
requires a family, a shape and a series (as well as a size, of
course).  A few examples
\begin{quote}
\begin{narrowversion}
\begin{verbatim}
{\bfseries\ttfamily
    and jolly good company!}
\end{verbatim}
\end{narrowversion}
\begin{wideversion}
\begin{verbatim}
{\bfseries\ttfamily and jolly good company!}
\end{verbatim}
\end{wideversion}
\end{quote}
produces bold typewriter text (but note the lack of a % ! line break, big time 
\begin{narrowversion} % non hyper version
  bold typewriter font~--- \Qref{}{Q-bold-extras}~---
\end{narrowversion}
\begin{wideversion}
  \Qref{bold typewriter font}{Q-bold-extras}
\end{wideversion}
in the default Computer Modern fonts), or
\begin{quote}
\begin{narrowversion}
\begin{verbatim}
{\slshape\sffamily
    Never mind the weather\/}
\end{verbatim}
\end{narrowversion}
\begin{wideversion}
\begin{verbatim}
{\slshape\sffamily Never mind the weather\/}
\end{verbatim}
\end{wideversion}
\end{quote}
(note the italic correction needed on slanted fonts, too).

\LaTeXe{}'s text block commands take the first two letters of the
modal commands, and form a \csx{text}\emph{\texttt{xx}} command from
them.  Thus \csx{bfseries} becomes \cmdinvoke*{textbf}{text},
\csx{itshape} becomes \cmdinvoke*{textit}{text}, and \csx{ttfamily}
becomes \cmdinvoke*{texttt}{text}.  Block commands may be nested, as:
\begin{quote}
\begin{verbatim}
\textit{\textbf{Never mind the rain}}
\end{verbatim}
\end{quote}
to produce bold italic text (note that the block commands supply
italic corrections where necessary), and they be nested with the
\LaTeXe{} modal commands, too:
\begin{quote}
\begin{narrowversion}
\begin{verbatim}
\texttt{\bfseries
    So long as we're together}
\end{verbatim}
\end{narrowversion}
\begin{wideversion}
\begin{verbatim}
\texttt{\bfseries So long as we're together}
\end{verbatim}
\end{wideversion}
\end{quote}
for bold typewriter, or
\begin{quote}
\begin{narrowversion}
\begin{verbatim}
{\slshape\textbf{%
    Whoops!  she goes again}\/}
\end{verbatim}
\end{narrowversion}
\begin{wideversion}
\begin{verbatim}
{\slshape \textbf{Whoops!  she goes again}\/}
\end{verbatim}
\end{wideversion}
\end{quote}
for a bold slanted instance of the current family (note the italic
correction applied at the end of the modal command group, again).

The new commands (as noted above) override commands of the same type.
In almost all cases, this merely excludes ludicrous ideas such as
``upright slanted'' fonts, or ``teletype roman'' fonts.  There are a
couple of immediate oddities, though.  The first is the conflict
between \csx{itshape} (or \csx{slshape}) and \csx{scshape}: while many
claim that an italic small-caps font is typographically unsound, such
fonts do exist.  Daniel Taupin's \Package{smallcap} package enables
use of the instances in the \Qref*{\acro{EC} fonts}{Q-ECfonts}, and
similar techniques could be brought to bear on many other font sets.
The second is the conflict between \csx{upshape} and \csx{itshape}:
Knuth actually offers an upright-italic font which \LaTeX{} uses for
the ``\pounds{}'' symbol in the default font set.  The combination is
sufficiently weird that, while there's a defined font shape, no
default \LaTeX{} commands exist; to use the shape, the (eccentric) user
needs \LaTeX{}'s simplest font selection commands:
\begin{quote}
\begin{narrowversion}
\begin{verbatim}
{\fontshape{ui}\selectfont
    Tra la la, di dee}
\end{verbatim}
\end{narrowversion}
\begin{wideversion}
\begin{verbatim}
{\fontshape{ui}\selectfont Tra la la, di dee}
\end{verbatim}
\end{wideversion}
\end{quote}
\begin{ctanrefs}
\item[smallcap.sty]\CTANref{smallcap}
\end{ctanrefs}

\Question[Q-newfont*]{What's wrong with \csx{newfont}?}

If all else fails, you \emph{can} specify a font using the \LaTeX{}
\csx{newfont} command.  The font so specified doesn't fit into the
\LaTeX{} font selection mechanism, but the technique can be tempting
under several circumstances.  The command is merely the thinnest of
wrappers around the \csx{font} primitive, and doesn't really fit with
\LaTeX{} at all.  A simple, but really rather funny, example of the
problems it poses, may be seen in:
\begin{quote}
\begin{verbatim}
\documentclass[10pt]{article}
\begin{document}
\newfont{\myfont}{cmr17 scaled 2000}
\myfont
\LaTeX
\end{document}
\end{verbatim}
\end{quote}
(the reader is encouraged to try this).  The ``A'' of \csx{LaTeX} pretty
much disappears: \LaTeX{} chooses the size on the ``A'' according to
\emph{its} idea of the font size (10pt), but positions it according to
the dimensions of ``\csx{myfont}'', which is more than three times
that size.

Another ``\csx{myfont}'' example arises from an entirely different
source.  The mini-document:
\begin{quote}
\begin{verbatim}
\documentclass{article}
\begin{document}
\newfont{\myfont}{ecrm1000}
{\myfont voil\`a}
\end{document}
\end{verbatim}
\end{quote}
gives you ``German low double quotes'' (under the ``a'') in place of
the grave accent.  This happens because \FontName{ecrm1000} is in a
different \Qref*{font encoding}{Q-whatenc} than \LaTeX{} is
expecting~--- if you use the \LaTeX{} \Package{fontenc} package to
select the \acro{EC} fonts, all these tiresome encoding issues are
solved for you, behind the scenes.

There does however remain a circumstance when you will be tempted to
use \csx{newfont}~--- viz., to get a font size that doesn't fall into
the Knuth standard set of sizes: \LaTeX{} (by default) won't allow you
to use such a size.  Don't despair: see the answer % ! line break
``\Qref*{arbitrary font sizes}{Q-fontsize}''.

%*****************************************quote environments up to here

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\section{The joy of \TeX{} errors}

\Question[Q-erroradvice]{How to approach errors}

Since \TeX{} is a macroprocessor, its error messages are often
difficult to understand; this is a (seemingly invariant) property of
macroprocessors.  Knuth makes light of the problem in the \TeX{}book,
suggesting that you acquire the sleuthing skills of a latter-day
Sherlock Holmes; while this approach has a certain romantic charm to
it, it's not good for the `production' user of \AllTeX{}.  This
answer (derived, in part, from an article by Sebastian Rahtz in
\TUGboat{} 16(4)) offers some general guidance in dealing with \TeX{}
error reports, and other answers in this section deal with common (but
perplexing) errors that you may encounter.  There's a long list of
``hints'' in Sebastian's article, including the following:
\begin{itemize}
\item Look at \TeX{} errors; those messages may seem cryptic at first,
  but they often contain a straightforward clue to the problem.  See
  \Qref[question]{the structure of errors}{Q-errstruct} for further
  details. 
\item Read the \extension{log} file; it contains hints to things you may
  not understand, often things that have not even presented as error
  messages.
\item Be aware of the amount of context that \TeX{} gives you.  The
  error messages gives you some bits of \TeX{} code (or of the
  document itself), that show where the error ``actually happened'';
  it's possible to control how much of this `context' \TeX{} actually
  gives you.  \LaTeX{} (nowadays) instructs \TeX{} only to give you
  one line of context, but you may tell it otherwise by saying
\begin{quote}
\begin{verbatim}
\setcounter{errorcontextlines}{999}
\end{verbatim}
\end{quote}
  in the preamble of your document.  (If you're not a confident macro
  programmer, don't be ashamed of cutting that 999 down a bit; some
  errors will go on and \emph{on}, and spotting the differences
  between those lines can be a significant challenge.)
\item As a last resort, tracing can be a useful tool; reading a full
  \AllTeX{} trace takes a strong constitution, but once you know how,
  the trace can lead you quickly to the source of a problem.  You need
  to have read the \TeX{}book (see
% beware line break
  \Qref[question]{books about \TeX{}}{Q-books}) in some detail, fully
  to understand the trace.
  
  The command \csx{tracingall} sets up maximum tracing; it also sets
  the output to come to the interactive terminal, which is somewhat of
  a mixed blessing (since the output tends to be so vast~--- all but
  the simplest traces are best examined in a text editor after the event).

  The \LaTeX{} \Package{trace} package (first distributed with the
  2001 release of \LaTeX{}) provides more manageable tracing.  Its
  \csx{traceon} command gives you what \csx{tracingall} offers, but
  suppresses tracing around some of the truly verbose parts of
  \LaTeX{} itself.  The package also provides a \csx{traceoff}
  command (there's no ``off'' command for \csx{tracingall}), and a
  package option (|logonly|) allows you to suppress output to the
  terminal.
\end{itemize}
The best advice to those faced with \TeX{} errors is not to panic:
most of the common errors are plain to the eye when you go back to the
source line that \TeX{} tells you of.  If that approach doesn't work,
the remaining answers in this section deal with some of the odder
error messages you may encounter.  You should not ordinarily need to
appeal to the \Qref*[question]{wider public}{Q-gethelp}
for assistance, but if you do, be sure to
report full backtraces (see |errorcontextlines| above) and so on.
\begin{ctanrefs}
\item[trace.sty]Distributed as part of \CTANref{2etools}
\end{ctanrefs}

\Question[Q-errstruct]{The structure of \TeX{} error messages}

\TeX{}'s error messages are reminiscent of the time when \TeX{} itself
was conceived (the 1970s): they're not terribly user-friendly, though
they do contain all the information that \TeX{} can offer, usually in
a pretty concise way.

\TeX{}'s error reports all have the same structure:
\begin{itemize}
\item An error message
\item Some `context'
\item An error prompt
\end{itemize}
The error message will relate to the \emph{\TeX{}} condition that is
causing a problem.  Sadly, in the case of complex macro packages such
as \LaTeX{}, the underlying \TeX{} problem may be superficially
difficult to relate to the actual problem in the ``higher-level''
macros.  Many \LaTeX{}-detected problems manifest themselves as
`generic' errors, with error text provided by \LaTeX{} itself (or by a
\LaTeX{} class or package).

The context of the error is a stylised representation of what \TeX{}
was doing at the point that it detected the error.  As noted in
\Qref[question]{approaching errors}{Q-erroradvice}, a macro package
can tell \TeX{} how much context to display, and the user may need to
undo what the package has done.  Each line of context is split at the
point of the error; if the error \emph{actually} occurred in a macro
called from the present line, the break is at the point of the call.
(If the called object is defined with arguments, the ``point of call''
is after all the arguments have been scanned.)  For example:
\begin{verbatim}
\blah and so on
\end{verbatim}
produces the error report
\begin{verbatim}
! Undefined control sequence.
l.4 \blah
          and so on
\end{verbatim}
while:
\begin{verbatim}
\newcommand{\blah}[1]{\bleah #1}
\blah{to you}, folks
\end{verbatim}
produces the error report
\begin{verbatim}
! Undefined control sequence.
\blah #1->\bleah 
                 #1
l.5 \blah{to you}
                 , folks
\end{verbatim}
If the argument itself is in error, we will see things such as
\begin{verbatim}
\newcommand{\blah}[1]{#1 to you}
\blah{\bleah}, folks
\end{verbatim}
producing
\begin{verbatim}
! Undefined control sequence.
<argument> \bleah 
                  
l.5 \blah{\bleah}
                 , folks
\end{verbatim}

The prompt accepts single-character commands: the list of what's
available may be had by typing |?|\@.  One immediately valuable
command is |h|, which gives you an expansion of \TeX{}s original
pr\'ecis message, sometimes accompanied by a hint on what to do to
work round the problem in the short term.  If you simply type `return'
(or whatever else your system uses to signal the end of a line) at the
prompt, \TeX{} will attempt to carry on (often with rather little
success).

\Question[Q-extrabrace]{An extra `\texttt{\cbracesymbol{}}'??}
\keywords{caption heading}

You've looked at your \LaTeX{} source and there's no sign of a misplaced
\texttt{\cbracesymbol{}} on the line in question.

Well, no: this is \TeX{}'s cryptic way of hinting that you've put a
\begin{wideversion} % hyper
\Qref{fragile command}{Q-protect} in a moving argument.
\end{wideversion}
\begin{narrowversion}
fragile command in a moving argument (\Qref{}{Q-protect}).
\end{narrowversion}

For example, \csx{footnote} is fragile, and if we put that in the
moving argument of a \csx{section} command, as
\begin{quote}
\begin{narrowversion}
\begin{verbatim}
\section{Mumble\footnote{%
    I couldn't think of anything better}}
\end{verbatim}
\end{narrowversion}
\begin{wideversion}
\begin{verbatim}
\section{Mumble\footnote{I couldn't think of anything better}}
\end{verbatim}
\end{wideversion}
\end{quote}
we get told
\begin{quote}
\begin{verbatim}
! Argument of \@sect has an extra }.
\end{verbatim}
\end{quote}
The same happens with captions (the following is a simplification of a
\Newsgroup{comp.text.tex} post):
\begin{quote}
\begin{verbatim}
\caption{Energy: \[e=mc^2\]}
\end{verbatim}
\end{quote}
giving us the error message
\begin{quote}
\begin{verbatim}
! Argument of \@caption has an extra }.
\end{verbatim}
\end{quote}
The solution is usually to use a robust command in place of the one
you are using, or to force your command to be robust by prefixing it
with \csx{protect}, which in the \csx{section} case would show as
\begin{quote}
\begin{narrowversion}
\begin{verbatim}
\section{Mumble\protect\footnote{%
    I couldn't think of anything better}}
\end{verbatim}
\end{narrowversion}
\begin{wideversion}
\begin{verbatim}
\section{Mumble\protect\footnote{I couldn't think of anything better}}
\end{verbatim}
\end{wideversion}
\end{quote}
In both the \csx{section} case and the \csx{caption} case, you can
separate the moving argument, as in
\cmdinvoke*{section}[moving]{static}; this gives us another standard
route~--- simply to omit (or otherwise sanitise) the fragile command
in the moving argument.  So, one might rewrite the \csx{caption}
example as:
\begin{quote}
\begin{narrowversion}
\begin{verbatim}
\caption[Energy:  $E=mc^2$]%
        {Energy: \[E=mc^2\]}
\end{verbatim}
\end{narrowversion}
\begin{wideversion}
\begin{verbatim}
\caption[Energy:  $E=mc^2$]{Energy: \[E=mc^2\]}
\end{verbatim}
\end{wideversion}
\end{quote}
for, after all, even if you want display maths in a caption, you
surely don't want it in the list of figures.

The case of footnotes is somewhat more complex;
``\Qref[question]{footnotes in \LaTeX{} section headings}{Q-ftnsect}''
deals specifically with that issue.

\Question[Q-semanticnest]{Capacity exceeded [semantic nest\,\dots{}]}

\begin{narrowversion}
\begin{verbatim}
! TeX capacity exceeded, sorry [semantic nest
                                      size=100].
...
If you really absolutely need more capacity,
you can ask a wizard to enlarge me.
\end{verbatim}
\end{narrowversion}
\begin{wideversion}
\begin{verbatim}
! TeX capacity exceeded, sorry [semantic nest size=100].
...
If you really absolutely need more capacity,
you can ask a wizard to enlarge me.
\end{verbatim}
\end{wideversion}
Even though \TeX{} suggests (as always) that enlargement by a wizard
may help, this message usually results from a broken macro or bad
parameters to an otherwise working macro.

The ``semantic nest'' \TeX{} talks about is the nesting
of boxes within boxes.  A stupid macro can provoke the error pretty
easily:
\begin{quote}
\begin{narrowversion}
\begin{verbatim}
\def\silly{\hbox{here's \silly
                         being executed}}
\silly
\end{verbatim}
\end{narrowversion}
\begin{wideversion}
\begin{verbatim}
\def\silly{\hbox{here's \silly being executed}}
\silly
\end{verbatim}
\end{wideversion}
\end{quote}
The extended traceback
% beware of filling this line...
(see \Qref{\emph{general advice} on errors}{Q-erroradvice})
\emph{does} help, though it does rather run on.  In the case above,
the traceback consists of
\begin{verbatim}
\silly ->\hbox {
                here's \silly being executed}
\end{verbatim}
followed by 100 instances of
\begin{verbatim}
\silly ->\hbox {here's \silly 
                              being executed}
\end{verbatim}
The repeated lines are broken at exactly the offending macro; of
course the loop need not be as simple as this~--- if \csx{silly} calls
\csx{dopy} which boxes \csx{silly}, the effect is just the same and
alternate lines in the traceback are broken at alternate positions.

There are in fact two items being consumed when you nest boxes: the
other is the grouping level.  Whether you exhaust your % !line wrap
\emph{semantic nest} or your permitted \emph{grouping levels} first is
controlled entirely by the relative size of the two different sets of
buffers in your \AllTeX{} executable.

\Question[Q-noroom]{No room for a new `\emph{thing}'}

The technology available to Knuth at the time \TeX{} was written is
said to have been particularly poor at managing dynamic storage; as a
result much of the storage used within \TeX{} is allocated as fixed
arrays, in the reference implementations.  Many of these fixed arrays
are expandable in modern \TeX{} implementations, but size of the
arrays of ``registers'' is written into the specification as being 256
(usually); this number may not be changed if you still wish to call
the result \TeX{}
%% beware line wrap
(see \Qref[question]{testing \TeX{} implementations}{Q-triptrap}).

If you fill up one of these register arrays, you get a \TeX{} error
message saying
\begin{quote}
\begin{verbatim}
! No room for a new \<thing>.
\end{verbatim}
\end{quote}
The \csx{thing}s in question may be \csx{count} (the object underlying
\LaTeX{}'s \csx{newcounter} command), \csx{skip} (the object underlying
\LaTeX{}'s \csx{newlength} command), \csx{box} (the object underlying
\LaTeX{}'s \csx{newsavebox} command), or \csx{dimen}, \csx{muskip},
\csx{toks}, \csx{read}, \csx{write} or \csx{language} (all types of object
whose use is ``hidden'' in \LaTeX{}; the limit on the number of
\csx{read} or \csx{write} objects is just 16).

There is nothing that can directly be done about this error, as you can't
extend the number of available registers without extending \TeX{}
itself.
\begin{htmlversion}
  Of course, \Qref{\eTeX{}}{Q-etex} and \Qref{Omega}{Q-omegaleph}
\end{htmlversion}
\htmlignore
% beware line wrap here
  Of course, \ensuremath{\Omega} and \eTeX{}~---
  \Qref[see questions]{}{Q-omegaleph} \Qref[and]{}{Q-etex} respectively~---
\endhtmlignore
 both do this, as does \Qref*{MicroPress Inc's V\TeX{}}{Q-commercial}.

The commonest way to encounter one of these error messages is to have
broken macros of some sort, or incorrect usage of macros (an example
is discussed in \Qref[question]{epsf problems}{Q-epsf}).

However, sometimes one just \emph{needs} more than \TeX{} can offer,
and when this happens, you've just got to work out a different way of
doing things.  An example is the % beware line wrap
\Qref*{difficulty of loading \PiCTeX{} with \LaTeX{}}{Q-usepictex}.
In cases like \PiCTeX{}, it may be possible to use
\Qref*{\eTeX{}}{Q-etex} (all modern distributions provide it).  The
\LaTeX{} package \Package{etex} modifies the register allocation
mechanism to make use of \eTeX{}'s extended register sets (it's a
derivative of the \plaintex{} macro file \Package{etex.src}, which is
used in building the \eTeX{} Plain format; both files are part of the
\eTeX{} distribution).  Unfortunately, \eTeX{} doesn't help with
\csx{read} or \csx{write} objects.

\Question[Q-epsf]{\texttt{epsf} gives up after a bit}

Some copies of the documentation of \File{epsf.tex} seem to suggest
that the command
\begin{verbatim}
  \input epsf
\end{verbatim}
is needed for every figure included.  If you follow this suggestion
too literally, you get an error
\begin{verbatim}
  ! No room for a new \read .
\end{verbatim}
after a while; this is because each time \File{epsf.tex} is loaded, it
allocates itself a \emph{new} file-reading handle to check the figure
for its bounding box, and there just aren't enough of these things
(see \Qref[question]{no room for a new thing}{Q-noroom}).

The solution is simple~--- this is in fact an example of misuse of
macros; one only need read \File{epsf.tex} once, so change
\begin{verbatim}
  ...
  \input epsf
  \epsffile{...}
  ...
  \input epsf
  \epsffile{...}
\end{verbatim}
(and so on) with a single
\begin{verbatim}
  \input epsf
\end{verbatim}
somewhere near the start of your document, and then decorate your
\csx{epsffile} statements with no more than adjustments of
\csx{epsfxsize} and so on.

\Question[Q-badhyph]{Improper \csx{hyphenation} will be flushed}

For example
\begin{verbatim}
! Improper \hyphenation will be flushed.
\'#1->{
       \accent 19 #1}
<*> \hyphenation{Ji-m\'e
                        -nez}
\end{verbatim}
(in \plaintex{}) or
\begin{verbatim}
! Improper \hyphenation will be flushed.
\leavevmode ->\unhbox 
                      \voidb@x 
<*> \hyphenation{Ji-m\'e
                        -nez}
\end{verbatim}
in \LaTeX{}.

As mentioned in \Qref[question]{``hyphenation failures''}{Q-nohyph},
words with accents in them may not be hyphenated.  As a result, any
such word is deemed improper in a \csx{hyphenation} command.

The solution is to use a font that contains the character in question,
and to express the \csx{hyphenation} command in terms of that
character; this ``hides'' the accent from the hyphenation mechanisms.
\LaTeX{} users can be achieved this by use of the \Package{fontenc}
package (part of the \LaTeX{} distribution).  If you select an 8-bit
font with the package, as in \cmdinvoke{usepackage}[T1]{fontenc},
accented-letter commands such as the |\'||e| in
|\hyphenation{Ji-m\'||e-nez}| automatically become the single accented
character by the time the hyphenation gets to look at it.

\Question[Q-tmupfl]{``Too many unprocessed floats''}

If \LaTeX{} responds to a \cmdinvoke{begin}{figure} or
\cmdinvoke{begin}{table} command with the error message
\begin{htmlversion}
\begin{verbatim}
! LaTeX Error: Too many unprocessed floats.

See the LaTeX manual or LaTeX Companion for explanation.
\end{verbatim}
\end{htmlversion}
\htmlignore
\ifpdf
\begin{verbatim}
! LaTeX Error: Too many unprocessed floats.

See the LaTeX manual or LaTeX Companion for explanation.
\end{verbatim}
\else
\begin{verbatim}
! LaTeX Error: Too many unprocessed floats.

See the LaTeX manual or LaTeX Companion
...                           for explanation.
\end{verbatim}
\fi
\endhtmlignore
your figures (or tables) are failing to be placed properly.  \LaTeX{}
has a limited amount of storage for `floats' (figures, tables, or
floats you've defined yourself with the \Package{float} package); if
you don't let it ever actually typeset any floats, it will run out of
space.

This failure usually occurs in extreme cases of
% beware line break
\nothtml{floats moving ``wrongly'' (see }%
\Qref[question]{floats moving ``wrongly''}{Q-floats}\latexhtml{);}{;}
\LaTeX{} has found it can't place a float, and floats of the same type
have piled up behind it.  \LaTeX{}'s idea is to ensure that caption
numbers are sequential in the document: the caption number is
allocated when the figure (or whatever) is created, and can't be
changed, so that placement out of order would mean figure numbers
appearing out of order in the document (and in the list of figures, or
whatever).  So a simple failure to place a figure means that no
subsequent figure can be placed; and hence (eventually) the error.

Techniques for solving the problem are discussed in the
\nothtml{floats question (}%
\Qref[\htmlonly]{floats question}{Q-floats}\nothtml{)}
already referenced.

The error also occurs in a 
long sequence of \environment{figure} or \environment{table}
environments, with no intervening
text.  Unless the environments will fit ``here'' (and you've allowed
them to go ``here''), there will never be a page break, and so there
will never be an opportunity for \LaTeX{} to reconsider placement.
(Of course, the floats can't all fit ``here'' if the sequence is
sufficiently prolonged: once the page fills, \LaTeX{} won't place any
more floats, leading to the error.

Techniques for resolution may involve redefining the floats using the
\Package{float} package's \texttt{[H]} float qualifier, but you are unlikely
to get away without using \csx{clearpage} from time to time.
\begin{ctanrefs}
\item[float.sty]\CTANref{float}
\end{ctanrefs}

\Question[Q-atvert]{\csx{spacefactor} complaints}

The errors
\begin{verbatim}
! You can't use `\spacefactor' in vertical mode.
\@->\spacefactor 
                 \@m 
\end{verbatim}
or
\begin{verbatim}
! You can't use `\spacefactor' in math mode.
\@->\spacefactor 
                 \@m 
\end{verbatim}
or simply
\begin{verbatim}
! Improper \spacefactor.
...
\end{verbatim}
bites the \LaTeX{} programmer who uses an internal command without taking
``precautions''.  The problem is discussed in detail in
% beware line wrap
``\Qref*[question]{\texttt{@} in macro names}{Q-atsigns}'',
together with solutions.

\Question[Q-endingroup]{\csx{end} occurred inside a group}

The actual error we observe is:

\nothtml{\noindent}%
|(\end occurred inside a group at level <|\texttt{\emph{n}}|>)|

\nothtml{\noindent}%
and it tells us that something we started in the document never got
finished before we ended the document itself.  The things involved
(`groups') are what \TeX{} uses for restricting the scope of things:
you see them, for example, in the ``traditional'' font selection
commands: |{\it stuff\/}|~--- if the closing brace is left off such a
construct, the effect of \csx{it} will last to the end of the document,
and you'll get the diagnostic.

\TeX{} itself doesn't tell you where your problem is, but you can
often spot it by looking at the typeset output in a previewer.
Otherwise, you can usually find mismatched braces using an intelligent
editor (at least \ProgName{emacs} and \ProgName{winedt} offer this facility).
However, groups are not \emph{only} created by matching
\texttt{\obracesymbol{}} with \texttt{\cbracesymbol{}}:
other grouping commands are discussed elsewhere in these \acro{FAQ}s,
and are also a potential source of unclosed group.

\cmdinvoke{begin}{\meta{environment}} encloses the environment's body
in a group, and establishes its own diagnostic mechanism.  If you end
the document before closing some other environment, you get the
`usual' \LaTeX{} diagnostic
\htmlignore
\begin{dviversion}
\begin{verbatim}
! LaTeX Error: \begin{blah} on input line 6
                       ended by \end{document}.
\end{verbatim}
\end{dviversion}
\begin{pdfversion}
\begin{verbatim}
! LaTeX Error: \begin{blah} on input line 6 ended by \end{document}.
\end{verbatim}
\end{pdfversion}
\endhtmlignore
\begin{htmlversion}
\begin{verbatim}
! LaTeX Error: \begin{blah} on input line 6 ended by \end{document}.
\end{verbatim}
\end{htmlversion}
which (though it doesn't tell you which \emph{file} the
\cmdinvoke{begin}{blah} was in) is usually enough to locate the
immediate problem.  If you press on past the \LaTeX{} error, you get
one or more repetitions of the ``occurred inside a group'' message
before \LaTeX{} finally exits.  The \Package{checkend} package
recognises other unclosed \cmdinvoke{begin}{blob} commands, and
generates an ``ended by'' error message for each one, rather than
producing the ``occurred inside a group'' message, which is sometimes
useful (if you remember to load the package).

In the absence of such information from \LaTeX{}, you need to use
``traditional'' binary search to find the offending group.  Separate
the preamble from the body of your file, and process each half on its
own with the preamble; this tells you which half of the file is at
fault.  Divide again and repeat.  The process needs to be conducted
with care (it's obviously possible to split a correctly-written group
by chopping in the wrong place), but it will usually find the problem
fairly quickly.

\eTeX{} (and \elatex{}~--- \LaTeX{} run on \eTeX{}) gives you
further diagnostics after the traditional infuriating \TeX{} one~--- it
actually keeps the information in a similar way to \LaTeX{}:
\htmlignore
\begin{dviversion}
\begin{verbatim}
(\end occurred inside a group at level 3)

### semi simple group (level 3) entered
                         at line 6 (\begingroup)
### simple group (level 2) entered at line 5 ({)
### simple group (level 1) entered at line 4 ({)
### bottom level
\end{verbatim}
\end{dviversion}
\begin{pdfversion}
\begin{verbatim}
(\end occurred inside a group at level 3)

### semi simple group (level 3) entered at line 6 (\begingroup)
### simple group (level 2) entered at line 5 ({)
### simple group (level 1) entered at line 4 ({)
### bottom level
\end{verbatim}
\end{pdfversion}
\endhtmlignore
\begin{htmlversion}
\begin{verbatim}
(\end occurred inside a group at level 3)

### semi simple group (level 3) entered at line 6 (\begingroup)
### simple group (level 2) entered at line 5 ({)
### simple group (level 1) entered at line 4 ({)
### bottom level
\end{verbatim}
\end{htmlversion}
The diagnostic not only tells us where the group started, but also the
\emph{way} it started: \csx{begingroup} or |{| (which is an alias of
\csx{bgroup}, and the two are not  distinguishable at the \TeX{}-engine
level).
\begin{ctanrefs}
\item[checkend.sty]Distributed as part of \CTANref{bezos}
\end{ctanrefs}

\Question[Q-nonum]{``Missing number, treated as zero''}

In general, this means you've tried to assign something to a count,
dimension or skip register that isn't (in \TeX{}'s view of things) a
number.  Usually the problem will become clear using the
\Qref*{ordinary techniques of examining errors}{Q-erroradvice}.

Two \LaTeX{}-specific errors are commonly aired on the newsgroups.

The commonest arises from attempting to use an example from the
\Qref*{\emph{The \LaTeX{} Companion} (first edition)}{Q-books}, and is
exemplified by the following error text:
\begin{verbatim}
! Missing number, treated as zero.
<to be read again> 
                   \relax 
l.21 \begin{Ventry}{Return values}
\end{verbatim}
The problem arises because, in its first edition, the
\emph{Companion}'s examples always assumed that the \Package{calc}
package is loaded: this fact is mentioned in the book, but often not
noticed.  The remedy is to load the \Package{calc} package in any
document using such examples from the \emph{Companion}.  (The problem
does not really arise with the second edition; copies of all the
examples are available on the accompanying \CDROM{}, or on
\acro{CTAN}.)

The other problem, which is increasingly rare nowadays, arises from
misconfiguration of a system that has been upgraded from \LaTeXo{}:
the document uses the \Package{times} package, and the error appears
at \cmdinvoke{begin}{document}.  The file search paths are wrongly set
up, and your \cmdinvoke{usepackage}{times} has picked up a \LaTeXo{}
version of the package, which in its turn has invoked another which
has no equivalent in \LaTeXe{}.  The obvious solution is to rewrite
the paths so that \LaTeXo{} packages are chosen only as a last resort
so that the startlingly simple \LaTeXe{} \Package{times} package will
be picked up.  Better still is to replace the whole thing with
something more modern still; current \Package{psnfss} doesn't provide
a \Package{times} package~--- the alternative \Package{mathptmx}
incorporates \FontName{Times}-like mathematics, and a sans-serif face
based on \FontName{Helvetica}, but scaled to match \FontName{Times}
text rather better.
\begin{ctanrefs}
\item[calc.sty]Distributed as part of \CTANref{2etools}
\item[\nothtml{\rmfamily}Examples for \nothtml{\upshape}\LaTeX{} Companion]\CTANref{tlc2}
\item[The psnfss bundle]\CTANref{psnfss}
\end{ctanrefs}

\Question[Q-typend]{``Please type a command or say \csx{end}''}

Sometimes, when you are running \AllTeX{}, it will abruptly stop and
present you with a prompt (by default, just a |*| character).  Many
people (including this author) will reflexively hit the `return'
key, pretty much immediately, and of course this is no help at all~---
\TeX{} just says:
\begin{verbatim}
(Please type a command or say `\end')
\end{verbatim}
and prompts you again.

What's happened is that your \AllTeX{} file has finished prematurely,
and \TeX{} has fallen back to a supposed including file, from the
terminal.  This could have happened simply because you've omitted
the \csx{bye} (\plaintex{}), \cmdinvoke{end}{document} (\LaTeX{}), or
whatever.  Other common errors are failure to close the braces round a
command's argument, or (in \LaTeX{}) failure to close a verbatim
environment: in such cases you've already read and accepted an
error message about encountering end of file while scanning something.

If the error is indeed because you've forgotten to end your document,
you can insert the missing text: if you're running \plaintex{}, the
advice, to ``say \csx{end}'' is good enough: it will kill the run; if
you're running \LaTeX{}, the argument will be necessary:
\cmdinvoke{end}{document}.  

However, as often as not this isn't the problem, and (short of
debugging the source of the document before ending) brute force is
probably necessary.  Excessive force (killing the job that's
running \TeX{}) is to be avoided: there may well be evidence in the
\extension{log} file that will be useful in determining what the
problem is~--- so the aim is to persuade \TeX{} to shut itself down
and hence flush all log output to file.

If you can persuade \TeX{} to read it, an end-of-file indication
(control-|D| under Unix, control-|Z| under Windows) will provoke
\TeX{} to report an error and exit immediately.  Otherwise you should
attempt to provoke an error dialogue, from which you can exit (using
the |x| `command').  An accessible error could well be inserting an
illegal character: what it is will depend on what macros you are
running.  If you can't make that work, try a silly command name or
two.

\Question[Q-unkgrfextn]{``Unknown graphics extension''}

The \LaTeX{} graphics package deals with several different types of
\acro{DVI} (or other) output drivers; each one of them has a potential
to deal with a different selection of graphics formats.  The package
therefore has to be told what graphics file types its output driver
knows about; this is usually done in the \meta{driver}\extension{def} file
corresponding to the output driver you're using.

The error message arises, then, if you have a graphics file whose
extension doesn't correspond with one your driver knows about.  Most
often, this is because you're being optimistic: asking
\ProgName{dvips} to deal with a \extension{png} file, or \PDFTeX{} to deal with
a \extension{eps} file: the solution in this case is to transform the graphics
file to a format your driver knows about.

If you happen to \emph{know} that your device driver deals with the
format of your file, you are probably falling foul of a limitation of
the file name parsing code that the graphics package uses.  Suppose
you want to include a graphics file \File{home.bedroom.eps} using the
\ProgName{dvips} driver; the package will conclude that your file's
extension is \extension{bedroom.eps}, and will complain.

The \Package{grffile} package deals with the last problem (and
others~--- see the package documentation); using the package, you may
write:
\begin{quote}
\begin{verbatim}
\usepackage{graphicx}
\usepackage{grffile}
...
\includegraphics{home.bedroom.eps}
\end{verbatim}
\end{quote}
or you may even write
\begin{quote}
\begin{verbatim}
\includegraphics{home.bedroom}
\end{verbatim}
\end{quote}
and \Package{graphicx} will find a \extension{eps} or \extension{pdf}
(or whatever) version, according to what version of \AllTeX{} you're
running.

If for some reason you can't use \Package{grffile}, you have three
unsatisfactory alternatives:
\begin{itemize}
\item Rename the file~--- for example \File{home.bedroom.eps}\arrowhyph{}%
  \File{home-bedroom.eps}
\item Mask the first dot in the file name:
\begin{verbatim}
\newcommand*{\DOT}{.}
\includegraphics{home\DOT bedroom.eps}
\end{verbatim}
\item Tell the graphics package what the file is, by means of options
  to the \csx{includegraphics} command:
\begin{narrowversion}
\begin{verbatim}
\includegraphics[type=eps,ext=.eps,
                 read=.eps]{home.bedroom}
\end{verbatim}
\end{narrowversion}
\begin{wideversion}
\begin{verbatim}
\includegraphics[type=eps,ext=.eps,read=.eps]{home.bedroom}
\end{verbatim}
\end{wideversion}
\end{itemize}
\begin{ctanrefs}
\item[grffile.sty]Distributed as part of the \CTANref{oberdiek} collection
\end{ctanrefs}

\Question[Q-nodollar]{``Missing \texttt{\$} inserted''}

There are certain things that \emph{only} work in maths mode.  If your
document is not in maths mode and you have an |_| or a |^| character,
\TeX{} (and by inheritance, \LaTeX{} too) will say
\begin{verbatim}
! Missing $ inserted
\end{verbatim}
as if you couldn't possibly have misunderstood the import of what you
were typing, and the only possible interpretation is that you had
committed a typo in failing to enter maths mode.  \TeX{}, therefore,
tries to patch things up by inserting the \texttt{\$} you `forgot', so that
the maths-only object will work; as often as not this will land you in
further confusion.

It's not just the single-character maths sub- and superscript
operators: anything that's built in or declared as a maths operation,
from the simplest lower-case \csx{alpha} through the inscrutable
\csx{mathchoice} primitive, and beyond, will provoke the error if
misused in text mode.

\LaTeX{} offers a command \csx{ensuremath}, which will put you in maths
mode for the execution of its argument, if necessary: so if you want
an \csx{alpha} in your running text, say
\cmdinvoke{ensuremath}{\csx{alpha}}; if the bit of running text somehow
transmutes into a bit of mathematics, the \csx{ensuremath} will become
a no-op, so it's pretty much always safe.

\Question[Q-fontunavail]{Warning: ``Font shape \dots{}\ not available''}

\LaTeX{}'s font selection scheme maintains tables of the font families
it has been told about.  These tables list the font families that
\LaTeX{} knows about, and the shapes and series in which those font
families are available.  In addition, in some cases, the tables list
the sizes at which \LaTeX{} is willing to load fonts from the family.

When you specify a font, using one of the \LaTeX{} font selection
commands, \LaTeX{} looks for the font (that is, a font that matches
the encoding, family, shape, series and size that you want) in its
tables.  If the font isn't there at the size you want, you will see a
message like:
\htmlignore
\begin{dviversion}
\begin{verbatim}
LaTeX Font Warning: Font shape `OT1/cmr/m/n' in
...                 size <11.5> not available
(Font)              size <12> substituted on
...                 input line ...
\end{verbatim}
(All the message texts in this answer have been wrapped so that they
will fit in the narrow columns of this version of the \acro{FAQ}.  The
continuation marker is |...| at the start of the broken-off portion of
the line.)

\end{dviversion}
\begin{pdfversion}
\begin{verbatim}
LaTeX Font Warning: Font shape `OT1/cmr/m/n' in size <11.5> not available
(Font)              size <12> substituted on input line ...
\end{verbatim}
\end{pdfversion}
\endhtmlignore
\begin{htmlversion}
\begin{verbatim}
LaTeX Font Warning: Font shape `OT1/cmr/m/n' in size <11.5> not available
(Font)              size <12> substituted on input line ...
\end{verbatim}
\end{htmlversion}
There will also be a warning like:
\htmlignore
\begin{dviversion}
\begin{verbatim}
LaTeX Font Warning: Size substitutions with
...                 differences
(Font)              up to 0.5pt have occurred.
\end{verbatim}
\end{dviversion}
\begin{pdfversion}
\begin{verbatim}
LaTeX Font Warning: Size substitutions with differences
(Font)              up to 0.5pt have occurred.
\end{verbatim}
\end{pdfversion}
\endhtmlignore
\begin{htmlversion}
\begin{verbatim}
LaTeX Font Warning: Size substitutions with differences
(Font)              up to 0.5pt have occurred.
\end{verbatim}
\end{htmlversion}
after \LaTeX{} has encountered \cmdinvoke{end}{document}.

The message tells you that you've chosen a font size that is not in
\LaTeX{}'s list of ``allowed'' sizes for this font; \LaTeX{} has
chosen the nearest font size it knows is allowed.  In fact, you can
tell \LaTeX{} to allow \emph{any} size: the restrictions come from the
days when only bitmap fonts were available, and they have never
applied to fonts that come in scaleable form in the first place.
Nowadays, most of the fonts that were once bitmap-only are also
available in scaleable (Adobe Type~1) form.  If your installation uses
scaleable versions of the Computer Modern or European Computer Modern
(\acro{EC}) fonts, you can tell \LaTeX{} to remove the restrictions;
use the \Package{type1cm} or \Package{type1ec} package as appropriate.

If the combination of font shape and series isn't available, \LaTeX{}
will usually have been told of a fall-back combination that may be
used, and will select that:
\htmlignore
\begin{dviversion}
\begin{verbatim}
LaTeX Font Warning: Font shape `OT1/cmr/bx/sc'
...                 undefined
(Font)              using `OT1/cmr/bx/n'
...                 instead on input line 0.
\end{verbatim}
\end{dviversion}
\begin{pdfversion}
\begin{verbatim}
LaTeX Font Warning: Font shape `OT1/cmr/bx/sc' undefined
(Font)              using `OT1/cmr/bx/n' instead on input line 0.
\end{verbatim}
\end{pdfversion}
\endhtmlignore
\begin{htmlversion}
\begin{verbatim}
LaTeX Font Warning: Font shape `OT1/cmr/bx/sc' undefined
(Font)              using `OT1/cmr/bx/n' instead on input line 0.
\end{verbatim}
\end{htmlversion}

Substitutions may also be ``silent''; in this case, there is no more
than an ``information'' message in the log file.  For example, if you
specify an encoding for which there is no version in the current font
family, the `default family for the encoding' is selected.  This
happens, for example, if you use command \csx{textbullet}, which is
normally taken from the maths symbols font, which is in |OMS|
encoding.  My test log contained:
\htmlignore
\begin{dviversion}
\begin{verbatim}
LaTeX Font Info:    Font shape `OMS/cmr/m/n' in
...                 size <10> not available
(Font)              Font shape `OMS/cmsy/m/n'
...                 tried instead on input
...                 line ...
\end{verbatim}
\end{dviversion}
\begin{pdfversion}
\begin{verbatim}
LaTeX Font Info:    Font shape `OMS/cmr/m/n' in size <10> not available
(Font)              Font shape `OMS/cmsy/m/n' tried instead on input line ...
\end{verbatim}
\end{pdfversion}
\endhtmlignore
\begin{htmlversion}
\begin{verbatim}
LaTeX Font Info:    Font shape `OMS/cmr/m/n' in size <10> not available
(Font)              Font shape `OMS/cmsy/m/n' tried instead on input line ...
\end{verbatim}
\end{htmlversion}

In summary, these messages are not so much error messages, as
information messages, that tell you what \LaTeX{} has made of your
text.  You should check what the messages say, but you will ordinarily
not be surprised at their content.
\begin{ctanrefs}
\item[type1cm.sty]\CTANref{type1cm}
\item[type1ec.sty]\CTANref{type1ec}
\end{ctanrefs}

\Question[Q-buffovl]{Unable to read an entire line}

\TeX{} belongs to the generation of applications written for
environments that didn't offer the sophisticated string and i/o
manipulation we nowadays take for granted (\TeX{} was written in
Pascal, and the original Pascal standard made no mention of i/o, so
that anything but the most trivial operations were likely to be
unportable).

When you overwhelm \TeX{}'s input mechanism, you get told:
\begin{verbatim}
! Unable to read an entire line---bufsize=3000.
    Please ask a wizard to enlarge me.
\end{verbatim}
(for some value of `3000'~--- the quote was from a
\Newsgroup{comp.text.tex} posting by a someone who was presumably
using an old \TeX{}).

As the message implies, there's (what \TeX{} thinks of as a) line in
your input that's ``too long'' (to \TeX{}'s way of thinking).  Since
modern distributions tend to have tens of thousands of bytes of input
buffer, it's somewhat rare that these messages occur ``for real''.
Probable culprits are:
\begin{itemize}
\item A file transferred from another system, without translating
  record endings.  With the decline of fixed-format records (on
  mainframe operating systems) and the increased intelligence of
  \TeX{} distributions at recognising other systems' explicit
  record-ending characters, this is nowadays rather a rare cause of
  the problem.
\item A graphics input file, which a package is examining for its
  bounding box, contains a binary preview section.  Again,
  sufficiently clever \TeX{} distributions recognise this situation,
  and ignore the previews (which are only of interest, if at all, to a
  \TeX{} previewer).
\end{itemize}

The usual advice is to ignore what \TeX{} says (i.e., anything about
enlarging), and to put the problem right in the source. 

If the real problem is over-long text lines, most self-respecting text
editors will be pleased to automatically split long lines (while
preserving the ``word'' structure) so that they are nowhere any longer
than a given length; so the solution is just to edit the file.

If the problem is a ridiculous preview section, try using
\ProgName{ghostscript} to reprocess the file, outputting a ``plain
\extension{eps}'' file.  (\ProgName{Ghostscript} is distributed with a script
\ProgName{ps2epsi} which will regenerate the preview if necessary.)
Users of the shareware program \ProgName{GSview} will find buttons to
perform the required transformation of the file being displayed.
\begin{ctanrefs}
\item[ghostscript]Browse \CTANref{ghostscript}
\item[GSview]Browse \CTANref{gsview}
\end{ctanrefs}

\Question[Q-formatstymy]{``Fatal format file error; I'm stymied''}

\AllTeX{} applications often fail with this error when you've been
playing with the configuration, or have just installed a new version.

The format file contains the macros that define the system you want to
use: anything from the simplest (\plaintex{}) all the way to the most
complicated, such as \LaTeX{} or \CONTeXT{}.  From the command you
issue, \TeX{} knows which format you want.

The error message
\begin{verbatim}
  Fatal format file error; I'm stymied
\end{verbatim}
means that \TeX{} itself can't understand the format you want.
Obviously, this could happen if the format file had got corrupted, but
it usually doesn't.  The commonest cause of the message, is that a new
binary has been installed in the system: no two \TeX{} binaries on the
same machine can
understand each other's formats.  So the new version of \TeX{} you
have just installed, won't understand the format generated by the one
you installed last year.

Resolve the problem by regenerating the format; of course, this
depends on which system you are using.
\begin{itemize}
\item On a te\TeX{}-based system, run
\begin{verbatim}
  fmtutil --all
\end{verbatim}
  or
\begin{verbatim}
  fmtutil --byfmt=<format name>
\end{verbatim}
  to build only the format that you are interested in.
\item On a \miktex{} system, click \texttt{Start}\arrowhyph{}%
\texttt{Programs}\arrowhyph{}%
\texttt{\miktex{} \emph{version}}\arrowhyph{}%
\texttt{\miktex{} Options}, and in the options window, click
  \texttt{Update now}.
\end{itemize}

\Question[Q-nonpdfsp]{Non-\acro{PDF} special ignored!}

This is a \PDFTeX{} error: \PDFTeX{} is running in \acro{PDF} output
%  beware line break at end line
mode, and it has encountered a \nothtml{\csx{special} command (}%
\Qref{\csx{special}}{Q-specials}\latexhtml{)}{ command}.  \PDFTeX{} is
able to generate its own output, and in this mode of operation has no
need of \csx{special} commands (which allow the user to pass
information to the driver being used to generate output).

Why does this happen?  \LaTeX{} users, nowadays, hardly ever use
\csx{special} commands on their own~--- they employ packages to do the
job for them.  Some packages will generate \csx{special} commands
however they are invoked: \Package{pstricks} is an example (it's very
raison d'\^etre is to emit \PS{} code in a sequence of \csx{special}
commands).  \Package{Pstricks} may be dealt with by other means (the
\Package{pdftricks} package offers a usable technique).

More amenable to correction, but more confusing, are packages (such as
\Package{color}, \Package{graphics} and \Package{hyperref}) that
specify a ``driver''.  These packages have plug-in modules that
determine what \csx{special} (or other commands) are needed to generate
any given effect: the \texttt{pdftex} driver for such packages knows not to
generate \csx{special} commands.  In most circumstances, you can let
the system itself choose which driver you need; in this case
everything will act properly when you switch to using \PDFLaTeX{}.  If
you've been using \ProgName{dvips} (and specifying the |dvips| driver)
or \ProgName{dvipdfm} (for which you have to specify the driver), and
decide to try \PDFLaTeX{}, you \emph{must} remove the |dvips| or
|dvipdfm| driver specification from the package options, and let the
system recognise which driver is needed.
\begin{ctanrefs}
\item[pdftricks.sty]\CTANref{pdftricks}
\item[pstricks.sty]\CTANref{pstricks}
\end{ctanrefs}

\Question[Q-8000]{Mismatched mode ljfour and resolution 8000}

You're running \ProgName{dvips}, and you encounter a stream of error
messages, starting with ``\texttt{Mismatched mode}''.  The mode is the
default used in your installation~--- it's set in the \ProgName{dvips}
configuration file, and \texttt{ljfour} is commonest (since it's the
default in most distributions), but not invariable.

The problem is that \ProgName{dvips} has encountered a font for which
it must generate a bitmap (since it can't find it in Type~1 format),
and there is no proforma available to provide instructions to give to
\MF{}.

So what to do?  The number 8000 comes from the `\texttt{-Ppdf}' option
to \ProgName{dvips}, which you might have found from the answer
\nothtml{``wrong type of fonts'' (}% beware % beware line breaks
\Qref{``wrong type of fonts''}{Q-fuzzy-type3}\nothtml{)}.  The obvious
solution is to switch to the trivial substitute `\texttt{-Pwww}',
which selects the necessary type~1 fonts for \acro{PDF} generation,
but nothing else: however, this will leave you with undesirable bitmap
fonts in your \acro{PDF} file.  The ``proper'' solution is to find a
way of expressing what you want to do, using type~1 fonts.

\Question[Q-toodeep]{``Too deeply nested''}

This error appears when you start a \LaTeX{} list.

\LaTeX{} keeps track of the nesting of one list inside another.  There
is a set of list formatting parameters built-in for application to
each of the list nesting levels; the parameters determine indentation,
item separation, and so on.  The \environment{list} environment (the
basis for list environments like \environment{itemize} and
\environment{enumerate}) ``knows'' there are only 6 of these sets.

There are also different label definitions for the
\environment{enumerate} and \environment{itemize} environments at
their own private levels of nesting.  Consider this example:
\begin{quote}
\begin{verbatim}
\begin{enumerate}
\item first item of first enumerate
  \begin{itemize}
  \item first item of first itemize
    \begin{enumerate}
    \item first item of second enumerate
    ...
    \end{enumerate}
  ...
  \end{itemize}
...
\end{enumerate}
\end{verbatim}
\end{quote}
In the example,
\begin{itemize}
\item the first \environment{enumerate} has labels as for a
  first-level \environment{enumerate}, and is indented as for a
  first-level list;
\item the first \environment{itemize} has labels as for a first level
  \environment{itemize}, and is indented as for a second-level list;
  and
\item the second \environment{enumerate} has labels as for a
  second-level \environment{enumerate}, and is indented as for a
  third-level list.
\end{itemize}
Now, as well as \LaTeX{} \emph{knowing} that there are 6~sets of
parameters for indentation, it also \emph{knows} that there are only
4~types of labels each, for the environments \environment{enumerate}
and \environment{itemize} (this ``knowledge'' spells out a requirement
for class writers, since the class supplies the sets of parameters).

From the above, we can deduce that there are several ways we can run
out of space: we can have 6~lists (of any sort) nested, and try to
start a new one; we can have 4~\environment{enumerate} environments
somewhere among the set of nested lists, and try to add another one;
and we can have 4~\environment{itemize} environments somewhere among
the set of nested lists, and try to add another one.

What can be done about the problem?  Not much, short of rewriting
\LaTeX{}~--- you really need to rewrite your document in a slightly
less labyrinthine way.

\Question[Q-inputlev]{Capacity exceeded~--- input levels}

The error
\begin{wideversion}
\begin{verbatim}
! TeX capacity exceeded, sorry [text input levels=15].
\end{verbatim}
\end{wideversion}
\begin{narrowversion}
\begin{verbatim}
! TeX capacity exceeded, sorry
                         [text input levels=15].
\end{verbatim}
\end{narrowversion}
is caused by nesting your input too deeply.  You can provoke it with
the trivial (\plaintex{}) file \File{input.tex}, which contains
nothing but: 
\begin{verbatim}
\input input
\end{verbatim}
In the real world, you are unlikely to encounter the error with a
modern \TeX{} distribution.  Te\TeX{} (used to produce the error
message above) allows 15 files open for \TeX{} input at any one time,
which is improbably huge for a document generated by real human
beings.

However, for those improbable (or machine-generated) situations,
some distributions offer the opportunity to adjust the parameter
|max_in_open| in a configuration file.

\Question[Q-hyperdupdest]{\PDFTeX{} destination \dots{} ignored}

The warning:
\begin{quote}
\begin{wideversion}
\begin{verbatim}
! pdfTeX warning (ext4): destination with the same identifier
(name{page.1}) has been already used, duplicate ignored
\end{verbatim}
\end{wideversion}
\begin{narrowversion}
\begin{verbatim}
! pdfTeX warning (ext4): destination with
  the same identifier (name{page.1}) has
  been already used, duplicate ignored
\end{verbatim}
{\small NB: message text wrapped to fit in the column\par}
\end{narrowversion}
\end{quote}
arises because of duplicate page numbers in your document.  The
problem is usually soluble: see % beware line break
\Qref*[question]{\acro{PDF} page destinations}{Q-pdfpagelabels}~--- which
answer also describes the problem in more detail.

If the identifier in the message is different, for example
|name{figure.1.1}|, the problem is (usually) due to a problem of
package interaction.  Some packages are simply incompatible with
\Package{hyperref}, but most work simply by ignoring it.  In most
cases, therefore, you should load your package before you load
\Package{hyperref}, and \Package{hyperref} will patch things up so
that they work, so you can utilise your (patched) package \emph{after}
loading both:
\begin{quote}
  \cmdinvoke{usepackage}{\emph{your package}}\\
  \texttt{...}\\
  \cmdinvoke{usepackage}[\emph{opts}]{hyperref}\\
  \texttt{...}\\
  \meta{code that uses your package}
\end{quote}
\begin{wideversion}
For example:
\begin{quote}
\begin{verbatim}
\usepackage{float}          % defines \newfloat
...
\usepackage[...]{hyperref}  % patches \newfloat
...
\newfloat{...}{...}{...}
\end{verbatim}
\end{quote}
\end{wideversion}
\begin{narrowversion}
So, if we need \csx{newfloat}:
\begin{quote}
\cmdinvoke{usepackage}{float}
\end{quote}
will define the command,
\begin{quote}
\cmdinvoke{usepackage}[\emph{opts}]{hyperref}
\end{quote}
will patch it, and now: 
\begin{quote}
\cmdinvoke{newfloat}{...}{...}{...}
\end{quote}
will use the command, patched to create `proper' hyperreferences.
\end{narrowversion}
You should load packages in this order as a matter of course, unless
the documentation of a package says you \emph{must} load it after
\Package{hyperref}.  (There aren't many packages that require to be
loaded after hyperref: one such is \Class{memoir}'s
``\Package{hyperref} fixup'' package \Package{memhfixc}.)

If loading your packages in the (seemingly) ``correct'' order doesn't
solve the problem, you need to \Qref*{seek further help}{Q-gethelp}.

\Question[Q-altabcr]{Alignment tab changed to \csx{cr}}

This is an error you may encounter in \LaTeX{} when a tabular
environment is being processed.  ``Alignment tabs'' are the
\texttt{\&} signs that separate the columns of a tabular; so the error
message
\begin{quote}
\begin{narrowversion}
\begin{verbatim}
! Extra alignment tab has been 
                            changed to \cr
\end{verbatim}
\end{narrowversion}
\begin{wideversion}
\begin{verbatim}
! Extra alignment tab has been changed to \cr
\end{verbatim}
\end{wideversion}
\end{quote}
could arise from a simple typo, such as:
\begin{quote}
\begin{verbatim}
\begin{tabular}{ll}
  hello   & there & jim \\
  goodbye & now
\end{tabular}
\end{verbatim}
\end{quote}
where the second \texttt{\&} in the first line of the table is more than the
two-column \texttt{ll} column specification can cope with. In this
case, an extra ``\texttt{l}'' in that solves the problem.  (If you
continue from the error in this case, ``\texttt{jim}'' will be moved
to a row of his own.)  Another simple typo that can provoke the error
is:
\begin{quote}
\begin{verbatim}
\begin{tabular}{ll}
  hello   & there
  goodbye & now
\end{tabular}
\end{verbatim}
\end{quote}
where the `\texttt{\bsbs }' has been missed from the first line of the table.
In this case, if you continue from the error, you will find that
\LaTeX{} has made a table equivalent to:
\begin{quote}
\begin{verbatim}
\begin{tabular}{ll}
  hello   & there goodbye\\
  now
\end{tabular}
\end{verbatim}
\end{quote}
(with the second line of the table having only one cell).

Rather more difficult to spot is the occurrence of the error when
you're using alignment instructions in a ``\texttt{p}'' column:
\begin{quote}
\begin{verbatim}
\usepackage{array}
...
\begin{tabular}{l>{\raggedright}p{2in}}
here & we are again \\
happy & as can be
\end{tabular}
\end{verbatim}
\end{quote}
the problem here (as explained in % ! line break
\Qref[question]{tabular cell alignment}{Q-tabcellalign}) is that the
\csx{raggedright} command in the column specification has overwritten
\environment{tabular}'s definition of \texttt{\bsbs }, so that
``\texttt{happy}'' appears in a new line of the second column, and the
following \texttt{\&} appears to \LaTeX{} just like the second
\texttt{\&} in the first example above.

Get rid of the error in the way described in % ! linebreak
\Qref[question]{tabular cell alignment}{Q-tabcellalign}~--- either use
\csx{tabularnewline} explicitly, or use the \csx{RBS} trick described
there.
\begin{ctanrefs}
\item[array.sty]Distributed as part of \CTANref{2etools}
\end{ctanrefs}

\Question[Q-divzero]{Graphics division by zero}

While the error
\begin{quote}
\begin{verbatim}
! Package graphics Error: Division by 0.
\end{verbatim}
\end{quote}
can actually be caused by offering the package a figure which claims
to have a zero dimension, it's more commonly caused by rotation.

Objects in \TeX{} may have both height (the height above the baseline)
and depth (the distance the object goes below the baseline).  If you
rotate an object by 180\,degrees, you convert its height into depth,
and vice versa; if the object started with zero depth, you've
converted it to a zero-height object.

Suppose you're including your graphic with a command like:
\begin{quote}
\begin{wideversion}
\begin{verbatim}
\includegraphics[angle=180,height=5cm]{myfig.eps}
\end{verbatim}
\end{wideversion}
\begin{narrowversion}
\begin{verbatim}
\includegraphics[angle=180,%
                height=5cm]{myfig.eps}
\end{verbatim}
\end{narrowversion}
\end{quote}
In the case that \File{myfig.eps} has no depth to start with, the
scaling calculations will produce the division-by-zero error.

Fortunately, the \Package{graphicx} package has a keyword
\pkgoption{totalheight}, which allows you to specify the size of the
image relative to the sum of the object's \pkgoption{height} and
\pkgoption{depth}, so
\begin{quote}
\begin{wideversion}
\begin{verbatim}
\includegraphics[angle=180,totalheight=5cm]{myfig.eps}
\end{verbatim}
\end{wideversion}
\begin{narrowversion}
\begin{verbatim}
\includegraphics[angle=180,%
           totalheight=5cm]{myfig.eps}
\end{verbatim}
\end{narrowversion}
\end{quote}
will resolve the error, and will behave as you might hope.

If you're using the simpler \Package{graphics} package, use the
\texttt{*} form of the \csx{resizebox} command to specify the use of
\pkgoption{totalheight}:
\begin{quote}
\begin{verbatim}
\resizebox*{!}{5cm}{%
  \rotatebox{180}{%
    \includegraphics{myfig.eps}%
  }%
}
\end{verbatim}
\end{quote}
\begin{ctanrefs}
\item[graphics.sty,graphicx.sty]Both parts of the \CTANref{graphics} bundle
\end{ctanrefs}

\Question[Q-missbegdoc]{Missing \csx{begin}\marg{document}}

Give it a file of plain text, or a \LaTeX{} file that really does have no
\cmdinvoke{begin}{document} command in it, and \LaTeX{} will produce
this error, quite correctly.  \LaTeX{} \emph{needs}
\cmdinvoke{begin}{document} so as to know when to execute the commands
that finish off the document preamble.

Other than that, the error can occur as a result of an error of yours,
of a corrupt \extension{aux} file, or of a buggy class or package.

The errors you might commit are absent-mindedly typing a document
command (such as \csx{section}) in the preamble of your document,
missing the comment marker from the beginning of a line, or giving too
many arguments to one of the setup commands related to the class or a
package that you have loaded.

A corrupt \extension{aux} file might be due to any number of things;
delete the file and to run \LaTeX{} again, twice.  If the error
recurs, it's probably due to a buggy class or package.

If the error occurs while \LaTeX{} is reading a class or package, then
there's probably a bug in the file.  The author of the class or
package stands the best chance of finding the bug, but with luck you
(or someone you ask on a mailing list or on \Newsgroup{comp.text.tex})
will be able to spot the problem and provide a work-around.  Always
report such bugs, even if you have found a work-around.

\Question[Q-normalszmiss]{\csx{normalsize} not defined}

The \LaTeX{} error:
\begin{quote}
\begin{narrowversion}
\begin{verbatim}
The font size command \normalsize is not
   defined: there is probably something
   wrong with the class file.
\end{verbatim}
\end{narrowversion}
\begin{wideversion}
\begin{verbatim}
The font size command \normalsize is not defined:
there is probably something wrong with the class file.
\end{verbatim}
\end{wideversion}
\end{quote}
is reporting something pretty fundamental (document base font size not
set up).  While this \emph{can}, as the message implies, be due to a
broken class file, the more common cause is that you have simply
forgotten to put a \csx{documentclass} command in your document.

\Question[Q-manymathalph]{Too many math alphabets}

\TeX{} mathematics is one of its most impressive features, yet the
internal structure of the mechanism that produces it is painfully
complicated and (in some senses) pathetically limited.  One area of
limitation is that one is only allowed 16~''maths alphabets''

\LaTeX{} offers the user quite a lot of flexibility with allocating
maths alphabets, but few people use the flexibility directly.
Nevertheless, there are many packages that provide symbols, or that
manipulate them, which allocate themselves one or more maths alphabet.

If you can't afford to drop any of these packages, there's
still hope if you're using the \Package{bm} package to support
\Qref*{bold maths}{Q-boldgreek}: \Package{bm} is capable
of gobbling alphabets as if there is no tomorrow.  The package defines
two limiter commands: \csx{bmmax} (for \emph{bold} symbols; default~4)
and \csx{hmmax} (for \emph{heavy} symbols, if you have them;
default~3), which control the number of alphabets to be used.  

Any reduction of the \csx{\emph{xx}max} variables will slow
\Package{bm} down~--- but that's surely better than the document not
running at all.  So unless you're using maths fonts (such as
\FontName{Mathtime Plus}) that feature a heavy symbol weight, suppress all
use of heavy families by
\begin{quote}
\begin{verbatim}
  \renewcommand{\hmmax}{0}
\end{verbatim}
\end{quote}
and then steadily reduce the bold families, starting with
\begin{quote}
\begin{verbatim}
  \renewcommand{\bmmax}{3}
\end{verbatim}
\end{quote}
until (with a bit of luck) the error goes away.
\begin{ctanrefs}
\item[bm.sty]Distributed as part of \CTANref{2etools}
\end{ctanrefs}

\Question[Q-ouparmd]{Not in outer par mode}

The error:
\begin{quote}
\begin{verbatim}
! LaTeX Error: Not in outer par mode.
\end{verbatim}
\end{quote}
comes when some ``main'' document feature is shut up somewhere it
doesn't like.

The commonest occurrence is when the user wants a figure somewhere
inside a table:
\begin{quote}
\begin{verbatim}
\begin{tabular}{|l|}
  \hline
  \begin{figure}
  \includegraphics{foo}
  \end{figure}
  \hline
\end{tabular}
\end{verbatim}
\end{quote}
a construction that was supposed to put a frame around the diagram,
but doesn't work, any more than:
\begin{quote}
\begin{verbatim}
\framebox{\begin{figure}
  \includegraphics{foo}
  \end{figure}%
}
\end{verbatim}
\end{quote}
The problem is, that the \environment{tabular} environment, and the
\csx{framebox} command restrain the \environment{figure} environment
from its natural m\'etier, which is to float around the document.

The solution is simply not to use the \environment{figure} environment
here:
\begin{quote}
\begin{verbatim}
\begin{tabular}{|l|}
  \hline
  \includegraphics{foo}
  \hline
\end{tabular}
\end{verbatim}
\end{quote}
What was the float for?~--- as written in the first two examples, it
serves no useful purpose; but perhaps you actually wanted a diagram
and its caption framed, in a float.

It's simple to achieve this~--- just reverse the order of the
environments (or of the \environment{figure} environment and the
command):
\begin{quote}
\begin{verbatim}
\begin{figure}
  \begin{tabular}{|l|}
    \hline
    \includegraphics{foo}
    \caption{A foo}
    \hline
  \end{tabular}
\end{figure}
\end{verbatim}
\end{quote}
The same goes for \environment{table} environments (or any other sort
of float you've defined for yourself) inside tabulars or box commands;
you \emph{must} get the float environment out from inside, one way or
another.

\Question[Q-errmissitem]{Perhaps a missing \csx{item}?}

Sometimes, the error
\begin{quote}
\begin{verbatim}
Something's wrong--perhaps a missing \item
\end{verbatim}
\end{quote}
actually means what it says:
\begin{quote}
\begin{verbatim}
\begin{itemize}
  boo!
\end{itemize}
\end{verbatim}
\end{quote}
produces the error, and is plainly in need of an \csx{item} command.

You can also have the error appear when at first sight things are
correct:
\begin{quote}
\begin{verbatim}
\begin{tabular}{l}
  \begin{enumerate}
  \item foo\\
  \item bar
  \end{enumerate}
\end{tabular}
\end{verbatim}
\end{quote}
produces the error at the \texttt{\bsbs }.  This usage is just wrong; if you
want to number the cells in a table, you have to do it ``by hand'':
\begin{quote}
\begin{verbatim}
\newcounter{tablecell}
\begin{tabular}{l}
  \stepcounter{tablecell}
  \thetablecell. foo\\
  \stepcounter{tablecell}
  \thetablecell. bar
  \end{enumerate}
\end{tabular}
\end{verbatim}
\end{quote}
This is obviously untidy; a command \csx{numbercell} defined as:
\begin{quote}
\begin{verbatim}
\newcounter{tablecell}
\newcommand*{\numbercell}{%
  \stepcounter{tablecell}%
  \thetablecell. % **
}
\end{verbatim}
\end{quote}
could make life easier:
\begin{quote}
\begin{verbatim}
\begin{tabular}{l}
  \numbercell foo\\
  \numbercell bar
  \end{enumerate}
\end{tabular}
\end{verbatim}
\end{quote}
(Note the deliberate introduction of a space as part of the command,
marked with asterisks.)

However, the error regularly appears when you would never have thought
that a \csx{item} command  might be appropriate.  For example, the
seemingly innocent:
\begin{quote}
\begin{verbatim}
\fbox{%
  \begin{alltt}
    boo!
  \end{alltt}%
}
\end{verbatim}
\end{quote}
produces the error (the same happens with \csx{mbox} in place of
\csx{fbox}, or with either of their ``big brothers'', \csx{framebox} and
\csx{makebox}).  This is because the \environment{alltt} environment
uses a ``trivial'' list, hidden inside their definition.  (The
\environment{itemize} environment also has this construct inside
itself, in fact, so \cmdinvoke{begin}{itemize} won't work inside an
\csx{fbox}, either.)  The list construct wants to happen between
paragraphs, so it makes a new paragraph of its own.  Inside the
\csx{fbox} command, that doesn't work, and subsequent macros convince
themselves that there's a missing \csx{item} command.

To solve this rather cryptic error, one must put the
\environment{alltt} inside a paragraph-style box.  The following
modification of the above \emph{does} work:
\begin{quote}
\begin{verbatim}
\fbox{%
  \begin{minipage}{0.75\textwidth}
    \begin{alltt}
      hi, there!
    \end{alltt}
  \end{minipage}
}
\end{verbatim}
\end{quote}
The code above produces a box that's far too wide for the text.  One
may want to use something that allows % ! line break
\Qref*{variable size boxes}{Q-varwidth} in place of the
\environment{minipage} environment.

Oddly, although the \environment{verbatim} environment wouldn't work
inside a \csx{fbox} command argument (see % ! line break
\Qref[question]{verbatim in command arguments}{Q-verbwithin}), you
get an error that complains about \csx{item}: the environment's
internal list bites you before \environment{verbatim} has even had a
chance to create its own sort of chaos.

Another (seemingly) obvious use of \csx{fbox} also falls foul of this
error:
\begin{quote}
\begin{verbatim}
\fbox{\section{Boxy section}}
\end{verbatim}
\end{quote}
This is a case where you've simply got to be more subtle; you should
either write your own macros to replace the insides of \LaTeX{}'s
sectioning macros, or  look for some alternative in the packages
discussed in % ! line break
``\Qref*[question]{The style of section headings}{Q-secthead}''.

\Question[Q-errparnum]{Illegal parameter number in definition}

The error message means what it says.  In the simple case, you've
attempted a definition like:
\begin{quote}
\begin{verbatim}
\newcommand{\abc}{joy, oh #1!}
\end{verbatim}
\end{quote}
or (using \TeX{} primitive definitions):
\begin{quote}
\begin{verbatim}
\def\abc{joy, oh #1!}
\end{verbatim}
\end{quote}
In either of the above, the definition uses an argument, but the
programmer did not tell \AllTeX{}, in advance, that she was going to.
The fix is simple~--- \cmdinvoke{newcommand}{\csx{abc}}[1], in the
\LaTeX{} case, |\def\abc#1| in the basic \TeX{} case.

The more complicated case is exemplified by the attempted definition:
\begin{quote}
\begin{verbatim}
\newcommand{\abc}{joy, oh joy!%
  \newcommand{\ghi}[1]{gloom, oh #1!}%
}
\end{verbatim}
\end{quote}
will also produce this error, as will its \TeX{} primitive equivalent:
\begin{quote}
\begin{verbatim}
\def\abc{joy, oh joy!%
  \def\ghi#1{gloom, oh #1!}%
}
\end{verbatim}
\end{quote}
This is because special care is needed when defining one macro within
the code of another macro.  This is explained elsewhere, separately
for \Qref*[question]{\LaTeX{} definitions}{Q-ltxhash} and for
\Qref*[question]{\TeX{} primitive definitions}{Q-hash}

\Question[Q-fllost]{Float(s) lost}

The error
\begin{quote}
\begin{verbatim}
! LaTeX Error: Float(s) lost.
\end{verbatim}
\end{quote}
seldom occurs, but always seems deeply cryptic when it \emph{does}
appear.

The message means what it says: one or more figures, tables, etc., or
marginpars has not been typeset.  (Marginpars are treated internally
as floats, which is how they come to be lumped into this error
message.)

The most likely reason is that you placed a float or a \csx{marginpar}
command inside another float or marginpar, or inside a
\environment{minipage} environment, a \csx{parbox} or \csx{footnote}.
Note that the error may be detected a long way from the problematic
command(s), so the techniques of % ! line break
\Qref*{tracking down elusive errors}{Q-erroradvice} all need to be
called into play.

This author has also encountered the error when developing macros that
used the \LaTeX{} internal float mechanisms.  Most people doing that
sort of thing are expected to be able to work out their own problems\dots{}

\Question[Q-optionclash]{Option clash for package}

So you've innocently added:
\begin{quote}
\cmdinvoke{usepackage}[draft]{graphics}
\end{quote}
to your document, and \LaTeX{} responds with
\begin{wideversion}
\begin{quote}
\begin{verbatim}
! LaTeX Error: Option clash for package graphics.
\end{verbatim}
\end{quote}
\end{wideversion}
\begin{narrowversion}
\begin{quote}
\begin{verbatim}
! LaTeX Error: Option clash for package
                                    graphics.
\end{verbatim}
\end{quote}
\end{narrowversion}

The error is a complaint about loading a package % ! line break
\emph{with options}, more than once (\LaTeX{} doesn't actually examine
what options there are: it complains because it can't do anything with
the multiple sets of options).  You can load a package
any number of times, with no options, and \LaTeX{} will be happy, but
you may only supply options when you first load the package.

So perhaps you weren't entirely innocent~--- the error would have
occurred on the second line of:
\begin{quote}
\cmdinvoke{usepackage}[dvips]{graphics}\\
\cmdinvoke{usepackage}[draft]{graphics}
\end{quote}
which could quite reasonably (and indeed correctly) have been typed:
\begin{quote}
\cmdinvoke{usepackage}[dvips,draft]{graphics}
\end{quote}

But if you've not made that mistake (even with several lines
separating the \csx{usepackage} commands, it's pretty easy to spot),
the problem could arise from something else loading the package for
you.  How do you find the culprit?  The "\texttt{h}" response to the
error message tells you which options were loaded each time.
Otherwise, it's down to the log analysis games discussed in % ! line break
``\Qref*{How to approach errors}{Q-erroradvice}''; the trick to remember
is that that the process of loading each file is parenthesised in the
log; so if package \Package{foo} loads \Package{graphics}, the log
will contain something like:
\begin{quote}
\begin{verbatim}
(<path>/foo.sty ...
...
(<path>/graphics.sty ...
...)
...
)
\end{verbatim}
\end{quote}
(the parentheses for \Package{graphics} are completely enclosed in
those for \Package{foo}; the same is of course true if your class
\Class{bar} is the culprit, except that the line will start with the
path to \texttt{bar.cls}).

If we're dealing with a package that loads the package you are
interested in, you need to ask \LaTeX{} to slip in options when
\Package{foo} loads it.  Instead of:
\begin{quote}
\cmdinvoke{usepackage}{foo}\\
\cmdinvoke{usepackage}[draft]{graphics}
\end{quote}
you would write:
\begin{quote}
\cmdinvoke{PassOptionsToPackage}{draft}{graphics}\\
\cmdinvoke{usepackage}{foo}
\end{quote}
The command \csx{PassOptionsToPackage} tells \LaTeX{} to behave as if
its options were passed, when it finally loads a package.  As you would
expect from its name, \csx{PassOptionsToPackage} can deal with a list
of options, just as you would have in the the options brackets of
\csx{usepackage}.

More trickily, instead of:
\begin{quote}
\cmdinvoke{documentclass}[...]{bar}\\
\cmdinvoke{usepackage}[draft]{graphics}
\end{quote}
you would write:
\begin{quote}
\cmdinvoke{PassOptionsToPackage}{draft}{graphics}\\
\cmdinvoke{documentclass}[...]{bar}
\end{quote}
with \csx{PassOptionsToPackage} \emph{before} the \csx{documentclass}
command.

However, if the \Package{foo} package or the \Class{bar} class loads
\Package{graphics} with an option of its own that clashes with
what you need in some way, you're stymied.  For example:
\begin{quote}
\cmdinvoke{PassOptionsToPackage}{draft}{graphics}
\end{quote}
where the package or class does:
\begin{quote}
\cmdinvoke{usepackage}[final]{graphics}
\end{quote}
sets \pkgoption{final} \emph{after} it's dealt with option you passed to
it, so your \pkgoption{draft} will get forgotten.  In extreme cases,
the package might generate an error here (\Package{graphics} doesn't
go in for that kind of thing, and there's no indication that
\pkgoption{draft} has been forgotten).

In such a case, you have to modify the package or class itself
(subject to the terms of its licence).  It may prove useful to contact
the author: she may have a useful alternative to suggest.

\Question[Q-checksum]{Checksum mismatch in font}

When \MF{} generates a font it includes a checksum in the font bitmap
file, and in the font metrics file (\acro{TFM}).  \AllTeX{} includes
the checksum from the \acro{TFM} file in the \acro{DVI} file.

When \ProgName{dvips} (or other \acro{DVI} drivers) process a
\acro{DVI} file, they compare checksums in the \acro{DVI} file to
those in the bitmap fonts being used for character images.  If the
checksums don't match, it means the font metric file used by \AllTeX{}
was not generated from the same \MF{} program that generated the
font.

This commonly occurs when you're processing someone else's \acro{DVI}
file.

The fonts on your system may also be at fault: possibilities are that
the new \acro{TFM} was not installed, or installed in a path after an
old \acro{TFM} file, or that you have a personal cache of bitmaps from
an old version of the font.

In any case, look at the output -- the chances are that it's perfectly
\acro{OK}, since metrics tend not to change, even when the bitmaps are
improved.  (Indeed, many font designers~--- Knuth included~---
maintain the metrics come what may.)

If the output \emph{does} look bad, your only chance is to regenerate
things from scratch.  Options include: flushing your bitmap cache,
rebuild the \acro{TFM} file locally, and so on.

\Question[Q-entercompmode]{Entering compatibility mode}

You run your \LaTeX{} job, and it starts by saying
\begin{quote}
\begin{verbatim}
Entering LaTeX 2.09 COMPATIBILITY MODE
\end{verbatim}
\end{quote}
followed by lines of asterisks and \texttt{!!WARNING!!}.

This means that the document is not written in ``current'' \LaTeX{}
syntax, and that there is no guarantee that all parts of the document
will be formatted correctly.

If the document is someone else's, and you want no more than a copy to
read, ignore the error.  The document may fail elsewhere, but as often
as not it will provide a \extension{dvi} or \extension{pdf} that's
adequate for most purposes.

If it's a new document you have just started working on, you have been
misled by someone.  You have written something like:
\begin{quote}
  \cmdinvoke{documentstyle}{article}
\end{quote}
or, more generally:
\begin{quote}
  \cmdinvoke*{documentstyle}[options]{class}
\end{quote}
These forms are (as the warning says) \LaTeXo{} syntax, and to get rid
of the warning, you must change the command.

The simple form is easy to deal with:
\begin{quote}
  \cmdinvoke{documentstyle}{article}
\end{quote}
should become:
\begin{quote}
  \cmdinvoke{documentclass}{article}
\end{quote}
The complex form is more difficult, since \LaTeXo{} ``options''
conflate two sorts of things~--- options for the class (such as
\pkgoption{11pt}, \pkgoption{fleqn}), and packages to be loaded.
So:
\begin{quote}
  \cmdinvoke{documentstyle}[11pt,verbatim]{article}
\end{quote}
should become:
\begin{quote}
  \cmdinvoke{documentclass}[11pt]{article}\\
  \cmdinvoke{usepackage}{verbatim}
\end{quote}
because \pkgoption{11pt} happens to be a class option, while
\Package{verbatim} is a package.

There's no simple way to work out what are class options under
\LaTeXo{}; for \Class{article}, the list includes \pkgoption{10pt},
\pkgoption{11pt}, \pkgoption{12pt}, \pkgoption{draft},
\pkgoption{fleqn}, \pkgoption{leqno}, \pkgoption{twocolumn} and
\pkgoption{twoside}~--- anything else must be a package.

Your document may well ``just work'' after changes like those above;
if not, you should think through what you're trying to do, and consult
documentation on how to do it~--- there are lots of % ! line break
\Qref*{free tutorials}{Q-tutorials*} to help you on your way, if you
don't have access to a \LaTeX{} manual of any sort.

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\section{Current \TeX{}-related projects}

\Question[Q-LaTeX3]{The \LaTeX{} project}

The \LaTeX{} project team (see \URL{http://www.latex-project.org/latex3.html})
is a small group of volunteers whose aim is
to produce a major new document processing system based on the
principles pioneered by Leslie Lamport in the current \LaTeX{}.  The
new system is (provisionally) called \LaTeX{}3; it
will remain freely available and it will be fully documented at
all levels.

The \LaTeX{} team's first product (\LaTeXe{}) was delivered in 1994
(it's now properly called ``\LaTeX{}'', since no other version is current).

\LaTeXe{} was intended as a consolidation exercise, unifying several
sub-variants of \LaTeX{} while changing nothing whose change wasn't
absolutely necessary.  This has permitted the team to support a single
version of \LaTeX{}, in parallel with development of \LaTeX{}3.

Some of the older discussion papers about directions for \LaTeX{}3 are
to be found on \acro{CTAN}; other (published) articles are to be
found on the project web site
(\URL{http://www.latex-project.org/papers/}), as is some of the
project's experimental code
(see \URL{http://www.latex-project.org/code.html}, which allows you to
read the project's source repository).  You can
participate in discussions of the future of \LaTeX{} through the
mailing list \texttt{latex-l}.  Subscribe to the list by sending a
message `\texttt{subscribe latex-l <\emph{your name}>}' to 
\mailto{listserv@urz.Uni-Heidelberg.de}
\begin{ctanrefs}
\item[\nothtml{\rmfamily}\LaTeX{} project publications]\CTANref{ltx3pub}
\end{ctanrefs}

\Question[Q-mathml]{Future \acro{WWW} technologies and \AllTeX{}}

An earlier answer % ! line break
(\Qref[number]{``converting to \acro{HTML}''}{Q-LaTeX2HTML})
addresses the issue of converting existing \AllTeX{} documents for
viewing on the Web as \acro{HTML}.  All the present techniques are
somewhat flawed: the answer explains why.

However, things are changing, with
better font availability, cunning \acro{HTML} programming and the
support for new Web standards.
\begin{description}
\item[Font technologies] Direct representation of mathematics in
  browsers has been hampered up to now by the limited range of symbols
  in the fonts one can rely on being available.  Some existing
  \AllTeX{} to \acro{HTML} converters provide maths symbols by
  hitching them to alternate font face specifications for standard
  code points in a non-standard way.  This does nothing for the
  universality of the \acro{HTML} so generated.
  
  In the near future, we can expect rather wide availability of
  Unicode fonts with good coverage of symbols, which should make life
  easier for those who need to represent mathematics.
\item[\acro{XML}] The core of the range of new standards is
  \acro{XML}, which provides a framework for better structured markup;
  limited support for it has already appeared in some browsers.

  Conversion of \AllTeX{} source to \acro{XML} is already available
  (through \TeX{}4ht at least), and work continues in that arena.  The
  alternative, authoring in \acro{XML} (thus producing documents that
  are immediately Web-friendly, if not ready) and using \AllTeX{} to
  typeset is also well advanced.  One useful technique is
  \Qref*{\emph{transforming} the \acro{XML} to \LaTeX{}}{Q-SGML2TeX},
  using an \acro{XSLT} stylesheet or code for an \acro{XML} library,
  and then simply using \LaTeX{}; alternatively, one may
  \Qref*{typeset direct from the \acro{XML} source}{Q-readML}.
\item[Direct representation of mathematics]
  Math\acro{ML} is a standard for representing maths on the Web; its
  original version was distinctly limited, but version 2 of Math\acro{ML}
  has had major browser support since 2002 with richness of mathematical
  content for online purposes approaching that of \TeX{} for print.
  Browser support for Math\acro{ML} is provided by \ProgName{amaya}, the
  `Open Source' browser \ProgName{mozilla} (and its derivatives
  including \ProgName{NetScape}, \ProgName{Firefox} and \ProgName{Galeon}) and
  \ProgName{Internet Explorer} when equipped with a suitable plug-in
  such as \ProgName{MathPlayer}.
  There's evidence that \AllTeX{} users are starting to use such
  browsers.  Some believe that \acro{XHTML}+Math\acro{ML} now provides
  better online viewing than \acro{PDF}.
  Work to produce \acro{XHTML}+Math\acro{ML} is well advanced in both the
  \TeX{}4ht and \ProgName{TtH} projects for \AllTeX{} conversion.
%%   Such conversion, however, has limits of soundness unless one
%%   is very much aware of the needs of one's conversion program
%%   and adapts one's usage of \AllTeX{} accordingly.

  An approach different from \AllTeX{} conversion is taken by
  the \href{http://www.albany.edu/~hammond/gellmu/}{\emph{GELLMU} Project}.
  Its \emph{article} \acro{XML} document type, which has a markup vocabulary
  close to \LaTeX{} that can be edited using \LaTeX{}-like markup
  (even though it is not \LaTeX{}~--- so far), comes with translators
  that make both \acro{PDF} (via \emph{pdflatex}) and
  \acro{XHTML}+Math\acro{ML}.  Such an approach avoids the inherent
  limitations of the ``traditional'' \AllTeX{} translation processes,
  which have traps that can be sprung by unfettered use of \AllTeX{}
  markup.
\item[Graphics] 
  \acro{SVG} is a standard for graphics representation on the web.
  While the natural use is for converting existing figures,
  representations of formulas are also possible, in place of the separate
  bitmaps that have been used in the past (and while we wait for the
  wider deployment of Math\acro{ML}).
  
  Browser plug-ins, that deal with \acro{SVG} are already available
  (Adobe offer one, for example).  More recently, the open source
  graphics editor \href{http://www.inkscape.org/}{\ProgName{Inkscape}}
  has appeared, and has been reported to be useful for
  \acro{SVG}-related work in at least one \TeX{}-related project.  Be
  aware that the developers of \ProgName{Inkscape} have no illusions
  about being able to replace commercial software, yet\dots{}
\item[Direct use of \TeX{} markup]
  Some time back, \acro{IBM} developed a browser plug-in called
  TechExplorer, which would display \AllTeX{} documents direct in a
  browser.  Over the years, it developed into a Math\acro{ML} browser
  plug-in, while still retaining its \AllTeX{} abilities, but it's now
  distributed (free for Linux and Windows platforms) by
  \href{http://www.integretechpub.com/}{Integre Technical Publishing}.

  The disadvantage of the TechExplorer approach is that it places the
  onus on the browser user; and however technically proficient
  \emph{you} are, it's never safe to assume too much of your readers.
  An interesting alternative is
  \href{http://www.forkosh.com/mimetex.html}{Mime\TeX{}}, which sits
  on your server as a \acro{CGI} script, and you use it to include
  your \TeX{}, in your \acro{HTML}, as if it were an image:
\begin{quote}
\begin{wideversion}
\begin{verbatim}
<img src="../cgi-bin/mimetex.cgi?f(x)=\int\limits_{-\infty}^xe^{-t^2}dt">
\end{verbatim}
\end{wideversion}
\begin{narrowversion}
\begin{verbatim}
<img src="../cgi-bin/mimetex.cgi?f(x)=
   \int\limits_{-\infty}^xe^{-t^2}dt">
\end{verbatim}
\end{narrowversion}
\end{quote}
\end{description}
\begin{ctanrefs}
\item[GELLMU]\CTANref{gellmu}
\item[MimeTeX]\CTANref{MimeTeX}
\item[TeX4HT]\CTANref{tex4ht}
\end{ctanrefs}

\Question[Q-textrace]{Making outline fonts from \MF{}}

\ProgName{TeXtrace}, originally developed by  P\'eter Szab\'o, is a
bundle of Unix scripts that use  Martin Weber's freeware boundary
tracing package
\href{http://autotrace.sourceforge.net}{\ProgName{autotrace}} to 
generate Type~1 outline fonts from \MF{} bitmap 
font outputs.  The result is unlikely ever to be of the quality of
the commercially-produced Type~1 font, but there's always the
\href{http://fontforge.sourceforge.net/}{\ProgName{FontForge}} font
editor to tidy things.  Whatever, there
remain fonts which many people find useful and which fail to attract
the paid experts, and auto-tracing is providing a useful service here.
Notable sets of
fonts generated using \ProgName{TeXtrace} are P\'eter Szab\'o's own
\acro{EC}/\acro{TC} font set \FontName{tt2001} and Vladimir Volovich's
\acro{CM}-Super set, which covers the \acro{EC}, \acro{TC}, and the
Cyrillic \acro{LH} font sets (for details of both of which sets, see
\Qref[answer]{``8-bit'' type 1 fonts}{Q-type1T1}).

Another system, which arrived slightly later, is 
\href{http://www.cs.uu.nl/~hanwen/mftrace/}{\ProgName{mftrace}}:
this is a small \ProgName{Python} program that does the same job.
\ProgName{Mftrace} may use either \ProgName{autotrace} (like
\ProgName{TeXtrace}) or Peter Selinger's
\href{http://potrace.sourceforge.net}{\ProgName{potrace}} to produce
the initial outlines to process.  \ProgName{Mftrace} is said to be
more flexible, and easier to use, than is \ProgName{TeXtrace}, but both systems
are increasingly being used to provide Type~1 fonts to the public domain.

The \ProgName{MetaType1} system aims to use \MF{} font sources, by way
of \MP{} and a bunch of scripts and so on, to produce high-quality
Type~1 fonts.  The first results, the % ! line break
\Qref*{\Package{Latin Modern} fonts}{Q-type1T1}, are now
well-established, and a bunch of existing designs have been reworked
in MetaType1 format.
\begin{ctanrefs}
\item[MetaType1]\CTANref{metatype1}
\end{ctanrefs}

\Question[Q-WYGexpts]{The \TeX{} document preparation environment}


``\Qref*{Why \TeX{} is not \WYSIWYG{}}{Q-notWYSIWYG}''
outlines the reasons (or excuses) for the huge disparity of user
interface between ``typical'' \TeX{} environments and commercial word
processors.

Nowadays, at last, there is a range of tools available that try either
to bridge or to close the gap.  One range modestly focuses on
providing the user with a legible source document.  At the other
extreme we have \href{http://www.texmacs.org}{\ProgName{TeXmacs}},
a~document processor using
\TeX{}'s algorithms and fonts for both editor display and printing.
\ProgName{TeXmacs} does not use the \TeX{}
language itself (though among other formats, \LaTeX{} may be exported
and imported).  A bit closer to \LaTeX{} is
\href{http://www.lyx.org/}{LyX}, which has its own
editor display and file formats as well, but does its print output by
exporting to \LaTeX{}.  The editor display merely resembles the
printed output, but you have the possibility of entering arbitrary
\LaTeX{} code.  If you use constructs that LyX does not
understand, it will just display them as source text marked red, but
will properly export them.

Since a lot of work is needed to create an editor from scratch that
actually is good at editing (as well as catering for \TeX{}), it is
perhaps no accident that several approaches have been implemented
using the extensible \ProgName{emacs} editor.  The low end of the
prettifying range is occupied by syntax highlighting: marking \TeX{}
tokens, comments and other stuff with special colours.
Many free editors (including \ProgName{emacs}) can cater for \TeX{} in
this way.  Under Windows, one of the more popular editors with such
support is the
Shareware product \href{http://www.winedt.com/}{\ProgName{winedt}}.
Continuing the range of
tools prettifying your input, we have the \ProgName{emacs} package
\href{http://x-symbol.sourceforge.net}{\Package{x-symbol}}, which does
the \WYSIWYG{} part of its work by replacing single \TeX{} tokens and
accented letter sequences with appropriate-looking characters on the
screen.

A different type of tool focuses on making update and access to
previews of the typeset document more immediate.  A recent addition
in several viewers, editors and \TeX{} executables are so-called
`source specials' for cross-navigation.  When \TeX{} compiles a
document, it will upon request insert special markers for every input
line into the typeset output.  The markers are interpreted by the \acro{DVI}
previewer which can be made to let its display track the page
corresponding to the editor input position, or to let the editor jump
to a source line corresponding to a click in the preview window.

An \ProgName{emacs} package that combines this sort of editor movement
tracking with automatic fast recompilations (through the use of dumped
formats) is
\href{http://pauillac.inria.fr/whizzytex/}{\Package{WhizzyTeX}}
 which is best used with a previewer by the
same author.  A simpler package in a similar spirit is called
\href{http://www.activetex.org/}{\Package{InstantPreview}} and makes
use of a continuously running copy of \TeX{}
(under the moniker of \texttt{TeX daemon}) instead of dumping formats to
achieve its speed.

Another \ProgName{emacs} package called
\href{http://preview-latex.sourceforge.net}{\Package{preview-latex}}
tries to solve
the problem of visual correlation between source and previews in a
more direct way: it uses a \LaTeX{} package to chop the document source
into interesting fragments (like figures, text or display math) which
it runs through \LaTeX{} and replaces the source text of those
fragments with the corresponding rendered output images.  Since it
does not know about the structure of the images, at the actual cursor
position the source text is displayed while editing rather than the
preview.  This approach is more or less a hybrid of the source
prettifying and fast preview approaches since it works in the source
buffer but uses actual previews rendered by \LaTeX{}.

A more ambitious contender is called \TeX{}lite.  This
system is only available on request from its author;
it continuously updates its screen with the help of a special version
of \TeX{} dumping its state in a compressed format at each page and
using hooks into \TeX{}'s line breaking mechanism for reformatting
paragraphs on the fly.  That way, it can render the output from the
edited \TeX{} code with interactive speed on-screen, and it offers the
possibility of editing directly in the preview window.

That many of these systems occupy slightly different niches can be
seen by comparing the range of the
\ProgName{emacs}-based solutions ranging from syntax highlighting to instant
previewing: all of them can be activated at the same time without
actually interfering in their respective tasks.

The different approaches offer various choices differing in the
immediacy of their response, the screen area they work on (source or
separate window), degree of correspondence of the display to the final
output, and the balance they strike between visual aid and visual
distraction.
\begin{ctanrefs}
\item[preview-latex]Browse \CTANref{preview-latex}
\item[texmacs]Browse \CTANref{texmacs}
\end{ctanrefs}

\Question[Q-ant]{The \textsf{ANT} typesetting system}

Achim Blumensath's \href{http://ant.berlios.de}{\textsf{ANT}} project,
in contrast to \NTS{}, aims
not to replicate \TeX{} with a different implementation technique, but
rather to provide a replacement for \TeX{} which uses \TeX{}-like
typesetting algorithms in a very different programming environment.
\textsf{ANT} remains under development, but it is now approaching the
status of a usable typesetting system.

\textsf{ANT}'s markup language is immediately recognisable to the
\AllTeX{} user, but the scheme of implementing design in
\textsf{ANT}'s own implementation language (presently
\ProgName{OCaml}) comes as a pleasant surprise to the jaded \acro{FAQ}
writer.  This architecture holds the promise of a system that avoids a
set of serious problems with \TeX{}'s user interface: those that
derive from the design language being the same as the markup language.
\begin{ctanrefs}
\item[\textsf{ANT}]\CTANref{ant}
\end{ctanrefs}

\Question[Q-extex]{The \ExTeX{} project}

\href{http://www.extex.org/}{The \ExTeX{} project} is
building on the experience of the many existing \TeX{} development and
extension projects, to develop a new \TeX{}-like system.  The system
is to be developed in Java (like the ill-fated \NTS{} project).

While \ExTeX{} will implement all of \TeX{}'s primitives, some may be
marked as obsolete, and ``modern'' alternatives provided (an obvious
example is the primitive \csx{input} command, whose syntax inevitably
makes life difficult for users of modern operating system file
paths).  Desirable extensions from \Qref*{\eTeX{}}{Q-etex},
\Qref*{\PDFTeX{}}{Q-whatpdftex} and \Qref*{\ensuremath{\Omega}}{Q-omegaleph}
have been identified.

Usability will be another focus of the work: debugging support and log
filtering mechanisms will please those who have long struggled with
\TeX{} macros.

\ExTeX{} will accept Unicode input, from the start.  In the longer
term, drawing primitives are to be considered.

\Question[Q-omegaleph]{Omega and Aleph}

Omega \nothtml{(\ensuremath{\Omega})} was developed as an extension of
\TeX{}, to use with multilingual texts, expressed in a variety of
input encodings.  Omega uses 16-bit, Unicode-encoded, characters.  It
provides many innovative concepts, notably including the ``translation
process'' that takes a character stream and transforms it according to
various processes that may be internally specified, or be a separate
program.

While Omega showed a lot of promise at its mid-1990s announcement, its
development was slow, and development was essentially dead by the time
that one of the original developers withdrew (taking with him a bunch
of research students).

Before that distressing event, a separate thread of development was
started, to produce a program called Aleph
\nothtml{(\ensuremath{\aleph})}, which merged the facilities of
\Qref*{\eTeX{}}{Q-etex} into a stable Omega codebase and added other
extensions.  Aleph also proved an attractive platform for many people;
but its development, too, has dried up.

The latest news (from Euro\TeX{} 2006) is that development of Omega is
picking up again, in parallel with research into what the (new)
authors consider a rational scheme for supporting \TeX{}-style
typesetting.  The new system is to be known as Omega-2
(\latexhtml{\ensuremath{\Omega_2}}{Omega subscript 2}), and is being
designed in a modular fashion so that support of new facilities (such
as use of advanced OpenType fonts) can be added in a relatively
straightforward fashion.

The work done in the Aleph project is also being carried forward in
the \Qref*{\LuaTeX{}}{Q-luatex} project.

\Question[Q-luatex]{\PDFTeX{} becomes \LuaTeX{}}

As is said elsewhere in these \acro{FAQ}s, development of
\Qref*{\PDFTeX{}}{Q-whatpdftex} is ``in essence'' complete~---
development of new facilities continues, but the limitations of the
present structure impose a strong limit on what facilities are
possible.  (The \PDFTeX{} team has announced that no further
developments will be added after the release of \PDFTeX{} 1.50.0,
which will be the next major release.)

In this context, the idea of \LuaTeX{} arose.
\href{http://www.lua.org/}{\ProgName{Lua}} is a script
language, designed to offer an interpreter with a very small
``footprint'', so it is rather easy to build it into other
applications.  So \LuaTeX{} was launched as a \PDFTeX{}
executable with a \ProgName{Lua} interpreter built into it.

A \href{http://www.luatex.org/}{\LuaTeX{} project} is now proceeding
(with monetary support from various sources) and is pursuing avenues
that many of the other
current projects have in their sights, notably Unicode character
representations and support for OpenType fonts.  Work is also in hand
to integrate the extensions pioneered by \Qref*{Aleph}{Q-omegaleph}.

The next release of \texlive{} (due in July 2008) and \miktex{}
version 2.8 (no current release date) will incorporate \LuaTeX{}.
\CONTeXT{} distributions can already make use of it.

\Question[Q-xetex]{The \xetex{} project}

\xetex{} (by Jonathan Kew) is a successor to the shareware \TeX{}/\acro{GX}
program for Macintoshes. It is a Unicode-based (\acro{UTF}-8) TeX
implementation which is able to make use of Mac~\acro{OS}~X \acro{AAT}
(Apple Advanced Typography) \extension{dfonts} and OpenType fonts.  It
uses Apple's Quartz system (which facilitates the afore-mentioned font
access) to generate \acro{PDF} output.  \xetex{} supports Unicode
character sets and bidirectional typesetting, and is widely used by
people studying linguistics, as well as an increasing range of people
working in other fields.

A Linux and Unix-system version is available in \texlive{}~2007; that
version (of course) relies on OpenType fonts alone.  A version is
planned for \miktex{} version 2.7 (currently planned for December 2007).

The project has a \href{http://scripts.sil.org/xetex}{web site} for
the user who wants more than this simple answer, and you can also sign
up to a \href{http://www.tug.org/mailman/listinfo/xetex}{mailing list}.

\Question[Q-biblatex]{Replacing the \BibTeX{}--\LaTeX{} mechanism}

Producing a successor to \BibTeX{} has long been a favoured activity
among a certain class of \TeX{}-users; the author has seen reports of
progress (on several projects), over the years, but few that claim to
be ready for ``real-world'' use.

Few would deny that \BibTeX{} is ripe for renewal: as originally
conceived, it was a program for creating bibliographies for technical
documents, in English.  People have contributed mechanisms for a
degree of multilingual use (whose techniques are arcane, and quite
likely inextensible); and specialist \BibTeX{} style files are
available for use in non-technical papers.

\BibTeX{} uses a style language whose mechanisms are unfamiliar to
most current programmers: it's difficult to learn, but since there are
fewer opportunities to write the language, it's also difficult to become
fluent (in the way that so many people fluently write the equally
arcane \TeX{} macro language).

Oren Patashnik (the author of \BibTeX{}) summarises the issues as he
sees them, in a % !line break
\href{http://tug.org/TUGboat/Articles/tb24-1/patashnik.pdf}{\acro{TUG} conference paper from 2003}
that seems to suggest that we might expect a
\BibTeX{}~1.0\dots{}which hasn't (yet) appeared.

In the absence of \BibTeX{}~1.0, what do we need from the bibliography
system of the future?~--- simple: a superset of what \BibTeX{} does
(or can be made to do), implemented in a simpler style language, with
coherent multilingual capabilities.

Of the direct \BibTeX{} replacements, the only one whose authors have
sufficient confidence to submit to \acro{CTAN} is Cross\TeX{}.
Cross\TeX{}'s language feels familiar to the existing user of
\BibTeX{}, but it's redesigned in an object-oriented style, and looks
(to a non-user) as if it may well be adequately flexible.

Cross\TeX{}'s team respond to queries, and seem well aware of the
need for multilingual support.  Cross\TeX{} is probably a development
to watch.

Two interesting alternative approaches, that the author has
investigated, are \Package{amsrefs} and \Package{biblatex}.
\Package{Amsrefs} does away with \BibTeX{} altogether, while
\Package{biblatex} makes rather limited use of \BibTeX{}.  Both are
heavily dependent on \LaTeX{}'s support.

\Package{Amsrefs} uses a transformed \extension{bib} file, which is
expressed as \LaTeX{} macros.  (The package provides a \BibTeX{} style
that performs the transformation, so that a \LaTeX{} source containing
a \cmdinvoke{nocite}{*} command enables \BibTeX{} to produce a usable
\Package{amsrefs} bibliography database.)

\Package{Amsrefs} is maintained by the AMS as part of its author
support programme,

\Package{Biblatex} uses \BibTeX{} more-or-less as normal, but with
\Package{biblatex}'s own style; the style of citations and of the
bibliography itself is determined by the way your \Package{biblatex}
style has been set up.  This structure eliminates the collections of
\BibTeX{} styles, at a stroke; the package comes with a basic set of
styles, and details are determined by options, set at package loading
time.  The author, Philipp Lehman, evaluated the whole field of
bibliography software before starting, and as a result the package
comes with answers to many of the questions asked in the bibliography
sections of these \acro{FAQ}s.

\Package{Biblatex} is released as experimental software, but it's
clear that many users are already using it happily; Lehman is
responsive to problem reports, at the moment, but a set of expert
users is already establishing itself.
\begin{ctanrefs}
\item[amsrefs.sty]\CTANref{amsrefs}
\item[biblatex.sty]\CTANref{biblatex}
\item[\nothtml{\rmfamily}CrossTeX]\CTANref{crosstex}
\end{ctanrefs}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%
% This is the last section, and is to remain the last section...
\section{You're still stuck?}

\Question[Q-noans]{You don't understand the answer}

While the \acro{FAQ} maintainers don't offer a `help' service, they're
very keen that you understand the answers they've already written.
They're (almost) written ``in a vacuum'', to provide something to
cover a set of questions that have arisen; it's always possible that
they're written in a way that a novice won't understand them.

Which is where you can help the community.  Mail the 
\begin{wideversion}
  \href{mailto:faq-devel@tex.ac.uk}{maintainers}
\end{wideversion}
\begin{narrowversion}
  maintainers (at \Email{faq-devel@tex.ac.uk})
\end{narrowversion}
to report the answer that you find unclear, and (if you can) suggest
what we need to clarify.  Time permitting (the team is small and all
its members are busy), we'll try and clarify the answer.  This way,
with a bit of luck, we can together improve the value of this resource
to the whole community.

Note that the \acro{FAQ} development email address is not for
answering questions: it's for you to suggest which questions we should
work on, or new questions we should answer in future editions.

Those who simply ask questions at that address will be referred to
\mailto{texhax@tug.org} or to \Newsgroup{comp.text.tex}.

\Question[Q-newans]{Submitting new material for the \acro{FAQ}}

The \acro{FAQ} will never be complete, and we always expect that
there will be people out there who know better than we do about
something or other.  We always need to be put right about whatever
we've got wrong, and suggestions for improvements, particularly
covering areas we've missed, are always needed: mail anything you have
to the
\begin{wideversion}
  \href{mailto:faq-devel@tex.ac.uk}{maintainers}
\end{wideversion}
\begin{narrowversion}
  maintainers (at \Email{faq-devel@tex.ac.uk})
\end{narrowversion}

If you have actual material to submit, your contribution is more than
ever welcome.  Submission in plain text is entirely acceptable, but
if you're really willing, you may feel free to mark up your submission
in the form needed for the \acro{FAQ} itself.  The markup is a
strongly-constrained version of \LaTeX{}~--- the constraints come from
the need to translate the marked-up text to \acro{HTML} on the fly
(and hence pretty efficiently).  There is a file \File{markup-syntax}
in the \acro{FAQ} distribution that describes the structure of the
markup, but there's no real substitute for reading at least some of
the source (\File{faqbody.tex}) of the \acro{FAQ} itself.  If you
understand \ProgName{Perl}, you may also care to look at the
translation code in \File{texfaq2file} and \File{sanitize.pl} in the
distribution: this isn't the code actually used on the Web site, but
it's a close relation and is kept
up to date for development purposes.
\begin{ctanrefs}
\item[\nothtml{\rmfamily}\acro{FAQ} distribution]\CTANref{faq}
\end{ctanrefs}

\Question[Q-latexbug]{Reporting a \LaTeX{} bug}

The \LaTeX{} team supports \LaTeX{}, and will deal with
% beware line wrap
\emph{bona fide} bug reports.  Note that the \LaTeX{} team does
\emph{not} deal with contributed packages~--- just the software that
is part of the \LaTeX{} distribution itself: \LaTeX{} and the
``required'' packages.
Furthermore, you need to be slightly
careful to produce a bug report that is usable by the team.  The steps
are:

\nothtml{\noindent}\textbf{1.} Are you still using current \LaTeX{}?  Maintenance is only
available for sufficiently up-to-date versions of \LaTeX{}~--- if your
\LaTeX{} is more than two versions out of date, the bug reporting
mechanisms may reject your report.

\nothtml{\noindent}\textbf{2.} Has your bug already been reported?  Browse the
% beware line break
\href{http://www.latex-project.org/cgi-bin/ltxbugs2html?introduction=yes}{\LaTeX{} bugs database},
to find any earlier instance of your bug.  In many cases, the database
will list a work-around.

\nothtml{\noindent}\textbf{3.} Prepare a % ! line break
\Qref*{``minimum'' file}{Q-minxampl} that exhibits the problem.
Ideally, such a file should contain no contributed packages~--- the
\LaTeX{} team as a whole takes no responsibility for such packages (if
they're supported at all, they're supported by their authors).  The
``minimum'' file should be self-sufficient: if a member of the team
should run it in a clean directory, on a system with no contributed
packages, it should replicate your problem.

\nothtml{\noindent}\textbf{4.} Run your file through \LaTeX{}: the bug
system needs the \extension{log} file that this process creates.

You now have two possible ways to proceed: either create a mail report
to send to the bug processing mechanism (5, below), or submit your bug
report via the web (7, below).

\nothtml{\noindent}\textbf{5.} Process the bug-report creation file, using \LaTeX{} itself:
\begin{verbatim}
  latex latexbug
\end{verbatim}
\File{latexbug} asks you some questions, and then lets you describe
the bug you've found.  It produces an output file \File{latexbug.msg},
which includes the details you've supplied, your ``minimum'' example
file, and the log file you got after running the example.  (I always
need to edit the result before submitting it: typing text into
\File{latexbug} isn't much fun.)

\nothtml{\noindent}\textbf{6.} Mail the resulting file to
\Email{latex-bugs@latex-project.org}; the subject line of your email
should be the same as the bug title you gave to \File{latexbug}.  The
file \File{latexbug.msg} should be included into your message in-line:
attachments are likely to be rejected by the bug processor.

\nothtml{\noindent}\textbf{7.} Connect to the
% beware line break
\href{http://www.latex-project.org/bugs-upload.html}{latex bugs processing web page}
and enter details of your bug~--- category, summary and full
description, and the two important files (source and log file); note
that members of the \LaTeX{} team \emph{need} your name and email address, as
they may need to discuss the bug with you, or to advise you of a
work-around.

\htmlignore
\par
\endhtmlignore
\Question[Q-bug]{What to do if you find a bug}
\htmlignore
\par
\endhtmlignore
%
% This here isn't a reference to a question...
\label{lastquestion}

For a start, make entirely sure you \emph{have} found a bug.
Double-check with books about \TeX{}, \LaTeX{}, or whatever you're using;
compare what you're seeing against the other answers above; ask every
possible person you know who has any \TeX{}-related expertise.
The reasons for all this caution are various.

If you've found a bug in \TeX{} itself, you're a rare animal indeed.
Don Knuth is so sure of the quality of his code that he offers real
money prizes to finders of bugs; the cheques he writes are
such rare items that they are seldom cashed. If \emph{you}
think you have found a genuine fault in \TeX{} itself (or \MF{}, or the
\acro{CM} fonts, or the \TeX{}book), don't immediately write to Knuth,
however. He only looks at bugs infrequently, and even then
only after they are agreed as bugs by a small vetting team. In the
first instance, contact Barbara Beeton at the \acro{AMS}
(\Email{bnb@ams.org}), or contact
\Qref*{\acro{TUG}}{Q-TUG*}.

If you've found a bug in \LaTeXe{}, \Qref*{report it}{Q-latexbug}
using mechanisms supplied by the \LaTeX{} team.  (Please be
careful to ensure you've got a \LaTeX{} bug, or a bug in one of the
``required''  packages distributed by the \LaTeX{} team.)

If you've found a bug in a contributed \LaTeX{} package, you could try
contacting the author (if you can find a contact address).  However,
it's generally best to treat any package as unsupported, in the first
instance, and only try the author \emph{after} mailing list/news group
support has failed you.

If you've found a bug in \LaTeXo{}, or some other such unsupported
software, you may find help or
\emph{de facto} support on a newsgroup such as
\Newsgroup{comp.tex.tex} or on a mailing list such as
\mailto{texhax@tug.org}; be careful to include a % ! line wrap
\Qref*{code example}{Q-minxampl} of the
failure, if relevant.

Failing all else, you may need to pay for
help~--- \acro{TUG} maintains a % ! line break
\href{http://www.tug.org/consultants.html}{register of \TeX{} consultants}.


%%% Local Variables: 
%%% mode: latex
%%% TeX-master: t
%%% End: