summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/source/latex/sseq/sseq.dtx
blob: dbc22b65f953756f78c16af637a7a162791ed349 (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
%
% ^^A This is file sseq.dtx. First LaTeX the accompanying file sseq.ins
% ^^A to produce the package file sseq.sty.
% ^^A Then LaTeX this file to produce the documentation of the sseq package.
% ^^A
% ^^A (c) 2003 Tilman Bauer. Freely distributable under the LaTeX Project Public License (LPPL)
% ^^A
% \iffalse
%<*never>
\documentclass{ltxdoc}
\usepackage[dvips]{sseq}
\begin{document}
\DocInput{sseq.dtx}
\end{document}
%</never>
% \fi

% 
% \changes{v1.0}{November 12, 2003}{First release of code and documentation}
% \changes{v1.01}{November 15, 2003}{Bug fix with clipping after a ssgoto}
% \changes{v1.02}{November 18, 2003}{Bug fix that would mess up page numbering in some cases}
% \changes{v1.03}{December 11, 2003}{Added examples to documentation, bug fix in grid drawing}
%
% \iffalse
%<*package>
\NeedsTeXFormat{LaTeX2e}

\ProvidesPackage{sseq}

\RequirePackage{ifthen,calc,pifont}

\newboolean{usesps}
\setboolean{usesps}{true}
\newboolean{usescolor}
\setboolean{usescolor}{true}
\newboolean{debug}
\setboolean{debug}{false}

\DeclareOption{ps}{\setboolean{usesps}{true}}
\DeclareOption{nops}{\setboolean{usesps}{false}}
\DeclareOption{color}{\setboolean{usescolor}{true}}
\DeclareOption{nocolor}{\setboolean{usescolor}{false}}
\DeclareOption{debug}{\setboolean{debug}{true}}
\DeclareOption*{\PassOptionsToPackage{\CurrentOption}{xy}}

\ProcessOptions

\ifx\xyloaded\undefined \RequirePackage[curve,frame]{xy} \fi

\ifthenelse{\boolean{usesps}}{\xyrequire{ps}}{}
\ifthenelse{\boolean{usescolor}}{\xyrequire{color}}{}


%</package>
% \fi
%
% \title{Typesetting spectral sequences in \LaTeX\ with sseq.sty}
% \author{Tilman Bauer\footnote{tbauer@math.uni-muenster.de}}
% \date{November 12, 2003}
%
% \MakeShortVerb{\|}
% \maketitle
%
% \section{Introduction}
%
% The present package, \texttt{sseq}, facilitates the typesetting of mathematical objects called \emph{spectral sequence charts} (henceforth simply called ``chart''). From a typographical point of view, a chart is a two-dimensional grid with integer coordinates; at every position (x,y), there may be any number of symbols (usually dots, little circles or boxes, digits etc.), possibly decorated with labels, and between any two such symbols may or may not be a connection---e.~g., a line, an arrow, or some curved line.
%
% The \texttt{sseq} package is built on top of the \Xy-pic package by K.~H.~Rose and R.~Moore. It shares the disadvantage of using up lots of \TeX's memory; therefore, if your system provides a \texttt{biglatex} or \texttt{hugelatex} command, it is wise to use it when using \texttt{sseq}. Still, problems may arise with very large charts (i.e., more than $100\times100$).
%
% This package automates the following functions and thereby offers an improvement over pure \Xy-pic graphics:
%
% \begin{itemize}
% \item Automatic drawing of the grid and the axis labels;
% \item Clipping. Anything outside the displayed portion of the chart is clipped away. This has the advantage that a large chart, which does not fit on a page, can be cut into smaller pieces which contain exactly the same \texttt{sseq} code, but different clipping regions.
% \item Arranging. Multiple symbols dropped at the same integer coordinates will be automatically arranged so that they usually do not overlap. The algorithm for doing this is rather primitive, but still powerful enough for most applications
% \item Simplified ``turtle graphics'' syntax. Every primitive element of a chart is typeset with a macro defined by \texttt{sseq}; no cryptic command lines like in \Xy-pic.
% \item More flexibility. Control structures (loops, if/then, etc.) are allowed inside the \texttt{sseq} environment.
% \end{itemize}
%
%
% \section{Global options}
%
% The |sseq| package is loaded with
%
% |\usepackage[|\emph{options...}|]{sseq}|.
%
% The following options are defined:
%
% \begin{itemize}
% \item |nops| will tell \Xy-pic not to generate PostScript code but to use special \TeX fonts to typeset the diagrams. This is preferable if you do not have a PostScript printer; however, the overhead in memory and time usage is so enormous that this should only serve as a last resort against incompatibilities
% \item |nocolor| will tell |sseq| not to generate any color information. This includes gray shades. Many |dvi| drivers do not support color, but most of them tolerate (i.e. ignore) the color directives.
% \item |debug| will typeout the \Xy-pic code generated by every |sseq| environment and wait for the user to confirm.
% \item any other options are fed into \Xy-pic. Thus, for example, the option |dvips| will tell \Xy-pic to generate code for the |dvips| driver.
% \end{itemize}
%
%
% \section{Basic usage}
%
% A spectral sequence is typeset by the code
%
% |\begin{sseq}{x}{y}|
%
% \emph{(sseq commands...)}
%
% |\end{sseq}|
%
% Here |x| and |y| are nonnegative integers specifying the size of the grid. By default, the bottom left corner of the chart will have coordinates $(0,0)$; however, this can be changed by issung
%
% |\sseqxstart=|\emph{(starting x position)}
%
% |\sseqystart=|\emph{(starting y position)}
%
% By default, the size of one coordinate square is .4cm; this can be changed by
%
% |\sseqentrysize=|\emph{(new length)}
%
% Normally, all even labels are printed (for space reasons); this can be changed by
%
% |\sseqxstep=|\emph{(x-axis label step)}
%
% |\sseqystep=|\emph{(y-axis label step)}
%
% Setting these to $1$ will typeset every label; setting it to $n$ will typeset every $n$th label.
%
% All of the above have to be issued \textbf{before} the |\begin{sseq}| command. They remain valid for subsequent charts until changed again.
%
%
% \section{sseq commands}
%
% Inside an |sseq| environment there is defined a virtual cursor, which starts out at position $(0,0)$ (even if that position is not within the clipping region!). All drawing commands are relative to the current cursor position; this facilitates reusage of |sseq| code when a certain pattern has to be repeated, as is often the case in mathematical spectral sequences.
%
%
% ^^A Produce save boxes for the circled digits
% \ifthenelse{0=1}{
\newsavebox{\sseqcircledone}
\newsavebox{\sseqcircledtwo}
\newsavebox{\sseqcircledthree}
\newsavebox{\sseqcircledfour}
\newsavebox{\sseqcircledfive}
\newsavebox{\sseqcircledsix}
\newsavebox{\sseqcircledseven}
\newsavebox{\sseqcircledeight}
\newsavebox{\sseqcirclednine}
\sbox{\sseqcircledone}{\ding{192}}
\sbox{\sseqcircledtwo}{\ding{193}}
\sbox{\sseqcircledthree}{\ding{194}}
\sbox{\sseqcircledfour}{\ding{195}}
\sbox{\sseqcircledfive}{\ding{196}}
\sbox{\sseqcircledsix}{\ding{197}}
\sbox{\sseqcircledseven}{\ding{198}}
\sbox{\sseqcircledeight}{\ding{199}}
\sbox{\sseqcirclednine}{\ding{200}}
%
% 
\newboolean{sseqhasfinishedpos}
\setboolean{sseqhasfinishedpos}{true}
\newboolean{sseqhasopenconn}
\setboolean{sseqhasopenconn}{false}
\newboolean{sseqclip}
\setboolean{sseqclip}{true}
\newboolean{sseqprevclip}\setboolean{sseqprevclip}{false}
\newboolean{sseqcurrclip}\setboolean{sseqcurrclip}{false}

\def\sseqconncommand{}

\ifthenelse{\boolean{usescolor}}
{
 \newxyColor{sseqgr}{0.65}{gray}{}
 \newxycolor{ssred}{Red}
 \newxycolor{ssblack}{Black}
}{}
\newcommand{\ssconncolor}{ssblack}
\newcommand{\sslabelcolor}{ssblack}
\newcommand{\ssplacecolor}{ssblack}
\def\ssoldconncolor{ssblack}


%% ^^A Initialization
\newcount\sseqxstart \sseqxstart=0
\newcount\sseqystart \sseqystart=0
\newcount\sseqxstep \sseqxstep=2
\newcount\sseqystep \sseqystep=2
\newdimen\sseqentrysize \sseqentrysize=0.4cm
\newif\ifssclipped 

\newtoks\sseqcmdlist
\sseqcmdlist={}

\def\currprefix{}

\def\sseqcurrentname{}

\long\def\ntimes#1#2{
\ifnum#1>0
 #2
 \count0=#1
 \advance\count0 by -1
 \edef\tmpcnt{\the\count0}
 \ntimes{\tmpcnt}{#2}
\fi
}

\newif\ifforcondition

\long\def\for#1=#2\to#3\do#4\od{
#1=#2
\loop
\ifnum#1>#3\forconditionfalse\else\forconditiontrue\fi
\ifforcondition
 #4
 \advance #1 by 1
 \repeat
}

%
% ^^A \putxy will put a list of commands into the execution queue
%
\def\putxyq#1{\toks0={#1}%
 \edef\act{\noexpand\sseqcmdlist={\the\sseqcmdlist \the\toks0}}
 \act
}
\def\putxy#1{%
 \edef\act{\noexpand\sseqcmdlist={\the\sseqcmdlist #1}}
 \act
}

%
%
%
\def\sseqwritecolor#1{
\ifthenelse{\boolean{usescolor}}{
  \putxy {[#1]}
}{}
}
%
%
%

\def\sseqconcludeconnection{
\sseqconncommand
\setboolean{sseqhasopenconn}{false}
}

\def\dropvarname#1#2{\csname sseqdrop#1,#2\endcsname}

\def\ifuniquedrop#1#2{
\edef\tmpval{\dropvarname{#1}{#2}}
\expandafter\ifx\tmpval1
}

\def\ifnodrop#1#2{
\edef\tmpval{\dropvarname{#1}{#2}}
\expandafter\ifx\tmpval\relax
}

\def\ssdroperrormsg#1#2{
 \ifnodrop{#1}{#2}
  \PackageError{sseq}{cannot open position (#1,#2): nothing dropped yet}{You cannot draw any connection until you have drawn the source.}
 \else
  \PackageError{sseq}{cannot open position (#1,#2): multiple drops}{You cannot specify this position by coordinates. Instead, name it.}
 \fi
}

\def\ssopenposition#1#2{
\ifuniquedrop{#1}{#2}
 \def\sseqcurrentname{ss(#1,#2)1}
 \putxy{"\sseqcurrentname"}
\else \ssdroperrormsg{#1}{#2}
\fi
\setboolean{sseqhasfinishedpos}{false}
}

\newcommand{\ssassertsource}{
\ifthenelse{\boolean{sseqhasfinishedpos}}{
\ssopenposition{\the\sseqposx}{\the\sseqposy}
}
{}
}

\newcommand{\ssputsemicolon}{
\putxy{;}
\ifthenelse{\boolean{sseqcurrclip}}{
 \setboolean{sseqprevclip}{true}}{
 \setboolean{sseqprevclip}{false}}
}

\newcommand{\ssfinishpos}{
\ifthenelse{\boolean{sseqhasfinishedpos}}{}{
\setboolean{sseqhasfinishedpos}{true}
\ssputsemicolon
}
\ifthenelse{\boolean{sseqhasopenconn}}
{
  \ssopenposition{\the\sseqposx}{\the\sseqposy}
  \sseqconcludeconnection
  \ifthenelse{\boolean{sseqhasfinishedpos}}{}{
  \setboolean{sseqhasfinishedpos}{true}
  \ssputsemicolon}
}{}
}

\newcommand{\ssnewpos}{
\ssfinishpos
\setboolean{sseqhasfinishedpos}{false}
}

\def\ssifposinclippingregion#1#2{
  \ssclippedtrue
  \ifthenelse{\boolean{sseqclip}}{
   \ifnum#1<\sseqxstart \ssclippedfalse \fi
   \ifnum#1<\sseqxend \else \ssclippedfalse \fi
   \ifnum#2<\sseqystart \ssclippedfalse \fi
   \ifnum#2<\sseqyend \else \ssclippedfalse \fi
  }{}
  \ifssclipped
}

\def\sseqrearrange#1#2#3#4#5{
\dimen0 = \csname sseqcoordx<#1,#2>#3\endcsname
\dimen1 = \csname sseqcoordy<#1,#2>#3\endcsname
\advance\dimen0 by #4
\advance\dimen1 by #5
\expandafter\edef\csname sseqcoordx<#1,#2>#3\endcsname{\the\dimen0}
\expandafter\edef\csname sseqcoordy<#1,#2>#3\endcsname{\the\dimen1}
}

\def\sseqstacking#1#2#3{ % ^^A (xpos, ypos, number of previous drops)
 \dimen5=\sseqentrysize
 \divide\dimen5 by 4
 \dimen6=\dimen5
 \multiply\dimen6 by -1
%
 \count11=0
 \for\count10=1 \to #3 \do
  \if1\csname sseqwillmove<#1,#2>\the\count10 \endcsname
   \advance\count11 by 1
   \expandafter\count\the\count11=\count10
  \fi
 \od
 % ^^A Now count11 contains the number of previously dropped objects that have to be rearranged.
 \ifcase\count11
  % ^^A 0
  \PackageError{sseq}{This can't happen!}{Internal error. Contact the author.}
 \or % ^^A 1
  \sseqrearrange{#1}{#2}{\the\count1}{\the\dimen6}{\the\dimen5}
  \advance\sseqx by \dimen5
  \advance\sseqy by \dimen6
 \or % ^^A 2
  \sseqrearrange{#1}{#2}{\the\count2}{0pt}{\the\dimen5}
  \sseqrearrange{#1}{#2}{\the\count2}{0pt}{\the\dimen5}
  \advance\sseqy by \dimen6
 \or % ^^A 3
  \sseqrearrange{#1}{#2}{\the\count3}{\the\dimen6}{0pt}
  \advance\sseqx by \dimen5
 \else
  \PackageError{sseq}{Too many drops at (#1,#2)}{The sseq.sty algorithm can only place up to four independent drops in one position.}
 \fi
}

\newcommand{\ssplacespecial}[4]{
\ifthenelse{\boolean{sseqhasfinishedpos}}{}{
 \ssputsemicolon
}
\setboolean{sseqhasfinishedpos}{false}
%
%
\sseqx=\sseqentrysize
\multiply\sseqx \sseqxdir
\multiply\sseqx by #1
\advance\sseqx by \sseqhalfentry
\advance\sseqx by \sseqoffsetx
\advance\sseqx by \sseqoffx
%
\sseqy=\sseqentrysize
\multiply\sseqy \sseqydir
\multiply\sseqy by #2
\advance\sseqy by \sseqhalfentry
\advance\sseqy by \sseqoffsety
\advance\sseqy by \sseqoffy
%
\expandafter\def\expandafter\tmpname\expandafter{\csname sseqdrop#1,#2\endcsname}
%
\ifnodrop{#1}{#2}
\expandafter\def\tmpname{1}
\else
 \edef\setcnt{\noexpand\count0=\tmpname}
 \setcnt
 \sseqstacking{#1}{#2}{\tmpname}
 \advance\count0 by 1
 \expandafter\edef\tmpname{\the\count0}
\fi
\putxy{<\csname sseqcoordx<#1,#2>\tmpname\endcsname,\csname sseqcoordy<#1,#2>\tmpname \endcsname>}
\expandafter\edef\csname sseqcoordx<#1,#2>\tmpname\endcsname{\the\sseqx}
\expandafter\edef\csname sseqcoordy<#1,#2>\tmpname\endcsname{\the\sseqy}
\expandafter\def\csname sseqwillmove<#1,#2>\tmpname\endcsname{1}
%^^A \putxy{<\the\sseqx,\the\sseqy>}
\setboolean{sseqcurrclip}{true}
\ssifposinclippingregion{#1}{#2}
 \setboolean{sseqcurrclip}{false}
 \putxy{*#3}
 \sseqwritecolor{\ssplacecolor}
 \putxy{#4}
\fi
%
% ^^A now give it a unique name
%
\edef\sseqcurrentname{ss(#1,#2)\tmpname}
\putxy{="\sseqcurrentname"}
\ifthenelse{\boolean{sseqhasopenconn}}{\sseqconcludeconnection}{}
}

\newcommand{\ssplace}[3]{
\ssplacespecial{#1}{#2}{}{{#3}}
}

\newcommand{\ssplaceboxed}[3]{
 \ifthenelse{\boolean{usescolor}}{
   \ssplacespecial{#1}{#2}{+<2pt>[F:\ssplacecolor]}{{#3}}
 }{
   \ssplacespecial{#1}{#2}{+<2pt>}{{#3}}
 }
}

\newcommand{\ssplacecircled}[3]{
\ifthenelse{\equal{#3}{1}}{
 \ssplacespecial{#1}{#2}{}{[o]{\copy\sseqcircledone}}}{
 \ifthenelse{\equal{#3}{2}}{
  \ssplacespecial{#1}{#2}{}{[o]{\copy\sseqcircledtwo}}}{
  \ifthenelse{\equal{#3}{3}}{
   \ssplacespecial{#1}{#2}{}{[o]{\copy\sseqcircledthree}}}{
   \ifthenelse{\equal{#3}{4}}{
    \ssplacespecial{#1}{#2}{}{[o]{\copy\sseqcircledfour}}}{
    \ifthenelse{\equal{#3}{5}}{
     \ssplacespecial{#1}{#2}{}{[o]{\copy\sseqcircledfive}}}{
     \ifthenelse{\equal{#3}{6}}{
      \ssplacespecial{#1}{#2}{}{[o]{\copy\sseqcircledsix}}}{
      \ifthenelse{\equal{#3}{7}}{
       \ssplacespecial{#1}{#2}{}{[o]{\copy\sseqcircledseven}}}{
       \ifthenelse{\equal{#3}{8}}{
        \ssplacespecial{#1}{#2}{}{[o]{\copy\sseqcircledeight}}}{
        \ifthenelse{\equal{#3}{9}}{
         \ssplacespecial{#1}{#2}{}{[o]{\copy\sseqcirclednine}}}{
         \ifthenelse{\boolean{usescolor}}{
          \ssplacespecial{#1}{#2}{+<3pt>}{[o][F:\ssplacecolor]{#3}}
         }{
          \ssplacespecial{#1}{#2}{+<3pt>}{[o]{#3}}
         }
        }
       }
      }
     }
    }
   }
  }
 }
}
}

\newcommand{\ssbull}[2]{
\ifthenelse{\boolean{usescolor}}{
 \ssplacespecial{#1}{#2}{+<1.1mm>[o][F:\ssplacecolor]}{{}*[\ssplacecolor]\noexpand\frm{*}}
 }{
 \ssplacespecial{#1}{#2}{+<1.1mm>[o]}{{}*\noexpand\frm{*}}
 }
}

\newcommand{\sscirc}[2]{
\ssplacespecial{#1}{#2}{}{[o]-={\circ}}
}

\newcommand{\ssglobalname}[1]{\currprefix#1}


\def\sssetglobalname#1{
 \ssassertsource
 \expandafter\edef\csname sseqpos<#1>\endcsname{\sseqcurrentname}
 \expandafter\edef\csname sseqx<#1>\endcsname{\the\sseqposx}
 \expandafter\edef\csname sseqy<#1>\endcsname{\the\sseqposy}
}
% }{}
%
% \DescribeMacro{\ssmoveto} 
% To move the cursor to position (x,y), use |\ssmoveto{x}{y}|.
%
% \ifthenelse{0=1}{
\newcommand{\ssmoveto}[2]{
\ssfinishpos
\sseqposx=#1
\sseqposy=#2
\ssifposinclippingregion{#1}{#2}
 \setboolean{sseqcurrclip}{false}
\fi
}
% }{}
% \DescribeMacro{\ssmove}
% To move the cursor relative to the current position by (x,y), use |\ssmove{x}{y}|.
%
% \iffalse
\newcommand{\ssmove}[2]{
\count0=\sseqposx
\advance\count0 by #1
\count1=\sseqposy
\advance\count1 by #2
\ssmoveto{\count0}{\count1}
}
% \fi
%
% \DescribeMacro{\ssdrop}
% The command |\ssdrop{|\emph{mathcode}|}| will display \emph{mathcode} at the current cursor position. The argument is always interpreted in math mode.
%
% \iffalse
\newcommand{\ssdrop}[1]{
\ssplace {\the\sseqposx} {\the\sseqposy} {#1}
}
% \fi
%
% \DescribeMacro{\ssdropbull}
% This command is a shorthand for and improvement over |\ssdrop{\bullet}|, i.e. it will typeset a thick black dot at the current cursor position. It is better than the longer version because the bounding circle of a |\bullet| is not accurate in most fonts. However, some |dvi| drivers do not support this and typeset a square instead of a bullet. If that is the case, either use a different driver (like |dvips|), or use |\ssdrop{\bullet}| instead at the cost of a slightly poorer display.
%
% \iffalse
\newcommand{\ssdropbull}{\ssbull {\the\sseqposx} {\the\sseqposy}}
% \fi
%
% \DescribeMacro{\ssdropboxed}
% This command is the same as |\ssdrop|, except that it will also draw a box around its argument.
%
% \iffalse
\newcommand{\ssdropboxed}[1]{
\ssplaceboxed {\the\sseqposx} {\the\sseqposy} {#1}
}
% \fi
%
% \DescribeMacro{\ssdropcircled}
% This command is the same as |\ssdrop|, except that it will also draw a circle around its argument. If the argument is a single digit, the symbol dropped will be prettified by replacing it with a character from the |dingbats| font.
%
% \iffalse
\newcommand{\ssdropcircled}[1]{
\ssplacecircled {\the\sseqposx} {\the\sseqposy} {#1}
}
% \fi
%
% \DescribeMacro{\ssname}
% |\ssname{|\emph{name}|}| gives the object most recently dropped the name \emph{name}. If the previous command is one of the drop commands, then it refers to that object; if it is not, then if there is one and only one object at the current cursor position, it refers to that object; if that is also not the case, an error message is generated.
%
% \iffalse
\def\ssname#1{
 \sssetglobalname{\ssglobalname{#1}}
}
% \fi
%
% \DescribeMacro{\ssgoto}
% After an object has been given a \emph{name} with |\ssname|, the cursor can be moved back to that object at any time by issuing |\ssgoto{|\emph{name}|}|. This becomes necessary when there is more than one object in one position.
%
% \iffalse
\newcommand{\ssgoto}[1]{
\ssabsgoto{\ssglobalname{#1}}
}
% \fi
%
% \DescribeMacro{\ssprefix}
% Often the mechanism provided by |\ssname|/|\ssgoto| is not flexible enough to deal with repeated code. In that case, |\ssprefix{|\emph{prefix}|}| defines a prefix for all names that follow; i.e. a |\ssname{|\emph{name}|}| after such a command will really define a name \emph{prefixname}. However, since |\ssgoto| also observes the prefix, |\ssgoto{|\emph{name}|}| will still work. |\ssprefix| commands can be iterated; the prefices are then concatenated (most recent right).
%
% \iffalse
\newcommand{\ssprefix}[1]{
  \edef\currprefix{\currprefix#1}
}
% \fi
%
% \DescribeMacro{\ssresetprefix}
% This command resets the prefix defined by (a sequence of) |\ssprefix| to the empty prefix.
%
% \iffalse
\newcommand{\ssresetprefix}{\def\currprefix{}}
% \fi
%
% \DescribeMacro{\ssabsgoto}
% This is a version of |\ssgoto| that ignores the current prefix.
%
% \ifthenelse{0=1}{
\newcommand{\ssabsgoto}[1]{
\ssnewpos
\edef\ssoldconncolor{\ssconncolor}
\putxy{"\csname sseqpos<#1>\endcsname"}
\sseqposx=\csname sseqx<#1>\endcsname
\sseqposy=\csname sseqy<#1>\endcsname
\ssifposinclippingregion{\the\sseqposx}{\the\sseqposy}
 \setboolean{sseqcurrclip}{false}
\fi
}
% }{}
%
% \DescribeMacro{\ssdroplabel}
% This command decorates the previously typeset object with a label. It can be used either in the form
%
% |\ssdroplabel{|\emph{label}|}|
%
% or in the form
%
% |\ssdroplabel[|\emph{pos}|]{|\emph{label}|}|.
%
% The \emph{label} will then be typeset next to the most recently dropped object (for a definition for what that is, exactly, consult the description of |\ssname|). The optional argument \emph{pos}, which defaults to |U|, can be one of |U|,|LU|,|RU|,|L|,|R|,|LD|,|RD|,|D|, and denotes one of eight directions in which the label is positioned relative to the object it labels.
%
% \ifthenelse{0=1}{
\newcommand{\ssdroplabel}[2][U]{
\ssassertsource
\ssifposinclippingregion{\the\sseqposx}{\the\sseqposy}
 \putxy{="prev"}
 \ifthenelse{\boolean{usescolor}}{
  \ifthenelse{\equal{#1}{U}}{
   \putxy{+U*[\sslabelcolor]!D{#2}}}{}
  \ifthenelse{\equal{#1}{LU}}{
  \putxy{+LU*[\sslabelcolor]!RD{#2}}}{}
  \ifthenelse{\equal{#1}{RU}}{
  \putxy{+RU*[\sslabelcolor]!LD{#2}}}{}
  \ifthenelse{\equal{#1}{R}}{
  \putxy{+R*[\sslabelcolor]!L{#2}}}{}
  \ifthenelse{\equal{#1}{L}}{
  \putxy{+L*[\sslabelcolor]!R{#2}}}{}
  \ifthenelse{\equal{#1}{D}}{
  \putxy{+D*[\sslabelcolor]!U{#2}}}{}
  \ifthenelse{\equal{#1}{LD}}{
  \putxy{+LD*[\sslabelcolor]!RU{#2}}}{}
  \ifthenelse{\equal{#1}{RD}}{
  \putxy{+RD*[\sslabelcolor]!LU{#2}}}{}
 }{
  \ifthenelse{\equal{#1}{U}}{
   \putxy{+U*!D{#2}}}{}
  \ifthenelse{\equal{#1}{LU}}{
  \putxy{+LU*!RD{#2}}}{}
  \ifthenelse{\equal{#1}{RU}}{
  \putxy{+RU*!LD{#2}}}{}
  \ifthenelse{\equal{#1}{R}}{
  \putxy{+R*!L{#2}}}{}
  \ifthenelse{\equal{#1}{L}}{
  \putxy{+L*!R{#2}}}{}
  \ifthenelse{\equal{#1}{D}}{
  \putxy{+D*!U{#2}}}{}
  \ifthenelse{\equal{#1}{LD}}{
  \putxy{+LD*!RU{#2}}}{}
  \ifthenelse{\equal{#1}{RD}}{
  \putxy{+RD*!LU{#2}}}{}
 }
 \putxy{;"prev"}
\fi
}
% }{}
%
% \DescribeMacro{\ssdropextension}
% This command has no arguments and is rather specialized. It refers to a previously dropped object (see |\ssname|), draws a circle around it, and considers that circle a new object. Thus it produces a new circle object that is attached to the original object, and not subject to the algorithm that tries to make objects non-overlapping
%
% \ifthenelse{0=1}{
\newcommand{\ssdropextension}{
\ssassertsource
\expandafter\def\expandafter\tmpname\expandafter{\csname sseqdrop\the\sseqposx,\the\sseqposy\endcsname}
\edef\setcnt{\noexpand\count0=\tmpname}
\setcnt
\advance\count0 by 1
\expandafter\edef\tmpname{\the\count0}
\setboolean{sseqcurrclip}{true}
\ssifposinclippingregion{\the\sseqposx}{\the\sseqposy}
 \setboolean{sseqcurrclip}{false}
 \putxy{*+<1mm,1mm>\noexpand\frm{}*}
 \sseqwritecolor{\ssplacecolor}
 \putxyq{\cir{}}
\fi
%
% ^^A now give it a unique name
%
\edef\sseqcurrentname{ss(\the\sseqposx,\the\sseqposy)\tmpname}
\putxy{="\sseqcurrentname"}
\ifthenelse{\boolean{sseqhasopenconn}}{\sseqconcludeconnection}{}
}

\newcommand{\ssprepareline}[2]{
\ifthenelse{\boolean{sseqhasfinishedpos}}{
 \ssopenposition{\the\sseqposx}{\the\sseqposy}
}{}
\advance\sseqposx by #1
\advance\sseqposy by #2
\setboolean{sseqhasopenconn}{true}
\edef\ssoldconncolor{\ssconncolor}
}

\newcommand{\sspreparevoidline}[2]{
\ifthenelse{\boolean{sseqhasfinishedpos}}{
 \ssopenposition{\the\sseqposx}{\the\sseqposy}
}{}
\ifthenelse{\boolean{sseqhasfinishedpos}}{}{
 \ssputsemicolon
}
\setboolean{sseqhasfinishedpos}{false}
%
%
%
\sseqx=\sseqentrysize
\multiply\sseqx \sseqxdir
\multiply\sseqx by #1
%
\sseqy=\sseqentrysize
\multiply\sseqy \sseqydir
\multiply\sseqy by #2
%
\putxy{p+<\the\sseqx,\the\sseqy>}
\edef\ssoldconncolor{\ssconncolor}
}

\def\sseqifconninclippingregion{%
\ifthenelse{\boolean{sseqcurrclip}\and\boolean{sseqprevclip}}{
  \ssclippedfalse}{
  \ssclippedtrue
 }
 \ifssclipped
}
% }{}
%
% \DescribeMacro{\ssstroke}
% There are two ways of typesetting connections between objects. One of them is the suit of commands |\ssstroke|, |\sscurve|, |\ssdashedstroke|, |\ssdashedcurve|, |\ssarrowhead|, which all behave similarly. |\ssstroke| requires that the cursor recently moved from one object to another. It takes no arguments and typesets a straight line between the two objects. Example: Suppose there are two objects, which have been given the names |a| and |b| by |\ssname|. Drawing a line between them is achieved by the command |\ssgoto{a} \ssgoto{b} \ssstroke|.
%
% \ifthenelse{0=1}{
\newcommand{\ssstroke}{
\ssassertsource
% ^^A only do it if not both source and target are outside the clipping region
\sseqifconninclippingregion
 \putxy{**} \sseqwritecolor{\ssoldconncolor}
 \putxyq{\dir{-}}
\fi
}
% }{}
%
% \DescribeMacro{\sscurve}
% This command behaves like |\ssstroke|, except that it takes an additional real number argument which denotes a curving factor for the line. $0$ means straight.
%
% \ifthenelse{0=1}{
\newcommand{\sscurve}[1]{
\ssassertsource
\sseqifconninclippingregion
 \putxy{**} \sseqwritecolor{\ssoldconncolor}
 \putxyq{\crv{:(.5,#1)}}
\fi
}
% }{}
%
% \DescribeMacro{\ssdashedstroke}
% Like |\ssstroke|, but typesets a dashed line.
%
% \ifthenelse{0=1}{
\newcommand{\ssdashedstroke}{
\ssassertsource
\sseqifconninclippingregion
 \putxy{**} \sseqwritecolor{\ssoldconncolor}
 \putxyq{\dir{--}}
\fi
}
% }{}
%
% \DescribeMacro{\ssdashedcurve}
% Like |\sscurve|, but typesets a dashed curve.
%
% \ifthenelse{0=1}{
\newcommand{\ssdashedcurve}[1]{
\ssassertsource
\sseqifconninclippingregion
 \putxy{**} \sseqwritecolor{\ssoldconncolor}
 \putxyq{\crv{~**\dir{--}:(.5,#1)}}
\fi
}
% }{}
%
% \DescribeMacro{\ssarrowhead}
% Typesets an arrow head onto the connection most recently typeset.
%
% \ifthenelse{0=1}{
\newcommand{\ssarrowhead}{
\sseqifconninclippingregion
 \putxy {?>*} \sseqwritecolor{\ssoldconncolor}
 \putxyq{\dir{>}}
\fi
}
% }{}
%
% \DescribeMacro{\ssline}
% The second way of producing connections is the suit of commands that follow, starting with |\ssline| \emph{x y}. This command draws a straight line from the most recent object (cf. |\ssname|) to an object at relative position $(x,y)$, and it moves that cursor to that new position. If |\ssline| is followed by a drop command, then the line is attached to this newly dropped object (note the slightly out-of-order execution!), no matter how many other objects there are at the target position. However, if it is not followed by a drop command, then there has to be one and only one object at the target position, otherwise an error message is generated.
%
% \iffalse
\newcommand{\ssline}[2]{
\ssprepareline{#1}{#2}
\def\sseqconncommand{\ssstroke}
}
% \fi
%
% \DescribeMacro{\sscurvedline}
% Like |\ssline|; the third argument is a real number denoting a curvature factor.
%
% \iffalse
\newcommand{\sscurvedline}[3]{
\ssprepareline{#1}{#2} \def\sseqconncommand{\sscurve{#3}}
}
% \fi
%
% \DescribeMacro{\ssdashedline}
% Like |\ssline|; typesets a curved line
% 
% \iffalse
\newcommand{\ssdashedline}[2]{
\ssprepareline{#1}{#2} \def\sseqconncommand{\ssdashedstroke}
}
% \fi
%
% \DescribeMacro{\sscurveddashedline}
% Like |\sscurvedline|; typesets a dashed curve
%
% \iffalse
\newcommand{\sscurveddashedline}[3]{
\ssprepareline{#1}{#2} \def\sseqconncommand{\ssdashedcurve{#3}}
}
% \fi
%
% \DescribeMacro{\ssarrow}
% Like |\ssline|; but adds an arrowhead at the end
%
% \iffalse
\newcommand{\ssarrow}[2]{
\ssprepareline{#1}{#2}
\def\sseqconncommand{\ssstroke\ssarrowhead}
}
% \fi
%
% \DescribeMacro{\sscurvedarrow}
% Like |\sscurve|; but adds an arrowhead at the end
%
% \iffalse
\newcommand{\sscurvedarrow}[3]{
\ssprepareline{#1}{#2} \def\sseqconncommand{\sscurve{#3}\ssarrowhead}
}
% \fi
%
% \DescribeMacro{\ssdashedarrow}
% Like |\ssdashedline|; but adds an arrowhead at the end
%
% \iffalse
\newcommand{\ssdashedarrow}[2]{
\ssprepareline{#1}{#2} \def\sseqconncommand{\ssdashedstroke\ssarrowhead}
}
% \fi
%
% \DescribeMacro{\sscurveddashedarrow}
% Like |\sscurveddashedline|; but adds an arrowhead at the end
%
% \iffalse
\newcommand{\sscurveddashedarrow}[3]{
\ssprepareline{#1}{#2} \def\sseqconncommand{\ssdashedcurve{#3}\ssarrowhead}
}
% \fi
%
% \DescribeMacro{\ssvoidline}
% This command behaves like |\ssline| except it disregards the target and just typesets a line to the given position. This is useful if the line is not supposed to have an object as its target. Unlike |\ssline| and its companions, it does \textbf{not} move the cursor.

%
% \iffalse
\newcommand{\ssvoidline}[2]{
\sspreparevoidline{#1}{#2}
\ssstroke
\putxy{,p}
}
% \fi
%
% \DescribeMacro{\ssvoidarrow}
% Same as |\ssvoidline|, but typesets an arrow.
%
% \iffalse
\newcommand{\ssvoidarrow}[2]{
\sspreparevoidline{#1}{#2}
\ssstroke\ssarrowhead
\putxy{,p}
}
% \fi
%
% \DescribeMacro{\ssbullstring}
% |\ssbullstring{x}{y}{n}| is a shortcut for |\ssdropbull| followed by $n$ copies of |\ssline{x}{y} \ssdropbull|.
% \iffalse
\newcommand{\ssbullstring}[3]{
\ifnum#3>0
 \ifnum#3=1
  \ssdropbull
 \else
  \ssdropbull
  \ssline{#1}{#2}
  \count0=#3
  \advance\count0 by -1
  \edef\sseqbullcnt{\the\count0}
  \ssbullstring{#1}{#2}{\sseqbullcnt}
\fi\fi
}
% \fi
%
% \DescribeMacro{\ssinfbullstring}
% |\ssinfbullstring{x}{y}{n}| is a shortcut for |\ssdropbull| followed by $n$ copies of |\ssline{x}{y} \ssdropbull|, followed by |\ssvoidarrow{x}{y}|.
%
% \iffalse
\newcommand{\ssinfbullstring}[3]{
\ssbullstring{#1}{#2}{#3}
\ssvoidarrow{#1}{#2}
}
% \fi
%
% \section{Additional parameters}
%
% For typesetting dropped objects, |sseq| uses the color |\ssplacecolor|, for connections, |\ssconncolor|, and for labels, |\sslabelcolor|. These all default to black, but can be |\def|'d at any point to any valid \Xy-pic color. There are pre-defined colors |ssblack|, |sseqgr|, and |ssred|, denoting black, light gray, and red.
%
% At any point, clipping can be switched on or off by setting
%
% |\setboolean{sseqclip}{true}| or |\setboolean{sseqclip}{false}|
%
%
% \section{Examples}
%
% \newtheorem{ex}{Example}
%
%\begin{ex}
%The following code generates a $5 \times 5$ grid with labels between $-2$ and $2$. The size of every square is $(.8cm)^2$, and labels are written on every square. A bullet is drawn at coordinate (0,0).
%
%\noindent
%\begin{minipage}{\textwidth/2}
%\begin{verbatim}
%\sseqxstart=-2
%\sseqystart=-2
%\sseqentrysize=.8cm
%\sseqxstep=1
%\sseqystep=1
%\begin{sseq}{5}{5}
%\ssdropbull
%\end{sseq}
%\end{verbatim}
%\end{minipage}
%\begin{minipage}{\textwidth/2}
%\sseqxstart=-2
%\sseqystart=-2
%\sseqentrysize=.8cm
%\sseqxstep=1
%\sseqystep=1
%\begin{sseq}{5}{5}
%\ssdropbull
%\end{sseq}
%\end{minipage}
%\end{ex}
%
%\sseqxstart=0
%\sseqystart=0
%\sseqentrysize=.6cm
%\sseqxstep=2
%\sseqystep=2
%
%\begin{ex}
%This example demonstrates how to move the cursor and drop objects and labels. Note how the last bullet, which is dropped at position (8,4), is outside the grid and thus clipped.
%
%\noindent
%\begin{minipage}{\textwidth/2}
%\begin{verbatim}
%\begin{sseq}{7}{7}
%\ssdropbull
%\ssdroplabel{(0,0)}
%\ssmove 2 1
%\ssdrop{\clubsuit}
%\ssdropextension
%\ssdropextension
%\ssdropextension
%\ssdroplabel[RU]{(2,1)}
%\ssmove 0 4
%\ssdropcircled{8}
%\ssmoveto 5 4
%\ssdropboxed{\spadesuit}
%\ssdroplabel[R]{(5,4)}
%\ssmove 3 0
%\ssdropbull
%\end{sseq}
%\end{verbatim}
%\end{minipage}
%\begin{minipage}{\textwidth/2}
%\begin{sseq}{7}{7}
%\ssdropbull
%\ssdroplabel{(0,0)}
%\ssmove 2 1
%\ssdrop{\clubsuit}
%\ssdropextension
%\ssdropextension
%\ssdropextension
%\ssdroplabel[RU]{(2,1)}
%\ssmove 0 4
%\ssdropcircled{8}
%\ssmoveto 5 4
%\ssdropboxed{\spadesuit}
%\ssdroplabel[R]{(5,4)}
%\ssmove 3 0
%\ssdropbull
%\end{sseq}
%\end{minipage}
%\end{ex}
% 
%\sseqentrysize=.4cm
%\begin{ex}
%This example illustrates the different ways of drawing connections. Note how the size of the axis labels is adjusted to the grid size.
%
%\noindent
%\begin{minipage}{\textwidth/2}
%\begin{verbatim}
%\sseqentrysize=.4cm
%\begin{sseq}{10}{7}
%\ssdropbull
%\ssmove 4 4
%\ssdropbull \ssstroke
%\sscurve{-.5}
%\ssdashedcurve{.1} \ssarrowhead
%\ssmove 4 0 \ssdropcircled{T}
%\ssstroke
%\ssmoveto 0 6
%\ssdropbull 
%\ssline {1} {-1}
%\sscurvedline 7 {-1} {.2}
%\ssdropbull 
%\end{sseq}
%\end{verbatim}
%\end{minipage}
%\begin{minipage}{\textwidth/2}
%\begin{sseq}{10}{7}
%\ssdropbull
%\ssmove 4 4
%\ssdropbull \ssstroke
%\sscurve{-.5}
%\ssdashedcurve{.1} \ssarrowhead
%\ssmove 4 0 \ssdropcircled{T}\ssstroke
%\ssmoveto 0 6
%\ssdropbull 
%\ssline {1} {-1}
%\ssdropbull
%\sscurvedline 7 {-1} {.2}
%\end{sseq}
%\end{minipage}
%\end{ex}
%
%\begin{ex}
%This sample code shows how to use names for objects dropped in spectral sequence; this is particularly useful when more than one item is dropped at one position. It also demonstrates void arrows, which do not need a target.
%
%\noindent
%\begin{minipage}{\textwidth*2/3}
%\begin{verbatim}
%\begin{sseq}{5}{5}
%\ssdropbull \ssname{a} \ssvoidarrow 0 1
%\ssdropbull \ssname{b} \ssvoidarrow 0 1
%\ssdropbull \ssname{c} \ssvoidarrow 0 1
%\ssdropextension \ssname{d}
%\ssmove 4 4
%\ssdropbull \ssname{e}
%\ssdropbull \ssname{f}
%\ssgoto a \ssgoto f \ssstroke
%\ssgoto e \ssstroke
%\ssgoto d \sscurve{.2}
%\ssline 4 0 \ssdropbull
%\end{sseq}
%\end{verbatim}
%\end{minipage}
%\begin{minipage}{\textwidth/3}
%\begin{sseq}{5}{5}
%\ssdropbull \ssname{a}\ssvoidarrow 0 1
%\ssdropbull \ssname{b}\ssvoidarrow 0 1
%\ssdropbull \ssname{c}\ssvoidarrow 0 1
%\ssdropextension \ssname{d}
%\ssmove 4 4
%\ssdropbull \ssname{e}
%\ssdropbull \ssname{f}
%\ssgoto a \ssgoto f \ssstroke
%\ssgoto e \ssstroke
%\ssgoto d \sscurve{.2}
%\ssline 4 0 \ssdropbull
%\end{sseq}
%\end{minipage}
%\end{ex}
%
%\begin{ex}
% This final example shows how to take advantage of loops and prefices.
%
%\noindent
%\begin{minipage}[t]{\textwidth*1/3}
%\begin{verbatim}
%\newcount\cnti
%\def\drawstring#1#2{
% \ifnum#2=1
%  \ssdropbull \ssname{#1}
% \else
%  \ssdropbull \ssname{#1}
%  \ssline 1 0
%  \ssprefix{i}
%  \cnti=#2
%  \advance \cnti by -1
%  \drawstring{#1}
%   {\the\cnti}
% \fi
%}
%\end{verbatim}
%\end{minipage}
%\begin{minipage}[t]{\textwidth*1/3}
%\begin{verbatim}
%\def\drawlines#1#2#3{
% \ifnum#3>0
%  \cnti=#3
%  \ssgoto{#1} \ssgoto{#2}
%  \ssstroke \ssarrowhead
%  \ssprefix{i}
%  \advance \cnti by -1
%  \drawlines{#1}{#2}
%   {\the\cnti}
% \fi
%}
%\end{verbatim}
%\end{minipage}
%\begin{minipage}[t]{\textwidth*1/3}
%\begin{verbatim}
%\begin{sseq}{9}{4}
%\ssmoveto 0 3
%\drawstring{a}{8}
%\ssmoveto 0 3
%\ssresetprefix
%\drawstring{b}{8}
%\ssmoveto 0 0
%\ssresetprefix
%\drawstring{c}{8}
%\ssresetprefix
%\drawlines{c}{a}{8}
%\ssresetprefix
%\drawlines{b}{iic}{6}
%\end{sseq}
%\end{verbatim}
%\end{minipage}
%
% The result is shown in the following chart:
%\newcount\cnti
%\def\drawstring#1#2{
% \ifnum#2=1
%  \ssdropbull \ssname{#1}
% \else
%  \ssdropbull \ssname{#1}
%  \ssline 1 0
%  \ssprefix{i}
%  \cnti=#2
%  \advance \cnti by -1
%  \drawstring{#1}
%   {\the\cnti}
% \fi
%}
%\def\drawlines#1#2#3{
% \ifnum#3>0
%  \cnti=#3
%  \ssgoto{#1} \ssgoto{#2}
%  \ssstroke \ssarrowhead
%  \ssprefix{i}
%  \advance \cnti by -1
%  \drawlines{#1}{#2}
%   {\the\cnti}
% \fi
%}
%\begin{sseq}{9}{4}
%\ssmoveto 0 3
%\drawstring{a}{8}
%\ssmoveto 0 3
%\ssresetprefix
%\drawstring{b}{8}
%\ssmoveto 0 0
%\ssresetprefix
%\drawstring{c}{8}
%\ssresetprefix
%\drawlines{c}{a}{8}
%\ssresetprefix
%\drawlines{b}{iic}{6}
%\end{sseq}
%\end{ex}
%
%\section{Final remarks}
%
% This package has been extremely helpful for my own mathematical work, and it most likely carries the characteristics of a tool initially developed for my own purposes only. Before this published version, there was an earlier version of |sseq| which was much less powerful; and what is worse, this version is not fully upward compatible with the previous one. (Every object that was dropped was forgotten right afterwards; thus connections could not properly connect objects but were always drawn from the center of the box corresponding to a coordinate to the center of the box corresponding to the target coordinate, resulting in fairly ugly pictures.)
%
% Many things remain to be desired:
%
% \begin{itemize}
% \item |sseq| seems to be too voracious in memory
% \item While object are placed next to each other, no attempt is made not to make connections overlap
% \item Other things ought to be customizable: The grid style, the axis labels, etc.
% \item A ``grayout'' option that automatically turns the source and target of any arrow into a different color would be highly useful for spectral sequence charts
% \end{itemize}
%
% Given time and leisure, I might or might not implement one or more of these improvements and make them available; of course, I would be even more happy if somebody else did it. (Needless to say, I would request that I be informed of and sent the enhancements.) I do guarantee that all further versions of |sseq| that might or might not be written by me will be compatible with the documented code written for this version.
%
% \endinput
% ^^A\sseqdrawgrid
%
\def\sseqdrawgrid#1#2{
\sseqi=0
\sseqj=0
\loop
 \sseqy=\sseqentrysize
 \multiply \sseqy by \sseqj
 \advance \sseqy by \sseqlabelbarwidth
 %
 \putxy{<\the\sseqlabelbarwidth,\the\sseqy>;<\the\sseqx,\the\sseqy>**}
 \sseqwritecolor{sseqgr}
 \putxyq{\dir {.},}
 \advance\sseqj 1
\ifnum\sseqj>#2 \else \repeat
%
\sseqy = \sseqentrysize
\multiply \sseqy by #2
\advance \sseqy by \sseqlabelbarwidth
\loop
 \sseqx=\sseqentrysize
 \multiply \sseqx by \sseqi
 \advance \sseqx by \sseqlabelbarwidth
 %
 \putxy{<\the\sseqx,\the\sseqlabelbarwidth>;<\the\sseqx,\the\sseqy>**}
 \sseqwritecolor{sseqgr}
 \putxyq{\dir {.},}
 \advance \sseqi 1
\ifnum\sseqi>#1 \else \repeat
}
%
% ^^A\sseqdrawlabels
%
\def\sseqdrawlabels#1#2{
\sseqi=\sseqxstart
\sseqposx=\sseqxstart
\multiply \sseqposx by -1
\advance \sseqposx \sseqi
\count0=\sseqxdir
\multiply\count0 by \sseqxdir
\multiply\count0 by \sseqxstep
\count1=\sseqydir
\multiply\count1 by \sseqydir
\multiply\count1 by \sseqystep
\loop
 \sseqxx=\sseqentrysize
 \multiply\sseqxx by \sseqposx
 \advance\sseqxx by \sseqhalfentry
 \advance\sseqxx by \sseqlabelbarwidth
 \putxy { <\the\sseqxx,0pt>*}
 \putxyq{\txt\sseqlabelfont}
 \putxy {{\the\sseqi},}
 \advance\sseqi by \sseqxstep
 \advance\sseqposx by \count0
\ifnum\sseqposx<#1 \repeat
%
\sseqj=\sseqystart
\sseqposy=\sseqj
\multiply\sseqposy by -1
\advance\sseqposy by \sseqj
\loop
 \sseqyy=\sseqentrysize
 \multiply\sseqyy by \sseqposy
 \advance\sseqyy by \sseqhalfentry
 \advance\sseqyy by \sseqlabelbarwidth
 \putxy { <0pt,\the\sseqyy>*}
 \putxyq {\txt\sseqlabelfont}
 \putxy{{\the\sseqj},}
 \advance\sseqj by \sseqystep
 \advance\sseqposy by \count1
\ifnum\sseqposy<#2\repeat
}


%
%
\newenvironment{sseq}[2]{
\begingroup
%
% ^^A Initialize some local counters and dimensions
%
\countdef\sseqxend=150 \sseqxend=\sseqxstart \advance\sseqxend by #1
\countdef\sseqyend=151 \sseqyend=\sseqystart \advance\sseqyend by #2
\dimendef\sseqoffx=200 \sseqoffx=0pt
\dimendef\sseqoffy=201 \sseqoffy=0pt
\dimendef\sseqoffsetx=202
\dimendef\sseqoffsety=203
\countdef\sseqi=152 \sseqi=0
\countdef\sseqj=153 \sseqj=0
\countdef\sseqxdir=154
\countdef\sseqposx=155
\countdef\sseqposy=156
\countdef\sseqydir=157
\dimendef\sseqlabelbarwidth=204
\dimendef\sseqhalfentry=205
\dimendef\sseqx=206
\dimendef\sseqy=207
\dimendef\sseqxx=208
\dimendef\sseqyy=209
\dimendef\sseqlabelwidth=210 
\dimendef\sseqrightlabelwidth=211 
\dimendef\sseqlabelsize=212 

\ifnum\sseqxstep<0 \sseqxdir=-1 \else \sseqxdir=1 \fi
\ifnum\sseqystep<0 \sseqydir=-1 \else \sseqydir=1 \fi
\def\sseqlabelfontsize{12}
%
% Backup count0 - count9 (these are page numbers!)
%
\edef\sseqsavecnto{\the\count0}
\edef\sseqsavecnti{\the\count1}
\edef\sseqsavecntii{\the\count2}
\edef\sseqsavecntiii{\the\count3}
\edef\sseqsavecntiv{\the\count4}
\edef\sseqsavecntv{\the\count5}
\edef\sseqsavecntvi{\the\count6}
\edef\sseqsavecntvii{\the\count7}
\edef\sseqsavecntviii{\the\count8}
\edef\sseqsavecntix{\the\count9}
%
% ^^A Compute the maximal axis label width
%
\sseqlabelwidth=14pt
\sseqrightlabelwidth=10pt
\ifnum\sseqxstart<0
 \advance\sseqlabelwidth by 8pt
 \ifnum\sseqxstart<-9
  \advance\sseqlabelwidth by 6pt
  \ifnum\sseqxstart<-99
   \advance\sseqlabelwidth by 6pt
  \fi
 \fi
\fi
\ifnum\sseqxend>10
 \advance\sseqrightlabelwidth by 6pt
 \ifnum\sseqxend>100
  \advance\sseqrightlabelwidth by 6pt
 \fi
\fi
\ifnum\sseqrightlabelwidth>\sseqlabelwidth
 \sseqlabelwidth=\sseqrightlabelwidth
\fi
\sseqlabelsize=10pt
\count0=\sseqentrysize
\multiply \count0 by 160
\divide \count0 by \sseqlabelwidth
\multiply \sseqlabelsize by \count0
\divide \sseqlabelsize by 100
\ifdim\sseqlabelsize<11pt
 \def\sseqlabelfontsize{10}
 \ifdim\sseqlabelsize<9.5pt
  \def\sseqlabelfontsize{9}
  \ifdim\sseqlabelsize<8.5pt
   \def\sseqlabelfontsize{8}
  \fi
 \fi
\fi
\edef\sz{\the\sseqlabelsize}
\putxyq {\font \sseqlabelfont = cmtt}
\putxy{\sseqlabelfontsize\space at \the\sseqlabelsize\space}
\sseqlabelbarwidth=\sseqlabelsize
\divide\sseqlabelbarwidth by 2
\dimen0=\sseqentrysize
\multiply\dimen0 by -1
\multiply\dimen0 by \sseqxdir
\multiply\dimen0 by \sseqxstart
\sseqoffsetx=\sseqlabelbarwidth
\advance\sseqoffsetx by \dimen0
\dimen0=\sseqentrysize
\multiply\dimen0 by -1
\multiply\dimen0 by \sseqydir
\multiply\dimen0 by \sseqystart
\sseqoffsety=\sseqlabelbarwidth
\advance\sseqoffsety by \dimen0
\sseqhalfentry=\sseqentrysize
\divide\sseqhalfentry by 2
\sseqx=\sseqentrysize
\multiply \sseqx by #1
\advance \sseqx by \sseqlabelbarwidth
\sseqy=\sseqentrysize
\multiply \sseqy by \sseqj
\advance \sseqy by \sseqlabelbarwidth
\sseqxx=\sseqx
\sseqyy=\sseqy
\advance\sseqxx by \sseqhalfentry
\advance\sseqyy by \sseqhalfentry
%
%
% ^^A start the xy environment
\putxyq {\xy}
%
%
\sseqdrawgrid{#1}{#2}
\sseqdrawlabels{#1}{#2}
%
%
\sseqposx=0
\sseqposy=0
}
%
%
% ^^A PART FOR \end{sseq}
%
{
\relax
\ssfinishpos
\putxyq{\endxy}
\bigskip
\edef\lst{\the\sseqcmdlist}
\ifthenelse{\boolean{debug}}{\show\lst}{}
%
% ^^A Restore count0-count9 in case we're in the middle of a page break.
%
\count0=\sseqsavecnto
\count1=\sseqsavecnti
\count2=\sseqsavecntii
\count3=\sseqsavecntiii
\count4=\sseqsavecntiv
\count5=\sseqsavecntv
\count6=\sseqsavecntvi
\count7=\sseqsavecntvii
\count8=\sseqsavecntviii
\count9=\sseqsavecntix
\the\sseqcmdlist
\endgroup
\bigskip
}
%
% \Finale