summaryrefslogtreecommitdiff
path: root/macros/generic/diagrams/taylor/manual.tex
blob: e9b6a044a0e152ba97acccd0b9d1b7bcc64c0f1a (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
\errorcontextlines 999
%
%               =========================================
\title          {       Commutative Diagrams in \TeX\   %
                                (version 4)}
%               |                                       |
%               |                   by                  |
%               |                                       |
\author     {{\bf               Paul Taylor             }\\
%               =========================================
%
                    {\tt www.cs.man.ac.uk/$\sim$pt}}
%
\date                           {15 June 1997}
%
\def\abstracttext
        {\TeX\ and \LaTeX\ have become standard as a way of writing papers
        in Computer Science and Category Theory.
        Even in source form they are easier to compose and read than
        attempts to write mathematics in ASCII.  In~Category Theory
        ``commutative diagrams'' are essential for a clear visual
        understanding of the paper, but the graphics capabilities of \TeX\
        are so limited that it is very difficult to draw them nicely, if at
        all. This manual describes a new but reverse-compatible version of
        a package to draw such diagrams, expressed in a language in which many
        users have already found it very easy to express themselves.}
%
% ===============================================================
\documentclass[a4paper]{article}
\usepackage{diagrams}
\makeatletter
\makeindex
\def\pt@input#1#2#3{\openin1 #1 \ifeof1 \typeout{#2}#3%
  \else\closein1 \relax\input #1 \fi}%
%
% Read the diagram macros file, saving the banner from the top.
\let\messagex\message
\def\banner{Paul Taylor's diagrams package}%
%\def\getbanner<#1>{\def\banner{#1}}%
%\def\message#1{\getbanner#1\let\message\messagex\message{#1}}%
%\pt@input{diagrams}%
%{I can't find the commutative diagrams package,
%so I can't process the manual!}\endinput
%\ifx\newarrow\undefined
%\message{This manual cannot be processed by any version earlier than 3.24.}%
%\message{Please get an up-to-date version from ftp.dcs.qmw.ac.uk.}%
%\expandafter\endinput\fi
%
%  **********************************************************
%  * You can experiment with changing the following options *
%  *  as explained in the "Options" section of this manual. *
%  **********************************************************
%
\diagramstyle[tight,centredisplay%
%,dpi=300%              300dpi is default; 
%,dpi=212%               for two-up (A4 on A5) reduction of 300dpi
,dpi=600%              for more modern laser-printers
%,dpi=424%              for two-up (A4 on A5) reduction of 600dpi
%,PostScript=Rokicki%
,UglyObsolete%         formerly called ``noPostScript''
%,TPIC%
,heads=LaTeX%
%,heads=vee%
%,heads=triangle%
%,heads=curlyvee%       uses AMS symbols
%,heads=littlevee%
%,heads=boldlittlevee%   needs good-bold-math below
%,heads=littleblack%    uses AMS symbols
%,heads=blacktriangle%  uses AMS symbols
]
% The boldhook tails and boldlittlevee heads use sizes of cmsy and cmmi
% fonts which you may not have available. In this case, please change
% the following to \havegoodboldmathfalse.
\newif\ifhavegoodboldmath\havegoodboldmathtrue
%
% ===============================================================
% ===============================================================
% Try to read various non-essential auxiliary input files.
%
\iftrue
   \ifx\ds@amssymb\undefined
   \ifx\ds@mssymb\undefined
   \ifx\ds@amssymbols\undefined
   \pt@input{amssymb.sty}{}{%
   \pt@input{mssymb.tex}{}{%
   \pt@input{amssymbols.sty}%
   {Some of the arrowheads in the diagrams package use symbols from the extra
   ^^Jfonts (msxm/msym or msam/msbm) provided by the American Mathematical
   Society.^^JYou can get these by anonymous FTP from e-math.ams.com and
   elsewhere.
   ^^JIn this manual the relevant examples will just be left out.^^J}{}}}%
   \else\ds@amssymbols\fi\else\ds@mssymb\fi\else\ds@amssymb\fi
   \makeatletter % old versions of mssymb b*gg*r up \catcode`\@
\fi
%
\pt@input{a4.sty}%
{^^JThis manual was written for European A4 paper, but you do not have a4.sty.
^^JYou'll get lots of Over-full \string\hbox'es, but don't worry.
It doesn't matter.^^JWe can carry on without any real harm.}{}%
\advance\textheight 5mm
%
\def\AMS{$\cal A$\kern-.1667em\lower.5ex\hbox{$\cal M$}\kern-.125em$\cal S$}
\def\AmSTeX{\AMS-\TeX}
\def\LAMSTeX{L\raise.42ex\hbox{\kern-.3em\the\scriptfont2 A}%
                 \kern-.2em\lower.376ex\hbox{\the\textfont2 M}%
                 \kern-.125em {\the\textfont2 S}-\TeX}
\def\AMSLaTeX{\AMS-\LaTeX}
\def\LaTeXe{\mbox{\LaTeX\kern.15em$2_{\textstyle\varepsilon}$}}

\def\PiC{P\kern-.12em\lower.5ex\hbox{I}\kern-.075emC}
\def\PiCTeX{\PiC\kern-.11em\TeX}
\def\XYpic{\leavevmode\hbox{X\kern-.3em\lower.4ex\hbox{Y\kern-.15em}-pic}}

%
%  I prefer paragraphs spaced rather than indented
\parskip=2pt plus 2pt minus 1pt
%  and I don't like hyphenation
\spaceskip=.5em plus .6em minus .2em
\pretolerance=2000
\binoppenalty=2000
\relpenalty=1500
%  Penalty for splitting paragraphs
\interlinepenalty=150
\predisplaypenalty=10000
\postdisplaypenalty=400
\@beginparpenalty=\predisplaypenalty
%
%
%\let\@mkboth\markboth
\def\@oddfoot{}%
\def\@evenfoot{}%
\def\@evenhead{{\bf\thepage}\hfil{\rm\topmark}}%
\def\@oddhead{{\rm\banner}\hfil{\bf\thepage}}%
\def\sectionmark#1{\mark{\thesection. #1}}% should have \S but doesn't work
%\def\section@mark#1{\markboth{#1}{\banner}}%
\@twosidetrue
%
%
\let\volx\relax % for ltugbot.sty
\newcommand{\bsl}{$\backslash$}
%
\def\ix#1{#1\index{#1}}\def\person#1#2{#1 #2\index{#2, #1}}%
{\escapechar-1 \xdef\bslch{\string\\}}%
\def\ixcmd#1{{\escapechar-1 \xdef\cmdname{\string#1}}%
   \expandafter\index{\cmdname @\bslch verb/\string#1/}}%
\def\ixprotect#1{{\escapechar-1 \xdef\cmdname{\string#1}}%
   \expandafter\index{\cmdname @\protect#1}}%

\newarrow{Congruent}33333
\newarrow{Curlyto}----{curlyvee}
\newarrow{TeXto}----{->}
\newarrow{TeXonto}----{->>}
\newarrow{Blackinto}{blacktriangle}--->
\newarrow{Openinto}{triangle}--->
\newarrow{EEmbedd}{>>}---{>>}
\newarrow{Corresponds}<--->
\newarrow{Backwards}<----
\newarrow{Multi}----o
\newarrow{Crossto}----X
\newarrow{Partial}----{harpoon}
\newarrow{Into}{\ifhavegoodboldmath bold\fi hook}--->

%=================================================================
%
%               verbatim array
%
%=================================================================


% This defines two new LaTeX environments: verbarray and verbdiag.

% The first is like the verbatim environment, except that it treats each
% cell of an array individually, centring the text within aligned &s. The two
% arguments specify the text to be used for & and \\.  Because of the
% eager parsing at the beginning of a cell, \relax is needed before
% commands that expand to anything other than their own text.
% For example,
%   \begin{verbarray}{\ \&\ }{\ \string\\ \ }
%   A&\relax\rTo^f&B\\
%   \relax\dTo^g&&\relax\dTo^h\\
%   C&\relax\rTo^k&D
%   \end{verbarray}
% produces the contents of a simple diagram.

% The second packages this to produce a verbatim diagram, ie it encloses
% the text in ``\begin{diagram}'' and ``\end{diagram}''. Any text which
% follows ``\begin{verbdiag}'' on the same line is copied verbatim after
% \begin{diagram}.

% Here is a list of the characters that have been specially catcoded
% except &  [adapted from plain.tex]
\def\dospecialsexceptand{\do\\\do\{\do\}\do\$%
  \do\^\do\^^K\do\_\do\^^A\do\%\do\~}
% (not counting ascii null, tab, linefeed, formfeed, return, delete)
% Each symbol in the list is preceded by \do, which can be defined
% if you want to do something to every item in the list.

\def\lverbcell{\begingroup \catcode``=13 \@noligs 
\tt \let\do\@makeother \dospecialsexceptand \dolverbcell}
\def\dolverbcell#1\rverbcell{#1\endgroup}

\def\verbarraycr{\omit{\verbarraycrstring}\cr}

\newenvironment{verbarray}[2]%
{\abovedisplayskip\z@ \abovedisplayshortskip\abovedisplayskip
\belowdisplayskip\abovedisplayskip\belowdisplayshortskip\abovedisplayskip
$$\hss\vbox\bgroup
\tabskip\z@
\let\\\verbarraycr\edef\verbarraycrstring{#2}%
\halign\bgroup
\hfil\lverbcell##\rverbcell\hfil&&{#1}\hfil\lverbcell##\rverbcell\hfil\cr
%$$
}%
{%$$
\verbarraycr\egroup\egroup\hss$$}

\def\ke{\kern.25em}

\newenvironment{verbdiag}%
{\begin{pageblock}%
  \vspace{2ex}%
  \let\do\@makeother
  \def\beginverbdiag{\begin{verbarray}{\ke\tt\&\ke}{\ke\string\\}}%
  \noindent\tt\string\begin\{diagram\}
  \bgroup\aftergroup\beginverbdiag\let\par\egroup
  \obeylines\dospecials
}%
{\end{verbarray}%
  \string\end\{diagram\}%\$\$
  \vspace{2ex}%
  \end{pageblock}%
}

\newenvironment{clean}{}{}
\newenvironment{pageblock}{\vbox\bgroup}{\egroup}

\makeatother
%=============================================================================
%=============================================================================
%=============================================================================

\begin{document}
\maketitle
\begin{abstract}\noindent\abstracttext\end{abstract}

\section{Introduction}
In papers in mathematics and computer science which employ Category Theory,
there is much benefit in clarity if ``commutative diagrams'' are used as
much as possible to illustrate definitions, equations and universal
properties.  Here is a typical such diagram: it is one of the
Mac~Lane-Kelly equations.%
\index{Mac Lane, Saunders}\index{Kelly, Gregory Max}
\def\Id{{\rm id}}\def\Assl{{\rm assl}}%
\begin{diagram}[width=6em]
A*(B*(C*D))&\relax\rTo^\Assl&(A*B)*(C*D)&\relax\rTo^\Assl&((A*B)*C)*D\\
\dTo^{\Id*\Assl} &       &   =    &      &\relax\uTo_{\Assl*\Id}\\
  A*((B*C)*D)  &       &\relax\rTo^\Assl &      &  (A*(B*C))*D\\
\end{diagram}
This manual describes version~4 of the author's package for drawing 
diagrams line this in (plain) \TeX\ or \LaTeX.
Version~3 is already very widely used in
the Category Theory and Theoretical Computer Science communities.
Most of the underlying code has been rewritten, with a great improvement to
the appearance of the diagrams, but it remains compatible with the previously
developed and very popular straightforward language.

\section{Design Criteria}
Drawing such a diagram using the \LaTeX\ \verb/picture/ environment%
\ixprotect\LaTeX\index{picture environment}
takes
about sixty lines of code, though some saving is possible (with the positioning
of labels on arrows) by means of some simple macro programming.
To get the arrows to match up neatly with the objects takes quite a lot of
experimentation, and the whole job has to be repeated with each new diagram
or each modification.
Again, the use of macros for commonly occurring diagrams such as squares and
triangles can save effort, but this does not postpone the difficulty very
far, because as soon as we want to draw a slightly more complicated diagram
we're back to square one.

The now widespread use of workstations with big screens and ``personal''
computers has lead to a kind of religious fervour that a mouse with at most
three buttons is always easier to use than a keyboard with maybe over a hundred.
This might be so if the tracking software were accurate and could use telepathy
to ascertain what the user wanted, but in reality the attempts I have seen to
``draw it on the screen'' and include the result in a \TeX\ document have
looked as professional as what children bring home from their first
day at school. My view is, if you want {\em wysiwyg,} use pen and paper!%
\index{wysiwyg}\index{mouse}

Besides the awful results, mouse-driven methods take longer and are less
portable. If you want to write a joint paper with a colleague on the other
side of the world, it is a great deal simpler to send a single ascii file
by electronic mail than to package twenty of them (including one file per
diagram as well as the main text) encoded in some weird commercial binary
format.

On the basis of these remarks, the design criteria of this package are as
follows:

\begin{enumerate}

\item The entire diagram must form part of the source of the document itself.
In other words, there must be no preprocessing 
({\em cf.}~{\tt eqn} in {\sc Unix})
or inclusion of files (such as {\sc \ix{PostScript}} pictures).

\item Simple diagrams must be able to be drawn ``on the fly'' and not
need to be drawn on paper first.
Obviously, complex diagrams will already have been worked out on paper anyway.

\item The layout of the source code must resemble the intended
diagram as far as syntactically possible.

\item There must be no \ix{measuring} of labels to calculate \ix{co-ordinates}
or lengths of arrows.

\item There must be a variety of arrow styles, with facilities for
defining new ones.\index{arrowheads}\index{heads}\index{diagonal arrows}
Diagonal arrows (which, through lack of appropriate primitives,
\TeX\ makes very difficult to draw) should be provided at various
slopes, albeit with limited choice and features.

\item The package must be compatible both with {\tt plain}~\TeX\ and%
\index{plain \protect\TeX}\ixprotect\LaTeX\
with \LaTeX, and not rely on non-standard fonts\footnote{Diagonal lines
can {\em only\/} be drawn using \LaTeX's {\tt line10} and {\tt linew10}
fonts,\index{line10 and linew10 fonts}\index{AMS symbols fonts}
and for exotic arrow styles the AMS maths symbols fonts may be
useful: we regard these as standard.
\person{Alan}{Jeffery}'s \ix{St.\protect~Mary Road symbols font}
is also useful.}
or language features.

\item Future versions which improve the appearance of the diagrams
must, as far as possible, be compatible with past papers written using the
package --- but you hack at your own risk!

\end{enumerate}

\noindent In addition there are {\ae}sthetic criteria,
some of which may be a matter of opinion:

\begin{itemize}

\item Arrows should \ix{stretch} to meet the objects which are intended to
be their endpoints.

\item Arrows should be aligned (both horizontally and vertically)
with the centres of the objects.\index{aligned labels}

\item Labels on arrows should not affect the spacing of the diagram
except to avoid overlapping.\index{labels}

\item Stretching of arrows should not affect the centering of their
labels.

\end{itemize}

%=================================================================
%
%               my version
%
%=================================================================

\section{Typing the diagram}\label{typing}

The diagram above is produced in \LaTeX\ixprotect\LaTeX\
as follows:%
\ixcmd\input\ixcmd\usepackage
\ixcmd\diagram\ixcmd\enddiagram
\ixcmd{\begin{diagram}}\ixcmd{\end{diagram}}%


\vskip2ex

\begin{pageblock}
\noindent\verb/\input diagrams/\\
\verb/\def\Assl{{\rm assl}}\def\Id{{\rm id}}/\\[-2ex]
\begin{verbdiag}
A*(B*(C*D))&\relax\rTo^\Assl&(A*B)*(C*D)&\relax\rTo^\Assl&((A*B)*C)*D&\\
\relax\dTo^{\Id*\Assl}&&=&&\relax\uTo_{\Assl*\Id}&\\
A*((B*C)*D)&&\relax\rTo^\Assl&&(A*(B*C))*D&
\end{verbdiag}
\end{pageblock}
In {\tt plain} \TeX\index{plain \protect\TeX}
you do the same thing,  writing \verb/\diagram/ and
\verb/\enddiagram/ wherever we have \verb/\begin{diagram}/ and
\verb/\end{diagram}/.

In \LaTeXe\ixprotect\LaTeXe\ you can put
\begin{quote}
\verb/\usepackage{diagrams}/
\end{quote}
in place of the \verb/\input/ command, but you have to rename or alias
the file to \verb/diagrams.sty/.\index{diagrams.sty}\index{diagrams.tex}

The basic rule is to divide the diagram into cells,
\begin{diagram}[height=1em,width=0pt,loose,textflow]
%&&\relax\ && \ && \ && \ \\%39
&A*(B*(C*D))\;&&\rTo^{\qquad\Assl\qquad}&&\;(A*B)*(C*D)\;&&
\rTo^{\qquad\Assl\qquad}&&\;((A*B)*C)*D\\%38
\ &\HonV&&&& \rDots &&&&\HonV& \ \\%37
\\
&\dTo^{\Id*\Assl} &
        \uDots && \uDots &=& \uDots && \uDots &
        \uTo_{\Assl*\Id}\\%36
\\
\ &\HonV&&&& \rDots &&&&\HonV& \ \\%35
&A*((B*C)*D) & & & & \rTo_\Assl & & & & (A*(B*C))*D \\%34
%&& \ && \ && \ && \ \\%33
\end{diagram}
just like the cells of a \ix{matrix}, and then type the contents
of the cells with columns delimited by ``{\tt\&}''\ixcmd{&} and rows by
``\verb/\\/''.\expandafter\index{\string\\@\string\\}
The bottom arrow extends through the \ix{empty cells} either
side of~it. Notice that although the matrix imposes a kind of co-ordinate
system, the widths of the columns and the heights of the rows are variable
and chosen automatically --- by \TeX, in the same way as it does for matrices,
tables,~{\it etc.}\index{co-ordinates}

At first you will probably need to draw the diagram carefully on paper and
divide it into cells in this way before typing it in.
The main difficulty is working out how many \verb/&/s\ixcmd{&} to insert;
for this it is useful to observe that {\em in the simplest cases\/}%
   \footnote{The bottom arrow disobeys this rule, since it goes across
   three columns.}
\begin{itemize}\index{parity rule}
\item objects and verticals go in odd-numbered columns, and
\item horizontals and diagonals go in even-numbered columns.
\end{itemize}
Then, of course, you need an even number of \verb/&/s between columns
of the same parity and an odd number between different ones.
After a little practice you'll learn other rules of thumb,
but even if you make a mistake, the DVI previewer will make it clear how
to correct~it.
Error messages about {\em clashing\/}\index{clashing arrows}
or {\em unterminated\/} arrows\index{unterminated arrows} indicate
that something is wrong without previewing.\index{error checking}

Each cell should contain {\it either\/} an \ix{object} (an~ordinary
mathematical expression, set in maths mode) {\it or\/}~a~\ix{morphism}
(an~\ix{arrow} such as \verb/\rTo^f/). Horizontal and vertical arrows cannot
be mixed in one cell; moreover only one horizontal arrow per cell is allowed,
but see the section~\ref{parallels} on parallel maps below.

The horizontal and vertical arrows extend through the \ix{empty cells} either
side until they meet a non-empty cell, just like the
rook\index{rook (chess rule)} (castle\index{castle (chess rule)})
in chess.
For this purpose anything other than \ix{white space} (space, tab and newline),
comments (\verb/%/) and \verb/\empty/ in the source make a cell non-empty.
For example \verb/\null/, \verb*/\ / or \verb/{}/\index{{}}
may be used to terminate arrows: it's not necessary that anything be printed.
If you don't terminate an arrow, it will extend to
the \ix{edge of the diagram},
but just exactly where the ``edge'' {\em is}, particularly the right one,
will be determined somewhat arbitrarily.

The \ix{chess rule} does not apply to diagonals, whose endpoints are specified
differently: see section~\ref{diagonals}.

Do not enclose the arrow commands in \ix{boxes} or \ix{braces}, because this
prevents the automatic \ix{stretch}ing from working.

The {\em horizontal\/} arrow commands
\index{horizontal arrows} (including \verb/\pile/) \ixcmd\pile
may also be used in \ix{text}, $A \rTo^f B$.
Since there is no enclosing matrix, this is written
as \verb/$A \rTo^f B$/ {\em without\/}~\verb/&/.\ixcmd{&}
You still need the \ix{dollars}\ixcmd{$}
because it's still a \ix{mathematical expression}.
Arrows participate in the horizontal stretching and shrinking of spaces
between words in a paragraph, but of course their labels also force
the lines of the paragraph apart.

The arrow commands are {\em \ix{fragile}\/} in the \LaTeX\ sense:
if you want to use them in section headings you must \verb/\protect/%
\ixcmd\protect\ them.


%===========================================================================

\section{Labels}

Each arrow  carries up to three \ix{labels}, whose position is specified
analogously to \ix{superscripts}%
   \footnote{However they are {\em not\/} recognised syntactically in the
   same way, and so for instance {\tt\bsl nolimits}\ixcmd\nolimits\
   will not work.
   The sub- and superscript characters are recognised by their
   {\tt\string\catcode}s, so {\tt\string\sp} and {\tt\string\sb}%
   \ixcmd\catcode\ixcmd\sp\ixcmd\sb\ixcmd\ifx\ixcmd\ifcat\
   will work, but the others are compared using {\tt\string\ifx},
   so have to be the same characters, with the same {\tt\string\catcode}s
   as when {\tt diagrams.tex} was read in.
   \index{Sp environment}\index{Sb environment}%
   \ixprotect\AmSTeX\ixprotect\AMSLaTeX\index{{}}\ixcmd\bgroup\ixcmd\egroup
   The {\tt Sb} and {\tt Sp} environments
   in \AmSTeX\space and \AMSLaTeX\space will not work, and the text of the
   label itself must be either a single token or be explicitly enclosed in
   {\tt\string{\string}} or {\tt\string\bgroup\string\egroup}.}
by
\begin{center}
\vskip-2ex
\verb/^/ above,\qquad \verb/_/ below,\qquad \verb/</ left,\qquad
\verb/>/ right\qquad and\qquad \verb/~/ middle.
\end{center}
\ixcmd{^}\ixcmd{_}\ixcmd{~}\index{<@$<$}\index{>@$>$}%
For reverse compatibility, above=left and below=right for vertical arrows.
Very old versions of the package used positional arguments; these are also
still supported, but {\em must be enclosed in braces, e.g.\/}~\verb/\rTo{f}{g}/
but not \verb/\rTo f g/.

Explicitly, the labels are placed as follows:
\begin{itemize}
\item for {\bf horizontal} arrows,\index{horizontal arrows}
   \verb/\rTo^f_g/ and \verb/\rTo{f}{g}/
   give \smash{$\mathop{\longrightarrow}\limits^f_g$};
\item for {\bf vertical} arrows,\index{vertical arrows}
   \verb/\dTo <f >g/, \verb/\dTo^f_g/ and
   \verb/\dTo{f}{g}/ give $f{\big\downarrow}g$;
\item for {\bf positive\/} gradient {\bf diagonal} arrows,%
   \index{diagonal arrows}\index{positive gradient}\index{negative gradient}
   \verb/\ldTo^f_g/, \verb/\ldTo <f >g/ and \verb/\ldTo{f}{g}/ all give
   ${}^f\!\!\!\!\swarrow\!\!\!\!_g$ (similarly \verb/\ruTo/).
\item but for {\bf negative\/} gradient arrows, above=right and below=left,
   so \verb/\rdTo^f_g/, \verb/\rdTo <g >f/ and \verb/\rdTo{f}{g}/ give
   ${}_g\!\!\!\searrow\!\!\!^f$ (similarly \verb/\luTo/);
\item Using tilde, the label may instead {\bf break} the arrow: \verb/\rTo~f/
   gives \hbox to5em{$A\rTo~{\textstyle f}B$}.\index{broken arrows}
   If~the arrow had a middle
   ({\em e.g.}~\verb/+/ in \verb/\rCrossedInto/, page~\pageref{crossedinto}),
   \ixcmd\newarrowmiddle\ixcmd\rCrossedInto
   the label would replace~it.
   This is sometimes useful to preserve the symmetry of a diagram with three
   verticals.
\end{itemize}
Although the arrows extend into adjacent cells, the labels on horizontal and
vertical maps remain centred {\em in~the cell in which the arrow was declared.}

Any ordinary (mathematical) text you put in the cell with an arrow will
appear in the usual way:
\begin{itemize}
\item For horizontal arrows it will therefore be attached to the arrowhead
  or tail.

  This offers a simple way of \ix{annotating the head of an arrow},%
  \index{arrowheads!annotating}
  for example
    \verb/$ A \rTo^f \relax ^*  B  {}_s \lTo_g C$/\quad gives
  \begin{quote}
     $ A \rTo^f \relax ^* B  {}_s \lTo_g C$.
  \end{quote}
  where \verb/\relax/ is needed to stop \verb/\rTo/ from reading \verb/^*/
  as another label and \verb/{}/ serves as an object to which $s$ is
  subscripted.\ixcmd\relax\index{{}}
  The spacing in this example is not entirely satisfactory, because
  \verb/\rTo/ and \verb/\lTo/ generate the \verb/shortfall/ spacing as
  part of themselves and regard everything else as their targets.
  You can use \verb/\!/ and \verb/\;/ commands to compensate for this,
  remembering that should you subsequently change the \verb/shortfall/
  amount then you must also adjust the compensation.\index{shortfall}

  An alternative way of doing this is to define a new arrow command:
  section~\ref{newarrow} explains how.\ixcmd\newarrow

  Don't make a habit of putting \verb/\relax/ after arrow commands:
  it can lead to gaps in short double-shafted arrows, for reasons which
  are too complicated to explain here.
\item For vertical and diagonal arrows additional text will lie to the
  side of (or between) the arrows.
  In the case of verticals this is at the same height as the middle and labels
  of the arrows; see section~\ref{parallels}.
\end{itemize}

\ixcmd\textstyle\ixcmd\displaystyle\ixcmd\scriptstyle\ixcmd\scriptscriptstyle
\ixcmd\labelstyle\ixcmd\objectstyle
By default the labels on the arrows are set in \verb/\textstyle/ 
(the same size as in text) when they are part of a matrix, and in
\verb/\scriptstyle/ (like subscripts) in text. However this may be changed
using the \verb/labelstyle/ option (page~\pageref{labelstyle}).
%This re-defines the command \verb/\labelstyle/, for instance
\begin{quote}
\begin{verbatim}
\begin{displaymath}
\begin{diagram}[labelstyle=\scriptscriptstyle]
A &\rTo^{\sum^n_1 f_i}_{\rm scriptscript} & B
\end{diagram}
\qquad
...
\end{displaymath}
\end{verbatim}
\end{quote}
\noindent gives \vadjust{\vskip-4ex}%
\begin{displaymath}
\hss\begin{diagram}[inline,labelstyle=\scriptscriptstyle]
A & \rTo^{\sum^n_1 f_i}_{\rm scriptscript} & B
\end{diagram}
\qquad
\begin{diagram}[inline,labelstyle=\scriptstyle]
A & \rTo^{\sum^n_1 f_i}_{\rm script} & B
\end{diagram}
\qquad
\begin{diagram}[inline,labelstyle=\textstyle]
A & \rTo^{\sum^n_1 f_i}_{\rm text} & B
\end{diagram}
\qquad
\begin{diagram}[inline,labelstyle=\displaystyle]
A &\relax\rTo^{\sum^n_1 f_i}_{\rm display} & B
\end{diagram}
\hss\end{displaymath}
Similarly, objects within a diagram are set in \verb/\displaystyle/ unless the
\verb/objectstyle/ option is used.
(In text, {\em e.g.}~\verb/$A \rTo B$/, the setting of the objects is
out of the control of the diagrams package.
Unless you have done some special programming of your own, they will
be set in \verb/\textstyle/.)

%===========================================================================

\section{The Cube}\label{cube}
The \ix{cube} offers a good example of how horizontal and \ix{vertical arrows}
\ix{stretch}.\index{horizontal arrows}
Notice how the cells have been sub-divided further to give the
``3D'' effect,\index{3D effect}
and that the positions of the labels on the maps betray
the cells in which they were declared.
Because of the sub-division, the \ix{parity rule} for the column in which the
horizontal arrows go has broken down.
You should now formulate for yourself a new rule of thumb
for the cases when you need one, two, three or four \verb/&/s between
two commands.\ixcmd{&}

\begin{verbdiag}
A'&&\relax\rTo^{f'}&&B'&&&\\
&\relax\rdTo_a&&&\relax\vLine^{h'}&\relax\rdTo_b&&\\
\relax\dTo^{g'}&&A&\relax\rTo^f&\relax\HonV&&B&\\
&&\relax\dTo^g&&\relax\dTo&&&\\
C'&\relax\hLine&\relax\VonH&\relax\rTo^{k'}&D'&&\relax\dTo_h&\\
&\relax\rdTo_c&&&&\relax\rdTo_d&&\\
&&C&&\relax\rTo^k&&D&
\end{verbdiag}

\ixcmd\HonV\ixcmd\VonH\index{broken arrows}\index{hidden lines}%
\index{meeting lines}\index{joining lines}\index{corners}
The broken lines ($h'$~and~$k'$) are simply two arrows. The commands
\verb/\HonV/ (``horizontal on vertical'') and \verb/\VonH/ (``vertical
on horizontal'') allow arrows in one direction to pass through, whilst
obstructing arrows in the other direction as if an object were present.
They each have an optional argument: \verb/\HonV[=]/ and \verb/\VonH[\|]/
should be used to allow extra space for double lines.
An~alternative is to declare the ``front'' line in the intersection cell,
where it will have the effect of obstructing the other arrow,
but then its label (if any) would clash with the other arrow.

\ixcmd\HmeetV
There is also a command \verb/\HmeetV/ which causes single horizontal and
vertical lines to meet, forming a corner.
\begin{diagram}[notextflow]
   A'  &    &\rTo^{f'} &      &   B'   \\
      & \rdTo_a &      &      & \vLine^{h'}& \rdTo_b  \\
\dTo^{g'} &    &   A   & \rTo^f  & \HonV   &    &  B  \\
      &    & \dTo^g  &      & \dTo   \\
   C'  & \hLine & \VonH   & \rTo^{k'} &   D'   &    & \dTo_h \\
      & \rdTo_c &      &      &      & \rdTo_d  \\
      &    &   C   &      & \rTo^k  &    &  D  \\
\end{diagram}
You should soon be able to read and compose the source of
these diagrams as easily as the printed version, although one would not
normally go to the trouble of aligning the \verb/&/s in the source code!%
\footnote{To do so neatly in this manual required special programming: the
{\tt verbatim} environment produced unsatisfactory results.}%
\index{verbatim environment}

%==========================================================================

\section{Parallel arrows}\label{parallels}\index{parallel arrows}%
\ixcmd\pile\ixcmd\Downarrow\ixcmd\dashv\ixcmd\puncture
You can draw two arrows between the same two vertices,
including extra things like \ix{2-cells} ($\Downarrow$, \verb/\Downarrow/),
the adjoint symbol ($\dashv$, \verb/\dashv/) in between.
\person{Peter}{Freyd}'s \verb/\puncture/ symbol is also defined in the diagrams
package.\index{adjunction}

\begin{verbdiag}
A&\relax\pile{\rTo^f\\
\puncture\quad\alpha \\
\rTo_g}&B&\\
\relax\dTo^h\dashv\uTo_k&&&\\
C&&&
\end{verbdiag}

\vskip-4ex
\diagram
A & \pile{ \rTo^f \\ \puncture\quad\alpha \\ \rTo_g } & B \\
\dTo^h \relax\dashv \uTo_k \\
C \\
\enddiagram

{\bf Horizontal} arrows\index{horizontal arrows}\index{pilespacing}
may be \verb/\pile/d on top of each other.
Effectively, a one-column diagram is created, which may have {\em either\/}
a horizontal arrow {\em or\/} an object in each row. This works both
in diagrams and in text.
The spacing (\verb/\baselineskip/\ixcmd\baselineskip) between the rows
is {\em half\/} of that specified by the \verb/pilespacing/ option
(page~\pageref{pilespacing}),
on the assumption that you will put something
between parallel arrows; a blank line (\verb/\\ \\/) will suffice, then
the spacing is the same as that for vertical arrows.

{\bf Vertical} arrows\index{vertical arrows}
may simply be put together in the same cell,
with any text between them. The spacing is always that given by
\verb/\pilespacing/.
(\verb/\pile/ must not be used.)

{\bf Diagonal} lines.\index{diagonal arrows}
At the moment parallel diagonal lines are not properly implemented;
(there will be a \verb/crab/\index{crab} option for transverse movement).

However the option \verb/fixed/\index{fixed} may be used to force the
diagonals to be set on the firsr pass, as fixed (non-stretching) boxes.
These can  be juxtaposed, separated with explicit space and 
moved with \verb/\raise/ or \verb/\raisebox/ commands.
\begin{quote}
\verb/\raise 5pt \hbox{$\ldTo^R$}\rightthreetimes\raise-5pt\hbox{$\ruTo^L$}/
\end{quote}
\ixcmd\raise\ixcmd\raisebox\ixcmd\lower\index{error checking}%
There is an error message (``you must not put arrows in \ix{braces}''),
which warns you that this is not a satisfactory solution.

%==========================================================================
\section{Defining arrow styles}\label{newarrow}
It is easy to define other arrows besides the basic line with arrowhead given
by \verb/\rTo/ and friends.\index{arrowheads} For example,\ixcmd\newarrow

%\vskip-3\baselineskip

\ifx\twoheadrightarrow\undefined % a typical AMS symbol name
  \let\amsarrows\empty
\else
  \def\amsarrows{%
  TeXonto&----\{->>\}&\rTeXonto\cr
  }%
  \ixcmd\rTeXonto
\fi

\ifhavegoodboldmath
  \def\boldarrows{CrossedInto&\{boldhook\}-+->&
    %\showboxdepth999 \showboxbreadth 999 \tracingonline 1
    %\tracingcommands1 \tracingmacros1
    \rCrossedInto
    %\showlists
    \cr}%
  \newarrow{CrossedInto}{boldhook}-+->
\else
  \def\boldarrows{CrossedInto&C-+->&\rCrossedInto\cr}%
  \newarrow{CrossedInto}C-+->
\fi

\ixcmd\rTo\ixcmd\rLine\ixcmd\rEmbed\ixcmd\rOnto\ixcmd\rEEmbedd
\ixcmd\rDotsto\ixcmd\rDashto\ixcmd\rCorresponds\ixcmd\rImplies
\ixcmd\rMapsto\ixcmd\rInto\ixcmd\rOpeninto\ixcmd\rCongruent
\ixcmd\rTeXto\ixcmd\rBackwards\ixcmd\rMulti\ixcmd\rCrossto
\ixcmd\rPartial\ixcmd\rCrossedInto
\index{>@$>$ arrowhead}\index{-- filler}\index{>>@$\gg$ arrowhead}
\index{. filler}%
\index{dash filler}\index{| tail}\index{O arrowheads}\index{x arrowheads}%
\index{harpoon arrowhead}\index{triangle arrowheads}\index{3 filler}%
\index{hook tail}\index{C tail}\index{boldhook tail}%

\begin{quote}\leavevmode\label{crossedinto}
\vbox{\halign{\tt\string\newarrow\kern2pt\{#\}\kern2pt\hfil&\tt#\quad\hfil&%
   $#$\cr\omit&&\omit\kern80pt\cr
  To&---->&\rTo\cr
  Line&-----&\rLine\cr
  Embed&>--->&\rEmbed\cr
  Onto&----\{>>\}&\rOnto\cr
  EEmbedd&\{>>\}---\{>>\}&\rEEmbedd\cr
  Dotsto&....>&\rDotsto\cr
  Dashto&\{\}\{dash\}\{\}\{dash\}>&\rDashto\cr
  Corresponds&<--->&\rCorresponds\cr
  \boldarrows
  Implies&====\{=>\}&\rImplies\cr
  Mapsto&|--->&\rMapsto\cr
  Into&C--->&\rInto\cr
  Openinto&\{triangle\}--->&\rOpeninto\cr
  Congruent&33333&\rCongruent\cr
  TeXto&----\{->\}&\rTeXto\cr
  Backwards&<----&\rBackwards\cr
  Multi&----o&\rMulti\cr
  Crossto&----X&\rCrossto\cr
  Partial&----\{harpoon\}&\rPartial\cr
  \amsarrows
}}\end{quote}
\noindent Note that the
\ixcmd\rightharpoonhown\ixcmd\twoheadrightarrow\ixcmd\rightarrow
\ixcmd\Rightarrow\ixcmd\boldmath
\index{->>@\protect\verb/->>/ arrowhead}%
\index{->@\protect\verb/->/ arrowhead}%
\index{littlevee arrowheads}\index{boldlittlevee arrowheads}%
\ifx\twoheadrightarrow\undefined\else\verb/{->>}/, \fi
\verb/{harpoon}/, \verb/{->}/ and \verb/{=>}/ heads
use \TeX's \verb/\rightharpoondown/ ($\rightharpoondown$), \verb/\rightarrow/
($\rightarrow$) and \verb/\Rightarrow/ ($\Rightarrow$) symbols, consisting
of heads {\em with shafts.}
\ifhavegoodboldmath
   Also, the \verb/boldbook/ tail uses \LaTeX's \verb/\boldmath/:
\else
   There is also a \verb/boldhook/ tail, which is not shown because the
   appropriate fonts were not available when this copy of the manual
   was printed:
\fi
please see the note about \verb/heads=littlevee/
on page~\pageref{heads option}.
The \verb/hook/ and \verb/C/ tails are the same.

Each declaration\ixcmd\newarrow
\index{north (east, west)}\index{south (east, west)}\index{east}\index{west}%
\index{compass}\index{left}\index{right}\index{up}\index{down}
\begin{center}
\verb/\newarrow{/{\em Name\/}\verb/}{/{\em tail\/}\verb/}{/{\em filler\/}%
\verb/}{/{\em middle\/}\verb/}{/{\em filler\/}\verb/}{/{\em head\/}\verb/}/
\end{center}
defines eight arrow commands
$$\vcenter{\advance\hsize-2.5\baselineskip\advance\hsize-6em
  \halign{\tt\bsl#\it Name\quad\hfil&#\hfil\quad or\quad&#\hfil\cr
  r&right&east\cr
  l&left&west\cr
  d&down&south\cr
  u&up&north\cr
  ru&right \& up&northeast\cr
  rd&right \& down&southeast\cr
  lu&left \& up&northwest\cr
  ld&left \& down&southwest\cr
}}\qquad\qquad
  \begin{diagram}[vcentre,inline,size=1.75\baselineskip,abut,shortfall=4pt]
   \hbox{\tt lu}&&\hbox{\tt u}&&\hbox{\tt ru}\\
   &\luTo[lowershortfall=2pt]&\uTo[lowershortfall=2pt]&
     \ruTo[lowershortfall=2pt]\\
   \hbox{\tt l}&\lTo[rightshortfall=2pt]&\vcenter{}&\rTo[leftshortfall=2pt]&
     \hbox{\tt r}\\
   &\ldTo[uppershortfall=2pt]&\dTo[uppershortfall=2pt]&
     \rdTo[uppershortfall=2pt]\\
   \hbox{\tt ld}&&\hbox{\tt d}&&\hbox{\tt rd}
  \end{diagram}$$
from the five named components.

\ixcmd\isomorphic\ixcmd\cong
Some but not all of the names given in the examples above are defined in the
source of the package as distributed.
However this is only really intended for reverse compatibility, because
just as it is better to define a macro \verb/\isomorphic/ for the
symbol $\cong$ (if that is what you use it to mean) than to write
\verb/\cong/ in your documents, so it is advisable to define the arrow
command names in the file where you keep your private collection of symbols.

\ixcmd\rEmbed\ixcmd\rInto\ixcmd\rOpeninto\ixcmd\rImmerse\ixcmd\rInclude
\ixcmd\rInternalise
For example, if in your subject there are special kinds of functions known
standardly as immersions, inclusions and internalisations and written as
$\rInto$, $\rEmbed$ and $\rOpeninto$, then you should define
\verb/\rImmerse/, \verb/\rInclude/ and \verb/\rInternalise/ instead of
using the names \verb/\rInto/, \verb/\rEmbed/ and \verb/\rOpeninto/.
The motto is {\em what you see is what you mean\/}!
This avoids  remembering or getting confused about the so-called
standard macro names, and also enables you to change your mind about the
notation if it is not standard but subject to experimentation.

\ixcmd\newarrowhead\ixcmd\newarrowtail\ixcmd\newarrowmiddle
\ixcmd\newarrowfiller
The components as given in the \verb/\newarrow/ command are mnemonics,
which are themselves defined using the commands
\begin{center}
\verb/\newarrowhead/, \verb/\newarrowtail/, \verb/\newarrowfiller/
and \verb/\newarrowmiddle/.
\end{center}
Most of the characters in the standard \TeX\ \ix{Computer Modern fonts} which
are appropriate for these components have already been used in the package
and are illustrated above.
If you wish to define other components, the examples at the end of the
source show how to do this.
If you are doing this with publicly available fonts, please contribute
them for the benefit of other users by sending the definitions to me by
electronic mail.
It is in your interests to do so --- and to confine use of these four
component-declaration commands to a single macro file --- because a more
elaborate syntax may be used in future to facilitate adjustment of
positioning. The \verb/\newarrow/ command itself, however, will remain
as it is.

\index{>@$>$ arrowhead}\index{>>@$\gg$ arrowhead}%
\index{heads}\index{arrowheads}\index{+ arrowhead}\index{x arrowheads}%
\index{O arrowheads}%
\ixcmd\rBackwards\ixprotect{\LaTeX\ arrowheads}%
The components \verb/>/, \verb/{>>}/, \verb/</, \verb/{<<}/, \verb/x/,
\verb/+/, \verb/O/ and \verb/o/ can be used both as heads (fifth position)
and \ix{tails} (first).
The declaration \verb/<----/ defines \verb/\rBackwards/ to be a left-ward
pointing arrow and \verb/\lBackwards/ to point right;
this is not recommended, as you're certain to get confused.
We shall see in the next section how to change the style of the four
arrowhead components in a systematic way, thereby avoiding the ugly mixture
of vee and \LaTeX\ arrowheads obtained using earlier versions of this package.

\ixcmd\newarrow
In some of the examples above (with the dot and rule fillers) the filler was
repeated as the middle and one or both of the tips, whereas with others
(dash) we used empty middle and tips instead.
This was just to make the definitions easier to type: \verb/\newarrow/
treats middles and tips which agree with the fillers as empty ones.
It is possible to use two different fillers, but this is not recommended.

\ixcmd\HorizontalMap\ixcmd\VerticalMap\ixcmd\DiagonalMap
The commands \verb/\HorizontalMap/ and \verb/\VerticalMap/ are still
supported, but should be replaced by \verb/\newarrow/.
These ought only to have been used in macro files --- not in the text of
documents --- to define four arrow commands together (right, left, up and down).
The twenty arguments defining the five components of each of these four
arrows can (if they're not already provided) be re-arranged as the four
arguments of each of five \verb/\newarrowhead/, {\em etc.,} declarations
with the same effect.
The mnemonics of the five components are then given to \verb/\newarrow/.
If~you have any difficulty doing this conversion, please contact me.


%==========================================================================

\section{Options}\label{options}\index{options}
\ixcmd\diagram\ixcmd{\begin{diagram}}\ixcmd\diagramstyle\ixcmd\usepackage
\ixprotect\LaTeX\ixprotect\LaTeXe
The \verb/\diagram/ or \verb/\begin{diagram}/ command and the arrow
commands may be followed by a list of options in square brackets, for example
\begin{center}
\verb/\begin{diagram}[size=2em,textflow]/ \qquad \verb/\rTo[abut]/
\end{center}
which apply to the diagram or arrow to which they are attached.
Options may be given for an entire document, or within \TeX's normal
scoping rules, by a stand-alone command such as
\begin{center}
\verb/\diagramstyle[centredisplay,PostScript=dvips]/
\end{center}
You may use any number of \verb/\diagramstyle/ commands.
In \LaTeXe\ these options can be given when loading:
\begin{center}
\verb/\usepackage[centredisplay,PostScript=dvips]{diagrams}/
\end{center}
though you should avoid using macros in the option values
(see page~\pageref{miss endcs}).

{\bf Note:} if the text of the first cell in a diagram begins with a
square bracket, the program will attempt to read it as an option, just
as square brackets within \LaTeX\ \verb/array/s can cause trouble.
This usually leads to a catastrophic
error, which can be avoided using \verb/\diagramstyle[nooptions]/.%
\index{nooptions}\index{{}[]}\ixcmd{\begin{diagram}}
This problem doesn't arise in \LaTeX\ if you use \verb/\begin{diagram}/
followed by a (space or) new line before the text of the diagram.

Some options take a value, using an equals sign; those enclosed in square
brackets below are optional, the others mandatory.
Most of the options are appropriate for diagrams rather than arrows.

\def\coordpair{{\rm($x$,$y$)}}

\begin{description}
\def\makelabel#1{{\tt#1} --- }
\item[abut] Leave no gap between maps and objects; useful for (``Hasse'')
   diagrams displaying order structures (page~\pageref{Hasse}).%
   \index{abut}\index{posets}\index{Hasse diagrams}\index{order structures}%
   \index{lattices}\index{shortfall}
\item[alignlabels] The \ix{labels} on horizontal arrows remain centred in the 
   cells where they are defined, despite different size endpoints;
   {\em cf.} \verb/midshaft/.\index{midshaft}\index{aligned labels}
   This is the default, and it is recommended for diagrams of a regular
   character.
   If there is insufficient space to position the labels in this way, they
   are centred (automatically and silently) instead.
   Whichever option is used, the middle of the arrow, if present, is always
   positioned with the labels.
\item[amstex] Enable recognition of \AmSTeX's commutative diagram commands;
   see section~\ref{emulate}.\ixprotect\AmSTeX\index{amscd.sty}
\item[balance] The whole diagram is centred horizontally without regard to
   the left- and rightmost labels,
   so that its weight lies in the middle of the page.
   This is not the default, because if you were not aware of it the gaps
   would come as a surprise, but it is recommended.%
   \index{balance}\index{centre}
\item[bottom] When the diagram is placed alongside some simple text,
   the baseline of that text is aligned with that of the bottom row of the
   diagram.\index{bottom}
\item[centre {\em or\/} center] The diagram is centred%
    \footnote{Notice that I have provided the ``-er'' alternative as a
    courtesy to American users which \person{Donald}{Knuth}
     and \person{Leslie}{Lamport} did not afford to British ones.}
   na\"{\i}vely, using \verb/nobalance/ and \verb/vcentre/;
   {\em cf.}~\verb/middle/.\index{nobalance}\ixcmd\vcenter\index{centre}
\item[centredisplay {\em or\/} centerdisplay] Disables \verb/flushleft/,
   enables \verb/balance/ and gives a warning when used within \verb/$$...$$/
   (see below).\index{flush left}\ixcmd{$$}
\item[cmex] Set the arrow parts appropriately for use of the \verb/cmex/
   (Computer Modern \ix{extension font})\index{Computer Modern fonts};
   used by the \ix{brace} and \ix{paretheses} arrows.\index{cmex}
%\item[defaultsize]
\item[diagonalbase=\coordpair] Start \ix{diagonal arrows} from
   $x$~columns beyond (left or right depending on the direction)
   and $y$~rows above the current cell. Default (1,1).
   Intended for emulation of other diagrams packages:
   see section~\ref{emulate}.
%\item[displayoneliner] Disables \verb/inlineoneliner/.
\item[dotted] Use \ix{dots} instead of a ruled line for arrow shafts.
   Useful for mediators for \ix{universal properties} in category theory.
\item[dpi={\em resolution\/}] Anticipate the output resolution in pixels per
   inch (default 300). A~fudge factor is applied to horizontal and vertical
   ruled lines, without which pixel rounding at 300dpi would cause the
   {\em bottom\/} rather than the middle of the horizontal rule to align
   with the cusp of the \ix{vee arrowheads}:\index{dpi}
   compare $\rTo[heads=vee]$ and $\rTo[nopixel,heads=vee]$.
   Other similar adjustments may also be made to character positioning,
   and to the slopes of diagonals in PostScript mode to avoid ``stepping.''
   Most office laser printers are 300dpi, but if you intend to use a printer
   of a different resolution for your final output, set {\tt dpi=1270} or
   whatever --- otherwise the shafts will be too low instead. The same applies
   if you intend to magnify or reduce; for example {\tt dpi=212} should be
   used for two-up or \ix{A4-on-A5} final printing.
   In \verb/plain/ \TeX\ you may set \verb/\magnification/ at the beginning
   of the file, but {\em do not\/} change \verb/dpi/ as this compensates
   automatically.
   The \verb/nopixel/ option disables the fudge factor.%
   \ixcmd\magnification\index{pixel size}\index{300 dpi}\index{resolution}
\item[dpm={\em resolution\/}] As {\tt dpi} but in dots per metre; {\em e.g.}
   1270dpi=50000dpm.
\item[eqno={\em label\/}] Place {\em label\/} (in maths mode) beside the
  diagram, as an \ix{equation number}.
  See also \verb/LaTeXeqno/.
\item[fixed] Force diagonal arrows to be set on the first pass and not
   stretched.
\item[flushleft{[={\em width\/}]}] The old version of \verb/leftflush/.
  The alignment is on the edge of the grid, irrespective of
  what vertical maps are present
  (this makes the diagram stick out on the left with no good visual reason).
  \index{indented style}\index{asymmetric design}
\item[grid={\em name\/}] Use the \ix{grid} {\em name}.
  See page~\pageref{grid}.\ixcmd\newdiagramgrid
\item[gridx={\em name\/}] Use the grid with the horizontal and vertical
  components interchanged.
\item[h={\em distance\/}] Same as \verb/height/.\index{height}\index{size}
\item[hcentre {\em or\/} hcenter] Same as \verb/nobalance/.%
  \index{balance}\index{centre}
\item[heads={\em name\/}]\label{heads option}
  Set the \verb/>/ and \verb/{>>}/ arrow heads
  and tails to those defined by \verb/\newarrowhead{/{\em name\/}\verb/}/ and
  \verb/\newarrowtail{/{\em name\/}\verb/}/.
  \index{arrowheads}\index{heads}\ixcmd\newarrowhead\ixcmd\newarrowtail
  \index{line10 and linew10 fonts}\ixprotect{\LaTeX\ arrowheads}%
  \index{vee arrowheads}\index{littlevee arrowheads}\index{O arrowheads}%
  \index{boldlittlevee arrowheads}\index{triangle arrowheads}%
  \index{x arrowheads}\index{curlyvee arrowheads}%
  \index{blacktriangle arrowheads}\index{littleblack arrowheads}%
  \index{AMS symbols fonts}\ixcmd\boldmath
  The following styles are currently available:
  \message{(There may follow a warning message about LaTeX diagonals
    - please ignore it.)}%
  \begin{quote}
    \ifx\twoheadrightarrow\undefined\else\def\amsarrows{%
   \dohead{curlyvee}(uses AMS symbols)\cr
   \dohead{blacktriangle}(uses AMS symbols)\cr
   \dohead{littleblack}(uses AMS symbols)\cr
    }\fi
    \ifhavegoodboldmath\def\boldarrows{%
   \dohead{boldlittlevee}(uses {\tt\string\boldmath})\cr
    }\else\let\boldarrows\empty\fi
  \diagramstyle[l>=50pt]\leavevmode
  \def\dohead#1{\tt#1\quad&\relax
  \csname diagramstyle\endcsname[heads=#1]$\rEmbed\quad\rEEmbedd$&\quad}
 \vbox{\halign{#&#&#\hfil\cr&\omit\kern100pt\cr
   \dohead{LaTeX}(default; uses {\tt line10})\cr
   \dohead{vee}\cr
   \dohead{littlevee}\cr
   \boldarrows
   \dohead{triangle}\cr
   \dohead{o}\cr
   \dohead{O}\cr
   \dohead{X}\cr
   \dohead{+}\cr
   \amsarrows
  }}\end{quote}
  \ifx\twoheadrightarrow\undefined
     There are also heads called
     \verb/curlyvee/, \verb/blacktriangle/ and \verb/littleblack/,
     but these require the AMS symbols fonts, which were unfortunately
     not available when this copy of the manual was printed.
     If~you try to use them 
  \else
     The vertical \verb/curlyvee/ heads come from the AMS symbols, and
     the horizontals, from \verb/cmsy/ in the \ix{Computer Modern fonts},
     seem appear to be slightly mis-aligned with the \verb/vee/ heads
     from \verb/cmmi/.
     If~you use them but forget to
       \ifx\usepackage\undefined
         \verb/\input mssymb/,
       \else
         \verb/\usepackage{amssymb}/,
       \fi
  \fi
  \index{undefined control sequence}\index{cmsy}\index{amssymb.sty}%
  you'll get an ``{\tt undefined control sequence}'' error in the middle of
  a lot of garbage (deeply nested): hit return several times and carry on.

  The \verb/boldlittlevee/ heads \ifhavegoodboldmath\else(not shown above) \fi
  rely on \LaTeX's \verb/\boldmath/ command, and default to \verb/littlevee/
  in \verb/plain/ \TeX.\index{plain \protect\TeX}\ixprotect{\LaTeX 2.09}
  They~may not work correctly if you use \person{Leslie}{Lamport}'s old
  \LaTeX2.09 \ix{font selection}.
  Even if you use \person{Frank}{Mittelbach} and \person{Rainer}{Sch\"opf}'s
  new one (which is part of \LaTeXe\ixprotect\LaTeXe) some \ix{PK files}
    \ifhavegoodboldmath
      which are not in the standard distribution may be needed.
    \else
      are needed which were not available when this copy of the manual
      was printed.
    \fi
  It~is only intended for final copy in the event that the \verb/littlevee/
  appears too feint. The same applies to the \verb/boldhook/ tails.
\item[height={\em distance\/}] The distance between the baselines of
  successive rows in the diagram is as specified. Note that as objects and
  arrows commonly alternate, this is usually half the distance between
  one horizontal arrow and the next.\index{height}\index{size}
\item[hmiddle] Same as \verb/balance/.\index{balance}\index{centre}
\item[hug] If \verb/PostScript/ is enabled, rotate labels on %vertical and
  diagonal maps. %The text then runs {\em up\/} the verticals.
  (Not yet implemented --- in fact the \verb/PostScript/ option currently
  {\em always\/} does this to diagonals, but not to verticals.
\item[htriangleheight={\em distance\/}] Set \verb/height/={\em distance\/}
  and then \verb/width/ in such a way that the minimal $3\times5$-grid
  will make an equilateral $\triangleright$ \ix{triangle},
  and a $5\times7$-grid makes a regular \ix{hexagon} (page~\pageref{hexagon}).
  If~the {\em distance\/} is not specified, the existing \verb/height/
  is used and the \verb/width/ adjusted accordingly.
\item[htrianglewidth={\em distance\/}] Set \verb/width/={\em distance\/}
  and then \verb/height/ to make these figures.
\item[inline] Use this option on individual diagrams which are being displayed
  alongside one another, for example in \verb/$$/...\verb/$$/ or \LaTeX's
  \verb/center/ or \verb/displaymath/ environments, when the global display
  option is \verb/flushleft/ or \verb/centredisplay/.\index{in line}%
  \index{flush left}\index{displaymath environment}\index{center environment}
%\item[inlineoneliner] If the diagram has only one row, run it on in the text
%  instead of displaying~it. (This is highly questionable.)
\item[l>={\em distance\/}] Forces arrows (particularly horizontals and
  rotated diagonals) to have   at least the specified length (default 2em),
  to avoid getting \ix{birds' feet} instead of arrows:
  \hbox to2.8em{$A\rTo[l>=0pt,heads=vee]B$}.
  Sometimes this makes the arrow \ix{over-print} an object or appear displaced;
  in this case you'll see an ``over-full \verb/\hbox/'' or ``increase
  cell \ix{width}'' error message.\index{over-full hbox}
\item[labelstyle={\em command\/}]\label{labelstyle}
  Inserts this command in every label
  text;\ixcmd\scriptstyle\index{labels}
  \verb/\scriptstyle/ is the commonest choice apart from the default.
\item[landscape] If \verb/PostScript/ is enabled, rotate the entire diagram
  by $90^\circ$ anticlockwise.\index{landscape}\index{PostScript}
  Options which refer to the extreme rows and columns are modified
  accordingly. Useful for big diagrams with long objects or labels.%
  \index{rotation}
\item[large] Same as \verb/size=5em/.\index{size}\index{large}
\item[LaTeXeqno] Use \LaTeX's running \verb/equation/ numbering
  for an \verb/eqno/ (\emph{q.v.}).\index{equation number}
  You can put a \LaTeX\ \verb/\label/ inside the diagram.\ixcmd{label}
\item[lefteqno] Place the \ix{equation number}, as given by \verb/eqno/, on the
  left of the diagram.
\item[leftflush{[={\em width\/}]}]
  Display the diagram on the left of the page instead of the centre,
  {\em cf.} \verb/fleqn.sty/.\index{flush left}\index{fleqn.sty}
  This is considered good \ix{book design} by certain publishers.
  If {\em width\/} is given, the leftmost vertical of the diagram is,
  if possible, aligned at that distance from the left edge of the page.
  The idea is that the arrows, rather than the text, define the
  visual extent of the diagram.
  If the first column contains multiple verticals, the leftmost
  of them is used for the alignment.
  If there are no verticals in the leftmost column, the alignment
  is on the left extremity of the text.
  \index{indented style}\index{asymmetric design}
\item[leftshortfall={\em distance\/}] The gap between the arrow (to which it
  is applied individually) and the object on its left is as specified.%
  \index{short fall}
%\item[locate=$x$:$y$] Move the origin of the diagonals. Not yet implemented.
\item[lowershortfall={\em distance\/}] Similarly below.
\item[loose] The rows and columns of the diagram have {\em at least\/} the
  \verb/height/ and \verb/width/ specified, but may stretch, in the same
  way as those of an array or table.
  This is the default, because the results are more of less right in most
  circumstances, but this can result in gaps in the diagram, so it is
  recommended that \verb/tight/ be used in the final version of a document,
  with appropriate manual adjustment of the size of the grid.%
  \index{tight}\index{loose}\index{width}
\item[middle] The diagram is centred both horizontally
   using \verb/balance/ and vertically using \verb/vmiddle/, {\em q.v.}%
   \index{middle}\index{centre}\index{balance}
\item[midhshaft {\em or\/} midshaft] Labels are centred in the shafts of
  horizontal arrows; {\em cf.} \verb/alignlabels/.%
  \index{aligned labels}\index{midshaft}
  This happens automatically for in-text or one-line diagrams,
  or if the arrow is too short to align the labels.
%\item[midvshaft] The same for vertical arrows (doesn't work).
%\item[missives] Enable missives.
\item[moreoptions] Allow another list of \ix{options} in square brackets.
  This is intended for macros like
  %\begin{center}
  \verb/\def\funnydiagram{\diagram[/{\em options\/}\verb/,moreoptions]}/
  %\end{center}
  to allow \verb/\funnydiagram[/{\em options\/}\verb/]/.
  The arrow commands always allow any number of lists of options.
\item[nobalance] Horizontal centring of diagrams is done with respect to the
  extremities.\index{balance}
\item[nohcheck] Disables certain \ix{error checking}.
\item[nohug] Do not rotate the labels on vertical and diagonal maps, but
  print them horizontally.
  (Not yet implemented --- in fact the \verb/PostScript/ option currently
  {\em always\/} rotates labels on diagonals, but not on verticals.
\item[nooptions] Used in \verb/\diagramstyle/, this disables the parsing
  of \ix{options}. \ixcmd\diagramstyle
  This is for reverse compatibility in the case where several diagrams
  begin with a square bracket.
\item[noorigin] Disables \verb/origin/ and \verb/balance/.%
  \index{balance}\index{origin}
\item[nopixel] Disable the \verb/dpi/ fudge factor, {\em q.v.}, by setting
  a very high resolution.\index{pixel size}
\item[noPostScript] Disables the use of embedded {\sc \ix{PostScript}}
  {\em and\/} the \verb/PS/ and \verb/noPS/ options.
  The value, if any, is ignored, so you need only edit in/out the prefix
  \verb/no/ whilst leaving the choice of {\sc PostScript} translator intact.
\item[noPS] Disable {\sc PostScript} on individual maps and diagrams.
\item[notextflow] Disables \verb/textflow/. This is needed on some individual
  diagrams (where they appear as nouns in a sentence, for instance) when you
  use \verb/\diagramstyle[textflow]/.\index{text flow}
\item[noTPIC] Disable the use of TPIC \verb/\special/s.%
  \index{TPIC}\ixcmd\special
\item[objectstyle={\em command\/}] Inserts this command in every \ix{object}
  text; \ixcmd\scriptstyle
  \verb/\scriptstyle/ is the commonest choice apart from the default.
\item[origin] Makes the width, height and depth of the whole diagram zero,
  locating it at the baseline of the bottom row, in the centre of the leftmost
  column.
  This allows it to be positioned by the user; useful for mixing diagrams with
  \LaTeX\ pictures and other graphics.
  \index{origin}\index{picture environment}\ixprotect\LaTeX
\item[p={\em distance or\/} pilespacing={\em distance\/}] Set the distance
  between parallel verticals (in the same cell); that between the rows of a
  \verb/\pile/ is half of this to allow things to be put between parallel
  horizontals.\index{parallel arrows}\ixcmd\pile\label{pilespacing}
\item[pixelsize={\em distance\/}] Anticipate this output resolution;
  {\tt pixelsize=.02true mm} is the same as {\tt dpi=1270} or {\tt dpm=50000}.%
  \index{pixel size}
\item[portrait] Disable the \verb/landscape/ option,
  {\em q.v.}\index{landscape}\index{portrait}
\item[PostScript={\em author\/}]\label{PS}
  Enable the use of embedded \ix{Adobe}
  {\sc \ix{PostScript}} \verb/\special/ commands in a form supported by
  {\em author\/}'s translator.
  The following are currently recognised by the {\em author\/}s' surnames,
  their programs or their companies.
  The surname is the preferable form, since the programs have very similar
  names.
  The master \ix{FTP} source is also given.\index{anonymous FTP}
  \begin{itemize}
  \item (Tomas) \verb/Rokicki/, \verb/dvips/, \verb/RadicalEye/:
    labrea.stanford.edu /pub/dvips9999.tar.Z%
    \index{Rokicki, Tomas}\index{dvips}\index{Radical Eye}
  \item (Stephan) \verb/Bechtolsheim/, \verb/dvitps/,
    \verb/IntegratedComputerSystems/:\\
    arthur.cs.purdue.edu /pub/TeXPS-9.99.tar.Z%
    \index{Bechtolsheim, Stephen}\index{Integrated Computer Systems}%
    \index{dvitps}
  \item (James) \verb/Clark/, \verb/dvitops/\index{Clark, James}\index{dvitops}
  \end{itemize}
  These are currently used to implement diagonals by rotating horizontals.
  It is not possible to use \person{Andrew}{Trevorrow}'s Oz\TeX.%
  \index{oztex@Oz\protect\TeX}
\item[PS] Suppose you want to use {\sc \ix{PostScript}} for some but not all
  maps and diagrams in the final version. Then use \verb/PS/ for each of them
  but put \verb/\diagramstyle{noPostScript}/ in the preamble during drafting.
\item[repositionpullbacks] The \ix{pullback} symbols 
  have a fixed position relative to the cell, irrespectively of
  where you put the \verb/\SEpbk/ {\em etc}.~command.
\item[righteqno] Put the \ix{equation number} (\verb/eqno/), if any,
  on the right.
\item[rightshortfall={\em distance\/}] Analogous to \verb/leftshortfall/.%
  \index{short fall}
\item[ruleaxis] Set the height of the shaft of the horizontal arrows;
  normally \verb/\mathaxis/.
  \index{ruleaxis}\index{horizontal arrow}\ixcmd\mathaxis
\item[s={\em distance\/}] Same as \verb/size/.\index{size}
\item[scriptlabels] Labels on  maps are set in \verb/\scriptstyle/; useful
  if they're rather long.
\item[shortfall={\em distance\/}] Set the gap between arrows and the objects
  to which they point.\index{short fall}
%\item[showpair=\coordpair] Debug
\item[silent] Suppress \ix{warnings} and second-pass \ix{error messages}.
  Only use this option if either you don't care what the diagram looks like
  or you've typeset it and looked at the result already. Not recommended.
  \index{silent}
\item[size={\em distance\/}] Set both \verb/height=/{\em distance\/} and
  \verb/width=/{\em distance}.\index{size}
  \begin{center}
  {\bf Most geometrical problems with diagrams can be solved by enlarging
  the cells.} Please try this and the \verb/tight/ option before contacting me.
  \end{center}
\item[small] Same as \verb/size=2em/.\index{size}
\item[textflow] The text which follows the diagram in the \TeX\ source is
  brought up to fill out the line preceding it; useful to avoid the
  ``such that the diagram $\clubsuit$ commutes'' clich\'e.
  This has been used for several diagrams in this manual.\index{text flow}
\item[thick{[={\em breadth\/}]}] As \LaTeX\ \verb/\thicklines/, optionally
  setting the width of orthogonal ruled lines. The \LaTeX\ command itself has
  no effect within diagrams. The default rule breadth is twice that for the
  \verb/thin/ option.\ixcmd\thicklines
\item[thin{[={\em breadth\/}]}] This is similarly analogous to
  \verb/\thinlines/.\ixcmd\thinlines
  The default rule breadth is the same as that used by \TeX, namely
   \verb/\fontdimen8\textfont3/.
\item[tight] Force all of the cells in the grid to have exactly the \ix{size}
  you specify.\index{tight}\index{height}\index{width}\index{loose}
  This is recommended for the final version of a document, but
  is not the default because it may cause \ix{over-print}ing,
  which requires the intervention of the user to cure
  (by setting \verb/height/ and \verb/width/);  {\em cf.} \verb/loose/.
\item[top] Analogous to \verb/bottom/, except that the top row is used.
\item[TPIC] Use \ix{TPIC} \verb/\special/ commands instead of \LaTeX\ line
  segments to draw diagonal lines.
  These are supported by {\sc Textures}, \person{Tomas}{Rokicki}'s
  \verb/dvips/ and \person{Paul}{Vojta}'s \verb/xdvi/.%
  \ixcmd\special\index{xdvi}\index{dvips}
\item[uppershortfall={\em distance\/}] Analogous to \verb/leftshortfall/,
  except above.\index{short fall}
\item[vcentre {\em or\/} vcenter] Vertical positioning is the same as with
  \TeX's \verb/\vcenter/\ixcmd\vcenter\ixcmd{[c]}\index{centre}
  command or \LaTeX's \verb/[c]/ option.
  However \verb/vmiddle/ is what is usually wanted.
\item[vmiddle] If a diagram with an odd number of rows of constant height
  (the usual case) is placed alongside some simple text,
  the baseline of the text will be aligned
  with that of the middle row, irrespectively of the height and depth of the
  labels on the top and bottom rows.
  In general, the baseline of the diagram is half-way between those of the
  top and bottom rows.\index{centre}
\item[vtriangleheight={\em distance\/}] Set \verb/height/={\em distance\/}
  and then \verb/width/ in such a way that the minimal $5\times3$-grid
  will make an equilateral $\bigtriangleup$ \ix{triangle}
  and a $9\times 5$-grid makes a regular \ix{hexagon} (page~\pageref{hexagon}).
  \index{width}\index{height}
\item[vtrianglewidth={\em distance\/}] Set \verb/width/={\em distance\/}
  and then \verb/height/ to make these figures.
\item[w={\em distance or\/} width={\em distance\/}] Set the distance between
  the centre of one column and the next to the right.\index{width}
\end{description}


%==========================================================================

\section{Application to adjunctions}
Here is a side application of commutative diagrams to displaying
``adjoint correspondences.'' It also illustrates the way arrows
stretch to meet their endpoints but keep their labels centred in
the column of arrows. The options are chosen to avoid getting
lots of extra space around the cells, which in this case we don't want.
Notice also the invisible ``objects'' terminating the \verb/\hLine/
``morphism'' command.\index{adjunction}

\ixcmd\hLine\ixcmd\dashv\index{empty cells}\index{invisible objects}

\begin{verbdiag}[loose,height=.8em,width=0pt]
&Z\times X&\relax\rTo^f&Y&\\
\relax\ &&\relax\hLine&&\relax\ &\\
&Z&\relax\rTo^{{\bf curry}(f)}&Y^X&
\end{verbdiag}

\vskip-6ex
\diagram[loose,height=.8em,width=0pt]
&Z \times X &\relax\rTo^f & Y \\
\ &&\relax\hLine && \ \\
&Z & \rTo^{\ {\bf curry}(f)\ } & Y^X \\
\enddiagram

\ixcmd\hfill

If you want the $Z$s lined up, it's no good \verb/\hfill/ing the second
one on the right, because the arrow will not stretch to meet
it\footnote{There is no way of detecting {\em where\/} \ix{glue} is placed
inside a box, so the \ix{stretch}ing algorithm {\em assumes\/} the object
is centred and extends the arrow by half the amount of glue in the
object box.}. The best solution is probably to split the object into
two cells:

\begin{verbdiag}[loose,height=.8em,width=0pt,l>=3em,midshaft]
&Z&\relax{}\times X&\relax\rTo^f&Y&\\
\relax\ &&&\relax\hLine&&\relax\ &\\
&Z&&\relax\rTo^{{\bf curry}(f)}&Y^X&
\end{verbdiag}

\vskip-6ex
\diagram[loose,height=.8em,width=0pt,l>=3em,midshaft]
&Z & {} \times X &\relax\rTo^f & Y \\
\ &&& \hLine&& \  \\
&Z & & \rTo^{{\bf curry}(f)} & Y^X \\
\enddiagram

\noindent The \verb/{}/ makes sure \verb/\times/ still gets the spacing
appropriate to a binary operator.

%==========================================================================
\section{Diagonal lines}\label{diagonals}\index{diagonal arrows}
Whereas horizontal and vertical arrows such as \verb/\rTo/ and \verb/\dTo/
stretch to meet their endpoints without your telling them where those are,
the diagonals (\verb/\ruTo/) need to be told explicitly if you want to use
them for anything other than to go across a $3\times3$ square.

\ixcmd\line\ixcmd\vector\ixcmd\ruTo\ixcmd\rdTo\ixcmd\luTo\ixcmd\ldTo
\ixcmd{()}%
The approximate direction of the arrow stays the same ---
right/left and up/down --- as given by its name.
The length (and exact direction) are given by {\em positive\/} coordinates.
As with \LaTeX's \verb/\line/s and \verb/\vector/s,
these are given pairs of (small) positive integers in round brackets, except
that there is no restriction on the values.

\ixcmd\laf\ixcmd\lah\index{line10 and linew10 fonts}\index{height}\index{width}
However these numbers count the {\em cells,} horizontally and vertically,
through which the arrow passes, rather than the absolute distance.
This means%
   \footnote{This represents a change from version~3, in which they were
   required to be the same for the diagonals to work. The coordinates are
   now converted internally into distances, and then back into a rational
   number, and the appropriate \LaTeX\ arrow characters chosen.
   The macros {\tt\string\laf}, {\tt\string\lah}, {\em etc.} and their octal
   arguments are now obsolete.}
that if the \verb/height/ of the rows and the \verb/width/ of the
columns are different, \verb/\ruTo(2,2)/ is no longer a $45^\circ$ slope.

The names of the arrow commands specify the horizontal direction first,
as a reminder that this is also the convention for coordinates.

Another difference from the orthogonal arrows is the rule for where to place
the command. Somewhat arbitrarily,%
   \footnote{The option \texttt{diagonalbase} changes this; it is
   intended for emulation of other diagrams packages.}
this is
\begin{quote}
   in the row {\em below the upper endpoint\/} (irrespectively of the direction
   of the arrowheads, if any), and in the adjoining column
\end{quote}
In the commonest case (the diagonal of a small square) this means the middle
of the square; more generally for positive gradients (\verb/\ruTo/ and
\verb/\ldTo/) the arrow command goes below and to the left of the upper
endpoint, and for negative gradients (\verb/\rdTo/ and \verb/\luTo/) below
and to the right.

\ixcmd\SEpbk\ixcmd\SWpbk\ixcmd\NEpbk\ixcmd\NWpbk
For example, here is the diagram which defines a \ix{pullback}.
The corner symbol is a macro (\verb/\SEpbk/) placed in the same cell as the
object, but which prints way outside it.
$$\begin{verbdiag}
U&&&&&\\
&\relax\rdTo~{(x,y)}\rdTo(4,2)^x\rdTo(2,4)_y&&&&\\
&&X\times_Z\SEpbk Y&\relax\rTo_p&X&\\
&&\relax\dTo^q&&\relax\dTo_f&\\
&&Y&\relax\rTo^g&Z&
\end{verbdiag}$$
\vskip-6ex
\begin{diagram}
U \\
  &\relax\rdTo~{(x,y)}     \rdTo(4,2)^x
    \rdTo(2,4)_y  \\
  &         & X\times_Z \SEpbk Y & \rTo_p & X      \\
  &         & \dTo^q             &        & \dTo_f \\
  &         & Y                  & \rTo^g & Z      \\
\end{diagram}

For reverse compatibility, some commands with ``\ix{compass}''
names are provided, such as \verb/\NW/, \verb/\WNW/, \verb/\NNNW/,
together with dotted and other variants. However
{\em the auxiliary file \verb/extra-diagonals.tex/ is obsolete and must
not be used.}

\label{Hasse}
The main use of diagonals other than the simplest ones is for illustrating
\ix{order structures} (``\ix{Hasse diagrams}'').\index{posets}\index{lattices}
Posets are trivial categories, but in practice they're the most difficult
diagrams to draw!
\begin{quote}
\begin{verbatim}
\begin{diagram}[height=2.5em,width=1.5em,abut]
o&&&&o&&&&o&&&&o\\
&\luLine\luLine(10,2)&&\ruLine&&\relax\luLine(6,2)&&
\ruLine(6,2)&&\luLine&&\ruLine\ruLine(10,2)&\\
&&o&&&&&&&&o&
\end{diagram}
\end{verbatim}
\end{quote}

\begin{diagram}[height=2.5em,width=1.5em,abut]
o&&&&o&&&&o&&&&o\\
&\relax\luLine\luLine(10,2)&&\relax\ruLine&&\relax\luLine(6,2)&&
\relax\ruLine(6,2)&&\relax\luLine&&\relax\ruLine\ruLine(10,2)\\
&&o&&&&&&&&o
\end{diagram}

\ixcmd\DiagonalMap\index{lams1 to 5 fonts}\index{line10 and linew10 fonts}
The obsolete command \verb/\DiagonalMap/ is also still supported, but should
be replaced by the new commands. If you have used this with fonts other than
\verb/line10/ (for example \person{Michael}{Spivak}'s fonts
\verb/lams1/ to \verb/lams5/),
please contact me to assist with conversion.

\ixcmd\raise\ixcmd\lower\ixcmd\raisebox\index{abut}%
By default, the diagonal arrows are set on the \ix{first pass} using
\LaTeX\ line segments.
By~contrast, the horizontals and verticals use ruled lines wherever possible
and are adjusted on a \ix{second pass} of the diagram
(within the \verb/\enddiagram/ command) to meet their endpoints.

When the diagonals are set during the first pass, everything happens
within the cell where they are declared, where the algorithm has
no access to information about the size (and exact whereabouts)
of the objects at which the arrows are meant to point.
Therefore the lengths of the diagonals are chosen somewhat arbitrarily,
though the \verb/abut/ option will make them touch a \verb/\cdot/.

To get better results we have to use more sophisticated methods,
and go outside what is strictly ``standard'' \TeX.

%==========================================================================
\section{Alternative \TeX nology}
In order to get the best results, you should be aware of the way in which
diagonals are constructed.
\TeX\ is ultimately only capable of positioning characters from various fonts
and drawing black rectangles with horizontal and vertical sides: there
is no primitive for diagonal lines or for \ix{rotation}.\index{diagonal arrows}
This means that we have
\begin{itemize}\ixcmd\line\ixcmd\vector
\item either to juxtapose characters with a limited choice of angles,
  as \LaTeX's \verb/\line/ and \verb/\vector/ commands do,
  with the result that (because of pixel rounding
  errors) they may not line up correctly,
\item or to use the loophole in the \ix{DVI} language provided by the
  \verb/\special/ command to tell some post-processing software
  (such as \verb/dvips/) to do the work for us, thereby surrendering
  portability,\ixcmd\special\index{dvips}
\item or to over-print a large number of dots, making the DVI file very
  large since at least 12 bytes are needed for each dot.
  This is what \PiCTeX\ does.\ixprotect\PiCTeX
\end{itemize}
In this package options are provided to employ the first two of these methods.
\begin{itemize}
\item By default, characters from \LaTeX's%
    \footnote{The code is similar to that underlying the \LaTeX\ commands,
    but is not the same. In particular, the line segment characters are
    equally spaced, instead of a single overlap between the last two.}
  \verb/line10/ font are used.\index{line10 and linew10 fonts}
  Arrowheads from this font are used irrespectively of those chosen by the
  \verb/heads/ option.
  The nearest%
    \footnote{The approximation uses \ix{continued fractions}, {\em alias\/}
    \ix{Euclid's algorithm}, with a correction.
    There is also code for computing \ix{Pythagorean sums} (for the lengths of
    rotated diagonals) and \ix{trigonometric functions} (currently unused).}
  available \LaTeX\ slope is chosen, with the effect that arrows
  may sometimes fall short or overshoot: \verb/height/ and \verb/width/
  should be set with this in mind.\index{height}\index{width}\index{size}
\item If the \verb/PostScript/ option is enabled, horizontal arrows are
  used, and \verb/\special/ commands%
     \footnote{The code is adapted from \person{Tomas}{Rokicki}'s
     {\tt \ix{rotate.sty}}.}
  are embedded in the DVI file which have the effect of rotating them.
  If the DVI file is post-processed
  by a program which does not understand Adobe {\sc PostScript} an error
  message will probably be generated and the arrows will appear horizontal.

  Currently the labels are rotated with the arrows; later there will be an
  option either to do this or to set them horizontally.

     Literal {\sc PostScript} commands are included in the DVI file
     using \TeX's \verb/\special/ command.
     The various DVI to {\sc PostScript} translators (page~\pageref{PS})
     make use of this in different ways,
     so it is necessary to specify which one you are using.
     I~use Tomas Rokicki's \verb/dvips/;
     if the program you use is not listed,
     please consult its manual for the appropriate way of including literal
     {\sc PostScript} commands and tell me the result
     so that I can add this as an option.
     The rotation code should be independent of the design of the translator.

     It does not and cannot work with the Oz\TeX\ {\sc PostScript} translator
     because this sorts the characters on each page by font and cannot deal
     with \verb/\special/ commands.\index{oztex@Oz\protect\TeX}
\item If the \verb/TPIC/%
     \footnote{\ix{TPIC} is a graphics preprocessor for \TeX\ by
     \person{Tim}{Morgan} which uses this set of {\tt\string\special} commands.
     The same ones were also adopted by \ixcmd\special
     \person{Dirk}{Grunwald} for {\tt \ix{texpictex}} and
      by \person{Conrad}{Kwok} for {\tt  \ix{eepic}},
     which are \LaTeX\ macro packages for \ix{graphics}.}
  option is enabled, a simpler set of \verb/\special/
  commands is used to draw diagonal lines, but rotation is not available.
  \verb/dvips/ and \verb/xdvi/ understand these, but other post-processors
  may give error messages and print nothing.\index{xdvi}\index{dvips}
\end{itemize}
No additional macro packages or special knowledge are needed to make use of
these methods: all of the necessary code is built in to the diagrams package.

Future versions may exploit these extensions to provide other features, such
as curved lines; indeed this is likely to be the main direction of further
development. Other methods may also be provided.
However
\begin{itemize}
\item if no extension option is selected a standard DVI file
  (using the \verb/line10/ font) will be always generated,
  giving an approximation to the features requested.
\item development of new features will use \verb/PostScript/ mode,
  without which a ``\ix{second class service}'' will be provided.
\end{itemize}



%===========================================================================
\section{Regular figures}

The difference between these options can be seen by trying to draw a
regular \ix{hexagon}.\label{hexagon}\index{abut}\index{tight}
$$\begin{verbdiag}[vtrianglewidth=1em,abut,tight]
   &&\relax{}&&\relax\rLine&&\relax{}&\\
   &\relax\ruLine&&&&&&\relax\luLine&\\
   \relax{}&&&&&&&&\relax{}&\\
   &\relax\luLine&&&&&&\relax\ruLine&\\
   &&\relax{}&&\relax\rLine&&\relax{}&
\end{verbdiag}$$
The \verb/PostScript/ and
\verb/TPIC/ options will make it meet up exactly, whereas the default \LaTeX\
method does not --- though it is surprisingly accurate!
\begin{center}
   \begin{diagram}[vtrianglewidth=1em,abut,tight,inline,PS]
   &&{}&&\rLine&&{}\\
   &\ruLine&&&&&&\luLine\\
   {}&&&&&&&&{}\\
   &\luLine&&&&&&\ruLine\\
   &&{}&&\rLine&&{}
   \end{diagram}
 \qquad\qquad
   \begin{diagram}[vtrianglewidth=1em,abut,tight,inline,noTPIC,noPS]
   &&{}&&\rLine&&{}\\
   &\ruLine&&&&&&\luLine\\
   {}&&&&\hbox{\rm\LaTeX}&&&&{}\\
   &\luLine&&&&&&\ruLine\\
   &&{}&&\rLine&&{}
   \end{diagram}
\end{center}
The \verb/vtrianglewidth/ option and its variants set the \verb/width/
and \verb/height/\index{width}\index{height}\index{size} of the cells,
but the array retains the symmetry of a rectangle.
Tesselations of \ix{triangle}s and \ix{hexagon}s
may be drawn in this way.

Drawing a regular \ix{pentagon}  requires rows and columns
of different sizes.
It~is envisaged that only a few special ways of doing this will
be used, so this feature is provided by a \emph{declaration}%
   \footnote{I cannot think of a natural way of specifying the distances
   without coding general \ix{Gaussian elimination}.
   I'm~quite happy to accept angles expressed in degrees.}
of the form\ixcmd\newdiagramgrid\label{grid}
\begin{quote}
\begin{verbatim}
\newdiagramgrid{pentagon}%
   {0.618034,0.618034,1,1,1,1,0.618034,0.618034}%
   {1.17557,1.17557,1.902113,1.902113}
\end{verbatim}
\end{quote}
(In fact this is already made within the source of the package.)
The numbers in the first list specify the distances between the centres
of the first and second columns, the second and third, and so on,
and similarly those in the second list the distances between the
baselines of the rows.
The units are the specified cell \verb/height/ and \verb/width/.

Once declared, the \ix{grid} is chosen by name using the obvious option.
Note that this forces the \verb/tight/ option.\index{tight}
\begin{verbatim}
\begin{verbdiag}[grid=pentagon,PostScript]
  &&&&(A*B)*(C*D)& \\
  &&&\ruTo(4,2)^\Assl&&\rdTo(4,2)^\Assl&\\
  A*(B*(C*D))&&&&&&&&((A*B)*C)*D&\\
  &\rdTo_{\Id*\Assl}&&&&&&\ruTo_{\Assl*\Id}&\\
  &&A*((B*C)*D)&&\rTo^\Assl&&(A*(B*C))*D&
\end{verbdiag}
\end{verbatim}
\begin{diagram}[grid=pentagon,small]
  &&&&(A*B)*(C*D)& \\
  &&&\relax\ruTo(4,2)^\Assl&&\relax\rdTo(4,2)^\Assl&\\
  A*(B*(C*D))&&&&&&&&((A*B)*C)*D&\\
  &\relax\rdTo_{\Id*\Assl}&&&&&&\relax\ruTo_{\Assl*\Id}&\\
  &&A*((B*C)*D)&&\relax\rTo^\Assl&&(A*(B*C))*D&
\end{diagram}
A similar grid for a pentagon with a vertical side is obtained by
the \verb/gridx/ option.

The grid \verb/perspective/\index{perspective} has this effect
on the \ix{cube} on page~\pageref{cube}:
\begin{diagram}[grid=perspective]
   A'  &    &\rTo^{f'} &      &   B'   \\
      & \rdTo_a &      &      & \vLine^{h'}& \rdTo_b  \\
\dTo^{g'} &    &   A   & \rTo^f  & \HonV   &    &  B  \\
      &    & \dTo^g  &      & \dTo   \\
   C'  & \hLine & \VonH   & \rTo^{k'} &   D'   &    & \dTo_h \\
      & \rdTo_c &      &      &      & \rdTo_d  \\
      &    &   C   &      & \rTo^k  &    &  D  \\
\end{diagram}
Without the \verb/PostScript/\index{PostScript} option the
\ix{diagonal arrows} will not be set correctly.


%===========================================================================

\iffalse
\section{Bent lines --- not currently implemented}

The diagonal lines in the previous section were difficult to draw and
rather ugly. Here is a prettier way of doing it:
\begin{verbdiag}
U&&\relax\hLine^x&&\relax\dlBentto&\\
&\relax\rdTo^{\langle x,y\rangle}&\\
\vLine^y&&X\times_Z\SEpbk Y&\relax\rTo^p&X&\\
&&\relax\dTo^q&&\relax\dTo_f\\
\relax\ruBentto&&Y&\relax\rTo^g&Z&\\
\end{verbdiag}
which gives:
\begin{diagram}
U && \hLine^x & &
\dlBentto \\
& \rdTo^{\langle x,y\rangle} \\
\vLine^y && X \times_Z \SEpbk Y & \rTo^p & X \\
&&\dTo^q && \dTo_f \\
\ruBentto&& Y & \rTo^g & Z \\
\end{diagram}

Notice that the bent lines consist of two separate arrow commands,
one of them an ordinary \verb/\hLine/ or \verb/\vLine/ and the other
a ``bent'' arrow.  The latter are designed to meet orthogonal lines
exactly. To be precise,
\begin{itemize}

\item \verb/\dlBentto/, {\em etc.}, has a corner which is vertically
positioned on the maths axis and includes a short horizontal line to
compensate for the space at the end of \verb/\hLine/.
{\em It~must be placed in the cell corresponding to the corner.}
There are similar commands \verb/\ulBentto/
for upward maps, \verb/\drBentto/ to meet lines on the right and
\verb/\dlBent/ without an arrowhead (and all the combinations).

\item \verb/\ruBentto/, {\em etc.}, has a corner which is horizontally
positioned in the centre of the {\em next\/} cell (assuming that's
empty). So {\em it must be placed in the cell next to the corner,
in fact that corresponding to the edge.} The arrow is extended 
automatically.
Again there are commands with variant names.

\end{itemize}

These bent line commands are defined in exactly the same way as ordinary
horizontal and vertical arrows, except that
\begin{itemize}

\item \verb/\dlBentto/ has only a bottom half, {\em i.e.}~the leading
tip and first filler are \verb/\empty/. The second filler and trailing
tip are quite ordinary but the middle is special (\verb/\ldmcorner/).

\item \verb/\ruBentto/, on the other hand, is a complete arrow, the
{\em tail\/} now being a special corner.

\end{itemize}
Other middles could be defined to give rounded corners, using \LaTeX's
{\tt circle10} font.
\fi


%=========================================================================
\section{Emulation of \TeX ercise 18.46}\label{18.46}
\ixprotect{\TeX book}\index{Exercise 18.46}\ixprotect{\TeX ercise 18.46}%
\index{emulation}%
This and the next section describe how to convert diagrams in your existing
documents which were drawn using other commutative diagram macro packages to
use this one, wherever possible changing only the preamble or macro
file and not the text itself.

Exercise 18.46 of {\em The \TeX book\/} provided some ideas for commutative
diagrams, from which the present package was originally developed.
The following instructions are based on what is given there,
but if you have added other arrow macros you will have to work out how to
re-define them by following the examples given.

\ixcmd\matrix
If you have used the {\em\TeX book\/} macros as they stand --- with
\verb/\matrix/ enclosing the diagram --- you will first have to distinguish
between the diagrams and real matrices.
(If~you give arrays of numbers to the commutative diagrams  package, they
will come out rather widely spaced.)
This process is unnecessary if you already have a macro for diagrams
rather than matrices: just re-define that in a similar way.

In~your macro file you probably have something like what follows the
\verb/\iffalse/ command below, but with additional macros written in
a similar way (this is the reason for setting it all out in gory detail
in the manual rather than providing an extra input file as in the case
of some of the ``packages'' described in the next section).
If~you make the following additions you will be able to revert to the 
original (in the unlikely event that you are not satisfied)
by changing this to \verb/\iftrue/.

This is not particularly difficult: when, as a \TeX\ novice, I~wrote my
Ph.D.~thesis in August 1986, I~had sixty diagrams drawn using 
the {\it\TeX book\/}
macros, together with several others that had to be drawn by hand.
Recovering that from an archive tape, I~recently found that all but five
of the sixty could be converted without any change at all to the text,
whilst the hand-drawn ones can now be drawn with the up-to-date package.

\ixcmd\mapright\ixcmd\mapleft\ixcmd\mapup\ixcmd\mapdown
\ixcmd\inputlineno
\begin{quote}\small
\begin{verbatim}
\iffalse
  % your macros, copied or adapted from TeXercise 18.46 (page 325)
  \def\mapright#1{\smash{\mathop{\longrightarrow}\limits^{#1}}}}
  \def\mapdown#1{\Big\downarrow\rlap{$\vcenter{\hbox{$\scriptstyle#1$}}$}}
  %
  \let\cdmatrix\matrix % revert to using \matrix for diagrams
\else
  % Replacement for the above using ...
  \input diagrams % Paul Taylor's diagrams.
%
  \def\mapright#1{\global\matrixwascdtrue\rTo^{#1}\relax}
  \def\mapleft #1{\global\matrixwascdtrue\lTo^{#1}\relax}
  \def\mapup   #1{\global\matrixwascdtrue\uTo>{#1}\relax}
  \def\mapdown #1{\global\matrixwascdtrue\dTo>{#1}\relax}
%
  % Maybe you have some variants like this:
  \def\mapupbefore#1{\global\matrixwascdtrue\uTo<{#1}\relax}
%
  % The following examples may also be useful:
  \let\into\rInto
  \def\horizadjoint#1#2{\pile{\lTo^{#1}\\\bot\\\rTo_{#2}}}
  \def\vertadjoint #1#2{\dTo<{#1}\dashv\uTo>{#2}}
%
  % Here is a replacement for \matrix which gives a commutative
  % diagram, including some extra macros for use inside them.
  \def\cdmatrix{\bgroup
    \edef\matrixlineno{\the\inputlineno}\global\matrixwascdfalse
    % 
    \let\matrix\pile   % inner \matrix is probably parallel horizontals
    %
    % re-define the diagonal arrows
    \let\nwarrow\luTo\let\nearrow\ruTo\let\swarrow\ldTo\let\searrow\rdTo
    % 
    \diagram[]% begin the diagram (without options)
    \getthematrix% delete this line if you use amstex rather than plain
    }
  \def\getthematrix#1{#1\endcdmatrix}
  \newif\ifmatrixwascd
  \def\endcdmatrix{\enddiagram\egroup}
%
  % The following tells you whether it was actually a diagram or
  % a matrix. Remove this when you've changed those \matrix
  % commands in your text which should be diagrams to \cdmatrix.
  \def\endcdmatrix{\enddiagram\egroup
    \expandafter\message{^^JThe \string\matrix\space at lines
      \matrixlineno--\the\inputlineno\space was really a
      \ifmatrixwascd diagram\else matrix\fi.^^J}}
  \let\matrix\cdmatrix \let\endmatrix\endcdmatrix
%
\fi
\end{verbatim}\end{quote}

The code as shown above assumes you have \TeX\ version~3 (to provide
\verb/\inputlineno/); it prints a \verb/\message/ to tell you whether
each \verb/\matrix/ has used any arrow commands.
With a clever choice of this message you can even get your editor
to make the necessary changes to the text for you in batch mode!
Delete the extra code after you have done this.

\ixprotect\AmSTeX\index{array environment}\ixcmd\endmatrix
Beware that \AmSTeX\space uses \verb/\matrix#1\endmatrix/ instead of
\verb/\matrix#1/.
In~this case, delete \verb/\getthematrix/ as indicated.
Then (where appropriate) change \verb/\endmatrix/ as well as \verb/\matrix/.
The same applies if you have used the \verb/array/ enviroment in \LaTeX.

%       \begin{itemize}
%       \item \verb/\matrix{..}/ must be changed to 
%               \verb/\diagram..\enddiagram/ (or~\verb/\commdiag{..}/).
%       \item \verb/\mapright/, {\em etc.,} must be changed to (or~defined
%               as) \verb/\rTo/. Positional arguments are still recognised,
%               {\em so long as they are enclosed in braces.}
%       \item \verb/\cr/ should be changed to \verb/\\/.
%       \end{itemize}

%=========================================================================
\section{Emulation of other macro packages}\label{emulate}\index{emulation}
There are several other \TeX\ macro packages in circulation for drawing
commutative diagrams, of varying degrees of sophistication.
This section describes how to adapt the preamble of an existing document
which was written to use such macros so that it prints diagrams like those
in this manual instead.
When you publish documents prepared in this fashion, please remember to
acknowledge the authors of both packages, making it clear which you used to
type the original source and which produced the finished product.%
\index{acknowledgement}

\bigskip
\noindent{\bf \ix{American Mathematical Society}}%
\ixprotect\AmSTeX\ixprotect\AMSLaTeX\index{amscd.sty}
(\AmSTeX, and \AMSLaTeX's \verb/amscd.sty/): see Michael Spivak below.

\bigskip
\noindent{\bf \person{Michael}{Barr}}'s \verb/catmac/\index{catmac.tex} macros
were based on a principle of overlapping squares.
Whilst this is perhaps closer conceptually to the
   categorical ideas which are being expressed, it is not possible to emulate
   the language using the matrix syntax. The simple shape macros can, however,
   be replaced by
\ixcmd\square
\begin{quote}\begin{verbatim}
\def\square[#1`#2`#3`#4;#5`#6`#7`#8]{%
   \diagram[]
      {#1} & \rTo^{#5} & {#2} \\
      \dTo<{#6} & & \dTo>{#7} \\
      {#3} & \rTo^{#8} & {#4}
   \enddiagram}
\end{verbatim}\end{quote}
   and similarly \verb/\atriangle/, \verb/\btriangle/, \verb/\dtriangle/,
   \verb/\ptriangle/, \verb/\qtriangle/, \verb/\Atriangle/, \verb/\Ctriangle/,
   \verb/\Driangle/, \verb/\Vriangle/,
   \verb/\Arianglepair/, \verb/\Vrianglepair/ and  \verb/\recurse/,
   which are easy exercises.%
\ixcmd\atriangle\ixcmd\btriangle\ixcmd\dtriangle\ixcmd\ptriangle
\ixcmd\qtriangle\ixcmd\Atriangle\ixcmd\Ctriangle\ixcmd\Driangle
\ixcmd\Vriangle\ixcmd\Arianglepair\ixcmd\Vrianglepair\ixcmd\recurse

\bigskip
\noindent{\bf \person{Karl}{Berry}}'s \verb/eplain/:\index{eplain.tex}
see Steven Smith below.

\bigskip
\noindent{\bf \person{Francis}{Borceux}}'s \verb/diagram/ package uses \LaTeX's
   \verb/picture/ environment\index{picture environment}
   instead of \TeX\ arrays, but since it is designed in an array fashion
   it can be interpreted.
   Instead of that file, use
\begin{quote}\begin{verbatim}
\input diagrams
\input Borceux-to-Taylor
\end{verbatim}\end{quote}
   This is available from the same place as (my) \verb/diagrams.tex/ itself.
   Currently the curved, free and multiple arrows
   are not implemented, and all size parameters are ignored.

\bigskip
\noindent{\bf \person{Eitan}{Gurari}}'s \verb/dratex/:\index{dratex}
I haven't looked in to this package yet.

\bigskip
\noindent{\bf Donald Knuth}'s Exercise 18.46:
   see section~\ref{18.46} of this manual.
   
%\bigskip
%\noindent{\bf J\"urgen Koslowski}: I haven't looked in to this package yet.

\bigskip
\noindent{\bf \person{Frank}{Mittelbach}}'s  \AMSLaTeX\space \verb/amscd.sty/:
see Michael Spivak below.

\bigskip
\noindent{\bf \person{John}{Reynolds}}:
I haven't looked in to this package yet.

\bigskip
\noindent{\bf \person{Kris}{Rose}}'s \XYpic\ixprotect\XYpic\
   uses a different convention for
   where to declare arrows, namely in the cells with their sources.
   This convention will be supported in the next release.
   The syntax of Rose's arrow commands is also more complicated.
   I~do not intend to support his fonts or turning commands.

\bigskip
\noindent{\bf \person{Rainer}{Sch\"opf}}'s  \AMSLaTeX\space \verb/amscd.sty/:
see Michael Spivak below.

\bigskip
\noindent{\bf \person{Steven}{Smith}}: I haven't looked in to this package yet.

\bigskip
\noindent{\bf \person{Michael}{Spivak}}'s \LAMSTeX:\ixprotect\LAMSTeX
similar comments apply here as  to Kris Rose's package.

\bigskip\noindent{\bf Michael Spivak}'s \AmSTeX\space\ixprotect\AmSTeX
   (as described in {\em The Joy of \TeX\/})%
   \index{joy@{\em The Joy of \protect\TeX}}
   had some very primitive commutative diagrams,\ixcmd\CD\ixcmd\endCD
   enclosed in \verb/\CD...\endCD/.
   \iffalse
   Horizontal arrows were drawn with the commands
   \verb/@</$f$\verb/</$g$/\verb/</ or \verb/@(/$f$\verb/(/$g$/\verb/(/
   and \verb/@>/$f$\verb/>/$g$/\verb/>/ or \verb/@)/$f$\verb/)/$g$/\verb/)/,
   where $f$ and $g$ are the upper and lower labels.
   Vertical arrows used
   \verb/@A/$f$\verb/A/$g$/\verb/A/ and \verb/@V/$f$\verb/V/$g$/\verb/V/
   where $f$ and $g$ are the left and right labels.
   These arrows were only as long as their labels.
   A~long equals without labels could be drawn with % ??? \verb/@-/,
   \verb/@=/ and \verb/@|/ or \verb/@\vert/.  % ?? \verb/@\|/ and \verb/@\Vert/
   for single and double lines.
   \fi

   You can obtain a dramatic improvement in these diagrams without changing
   the text of your document by using my package with the \verb/amstex/ option.
   Given a (complete, correct) \AmSTeX\ document, change the header to read
   \begin{quote}\begin{verbatim}
        \input amstex
        \input diagrams
        \diagramstyle[amstex]
   \end{verbatim}\end{quote}
   \vskip-2ex
   If~\AmSTeX\space or \AMSLaTeX\space (\verb/amscd.sty/) had been loaded,
   this will replace the definitions.\ixprotect\AMSLaTeX\index{amscd.sty}

   You can also include \AmSTeX\space diagrams extracted from old papers
   in new \verb/plain/ \TeX\ or \LaTeX\ documents. In~this case,
   do not load \AmSTeX\ (unless you want it for some other reason)
   but instead use
   \begin{quote}\begin{verbatim}
        \input diagrams
        \def\CD{\diagram[amstex]}
   \end{verbatim}\end{quote}
   \vskip-2ex
   to confine the changes to the meaning of the \verb/@/ character to the
   diagrams themselves.
   The in-line horizontal arrows will then not be interpreted.

\bigskip
\noindent{\bf \person{Timothy}{van Zandt}}'s \verb/pstricks/:\index{pstricks}
I haven't looked in to this package yet.

%=========================================================================
\section{Frequently asked questions}\label{faq}
\noindent{\bf Wouldn't it be better to draw it with a mouse?} No.%
\index{mouse}\index{wysiwyg}

\bigskip\noindent{\bf How do I get it?}
See section~\ref{get}.

\bigbreak\noindent{\bf Is it compatible with ...?}\index{compatibility}
From 1986 until after version~3 of this package was announced in July~1990
I~used \verb/plain/ \TeX,\index{plain \protect\TeX}
whilst giving assistance to colleagues who used \LaTeX. \ixprotect\LaTeX
In~December 1991 the local \TeX\ system was converted to use
\person{Frank}{Mittelbach} and \person{Rainer}{Sch\"opf}'s font selection
(NFSS1)\index{NFSS} for \LaTeX.
Now we use \LaTeXe\ixprotect\LaTeXe, which includes NFSS2.

Consequently there is a great deal of collective experience in using the
diagrams package in all of these environments. I~do not have experience
of \AmSTeX, \AMSLaTeX, \verb/eplain/ or commercial \TeX\ packages, but
do not know of any reason why it should not work with them:
please tell me if you find any difficulties.

It is, regrettably, not uncommon for publishers to copy parts of
\LaTeX\ and {\tt\ix{article.sty}}
into their own journal and conference styles,%
\index{journals}\index{conference proceedings}
and not keep these up to date with respect to bug-fixes and other changes.
Many of the bug reports which I~receive in connection with the diagrams
package are in fact traceable to errors of this kind in publishers' styles.
My~policy is that I~will no longer fix bugs in software from commercial
organisations for free, but suggest some consultancy arrangement.
If, however, it is possible to make the package more robust and circumvent
such bugs in other software then I~will do this.

\person{Richard}{Stallman}'s \verb/texinfo/\index{texinfo.tex}
is designed for documenting other software,
in which \TeX's special characters often have important meanings.
For this reason many of the \verb/\catcode/s \ixcmd\catcode
have been changed, and in
particular \verb/@/ is used where \TeX\ uses \verb/\/.
The usual \TeX\ meanings are restored within \verb/@tex..\Etex/.
It~is possible to load this package without this, but you must do
\begin{quote}\begin{verbatim}
@catcode`@\=0 \catcode`\%=14 \input diagrams \catcode`\%=12 \catcode`\\=13
\end{verbatim}\end{quote}
You must also do \verb/@catcode`@&=4/ before using \verb/@diagram/.
Braces \verb/{}/ stay the same.

Unfortunately the package does not seem to work with TeX-XeT,
the extension to \TeX\ for typesetting Arabic and Hebrew.
I~believe this problem is insuperable.

\bigbreak\noindent{\bf Does it use any special \ix{fonts}?} No.
One of the design
criteria of the package is that all of the components come from the standard
\ix{Computer Modern fonts} that come with \TeX,
except that the diagonal arrowhead characters come from \LaTeX's
\verb/line10/ font.\index{line10 and linew10 fonts}
As~one user said,
\begin{quote}
``I agree with you in being against the use of additional  fonts.
It takes some time and experience to port, say, 
\LAMSTeX\ixprotect\LAMSTeX\space fonts to [my `personal' computer].
I would much prefer embedded {\sc PostScript} commands.\index{PostScript}
Custom \ix{DVI} drivers such as \verb/xdvi/,\index{xdvi} on the other hand,
are not widely available, at  least not for [my computer].''
\end{quote}
There are {\em optional\/} arrowheads from the \ix{AMS symbols fonts},
which were
\ifx\twoheadrightarrow\undefined not available\else used\fi\space
when this copy of the manual was printed. They may be obtained by anonymous
\ix{FTP} from \verb/e-math.ams.com/.\index{anonymous FTP}

It is sometimes claimed that it is advantageous to have specially designed
fonts in order to ensure that the components match up correctly.
However the reason why they frequently do not is pixel-rounding,
{\em even when the DVI-driver does this correctly according to the rules
specified by \person{Donald}{Knuth}}.\index{pixel size}%
   \footnote{If you don't believe me, calculate for yourself which pixels
   are inked when a 0.4pt-wide rule is centered on the maths axis of
   {\tt cmmi10} (2.5pt above the baseline) at 300dpi (1~point~=~4.15~pixels),
   and compare this with characters such as $\greaterthan$ in the output of
   {\tt gftype -i cmmi10.300gf}. The character $\succ$ in {\tt cmsy} is
   one pixel lower than this.}
The \verb/dpi/ option has been included to correct for this.\index{dpi}

If you have other arrowhead fonts available, such as those provided by
\person{Kris}{Rose} for \XYpic\ixprotect\XYpic\
and \person{Michael}{Spivak} for \LAMSTeX,\ixprotect\LAMSTeX\
you may use them if you write your own \verb/\newarrowhead/ commands.%
\ixcmd\newarrowhead

\bigbreak\noindent{\bf Corruption by \ix{electronic mail}.}\index{corruption}
If you cannot use FTP and the route to you by electronic mail passes
through non-\ix{ASCII} machines (such as through \ix{BITNET}),
the file may suffer corruption.\index{EBCDIC}
This doesn't matter very much with the manual, but the macro
package itself has a list of characters at the top, and use of most of those
which experience has shown to be vulnerable has been confined to the first
section, wherever possible. Search for the word ASCII if in doubt.

\bigbreak\noindent{\bf \TeX\ capacity exceeded.}
\TeX\ was designed in the early 1980s, when RAM was measured in kilobytes,
and does not have \ix{dynamic memory allocation}.
Although \verb/tex.web/\index{tex.web}
says loudly ``Don't Touch!'', the compile-time
parameters listed on page 300 of {\it The \TeX book\/} {\em are\/} meant to be
changeable, and \person{Donald}{Knuth} provided a mechanism
(\verb/tex.ch/) for doing so.
\person{Karl}{Berry}'s widely used \verb/web-to-C/\index{web-to-C}
{\sc Unix}\index{Unix} port of \TeX\
increases them substantially --- in accordance with the \ix{RAM} available in
1990s hardware and that needed by 1990s software. There is nothing
{\sc Unix}-specific about these changes: they can just as well be made in
any other compilation environment.
Currently it seems Oz\TeX\index{oztex@Oz\protect\TeX} has not made
the changes --- please complain about this to its author,
\person{Andrew}{Trevorrow}, not~me.

The increase in size over version~3 is largely due to the diagnostics,
{\em i.e.} helping you to use the package!\index{error recovery}

If you get ``no room for another \verb/\dimen/'' \ixcmd\dimen
it probably means you're using \PiCTeX\ixprotect\PiCTeX,
which uses 110 out of the available~256; I~use~20.

The process of stretching the arrows in a completed diagram is quite slow,
but at least in this package \TeX\ spends the time doing something useful
rather than parsing (\LaTeX\ \verb/picture/)\index{picture environment}
\verb/\put/ commands inside macros.
The emulation of \person{Francis}{Borceux}'s macros, for instance,
is 50\% faster than the original.
\person{Kris}{Rose}'s \XYpic\ixprotect\XYpic\ takes about six times
as long to draw the same diagram.

\bigbreak\noindent{\bf Default \ix{arrowheads}.} Even when you define your own
arrows with special arrowheads, you still get get \LaTeX\ heads on diagonals.
This is because \LaTeX\ heads are available in a variety of directions,
but your special ones are only defined for up, down, left and right.
To~get special heads on diagonals, it is necessary to rotate them, and to
do that you need the \verb/PostScript/ option.%
\index{diagonal arrows}\index{PostScript}

\bigbreak\noindent{\bf Display options.} If, as was advised in earlier versions
of this manual, you enclose the diagram in \verb/$$...$$/\ixcmd{$$}
or a \index{displaymath environment},
the new \ix{options} in section~\ref{options} for positioning it cannot work.
Except in those cases where you want two or more diagrams side by side,
or a small diagram in-line in the text, it is better to remove such
enclosings; then you can experiment with the options using
\verb/\diagramstyle/. \ixcmd\diagramstyle
\LaTeX's \verb/center/ environment is,\index{center environment}
for this purpose, {\em not\/} a display but a paragraph of text,
with some strange results if you use the \verb/textflow/ option;%
\index{text flow}
in this case you should use the \verb/inline/ option\index{in line}
on the individual diagrams to make them appear side by side.

\bigskip\noindent{\bf Large \ix{gaps} between diagonals and their endpoints.}
\index{PostScript}\index{diagonal arrows}
This happens if you try to use the default \verb/LaTeX/ line segments
to draw very steep or very shallow diagonals.
Try using the \verb/PostScript/ option.

By~default, the (rows and) columns of the matrix forming the diagram can
\ix{stretch} to accommodate long pieces of text as objects and arrow labels.
This is appropriate for rectangular diagrams and requires no user intervention.
If,~however, you have diagonals, this stretching causes them to fall short of
the objects to which they are meant to point, because currently they are
(unlike the horizontals and verticals) rigid.
\message{A message about "badly drawn diagonals" follows. It is deliberate.}%

\vskip-5ex
\begin{diagram}[loose,size=3em,notextflow,heads=LaTeX,noPS]
   A & \rTo^{\lessthan 1_A,0_A\greaterthan} & A\times N\\
   & \rdTo[fixed]_f&\dDotsto>h\\
   &&B
\end{diagram}
An example provided by a user is shown. The solution is to use options like
\begin{quote}
  \verb/\begin{diagram}[tight,width=4em,height=3em]/
\end{quote}
See section~\ref{options} for details.\index{tight}
Sometimes there isn't room on the page to increase the width sufficiently.
Try using the \verb/scriptlabels/ option, or, failing that, put the whole
diagram in the scope of a \LaTeX\ \verb/\small/ or even \verb/\tiny/
declaration.\ixcmd\small\ixcmd\tiny

This real-life example illustrates another common problem: the symbols
$\lessthan$ and $\greaterthan$ are {\em \ix{relations}\/}
$\langle$not~brackets$\rangle$ --- and it's not unusual to see line-breaks
the wrong side of them, even in published, supposedly proof-read, books.
If~you don't often use the strict arithmetical relations and find it a bore
to type \verb/\langle..\rangle/, put the following in your macro file:%
\ixcmd\langle\ixcmd\rangle\ixcmd{<}\ixcmd{>}\ixcmd\mathcode
\ixcmd\mathchardef
\begin{quote}\begin{verbatim}
\mathcode`\<="4268     % < = \langle
\mathcode`\>="5269     % > = \rangle
\mathchardef\gt="313E  % arithmetic
\mathchardef\lt="313C  % strict order
\end{verbatim}\end{quote}
\ixcmd\mbox
As another piece of general advice, many people use \verb/\mbox/ when it is
completely unnecessary. Amongst other things, it inhibits the reduction of
the contents when used as a sub- or superscript.
In~\LaTeXe, try using the \verb/\text/\ixcmd\text\ and
\verb/\ensuremath/\ixcmd\ensuremath\ commands.

%\bigskip\noindent{\bf Diagonals overprint or don't quite meet their
%endpoints.} I'm~sorry about this: it's because I~haven't got round to writing
%the code to stretch the diagonals in the same way as the horizontals and
%verticals. This will be done in the next release, because I~need it for my
%book.
%
%In~the case of poset diagrams, the \verb/[tight,abut]/ options should work
%satisfactorily.

\bigskip\noindent{\bf ``Badly drawn diagonals'' error message.}%
\index{badly drawn diagonals}\index{diagonal arrows}
This warning is given if (a)~you use diagonals which are set on the first
pass ({\em i.e.}~\LaTeX, \ix{TPIC} or \verb/fixed/\index{fixed}) {\em and\/}
(b)~some of the columns are significantly wider than was specified by
the \verb/width/ or \verb/size/ option.\index{width}\index{size}
It~indicates that the problem above, with big gaps at the ends of diagonals,
may have occurred.
Check this, and if necessary set the \verb/tight/ option and specify the
necessary (increased) \verb/width/ yourself.
Alternatively, use the \verb/PostScript/ option to get the diagonals
set on the second pass; then they will meet their endpoints.%
\index{PostScript}\index{width}\index{size}

\bigskip\noindent{\bf Labels on arrows \ix{over-print} objects or
\ix{arrowheads} become detached.}\index{labels}\index{decapitated arrows}
You're trying to squeeze too much into the column: increase
\verb/width/ (as it tells you to do). If~the object at one end is much
longer than that at the other, the \verb/midshaft/ option may be appropriate.%
\index{midshaft}\index{width}\index{size}

\bigskip\noindent{\bf Mixed or missing \ix{arrowheads}.}
The idea of providing the \verb/heads/\index{heads} option
is that you should specify at the beginning of your
document which style you want. The default is \verb/heads=LaTeX/ since this
provides consistency between orthogonal and diagonal arrowheads when rotation
is not available.

\bigskip\noindent{\bf Undefined symbols.}%
\index{undefined control sequence} To~use the curly and black
arrowheads you need the \ix{AMS symbols fonts};
if one of these (\verb/\curlyvee/, \verb/\blacktriangleleft/)%
\ixcmd\curlyvee\ixcmd\blacktriangleleft\ is undefined,
hit return several times to complete
the run of \TeX\ on your document, then go back and insert
       \ifx\usepackage\undefined
         \verb/\input mssymb/
       \else
         \verb/\usepackage{amssymb}/
       \fi
or change the heads declaration.\index{amssymb.sty}

If~you find a symbol with a \ix{meaningless name} like \verb/\CD@gF/
\ixcmd{\CD@gF} or
\verb/\cD@hA/ is undefined, it means that you have used internal macros
from a previous version of the diagrams package. Please remove them:
the names are deliberately meaningless to persuade you not to use them.

\bigbreak\noindent{\bf Can you put \ix{diagrams within diagrams}?}%
\index{nested diagrams}\ixcmd\pile\index{parallel arrows}
Yes, but it's not often that such things are needed. Remember that
\verb/\pile/ is used for parallel horizontals. Sometimes you may want an
array of diagrams.

During development I~found problems when the first cell of the inner
diagram was empty, and version 3.22 resulted in \TeX's elusive
``\ix{interwoven alignment preambles} are not allowed'' error
({\it The \TeX book}, page 299).\ixprotect{\TeX book}
Although I believe these bugs have now been fixed, this is a delicate area
and it is possible that others may arise.

\bigskip\noindent{\bf \verb/Missing \endcsname inserted./}\label{miss endcs}
\index{missing \protect\verb/\endcsname/}\ixcmd\endcsname\ixcmd\the
This can happen if a macro occurs within an option [in~square brackets].
In~general you must ensure that such macros expand to text characters only.
For example in \LaTeXe:\ixprotect\LaTeXe\ixcmd\usepackage
\begin{quote}
  \verb/\usepackage[flushleft=\mainindent]{diagrams}/
\end{quote}
where \verb/\mainindent/ is a \verb/\dimen/;
in this case \verb/\the\mainindent/ will work,
because \verb/\the/ expands the \verb/\dimen/ to its value
({\it\TeX book}, page 214).
Values for options to individual diagrams and arrows, or parsed by
\verb/\diagramstyle/ instead of \verb/\usepackage/, may safely contain
macros where appropriate.

\bigskip\noindent{\bf Horizontal arrows \ix{overprint} objects.}
\index{horizontal arrows}\ixcmd\hfill\ixcmd\hss\ixcmd\hspace\ixcmd\hidewidth
You must not use \verb/\hfill/, \verb/\hss/, \verb/\hspace/,
\verb/\hidewidth/ or other similar commands to try to
alter the effective size of the object.

\index{bug reports}
\bigskip\noindent{\bf What if it still doesn't work?} If you have a problem
which is not answered by this manual, please compile a {\em short\/} file
containing your problem diagram and any macros (such as \verb/\Assl/ in
section~\ref{typing}) it contains. Run it through \verb/tex/ or \verb/latex/
to check that no definitions are missing, and include a note of the date
and version number which you are using. Then send it by {\em electronic\/}
mail: please do not use the telephone or postal mail.

\ixcmd\scrollmode\index{error recovery}
I am keen to know about any adverse interactions with other software,
anything which is not well explained in this manual, or any cases of
mis-typing in which \verb/\scrollmode/ does not get to the end of the
document because of a diagrams error.

% automatic floats
% picture-mode inserts for braids, etc

%=========================================================================
\section{Conditions of use}\index{conditions of use}\index{copyright}
You may freely copy and pass on this package and include it in collections
of free software, but may not alter it or charge a fee for it.

\index{registration as a user}
Please ensure that you are registered with me as a user, so that you can be
informed of new versions. Any \ix{electronic mail} message containing the words
``commutative'' or ``diagram'' automatically registers you, as does quoting
your electronic mail address when fetching it by~\ix{FTP} from
\verb/ftp.dcs.qmw.ac.uk/.

\index{acknowledgement}
If you consider this package good enough to use, then it is good enough to
acknowledge.  After all, it is academic protocol to credit prior or
simultaneous discovery of techniques related to your own, even if you were
unaware of them or did not rely on them when you made your own discovery.
Such acknowledgement is a condition of use of this package.
However this condition is waived if use amounts to no more than five diagrams,
each of which is either a square or a triangle.
This acknowledgement must, of course, be removed if the document is re-typeset
by methods which do not use this package.

No permission was in the past given to use this package for
commercial purposes.\index{commercial use}
This includes a document whose copyright is seded by the author (for valuable
consideration or not) to another person or body which subsequently intends to
collect \ix{royalties} for its reproduction.
This applies to certain journals and conference proceedings.
Permission is now granted for its use for the production of academic
research and \ix{textbooks}, \ix{journals} and \ix{conference proceedings},
subject to the conditions that
\begin{itemize}
\item acknowledgement be given as above,
\item an up-to-date version of the package be used for the final production,
\item and one copy of the book be sent to me on publication in lieu of royalty,
  at the above address.
\end{itemize}
Use by commercial organisations is considered (for this purpose) to be
academic if the results are intended for publication in an academic forum,
concern pure research and do not relate to any particular commercial product.

The software may not be used for any military purpose under any circumstances.%
\index{military use}

No \ix{warranty} is given with this software.
It is supplied ``\ix{as is}'', and neither the source nor this manual
nor anything else shall be taken as a \ix{representation}
that it will perform any particular function, is suitable for any particular
purpose or is of \ix{merchantable quality}.
In executing the software, the user implicitly accepts the above conditions
and indemnifies\index{indemnification} the author,
\ix{Queen Mary and Westfield College}
and any person through whom the software was obtained, against
\ix{liability} for direct or consequential \ix{damages}
arising from the use of this software.

{\em Whenever\/} you use computers you {\em must\/} keep at least two
back-up copies of all of your files, with one of them well away from the
machine, in case of fire or major failure.
Before sending any documents for publication or to an expendive printer
make a thorough visual check using a previewer such as \verb/xdvi/\index{xdvi}
and a low resolution printer.

%=========================================================================
\section{Reverse compatibility}\index{compatibility}
Compatibility with past and future versions (the numbers of some of which have
been assigned {\em post facto\/}) is as follows. Note the difference between
``should'' and ``must''.

\begin{description}
\item[Version 0:] See section~\ref{18.46}.
\item[Version 1:] Horizontal arrows made to stretch to edge of cell; 1987--9.
        \begin{itemize}
        \item \verb/\rTo{f}{g}/ works, but \verb/\rTo f g/ doesn't: it must
                be changed to \verb/\rTo^f_g/.
        \item the \verb/\mkern-20mu\rTo{f}{g}\mkern-20mu/ idiom for manual
                stretching of horizontal arrows to meet objects must be
                removed.\ixcmd\mkern
        \item \verb/\VerticalMapHeight/ and \verb/\VerticalMapDepth/ commands
                are obsolete and are ignored: they should be removed.%
                \ixcmd\VerticalMapHeight\ixcmd\VerticalMapDepth
        \item Three- or four-argument uses of \verb/\HorizontalMap/,
                \verb/\VerticalMap/ and \verb/\DiagonalMap/ must be
                changed to five-argument uses or, preferably, to
                \verb/\newarrow/.%
                \ixcmd\HorizontalMap\ixcmd\VerticalMap\ixcmd\DiagonalMap
        \item Nested \verb/\commdiag/ commands for parallel maps must be
                changed to \verb/\pile/.\ixcmd\commdiag\ixcmd\pile
                \index{nested diagrams}\index{parallel arrows}
        \item Parallel maps constructed by putting them in the rows or columns
                before and after must be moved to the correct cell and
                (in the case of horizontals) put in a \verb/\pile/.
        \end{itemize}
\item[Version 2:] Horizontal arrows made to stretch to meet objects and
``\ix{superscript}'' labels introduced;  versions with banners
dated September to December 1989.
        \begin{itemize}
        \item \verb/&\rTo\across3&/ now works more accurately than in
                version~3, but should be changed to \verb/&&\rTo&&/.%
                \ixcmd\across
        \item {\raggedright The parameters \verb/\HorizontalMapLength/,
                \verb/\VerticalMapHeight/, \verb/\VerticalMapDepth/,
                \verb/\VerticalMapExtraHeight/, \verb/\VerticalMapExtraDepth/
                and \verb/\DiagonalLineSegments/ are obsolete and are ignored:
                they should be removed.\par}%
                \ixcmd\HorizontalMapLength\ixcmd\VerticalMapHeight
                \ixcmd\VerticalMapExtraDepth\ixcmd\DiagonalLineSegments
                \ixcmd\VerticalMapDepth\ixcmd\VerticalMapExtraHeight
        \item The \ix{labels} on southeast and northwest \ix{diagonal arrows}
                have changed their position.
                \verb/^/~and \verb/_/\ixcmd{^}\ixcmd{_} previously meant
                left and right respectively for diagonals; they now mean ---
                more logically --- above and below; \verb/</ and \verb/>/ are
                used for left and right, respectively. Unqualified labels
                are positioned as they originally were: the first above and
                the second below.
        \item Diagonal lines are constructed differently; user-defined
                \ix{diagonal arrows} should be replaced with \verb/\ruTo(2,4)/ 
                {\em etc.,} and explicit movement of them removed.
        \item Bent lines, with \verb/\dlBent/ and \verb/\ruBentto/, currently
                do not work. Instead \verb/\HmeetV/ must be
                placed at the corner. Bent or half arrows will be reintroduced
                later but with a different naming convention.%
                \index{bent lines}\ixcmd\dlBent\ixcmd\ruBentto\ixcmd\HmeetV
        \end{itemize}
\item[Version 3:] Vertical maps also made to stretch to meet objects; widely
circulated with banners dated July 1990 to April 1992.
        \begin{itemize}
        \item \verb/\HorizontalMap/, \verb/\VerticalMap/ and 
                \verb/\DiagonalMap/ should be replaced by \verb/\newarrow/
                declarations.%
                \ixcmd\HorizontalMap\ixcmd\VerticalMap\ixcmd\DiagonalMap
        \item Negative spacing around \ix{wide objects} (used to avoid the
                stretching of the diagram which they caused) should be
                removed, and the \verb/tight/ option used instead.
                This is because objects are now allowed to extend into the
                neighbouring columns, with a check that there is enough space.
        \item Enclosing \verb/$$...$$/ or display environments should be
                removed, as they prevent the new display positioning options
                from working.\ixcmd{$$}\index{display options}
        \item Diagonal arrows with ``\ix{compass}'' names,
                particularly the ones from \verb/extra-diagonals.tex/
                \index{extra-diagonals.tex}\index{diagonal arrows}
                (which must not be used any more),
                should be changed to the new geometrical names.
        \item The command names \verb/\lt/ and \verb/\gt/ (for $\lessthan$ and
                $\greaterthan$) have been removed, at the request of a user
                who considered these to be unreasonable names for internal
                commands.\ixcmd\lt\ixcmd\gt\ixcmd{>}\ixcmd{<}%
                \ixcmd\greaterthan\ixcmd\lessthan
        \item The arrow commands with names like \verb/\rArr/ and \verb/\rTo/
                now all use the default \ix{arrowheads}; the original behaviour
               (\verb/\rArr/ used \verb/LaTeX/ and \verb/\rTo/ used \verb/vee/)
               may be restored by changing a switch \verb/\iffalse/ in the
               final section of the source.\ixcmd\rArr\index{vee arrowheads}%
               \ixprotect{\LaTeX\ arrowheads}
        \end{itemize}
\item[Version 4:] Advertised in September 1992.
        \begin{itemize}
        \item The default arrowhead has been changed from \verb/vee/ to
               \verb/LaTeX/ to ensure consistency if \verb/PostScript/
               is not used.\index{arrowheads}
        \item Explicit movement of \ix{diagonal arrows} vertically using
               \verb/\raise/, \verb/\lower/ or \verb/\raisebox/
               \ixcmd\raise\ixcmd\lower\ixcmd\raisebox
               or horizontally by spacing commands or otherwise
               will not work for the diagonals which are adjusted to meet
               their endpoints.\index{stretch}
               For the time being use either of the options
               \verb/noPS/ or \verb/fixed/\index{PostScript}\index{fixed}
               to suppress adjustment.
               A~new option \verb/crab/\index{crab} will be introduced
               shortly to allow \ix{sideways movement of arrows}.
        \end{itemize}
\item[Future:] The following are high on the agenda:
  \begin{itemize}
  \item Placing of labels at the head and tail of arrows.
  \item Curved arrows (\verb/PostScript/ only).
  \item Sideways movement of arrows.
  \item An~alternative way of specifying the positions of arrows,
    namely at the tail with signed relative co-ordinates for
    the head, to allow emulation of
    \person{Kris}{Rose}'s \XYpic\ixprotect\XYpic\ and
    \person{Michael}{Spivak}'s \LAMSTeX\ixprotect\LAMSTeX.
  \item Shifting objects, by specifying the left or right width.
  \item Option to rotate labels on diagonals or leave them horizontal.
  \item Application to electronic circuit diagrams.
  \end{itemize}
\end{description}

Suggestions for improvements and further applications ({\em e.g.\/} proof nets,
Petri nets and circuit diagrams) are welcome.

%==========================================================================

\section{Availability}\label{get}


The diagram package is currently available as a single
112kb\footnote{Without comments; the development version is about 300kb.}
printable \TeX\ source file which is compatible with both \LaTeX\
and {\tt plain} \TeX. It loads the \LaTeX\ {\tt line10} font as \verb/\tenln/
(its \LaTeX\ name) and also defines some (exotic) arrow commands in terms
the AMS symbols, but if these are to be used then the
       \ifx\usepackage\undefined
         file \verb/mssymb/
       \else
         package \verb/amssymb/
       \fi
must be loaded separately.

\index{anonymous FTP}
It~is easiest to get this package by anonymous \ix{FTP}.
This stands for ``\ix{file transfer protocol}'';
it is a way in which you can log on interactively to my computer and fetch
(some of) my files. A~very large amount of software is now freely available
by this method, so it is well worth putting pressure on your system
administrator to get your machines connected.

The authoritative version of the package may be found at the FTP address
\begin{quote}
{\tt ftp://ftp.dcs.qmw.ac.uk/pub/tex/contrib/pt/diagrams}
\end{quote}
It may also be obtained from the \ix{Comprehensive \TeX\ Archive Network}
(\ix{CTAN)} at any of the sites
\begin{quote}
  \begin{tabular}{llll}
  ftp.adfa.oz.au &Australia&            /pub/tex/ctan\\
  ftp.cs.rmit.edu.au  &Australia&       /tex-archive\\
  ftp.muni.cz &Czech Republic&      /pub/tex/CTAN\\
  ftp.tex.ac.uk &England& /tex-archive\\% (/pub/tex /pub/archive)\\
  ftp.loria.fr &France&                 /pub/unix/tex/ctan\\
  ftp.uni-bielefeld.de &Germany&        /pub/tex\\
  ftp.uni-stuttgart.de &Germany&        /tex-archive (/pub/tex)\\
  ftp.dante.de  &Germany&         /tex-archive\\% (/pub/tex /pub/archive)\\
  ftp.center.osaka-u.ac.jp &Japan&      /CTAN\\
  wuarchive.wustl.edu &Missouri, USA&   /packages/TeX\\
  ftp.cs.ruu.nl &Netherlands&       /pub/tex-archive\\
  ftp.duke.edu &North Carolina, USA&    /tex-archive\\
  sunsite.unc.edu &North Carolina, USA& /pub/packages/TeX\\
  ftpserver.nus.sg &Singapore&          /pub/zi/TeX\\
  nic.switch.ch &Switzerland&           /mirror/tex\\
  dongpo.math.ncu.edu.tw &Taiwan&       /tex-archive\\
  ftp.uu.net &Virginia, USA&            /pub/text-processing/TeX\\
  ftp.shsu.edu  &Texas, USA& /tex-archive\\% (/pub/tex /pub/archive)\\
  \end{tabular}
\end{quote}
where the root of the archive is the given directory and my package is
\begin{quote}
  {\tt macros/generic/diagrams/Taylor/diagrams.tex}
\end{quote}
relative to this.

The ``\verb/archie/''\index{archie} utility is extremely useful as a way
of locating software and other information on the \ix{Internet}.
You just give it (part of) the name of the file you want
({\em e.g.}~``diagram'') and it will tell you where files of that name
are located in numerous public \ix{FTP} archives around the world.
Beware, however, that many of them are just ``\ix{magpies' nests}'' ---
they collect things from other places without verifying their
authenticity or keeping them up to date.\index{anonymous FTP}

If you are unable to use FTP it is possible to get the package
(and indeed anything you can get by ftp) by electronic mail.
I~do not recommend this method, because it is susceptible to
corruption, and you have to concatenate the files and remove the
mail headers. Send the following message to
\verb/<ftpmail@doc.ic.ac.uk>/:
\begin{quote}
\begin{verbatim}
open ftp.dcs.qmw.ac.uk
cd pub/tex/pt/diagrams
get diagrams-V4-news
get diagrams.tex
get diagrams-manual.tex
quit
\end{verbatim}
\end{quote}
You will get an acknowledgement message first, followed by the files,
and finally a job log file.
The files may be split up into several messages.
%in which case the \verb/Subject:/
%lines will begin \verb/[part /$n$\verb/ of /$m$\verb/]/.
%
\iffalse Other availability information will be added later, after checking.
Also available from
archive.cs.ruu.nl [131.211.80.17] /pub/TEX/DIAGRAM/diagrams.tex
%
Other \TeX\ FTP sources:
e-math.ams.com [130.44.1.100] for AMS symbols and AMS-\LaTeX.
ftp.cs.umb.edu [192.12.26.23] for Karl Berry's web-to-C \TeX\ port.
\fi

\makeatletter\pt@input{manual.ind}{}{}
%============================================================================
\end{document} 

% Ideas for future editions of this manual:

% Use bezier.sty and the origin option in a picture environment to draw
% braids on top of a diagram - Robert Seely had an example.

% I haven't composed the example yet.
%\newif\ifHaveBezier\HaveBeziertrue
%\pt@input{bezier.sty}%
%{^^JYou don't have bezier.sty. That's a pity, because I wanted to show you an
%^^Jexample of drawing curved lines on top of a diagram. We'll do without it.}%
%\HaveBezierfalse

% Use \matrix or array environment to put long objects on two lines within
% a diagram. LFPP.tex has a suitable example.

% Commutative diagram of posets. Example in my thesis (fig 2.2.13) (5.2.2)

% new sections:
%   other TeX macros of mine
%   resource usage
%   list of errors
%   how to draw {\em nice\/} diagrams

% FTP instructions