Debian Codegraph @

texmf-dist/source/latex/sseq/sseq.dtx

raw
1 %
2 % ^^A This is file sseq.dtx. First LaTeX the accompanying file sseq.ins
3 % ^^A to produce the package file sseq.sty.
4 % ^^A Then LaTeX this file to produce the documentation of the sseq package.
5 % ^^A
6 % ^^A (c) 2003-2007 Tilman Bauer. Freely distributable under the LaTeX Project Public License (LPPL)
7 % ^^A
8 % \ifthenelse{0=1}{
9 %<*never>
10 \documentclass{ltxdoc}
11 \usepackage{sseq}
12 \EnableCrossrefs
13 \CodelineIndex
14 \RecordChanges
15 \begin{document}
16 \DocInput{sseq.dtx} \PrintIndex \PrintChanges
17 \end{document}
18 %</never>
19 % }{}
20
21 %
22 % \changes{v1.0}{November 12, 2003}{First release of code and documentation}
23 % \changes{v1.01}{November 15, 2003}{Bug fix with clipping after a ssgoto}
24 % \changes{v1.02}{November 18, 2003}{Bug fix that would mess up page numbering in some cases}
25 % \changes{v1.03}{December 11, 2003}{Added examples to documentation, bug fix in grid drawing}
26 % \changes{v1.04}{January 19, 2004}{Up to nine drops per square now possible, added customization of the grid}
27 % \changes{v1.05}{December 9, 2004}{Added support for different packing strategies; support for dotted lines}
28 % \changes{v1.06}{August 1, 2005}{sseqxstep=0 will now suppress printing of horizontal label; similarly sseqystep=0 and vertical labels}
29 % \changes{v2.0a}{July 16, 2007}{Completely recoded the graphics for using pgf instead of xyPic. Many new features. Consult the manual.}
30 % \changes{v2.0}{April 9, 2009}{bug fix with arrows leaving the chart}
31 % \changes{v2.01}{September 6, 2013}{bug fix with bent arrows displaying hooks. Now requires at least tikz/pgf version 2.0}
32 % \ifthenelse{0=1}{
33 %<*package>
34 \NeedsTeXFormat{LaTeX2e}
35
36 \ProvidesPackage{sseq}[2009/04/09 ver 2.0]
37
38 \RequirePackage{ifthen,calc,pifont}
39 \RequirePackage{pgf}[2008/02/20]
40 \RequirePackage{xkeyval}
41 \usepgflibrary{decorations.pathmorphing}
42
43 %^^A \newboolean{usesps}
44 %^^A \setboolean{usesps}{true} % Deprecated for pgf version of sseq
45 \newboolean{usescolor}
46 \setboolean{usescolor}{true}
47 \newboolean{debug}
48 \setboolean{debug}{false}
49
50 \DeclareOption{ps}{\errmessage{sseq: ps/nops is deprecated}}
51 \DeclareOption{nops}{\errmessage{sseq: ps/nops is deprecated}}
52 \DeclareOption{dvips}{\errmessage{sseq: deprecated option dvips ignored}}
53 \DeclareOption{xdvi}{\errmessage{sseq: deprecated option xdvi ignored}}
54 \DeclareOption{color}{\setboolean{usescolor}{true}}
55 \DeclareOption{nocolor}{\setboolean{usescolor}{false}}
56 \DeclareOption{debug}{\setboolean{debug}{true}}
57
58 \ProcessOptions
59
60 %</package>
61 % }{}
62 %
63 % \title{Typesetting spectral sequences in \LaTeX\ with sseq.sty}
64 % \author{Tilman Bauer\footnote{[email protected]}}
65 % \date{April 9, 2009}
66 %
67 % \MakeShortVerb{\|}
68 %
69 % \maketitle
70 %
71 % \section{Introduction}
72 %
73 % The present package, \texttt{sseq}, facilitates the typesetting of mathematical objects called \emph{spectral sequence charts} (henceforth simply called ``chart''). From a typographical point of view, a chart is a two-dimensional grid with integer coordinates; at every position (x,y), there may be any number of symbols (usually dots, little circles or boxes, digits etc.), possibly decorated with labels, and between any two such symbols may or may not be a connection---e.~g., a line, an arrow, or some curved line.
74 %
75 % The \texttt{sseq} package is built on top of the pgf package by Till Tantau. It shares the disadvantage of using up lots of \TeX's memory; therefore, if your system provides a \texttt{biglatex} or \texttt{hugelatex} command, it is wise to use it when using \texttt{sseq}. Still, problems may arise with very large charts (i.e., more than $100\times100$). Previous versions of |sseq| (pre-2.0) were based on the graphics package xy-Pic; the current version produces higher quality output and allows for more customization, at the cost of requiring a fairly recent \TeX distribution (or, at least, the packages |pgf| and |xkeyval| should be installed and the former should be no older than from 2006).
76 %
77 % This package automates the following functions:
78 %
79 % \begin{itemize}
80 % \item Automatic drawing of the grid and the axis labels;
81 % \item Clipping. Anything outside the displayed portion of the chart is clipped away. This has the advantage that a large chart, which does not fit on a page, can be cut into smaller pieces which contain exactly the same \texttt{sseq} code, but different clipping regions.
82 % \item Arranging. Multiple symbols dropped at the same integer coordinates will be automatically arranged so that they usually do not overlap. The algorithm for doing this is rather primitive, but still powerful enough for most applications
83 % \item Simplified ``turtle graphics'' syntax. Every primitive element of a chart is typeset with a macro defined by \texttt{sseq}.
84 % \item Control structures (loops, if/then, etc.) are allowed inside the \texttt{sseq} environment.
85 % \end{itemize}
86 %
87 %
88 % \section{Global options}
89 %
90 % The |sseq| package is loaded with
91 %
92 % |\usepackage[|\meta{options...}|]{sseq}|.
93 %
94 % The following options are defined:
95 %
96 % \begin{itemize}
97 % \item |nops| is a deprecated option of a previous version. It is ignored.
98 % \item |nocolor| will tell |sseq| not to generate any color information. This includes gray shades. Many |dvi| drivers do not support color, but most of them tolerate (i.e. ignore) the color directives.
99 % \item |debug| will type out the pgf code generated by every |sseq| environment and wait for the user to confirm.
100 % \end{itemize}
101 %
102 %
103 % \section{Basic usage}
104 %
105 % \DescribeEnv{sseq}
106 % A spectral sequence is typeset by the code
107 %
108 % |\begin{sseq}[|\meta{options...}|]{|\meta{x-range}|}{|\meta{y-range}|}|
109 %
110 % \meta{sseq commands...}
111 %
112 % |\end{sseq}|
113 %
114 % In the simplest case, a range is of the form \meta{min}|...|\meta{max}, where \meta{min} and \meta{max} are two integers with \meta{min} $\leq$ \meta{max}.
115 %
116 % Thus |\begin{sseq}{2...5}{-3...-1}\end{sseq}| will typeset
117 % \[\begin{sseq}{2...5}{-3...-1}\end{sseq}.\]
118 %
119 % It is also possible for ranges to be a comma-separated list of ranges of the above form, e.g. |0...3,8...10|. In this case, the chart is broken into several pieces. Here is an example:
120 %
121 % \noindent\begin{minipage}{\textwidth/2}
122 % \begin{verbatim}\begin{sseq}{-1...3,5...8,20...24}
123 % {0...2,4...4}
124 %\end{sseq}\end{verbatim}\end{minipage}\begin{minipage}{\textwidth/2}\begin{sseq}{-1...3,5...8,20...24}{0...2,4...4}\end{sseq}\bigskip\end{minipage}
125 %
126 % The minimum value of one block always has be at least two greater than the maximum of the previous block; |0...2,3...5| is illegal.
127 %
128 %
129 % The following options are defined for the |sseq| environment. Options in bold face are the default setting.
130 % \begin{description}
131 % \item[|grid=|]\meta{none,\textbf{crossword},go,dots,chess} Select an option of drawing the background grid.
132 %
133 % \begin{tabular}{ccccc}
134 % none & crossword & go & dots & chess\\
135 % \begin{sseq}[entrysize=2mm,labels=none,grid=none]{4}{4}\end{sseq} &
136 % \begin{sseq}[entrysize=2mm,labels=none,grid=crossword]{4}{4}\end{sseq} &
137 % \begin{sseq}[entrysize=2mm,labels=none,grid=go]{4}{4}\end{sseq} &
138 % \begin{sseq}[entrysize=2mm,labels=none,grid=dots]{4}{4}\end{sseq} &
139 % \begin{sseq}[entrysize=2mm,labels=none,grid=chess]{4}{4}\end{sseq}
140 % \end{tabular}
141 % \item[|entrysize=|\meta{size}] Specify the size of each square of the grid. The default is 4mm.
142 % \item[|labels=|\meta{labels},|xlabels=|\meta{labels},|ylabels=|\meta{labels}] Specify how labels on the x- and y-axis are drawn, respectively. The |labels| option sets both |xlabels| and |ylabels| to the same. Possible values are |none|, |numbers|, or an explicit list of semicolon-separated labels |{|\meta{$x_1$}|;|\meta{$x_2$}|;|\dots|}| which will be typeset in math mode. If the range consists of more than one block, the labels for the separate blocks are separated by a comma; see the example below. The default is |numbers|.
143 % \item[|labelstep=|\meta{step},|xlabelstep=|\meta{step},|ylabelstep=|\meta{step}] Frequently it is not desirable that every label is printed, but only every second or third label. This can be done by setting this option to a positive integer. The default is 2.
144 %
145 % The following example illustrates how labels can be customized:
146 %
147 % \noindent\begin{minipage}{\textwidth*2/3}
148 % \begin{verbatim}\begin{sseq}[xlabelstep=1,ylabelstep=4,
149 % xlabels={x_1;x_2;x_3,y_1;y_2;y_3}]
150 % {1...3,10...11}{0...4}
151 %\end{sseq}\end{verbatim}\end{minipage}\begin{minipage}{\textwidth/3}\begin{sseq}[xlabelstep=1,ylabelstep=4,xlabels={x_1;x_2;x_3,y_1;y_2;y_3}]{1...3,10...11}{0...4}\end{sseq}\end{minipage}
152 % \item[|gapsize=|\meta{size},|xgapsize=|\meta{size},|ygapsize=|\meta{size}] This sets the size of the gap between two blocks in a range (i.e. in the above example, the distance between the $x_3$ column and the $y_1$ column). The default is 3mm.
153 % \item[|gridstroke=|\meta{thickness}] For the grid types |crossword| and |go|, this sets the line width. The default is .1pt. A good option is to set it to the resolution of your output device.
154 % \item[|leak=|\meta{size},|xleak=|\meta{size},|yleak=|\meta{size}] When a line is drawn from within the visible range of the chart to a point outside, or vice versa, this line will protrude beyond the boundaries of the grid. These values define how far; the default is one third of |leak|.
155 % \item[|arrows=|\meta{arrow type}] Sets the default arrow type to use in the spectral sequence. Here are some default arrow types:
156 %
157 %\begin{sseq}[grid=none,labels=none]{0...3}{-2...0}
158 % \ssdrop{} \ssmove 3 0 \ssdrop{\mathtt{\;to}} \ssstroke[arrowto=to] \ssmove {-3}{-1}
159 % \ssdrop{} \ssmove 3 0 \ssdrop{\mathtt{\;stealth}} \ssstroke[arrowto=stealth] \ssmove {-3}{-1}
160 % \ssdrop{} \ssmove 3 0 \ssdrop{\mathtt{\;latex}} \ssstroke[arrowto=latex]
161 %\end{sseq}
162 %
163 % Other arrow types can be defined by the user or loaded from a library; see the pgf package documentation for details.
164 % \end{description}
165 %
166 % You may specify which algorithm you want to use to arrange multiple objects in
167 % a grid square. The following are possible:
168 % \begin{itemize}
169 % \item |\def\sseqpacking{\sspacksmart}|: the default, arrange dots roughly as on a dice
170 % \item |\def\sseqpacking{\sspackhorizontal}|: put all objects in a horizontal line, vertically centered.
171 % \item |\def\sseqpacking{\sspackvertical}|: put all objects in a vertical line, horizontally centered.
172 % \item |\def\sseqpacking{\sspackdiagonal}|: put all objects in a line going from top left to bottom right.
173 % \end{itemize}
174 %
175 % It is recommended to use the packing commands before the |\begin{sseq}| command;
176 % though it is possible to change the packing strategy within a single chart, the
177 % user has to take care to make sure that in every coordinate consistent packing
178 % strategies are used; the result will be unexpected otherwise.
179 %
180 % \section{sseq commands}
181 %
182 % Inside an |sseq| environment there is defined a virtual cursor, which starts out at position $(0,0)$ (even if that position is not within the visible region!). Most drawing commands are relative to the current cursor position; this facilitates reusage of |sseq| code when a certain pattern has to be repeated, as is often the case in mathematical spectral sequences.
183 %
184 %
185 % \ifthenelse{0=1}{
186 %
187 %
188
189 \def\sseq@currentname{}
190 \def\sseq@previousname{}
191
192 \newboolean{sseqhasopenconn}
193 \setboolean{sseqhasopenconn}{false}
194 \newboolean{sseqclip}
195 \setboolean{sseqclip}{true}
196
197 \def\sseqconncommand{}
198 \def\sseq@connbuffer{}
199 \def\sseq@currarrowstart{}
200 \def\sseq@currarrowend{}
201
202 \newif\ifsseq@connreverse
203
204 \ifthenelse{\boolean{usescolor}}
205 {
206 \definecolor{sseqgr}{gray}{0.65}
207 \definecolor{sslightgr}{gray}{0.8}
208 \definecolor{ssred}{rgb}{1,0,0}
209 \definecolor{ssblack}{rgb}{0,0,0}
210 }{}
211 \newcommand{\ssconncolor}{ssblack}
212 \newcommand{\sslabelcolor}{ssblack}
213 \newcommand{\ssplacecolor}{ssblack}
214
215 \def\sseqpacking{\sspacksmart}
216 % ^^A This is one of: {\sspacksmart,\sspackhorizontal,\sspackdiagonal,\sspackvertical}
217
218 %% ^^A Initialization
219 \newcount\sseqxstart \sseqxstart=0
220 \newcount\sseqystart \sseqystart=0
221 \newcount\sseqxstep
222 \newcount\sseqystep
223 \newdimen\sseqentrysize
224 \newdimen\sseq@xgap
225 \newdimen\sseq@ygap
226 \newdimen\sseq@xleak
227 \newdimen\sseq@yleak
228 \newdimen\ss@currsep \ss@currsep=\pgfshapeinnerxsep
229 \newdimen\ss@size
230 \newdimen\sseq@gridstrokethickness
231
232 \newsavebox\sseq@labelbox
233
234 \newif\ifssclipped
235 \newif\ifcurroutofrange
236
237 \newtoks\sseqcmdlist
238 \sseqcmdlist={}
239
240 \def\currprefix{}
241
242 \long\def\ntimes#1#2{
243 \ifnum#1>0
244 #2
245 \count0=#1
246 \advance\count0 by -1
247 \edef\tmpcnt{\the\count0}
248 \ntimes{\tmpcnt}{#2}
249 \fi
250 }
251
252 \long\def\for #1=#2\to#3\do#4\od{#1=#2 \sseq@for #1\to #3\do #4\od}
253 \long\def\sseq@for #1\to #2\do #3\od{%
254 \ifnum #1>#2 \else
255 #3\relax
256 \advance #1 by 1
257 \def\tempcmd{\sseq@for #1\to #2\do #3\od}%
258 \expandafter\tempcmd
259 \fi
260 }
261
262 \def\@eval#1#2{%
263 \edef\tempcmd{\noexpand#1#2}%
264 \tempcmd
265 }
266 %
267 % ^^A Support macros for ranges (like "-3...5,12...18")
268 %
269 \def\range@endmarker{END}
270 %
271 %
272 % ^^A range@parsenadnormalize{\targetcommand}{defaultstart}{string}
273 %
274 \def\range@parseandnormalize#1#2#3{\def#1{}\range@parseandnormalizeinnerloop{#1}{#2}{-10000}#3,END,}
275 %
276 \def\range@parseandnormalizeinnerloop#1#2#3#4,{%
277 \def\temp{#4}%
278 \ifx\temp\range@endmarker
279 \edef #1{#1END;END,}%
280 \else
281 \def\tempoutercmd{\range@parseinnerpart{#1}{#2}{#3}#4...END...}%
282 \expandafter\tempoutercmd
283 \fi
284 }
285 %
286 \def\range@parseinnerpart#1#2#3#4...#5...{%
287 \def\temp{#5}
288 \ifx\temp\range@endmarker
289 \count0=#2
290 \advance\count0 by #4
291 \advance\count0 by -1
292 \edef\tempcmd{\noexpand\range@parseinnerpart{\noexpand#1}{#2}{#3}#2...\number\count0...END...}
293 \else
294 \count0=#3
295 \count1=#4
296 \count2=#5
297 \ifnum\count1<\count0
298 \PackageError{sseq}{Illegal stepping in range}{In a range a...b,c...d, c has to be >= b+2. In your case, b+2=#3 and c=#4. I'll replace c by #3.}
299 \count1=#3
300 \fi
301 \ifnum\count2<\count1
302 \PackageError{sseq}{Illegal range}{In a range a...b, b has to be at least as big as a. In your case, a=\number\count1 and b=#5. I'll replace b by \number\count1.}
303 \count2=\count1
304 \fi
305 \count0=\count2
306 \advance\count0 by 2
307 \edef#1{#1\number\count1;\number\count2,}
308 \edef\tempcmd{\noexpand\range@parsegobbleend{\noexpand#1}{#2}{\number\count0}}
309 \fi
310 \tempcmd
311 }
312 %
313 \def\range@parsegobbleend#1#2#3#4...{%
314 \range@parseandnormalizeinnerloop{#1}{#2}{#3}%
315 }
316 %
317 % \range@loop {command} range
318 %
319 \newif\ifrangebreak
320 %
321 %
322 \def\range@loop#1#2;#3,{
323 \rangebreakfalse
324 \def\temp{#2}
325 \def\tempcmd{}
326 \ifx\temp\range@endmarker\else
327 #1{#2}{#3}
328 \advance\sseqj by 1
329 \ifrangebreak
330 \def\tempcmd{\range@gobbletoend}
331 \else
332 \def\tempcmd{\range@loop{#1}}
333 \fi
334 \fi
335 \tempcmd
336 }
337 %
338 %
339 \newif\ifoutofrange
340 %
341 % ^^A Compute absolute coordinates from logical ones
342 % ^^A return them in \sseqx and \sseqy
343 %
344 % ^^A \range@getabsoluteposition{pos}{stepinc}{gapinc}{offset}range
345 % ^^A return value in \dimen0; also set \ifoutofrange
346 %
347 \def\range@getabsoluteposition#1#2#3#4#5;#6,{
348 \outofrangefalse
349 \def\temp{#5}
350 \def\tempcmd{}
351 \count0=#1
352 \ifx\temp\range@endmarker
353 \outofrangetrue
354 \else % ^^A now #4 contains the current min and #5 the current max
355 \ifnum\count0<#5
356 \outofrangetrue
357 \def\tempcmd{\range@gobbletoend}
358 \else
359 \ifnum\count0>#6
360 \count0=#6
361 \advance\count0 by 1
362 \count1=#5
363 \multiply\count1 by -1
364 \advance\count0 by \count1
365 \dimen0=#2
366 \multiply\dimen0 by \count0
367 \advance\dimen0 by #4
368 \advance\dimen0 by #3
369 \edef\tempcmd{\noexpand\range@getabsoluteposition{#1}{#2}{#3}{\number\dimen0sp}}
370 \else
371 \count1=#5
372 \multiply\count1 by -1
373 \advance\count0 by \count1
374 \dimen0=#2
375 \multiply\dimen0 by \count0
376 \advance\dimen0 by #4
377 \def\tempcmd{\range@gobbletoend}
378 \fi
379 \fi
380 \fi
381 \tempcmd
382 }
383 \def\range@gobbletoend#1END,{}
384
385 \def\ss@getcoords#1#2{
386 \edef\tempcmd{\noexpand\range@getabsoluteposition{#1}{\number\sseqentrysize sp}{\number\sseq@xgap sp}{0pt}}
387 \expandafter\tempcmd\sseq@xrange
388 \sseqx=\dimen0
389 \edef\tempcmd{\noexpand\range@getabsoluteposition{#2}{\number\sseqentrysize sp}{\number\sseq@ygap sp}{0pt}}
390 \ifoutofrange
391 \expandafter\tempcmd\sseq@yrange
392 \outofrangetrue
393 \else
394 \expandafter\tempcmd\sseq@yrange
395 \fi
396 \sseqy=\dimen0
397 }
398
399
400 %
401 % ^^A \putxy will put a list of commands into the execution queue
402 %
403 \def\putxyq#1{\toks0={#1}%
404 \edef\act{\noexpand\sseqcmdlist={\the\sseqcmdlist \the\toks0}}%
405 \act
406 }
407 \def\putxy#1{%
408 \edef\act{\noexpand\sseqcmdlist={\the\sseqcmdlist #1}}%
409 \act
410 }
411
412 %
413 %
414 %
415 \def\sseqwritecolor#1{
416 \ifthenelse{\boolean{usescolor}}{
417 \putxy{\noexpand\color{#1}}
418 }{}
419 }
420 %
421 %
422 %
423
424 \def\sseqconcludeconnection{
425 \sseqconncommand
426 \setboolean{sseqhasopenconn}{false}
427 }
428
429 \def\dropvarname#1#2{\csname sseqdrop#1,#2\endcsname}
430
431 \def\ifuniquedrop#1#2{
432 \edef\tmpval{\dropvarname{#1}{#2}}
433 \expandafter\ifx\tmpval1
434 }
435
436 \def\ifnodrop#1#2{
437 \edef\tmpval{\dropvarname{#1}{#2}}
438 \expandafter\ifx\tmpval\relax
439 }
440
441 \def\ssdroperrormsg#1#2{
442 \ifnodrop{#1}{#2}
443 \PackageError{sseq}{cannot open position (#1,#2): nothing dropped yet}{You cannot draw any connection until you have drawn the source.}
444 \else
445 \PackageError{sseq}{cannot open position (#1,#2): multiple drops}{You cannot specify this position by coordinates. Instead, name it.}
446 \fi
447 }
448 %
449 % ^^A update sseqabsposx, sseqabspoy, ifcurroutofrange from sseqposx, sseqposy.
450 %
451 \def\sseq@updatecurrentdata{
452 \@eval\ss@getcoords{{\number\sseqposx}{\number\sseqposy}}
453 \sseqabsposx=\sseqx
454 \sseqabsposy=\sseqy
455 \let\ifcurroutofrange\ifoutofrange
456 }
457
458 \def\sseq@openposition{
459 \ifuniquedrop{\the\sseqposx}{\the\sseqposy}
460 \edef\sseq@currentname{ss(\number\sseqposx,\number\sseqposy)1}
461 \else
462 \ssdroperrormsg{\the\sseqposx}{\the\sseqposy}
463 \def\sseq@currentname{}
464 \fi
465 }
466
467 \def\ssassertsource{
468 \sseq@flushconn
469 \ifx\sseq@currentname\empty
470 \sseq@openposition
471 \fi
472 }
473
474 \def\ssfinishpos{
475 \sseq@flushconn
476 \ifx\sseq@currentname\empty
477 \else
478 \ifthenelse{\boolean{sseqhasopenconn}}
479 {
480 \sseqconcludeconnection
481 }{}
482 \edef\sseq@previousname{\sseq@currentname}
483 \def\sseq@currentname{}
484 \fi
485 }
486
487
488 % ^^A Packing subroutines. Count11 contains the number of previously dropped objects that have to be rearranged. Count0-count9 contain the previously dropped object numbers. dimen5 contains the stepping, dimen6 its negative.
489 \def\sspacksmart#1#2{
490 \ifcase\count11
491 % ^^A 0
492 \PackageError{sseq}{This can't happen!}{Internal error. Contact the author.}
493 \or % ^^A 1
494 \sseqrearrange{#1}{#2}{\the\count1}{\the\dimen6}{\the\dimen5}
495 \advance\sseqx by \dimen5
496 \advance\sseqy by \dimen6
497 \or % ^^A 2
498 \sseqrearrange{#1}{#2}{\the\count2}{0pt}{\the\dimen5}
499 \sseqrearrange{#1}{#2}{\the\count2}{0pt}{\the\dimen5}
500 \advance\sseqy by \dimen6
501 \or % ^^A 3
502 \sseqrearrange{#1}{#2}{\the\count3}{\the\dimen6}{0pt}
503 \advance\sseqx by \dimen5
504 \advance\sseqy by \dimen6
505 \or % ^^A 4 -- give up on being clever and put everything in one diagonal row.
506 \sseqrearrange{#1}{#2}{\the\count2}{\the\dimen6}{\the\dimen6}
507 \sseqrearrange{#1}{#2}{\the\count3}{\the\dimen5}{0pt}
508 \sseqrearrange{#1}{#2}{\the\count3}{\the\dimen5}{0pt}
509 \sseqrearrange{#1}{#2}{\the\count4}{\the\dimen5}{\the\dimen6}
510 \advance\sseqx by \dimen5
511 \advance\sseqx by \dimen5
512 \advance\sseqx by \dimen5
513 \advance\sseqy by \dimen6
514 \advance\sseqy by \dimen6
515 \advance\sseqy by \dimen6
516 \else
517 \advance\count11 by -1
518 \multiply\dimen5 by \count11
519 \multiply\dimen6 by \count11
520 \advance\sseqx by \dimen5
521 \advance\sseqy by \dimen6
522 \fi
523 }
524
525 \def\sspackhorizontal#1#2{
526 \divide\dimen6 by 2
527 \divide\dimen5 by 2
528 \for\count10=1 \to \count11 \do
529 \sseqrearrange{#1}{#2}{\the\count\count10}{\the\dimen6}{0pt}
530 \od
531 \multiply\dimen5 by \count11
532 \advance\sseqx by \dimen5
533 }
534 \def\sspackvertical#1#2{
535 \divide\dimen6 by 2
536 \divide\dimen5 by 2
537 \for\count10=1 \to \count11 \do
538 \sseqrearrange{#1}{#2}{\the\count\count10}{0pt}{\the\dimen6}
539 \od
540 \multiply\dimen5 by \count11
541 \advance\sseqy by \dimen5
542 }
543 \def\sspackdiagonal#1#2{
544 \divide\dimen6 by 2
545 \divide\dimen5 by 2
546 \for\count10=1 \to \count11 \do
547 \sseqrearrange{#1}{#2}{\the\count\count10}{\the\dimen6}{\the\dimen5}
548 \od
549 \multiply\dimen5 by \count11
550 \multiply\dimen6 by \count11
551 \advance\sseqx by \dimen5
552 \advance\sseqy by \dimen6
553 }
554
555
556 \def\sseqpack#1#2{
557 \expandafter\ifx\sseqpacking\ssequndefined
558 \PackageError{sseq}{Unknown packing option, reverting to \string\sspacksmart}{You apparently have redefined \string\sspacksmart. The only allowed values are: \string\sspacksmart,\string\sspackhorizontal,\string\sspackdiagonal,\string\sspackvertical.}
559 \gdef\sseqpacking{\sspacksmart}
560 \fi
561 \sseqpacking{#1}{#2}
562 }
563
564 \def\sseqrearrange#1#2#3#4#5{
565 \dimen0 = \csname sseqcoordx<#1,#2>#3\endcsname
566 \dimen1 = \csname sseqcoordy<#1,#2>#3\endcsname
567 \advance\dimen0 by #4
568 \advance\dimen1 by #5
569 \expandafter\edef\csname sseqcoordx<#1,#2>#3\endcsname{\the\dimen0}
570 \expandafter\edef\csname sseqcoordy<#1,#2>#3\endcsname{\the\dimen1}
571 }
572
573 \def\sseqstacking#1#2#3{ % ^^A (xpos, ypos, number of previous drops)
574 \dimen5=\sseqentrysize
575 \divide\dimen5 by 4
576 \dimen6=\dimen5
577 \multiply\dimen6 by -1
578 %
579 \count11=0
580 \for\count10=1 \to #3 \do
581 \if1\csname sseqwillmove<#1,#2>\the\count10 \endcsname
582 \advance\count11 by 1
583 \expandafter\count\the\count11=\count10
584 \fi
585 \od
586 \ifnum\count11<9
587 \else
588 \PackageError{sseq}{Too many drops at (#1,#2)}{The sseq.sty algorithm can only place up to nine independent drops in one position.}
589 \fi
590 \sseqpack{#1}{#2}
591 }
592
593 % ^^A This sets the new shape inner x- and y-separation to the new value
594 % ^^A It avoids issuing a command if it's already set to the right value
595 \def\ss@setshapesep#1{
596 \ifdim\ss@currsep=#1\else
597 \putxy{\noexpand\pgfsetshapeinnerxsep{#1}\noexpand\pgfsetshapeinnerysep{#1}}
598 \ss@currsep=#1
599 \fi
600 }
601
602 \def\sseq@setcircumference{
603 \expandafter\ss@size\expandafter=\expandafter\csname\sseq@currentname size\endcsname
604 \advance\ss@size by 1pt
605 \ifKV@sseqdrop@boxed
606 \advance\ss@size by 2pt
607 \fi
608 \ss@setshapesep{\the\ss@size}
609 }
610
611 % ^^A This replaces \ssplacespecial in the xy version.
612 % ^^A Arguments: 1,2 = x- and y-coordinates
613 % ^^A 3 = pgf shape
614 % ^^A 4 = pgf path usage
615 % ^^A 5 = contents
616 %
617 \def\ss@placespecial#1#2#3#4#5{
618 %
619 \ssfinishpos
620 %
621 \ss@getcoords{#1}{#2}
622 \advance\sseqx by \sseqhalfentry
623 \advance\sseqy by \sseqhalfentry
624 %
625 \expandafter\def\expandafter\tmpname\expandafter{\csname sseqdrop#1,#2\endcsname}
626 %
627 \ifnodrop{#1}{#2}
628 \expandafter\def\tmpname{1}
629 \else
630 \edef\setcnt{\noexpand\count0=\tmpname}
631 \setcnt
632 \sseqstacking{#1}{#2}{\tmpname}
633 \advance\count0 by 1
634 \expandafter\edef\tmpname{\the\count0}
635 \fi
636 \putxyq{\pgftransformshift}
637 \putxy{{\noexpand\pgfpoint{\csname sseqcoordx<#1,#2>\tmpname\endcsname}{\csname sseqcoordy<#1,#2>\tmpname \endcsname}}}
638 %
639 %
640 \ifoutofrange % ^^A Outside clipping region -- produce an empty node
641 \putxyq{\pgfnode{coordinate}{center}{}}
642 % ^^A now give it a unique name
643 \putxy{{ss(#1,#2)\tmpname}}
644 \putxyq{{}}
645 \else
646 \sseqwritecolor{\ssplacecolor}
647 \putxyq{\pgfnode{#3}{center}}
648 \putxyq{{#5}}
649 % ^^A now give it a unique name
650 \putxy{{ss(#1,#2)\tmpname}}
651 \putxyq{{#4}}
652 \fi
653 %
654 \putxyq{\pgftransformreset}
655 %
656 \def\temp{#5}
657 \ifx\temp\empty % ^^A It's a bullet or a circle or such
658 \dimen0=1pt
659 \else
660 \setbox0=\hbox{#5}
661 \dimen0=0.5\wd0
662 \fi
663 \expandafter\edef\csname sseqcoordx<#1,#2>\tmpname\endcsname{\the\sseqx}
664 \expandafter\edef\csname sseqcoordy<#1,#2>\tmpname\endcsname{\the\sseqy}
665 \expandafter\edef\csname ss(#1,#2)\tmpname size\endcsname{\number\dimen0 sp}
666 \expandafter\def\csname sseqwillmove<#1,#2>\tmpname\endcsname{1}
667 %
668 \edef\sseq@currentname{ss(#1,#2)\tmpname}
669 %
670 \ifthenelse{\boolean{sseqhasopenconn}}{\sseqconcludeconnection}{}
671 }
672
673 \newcommand{\ssplace}[3]{
674 \ss@setshapesep{0pt}
675 \putxyq{\pgfsetdash{}{0pt}}
676 \ss@placespecial{#1}{#2}{rectangle}{\pgfusepath{discard}}{\ensuremath{#3}}
677 }
678
679 \newcommand{\ssplaceboxed}[3]{
680 \ss@setshapesep{1pt}
681 \putxyq{\pgfsetdash{}{0pt}}
682 \ss@placespecial{#1}{#2}{rectangle}{\pgfusepath{stroke}}{\ensuremath{#3}}
683 }
684
685 \newcommand{\ssplacecircled}[3]{
686 \ifthenelse{\equal{#3}{1}
687 \OR \equal{#3}{2}
688 \OR \equal{#3}{3}
689 \OR \equal{#3}{4}
690 \OR \equal{#3}{5}
691 \OR \equal{#3}{6}
692 \OR \equal{#3}{7}
693 \OR \equal{#3}{8}
694 \OR \equal{#3}{9}}{
695 % ^^A replace circled single digits by the corresponding dings -- looks better
696 % ^^A The following adjustment to the bounding circle is based on experimentation
697 % ^^A Let's hope it doesn't differ too much from one dingbat font to the other...
698 \ss@setshapesep{-.3ex}
699 \count0=191
700 \advance\count0 by #3
701 \def\ss@tmpcmd{\ss@placespecial{#1}{#2}{circle}{\pgfusepath{discard}}}
702 \expandafter\ss@tmpcmd\expandafter{\expandafter\ding\expandafter{\the\count0}}
703 }{
704 \putxyq{\pgfsetdash{}{0pt}}
705 \ss@setshapesep{0pt}
706 \ss@placespecial{#1}{#2}{circle}{\pgfusepath{stroke}}{\ensuremath{#3}}
707 }
708 }
709
710 \newcommand{\ssglobalname}[1]{\currprefix#1}
711
712
713 \def\sssetglobalname#1{
714 \ssassertsource
715 \expandafter\edef\csname sseqpos<#1>\endcsname{\sseq@currentname}
716 \expandafter\edef\csname sseqx<#1>\endcsname{\the\sseqposx}
717 \expandafter\edef\csname sseqy<#1>\endcsname{\the\sseqposy}
718 }
719 % }{}
720 %
721 % \DescribeMacro{\ssmoveto}
722 % To move the cursor to the absolute position (x,y), use |\ssmoveto{x}{y}|.
723 %
724 % \ifthenelse{0=1}{
725 \newcommand{\ssmoveto}[2]{
726 \ifthenelse{\boolean{sseqhasopenconn}}
727 {
728 \sseqconcludeconnection
729 }{}
730 \ssfinishpos
731 \sseqposx=#1
732 \sseqposy=#2
733 \sseq@updatecurrentdata
734 }
735 % }{}
736 % \DescribeMacro{\ssmove}
737 % To move the cursor relative to the current position by (x,y), use |\ssmove{x}{y}|.
738 %
739 % \iffalse
740 \newcommand{\ssmove}[2]{
741 \sseqi=\sseqposx
742 \advance\sseqi by #1
743 \sseqj=\sseqposy
744 \advance\sseqj by #2
745 \@eval\ssmoveto{{\number\sseqi}{\number\sseqj}}
746 }
747 % \fi
748 %
749 %
750 % \DescribeMacro{\ssdrop}
751 % The command |\ssdrop[|\meta{optios}|]{|\meta{mathcode}|}| will display \emph{mathcode} at the current cursor position. The argument is always interpreted in math mode.
752 % The following options can be given:
753 % \begin{description}
754 % \item[|circled|] A circle is drawn around the object. If the object is a digit 1,\dots,9, a dingbat (eg. \ding{192}) is substituted.
755 % \item[|boxed|] A box is drawn around the object.
756 % \item[|color=|\meta{color}] The object is drawn in the specified color. Any \LaTeX{} color can be used, e.g. predefined colors such as |black|, |blue|, |PineGreen|, etc., or user defined rgb colors.
757 % \item[|name=|\meta{name}] This is equivalent to issuing |\ssname{|\meta{name}|}| after |\ssdrop|, see below.
758 % \end{description}
759 % If the argument is |\bullet| or |\circle|, the object is replaced by a better-spaced graphics primitive.
760 %
761 % \ifthenelse{0=1}{
762 \define@key{sseqdrop}{circled}[true]{\newif\ifKV@sseqdrop@circled\csname KV@sseqdrop@circled#1\endcsname}
763 \define@key{sseqdrop}{boxed}[true]{\newif\ifKV@sseqdrop@boxed\csname KV@sseqdrop@boxed#1\endcsname}
764 \define@key{sseqdrop}{color}{\def\ssplacecolor{#1}}
765 \define@key{sseqdrop}{name}{\def\sseq@name{#1}}
766 %
767 \def\ssdrop{\@ifnextchar[\sseq@drop{\sseq@drop[]}}
768 \def\sseq@drop[#1]#2{
769 \edef\sseq@savecolor{\ssplacecolor}
770 \def\sseq@name{\relax}
771 \presetkeys{sseqdrop}{circled=false,boxed=false}{}
772 \setkeys{sseqdrop}{#1}
773 \ifKV@sseqdrop@circled
774 \ssplacecircled{\number\sseqposx}{\number\sseqposy}{#2}
775 \else
776 \ifKV@sseqdrop@boxed
777 \ssplaceboxed{\number\sseqposx}{\number\sseqposy}{#2}
778 \else
779 \def\temp{#2}
780 \def\temptwo{\bullet}
781 \ifx\temp\temptwo
782 \ss@setshapesep{0pt}
783 \ss@placespecial{\number\sseqposx}{\number\sseqposy}{circle}{\pgfusepath{fill}}{}
784 \else
785 \def\temptwo{\circle}
786 \ifx\temp\temptwo
787 \ss@setshapesep{0pt}
788 \ss@placespecial{\number\sseqposx}{\number\sseqposy}{circle}{\pgfusepath{stroke}}{}
789 \else
790 \ssplace{\number\sseqposx}{\number\sseqposy}{#2}
791 \fi
792 \fi
793 \fi
794 \fi
795 \edef\ssplacecolor{\sseq@savecolor}
796 \def\temp{\relax}
797 \ifx\sseq@name\temp \else
798 \@eval\ssname{{\sseq@name}}
799 \fi
800 }
801 % }{}
802 %
803 % ^^A The following are commands purely kept for compatibility.
804 %
805 % \iffalse
806 %
807 \newcommand{\ssdropbull}{\ssdrop{\bullet}}
808 \newcommand{\ssdropboxed}[1]{\ssdrop[boxed]{#1}}
809 \newcommand{\ssdropcircled}[1]{\ssdrop[circled]{#1}}
810 % \fi
811 %
812 % \DescribeMacro{\ssname}
813 % |\ssname{|\meta{name}|}| gives the object most recently dropped the name \meta{name}. If the previous command is one of the drop commands, then it refers to that object; if it is not, then if there is one and only one object at the current cursor position, it refers to that object; if that is also not the case, an error message is generated.
814 %
815 % \iffalse
816 \def\ssname#1{
817 \sssetglobalname{\ssglobalname{#1}}
818 }
819 % \fi
820 %
821 % \DescribeMacro{\ssgoto}
822 % After an object has been given a \meta{name} with |\ssname|, the cursor can be moved back to that object at any time by issuing |\ssgoto{|\meta{name}|}|. This becomes necessary when there is more than one object in one position.
823 %
824 % \iffalse
825 \newcommand{\ssgoto}[1]{
826 \ssabsgoto{\ssglobalname{#1}}
827 }
828 % \fi
829 %
830 % \DescribeMacro{\ssprefix}
831 % Often the mechanism provided by |\ssname|/|\ssgoto| is not flexible enough to deal with repeated code. In that case, |\ssprefix{|\meta{prefix}|}| defines a prefix for all names that follow; i.e. a |\ssname{|\meta{name}|}| after such a command will really define a name \meta{prefix}\meta{name}. However, since |\ssgoto| also observes the prefix, |\ssgoto{|\meta{name}|}| will still work. |\ssprefix| commands can be iterated; the prefices are then concatenated (most recent right).
832 %
833 % \iffalse
834 \newcommand{\ssprefix}[1]{
835 \edef\currprefix{\currprefix#1}
836 }
837 % \fi
838 %
839 % \DescribeMacro{\ssresetprefix}
840 % This command resets the prefix defined by (a sequence of) |\ssprefix| to the empty prefix.
841 %
842 % \iffalse
843 \newcommand{\ssresetprefix}{\def\currprefix{}}
844 % \fi
845 %
846 % \DescribeMacro{\ssabsgoto}
847 % This is a version of |\ssgoto| that ignores the current prefix.
848 %
849 % \ifthenelse{0=1}{
850 \newcommand{\ssabsgoto}[1]{
851 \ifthenelse{\boolean{sseqhasopenconn}}
852 {
853 \sseqconcludeconnection
854 }{}
855 \ssfinishpos
856 \edef\sseq@currentname{\csname sseqpos<#1>\endcsname}
857 \sseqposx=\csname sseqx<#1>\endcsname
858 \sseqposy=\csname sseqy<#1>\endcsname
859 \sseq@updatecurrentdata
860 }
861 % }{}
862 %
863 % \DescribeMacro{\ssdroplabel}
864 % This command decorates the previously typeset object with a label. It is used in the form
865 % |\ssdroplabel[|\meta{options...}|]{|\meta{label}|}|.
866 %
867 % The \meta{label} will then be typeset next to the most recently dropped object (for a definition for what that is, exactly, consult the description of |\ssname|). If you specify one of |U|,|LU|,|RU|,|L|,|R|,|LD|,|RD|,|D| as an option, the label is positioned relative to the object it labels (default: |U|=up).
868 % As in |\ssdrop|, an option |color=|\meta{color} will typeset the label in the \LaTeX{} color \meta{color}.
869 %
870 % \ifthenelse{0=1}{
871 \define@key{sseqlabel}{color}{\def\sslabelcolor{#1}}
872 \define@key{sseqlabel}{pos}{\def\sseq@position{#1}}
873 \define@key{sseqlabel}{U}[]{\def\sseq@position{U}}
874 \define@key{sseqlabel}{LU}[]{\def\sseq@position{LU}}
875 \define@key{sseqlabel}{L}[]{\def\sseq@position{L}}
876 \define@key{sseqlabel}{LD}[]{\def\sseq@position{LD}}
877 \define@key{sseqlabel}{D}[]{\def\sseq@position{D}}
878 \define@key{sseqlabel}{RD}[]{\def\sseq@position{RD}}
879 \define@key{sseqlabel}{R}[]{\def\sseq@position{R}}
880 \define@key{sseqlabel}{RU}[]{\def\sseq@position{RU}}
881 %
882 \def\ssdroplabel{\@ifnextchar[\sseq@droplabel{\sseq@droplabel[]}}
883 \def\sseq@droplabel[#1]#2{
884 \ssassertsource
885 \ifcurroutofrange\else
886 \edef\sseq@savecolor{\sslabelcolor}
887 \def\sseq@position{L}
888 \setkeys{sseqlabel}{#1}
889 %
890 \ifthenelse{\equal{\sseq@position}{U}}{\def\sseq@anchor{north} \def\sseq@link{south}}{}
891 \ifthenelse{\equal{\sseq@position}{LU}}{\def\sseq@anchor{north west} \def\sseq@link{south east}}{}
892 \ifthenelse{\equal{\sseq@position}{L}}{\def\sseq@anchor{west} \def\sseq@link{east}}{}
893 \ifthenelse{\equal{\sseq@position}{LD}}{\def\sseq@anchor{south west} \def\sseq@link{north east}}{}
894 \ifthenelse{\equal{\sseq@position}{D}}{\def\sseq@anchor{south} \def\sseq@link{north}}{}
895 \ifthenelse{\equal{\sseq@position}{RD}}{\def\sseq@anchor{south east} \def\sseq@link{north west}}{}
896 \ifthenelse{\equal{\sseq@position}{R}}{\def\sseq@anchor{east} \def\sseq@link{west}}{}
897 \ifthenelse{\equal{\sseq@position}{RU}}{\def\sseq@anchor{north east} \def\sseq@link{south west}}{}
898 %
899 \sseqwritecolor{\sslabelcolor}
900 \putxyq{\pgftransformshift}
901 \putxy{{\noexpand\pgfpointanchor{\sseq@currentname}{\sseq@anchor}}}
902 \putxyq{\pgfnode{rectangle}}
903 \putxy{{\sseq@link}}
904 \putxyq{{\ensuremath{#2}}{}{\pgfusepath{discard}}}
905 \putxyq{\pgftransformreset}
906 \edef\sslabelcolor{\sseq@savecolor}
907 \fi
908 }
909 % }{}
910 %
911 % \DescribeMacro{\ssdropextension}
912 % This command has no arguments and is rather specialized. It refers to a previously dropped object (see |\ssname|), draws a circle around it, and considers that circle a new object. Thus it produces a new circle object that is attached to the original object, and not subject to the algorithm that tries to make objects non-overlapping.
913 %
914 % \ifthenelse{0=1}{
915 \define@key{sseqdropext}{circled}[true]{\newif\ifKV@sseqdrop@circled\csname KV@sseqdrop@circled#1\endcsname}
916 \define@key{sseqdropext}{boxed}[true]{\newif\ifKV@sseqdrop@boxed\csname KV@sseqdrop@boxed#1\endcsname}
917 \define@key{sseqdropext}{color}{\def\ssplacecolor{#1}}
918 \define@key{sseqdropext}{name}{\def\sseq@name{#1}}
919 %
920 \def\ssdropextension{\@ifnextchar[\sseq@dropextension{\sseq@dropextension[]}}
921 \def\sseq@dropextension[#1]{
922 \edef\sseq@savecolor{\ssplacecolor}
923 \def\sseq@name{\relax}
924 \presetkeys{sseqdropext}{circled=false,boxed=false}{}
925 \setkeys{sseqdrop}{#1}
926 \ssassertsource
927 \expandafter\def\expandafter\tmpname\expandafter{\csname sseqdrop\the\sseqposx,\the\sseqposy\endcsname}
928 \edef\setcnt{\noexpand\count0=\tmpname}
929 \setcnt
930 \advance\count0 by 1
931 \expandafter\edef\tmpname{\the\count0}
932 \putxyq{\pgftransformshift}
933 \putxy{{\noexpand\pgfpointanchor{\sseq@currentname}{center}}}
934 \ifoutofrange
935 \putxyq{\pgfnode{coordinate}{center}{}}
936 \putxy{{ss(\the\sseqposx,\the\sseqposy)\tmpname}{}}
937 \else
938 \sseqwritecolor{\ssplacecolor}
939 \sseq@setcircumference
940 \ifKV@sseqdrop@boxed
941 \putxyq{\pgfnode{rectangle}{center}{}}
942 \else
943 \putxyq{\pgfnode{circle}{center}{}}
944 \fi
945 \putxy{{ss(\the\sseqposx,\the\sseqposy)\tmpname}}
946 \putxyq{{\pgfusepath{stroke}}}
947 \fi
948 \putxyq{\pgftransformreset}
949 %
950 % ^^A now give it a unique name
951 %
952 \edef\sseq@currentname{ss(\number\sseqposx,\number\sseqposy)\tmpname}
953 \expandafter\edef\csname \sseq@currentname size\endcsname{\number\ss@size sp}
954 %
955 \ifthenelse{\boolean{sseqhasopenconn}}{\sseqconcludeconnection}{}
956 %
957 \edef\ssplacecolor{\sseq@savecolor}
958 \def\temp{\relax}
959 \ifx\sseq@name\temp \else
960 \@eval\ssname{{\sseq@name}}
961 \fi
962 }
963 %
964 \def\ssprepareline#1#2{
965 \ssassertsource\ssfinishpos
966 \advance\sseqposx by #1
967 \advance\sseqposy by #2
968 \sseq@updatecurrentdata
969 \setboolean{sseqhasopenconn}{true}
970 }
971 %
972 \def\extractcoords ss(#1,#2)#3{{#1}{#2}}
973 %
974 \def\sseq@flushconn{
975 \ifx\sseq@connbuffer\empty\else
976 \ifsseq@connreverse
977 \putxy{\noexpand\pgfsetarrows{\sseq@currarrowend-\sseq@currarrowstart}}
978 \else
979 \putxy{\noexpand\pgfsetarrows{\sseq@currarrowstart-\sseq@currarrowend}}
980 \fi
981 \sseq@connbuffer
982 \def\sseq@connbuffer{}
983 \def\sseq@currarrowstart{}
984 \def\sseq@currarrowend{}
985 \fi
986 }
987 % ^^A parameters: 1 = dashing (e.g. {{1pt}{1pt}} = dashed, {} = solid)
988 % ^^A 2 = bending ({} = no bend)
989 % ^^A 3 = target is void (true/false)
990 %
991 \def\sseq@connection#1#2#3{
992 \sseq@flushconn
993 \ifthenelse{\boolean{#3}}{}{\ssassertsource}
994 \sseq@connreversefalse
995 \edef\sseq@prevxy{\expandafter\extractcoords\sseq@previousname}
996 \expandafter\ss@getcoords\sseq@prevxy
997 % ^^A now prevxy={fromx}{fromy}, \ifoutofrange=fromclip, \sseqx,\sseqy = fromcoords (if in range)
998 % ^^A sseqposx=tox,sseqposy=toy, \ifcurroutofrange=toclip, \sseqabsposx,\sseqabsposy = tocoords (if in range)
999 % ^^A only do it if not both source and target are outside the clipping region
1000 \ifcurroutofrange
1001 \ifoutofrange % ^^A both out of range -- do nothing
1002 \else % ^^Afrom within range to out of range -- draw a void line
1003 % ^^A need to recompute the relative coordinates
1004 \@eval\sseq@diffhelper{\sseq@prevxy{\number\sseqposx}{\number\sseqposy}}
1005 \@eval\sseq@lineintooff{{\sseq@previousname}\sseq@prevxy{\number\count0}{\number\count1}{#1}{#2}}
1006 \fi
1007 \else
1008 \ifoutofrange % ^^A from out of range to within range -- draw a void line
1009 \ifthenelse{\boolean{#3}}{}{ % ^^A if the target is also void -- do nothing.
1010 \sseq@connreversetrue
1011 \@eval\sseq@diffhelper{{\number\sseqposx}{\number\sseqposy}\sseq@prevxy}
1012 \@eval\sseq@lineintooff{{\sseq@currentname}{\sseqposx}{\sseqposy}{\number\count0}{\number\count1}{#1}{#2}}
1013 }
1014 \else
1015 \putxyq{\pgfsetdash{#1}{0pt}}
1016 \ifthenelse{\boolean{#3}}{ % ^^A draw a void line
1017 \multiply\sseqx by -1
1018 \advance\sseqx by \sseqabsposx
1019 \multiply\sseqy by -1
1020 \advance\sseqy by \sseqabsposy
1021 \putxy{\noexpand\pgftransformshift{\noexpand\pgfpointanchor{\sseq@previousname}{center}}}
1022 \putxyq{\pgfpathmoveto}
1023 \putxy{{\noexpand\pgfpointshapeborder{\sseq@previousname}%
1024 {\noexpand\pgfpoint{\the\sseqx}{\the\sseqy}}}}
1025 }{
1026 \putxyq{\pgfpathmoveto}
1027 \putxy{{\noexpand\pgfpointshapeborder{\sseq@previousname}{\noexpand \pgfpointanchor{\sseq@currentname}{center}}}}
1028 }
1029 \putxyq{\pgfpathlineto}
1030 \ifthenelse{\boolean{#3}}{
1031 \putxy{{\noexpand\pgfpoint{\the\sseqx}{\the\sseqy}}}
1032 }{
1033 \putxy{{\noexpand\pgfpointshapeborder{\sseq@currentname}{\noexpand \pgfpointanchor{\sseq@previousname}{center}}}}
1034 }
1035 \def\sseq@temp{#2}
1036 \ifx\sseq@temp\empty
1037 \else
1038 \putxyq{\pgfdecorationsegmentamplitude=#2pc}
1039 \putxyq{\multiply\pgfdecorationsegmentamplitude by 3 }
1040 \putxyq{\pgfdecorationsegmentaspect=.3}
1041 \putxyq{\pgfdecoratecurrentpath{bent}}
1042 \fi
1043 \edef\sseq@connbuffer{\noexpand\sseqwritecolor{\ssconncolor}\noexpand\putxyq{\noexpand\pgfusepath{stroke}\noexpand\pgftransformreset}}
1044 \fi
1045 \fi
1046 }
1047 % ^^A xmin,ymin,xmax,ymax --> \count0,\count1
1048 \def\sseq@diffhelper#1#2#3#4{
1049 \count0=#1
1050 \multiply\count0 by -1
1051 \advance\count0 by #3
1052 \count1=#2
1053 \multiply\count1 by -1
1054 \advance\count1 by #4
1055 }
1056 % }{}
1057 %
1058 %
1059 % \DescribeMacro{\ssstroke}
1060 % There are two ways of typesetting connections between objects. One of them is the command |\ssstroke|, which
1061 % requires that the cursor recently moved from one object to another. It takes no non-optional arguments and typesets a
1062 % line between the two objects. Example: Suppose there are two objects, which have been given the names |a| and |b|
1063 % by |\ssname|. Drawing a line between them is achieved by the command |\ssgoto{a} \ssgoto{b} \ssstroke|.
1064 %
1065 % The following options can be given in the form |\ssstroke[options]|:
1066 % \begin{description}
1067 % \item[|color=|color] the connection is drawn in the given \LaTeX{} color
1068 % \item[|curve=|value] the connection is curved to the left by an amount proportional to the value given.
1069 % \item[{|dashed|[=dashing type]}] the connection is drawn in a dashed style. The optional \emph{dashing type} is an
1070 % expression of the form |{{a}{b}...}|, where each of a, b, \dots is a length (like 2pt or 3mm). The line then consists of
1071 % a stroke of length |a|, followed by a gap of length |b|, followed by a stroke of length ... etc.
1072 % \item[{|dotted|[=dashing type]}] the connection is drawn in a dotted style. If the optional dashing type is given,
1073 % this option behaves exactly like |dashed|.
1074 % \item[{|arrowfrom|[=arrow style]}] An arrow is drawn at the beginning of the line. The global arrow style can be overridden
1075 % by specifying an arrow style.
1076 % \item[{|arrowto|[=arrow style]}] An arrow is drawn at the end of the line.
1077 % \item[|void|] This option says that the target of the connection is not another object; instead, the connection should just point into the correct direction.
1078 % \end{description}
1079 %
1080 % \ifthenelse{0=1}{
1081 %
1082 \define@key{sseqstroke}{color}{\def\ssconncolor{#1}}
1083 \define@key{sseqstroke}{curve}{\def\sseq@curve{#1}}
1084 \define@key{sseqstroke}{dashed}[{{2pt}{2pt}}]{\def\sseq@dashing{#1}}
1085 \define@key{sseqstroke}{dotted}[{{.5pt}{2pt}}]{\def\sseq@dashing{#1}}
1086 \define@key{sseqstroke}{arrowfrom}[\sseq@defaultarrowstyle]{\edef\sseq@arrowfrom{#1}}
1087 \define@key{sseqstroke}{arrowto}[\sseq@defaultarrowstyle]{\edef\sseq@arrowto{#1}}
1088 \define@key{sseqstroke}{void}[true]{\newif\ifKV@sseqstroke@void\csname KV@sseqstroke@void#1\endcsname}
1089 %
1090 \def\ssstroke{\@ifnextchar[\sseq@stroke{\sseq@stroke[]}}
1091 \def\sseq@stroke[#1]{
1092 \edef\sseq@savecolor{\ssconncolor}
1093 \def\sseq@dashing{}
1094 \def\sseq@curve{}
1095 \edef\sseq@arrowfrom{\sseq@currarrowstart}
1096 \edef\sseq@arrowto{\sseq@currarrowend}
1097 \presetkeys{sseqstroke}{void=false}{}
1098 \setkeys{sseqstroke}{#1}
1099 \ifKV@sseqstroke@void % ^^A a void line
1100 \@eval\sseq@connection{{\sseq@dashing}{\sseq@curve}{true}}
1101 \else
1102 \@eval\sseq@connection{{\sseq@dashing}{\sseq@curve}{false}}
1103 \fi
1104 \edef\sseq@currarrowstart{\sseq@arrowfrom}
1105 \edef\sseq@currarrowend{\sseq@arrowto}
1106 \edef\ssconncolor{\sseq@savecolor}
1107 }
1108 % }{}
1109 %
1110 % ^^A Keep these for compatibility
1111 % \ifthenelse{0=1}{
1112 \newcommand{\sscurve}[1]{\sseq@stroke[curve=#1]}
1113 \newcommand{\ssdashedstroke}{\sseq@stroke[dashed]}
1114 \newcommand{\ssdashedcurve}[1]{\sseq@stroke[dashed,curve=#1]}
1115 \newcommand{\ssdottedstroke}{\sseq@stroke[dotted]}
1116 \newcommand{\ssdottedcurve}[1]{\sseq@stroke[dotted,curve=#1}
1117 % }{}
1118 %
1119 % \DescribeMacro{\ssarrowhead}
1120 % \DescribeMacro{\ssinversearrowhead}
1121 % Instead of specifying |arrowfrom| or |arrowto| in |ssstroke|, you can issue these commands afterwards to typeset an arrow head onto the beginning resp. end of the connection most recently typeset. There is one optional parameter |[|\meta{arrow style}|]| which selects the arrow tips of style \meta{arrow style}, cf. the documentation of |\ssstroke|.
1122 %
1123 % \ifthenelse{0=1}{
1124 \newcommand{\ssarrowhead}[1][\sseq@defaultarrowstyle]{\edef\sseq@currarrowend{#1}}
1125 \newcommand{\ssinversearrowhead}[1][\sseq@defaultarrowstyle]{\edef\sseq@currarrowstart{#1}}
1126 % }{}
1127 %
1128 % \DescribeMacro{\ssline}
1129 % A second way of producing connections is |\ssline[|\meta{options...}|]{|\meta{x}|}{|\meta{y}|}|. This command draws a connection from the most recent object (cf. |\ssname|) to an object at relative position (\meta{x},\meta{y}), and it moves that cursor to that new position. If |\ssline| is followed by a drop command, then the line is attached to this newly dropped object (note the slightly out-of-order execution!), no matter how many other objects there are at the target position. However, if it is not followed by a drop command, then there has to be one and only one object at the target position, otherwise an error message is generated. The options are exactly the same as for |\ssstroke|.
1130 %
1131 % \iffalse
1132 %
1133 \def\ssline{\@ifnextchar[\sseq@line{\sseq@line[]}}
1134 \def\sseq@line[#1]#2#3{
1135 \ssprepareline{#2}{#3}
1136 \edef\sseqconncommand{\noexpand\ssstroke[color=\ssconncolor,#1]}
1137 }
1138 \newcommand{\sscurvedline}[3]{\ssline[curve=#3]{#1}{#2}}
1139 \newcommand{\ssdashedline}[2]{\ssline[dashed]{#1}{#2}}
1140 \newcommand{\sscurveddashedline}[3]{\ssline[curve=#3,dashed]{#1}{#2}}
1141 % \fi
1142 %
1143 % \DescribeMacro{\ssarrow}
1144 % |\ssarrow[|\meta{options...}|]{|\meta x|}{|\meta y|}| is an abbreviation for\\
1145 % |\ssline[|\meta{options...}|,arrowto]{|\meta x|}{|\meta y|}|
1146 %
1147 % \ifthenelse{0=1}{
1148 \newcommand{\ssarrow}[3][]{
1149 \ssline[arrowto,#1]{#2}{#3}
1150 }
1151 \newcommand{\sscurvedarrow}[3]{\ssline[arrowto,curve=#3]{#1}{#2}}
1152 \newcommand{\ssdashedarrow}[2]{\ssline[arrowto,dashed]{#1}{#2}}
1153 \newcommand{\sscurveddashedarrow}[3]{\ssline[arrowto,dashed,curve=#3]{#1}{#2}}
1154 %
1155 %
1156 \def\ssvoidline#1#2{
1157 \ssassertsource
1158 \edef\sseq@resetcmd{\noexpand\sseqposx=\number\sseqposx%
1159 \noexpand\sseqposy=\number\sseqposy%
1160 \noexpand\def\noexpand\sseq@currentname{\sseq@currentname}
1161 \noexpand\sseq@updatecurrentdata}
1162 \ssmove{#1}{#2}
1163 \ssstroke[void]
1164 \sseq@resetcmd
1165 }
1166 \newcommand{\ssvoidarrow}[2]{\ssvoidline{#1}{#2}\ssarrowhead}
1167 \newcommand{\ssinversevoidarrow}[2]{\ssvoidline{#1}{#2}\ssinversearrowhead}
1168
1169 % This follows the conventions of pgf, i.e. #1, #2, #3, #4 are pgfpoints, return is a pgfpoint on the
1170 % intersection of line #3 in direction #4 with axis-linear rectangle #1-#2.
1171 \def\sseq@pointintersectionoflinewithrectangle#1#2#3#4{
1172 \pgf@process{#1}
1173 \pgf@xa=\pgf@x
1174 \pgf@ya=\pgf@y
1175 \pgf@process{#2}
1176 \pgf@xb=\pgf@x
1177 \pgf@yb=\pgf@y
1178 \pgf@process{#3}
1179 \pgf@xc=\pgf@x
1180 \pgf@yc=\pgf@y
1181 \pgf@process{#4}
1182 \dimen0=100cm % ^^A infinity
1183 \dimen1=100cm % ^^A infinity
1184 % ^^A
1185 \ifnum\pgf@x>0pt % ^^A line goes to the right
1186 \dimen0=\pgf@xb
1187 \advance\dimen0 by -\pgf@xc
1188 \divide\dimen0 by \pgf@x
1189 \fi
1190 \ifnum\pgf@x<0pt % ^^A line goes to the left
1191 \dimen0=\pgf@xa
1192 \advance\dimen0 by -\pgf@xc
1193 \divide\dimen0 by \pgf@x
1194 \fi
1195 \ifnum\pgf@y>0pt % ^^A line goes up
1196 \dimen1=\pgf@yb
1197 \advance\dimen1 by -\pgf@yc
1198 \divide\dimen1 by \pgf@y
1199 \fi
1200 \ifnum\pgf@y<0pt % ^^A line goes down
1201 \dimen1=\pgf@ya
1202 \advance\dimen1 by -\pgf@xc
1203 \divide\dimen1 by \pgf@y
1204 \fi
1205 \ifnum\dimen1<\dimen0
1206 \dimen0=\dimen1
1207 \fi
1208 % ^^A now dimen0 contains the stretching factor for #4 to the right point.
1209 \multiply\pgf@x by \dimen0
1210 \multiply\pgf@y by \dimen0
1211 \advance\pgf@x by \pgf@xc
1212 \advance\pgf@y by \pgf@yc
1213 }
1214
1215 %
1216 % ^^A draw a line from the named position #1 (coord #2,#3) to relative position (#4,#5).
1217 % ^^A clip it where appropriate.
1218 % ^^A #6 = dashing (e.g. {{1pt}{1pt}} = dashed, {} = solid)
1219 % ^^A #7 = bending ({} = no bend)
1220 %
1221
1222 \def\sseq@lineintooff#1#2#3#4#5#6#7{
1223 \putxyq{\begin{pgfscope}}
1224 \sseqj=0
1225 \def\tempcmd{\range@loop{\sseq@findxrange{#2}{#3}}}
1226 \expandafter\tempcmd\sseq@xrange
1227 % ^^A now \sseqxx = xmin, \sseqyy = ymin, \sseqx = xmax, \sseqy = ymax.
1228 \putxyq{\pgfsetdash{#6}{0pt}}
1229 \putxyq{\sseq@pointintersectionoflinewithrectangle}
1230 \putxy{{\noexpand\pgfpoint{\number \sseqxx sp}{\number \sseqyy sp}}}
1231 \putxy{{\noexpand\pgfpoint{\number \sseqx sp}{\number \sseqy sp}}}
1232 \putxyq{{\pgfpointanchor{#1}{center}}{\pgfpoint{#4 sp}{#5 sp}}}
1233 \putxyq{\sseqx=\pgf@x}
1234 \putxyq{\sseqy=\pgf@y}
1235 \putxyq{\pgfpathmoveto}
1236 \putxy{{\noexpand\pgfpointshapeborder{#1}%
1237 {\noexpand\pgfpoint{\noexpand\sseqx}{\noexpand\sseqy}}}}
1238 \putxyq{\pgfpathlineto}
1239 \putxyq{{\pgfpoint{\sseqx}{\sseqy}}}
1240 \def\temp{#7}
1241 \ifx\temp\empty
1242 \else
1243 \dimen0=#7pc
1244 \ifsseq@connreverse
1245 \multiply\dimen0 by -1
1246 \fi
1247 \putxy{\noexpand\pgfdecorationsegmentamplitude=\number\dimen0 sp}
1248 \putxyq{\advance\pgfdecorationsegmentamplitude by \pgfdecorationsegmentamplitude}
1249 \putxyq{\pgfdecorationsegmentaspect=.3}
1250 \putxyq{\pgfdecoratecurrentpath{bent}}
1251 \fi
1252
1253 \edef\sseq@connbuffer{\noexpand\sseqwritecolor{\ssconncolor}%
1254 \noexpand\putxyq{\noexpand\pgfusepath{stroke}\noexpand\end{pgfscope}}}
1255 }
1256
1257
1258 \def\sseq@findxrange#1#2#3#4{
1259 \ifnum#1<#3\else
1260 \ifnum#1>#4\else
1261 % ^^A found the correct range
1262 \sseqj=0
1263 \def\tempcmd{\range@loop{\sseq@findyrange{#1}{#2}{#3}{#4}}}
1264 \expandafter\tempcmd\sseq@yrange
1265 \rangebreaktrue
1266 \fi
1267 \fi
1268 }
1269 \def\sseq@findyrange#1#2#3#4#5#6{
1270 \ifnum#2<#5\else
1271 \ifnum#2>#6\else
1272 % ^^A found the correct range -- do the drawing
1273 \ss@getcoords{#3}{#5} % ^^A lower left corner in \sseqx,\sseqy
1274 \advance\sseqx by -\sseq@xleak
1275 \advance\sseqy by -\sseq@yleak
1276 \sseqxx=\sseqx
1277 \sseqyy=\sseqy
1278 \ss@getcoords{#4}{#6} % ^^A upper right corner in \sseqx,\sseqy
1279 \advance\sseqx by \sseq@xleak
1280 \advance\sseqx by \sseqentrysize
1281 \advance\sseqy by \sseq@yleak
1282 \advance\sseqy by \sseqentrysize
1283 \rangebreaktrue
1284 \fi
1285 \fi
1286 }
1287
1288 % }{}
1289 %
1290 % \DescribeMacro{\ssbullstring}
1291 % |\ssbullstring{x}{y}{n}| is a shortcut for |\ssdrop{\bullet}| followed by $n-1$ copies of |\ssline{x}{y} \ssdrop{\bullet}|.
1292 % \iffalse
1293 \newcommand{\ssbullstring}[3]{
1294 \ifnum#3>0
1295 \ifnum#3=1
1296 \ssdropbull
1297 \else
1298 \ssdropbull
1299 \ssline{#1}{#2}
1300 \count0=#3
1301 \advance\count0 by -1
1302 \edef\sseqbullcnt{\the\count0}
1303 \ssbullstring{#1}{#2}{\sseqbullcnt}
1304 \fi\fi
1305 }
1306 % \fi
1307 %
1308 % \DescribeMacro{\ssinfbullstring}
1309 % |\ssinfbullstring{x}{y}{n}| is a shortcut for |\ssdrop{\bullet}| followed by $n-1$ copies of |\ssline{x}{y} \ssdrop{\bullet}|, followed by |\ssarrow[void]{x}{y}|. The cursor finishes on the last bullet.
1310 %
1311 % \iffalse
1312 \newcommand{\ssinfbullstring}[3]{
1313 \ssbullstring{#1}{#2}{#3}
1314 \ssvoidarrow{#1}{#2}
1315 }
1316 % \fi
1317 %
1318 % \section{Examples}
1319 %
1320 %
1321 % \newtheorem{ex}{Example}
1322 %
1323 %\begin{ex}
1324 %The following code generates a $5 \times 5$ grid with labels between $-2$ and $2$. The size of every square is $(.8cm)^2$, and labels are written on every square. The grid is chess-style. A bullet is drawn at coordinate (0,0).
1325 %
1326 %\noindent
1327 %\begin{minipage}{\textwidth/2}
1328 %\begin{verbatim}
1329 %\begin{sseq}[grid=chess,labelstep=1,
1330 % entrysize=.8cm]{-2...2}{-2...2}
1331 %\ssdropbull
1332 %\end{sseq}
1333 %\end{verbatim}
1334 %\end{minipage}
1335 %\begin{minipage}{\textwidth/2}
1336 %\def\sseqgridstyle{\ssgridchess}
1337 %\begin{sseq}[grid=chess,labelstep=1,entrysize=.8cm]{-2...2}{-2...2}
1338 %\ssdropbull
1339 %\end{sseq}
1340 %\end{minipage}
1341 %\end{ex}
1342 %
1343 %
1344 %\begin{ex}
1345 %This example demonstrates how to move the cursor and drop objects and labels. Note how the last bullet, which is dropped at position (8,4), is outside the grid and thus clipped. The grid style is the default (|crossword|). \bigskip
1346 %
1347 %\noindent
1348 %\begin{minipage}{\textwidth/2}
1349 %\begin{verbatim}
1350 %\begin{sseq}{0...6}{0...6}
1351 %\ssdropbull
1352 %\ssdroplabel{(0,0)}
1353 %\ssmove 2 1
1354 %\ssdrop{\clubsuit}
1355 %\ssdropextension
1356 %\ssdropextension
1357 %\ssdropextension
1358 %\ssdroplabel[RU]{(2,1)}
1359 %\ssmove 0 4
1360 %\ssdropcircled{8}
1361 %\ssmoveto 5 4
1362 %\ssdropboxed{\spadesuit}
1363 %\ssdroplabel[R]{(5,4)}
1364 %\ssmove 3 0
1365 %\ssdropbull
1366 %\end{sseq}
1367 %\end{verbatim}
1368 %\end{minipage}
1369 %\begin{minipage}{\textwidth/2}
1370 %\begin{sseq}{0...6}{0...6}
1371 %\ssdropbull
1372 %\ssdroplabel{(0,0)}
1373 %\ssmove 2 1
1374 %\ssdrop{\clubsuit}
1375 %\ssdropextension
1376 %\ssdropextension
1377 %\ssdropextension
1378 %\ssdroplabel[RU]{(2,1)}
1379 %\ssmove 0 4
1380 %\ssdropcircled{8}
1381 %\ssmoveto 5 4
1382 %\ssdropboxed{\spadesuit}
1383 %\ssdroplabel[R]{(5,4)}
1384 %\ssmove 3 0
1385 %\ssdropbull
1386 %\end{sseq}
1387 %\end{minipage}
1388 %\end{ex}
1389 %
1390 %\begin{ex}
1391 %This example illustrates the different ways of drawing connections.
1392 %\bigskip
1393 %
1394 %\noindent
1395 %\begin{minipage}{\textwidth/2}
1396 %\begin{verbatim}
1397 %\begin{sseq}[grid=go]{0...9}{0...6}
1398 %\ssdropbull
1399 %\ssmove 4 4
1400 %\ssdropbull \ssstroke
1401 %\sscurve{-.5}
1402 %\ssdashedcurve{.1} \ssarrowhead
1403 %\ssmove 4 0 \ssdropcircled{T}
1404 %\ssstroke
1405 %\ssmoveto 0 6
1406 %\ssdropbull
1407 %\ssline {1} {-1}
1408 %\sscurvedline 7 {-1} {.2}
1409 %\ssdropbull
1410 %\end{sseq}
1411 %\end{verbatim}
1412 %\end{minipage}
1413 %\begin{minipage}{\textwidth/2}
1414 %\begin{sseq}[grid=go]{0...9}{0...6}
1415 %\ssdropbull
1416 %\ssmove 4 4
1417 %\ssdropbull \ssstroke
1418 %\sscurve{-.5}
1419 %\ssdashedcurve{.1} \ssarrowhead
1420 %\ssmove 4 0 \ssdropcircled{T}\ssstroke
1421 %\ssmoveto 0 6
1422 %\ssdropbull
1423 %\ssline {1} {-1}
1424 %\ssdropbull
1425 %\sscurvedline 7 {-1} {.2}
1426 %\end{sseq}
1427 %\end{minipage}
1428 %\end{ex}
1429 %
1430 %\begin{ex}
1431 %This sample code shows how to use names for objects dropped in spectral sequence; this is particularly useful when more than one item is dropped at one position. It also demonstrates void arrows, which do not need a target.
1432 %\bigskip
1433 %
1434 %\noindent
1435 %\begin{minipage}{\textwidth*2/3}
1436 %\begin{verbatim}
1437 %\begin{sseq}[grid=dots]{0...4}{0...4}
1438 %\ssdropbull \ssname{a} \ssvoidarrow 0 1
1439 %\ssdropbull \ssname{b} \ssvoidarrow 0 1
1440 %\ssdropbull \ssname{c} \ssvoidarrow 0 1
1441 %\ssdropextension \ssname{d}
1442 %\ssmove 4 4
1443 %\ssdropbull \ssname{e}
1444 %\ssdropbull \ssname{f}
1445 %\ssgoto a \ssgoto f \ssstroke
1446 %\ssgoto e \ssstroke
1447 %\ssgoto d \sscurve{.2}
1448 %\ssline 4 0 \ssdropbull
1449 %\end{sseq}
1450 %\end{verbatim}
1451 %\end{minipage}
1452 %\begin{minipage}{\textwidth/3}
1453 %
1454 %\begin{sseq}[grid=dots]{0...4}{0...4}
1455 %\ssdropbull \ssname{a}\ssvoidarrow 0 1
1456 %\ssdropbull \ssname{b}\ssvoidarrow 0 1
1457 %\ssdropbull \ssname{c}\ssvoidarrow 0 1
1458 %\ssdropextension \ssname{d}
1459 %\ssmove 4 4
1460 %\ssdropbull \ssname{e}
1461 %\ssdropbull \ssname{f}
1462 %\ssgoto a \ssgoto f \ssstroke
1463 %\ssgoto e \ssstroke
1464 %\ssgoto d \sscurve{.2}
1465 %\ssline 4 0 \ssdropbull
1466 %\end{sseq}
1467 %\end{minipage}
1468 %\end{ex}
1469 %
1470 %\begin{ex}
1471 % This final example shows how to take advantage of loops and prefices.
1472 %
1473 %\noindent
1474 %\begin{minipage}[t]{\textwidth*1/3}
1475 %\begin{verbatim}
1476 %\newcount\cnti
1477 %\def\drawstring#1#2{
1478 % \ifnum#2=1
1479 % \ssdropbull \ssname{#1}
1480 % \else
1481 % \ssdropbull \ssname{#1}
1482 % \ssline 1 0
1483 % \ssprefix{i}
1484 % \cnti=#2
1485 % \advance \cnti by -1
1486 % \drawstring{#1}
1487 % {\the\cnti}
1488 % \fi
1489 %}
1490 %\end{verbatim}
1491 %\end{minipage}
1492 %\begin{minipage}[t]{\textwidth*1/3}
1493 %\begin{verbatim}
1494 %\def\drawlines#1#2#3{
1495 % \ifnum#3>0
1496 % \cnti=#3
1497 % \ssgoto{#1} \ssgoto{#2}
1498 % \ssstroke \ssarrowhead
1499 % \ssprefix{i}
1500 % \advance \cnti by -1
1501 % \drawlines{#1}{#2}
1502 % {\the\cnti}
1503 % \fi
1504 %}
1505 %\end{verbatim}
1506 %\end{minipage}
1507 %\begin{minipage}[t]{\textwidth*1/3}
1508 %\begin{verbatim}
1509 %\begin{sseq}[grid=none]
1510 % {0...8}{0...3}
1511 %\ssmoveto 0 3
1512 %\drawstring{a}{8}
1513 %\ssmoveto 0 3
1514 %\ssresetprefix
1515 %\drawstring{b}{8}
1516 %\ssmoveto 0 0
1517 %\ssresetprefix
1518 %\drawstring{c}{8}
1519 %\ssresetprefix
1520 %\drawlines{c}{a}{8}
1521 %\ssresetprefix
1522 %\drawlines{b}{iic}{6}
1523 %\end{sseq}
1524 %\end{verbatim}
1525 %\end{minipage}
1526 %
1527 % \bigskip
1528 %
1529 % The result is shown in the following chart:
1530 %\newcount\cnti
1531 %\def\drawstring#1#2{
1532 % \ifnum#2=1
1533 % \ssdropbull \ssname{#1}
1534 % \else
1535 % \ssdropbull \ssname{#1}
1536 % \ssline 1 0
1537 % \ssprefix{i}
1538 % \cnti=#2
1539 % \advance \cnti by -1
1540 % \drawstring{#1}
1541 % {\the\cnti}
1542 % \fi
1543 %}
1544 %\def\drawlines#1#2#3{
1545 % \ifnum#3>0
1546 % \cnti=#3
1547 % \ssgoto{#1} \ssgoto{#2}
1548 % \ssstroke \ssarrowhead
1549 % \ssprefix{i}
1550 % \advance \cnti by -1
1551 % \drawlines{#1}{#2}
1552 % {\the\cnti}
1553 % \fi
1554 %}
1555 %\begin{tabular}{l}
1556 %\begin{sseq}[grid=none]{0...8}{0...3}
1557 %\ssmoveto 0 3
1558 %\drawstring{a}{8}
1559 %\ssmoveto 0 3
1560 %\ssresetprefix
1561 %\drawstring{b}{8}
1562 %\ssmoveto 0 0
1563 %\ssresetprefix
1564 %\drawstring{c}{8}
1565 %\ssresetprefix
1566 %\drawlines{c}{a}{8}
1567 %\ssresetprefix
1568 %\drawlines{b}{iic}{6}
1569 %\end{sseq}
1570 %\end{tabular}
1571 %\end{ex}
1572 %
1573 %\section{Final remarks}
1574 %
1575 % This package has been extremely helpful for my own mathematical work, and it most likely carries the characteristics of a tool initially developed for my own purposes only. Before this published version, there was an earlier version of |sseq| which was much less powerful; and what is worse, this version is not fully upward compatible with the previous one. (Every object that was dropped was forgotten right afterwards; thus connections could not properly connect objects but were always drawn from the center of the box corresponding to a coordinate to the center of the box corresponding to the target coordinate, resulting in fairly ugly pictures.)
1576 %
1577 % Many things remain to be desired:
1578 %
1579 % \begin{itemize}
1580 % \item |sseq| seems to be too voracious in memory
1581 % \item While object are placed next to each other, no attempt is made not to make connections overlap
1582 % \item A ``grayout'' option that automatically turns the source and target of any arrow into a different color would be highly useful for spectral sequence charts
1583 % \end{itemize}
1584 %
1585 % Given time and leisure, I might or might not implement one or more of these improvements and make them available; of course, I would be even more happy if somebody else did it. (Needless to say, I would request that I be informed of and sent the enhancements.) I do guarantee that all further versions of |sseq| that might or might not be written by me will be compatible with the documented code written for this version.
1586 %
1587 % \endinput
1588 %
1589 %
1590 \def\ssgridcrossword#1#2{
1591 \pgfsetlinewidth{\the\sseq@gridstrokethickness}
1592 \pgfpathgrid[stepx=\the\sseqentrysize,stepy=\the\sseqentrysize]{\pgfpointorigin}{\pgfpoint{#1*\sseqentrysize}{#2*\sseqentrysize}}
1593 \pgfusepath{stroke}
1594 }
1595
1596 \def\ssgridgo#1#2{
1597 \pgfsetlinewidth{\the\sseq@gridstrokethickness}
1598 \pgftransformxshift{\the\sseqhalfentry}
1599 \pgftransformyshift{\the\sseqhalfentry}
1600 \pgfpathgrid[stepx=\the\sseqentrysize,stepy=\the\sseqentrysize]{\pgfpoint{-\the\sseqhalfentry}{-\the\sseqhalfentry}}{\pgfpoint{#1*\sseqentrysize-\sseqhalfentry}{#2*\sseqentrysize-\sseqhalfentry}}
1601 \pgfusepath{stroke}
1602 }
1603
1604 \def\ssgridnone#1#2{}
1605
1606 \def\ssgriddots#1#2{
1607 \pgfsetlinewidth{1pt}
1608 \pgfsetdash{{1pt}{\the\sseqentrysize-1pt}}{\the\sseqhalfentry+.5pt}
1609 \pgftransformxshift{\the\sseqhalfentry}
1610 \pgftransformyshift{\the\sseqhalfentry}
1611 \pgfpathgrid[stepx=\the\sseqentrysize,stepy=\the\sseqentrysize]{\pgfpoint{-\the\sseqhalfentry}{-\the\sseqhalfentry}}{\pgfpoint{#1*\sseqentrysize-\sseqhalfentry}{#2*\sseqentrysize-\sseqhalfentry}}
1612 \pgfusepath{stroke}
1613 }
1614
1615 \def\ssgridchess#1#2{
1616 \pgfsetlinewidth{\the\sseqentrysize}
1617 \pgfsetdash{{\the\sseqentrysize}{\the\sseqentrysize}}{\the\sseqentrysize}
1618 \pgfsetcolor{sslightgr}
1619 \pgftransformxshift{\the\sseqhalfentry}
1620 \pgftransformyshift{\the\sseqhalfentry}
1621 \pgfpathgrid[stepx=\the\sseqentrysize*2,stepy=\the\sseqentrysize*2]{\pgfpoint{-\the\sseqhalfentry}{-\the\sseqhalfentry}}{\pgfpoint{#1*\sseqentrysize-\sseqhalfentry}{#2*\sseqentrysize-\sseqhalfentry}}
1622 \pgfusepath{stroke}
1623 }
1624
1625 \def\sseq@drawgrid{
1626 \expandafter\ifx\sseqgridstyle\ssequndefined
1627 \PackageError{sseq}{Unknown grid option, reverting to \string\ssgridnone}{You apparently have redefined \string\sseqgridstyle. The only allowed values are: \string\ssgridnone,\string\ssgriddots,\string\ssgridgo,\string\ssgridcrossword,\string\ssgridchess.}
1628 \gdef\sseqgridstyle{\ssgridnone}
1629 \fi
1630 \sseqj=0
1631 \def\tempcmd{\range@loop{\sseq@innergridloop}}
1632 \expandafter\tempcmd\sseq@xrange
1633 }
1634 % ^^A The following is called for every part #1...#2
1635 %
1636 \def\sseq@innergridloop#1#2{
1637 \sseqj=0
1638 \def\tempcmd{\range@loop{\sseq@gridwrapper{#1}{#2}}}
1639 \expandafter\tempcmd\sseq@yrange
1640 }
1641 \def\sseq@gridwrapper#1#2#3#4{
1642 \begin{pgfscope}
1643 \ss@getcoords{#1}{#3}
1644 \sseqxx=\sseqx
1645 \sseqyy=\sseqy
1646 \count0=#2\advance\count0 by 1
1647 \count1=#4\advance\count1 by 1
1648 \pgftransformshift{\pgfpoint{\the\sseqxx}{\the\sseqyy}}
1649 \count2=#1
1650 \multiply\count2 by -1
1651 \advance\count0 by \count2
1652 \count2=#3
1653 \multiply\count2 by -1
1654 \advance\count1 by \count2
1655 \@eval\sseqgridstyle{{\number\count0}{\number\count1}}
1656 \end{pgfscope}
1657 }
1658 %
1659 % ^^A \sseq@drawlabels
1660 %
1661 \def\sseq@drawlabels{
1662 \sseqj=0
1663 \def\tempcmd{\range@loop{\sseqk=-\sseqxstep \sseq@drawhorizontallabels}}
1664 \expandafter\tempcmd\sseq@xrange
1665 \sseqj=0
1666 \def\tempcmd{\range@loop{\sseqk=-\sseqystep \sseq@drawverticallabels}}
1667 \expandafter\tempcmd\sseq@yrange
1668 }
1669 %
1670
1671 \def\sseq@drawhorizontallabels#1#2{
1672 \advance\sseqk by \sseqxstep
1673 \sseqi=#1
1674 \ifnum\sseqi>#2\else
1675 \ss@getcoords{\the\sseqi}{0}
1676 \advance\sseqx by \sseqhalfentry
1677 \sseqxlabel
1678 \sbox\sseq@labelbox{\strut\ensuremath{\sseq@answer}}
1679 \dimen0 = \ht\sseq@labelbox
1680 \advance\dimen0 by \dp\sseq@labelbox
1681 \pgf@protocolsizes{0pt}{-\dimen0} % ^^A fixes a bug with bounding boxes in pgf
1682 \pgftext[top,at=\pgfpoint{\the\sseqx}{0pt}]{\usebox{\sseq@labelbox}}
1683 \advance\sseqi by \sseqxstep
1684 \edef\tempcmd{\noexpand\sseq@drawhorizontallabels{\number\sseqi}{#2}}
1685 \expandafter\tempcmd
1686 \fi
1687 }
1688 %
1689 \def\sseq@drawverticallabels#1#2{
1690 \advance\sseqk by \sseqystep
1691 \sseqi=#1
1692 \ifnum\sseqi>#2\else
1693 \ss@getcoords{0}{\the\sseqi}
1694 \advance\sseqy by \sseqhalfentry
1695 \sseqylabel
1696 \pgftext[right,at=\pgfpoint{-2pt}{\the\sseqy}]{\ensuremath{\sseq@answer}}
1697 \advance\sseqi by \sseqystep
1698 \edef\tempcmd{\noexpand\sseq@drawverticallabels{\number\sseqi}{#2}}
1699 \expandafter\tempcmd
1700 \fi
1701 }
1702 %
1703 % ^^A #1 = number of outer part
1704 % ^^A #2 = number of inner part
1705 %
1706 %
1707 \def\sseq@labelfromlist#1#2#3,{
1708 \def\temp{#3}
1709 \def\tempcmd{}
1710 \ifx\temp\range@endmarker
1711 \def\sseq@answer{?}
1712 \else
1713 \count0=#1
1714 \ifnum\count0=0
1715 \def\sseq@lastlabel{}
1716 \def\tempcmd{\sseq@innerlabelfromlist{#2}#3;END;}
1717 \else
1718 \advance\count0 by -1
1719 \edef\tempcmd{\noexpand\sseq@labelfromlist{\number\count0}{#2}}
1720 \fi
1721 \fi
1722 \tempcmd
1723 }
1724
1725 \def\sseq@innerlabelfromlist#1#2;{
1726 \def\temp{#2}
1727 \def\tempcmd{}
1728 \ifx\temp\range@endmarker
1729 \ifx\sseq@lastlabel\empty
1730 \def\sseq@answer{?}
1731 \else
1732 \count0=#1
1733 \ifnum\count0=0
1734 \def\sseq@answer{\ensuremath{\sseq@lastlabel}}
1735 \def\tempcmd{\range@gobbletoend}
1736 \else
1737 \advance\count0 by -1
1738 \edef\tempcmd{\noexpand\sseq@innerlabelfromlist{\number\count0}END;}
1739 \fi
1740 \fi
1741 \else
1742 \def\sseq@lastlabel{#2}
1743 \count0=#1
1744 \ifnum\count0=0
1745 \def\sseq@answer{\ensuremath{#2}}
1746 \def\tempcmd{\range@gobbletoend}
1747 \else
1748 \advance\count0 by -1
1749 \edef\tempcmd{\noexpand\sseq@innerlabelfromlist{\number\count0}}
1750 \fi
1751 \fi
1752 \tempcmd
1753 }
1754 %
1755 % ^^A options that can be passed to sseq
1756 %
1757 \define@key{sseq}{grid}{
1758 \expandafter\def\expandafter\sseqgridstyle\expandafter{\csname ssgrid#1\endcsname}
1759 }
1760 %
1761 \define@key{sseq}{entrysize}{
1762 \sseqentrysize=#1
1763 }
1764 \define@key{sseq}{labels}{
1765 \setkeys{sseq}{xlabels=#1,ylabels=#1}
1766 }
1767 \define@key{sseq}{xlabels}{
1768 \def\temp{#1}
1769 \def\temptwo{none}
1770 \ifx\temp\temptwo
1771 \def\sseqxlabel{\def\sseq@answer{}}
1772 \else
1773 \def\temptwo{numbers}
1774 \ifx\temp\temptwo
1775 \def\sseqxlabel{\def\sseq@answer{\the\sseqi}}
1776 \else
1777 \def\sseqxlabel{%
1778 \@eval\sseq@labelfromlist{{\number\sseqj}{\number\sseqk}}#1,END,%
1779 }
1780 \fi
1781 \fi
1782 }
1783 \define@key{sseq}{ylabels}{
1784 \def\temp{#1}
1785 \def\temptwo{none}
1786 \ifx\temp\temptwo
1787 \def\sseqylabel{\def\sseq@answer{}}
1788 \else
1789 \def\temptwo{numbers}
1790 \ifx\temp\temptwo
1791 \def\sseqylabel{\def\sseq@answer{\the\sseqi}}
1792 \else
1793 \def\sseqylabel{%
1794 \@eval\sseq@labelfromlist{{\number\sseqj}{\number\sseqk}}#1,END,%
1795 }
1796 \fi
1797 \fi
1798 }
1799 \define@key{sseq}{xlabelstep}{\sseqxstep=#1}
1800 \define@key{sseq}{ylabelstep}{\sseqystep=#1}
1801 \define@key{sseq}{labelstep}{\setkeys{sseq}{xlabelstep=#1}\setkeys{sseq}{ylabelstep=#1}}
1802
1803 \define@key{sseq}{gapsize}{\setkeys{sseq}{xgapsize=#1}\setkeys{sseq}{ygapsize=#1}}
1804 \define@key{sseq}{xgapsize}{\sseq@xgap=#1}
1805 \define@key{sseq}{ygapsize}{\sseq@ygap=#1}
1806 \define@key{sseq}{leak}{\setkeys{sseq}{xleak=#1}\setkeys{sseq}{yleak=#1}}
1807 \define@key{sseq}{xleak}{\sseq@xleak=#1}
1808 \define@key{sseq}{yleak}{\sseq@yleak=#1}
1809 \define@key{sseq}{gridstroke}{\sseq@gridstrokethickness=#1}
1810 \define@key{sseq}{arrows}{\def\sseq@defaultarrowstyle{#1}}
1811 %
1812 % ^^A Defaults
1813 %
1814 \sseqentrysize=0.4cm
1815 \sseq@xgap=0.3cm
1816 \sseq@ygap=0.3cm
1817 \global\sseq@xleak=-100mm
1818 \global\sseq@yleak=-100mm
1819 \sseqxstep=2
1820 \sseqystep=2
1821 \def\sseqgridstyle{\ssgridcrossword}
1822 \def\sseq@defaultarrowstyle{to}
1823
1824 \newenvironment{sseq}[3][]{%
1825 \begingroup
1826 %
1827 % ^^A Start the PGF environment
1828 \begin{pgfpicture}
1829 %
1830 % ^^A Initialize some local counters and dimensions
1831 %
1832 \countdef\sseqi=152%
1833 \countdef\sseqj=153%
1834 \countdef\sseqxdir=154%
1835 \countdef\sseqposx=155%
1836 \countdef\sseqposy=156%
1837 \countdef\sseqydir=157%
1838 \countdef\sseqk=158%
1839 \dimendef\sseqhalfentry=205%
1840 \dimendef\sseqx=206%
1841 \dimendef\sseqy=207%
1842 \dimendef\sseqxx=208%
1843 \dimendef\sseqyy=209%
1844 \dimendef\sseqabsposx=210%
1845 \dimendef\sseqabsposy=211%
1846 \sseq@gridstrokethickness=.1pt%
1847 %\ifnum\sseqxstep<0 \sseqxdir=-1 \else \sseqxdir=1 \fi
1848 %\ifnum\sseqystep<0 \sseqydir=-1 \else \sseqydir=1 \fi
1849 %
1850 % Backup count0 - count9 (these are page numbers!)
1851 %
1852 \edef\sseqsavecnto{\number\count0}%
1853 \edef\sseqsavecnti{\number\count1}%
1854 \edef\sseqsavecntii{\number\count2}%
1855 \edef\sseqsavecntiii{\number\count3}%
1856 \edef\sseqsavecntiv{\number\count4}%
1857 \edef\sseqsavecntv{\number\count5}%
1858 \edef\sseqsavecntvi{\number\count6}%
1859 \edef\sseqsavecntvii{\number\count7}%
1860 \edef\sseqsavecntviii{\number\count8}%
1861 \edef\sseqsavecntix{\number\count9}%
1862 %
1863 % ^^A Parse arguments
1864 %
1865 %
1866 \setkeys{sseq}{#1}
1867 %
1868 \ifnum\sseqxstep=0 % ^^A old-fashioned way of disabling labels
1869 \setkeys{sseq}{xlabels=none}
1870 \sseqxstep=1
1871 \else
1872 \@ifundefined{sseqxlabel}{\setkeys{sseq}{xlabels=numbers}}{}
1873 \fi
1874 \ifnum\sseqystep=0 % ^^A old-fashioned way of disabling labels
1875 \setkeys{sseq}{ylabels=none}%
1876 \sseqystep=1
1877 \else
1878 \@ifundefined{sseqylabel}{\setkeys{sseq}{ylabels=numbers}}{}
1879 \fi
1880 \ifdim\sseq@xleak=-100mm
1881 \sseq@xleak=0.3\sseq@xgap
1882 \fi
1883 \ifdim\sseq@yleak=-100mm
1884 \sseq@yleak=0.3\sseq@ygap
1885 \fi
1886 %
1887 %
1888 %
1889 \range@parseandnormalize{\sseq@xrange}{\sseqxstart}{#2}
1890 \range@parseandnormalize{\sseq@yrange}{\sseqystart}{#3}
1891 %
1892 % ^^A Some setup
1893 \pgfsetshapeminwidth{1.1mm}
1894 \pgfsetshapeinnerxsep{1pt}
1895 \pgfsetshapeinnerysep{1pt}
1896 %
1897 \sseqhalfentry=\sseqentrysize
1898 \divide\sseqhalfentry by 2
1899 %
1900 \sseq@drawgrid
1901 \sseq@drawlabels
1902 %
1903 % ^^A Move to turtle to (0,0)
1904 \sseqposx=0
1905 \sseqposy=0
1906 %\sseq@updatecurrentdata
1907 }
1908 %
1909 %
1910 % ^^A PART FOR \end{sseq}
1911 %
1912 {
1913 \relax
1914 \ssmoveto 0 0 \ssmoveto 0 0
1915 \edef\lst{\the\sseqcmdlist}
1916 \ifthenelse{\boolean{debug}}{\show\lst}{}
1917 \the\sseqcmdlist
1918 %
1919 % ^^A Restore count0-count9 in case we're in the middle of a page break.
1920 %
1921 \count0=\sseqsavecnto
1922 \count1=\sseqsavecnti
1923 \count2=\sseqsavecntii
1924 \count3=\sseqsavecntiii
1925 \count4=\sseqsavecntiv
1926 \count5=\sseqsavecntv
1927 \count6=\sseqsavecntvi
1928 \count7=\sseqsavecntvii
1929 \count8=\sseqsavecntviii
1930 \count9=\sseqsavecntix
1931 \end{pgfpicture}
1932 \endgroup
1933 }
1934 %
1935 % \Finale