-
Notifications
You must be signed in to change notification settings - Fork 0
/
sseqpages.sty
4939 lines (4609 loc) · 207 KB
/
sseqpages.sty
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
%%
%% Package: sseqpages.sty version 1.0
%% Author: Hood Chatham
%% Email: [email protected]
%% Date: 2017-05-23
%% License: Latex Project Public License
%%
%% A package for drawing spectral sequences
%%
% TODO:
% lastclass stack
%
% Don't really care about:
% Fix shifts (what does this mean again? label shifts of some sort?)
% improve axes options? allow axis to be centered on coordinate or centered between coordinates
% Various pipe dream lua only features.
\NeedsTeXFormat{LaTeX2e}
\ProvidesPackage{sseqpages}
\newif\ifsseq@versionwarn
\RequirePackage{tikz}
\RequirePackage{etoolbox}
\RequirePackage{xparse}
\usetikzlibrary{quotes}
\usetikzlibrary{fit}
\usetikzlibrary{positioning}
\usetikzlibrary{intersections}
\usetikzlibrary{backgrounds}
\usepgflibrary{arrows.meta}
\usetikzlibrary{shapes}
%\usetikzlibrary{profiler}
\def\sseq@authorname#1{Hood Chatham}
\def\sseq@authoremail#1{[email protected]}
\DeclareOption{versionwarn}{\sseq@versionwarntrue}
\ProcessOptions\relax
\@ifpackagelater{tikz}{2015/07/08}{%
\@ifpackagelater{tikz}{2015/08/08}{%
\ifsseq@versionwarn
\expandafter\PackageWarning
\else
\expandafter\PackageError
\fi
{sseqpages}{You are using a version of Tikz later than the version sseqpages was developed for. Something might go wrong. Please say
'\string\usepackage[version warn]{sseqpages}' to suppress this error message and email me at \sseq@authoremail{} if you find any bugs}{}
}{%
% Current version of tikz
}
}{%
\ifsseq@versionwarn
\PackageWarning{sseqpages}{I'm not sure that the sseqpages package will work with Tikz versions earlier than 3.0.1a.}
\else
\PackageError{sseqpages}{I'm not sure that the sseqpages package will work with Tikz versions earlier than 3.0.1a. Please say
'\string\usepackage[version warn]{sseqpages}' to suppress this error message, and email me at \sseq@authoremail{} to let me know whether sseqpages works with your version
of Tikz. Or just update Tikz}{}
\fi
}
%%%%%% %%%%%%
%% %%
%% Declarations and preliminaries %%
%% %%
%%%%%% %%%%%%
\newif\ifsseq@hasname
\newif\ifsseq@updateexisting
\newif\ifsseq@ispageenv
\newif\ifsseq@keepchanges
\newif\ifsseq@globaldetone
\newif\ifsseq@needstikz
\newif\ifsseq@thispage
\newif\ifsseq@outofrange
\newif\ifsseq@classlabel
\newif\ifsseq@draworphanedges
\newif\ifsseq@drawedge
\newif\ifsseq@tikzprims@integershift
\sseq@drawedgetrue
\sseq@tikzprims@integershifttrue
\newif\ifsseq@tempif
\newtoks\sseq@temptoks
\newtoks\sseq@scope@toks
\newcount\sseq@anonsseqcount
\newcount\sseq@context@depth
\newcount\sseq@context@tempcount
\newcount\sseq@x
\newcount\sseq@y
\newcount\sseq@tempcount
\newcount\sseq@tempcountb
\newcount\sseq@tempx
\newcount\sseq@tempy
\newcount\sseq@tempxb
\newcount\sseq@tempyb
\sseq@context@depth\z@
\sseq@x\z@ \sseq@y\z@
\newdimen\sseq@gridstrokethickness
\sseq@gridstrokethickness=.1pt
% Ensure \@xp and \@nx have the correct values in case that amsmath isn't loaded
\let\@xp\expandafter
\let\@nx\noexpand
\def\@xptwo{\@xp\@xp\@xp}
\def\@xpthree{\@xp\@xp\@xp\@xp\@xp\@xp\@xp}
\def\sseq@nil{\sseq@thisshouldnthappen@nil unique expansion} % This expansion text should be unique so that \ifx\sseq@nil\othercommand is false.
\def\sseq@infinity{10000} % Larger than any coordinate anyone will ever use.
\def\sseq@macroname{\@xp\@gobble\string}
\def\sseq@gobble@to@nil#1\sseq@nil{}
% These are only used by defertikzcommand now
\def\sseq@callas#1{\def\sseq@callcmd{#1}}
\def\sseq@call#1{\bgroup\@xp\let\sseq@callcmd#1\@xptwo\egroup\sseq@callcmd}
\def\sseq@getfirstchar#1#2\sseq@nil{#1} % used in shift/checkshift transform
\def\sseq@smuggle@macro#1#2\egroup{\@xp\egroup\@xp\def\@xp#1\@xp{#1}}
% For expandable macros
\def\sseq@ifhop#1#2\fi{\fi#1}
\def\sseq@swapapply#1#2{#2#1}
\def\sseq@eval#1{\bgroup\edef\sseq@temp{#1}\@xp\egroup\sseq@temp}% I got this from sseq.sty
\def\sseq@protectedeval#1{\bgroup\sseq@protected@edef\sseq@temp{#1}\@xp\egroup\sseq@temp}
\def\sseq@eval@show#1{\bgroup\edef\sseq@temp{#1}\show\sseq@temp\@xp\egroup\sseq@temp}
\def\sseq@profilenew#1#2{\pgfprofilenew{#1}\pretocmd#2{\pgfprofilestart{#1}}{}{\error}\apptocmd#2{\pgfprofileend{#1}}{}{\error}}
\def\sseq@removeparens{\@xp\sseq@removeparens@}
\def\sseq@removeparens@(#1){#1}
% Stolen from trimspaces.sty
\bgroup
\catcode`\Q=3
\gdef\sseq@trimspaces#1{%
\romannumeral-`\q\sseq@trim@trim@\noexpand#1Q Q%
}
\long\gdef\sseq@trim@trim@#1 Q{\sseq@trim@trim@@#1Q}
\long\gdef\sseq@trim@trim@@#1Q#2{#1}
\egroup
\def\sseq@trimleadingspaces{\romannumeral-`q}
\def\sseq@ifempty#1{%
\@xp\ifx\@xp\sseq@nil\detokenize{#1}\sseq@nil
\@xp\@firstoftwo
\else
\@xp\@secondoftwo
\fi
}
\def\sseq@eatspacesthen#1{\bgroup\sseq@temptoks{#1}\@xp\@xp\@xp\egroup\@xp\the\@xp\sseq@temptoks\romannumeral-`\q}
\let\sseq@pgfmathparse@save\pgfmathparse
\def\sseq@pgfmathparse#1{\let\@@protect\protect\def\protect{}\sseq@pgfmathparse@save{#1}\restore@protect} % Prevent \protect from causing trouble for \pgfmathparse
%%% ifintexpr
% #1 -- expresion to test
% #2 -- true case
% #3 -- false case
% This tests true if \numexpr #1\relax throws no error and consumes all of #1 and false otherwise.
% Test if single token input is a digit
\def\sseq@ifdigit#1{
\ifodd0\ifx#101\fi\ifx#111\fi\ifx#121\fi\ifx#131\fi\ifx#141\fi\ifx#151\fi\ifx#161\fi\ifx#171\fi\ifx#181\fi\ifx#191\fi\relax
\@xp\@firstoftwo
\else
\@xp\@secondoftwo
\fi
}
\bgroup\lccode`\!=`\ \lowercase{\egroup
\let\sseq@otherspace!% This has to be a let, no idea why
}
% Spaces matter to us, because \sseq@ifintexpr{1 1} is false but \sseqsifintexpr{11} is true
% so we make spaces into catcode other and use \scantokens
\def\sseq@ifintexpr#1{%
\bgroup
\catcode`\ =12\relax
\sseq@tempcount\z@
\makeatletter
\scantokens{\sseq@ifintexpr@first{needsint}#1\sseq@nil}%
\@xp\egroup\next
}
\def\sseq@ifintexpr@first#1#2{\sseq@ifintexpr@{#2}}
% We need to use \futurelet so that we can detect open braces even when they only surround one token like {1}
% so we have to store the state in \sseq@ifintexpr@state
\ExplSyntaxOn
\def\sseq@ifintexpr@#1{\def\sseq@ifintexpr@state{#1}\futurelet\temptok\sseq@ifintexpr@@}
\def\sseq@ifintexpr@@{%
\ifx\temptok\bgroup%
\let\next\sseq@ifintexpr@false
\else
\ifx\temptok\sseq@nil
\@xp\let\@xp\next\csname sseq@ifintexpr@@\sseq@ifintexpr@state @done\endcsname
\else
% Even though I \let \sseq@otherspace to a space of catcode other up there,
% I still need this freaking expandafter here. God only knows why. Figured this out by trial and error.
% We need to check here for a space because \string<space> produces NO OUTPUT regardless of the catcode of the space.
% This fucks over \sseq@ifintexpr@@@ real hard because it doesn't expect \string#1 to produce no characters.
\@xp\ifx\sseq@otherspace\temptok
\def\next{\sseq@ifintexpr@next{~}\@xp\next\@gobble}
\else
\let\next\sseq@ifintexpr@@@
\fi
\fi
\fi
\next
}
\def\sseq@ifintexpr@@@#1{
\ifcat$\@xp\@gobble\string#1$%
\@xp\sseq@ifintexpr@@@@\@xp#1
\else
% scantokens puts an extra space character after control sequences, so to give them the best shot at working, eat that space character
% Then use f expansion.
\@xp\@xp\@xp\sseq@ifintexpr@@@fexpcs\@xp\@xp\@xp#1\@xp\@gobble
\fi
}
% Unfortunately, if we have a macro that takes an argument inside another macro that takes an argument, this will fail (the inside macro will get a space) but such is life.
\def\sseq@ifintexpr@@@fexpcs{\exp_last_unbraced:Nf\sseq@ifintexpr@@@fexpcs@}
\def\sseq@ifintexpr@@@fexpcs@{\futurelet\temptok\sseq@ifintexpr@@@fexpcs@@}
\def\sseq@ifintexpr@@@fexpcs@@{
\ifx\temptok\bgroup
\@xp\sseq@ifintexpr@false
\else
\ifx\temptok\sseq@error
\@xpthree\sseq@error\@xp\@xp\@xp\@gobbletwo
\else
\@xp\@xp\@xp\sseq@ifintexpr@@@@
\fi
\fi
}
%\exp_last_unbraced:Nf\sseq@ifintexpr@@
\ExplSyntaxOff
% We can't just use \futurelet because "\let\test(" makes \test unexpandable
% (I guess that makes sense, but why is it that I need \@xp\ifx\otherspace above if I've also \let\otherspace to a character? Mysterious...),
% so then "\csname hello\test\endcsname" is an error. This indexes into our state machine,
% cases: a digits, + or -, * or /, (, ), or something else (anything else always leads to false
\def\sseq@ifintexpr@@@@#1{%
\ifx#1\sseq@nil
\def\next{\csname sseq@ifintexpr@@\sseq@ifintexpr@state @done\endcsname\sseq@nil}%
\else
\sseq@ifdigit{#1}%
{\sseq@ifintexpr@next{digit}}%
{%
\ifx#1+%
\sseq@ifintexpr@next{+-}
\else
\ifx#1-%
\sseq@ifintexpr@next{+-}
\else
\ifx#1*%
\sseq@ifintexpr@next{*/}
\else
\ifx#1/%
\sseq@ifintexpr@next{*/}
\else
\pgfutil@ifundefined{sseq@ifintexpr@@\sseq@ifintexpr@state @#1}%
{\let\next\sseq@ifintexpr@false}%
{\sseq@ifintexpr@next{#1}}%
\fi
\fi
\fi
\fi
}%
\fi
\next
}
\def\sseq@ifintexpr@true#1\sseq@nil{\ifnum\sseq@tempcount=\z@ \let\next\@firstoftwo\else\let\next\@secondoftwo\fi}
\def\sseq@ifintexpr@false#1\sseq@nil{\let\next\@secondoftwo}
\def\sseq@makeifint#1#2#3{\@xp\def\csname sseq@ifintexpr@@#1@#2\endcsname{#3}}
\def\sseq@ifintexpr@next#1{\@xp\let\@xp\next\csname sseq@ifintexpr@@\sseq@ifintexpr@state @#1\endcsname}
\sseq@makeifint{needsint}{done}{\sseq@ifintexpr@false}
\sseq@makeifint{needsint}{digit}{\sseq@ifintexpr@{int}}
\sseq@makeifint{needsint}{*/}{\sseq@ifintexpr@false}
\sseq@makeifint{needsint}{+-}{\sseq@ifintexpr@{needsint}}
\sseq@makeifint{needsint}{(}{\advance\sseq@tempcount\@ne\sseq@ifintexpr@{needsint}}
\sseq@makeifint{needsint}{)}{\sseq@ifintexpr@false}
\sseq@makeifint{needsint}{ }{\sseq@ifintexpr@{needsint}}
\sseq@makeifint{int}{done}{\sseq@ifintexpr@true}
\sseq@makeifint{int}{digit}{\sseq@ifintexpr@{int}}
\sseq@makeifint{int}{*/}{\sseq@ifintexpr@{needsint}}
\sseq@makeifint{int}{+-}{\sseq@ifintexpr@{needsint}}
\sseq@makeifint{int}{(}{\sseq@ifintexpr@false}
\sseq@makeifint{int}{)}{
\advance\sseq@tempcount\m@ne
\ifnum\sseq@tempcount<\z@\relax
\@xp\@xp\@xp\sseq@ifintexpr@false\@xp\@gobble
\else
\@xp\sseq@ifintexpr@
\fi{nointallowed}
}
\sseq@makeifint{int}{ }{\sseq@ifintexpr@{nointallowed}}
\sseq@makeifint{nointallowed}{done}{\sseq@ifintexpr@true}
\sseq@makeifint{nointallowed}{digit}{\sseq@ifintexpr@false}
\sseq@makeifint{nointallowed}{*/}{\sseq@ifintexpr@{needsint}}
\sseq@makeifint{nointallowed}{+-}{\sseq@ifintexpr@{needsint}}
\sseq@makeifint{nointallowed}{(}{\sseq@ifintexpr@false}
\sseq@makeifint{nointallowed}{)}{
\advance\sseq@tempcount\m@ne
\ifnum\sseq@tempcount<\z@
\@xp\@xp\@xp\sseq@ifintexpr@false\@xp\@gobble
\else
\@xp\sseq@ifintexpr@
\fi{nointallowed}
}
\sseq@makeifint{nointallowed}{ }{\sseq@ifintexpr@{nointallowed}}
%% Error messages
\newtoks\sseq@thiscalltoks
\def\sseq@thiscall{\the\sseq@thiscalltoks}
\def\sseq@setthiscall{\let\sseq@error@annotation\sseq@error@annotation@call\sseq@thiscalltoks}
\def\sseq@esetthiscall#1{\let\sseq@error@annotation\sseq@error@annotation@call\sseq@eval{\sseq@thiscalltoks{#1}}}
\def\sseq@error@annotation{.^^J(\sseq@errorinfo)}
\def\sseq@error@annotation@call{.^^J(Error occurred during call "\sseq@thiscall"\space \sseq@errorinfo)}
\let\sseq@errmessage@std\errmessage
\def\sseq@errmessage#1{\sseq@builderrorinfo\sseq@errmessage@std{#1\sseq@error@annotation}}
\def\sseq@errorwithinfo#1{\let\errmessage\sseq@errmessage@std\sseq@builderrorinfo\pgfutil@packageerror{sseqpages}{#1\sseq@error@annotation}{}}
\def\sseq@errornoinfo#1{\let\errmessage\sseq@errmessage@std\sseq@builderrorinfo\pgfutil@packageerror{sseqpages}{#1}{}}
\DeclareRobustCommand\sseq@error{\sseq@error@}% This is robust just for \isalive...
\let\sseq@error@\sseq@errornoinfo
\def\sseq@errorinfo{}% Changed during \foreach
\def\sseq@inputlineno{\the\inputlineno}
\def\sseq@builderrorinfo{}% Changed during \foreach
\def\sseq@errorinfo@foreach{in the \@nx\foreach block that ends on line \the\inputlineno, with variable values:}
\def\sseq@error@internal#1{\sseq@error{Internal error: #1. Contact package author \sseq@authorname{} at \sseq@authoremail{}}{}}
\def\sseq@error@range{\sseq@error{Empty spectral sequence. For every spectral sequence you must either specify both the "x range" and "y range" or include at least one
\string\class}}
\def\sseq@error@standardparse#1{\sseq@error{You cannot use \string#1 inside a scope that has either the background key or coordinate transformations other than integer shifts}}
\def\sseq@errorifpt#1#2{\sseq@errorifpt@#1.\sseq@nil{#2}}
\def\sseq@errorifpt@#1.#2\sseq@nil#3{\ifx\sseq@nil#2\sseq@nil\else\sseq@error{#3}\fi}
%%%%%% %%%%%%
%% %%
%% Commands to define other commands %%
%% %%
%%%%%% %%%%%%
\ExplSyntaxOn
%%% \sseq@DeclareDocumentCommand
%
% \sseq@DeclareDocumentCommand\somecommand is shorthand for \sseq@DeclareDocumentCommandAs\sseq@somecommand\somecommand
%
% so the result is that it defines \sseq@somecommand intended to be \let to \somecommand later.
\cs_new_protected:Npn\sseq@DeclareDocumentCommand#1{%
\exp_args:Nc \sseq@DeclareDocumentCommandAs { sseq@ \cs_to_str:N #1 }#1
}
%%% \sseq@DeclareDocumentCommandAS
%
% #1 - the command to define
% #2 - the command to use in argument parsing errors
% #3 - parameters (\NewDocumentCommand style)
% #4 - code
%
% See my stack exchange question: https://tex.stackexchange.com/questions/350596/control-error-messages-made-by-commands-defined-with-newdocumentcommand
\cs_new_protected:Npn\sseq@DeclareDocumentCommandAs#1#2#3#4{
\group_begin:
\cs_set_eq:cN { tempsave_ \cs_to_str:N #2 } #2 % Store the original value of #2
\cs_set_eq:cc { tempsave_ \cs_to_str:N #2 \c_space_tl code } { \cs_to_str:N #2 \c_space_tl code } % Store the original value of #2
\DeclareDocumentCommand#2{#3}{\group_end: #4}
\cs_new:Npx #1{
\group_begin:
\exp_not:N \cs_set_eq:NN
\exp_not:c { \cs_to_str:N #2 \c_space_tl code }
\exp_not:c { \cs_to_str:N #1 \c_space_tl code }
\exp_not:c { \cs_to_str:N #1 \c_space_tl inner }
}
\cs_gset_eq:cN { \cs_to_str:N #1 \c_space_tl inner } #2
\cs_gset_eq:cc { \cs_to_str:N #1 \c_space_tl code } { \cs_to_str:N #2 \c_space_tl code }
\cs_gset_eq:Nc #2 { tempsave_ \cs_to_str:N #2 }
\cs_gset_eq:cc { \cs_to_str:N #2 \c_space_tl code } { tempsave_ \cs_to_str:N #2 \c_space_tl code }
\group_end:
}
%%% Commands to help the user define "groups" of commands to be reused
\NewDocumentCommand\sseqnewgroup{smO{0}m}{
\sseq@eval{\@nx\sseqnewcmd\IfBooleanT{#1}{*}\@nx#2(\@nx\sseq@macrox,\@nx\sseq@macroy)[#3]}{%
\bgroup
\def\sseq@newgroup@temp{}%
\sseq@tempiffalse
\sseq@ifempty{\options}{}{\sseq@tempiftrue}%
\sseq@tempcount=\numexpr\sseq@macrox\relax
\sseq@tempcountb=\numexpr\sseq@macroy\relax
\ifnum\sseq@tempcount=\z@\else\sseq@tempiftrue\fi
\ifnum\sseq@tempcountb=\z@\else\sseq@tempiftrue\fi
\ifsseq@tempif\sseq@eval{\@nx\begin{scope}[xshift=\the\sseq@tempcount,yshift=\the\sseq@tempcountb,\unexpanded{\options}]}\def\sseq@newgroup@temp{\end{scope}}\fi%
{}#4% This is set up to make sure no space problems occur with \patchcmd
\sseq@newgroup@temp
\egroup
}%
}
\ExplSyntaxOff
\NewDocumentCommand\sseqnewcmd{smD(){\x,\y}O{0}m}{
\IfBooleanF{#1}{
\@ifundefined{\sseq@macroname #2}{}{%
\sseq@error{%
A command named \string#2\space already exists. If you want to overwrite an existing command, say
'\string\sseqnewcmd*\string#2...' or '\string\sseqnewgroup*\string#2...' as appropriate%
}{}%
}
}
\ifnum#4>6 \sseq@error{Commands defined using '\string\sseqnewcmd' or '\string\sseqnewgroup' can take at most six arguments}\fi
\sseqnewcmd@#2(#3){#4}{#5}
}
\NewDocumentCommand\sseqnewdcmd{msD(){\x,\y}O{0}m}{
\IfBooleanT{#2}{
\@ifundefined{\sseq@macroname #1}{}{%
\sseq@error{%
A command named \string#1\space already exists. If you want to overwrite an existing command, say
'\string\sseqnewcmd*\string#1...' or '\string\sseqnewgroup*\string#1...' as appropriate%
}{}%
}
}
\ifnum#4>5 \sseq@error{Commands defined using '\string\sseqnewdcmd' can take at most five arguments}\fi
\sseqnewdcmd@#1(#3){#4}{#5}
}
\bgroup\lccode`\*=`\#\lccode`C=`C\lccode`\O=`\O\lowercase{\egroup
\def\sseqnewcmd@#1(#2,#3)#4#5{
\def\temp##1##2##3##4##5##6{#5}% Substitute placeholders for the arguments the user put in the body of the macro -- we'll replace these with actual pounds later.
\sseq@temptoks\@xp{\temp\ppfour\ppfive\ppsix\ppseven\ppeight\ppnine}%
\edef\helper{\@xp\@nx\csname \sseq@macroname#1@\endcsname}
\sseq@eval{\@nx\DeclareDocumentCommand\@nx#1{O{}u(u,u)}{\@xp\@nx\helper\unexpanded{{##1}{##3}{##4}}}}
\chardef\sseq@temp=3\relax
\sseq@eval{\gdef\@xp\@nx\helper\sseqnewcmd@makearglist{#4}{\the\sseq@temptoks}}
\bgroup % Now we need to replace those fake \ppn placeholders with real pounds. Because of \lowercase, real pounds are *'s.
\@xp\sseq@patchrepeat\helper{\options}{*1}%
\@xp\sseq@patchrepeat\helper{#2}{*2}%
\@xp\sseq@patchrepeat\helper{#3}{*3}%
\@xp\sseq@patchrepeat\helper{\ppfour}{*4}%
\@xp\sseq@patchrepeat\helper{\ppfive}{*5}%
\@xp\sseq@patchrepeat\helper{\ppsix}{*6}%
\@xp\sseq@patchrepeat\helper{\ppseven}{*7}%
\@xp\sseq@patchrepeat\helper{\ppeight}{*8}%
\@xp\sseq@patchrepeat\helper{\ppnine}{*9}%
\sseq@eval{\global\let\@xp\@nx\helper\@xp\@nx\helper}%
\egroup
}
\def\sseqnewdcmd@#1(#2,#3)[#4]#5{
\ifnum#4>5 \sseq@error{Commands defined using '\string\sseqnewdcmd' can take at most five arguments}\fi
\def\temp##1##2##3##4##5{#5}% Substitute placeholders for the arguments the user put in the body of the macro -- we'll replace these with actual pounds later.
\sseq@temptoks\@xp{\temp\ppfive\ppsix\ppseven\ppeight\ppnine}%
\edef\helpera{\@xp\@nx\csname \sseq@macroname#1@\endcsname}
\edef\helperb{\@xp\@nx\csname \sseq@macroname#1@@\endcsname}
\sseq@eval{\@nx\DeclareDocumentCommand\@nx#1{O{}u(u)}{\@xp\@nx\helper\unexpanded{{##1}{##3}{##4}}}}
\chardef\sseq@temp=4\relax
\sseq@eval{\gdef\@xp\@nx\helper\sseqnewcmd@makearglist{#4}{\the\sseq@temptoks}}
\bgroup % Now we need to replace those fake \ppn placeholders with real pounds. Because of \lowercase, real pounds are *'s.
\@xp\sseq@patchrepeat\helper{\options}{*1}%
\@xp\sseq@patchrepeat\helper{\dpage}{*2}%
\@xp\sseq@patchrepeat\helper{#2}{*3}%
\@xp\sseq@patchrepeat\helper{#3}{*4}%
\@xp\sseq@patchrepeat\helper{\ppfive}{*5}%
\@xp\sseq@patchrepeat\helper{\ppsix}{*6}%
\@xp\sseq@patchrepeat\helper{\ppseven}{*7}%
\@xp\sseq@patchrepeat\helper{\ppeight}{*8}%
\@xp\sseq@patchrepeat\helper{\ppnine}{*9}%
\sseq@eval{\global\let\@xp\@nx\helper\@xp\@nx\helper}%
\egroup
}
}% end lowercase
\def\sseqnewcmd@makearglist#1{%
\unexpanded{##1##2##3}%
\@xp\sseqnewcmd@makearglist@\the\numexpr#1+\sseq@temp
}
\def\sseqnewcmd@makearglist@#1{%
\ifnum#1>\sseq@temp
\@xp\sseqnewcmd@makearglist@\the\numexpr#1-1\unexpanded{#####1}%
\fi
}
\def\sseq@patchrepeat#1#2#3{\patchcmd#1{#2}{#3}{\sseq@patchrepeat#1{#2}{#3}}{}}
%%%%%% %%%%%%
%% %%
%% Load and Store %%
%% %%
%%%%%% %%%%%%
% These are attributes that come with a given spectral sequence (by name)
% All of these values are loaded at the beginning of sseqpage (and of sseqdata if an existing sseq is being modified).
% They are then stored together at the end of sseqdata (and of sseqpage if "keep changes" option is present).
\def\sseq@storelist{}
\def\sseq@storelist@setdefaults{}
\def\sseq@addtostorelist#1#2{%
\sseq@g@addto@macro\sseq@storelist{\\#1}%
\sseq@x@addto@macro\sseq@storelist@setdefaults{\global\let\@nx#1\@xp\@nx\csname \sseq@macroname#1@default\endcsname}%
\@xp\gdef\csname\sseq@macroname#1@default\endcsname{#2}%
}
\def\sseq@addiftostorelist#1{\sseq@addiftostorelistopt{#1}{false}}
\def\sseq@addiftostorelist@truedefault#1{\sseq@addiftostorelistopt{#1}{true}}
\def\sseq@addiftostorelistopt#1#2{%
\@xp\newif\csname ifsseq@#1\endcsname
\sseq@g@addto@macro\sseq@storelist{\sseq@storelistif{#1}}%
\sseq@x@addto@macro\sseq@storelist@setdefaults{\@xp\@nx\csname sseq@#1@default\endcsname}%
\@xp\xdef\csname sseq@#1@default\endcsname{\global\@xp\@nx\csname sseq@#1#2\endcsname}%
}
\def\sseq@addkeytostorelist#1#2{
\sseq@g@addto@macro\sseq@storelist{\sseq@storelistkey{#1}}%
\sseq@x@addto@macro\sseq@storelist@setdefaults{
\global\let\@xp\@nx\csname pgfk@#1/.@cmd\endcsname\@xp\@nx\csname pgfk@#1/.@cmd@default\endcsname
\global\let\@xp\@nx\csname pgfk@#1/.@body\endcsname\@xp\@nx\csname pgfk@#1/.@body@default\endcsname
}%
\pgfkeysdef{#1}{#2}%
\global\@xp\let\csname pgfk@#1/.@cmd@default\@xp\endcsname\csname pgfk@#1/.@cmd\endcsname
\global\@xp\let\csname pgfk@#1/.@body@default\@xp\endcsname\csname pgfk@#1/.@body\endcsname
}
% transfer data about the current spectral sequence between \<command> and \<command><sseqname>
\def\sseq@storelist@store#1{\global\@xp\let\csname\sseq@macroname#1@@@\sseq@thename\endcsname#1}
\def\sseq@storelist@get#1{\global\@xp\let\@xp#1\csname\sseq@macroname#1@@@\sseq@thename\endcsname}
\def\sseq@storelistif@store#1{%
\@xp\edef\csname sseq@storeif@#1\endcsname{\csname ifsseq@#1\endcsname \@xp\@nx\csname sseq@#1true\endcsname\else\@xp\@nx\csname sseq@#1false\endcsname\fi}%
\@xp\sseq@storelist@store\csname sseq@storeif@#1\endcsname
}
\def\sseq@storelistif@get#1{
\@xp\sseq@storelist@get\csname sseq@storeif@#1\endcsname
\csname sseq@storeif@#1\endcsname
}
\def\sseq@storelistkey@store#1{
\global\@xp\let\csname pgfk@#1/.@cmd@@@\sseq@thename\@xp\endcsname\csname pgfk@#1/.@cmd\endcsname
\global\@xp\let\csname pgfk@#1/.@body@@@\sseq@thename\@xp\endcsname\csname pgfk@#1/.@body\endcsname
}
\def\sseq@storelistkey@get#1{
\global\@xp\let\csname pgfk@#1/.@cmd\@xp\endcsname\csname pgfk@#1/.@cmd@@@\sseq@thename\endcsname
\global\@xp\let\csname pgfk@#1/.@body\@xp\endcsname\csname pgfk@#1/.@body@@@\sseq@thename\endcsname
}
\def\sseq@storecmds{\let\\\sseq@storelist@store\let\sseq@storelistif\sseq@storelistif@store\let\sseq@storelistkey\sseq@storelistkey@store\sseq@storelist}
\def\sseq@getcmds{\let\\\sseq@storelist@get\let\sseq@storelistif\sseq@storelistif@get\let\sseq@storelistkey\sseq@storelistkey@get\sseq@storelist}
%%%% New "poor man's OOP" Load/Store
% Directly stores things into commands that are annotated with the name of the spectral sequence.
% I use this primarily for commands that won't necessarily exist for every spectral sequence
% for instance because it has the description of a particular class or differential as part of its name
\def\sseq@obj@fullname#1{sseq.\sseq@thename.#1}
\def\sseq@obj#1{\csname sseq.\sseq@thename.#1\endcsname}
\def\sseq@obj@gdef#1{\@xptwo\gdef\sseq@obj{#1}}
\def\sseq@obj@xdef#1{\@xptwo\xdef\sseq@obj{#1}}
\def\sseq@obj@xodef#1{\@xp\gdef\csname \sseq@obj@fullname{#1}\@xp\endcsname\@xp}
\def\sseq@obj@let#1{\@xptwo\let\sseq@obj{#1}}
\def\sseq@obj@gletcsname#1#2{\global\@xp\let\csname\sseq@obj@fullname{#1}\@xp\endcsname\csname#2\endcsname}
\def\sseq@obj@gletobj#1#2{\global\@xp\let\csname\sseq@obj@fullname{#1}\@xp\endcsname\csname\sseq@obj@fullname{#2}\endcsname}
\def\sseq@obj@undef#1{\@xptwo\let\sseq@obj{#1}\relax}
\def\sseq@obj@show#1{\@xptwo\show\sseq@obj{#1}}
\def\sseq@obj@ifundef#1{\@ifundefined{\sseq@obj@fullname{#1}}}
\def\sseq@obj@ifdef#1#2#3{\@ifundefined{\sseq@obj@fullname{#1}}{#3}{#2}}
\def\sseq@obj@inc#1{\bgroup\sseq@tempcount\sseq@obj{#1}\relax\advance\sseq@tempcount\@ne\sseq@obj@xdef{#1}{\the\sseq@tempcount}\egroup}
\def\sseq@obj@gaddto{\@xptwo\sseq@g@addto@macro\sseq@obj}
\def\sseq@obj@xaddto{\@xptwo\sseq@x@addto@macro\sseq@obj}
\def\sseq@obj@xoaddto#1{\@xp\sseq@g@addto@macro\csname \sseq@obj@fullname{#1}\@xp\endcsname\@xp}
\def\sseq@obj@map#1#2{\def\\##1{#2}\sseq@obj{#1}}
\def\sseq@obj@ifchanged#1#2#3{\sseq@obj@ifundef{#1.changed}{#3}{#2}}
\def\sseq@obj@changedtrue#1{\sseq@obj@gdef{#1.changed}{}}
\def\sseq@obj@changedfalse#1{\sseq@obj@undef{#1.changed}}
\def\sseq@cleanup@obj#1{
\ifsseq@keepchanges\else
\sseq@obj@ifchanged{#1}{}{
\sseq@obj@changedtrue{#1}
\sseq@x@addto@macro\sseq@pagecleanup{
\@xptwo\ifx\sseq@obj{#1}\relax
\global\@nx\sseq@obj@let{#1}\relax
\else
\@nx\sseq@obj@gdef{#1}{\unexpanded\@xpthree{\sseq@obj{#1}}}
\fi
\@nx\sseq@obj@changedfalse{#1}
}
}
\fi
}
%%%% add to macro commands
\def\sseq@d@addto@macro#1#2{\@xp\def\@xp#1\@xp{#1#2}}
\def\sseq@e@addto@macro#1#2{\edef#1{\unexpanded\@xp{#1}#2}} % let #2 be expanded
\def\sseq@eo@addto@macro#1#2{\edef#1{\unexpanded\@xp{#1}\unexpanded\@xp{#2}}} % let #2 be expanded once
\def\sseq@g@addto@macro#1#2{\@xp\gdef\@xp#1\@xp{#1#2}}
\def\sseq@x@addto@macro#1#2{\xdef#1{\unexpanded\@xp{#1}#2}} % let #2 be expanded
\def\sseq@protected@edef{\let\sseq@store@slsl\\\def\\{\protect\\}\let\@@protect \protect \let \protect \@unexpandable@protect \afterassignment \sseq@restore@protect \edef}
\def\sseq@protected@xdef{\let\sseq@store@slsl\\\def\\{\protect\\}\let\@@protect \protect \let \protect \@unexpandable@protect \afterassignment \sseq@restore@protect \xdef}
\def\sseq@restore@protect{\let\protect\@@protect\let\\\sseq@store@slsl}
\def\sseq@xprotected@addto@macro#1#2{\sseq@protected@xdef#1{\unexpanded\@xp{#1}#2}}
%%%% Saved paths, temporary saved paths, background saved paths
% \sseq@savedpaths@whatever is redefined to be \sseq@savedpaths@whatever@standard or \sseq@savedpaths@whatever@temporary depending on context
% This simplifies the code a lot because I don't have to check again where I should put things.
\sseq@addtostorelist\sseq@savedpaths{}
\def\sseq@tempsavedpaths{}
\def\sseq@savedpaths@addclass@standard#1{\sseq@x@addto@macro\sseq@savedpaths{\@nx\sseq@class@draw@ifpage{#1}}}
\def\sseq@savedpaths@adddifferential@standard#1{\sseq@x@addto@macro\sseq@savedpaths{\@nx\sseq@differential@draw@ifpage{#1}}}
\def\sseq@savedpaths@addstructline@standard#1{\sseq@x@addto@macro\sseq@savedpaths{\@nx\sseq@structline@draw@ifpage{#1}}}
\def\sseq@savedpaths@add@standard{\sseq@g@addto@macro\sseq@savedpaths}
\def\sseq@savedpaths@xadd@standard{\sseq@x@addto@macro\sseq@savedpaths}
\def\sseq@savedpaths@show@standard{\show\sseq@savedpaths}
\def\sseq@scope@savedpaths@add@standard#1{\sseq@savedpaths@add@standard{#1}\sseq@savedpaths@add@background{#1}}
\def\sseq@savedpaths@addclass@temporary#1{\sseq@x@addto@macro\sseq@tempsavedpaths{\@nx\sseq@class@draw@ifpage{#1}}}
\def\sseq@savedpaths@adddifferential@temporary#1{\sseq@x@addto@macro\sseq@tempsavedpaths{\@nx\sseq@differential@draw@ifpage{#1}}}
\def\sseq@savedpaths@addstructline@temporary#1{\sseq@x@addto@macro\sseq@tempsavedpaths{\@nx\sseq@structline@draw@ifpage{#1}}}
\def\sseq@savedpaths@add@temporary{\sseq@g@addto@macro\sseq@tempsavedpaths}
\def\sseq@savedpaths@xadd@temporary{\sseq@x@addto@macro\sseq@tempsavedpaths}
\def\sseq@savedpaths@show@temporary{\show\sseq@tempsavedpaths}
\def\sseq@scope@savedpaths@add@temporary#1{\sseq@savedpaths@add@temporary{#1}\sseq@savedpaths@add@background{#1}}
\def\sseq@savedpaths@addclass@background#1{\sseq@error@internal{\@nx\sseq@savedpaths@addclass occurred in background mode}}
\def\sseq@savedpaths@adddifferential@background#1{\sseq@error@internal{\@nx\sseq@savedpaths@adddifferential occurred in background mode}}
\def\sseq@savedpaths@addstructline@background#1{\sseq@error@internal{\@nx\sseq@savedpaths@addstructline occurred in background mode}}
\def\sseq@savedpaths@add@background{\sseq@g@addto@macro\sseq@savedbackgroundpaths}
\def\sseq@savedpaths@xadd@background{\sseq@x@addto@macro\sseq@savedbackgroundpaths}
\def\sseq@savedpaths@show@background{\show\sseq@savedbackgroundpaths}
\def\sseq@setsavedpaths#1{%
\@xp\let\@xp\sseq@savedpaths@addclass \csname sseq@savedpaths@addclass@#1\endcsname
\@xp\let\@xp\sseq@savedpaths@adddifferential\csname sseq@savedpaths@adddifferential@#1\endcsname
\@xp\let\@xp\sseq@savedpaths@addstructline \csname sseq@savedpaths@addstructline@#1\endcsname
\@xp\let\@xp\sseq@savedpaths@add \csname sseq@savedpaths@add@#1\endcsname
\@xp\let\@xp\sseq@savedpaths@xadd \csname sseq@savedpaths@xadd@#1\endcsname
\pgfutil@ifundefined{sseq@scope@savedpaths@add@#1}{}{%
\@xp\let\@xp\sseq@savedpaths@show \csname sseq@savedpaths@show@#1\endcsname
\@xp\let\@xp\sseq@scope@savedpaths@add \csname sseq@scope@savedpaths@add@#1\endcsname
}%
}
\def\sseq@usesavedpaths{%
\sseq@savedpaths
\sseq@clearchangestyles
\sseq@tempsavedpaths
\gdef\sseq@tempsavedpaths{}%
}
%%% Install user commands
% copy commands into user namespace by removing sseq@ prefixes
% given a list of commands, \let\thiscommand\sseq@thiscommand on each one
\def\sseq@usermacrolist{\class\replaceclass\d\structline\classoptions\doptions\structlineoptions\circleclasses
\pgfmathparse\isalive\getdtarget\lastx\lasty\savestack\restorestack\pushstack}
\def\sseq@installusermacros{\@xp\sseq@installusermacros@\sseq@usermacrolist\sseq@nil}
\def\sseq@installusermacros@#1{%
\ifx#1\sseq@nil\else % if so, that was the last command in the list
\@xp\let\@xp#1\csname sseq@\sseq@macroname#1\endcsname
\@xp\sseq@installusermacros@
\fi %
}
%%%%%% %%%%%%
%% %%
%% Patch \foreach error messages %%
%% %%
%%%%%% %%%%%%
% All this complicated foreach patching only currently gets applied to making better error messages...
% Put together an error message that says which stage in the for loop caused the error
\def\sseq@builderrorinfo@foreach{%
\let\sseq@errorinfo\sseq@errorinfo@foreach % The starting message, which says we're in a for each loop and these are the variables involved
% Now print each of the current saved values
\let\\\sseq@errorinfo@foreach@slsl % Iterator to print out "variable = value"
\sseq@context@tempcount\z@
\loop % Work through each layer of context / foreach loop
\advance\sseq@context@tempcount\@ne
\csname sseq@for@savedtoks\the\sseq@context@tempcount\endcsname
\ifnum\sseq@context@tempcount<\sseq@context@depth\repeat %
}
\def\sseq@errorinfo@foreach@slsl#1#2{% No semicolon before the first variable
\sseq@g@addto@macro\sseq@errorinfo{ \@nx#1= #2}\let\\\sseq@errorinfo@foreach@slsl@ii
}
\def\sseq@errorinfo@foreach@slsl@ii#1#2{%
\sseq@g@addto@macro\sseq@errorinfo{; \@nx#1= #2}%
}
\def\sseq@pgffor@atbeginforeach{%
\begingroup %
\let\protect\empty % prevent issues if protected variables like \xmax are used as the loop max
\let\sseq@builderrorinfo\sseq@builderrorinfo@foreach % Install foreach error annotations
\let\errmessage\sseq@errmessage
\let\sseq@error@\sseq@errorwithinfo
\advance\sseq@context@depth\@ne
\sseq@for@clearsavedtoks % empty the saved variables at this level
}
\def\sseq@for@clearsavedtoks{\@xp\gdef\csname sseq@for@savedtoks\the\sseq@context@depth\endcsname{}}
\def\sseq@for@savemacro#1#2{\@xp\sseq@g@addto@macro\csname sseq@for@savedtoks\the\sseq@context@depth\endcsname{\\#1{#2}}}
\def\sseq@for@esavemacro#1#2{\@xp\sseq@x@addto@macro\csname sseq@for@savedtoks\the\sseq@context@depth\endcsname{\@nx\\\@nx#1{#2}}}
\def\sseq@for@savemacros{\@ifnextchar\def{\sseq@for@savemacros@}{}}
\def\sseq@for@savemacros@#1#2#3{\sseq@for@savemacro#2{#3}\@ifnextchar\def{\sseq@for@savemacros@}{}}
\def\sseq@for@savedpaths@add#1{%
\sseq@savedpaths@add@background{#1}%
\ifsseq@keepchanges
\sseq@savedpaths@add@standard{#1}%
\else
\sseq@savedpaths@add@temporary{#1}%
\fi
}
%% Patch \foreach (Modifies tikz code)
% Perform a deep copy
% All of this \foreach stuff is defined by tikz in the file /pgf/utilities/pgffor.code.tex
\def\sseq@pgffor@@vars@opt[#1]{\pgfkeys{/sseqpages/foreach/.cd,#1}\pgffor@vars}
\let\sseq@pgffor@doloop\pgffor@doloop
\let\sseq@pgffor@invokebody\pgffor@invokebody
\let\sseq@pgffor@assign@@@parse\pgffor@assign@@@parse
\let\sseq@pgffor@count@@parse\pgffor@count@@parse
\let\sseq@pgffor@remember@@@parse\pgffor@remember@@@parse
\let\sseq@pgffor@remember@@@parse@old\pgffor@remember@@@parse@old
\let\sseq@pgffor@multiassignfinal\pgffor@multiassignfinal
\let\sseq@pgffor@default@endgroup\pgffor@default@endgroup
\let\sseq@pgffor@atendforeach\pgffor@atendforeach
\def\sseq@patchfor{%
\let\pgffor@@vars@opt\sseq@pgffor@@vars@opt
\let\pgffor@atbeginforeach\sseq@pgffor@atbeginforeach
\let\pgffor@invokebody\sseq@pgffor@invokebody
\let\pgffor@doloop\sseq@pgffor@doloop
\let\pgffor@assign@@@parse\sseq@pgffor@assign@@@parse
\let\pgffor@count@@parse\sseq@pgffor@count@@parse
\let\pgffor@remember@@@parse\sseq@pgffor@remember@@@parse
\let\pgffor@remember@@@parse@old\sseq@pgffor@remember@@@parse@old
\let\pgffor@multiassignfinal\sseq@pgffor@multiassignfinal
\let\pgffor@default@endgroup\sseq@pgffor@default@endgroup
\let\pgffor@atendforeach\sseq@pgffor@atendforeach
}
%% Now modify all of the commands to tell sseqpages about the variable values
\def\sseq@for@nopatch{\sseq@error@internal{failed to patch \string\foreach}}
\patchcmd\sseq@pgffor@invokebody % store setting after
{\expandafter\expandafter\expandafter\def\expandafter\pgffor@var\expandafter{\pgffor@value}}
{\expandafter\expandafter\expandafter\def\expandafter\pgffor@var\expandafter{\pgffor@value}%
\@xp\sseq@for@esavemacro\pgffor@var{\pgffor@var}}
{}{\sseq@for@nopatch}
\patchcmd\sseq@pgffor@invokebody
{\expandafter\expandafter\expandafter\pgffor@reset@hooks\expandafter\pgffor@beginhook\expandafter\pgffor@body\pgffor@endhook}
{\expandafter\expandafter\expandafter\pgffor@reset@hooks\expandafter\pgffor@beginhook\expandafter\pgffor@body\pgffor@endhook}
{}{\sseq@for@nopatch}
\patchcmd\sseq@pgffor@doloop % store setting before
{\ifx\pgffor@assign@before@code}
{\@xp\sseq@for@esavemacro\pgffor@var{\pgffor@var}%
\ifx\pgffor@assign@before@code}
{}{\sseq@for@nopatch}
\patchcmd\sseq@pgffor@invokebody % reset stored definitions before
{\ifx\pgffor@assign@after@code}
{\sseq@for@clearsavedtoks%
\ifx\pgffor@assign@after@code}
{}{\sseq@for@nopatch}
\patchcmd\sseq@pgffor@doloop % reset stored definitions before
{\ifx\pgffor@assign@after@code}
{\sseq@for@clearsavedtoks%
\ifx\pgffor@assign@after@code}
{}{\sseq@for@nopatch}
\patchcmd\sseq@pgffor@remember@@@parse@old
{\pgfutil@append@tomacro{\pgffor@assign@once@code}{\def#2{#4}}}
{\pgfutil@append@tomacro{\pgffor@assign@once@code}{\def#2{#4}\sseq@for@savemacro#2{#4}}}
{}{\sseq@for@nopatch}
\patchcmd\sseq@pgffor@assign@@@parse
{\pgfutil@append@tomacro{\pgffor@assign@once@code}{\pgfmathparse{#2}\let#1=\pgfmathresult}}
{\pgfutil@append@tomacro{\pgffor@assign@once@code}{\pgfmathparse{#2}\let#1=\pgfmathresult\sseq@for@esavemacro#1{\pgfmathresult}}}
{}{\sseq@for@nopatch}
\patchcmd\sseq@pgffor@assign@@@parse
{\pgfutil@append@tomacro{\pgffor@assign@once@code}{\def#1{#2}}}
{\pgfutil@append@tomacro{\pgffor@assign@once@code}{\def#1{#2}\sseq@for@savemacro#1{#2}}}
{}{\sseq@for@nopatch}
\patchcmd\sseq@pgffor@assign@@@parse
{\pgfutil@append@tomacro{\pgffor@assign@before@code}{\pgfmathparse{#2}\let#1=\pgfmathresult}}
{\pgfutil@append@tomacro{\pgffor@assign@before@code}{\pgfmathparse{#2}\let#1=\pgfmathresult\sseq@for@esavemacro#1{\pgfmathresult}}}
{}{\sseq@for@nopatch}
\patchcmd\sseq@pgffor@assign@@@parse
{\pgfutil@append@tomacro{\pgffor@assign@before@code}{\def#1{#2}}}
{\pgfutil@append@tomacro{\pgffor@assign@before@code}{\def#1{#2}\sseq@for@savemacro#1{#2}}}
{}{\sseq@for@nopatch}
\patchcmd\sseq@pgffor@count@@parse
{\pgfutil@append@tomacro\pgffor@assign@before@code{\pgfmathparse{int(#1+1)}\let#1=\pgfmathresult}}
{\pgfutil@append@tomacro\pgffor@assign@before@code{\pgfmathparse{int(#1+1)}\let#1=\pgfmathresult\sseq@for@esavemacro#1{\pgfmathresult}}}
{}{\sseq@for@nopatch}
\patchcmd\sseq@pgffor@remember@@@parse
{\pgfutil@append@tomacro{\pgffor@assign@after@code}{\expandafter\def\expandafter#1\expandafter{\the#2}}}
{\pgfutil@append@tomacro{\pgffor@assign@after@code}{\expandafter\def\expandafter#1\expandafter{\the#2}\sseq@for@esavemacro#1{\the#2}}}
{}{\sseq@for@nopatch}
\patchcmd\sseq@pgffor@remember@@@parse
{\pgfutil@append@tomacro{\pgffor@assign@after@code}{\expandafter\def\expandafter#1\expandafter{#2}}}
{\pgfutil@append@tomacro{\pgffor@assign@after@code}{\expandafter\def\expandafter#1\expandafter{#2}\@xp\sseq@for@savemacro\@xp#1\@xp{#2}}}
{}{\sseq@for@nopatch}
\patchcmd\sseq@pgffor@remember@@@parse@old
{\pgfutil@append@tomacro{\pgffor@assign@after@code}{\edef#2{#1}}}
{\pgfutil@append@tomacro{\pgffor@assign@after@code}{\edef#2{#1}\sseq@for@esavemacro#2{#1}}}
{}{\sseq@for@nopatch}
\patchcmd\sseq@pgffor@multiassignfinal
{\expandafter\expandafter\expandafter\def\expandafter\pgffor@currentvar\expandafter{\pgffor@temp}}
{\expandafter\expandafter\expandafter\def\expandafter\pgffor@currentvar\expandafter{\pgffor@temp}%
\@xp\sseq@for@esavemacro\pgffor@currentvar{\pgffor@temp}}
{}{\sseq@for@nopatch}
\patchcmd\sseq@pgffor@default@endgroup
{\else\pgffor@remember@once@expanded}
{\else\pgffor@remember@once@expanded %
\@xp\sseq@for@savemacros\pgffor@remember@once@expanded}
{}{\sseq@for@nopatch}
\patchcmd\sseq@pgffor@atendforeach
{\else\pgffor@remember@expanded}
{\else\pgffor@remember@expanded %
\@xp\sseq@for@savemacros\pgffor@remember@expanded}
{}{\sseq@for@nopatch}
\pretocmd\sseq@pgffor@atendforeach{\sseq@for@clearsavedtoks}{}{\sseq@for@nopatch}
%%%%%% %%%%%%
%% %%
%% Some Internal Utilities %%
%% %%
%%%%%% %%%%%%
\def\sseq@iffullcoord(#1){\@xp\sseq@iffullcoord@#1,\sseq@nil}
\def\sseq@iffullcoord@#1,#2,#3\sseq@nil{\ifx\sseq@nil#3\sseq@nil\@xp\@secondoftwo\else\@xp\@firstoftwo\fi}
% Only works for full coordinates. Used for error checking in \replaceclass and \d.
\def\sseq@ifundefcoord{\@xp\sseq@ifundefcoord@}
\def\sseq@ifundefcoord@(#1){%
\sseq@obj@ifundef{class.(#1).num}%
}
\def\sseq@ifdead#1{\ifnum\sseq@obj{class.#1[\sseq@obj{class.#1.num}].page}<\sseq@infinity\relax \@xp\@firstoftwo\else\@xp\@secondoftwo\fi}
\def\sseq@getdeathpage#1{\sseq@obj{class.#1[\sseq@obj{class.#1.num}].page}}
%%%%%%%%
%%
%% Coordinate Parsers
%%
%%%%%%%%
% These do all of the work of taking a coordinate of the form (x,y), (x,y,n), or (x,y,tag) and turning them
% into the internal representation needed for the rest of the package.
% This comes in two parts:
% \sseq@parsecoord@maincoord -- separates a coordinate into {x,y}{n or tag}, numerically evaluates x and y, and adds in the values of \sseq@x and \sseq@y
% \sseq@parsecoord@index -- decides which class {n or tag} represents
%
% There are three interface commands:
% \sseq@parsecoord -- for most things
% \sseq@cparsecoord -- for \class (but not for \replaceclass or \classoptions). Doesn't use \sseq@parsecoord@index at all.
% \sseq@dparsecoord -- for \d and \doptions
% \sseq@parsecoordex -- for \isalive: the body of a page constraint needs to be \edef'd so we need a completely expandable version.
% The expandable version doesn't have any error checking -- to get the error checking, we pass the coordinates once through the unexpandable version
% inside of an hbox.
\def\sseq@errortype{}
\def\sseq@printerrortype{\@xp\sseq@ifempty\@xp{\sseq@errortype}{}{ for \sseq@errortype}}
%% Pulls off x,y and evaluates them, puts n or empty into a separate variable.
% #1 -- a coordinate of the form {x,y} or {x,y,stuff}
\ExplSyntaxOn
\def\sseq@parsecoord@maincoord{\exp_args:Nx\sseq@parsecoord@maincoord@}
\ExplSyntaxOff
\def\sseq@parsecoord@maincoord@#1{%
\pgfutil@in@,{#1}
\ifpgfutil@in@
\sseq@parsecoord@maincoord@@#1,\sseq@nil
\else
\sseq@obj@ifdef{class.namedclass.#1}{
\def\sourcename{#1}
\@xpthree\sseq@parsecoord@maincoord@named\sseq@obj{class.namedclass.#1}\sseq@nil
}{
\sseq@error{Invalid coordinate\sseq@printerrortype}
}
\fi
}
\def\sseq@parsecoord@maincoord@@#1,#2,#3\sseq@nil{%
\sseq@ifintexpr{#1}{
\sseq@ifintexpr{#2}{}{\sseq@error{Invalid y coordinate\sseq@printerrortype}}%
\edef\sseq@xcoord{\the\numexpr\sseq@x+(#1)\relax}%
\edef\sseq@ycoord{\the\numexpr\sseq@y+(#2)\relax}%
\edef\sseq@xycoord{\sseq@xcoord,\sseq@ycoord}%
\sseq@ifempty{#3}{\let\sseq@restcoord\pgfutil@empty}{%
\edef\sseq@restcoord{\sseq@removecomma#3\sseq@nil}%
}%
}{% We might be a name...
\sseq@obj@ifdef{class.namedclass.#1}{
\def\sourcename{#1}
\@xpthree\sseq@parsecoord@maincoord@named\sseq@obj{class.namedclass.#1}\sseq@nil
\edef\sseq@restcoord{\sseq@removecomma#2,#3\sseq@nil}
}{
\sseq@error{Invalid x coordinate\sseq@printerrortype}
}
}%
}%
\def\sseq@parsecoord@maincoord@named#1,#2,#3\sseq@nil{
\def\sseq@xcoord{#1}%
\def\sseq@ycoord{#2}%
\edef\sseq@xycoord{\sseq@xcoord,\sseq@ycoord}
\def\sseq@restcoord{}
\def\sseq@rawindex{#3}
\def\sseq@index{#3}
}
\def\sseq@removecomma#1,\sseq@nil{#1}
% "Input" to this command is stored in the following commands:
% \sseq@xycoord -- x,y
% \sseq@rawindex -- n
% \sseq@errortype -- description for error messages
\def\sseq@parsecoord@index{%
\ifx\sseq@rawindex\pgfutil@empty
\def\sseq@index{1}
\else
\sseq@obj@ifdef{partcoord.(\sseq@xycoord).tag.\sseq@class@tagprefix\sseq@rawindex}{% If the raw index is a tag
\edef\sseq@index{\sseq@obj{partcoord.(\sseq@xycoord).tag.\sseq@class@tagprefix\sseq@rawindex}}
}{%
\sseq@ifintexpr{\sseq@rawindex}{%
\sseq@obj@ifundef{partcoord.(\sseq@xycoord).numnodes}{\sseq@error{No classes yet exist in (\sseq@xycoord)}}{}%
\ifnum\sseq@rawindex<\z@%
\edef\sseq@index{\the\numexpr\sseq@obj{partcoord.(\sseq@xycoord).numnodes} + \sseq@rawindex + \@ne\relax}%
\ifnum\sseq@index<\@ne
\sseq@error{Index '\sseq@rawindex' provided\sseq@printerrortype\space is out of bounds -- only \sseq@obj{partcoord.(\sseq@xycoord).numnodes} classes exist at position (\sseq@xycoord)}%
\fi
\else
\ifnum\sseq@rawindex>\sseq@obj{partcoord.(\sseq@xycoord).numnodes}\relax
\sseq@error{Index '\sseq@rawindex' provided\sseq@printerrortype\space is out of bounds -- only \sseq@obj{partcoord.(\sseq@xycoord).numnodes} classes exist at position (\sseq@xycoord)}%
\fi
\edef\sseq@index{\the\numexpr\sseq@rawindex}
\fi
}{
\sseq@error{Tag '\sseq@rawindex' provided\sseq@printerrortype\space is not a valid integer expression but no such tag exists in position (\sseq@xycoord)}%
}
}
\fi
}
% #1 -- name to define
% #2 -- coordinate
% #3 -- the error message
\def\sseq@parsecoord#1#2#3{%
\def\sseq@index{}
\def\sseq@errortype{#3}
\sseq@parsecoord@maincoord{#2}%
\let\sseq@rawindex\sseq@restcoord
\ifx\sseq@index\pgfutil@empty
\sseq@parsecoord@index
\fi
\@xp\let\csname \sseq@macroname#1@partial\endcsname\sseq@xycoord
\edef#1{(\sseq@xycoord,\sseq@index)}%
\@xp\edef\csname\sseq@macroname#1nopar\endcsname{\sseq@xycoord,\sseq@index}
\@xp\def\csname\sseq@macroname#1name\endcsname{(#2)}%
\@xp\edef\csname\sseq@macroname#1@internalname\endcsname{sseq{\sseq@xycoord,\sseq@index}}%
}
% #1 -- coordinate
\def\sseq@cparsecoord#1{%
\def\sseq@index{}
\sseq@parsecoord@maincoord{#1}{}%