Debian Codegraph @

texmf-dist/tex/latex/spectralsequences/spectralsequences.sty

raw
1 %%
2 %% Package: spectralsequences v1.3.3 2023-01-28
3 %% Author: Hood Chatham
4 %% Email: [email protected]
5 %% Date: 2023-01-28
6 %% License: Latex Project Public License
7 %%
8 %% A package for drawing spectral sequences
9 %%
10
11
12 % TODO:
13 % Try catch blocks
14 % Make an argument type for the \d page argument.
15 % deal with xmin, xmax, etc (was there actually a problem we were trying to fix?)
16 %
17 % Redo sseqerrortest and set up regression test script as part of build (damn I didn't realize we'd lost anything imporant with that find -d disaster)
18 % Maybe we should add some other regression tests too
19 %
20 % Lower priority:
21 % error messages that should be warnings by default?
22 %
23
24
25 \NeedsTeXFormat{LaTeX2e}
26 \ProvidesPackage{spectralsequences}[2023/01/28 v1.3.3]
27
28 \RequirePackage{tikz}
29 \RequirePackage{etoolbox}
30 \RequirePackage{xparse}
31 \RequirePackage{verbatim}
32
33 \usetikzlibrary{quotes}
34 \usetikzlibrary{fit}
35 \usetikzlibrary{positioning}
36 \usetikzlibrary{intersections}
37 \usetikzlibrary{backgrounds}
38 \usepgflibrary{arrows.meta}
39 \usetikzlibrary{shapes}
40 %\usetikzlibrary{patterns}
41 %\usetikzlibrary{profiler}
42
43 \newif\ifsseq@draftmode
44 \newif\ifsseq@tooltip
45 \DeclareOption{draft}{\sseq@draftmodetrue}
46 \DeclareOption{tooltips}{\sseq@tooltiptrue}
47 \ProcessOptions\relax
48
49 \ifsseq@tooltip
50 \RequirePackage{pdfcomment}
51 \else
52 \let\ulp@afterend\relax % So that removing the tooltip option doesn't cause the aux file to have an error.
53 \fi
54
55 \def\sseq@authorname{Hood Chatham}
56 \def\sseq@authoremail{[email protected]}
57 \def\sseq@issuetracker{https://github.com/SpectralSequences/latex/issues/new}
58
59
60 % Commands we are going to expose just inside of environments
61 \def\sseq@macrolist{%
62 \xcoord\ycoord\page %\xmin\xmax\ymin\ymax % these just get protected
63 % Defined in sseqmessages:
64 \quiet\endquiet
65 % These are defined in sseqmain:
66 \class\classoptions\replaceclass\replacesource\replacetarget
67 \replacestructlines
68 \d\doptions\kill\structline\structlineoptions\extension\extensionoptions\circleclasses
69 \lastlabel
70 % The following are defined in sseqparsers:
71 \pgfmathparse\isalive\lastx\lasty\lastclass\savestack\restorestack\pushstack\nameclass\tagclass
72 \parsecoordinate\parsedifferential\getdtarget\gettag
73 \IfOutOfBoundsTF\IfOutOfBoundsT\IfOutOfBoundsF\IfInBoundsTF\IfInBoundsT\IfInBoundsF
74 \IfExistsTF\IfExistsT\IfExistsF\IfAliveTF\IfAliveT\IfAliveF
75 \IfValidDifferentialTF\IfValidDifferentialT\IfValidDifferentialF
76 \DrawIfValidDifferentialTF\DrawIfValidDifferentialT\DrawIfValidDifferentialF\DrawIfValidDifferential
77 % sseqforeach
78 \Do\DoUntilOutOfBounds\DoUntilOutOfBoundsThenNMore
79 }
80
81
82 % All the tikz commands. We replace these in our environment too. Replacements defined in sseqparsers.
83 \def\sseq@tikzcommands{%
84 \clip\coordinate\draw\fill\filldraw
85 \graph\matrix\node\path\pattern
86 \shade\shadedraw\useasboundingbox
87 }
88
89
90 %%%%%% %%%%%%
91 %% %%
92 %% Declarations and preliminaries %%
93 %% %%
94 %%%%%% %%%%%%
95 \newif\ifsseq@inprogress
96
97 \newif\ifsseq@hasname
98 \newif\ifsseq@updateexisting
99 \newif\ifsseq@ispageenv
100 \newif\ifsseq@keepchanges
101 \newif\ifsseq@keepglobaloptions
102 \newif\ifsseq@globaldetone
103
104 \newif\ifsseq@needstikz
105 \newif\ifsseq@thispage
106 \newif\ifsseq@outofrange
107 \newif\ifsseq@classlabel
108 \newif\ifsseq@draworphanedges
109 \newif\ifsseq@draw
110 \newif\ifsseq@drawedge
111 \newif\ifsseq@tikzprims@integershift
112 \newif\ifsseq@anchor
113 \newif\ifsseq@rangecheck
114 \newif\ifsseq@rangecheck@sideways
115
116 \sseq@drawedgetrue
117 \sseq@tikzprims@integershifttrue
118
119 \newif\ifsseq@patchforeach
120 \newif\ifsseq@patchfit
121 \newif\ifsseq@patchxparseU
122
123 \newif\ifsseq@tempif
124 \newif\ifsseq@gtempif
125 \newif\ifsseq@error
126
127 \newtoks\sseq@temptoks
128 \newtoks\sseq@scope@toks
129
130 \newcount\sseq@thepagecount
131 \newcount\sseq@anonsseqcount
132 \newcount\sseq@x
133 \newcount\sseq@y
134 \newcount\sseq@tempcount
135 \newcount\sseq@tempcountb
136 \newcount\sseq@tempx
137 \newcount\sseq@tempy
138 \newcount\sseq@tempxb
139 \newcount\sseq@tempyb
140 \newcount\sseq@xoffset % We add these to everything to avoid overflow errors as much as possible
141 \newcount\sseq@yoffset
142
143 \newcount\sseq@stackdepth
144
145 \newdimen\sseq@tempdimen
146 \newdimen\sseq@tempxdimen
147 \newdimen\sseq@tempydimen
148 \newdimen\sseq@xscalecm
149 \newdimen\sseq@yscalecm
150 \newdimen\sseq@clip@xcenter
151 \newdimen\sseq@clip@ycenter
152 \newdimen\sseq@tooltip@height
153 \newdimen\sseq@tooltip@width
154 \newdimen\sseq@gridstrokethickness
155 \sseq@gridstrokethickness=.1pt
156
157 % Ensure \@xp and \@nx have the correct values in case that amsmath isn't loaded
158 \let\@xp\expandafter
159 \let\@nx\noexpand
160 \def\@xptwo{\@xp\@xp\@xp}
161 \def\@xpthree{\@xp\@xp\@xp\@xp\@xp\@xp\@xp}
162 \def\sseq@nil{\sseq@thisshouldnthappen@nil unique expansion} % This expansion text should be unique so that \ifx\sseq@nil\othercommand is false.
163 \def\sseq@infinity{10000} % Larger than any coordinate anyone will ever use.
164 \newcount\sseq@infinitycount
165 \sseq@infinitycount=\sseq@infinity\relax
166 \def\sseq@macroname{\@xp\@gobble\string}
167 \def\sseq@gobble@to@nil#1\sseq@nil{}
168 \def\sseq@macrogobble#1->{}
169
170 % These are only used by defertikzcommand now
171 \def\sseq@callas#1{\def\sseq@callcmd{#1}}
172 \def\sseq@call#1{\bgroup\@xp\let\sseq@callcmd#1\@xptwo\egroup\sseq@callcmd}
173
174 \def\sseq@getfirstchar#1#2\sseq@nil{#1} % used in shift/checkshift transform
175 \def\sseq@smuggle@macro#1#2\egroup{\@xp\egroup\@xp\def\@xp#1\@xp{#1}}
176
177
178 \def\sseq@protected@edef{\let\sseq@store@slsl\\\def\\{\protect\\}\let\@@protect \protect \let \protect \@unexpandable@protect \afterassignment \sseq@restore@protect \edef}
179 \def\sseq@protected@xdef{\let\sseq@store@slsl\\\def\\{\protect\\}\let\@@protect \protect \let \protect \@unexpandable@protect \afterassignment \sseq@restore@protect \xdef}
180 \def\sseq@restore@protect{\let\protect\@@protect\let\\\sseq@store@slsl}
181
182 \def\sseq@eval#1{\bgroup\edef\sseq@temp{#1}\@xp\egroup\sseq@temp}% I got this from sseq.sty
183 \def\sseq@protectedeval#1{\bgroup\sseq@protected@edef\sseq@temp{#1}\@xp\egroup\sseq@temp}
184 \def\sseq@eval@show#1{\bgroup\edef\sseq@temp{#1}\show\sseq@temp\@xp\egroup\sseq@temp}
185 \def\sseq@profilenew#1#2{\pgfprofilenew{#1}\pretocmd#2{\pgfprofilestart{#1}}{}{\error}\apptocmd#2{\pgfprofileend{#1}}{}{\error}}
186
187 %%%% add to macro commands
188 \def\sseq@d@addto@macro#1#2{\@xp\def\@xp#1\@xp{#1#2}}
189 \def\sseq@e@addto@macro#1#2{\edef#1{\unexpanded\@xp{#1}#2}} % let #2 be expanded
190 \def\sseq@eo@addto@macro#1#2{\edef#1{\unexpanded\@xp{#1}\unexpanded\@xp{#2}}} % let #2 be expanded once
191 \def\sseq@g@addto@macro#1#2{\@xp\gdef\@xp#1\@xp{#1#2}}
192 \def\sseq@x@addto@macro#1#2{\xdef#1{\unexpanded\@xp{#1}#2}} % let #2 be expanded
193 \def\sseq@xprotected@addto@macro#1#2{\sseq@protected@xdef#1{\unexpanded\@xp{#1}#2}}
194
195 \def\sseq@d@addto@toks#1#2{#1\@xp{\the#1#2}}
196 \def\sseq@e@addto@toks#1#2{\sseq@eval{#1{\the#1#2}}}
197
198 \def\sseq@d@addto@temptoks{\sseq@d@addto@toks\sseq@temptoks}
199 \def\sseq@e@addto@temptoks{\sseq@e@addto@toks\sseq@temptoks}
200
201
202 % Used in sseqkeys to delete spaces from style commands.
203 % Set the catcode of space to ignore, and then reparse the characters in #2.
204 \def\sseq@setmacronospaces#1#2{%
205 \bgroup\catcode`\ =9\relax
206 \makeatletter
207 \scantokens{\expandafter\egroup\expandafter\def\expandafter#1\expandafter{\csname #2\endcsname}}%
208 }
209
210 \def\sseq@setnospaces#1#2{%
211 \bgroup\catcode`\ =9\relax
212 \makeatletter
213 \scantokens{\expandafter\egroup\expandafter\def\expandafter#1\expandafter{\@firstofone{#2}}}%
214 }
215
216
217 \def\sseq@removeparens{\@xp\sseq@removeparens@}
218 \def\sseq@removeparens@(#1){#1}
219
220 % Stolen from trimspaces.sty
221 \bgroup
222 \catcode`\Q=3
223 \gdef\sseq@trimspaces#1{%
224 \romannumeral-`\q\sseq@trim@trim@\noexpand#1Q Q%
225 }
226 \long\gdef\sseq@trim@trim@#1 Q{\sseq@trim@trim@@#1Q}
227 \long\gdef\sseq@trim@trim@@#1Q#2{#1}
228 \egroup
229 \def\sseq@trimleadingspaces{\romannumeral-`q}
230
231 \def\sseq@ifempty#1{%
232 \@xp\ifx\@xp\sseq@nil\detokenize{#1}\sseq@nil
233 \@xp\@firstoftwo
234 \else
235 \@xp\@secondoftwo
236 \fi
237 }
238
239 \def\sseq@ifnil#1{
240 \ifx\sseq@nil#1
241 \@xp\@firstoftwo
242 \else
243 \@xp\@secondoftwo
244 \fi
245 }
246
247 \let\sseq@breakpoint\relax
248 \let\sseq@breakpointfinally\@gobble
249 \long\def\sseq@break#1\sseq@breakpoint{}
250 \def\sseq@fbreak{\@xp\sseq@break\romannumeral-`0}
251 \long\def\sseq@break@finally#1\sseq@breakpoint#2{#2}
252
253 \long\def\sseq@breakfi{\fi\sseq@break}
254 \long\def\sseq@breakfifi{\fi\fi\sseq@break}
255 \long\def\sseq@breakfififi{\fi\fi\fi\sseq@break}
256 \long\def\sseq@breakdataenv#1\end#2{
257 \def\sseq@tempa{sseqdata}\def\sseq@tempb{#2}\ifx\sseqtempa\sseqtempb
258 \@xp\sseq@breakdataenv@
259 \else
260 \@xp\sseq@breakdataenv
261 \fi
262 }
263 \def\sseq@breakdataenv@{\let\endsseqdata\sseq@breakendsseqdata\end{sseqdata}}
264
265 \long\def\sseq@breakpageenv#1\end#2{
266 \def\sseq@tempa{sseqpage}\def\sseq@tempb{#2}\ifx\sseqtempa\sseqtempb
267 \@xp\sseq@breakpageenv@
268 \else
269 \@xp\sseq@breakpageenv
270 \fi
271 }
272 \def\sseq@breakpageenv@{\let\endsseqpage\sseq@breakendsseqpage\end{sseqpage}}
273 \def\sseq@breakendsseqdata{}
274 \def\sseq@breakendsseqpage{}
275
276 \def\sseq@seteverythingtonoops{%
277 \let\sseqdata\comment
278 \let\sseqpage\comment
279 \let\sseqkeys\@gobble
280 \let\sseqnewgroup\@gobblethree
281 }
282
283 \newif\ifsseq@insidewaysenv
284 \sseq@insidewaysenvfalse
285 \def\SseqOrientationNormal{\sseq@insidewaysenvfalse}
286 \def\SseqOrientationSideways{\sseq@insidewaysenvtrue}
287 \def\SseqOrientationToggle{\ifsseq@insidewaysenv\sseq@insidewaysenvfalse\else\sseq@insidewaysenvtrue\fi}
288 \AtBeginEnvironment{sideways}{\SseqOrientationToggle}
289
290
291 \input sseqmessages.code.tex % Exposes directly: \sseqerrortowarning
292 \input sseqcheckdefinitions.code.tex
293
294 \ifsseq@tempif\else % Set to false in checkdefinitions if it failed to patch the key-value system.
295 \sseq@seteverythingtonoops
296 \sseq@pgfkeyspatchfailed
297 \fi
298
299 \input sseqloadstore.code.tex % Responsible for installing environment-only macros
300 \input sseqmacromakers.code.tex % Exposes directly: \DeclareSseqCommand, \NewSseqCommand, \DeclareSseqGroup, \NewSseqGroup
301
302 \input sseqparsers.code.tex % Responsible for making tikz modifications, exposes directly \sseqnormalizemonomial, \sseqparseint
303
304
305
306 \ifsseq@patchforeach
307 \input sseqforeach.code.tex
308 \else
309 \def\sseq@patchfor{}
310 \fi
311
312 \input sseqkeys.code.tex % Exposes directly: \sseqset, \sseqnewfamily
313 \input sseqmain.code.tex % Defines all the main commands. Exposes directly: the environments, \xmin, \xmax, etc, \SseqCopyPage
314 \input sseqdrawing.code.tex
315
316 % Give standard definitions for savedpaths wrappers
317 \def\sseq@beginscope@object{\begin{scope}}
318 \def\sseq@endscope@object{\end{scope}}
319 \let\sseq@scope@object\@firstofone
320 \let\sseq@style@object\@firstofone
321 \let\sseq@class@object\sseq@class@draw@ifpage
322 \let\sseq@differential@object\sseq@differential@draw@ifpage
323 \let\sseq@structline@object\sseq@structline@draw@ifpage
324 \let\sseq@extension@object\sseq@extension@draw@ifpage
325 \let\sseq@circleclass@object\sseq@circleclass@draw@ifpage
326 \let\sseq@tikzpath@object\@firstofone
327
328
329 %%% Some default key settings
330 \sseqset{
331 edge labels={auto=right},
332 classes={draw,circle,inner sep=0pt,minimum size=0.35em},
333 circle classes={newellipse, ellipse ratio=1.2,draw, inner sep=2pt},
334 edges=draw,
335 math nodes,
336 differentials=->,
337 pins=help lines
338 }
339
340 \ifsseq@tooltip
341 \let\sseqtooltip\sseq@tooltip@wrapper
342 \fi
343
344 % Extra commands to expose:
345 \let\sseqifempty\sseq@ifempty
346 \let\SseqParseInt\sseqparseint
347 \let\SseqNewFamily\sseqnewfamily
348
349 \def\sseqpower#1#2{\@xp\sseqtypesetpower@\@xp{\the\numexpr#2}{#1}{1}}
350 \def\sseqpowerempty#1#2{\@xp\sseqtypesetpower@\@xp{\the\numexpr#2}{#1}{}}
351 \def\sseqtypesetpower@#1#2#3{\ifnum#1=\z@#3\else\ifnum#1=\@ne#2\else#2^{#1}\fi\fi}