summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/latex
diff options
context:
space:
mode:
authorKarl Berry <karl@freefriends.org>2017-06-19 21:07:40 +0000
committerKarl Berry <karl@freefriends.org>2017-06-19 21:07:40 +0000
commit787b1d312f205766480ce986a9f98548cc396dae (patch)
treea01010a46833874f9247534568d49f35446a3cc7 /Master/texmf-dist/tex/latex
parent24274bfce4fb35c537447dace80be3d48d7c250b (diff)
spectralsequences (19jun17)
git-svn-id: svn://tug.org/texlive/trunk@44639 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/tex/latex')
-rw-r--r--Master/texmf-dist/tex/latex/spectralsequences/spectralsequences.sty279
-rw-r--r--Master/texmf-dist/tex/latex/spectralsequences/sseqcheckdefinitions.code.tex170
-rw-r--r--Master/texmf-dist/tex/latex/spectralsequences/sseqdrawing.code.tex990
-rw-r--r--Master/texmf-dist/tex/latex/spectralsequences/sseqforeach.code.tex88
-rw-r--r--Master/texmf-dist/tex/latex/spectralsequences/sseqkeys.code.tex1667
-rw-r--r--Master/texmf-dist/tex/latex/spectralsequences/sseqloadstore.code.tex175
-rw-r--r--Master/texmf-dist/tex/latex/spectralsequences/sseqmacromakers.code.tex389
-rw-r--r--Master/texmf-dist/tex/latex/spectralsequences/sseqmain.code.tex1123
-rw-r--r--Master/texmf-dist/tex/latex/spectralsequences/sseqmessages.code.tex508
-rw-r--r--Master/texmf-dist/tex/latex/spectralsequences/sseqparsers.code.tex1324
10 files changed, 6713 insertions, 0 deletions
diff --git a/Master/texmf-dist/tex/latex/spectralsequences/spectralsequences.sty b/Master/texmf-dist/tex/latex/spectralsequences/spectralsequences.sty
new file mode 100644
index 00000000000..62ff3e40a4f
--- /dev/null
+++ b/Master/texmf-dist/tex/latex/spectralsequences/spectralsequences.sty
@@ -0,0 +1,279 @@
+%%
+%% Package: spectralsequences.sty version 1.0
+%% Author: Hood Chatham
+%% Email: hood@mit.edu
+%% Date: 2017-06-18
+%% License: Latex Project Public License
+%%
+%% A package for drawing spectral sequences
+%%
+
+
+% TODO:
+% label handler key, \sseqnormalizepolynomial
+% speed up off page edges (uses 10% of the draw time for page 0 of tmfass)
+% speed up label nodes
+% try to restrict fragility issues to tooltips and tikz primitives... annoying
+% error messages that should be warnings by default?
+% improve axes options? allow axis to be centered on coordinate or centered between coordinates
+% recover from failing to patch pgfkeys
+
+\NeedsTeXFormat{LaTeX2e}
+\ProvidesPackage{spectralsequences}[2017/06/04 v1.0]
+
+\RequirePackage{tikz}
+\RequirePackage{etoolbox}
+\RequirePackage{xparse}
+\RequirePackage{verbatim}
+\RequirePackage{pdfcomment}
+
+\usetikzlibrary{quotes}
+\usetikzlibrary{fit}
+\usetikzlibrary{positioning}
+\usetikzlibrary{intersections}
+\usetikzlibrary{backgrounds}
+\usepgflibrary{arrows.meta}
+\usetikzlibrary{shapes}
+%\usetikzlibrary{profiler}
+
+\newif\ifsseq@draftmode
+\DeclareOption{draft}{\sseq@draftmodetrue}
+\ProcessOptions\relax
+
+\def\sseq@authorname{Hood Chatham}
+\def\sseq@authoremail{hood@mit.edu}
+
+
+%\sseq@draftmodetrue
+
+%%%%%% %%%%%%
+%% %%
+%% Declarations and preliminaries %%
+%% %%
+%%%%%% %%%%%%
+\newif\ifsseq@inprogress
+
+\newif\ifsseq@hasname
+\newif\ifsseq@updateexisting
+\newif\ifsseq@ispageenv
+\newif\ifsseq@keepchanges
+\newif\ifsseq@keepglobaloptions
+\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
+\newif\ifsseq@anchor
+\sseq@drawedgetrue
+\sseq@tikzprims@integershifttrue
+
+\newif\ifsseq@patchforeach
+\newif\ifsseq@patchfit
+
+\newif\ifsseq@tempif
+\newif\ifsseq@gtempif
+\newif\ifsseq@error
+
+\newtoks\sseq@temptoks
+\newtoks\sseq@temptoksii
+\newtoks\sseq@scope@toks
+
+\newcount\sseq@thepagecount
+\newcount\sseq@anonsseqcount
+\newcount\sseq@x
+\newcount\sseq@y
+\newcount\sseq@tempcount
+\newcount\sseq@tempcountb
+\newcount\sseq@tempx
+\newcount\sseq@tempy
+\newcount\sseq@tempxb
+\newcount\sseq@tempyb
+
+\newcount\sseq@stackdepth
+
+\newdimen\sseq@tooltip@height
+\newdimen\sseq@tooltip@width
+\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.
+\newcount\sseq@infinitycount
+\sseq@infinitycount=\sseq@infinity\relax
+\def\sseq@macroname{\@xp\@gobble\string}
+\def\sseq@gobble@to@nil#1\sseq@nil{}
+\def\sseq@macrogobble#1->{}
+
+% 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}}
+
+
+\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@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}}
+
+%%%% 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@xprotected@addto@macro#1#2{\sseq@protected@xdef#1{\unexpanded\@xp{#1}#2}}
+
+\def\sseq@d@addto@toks#1#2{#1\@xp{\the#1#2}}
+\def\sseq@e@addto@toks#1#2{\sseq@eval{#1{\the#1#2}}}
+
+\def\sseq@d@addto@temptoks{\sseq@d@addto@toks\sseq@temptoks}
+\def\sseq@e@addto@temptoks{\sseq@e@addto@toks\sseq@temptoks}
+
+
+% Used in sseqkeys to delete spaces from style commands.
+\def\sseq@setmacronospaces#1#2{%
+ \bgroup\catcode`\ =9\relax
+ \scantokens{\@xp\egroup\@xp\def\@xp#1\@xp{\csname #2\endcsname}}%
+}
+
+
+\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@ifnil#1{
+ \ifx\sseq@nil#1
+ \@xp\@firstoftwo
+ \else
+ \@xp\@secondoftwo
+ \fi
+}
+
+\let\sseq@breakpoint\relax
+\def\sseq@break#1\sseq@breakpoint{}
+\def\sseq@break@withcleanup#1\sseq@breakpoint#2{}
+
+\def\sseq@breakfi{\fi\sseq@break}
+\def\sseq@breakfifi{\fi\fi\sseq@break}
+\def\sseq@breakfififi{\fi\fi\fi\sseq@break}
+\long\def\sseq@breakdataenv#1\end#2{
+ \def\sseq@tempa{sseqdata}\def\sseq@tempb{#2}\ifx\sseqtempa\sseqtempb
+ \@xp\sseq@breakdataenv@
+ \else
+ \@xp\sseq@breakdataenv
+ \fi
+}
+\def\sseq@breakdataenv@{\let\endsseqdata\sseq@breakendsseqdata\end{sseqdata}}
+
+\long\def\sseq@breakpageenv#1\end#2{
+ \def\sseq@tempa{sseqpage}\def\sseq@tempb{#2}\ifx\sseqtempa\sseqtempb
+ \@xp\sseq@breakpageenv@
+ \else
+ \@xp\sseq@breakpageenv
+ \fi
+}
+\def\sseq@breakpageenv@{\let\endsseqpage\sseq@breakendsseqpage\end{sseqpage}}
+\def\sseq@breakendsseqdata{}
+\def\sseq@breakendsseqpage{}
+
+\def\sseq@seteverythingtonoops{%
+ \let\sseqdata\comment
+ \let\sseqpage\comment
+ \let\sseqkeys\@gobble
+ \let\sseqnewgroup\@gobblethree
+}
+
+% Commands we are going to expose just inside of environments
+\def\sseq@macrolist{%
+ % These are defined in sseqmain:
+ \class\replaceclass\d\structline\classoptions\doptions\structlineoptions\circleclasses
+ % The following are defined in sseqparsers:
+ \pgfmathparse\isalive\lastx\lasty\lastclass\savestack\restorestack\pushstack\nameclass\tagclass
+ \parsecoordinate\parsedifferential\getdtarget\gettag
+ \xcoord\ycoord\page %\xmin\xmax\ymin\ymax % these just get protected
+}
+
+% All the tikz commands. We replace these in our environment too. Replacements defined in sseqparsers.
+\def\sseq@tikzcommands{%
+ \clip\coordinate\draw\fill\filldraw
+ \graph\matrix\node\path\pattern
+ \shade\shadedraw\useasboundingbox
+}
+
+
+\input sseqmessages.code.tex % Exposes directly: \sseqerrortowarning
+\input sseqcheckdefinitions.code.tex
+
+%\sseq@patchforeachfalse
+
+\ifsseq@tempif\else % Set to false in checkdefinitions if it failed to patch the key-value system.
+ \sseq@seteverythingtonoops
+ \sseq@pgfkeyspatchfailed
+\fi
+
+\input sseqloadstore.code.tex % Responsible for installing environment-only macros
+\input sseqmacromakers.code.tex % Exposes directly: \DeclareSseqCommand, \NewSseqCommand, \DeclareSseqGroup, \NewSseqGroup
+
+\input sseqparsers.code.tex % Responsible for making tikz modifications, exposes directly \sseqnormalizemonomial
+
+
+\ifsseq@patchforeach
+ \input sseqforeach.code.tex
+\else
+ \def\sseq@patchfor{}
+\fi
+
+\input sseqkeys.code.tex % Exposes directly: \sseqset
+\input sseqmain.code.tex % Defines all the main commands. Exposes directly: the environments, \xmin, \xmax, etc.
+\input sseqdrawing.code.tex
+
+
+%%% Some default key settings
+\sseqset{
+ edge labels={auto=right},
+ classes={draw,circle,inner sep=0pt,minimum size=0.35em},
+ circle classes={newellipse, ellipse ratio=1.2,draw, inner sep=2pt},
+ edges=draw,
+ math nodes,
+ differentials=->
+}
+
+% Extra commands to expose:
+\let\sseqifempty\sseq@ifempty
+
+\def\sseqpower#1#2{\@xp\sseqtypesetpower@\@xp{\the\numexpr#2}{#1}{1}}
+\def\sseqpowerempty#1#2{\@xp\sseqtypesetpower@\@xp{\the\numexpr#2}{#1}{}}
+\def\sseqtypesetpower@#1#2#3{\ifnum#1=\z@#3\else\ifnum#1=\@ne#2\else#2^{#1}\fi\fi}
diff --git a/Master/texmf-dist/tex/latex/spectralsequences/sseqcheckdefinitions.code.tex b/Master/texmf-dist/tex/latex/spectralsequences/sseqcheckdefinitions.code.tex
new file mode 100644
index 00000000000..bdbc68f51b5
--- /dev/null
+++ b/Master/texmf-dist/tex/latex/spectralsequences/sseqcheckdefinitions.code.tex
@@ -0,0 +1,170 @@
+%%
+%% Package: spectralsequences.sty version 1.0
+%% Author: Hood Chatham
+%% Email: hood@mit.edu
+%% Date: 2017-06-18
+%% License: Latex Project Public License
+%%
+%% File: sseqcheckdefinitions.code.tex
+%%
+%% A few tikz commands are modified in sseqpages. This file checks the definitions of all commands modified. Of course, this is insufficient to ensure that
+%% the behavior isn't completely wrong, but at least it's a sanity check.
+%%
+
+% TODO: we could recover from failing to patch keys.
+
+\sseq@tempiftrue
+\begingroup
+
+\def\sseq@checkdef#1{\def\sseq@temp{\sseq@checkdef@{#1}}\afterassignment\sseq@temp\@xp\def\csname sseq@check@\sseq@macroname#1\endcsname}
+\def\sseq@checkdef@#1{\@xp\ifx\csname sseq@check@\sseq@macroname#1\endcsname#1\else
+ \sseq@tempiffalse
+\fi}
+
+%%
+%% sseqkeys.code.tex
+%%
+
+
+\sseq@checkdef\pgfkeys@case@one{%
+ \pgfkeysifdefined{\pgfkeyscurrentkey/.@cmd}%
+ {\pgfkeysgetvalue{\pgfkeyscurrentkey/.@cmd}{\pgfkeys@code}%
+ \expandafter\pgfkeys@code\pgfkeyscurrentvalue\pgfeov}
+ {\pgfkeys@case@two}%
+}
+
+\sseq@checkdef\pgfkeys@case@two@extern{%
+ \ifx\pgfkeyscurrentvalue\pgfkeysnovalue@text%
+ \pgfkeysvalueof{\pgfkeyscurrentkey}%
+ \else%
+ \pgfkeyslet{\pgfkeyscurrentkey}\pgfkeyscurrentvalue%
+ \fi%
+}
+
+
+\ifsseq@tempif\else
+ \endgroup
+ \sseq@tempiffalse % We'll throw a critical error in spectralsequences.sty to end input
+ \endinput
+\fi
+%%
+%% sseqdrawing.code.tex
+%%
+
+%from \pgf\frontendlayer\tikz\libraries\tikzlibraryfit.code.tex line 81
+\sseq@checkdef\tikz@lib@fit@scan@handle#1{%
+ \iftikz@shapeborder%
+ % Ok, fit all four external anchors, if they exist
+ \tikz@lib@fit@adjust{\pgfpointanchor{\tikz@shapeborder@name}{west}}%
+ \tikz@lib@fit@adjust{\pgfpointanchor{\tikz@shapeborder@name}{east}}%
+ \tikz@lib@fit@adjust{\pgfpointanchor{\tikz@shapeborder@name}{north}}%
+ \tikz@lib@fit@adjust{\pgfpointanchor{\tikz@shapeborder@name}{south}}%
+ \else%
+ \tikz@lib@fit@adjust{#1}%
+ \fi%
+ \tikz@lib@fit@scan%
+}
+
+% from \pgf\frontendlayer\tikz\tikz.code.tex line 5164
+\sseq@checkdef\tikz@calc@anchor#1.#2\tikz@stop{%
+ \pgfpointanchor{\tikz@pp@name{#1}}{#2}%
+}
+
+\ifsseq@tempif
+ \global\sseq@patchfittrue
+\else
+ \sseq@warning{fit-patch-failed}
+ \global\sseq@patchfitfalse
+\fi
+
+\sseq@tempiftrue
+
+
+%%
+%% sseqforeach.code.tex
+%%
+\sseq@checkdef\pgffor@@vars@opt[#1]{\pgfkeys{/pgf/foreach/.cd,#1}\pgffor@vars}
+
+\sseq@checkdef\pgffor@doloop{%
+ \pgffor@begingroup
+ \edef\pgffor@temp{\expandafter\Pgffor@geT\the\pgffor@iter}%
+ \edef\pgffor@incheck{{.0/}{\pgffor@temp/}}%
+ \expandafter\pgfutil@in@\pgffor@incheck%
+ \ifpgfutil@in@%
+ \expandafter\pgffor@strip\pgffor@temp%
+ \fi%
+ \expandafter\pgfutil@in@\expandafter/\expandafter{\pgffor@var}%
+ \ifpgfutil@in@%
+ \expandafter\def\expandafter\pgffor@valuerest\expandafter{\pgffor@temp//\relax}%
+ \expandafter\pgffor@multiassign\pgffor@var/\pgffor@stop/\pgffor@stop/\relax%
+ \else%
+ % Convert to alphabetic sequence, if necessary.
+ \ifpgffor@alphabeticsequence%
+ \pgffor@makealphabetic\pgffor@temp%
+ \expandafter\let\pgffor@var=\pgffor@temp%
+ \else%
+ \expandafter\expandafter\expandafter\def\expandafter\pgffor@var\expandafter{\pgffor@temp}%
+ \fi%
+ \fi%
+ % Insert any context, if any.
+ \ifpgffor@context%
+ \let\pgffor@temp=\pgffor@dots@pre%
+ \expandafter\pgfutil@append@macrotomacro\expandafter%
+ {\expandafter\pgffor@temp\expandafter}\expandafter{\pgffor@var}%
+ \expandafter\pgfutil@append@macrotomacro\expandafter%
+ {\expandafter\pgffor@temp\expandafter}\expandafter{\pgffor@dots@post}%
+ \expandafter\let\pgffor@var=\pgffor@temp%
+ \fi%
+ % Perform assignments before loop body.
+ \ifx\pgffor@assign@before@code\pgfutil@empty%
+ \else%
+ \pgffor@assign@before@code%
+ \fi%
+ %
+ \expandafter\expandafter\expandafter\pgffor@reset@hooks\expandafter\pgffor@beginhook\expandafter\pgffor@body\pgffor@endhook%
+ %
+ % Perform assignments after loop body.
+ \ifx\pgffor@assign@after@code\pgfutil@empty%
+ \else%
+ \pgffor@assign@after@code%
+ \fi%
+ \pgffor@endgroup%
+ \pgffor@loop%
+}
+
+\sseq@checkdef\pgffor@invokebody{%
+ \pgffor@begingroup%
+ \expandafter\pgfutil@in@\expandafter/\expandafter{\pgffor@var}%
+ \ifpgfutil@in@%
+ \expandafter\def\expandafter\pgffor@valuerest\expandafter{\pgffor@value//\relax}%
+ \expandafter\pgffor@multiassign\pgffor@var/\pgffor@stop/\pgffor@stop/\relax%
+ \else%
+ \expandafter\expandafter\expandafter\def\expandafter\pgffor@var\expandafter{\pgffor@value}%
+ \fi%
+ % Execute assign once code.
+ \ifx\pgffor@assign@once@code\pgfutil@empty%
+ \else\pgffor@assign@once@code%
+ \fi%
+ % Execute assign before code.
+ \ifx\pgffor@assign@before@code\pgfutil@empty%
+ \else\pgffor@assign@before@code%
+ \fi%
+ %
+ \expandafter\expandafter\expandafter\pgffor@reset@hooks\expandafter\pgffor@beginhook\expandafter\pgffor@body\pgffor@endhook%
+ % Execute assign after code.
+ \ifx\pgffor@assign@after@code\pgfutil@empty%
+ \else%
+ \pgffor@assign@after@code%
+ \fi%
+ %
+ \pgffor@endgroup%
+}
+
+\ifsseq@tempif
+ \global\sseq@patchforeachtrue
+\else
+ \sseq@warning{foreach-patch-failed}
+ \global\sseq@patchforeachfalse
+\fi
+
+\endgroup \ No newline at end of file
diff --git a/Master/texmf-dist/tex/latex/spectralsequences/sseqdrawing.code.tex b/Master/texmf-dist/tex/latex/spectralsequences/sseqdrawing.code.tex
new file mode 100644
index 00000000000..098e73f9110
--- /dev/null
+++ b/Master/texmf-dist/tex/latex/spectralsequences/sseqdrawing.code.tex
@@ -0,0 +1,990 @@
+%%
+%% Package: spectralsequences.sty version 1.0
+%% Author: Hood Chatham
+%% Email: hood@mit.edu
+%% Date: 2017-06-18
+%% License: Latex Project Public License
+%%
+%% File: sseqdrawing.code.tex
+%%
+%% Defines the macros that draw the features of the spectral sequence (at least, those that aren't drawn by tikz).
+%% Everything here has to be super optimized, because like 90% of the execution time is in these functions.
+%% In particular, tikz is a horrible performance hole that must be avoided at all costs. For example, the code
+%% the code to produce the axis ticks used to use the tikz \node command, and in the file example_KF3n.tex drawing
+%% the axes ticks was taking about 1/3 of the compile time (a little under 1s out of a 3.2)
+%%
+
+
+
+%%%
+%%% Draw axes and clip
+%%%
+\def\sseq@handlexaxis{
+ \ifsseq@drawxaxis
+ \bgroup
+ \ifsseq@borderxaxis\else
+ \let\sseq@ymin\sseq@yaxisorigin % Warning: this is a stupid, lazy hack.
+ \fi
+ \sseq@drawxaxis
+ \ifsseq@drawxaxisticks
+ \sseq@drawxticks
+ \fi
+ \egroup
+ \fi
+}
+\def\sseq@handleyaxis{
+ \ifsseq@drawyaxis
+ \bgroup
+ \ifsseq@borderyaxis\else
+ \let\sseq@xmin\sseq@xaxisorigin % Warning: this is a stupid, lazy hack.
+ \fi
+ \sseq@drawyaxis
+ \ifsseq@drawyaxisticks
+ \sseq@drawyticks
+ \fi
+ \egroup
+ \fi
+}
+\def\sseq@drawxaxis{
+ \bgroup
+ \pgftransformreset
+ \sseq@globaldetonetransform
+ %
+ \bgroup
+ \pgftransformxshift{\sseq@xaxis@end@extend}\pgftransformyshift{-\sseq@xaxisgap}
+ \sseq@globalscaletransform
+ \pgfpathmoveto{\pgfpoint{\sseq@xmax cm}{\sseq@ymin cm}}
+ \egroup
+ \bgroup
+ \pgftransformxshift{-\sseq@yaxisgap}
+ %\pgftransformxshift{-\sseq@ylabelgap}
+ \pgftransformxshift{-\sseq@xaxis@start@extend}
+ \pgftransformyshift{-\sseq@xaxisgap}
+ \sseq@globalscaletransform
+ \pgfpathlineto{\pgfpoint{\sseq@xmin cm}{\sseq@ymin cm}}
+ \egroup
+ \egroup
+ \pgfusepath{stroke}
+}
+\def\sseq@drawyaxis{
+ \bgroup
+ \pgftransformreset
+ \sseq@globaldetonetransform
+ \bgroup
+ \pgftransformyshift{\sseq@yaxis@end@extend}\pgftransformxshift{-\sseq@yaxisgap}
+ \sseq@globalscaletransform
+ \pgfpathmoveto{\pgfpoint{\sseq@xmin cm}{\sseq@ymax cm}}
+ \egroup
+ \bgroup
+ \pgftransformyshift{-\sseq@xaxisgap}
+ %\pgftransformyshift{-\sseq@xlabelgap}
+ \pgftransformyshift{-\sseq@yaxis@start@extend}
+ \pgftransformxshift{-\sseq@yaxisgap}
+ \sseq@globalscaletransform
+ \pgfpathlineto{\pgfpoint{\sseq@xmin cm}{\sseq@ymin cm}}
+ \egroup
+ \egroup
+ \pgfusepath{stroke}%
+}
+\def\sseq@drawxticks{
+ \sseq@tempy=\sseq@ymin\relax
+ \sseq@tempx=\sseq@xmax\relax
+ \advance\sseq@tempx\@ne\relax
+ \edef\sseq@temp{\the\sseq@tempx}%
+ \sseq@tempx=\sseq@xmin\relax
+ \loop
+ \bgroup
+ \sseq@eval{\@nx\pgftransformshift{\@nx\pgfpoint{\the\sseq@tempx cm}{\the\sseq@tempy cm}}}
+ \pgftransformresetnontranslations
+ \sseq@globaldetonetransform
+ \pgftransformyshift{-\sseq@xlabelgap}\pgftransformyshift{-\sseq@xaxisgap}
+ \pgftransformresetnontranslations
+ \ifsseq@rotatelabels\sseq@globalrotatetransform\fi
+ \sseq@xtickstyle
+ \tikz@options
+ \pgftext{\hbox{$\sseq@xtickfn{\the\sseq@tempx}$}}
+ \egroup
+ \advance\sseq@tempx\sseq@xtickstep\relax
+ \ifnum\sseq@tempx<\sseq@temp\repeat
+}
+\def\sseq@drawyticks{
+ \sseq@tempx=\sseq@xmin\relax
+ \sseq@tempy=\sseq@ymax\relax
+ \advance\sseq@tempy\@ne\relax
+ \edef\sseq@tempmax{\the\sseq@tempy}
+ \sseq@tempy=\sseq@ymin\relax
+ \loop
+ \bgroup
+ \sseq@eval{\@nx\pgftransformshift{\@nx\pgfpoint{\the\sseq@tempx cm}{\the\sseq@tempy cm}}}
+ \pgftransformresetnontranslations
+ \sseq@globaldetonetransform
+ \pgftransformxshift{-\sseq@ylabelgap}\pgftransformxshift{-\sseq@yaxisgap}
+ \pgftransformresetnontranslations
+ \ifsseq@rotatelabels\sseq@globalrotatetransform\fi
+ \sseq@ytickstyle
+ \tikz@options
+ \pgftext{\hbox{$\sseq@ytickfn{\the\sseq@tempy}$}}
+ \egroup
+ \advance\sseq@tempy\sseq@ytickstep\relax
+ \ifnum\sseq@tempy<\sseq@tempmax\repeat
+}
+\def\sseq@setupclip{
+ %\clip(\sseq@xmin-0.4,\sseq@ymin-0.4) rectangle (\sseq@xmax+0.5,\sseq@ymax+0.5);%
+ \ifsseq@clip
+ \ifx\sseq@customclip\pgfutil@empty
+ \bgroup
+ \pgftransformreset
+ \sseq@globaldetonetransform
+ \ifsseq@borderyaxis
+ \def\xmin{\pgftransformxshift{-\sseq@yaxisgap}\pgftransformxshift{\sseq@yclip@axisgap}}
+ \else
+ \def\xmin{\pgftransformxshift{-\sseq@xaxis@start@extend}\pgftransformxshift{-\sseq@clip@padding@left}}
+ \fi
+ \ifsseq@borderxaxis
+ \def\ymin{\pgftransformyshift{-\sseq@xaxisgap}\pgftransformyshift{\sseq@xclip@axisgap}}
+ \else
+ \def\ymin{\pgftransformyshift{-\sseq@yaxis@start@extend}\pgftransformyshift{-\sseq@clip@padding@bottom}}
+ \fi
+ \def\xmax{\pgftransformxshift{\sseq@xaxis@end@extend}\pgftransformxshift{\sseq@clip@padding@right}}
+ \def\ymax{\pgftransformyshift{\sseq@yaxis@end@extend}\pgftransformyshift{\sseq@clip@padding@top}}
+ \bgroup
+ \xmin\ymin\sseq@globalscaletransform
+ \pgfpathmoveto{\pgfpoint{\sseq@xmin cm}{\sseq@ymin cm}}
+ \egroup
+ \bgroup
+ \xmin\ymax\sseq@globalscaletransform
+ \pgfpathlineto{\pgfpoint{\sseq@xmin cm}{\sseq@ymax cm}}
+ \egroup
+ \bgroup
+ \xmax\ymax\sseq@globalscaletransform
+ \pgfpathlineto{\pgfpoint{\sseq@xmax cm}{\sseq@ymax cm}}
+ \egroup
+ \bgroup
+ \xmax\ymin\sseq@globalscaletransform
+ \pgfpathlineto{\pgfpoint{\sseq@xmax cm}{\sseq@ymin cm}}
+ \egroup
+ \egroup
+ \pgfpathclose
+ \pgfgetpath\sseq@theclippath % This stores the clipping so I can find intersections later
+ \pgfusepath{discard}% This has to be after the egroup or else the clipping gets screwed up
+ \bgroup
+ %\sseq@globalscaletransform
+ \pgfpathmoveto{\pgfpoint{\sseq@xmin cm}{\sseq@ymin cm}}
+ \pgfpathlineto{\pgfpoint{\sseq@xmin cm}{\sseq@ymax cm}}
+ \pgfpathlineto{\pgfpoint{\sseq@xmax cm}{\sseq@ymax cm}}
+ \pgfpathlineto{\pgfpoint{\sseq@xmax cm}{\sseq@ymin cm}}
+ \pgfpathclose
+ \egroup
+ \pgfgetpath\sseq@therangepath % Only for deciding whether to draw "tricky edges"
+ \pgfusepath{discard}
+ \else
+ \def\sseq@temp{\path[name path=temp]}
+ \@xptwo\sseq@temp\@xp\@gobble\sseq@customclip
+ \pgfgetpath\sseq@theclippath
+ \let\sseq@theclippath\tikz@intersect@path@name@temp
+ \fi
+ \else
+ \let\sseq@theclippath\relax
+ \fi
+}
+\def\sseq@useclip{\ifx\sseq@theclippath\relax\else\pgfsetpath\sseq@theclippath\pgfusepath{clip}\fi}
+\def\sseq@grid@chess{
+ \bgroup
+ \pgfscope
+ \sseq@useclip
+ \pgflowlevelsynccm
+ \pgfsetlinewidth{1cm}
+ \pgfsetdash{{1cm}{1cm}}{1cm}
+ \pgfsetcolor{lightgray}
+ \pgfpathgrid[stepx=2cm,stepy=2cm]{\pgfpoint{-0.5cm}{-0.5cm}}{\pgfpoint{\sseq@xmax cm+0.499cm}{\sseq@ymax cm+0.499cm}}
+ \pgfusepath{stroke}
+ \endpgfscope
+ \egroup
+}
+\def\sseq@grid@crossword{
+ \bgroup
+ \pgfscope
+ \pgfsetlinewidth{\the\sseq@gridstrokethickness}
+ \sseq@useclip
+ \pgftransformxshift{-0.5cm}
+ \pgftransformyshift{-0.5cm}
+ \pgfpathgrid[stepx=1cm,stepy=1cm]{\pgfpoint{-1cm}{-1cm}}{\pgfpoint{\xmax cm+0.99cm}{\ymax cm+0.99cm}}
+ \pgfusepath{stroke}
+ \endpgfscope
+ \egroup
+}
+\def\sseq@grid@go{
+ \bgroup
+ \pgfscope
+ \sseq@useclip
+ \pgfsetlinewidth{\the\sseq@gridstrokethickness}
+ \pgfpathgrid[stepx=1cm,stepy=1cm]{\pgfpoint{-1cm}{-1cm}}{\pgfpoint{\xmax cm+0.5cm}{\ymax cm+0.5cm}}
+ \pgfusepath{stroke}
+ \endpgfscope
+ \egroup
+}
+\def\sseq@grid@none{}
+\def\sseq@grid@dots{
+ \bgroup
+ \pgfscope
+ \pgfgettransform\sseq@savetransform
+ \pgftransformreset
+ \sseq@globalscaletransform
+ \pgfgettransformentries{\sseq@a}{\sseq@b}{\sseq@c}{\sseq@d}{\sseq@u}{\sseq@v}
+ \pgfsettransform\sseq@savetransform
+ \sseq@useclip
+ \pgftransformxshift{-1.5cm}
+ \pgftransformyshift{-0.5cm}
+ \pgfsetdash{{1pt}{\sseq@a*1cm-1pt}}{0.5cm+.5pt}
+ \pgfsetlinewidth{1pt}
+ \sseq@tempy=\sseq@ymin\relax
+ \advance\sseq@tempy\m@ne
+ \loop
+ \advance\sseq@tempy\@ne
+ \pgfpathmoveto{\pgfpoint{\sseq@xmin cm+0.5cm/\sseq@a}{\the\sseq@tempy cm}}
+ \pgfpathlineto{\pgfpoint{\sseq@xmax cm+1.01cm }{\the\sseq@tempy cm}}
+ \ifnum\sseq@tempy<\sseq@ymax\repeat
+ %\pgfpathgrid[stepx=1cm,stepy=1cm]{\pgfpoint{-0.5cm}{-0.5cm}}{\pgfpoint{\xmax cm-0.5cm}{\ymax cm-0.5cm}}
+ \pgfusepath{stroke}
+ \endpgfscope
+ \egroup
+}
+%%%
+%%% Draw Classes
+%%%
+%%% Class offsets
+\sseqnewclasspattern{standard}{
+ (0,0);
+ (-0.13,0)(0.13,0);
+ (-0.2,0)(0,0)(0.2,0);
+ (-0.13,-0.13)(0.13,-0.13)(-0.13,0.13)(0.13,0.13);
+ (-0.16,-0.16)(0.16,-0.16)(-0.16,0.16)(0.16,0.16)(0,0);
+ (-0.13,-0.2)(-0.13,0)(-0.13,0.2)(0.13,-0.2)(0.13,0)(0.13,0.2);
+}
+\sseqnewclasspattern{linear}{
+ (0,0);
+ (-0.13,0)(0.13,0);
+ (-0.2,0)(0,0)(0.2,0);
+ (-0.3,0)(-0.1,0)(0.1,0)(0.3,0);
+ (-0.4,0)(-0.2,0)(0,0)(0.2,0)(0.4,0);
+ (-0.5,0)(-0.3,0)(-0.1,0)(0.1,0)(0.3,0)(0.5,0);
+}
+\def\sseq@offset#1#2{
+ \sseq@eval{\@nx\pgftransformshift{\@nx\pgfpoint{0\csname sseq@\sseq@classpattern xoffset#1/#2\endcsname cm}{0\csname sseq@\sseq@classpattern yoffset#1/#2\endcsname cm}}}
+}
+\def\sseq@class@getparts#1(#2,#3,#4)[#5].{
+ \sseq@seterrorannotation@drawing{#1}{#2}{#3}{#4}{#5}
+ \def\sseq@thisclassname{class.(#2,#3,#4)}
+ \def\sseq@thisnodename{sseq{#2,#3,#4}}
+ \def\sseq@thispos{(#2,#3)}
+ \def\sseq@thisposnum{#4}
+ \def\sseq@thisclassnum{#5}
+}
+
+\def\sseqtooltip#1#2{%
+ \edef\temp{\detokenize\@xpthree{#2}}%
+ \edef\temp{\@xp\sseqtooltip@replaceslashes\@xp{\temp}}%
+ \sseq@eval{\@nx\pdftooltip{\unexpanded{#1}}{\temp}}%
+}
+\bgroup\lccode`\!=`\\\lowercase{\egroup
+\def\sseqtooltip@replaceslashes#1{\sseqtooltip@replaceslashes@#1!\sseq@nil}
+\def\sseqtooltip@replaceslashes@#1!#2{%
+ #1%
+ \ifx\sseq@nil#2\@xp\@gobble\else
+ \@nx\@nx\@nx\textbackslash
+ \@xp\sseqtooltip@replaceslashes@
+ \fi#2%
+}
+}
+
+% #1 -- the name of the node object
+\def\sseq@class@drawnode#1{%
+ \begingroup
+ \sseq@class@getparts#1.
+ \sseq@tempx=\sseq@obj{\sseq@thisclassname.x}\relax
+ \sseq@tempy=\sseq@obj{\sseq@thisclassname.y}\relax
+ \sseq@needstikzfalse
+ \sseq@options@firstpassmode
+ \sseq@thesseqstyle
+ \sseq@theclassstyle
+ \ifnum\sseq@obj{#1.page}=\sseq@infinitycount
+ \sseq@thepermanentcyclestyle
+ \else
+ \sseq@thetransientcyclestyle
+ \ifsseq@thispage
+ \sseq@thethispagecyclestyle
+ \fi
+ \fi
+ \the\sseq@scope@toks
+ \sseq@obj{#1.needstikz}
+%
+ \sseq@outofrangetrue
+ \ifnum\sseq@tempx<\sseq@xmaxpp\relax\ifnum\sseq@tempx>\sseq@xminmm\relax\ifnum\sseq@tempy<\sseq@ymaxpp\relax\ifnum\sseq@tempy>\sseq@yminmm\relax
+ \sseq@outofrangefalse
+ \pgfscope
+ \let\tikz@options\pgfutil@empty
+ \let\tikz@alias=\pgfutil@empty
+ \def\pgfkeysdefaultpath{/sseqpages/class/}
+ \sseq@options@secondpassmode
+ \sseq@thesseqstyle
+ \sseq@theclassstyle
+ \ifnum\sseq@obj{#1.page}=\sseq@infinitycount
+ \sseq@thepermanentcyclestyle
+ \else
+ \sseq@thetransientcyclestyle
+ \ifsseq@thispage
+ \sseq@thethispagecyclestyle
+ \fi
+ \fi
+ \the\sseq@scope@toks
+ \sseq@obj{#1.options}%
+ \sseq@eval{\@nx\pgftransformshift{\@nx\pgfpoint{\the\sseq@tempx cm}{\the\sseq@tempy cm}}}
+ \sseq@eval{\@nx\pgftransformshift{\@nx\pgfpoint{-\the\sseq@x cm}{-\the\sseq@y cm}}}
+ \iftikz@fullytransformed\pgfgettransform{\savetransform}\fi
+ \pgftransformresetnontranslations
+ \sseq@globalrotatetransform
+ \sseq@classplacementtransform
+ \sseq@obj@ifdef{#1.offset}{\sseq@obj{#1.offset}}{%
+ \sseq@offset{\sseq@thisposnum}{\sseq@obj{partcoord.\sseq@thispos.numnodes}}%
+ }%
+ \iftikz@fullytransformed\pgfsettransform{\savetransform}\else\pgftransformresetnontranslations\ifsseq@rotatelabels\sseq@globalrotatetransform\fi\fi
+ \tikz@options
+ \ifsseq@needstikz
+ \let\sseq@mode\tikz@mode
+ \tikzset{every text node part/.code/.expand once={\sseq@globalrotatetransform\sseq@obj{#1.nodetext.options}}}%
+ \sseq@eval{%
+ \@nx\node[/utils/exec={\let\@nx\tikz@mode\@nx\sseq@mode},
+ /handlers/first char syntax/the character "/.initial=\@nx\sseq@handlequote
+ ] (\sseq@thisnodename) {\unexpanded\@xpthree{\sseq@obj{#1.nodetext}}}
+ [every text node part/.code={}]
+ \@nx\sseq@obj{#1.labelnodes};
+ }%
+ \else
+ \tikz@node@textfont
+ \edef\sseq@classnodetextoptions{\@xptwo\@nx\sseq@obj{#1.nodetext.options}}
+ \edef\sseq@classnodetext{\@xptwo\@nx\sseq@obj{#1.nodetext}}
+ \sseq@setnodetext
+ \let\tikz@fig@name\sseq@thisnodename
+ \pgfmultipartnode{\tikz@shape}{\tikz@anchor}{\tikz@fig@name}{\sseq@drawnode}%
+ \tikz@alias
+ \sseq@obj{#1.labelnodes}
+ \fi
+ \sseq@obj@ifdef{#1.tooltip}{
+ \pgfpointanchor{\sseq@thisnodename}{west}
+ \pgf@xa=\pgf@x
+ \pgfpointanchor{\sseq@thisnodename}{south}
+ \pgf@ya=\pgf@y
+%
+ \pgf@process{\pgfpointdiff{\pgfpointtransformed{\pgfpointanchor{\sseq@thisnodename}{west}}}{\pgfpointtransformed{\pgfpointanchor{\sseq@thisnodename}{east}}}}
+ \pgf@xb=\pgf@x
+ \pgf@process{\pgfpointdiff{\pgfpointtransformed{\pgfpointanchor{\sseq@thisnodename}{south}}}{\pgfpointtransformed{\pgfpointanchor{\sseq@thisnodename}{north}}}}
+ \pgf@yb=\pgf@y
+%
+ \setbox\tikz@tempbox=\hbox{
+ \pgfinterruptpicture
+ \sseqtooltip{\rule{\pgf@xb}{0pt}\rule{0pt}{\pgf@yb}}{\sseq@obj{#1.tooltip}}
+ \endpgfinterruptpicture
+ }
+ {%
+ \pgftransformshift{\pgfpoint{\pgf@xa}{\pgf@ya}}%
+ \pgfapproximatenonlineartransformation%
+ \pgfqboxsynced{\tikz@tempbox}%
+ }%
+ }{}
+ \endpgfscope
+ \fi\fi\fi\fi
+ \ifsseq@outofrange
+ \sseq@eval{\@nx\pgftransformshift{\@nx\pgfpoint{\the\sseq@tempx cm}{\the\sseq@tempy cm}}}%
+ \sseq@eval{\@nx\pgftransformshift{\@nx\pgfpoint{-\the\sseq@x cm}{-\the\sseq@y cm}}}
+ \pgftransformresetnontranslations
+ \sseq@globalrotatetransform
+ \sseq@classplacementtransform
+ \sseq@offset{\sseq@thisposnum}{\sseq@obj{partcoord.\sseq@thispos.numnodes}}
+ \pgfcoordinate{\sseq@thisnodename}{\pgfpointorigin}%
+ \fi
+ \endgroup
+}
+\def\sseq@setnodetext{%
+ \setbox\pgfnodeparttextbox=\hbox{%
+ \pgfscope%
+ \tikzset{every text node part/.try}%
+ \sseq@classnodetextoptions
+ \ifx\tikz@textopacity\pgfutil@empty%
+ \else%
+ \pgfsetfillopacity{\tikz@textopacity}%
+ \pgfsetstrokeopacity{\tikz@textopacity}%
+ \fi%
+ \pgfinterruptpicture
+ \ifx\tikz@text@width\pgfutil@empty%
+ \tikz@textfont%
+ \else%
+ \begingroup%
+ \pgfmathsetlength{\pgf@x}{\tikz@text@width}%
+ \pgfutil@minipage[t]{\pgf@x}\leavevmode\hbox{}%
+ \tikz@textfont%
+ \tikz@text@action%
+ \fi%
+ \ifx\tikz@textcolor\pgfutil@empty%
+ \else%
+ \pgfutil@colorlet{.}{\tikz@textcolor}%
+ \fi%
+ \pgfsetcolor{.}%
+ \tikz@atbegin@node%
+ \sseq@classnodetext%
+ \tikz@atend@node%
+ \ifx\tikz@text@width\pgfutil@empty%
+ \else%
+ \pgfutil@endminipage%
+ \endgroup%
+ \fi%
+ \endpgfinterruptpicture
+ \endpgfscope%
+ }%
+ \ifx\tikz@text@width\pgfutil@empty%
+ \else%
+ \pgfmathsetlength{\pgf@x}{\tikz@text@width}%
+ \wd\pgfnodeparttextbox=\pgf@x%
+ \fi%
+ \ifx\tikz@text@height\pgfutil@empty%
+ \else%
+ \pgfmathsetlength{\pgf@x}{\tikz@text@height}%
+ \ht\pgfnodeparttextbox=\pgf@x%
+ \fi%
+ \ifx\tikz@text@depth\pgfutil@empty%
+ \else%
+ \pgfmathsetlength{\pgf@x}{\tikz@text@depth}%
+ \dp\pgfnodeparttextbox=\pgf@x%
+ \fi%
+}
+\def\sseq@drawnode{%
+ \pgfutil@tempdima=\pgflinewidth%
+ {%
+ \tikz@mode%
+ %\iftikz@mode@clip \sseq@error@internal{Clip shouldn't happen here, but this error should be caught earlier}{}\fi %
+ \iftikz@mode@draw%
+ \iftikz@mode@double%
+ % Change line width
+ \begingroup%
+ \pgfsys@beginscope%
+ \tikz@double@setup%
+ \fi%
+ \fi%
+ %
+ % Step 10: Do stroke/fill as needed
+ %
+ \sseq@eval{\noexpand\pgfusepath{%
+ \iftikz@mode@fill fill,\fi%
+ \iftikz@mode@draw draw,\fi%
+ }}%
+ %
+ % Step 11: Double stroke, if necessary
+ %
+ \iftikz@mode@draw%
+ \iftikz@mode@double%
+ \pgfsys@endscope%
+ \endgroup%
+ \fi%
+ \fi
+ }%
+ \global\pgflinewidth=\pgfutil@tempdima%
+}
+
+%%%
+%%% Drawing edges
+%%%
+\def\sseq@ifinrange(#1){\sseq@ifinrange@#1,\sseq@nil}
+\def\sseq@ifinrange@#1,#2,#3\sseq@nil{%
+ \sseq@tempx=#1\relax\sseq@tempy=#2\relax
+ \sseq@outofrangetrue
+ \ifnum\sseq@tempx<\sseq@xmaxpp\relax\ifnum\sseq@tempx>\sseq@xminmm\relax\ifnum\sseq@tempy<\sseq@ymaxpp\relax\ifnum\sseq@tempy>\sseq@yminmm\relax
+ \sseq@outofrangefalse
+ \fi\fi\fi\fi
+ \ifsseq@outofrange
+ \@xp\pgfutil@secondoftwo
+ \else
+ \@xp\pgfutil@firstoftwo
+ \fi
+}
+
+\def\sseq@fullcoord@to@partialcoord(#1){\sseq@fullcoord@to@partialcoord@#1,\@nil}
+\def\sseq@fullcoord@to@partialcoord@#1,#2,#3\@nil{{#1cm}{#2cm}}
+% #1 -- source (full)
+% #2 -- target (full)
+% #3 -- which type of edge (either "structline" or "differential")
+% #4 -- options
+\def\sseq@drawedge(#1)(#2)#3#4{%
+ \begingroup\pgfscope
+ \def\sseq@edgetype{#3}
+ \let\sseq@edgesourceanchor\pgfutil@empty
+ \let\sseq@edgetargetanchor\pgfutil@empty
+%
+ \sseq@needstikzfalse
+ \def\pgfkeysdefaultpath{/sseqpages/#3/}%
+ \sseq@options@bothpassmode
+ \sseq@thesseqstyle
+ \sseq@theedgestyle\csname sseq@the#3style\endcsname\the\sseq@scope@toks
+ #4%
+ \sseq@eval{\@nx\pgftransformshift{\@nx\pgfpoint{-\the\sseq@x cm}{-\the\sseq@y cm}}}%
+ % First calculate actual start and end of the edge
+ \let\tempaf\pgfutil@empty
+ \ifx\sseq@edgesourceanchor\pgfutil@empty % Check that the source doesn't have a specified anchor
+ \def\tempa{\pgfpointanchor{sseq{#1}}{center}}% if so, start by taking the center of that coordinate
+ \else
+ \edef\tempa{\@nx\pgfpointanchor{sseq{#1}}{\sseq@edgesourceanchor}} % If it has an anchor, use that
+ \let\tempaf\tempa
+ \fi
+ \ifx\sseq@edgetargetanchor\pgfutil@empty % check that the target doesn't have a specified anchor
+ \def\tempb{\pgfpointshapeborder{sseq{#2}}{\tempa}}% if so, our end point is the point on the boundary of node b that is in the direction of our initial start coordinate
+ \else
+ \edef\tempb{\@nx\pgfpointanchor{sseq{#2}}{\sseq@edgetargetanchor}}% If it has a specified anchor, use that
+ \fi
+ \let\tempbf\tempb
+ \ifx\tempaf\pgfutil@empty%
+ \def\tempaf{\pgfpointshapeborder{sseq{#1}}{\tempb}}%
+ \fi
+%
+ \tikz@options
+ \tikz@mode
+ \def\temparrowstartspec{}%
+ \def\temparrowendspec{}%
+ \pgfcoordinate{tempa}{\tempaf}%
+ \pgfcoordinate{tempb}{\tempbf}%
+ \pgftransformreset
+ \sseq@ifinrange(#1){\sseq@ifinrange(#2){\sseq@outofrangefalse}{\sseq@outofrangetrue}}{\sseq@outofrangetrue}%
+ \ifsseq@outofrange
+ \sseq@handleoffpageedge{#1}{#2}{#3}%
+ \fi
+ \ifsseq@drawedge
+ % TODO: should some sort of transformation manipulation be here? Maybe allow user to specify preference?
+ % Don't draw dots on very short segments
+ \pgfpointdiff{\tempbf}{\tempaf}
+ \pgfmathveclen{\pgf@x}{\pgf@y}%
+ \@xp\pgfmathint\@xp{\pgfmathresult}%
+ \ifnum\pgfmathresult<10\relax%%17? % TODO: Fix this predicate
+ \tikzset{every text node part/.append code={\pgfsetcolor{white}}}% I wonder why this is here...
+ \ifx\temparrowstartspec\pgfutil@empty
+ \else
+ \def\temparrowstartspec{\pgfsetarrowsstart{}}%
+ \fi
+ \ifx\temparrowendspec\pgfutil@empty
+ \else
+ \def\temparrowendspec{\pgfsetarrowsend{}}%
+ \fi
+ \fi
+ \ifsseq@needstikz
+ \draw[/sseqpages,
+ /utils/exec={\sseq@thesseqstyle\sseq@theedgestyle\csname sseq@the#3style\endcsname\the\sseq@scope@toks
+ \temparrowstartspec\temparrowendspec #4}%
+ ] (tempa) to (tempb);%
+ \else
+ \temparrowstartspec
+ \temparrowendspec
+ \pgfpathmoveto{\pgfpointanchor{tempa}{center}}%
+ \pgfpathlineto{\pgfpointanchor{tempb}{center}}%
+ \sseq@eval{\noexpand\pgfusepath{%
+ \iftikz@mode@fill fill,\fi
+ \iftikz@mode@draw draw,\fi
+ }}%
+ \fi
+ \fi
+ \sseq@breakpoint
+ \endpgfscope\endgroup
+}
+
+% TODO: this macro is super expensive. Make it faster (avoid
+\def\sseq@handleoffpageedge#1#2#3{
+ \pgfpathmoveto{\tempaf}%
+ \pgfpathlineto{\tempbf}%
+ \pgfgetpath\thispath
+ \pgfusepath{discard}%
+ \pgfintersectionofpaths{\pgfsetpath\sseq@theclippath}{\pgfsetpath\thispath}%
+ \ifcase\pgfintersectionsolutions\relax
+ % No intersections, but one or both endpoints may be out of range but still in clipping region due to scaling. Add ellipses as appropriate.
+ \sseq@ifinrange(#1){% If the first endpoint is in range, the second must be out of range b/c sseq@outofrange is true.
+ %\edef\temparrowendspec{\@nx\pgfsetarrowsend{\csname sseq@runoffarrow@end@#3@spec\endcsname}}
+ }{%
+ \sseq@ifinrange(#2){%
+ \edef\temparrowstartspec{\@nx\pgfsetarrowsstart{\csname sseq@runoffarrow@start@#3@spec\endcsname}}
+ }{\sseq@drawedge@handletrickyedge}% uh-oh, both ends are out of range
+ }%
+ \or
+ \sseq@ifinrange(#1){% If the startpoint is in range, the intersection must be the end.
+ \def\tempbf{\pgfpointintersectionsolution{1}}
+ \edef\temparrowendspec{\@nx\pgfsetarrowsend{\csname sseq@runoffarrow@end@#3@spec\endcsname}}
+ \pgfcoordinate{tempb}{\tempbf}
+ }{%
+ \sseq@ifinrange(#2){% If the startpoint is out of range and the endpoint is in range, the intersection must be the start
+ \def\tempaf{\pgfpointintersectionsolution{1}}%
+ \edef\temparrowstartspec{\@nx\pgfsetarrowsstart{\csname sseq@runoffarrow@start@#3@spec\endcsname}}%
+ \pgfcoordinate{tempa}{\tempaf}%
+ }{\sseq@drawedge@handletrickyedge}% Uh-oh, both ends are out of range.
+ }
+ \or% an orphan
+ \ifsseq@draworphanedges
+ \sseq@drawedge@handleorphan
+ \else
+ \sseq@drawedgefalse % Don't draw "orphaned edges"
+ \fi
+ \else
+ \sseq@error{clip-not-convex}%
+ \sseq@breakfifi
+ \fi
+}
+
+\def\sseq@drawedge@handletrickyedge{%
+ \ifsseq@draworphanedges
+ \pgfintersectionofpaths{\pgfsetpath\sseq@therangepath}{\pgfsetpath\thispath}%
+ \ifnum\pgfintersectionsolutions=\z@
+ \sseq@drawedgefalse % don't draw orphan edges that never intersect actual range
+ \else% Now we have to make a line through tempa and tempb long enough so that it intersects the original clip area twice.
+ \pgfmathanglebetweenpoints{\pgfpointanchor{tempa}{center}}{\pgfpointanchor{tempb}{center}}%
+ \edef\tempangle{\pgfmathresult}
+ \pgfpathmoveto{\pgfpointadd{\pgfpointanchor{tempa}{center}}{\pgfpointpolar{\tempangle}{100cm}}}% a really long line
+ \pgfpathlineto{\pgfpointadd{\pgfpointanchor{tempa}{center}}{\pgfpointpolar{\tempangle}{-100cm}}}%
+ \pgfgetpath\thispath
+ \pgfusepath{discard}
+ \pgfintersectionofpaths{\pgfsetpath\sseq@theclippath}{\pgfsetpath\thispath}
+ \sseq@drawedge@handleorphan
+ \fi
+ \else
+ \sseq@drawedgefalse
+ \fi
+}
+
+
+\def\sseq@drawedge@handleorphan{%
+ \def\tempaf{\pgfpointintersectionsolution{1}}%
+ \def\tempbf{\pgfpointintersectionsolution{2}}%
+ \edef\temparrowstartspec{\@nx\pgfsetarrowsstart{\csname sseq@runoffarrow@start@\sseq@edgetype @spec\endcsname}}%
+ \edef\temparrowendspec{\@nx\pgfsetarrowsend{\csname sseq@runoffarrow@end@\sseq@edgetype @spec\endcsname}}%
+ \pgfcoordinate{tempa}{\tempaf}%
+ \pgfcoordinate{tempb}{\tempbf}%
+}
+
+
+%
+% #1 -- first coordinate
+% #2 -- second coordinate
+% #3 -- uid
+\def\sseq@circleclass@draw#1#2#3{
+ \begingroup
+ \pgfmathanglebetweenpoints{\pgfpointanchor{sseq{#2}}{center}}{\pgfpointanchor{sseq{#3}}{center}}
+ \let\tempangle\pgfmathresult
+ \let\tikz@lib@fit@scan@handle\sseq@fit@tikz@lib@fit@scan@handle % install fit modifications.
+ \let\tikz@calc@anchor\sseq@fit@tikz@calc@anchor
+ \sseq@tempiftrue
+ \node[
+ rotate fit=\tempangle,
+ /utils/exec={\sseq@thesseqstyle\sseq@thecircleclassstyle\the\sseq@scope@toks\sseq@savedoptioncode
+ \sseq@obj{#1.options}
+ \sseq@obj{#1.fitnodes}
+ \@xp\pgfkeysalso\@xp{\romannumeral0\sseq@obj{#1.tikzprimoptions}}
+ }
+ ] {};
+ \endgroup
+}
+% Modifies tikz commands \tikz@lib@fit@scan@handle from \pgf\frontendlayer\tikz\libraries\tikzlibraryfit.code.tex line 81 and
+% \tikz@calc@anchor from \pgf\frontendlayer\tikz\tikz.code.tex line 5164
+% make it so that fit silently ignores nodes that are not defined.
+% This is copied with modification from \pgf\frontendlayer\tikz\libraries\tikzlibraryfit.code.tex line 81
+\def\sseq@fit@tikz@lib@fit@scan@handle#1{%
+ \ifsseq@tempif % this has been set in the following macro to be true if there is a node with the given name. If it's not true, ignore this.
+ \iftikz@shapeborder%
+ % Ok, fit all four external anchors, if they exist
+ \tikz@lib@fit@adjust{\pgfpointanchor{\tikz@shapeborder@name}{west}}%
+ \tikz@lib@fit@adjust{\pgfpointanchor{\tikz@shapeborder@name}{east}}%
+ \tikz@lib@fit@adjust{\pgfpointanchor{\tikz@shapeborder@name}{north}}%
+ \tikz@lib@fit@adjust{\pgfpointanchor{\tikz@shapeborder@name}{south}}%
+ \else%
+ \tikz@lib@fit@adjust{#1}%
+ \fi%
+ \fi
+ \sseq@tempiftrue
+ \tikz@lib@fit@scan%
+}
+
+% This is copied with modification from \pgf\frontendlayer\tikz\tikz.code.tex line 5164
+\def\sseq@fit@tikz@calc@anchor#1.#2\tikz@stop{%
+ \pgfutil@ifundefined{pgf@sh@ns@#1}{\sseq@tempiffalse}{%If the node doesn't exist, don't throw an error but record that we should skip it
+ \pgfpointanchor{\tikz@pp@name{#1}}{#2}%
+ }%s
+}
+
+
+%% New shapes and arrows
+%% These use lots of keys with spaces so it's convenient to turn off ExplSyntax.
+
+% Stolen from: https://tex.stackexchange.com/a/24621
+\pgfqkeys{/pgf}{
+ ellipse ratio/.code={\pgfkeyssetvalue{/pgf/ellipse ratio}{#1}},
+ ellipse ratio/.initial=1
+}
+\pgfdeclareshape{newellipse}
+{
+ \inheritsavedanchors[from=ellipse]
+ \inheritanchorborder[from=ellipse]
+ \savedanchor\radius{%
+ %
+ % Caculate ``height radius''
+ %
+ \pgf@y=.5\ht\pgfnodeparttextbox%
+ \advance\pgf@y by.5\dp\pgfnodeparttextbox%
+ \pgfmathsetlength\pgf@yb{\pgfkeysvalueof{/pgf/inner ysep}}%
+ \advance\pgf@y by\pgf@yb%
+ %
+ % Caculate ``width radius''
+ %
+ \pgf@x=.5\wd\pgfnodeparttextbox%
+ \pgfmathsetlength\pgf@xb{\pgfkeysvalueof{/pgf/inner xsep}}%
+ \advance\pgf@x by\pgf@xb%
+ %
+ % Adjust
+ %
+ \pgfkeysgetvalue{/pgf/ellipse ratio}{\ratioscale}
+ \pgfmathsetmacro\widthfactor{sqrt(\ratioscale^2+1)/\ratioscale}
+ \pgfmathsetmacro\heightfactor{sqrt(\ratioscale^2+1)}
+ \pgf@x=\widthfactor\pgf@x%
+ \pgf@y=\heightfactor\pgf@y%
+ %
+ % Adjust height, if necessary
+ %
+ \pgfmathsetlength\pgf@yc{\pgfkeysvalueof{/pgf/minimum height}}%
+ \ifdim\pgf@y<.5\pgf@yc%
+ \pgf@y=.5\pgf@yc%
+ \fi%
+ %
+ % Adjust width, if necessary
+ %
+ \pgfmathsetlength\pgf@xc{\pgfkeysvalueof{/pgf/minimum width}}%
+ \ifdim\pgf@x<.5\pgf@xc%
+ \pgf@x=.5\pgf@xc%
+ \fi%
+ %
+ % Add outer sep
+ %
+ \pgfmathsetlength{\pgf@xb}{\pgfkeysvalueof{/pgf/outer xsep}}%
+ \pgfmathsetlength{\pgf@yb}{\pgfkeysvalueof{/pgf/outer ysep}}%
+ \advance\pgf@x by\pgf@xb%
+ \advance\pgf@y by\pgf@yb%
+ }
+
+ \inheritanchor[from=ellipse]{center}
+ \inheritanchor[from=ellipse]{mid}
+ \inheritanchor[from=ellipse]{base}
+ \inheritanchor[from=ellipse]{north}
+ \inheritanchor[from=ellipse]{south}
+ \inheritanchor[from=ellipse]{west}
+ \inheritanchor[from=ellipse]{mid west}
+ \inheritanchor[from=ellipse]{base west}
+ \inheritanchor[from=ellipse]{north west}
+ \inheritanchor[from=ellipse]{south west}
+ \inheritanchor[from=ellipse]{east}
+ \inheritanchor[from=ellipse]{mid east}
+ \inheritanchor[from=ellipse]{base east}
+ \inheritanchor[from=ellipse]{north east}
+ \inheritanchor[from=ellipse]{south east}
+
+ \inheritbackgroundpath[from=ellipse]
+}
+
+%%
+%%
+%% n concentric circles
+%%
+
+\tikzset{circlen/.code={\def\circlen@n{#1}\pgfkeysalso{shape=circlen@shape}}}
+\pgfdeclareshape{circlen@shape}
+{
+ \savedanchor\centerpoint{%
+ \pgf@x=.5\wd\pgfnodeparttextbox%
+ \pgf@y=.5\ht\pgfnodeparttextbox%
+ \advance\pgf@y by-.5\dp\pgfnodeparttextbox%
+ }
+
+ \saveddimen\radius{%
+ %
+ % Caculate ``height radius''
+ %
+ \pgf@ya=.5\ht\pgfnodeparttextbox%
+ \advance\pgf@ya by.5\dp\pgfnodeparttextbox%
+ \pgfmathsetlength\pgf@yb{\pgfkeysvalueof{/pgf/inner ysep}}%
+ \advance\pgf@ya by\pgf@yb%
+ %
+ % Caculate ``width radius''
+ %
+ \pgf@xa=.5\wd\pgfnodeparttextbox%
+ \pgfmathsetlength\pgf@xb{\pgfkeysvalueof{/pgf/inner xsep}}%
+ \advance\pgf@xa by\pgf@xb%
+ %
+ % Calculate length of radius vector:
+ %
+ \pgf@process{\pgfpointnormalised{\pgfqpoint{\pgf@xa}{\pgf@ya}}}%
+ \ifdim\pgf@x>\pgf@y%
+ \c@pgf@counta=\pgf@x%
+ \ifnum\c@pgf@counta=\z@%
+ \else%
+ \divide\c@pgf@counta by 255\relax%
+ \pgf@xa=16\pgf@xa\relax%
+ \divide\pgf@xa by\c@pgf@counta%
+ \pgf@xa=16\pgf@xa\relax%
+ \fi%
+ \else%
+ \c@pgf@counta=\pgf@y%
+ \ifnum\c@pgf@counta=\z@%
+ \else%
+ \divide\c@pgf@counta by 255\relax%
+ \pgf@ya=16\pgf@ya\relax%
+ \divide\pgf@ya by\c@pgf@counta%
+ \pgf@xa=16\pgf@ya\relax%
+ \fi%
+ \fi%
+ \pgf@x=\pgf@xa%
+ %
+ % If necessary, adjust radius so that the size requirements are
+ % met:
+ %
+ \pgfmathsetlength{\pgf@xb}{\pgfkeysvalueof{/pgf/minimum width}}%
+ \pgfmathsetlength{\pgf@yb}{\pgfkeysvalueof{/pgf/minimum height}}%
+ \ifdim\pgf@x<.5\pgf@xb%
+ \pgf@x=.5\pgf@xb%
+ \fi%
+ \ifdim\pgf@x<.5\pgf@yb%
+ \pgf@x=.5\pgf@yb%
+ \fi%
+ %
+ % Now, add larger of outer sepearations.
+ %
+ \pgfmathsetlength{\pgf@xb}{\pgfkeysvalueof{/pgf/outer xsep}}%
+ \pgfmathsetlength{\pgf@yb}{\pgfkeysvalueof{/pgf/outer ysep}}%
+ \ifdim\pgf@xb<\pgf@yb%
+ \advance\pgf@x by\pgf@yb%
+ \else%
+ \advance\pgf@x by\pgf@xb%
+ \fi%
+ \pgf@xb=2pt
+ \multiply\pgf@xb\circlen@n
+ \advance\pgf@x\pgf@xb
+ \advance\pgf@x-2pt\relax
+ }
+
+ %
+ % Anchors
+ %
+ \anchor{center}{\centerpoint}
+ \anchor{mid}{\centerpoint\pgfmathsetlength\pgf@y{.5ex}}
+ \anchor{base}{\centerpoint\pgf@y=0pt}
+ \anchor{north}{\centerpoint\advance\pgf@y by\radius}
+ \anchor{south}{\centerpoint\advance\pgf@y by-\radius}
+ \anchor{west}{\centerpoint\advance\pgf@x by-\radius}
+ \anchor{east}{\centerpoint\advance\pgf@x by\radius}
+ \anchor{mid west}{\centerpoint\advance\pgf@x by-\radius\pgfmathsetlength\pgf@y{.5ex}}
+ \anchor{mid east}{\centerpoint\advance\pgf@x by\radius\pgfmathsetlength\pgf@y{.5ex}}
+ \anchor{base west}{\centerpoint\advance\pgf@x by-\radius\pgf@y=0pt}
+ \anchor{base east}{\centerpoint\advance\pgf@x by\radius\pgf@y=0pt}
+ \anchor{north west}{
+ \centerpoint
+ \pgf@xa=\radius
+ \advance\pgf@x by-0.707107\pgf@xa
+ \advance\pgf@y by0.707107\pgf@xa
+ }
+ \anchor{south west}{
+ \centerpoint
+ \pgf@xa=\radius
+ \advance\pgf@x by-0.707107\pgf@xa
+ \advance\pgf@y by-0.707107\pgf@xa
+ }
+ \anchor{north east}{
+ \centerpoint
+ \pgf@xa=\radius
+ \advance\pgf@x by0.707107\pgf@xa
+ \advance\pgf@y by0.707107\pgf@xa
+ }
+ \anchor{south east}{
+ \centerpoint
+ \pgf@xa=\radius
+ \advance\pgf@x by0.707107\pgf@xa
+ \advance\pgf@y by-0.707107\pgf@xa
+ }
+ \anchorborder{
+ \pgf@xa=\pgf@x%
+ \pgf@ya=\pgf@y%
+ \edef\pgf@marshal{%
+ \noexpand\pgfpointborderellipse
+ {\noexpand\pgfqpoint{\the\pgf@xa}{\the\pgf@ya}}
+ {\noexpand\pgfqpoint{\radius}{\radius}}%
+ }%
+ \pgf@marshal%
+ \pgf@xa=\pgf@x%
+ \pgf@ya=\pgf@y%
+ \centerpoint%
+ \advance\pgf@x by\pgf@xa%
+ \advance\pgf@y by\pgf@ya%
+ }
+
+ %
+ % Background path
+ %
+ \behindbackgroundpath{
+ \pgfutil@tempdima=\radius%
+ \pgfmathsetlength{\pgf@xb}{\pgfkeysvalueof{/pgf/outer xsep}}%
+ \pgfmathsetlength{\pgf@yb}{\pgfkeysvalueof{/pgf/outer ysep}}%
+ \ifdim\pgf@xb<\pgf@yb%
+ \advance\pgfutil@tempdima by-\pgf@yb%
+ \else%
+ \advance\pgfutil@tempdima by-\pgf@xb%
+ \fi%
+ \sseq@tempcount=\@ne
+ \loop
+ \pgfpathcircle{\centerpoint}{\pgfutil@tempdima}%
+ \advance\pgfutil@tempdima-2pt\relax
+ \advance\sseq@tempcount\@ne
+ \ifnum\sseq@tempcount<\circlen@n \repeat
+ \tikz@mode
+ \sseq@eval{\noexpand\pgfusepath{
+ \iftikz@mode@draw draw,\fi
+ }}
+ }
+ \backgroundpath{%
+ \pgfutil@tempdima=\radius%
+ \pgfmathsetlength{\pgf@xb}{\pgfkeysvalueof{/pgf/outer xsep}}%
+ \pgfmathsetlength{\pgf@yb}{\pgfkeysvalueof{/pgf/outer ysep}}%
+ \ifdim\pgf@xb<\pgf@yb%
+ \advance\pgfutil@tempdima by-\pgf@yb%
+ \else%
+ \advance\pgfutil@tempdima by-\pgf@xb%
+ \fi%
+ \advance\pgfutil@tempdima2pt\relax
+ \pgfutil@tempdimb=-2pt\relax
+ \multiply\pgfutil@tempdimb\circlen@n
+ \advance\pgfutil@tempdima\pgfutil@tempdimb\relax
+ \pgfpathcircle{\centerpoint}{\pgfutil@tempdima}
+ }
+}
+
+
+
+% For out of bounds edges:
+
+\pgfdeclarearrow{
+ name = ...,
+ parameters = { \the\pgfarrowlength\the\pgflinewidth},
+ setup code = {
+ % The different end values:
+ \pgfarrowssetlineend{-\pgfarrowlength}
+ \pgfarrowssetbackend{-0.6\pgfarrowlength}
+ % The hull
+ \pgfarrowshullpoint{-\pgfarrowlength}{0pt}
+ \pgfarrowshullpoint{\pgfarrowlength}{0pt}
+ % Saves: Only the length:
+ \pgfarrowssavethe\pgfarrowlength
+ \pgfarrowssavethe\pgflinewidth
+ },
+ drawing code = {
+ \pgfpathcircle{\pgfpoint{-0.7\pgfarrowlength}{0pt}}{1.5\pgflinewidth}
+ \pgfpathcircle{\pgfpoint{-0.4\pgfarrowlength}{0pt}}{1.5\pgflinewidth}
+ \pgfpathcircle{\pgfpoint{-0.1\pgfarrowlength}{0pt}}{1.5\pgflinewidth}
+ \pgfpathclose
+ \pgfusepathqfill
+ },
+ defaults = { length = 0.3cm }
+} \ No newline at end of file
diff --git a/Master/texmf-dist/tex/latex/spectralsequences/sseqforeach.code.tex b/Master/texmf-dist/tex/latex/spectralsequences/sseqforeach.code.tex
new file mode 100644
index 00000000000..0d4c4758215
--- /dev/null
+++ b/Master/texmf-dist/tex/latex/spectralsequences/sseqforeach.code.tex
@@ -0,0 +1,88 @@
+%%
+%% Package: spectralsequences.sty version 1.0
+%% Author: Hood Chatham
+%% Email: hood@mit.edu
+%% Date: 2017-06-18
+%% License: Latex Project Public License
+%%
+%% File: sseqforeach.code.tex
+%%
+%% Patches the \foreach command to obtain better error reporting
+%%
+
+
+% All of this \foreach stuff is defined by tikz in the file /pgf/utilities/pgffor.code.tex
+
+\def\sseq@for@nopatch{\sseq@error{foreach-patch-failed}\def\sseq@patchfor{}\endinput}
+
+\newtoks\sseq@foreachcall
+
+\def\sseq@for@vars{}
+\def\sseq@for@savemacro#1{\sseq@d@addto@macro\sseq@for@vars{\sseq@for@vars@do#1}}
+\def\sseq@for@vars@do#1{; \string#1 = #1}
+\def\sseq@for@vars@donx#1{; \string#1= #1}
+\ExplSyntaxOn
+\def\sseq@for@printvars{\ifx\sseq@for@vars\pgfutil@empty\else\exp_last_unbraced:Nf\@gobble\sseq@for@vars\fi}
+\ExplSyntaxOff
+
+
+\def\sseq@patchfor{%
+ \let\pgffor@atbeginforeach\sseq@pgffor@atbeginforeach
+ \let\pgffor@@vars@opt\sseq@pgffor@@vars@opt
+}
+\def\sseq@pgffor@modify#1{%
+ \@xp\let\csname sseq@\sseq@macroname#1\endcsname #1%
+ \eappto\sseq@patchfor{\let\@nx#1 \@xp\@nx\csname sseq@\sseq@macroname#1\endcsname}%
+}
+
+
+
+\def\sseq@pgffor@recordarg#1#2{
+ \sseq@pgffor@modify#1
+ \@xp\pretocmd\csname sseq@\sseq@macroname#1\endcsname{\sseq@foreachcall\@xp{\the\sseq@foreachcall#2}}{}{\sseq@for@nopatch}
+}
+\def\sseq@pgffor@erecordarg#1#2{
+ \sseq@pgffor@modify#1
+ \@xp\pretocmd\csname sseq@\sseq@macroname#1\endcsname{\sseq@eval{\sseq@foreachcall{\the\sseq@foreachcall#2}}}{}{\sseq@for@nopatch}
+}
+
+
+
+\bgroup\lccode`\*=`\#\lowercase{\egroup
+
+
+\def\sseq@pgffor@atbeginforeach{%
+ \begingroup %
+ \sseq@atbeginforeach@msgsetup
+ % \pgffor@macro@list calls \pgffor@normal@list, so we need to mark that the list has already been added to foreachcall.
+ \sseq@tempiftrue
+}
+
+% Modify the foreach argument parser commands to put the call into \sseq@foreachcall and to tell us what the variables are
+\def\sseq@pgffor@@vars@opt[#1]{\sseq@foreachcall\@xp{\the\sseq@foreachcall#1}\pgfkeys{/sseqpages/foreach/.cd,#1}\pgffor@vars}
+
+\sseq@pgffor@recordarg\pgffor@@vars{*1}
+\pretocmd\sseq@pgffor@@vars{\sseq@for@savemacro*1}{}{\sseq@for@nopatch}
+
+\sseq@pgffor@recordarg\pgffor@@vars@slash@gobble{/}
+\sseq@pgffor@recordarg\pgffor@macro@list{in *1}
+\pretocmd\sseq@pgffor@macro@list{\sseq@tempiffalse}{}{\sseq@for@nopatch}% Don't add this again in \pgffor@normal@lis
+
+\sseq@pgffor@modify\pgffor@normal@list
+% Add list to argument if it wasn't a macro
+\pretocmd\sseq@pgffor@normal@list{\ifsseq@tempif\sseq@foreachcall\@xp{\the\sseq@foreachcall in {*1}}\fi\sseq@tempiftrue}{}{\sseq@for@nopatch}
+
+\sseq@pgffor@recordarg\pgffor@collectforeach@macro{\foreach}
+\sseq@pgffor@recordarg\pgffor@collectforeach@normal{\foreach}
+
+\sseq@pgffor@modify\pgffor@iterate
+\pretocmd\sseq@pgffor@iterate{\sseq@opushstacktrace{\the\sseq@foreachcall}\sseq@thiscalltoks\@xp{\the\sseq@foreachcall}}{}{\sseq@for@nopatch}
+
+\sseq@pgffor@modify\pgffor@doloop
+\sseq@pgffor@modify\pgffor@invokebody
+\patchcmd\sseq@pgffor@doloop{\pgffor@begingroup}{\pgffor@begingroup\sseq@xsetlastcall{\the\sseq@foreachcall}}{}{\sseq@for@nopatch}
+\patchcmd\sseq@pgffor@invokebody{\pgffor@begingroup}{\pgffor@begingroup\sseq@xsetlastcall{\the\sseq@foreachcall}}{}{\sseq@for@nopatch}
+}
+
+%TODO: also hook \pgffor@assign@parse, \pgffor@remember@parse, \pgffor@count@parse.
+
diff --git a/Master/texmf-dist/tex/latex/spectralsequences/sseqkeys.code.tex b/Master/texmf-dist/tex/latex/spectralsequences/sseqkeys.code.tex
new file mode 100644
index 00000000000..74667335805
--- /dev/null
+++ b/Master/texmf-dist/tex/latex/spectralsequences/sseqkeys.code.tex
@@ -0,0 +1,1667 @@
+%%
+%% Package: spectralsequences.sty version 1.0
+%% Author: Hood Chatham
+%% Email: hood@mit.edu
+%% Date: 2017-06-18
+%% License: Latex Project Public License
+%%
+%% File: sseqkeys.code.tex
+%% Exposes: \sseqset
+%%
+%% Sets up the keys for sseqpages. There are a lot of them...
+%%
+
+
+
+\def\sseq@pgfqkeysdirlist#1#2{%
+ \sseq@temptoks{#2}%
+ \sseq@pgfqkeysdirlist@#1,\sseq@nil
+}
+
+\def\sseq@pgfqkeysdirlist@#1,{%
+ \sseq@eval{\@nx\pgfqkeys{#1}{\the\sseq@temptoks}}%
+ \@ifnextchar\sseq@nil{\@gobble}{\sseq@pgfqkeysdirlist@}%
+}
+
+%%%% Interface macros:
+% These are the things that are used outside of this section:
+\let\sseq@pgfkeys@error@save\pgfkeys@error
+\pgfkeys{/sseqpages/userstyles/.unknown/.code={\sseq@passoptionto{\sseq@sseqsetdirectory}}}
+\def\sseqset#1{\pgfqkeys{/sseqpages/userstyles}{#1}}
+
+\def\sseq@sseqsetdirectory{/sseqpages/global/default}
+
+\def\sseq@set{\pgfqkeys{/sseqpages}}
+
+%%%
+%%% Local Keys
+%%%
+
+% This is where and how we are going to store the results of our local options. Note that definitions need to be local to allow recursion.
+\def\sseq@savedoptioncode{}
+\def\sseq@d@addto@options{\sseq@d@addto@macro\sseq@savedoptioncode}
+\def\sseq@e@addto@options{\sseq@e@addto@macro\sseq@savedoptioncode}
+
+% #1 -- name of key
+% #2 -- options
+% This is the main way that we use options. (We also use \pgfqkeys{/sseqpages/global} and some similar things)
+% Dumps out code that the option indexes into \sseq@savedoptioncode
+% This is because \pgfkeys has a high performance cost, so instead of using \pgfkeys once per page,
+% we use this once when putting together the spectral sequence and save the result.
+\def\sseq@processoptions#1#2{%
+ \def\sseq@savedoptioncode{}%
+ \sseq@protectedeval{\@nx % TODO: get rid of this protectedeval
+ \pgfqkeys{/sseqpages/#1}{#2}
+ }%
+}
+
+% First pass versus second pass:
+% Lots of options mainly do stuff on the drawing run, but still need to warn the sseq setup algorithms that they're around
+% on the first pass. Some only do things on the first pass or only do things on the second pass.
+% For example, shifts: shifts apply a coordinate transform on the second pass, but also need to factor into the coordinates of
+% classes etc which are computed at specification time not at draw time. So xshift=2 increases \sseq@x by 2 on it's first pass and
+% applies a coordinate transfrom by 2cm on the second pass.
+
+% normal mode does the firstpass options now and saves the secondpass options in \sseq@savedoptioncode for later use.
+% firstpass mode does the firstpass options and throws away the secondpass options.
+% secondpass mode throws away the firstpass options and does the secondpass options NOW
+% bothpass mode does both firstpass and secondpass options NOW
+% We spend the vast majority of our time in normal mode.
+
+\def\sseq@options@use#1{#1}
+\def\sseq@options@normalmode{\let\sseq@options@firstpass\sseq@options@use\let\sseq@options@secondpass\sseq@d@addto@options}
+\def\sseq@options@firstpassmode{\let\sseq@options@firstpass\sseq@options@use\let\sseq@options@secondpass\@gobble}
+\def\sseq@options@secondpassmode{\let\sseq@options@firstpass\@gobble\let\sseq@options@secondpass\sseq@options@use}
+\def\sseq@options@bothpassmode{\let\sseq@options@firstpass\sseq@options@use\let\sseq@options@secondpass\sseq@options@use}
+\sseq@options@normalmode
+
+\pgfqkeys{/handlers}{
+ .sseq @ first pass code/.code={
+ \pgfkeysalso{\pgfkeyscurrentpath/.code={\sseq@options@firstpass{#1}}}
+ },
+ .sseq @ first pass append code/.code={
+ \pgfkeysalso{\pgfkeyscurrentpath/.append code={\sseq@options@firstpass{#1}}}
+ },
+ .sseq @ second pass code/.code={
+ \pgfkeysalso{\pgfkeyscurrentpath/.code={\sseq@options@secondpass{#1}}}
+ },
+ .sseq @ second pass append code/.code={
+ \pgfkeysalso{\pgfkeyscurrentpath/.append code={\sseq@options@secondpass{#1}}}
+ },
+ .sseq @ second pass store in/.code={
+ \pgfkeysalso{\pgfkeyscurrentpath/.code={\sseq@options@secondpass{\def#1{##1}}}}
+ },
+ .sseq @ code/.code 2 args={
+ \pgfkeysalso{\pgfkeyscurrentpath/.code={\sseq@options@firstpass{#1}}}
+ \pgfkeysalso{\pgfkeyscurrentpath/.append code={\sseq@options@secondpass{#1}}}
+ },
+ .sseq @ transform/.code={
+ \sseq@keys@lastpart
+ \edef\sseq@temppath{\pgfkeyscurrentpath/\sseq@temp}
+ \pgfkeysalso{\sseq@temppath/.code/.expanded={\@nx\sseq@checktransform{\sseq@temp}\unexpanded{{##1}}}}
+ \pgfkeysalso{\sseq@temppath/.sseq @ second pass append code/.expanded={\@nx\sseq@pgfkeysdocommand{\sseq@temp}\unexpanded{{##1}}}}%
+ },
+ .sseq @ stdparse do transform/.code={
+ \sseq@keys@lastpart
+ \edef\sseq@temppath{\pgfkeyscurrentpath/\sseq@temp}
+ \ifx\pgfkeyscurrentvalue\pgfkeysnovalue@text
+ \pgfkeysalso{\sseq@temppath/.code/.expanded={\@nx\sseq@standardparse\@nx\sseq@options@secondpass{\@nx\sseq@pgfkeysdocommand{\sseq@temp}\unexpanded{{##1}}}}}
+ \else
+ \pgfkeysalso{\sseq@temppath/.code/.expanded={\@nx\sseq@standardparse\@nx\sseq@options@secondpass{\@nx\sseq@pgfkeysdocommand{\sseq@temp}{#1}}}s}
+ \fi
+ },
+ .sseq @ illegal/.code={
+ \sseq@keys@lastpart
+ \edef\sseq@temppath{\pgfkeyscurrentpath/\sseq@temp}
+ \pgfkeysalso{\sseq@temppath/.code/.expanded={\@nx\sseq@error@n{option-illegal}{\sseq@temp}}}
+ },
+ .sseq @ illegal as global/.code={
+ \sseq@keys@lastpart
+ \pgfkeysalso{/sseqpages/global/\sseq@temp/.code/.expanded={\@nx\sseq@error@n{option-illegal-as-global}{\sseq@temp}}}
+ },
+ .sseq @ global only/.code={
+ \sseq@keys@lastpart
+ \pgfkeysalso{/sseqpages/\sseq@temp/.code/.expanded={\@nx\sseq@error@n{option-global-only}{\sseq@temp}}}
+ }
+}
+
+
+%%% Some easy internal macros
+
+% This is for .unknown handlers. Try same key in different directory #1.
+\def\sseq@passoptionto#1{\sseq@eval{\@nx\pgfqkeys{#1}{\pgfkeyscurrentname={\unexpanded\@xp{\pgfkeyscurrentvalue}}}}}
+
+\def\sseq@pgfkeysdocommand#1#2{
+ \sseq@tempiffalse
+ \sseq@pgfkeysdocommand@try{/tikz/#1}{#2}
+ \sseq@pgfkeysdocommand@try{/pgf/#1}{#2}
+ % is this really an internal error? Maybe we should have failed earlier?
+ \ifsseq@tempif\else\sseq@error@internal@nn{do-command-failed}{#1}{#2}\fi
+}
+
+\def\sseq@pgfkeysdocommand@try#1#2{
+ \ifsseq@tempif\else
+ \pgfkeysifdefined{#1/.@cmd}{
+ \sseq@tempiftrue
+ \pgfkeysgetvalue{#1/.@cmd}{\pgfkeys@code}%
+ \pgfkeys@code#2\pgfeov
+ }{
+ \pgfkeysifdefined{#1}{
+ \sseq@tempiftrue
+ \pgfkeyssetvalue{#1}{#2}
+ }{}
+ }
+ \fi
+}
+
+%%%
+% Our main unknown option handler
+% This is copied from the standard tikz .unknown handler, but instead of running the code it stores it in \sseq@savedoptioncode.
+% When it tries the key in /tikz and in /pgf it also recursively expands \pgfkeysalso's.
+
+\def\sseq@keys@unknown@error@normal{\sseq@error{unknown-key}} % a hook so we can turn off errors if we like
+\let\sseq@keys@unknown@error\sseq@keys@unknown@error@normal % This is used in .sseq style
+\let\sseq@add@tikzkey@to@options\sseq@e@addto@options % another hook for .sseq style
+
+\def\sseq@keys@unknown{%
+ \let\tikz@key\pgfkeyscurrentname
+ \sseq@keys@try@addtooptions{/sseqpages/userstyles,/tikz,/pgf}{}{%
+ \@xp\pgfutil@in@\@xp!\@xp{\tikz@key}%
+ \ifpgfutil@in@%
+ % this is a color!
+ \sseq@keys@unknown@handlecolor
+ \else%
+ \pgfutil@doifcolorelse{\tikz@key}%
+ {%
+ \sseq@keys@unknown@handlecolor
+ }%
+ {%
+ % Ok, second chance: This might be an arrow specification:
+ \@xp\pgfutil@in@\@xp-\@xp{\tikz@key}%
+ \ifpgfutil@in@%
+ % Ah, an arrow spec!
+ \sseq@add@tikzkey@to@options{\@nx\tikz@processarrows{\tikz@key}}%
+ \else%
+ % Ok, third chance: A shape!
+ \@xp\ifx\csname pgf@sh@s@\tikz@key\endcsname\relax%
+ \sseq@keys@unknown@error%
+ \else%
+ \sseq@add@tikzkey@to@options{\def\@nx\tikz@shape{\tikz@key}}%
+ \fi%
+ \fi%
+ }%
+ \fi%
+ }%
+}
+
+\def\sseq@keys@unknown@handlecolor{%
+ \sseq@add@tikzkey@to@options{\@nx\tikz@addoption{\@nx\tikz@compat@color@set{\tikz@key}}}%
+ \sseq@add@tikzkey@to@options{\def\@nx\tikz@textcolor{\tikz@key}}%
+}
+
+%%% \sseq@keys@try@addtooptions
+% #1 -- a comma separated list of directories
+% #2 -- success code
+% #3 -- failure code
+%
+% This is for the main .unknown handler and for \sseq@addstylecodetooptions (which pretends to be \pgfkeys executed in a directory with only a .unknown)
+% Tries to run the current key (\pgfkeyscurrentname=\pgfkeyscurrentvalue) in each of the directories in turn.
+% If it finds the key in one of the directories, recursively expand the \pgfkeysalso in the code,
+% add the final result to \sseq@savedoptioncode, and run success code. Otherwise run failure code.
+%
+% The goal is to avoid storing any commands that require the use of pgfkeys.
+% This is only a partial solution, because it misses \tikzset, \pfgqkeys, etc.
+% \pgfkeysalso is particularly dangerous though because we might not remember what directory it was supposed to happen in.
+% In order to get the recursive expansion of \pgfkeysalso's we need to modify the pgfkeys algorithm so that it
+% passes control back to \sseq@keys@addtooptions@checkalso when it's done.
+% Modifies tikz commands \pgfkeys@case@one and \pgfkeys@case@two@extern from file /pgf/utilities/pgfkeys.code.tex lines 352 and 365
+\def\sseq@keys@try@addtooptions#1{%
+ \sseq@keys@try@addtooptions@#1,\sseq@nil
+}
+\def\sseq@keys@try@addtooptions@#1,{%
+ \bgroup
+ \def\pgfkeysdefaultpath{#1/}%
+ \def\next{\egroup\@ifnextchar\sseq@nil{\@xp\@secondoftwo\@gobble}{\sseq@keys@try@addtooptions@}}%
+ \pgfkeysifdefined{#1/\pgfkeyscurrentname/.@cmd}{%
+ \ifx\pgfkeyscurrentvalue\pgfkeysnovalue@text% Hmm... no value
+ \pgfkeysifdefined{#1/\pgfkeyscurrentname/.@def}%
+ {\pgfkeysgetvalue{#1/\pgfkeyscurrentname/.@def}{\pgfkeyscurrentvalue}}
+ {}% no default, so leave it
+ \fi%
+ \pgfkeysgetvalue{#1/\pgfkeyscurrentname/.@cmd}{\pgfkeys@code}%
+ \sseq@eval{\@nx\sseq@keys@addtooptions@checkalso{\unexpanded\@xptwo{\@xp\pgfkeys@code\pgfkeyscurrentvalue\pgfeov}}}%
+ \sseq@smuggle@macro\sseq@savedoptioncode
+ \egroup
+ \def\next{\@xp\@firstoftwo\sseq@gobble@to@nil}%
+ }{%
+ \pgfkeysifdefined{#1/\pgfkeyscurrentname}{%
+ \egroup
+ \sseq@add@tikzkey@to@options{\@nx\pgfkeyssetvalue{#1/\pgfkeyscurrentname}{\unexpanded\@xp{\pgfkeyscurrentvalue}}}%
+ \def\next{\@xp\@firstoftwo\sseq@gobble@to@nil}%
+ }{}%
+ }%
+ \next
+}
+
+\def\sseq@keys@addtooptions@checkalso#1{%
+ \let\pgfkeys@case@one\sseq@pgfkeys@case@one@store
+ \let\pgfkeys@case@two@extern\sseq@pgfkeys@case@two@extern@store
+ \sseq@keys@addtooptions@checkalso@#1\pgfkeysalso\sseq@nil
+}
+\def\sseq@keys@addtooptions@checkalso@#1\pgfkeysalso#2{%
+ \sseq@add@tikzkey@to@options{\unexpanded{#1}}%
+ \ifx\sseq@nil#2%
+ \let\pgfkeys@case@one\sseq@pgfkeys@case@one@save
+ \let\pgfkeys@case@two@extern\sseq@pgfkeys@case@two@extern@save
+ \else
+ \pgfkeysalso{#2}%
+ \@xp\sseq@keys@addtooptions@checkalso@
+ \fi
+}
+
+\let\sseq@pgfkeys@case@one@save\pgfkeys@case@one
+\let\sseq@pgfkeys@case@two@extern@save\pgfkeys@case@two@extern
+\def\sseq@pgfkeys@case@one@store{%
+ \pgfkeysifdefined{\pgfkeyscurrentkey/.@cmd}{%
+ \pgfkeysgetvalue{\pgfkeyscurrentkey/.@cmd}{\pgfkeys@code}%
+ % The following line is the only change, it used to be \@xp\pgfkeys@code\pgfkeyscurrentvalue\pgfeov which would just run the code.
+ % Instead we recursively expand the \pgfkeysalso's and then store in it \sseq@savedoptioncode
+ \sseq@eval{\@nx\sseq@keys@addtooptions@checkalso{\unexpanded\@xptwo{\@xp\pgfkeys@code\pgfkeyscurrentvalue\pgfeov}}}%
+ }{\pgfkeys@case@two}%
+}
+\def\sseq@pgfkeys@case@two@extern@store{%
+ \ifx\pgfkeyscurrentvalue\pgfkeysnovalue@text%
+ \pgfkeysvalueof{\pgfkeyscurrentkey}% this probably isn't a real case
+ \else%
+ % The following line is the only change, it used to be (roughly) \pgfkeyssetvalue{\pgfkeyscurrentkey}{\pgfkeyscurrentvalue}
+ % which would immediately set the value. Instead we store in it \sseq@savedoptioncode
+ \sseq@add@tikzkey@to@options{\@nx\pgfkeyssetvalue{\pgfkeyscurrentkey}{\unexpanded\@xp{\pgfkeyscurrentvalue}}}%
+ \fi%
+}
+
+\pgfkeys{%
+ /sseqpages/.is family,
+ /sseqpages/.unknown/.code={\sseq@keys@unknown},
+%
+ /sseqpages/class/.unknown/.code={%
+ \expandafter\ifx\csname pgf@sh@s@\pgfkeyscurrentname\endcsname\relax % is it the name of a shape?
+ \sseq@passoptionto{/sseqpages}%
+ \else
+ \sseq@e@addto@options{\def\@nx\tikz@shape{\pgfkeyscurrentname}}% if so, store it
+ \fi
+ },
+ /sseqpages/.is family,
+ /sseqpages/scope/.is family,
+ /sseqpages/scope/.unknown/.code={\sseq@passoptionto{/sseqpages}},
+ /sseqpages/class/.is family,
+ /sseqpages/class/label/.is family,
+ /sseqpages/class/label/.unknown/.code={\sseq@keys@unknown},
+ /sseqpages/class/node texts/.is family,
+ /sseqpages/class/node texts/.unknown/.code={\sseq@passoptionto{/tikz}},
+ /sseqpages/differential/.is family,
+ /sseqpages/differential/.unknown/.code={\sseq@passoptionto{/sseqpages}},
+ /sseqpages/struct line/.is family,
+ /sseqpages/struct line/.unknown/.code={\sseq@passoptionto{/sseqpages}},
+ /sseqpages/label/.is family,
+ /sseqpages/label/.unknown/.code={\sseq@keys@unknown},
+ /sseqpages/tikz primitives/.is family,
+ /sseqpages/tikz primitives/.unknown/.code={\sseq@keys@unknown},
+ % One off directories
+ /sseqpages/fit/.unknown/.code={\sseq@passoptionto{/sseqpages}},
+ /sseqpages/foreach/.unknown/.code={\sseq@passoptionto{/pgf/foreach}},
+ /sseqpages/class placement/.unknown/.code={\sseq@passoptionto{/tikz}}
+}
+
+\pgfqkeys{/sseqpages/class}{shape/.code={\edef\tikz@shape{\pgfkeyscurrentname}}} % shape=whatever shape passing
+
+\pgfqkeys{/sseqpages/class/label}{% maybe implement multipart node labels this way? No way!
+ node/.sseq @ first pass code={\sseq@classlabelfalse},
+ inside/.sseq @ first pass code={\sseq@classlabelfalse}
+}
+
+%% label directions
+\def\sseq@labeldirectionlist{\\{above}\\{below}\\{left}\\{right}\\{above left}\\{above right}\\{below left}\\{below right}}
+\def\sseq@setlabeldirectionkeys#1{
+ \@ifnextchar[{\sseq@setlabeldirectionkeys@{#1}}{\sseq@setlabeldirectionkeys@{#1}[/.code]}%]
+}
+\def\sseq@setlabeldirectionkeys@#1[#2]#3{
+ \def\sseq@temp##1{#3}
+ \sseq@temptoks{}
+ \def\\##1{
+ \sseq@eval{\sseq@temptoks{\the\sseq@temptoks##1#2={\unexpanded\@xp{\sseq@temp{##1}}},}}
+ }
+ \sseq@labeldirectionlist
+ \sseq@eval{\@nx\pgfqkeys{#1}{\the\sseq@temptoks}}
+}
+
+\def\\#1{\@xp\sseq@addtostorelist\csname sseq@default@#1@distance\endcsname{1ex}}
+\sseq@labeldirectionlist
+\def\sseq@defaultlabeldistance#1{\@xp\csname sseq@default@#1@distance\endcsname}
+\def\sseq@setdefaultlabeldistance#1#2{\sseq@savedpaths@add{\@xp\gdef\csname sseq@default@#1@distance\endcsname{#2}}}
+\def\sseq@setdefaultlabeldistances#1{\def\\##1{\sseq@setdefaultlabeldistance{##1}{#1}}\sseq@labeldirectionlist}
+
+
+
+\sseq@setlabeldirectionkeys{/sseqpages/class/label}[/.sseq @ first pass code]
+ {\sseq@classlabeltrue\def\sseq@class@labelposition@name{#1}\def\sseq@class@labelposition@distance{##1}}
+\sseq@setlabeldirectionkeys{/sseqpages/class/label}[/.sseq @ second pass append code]{\sseq@class@positionlabel{#1}{##1}}
+\sseq@setlabeldirectionkeys{/sseqpages/class/label}[/.default]{\sseq@defaultlabeldistance{#1}}
+\sseq@setlabeldirectionkeys{/sseqpages/global/class/label}[/.default]{\sseq@defaultlabeldistance{#1}}
+
+\sseq@setlabeldirectionkeys{/sseqpages/global}[ label distance/.code]{\sseq@setdefaultlabeldistance{#1}{##1}}
+\sseq@setlabeldirectionkeys{/sseqpages}[ label distance/.code]{\sseq@setdefaultlabeldistance{#1}{##1}}
+
+\sseq@pgfqkeysdirlist{/sseqpages/global,/sseqpages}{
+ label distance/.code={\sseq@setdefaultlabeldistances{#1}}
+}
+
+\def\sseq@class@positionlabel#1#2{\sseq@pgfkeysdocommand{#1}{#2}}
+
+
+
+\sseq@addtostorelist\sseq@classlabeltextfn{} % \sseq@classlabeltextfn is public via "class label handler"
+\let\sseq@classlabeltextfn@default\@gobble
+\def\sseq@labeltextfn#1{#1} % labeltextfn is private
+\def\sseq@labeltextfn@rotatescale#1{%
+ \@nx\ifmmode
+ \@nx\scalebox{\sseq@labletext@scale@factor}{\@nx\rotatebox{\sseq@labletext@rotate@angle}{$#1$}}%
+ \@nx\else
+ \@nx\scalebox{\sseq@labletext@scale@factor}{\@nx\rotatebox{\sseq@labletext@rotate@angle}{#1}}%
+ \@nx\fi
+}
+\def\sseq@labletext@rotate@angle{0}
+\def\sseq@labletext@scale@factor{1}
+
+\bgroup\lccode`8=`p\lccode`9=`t\lowercase{\egroup
+\def\sseq@eatpt#189{#1}
+}
+
+\sseq@pgfqkeysdirlist{/sseqpages/label,/sseqpages/class/label}{
+ rotate/.code={%
+ \let\sseq@labeltextfn\sseq@labeltextfn@rotatescale
+ \edef\sseq@labletext@rotate@angle{\@xp\sseq@eatpt\the\dimexpr\sseq@labletext@rotate@angle pt+#1pt}%
+ },
+ scale/.code={%
+ \let\sseq@labeltextfn\sseq@labeltextfn@rotatescale
+ \edef\sseq@labletext@scale@factor{\@xp\sseq@eatpt\the\dimexpr\sseq@labletext@scale@factor pt*#1}%
+ },
+% shift/.sseq @ second pass code={\pgfkeysalso{xshift=\sseq@shift@getx#1}\pgfkeysalso{yshift=\sseq@shift@gety#1}}
+}
+
+
+\pgfqkeys{/sseqpages/global}{
+ background color/.initial=white
+}
+\pgfqkeys{/sseqpages/label}{
+ description/.code={%
+ \edef\sseq@edgeoptionhook{\@nx\pgfkeys{/tikz/fill=\pgfkeysvalueof{/sseqpages/global/background color}}}%
+ },
+ description/.sseq @ second pass append code={%
+ \pgfkeysalso{/tikz/anchor=center}%
+ }
+}
+
+\def\sseq@edgeoptionhook{}% This is just to make description work.
+
+%% Quote handling
+% \sseq@handlequote will be installed later as the 'first char syntax' for ".
+\def\sseq@protectlabel{\@nx\sseq@protectlabel\@nx}
+\def\sseq@handlequote#1{\pgfkeysalso{handle quote=#1}}
+\pgfkeys{%
+ /sseqpages/class/handle quote/.code={%
+ \let\tikz@quotes@as@save\tikz@quotes@as
+ \let\tikz@quotes@as\sseq@handleclassquotes
+ \tikz@quote@parser{#1}%
+ \let\tikz@quotes@as\tikz@quotes@as@save
+ },
+ /sseqpages/handle quote/.code={%
+ \begingroup % group gets ended by handleedgequotes
+ \let\tikz@quotes@as\sseq@handleedgequotes
+ \tikz@quote@parser{#1}%
+ }
+}
+
+
+\def\sseq@processlabels@default{%
+ \global\let\sseq@classnodetext\pgfutil@empty
+ \global\let\sseq@classnodetextoptions\pgfutil@empty
+ \global\let\sseq@classlabelnodes\pgfutil@empty
+}
+\let\sseq@processlabels\sseq@processlabels@default
+
+\def\sseq@handlescopequotes#1#2{% We use this via \let\tikz@quotes@as\sseq@handleclassquotes
+ /utils/exec={% so it's called inside \pgfkeysalso{stuff}. Need to surround with /utils/exec={} to get out.
+ \global\let\sseq@classnodetext\pgfutil@empty%
+ \global\let\sseq@classnodetextoptions\pgfutil@empty%
+ \global\let\sseq@classlabelnodes\pgfutil@empty%
+ \sseq@handleclassquotes@inner{#1}{#2}%
+ }
+}
+
+% We use this via \let\tikz@quotes@as\sseq@handleclassquotes
+% so it's called inside \pgfkeysalso{stuff}. Need to surround with /utils/exec={} to get out.
+\def\sseq@handleclassquotes#1#2{/utils/exec={\sseq@d@addto@macro\sseq@processlabels{\sseq@handleclassquotes@inner{#1}{#2}}}}
+
+\def\sseq@handleclassquotes@inner#1#2{%
+ \begingroup\pgfscope
+ \sseq@options@firstpassmode
+ \sseq@thesseqstyle
+ \sseq@thelabelstyle
+ \sseq@theclasslabelstyle
+ \the\sseq@scope@toks
+ \sseq@options@normalmode
+ \sseq@processoptions{class/label}{#2}%
+ \ifx\sseq@classlabeltextfn\@gobble
+ \def\processedlabel{#1}%
+ \else
+ \sseq@classlabeltextfn{#1}% labeltextfn is a private handler, classlabeltextfn is exposed via "class label handler"
+ \fi
+ \ifsseq@classlabel
+ \sseq@options@firstpassmode
+ \the\sseq@outerclasslabelstyle
+ \sseq@xprotected@addto@macro\sseq@classlabelnodes{
+ \@nx\ifsseq@needstikz
+ node[
+ /sseqpages/class/label,
+ /utils/exec={
+ \let\@nx\sseq@tikz@transform@save\@nx\tikz@transform
+ \let\@nx\tikz@transform\relax % The next line was set up to fix the classlabelstyle glitch
+ \the\sseq@sseqstyle\@nx\the\sseq@sseqstyle@page
+ \the\sseq@labelstyle\@nx\the\sseq@labelstyle@page\the\sseq@classlabelstyle\@nx\the\sseq@classlabelstyle@page
+ \sseq@theouterclasslabelstyle\unexpanded\@xp{\sseq@savedoptioncode}%
+ % \@nx\iftikz@fullytransformed\@nx
+ % \@nx\tikz@fullytransformedtrue
+ % \else
+ % \@nx{\@nx\pgftransformresetnontranslations\@nx\sseq@globalrotatetransform}
+ % \@nx\fi
+ \let\@nx\tikz@transform\@nx\sseq@tikz@transform@save
+ }%
+ ]{\sseq@labeltextfn{\processedlabel}}%
+ \@nx\else
+ \@nx\node[
+ /sseqpages/class/label,
+ /utils/exec={
+ \let\@nx\sseq@tikz@transform@save\@nx\tikz@transform
+ \let\@nx\tikz@transform\relax % The next line was set up to fix the classlabelstyle glitch
+ \the\sseq@sseqstyle\@nx\the\sseq@sseqstyle@page
+ \the\sseq@labelstyle\@nx\the\sseq@labelstyle@page\the\sseq@classlabelstyle\@nx\the\sseq@classlabelstyle@page
+ \sseq@theouterclasslabelstyle\unexpanded\@xp{\sseq@savedoptioncode}
+ % \@nx\iftikz@fullytransformed\@nx
+ % \@nx\tikz@fullytransformedtrue
+ % \else
+ % \@nx{\@nx\pgftransformresetnontranslations\@nx\sseq@globalrotatetransform}
+ % \@nx\fi
+ \let\@nx\tikz@transform\@nx\sseq@tikz@transform@save
+ }
+ ]{\unexpanded\@xp{\@xp\sseq@labeltextfn\@xp{\processedlabel}}};%
+ \@nx\fi
+ }%
+ \else
+ \sseq@options@firstpassmode
+ \the\sseq@innerclasslabelstyle
+ \sseq@options@normalmode
+ \sseq@protectedeval{\@nx\pgfqkeys{/sseqpages/class/label}{#2}}%
+ \sseq@protected@xdef\sseq@classnodetext{\processedlabel}%
+ \xdef\sseq@classnodetextoptions{%
+ %\unexpanded{\def\pgfkeysdefaultpath{/sseqpages/class/node texts/}}%
+ \sseq@thelabelstyle\sseq@theinnerclasslabelstyle\unexpanded\@xp{\sseq@savedoptioncode}%
+ }%
+ \fi
+ \endpgfscope\endgroup
+}
+
+\def\sseq@handleedgequotes#1#2{% We use this via \let\tikz@quotes@as\sseq@handleedgequotes
+ /utils/exec={% so it's called inside \pgfkeysalso{stuff}. Need to surround with /utils/exec={} to get out.
+ \endgroup
+ \let\sseq@savedoptioncode@save\sseq@savedoptioncode
+ \sseq@processoptions{label}{#2}
+ \sseq@needstikztrue
+ \let\sseq@temp\sseq@savedoptioncode
+ \let\sseq@savedoptioncode\sseq@savedoptioncode@save
+ \sseq@e@addto@options{
+ \@nx\tikzset{
+ every to/.append style={
+ edge node={
+ node [/sseqpages/label,
+ /utils/exec={
+ \let\@nx\sseq@tikz@transform@save\@nx\tikz@transform
+ \let\@nx\tikz@transform\relax
+ \@nx\sseq@thelabelstyle\@nx\sseq@theedgelabelstyle
+ \unexpanded\@xp{\sseq@temp}
+ \ifsseq@rotatelabels\iftikz@fullytransformed\else\@nx\tikz@fullytransformedtrue\@nx\tikz@addtransform{\@nx\pgftransformresetnontranslations\@nx\sseq@globalrotatetransform}\fi\fi
+ \unexpanded\@xp{\sseq@edgeoptionhook} % this is just to make description work
+ \let\@nx\tikz@transform\@nx\sseq@tikz@transform@save
+ }
+ ]{\sseq@labeltextfn{#1}}
+ }
+ }
+ }
+ }
+ }
+}
+
+
+\def\sseq@checktransform@error{\sseq@error@nn{illegal-transform}}
+\let\sseq@checktransform\sseq@checktransform@error
+
+
+%% Parsing, background vs foreground, and context
+\def\sseq@standardparse{%
+ \let\sseq@tikzprimitives@coords@maybeclass\sseq@tikzprimitives@coords@notaclass
+ \let\sseq@checktransform\@gobbletwo
+ \let\sseq@tikz@shifttransform\sseq@okayshifttransform
+ %((((((((((((((((((
+ \def\class##1){\sseq@setthiscall{\string\class##1)}\sseq@error@x{standard-parse}{\string\class}}%
+ \def\replaceclass##1){\sseq@setthiscall{\string\replaceclass##1)}\sseq@error@x{standard-parse}{\string\replaceclass}}%
+ \def\classoptions##1){\sseq@setthiscall{\string\classoptions##1)}\sseq@error@x{standard-parse}{\string\classoptions}}%
+ \def\d##1){\sseq@setthiscall{\string\d##1)}\sseq@error@x{standard-parse}{\string\d}}%
+ \def\doptions##1){\sseq@setthiscall{\string\doptions##1)}\sseq@error@x{standard-parse}{\string\doptions}}%
+ \def\structline##1)##2){\sseq@setthiscall{\string\structline##1)##2)}\sseq@error@x{standard-parse}{\string\structline}}%
+ \def\structlineoptions##1)##2){\sseq@setthiscall{\string\structlineoptions##1)##2)}\sseq@error@x{standard-parse}{\string\structlineoptions}}%
+}
+
+\def\sseq@nodeparse{%
+ \let\sseq@tikzprimitives@coords@maybeclass\sseq@tikzprimitives@coords@maybeclass@save
+ \let\sseq@tikzprimitives@coords@maybeclass
+ \def\sseq@transform{\sseq@error@nn{illegal-transform}} % Disallow most coordinate transforms
+ \let\sseq@shifttransform\sseq@checkshifttransform
+ \let\class\sseq@class
+ \let\replaceclass\sseq@replaceclass
+ \let\structline\sseq@structline
+}
+
+
+\sseq@pgfqkeysdirlist{/sseqpages,/sseqpages/tikz primitives}{%
+ standard parse/.code={
+ \let\sseq@firstpass@shifttransform\@gobbletwo
+ \sseq@d@addto@options{\sseq@standardparse}
+ \pgfkeys{/sseqpages/tikz primitives/shift/.sseq @ second pass code={\tikzset{shift={##1}}}}
+ },
+ node parse/.code={ % This is never used, probably broken, and likely shouldn't exist
+ \let\sseq@firstpass@shifttransform\sseq@firstpass@checkshifttransform
+ \let\sseq@checktransform\sseq@checktransform@error
+ \sseq@d@addto@options{\sseq@nodeparse}
+ },
+ background/.code={\sseq@setsavedpaths{background}\pgfkeysalso{standard parse}},
+ foreground/.code={\ifsseq@keepchanges\sseq@setsavedpaths{standard}\else\sseq@setsavedpaths{temporary}\fi\pgfkeysalso{node parse}}
+}
+
+\pgfkeys{
+ /sseqpages/tikz primitives/handle quote/.sseq @ second pass code={\tikzset{#1}},
+ /tikz/handle quote/.code={\sseq@error{tikz-edge-quotes}}
+}
+
+\sseq@pgfqkeysdirlist{/sseqpages/class,/sseqpages/differential}{
+ standard parse/.sseq @ first pass code={\sseq@error@n{option-tikz-prims-only}{standard parse}},
+ background/.sseq @ first pass code={\sseq@error@n{option-tikz-prims-only}{background}}
+}
+
+\def\sseq@class@tag{}
+\def\sseq@class@tagprefix{}
+\def\sseq@class@name{}
+\def\sseq@namehandler{}%\@xp\sseq@normalizepolynomial\@xp{\sseq@class@name}\let\sseq@class@name\sseq@polynomial}
+\def\sseq@currenttag{\sseq@class@tag}% for the user ??
+\def\sseq@tooltip{}
+\pgfqkeys{/sseqpages/scope}{
+ tag/.code={\pgfkeys@spdef\sseq@class@tag{#1}},
+ tag prefix/.code={\pgfkeys@spdef\temp{#1}\sseq@e@addto@macro\sseq@class@tagprefix{\unexpanded\@xp{#1}}}
+}
+
+\pgfqkeys{/sseqpages/class}{
+ name/.code={\def\sseq@class@name{#1}\pgfkeysalso{/sseqpages/alias=#1}},
+ show name/.code={\def\sseq@class@showname{#1}},
+ page/.code={\sseq@getnumrange\sseq@class@page{#1}},% page & gen are only for \classoptions.
+ generation/.code={\sseq@getnumrange\sseq@gen{#1}}, % \class tests if \sseq@class@page is set and throw an error if so.
+ tag/.code={\sseq@d@addto@macro\sseq@class@tag{#1}},
+ offset/.code={\def\sseq@tempoffset{#1}},
+ tooltip/.sseq @ first pass code={\def\sseq@tooltip{#1}}
+}
+
+\pgfqkeys{/sseqpages/struct line}{
+ page/.code={\sseq@getnumrange\sseq@structline@page{#1}}
+}
+
+\def\sseq@fitalso{}
+\pgfqkeys{/sseqpages/fit}{
+ fit/.sseq @ first pass code={\sseq@d@addto@macro\sseq@fitalso{#1}},
+ page/.code={\sseq@getnumrange\sseq@fit@page{#1}}
+}
+
+\def\sseq@getnumrange#1#2{
+ \pgfutil@in@{--}{#2}\ifpgfutil@in@
+ \sseq@getnumrange@range#1#2\sseq@nil
+ \else
+ \edef#1{\the\numexpr#2}
+ \fi
+}
+\def\sseq@getnumrange@range#1#2--#3\sseq@nil{\edef#1{\the\numexpr#2}\@xp\edef\csname\sseq@macroname#1max\endcsname{\the\numexpr#3}}
+
+%% Needs tikz
+% Force \class or \d to fall back to using tikz to render their output
+% Rather than using the faster direct \pgf primitives (largely copied from tikz to maximize compatibility)
+% Drawing with tikz is slower, but I don't want to reimplement these features
+\def\sseq@needstikzandpass#1#2{\sseq@needstikzandpass@{#1}#2,\@nil}
+\def\sseq@needstikzandpass@#1#2,{%
+ \pgfqkeys{#1}{#2/.code={\sseq@options@firstpass{\sseq@needstikztrue}\sseq@options@secondpass{\sseq@pgfkeysdocommand{#2}{##1}\sseq@needstikztrue}}}%
+ \@ifnextchar\@nil{\@gobble}{\sseq@needstikzandpass@{#1}}%
+}
+
+\pgfqkeys{/sseqpages}{needs tikz/.code=\sseq@needstikztrue}
+\sseq@needstikzandpass{/sseqpages}{%
+ shade, blend mode, pattern, path picture, path fading, decorate, pin, label
+}
+
+\sseq@needstikzandpass{/sseqpages/differential}{%
+ bend left, bend right, in, out, relative, looseness, in looseness, out looseness,
+ min distance, max distance, out min distance, out max distance, in min distance, in max distance, distance,
+ controls, in control, out control,
+ loop, loop above, loop below, loop left, loop right % maybe delete the loops and replace them with errors? It's pretty pointless to use these.
+}
+
+\sseq@needstikzandpass{/sseqpages/struct line}{%
+ bend left, bend right, in, out, relative, looseness, in looseness, out looseness,
+ min distance, max distance, out min distance, out max distance, in min distance, in max distance, distance,
+ controls, in control, out control,
+ loop, loop above, loop below, loop left, loop right % maybe delete the loops and replace them with errors? It's pretty pointless to use these.
+}
+
+% circle split/.code=\sseq@needstikzandpass,
+% circle solidus/.code=\sseq@needstikzandpass,
+% ellipse split/.code=\sseq@needstikzandpass,
+% rectangle split/.code=\sseq@needstikzandpass,
+% align/.code=\sseq@needstikzandpass,
+
+\sseq@addtostorelist\sseq@runoffarrow@start@differential@spec{...}
+\sseq@addtostorelist\sseq@runoffarrow@end@differential@spec{...}
+\sseq@addtostorelist\sseq@runoffarrow@start@structline@spec{...}
+\sseq@addtostorelist\sseq@runoffarrow@end@structline@spec{...}
+\sseq@pgfqkeysdirlist{/sseqpages/global,/sseqpages}{
+ run off differentials/.code args={#1-#2}{\def\sseq@runoffarrow@start@differential@spec{#1}\def\sseq@runoffarrow@end@differential@spec{#2}},
+ run off struct lines/.code args={#1-#2}{\def\sseq@runoffarrow@start@structline@spec{#1}\def\sseq@runoffarrow@end@structline@spec{#2}},
+ run off/.forward to=/sseqpages/run off differentials,
+ run off/.forward to=/sseqpages/run off struct lines
+}
+
+
+\sseq@pgfqkeysdirlist{/sseqpages/differential,/sseqpages/struct line}{
+ source anchor/.sseq @ second pass store in=\sseq@edgesourceanchor,
+ target anchor/.sseq @ second pass store in=\sseq@edgetargetanchor,
+ shorten >/.sseq @ second pass code={\sseq@pgfkeysdocommand{shorten >}{#1}},
+ shorten </.sseq @ second pass code={\sseq@pgfkeysdocommand{shorten <}{#1}},
+}
+\pgfqkeys{/sseqpages/differential}{
+ /sseqpages/differential/invisible/.sseq @ first pass code={\sseq@drawdifferentialfalse}
+}
+\newif\ifsseq@drawdifferential
+\sseq@drawdifferentialtrue
+
+%%%
+%%% Global Keys
+%%%
+
+%%% Style options
+
+%% Add key code to \sseq@savedoptioncode
+% #1 -- a list of directories to search
+% #2 -- keys
+% This is a faster and sloppier way of doing:
+%\def\sseq@temp{#1}
+%\pgfqkeys{/sseqpages/alwaysunknown}{#2}
+% and defining an event handler: alwaysunknown/.unknown/.code={\@xp\sseq@keys@try@addtooptions\@xp{\sseq@temp}{}{\sseq@keys@unknown}
+% Copied with modification from /pgf/utilities/pfgkeys.code.tex
+\def\sseq@addstylecodetooptions#1#2{%
+ \def\sseq@directorylist{#1}%
+ \sseq@simple@pgfkeys@parse#2,\pgfkeys@mainstop
+}
+
+\def\sseq@simple@pgfkeys@parse{\futurelet\pgfkeys@possiblerelax\sseq@simple@pgfkeys@parse@main}
+\def\sseq@simple@pgfkeys@parse@main{%
+ \ifx\pgfkeys@possiblerelax\pgfkeys@mainstop%
+ \@xp\@gobble
+ \else%
+ \@xp\sseq@simple@pgfkeys@@normal
+ \fi%
+}
+
+\def\sseq@simple@pgfkeys@@normal#1,{%
+ \sseq@simple@pgfkeys@unpack#1=\pgfkeysnovalue=\pgfkeys@stop
+ \sseq@simple@pgfkeys@parse
+}
+
+\def\sseq@simple@pgfkeys@unpack#1=#2=#3\pgfkeys@stop{%
+ \pgfkeys@spdef\pgfkeyscurrentkey{#1}%
+ \pgfkeys@spdef\pgfkeyscurrentvalue{#2}%
+ \ifx\pgfkeyscurrentkey\pgfkeys@empty\else
+ \def\next{\@xp\sseq@keys@try@addtooptions\@xp{\sseq@directorylist}{}{\sseq@addstylecodetooptions@unknown}}%
+ \sseq@simple@pgfkeys@checkquote#1\sseq@nil{%
+ \def\pgfkeyscurrentname{handle quote}%
+ \def\pgfkeyscurrentvalue{#1}%
+ }{%
+ \edef\pgfkeyscurrentkey{\pgfkeyscurrentkey}%
+ \ifx\pgfkeyscurrentkey\pgfkeys@empty
+ \let\next\relax
+ \else%
+ \let\pgfkeyscurrentname\pgfkeyscurrentkey
+ \fi
+ }%
+ \@xp\next
+ \fi
+}
+\let\sseq@addstylecodetooptions@unknown\sseq@keys@unknown
+
+\long\def\sseq@simple@pgfkeys@checkquote#1#2\sseq@nil{%
+ \ifx#1"%
+ \@xp\@firstoftwo
+ \else
+ \@xp\@secondoftwo
+ \fi
+}
+
+\def\sseq@sseqstyle@globalpart{}
+
+
+\def\sseq@stylelist{}
+\def\sseq@clearchangestyles{}
+
+
+\def\sseq@newstyles#1#2{\def\sseq@temppath{#1}\sseq@newstyles@#2,\sseq@nil}
+\def\sseq@newstyles@#1,{\sseq@newsseqstyle{\sseq@trimleadingspaces#1}\@ifnextchar\sseq@nil{\@gobble}{\sseq@newstyles@}}
+
+\def\sseq@set@newstyle#1{\pgfqkeys{/sseqpages}{#1}\pgfqkeys{/sseqpages/global}{#1}\pgfqkeys{/sseqpages/global/default}{#1}\pgfqkeys{/sseqpages/first pass}{#1}}
+
+\def\sseq@newsseqstyle#1{%
+ \sseq@setmacronospaces\sseq@tempcmd{sseq@#1style}%
+ \edef\sseq@tempcmdb{\csname\@xp\sseq@macroname\sseq@tempcmd @page\endcsname}%
+ \sseq@setmacronospaces\sseq@tempcmdc{sseq@the#1style}%
+ \@xp\edef\sseq@tempcmdc{\@nx\the\@xp\@nx\sseq@tempcmd\@nx\the\sseq@tempcmdb}%
+ \@xp\newtoks\sseq@tempcmd
+ \@xp\newtoks\sseq@tempcmdb
+ \sseq@x@addto@macro\sseq@stylelist{\sseq@tempcmd{\@nx\the\sseq@tempcmd}}%
+ \sseq@x@addto@macro\sseq@clearchangestyles{\sseq@tempcmdb{}}%
+ \sseq@set@newstyle{%
+ #1s/.ecode={%
+ \let\@nx\sseq@savedoptioncode@store\@nx\sseq@savedoptioncode
+ \edef\@nx\sseq@savedoptioncode{\@nx\the\sseq@tempcmd}%
+ \@nx\sseq@addstylecodetooptions{\sseq@temppath}{##1}%
+ \sseq@tempcmd\@nx\@xp{\@nx\sseq@savedoptioncode}%
+ \@nx\ifsseq@inprogress
+ \@nx\sseq@savedpaths@xadd{\sseq@tempcmd{\@nx\the\sseq@tempcmd}}%
+ \@nx\fi
+ \let\@nx\sseq@savedoptioncode\@nx\sseq@savedoptioncode@store
+ },%
+ change #1s/.ecode={%
+ \@nx\ifsseq@ispageenv\@nx\else\@nx\sseq@error@nn{change-style-data}{#1}{##1}\@nx\fi
+ \@nx\ifsseq@hasname\@nx\else\@nx\sseq@error@nn{change-style-standalone}{#1}{##1}\@nx\fi
+ \let\@nx\sseq@savedoptioncode@store\@nx\sseq@savedoptioncode
+ \edef\@nx\sseq@savedoptioncode{\@nx\the\sseq@tempcmdb}%
+ \@nx\sseq@addstylecodetooptions{\sseq@temppath}{##1}%
+ \sseq@tempcmdb\@nx\@xp{\@nx\sseq@savedoptioncode}%
+ \let\@nx\sseq@savedoptioncode\@nx\sseq@savedoptioncode@store
+ }
+ }%
+}
+
+
+\newtoks\sseq@sseqstyle
+\newtoks\sseq@sseqstyle@page
+\def\sseq@thesseqstyle{\the\sseq@sseqstyle\the\sseq@sseqstyle@page}
+
+% sseqs has to be handled separately, because it must decide whether an option is a global option or not
+% and handle them at different times. This makes the code a little trickier.
+\sseq@g@addto@macro\sseq@stylelist{\sseq@sseqstyle{\the\sseq@sseqstyle}}%
+\sseq@g@addto@macro\sseq@clearchangestyles{\sseq@sseqstyle@page{}}%
+\sseq@set@newstyle{
+ sseqs/.code={%
+ \let\sseq@savedoptioncode@store\sseq@savedoptioncode
+ \let\sseq@savedoptioncode\sseq@sseqstyle@globalpart
+ \def\sseq@addstylecodetooptions@unknown{%
+ \let\sseq@sseqstyle@globalpart\sseq@savedoptioncode
+ \edef\sseq@savedoptioncode{\the\sseq@sseqstyle}%
+ \sseq@keys@unknown
+ \sseq@sseqstyle\@xp{\sseq@savedoptioncode}%
+ \let\sseq@savedoptioncode\sseq@sseqstyle@globalpart
+ }%
+ \sseq@addstylecodetooptions{/sseqpages/global}{#1}%
+ \let\sseq@sseqstyle@globalpart\sseq@savedoptioncode
+ \ifsseq@inprogress
+ \sseq@savedpaths@xadd{\sseq@sseqstyle{\the\sseq@sseqstyle}}%
+ \fi
+ \let\sseq@addstylecodetooptions@unknown\sseq@keys@unknown
+ \let\sseq@savedoptioncode\sseq@savedoptioncode@store
+ },%
+ change sseqs/.code={%
+ \ifsseq@ispageenv\else\sseq@error@nn{change-style-data}{sseq}{#1}\fi
+ \ifsseq@hasname\else\sseq@error@nn{change-style-standalone}{sseq}{#1}\fi
+ \let\sseq@savedoptioncode@store\sseq@savedoptioncode
+ \edef\sseq@savedoptioncode{\the\sseq@sseqstyle@page}%
+ \sseq@addstylecodetooptions{\sseq@temppath}{#1}%
+ \sseq@sseqstyle@page\@xp{\sseq@savedoptioncode}%
+ \let\sseq@savedoptioncode\sseq@savedoptioncode@store
+ }
+}
+
+
+%\sseq@newstyles{/sseqpages/}{sseq}% DON'T make this /global/default! Bad things will happen.
+\sseq@newstyles{/sseqpages/label,/sseqpages}{edge, label, edge label, differential label, struct line label}
+\sseq@newstyles{/sseqpages/class,/sseqpages}{class, permanent cycle, transient cycle, this page cycle}
+\sseq@newstyles{/sseqpages/differential,/sseqpages}{differential}
+\sseq@newstyles{/sseqpages/struct line,/sseqpages}{struct line, this page struct line}
+\sseq@newstyles{/sseqpages/class/label}{class label, inner class label, outer class label}
+\sseq@newstyles{/sseqpages/tikz primitives}{tikz primitive}
+\sseq@newstyles{/sseqpages/fit}{circle class}
+
+
+\sseq@set@newstyle{sseq/.style={sseqs={#1}},change sseq/.style={change sseqs={#1}},
+ classes/.style={classs={#1}},change classes/.style={change classs={#1}},
+ circle classes/.style={circle classs={#1}},change circle classes/.style={change circle classs={#1}},
+}% "class" has a nonstandard plural
+\sseq@set@newstyle{
+ cycles/.code={\pgfkeysalso{classes={#1}}},
+ permanent classes/.code={\pgfkeysalso{permanent cycles={#1}}},
+ transient classes/.code={\pgfkeysalso{transient cycles={#1}}},
+ this page classes/.code={\pgfkeysalso{this page cycles={#1}}},
+ cycle style/.code={\pgfkeysalso{class style={#1}}},
+ permanent class style/.code={\pgfkeysalso{permanent cycle style={#1}}},
+ transient class style/.code={\pgfkeysalso{transient cycle style={#1}}},
+ this page class style/.code={\pgfkeysalso{this page cycle style={#1}}},
+ class label position/.code={\pgfkeysalso{class label positions={#1}}}
+}%
+
+\def\sseq@newplotstyle#1{
+ \sseq@setmacronospaces\sseq@tempcmd{sseq@#1style}
+ \sseq@setmacronospaces\sseq@tempcmdb{sseq@#1style@default}
+ \sseq@eval{\@nx\sseq@addtostorelist\@xp\@nx\sseq@tempcmd{\@xp\@nx\sseq@tempcmdb}}
+ \@xp\def\sseq@tempcmdb{}
+ \pgfqkeys{/sseqpages/global}{%
+ #1 style/.ecode={
+ \unexpanded{\let\sseq@savedoptioncode@store\sseq@savedoptioncode}
+ \let\@nx\sseq@savedoptioncode\@xp\@nx\sseq@tempcmd
+ \unexpanded{\sseq@addstylecodetooptions{/tikz}}{##1}
+ \let\@xp\@nx\sseq@tempcmd\@nx\sseq@savedoptioncode
+ \unexpanded{\let\sseq@savedoptioncode\sseq@savedoptioncode@store}
+ }
+ }
+ % Only difference here is \sseq@tempcmdb -- which puts it in the default code -- instead of \sseq@tempcmd
+ \pgfqkeys{/sseqpages/global/default}{%
+ #1 style/.ecode={
+ \unexpanded{\let\sseq@savedoptioncode@store\sseq@savedoptioncode}
+ \let\@nx\sseq@savedoptioncode\@xp\@nx\sseq@tempcmdb
+ \unexpanded{\sseq@addstylecodetooptions{/tikz}}{##1}
+ \let\@xp\@nx\sseq@tempcmdb\@nx\sseq@savedoptioncode
+ \unexpanded{\let\sseq@savedoptioncode\sseq@savedoptioncode@store}
+ }
+ }
+}
+
+
+\def\sseq@newplotstyles#1{\def\sseq@temppath{#1}\sseq@newplotstyles@#1,\sseq@nil}
+\def\sseq@newplotstyles@#1,{\sseq@newplotstyle{\sseq@trimleadingspaces#1}\@ifnextchar\sseq@nil{\@gobble}{\sseq@newplotstyles@}}
+
+\sseq@newplotstyles{x tick, y tick}
+
+
+%%% Global keys handlers and infrastructure
+
+\def\sseq@keys@lastpart{%
+ \edef\pgfkeyscurrentkey{\pgfkeyscurrentpath}%
+ \pgfkeys@split@path
+ \edef\sseq@temp{\pgfkeyscurrentname}%
+ \edef\sseq@temp@ii{\pgfkeyscurrentkey}%
+}
+
+\pgfqkeys{/handlers}{
+ .sseq store in/.code 2 args={%
+ \sseq@addtostorelist#1{#2}%
+ \sseq@keys@lastpart
+ \pgfkeys{%
+ \sseq@temp@ii/.store in=#1,%
+ /sseqpages/global/default/\sseq@temp/.store in/.expand once=\csname \sseq@macroname#1@default\endcsname
+ }%
+ },
+ .sseq append to style/.code 2 args={%
+ \sseq@addkeytostorelist{#1}{\pgfkeysalso{#2}}%
+ \sseq@keys@lastpart
+ \pgfkeys{%
+ \sseq@temp@ii/.style={#1/.append style={##1}},%
+ /sseqpages/global/default/\sseq@temp/.ecode={%
+ \@nx\apptocmd\@xp\@nx\csname pgfk@#1/.@cmd@default\endcsname{\@nx\pgfkeysalso{##1}}{}{\@nx\sseq@error{this-shouldnt-happen}}%
+ \global\let\@xp\@nx\csname pgfk@#1/.@cmd@default\endcsname\@xp\@nx\csname pgfk@#1/.@cmd@default\endcsname
+ }%
+ }%
+ },
+ .sseq is if/.code={%
+ \sseq@addiftostorelist@truedefault{#1}%
+ \sseq@keys@lastpart
+ \pgfkeys{%
+ \sseq@temp@ii/.is if=sseq@#1,%
+ /sseqpages/global/default/\sseq@temp/.code={\@xp\edef\csname sseq@#1@default\endcsname{\global\@xp\@nx\csname sseq@#1##1\endcsname}},%
+ /sseqpages/global/default/\sseq@temp/.default=true,%
+ }%
+ },
+ .sseq is if false/.code={%
+ \sseq@keys@lastpart
+ \pgfkeys{%
+ /sseqpages/global/\sseq@temp/.code/.expanded={\@xp\@nx\csname sseq@#1false\endcsname},
+ /sseqpages/global/\sseq@temp/.value forbidden,
+ % value forbidden and ecode don't work correctly together so we have to use .code/.expanded .
+ % I made a thread here: https://sourceforge.net/p/pgf/discussion/477362/thread/3e75d813/
+ /sseqpages/global/default/\sseq@temp/.code/.expanded={\def\@xp\@nx\csname sseq@#1@default\endcsname{\global\@xp\@nx\csname sseq@#1false\endcsname}},
+ /sseqpages/global/default/\sseq@temp/.value forbidden,
+ }%
+ },
+ .sseq default code/.code={%
+ \sseq@keys@lastpart
+ \pgfkeys{/sseqpages/global/default/\sseq@temp/.code={#1}}%
+ },
+ .sseq default code 2 args/.code={%
+ \sseq@keys@lastpart
+ \pgfkeys{/sseqpages/global/default/\sseq@temp/.code 2 args={#1}}%
+ },
+ .sseq default error/.code={%
+ \sseq@keys@lastpart
+ \pgfkeys{/sseqpages/global/default/\sseq@temp/.ecode={\@nx\sseq@error@n{option-no-default-allowed}{\sseq@temp}}}%
+ },
+ .sseq x y alias/.code={%
+ \sseq@keys@lastpart
+ \ifx\pgfkeysnovalue#1%
+ \edef\sseq@tempb##1{##1 \sseq@temp}%
+ \else
+ \def\sseq@tempb##1{#1}%
+ \sseq@usedparam\sseq@tempb
+ \fi
+ \pgfkeys{%
+ /sseqpages/global/\sseq@temp/.ecode={\@nx\pgfkeysalso{\sseq@tempb{x}={##1},\sseq@tempb{y}={##1}}},%
+ /sseqpages/global/default/\sseq@temp/.ecode={\@nx\pgfkeysalso{\sseq@tempb{x}={##1},\sseq@tempb{y}={##1}}}%
+ }%
+ }
+}
+
+\bgroup\lccode`*=`#\lowercase{\egroup
+ \def\sseq@usedparam#1{
+ \@xp\sseq@usedparam@\@xp#1\meaning#1*\@nil
+ }
+ \def\sseq@usedparam@#1#2->#3*#4\@nil{
+ \sseq@ifempty{#4}{
+ \@xp\def\@xp#1\@xp##\@xp1\@xp{\@xp##\@xp1\@xp\space#1{}}
+ }{}
+ }
+}
+
+\def\sseq@add@tikzkey@to@options@forstylehander#1{\sseq@e@addto@options{\@nx\sseq@options@secondpass{#1}}}
+\pgfqkeys{/handlers}{ % defines sseq style, etc
+ sseq @@ make style handler/.style 2 args={%
+ .sseq #1/.code={%
+ \sseq@keys@lastpart
+ \let\sseq@savedoptioncode@store\sseq@savedoptioncode
+ \def\sseq@keys@unknown@error{}%
+ \def\sseq@savedoptioncode{}%
+ \let\sseq@add@tikzkey@to@options\sseq@add@tikzkey@to@options@forstylehander
+ \sseq@addstylecodetooptions{/sseqpages/scope}{##1}%
+ \sseq@eval{\@nx\pgfkeys{/sseqpages/scope/\sseq@temp/.#2={\unexpanded\@xp{\sseq@savedoptioncode}}}}%
+ \def\sseq@savedoptioncode{}%
+ \sseq@addstylecodetooptions{/sseqpages/class}{##1}%
+ \sseq@eval{\@nx\pgfkeys{/sseqpages/class/\sseq@temp/.#2={\unexpanded\@xp{\sseq@savedoptioncode}}}}%
+ \def\sseq@savedoptioncode{}%
+ \sseq@addstylecodetooptions{/sseqpages/differential}{##1}%
+ \sseq@eval{\@nx\pgfkeys{/sseqpages/differential/\sseq@temp/.#2={\unexpanded\@xp{\sseq@savedoptioncode}}}}%
+ \def\sseq@savedoptioncode{}%
+ \sseq@addstylecodetooptions{/sseqpages/struct line}{##1}%
+ \sseq@eval{\@nx\pgfkeys{/sseqpages/struct line/\sseq@temp/.#2={\unexpanded\@xp{\sseq@savedoptioncode}}}}%
+ \def\sseq@savedoptioncode{}%
+ \sseq@addstylecodetooptions{/sseqpages/circle classes}{##1}
+ \sseq@eval{\@nx\pgfkeys{/sseqpages/circle classes/\sseq@temp/.#2={\unexpanded\@xp{\sseq@savedoptioncode}}}}%
+ \def\sseq@savedoptioncode{}%
+ \sseq@addstylecodetooptions{/sseqpages/tikz primitives}{##1}%
+ \sseq@eval{\@nx\pgfkeys{/sseqpages/tikz primitives/\sseq@temp/.#2={\unexpanded\@xp{\sseq@savedoptioncode}}}}%
+ \let\sseq@savedoptioncode\sseq@savedoptioncode@store
+ \let\sseq@addstylecodetooptions@unknown\sseq@keys@unknown
+ \let\sseq@keys@unknown@error\sseq@keys@unknown@error@normal
+ \let\sseq@add@tikzkey@to@options\sseq@e@addto@options
+ }%
+ },%
+ sseq @@ make code handler/.style={%
+ .sseq #1/.code={%
+ \sseq@keys@lastpart
+ \pgfkeys{
+ /sseqpages/class/\sseq@temp/.#1={##1},%
+ /sseqpages/differential/\sseq@temp/.#1={##1},%
+ /sseqpages/struct line/\sseq@temp/.#1={##1}%
+ }%
+ }%
+ },
+%
+ sseq @@ make style handler={style}{code},
+ sseq @@ make style handler={prefix style}{prefix code},
+ sseq @@ make style handler={append style}{append code},
+ sseq @@ make code handler=code,
+ sseq @@ make code handler=prefix code,
+ sseq @@ make code handler=append code,
+%
+ .global sseq style/.code={\pgfkeys{\pgfkeyscurrentpath/.code=\pgfkeysalso{#1}}},
+ .global sseq prefix style/.code={\pgfkeys{\pgfkeyscurrentpath/.add code={\pgfkeysalso{#1}}{}}},
+ .global sseq append style/.code={\pgfkeys{\pgfkeyscurrentpath/.add code={}{\pgfkeysalso{#1}}}},
+%
+%
+ .sseq grading/.code 2 args={%
+ \sseq@keys@lastpart
+ \pgfkeys{%
+ /sseqpages/global/\sseq@temp/.estyle={\unexpanded{degree={#1}{#2}}},%I'm not really sure why these need to be estyle and \unexpanded but it does...
+ /sseqpages/global/default/\sseq@temp/.estyle={\unexpanded{degree={#1}{#2}}},%
+ /sseqpages/\sseq@temp/.sseq @ global only
+ }%
+ },
+ Adams grading/.sseq grading={-1}{#1},
+ homological Serre grading/.sseq grading={-#1}{#1-1},
+ cohomological Serre grading/.sseq grading={#1}{1-#1},
+}
+
+%%% Define global keys setter
+\gdef\sseq@globalkeys#1{%
+ \let\sseq@storetilde~%
+ \def~{}%
+ \pgfqkeys{/sseqpages/global}{#1}%
+ \sseq@globalkeys@#1,\sseq@nil
+ \let~\sseq@storetilde
+}
+
+\def\sseq@globalkeys@#1,{%
+ \sseq@tempiftrue
+ \sseq@keys@removehandler{#1}%
+ \ifsseq@tempif
+ \pgfkeys{/sseqpages/\sseq@temp/.sseq @ global only}%
+ \pgfkeysifdefined{/sseqpages/global/default/\sseq@temp/.@cmd}{}{%
+ \pgfkeys{/sseqpages/global/default/\sseq@temp/.ecode={\@nx\pgfkeysalso{sseqs={\sseq@temp}}}}%
+ }%
+ \fi
+ \sseq@globalkeys@next
+}
+
+\def\sseq@globalkeys@eatentry#1,{%
+ \sseq@globalkeys@next
+}
+
+\def\sseq@globalkeys@next{%
+ \@ifnextchar\sseq@nil{\@gobble}{%
+ \@ifnextchar~{\sseq@globalkeys@eatentry}{%
+ \@ifnextchar,{\sseq@globalkeys@eatentry}{%
+ \sseq@globalkeys@
+ }%
+ }%
+ }%
+}
+
+\def\sseq@keys@ignorehandlers{%
+ \\{value forbidden}\\{value required}\\{default}%\\{sseq store in}\\{sseq is if}%
+ \\{sseq default code}\\{sseq default code 2 args}%
+}
+\def\sseq@keys@removehandler#1{\sseq@keys@removehandler@#1=\sseq@nil}
+\def\sseq@keys@removehandler@#1/.#2=#3\sseq@nil{%
+ \def\sseq@temp{#2}%
+ \def\\##1{\def\sseq@tempii{##1}\ifx\sseq@tempii\sseq@temp \sseq@tempiffalse\let\\\@gobble\fi}%
+ \sseq@keys@ignorehandlers
+ \def\sseq@temp{#1}%
+}
+
+
+%%% Define global keys
+\def\sseq@currentoptionpath{default}
+\pgfkeys{
+ % \sseq@currentoptionpath is set to \sseq@thename in \sseqdata, then "temp" in \sseqpage
+ /sseqpages/global/.unknown/.code={%
+ \let\sseq@tempa\pgfkeyscurrentname
+ \let\sseq@tempb\pgfkeyscurrentvalue
+ \sseq@eval{\@nx\pgfqkeys{/sseqpages/global}{/sseqpages/userstyles/\sseq@tempa/.try={\unexpanded\@xp{\sseq@tempb}}}}
+ \ifpgfkeyssuccess\else
+ \pgfkeysifdefined{/tikz/\pgfkeyscurrentname/.@cmd}{\@firstofone}{\pgfkeysifdefined{/tikz/\pgfkeyscurrentname}{\@firstofone}{%
+ \sseq@error{unknown-global}\@gobble
+ }}{%
+ \pgfkeysalso{{\sseq@currentoptionpath} options/.append code/.expand twice={\@xp\@xp\@xp\tikzset\@xp\@xp\@xp{\@xp\sseq@tempa\@xp=\@xp{\sseq@tempb}}}}%
+ \sseq@eval{%
+ \global\let\@xp\@nx\csname pgfk@/sseqpages/global/{\sseq@currentoptionpath} options/.@cmd\endcsname
+ \@xp\@nx\csname pgfk@/sseqpages/global/{\sseq@currentoptionpath} options/.@cmd\endcsname
+ }%
+ }%
+ \fi
+ },
+ /sseqpages/global/default/.unknown/.code={%
+ \sseq@passoptionto{/sseqpages/global}%
+ },
+ /sseqpages/global/{default} options/.code={},
+ /sseqpages/global/name only/.unknown/.code={},
+ /sseqpages/global/sseqstyle/.unknown/.code={}
+}
+
+\pgfqkeys{/sseqpages/global/name only}{
+ name/.code={\def\sseq@thename{#1}\sseq@hasnametrue},
+ name/.value required,
+ keep changes/.is if=sseq@keepchanges,
+ update existing/.code={\ifsseq@ispageenv\sseq@error{page-update-existing}\fi\sseq@updateexistingtrue},
+ update existing/.sseq default code={\sseq@updateexistingtrue}
+}
+
+\sseq@addtostorelist\sseq@grid{\relax}
+\sseq@addiftostorelist{hasdegree}
+\let\sseq@maybemathswitch\relax
+\sseq@globalkeys{%
+ name/.code={},
+ name/.sseq default error,
+ ~page/.code={
+ \ifsseq@hasname
+ \sseq@ifintexpr{#1}{
+ \def\sseq@thepage{#1}\sseq@thepagecount=#1\relax\let\page\sseq@thepage
+ }{
+ \sseq@error{invalid-page}{#1}
+ }
+ \else
+ \sseq@error{page-no-name}
+ \fi
+ },
+ ~page/.sseq default error,% implement page default?
+ degree/.code 2 args={\def\sseq@targetx##1{#1}\def\sseq@targety##1{#2}},
+ degree/.sseq default code 2 args={\def\sseq@targetx@default##1{#1}\def\sseq@targety@default##1{#2}},
+ strict degree/.sseq is if=strictdegree,
+ lax degree/.sseq is if false=strictdegree,
+ update existing/.code={}, % processed with "name" key and "keep changes" key in /sseqpages/global/name only
+ keep changes/.code={%
+ \ifsseq@hasname\else\sseq@error{keep-changes-no-name}\fi
+ \ifsseq@ispageenv\else\sseq@error{keep-changes-sseqdata}\fi
+ },
+ grid/.code={\ifcsname sseq@grid@#1\endcsname\@xp\let\@xp\sseq@grid\csname sseq@grid@#1\endcsname\else\sseq@error@n{unknown-grid}{#1}\fi},
+ grid/.sseq default code={\ifcsname sseq@grid@#1\endcsname\@xp\let\@xp\sseq@grid@default\csname sseq@grid@#1\endcsname\else\sseq@error@n{unknown-grid}{#1}\fi},
+ math nodes/.sseq is if=mathnodes, % TODO: make this locally toggleable
+ custom clip/.sseq store in=\sseq@customclip{},
+ clip/.sseq is if=clip,
+ draw differentials/.sseq is if=drawdifferentials,
+ no differentials/.sseq is if false={drawdifferentials},
+ draw struct lines/.sseq is if=drawstructlines,
+ no struct lines/.sseq is if false={drawstructlines},
+ draw orphan edges/.sseq is if=draworphanedges,
+ no orphan edges/.sseq is if false={draworphanedges},
+ class pattern/.sseq store in=\sseq@classpattern{standard},
+ class pattern/.append code={\ifcsname sseq@\sseq@classpattern xoffset1/1\endcsname\else\sseq@error{unknown-class-pattern}\fi},
+ class placement transform/.code={%
+ \bgroup
+ \let\tikz@transform\pgfutil@empty
+ \pgfqkeys{/sseqpages/class placement}{#1}%
+ \global\let\sseq@classplacementtransform\tikz@transform
+ \egroup
+ },
+ class placement transform/.sseq default code={%
+ \bgroup
+ \let\tikz@transform\pgfutil@empty
+ \pgfqkeys{/sseqpages/class placement}{#1}%
+ \global\let\sseq@classplacementtransform@default\tikz@transform
+ \egroup
+ },
+ class placement transform/.value required,
+ add class placement transform/.code={%
+ \bgroup
+ \let\tikz@transform\pgfutil@empty
+ \pgfqkeys{/sseqpages/class placement}{#1}%
+ \sseq@x@addto@macro\sseq@classplacementtransform{\unexpanded\@xp\tikz@transform}
+ \egroup
+ },
+ add class placement transform/.sseq default code={%
+ \bgroup
+ \let\tikz@transform\pgfutil@empty
+ \pgfqkeys{/sseqpages/class placement}{#1}%
+ \sseq@x@addto@macro\sseq@classplacementtransform@default{\unexpanded\@xp\tikz@transform}
+ \egroup
+ },
+ add class placement transform/.value required,
+}
+
+\sseq@mathnodestrue
+
+\sseq@addtostorelist\sseq@targetx{}\sseq@addtostorelist\sseq@targety{}
+\sseq@addtostorelist\sseq@xtickstep{1}\sseq@addtostorelist\sseq@ytickstep{1}
+\sseq@addtostorelist\sseq@classplacementtransform{}
+
+
+\sseq@addiftostorelist@truedefault{borderxaxis}\sseq@addiftostorelist@truedefault{borderyaxis}
+\sseq@addtostorelist\sseq@xaxisorigin{0}\sseq@addtostorelist\sseq@yaxisorigin{0}
+
+%%% Range keys and commands
+\sseq@globalkeys{%
+ x range/.code 2 args={\sseq@xrange{#1}{#2}},
+ x range/.sseq default code 2 args={\sseq@xrange@default{#1}{#2}},
+ y range/.code 2 args={\sseq@yrange{#1}{#2}},
+ y range/.sseq default code 2 args={\sseq@yrange@default{#1}{#2}},
+ xrange/.forward to=/sseqpages/global/x range,
+ yrange/.forward to=/sseqpages/global/y range
+}
+
+% These are set up so that if the user specifies no \xrange, the minimum position of any node can be calculated on the fly.
+\@xp\sseq@addtostorelist\@xp\sseq@xmin\@xp{\sseq@infinity}
+\@xp\sseq@addtostorelist\@xp\sseq@ymin\@xp{\sseq@infinity}
+\@xp\sseq@addtostorelist\@xp\sseq@xmax\@xp{\@xp-\sseq@infinity}
+\@xp\sseq@addtostorelist\@xp\sseq@ymax\@xp{\@xp-\sseq@infinity}
+\sseq@addtostorelist\xmin{\protect\sseq@xmin}
+\sseq@addtostorelist\ymin{\protect\sseq@ymin}
+\sseq@addtostorelist\xmax{\protect\sseq@xmax}
+\sseq@addtostorelist\ymax{\protect\sseq@ymax}
+% These are used to decide whether to add a certain node to savedpaths.
+% In general the check is whether xmin<=xcoord<=xmax, but since Latex has no <=, set xminmm=xmin-1, xmaxpp=xmax+1.
+% If the user doesn't specify a range, all nodes should be rendered
+% To ensure that xminmm<xccord<xminpp in that case, set the default to xminmm=-\infty, xmaxpp=+\infty.
+\@xp\sseq@addtostorelist\@xp\sseq@xminmm\@xp{\@xp-\sseq@infinity}
+\@xp\sseq@addtostorelist\@xp\sseq@yminmm\@xp{\@xp-\sseq@infinity}
+\@xp\sseq@addtostorelist\@xp\sseq@xmaxpp\@xp{\sseq@infinity}
+\@xp\sseq@addtostorelist\@xp\sseq@ymaxpp\@xp{\sseq@infinity}
+
+\def\sseq@xrange#1#2{%
+ \global\let\sseq@xminmax\@gobbletwo % Don't need to calculate range of nodes if user specifies it
+ \gdef\sseq@xmin{#1}%
+ \gdef\sseq@xmax{#2}%
+ \let\xmin\sseq@xmin
+ \let\xmax\sseq@xmax
+ % Need to know decremented \xmin and incremented \xmax to decide which nodes to print
+ \sseq@tempcount=#1 \advance\sseq@tempcount-1\xdef\sseq@xminmm{\the\sseq@tempcount}%
+ \sseq@tempcount=#2 \advance\sseq@tempcount1\xdef\sseq@xmaxpp{\the\sseq@tempcount}%
+}
+\def\sseq@yrange#1#2{%
+ \global\let\sseq@yminmax\@gobbletwo %
+ \gdef\sseq@ymin{#1}%
+ \gdef\sseq@ymax{#2}%
+ \let\ymin\sseq@ymin
+ \let\ymax\sseq@ymax
+ \sseq@tempcount=#1 \advance\sseq@tempcount-1\xdef\sseq@yminmm{\the\sseq@tempcount}%
+ \sseq@tempcount=#2 \advance\sseq@tempcount1\xdef\sseq@ymaxpp{\the\sseq@tempcount}%
+}
+
+\def\sseq@xrange@default#1#2{%
+ \global\let\sseq@xminmax\@gobbletwo % Don't need to calculate range of nodes if user specifies it
+ \gdef\sseq@xmin@default{#1}%
+ \gdef\sseq@xmax@default{#2}%
+ % Need to know decremented \xmin and incremented \xmax to decide which nodes to print
+ \sseq@tempcount=#1 \advance\sseq@tempcount-1\xdef\sseq@xminmm@default{\the\sseq@tempcount}%
+ \sseq@tempcount=#2 \advance\sseq@tempcount1\xdef\sseq@xmaxpp@default{\the\sseq@tempcount}%
+}
+\def\sseq@yrange@default#1#2{%
+ \global\let\sseq@yminmax\@gobbletwo %
+ \gdef\sseq@ymin@default{#1}%
+ \gdef\sseq@ymax@default{#2}%
+ \sseq@tempcount=#1 \advance\sseq@tempcount-1\xdef\sseq@yminmm@default{\the\sseq@tempcount}%
+ \sseq@tempcount=#2 \advance\sseq@tempcount1\xdef\sseq@ymaxpp@default{\the\sseq@tempcount}%
+}
+
+% If #1 is less than \xmin or greater than \xmax, update \xmin or \xmax appropriately
+% Gets set to \@gobble if user specifies range
+\def\sseq@xminmax@active#1#2{%
+ \ifnum#1<\sseq@xmin\relax
+ \ifx\sseq@yminmax\@gobbletwo
+ \ifnum#2>\sseq@yminmm\relax
+ \ifnum#2<\sseq@ymaxpp\relax
+ \xdef\sseq@xmin{#1}%
+ \fi
+ \fi
+ \else
+ \xdef\sseq@xmin{#1}%
+ \fi
+ \fi
+ \ifnum#1>\sseq@xmax\relax
+ \ifx\sseq@yminmax\@gobbletwo
+ \ifnum#2>\sseq@yminmm\relax
+ \ifnum#2<\sseq@ymaxpp\relax
+ \xdef\sseq@xmax{#1}%
+ \fi
+ \fi
+ \else
+ \xdef\sseq@xmax{#1}%
+ \fi
+ \fi
+}
+
+\def\sseq@yminmax@active#1#2{%
+ \ifnum#2<\sseq@ymin\relax
+ \ifx\sseq@xminmax\@gobbletwo
+ \ifnum#1>\sseq@xminmm\relax
+ \ifnum#1<\sseq@xmaxpp\relax
+ \xdef\sseq@ymin{#2}%
+ \fi
+ \fi
+ \else
+ \xdef\sseq@ymin{#2}%
+ \fi
+ \fi
+ \ifnum#2>\sseq@ymax\relax
+ \ifx\sseq@xminmax\@gobbletwo
+ \ifnum#1>\sseq@xminmm\relax
+ \ifnum#1<\sseq@xmaxpp\relax
+ \xdef\sseq@ymax{#2}%
+ \fi
+ \fi
+ \else
+ \xdef\sseq@ymax{#2}%
+ \fi
+ \fi
+}
+
+%%% Axes and Layout options
+\sseq@addtostorelist{\sseq@xtickfn}{} % These should initially be the identity macro, but addtostorelist doesn't accept functions as default
+\sseq@addtostorelist{\sseq@ytickfn}{} % so the default is instated in begin{sseqdata} / begin{sseqpicture}.
+\sseq@globalkeys{%
+ title/.sseq store in=\sseq@title{},
+ title style/.sseq append to style={/sseqpages/global/every title}{at={(0.5*\xmin+0.5*\xmax,\ymax)}},
+ draw title/.sseq is if=drawtitle,
+ no title/.code=\sseq@drawtitlefalse,
+%
+ x label/.sseq store in=\sseq@xaxislabel{},
+ y label/.sseq store in=\sseq@yaxislabel{},
+ x label style/.sseq append to style={/sseqpages/global/every x axis label}{at={(0.5*\xmin+0.5*\xmax,\ymin)}},
+ y label style/.sseq append to style={/sseqpages/global/every y axis label}{at={(\xmin ,0.5*\ymax+0.5*\ymin)}},
+ label style/.sseq x y alias,
+ draw x label/.sseq is if=drawxaxislabel,
+ draw y label/.sseq is if=drawyaxislabel,
+ no x label/.sseq is if false={drawxaxislabel},
+ no y label/.sseq is if false={drawyaxislabel},
+ no labels/.sseq x y alias=no #1 label,
+ draw labels/.sseq x y alias=draw #1 label,
+%
+ no x axis/.sseq is if false={drawxaxis},
+ no y axis/.sseq is if false={drawyaxis},
+ no axes/.value forbidden,
+ no axes/.sseq x y alias=no #1 axis,
+ draw x axis/.sseq is if=drawxaxis,
+ draw y axis/.sseq is if=drawyaxis,
+ draw axes/.sseq x y alias=draw #1 axis,
+ rotate labels/.sseq is if=rotatelabels,
+%
+ draw x ticks/.sseq is if=drawxaxisticks,
+ no x ticks/.sseq is if false=drawxaxisticks,
+ draw y ticks/.sseq is if=drawyaxisticks,
+ no y ticks/.sseq is if false=drawyaxisticks,
+ no ticks/.sseq x y alias=no #1 ticks,
+ no ticks/.value forbidden,
+ draw ticks/.sseq x y alias=draw #1 ticks,
+ draw ticks/.default=true,
+ tick step/.sseq x y alias,
+ tick step/.value required,
+ x tick step/.sseq store in=\sseq@xtickstep{1},
+ y tick step/.sseq store in=\sseq@ytickstep{1},
+ x tick handler/.code={\def\sseq@xtickfn##1{#1}},
+ x tick handler/.sseq default code={\def\sseq@xtickfn@default##1{#1}},
+ y tick handler/.code={\def\sseq@ytickfn##1{#1}},
+ y tick handler/.sseq default code={\def\sseq@ytickfn@default##1{#1}},
+ class label handler/.code = {\long\def\sseq@classlabeltextfn##1{#1}}, % \long so that \ifx\classlabeltextfn\@gobble compares true if this is empty (\@gobble is long...)
+ class label handler/.sseq default code={\long\def\sseq@classlabeltextfn@default##1{#1}},
+ x tick style/.sseq store in=\sseq@xtickstyle{},
+ y tick style/.sseq store in=\sseq@ytickstyle{},
+ tick style/.sseq x y alias,
+%
+ x axis style/.is choice,
+ y axis style/.is choice,
+ axes style/.sseq x y alias=axis style,
+ ~x axis style/border/.code={\sseq@drawxaxistrue\sseq@borderxaxistrue},
+ ~y axis style/border/.code={\sseq@drawyaxistrue\sseq@borderyaxistrue},
+ ~x axis style/center/.code={
+ \sseq@drawxaxistrue\sseq@borderxaxisfalse
+ \ifx\sseq@xaxisgap\sseq@xaxisgap@default
+ \def\sseq@xaxisgap{0cm}
+ \fi
+ },
+ ~y axis style/center/.code={\sseq@drawyaxistrue\sseq@borderyaxisfalse\ifx\sseq@yaxisgap\sseq@yaxisgap@default\def\sseq@yaxisgap{0cm}\fi},
+ ~x axis style/none/.code={\sseq@drawxaxisfalse},
+ ~y axis style/none/.code={\sseq@drawyaxisfalse},
+ x axis origin/.sseq store in=\sseq@xaxisorigin{0},
+ y axis origin/.sseq store in=\sseq@yaxisorigin{0},
+ axes origin/.sseq x y alias=axis origin,
+}
+\pgfqkeys{/sseqpages}{%
+ class label handler/.code = {\long\def\sseq@classlabeltextfn##1{#1}}
+}
+
+\sseq@globalkeys{
+ axes gap/.sseq x y alias=axis gap,
+ axes gap/.value required,
+ x axis gap/.sseq store in=\sseq@xaxisgap{0.5cm},
+ y axis gap/.sseq store in=\sseq@yaxisgap{0.5cm},
+ tick gap/.sseq x y alias,
+ tick gap/.value required,
+ x tick gap/.sseq store in=\sseq@xlabelgap{0.5cm},
+ y tick gap/.sseq store in=\sseq@ylabelgap{0.5cm},
+ x axis extend start/.sseq store in=\sseq@xaxis@start@extend{0.9cm},
+ y axis extend start/.sseq store in=\sseq@yaxis@start@extend{0.9cm},
+ axes extend start/.sseq x y alias=axis extend start,
+ x axis extend end/.sseq store in=\sseq@xaxis@end@extend{0.5cm},
+ y axis extend end/.sseq store in=\sseq@yaxis@end@extend{0.5cm},
+ axes extend end/.sseq x y alias=axis extend end,
+ x axis clip padding/.sseq store in=\sseq@xclip@axisgap{0.1cm},
+ y axis clip padding/.sseq store in=\sseq@yclip@axisgap{0.1cm},
+ axes clip padding/.sseq x y alias=axis clip padding,
+ right clip padding/.sseq store in=\sseq@clip@padding@right{0.1cm},
+ left clip padding/.sseq store in=\sseq@clip@padding@left{0.4cm},
+ top clip padding/.sseq store in=\sseq@clip@padding@top{0.1cm},
+ bottom clip padding/.sseq store in=\sseq@clip@padding@bottom{0.4cm}
+}
+
+%%%
+%%% Coordinate transformations
+%%%
+
+%%% Global Coordinate Transformations
+\sseq@globaldetonetrue
+\sseq@addtostorelist\sseq@globaldetonetransform{}
+\sseq@addtostorelist\sseq@globalrotatetransform{}
+\sseq@addtostorelist\sseq@globalscaletransform{}
+
+\def\sseq@globaldetoneoption#1#2{%
+ \ifsseq@globaldetone\else
+ \sseq@error@n{det-one-after-scale}{#2}
+ \fi
+ \@xp\gdef\@xp\sseq@globaldetonetransform\@xp{\sseq@globaldetonetransform #1}%
+ #1
+}
+\def\sseq@globalscaleoption#1{%
+ \sseq@globaldetonefalse
+ \@xp\gdef\@xp\sseq@globalscaletransform\@xp{\sseq@globalscaletransform#1}#1%
+}
+\pgfqkeys{/sseqpages/global}{%
+ x/.sseq @ illegal,
+ y/.sseq @ illegal,
+ z/.sseq @ illegal,
+ xshift/.sseq @ illegal as global,
+ yshift/.sseq @ illegal as global,
+ shift/.sseq @ illegal as global,
+ scale around/.sseq @ illegal as global,
+ rotate around/.sseq @ illegal as global,
+ rotate/.code={%
+ \@xp\gdef\@xp\sseq@globalrotatetransform\@xp{\sseq@globalrotatetransform\pgftransformrotate{#1}}%
+ \sseq@globaldetoneoption{\pgftransformrotate{#1}}{rotate}%
+ },
+ rotate/.value required,
+ xslant/.code={\sseq@globaldetoneoption{\pgftransformxslant{#1}}{xslant}},
+ xslant/.value required,
+ yslant/.code={\sseq@globaldetoneoption{\pgftransformyslant{#1}}{yslant}},
+ yslant/.value required,
+ xmirror/.code={\sseq@globaldetoneoption{\pgftransformxscale{-1}}{xmirror}},
+ xmirror/.value forbidden,
+ ymirror/.code={\sseq@globaldetoneoption{\pgftransformyscale{-1}}{ymirror}},
+ ymirror/.value forbidden,
+ mirror/.forward to=/sseqpages/global/xmirror,
+ mirror/.forward to=/sseqpages/global/ymirror,
+ xscale/.code={%
+ \pgfmathparse{int(#1-1)}%
+ \ifnum\pgfmathresult<\z@%
+ \sseq@error@nn{negative-scale}{x}{#1}%
+ \fi
+ \sseq@globalscaleoption{\pgftransformxscale{#1}}%
+ },
+ xscale/.value required,
+ yscale/.code={%
+ \pgfmathparse{int(#1-1)}%
+ \ifnum\pgfmathresult<\z@
+ \sseq@error@nn{negative-scale}{y}{#1}%
+ \fi
+ \sseq@globalscaleoption{\pgftransformyscale{#1}}%
+ },
+ yscale/.value required,
+ scale/.code={%
+ \pgfmathparse{int(#1-1)}%
+ \ifnum\pgfmathresult<\z@
+ \sseq@error@nn{negative-scale}{}{#1}%
+ \fi
+ \sseq@globalscaleoption{\pgftransformscale{#1}}%
+ },
+ scale/.value required
+}
+
+%%% Local Coordinate transformations
+
+\pgfqkeys{/sseqpages/class placement}{
+ x shift/.code={\sseq@error@nn{class-placement-shift}{x shift}{#1}},
+ y shift/.code={\sseq@error@nn{class-placement-shift}{y shift}{#1}},
+ shift/.code={\sseq@error@nn{class-placement-shift}{shift}{#1}}
+}
+
+%% setup for coordinate transformation keys
+\def\sseq@checktransform{\sseq@error@nn{illegal-transform}}
+\pgfqkeys{/sseqpages}{%
+ x/.code={\sseq@error@n{option-illegal}{#1}},
+ y/.code={\sseq@error@n{option-illegal}{#1}},
+ z/.code={\sseq@error@n{option-illegal}{#1}},
+ xshift/.sseq @ second pass code={\sseq@shifttransform{x}{#1}}, % I don't know why it has to be this way,
+ xshift/.sseq @ first pass append code={\sseq@firstpass@shifttransform{x}{#1}}, % but it definitely breaks if I change it...
+ xshift/.value required,
+ yshift/.sseq @ second pass code={\sseq@shifttransform{y}{#1}},
+ yshift/.sseq @ first pass append code={\sseq@firstpass@shifttransform{y}{#1}},
+ yshift/.value required,
+ shift/.sseq @ transform, shift/.value required,
+ shift only/.sseq @ transform,
+ xscale/.sseq @ transform, xscale/.value required,
+ yscale/.sseq @ transform, yscale/.value required,
+ scale/.sseq @ transform, scale/.value required,
+ scale around/.sseq @ transform, scale around/.value required,
+ xslant/.sseq @ transform, xslant/.value required,
+ yslant/.sseq @ transform, yslant/.value required,
+ rotate/.sseq @ transform, rotate/.value required,
+ rotate around/.sseq @ transform, rotate around/.value required,
+ cm/.sseq @ transform, cm/.value required,
+ reset cm/.sseq @ transform, reset cm/.value forbidden,
+ transform canvas/.sseq @ transform, transform canvas/.value required
+}
+
+% These two should be exactly the same
+\def\sseq@shift@firstpassprocess#1{\sseq@shift@firstpassprocess@#1\sseq@nil}
+\def\sseq@shift@firstpassprocess@#1#2\sseq@nil{\ifx#1\pgfpointxy\sseq@shift@firstpassprocess@@#2\else\sseq@standardparse\fi}
+\def\sseq@shift@firstpassprocess@@#1#2{
+ \sseq@tikz@firstpass@checkshifttransform{x}{#1}
+ \sseq@tikz@firstpass@checkshifttransform{y}{#2}
+}
+
+\def\sseq@shift@secondpassprocess#1{\sseq@shift@secondpassprocess@#1\sseq@nil}
+\def\sseq@shift@secondpassprocess@#1#2\sseq@nil{\ifx#1\pgfpointxy\sseq@shift@secondpassprocess@@#2\else\sseq@standardparse \pgftransformshift{#1#2}\fi}
+\def\sseq@shift@secondpassprocess@@#1#2{
+ \sseq@tikz@shifttransform{x}{#1}
+ \sseq@tikz@shifttransform{y}{#2}
+}
+
+\sseq@pgfqkeysdirlist{/sseqpages/scope,/sseqpages/tikz primitives}{
+ shift/.code={
+ \sseq@options@firstpass{\tikz@scan@one@point\sseq@shift@firstpassprocess#1\relax}
+ \sseq@options@secondpass{\tikz@scan@one@point\sseq@shift@secondpassprocess#1\relax} % TODO: maybe try to save the work of processing the point twice?
+ },
+ xshift/.sseq @ first pass code=\sseq@tikz@firstpass@checkshifttransform{x}{#1},
+ yshift/.sseq @ first pass code=\sseq@tikz@firstpass@checkshifttransform{y}{#1},
+ xshift/.sseq @ second pass append code=\sseq@tikz@shifttransform{x}{#1},
+ yshift/.sseq @ second pass append code=\sseq@tikz@shifttransform{y}{#1},
+ rotate around/.sseq @ second pass code={\sseq@standardparse\sseq@pgfkeysdocommand{rotate}{#1}},
+ rotate/.sseq @ stdparse do transform, rotate/.value required,
+ xslant/.sseq @ stdparse do transform, xslant/.value required,
+ yslant/.sseq @ stdparse do transform, yslant/.value required,
+ xmirror/.sseq @ stdparse do transform={-1}, xmirror/.value forbidden,
+ ymirror/.sseq @ stdparse do transform={-1}, ymirror/.value forbidden,
+ xscale/.sseq @ stdparse do transform, xscale/.value required,
+ yscale/.sseq @ stdparse do transform, yscale/.value required,
+ scale/.sseq @ stdparse do transform, scale/.value required,
+ scale around/.sseq @ stdparse do transform, scale around/.value required
+}
+
+%%% Error checking for nonglobal transformations:
+
+\def\sseq@firstpass@checkshifttransform#1#2{%
+ \pgfmathparse{#2}%
+ \sseq@ifpgfmathresultisunitlessint{%
+ \@xp\pgfmathint\@xp{\pgfmathresult}%
+ \@xp\advance\csname sseq@#1\endcsname\pgfmathresult\relax
+ }{\sseq@error@n{illegal-transform}{#1shift}}%
+}
+\let\sseq@firstpass@shifttransform\sseq@firstpass@checkshifttransform
+
+\def\sseq@checkshifttransform#1#2{%
+ \pgfmathparse{#2}%
+ \sseq@ifpgfmathresultisunitlessint{%
+ \@xp\pgfmathint\@xp{\pgfmathresult}%
+ \@xp\advance\csname sseq@#1\endcsname\pgfmathresult\relax
+ \sseq@pgfkeysdocommand{#1shift}{#2cm}
+ }{\sseq@error@n{illegal-transform}{#1shift}}%
+}
+
+\def\sseq@okayshifttransform#1#2{%
+ \pgfmathparse{#2}
+ \ifpgfmathunitsdeclared
+ \sseq@pgfkeysdocommand{#1shift}{#2}
+ \else
+ \sseq@pgfkeysdocommand{#1shift}{#2cm}
+ \fi
+}
+
+\def\sseq@tikz@firstpass@checkshifttransform#1#2{%
+ \pgfmathparse{#2}%
+ \sseq@ifpgfmathresultisunitlessint{%
+ \@xp\pgfmathint\@xp{\pgfmathresult}%
+ \@xp\advance\csname sseq@\sseq@getfirstchar#1\sseq@nil\endcsname\pgfmathresult\relax
+ }{\sseq@standardparse}%
+}
+
+\def\sseq@tikz@shifttransform#1#2{%
+ \pgfmathparse{#2}%
+ \sseq@ifpgfmathresultisunitlessint{%
+ \@xp\pgfmathint\@xp{\pgfmathresult}%
+ \@xp\advance\csname sseq@\sseq@getfirstchar#1\sseq@nil\endcsname\pgfmathresult\relax
+ \sseq@pgfkeysdocommand{#1shift}{#2cm}
+ }{
+ \sseq@standardparse
+ \ifpgfmathunitsdeclared
+ \sseq@pgfkeysdocommand{#1shift}{#2}
+ \else
+ \sseq@pgfkeysdocommand{#1shift}{#2cm}
+ \fi
+ }%
+}
+
+\def\sseq@ifpgfmathresultisunitlessint{\ifpgfmathunitsdeclared\@xp\@secondoftwo\else\sseq@ifpgfmathresultisint{\@xp\@firstoftwo}{\@xp\@secondoftwo}\fi}
+\def\sseq@ifpgfmathresultisint{\@xp\sseq@ifpgfmathresultisint@\pgfmathresult..\sseq@nil}
+\def\sseq@ifpgfmathresultisint@#1.#2.#3\sseq@nil{\ifx\sseq@nil#2\sseq@nil\@xp\@firstoftwo\else \ifnum#2=\z@ \@xp\@xp\@xp\@firstoftwo\else \@xp\@xp\@xp\@secondoftwo\fi\fi}
+
+%%%% Options for Tikz primitives
+
+\def\sseq@pageconstraint{1}
+\def\sseq@pageconstraint@true{1}
+
+\sseq@pgfqkeysdirlist{/sseqpages/scope,/sseqpages/tikz primitives}{
+ page constraint/.code={
+ \sseq@updatepageconstraint{#1}{&&}
+ },
+ page constraint or/.code={
+ \sseq@updatepageconstraint{#1}{||}
+ },
+ page/.code={\sseq@getnumrange\temp{#1}\sseq@updatepageconstraintrange},
+ set page constraint/.store in=\sseq@pageconstraint,
+ background/.code={\sseq@standardparse\sseq@setsavedpaths{background}\pgfkeysalso{standard parse}},
+}
+
+\sseq@pgfqkeysdirlist{/sseqpages/scope,/sseqpages/tikz primitives,/sseqpages/fit}{
+ class style/.code={\sseq@d@addto@options{\sseq@thesseqstyle\sseq@theclassstyle\the\sseq@scope@toks}},
+ cycle style/.forward to=/sseqpages/tikz primitives/class style,
+ permanent class style/.code={\sseq@d@addto@options{\sseq@thesseqstyle\sseq@theclassstyle\sseq@thepermanentcyclestyle\the\sseq@scope@toks}},
+ permanent cycle style/.forward to=/sseqpages/tikz primitives/permanent class style,
+ transient class style/.code={\sseq@d@addto@options{\sseq@thesseqstyle\sseq@theclassstyle\sseq@thetransientcyclestyle\the\sseq@scope@toks}},
+ transient cycle style/.forward to=/sseqpages/tikz primitives/transient class style,
+ this page class style/.code={\sseq@d@addto@options{\sseq@thesseqstyle\sseq@theclassstyle\sseq@thetransientcyclestyle\sseq@thethispagecyclestyle\the\sseq@scope@toks}},
+ this page cycle style/.forward to=/sseqpages/tikz primitives/this page class style,
+ differential style/.code={\sseq@d@addto@options{\sseq@thesseqstyle\sseq@theedgestyle\sseq@thedifferentialstyle\the\sseq@scope@toks}},
+ struct line style/.code={\sseq@d@addto@options{\sseq@thesseqstyle\sseq@theedgestyle\sseq@thestructlinestyle\the\sseq@scope@toks}},
+ tikz primitive style/.code={\sseq@d@addto@options{\sseq@thesseqstyle\sseq@thetikzprimitivestyle\the\sseq@scope@toks}}
+ %this page struct line style/.sseq @ first pass code={\sseq@d@addto@options{\sseq@thesseqstyle\sseq@theedgestyle\sseq@thestructlinestyle\the\sseq@scope@toks}}
+}
diff --git a/Master/texmf-dist/tex/latex/spectralsequences/sseqloadstore.code.tex b/Master/texmf-dist/tex/latex/spectralsequences/sseqloadstore.code.tex
new file mode 100644
index 00000000000..e86a1baf071
--- /dev/null
+++ b/Master/texmf-dist/tex/latex/spectralsequences/sseqloadstore.code.tex
@@ -0,0 +1,175 @@
+%%
+%% Package: spectralsequences.sty version 1.0
+%% Author: Hood Chatham
+%% Email: hood@mit.edu
+%% Date: 2017-06-18
+%% License: Latex Project Public License
+%%
+%% File: sseqloadstore.code.tex
+%%
+%% Defines commands for maintaining separate namespaces between distinct spectral sequences and saving information.
+%%
+
+
+% 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@addtostorelistlet#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}%
+ \global\@xp\let\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@protectedxdef#1{\@xptwo\sseq@protected@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@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
+}
+
+
+%%%% 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@n{illegal-add-background-mode}{\sseq@savedpaths@addclass}}
+\def\sseq@savedpaths@adddifferential@background#1{\sseq@error@internal@n{illegal-add-background-mode}{\sseq@savedpaths@adddifferential}}
+\def\sseq@savedpaths@addstructline@background#1{\sseq@error@internal@n{illegal-add-background-mode}{\sseq@savedpaths@addstructline}}
+\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@savedpaths@addclass@ignore#1{}
+\def\sseq@savedpaths@adddifferential@ignore#1{}
+\def\sseq@savedpaths@addstructline@ignore#1{}
+\def\sseq@savedpaths@add@ignore#1{}
+\def\sseq@savedpaths@xadd@ignore#1{}
+\def\sseq@savedpaths@show@ignore#1{}
+\def\sseq@scope@savedpaths@add@ignore#1{}
+
+\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{}%
+} \ No newline at end of file
diff --git a/Master/texmf-dist/tex/latex/spectralsequences/sseqmacromakers.code.tex b/Master/texmf-dist/tex/latex/spectralsequences/sseqmacromakers.code.tex
new file mode 100644
index 00000000000..1a89dc4b66a
--- /dev/null
+++ b/Master/texmf-dist/tex/latex/spectralsequences/sseqmacromakers.code.tex
@@ -0,0 +1,389 @@
+%%
+%% Package: spectralsequences.sty version 1.0
+%% Author: Hood Chatham
+%% Email: hood@mit.edu
+%% Date: 2017-06-18
+%% License: Latex Project Public License
+%%
+%% File: sseqmacromakers.code.tex
+%% Exposes: \DeclareSseqCommand, \NewSseqCommand, \DeclareSseqGroup, \NewSseqGroup
+%%
+%% Set up commands to define other commands, both the internal macros, and the external ones.
+%% Also the internal macros \sseq@DeclareDocumentCommandAs and \sseq@DeclareDocumentCommand
+%% For the user commands, sets up call stack, thiscall, etc
+%%
+
+
+
+\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.
+%%% 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@recordmacros{\@xp\sseq@recordmacros@\sseq@macrolist\sseq@nil}
+\def\sseq@recordmacros@#1{%
+ \ifx#1\sseq@nil\else % if so, that was the last command in the list
+ \@xp\def\csname sseq@builtin\sseq@macroname#1\endcsname{}
+ \@xp\sseq@recordmacros@
+ \fi %
+}
+
+
+
+\def\sseq@installmacros{\@xp\sseq@installmacros@\sseq@macrolist\sseq@nil}
+\def\sseq@installmacros@#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@installmacros@
+ \fi %
+}
+
+
+% Capital U argument type is "Until" but puts back the token when it's done.
+\cs_new_protected:Npn \sseq__xparse_add_type_U:w #1
+ {
+ \__xparse_flush_m_args:
+ \__xparse_add_grabber_mandatory:N U
+ \tl_put_right:Nn \l__xparse_signature_tl { {#1} }
+ \__xparse_prepare_signature:N
+ }
+
+\cs_new_protected:Npn \sseq__xparse_grab_U:w #1#2 \l__xparse_args_tl
+ { \sseq__xparse_grab_U_aux:nnN {#1} {#2} \cs_set_protected_nopar:Npn }
+
+\cs_new_protected:Npn \sseq__xparse_grab_U_aux:nnN #1#2#3
+ {
+ \exp_after:wN #3 \l__xparse_fn_tl ##1 #1
+ {
+ \__xparse_add_arg:n {##1}
+ #2\l__xparse_args_tl #1
+ }
+ \l__xparse_fn_tl
+ }
+
+% I would like to patch the \__xparse_grab_U:w's in my commands into \sseq__xparse_grab_U:w's but I can't because of -NoValue-.
+\def\sseq@install@xparse@Uarggrabber{ \cs_set_eq:NN \__xparse_grab_U:w \sseq__xparse_grab_U:w }
+
+%%% \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:NN \__xparse_add_type_U:w \sseq__xparse_add_type_U:w
+ \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
+ \sseq@installmsghooks
+ \def\sseq@error@setup{}
+ \def\sseq@error@cleanup{\sseq@errortrue}
+ \let\sseq@error@annotation\empty
+ \DeclareDocumentCommand #2 { #3 } { #4 }
+ \ifsseq@error
+ \group_end:
+ \sseq@errortrue % This only happens if it came from user code, so don't set error to be false so it can break out too.
+ \@xp\sseq@break
+ \fi
+ \cs_if_exist:cTF{ \cs_to_str:N #2 \c_space_tl code }{
+ \cs_gset:Npx #1{
+ \begingroup
+ \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 }
+ }
+ \pretocmd:cnnn { \cs_to_str:N #2 \c_space_tl code } { \endgroup } { } { \sseq@error@x { macro-patch-failed } { \string#1 } }
+ \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 }
+ }{
+ \cs_gset_eq:NN #1 #2
+ }
+ \group_end: % In this case, I want to pass \sseq@errortrue out of the block, so I close the group before I break.
+ \sseq@breakpoint % So this breakpoint definitely should be after the \endgroup.
+}
+
+\cs_set_eq:NN \patchcmd:Nnnnn \patchcmd
+\cs_set_eq:NN \pretocmd:Nnnn \pretocmd
+\cs_generate_variant:Nn \patchcmd:Nnnnn {cnfnn}
+\cs_generate_variant:Nn \pretocmd:Nnnn {cfnn}
+\cs_generate_variant:Nn \pretocmd:Nnnn {cnnn}
+
+\cs_new_protected:Npn\NewSseqCommand#1{%
+ \cs_if_free:cTF { sseq @ usermacro @ \cs_to_str:N #1 } { \DeclareSseqCommand#1 } { \sseq@error@x{usermacro-not-free}{\string#1} \use_none:nn }
+}
+
+\cs_new_protected:Npn\DeclareSseqCommand#1#2#3{%
+ \cs_if_exist:cTF { sseq @ builtin @ \cs_to_str:N #1 } {\sseq@error@x{wont-override-system-macro}{\string#1}\sseq@break} {}
+ \cs_if_free:cT { sseq @ usermacro @ \cs_to_str:N #1 } {
+ \sseq@x@addto@macro { \sseq@installmacros } { \let \exp_not:N #1 \exp_not:c { sseq @ usermacro @ \cs_to_str:N #1 } }
+ }
+ % Make sure \cs_if_exist doesn't pass because there was a previously defined user macro with same name
+ \cs_undefine:c { sseq @ usermacro @ \cs_to_str:N #1 \c_space_tl code }
+ \exp_args:Nc \sseq@DeclareDocumentCommandAs { sseq @ usermacro @ \cs_to_str:N #1 } #1 { #2 } {
+ #3
+ \endgroup
+ }%
+ \ifsseq@error
+ \global\sseq@errorfalse
+ \@xp\sseq@break
+ \fi
+ \sseq@parseargspec{#1}{#2}%
+ % You might think we could skip this patching, and it's probably possible.
+ % However, this is responsible for turning the #'s of catcode other into #'s of catcode arg. I don't have as good of a way to do that.
+ % Also, this allows me to use \sseq@parseargspec after defining the command, so I don't have to run any error checking inside of it
+ % because if the argspec is invalid, \DeclareDocumentCommand will let me know.
+ \cs_if_exist:cTF{ sseq @ usermacro @ \cs_to_str:N #1 \c_space_tl code }{
+ \patchcmd:cnfnn{ sseq @ usermacro @ \cs_to_str:N #1 \c_space_tl code }{\endgroup}{
+ \@xp\endgroup
+ \@xp\begingroup
+ \the\sseq@temptoks
+ \sseq@atbeginusermacro@msgsetup
+ }{}{\error\sseq@error@x{usermacro-failed-patch}{\string#1}}
+ }{
+ \pretocmd:cfnn{ sseq @ usermacro @ \cs_to_str:N #1 }{
+ \@xp\begingroup
+ \the\sseq@temptoks
+ \sseq@atbeginusermacro@msgsetup
+ }{}{\error\sseq@error@x{usermacro-failed-patch}{\string#1}}
+ }
+ \cs_gset_eq:cc { sseq @ usermacro @ \cs_to_str:N #1 } { sseq @ usermacro @ \cs_to_str:N #1 }
+ \ifsseq@inprogress
+ \cs_set_eq:Nc #1 { sseq @ usermacro @ \cs_to_str:N #1 }
+ \fi
+ \sseq@breakpoint
+}
+
+%%% Commands to help the user define "groups" of commands to be reused
+\def\sseqnewgroup@splitcoord#1,#2\sseq@nil{%
+ \sseq@eval{
+ \@nx\begin{scope}[xshift=#1,yshift=#2,\unexpanded\@xp{\sseq@options}]
+ }
+}
+
+% #1 -- command
+% #2 -- argspec
+% #3 -- body of function (long)
+\NewDocumentCommand\NewSseqGroup{mm+m}{\DeclareSseqGroup@\NewSseqCommand{#1}{#2}{#3}}
+\NewDocumentCommand\DeclareSseqGroup{mm+m}{\DeclareSseqGroup@\DeclareSseqCommand{#1}{#2}{#3}}
+
+% #1 -- \NewSseqCommand or \DeclareSseqCommand
+% #2 -- command
+% #3 -- argspec
+% #4 -- body of function (long)
+\long\def\DeclareSseqGroup@#1#2#3#4{%
+ \group_begin:
+ \let\sseq@parseargspec\@gobbletwo % Get rid of argparse so we can change what gets added for setting up thiscall
+ \sseq@temptoks\@xp{\sseq@SseqGroup@argspec} % This gets added to the outer command by DeclareSseqCommand
+%
+ \sseq@installmsghooks
+ \def\sseq@error@setup{}
+ \def\sseq@error@cleanup{\sseq@errortrue}
+ \let\sseq@error@annotation\empty
+%
+% undefine so we can tell whether we need to patch \command<space>code or \command
+ \cs_undefine:c { sseq @ usermacro @ \cs_to_str:N #2 @ helper \c_space_tl code }
+ \exp_args:Nc \DeclareDocumentCommand { sseq @ usermacro @ \cs_to_str:N #2 @ helper } { #3 } {
+ #4
+ \end{scope}
+ }%
+ \ifsseq@error
+ \@xp\sseq@break
+ \fi
+ #1#2{od()}{%
+ \IfNoValueTF{##1}{\def\sseq@options{}}{\def\sseq@options{##1}}%
+ \IfNoValueTF{##2}{%
+ \sseq@eval{
+ \@nx\begin{scope}[\unexpanded\@xp{\sseq@options}]
+ }%
+ }{%
+ \sseqnewgroup@splitcoord##2\sseq@nil
+ }%
+ \csname sseq @ usermacro @ \sseq@macroname #2 @ helper \@xp\endcsname \@gobble % This gobble eats the endgroup added by sseqDeclareDocumentCommand
+ }%
+
+ \sseq@parseargspec@newgroup{#2}{#3}%
+ % You might think we could skip this patching, and it's probably possible.
+ % However, this is responsible for turning the #'s of catcode other into #'s of catcode arg. I don't have as good of a way to do that.
+ \cs_if_exist:cTF{ sseq @ usermacro @ \cs_to_str:N #2 @ helper \c_space_tl code }{
+ \pretocmd:cfnn { sseq @ usermacro @ \cs_to_str:N #2 @ helper \c_space_tl code }{
+ \the\sseq@temptoks
+ \sseq@atbeginusermacro@msgsetup
+ }{}{\error\sseq@error@x{usermacro-failed-patch}{\string#1}}
+ \cs_gset_eq:cc { sseq @ usermacro @ \cs_to_str:N #2 @ helper \c_space_tl code } { sseq @ usermacro @ \cs_to_str:N #2 @ helper \c_space_tl code } % globalize definition
+ }{
+ \pretocmd:cfnn { sseq @ usermacro @ \cs_to_str:N #2 @ helper }{
+ \the\sseq@temptoks
+ \sseq@atbeginusermacro@msgsetup
+ }{}{\error\sseq@error@x{usermacro-failed-patch}{\string#1}}
+ }
+ \cs_gset_eq:cc { sseq @ usermacro @ \cs_to_str:N #2 @ helper } { sseq @ usermacro @ \cs_to_str:N #2 @ helper } % globalize definition
+ \let\sseq@parseargspec\sseq@parseargspec@normal
+ \sseq@breakpoint
+ \group_end:
+}
+\let\sseqnewgroup\NewSseqGroup
+
+
+\bgroup\catcode`\#=12\relax
+ \gdef\sseq@SseqGroup@argspec{\sseq@eval{\sseq@temptoks{\IfNoValueF{#1}{\unexpanded{[#1]}}\IfNoValueF{#2}{\unexpanded{(#2)}}}}\@gobble}
+ \gdef\sseq@thearg{#\the\sseq@tempcount}
+\egroup
+
+
+% When there are arguments with default values (O, D, R, G), we need to put them into temporary macros to compare them and see if they are the default value
+% that's what temptoksii is for.
+\def\sseq@parseargspec#1#2{%
+ \sseq@tempcount=\z@
+ \sseq@temptoks{\@nx#1}% Holds the stuff that goes in \esetthiscall (so most stuff)
+ \sseq@temptoksii{}
+ \sseq@parseargspec@#2\sseq@nil
+ \sseq@eval{\sseq@temptoks{\the\sseq@temptoksii\@nx\sseq@usermacro@esetthiscall{\the\sseq@temptoks}}}
+}
+
+% For NewGroup:
+\let\sseq@parseargspec@normal\sseq@parseargspec
+\def\sseq@parseargspec@newgroup#1#2{%
+ \sseq@tempcount=\z@
+ \sseq@temptoks{}
+ \sseq@temptoksii{}%
+ \sseq@parseargspec@#2\sseq@nil
+ \sseq@eval{\sseq@temptoks{\the\sseq@temptoksii\@nx\sseq@usermacro@esetthiscall{\@nx\@nx\@nx#1\@nx\the\sseq@temptoks\the\sseq@temptoks}}}
+}
+
+
+\def\sseq@parseargspec@#1{
+ \advance\sseq@tempcount\@ne
+ \ifx#1\sseq@nil\else
+ \@xp\ifx\csname sseq@parseargspec@#1\@xp\endcsname\relax
+ \sseq@error@n{usermacro-unsupported-argument-type}{#1}
+ \else
+ \csname sseq@parseargspec@#1\@xptwo\endcsname
+ \fi
+ \fi
+}
+
+
+% Have to use \@alph to convert the number to a letter. Using a number here doesn't work because the control sequence gets retokenized
+% so we can only use letters in control sequences (another option would be to not expand the \csnames till later, but that would be harder).
+\def\sseq@parseargspec@ifargisnotdefault{%
+ \@nx\ifx
+ \@xp\@nx\csname sseq@parseargspec@temparg\@alph\sseq@tempcount\endcsname
+ \@xp\@nx\csname sseq@parseargspec@tempdefault\@alph\sseq@tempcount\endcsname
+ \unexpanded{%
+ \@xp\@gobble
+ \else
+ \@xp\@firstofone
+ \fi
+ }%
+}
+
+\def\sseq@parseargspec@setargdefault#1{%
+ \sseq@e@addto@toks\sseq@temptoksii{%
+ \def\@xp\@nx\csname sseq@parseargspec@temparg\@alph\sseq@tempcount\endcsname{\sseq@thearg}%
+ \def\@xp\@nx\csname sseq@parseargspec@tempdefault\@alph\sseq@tempcount\endcsname{\unexpanded{#1}}%
+ }
+}
+
+% Mandatory
+\def\sseq@parseargspec@m{%
+ \sseq@e@addto@temptoks{{\@nx\unexpanded{\sseq@thearg}}}
+ \sseq@parseargspec@
+}
+\def\sseq@parseargspec@l{%
+ \sseq@e@addto@temptoks{\@nx\unexpanded{\sseq@thearg}}
+ \sseq@parseargspec@
+}
+
+\def\sseq@parseargspec@u#1{%
+ \sseq@e@addto@temptoks{\@nx\unexpanded{\sseq@thearg}\unexpanded{\unexpanded{#1}}}
+ \sseq@parseargspec@
+}
+
+\def\sseq@parseargspec@U#1{%
+ \sseq@e@addto@temptoks{\@nx\unexpanded{\sseq@thearg}}
+ \sseq@parseargspec@
+}
+
+% Optional no default
+\def\sseq@parseargspec@o{%
+ \sseq@e@addto@temptoks{\@nx\IfNoValueF{\sseq@thearg}{[\@nx\unexpanded{\sseq@thearg}]}}
+ \sseq@parseargspec@
+}
+
+\def\sseq@parseargspec@d#1#2{%
+ \sseq@e@addto@temptoks{\@nx\IfNoValueF{\sseq@thearg}{\@nx\unexpanded{#1\sseq@thearg#2}}}
+ \sseq@parseargspec@
+}
+
+\def\sseq@parseargspec@r#1#2{ % technically required, but behaves like optional
+ \sseq@e@addto@temptoks{#1\@nx\unexpanded{\sseq@thearg}#2}
+ \sseq@parseargspec@
+}
+
+
+\def\sseq@parseargspec@g{%
+ \sseq@e@addto@temptoks{\@nx\IfNoValueF{\sseq@thearg}{\@nx\unexpanded{{\sseq@thearg}}}}
+ \sseq@parseargspec@
+}
+
+\def\sseq@parseargspec@s{%
+ \sseq@e@addto@temptoks{\@nx\IfBooleanT{\sseq@thearg}{*}}
+ \sseq@parseargspec@
+}
+
+\def\sseq@parseargspec@t#1{%
+ \sseq@e@addto@temptoks{\@nx\IfBooleanT{\sseq@thearg}{#1}}
+ \sseq@parseargspec@
+}
+
+
+
+\def\sseq@parseargspec@O#1{
+ \sseq@parseargspec@setargdefault{#1}%
+ \sseq@e@addto@temptoks{\sseq@parseargspec@ifargisnotdefault{\@nx\unexpanded{[\sseq@thearg]}}}%
+ \sseq@parseargspec@
+}
+\def\sseq@parseargspec@D#1#2#3{%
+ \sseq@parseargspec@setargdefault{#3}%
+ \sseq@e@addto@temptoks{\sseq@parseargspec@ifargisnotdefault{\@nx\unexpanded{#1\sseq@thearg#2}}}%
+ \sseq@parseargspec@
+}
+\def\sseq@parseargspec@R#1#2#3{%
+ \sseq@parseargspec@setargdefault{#3}%
+ \sseq@e@addto@temptoks{\sseq@parseargspec@ifargisnotdefault{\@nx\unexpanded{#1\sseq@thearg#2}}}%
+ \sseq@parseargspec@
+}
+\def\sseq@parseargspec@G#1{%
+ \sseq@parseargspec@setargdefault{#1}%
+ \sseq@e@addto@temptoks{\sseq@parseargspec@ifargisnotdefault{\@nx\unexpanded{{\sseq@thearg}}}}%
+ \sseq@parseargspec@
+}
+
+
+\ExplSyntaxOff
+
+%
diff --git a/Master/texmf-dist/tex/latex/spectralsequences/sseqmain.code.tex b/Master/texmf-dist/tex/latex/spectralsequences/sseqmain.code.tex
new file mode 100644
index 00000000000..edc87c5d2b0
--- /dev/null
+++ b/Master/texmf-dist/tex/latex/spectralsequences/sseqmain.code.tex
@@ -0,0 +1,1123 @@
+%%
+%% Package: spectralsequences.sty version 1.0
+%% Author: Hood Chatham
+%% Email: hood@mit.edu
+%% Date: 2017-06-18
+%% License: Latex Project Public License
+%%
+%% File: sseqmain.code.tex
+%%
+%% Defines the main environments and commands
+%%
+
+
+%%%%%%%
+%%%
+%%% Environment definitions
+%%%
+%%%%%%%
+
+\sseq@addtostorelist\sseq@savedbackgroundpaths{}
+\sseq@addtostorelist\sseq@restorestyles{}
+
+\def\sseqdata{\@ifnextchar[{\sseqdata@}{\sseqdata@[]}}%}
+
+\def\sseq@page{\protect\sseq@thepage}
+
+\def\sseqdata@[#1]{%
+ \edef\sseq@restorefont{\font@name}
+ \selectfont\nullfont % Avoid space hazards!
+
+ \def\par{}
+%
+ \ifx\pgfpictureid\@undefined\else %Uh-oh, we're inside tikz.
+ \sseq@error@n{env-inside-tikz}{sseqdata}\@xp\sseq@breakdataenv
+ \fi
+ \ifsseq@inprogress % Uh-oh, we're already in a sseq environment. This is not good.
+ \sseq@error@n{env-inside-sseq}{sseqdata}\@xp\sseq@breakdataenv
+ \fi
+ \sseq@inprogresstrue
+ \def\sseq@sseqsetdirectory{/sseqpages}
+ \sseq@keepchangestrue
+ \sseq@storelist@setdefaults
+ \let\sseq@xtickfn\@firstofone\let\sseq@ytickfn\@firstofone % These are default functions, which addtostorelist can't handle.
+%
+ \ifx\sseq@xmin@default\sseq@infinity
+ \let\sseq@xminmax\sseq@xminmax@active
+ \fi
+ \ifx\sseq@ymin@default\sseq@infinity
+ \let\sseq@yminmax\sseq@yminmax@active
+ \fi
+ \ifsseq@mathnodes
+ \let\sseq@maybemathswitch=$\@gobble$
+ \fi
+%
+ % copy commands into the user namespace.
+ \sseq@installmacros
+ \sseq@installmsghooks
+ \sseq@install@xparse@Uarggrabber
+ \def\xmin{\protect\sseq@xmin}\def\xmax{\protect\sseq@xmax}
+ \def\ymin{\protect\sseq@ymin}\def\ymax{\protect\sseq@ymax}
+%
+ \sseq@modtikzcommands % Defer evaluation of tikz primitives
+ \sseq@patchfor % patch \foreach to work with deferred macros
+ \pgfkeys{/handlers/first char syntax/the character "/.initial=\sseq@handlequote} % install quotes parsing
+%
+%
+ \pgfqkeys{/sseqpages/global/name only}{#1}
+ \@ifundefined{sseq@thename}{\sseq@error{env-data-no-name}\sseq@breakdataenv}{}
+ \sseq@obj@ifundef{exists}{
+ \sseq@obj@gdef{exists}{}
+ \pgfqkeys{/sseqpages/global}{{\sseq@thename} options/.code={}}
+ }{
+ \ifsseq@updateexisting\else
+ \sseq@error@x{env-data-already-exist}{\sseq@thename}% this could be a warning
+ \fi
+ \sseq@restorestyles
+ \sseq@getcmds
+
+ }
+ \sseq@setsavedpaths{standard}
+%
+ % the default option handler for /sseqpages/global adds to \sseq@currentoptionpath options
+ \let\sseq@currentoptionpath\sseq@thename
+ \pgfqkeys{/sseqpages/global}{#1}
+ \ifx\sseq@targetx\pgfutil@empty\else
+ \sseq@hasdegreetrue
+ \fi
+ \sseq@eval{
+ \global\let\@xp\@nx\csname pgfk@/sseqpages/global/{\sseq@currentoptionpath} options/.@cmd\endcsname
+ \@xp\@nx\csname pgfk@/sseqpages/global/{\sseq@currentoptionpath} options/.@cmd\endcsname
+ }
+ \sseq@savedpaths@xadd{\sseq@stylelist}
+ \sseq@savedpaths@add{\begingroup} % prevent some of the two-pass user macros horrors
+}
+
+% Just store all the settings
+\def\endsseqdata{
+ \sseq@savedpaths@add{\endgroup} % prevent some of the two-pass user macros horrors
+ \xdef\sseq@restorestyles{\sseq@stylelist}
+ \sseq@storecmds
+ \ignorespacesafterend
+}
+
+\def\sseqpage{\@ifnextchar[{\sseqpage@}{\sseqpage@[]}} %]
+
+\def\sseqpage@[#1]{%
+ \edef\sseq@restorefont{\font@name}
+ \selectfont\nullfont % Avoid space hazards!
+ \def\par{}
+%
+ \ifx\pgfpictureid\@undefined\else %Uh-oh, we're inside tikz.
+ \sseq@error@n{env-inside-tikz}{sseqpage}\@xp\sseq@breakpageenv
+ \fi
+ \ifsseq@inprogress % Uh-oh, we're already in a sseq environment. This is not good.
+ \sseq@error@n{env-inside-sseq}{sseqpage}\@xp\sseq@breakpageenv
+ \fi
+ \sseq@inprogresstrue
+ \sseq@ispageenvtrue
+ \def\sseq@sseqsetdirectory{/sseqpages}
+%
+ \let\sseq@xminmax\sseq@xminmax@active
+ \let\sseq@yminmax\sseq@yminmax@active
+ \ifsseq@mathnodes
+ \let\sseq@maybemathswitch=$\@gobble$
+ \fi
+%
+ % Copy commands into user namespace
+ \sseq@installmacros
+ \sseq@installmsghooks
+ \sseq@install@xparse@Uarggrabber
+ \def\xmin{\protect\sseq@xmin}\def\xmax{\protect\sseq@xmax}
+ \def\ymin{\protect\sseq@ymin}\def\ymax{\protect\sseq@ymax}
+ \sseq@modtikzcommands % Redefine tikz primitives to store themselves in the appropriate place
+ \sseq@patchfor % Change foreach to record it's variable values in the appropriate places
+ \pgfkeys{/handlers/first char syntax/the character "/.initial=\sseq@handlequote}% install quotes parsing
+%
+ \gdef\sseq@pagecleanup{}% For undoing local option settings
+%
+ \def\sseq@thepage{0}% page defaults to 0
+ \sseq@thepagecount=\z@
+ \pgfqkeys{/sseqpages/global/name only}{#1}% Get the name
+ \sseq@tempiftrue
+ \ifsseq@hasname
+ \sseq@obj@ifundef{exists}{
+ \sseq@error@x{env-page-not-exist}{\sseq@thename} % This could be a warning
+ \sseq@obj@gdef{exists}{}
+ \let\sseq@currentoptionpath\sseq@thename
+ \pgfqkeys{/sseqpages/global}{{\sseq@thename} options/.code={}}
+ \sseq@keepchangestrue
+ \sseq@keepglobaloptionstrue
+ \sseq@setsavedpaths{standard}
+ }{
+ \sseq@restorestyles
+ \sseq@getcmds
+ \ifsseq@keepchanges
+ \sseq@setsavedpaths{standard}
+ \else
+ \sseq@setsavedpaths{temporary}
+ \fi
+ \sseq@tempiffalse
+ \def\sseq@currentoptionpath{this page}
+ \pgfqkeys{/sseqpages/global}{{this page} options/.code={},#1}
+ }
+ \else
+ \edef\sseq@thename{temp@sseq@number@\the\sseq@anonsseqcount}
+ \global\advance\sseq@anonsseqcount1
+ \sseq@setsavedpaths{temporary}
+ \fi
+ \ifsseq@tempif % Either the spectral sequence has no name, or it has a name but no such existed.
+ \sseq@storelist@setdefaults
+ \sseq@savedpaths@xadd{\sseq@stylelist}
+ \let\sseq@currentoptionpath\sseq@thename
+ \pgfqkeys{/sseqpages/global}{{\sseq@thename} options/.code={},{this page} options/.code={},#1}
+ \sseq@eval{
+ \global\let\@xp\@nx\csname pgfk@/sseqpages/global/{\sseq@currentoptionpath} options/.@cmd\endcsname
+ \@xp\@nx\csname pgfk@/sseqpages/global/{\sseq@currentoptionpath} options/.@cmd\endcsname
+ }
+ \fi
+ \sseq@savedpaths@xadd{\sseq@stylelist}
+ \sseq@savedpaths@add{\begingroup} % prevent some of the two-pass user macros horrors
+ \ifx\sseq@targetx\pgfutil@empty\else
+ \sseq@hasdegreetrue
+ \fi
+}
+
+% Here we do all of the work to actually print the page
+\def\endsseqpage{
+ \sseq@savedpaths@add{\endgroup} % prevent some of the two-pass user macros horrors
+ \ifx\sseq@xmin\sseq@infinity\sseq@error{no-range}\def\sseq@xmin{0}\def\sseq@xmax{0}\@xp\sseq@break\fi % could be warning
+ \ifx\sseq@ymin\sseq@infinity\sseq@error{no-range}\def\sseq@ymin{0}\def\sseq@ymax{0}\@xp\sseq@break\fi
+%
+ \tikzset{
+ z=0pt,
+ every path/.style={},
+ every node/.style={}
+ }
+ \let\errmessage\sseq@errmessage@std
+ \begin{tikzpicture}[/sseqpages/global/{default} options,\ifsseq@hasname/sseqpages/global/{\sseq@thename} options\fi,/sseqpages/global/{this page} options]%
+ \sseq@sseqstyle@globalpart
+ \pgftransformreset
+ \sseq@globaldetonetransform
+ \sseq@globalscaletransform
+%
+ \let\sseq@transform\sseq@error@illegaltransform % Disallow most coordinate transforms
+ \let\sseq@shifttransform\sseq@checkshifttransform % Allow shifts as long as they are by integers and have no units.
+%
+ \sseq@setupclip
+ \pgfonlayer{background}%
+ % Axes labels only occur once per page, so the cost of typesetting them with tikz doesn't matter ... THANK GOD
+ \ifx\sseq@title\pgfutil@empty\else
+ \ifsseq@drawtitle
+ \sseq@eval{\unexpanded{\path (0.5*\xmin+0.5*\xmax,\ymax) node[
+ /sseqpages/global/every title,
+ above=\sseq@clip@padding@top+\sseq@yaxis@end@extend+10pt
+ ]} {\unexpanded\expandafter{\sseq@title}};}
+ \fi
+ \fi
+ % Don't touch the shifts -- they are very persnickety.
+ \ifx\sseq@xaxislabel\pgfutil@empty\else\ifsseq@drawxaxislabel
+ \sseq@eval{\noexpand\node[/sseqpages/global/every x axis label, yshift=-\sseq@xaxisgap-\sseq@yaxis@start@extend-10pt] {\unexpanded\expandafter{\sseq@xaxislabel}};}
+ \fi\fi
+ \ifx\sseq@yaxislabel\pgfutil@empty\else\ifsseq@drawyaxislabel
+ \sseq@eval{\noexpand\node[/sseqpages/global/every y axis label,rotate=90,yshift=\sseq@yaxisgap+\sseq@xaxis@start@extend+10pt] {\unexpanded\expandafter{\sseq@yaxislabel}};}
+ \fi\fi
+ \sseq@handlexaxis % Draw the axis with pgf primitives. These are defined in sseqdrawing.code.tex
+ \sseq@handleyaxis
+ \sseq@grid
+ \endpgfonlayer
+%
+ \ifsseq@mathnodes
+ \tikzset{execute at begin node=$,execute at end node=$}%
+ \fi
+ %\let\sseq@error@setup\sseq@error@setup@withinfo
+ \begingroup
+ \sseq@savedbackgroundpaths
+ \endgroup
+%
+ \sseq@useclip
+%
+ \ifsseq@drawdifferentials\else
+ \let\sseq@differential@draw@ifpage\@gobble
+ \fi
+ \ifsseq@drawstructlines\else
+ \let\sseq@structline@draw@ifpage\@gobble
+ \fi
+%
+ \sseq@usesavedpaths
+%
+ \ifsseq@keepchanges
+ \xdef\sseq@restorestyles{\sseq@stylelist}
+ \fi
+ \end{tikzpicture}%
+ \ifsseq@keepchanges
+ \sseq@storecmds % store changes
+ \else
+ \sseq@pagecleanup % undo any changes specific to this page
+ \fi
+ \sseq@breakpoint
+ \ignorespacesafterend
+}
+
+% Shorthand for sseqpage with empty body
+\def\printpage[#1]{%
+ \begin{sseqpage}[#1]
+ \end{sseqpage}%
+}
+
+%%% Scope
+\newcount\sseq@scope@savestackid
+\def\sseq@scope{\@ifnextchar[{\sseq@scope@}{\sseq@scope@[]}}%]
+\def\sseq@scope@[#1]{%
+ \sseq@scope@savedpaths@add{\begin{scope}}%
+ \sseq@processoptions{scope}{#1}% outputs into \sseq@savedoptioncode
+ \sseq@eval{\@nx\sseq@scope@savedpaths@add{\sseq@scope@toks{\unexpanded\@xp{\sseq@savedoptioncode\tikz@options}}}}%
+ %\advance\sseq@scope@savestackid\@ne
+ %\sseq@savestack@name{scope@save\the\sseq@scope@savestackid}
+}
+\def\sseq@endscope{%
+ \sseq@scope@savedpaths@add{\end{scope}}
+ %\sseq@restorestack@name{scope@save\the\sseq@scope@savestackid
+}
+
+
+
+
+\ifsseq@draftmode % Okay, have to dummy out all the main commands.
+ \sseq@setsavedpaths{ignore} % Don't add stuff to paths
+ \let\sseq@setsavedpaths\@gobble % and dummy out the normal mechanism that would change this
+
+ % We don't really want to add anything to the saved paths, but the whole tikz parser is already loaded in parsers and we want to dummy a bit of it out.
+ % It's good to have the parser itself though, because it is responsible for sanity checking the structure of the input. Just get rid of the hard tasks
+ % the parser does once it's parsed the stuff.
+ \def\sseq@defer@tikzcommand@option[#1]{%
+ \sseq@g@addto@macro\sseq@whattheusersaid{[#1]}%
+ \sseq@defer@tikzcommand@
+ } % These are the two expensive handlers, redefine them to do nothing.
+ \def\sseq@defer@tikzcommand@coord(#1){%
+ \sseq@g@addto@macro\sseq@whattheusersaid{(#1)}%
+ \sseq@defer@tikzcommand@
+ }
+
+
+ % All we want to do here is record the range. Have to process options in order to figure out where it is.
+ \sseq@DeclareDocumentCommand\class{or()}{%
+ \begingroup
+ \IfNoValueT{#2}{\sseq@break}%
+ \sseq@xsetthiscall{\string\class\IfNoValueF{#1}{[\unexpanded{#1}]}\unexpanded{(#2)}}%
+ \sseq@options@firstpassmode
+ \the\sseq@sseqstyle
+ \the\sseq@classstyle
+ \sseq@options@normalmode
+ \IfNoValueF{#1}{%
+ \sseq@processoptions{class}{#1}% Outputs result into \sseq@savedoptioncode
+ }%
+ \sseq@cparsecoord{#2}{}%
+ \sseq@xminmax{\xcoord}{\ycoord}%
+ \sseq@yminmax{\xcoord}{\ycoord}%
+ \sseq@pushstack@\coord % also need the class stack to calculate other \class commands.
+ \sseq@cleanup@obj{partcoord.(\partialcoord).numnodes}%
+ \sseq@cleanup@obj{partcoord.(\partialcoord).numnodespp}%
+ \ifnum\nodenum=\@ne
+ \sseq@obj@gdef{partcoord.(\partialcoord).numnodes}{0}%
+ \sseq@obj@gdef{partcoord.(\partialcoord).numnodespp}{1}%
+ \fi
+ \sseq@obj@xdef{partcoord.(\partialcoord).numnodes}{\nodenum}%
+ \sseq@obj@xdef{partcoord.(\partialcoord).numnodespp}{\the\numexpr\nodenum+1}%
+ \edef\classname{class.\coord[0]}%
+ \ifx\sseq@class@tag\pgfutil@empty\else
+ \sseq@obj@ifdef{partcoord.(\partialcoord).tag.\sseq@class@tagprefix\sseq@class@tag}{%
+ \sseq@error@xx{class-tag-already-defined}{\sseq@class@tagprefix\sseq@class@tag}{(\partialcoord)}% could be warning
+ }{}%
+ \sseq@cleanup@obj{partcoord.(\partialcoord).tag.\sseq@class@tagprefix\sseq@class@tag}%
+ \sseq@obj@xdef{partcoord.(\partialcoord).tag.\sseq@class@tagprefix\sseq@class@tag}{\nodenum}%
+ \fi
+ \ifx\sseq@class@name\pgfutil@empty\else
+ \sseq@cleanup@obj{class.\classname.name}
+ \sseq@cleanup@obj{class.namedclass.\sseq@class@name}
+ \sseq@namehandler
+ \sseq@obj@xdef{class.\classname.name}{\sseq@class@name}
+ \sseq@obj@xdef{class.namedclass.\sseq@class@name}{\coordnopar}
+ \fi
+ \sseq@breakpoint
+ \endgroup
+ }
+
+ % Now the rest of these can be no-ops
+ \sseq@DeclareDocumentCommand\classoptions{or()}{}
+ \sseq@DeclareDocumentCommand\replaceclass{or()}{}
+ \sseq@DeclareDocumentCommand\d{oU(r()d()}{}
+ \sseq@DeclareDocumentCommand\doptions{oU(r()d()}{}
+ \sseq@DeclareDocumentCommand\structline{or()r()}{}
+ \sseq@DeclareDocumentCommand\structlineoptions{or()r()}{}
+ \sseq@DeclareDocumentCommand\circleclasses{or()r()}{}
+ \endinput
+\fi
+
+
+\protected\def\sseq@xcoord{}\protected\def\sseq@ycoord{}
+
+%%%%%
+%%
+%% The main commands
+%%
+%%%%%
+%%% \class, \classoptions, \replaceclass
+\sseq@DeclareDocumentCommand\class{or()}{%
+ \begingroup
+ \IfNoValueT{#2}{\sseq@break}
+ \sseq@xsetthiscall{\string\class\IfNoValueF{#1}{[\unexpanded{#1}]}\unexpanded{(#2)}}%
+ \sseq@options@firstpassmode
+ \the\sseq@sseqstyle
+ \the\sseq@classstyle
+ \the\sseq@scope@toks
+ \sseq@options@normalmode
+ \IfNoValueF{#1}{%
+ \sseq@processoptions{class}{#1}% Outputs result into \sseq@savedoptioncode
+ }%
+%
+ \@ifundefined{sseq@class@page}{}{\sseq@error@xxx{cmdoptions-only}{page} {\string\class}{\string\classoptions}}% could be warnings
+ \@ifundefined{sseq@gen} {}{\sseq@error@xxx{cmdoptions-only}{generation}{\string\class}{\string\classoptions}}
+%
+ \sseq@cparsecoord{#2}{}%
+ \ifnum\csname sseq@\sseq@classpattern @maxclasses\endcsname<\nodenum\relax
+ \sseq@error@xxxx{classpattern-too-many-classes}{(\partialcoord)}{\nodenum}{\sseq@classpattern}{\@xp\the\csname sseq@\sseq@classpattern @maxclasses\endcsname}
+ \sseq@breakfi
+ \fi
+ \sseq@processlabels
+%
+ \sseq@xminmax{\xcoord}{\ycoord}%
+ \sseq@yminmax{\xcoord}{\ycoord}%
+ \sseq@cleanup@obj{partcoord.(\partialcoord).numnodes}%
+ \sseq@cleanup@obj{partcoord.(\partialcoord).numnodespp}%
+ \ifnum\nodenum=\@ne
+ \sseq@obj@gdef{partcoord.(\partialcoord).numnodes}{0}%
+ \sseq@obj@gdef{partcoord.(\partialcoord).numnodespp}{1}%
+ \fi
+ \sseq@obj@xdef{partcoord.(\partialcoord).numnodes}{\nodenum}%
+ \sseq@obj@xdef{partcoord.(\partialcoord).numnodespp}{\the\numexpr\nodenum+1}%
+ \edef\classname{class.\coord[0]}%
+ \ifx\sseq@class@tag\pgfutil@empty\else
+ \sseq@obj@ifdef{partcoord.(\partialcoord).tag.\sseq@class@tagprefix\sseq@class@tag}{
+ \sseq@error@xx{class-tag-already-defined}{\sseq@class@tagprefix\sseq@class@tag}{(\partialcoord)}% could be warning
+ }{}
+ \sseq@cleanup@obj{class.\coord.tag}
+ \sseq@obj@xdef{class.\coord.tag}{\sseq@class@tagprefix\sseq@class@tag}
+ \sseq@cleanup@obj{partcoord.(\partialcoord).tag.\sseq@class@tagprefix\sseq@class@tag}
+ \sseq@obj@xdef{partcoord.(\partialcoord).tag.\sseq@class@tagprefix\sseq@class@tag}{\nodenum}%
+ \fi
+ \ifx\sseq@class@name\pgfutil@empty\else
+ \sseq@cleanup@obj{class.\classname.name}
+ \sseq@cleanup@obj{class.namedclass.\sseq@class@name}
+ \sseq@namehandler
+ \sseq@obj@xdef{class.\classname.name}{\sseq@class@name}
+ \sseq@obj@xdef{class.namedclass.\sseq@class@name}{\coordnopar}
+ \fi
+ \ifcsname sseq@class@showname\endcsname
+ \sseq@eval{\@nx\sseq@handleclassquotes{\sseq@obj{class.\classname.name}}{\sseq@class@showname}}
+ \fi
+ \sseq@pushstack@\coord
+%
+%
+ \sseq@obj@gdef{class.\coord.num}{0}% For \replaceclass
+ \sseq@obj@xdef{\classname.page}{\sseq@infinity}%
+ \sseq@obj@xodef{\classname.options}{\sseq@savedoptioncode}%
+ \sseq@obj@xodef{\classname.nodetext}{\sseq@classnodetext}%
+ \sseq@obj@xodef{\classname.nodetext.options}{\sseq@classnodetextoptions}%
+ \sseq@obj@xodef{\classname.labelnodes}{\sseq@classlabelnodes}%
+ \sseq@obj@xdef{class.\coord.x}{\xcoord}%
+ \sseq@obj@xdef{class.\coord.y}{\ycoord}%
+ \sseq@obj@gdef{\classname.dependencies}{}%
+ \sseq@obj@xdef{\classname.needstikz}{\ifsseq@needstikz\@nx\sseq@needstikztrue\fi}%
+ \@ifundefined{sseq@tempoffset}{}{%
+ \tikz@scan@one@point\sseq@setoffset\sseq@tempoffset
+ }%
+ \ifx\sseq@tooltip\pgfutil@empty\else
+ \sseq@obj@protectedxdef{\classname.tooltip}{\sseq@tooltip}
+ \fi
+%
+ \sseq@savedpaths@addclass{class.\coord}%
+ \sseq@obj@gdef{class.\coord.style}{}%
+ \sseq@breakpoint
+ \endgroup
+}
+\def\sseq@setoffset#1{\sseq@obj@gdef{\classname.offset}{\pgftransformshift{#1}}}
+
+\sseq@DeclareDocumentCommand\classoptions{or()}{%
+ \begingroup
+ \sseq@xsetthiscall{\classoptions\IfNoValueF{#1}{[\unexpanded{#1}]}\unexpanded{(#2)}}%
+ \IfNoValueT{#1}{\sseq@error@x{cmdoptions-without-options}{\string\classoptions}\sseq@break}% could be warning
+ \IfNoValueT{#2}{\sseq@break}%
+ \sseq@options@firstpassmode
+ \the\sseq@sseqstyle
+ \the\sseq@classstyle
+ \the\sseq@scope@toks
+ \sseq@options@normalmode
+ \let\sseq@processlabels\sseq@processlabels@default % Don't double dip on labels from the scope or classstyle
+ \sseq@processoptions{class}{#1}% Outputs result into \sseq@savedoptioncode
+%
+ \sseq@parsecoord\coord{#2}{\string\classoptions}%
+%
+ \sseq@processlabels
+%
+ \let\partialcoord\coord@partial
+ \@ifundefined{sseq@class@page}{%
+ \@ifundefined{sseq@gen}{
+ \@ifundefined{sseq@thepage}{
+ \edef\sseq@gen{\sseq@obj{class.\coord.num}}
+ }{
+ \sseq@obj@pagetogen{class.\coord}{\sseq@thepage} % stores in \sseq@gen
+ }
+ \let\sseq@genmax\sseq@gen
+ }{
+ \ifnum\sseq@gen<\z@
+ \edef\sseq@gen{\the\numexpr\sseq@obj{class.\coord.num}+\sseq@gen+1}
+ \fi
+ \@ifundefined{sseq@genmax}{\let\sseq@genmax\sseq@gen}{
+ \edef\sseq@genmax{\the\numexpr\sseq@obj{class.\coord.num}+\sseq@genmax+1}
+ }
+ }
+ }{
+ \@ifundefined{sseq@gen}{}{\sseq@error{classoptions-page-gen}}% This could be a warning
+ \sseq@class@getgen{\sseq@class@page}
+ \@ifundefined{sseq@class@pagemax}{
+ % If no max is present, apply options to all pages starting at specified minimum
+ \edef\sseq@genmax{\sseq@obj{class.\coord.num}}%
+ \let\sseq@class@pagemax\sseq@infinity % ensure if "page" is defined, "pagemax" is defined too
+ }{
+ \let\sseq@genmin\sseq@gen
+ \sseq@class@getgen{\sseq@class@pagemax}
+ \let\sseq@genmax\sseq@gen
+ \let\sseq@gen\sseq@genmin
+ }
+ \edef\sseq@class@page{\the\numexpr\sseq@class@page-\@ne}
+ \edef\sseq@class@pagemax{\the\numexpr\sseq@class@pagemax+\@ne}
+ }
+ \ifnum\sseq@gen=\m@ne
+ \edef\sseq@gen{\sseq@obj{class.\coord.num}}
+ \fi
+ \edef\classname{class.\coord[\sseq@gen]}
+ \ifsseq@keepchanges\else
+ \ifnum\sseq@thepagecount>\sseq@obj{\classname.page}\relax
+ \sseq@error@xxx{classoptions-already-dead}{\sseq@gen}{\coordname}{\sseq@obj{\classname.page}}
+ \sseq@breakfifi
+ \fi
+ \ifnum\sseq@gen>\z@
+ \ifnum\sseq@thepagecount>\sseq@obj{class.\coord[\the\numexpr\sseq@gen-\@ne].page}\relax\else
+ \sseq@error@xx{classoptions-not-yet-born}{\sseq@gen}{\coord}{\sseq@class@page}%
+ \sseq@breakfififi
+ \fi
+ \fi
+ \fi{}
+ \ifx\sseq@class@tag\pgfutil@empty\else
+ \sseq@obj@ifdef{partcoord.(\partialcoord).tag.\sseq@class@tagprefix\sseq@class@tag}{%
+ \sseq@error@nn{class-tag-already-defined}{\sseq@class@tagprefix\sseq@class@tag}{\sseq@partialcoord}% could be warning
+ }%
+ \sseq@cleanup@obj{class.\coord.tag}%
+ \sseq@obj@xdef{class.\coord.tag}{\sseq@class@tagprefix\sseq@class@tag}%
+ \sseq@cleanup@obj{partcoord.(\partialcoord).tag.\sseq@class@tagprefix\sseq@class@tag}%
+ \sseq@obj@xdef{partcoord.(\partialcoord).tag.\sseq@class@tagprefix\sseq@class@tag}{\sseq@index}%
+ \fi
+ \ifx\sseq@class@name\pgfutil@empty\else
+ \sseq@obj@ifdef{class.\classname.name}{
+ \sseq@error@nn{classoptions-class-already-named}{\coord}{\sseq@obj{class.\classname.name}}%could be warning
+ }{}
+ \sseq@cleanup@obj{class.\classname.name}
+ \sseq@cleanup@obj{class.namedclass.\sseq@class@name}
+ \sseq@namehandler
+ \sseq@obj@xdef{class.\classname.name}{\sseq@class@name}
+ \sseq@obj@xdef{class.namedclass.\sseq@class@name}{\coordnopar}
+ \fi
+ \ifcsname sseq@class@showname\endcsname
+ \sseq@eval{\@nx\sseq@handleclassquotes{\sseq@obj{class.\classname.name}}{\sseq@class@showname}}
+ \fi
+ \sseq@tempcount=\sseq@gen\relax
+ \advance\sseq@tempcount\m@ne
+ \loop
+ \advance\sseq@tempcount\@ne
+ \edef\classname{class.\coord[\the\sseq@tempcount]}
+ \sseq@cleanup@obj{\classname.options}
+ \sseq@classoptions@setup@pagerange
+ \sseq@classoptions@obj@addto@withpagerange{\classname.options}{\sseq@savedoptioncode}
+ %
+ \ifx\sseq@classnodetext\pgfutil@empty\else
+ \sseq@cleanup@obj{\classname.nodetext}
+ \sseq@classoptions@obj@addto@withpagerange{\classname.nodetext}{\sseq@classnodetext}
+ \fi
+ \ifx\sseq@classnodetextoptions\pgfutil@empty\else
+ \sseq@cleanup@obj{\classname.nodetext.options}
+ \sseq@classoptions@obj@addto@withpagerange{\classname.nodetext.options}{\sseq@classnodetextoptions}
+ \fi
+ \ifx\sseq@classlabelnodes\pgfutil@empty\else
+ \sseq@cleanup@obj{\classname.labelnodes}
+ \sseq@classoptions@obj@addto@withpagerange{\classname.labelnodes}{\sseq@classlabelnodes}
+ \fi
+ \@ifundefined{sseq@tempoffset}{}{
+ \sseq@cleanup@obj{\classname.offset}
+ \tikz@scan@one@point\sseq@setoffset\sseq@tempoffset
+ }
+ \ifnum\sseq@tempcount<\sseq@genmax\repeat
+ \sseq@breakpoint
+ \endgroup
+}
+\def\sseq@classoptions@setup@pagerange{%
+ \@ifundefined{sseq@class@page}{
+ \def\sseq@classoptions@obj@addto@withpagerange@{\sseq@obj@gaddto{\sseq@tempobj}}
+ }{
+ \def\sseq@temp##1{##1}
+ \ifnum\sseq@tempcount=\sseq@gen\relax
+ \sseq@eval{\@nx\pretocmd\@nx\sseq@temp{\@nx\ifnum\sseq@thepagecount>\sseq@class@page\relax}{}{%
+ \@nx\sseq@error@x{this-shouldnt-happen}{file main, function \string\sseq@classoptions@setup@pagerange}
+ }}%
+ \apptocmd\sseq@temp{\fi}{}{\sseq@error@x{this-shouldnt-happen}{file main, function \string\sseq@classoptions@setup@pagerange}}
+ \fi
+ \ifnum\sseq@tempcount=\sseq@genmax\relax
+ \sseq@eval{\@nx\pretocmd\@nx\sseq@temp{\@nx\ifnum\sseq@thepagecount<\sseq@class@pagemax\relax}{}{\@nx\sseq@error@internal{}}}
+ \apptocmd\sseq@temp{\fi}{}{\sseq@error@internal{this-shouldnt-happen}{file main, function \string\sseq@classoptions@setup@pagerange}}
+ \fi
+ \@xp\def\@xp\sseq@temp\@xp##\@xp1\@xp{\@xp{\sseq@temp{##1}}}
+ \pretocmd\sseq@temp{\sseq@obj@gaddto{\sseq@tempobj}}{}{\sseq@error@internal{this-shouldnt-happen}{file main, function \string\sseq@classoptions@setup@pagerange}}
+ \let\sseq@classoptions@obj@addto@withpagerange@\sseq@temp
+ }
+}
+\def\sseq@classoptions@obj@addto@withpagerange#1#2{%
+ \def\sseq@tempobj{#1}%
+ \@xp\sseq@classoptions@obj@addto@withpagerange@\@xp{#2}%
+}
+\def\sseq@class@getgen#1{
+ \bgroup
+ \ifnum\sseq@obj{class.\coord.num}>\z@
+ \sseq@eval{\unexpanded{\sseq@obj@pagetogen{class.\coord}}{#1}} % stores in \sseq@gen
+ \else
+ \def\sseq@gen{0}
+ \fi
+ \sseq@smuggle@macro\sseq@gen
+ \egroup
+}
+\sseq@DeclareDocumentCommand\replaceclass{or()}{%
+ \begingroup
+ \sseq@xsetthiscall{\string\replaceclass\IfNoValueF{#1}{[\unexpanded{#1}]}\unexpanded{(#2)}}
+ \sseq@options@firstpassmode
+ \the\sseq@sseqstyle
+ \the\sseq@classstyle
+ \the\sseq@scope@toks
+ \sseq@options@normalmode
+ \IfNoValueF{#1}{%
+ \sseq@processoptions{class}{#1}% Outputs result into \sseq@savedoptioncode
+ }%
+%
+ \sseq@parsecoord\coord{#2}{\string\replaceclass}
+ \sseq@processlabels
+%
+ \sseq@ifundefcoord\coord{\sseq@error@x{replaceclass-no-class}{\coordname}\sseq@break}{}
+ \sseq@ifdead\coord{}{\sseq@error@x{replaceclass-not-dead-yet}{\coordname}\sseq@break}
+ \ifsseq@keepchanges\else
+ \ifnum\the\numexpr\sseq@obj{class.\coord[\sseq@obj{class.\coord.num}].page}<\sseq@thepagecount\else
+ \edef\sseq@temp{\sseq@obj{class.\coord[\sseq@obj{class.\coord.num}].page}}
+ \sseq@error@xxx{replaceclass-no-effect-on-this-page}{\coord}{\sseq@temp}{\the\numexpr\sseq@temp+\@ne}% warning
+ \sseq@breakfifi
+ \fi
+ \fi
+ \let\partialcoord\coord@partial
+ \ifx\sseq@class@tag\pgfutil@empty\else
+ \sseq@obj@ifdef{partcoord.(\partialcoord).tag.\sseq@class@tagprefix\sseq@class@tag}{%
+ \sseq@error@nn{class-tag-already-defined}{\sseq@class@tagprefix\sseq@class@tag}{\sseq@partialcoord}% could be warning
+ }{}%
+ \sseq@cleanup@obj{partcoord.(\partialcoord).tag.\sseq@class@tagprefix\sseq@class@tag}%
+ \sseq@obj@xdef{partcoord.(\partialcoord).tag.\sseq@class@tagprefix\sseq@class@tag}{\nodenum}%
+ \fi
+ \ifx\sseq@class@name\pgfutil@empty\else
+ \sseq@cleanup@obj{class.\classname.name}
+ \sseq@cleanup@obj{class.namedclass.\sseq@class@name}
+ \sseq@namehandler
+ \sseq@obj@xdef{class.\classname.name}{\sseq@class@name}
+ \sseq@obj@xdef{class.namedclass.\sseq@class@name}{\coordnopar}
+ \fi
+ \ifcsname sseq@class@showname\endcsname
+ \sseq@eval{\@nx\sseq@handleclassquotes{\sseq@obj{class.\classname.name}}{\sseq@class@showname}}
+ \fi
+ \sseq@cleanup@obj{class.\coord.num}
+ \sseq@obj@inc{class.\coord.num}
+ \let\partialcoord\coord@partial
+ \ifx\sseq@class@tag\pgfutil@empty\else
+ \sseq@obj@ifdef{partialcoord.(\partialcoord).tag.\sseq@class@tagprefix\sseq@class@tag}{%
+ \sseq@error@nn{class-tag-already-defined}{\sseq@class@tagprefix\sseq@class@tag}{\sseq@partialcoord}% could be warning
+ }{}%
+ \sseq@obj@xdef{partialcoord.(\partialcoord).tag.\sseq@class@tagprefix\sseq@class@tag}{\nodenum}%
+ \fi
+ \edef\classname{class.\coord[\sseq@obj{class.\coord.num}]}
+%
+ \sseq@obj@xdef{\classname.page}{\sseq@infinity}
+ \sseq@obj@xodef{\classname.options}{\sseq@savedoptioncode}
+ \sseq@obj@xodef{\classname.nodetext}{\sseq@classnodetext}
+ \sseq@obj@xodef{\classname.nodetext.options}{\sseq@classnodetextoptions}
+ \sseq@obj@xodef{\classname.labelnodes}{\sseq@classlabelnodes}
+ \sseq@obj@gdef{\classname.dependencies}{}
+ \sseq@obj@xdef{\classname.needstikz}{\ifsseq@needstikz\@nx\sseq@needstikztrue\fi}
+ \@ifundefined{sseq@tempoffset}{}{\tikz@scan@one@point\sseq@setoffset\sseq@tempoffset}
+%
+ \sseq@breakpoint
+ \endgroup
+}
+\def\sseq@class@draw@ifpage#1{
+ \bgroup
+ \sseq@obj@pagetogen{#1}{\sseq@thepage} % sets \sseq@gen
+ \ifnum\sseq@gen>\m@ne % -1 means no class to print
+ \ifnum\sseq@obj{#1[\sseq@gen].page}=\sseq@thepagecount
+ \sseq@thispagetrue
+ \fi
+ \sseq@gsetthiscall{class #1}
+ \sseq@class@drawnode{#1[\sseq@gen]}
+ \fi
+ \egroup
+}
+% #1 -- class
+% #2 -- page
+% If there is a class #1 drawn on page #2, set \sseq@gen to be the generation of that class, otherwise set \sseq@gen to be -1.
+\def\sseq@obj@pagetogen#1#2{
+ \bgroup
+ \def\sseq@gen{-1}
+ \sseq@tempcount=\m@ne
+ \sseq@tempcountb=\sseq@obj{#1.num}\relax
+ \loop
+ \advance\sseq@tempcount\@ne
+ \ifnum\sseq@obj{#1[\the\sseq@tempcount].page}<#2\relax\else
+ \edef\sseq@gen{\the\sseq@tempcount}
+ \sseq@tempcount=\sseq@tempcountb\relax
+ \fi
+ \ifnum\sseq@tempcount<\sseq@tempcountb\repeat
+ \sseq@smuggle@macro\sseq@gen
+ \egroup
+}
+%%%
+%%% \d and \doptions
+%%%
+
+\sseq@DeclareDocumentCommand\d{oU(r()d()}{%
+ \sseq@d@{d}{#1}{#2}{#3}{#4}%
+}
+\sseq@DeclareDocumentCommand\doptions{oU(r()d()}{%
+ \begingroup
+ \IfNoValueT{#1}{
+ \sseq@xsetthiscall{\@xp\string\csname#1\endcsname\unexpanded{#2(#3)}\IfNoValueF{#4}{\unexpanded{(#4)}}}%
+ \sseq@error@x{cmdoptions-without-options}{\string\doptions}\sseq@break % could be warning
+ }
+ \sseq@d@{doptions}{#1}{#2}{#3}{#4}%
+ \sseq@breakpoint
+ \endgroup
+}
+\def\sseq@d@#1#2#3#4#5{%
+ \begingroup
+ \sseq@options@firstpassmode
+ \the\sseq@sseqstyle
+ \the\sseq@edgestyle
+ \the\sseq@differentialstyle
+ \the\sseq@scope@toks
+ \sseq@options@normalmode
+ \IfNoValueF{#2}{
+ \sseq@processoptions{differential}{#2}% Outputs result into \sseq@savedoptioncode
+ }
+ \sseq@xsetthiscall{\@xp\string\csname#1\endcsname\IfNoValueF{#2}{\unexpanded{[#2]}}\unexpanded{#3(#4)}\IfNoValueF{#5}{\unexpanded{(#5)}}}%
+ \sseq@ifintexpr{#3}{%
+ \sseq@tempcount=\numexpr#3\relax % this is a convenient way to get rid of spaces because #3 has to be a number
+ }{%
+ \sseq@error@n{d-invalid-page}{#3}\sseq@break%
+ }%
+ \@xp\sseq@dparsecoord\@xp{\the\sseq@tempcount}{#4}{#5}%
+ \sseq@eval{\unexpanded{\csname sseq@d@#1\endcsname{#2}}{\the\sseq@tempcount}}%
+ \sseq@breakpoint
+ \endgroup
+}
+
+% #1 -- options
+% #2 -- page
+% #3 -- source coordinate
+\def\sseq@d@d#1#2{%%
+ \sseq@d@setpageminrec{class.\source}{#2}{source}% automatically handles \sseq@cleanup@obj
+ \sseq@d@setpageminrec{class.\target}{#2}{target}
+%
+ \ifsseq@drawdifferential
+ \sseq@obj@gdef{d.#2\source\target.page}{#2}
+ \sseq@obj@gdef{d.#2\source\target.style}{}%
+ \sseq@obj@xdef{d.#2\source\target.source}{\source}
+ \sseq@obj@xdef{d.#2\source\target.target}{\target}
+ \sseq@obj@xdef{d.#2\source\target.options}{\ifsseq@needstikz\@nx\sseq@needstikztrue\fi\unexpanded\@xp{\sseq@savedoptioncode}}
+%
+ \sseq@savedpaths@adddifferential{d.#2\source\target}%
+ \else
+ \sseq@obj@gdef{d.#2\source\target.invisible}{}
+ \fi
+}
+\def\sseq@d@doptions#1#2{%
+ \sseq@obj@ifundef{d.#2\source\target.options}{\sseq@error@n{cmdoptions-feature-doesn't-exist}{differential}\sseq@break}{}%
+ \sseq@obj@ifdef{d.#2\source\target.invisible}{\sseq@error{doptions-invisible}\sseq@break}
+ \ifsseq@keepchanges\else
+ \@ifundefined{sseq@thepage}{}{
+ \ifnum#2=\sseq@thepagecount\else\ifnum\sseq@thepagecount=\z@\else
+ \sseq@error@n{doptions-no-effect-on-this-page}{#2}\sseq@breakfififi
+ \fi\fi
+ }%
+ \fi
+%
+ \sseq@cleanup@obj{d.#2\source\target.options}
+ \sseq@obj@xoaddto{d.#2\source\target.options}{\sseq@savedoptioncode}
+}
+
+% Some helper macros:
+% #1 -- class name for \sseq@obj
+% #2 -- page
+% #3 -- source or target for error handling purposes.
+\def\sseq@d@setpageminrec#1#2#3{% not really recursive.
+ \sseq@cleanup@obj{#1[\sseq@obj{#1.num}].page}
+ \sseq@cleanup@obj{#1[\sseq@obj{#1.num}].deathinfo}
+ \sseq@cleanup@obj{#1[\sseq@obj{#1.num}].deathline}
+ \sseq@d@setpageclass{#1}{#2}{#3}
+ \sseq@obj@map{#1[\sseq@obj{#1.num}].dependencies}{
+ \sseq@d@setpagemin{##1}{#2} % automatically handles cleanup
+ }
+}
+
+% #1 -- class name for \sseq@obj
+% #2 -- page
+% #3 -- source or target for error handling purposes.
+\def\sseq@d@setpageclass#1#2#3{
+ \edef\sseq@classgenname{#1[\sseq@obj{#1.num}]}
+ % If the class is dead, then it's only not an error if it died on the current page
+ \ifnum\sseq@obj{\sseq@classgenname.page}<\sseq@infinitycount
+ % If the page it died on is greater than this one, hit-wrong-order error
+ \ifnum\sseq@obj{\sseq@classgenname.page}>#2\relax
+ \let\sseq@deadclass@genname\sseq@classgenname
+ \sseq@preparestacktrace
+ \sseq@error@xxxx{d-hit-wrong-order}{#3}{\csname #3name\endcsname}{#2}{\the\sseq@temptoks}
+ \sseq@breakfifi
+ \fi
+ % If the page it died on is less than this one, class-already-hit error
+ \ifnum\sseq@obj{\sseq@classgenname.page}<#2\relax
+ \let\sseq@deadclass@genname\sseq@classgenname
+ \sseq@preparestacktrace
+ \sseq@error@xxxx{d-class-already-hit}{#3}{\csname #3name\endcsname}{#2}{\the\sseq@temptoks}
+ \sseq@breakfifi
+ \fi
+ \fi
+ % If the class has been replaced before, that's only okay if it was replaced on a previous page.
+ \ifnum\sseq@obj{#1.num}>\z@
+ \sseq@tempcount=\sseq@obj{#1.num}\relax
+ \advance\sseq@tempcount\m@ne
+ \ifnum\sseq@obj{#1[\the\sseq@tempcount].page}<#2\relax\else
+ \ifnum#2=\sseq@obj{#1[\the\sseq@tempcount].page}
+ \sseq@error@xxxx{d-hit-same-page-replaceclass}{#3}{\csname #3name\endcsname}{#2}{\sseq@obj{#1[\the\sseq@tempcount].deathinfo}}
+ \sseq@breakfififi
+ \else
+ \edef\sseq@deadclass@genname{#1[\the\numexpr\sseq@obj{#1.num}-\@ne]}
+ \sseq@preparestacktrace
+ \sseq@error@xxxx{d-hit-wrong-order}{#3}{\csname #3name\endcsname}{#2}{\the\sseq@temptoks}
+ \sseq@breakfififi
+ \fi
+ \fi
+ \fi
+ \sseq@obj@xdef{\sseq@classgenname.page}{#2}
+ \sseq@obj@xdef{\sseq@classgenname.deathinfo}{#3 of differential \sseq@thiscall\space on page #2}
+ \bgroup
+ \def\foreach{\@nx\@nx\@nx\foreach}
+ \protected\def\\{}
+ \let\sseq@possibleperiod\empty
+ \let\sseq@possibleperiodb\empty
+ \sseq@obj@xdef{\sseq@classgenname.deathlocation}{%
+ on input line \the\inputlineno\sseq@error@inforeachloop
+ }
+ \sseq@obj@xdef{\sseq@classgenname.deathline}{\the\inputlineno}
+ \sseq@tempiffalse
+ \edef\sseq@temp{\the\sseq@foreachcall}
+ \ifx\sseq@temp\pgfutil@empty\else\sseq@tempiftrue\fi
+ \ifx\sseq@restofstacktrace\pgfutil@empty\else\sseq@tempiftrue\fi
+ \sseq@obj@xdef{\sseq@classgenname.deathstacktrace}{%
+ \ifsseq@tempif
+ \unexpanded{\\\\}Stack trace for differential \sseq@thiscall\ that killed #3:\unexpanded{\\}%
+ \ifx\sseq@temp\sseq@empty\else\unexpanded{\ \ \ }\@nx\sseq@stack@unexpanded{\unexpanded\@xp{\the\sseq@foreachcall}}\fi
+ \unexpanded\@xp{\sseq@restofstacktrace}%
+ \fi
+ }
+ \egroup
+}
+
+\def\sseq@preparestacktrace{
+ \def\foreach{\@nx\foreach}
+ \edef\sseq@temp@i{\unexpanded\@xpthree{\sseq@obj{\sseq@deadclass@genname.deathline}}}
+ \edef\sseq@temp@ii{\the\inputlineno}
+ \ifx\sseq@temp@i\sseq@temp@ii
+ \sseq@temptoks\@xpthree{\sseq@obj{\sseq@deadclass@genname.deathinfo} (in the same \foreach loop)}
+ \else
+ \protected\def\\{}
+ \sseq@eval{\sseq@temptoks{\unexpanded\@xpthree{\sseq@obj{\sseq@deadclass@genname.deathinfo}}\space(\sseq@obj{\sseq@classgenname.deathlocation})}}
+ \sseq@e@addto@macro\sseq@errorinfo{\unexpanded\@xpthree{\sseq@obj{\sseq@deadclass@genname.deathstacktrace}}}
+ \fi
+}
+
+\def\sseq@d@setpagemin#1#2{
+ \ifnum\sseq@obj{#1.page}>#2\relax
+ \sseq@cleanup@obj{#1.page}
+ \sseq@obj@xdef{#1.page}{#2}
+ \fi
+}
+\def\sseq@differential@draw@ifpage#1{
+ \ifnum\sseq@thepagecount=\z@
+ \sseq@drawdifferential{#1}
+ \else
+ \ifnum\sseq@obj{#1.page}=\sseq@thepagecount\relax
+ \sseq@drawdifferential{#1}
+ \fi
+ \fi
+}
+\def\sseq@drawdifferential#1{
+ \bgroup
+ \sseq@eval{
+ \@nx\sseq@drawedge\sseq@obj{#1.source}\sseq@obj{#1.target}{differential}{%
+ \@xptwo\@nx\sseq@obj{#1.options}
+ }
+ }
+ \egroup
+}
+%%%
+%%% \structline and \structlineoptions
+%%%
+\sseq@DeclareDocumentCommand\structline{or()r()}{%
+ \begingroup
+ \sseq@xsetthiscall{\string\structline\IfNoValueF{#1}{\unexpanded{[#1]}}\unexpanded{(#2)(#3)}}%
+ \sseq@structline@main{structline}{#1}{#2}{#3}%
+}
+\sseq@DeclareDocumentCommand\structlineoptions{or()r()}{%
+ \begingroup
+ \sseq@xsetthiscall{\string\structlineoptions\IfNoValueF{#1}{\unexpanded{[#1]}}\unexpanded{(#2)(#3)}}%
+ \IfNoValueT{#1}{\sseq@error@x{cmdoptions-without-options}{\string\structlineoptions}\sseq@break@withcleanup}
+ \sseq@structline@main{structlineoptions}{#1}{#2}{#3}%
+ \sseq@breakpoint\@gobble\endgroup
+}
+\def\sseq@structline@main#1#2#3#4{%
+ \sseq@options@firstpassmode
+ \the\sseq@sseqstyle
+ \the\sseq@edgestyle
+ \the\sseq@structlinestyle
+ \the\sseq@scope@toks
+ \sseq@options@normalmode
+ \IfNoValueF{#2}{%
+ \sseq@processoptions{struct line}{#2}% Outputs result into \sseq@savedoptioncode
+ }%
+ \sseq@parsecoord\source{#3}{source of structure line}%
+ \sseq@parsecoord\target{#4}{target of structure line}%
+ \@ifundefined{sseq@structline@page}{%this is repeated in circleclasses
+ \def\sseq@pagemin{0}
+ \ifnum\sseq@obj{class.\source.num}>\z@
+ \edef\sseq@pagemin{\sseq@obj{class.\source[\the\numexpr\sseq@obj{class.\source.num}-1].page}}
+ \fi
+ \ifnum\sseq@obj{class.\target.num}>\z@
+ \edef\sseq@test{\sseq@obj{class.\target[\the\numexpr\sseq@obj{class.\target.num}-1].page}}
+ \ifnum\sseq@test>\sseq@pagemin\relax
+ \let\sseq@pagemin\sseq@test
+ \fi
+ \fi
+ }{\edef\sseq@pagemin{\the\numexpr\sseq@structline@page-\@ne}}
+ \csname sseq@structline@#1\endcsname
+ \sseq@breakpoint
+ \endgroup
+}
+\def\sseq@structline@structline{
+ \@ifundefined{sseq@structline@pagemax}{}{\sseq@error{structline-no-page-max}}% could be warning
+ \ifnum\sseq@pagemin<\sseq@obj{class.\source[\sseq@obj{class.\source.num}].page}\relax\else
+ \sseq@error{structline-stillborn}
+ \sseq@breakfi
+ \fi
+ \ifnum\sseq@pagemin<\sseq@obj{class.\target[\sseq@obj{class.\target.num}].page}\relax\else % If the \structline is dead before it is born, throw an error
+ \sseq@error{structline-stillborn}
+ \sseq@breakfi
+ \fi
+ \sseq@obj@ifdef{structline.\source\target.num}{%
+ \ifnum\sseq@obj{structline.\source\target[\sseq@obj{structline.\source\target.num}].page}=\sseq@infinitycount
+ \sseq@error@xx{structline-already-exists}{\sourcename}{\targetname}
+ \sseq@breakfi
+ \fi
+ \sseq@cleanup@obj{structline.\source\target.num}
+ \sseq@obj@inc{structline.\source\target.num}
+ }{
+ \sseq@obj@gdef{structline.\source\target.num}{0}
+ \sseq@savedpaths@addstructline{structline.\source\target}
+ }
+ \edef\sseq@structlinename{structline.\source\target[\sseq@obj{structline.\source\target.num}]}
+ \sseq@obj@xdef{\sseq@structlinename.page}{\sseq@infinity}
+ \sseq@obj@xdef{\sseq@structlinename.pagemin}{\sseq@pagemin}
+ \sseq@obj@xdef{\sseq@structlinename.source}{\source}
+ \sseq@obj@xdef{\sseq@structlinename.target}{\target}
+ \sseq@cleanup@obj{structline.\source\target.num}
+ \sseq@class@adddependence{class.\source}{\sseq@structlinename}% If the source or target is already dead, this will set structlinename.page
+ \sseq@class@adddependence{class.\target}{\sseq@structlinename}
+ \sseq@obj@xdef{\sseq@structlinename.options}{\ifsseq@needstikz\@nx\sseq@needstikztrue\fi\unexpanded\@xp{\sseq@savedoptioncode}}
+}
+\def\sseq@structline@structlineoptions{
+ \sseq@obj@ifundef{structline.\source\target.num}{
+ \sseq@error@n{cmdoptions-feature-doesn't-exist}{\structline}
+ \sseq@break
+ }{}
+ \@ifundefined{sseq@structline@page}{
+ \edef\sseq@gen{\sseq@obj{structline.\source\target.num}}
+ \let\sseq@genmax\sseq@gen
+ }{
+ \sseq@structline@getgen{\sseq@structline@page}
+ \@ifundefined{sseq@structline@pagemax}{%
+ % If no max is present, apply options to all pages starting at specified minimum
+ \edef\sseq@genmax{\sseq@obj{structline.\source\target.num}}%
+ \let\sseq@structline@pagemax\sseq@infinity
+ }{
+ \let\sseq@genmin\sseq@gen
+ \sseq@structline@getgen{\sseq@structline@pagemax}
+ \let\sseq@genmax\sseq@gen
+ \let\sseq@gen\sseq@genmin
+ }
+ \edef\sseq@structline@page{\the\numexpr\sseq@structline@page-1}
+ \edef\sseq@structline@pagemax{\the\numexpr\sseq@structline@pagemax+1}
+ }
+ \sseq@tempcount=\sseq@gen\relax
+ \advance\sseq@tempcount\m@ne
+ \loop
+ \advance\sseq@tempcount\@ne
+ \edef\sseq@structlinename{structline.\source\target[\the\sseq@tempcount]}
+ \sseq@cleanup@obj{\sseq@structlinename.options}
+ \ifsseq@needstikz
+ \sseq@obj@gaddto{\sseq@structlinename.options}{\sseq@needstikztrue}
+ \fi
+ \ifnum\sseq@tempcount=\sseq@gen\relax
+ \@ifundefined{sseq@structline@page}{}{
+ \edef\sseq@savedoptioncode{\@nx\ifnum\sseq@thepagecount>\sseq@structline@page\relax\unexpanded\@xp{\sseq@savedoptioncode}\@nx\fi}
+ }
+ \fi
+ \ifnum\sseq@tempcount=\sseq@genmax\relax
+ \@ifundefined{sseq@structline@pagemax}{}{
+ \edef\sseq@savedoptioncode{\@nx\ifnum\sseq@thepagecount<\sseq@structline@pagemax\relax\unexpanded\@xp{\sseq@savedoptioncode}\@nx\fi}
+ }
+ \fi
+ \sseq@obj@xoaddto{\sseq@structlinename.options}{\sseq@savedoptioncode}
+ \ifnum\sseq@tempcount<\sseq@genmax\repeat
+}
+\def\sseq@structline@getgen#1{
+ \bgroup
+ \sseq@tempcount=\sseq@obj{structline.\source\target.num}\relax
+ \ifnum\sseq@tempcount>\z@
+ \ifnum#1<\z@\relax
+ \@ifundefined{sseq@thepage}{
+ \ifnum\sseq@obj{structline.\source\target[\the\sseq@tempcount].page}<\sseq@infinitycount
+ \sseq@tempcount=\sseq@obj{structline.\source\target[\the\sseq@tempcount].page}\relax
+ \else
+ \advance\sseq@tempcount\m@ne
+ \sseq@tempcount=\sseq@obj{structline.\source\target[\the\sseq@tempcount].page}\relax
+ \advance\sseq@tempcount\@ne
+ \fi
+ }{
+ \sseq@tempcount=\sseq@thepagecount
+ }
+ \advance\sseq@tempcount\@ne
+ \advance\sseq@tempcount#1\relax
+ \fi
+ \sseq@eval{\unexpanded{\sseq@obj@pagetogen{structline.\source\target}}{\the\sseq@tempcount}} % stores in \sseq@gen
+ \else
+ \def\sseq@gen{0}
+ \fi
+ \sseq@smuggle@macro\sseq@gen
+ \egroup
+}
+\def\sseq@class@adddependence#1#2{
+ \edef\sseq@temp{\sseq@obj{#1.num}}
+ \sseq@d@setpagemin{#2}{\sseq@obj{#1[\sseq@temp].page}}% automatically handles cleanup
+ \sseq@cleanup@obj{#1[\sseq@temp].dependencies}
+ \sseq@obj@xaddto{#1[\sseq@temp].dependencies}{\@nx\\{#2}}
+}
+\def\sseq@structline@draw@ifpage#1{
+ \bgroup
+ \ifnum\sseq@thepagecount=\z@
+ \ifnum\sseq@obj{#1[0].pagemin}=\z@
+ \sseq@structline@draw{#1[0]}
+ \fi
+ \else
+ \sseq@obj@pagetogen{#1}{\sseq@thepage} % sets \sseq@gen
+ \ifnum\sseq@gen<\z@\else % negative sseq@gen means don't draw it
+ \ifnum\sseq@obj{#1[\sseq@gen].page}=\sseq@thepagecount
+ \sseq@thispagetrue
+ \fi
+ \ifnum\sseq@obj{#1[\sseq@gen].pagemin}<\sseq@thepagecount
+ \sseq@structline@draw{#1[\sseq@gen]}
+ \fi
+ \fi
+ \fi
+ \egroup
+}
+\def\sseq@structline@draw#1{\sseq@eval{\@nx\sseq@drawedge\sseq@obj{#1.source}\sseq@obj{#1.target}{structline}{\@nx\sseq@obj{#1.options}}}}
+
+
+
+
+
+
+\newcount\sseq@circleclassuid
+\sseq@DeclareDocumentCommand\circleclasses{or()r()}{
+ \begingroup
+ \def\sseq@keysfortikzprim{}
+ \IfNoValueF{#1}{
+ \sseq@processoptions{fit}{#1}
+ }
+ \sseq@parsecoord\coorda{#2}{first \@nx\circleclass class}
+ \sseq@parsecoord\coordb{#3}{second \@nx\circleclass class}
+%
+%
+ \ifsseq@keepchanges
+ \@ifundefined{sseq@fit@page}{% also in structline@main. TODO: refactor these chunks together?
+ \def\sseq@pagemin{0}
+ \ifnum\sseq@obj{class.\coorda.num}>\z@
+ \edef\sseq@pagemin{\sseq@obj{class.\coorda[\the\numexpr\sseq@obj{class.\coorda.num}-\@ne].page}}
+ \fi
+ \ifnum\sseq@obj{class.\coordb.num}>\z@
+ \edef\sseq@test{\sseq@obj{class.\coordb[\the\numexpr\sseq@obj{class.\coordb.num}-\@ne].page}}
+ \ifnum\sseq@test>\sseq@pagemin\relax
+ \let\sseq@pagemin\sseq@test
+ \fi
+ \fi
+ }{\edef\sseq@pagemin{\the\numexpr\sseq@fit@page-\@ne}}
+ \@ifundefined{sseq@fit@pagemax}{\let\sseq@pagemax\sseq@infinity}{\let\sseq@pagemax\sseq@fit@pagemax}
+ \else % Put it on the current page no matter what inside sseqpage
+ \let\sseq@pagemax\sseq@infinity\def\sseq@pagemin{-1}
+ \fi
+%
+%
+ \global\advance\sseq@circleclassuid\@ne
+ \edef\circleclassobjname{circleclass(\coordanopar)(\coordbnopar)\the\sseq@circleclassuid}
+%
+%
+ \sseq@obj@xodef{\circleclassobjname.options}{\sseq@savedoptioncode}
+ \sseq@obj@xodef{\circleclassobjname.tikzprimoptions}{\sseq@keysfortikzprim}
+ \sseq@obj@xdef{\circleclassobjname.fitnodes}{\@nx\tikz@lib@fit{(sseq{\coordanopar})(sseq{\coordbnopar})\sseq@fitalso}}
+ %\edef\temp{\@nx\sseq@circleclass@draw{\coorda@internalname}{\coordb@internalname}{\unexpanded\@xp{\sseq@savedoptioncode}}}
+ \sseq@savedpaths@xadd{\@nx\sseq@circleclass@draw@ifpage{\circleclassobjname}{\coordanopar}{\coordbnopar}}
+ \sseq@obj@xdef{\circleclassobjname.page}{\sseq@pagemax}
+ \sseq@obj@xdef{\circleclassobjname.pagemin}{\sseq@pagemin}
+ \@ifundefined{sseq@fit@pagemax}{
+ \ifsseq@keepchanges
+ \sseq@class@adddependence{class.\coorda}{\circleclassobjname}% If the source or target is already dead, this will set structlinename.page
+ \sseq@class@adddependence{class.\coordb}{\circleclassobjname}
+ \fi
+ }{}
+ \sseq@breakpoint
+ \endgroup
+}
+
+\ifsseq@patchfit\else
+ \sseq@DeclareDocumentCommand\circleclasses{or()r()}{%
+ \sseq@warning{circleclasses-not-provided}
+ }
+\fi
+
+\def\sseq@circleclass@draw@ifpage#1#2#3{
+ \ifnum\sseq@thepagecount<\numexpr\sseq@obj{#1.page}+\@ne
+ \ifnum\sseq@obj{#1.page}=\sseq@thepagecount
+ \sseq@thispagetrue
+ \fi
+ \ifnum\sseq@obj{#1.pagemin}<\sseq@thepagecount
+ \sseq@circleclass@draw{#1}{#2}{#3}
+ \fi
+ \fi
+} \ No newline at end of file
diff --git a/Master/texmf-dist/tex/latex/spectralsequences/sseqmessages.code.tex b/Master/texmf-dist/tex/latex/spectralsequences/sseqmessages.code.tex
new file mode 100644
index 00000000000..c8fbbb1eb75
--- /dev/null
+++ b/Master/texmf-dist/tex/latex/spectralsequences/sseqmessages.code.tex
@@ -0,0 +1,508 @@
+%%
+%% Package: spectralsequences.sty version 1.0
+%% Author: Hood Chatham
+%% Email: hood@mit.edu
+%% Date: 2017-06-18
+%% License: Latex Project Public License
+%%
+%% File: sseqmessages.code.tex
+%% Exposes: Error message redirects?
+%%
+%% Set up fancy error messages
+%%
+
+
+
+%% The error handling system is build on top of l3msg. l3msg produces errors like:
+%%
+%% !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+%% !
+%% ! LaTeX error: "<package>/<error-name>"
+%% !
+%% ! <error message text>
+%% !
+%% ! See the <package> documentation for further information. % produced by \msg_see_documentation_text:n{<package>}
+%% !...............................................
+%%
+%% The user will see underneath it l.<line number> <text on line>
+%%
+%% Unfortunately, if the error is in a \foreach statement, the user will only see the final line of the foreach loop, often just the close brace.
+%% It's impossible to tell from this where in the \foreach the error occurred. Similar problems occur if the command is inside a user command.
+%%
+%% We're going to modify this file to improve the situation.
+%%
+%% If the command is in a forloop or a user command I want to:
+%% -- annotate the error with the command that caused it, or the previous command if the error occurred before I can know what the current command looks like.
+%% -- present a stack trace to inform the user where exactly the problem occurred
+%%
+%%
+%% We automatically print the annotation and stack trace at the end of all l3msg messages by hooking into \msg_see_documentation_text:n.
+%% The annotation and stack trace are prepared by a command \sseq@error@setup which we hook into the beginning of the latex3 message processing code.
+%%
+%% Here's an example of the result:
+%%
+%% !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+%% !
+%% ! sseqpages error: "index-too-large"
+%% !
+%% ! Index '-3' provided for target of structure line is too large -- only 1
+%% ! classes exist at position (32,8).
+%% !
+%% ! (Error occurred during call "\structline(16,-1,-1)(16,0,-3)", in the % This is the annotation
+%% ! \foreach block that ends on line 158, with variable values: \n = 2.) % it's stored in \sseq@error@annotation
+%% !
+%% ! Stack trace: % This is the stack trace
+%% ! \towergroupb (8*\n ,4*\n ) % Produced by \sseq@printstacktrace
+%% ! \foreach \n in {2,3,4}
+%% !
+%% ! See the sseqpages documentation for further information.
+%% !
+%% ! Type <return> to continue.
+%% !...............................................
+
+
+\def\sseq@protecterror#1{\@nx\sseq@protecterror\unexpanded{{#1}}}
+
+% Stack, thiscall, foreachcall.
+% Here we record what the user has said (as best we can tell)
+\newtoks\sseq@thiscalltoks
+\def\sseq@thiscall{\the\sseq@thiscalltoks}
+\def\sseq@setthiscall#1{\sseq@seterrorannotation{call}\sseq@thiscalltoks{#1}}
+\def\sseq@esetthiscall#1{\sseq@seterrorannotation{call}\sseq@eval{\sseq@thiscalltoks{#1}}}
+\def\sseq@gsetthiscall{\sseq@seterrorannotation{call}\global\sseq@thiscalltoks}
+\def\sseq@xsetthiscall#1{\sseq@eval{\@nx\sseq@gsetthiscall{#1}}}
+\def\sseq@xsetlastcall#1{\sseq@eval{\global\sseq@thiscalltoks{#1}}}
+
+\def\sseq@usermacro@esetthiscall#1{\sseq@eval{\sseq@thiscalltoks{#1}}} % Don't set \sseq@error@annotation@call
+
+\newtoks\sseq@foreachcall
+\newtoks\sseq@topofstacktrace
+\sseq@topofstacktrace{}
+\def\sseq@restofstacktrace{}
+
+\def\sseq@pushstacktrace#1{
+ \edef\sseq@temp{\the\sseq@topofstacktrace}
+ \ifx\sseq@temp\pgfutil@empty\else
+ \edef\sseq@restofstacktrace{\unexpanded{\\\ \ \ }\@nx\sseq@stack@unexpanded{\the\sseq@topofstacktrace}\unexpanded\@xp{\sseq@restofstacktrace}}
+ \fi
+ \sseq@topofstacktrace{#1}
+}
+\def\sseq@opushstacktrace#1{\@xp\sseq@pushstacktrace\@xp{#1}}
+\def\sseq@stack@unexpanded#1{\@nx\sseq@stack@unexpanded\unexpanded{{#1}}}
+
+
+
+% Positional information about the error:
+% Lengths are five more than the correct length to account for the fact that the line starts with !<space> and to accommodate two quote characters and a comma.
+\def\sseq@error@annotation@aftercall{\\\\Error occurred after call\sseq@printthiscall\sseq@error@inforeachloop}
+\chardef\sseq@error@annotation@length@aftercall=34
+\def\sseq@error@annotation@call{\\\\Error occurred during call\sseq@printthiscall\sseq@error@inforeachloop}
+\chardef\sseq@error@annotation@length@call=33
+\def\sseq@error@annotation@atbeginforeach{\\\\Error occurred at the beginning of \string\foreach\ statement\sseq@printthiscall\sseq@error@inforeachloop}
+\chardef\sseq@error@annotation@length@atbeginforeach=60
+\def\sseq@error@annotation@atbeginusercmd{\\\\Error occurred at the beginning of user command\sseq@printthiscall\sseq@error@inforeachloop}
+\chardef\sseq@error@annotation@length@atbeginusercmd=54
+
+\def\sseq@seterrorannotation@drawing#1#2#3#4#5{%
+ \def\sseq@error@annotation{\\\\Error occurred while drawing class (#2,#3,#4)\ifnum#5>0 \space which has been replaced #5 time\ifnum#5>1s\fi\fi.
+ Look for a \ifnum#5>0\string\replaceclass\else\string\class\fi\space command that makes a class at that position.
+ Also make sure to check any \@nx\classoptions commands that could be the culprit.}%
+}
+
+\def\sseq@seterrorannotation#1{%
+ \@xp\let\@xp\sseq@error@annotation\csname sseq@error@annotation@#1\endcsname
+ \@xp\let\@xp\sseq@error@annotation@length\csname sseq@error@annotation@length@#1\endcsname
+}
+
+\sseq@seterrorannotation{aftercall}
+
+
+\def\sseq@error@inforeachloop{\sseq@possibleperiod}
+\def\sseq@error@inforeachloop@active{\sseq@possiblecomma in \foreach block with variable values:\sseq@for@printvars\sseq@possibleperiodb}
+\def\sseq@error@setup@errorinfo{}% Changed during \foreach and user commands
+
+\def\sseq@possiblecomma{,\space}
+\def\sseq@possibleperiod{.}
+\def\sseq@possibleperiodb{.}
+
+
+\def\sseq@error@announcestacktrace{\\\\Stack trace:}
+\def\sseq@printstacktrace{ % Only prints rest of stack trace because top element is mentioned in annotation.
+ \ifx\sseq@restofstacktrace\pgfutil@empty\else
+ \sseq@error@announcestacktrace\sseq@restofstacktrace
+ \fi
+}
+
+% \sseq@error@setup happens before the error is reported, \sseq@error@cleanup at the end.
+
+\ExplSyntaxOn
+
+\def\sseq@error@setup@withinfo{
+ \bgroup
+ \def\foreach{\@nx\foreach}
+ \sseq@countthiscall
+ \ifnum\sseq@thiscallnumchars>\numexpr\l_iow_line_count_int-\sseq@error@annotation@length\relax
+ \def\sseq@printthiscall{:\\\@xp\iow_indent:n\@xp{\the\sseq@thiscalltoks}\\}
+ \let\sseq@possiblecomma\empty
+ \let\sseq@possibleperiod\empty
+ \fi
+ \let\sseq@stack@unexpanded\unexpanded
+ \sseq@error@setup@errorinfo
+ \sseq@error@hook
+}
+
+\def\sseq@error@setup@noinfo {\bgroup\def\foreach{\@nx\foreach}\let\sseq@stack@unexpanded\unexpanded\def\sseq@error@annotation{}\sseq@error@hook}
+\let\sseq@error@setup\sseq@error@setup@noinfo
+\def\sseq@error@cleanup{\egroup\sseq@errortrue} % If the error was thrown in NewDocumentCommand, we need to process it. Just used in sseqmacromakers.
+
+
+\def\sseq@printthiscall{\ "\the\sseq@thiscalltoks"}
+% make \exp_args:NNNf:
+\let \sseq_dummy:NNn \empty
+\cs_generate_variant:Nn \sseq_dummy:NNn {NNf}
+
+
+% Count the chars in thiscall
+% Detokenize handles the control words, but keeps the spaces as spaces. To count them properly, we lowercase them into 0's (any nonspace character would do just fine).
+\def\sseq@countthiscall{
+ \bgroup\lccode`\ =`\0\relax
+ \edef\temp{\detokenize\@xp{\the\sseq@thiscalltoks}}
+ \exp_args:Nf\lowercase{
+ \exp_args:NNNf\egroup
+ \edef\sseq@thiscallnumchars{
+ \exp_args:NNo\@nx\tl_count:n{\temp}
+ }
+ }
+}
+
+\ExplSyntaxOff
+
+
+\def\sseq@error@hook{} % \sseq@error@hook is just used once in the isalive error handling to set \protect to relax. Probably a better way to do that...
+\def\sseq@errorinfo{%
+ \sseq@error@annotation
+ \sseq@printstacktrace
+}
+
+
+
+\def\sseq@atbeginusermacro@msgsetup{%
+ \let\protect\empty % prevent issues if protected variables like \xmax are used as the loop max
+ \let\sseq@error@setup@errorinfo\sseq@error@setup@errorinfo@active % Install foreach error annotations
+ \let\sseq@error@setup\sseq@error@setup@withinfo
+ \sseq@opushstacktrace{\the\sseq@thiscalltoks}
+}
+
+\def\sseq@atbeginforeach@msgsetup{%
+ \let\protect\empty % prevent issues if protected variables like \xmax are used as the loop max
+ \let\sseq@error@build@foreachvarsinfo\sseq@error@build@foreachvarsinfo@active % Install stack annotation
+ \let\sseq@error@inforeachloop\sseq@error@inforeachloop@active % install message indicating foreach variable values
+ \let\sseq@error@setup\sseq@error@setup@withinfo
+ \sseq@foreachcall{\foreach} % Stack gets pushed at the beginning of the body of the foreach loop once we know what the call looks like
+}
+
+
+\def\sseq@error@setup@errorinfo@active{%
+ \edef\tempa{\the\sseq@thiscalltoks}\edef\tempb{\the\sseq@foreachcall}
+ \ifx\tempa\tempb % We're at the beginning of a for loop
+ \sseq@seterrorannotation{atbeginforeach}
+ \else
+ \edef\tempb{\the\sseq@topofstacktrace}
+ \ifx\tempa\tempb % we're at the beginning of a user macro
+ \sseq@seterrorannotation{atbeginusercmd}
+ \else
+ % The top of the stack trace doesn't get included in the stack trace because it is assumed to be
+ % mentioned in the annotation. Since we aren't at the beginning of the foreach or usercmd,
+ % that means it won't be mentioned. Push an empty thing onto the stack so the innermost \foreach or usercommand is mentioned.
+ \sseq@pushstacktrace{}
+ \fi
+ \fi
+}
+
+
+
+
+
+
+%%%
+%%% Set up l3msg Hooks
+%%%
+
+
+\ExplSyntaxOn
+\char_set_catcode_space:N\ % Needed to make pretocmd work -- there are always spaces after every command, and they need to be retokenized as spaces
+
+\def\sseqerrortowarning#1{ \msg_redirect_name:nnn { sseqpages } { #1 } { warning } }
+
+\def\sseq@error {\msg_error:nn {sseqpages}}
+\def\sseq@error@n {\msg_error:nnn {sseqpages}}
+\def\sseq@error@nn {\msg_error:nnnn {sseqpages}}
+\def\sseq@error@nnn {\msg_error:nnnnn {sseqpages}}
+\def\sseq@error@nnnn{\msg_error:nnnnnn{sseqpages}}
+\def\sseq@error@x {\msg_error:nnx {sseqpages}}
+\def\sseq@error@xx {\msg_error:nnxx {sseqpages}}
+\def\sseq@error@xxx {\msg_error:nnxxx {sseqpages}}
+\def\sseq@error@xxxx{\msg_error:nnxxxx{sseqpages}}
+\def\sseq@warning {\msg_warning:nn{sseqpages}}
+
+\def\sseq@newerror#1#2{\msg_new:nnn{sseqpages}{#1}{#2}}
+\def\sseq@newerror@internal#1#2{\msg_new:nnn{sseqpages}{#1}{Internal error: #2 \sseq@contactpackageauthor}}
+\edef\sseq@contactpackageauthor{Contact package author \sseq@authorname\space at \sseq@authoremail.}
+
+
+\cs_new_eq:NN \__sseq_hooked_msg_see_documentation_text:n \msg_see_documentation_text:n
+\cs_new_eq:NN \__sseq_hooked_msg_fatal_code:nnnnnn \__msg_fatal_code:nnnnnn
+\cs_new_eq:NN \__sseq_hooked_msg_error_code:nnnnnn \__msg_error_code:nnnnnn
+\cs_new_eq:NN \__sseq_hooked_msg_warning_code:nnnnnn \__msg_warning_code:nnnnnn
+\cs_new_eq:NN \__sseq_hooked_msg_info_code:nnnnnn \__msg_info_code:nnnnnn
+
+
+\cs_new:Npn \sseq@installmsghooks {%
+ \cs_set_eq:NN \errmessage \sseq@errmessage
+ \cs_set_eq:NN \msg_see_documentation_text:n \__sseq_hooked_msg_see_documentation_text:n
+ \cs_set_eq:NN \__msg_fatal_code:nnnnnn \__sseq_hooked_msg_fatal_code:nnnnnn
+ \cs_set_eq:NN \__msg_error_code:nnnnnn \__sseq_hooked_msg_error_code:nnnnnn
+ \cs_set_eq:NN \__msg_warning_code:nnnnnn \__sseq_hooked_msg_warning_code:nnnnnn
+ \cs_set_eq:NN \__msg_info_code:nnnnnn \__sseq_hooked_msg_info_code:nnnnnn
+}
+
+\sseq@newerror@internal{msg-patch-failed}{Failed to patch the latex 3 message system. The errors will not be as expressive.}
+
+\def\sseq@msgpatchfailed{
+ \msg_error:nn{sseqpages}{msg-patch-failed}
+ \def\sseq@installmsghooks{}
+ \sseq@break
+}
+
+\let\sseq@errmessage@std\errmessage
+\def\sseq@errmessage#1{\sseq@error@setup\let\\\iow_newline:\sseq@errmessage@std{#1\sseq@error@annotation}\sseq@error@cleanup}
+
+\pretocmd\__sseq_hooked_msg_see_documentation_text:n{\sseq@errorinfo}{}{\sseq@msgpatchfailed}
+
+
+
+\pretocmd\__sseq_hooked_msg_fatal_code:nnnnnn {\sseq@error@setup} {}{\sseq@msgpatchfailed}
+\pretocmd\__sseq_hooked_msg_error_code:nnnnnn {\sseq@error@setup} {}{\sseq@msgpatchfailed}
+%\pretocmd\__sseq_hooked_msg_warning_code:nnnnnn{\sseq@msg@setup} {}{\sseq@msgpatchfailed}
+%\pretocmd\__sseq_hooked_msg_info_code:nnnnnn {\sseq@msg@setup} {}{\sseq@msgpatchfailed}
+\apptocmd\__sseq_hooked_msg_fatal_code:nnnnnn {\sseq@error@cleanup}{}{\sseq@msgpatchfailed}
+\apptocmd\__sseq_hooked_msg_error_code:nnnnnn {\sseq@error@cleanup}{}{\sseq@msgpatchfailed}
+%\apptocmd\__sseq_hooked_msg_warning_code:nnnnnn{\sseq@error@cleanup}{}{\sseq@msgpatchfailed}
+%\apptocmd\__sseq_hooked_msg_info_code:nnnnnn {\sseq@error@cleanup}{}{\sseq@msgpatchfailed}
+
+\sseq@breakpoint
+
+
+
+%%%%
+%%%%
+%%%% Error message definitions
+%%%%
+%%%%
+
+
+%%
+%%
+%% checkdefinitions -- patch-failed errors
+%%
+%%
+\@ifpackagelater{tikz}{2015/07/08}{
+ \sseq@newerror@internal{pgfkeys-patch-failed}{Failed to patch the key value system. Setting all commands to do nothing and quitting. Your copy of tikz is newer than the version sseqpages was designed for and seems to be incompatible with core features.}
+ \sseq@newerror@internal{fit-patch-failed}{Failed to patch fit. \@nx\circleclasses won't work. Your copy of tikz is newer than the version sseqpages was designed for and seems to be incompatible with \string\circleclasses.}
+ \sseq@newerror@internal{foreach-patch-failed}{Failed to patch \string\foreach. The errors sseqpages provides will be less comprehensive. Your copy of tikz is newer than the version sseqpages was designed for and seems to be incompatible with parts of the error handling system.}
+ \sseq@newerror@internal{circleclasses-not-provided}{\@nx\circleclasses won't work because your copy of tikz is too new. Instead I'm doing nothing.}
+}{
+ \sseq@newerror{pgfkeys-patch-failed}{Failed to patch the key value system. Setting all commands to do nothing and quitting. Your copy of tikz is older than the version sseqpages was designed for and seems to be incompatible with core features. Update tikz!}
+ \sseq@newerror{fit-patch-failed}{Failed to patch fit. \@nx\circleclasses won't work. Your copy of tikz is older than the version sseqpages was designed for and seems to be incompatible with \string\circleclasses. Update tikz!}
+ \sseq@newerror{foreach-patch-failed}{Failed to patch \string\foreach. The errors sseqpages provides will be less comprehensive. Your copy of tikz is older than the version sseqpages was designed for and seems to be incompatible with parts of the error handling system.}
+ \sseq@newerror{circleclasses-not-provided}{\@nx\circleclasses won't work because your copy of tikz is too old. Instead I'm doing nothing. Update tikz!}
+}
+
+
+\def\sseq@pgfkeyspatchfailed {
+ \msg_critical:nn { sseqpages } { pgfkeys-patch-failed }
+}
+
+
+\sseq@newerror@internal{this-shouldnt-happen}{This branch of the code should be unreachable. Something really weird has happened. Error occurred in #1.}
+
+% Convexity thing
+\sseq@newerror{clip-not-convex}{The clip you provided to the "clip" option was not convex and the current edge intersects it more than two times. I'm not going to draw it.}
+
+
+%%
+%%
+%% macromakers
+%%
+%%
+\sseq@newerror{won't-override-builtin}{Macro '#1' is a sseqpages builtin and I won't override it. Try a different name.}
+\sseq@newerror{usermacro-not-free}{Macro '#1' has already been defined using \string\DeclareSseqCommand, \string\NewSseqCommand, \string\DeclareSseqGroup, or \string\NewSseqGroup. I am overriding it. If this is what you intended, you should either use \@nx\DeclareSseqGroup or \string\DeclareSseqCommand, which won't complain.}
+
+\sseq@newerror{macro-patch-failed}{Failed to patch macro '#1'. This is probably some annoying catcode issue. Try \@nx\tracingpatches to see more information about why the patch failed.}
+\sseq@newerror{usermacro-unsupported-argument-type}{Unsupported argument type '#1'. All argument types in the 2017/05/29 release of xparse are supported except for v, e, and E.}
+
+%%
+%%
+%% parsers
+%%
+%%
+\sseq@newerror{classpattern-already-defined}{Class pattern '#1' already defined. Overwriting it.}
+\sseq@newerror{classpattern-unexpected-token}{Unexpected token '#1' in class pattern definition. Skipping the definition.}
+\sseq@newerror{classpattern-missing-tokens}{Incomplete class pattern definition. Skipping the definition.}
+\sseq@newerror{classpattern-extra-coord-ignored}{Extra coordinate '#1' ignored. You probably forgot a semicolon.}
+\sseq@newerror{classpattern-too-few-coords}{Too few coordinates in row #1.}
+
+\sseq@newerror{classpattern-too-many-classes}{%
+ Too many classes in position #1. You are trying to add a #2th class, but the current class pattern is "#3" which only defines offset patterns for up to #4 classes.
+ If you need to have this many classes in this position, you can make your own class pattern with \string\sseqnewclasspattern, but you might want to consider alternatives like using one class to represent multiple generators in some way -- it is hard to make a diagram look good with large numbers of classes in one position.%
+}
+
+\sseq@newerror{invalid-coordinate}{Invalid #1coordinate\sseq@printerrortype.}
+\sseq@newerror{no-classes}{No classes yet exist in #1.}
+\sseq@newerror{index-too-large}{Index '#1' provided\sseq@printerrortype\ is too large -- only #2 classes exist at position #3.}
+\sseq@newerror{undefined-tag}{Index '#1' provided\sseq@printerrortype\ is not a valid integer expression or known tag in position #2.}
+\sseq@newerror{class-no-tag}{The class #1 has no tag so I cannot get it.}
+
+\sseq@newerror{class-extra-coords}{Too many coordinates. Ignoring the extra ones.}
+\sseq@newerror{named-coordinate-class}{You can't pass a named coordinate to \string\class.} % Probably not actually possible to obtain this error
+\sseq@newerror{d-no-degree}{%
+ You must specify the degree of your spectral sequence if you want to use the differential command \string\d.
+ Specify the degree by providing 'degree={f(\#1)}{g(\#1)}' as an option to '\string\begin{sseqdata}',
+ where f(\#1) and g(\#1) are formulas for the x and y degree of the \#1th page differential.%
+}
+\sseq@newerror{d-named-coord-two-indexes}{You provided a named class and two indexes, but the named class already comes with an index so you can only provide one more for the target. Ignoring the second index.}% should be a warning
+\sseq@newerror{d-target-index-target-coord}{You provided both a target index and a target coordinate, but this overdetermines the differential. Ignoring the target index.}
+\sseq@newerror{d-wrong-degree}{Differential does not respect grading. The target should be in position #1 but instead it is #2 in position #3.}
+
+\sseq@newerror{index-ignored} {The coordinate #1 is not a class, but it has an index '#3'. Ignoring the index and treating it as the literal position #2.}
+\sseq@newerror{anchor-ignored} {The coordinate #1 is not a class, but it has an anchor '#3'. Ignoring the anchor and treating it as the literal position #2.}
+\sseq@newerror{invalid-tikz-coord}{The coordinate #1 does not refer to a tikz class but its #2 coordinate is not valid \string\pgfmathparse\ input.}
+
+
+%%
+%%
+%% loadstore
+%%
+%%
+\sseq@newerror{illegal-add-background-mode}{\string#1 occurred in background mode.} % Should be impossible to trigger
+
+%%
+%%
+%% keys
+%%
+%%
+
+\def\sseq@possiblecurrentvalue{\ifx\pgfkeyscurrentvalue\pgfkeysnovalue@text\else=\pgfkeyscurrentvalue\fi}
+\def\sseq@possiblecurrentvaluemean{\ifx\pgfkeyscurrentvalue\pgfkeysnovalue@text\else={\@xp\sseq@macrogobble\meaning\pgfkeyscurrentvalue}\fi}
+
+\sseq@newerror{option-illegal}{%
+ You said '#1\sseq@possiblecurrentvalue', but the option '#1' is
+ illegal in the sseqdata and sseqpage environments#3.%
+}
+\sseq@newerror{option-illegal-as-global}{%
+ You passed '#1\sseq@possiblecurrentvalue' as a global option, but option '#1' is illegal as a global option.%
+}
+\sseq@newerror{option-global-only}{%
+ You said '#1\sseq@possiblecurrentvaluemean', but the option '#1' is
+ only allowed as a global option (as in '\string\begin{sseqdata}[#1\sseq@possiblecurrentvaluemean]'
+ or '\string\begin{sseqpage}[#1\sseq@possiblecurrentvaluemean]').%
+}
+
+% Applies to name and page, and saying "sseqs={name=somename}" is just a bad idea.
+\sseq@newerror{option-no-default-allowed}{%
+ You cannot set a default value for '#1'.% Try \@nx\sseqset{sseqs={#1\ifx\pgfkeyscurrentvalue\pgfkeysnovalue@text\else=\pgfkeyscurrentvalue\fi}}.%
+}
+\sseq@newerror{option-tikz-prims-only}{%
+ You can only use '#1' as an option for tikz primitives, not for \@nx\class, \@nx\replaceclass, \@nx\classoptions, \@nx\d, \@nx\doptions, \@nx\structline, or \@nx\structlineoptions.%
+}
+
+\sseq@newerror{det-one-after-scale}{You cannot use the option '#1\ifx\pgfkeyscurrentvalue\pgfkeysnovalue@text\else=\pgfkeyscurrentvalue\fi' as a global option after using 'xscale', 'yscale', or 'scale'. Please move '#1\ifx\pgfkeyscurrentvalue\pgfkeysnovalue@text\else=\pgfkeyscurrentvalue\fi' before any scaling options.}
+\sseq@newerror{negative-scale}{You said '#1scale=#2' as a global option, but scaling by negative numbers is not allowed as a global option. Instead, please use the option '#1mirror', and then scale by the absolute value.}
+
+\sseq@newerror{illegal-transform}{%
+ You said '#1\ifx\pgfkeyscurrentvalue\pgfkeysnovalue@text\else=\pgfkeyscurrentvalue\fi', but
+ no coordinate transforms are allowed in the body of sseqpages or sseqdata other than shifts by unit-free integers
+ except as options for tikz primitives or for scopes that only contain tikz primitives. If you need a coordinate transformation,
+ first use the option 'standard parse'.%
+}
+
+\sseq@newerror{unknown-key}{I do not know the key "\pgfkeyscurrentname".}
+\sseq@newerror{unknown-global}{Undefined global option '\pgfkeyscurrentname\@xp\ifx\pgfkeyscurrentvalue\pgfkeysnovalue\else=\pgfkeyscurrentvalue\fi'.}
+
+\sseq@newerror{scope-quotes}{Quotes are not allowed as options to a scope.}
+\sseq@newerror{tikz-edge-quotes}{If you want to use quotes on a tikz edge, please provide it directly to the 'to' command e.g., \@nx\draw (0,0) to["hi"] (1,0);}
+
+\sseq@newerror{change-style-data}{It's pointless to use 'change #1s' in the sseqdata environment. Try '#1s={##1}' instead.}
+\sseq@newerror{change-style-standalone}{It's pointless to use 'change #1s' in a standalone sseqpage environment. Try '#1s={##1}' instead.}
+\sseq@newerror{page-update-existing}{Option 'update existing' is only for the sseqdata environment.}
+\sseq@newerror{page-no-name}{You can't specify a page but no name.}
+\sseq@newerror{keep-changes-no-name}{Option 'keep changes' is only for named spectral sequences.}
+\sseq@newerror{keep-changes-sseqdata}{Option 'keep changes' is only for the sseqpage environment.}
+\sseq@newerror{unknown-grid}{Undefined grid style '#1'.}
+\sseq@newerror{unknown-class-pattern}{Unknown class pattern '\sseq@classpattern'.}
+\sseq@newerror{class-placement-shift}{Shifts are illegal in the transformations applied in "class placement" key. If you want to shift your nodes, use \string\sseqnewclasspattern.} % #1 <- x shift, #2 <- shift amount
+\sseq@newerror{do-command-failed}{\string\sseq@pgfkeysdocommand{#1}{#2} failed.}
+
+\sseq@newerror{standard-parse}{You cannot use \string#1 inside a scope that has either the background key or coordinate transformations other than integer shifts.}
+
+%%
+%%
+%% main
+%%
+%%
+
+\sseq@newerror{env-inside-tikz}{#1 environment started inside tikz.}
+\sseq@newerror{env-inside-sseq}{#1 environment started inside other sseq environment.}
+\sseq@newerror{env-data-no-name}{Every 'sseqdata' environment must have a name. Specify one by saying 'name=your sseq name'.}
+\sseq@newerror{env-data-already-exist}{A spectral sequence with the name '#1' already exists; updating it. If you want to add to an already existing spectral sequence, please pass the option 'update existing'.} % warning
+\sseq@newerror{env-page-not-exist}{No spectral sequence named '#1' exists. Making a new one.} % warning
+
+
+\sseq@newerror{is-alive-illegal-here}{You can't use \@nx\isalive outside of a page constraint for a tikz primitive.}
+
+\sseq@newerror{no-range}{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.} % maybe warning?
+\sseq@newerror{index-larger-than-stack}{Index #1 is larger than the current stack depth #2.}
+\sseq@newerror{incomplete-tikz}{Incomplete tikz expression. What I have so far is #1 and I am stopping because I ran into #2. You probably forgot a semicolon.}
+
+
+\sseq@newerror{cmdoptions-only}{You can only use the '#1' option with #2, not with #3.} % warning
+\sseq@newerror{cmdoptions-without-options}{There is no reason to use \string#1 without giving options.} % warning
+\sseq@newerror{cmdoptions-feature-doesn't-exist}{There is no #1 of the form '\sseq@thiscall' so I can't add options to it.}
+
+\sseq@newerror{classoptions-already-dead}{Generation #1 of the class #2 perished on page #3 so there is no reason to add an option to it on page \sseq@thepage.}
+\sseq@newerror{classoptions-not-yet-born}{Generation #1 of the class #2 is not yet present on page \sseq@thepage\ so there is no reason to add an option to it.}
+\sseq@newerror{classoptions-page-gen}{Don't use both "page" and "generation" for the same \@nx\classoption command.} % warning
+\sseq@newerror{classoptions-class-already-named}{The class \coord\ already is named '\sseq@obj{class.\classname.name}'. Overwriting it. Use \@nx\nameclass if you want to give it a second name.}%warning
+\sseq@newerror{doptions-invisible}{Cannot add options to invisible differential.}
+\sseq@newerror{doptions-no-effect-on-this-page}{Adding an option to a differential on page #1 when the current page is \sseq@thepage\ and the 'keep changes' option is not present has no effect.}
+
+
+\sseq@newerror{class-tag-already-defined}{A class with tag '#1' is already defined in position #2. Overwriting it.} % warning
+
+\sseq@newerror{replaceclass-not-dead-yet}{I cannot replace the class at #1 because it seems to be alive and well.}
+\sseq@newerror{replaceclass-no-effect-on-this-page}{The class at #1 died on page #2 so replacing it only affects pages after #3, but the current page is \sseq@thepage.} % warning
+
+
+
+\sseq@newerror{d-invalid-page}{Invalid page '#1'.}
+\sseq@newerror{d-class-already-hit}{% #1 <-#3, #2 <-\csname #3name\endcsname, #3 <- #2, #4 <- \unexpanded\@xpthree{\sseq@obj{\sseq@temp.deathinfo}}
+ The #1 #2 of differential \sseq@thiscall\ on page #3 has already been the #4.
+ Use \string\replaceclass#2 before \sseq@thiscall.%
+}
+\sseq@newerror{d-hit-same-page-replaceclass}{%#1 <- #3, #2 <- \csname #3name\endcsname, #3 <- #2, #3 <-\sseq@obj{#1[\the\sseq@tempcount].deathinfo},
+ The #1 #2 of differential \sseq@thiscall\ was the #3.
+ If multiple differentials touch a class on the same page, they cannot be separated by a \@nx\replaceclass command.%
+}
+\sseq@newerror{d-hit-wrong-order}{%
+ The #1 #2 of differential \sseq@thiscall\ on page #3 has already been the #4.
+ First use the shorter differential, then \string\replaceclass#2, then the longer differential.%
+}
+
+
+\sseq@newerror{structline-no-page-max}{You cannot provide \@nx\structline with the option "page=min--max", only with "page=min".} %warning
+\sseq@newerror{structline-already-exists}{Cannot add a structline from #1 to #2 because such a structline already exists.}
+\sseq@newerror{structline-stillborn}{Structline dies before it is born. Perhaps you meant to specify a different source or target?}
+
+
+\ExplSyntaxOff
diff --git a/Master/texmf-dist/tex/latex/spectralsequences/sseqparsers.code.tex b/Master/texmf-dist/tex/latex/spectralsequences/sseqparsers.code.tex
new file mode 100644
index 00000000000..cbce7c25492
--- /dev/null
+++ b/Master/texmf-dist/tex/latex/spectralsequences/sseqparsers.code.tex
@@ -0,0 +1,1324 @@
+%%
+%% Package: spectralsequences.sty version 1.0
+%% Author: Hood Chatham
+%% Email: hood@mit.edu
+%% Date: 2017-06-18
+%% License: Latex Project Public License
+%%
+%% File: sseqparsers.code.tex
+%%
+%% Defines the parsers and input sanitizers. Also handles tikz primitive parsing and \isalive.
+%% ExplSyntaxOn for this whole file!
+
+\ExplSyntaxOn
+
+
+% Prevent \protect from causing trouble for \pgfmathparse
+\let\sseq@pgfmathparse@orig\pgfmathparse
+\def\sseq@pgfmathparse#1{\let\@@protect\protect\def\protect{}\sseq@pgfmathparse@orig{#1}\restore@protect}
+
+
+%%% ifpgfmathexpr
+% #1 -- expresion to test
+% #2 -- true case
+% #3 -- false case
+% This tests true if \pgfmathparse{#1} throws an error or not. Luckily, \pgfmathparse pipes its errors through \pgfmath@error so this is easy.
+\def\sseq@ifpgfmathexpr#1{
+ \bgroup
+ \let\protect\pgfutil@empty
+ \global\sseq@gtempiftrue
+ \def\pgfmath@error##1##2{\global\sseq@gtempiffalse}
+ \pgfmathparse{#1}
+ \ifpgfmathunitsdeclared
+ \xdef\sseq@mathresult{\pgfmathresult pt}
+ \else
+ \xdef\sseq@mathresult{\pgfmathresult}
+ \fi
+ \egroup
+ \ifsseq@gtempif
+ \@xp\@firstoftwo
+ \else
+ \@xp\@secondoftwo
+ \fi
+}
+
+
+% Test if single token input is a digit
+\def\sseq@ifdigit#1{
+ \ifodd0
+ \ifx#1 0 1 \else
+ \ifx#1 1 1 \else
+ \ifx#1 2 1 \else
+ \ifx#1 3 1 \else
+ \ifx#1 4 1 \else
+ \ifx#1 5 1 \else
+ \ifx#1 6 1 \else
+ \ifx#1 7 1 \else
+ \ifx#1 8 1 \else
+ \ifx#1 9 1 \else
+ \fi \fi \fi \fi \fi
+ \fi \fi \fi \fi \fi
+ \relax
+ \@xp\@firstoftwo
+ \else
+ \@xp\@secondoftwo
+ \fi
+}
+
+%%% 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.
+
+% 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
+ \char_set_catcode_other:N \ %
+ \sseq@tempcount\z@
+ \makeatletter
+ \scantokens{\sseq@ifintexpr@first{needsint}#1\sseq@nil}%
+ \@xp\egroup\next
+}
+\@xp\let\@xp\sseq@otherspace\c_catcode_other_space_tl % This has to be a let, no idea why
+%\def\sseq@ifintexpr#1{\@firstoftwo}
+
+% Gobble the space of catcode other that scantokens inserts after \sseq@ifintexpr@first
+\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
+
+\def\sseq@ifintexpr@#1{\def\sseq@ifintexpr@state{#1}\futurelet\testtok\sseq@ifintexpr@@}
+\def\sseq@ifintexpr@@{%
+ \ifx\testtok\bgroup%
+ \let\next\sseq@ifintexpr@false
+ \else
+ \ifx\testtok\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\testtok
+ \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\testtok\sseq@ifintexpr@@@fexpcs@@}
+\def\sseq@ifintexpr@@@fexpcs@@{
+ \ifx\testtok\bgroup
+ \@xp\sseq@ifintexpr@false
+ \else
+ \@xp\sseq@ifintexpr@@@@
+ \fi
+}
+
+
+
+%\exp_last_unbraced:Nf\sseq@ifintexpr@@
+
+
+% We can't just use \futurelet because "\let\testtok(" makes \testtok 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\testtok\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
+}
+
+% This has to eat the space
+%\bgroup\lccode`\*=`\ \lowercase{\egroup
+ \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}{\space}{\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}{\space}{\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}{\space}{\sseq@ifintexpr@{nointallowed}}
+
+%%
+%%
+%% New Class Pattern
+%%
+%%
+
+\newcount\sseq@cp@row
+\newcount\sseq@cp@n
+
+\def\sseqnewclasspattern#1#2{
+ \ifcsname sseq@#1xoffset1/1\endcsname\sseq@error@n{classpattern-already-defined}{#1}\fi % could be a warning
+ \begingroup
+ \def\sseq@name{#1}
+ \def\sseq@temp{}
+ \def\sseq@state{nocoord}
+ \sseq@cp@row=\@ne
+ \sseq@cp@n=\z@
+ \let\next\sseq@newclasspattern@
+ \sseq@newclasspattern@#2\sseq@nil
+}
+
+\def\sseq@newclasspattern@{
+ \@ifnextchar\bgroup{\sseq@error@n{classpattern-unexpected-token}{\{}}{\sseq@newclasspattern@processstate}
+}
+
+\def\sseq@newclasspattern@processstate{
+ \csname sseq@newclasspattern@processstate@\sseq@state\endcsname
+}
+
+\def\sseq@newclasspattern@processstate@xcoord#1{
+ \ifx#1,
+ \sseq@ifpgfmathexpr{\sseq@temp}{
+ \let\sseq@tempx\sseq@mathresult
+ \def\sseq@temp{}
+ \def\sseq@state{ycoord}
+ }{
+ \sseq@error{classpattern-not-integer-expression}
+ \let\next\sseq@newclasspattern@abort
+ }
+ \else
+ \ifx#1\sseq@nil
+ \sseq@error{classpattern-missing-tokens}
+ \let\next\endgroup
+ \else
+ \sseq@d@addto@macro\sseq@temp{#1}
+ \fi
+ \fi
+ \next
+}
+
+\def\sseq@newclasspattern@processstate@ycoord#1{
+ \ifx#1)
+ \sseq@ifpgfmathexpr{\sseq@temp}{% Need iffloatexpr =(
+ \let\sseq@tempy\sseq@mathresult
+ \def\sseq@temp{}
+ \def\sseq@state{nocoord}
+ \advance\sseq@cp@n\@ne
+ \ifnum\sseq@cp@n>\sseq@cp@row\relax
+ \sseq@error@x{classpattern-extra-coord-ignored}{(\sseq@tempx,\sseq@tempy)}
+ \else
+ \sseq@e@addto@macro\sseq@newclasspattern@dodefs{
+ \def\@xp\@nx\csname sseq@\sseq@name xoffset\the\sseq@cp@n/\the\sseq@cp@row\endcsname{\sseq@tempx}
+ \def\@xp\@nx\csname sseq@\sseq@name yoffset\the\sseq@cp@n/\the\sseq@cp@row\endcsname{\sseq@tempy}
+ }
+ \fi
+ }{
+ \sseq@error{classpattern-not-integer-expression}
+ \let\next\sseq@newclasspattern@abort
+ }
+ \else
+ \ifx#1\sseq@nil
+ \sseq@error{classpattern-missing-tokens}
+ \let\next\endgroup
+ \else
+ \sseq@d@addto@macro\sseq@temp{#1}
+ \fi
+ \fi
+ \next
+}
+
+\def\sseq@newclasspattern@processstate@nocoord#1{
+ \ifx#1(
+ \def\sseq@state{xcoord}
+ \else
+ \ifx#1;
+ \ifnum\sseq@cp@n=\sseq@cp@row\relax
+ \advance\sseq@cp@row\@ne
+ \sseq@cp@n=\z@
+ \else
+ \sseq@error@x{classpattern-too-few-coords}{\the\sseq@cp@row}
+ \let\next\sseq@newclasspattern@abort
+ \fi
+ \else
+ \ifx#1\sseq@nil
+ \let\next\sseq@newclasspattern@finish
+ \else
+ \sseq@error@n{classpattern-unexpected-token}{#1}
+ \let\next\sseq@newclasspattern@abort
+ \fi
+ \fi
+ \fi
+ \next
+}
+
+\def\sseq@newclasspattern@finish{
+ \ifnum\sseq@cp@n=\z@\relax
+ \advance\sseq@cp@row\m@ne
+ \else
+ \ifnum\sseq@cp@n=\sseq@cp@row\relax\else
+ \sseq@error@x{classpattern-too-few-coords}{\the\sseq@cp@row}
+ \let\sseq@newclasspattern@dodefs\empty
+ \fi
+ \fi
+ % This will make a definition even if the class pattern was rejected because of the too-few-coords error
+ % It doesn't matter though, because we don't use this to check for existence
+ \sseq@e@addto@macro\sseq@newclasspattern@dodefs{%
+ \chardef\@xp\@nx\csname sseq@\sseq@name @maxclasses\endcsname=\the\sseq@cp@row\relax
+ }%
+ \@xp\endgroup
+ \sseq@newclasspattern@dodefs
+
+
+}
+\def\sseq@newclasspattern@dodefs{}
+\def\sseq@newclasspattern@abort#1\sseq@nil{\endgroup}
+
+
+
+
+%%%%%% %%%%%%
+%% %%
+%% Coordinate Parsers %%
+%% %%
+%%%%%% %%%%%%
+
+% 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@infinitycount\@xp\@firstoftwo\else\@xp\@secondoftwo\fi}
+
+
+% 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}
+\let\sseq@relax\relax
+% The \sseq@relax is just to make \lastclass work. It has to pull an argument off the token stream to expandably check whether
+% it is an integer. However, without this \sseq@relax, \lastclass could appear as the last token of the edef, which is no good.
+\def\sseq@parsecoord@maincoord#1{\exp_last_unbraced:Nx\sseq@parsecoord@maincoord@{#1\sseq@relax}}
+\def\sseq@parsecoord@maincoord@#1\sseq@relax{%
+ \pgfutil@in@ \sseq@protecterror { #1 }
+ \ifpgfutil@in@
+ \bgroup
+ \sseq@restorefont
+ \let\sseq@protecterror\relax
+ \setbox0=\hbox{#1} % Trigger the error message
+ \egroup
+ \@xp\sseq@break
+ \else
+ \pgfutil@in@,{#1}
+ \ifpgfutil@in@
+ \sseq@parsecoord@maincoord@@#1,\sseq@nil
+ \else
+ \sseq@obj@ifdef{class.namedclass.\detokenize{#1}}{
+ \def\sourcename{#1}
+ \@xpthree\sseq@parsecoord@maincoord@named\sseq@obj{class.namedclass.#1}\sseq@nil
+ }{
+ \sseq@error{invalid-coordinate}\sseq@breakfifi
+ }
+ \fi
+ \fi
+}
+
+\def\sseq@parsecoord@maincoord@@#1,#2,#3\sseq@nil{%
+ \sseq@obj@ifdef{class.namedclass.\detokenize{#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@ifintexpr{#1}{
+ \sseq@ifintexpr{#2}{}{\sseq@error@n{invalid-coordinate}{y }\sseq@breakfifi} % breakfifi to get out of ifs from maincoord@
+ \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}%
+ }%
+ }{
+ \sseq@error@n{invalid-coordinate}{x }\sseq@breakfifi % breakfifi to get out of ifs from maincoord@
+ }
+ }%
+}%
+
+\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{}
+ \pgfkeys@spdef\sseq@rawindex{#3}
+ \def\sseq@index{#3}
+ \let\rawindex\sseq@rawindex
+ \let\index\sseq@index
+}
+
+\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@errortype@tikzprim{tikz ~ primitive}% This is sort of a silly hack, but this first error check shouldn't happen in a tikz primitive.
+\def\sseq@parsecoord@index{%
+ \sseq@obj@ifundef{partcoord.(\sseq@xycoord).numnodes}{
+ \ifx\sseq@errortype\sseq@errortype@tikzprim
+ \def\sseq@index{}% Communicates to \sseq@tikzprimitives@coords@maybeclass that this is not a class
+ \else
+ \sseq@error@x{no-classes}{(\sseq@xycoord)}\@xp\sseq@break
+ \fi
+ }{
+ \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}{%
+ \edef\sseq@rawindexeval{\the\numexpr\sseq@rawindex}
+ \ifnum\sseq@rawindexeval<\z@%
+ \edef\sseq@index{\the\numexpr\sseq@obj{partcoord.(\sseq@xycoord).numnodes} + \sseq@rawindex + \@ne\relax}%
+ \ifnum\sseq@index<\@ne
+ \sseq@error@xxx{index-too-large}{\sseq@rawindex}{\sseq@obj{partcoord.(\sseq@xycoord).numnodes}}{(\sseq@xycoord)}%
+ \edef\sseq@index{1}% or maybe I should break?
+ \fi
+ \else
+ \ifnum\sseq@rawindexeval>\sseq@obj{partcoord.(\sseq@xycoord).numnodes}\relax
+ \sseq@error@xxx{index-too-large}{\sseq@rawindex}{\sseq@obj{partcoord.(\sseq@xycoord).numnodes}}{(\sseq@xycoord)}%
+ \edef\sseq@rawindex{\sseq@obj{partcoord.(\sseq@xycoord).numnodes}}% or maybe I should break?
+ \fi
+ \edef\sseq@index{\the\numexpr\sseq@rawindex}
+ \fi
+ }{
+ \sseq@error@xx{undefined-tag}{\sseq@rawindex}{(\sseq@xycoord)}%
+ \def\sseq@index{1}%
+ }
+ }
+ \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
+ \@xp\sseq@parsecoord@index
+ \fi
+ \@xp\let\csname x\sseq@macroname#1\endcsname\sseq@xcoord
+ \@xp\let\csname y\sseq@macroname#1\endcsname\sseq@ycoord
+ \@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\def\csname\sseq@macroname#1nameunbraced\endcsname{#2}%
+ \@xp\edef\csname\sseq@macroname#1@internalname\endcsname{sseq{\sseq@xycoord,\sseq@index}}%
+}
+
+% EXPOSE: a wrapper around \sseq@parsecoord. Use full name of coordinate to avoid name class with sseq@parsecoord.
+\sseq@DeclareDocumentCommand \parsecoordinate { m r() }{%
+ \sseq@parsecoord{#1}{#2}{call of \string\parsecoord}%
+}
+
+% #1 -- coordinate
+\def\sseq@cparsecoord#1{%
+ \def\sseq@index{}
+ \sseq@parsecoord@maincoord{#1}%
+ \ifx\sseq@index\pgfutil@empty\else\sseq@error{named-coordinate-class}\fi% probably not possible to get this error
+ \ifx\sseq@restcoord\pgfutil@empty\else\sseq@error{class-extra-coords}\fi%
+ \let\partialcoord\sseq@xycoord
+ \let\xcoord\sseq@xcoord
+ \let\ycoord\sseq@ycoord
+ \edef\nodenum{\sseq@obj@ifundef{partcoord.(\partialcoord).numnodespp}{1}{\sseq@obj{partcoord.(\partialcoord).numnodespp}}}%
+ \edef\coordnopar{\xcoord,\ycoord,\nodenum}
+ \edef\coord{(\coordnopar)}%
+}
+
+
+% #1 -- page
+% #2 -- coordinate
+% #3 -- target coordinate or "No Value"
+\def\sseq@dparsecoord#1#2#3{%
+ \def\sseq@index{}%
+ \def\sseq@errortype{differential}%
+ \sseq@parsecoord@maincoord{#2}%
+ \ifx\sseq@index\pgfutil@empty
+ \edef\sseq@rawsindex{\@xp\sseq@dparsecoord@getxindex\@xp{\sseq@restcoord}}%
+ \@xp\pgfkeys@spdef\@xp\sseq@rawsindex\@xp{\sseq@rawsindex}
+ \edef\sseq@rawtindex{\@xp\sseq@dparsecoord@getyindex\@xp{\sseq@restcoord}}%
+ \@xp\pgfkeys@spdef\@xp\sseq@rawtindex\@xp{\sseq@rawtindex}
+ %
+ \let\sseq@rawindex\sseq@rawsindex
+ \def\sseq@errortype{source ~ of ~ differential}
+ \@xp\sseq@parsecoord@index % the \@xp is needed so that \sseq@break inside of parsecoordindex works properly.
+ \else
+ \edef\sseq@rawtindex{\@xp\sseq@dparsecoord@getxindex\@xp{\sseq@restcoord}}%
+ \@xp\pgfkeys@spdef\@xp\sseq@rawtindex\@xp{\sseq@rawtindex}
+ \edef\sseq@shouldbeempty{\@xp\sseq@dparsecoord@getyindex\@xp{\sseq@restcoord}}
+ \ifx\sseq@shouldbeempty\pgfutil@empty\else
+ \sseq@error{d-named-coord-two-indexes}
+ \fi
+ \fi
+ \let\sourcecoord\sseq@xycoord
+ \edef\source{(\sseq@xycoord,\sseq@index)}%
+ \ifx\sourcename\undefined
+ \edef\sourcename{(\sseq@xycoord\ifx\sseq@rawindex\pgfutil@empty\else,\sseq@rawindex\fi)}
+ \fi
+ \IfNoValueTF{#3}{
+ \ifsseq@hasdegree\else\sseq@error{d-no-degree}\@xp\sseq@break\fi
+ \sseq@eval{\edef\@nx\sseq@xycoord{\@nx\sseq@differential@gettarget{#1}{\sseq@xycoord}}}
+ \let\sseq@rawindex\sseq@rawtindex
+ \def\sseq@errortype{target ~ of ~ differential}
+ \sseq@parsecoord@index
+ \let\targetcoord\sseq@xycoord
+ \edef\target{(\sseq@xycoord,\sseq@index)}%
+ \edef\targetname{(\sseq@xycoord\ifx\sseq@rawindex\pgfutil@empty\else,\sseq@rawindex\fi)}
+ }{
+ \ifx\sseq@rawtindex\pgfutil@empty\else
+ \sseq@error{d-target-index-target-coord}
+ \fi
+ \sseq@parsecoord\target{#3}{differential}
+ \let\targetcoord\target@partial
+ \ifsseq@hasdegree
+ \ifsseq@strictdegree
+ \sseq@eval{\edef\@nx\sseq@checktarget{\@nx\sseq@differential@gettarget{#1}{\sourcecoord}}}
+ \ifx\sseq@checktarget\targetcoord\else
+ \sseq@error@xxx{d-wrong-degree}{(\sseq@checktarget)}{\targetname}{(\targetcoord)}
+ \fi
+ \fi
+ \fi
+ }
+}
+
+\def\sseq@differential@gettarget#1#2{\sseq@differential@gettarget@{#1}#2\sseq@nil}
+\def\sseq@differential@gettarget@#1#2,#3\sseq@nil{\the\numexpr#2+\sseq@targetx{#1}\relax,\the\numexpr#3+\sseq@targety{#1}\relax}
+
+\def\sseq@getfirsttwoelts#1,#2,#3\sseq@nil{#1,#2}
+\def\sseq@getdtarget#1#2#3{\sseq@eval{\edef\@nx#1{\@nx\sseq@differential@gettarget{#2}{\sseq@getfirsttwoelts#3,,\sseq@nil}}}}
+
+% Takes a comma separated list that can be empty, have one element, or two elements, returns first element (or empty if list is empty).
+\def\sseq@dparsecoord@getxindex#1{\sseq@dparsecoord@getxindex@#1,\sseq@nil}
+\def\sseq@dparsecoord@getxindex@#1,#2\sseq@nil{#1}
+% Takes a comma separated list that can be empty, have one element, or two elements, returns second element (or empty if less than two elements).
+\def\sseq@dparsecoord@getyindex#1{\sseq@dparsecoord@getyindex@#1,\sseq@nil}
+\def\sseq@dparsecoord@getyindex@#1,#2\sseq@nil{%
+ \sseq@ifempty{#2}{}{%
+ \sseq@removecomma#2\sseq@nil%
+ }%
+}
+
+\def\sseq@parsecoordinate#1#2{%
+ \sseq@parsecoord{#1}{#2}{call of \string\parsecoord}%
+}
+
+
+% EXPOSE: a wrapper around \sseq@parsecoord. Use full name of coordinate to avoid name class with sseq@parsecoord.
+\sseq@DeclareDocumentCommand \parsedifferential { m r() }{%
+ \sseq@dparsecoord{#1}{#2}{call of \string\parsecoord}%
+}
+
+% Expandable coordinate parsing for \isalive.
+% Doesn't do any error checking -- the error checking is done by passing it through \sseq@parsecoord in a non-\edef context.
+% #1 -- a callback. Must be a single command b/c it's an N in \exp_args
+% #2 -- the coordinate
+\cs_new:Npn \exp_last_unbraced:NNNf #1#2#3#4
+ {
+ \exp_after:wN #1
+ \exp_after:wN #2
+ \exp_after:wN #3 \tex_romannumeral:D -`0 #4
+ }
+
+\def\sseq@parsecoordex{\exp_last_unbraced:NNNf\sseq@parsecoordex@}
+\def\sseq@parsecoordex@#1(#2){\sseq@parsecoordex@@#1#2,\@nil}
+\def\sseq@parsecoordex@@#1#2,#3,#4\@nil{
+ \ifx&#4&
+ \exp_last_unbraced:NNo\sseq@parsecoord@indexex#1(\the\numexpr#2\@xp,\the\numexpr#3,1)
+ \else
+ \exp_args:NNo\sseq@parsecoord@indexex#1{\the\numexpr#2\@xp,\the\numexpr#3\@xp\relax\@xp}\@xp{\sseq@removecomma#4\sseq@nil}
+ \fi
+}
+
+
+% This is \sseq@parsecoord@index pared down as much as possible -- all error checking is removed because that will happen in a
+% \setbox0=\hbox{stuff} sequestered calculation that uses \sseq@parsecoord@index instead.
+% #1 -- callback which takes one argument -- the final coordinate in parentheses.
+% #2 -- x,y
+% #3 -- n
+\def\sseq@parsecoord@indexex#1#2#3{%
+ \sseq@obj@ifdef{partcoord.(#2).tag.\sseq@class@tagprefix#3}{% If the raw index is a tag
+ \exp_args:NNo\sseq@parsecoord@indexex@#1{\the\numexpr\sseq@obj{partcoord.(#2).tag.\sseq@class@tagprefix#3}}{#2}%
+ }{%
+ \ifnum\numexpr#3<0\space
+ \exp_args:NNo\sseq@parsecoord@indexex@#1{\the\numexpr\sseq@obj{partcoord.(#2).numnodes} + #3 + 1}{#2}%
+ \else
+ \exp_args:NNo\sseq@parsecoord@indexex@#1{\the\numexpr#3}{#2}%
+ \fi
+ }%
+}
+\def\sseq@parsecoord@indexex@#1#2#3{
+ #1(#3,#2)
+}
+
+
+
+
+%%%
+%%% The Stack
+%%%
+
+\sseq@addtostorelistlet\sseq@stacktop\relax
+\def\sseq@stackitem#1#2#3{\csname sseq.\sseq@thename.stack.#1.#3\endcsname} % gobble #2 which we added in for the error message
+\def\sseq@getstackentry#1{
+ \exp_args:No\sseq@getstackentry@{\sseq@stacktop}{#1}{#1} % Second copy of #1 for error message
+}
+
+\def\sseq@getstackentry@#1#2{
+ \ifnum#2=\z@\@xp\@firstoftwo\else\@xp\@secondoftwo\fi
+ {\sseq@stackitem{#1}}
+ {\@ifundefined{sseq.\sseq@thename.stack.#1.next}{\sseq@getstackentry@indextoolarge}{
+ \exp_args:Nf\sseq@getstackentry@{\csname sseq.\sseq@thename.stack.#1.next\@xp\endcsname\@xp}\@xp{\the\numexpr#2-1}
+ }}
+}
+
+\def\sseq@getstackentry@indextoolarge#1{\sseq@protecterror{\sseq@error@xx{index-larger-than-stack}{#1}{\the\sseq@stackdepth}}}
+
+\def\sseq@pushstack(#1){
+ \bgroup
+ \sseq@parsecoord\temp{#1}{}
+ \sseq@pushstack@\temp
+ \egroup
+}
+
+\def\sseq@pushstack@{\@xp\sseq@pushstack@@}
+
+\def\sseq@pushstack@@(#1,#2,#3){
+ \global\advance\sseq@stackdepth\@ne
+ \@xp\gdef\csname sseq.\sseq@thename.stack.\the\sseq@stackdepth.lastx\endcsname{#1}
+ \@xp\gdef\csname sseq.\sseq@thename.stack.\the\sseq@stackdepth.lasty\endcsname{#2}
+ \@xp\xdef\csname sseq.\sseq@thename.stack.\the\sseq@stackdepth.lastclass\endcsname{lastclass.\the\sseq@stackdepth}
+ \sseq@obj@gdef{class.namedclass.lastclass.\the\sseq@stackdepth}{#1,#2,#3}
+ \global\@xp\let\csname sseq.\sseq@thename.stack.\the\sseq@stackdepth.next\endcsname\sseq@stacktop
+ \xdef\sseq@stacktop{\the\sseq@stackdepth}
+}
+
+
+\newcount\sseq@userstacksavecount
+\def\sseq@savestack{
+ \global\advance\sseq@userstacksavecount\@ne
+ \sseq@savestack@name{usersave@\the\sseq@userstacksavecount}
+}
+\def\sseq@restorestack{
+ \sseq@restorestack@name{usersave@\the\sseq@userstacksavecount}
+ \global\advance\sseq@userstacksavecount\m@ne
+}
+
+\def\sseq@savestack@name#1{\sseq@obj@xdef{stack.save#1}{\sseq@stacktop}}
+
+\def\sseq@restorestack@name#1{\xdef\sseq@stacktop{\sseq@obj{stack.save#1}}}
+
+\def\sseq@lastx#1{
+ % \romannumeral is testing here whether #1 is a nonnegative integer
+ % if #1 consists of a single nonnegative integer then -0#1 will be turned into some nonpositive integer
+ % and romannumeral produces no output when handed a nonpositive integer, so the result will be empty.
+ % If #1 has any nonnumerical tokens or is negative, there will be left over stuff.
+ \@xp\sseq@ifempty\@xp{\romannumeral-0#1}{
+ \sseq@getstackentry{#1}{lastx}
+ }{
+ \sseq@getstackentry{0}{lastx}#1 % #1 isn't a number so put it back
+ }
+}
+\def\sseq@lasty#1{
+ \@xp\sseq@ifempty\@xp{\romannumeral-0#1}{
+ \sseq@getstackentry{#1}{lasty}
+ }{
+ \sseq@getstackentry{0}{lasty}#1 % #1 isn't a number so put it back
+ }
+}
+
+\def\sseq@lastclass#1{
+ \@xp\sseq@ifempty\@xp{\romannumeral-0#1}{
+ \sseq@getstackentry{#1}{lastclass}
+ }{
+ \sseq@getstackentry{0}{lastclass}#1 % #1 isn't a number so put it back
+ }
+}
+
+
+\def\sseq@nameclass#1(#2){
+ \bgroup
+ \sseq@parsecoord\coord{#2}{}
+ \sseq@cleanup@obj{class.namedclass.#1}
+ \sseq@obj@xdef{class.namedclass.#1}{\coordnopar}
+ \egroup
+}
+
+\def\sseq@tagclass#1(#2){%
+ \bgroup
+ \sseq@parsecoord\coord{#2}{}%
+ \sseq@obj@ifdef{partcoord.(\sseq@xycoord).tag.\sseq@class@tagprefix\sseq@class@tag}{%
+ \sseq@error@nn{class-tag-already-defined}{\sseq@class@tagprefix\sseq@class@tag}{(\sseq@xycoord)}% could be warning
+ }%
+ \sseq@cleanup@obj{class.\coord.tag}%
+ \sseq@obj@xdef{class.\coord.tag}{\sseq@class@tagprefix\sseq@class@tag}%
+ \sseq@cleanup@obj{partcoord.(\sseq@xycoord).tag.\sseq@class@tagprefix\sseq@class@tag}%
+ \sseq@obj@xdef{partcoord.(\sseq@xycoord).tag.\sseq@class@tagprefix\sseq@class@tag}{\sseq@index}%
+ \egroup
+}
+
+\def\sseq@gettag#1(#2){
+ \bgroup
+ \sseq@parsecoord\coord{#2}{}
+ \sseq@obj@ifdef{class.\coord.tag}{
+ \xdef#1{\sseq@obj{class.\coord.tag}}
+ }{
+ \sseq@error@n{class-no-tag}{(#2)}
+ }
+ \egroup
+}
+
+
+
+
+
+%%%%%%
+%%%
+%%% Tikz Primitives
+%%%
+%%%%%%
+
+% Replace a tikz command with a command that saves the command on savedpaths
+
+\def\sseq@modtikzcommands{%
+ \let\scope\sseq@scope
+ \let\endscope\sseq@endscope
+ \@xp\sseq@modtikzcommands@\sseq@tikzcommands\sseq@nil
+}
+\def\sseq@modtikzcommands@#1{%
+ \ifx#1\sseq@nil\else
+ \edef#1{\@xp\@nx\csname\sseq@macroname#1\space\endcsname\@nx#1}%
+ \@xp\let\csname\sseq@macroname#1\space\endcsname\sseq@defer@tikzcommand % This is just for error reporting so that it will say "Paragraph ended before \draw was complete"
+ \@xp\sseq@modtikzcommands@
+ \fi
+}
+
+\def\sseq@defer@tikzcommand#1{%
+ \begingroup
+ \let\sseq@isaliveprotect\sseq@isaliveprotect@protect
+ \sseq@callas{#1}%
+ \gdef\sseq@thepathsofar{#1[/utils/exec={\sseq@thesseqstyle\sseq@thetikzprimitivestyle\the\sseq@scope@toks\sseq@savedoptioncode}]}%
+ \xdef\sseq@whattheusersaid{\string#1}
+ \sseq@defer@tikzcommand@
+}
+
+\def\sseq@defer@tikzcommand@{%
+ \futurelet\testtok\sseq@defer@tikzcommand@@
+}
+
+\def\sseq@defer@tikzcommand@@{%
+ \ifx\testtok;
+ \let\next\sseq@defer@tikzcommand@finish
+ \else
+ \ifx\testtok[%
+ \let\next\sseq@defer@tikzcommand@option
+ \else
+ \ifx\testtok(%
+ \let\next\sseq@defer@tikzcommand@coord
+ \else
+ \@xp\ifx\space\testtok
+ \let\next\sseq@defer@tikzcommand@space
+ \else
+ \ifx\testtok\bgroup
+ \let\next\sseq@defer@tikzcommand@group
+ \else
+ \let\next\sseq@defer@tikzcommand@other
+ \fi
+ \fi
+ \fi
+ \fi
+ \fi
+ \sseq@call{\next}%
+}
+
+
+\def\sseq@defer@tikzcommand@option[#1]{%
+ \sseq@processoptions{tikz ~ primitives}{#1}%
+ \ifx\sseq@savedoptioncode\pgfutil@empty\else
+ \sseq@x@addto@macro\sseq@thepathsofar{[/utils/exec={\unexpanded\@xp{\sseq@savedoptioncode}}]}%
+ \fi
+ \sseq@g@addto@macro\sseq@whattheusersaid{[#1]}
+ \sseq@defer@tikzcommand@
+}
+
+\def\sseq@defer@tikzcommand@coord(#1){
+ \sseq@tikzprimitives@coord(#1)
+ \sseq@g@addto@macro\sseq@whattheusersaid{(#1)}
+ \sseq@defer@tikzcommand@
+}
+
+% When do groups occur in tikz commands? should we try to parse the inside?
+\def\sseq@defer@tikzcommand@group#1{
+ \sseq@g@addto@macro\sseq@whattheusersaid{{#1}}
+ \sseq@xprotected@addto@macro\sseq@thepathsofar{{#1}}%
+ \sseq@defer@tikzcommand@
+}
+
+\long\def\sseq@defer@tikzcommand@other#1{
+ \ifcat$\@xp\@gobble\string#1$ % test for control word. Won't catch active characters.
+ \@xp\use_i:nnn
+ \else
+ \@xp\ifx\csname sseq@illegalintikz@\string#1\endcsname\relax
+ \exp_last_unbraced:Nf \use_ii:nnn
+ \else
+ \exp_last_unbraced:Nf \use_iii:nnn
+ \fi
+ \fi{ % case i: it's not a control word. Just add it to the saved path
+ \sseq@g@addto@macro\sseq@whattheusersaid{#1}
+ \sseq@g@addto@macro\sseq@thepathsofar{#1}%
+ \sseq@defer@tikzcommand@
+ }{ % case ii: it's some different control word. Let's try full expanding it.
+ % note that here we cannot figure out what the user actually said, so we just have to report the f-expanded version.
+ \def\tempa{#1} % save the current value
+ \exp_last_unbraced:Nf \sseq@defer@tikzcommand@other@cs#1
+ }{ % case iii: it's an illegal control word (e.g., \class, \d, \begin, \end, ...) throw an error.
+ \sseq@error@xx{incomplete-tikz}{\unexpanded\@xp{\sseq@whattheusersaid}}{
+ \ifx\par#1 the ~ start ~ of ~ a ~ new ~ paragraph
+ \else \string#1\fi
+ }
+ \sseq@defer@tikzcommand@finish@ % finish@ doesn't try to grab a semicolon, which is good because there isn't one.
+ #1 % Reinsert the token that is causing us to stop
+ }
+}
+
+\def\sseq@defer@tikzcommand@other@cs#1{ % so we f expanded the control sequence, now we test if that did anything
+ \def\tempb{#1} % get the first f expanded token
+ \ifx\tempa\tempb
+ \@xp\@firstoftwo
+ \else
+ \@xp\@secondoftwo
+ \fi{% it didn't get expanded any more, so just add it to the stored stuff
+ \sseq@g@addto@macro\sseq@whattheusersaid{#1}
+ \sseq@g@addto@macro\sseq@thepathsofar{#1}
+ \sseq@defer@tikzcommand@
+ }{% it got expanded. Run it through the main loop again.
+ \sseq@defer@tikzcommand@#1
+ }
+}
+
+% Illegal control words:
+\long\def\sseq@setillegalcontrolwords#1{\sseq@setillegalcontrolwords@#1\sseq@nil}
+\long\def\sseq@setillegalcontrolwords@#1{
+ \ifx#1\sseq@nil\else
+ \@xp\def\csname sseq@illegalintikz@\string#1\endcsname{}
+ \@xp\sseq@setillegalcontrolwords@
+ \fi
+}
+
+% We missing anything here?
+\sseq@setillegalcontrolwords{
+ \class\classoptions\replaceclass\d\doptions\structline\structlineoptions\circleclasses
+ \savestack\restorestack\pushstack\nameclass\foreach\begin\end\par
+ \clip\coordinate\draw\fill\filldraw
+ \graph\matrix\node\path\pattern
+ \shade\shadedraw\useasboundingbox
+}
+
+
+\@xp\def\@xp\sseq@defer@tikzcommand@space\space{%
+ \sseq@g@addto@macro\sseq@thepathsofar{~}%
+ \sseq@g@addto@macro\sseq@whattheusersaid{~}
+ \sseq@defer@tikzcommand@
+}
+
+\def\sseq@defer@tikzcommand@finish;{
+ \sseq@g@addto@macro\sseq@whattheusersaid{;}
+ \sseq@defer@tikzcommand@finish@
+}
+
+% If the expression was incomplete, we'll jump here
+\def\sseq@defer@tikzcommand@finish@{
+ \sseq@g@addto@macro\sseq@thepathsofar{;}
+ \global\sseq@thiscalltoks\@xp{\sseq@whattheusersaid}
+ \ifx\sseq@pageconstraint\sseq@pageconstraint@true
+ \sseq@savedpaths@xadd{\unexpanded\@xp{\sseq@thepathsofar}}%
+ \else
+ \sseq@savedpaths@xadd{%
+ \@nx\sseq@tikzcommand@conditionaldraw{\unexpanded\@xp{\sseq@thepathsofar}}{\unexpanded\@xp{\sseq@pageconstraint}}
+ }%
+ \fi
+ \endgroup
+}
+
+
+\def\sseq@tikzcommand@conditionaldraw#1#2{%
+ \sseq@pgfmathparse@rescan{#2}%
+ \ifnum\pgfmathresult>\z@ #1 \fi
+}
+
+\def\sseq@pgfmathparse@rescan#1{\makeatletter\catcode`\&=12\relax\scantokens{\pgfmathparse{#1}}}
+
+%%% Coordinate parser, copied with huge simplifications from \tikz@@scan@@no@calculator, tikz.code.tex line 4994.
+%%% We don't need to handle any of the weird cases, we just need to know about them so we can give up and let tikz do the work later.
+% TODO: do same coordinate fixing for coordinates in calculations (yeah right! not even clear this is a good idea...)
+\def\sseq@tikzprimitives@coord(#1){
+ \begingroup
+ \let\next\sseq@tikzprimitives@coords@maybenamedclass
+ \ifsseq@tikzprims@integershift
+ \pgfutil@in@${#1}
+ \ifpgfutil@in@
+ \let\next\sseq@tikzprimitives@coords@handlemath
+ \else
+ \pgfutil@in@ :{#1}
+ \ifpgfutil@in@\else
+ \pgfutil@in@{intersection }{#1}
+ \ifpgfutil@in@\else
+ \pgfutil@in@|{#1}%
+ \ifpgfutil@in@\else
+ \pgfutil@in@,{#1}
+ \ifpgfutil@in@
+ \let\next\sseq@tikzprimitives@coords@maybeclass
+ \fi
+ \fi
+ \fi
+ \fi
+ \fi
+ \fi
+ \next{#1}
+ \endgroup
+}
+\def\sseq@tikzprimitives@coords@maybeclass#1{
+ \let\next\sseq@tikzprimitives@coords@notaclass % most branches do this.
+ % First check whether there are any of the protect "to be determined later" variables like \xmax, etc. If there are, it's not a class
+ \sseq@protected@edef\sseq@temp@i{#1}
+ \edef\sseq@temp@ii{#1}
+ \ifx\sseq@temp@i\sseq@temp@ii
+ \@xp\sseq@tikzprimitive@getcoord@anchor#1.\sseq@nil % puts coord into \sseq@tempcoord, anchor if any into \sseq@tempanchor
+ \exp_args:NNo\pgfutil@in@.{\sseq@tempanchornopt} % If there's an extra . in the "anchor", it's not an anchor, and this is not a class
+ \ifpgfutil@in@\else
+ \exp_args:NNo \pgfutil@in@,{\sseq@tempcoord} % If the . we used to delineate the "anchor" was in the x-coordinate, it's not an anchor and this is not a class
+ \ifpgfutil@in@
+ \exp_args:NNo \pgfutil@in@,{\sseq@tempanchornopt} % If there is a comma in the "anchor" it's not an anchor and this is not a class
+ \ifpgfutil@in@\else
+ \ifx\sseq@tempanchor\pgfutil@empty
+ \sseq@tempiftrue
+ \else % If there's an "anchor" we need to test whether the expression is a valid decimal coordinate. If it is, we're going to treat it as not a class
+ % outputs into sseq@tempif, sets sseq@tempiffalse if it IS valid math, b/c then we're not a anchor
+ \sseq@anchortrue % If this ends up getting handled as a tikz coordinate, we'll have to add an "anchor ignored" error
+ \sseq@tikzprimitives@testlastcoord@validmathexpression#1,\sseq@nil
+ \fi
+ \ifsseq@tempif
+ \@xp\sseq@tikzprimitives@ifintcoords\@xp{\sseq@tempcoord}{ % check we're all integer coordinates
+ \sseq@parsecoord\coord{\sseq@tempcoord}{tikz ~ primitive}%
+ \ifx\sseq@index\pgfutil@empty\else
+ \sseq@x@addto@macro\sseq@thepathsofar{(sseq{\sseq@removeparens\coord}\sseq@tempanchor)}% Okay, we're all set, it's a class
+ \let\next\@gobble % don't run \sseq@tikzprimitives@notaclass
+ \fi
+ }{}%
+ \fi
+ \fi
+ \fi
+ \fi
+ \fi
+ \next{#1}
+}
+
+% Sets tempiffalse if if the second coordinate IS a valid math expression -- then t
+\def\sseq@tikzprimitives@testlastcoord@validmathexpression#1,#2,#3\sseq@nil{
+ \sseq@ifpgfmathexpr{#2}{
+ \sseq@tempiffalse
+ }{
+ \sseq@tempiftrue
+ }
+}
+
+\def\sseq@tikzprimitives@coords@maybenamedclass#1{
+ \sseq@tikzprimitive@getcoord@anchor#1.\sseq@nil % puts coord into \sseq@tempcoord, anchor if any into \sseq@tempanchor
+ \sseq@protectedeval{\@nx\sseq@obj@ifdef{class.namedclass.\@nx\detokenize{\sseq@tempcoord}}}{% need this detokenize here to prevent it from throwing errors when there's a command inside...
+ \sseq@x@addto@macro\sseq@thepathsofar{(sseq{\sseq@obj{class.namedclass.\sseq@tempcoord}\sseq@tempanchor})}
+ }{
+ \sseq@tikzprimitives@coords@notaclass{#1}
+ }
+}
+
+\let\sseq@tikzprimitives@coords@maybeclass@save\sseq@tikzprimitives@coords@maybeclass
+
+
+\def\sseq@tikzprimitives@coords@notaclass#1{
+ \def\next{\sseq@tikzprimitives@coords@notaclass@leavetotikz{#1}}
+ \pgfutil@in@${#1}
+ \ifpgfutil@in@\else
+ \pgfutil@in@ :{#1}
+ \ifpgfutil@in@\else
+ \pgfutil@in@{intersection }{#1}
+ \ifpgfutil@in@\else
+ \pgfutil@in@|{#1}%
+ \ifpgfutil@in@\else
+ \pgfutil@in@,{#1}
+ \ifpgfutil@in@
+ \def\next{\sseq@tikzprimitives@coords@notaclass@handle{#1}}
+ \fi
+ \fi
+ \fi
+ \fi
+ \fi
+ \next
+}
+
+\def\sseq@tikzprimitives@coords@notaclass@leavetotikz#1{
+ \sseq@g@addto@macro\sseq@thepathsofar{(#1)}
+}
+
+\def\sseq@tikzprimitives@coords@notaclass@handle#1{
+ \ifsseq@anchor
+ % Still seems impossible to trigger this?
+ \sseq@error@xxx{anchor-ignored}{(#1)}{(\unexpanded\@xp{\sseq@tempcoord})}{\sseq@tempanchor}
+ \@xp\sseq@tikzprimitives@coords@notaclass@handle@\sseq@tempcoord,\sseq@nil
+ \else
+ \sseq@tikzprimitives@coords@notaclass@handle@#1,\sseq@nil
+ \fi
+}
+
+\def\sseq@tikzprimitives@coords@notaclass@handle@#1,#2,#3\sseq@nil{
+ \sseq@ifempty{#3}{
+ \let\sseq@index\pgfutil@empty
+ }{
+ \edef\sseq@index{,\unexpanded\@xp{\sseq@removecomma#3\sseq@nil}}
+ \edef\sseq@indexnocomma{\unexpanded\@xp{\sseq@removecomma#3\sseq@nil}}
+ }
+ \sseq@ifpgfmathexpr{#1}{
+ % Decide whether we can keep the result, which is stored in \sseq@mathresult
+ \protected@edef\sseq@tempa{#1}
+ \edef\sseq@tempb{#1}
+ \ifx\sseq@tempa\sseq@tempb
+ \let\sseq@tempx\sseq@mathresult
+ \else
+ \def\sseq@tempx{#1}
+ \fi
+ }{
+ \sseq@error@xx{invalid-tikz-coord}{(#1,#2\sseq@index)}{x}
+ \def\sseq@defer@tikzcommand@finish;{\endgroup}
+ }
+ \sseq@ifpgfmathexpr{#2}{
+ % Decide whether we can keep the result, which is stored in \sseq@mathresult
+ \protected@edef\sseq@tempa{#2}
+ \edef\sseq@tempb{#2}
+ \ifx\sseq@tempa\sseq@tempb
+ \let\sseq@tempy\sseq@mathresult
+ \else
+ \def\sseq@tempy{#2}
+ \fi
+ }{
+ \sseq@error@xx{invalid-tikz-coord}{(#1,#2\sseq@index)}{y}
+ \def\sseq@defer@tikzcommand@finish;{\endgroup}
+ }
+ \def\sseq@tempa{#1}
+ \ifx\sseq@index\pgfutil@empty\else
+ \sseq@error@xxx{index-ignored}{(\unexpanded{#1,#2}\unexpanded\@xp{\sseq@index})}{\unexpanded{(#1,#2)}}{\unexpanded\@xp{\sseq@indexnocomma}}
+ \fi
+ \sseq@xprotected@addto@macro\sseq@thepathsofar{(\sseq@tempx,\sseq@tempy)}
+}
+
+\def\sseq@tikzprimitives@ifintcoords#1{\sseq@tikzprimitives@ifintcoords@#1,\sseq@nil}
+\def\sseq@tikzprimitives@ifintcoords@#1,#2,#3\sseq@nil{%
+ \sseq@ifintexpr{#1}{%
+ \sseq@ifintexpr{#2}{%
+ \@firstoftwo
+ }{\@secondoftwo}%
+ }{\@secondoftwo}%
+}
+\def\sseq@tikzprimitives@coords@handlemath#1{\sseq@tikzprimitives@coords@handlemath@(#1)}
+\def\sseq@tikzprimitives@coords@handlemath@#1$#2$){\sseq@g@addto@macro\sseq@thepathsofar{#1$#2$)}}
+\def\sseq@tikzprimitive@getcoord@anchor#1.#2\sseq@nil{
+ \def\sseq@tempcoord{#1}
+ \ifx\sseq@nil#2\sseq@nil
+ \def\sseq@tempanchor{}
+ \def\sseq@tempanchornopt{}
+ \else
+ \edef\sseq@tempanchor{.\sseq@tikzprimitive@getcoord@anchor@eatdot#2}
+ \edef\sseq@tempanchornopt{\sseq@tikzprimitive@getcoord@anchor@eatdot#2}
+ \fi
+}
+\def\sseq@tikzprimitive@getcoord@anchor@eatdot#1.{#1}
+\def\sseq@uptopt#1.#2\sseq@nil{#1}
+%%% Page constraint and \isalive
+% #1 -- the new page constraint
+% #2 -- a binary logical operator (&& or ||).
+\def\sseq@updatepageconstraint#1#2{
+ \def\sseq@isaliveprotect{}
+ \let\sseq@isalive@\sseq@isalive@active
+ \bgroup
+ % Was pretty hard to get \isalive to report errors correctly. And to work in general >_<
+ \let\sseq@isalive@parens\sseq@isalive@parens@check
+ \sseq@d@addto@macro\sseq@error@hook{\let\protect\relax}%
+ \let\protect\@unexpandable@protect
+ \edef\sseq@error@annotation{\unexpanded{.^^J(In page constraint "#1")}\unexpanded\@xp{\sseq@error@annotation}}
+ \selectfont\sseq@restorefont
+ \setbox0=\hbox{#1}
+ \egroup
+ \sseq@protected@edef\sseq@pageconstraint{(\unexpanded\@xp{\sseq@pageconstraint})#2(#1)}
+}
+
+
+%TODO: fix this...
+\def\sseq@updatepageconstraintrange{%
+ \sseq@protected@edef\sseq@pageconstraint{%
+ (\unexpanded\@xp{\sseq@pageconstraint})&&(\temp<=\page \ifx\tempmax\empty\else&&\page<=\tempmax\fi)%
+ }%
+}
+
+% This protect variant allows us to delay evaluation of \isalive, just so that we can
+% capture something close to the original argument to (does this matter anymore?)
+\let\sseq@isaliveprotect\relax
+\def\sseq@isaliveprotect@protect{\@nx\sseq@isaliveprotect\@nx}
+\def\sseq@isalive{\sseq@isaliveprotect\sseq@isalive@}
+\def\sseq@isalive@{\sseq@isalive@error}
+\def\sseq@isalive@error{\sseq@error{is-alive-illegal-here}}
+\def\sseq@isalive@active#1{%
+ \@xp\ifx\@xp$\@gobble#1$%
+ \@xp\sseq@isalive@parens\@xp#1%
+ \else
+ \sseq@isalive@list#1\sseq@nil
+ \fi
+}
+\def\sseq@isalive@list(#1)#2{%
+ \sseq@isalive@parens(#1)%
+ \ifx\sseq@nil#2\else
+ &&\@xp\sseq@isalive@list\@xp#2%
+ \fi
+}
+
+\def\sseq@isalive@parens@check(#1){
+ \sseq@parsecoord\coord{#1}{\string\isalive}
+}
+\def\sseq@isalive@parens(#1){\sseq@parsecoordex\sseq@isalive@parens@(#1)}
+\def\sseq@isalive@parens@(#1,#2,#3){\@nx\sseq@isalive@final{#1}{#2}{#3}{\sseq@obj{class.(#1,#2,#3).num}}}
+\def\sseq@isalive@final#1#2#3#4{%
+ \ifnum\sseq@obj{class.(#1,#2,#3)[#4].page}<\sseq@thepagecount
+ 0%
+ \else
+ \ifnum#4=\z@
+ 1%
+ \else
+ \ifnum\sseq@obj{class.(#1,#2,#3)[\the\numexpr #4-1\relax].page}=\sseq@thepagecount
+ 0%
+ \else
+ 1%
+ \fi
+ \fi
+ \fi
+}
+
+
+
+
+
+%%%
+%%% This is a macro for typesetting monomials.
+%%%
+
+% We need to check for math subscript characters
+\char_set_catcode_math_subscript:N \_
+
+\protected\def\sseqnormalizemonomial#1{
+ \bgroup
+ \def\sseq@support{}
+ \sseq@ifempty{#1}{1}{
+ \sseqnormalizemonomial@#1\sseq@nil
+ }
+}
+\def\sseqnormalizemonomial@#1{
+ \pgfkeys@spdef\sseq@var{#1}
+ \def\sseq@power{1}
+ \def\sseq@subscript{}
+ \futurelet\testtok\sseqnormalizemonomial@@
+}
+
+\def\sseqnormalizemonomial@@{
+ \ifx\testtok^
+ \let\next\sseqnormalizemonomial@sup
+ \else
+ \ifx\testtok_
+ \let\next\sseqnormalizemonomial@sub
+ \else
+ \let\next\sseqnormalizemonomial@add
+ \fi
+ \fi
+ \next
+}
+
+\def\sseqnormalizemonomial@sup^#1{
+ \edef\sseq@power{\the\numexpr#1\relax}
+ \futurelet\testtok\sseqnormalizemonomial@@
+}
+
+\def\sseqnormalizemonomial@sub_#1{
+ \def\sseq@subscript{_{#1}}
+ \futurelet\testtok\sseqnormalizemonomial@@
+}
+
+\def\sseqnormalizemonomial@add{
+ \def\temp{1}
+ \ifx\sseq@var\temp\else
+ \edef\sseq@var{\unexpanded\@xp{\sseq@var}\unexpanded\@xp{\sseq@subscript}}
+ \@ifundefined{\sseqnormalizemonomial@varcs}{
+ \@xp\edef\csname\sseqnormalizemonomial@varcs\endcsname{\sseq@power}
+ \sseq@e@addto@macro\sseq@support{\@nx\\{\unexpanded\@xp{\sseq@var}}{\sseqnormalizemonomial@varcs}}%
+ }{
+ \@xp\edef\csname\sseqnormalizemonomial@varcs\endcsname{\the\numexpr\csname\sseqnormalizemonomial@varcs\endcsname + \sseq@power}
+ }
+ \fi
+ \sseqnormalizemonomial@testend
+}
+
+% This is supposed to take a space out of the input stream. For some reason \futurelet grabs it even though it's not supposed to...
+% Make sure braces go around argument, except that if they go around \sseq@nil, \futurelet will grab the the open brace and not see
+% the \sseq@nil. So we use a full expansion and don't put braces around \sseq@nil if that's our argument.
+% MOTHERFUCKING SPACES.
+\def\sseqnormalizemonomial@id#1{
+ \ifx\sseq@nil#1
+ \@xp\@firstoftwo
+ \else
+ \@xp\@secondoftwo
+ \fi{\@nx\sseq@nil}{{#1}}
+}
+
+\def\sseqnormalizemonomial@testend{
+ \ifx\testtok\sseq@nil
+ \sseqnormalizemonomial@done
+ \sseq@smuggle@macro\processedlabel
+ \egroup
+ \let\next\@gobble
+ \else
+ \@xp\ifx\space\testtok % not sure why I have to test for spaces like this -- figured it out with trial and error, like in \ifintexpr
+ % I'm not really sure why a space can show up here, but it crashes the macro and we don't care about spaces.
+ % I can't \@gobble the space because it will ignore it and take the next argument. What I can do is \@firstofone it away, but that deletes braces
+ % and in our case it's safe to put in extra braces but not to delete them. So I have \sseqnormalizemonomial@id...
+ % LaTeX is really really weird.
+ \def\next{\@xp\futurelet\@xp\testtok\@xp\sseqnormalizemonomial@testend\romannumeral-`0\sseqnormalizemonomial@id}
+ \else
+ \let\next\sseqnormalizemonomial@
+ \fi
+ \fi
+ \next
+}
+
+\def\sseqnormalizemonomial@varcs{sseqnormalizemonomial@var@\detokenize\@xp{\sseq@var}}
+
+\def\sseqnormalizemonomial@done{
+ \def\processedlabel{}
+ \def\\##1##2{
+ \sseq@tempcount=\csname ##2\endcsname\relax
+ \ifnum\sseq@tempcount=\z@
+ \else
+ \ifnum\sseq@tempcount=\@ne
+ \sseq@d@addto@macro\processedlabel{##1}
+ \else
+ \sseq@e@addto@macro\processedlabel{\unexpanded{##1}^{\the\sseq@tempcount}}
+ \fi
+ \fi
+ }
+ \sseq@support
+ \ifx\processedlabel\pgfutil@empty % use 1 for empty monomial
+ \def\processedlabel{1}
+ \fi
+}
+
+% Restore catcode of underscore to letter
+\catcode`\_ = 11\relax
+
+
+
+
+\ExplSyntaxOff \ No newline at end of file