diff options
author | Karl Berry <karl@freefriends.org> | 2009-04-10 23:38:46 +0000 |
---|---|---|
committer | Karl Berry <karl@freefriends.org> | 2009-04-10 23:38:46 +0000 |
commit | 454868a5f2b777edfb9823ae5a2f2f93d029b95c (patch) | |
tree | 8e68bd61407c42c11c90af1e1b47b1e099728c93 /Master/texmf-dist/source/latex/sseq | |
parent | c1d46af88c872513681359f3318adf75eff204e6 (diff) |
sseq 2.0 (10apr09)
git-svn-id: svn://tug.org/texlive/trunk@12686 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/source/latex/sseq')
-rw-r--r-- | Master/texmf-dist/source/latex/sseq/sseq.dtx | 1965 |
1 files changed, 1227 insertions, 738 deletions
diff --git a/Master/texmf-dist/source/latex/sseq/sseq.dtx b/Master/texmf-dist/source/latex/sseq/sseq.dtx index dbc22b65f95..64914ae4f5b 100644 --- a/Master/texmf-dist/source/latex/sseq/sseq.dtx +++ b/Master/texmf-dist/source/latex/sseq/sseq.dtx @@ -3,193 +3,241 @@ % ^^A to produce the package file sseq.sty. % ^^A Then LaTeX this file to produce the documentation of the sseq package. % ^^A -% ^^A (c) 2003 Tilman Bauer. Freely distributable under the LaTeX Project Public License (LPPL) +% ^^A (c) 2003-2007 Tilman Bauer. Freely distributable under the LaTeX Project Public License (LPPL) % ^^A -% \iffalse +% \ifthenelse{0=1}{ %<*never> \documentclass{ltxdoc} -\usepackage[dvips]{sseq} +\usepackage{sseq} +\EnableCrossrefs +\CodelineIndex +\RecordChanges \begin{document} -\DocInput{sseq.dtx} +\DocInput{sseq.dtx} \PrintIndex \PrintChanges \end{document} %</never> -% \fi +% }{} % % \changes{v1.0}{November 12, 2003}{First release of code and documentation} % \changes{v1.01}{November 15, 2003}{Bug fix with clipping after a ssgoto} % \changes{v1.02}{November 18, 2003}{Bug fix that would mess up page numbering in some cases} % \changes{v1.03}{December 11, 2003}{Added examples to documentation, bug fix in grid drawing} -% -% \iffalse +% \changes{v1.04}{January 19, 2004}{Up to nine drops per square now possible, added customization of the grid} +% \changes{v1.05}{December 9, 2004}{Added support for different packing strategies; support for dotted lines} +% \changes{v1.06}{August 1, 2005}{sseqxstep=0 will now suppress printing of horizontal label; similarly sseqystep=0 and vertical labels} +% \changes{v2.0a}{July 16, 2007}{Completely recoded the graphics for using pgf instead of xyPic. Many new features. Consult the manual.} +% \changes{v2.0}{April 9, 2009}{bug fix with arrows leaving the chart} +% \ifthenelse{0=1}{ %<*package> \NeedsTeXFormat{LaTeX2e} -\ProvidesPackage{sseq} +\ProvidesPackage{sseq}[2009/04/09 ver 2.0] \RequirePackage{ifthen,calc,pifont} +\RequirePackage{pgf}[2006/01/01] +\RequirePackage{xkeyval} +\usepgflibrary{snakes} -\newboolean{usesps} -\setboolean{usesps}{true} +%^^A \newboolean{usesps} +%^^A \setboolean{usesps}{true} % Deprecated for pgf version of sseq \newboolean{usescolor} \setboolean{usescolor}{true} \newboolean{debug} \setboolean{debug}{false} -\DeclareOption{ps}{\setboolean{usesps}{true}} -\DeclareOption{nops}{\setboolean{usesps}{false}} +\DeclareOption{ps}{\errmessage{sseq: ps/nops is deprecated}} +\DeclareOption{nops}{\errmessage{sseq: ps/nops is deprecated}} +\DeclareOption{dvips}{\errmessage{sseq: deprecated option dvips ignored}} +\DeclareOption{xdvi}{\errmessage{sseq: deprecated option xdvi ignored}} \DeclareOption{color}{\setboolean{usescolor}{true}} \DeclareOption{nocolor}{\setboolean{usescolor}{false}} \DeclareOption{debug}{\setboolean{debug}{true}} -\DeclareOption*{\PassOptionsToPackage{\CurrentOption}{xy}} \ProcessOptions -\ifx\xyloaded\undefined \RequirePackage[curve,frame]{xy} \fi - -\ifthenelse{\boolean{usesps}}{\xyrequire{ps}}{} -\ifthenelse{\boolean{usescolor}}{\xyrequire{color}}{} - - %</package> -% \fi +% }{} % % \title{Typesetting spectral sequences in \LaTeX\ with sseq.sty} -% \author{Tilman Bauer\footnote{tbauer@math.uni-muenster.de}} -% \date{November 12, 2003} +% \author{Tilman Bauer\footnote{tilman@alum.mit.edu}} +% \date{April 9, 2009} % % \MakeShortVerb{\|} +% % \maketitle % % \section{Introduction} -% +% % The present package, \texttt{sseq}, facilitates the typesetting of mathematical objects called \emph{spectral sequence charts} (henceforth simply called ``chart''). From a typographical point of view, a chart is a two-dimensional grid with integer coordinates; at every position (x,y), there may be any number of symbols (usually dots, little circles or boxes, digits etc.), possibly decorated with labels, and between any two such symbols may or may not be a connection---e.~g., a line, an arrow, or some curved line. % -% The \texttt{sseq} package is built on top of the \Xy-pic package by K.~H.~Rose and R.~Moore. It shares the disadvantage of using up lots of \TeX's memory; therefore, if your system provides a \texttt{biglatex} or \texttt{hugelatex} command, it is wise to use it when using \texttt{sseq}. Still, problems may arise with very large charts (i.e., more than $100\times100$). +% 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). % -% This package automates the following functions and thereby offers an improvement over pure \Xy-pic graphics: +% This package automates the following functions: % % \begin{itemize} % \item Automatic drawing of the grid and the axis labels; % \item Clipping. Anything outside the displayed portion of the chart is clipped away. This has the advantage that a large chart, which does not fit on a page, can be cut into smaller pieces which contain exactly the same \texttt{sseq} code, but different clipping regions. % \item Arranging. Multiple symbols dropped at the same integer coordinates will be automatically arranged so that they usually do not overlap. The algorithm for doing this is rather primitive, but still powerful enough for most applications -% \item Simplified ``turtle graphics'' syntax. Every primitive element of a chart is typeset with a macro defined by \texttt{sseq}; no cryptic command lines like in \Xy-pic. -% \item More flexibility. Control structures (loops, if/then, etc.) are allowed inside the \texttt{sseq} environment. +% \item Simplified ``turtle graphics'' syntax. Every primitive element of a chart is typeset with a macro defined by \texttt{sseq}. +% \item Control structures (loops, if/then, etc.) are allowed inside the \texttt{sseq} environment. % \end{itemize} % % % \section{Global options} -% +% % The |sseq| package is loaded with % -% |\usepackage[|\emph{options...}|]{sseq}|. +% |\usepackage[|\meta{options...}|]{sseq}|. % % The following options are defined: % % \begin{itemize} -% \item |nops| will tell \Xy-pic not to generate PostScript code but to use special \TeX fonts to typeset the diagrams. This is preferable if you do not have a PostScript printer; however, the overhead in memory and time usage is so enormous that this should only serve as a last resort against incompatibilities +% \item |nops| is a deprecated option of a previous version. It is ignored. % \item |nocolor| will tell |sseq| not to generate any color information. This includes gray shades. Many |dvi| drivers do not support color, but most of them tolerate (i.e. ignore) the color directives. -% \item |debug| will typeout the \Xy-pic code generated by every |sseq| environment and wait for the user to confirm. -% \item any other options are fed into \Xy-pic. Thus, for example, the option |dvips| will tell \Xy-pic to generate code for the |dvips| driver. +% \item |debug| will type out the pgf code generated by every |sseq| environment and wait for the user to confirm. % \end{itemize} % % % \section{Basic usage} % +% \DescribeEnv{sseq} % A spectral sequence is typeset by the code % -% |\begin{sseq}{x}{y}| +% |\begin{sseq}[|\meta{options...}|]{|\meta{x-range}|}{|\meta{y-range}|}| % -% \emph{(sseq commands...)} +% \meta{sseq commands...} % % |\end{sseq}| % -% Here |x| and |y| are nonnegative integers specifying the size of the grid. By default, the bottom left corner of the chart will have coordinates $(0,0)$; however, this can be changed by issung -% -% |\sseqxstart=|\emph{(starting x position)} -% -% |\sseqystart=|\emph{(starting y position)} -% -% By default, the size of one coordinate square is .4cm; this can be changed by -% -% |\sseqentrysize=|\emph{(new length)} -% -% Normally, all even labels are printed (for space reasons); this can be changed by -% -% |\sseqxstep=|\emph{(x-axis label step)} -% -% |\sseqystep=|\emph{(y-axis label step)} +% 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}. +% +% Thus |\begin{sseq}{2...5}{-3...-1}\end{sseq}| will typeset +% \[\begin{sseq}{2...5}{-3...-1}\end{sseq}.\] +% +% 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: +% +% \noindent\begin{minipage}{\textwidth/2} +% \begin{verbatim}\begin{sseq}{-1...3,5...8,20...24} +% {0...2,4...4} +%\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} +% +% 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. +% +% +% The following options are defined for the |sseq| environment. Options in bold face are the default setting. +% \begin{description} +% \item[|grid=|]\meta{none,\textbf{crossword},go,dots,chess} Select an option of drawing the background grid. +% +% \begin{tabular}{ccccc} +% none & crossword & go & dots & chess\\ +% \begin{sseq}[entrysize=2mm,labels=none,grid=none]{4}{4}\end{sseq} & +% \begin{sseq}[entrysize=2mm,labels=none,grid=crossword]{4}{4}\end{sseq} & +% \begin{sseq}[entrysize=2mm,labels=none,grid=go]{4}{4}\end{sseq} & +% \begin{sseq}[entrysize=2mm,labels=none,grid=dots]{4}{4}\end{sseq} & +% \begin{sseq}[entrysize=2mm,labels=none,grid=chess]{4}{4}\end{sseq} +% \end{tabular} +% \item[|entrysize=|\meta{size}] Specify the size of each square of the grid. The default is 4mm. +% \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|. +% \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. +% +% The following example illustrates how labels can be customized: +% +% \noindent\begin{minipage}{\textwidth*2/3} +% \begin{verbatim}\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{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} +% \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. +% \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. +% \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|. +% \item[|arrows=|\meta{arrow type}] Sets the default arrow type to use in the spectral sequence. Here are some default arrow types: +% +%\begin{sseq}[grid=none,labels=none]{0...3}{-2...0} +% \ssdrop{} \ssmove 3 0 \ssdrop{\mathtt{\;to}} \ssstroke[arrowto=to] \ssmove {-3}{-1} +% \ssdrop{} \ssmove 3 0 \ssdrop{\mathtt{\;stealth}} \ssstroke[arrowto=stealth] \ssmove {-3}{-1} +% \ssdrop{} \ssmove 3 0 \ssdrop{\mathtt{\;latex}} \ssstroke[arrowto=latex] +%\end{sseq} % -% Setting these to $1$ will typeset every label; setting it to $n$ will typeset every $n$th label. +% Other arrow types can be defined by the user or loaded from a library; see the pgf package documentation for details. +% \end{description} % -% All of the above have to be issued \textbf{before} the |\begin{sseq}| command. They remain valid for subsequent charts until changed again. +% You may specify which algorithm you want to use to arrange multiple objects in +% a grid square. The following are possible: +% \begin{itemize} +% \item |\def\sseqpacking{\sspacksmart}|: the default, arrange dots roughly as on a dice +% \item |\def\sseqpacking{\sspackhorizontal}|: put all objects in a horizontal line, vertically centered. +% \item |\def\sseqpacking{\sspackvertical}|: put all objects in a vertical line, horizontally centered. +% \item |\def\sseqpacking{\sspackdiagonal}|: put all objects in a line going from top left to bottom right. +% \end{itemize} % +% It is recommended to use the packing commands before the |\begin{sseq}| command; +% though it is possible to change the packing strategy within a single chart, the +% user has to take care to make sure that in every coordinate consistent packing +% strategies are used; the result will be unexpected otherwise. % % \section{sseq commands} % -% Inside an |sseq| environment there is defined a virtual cursor, which starts out at position $(0,0)$ (even if that position is not within the clipping region!). All drawing commands are relative to the current cursor position; this facilitates reusage of |sseq| code when a certain pattern has to be repeated, as is often the case in mathematical spectral sequences. -% +% 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. % -% ^^A Produce save boxes for the circled digits +% % \ifthenelse{0=1}{ -\newsavebox{\sseqcircledone} -\newsavebox{\sseqcircledtwo} -\newsavebox{\sseqcircledthree} -\newsavebox{\sseqcircledfour} -\newsavebox{\sseqcircledfive} -\newsavebox{\sseqcircledsix} -\newsavebox{\sseqcircledseven} -\newsavebox{\sseqcircledeight} -\newsavebox{\sseqcirclednine} -\sbox{\sseqcircledone}{\ding{192}} -\sbox{\sseqcircledtwo}{\ding{193}} -\sbox{\sseqcircledthree}{\ding{194}} -\sbox{\sseqcircledfour}{\ding{195}} -\sbox{\sseqcircledfive}{\ding{196}} -\sbox{\sseqcircledsix}{\ding{197}} -\sbox{\sseqcircledseven}{\ding{198}} -\sbox{\sseqcircledeight}{\ding{199}} -\sbox{\sseqcirclednine}{\ding{200}} % % -\newboolean{sseqhasfinishedpos} -\setboolean{sseqhasfinishedpos}{true} + +\def\sseq@currentname{} +\def\sseq@previousname{} + \newboolean{sseqhasopenconn} \setboolean{sseqhasopenconn}{false} \newboolean{sseqclip} \setboolean{sseqclip}{true} -\newboolean{sseqprevclip}\setboolean{sseqprevclip}{false} -\newboolean{sseqcurrclip}\setboolean{sseqcurrclip}{false} \def\sseqconncommand{} +\def\sseq@connbuffer{} +\def\sseq@currarrowstart{} +\def\sseq@currarrowend{} + +\newif\ifsseq@connreverse \ifthenelse{\boolean{usescolor}} { - \newxyColor{sseqgr}{0.65}{gray}{} - \newxycolor{ssred}{Red} - \newxycolor{ssblack}{Black} + \definecolor{sseqgr}{gray}{0.65} + \definecolor{sslightgr}{gray}{0.8} + \definecolor{ssred}{rgb}{1,0,0} + \definecolor{ssblack}{rgb}{0,0,0} }{} \newcommand{\ssconncolor}{ssblack} \newcommand{\sslabelcolor}{ssblack} \newcommand{\ssplacecolor}{ssblack} -\def\ssoldconncolor{ssblack} +\def\sseqpacking{\sspacksmart} +% ^^A This is one of: {\sspacksmart,\sspackhorizontal,\sspackdiagonal,\sspackvertical} %% ^^A Initialization \newcount\sseqxstart \sseqxstart=0 \newcount\sseqystart \sseqystart=0 -\newcount\sseqxstep \sseqxstep=2 -\newcount\sseqystep \sseqystep=2 -\newdimen\sseqentrysize \sseqentrysize=0.4cm +\newcount\sseqxstep +\newcount\sseqystep +\newdimen\sseqentrysize +\newdimen\sseq@xgap +\newdimen\sseq@ygap +\newdimen\sseq@xleak +\newdimen\sseq@yleak +\newdimen\ss@currsep \ss@currsep=\pgfshapeinnerxsep +\newdimen\ss@size +\newdimen\sseq@gridstrokethickness + +\newsavebox\sseq@labelbox + \newif\ifssclipped +\newif\ifcurroutofrange \newtoks\sseqcmdlist \sseqcmdlist={} \def\currprefix{} -\def\sseqcurrentname{} - \long\def\ntimes#1#2{ \ifnum#1>0 #2 @@ -200,27 +248,163 @@ \fi } -\newif\ifforcondition +\long\def\for #1=#2\to#3\do#4\od{#1=#2 \sseq@for #1\to #3\do #4\od} +\long\def\sseq@for #1\to #2\do #3\od{% + \ifnum #1>#2 \else + #3\relax + \advance #1 by 1 + \def\tempcmd{\sseq@for #1\to #2\do #3\od}% + \expandafter\tempcmd + \fi +} + +\def\@eval#1#2{% + \edef\tempcmd{\noexpand#1#2}% + \tempcmd +} +% +% ^^A Support macros for ranges (like "-3...5,12...18") +% +\def\range@endmarker{END} +% +% +% ^^A range@parsenadnormalize{\targetcommand}{defaultstart}{string} +% +\def\range@parseandnormalize#1#2#3{\def#1{}\range@parseandnormalizeinnerloop{#1}{#2}{-10000}#3,END,} +% +\def\range@parseandnormalizeinnerloop#1#2#3#4,{% + \def\temp{#4}% + \ifx\temp\range@endmarker + \edef #1{#1END;END,}% + \else + \def\tempoutercmd{\range@parseinnerpart{#1}{#2}{#3}#4...END...}% + \expandafter\tempoutercmd + \fi +} +% +\def\range@parseinnerpart#1#2#3#4...#5...{% + \def\temp{#5} + \ifx\temp\range@endmarker + \count0=#2 + \advance\count0 by #4 + \advance\count0 by -1 + \edef\tempcmd{\noexpand\range@parseinnerpart{\noexpand#1}{#2}{#3}#2...\number\count0...END...} + \else + \count0=#3 + \count1=#4 + \count2=#5 + \ifnum\count1<\count0 + \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.} + \count1=#3 + \fi + \ifnum\count2<\count1 + \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.} + \count2=\count1 + \fi + \count0=\count2 + \advance\count0 by 2 + \edef#1{#1\number\count1;\number\count2,} + \edef\tempcmd{\noexpand\range@parsegobbleend{\noexpand#1}{#2}{\number\count0}} + \fi + \tempcmd +} +% +\def\range@parsegobbleend#1#2#3#4...{% +\range@parseandnormalizeinnerloop{#1}{#2}{#3}% +} +% +% \range@loop {command} range +% +\newif\ifrangebreak +% +% +\def\range@loop#1#2;#3,{ + \rangebreakfalse + \def\temp{#2} + \def\tempcmd{} + \ifx\temp\range@endmarker\else + #1{#2}{#3} + \advance\sseqj by 1 + \ifrangebreak + \def\tempcmd{\range@gobbletoend} + \else + \def\tempcmd{\range@loop{#1}} + \fi + \fi + \tempcmd +} +% +% +\newif\ifoutofrange +% +% ^^A Compute absolute coordinates from logical ones +% ^^A return them in \sseqx and \sseqy +% +% ^^A \range@getabsoluteposition{pos}{stepinc}{gapinc}{offset}range +% ^^A return value in \dimen0; also set \ifoutofrange +% +\def\range@getabsoluteposition#1#2#3#4#5;#6,{ + \outofrangefalse + \def\temp{#5} + \def\tempcmd{} + \count0=#1 + \ifx\temp\range@endmarker + \outofrangetrue + \else % ^^A now #4 contains the current min and #5 the current max + \ifnum\count0<#5 + \outofrangetrue + \def\tempcmd{\range@gobbletoend} + \else + \ifnum\count0>#6 + \count0=#6 + \advance\count0 by 1 + \count1=#5 + \multiply\count1 by -1 + \advance\count0 by \count1 + \dimen0=#2 + \multiply\dimen0 by \count0 + \advance\dimen0 by #4 + \advance\dimen0 by #3 + \edef\tempcmd{\noexpand\range@getabsoluteposition{#1}{#2}{#3}{\number\dimen0sp}} + \else + \count1=#5 + \multiply\count1 by -1 + \advance\count0 by \count1 + \dimen0=#2 + \multiply\dimen0 by \count0 + \advance\dimen0 by #4 + \def\tempcmd{\range@gobbletoend} + \fi + \fi + \fi + \tempcmd +} +\def\range@gobbletoend#1END,{} -\long\def\for#1=#2\to#3\do#4\od{ -#1=#2 -\loop -\ifnum#1>#3\forconditionfalse\else\forconditiontrue\fi -\ifforcondition - #4 - \advance #1 by 1 - \repeat +\def\ss@getcoords#1#2{ + \edef\tempcmd{\noexpand\range@getabsoluteposition{#1}{\number\sseqentrysize sp}{\number\sseq@xgap sp}{0pt}} + \expandafter\tempcmd\sseq@xrange + \sseqx=\dimen0 + \edef\tempcmd{\noexpand\range@getabsoluteposition{#2}{\number\sseqentrysize sp}{\number\sseq@ygap sp}{0pt}} + \ifoutofrange + \expandafter\tempcmd\sseq@yrange + \outofrangetrue + \else + \expandafter\tempcmd\sseq@yrange + \fi + \sseqy=\dimen0 } + % % ^^A \putxy will put a list of commands into the execution queue % \def\putxyq#1{\toks0={#1}% - \edef\act{\noexpand\sseqcmdlist={\the\sseqcmdlist \the\toks0}} + \edef\act{\noexpand\sseqcmdlist={\the\sseqcmdlist \the\toks0}}% \act } \def\putxy#1{% - \edef\act{\noexpand\sseqcmdlist={\the\sseqcmdlist #1}} + \edef\act{\noexpand\sseqcmdlist={\the\sseqcmdlist #1}}% \act } @@ -229,7 +413,7 @@ % \def\sseqwritecolor#1{ \ifthenelse{\boolean{usescolor}}{ - \putxy {[#1]} + \putxy{\noexpand\color{#1}} }{} } % @@ -237,8 +421,8 @@ % \def\sseqconcludeconnection{ -\sseqconncommand -\setboolean{sseqhasopenconn}{false} + \sseqconncommand + \setboolean{sseqhasopenconn}{false} } \def\dropvarname#1#2{\csname sseqdrop#1,#2\endcsname} @@ -260,59 +444,120 @@ \PackageError{sseq}{cannot open position (#1,#2): multiple drops}{You cannot specify this position by coordinates. Instead, name it.} \fi } - -\def\ssopenposition#1#2{ -\ifuniquedrop{#1}{#2} - \def\sseqcurrentname{ss(#1,#2)1} - \putxy{"\sseqcurrentname"} -\else \ssdroperrormsg{#1}{#2} -\fi -\setboolean{sseqhasfinishedpos}{false} +% +% ^^A update sseqabsposx, sseqabspoy, ifcurroutofrange from sseqposx, sseqposy. +% +\def\sseq@updatecurrentdata{ + \@eval\ss@getcoords{{\number\sseqposx}{\number\sseqposy}} + \sseqabsposx=\sseqx + \sseqabsposy=\sseqy + \let\ifcurroutofrange\ifoutofrange } -\newcommand{\ssassertsource}{ -\ifthenelse{\boolean{sseqhasfinishedpos}}{ -\ssopenposition{\the\sseqposx}{\the\sseqposy} -} -{} +\def\sseq@openposition{ + \ifuniquedrop{\the\sseqposx}{\the\sseqposy} + \edef\sseq@currentname{ss(\number\sseqposx,\number\sseqposy)1} + \else + \ssdroperrormsg{\the\sseqposx}{\the\sseqposy} + \def\sseq@currentname{} + \fi } -\newcommand{\ssputsemicolon}{ -\putxy{;} -\ifthenelse{\boolean{sseqcurrclip}}{ - \setboolean{sseqprevclip}{true}}{ - \setboolean{sseqprevclip}{false}} +\def\ssassertsource{ + \sseq@flushconn + \ifx\sseq@currentname\empty + \sseq@openposition + \fi } -\newcommand{\ssfinishpos}{ -\ifthenelse{\boolean{sseqhasfinishedpos}}{}{ -\setboolean{sseqhasfinishedpos}{true} -\ssputsemicolon -} -\ifthenelse{\boolean{sseqhasopenconn}} -{ - \ssopenposition{\the\sseqposx}{\the\sseqposy} - \sseqconcludeconnection - \ifthenelse{\boolean{sseqhasfinishedpos}}{}{ - \setboolean{sseqhasfinishedpos}{true} - \ssputsemicolon} -}{} +\def\ssfinishpos{ + \sseq@flushconn + \ifx\sseq@currentname\empty + \else + \ifthenelse{\boolean{sseqhasopenconn}} + { + \sseqconcludeconnection + }{} + \edef\sseq@previousname{\sseq@currentname} + \def\sseq@currentname{} + \fi +} + + +% ^^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. +\def\sspacksmart#1#2{ + \ifcase\count11 + % ^^A 0 + \PackageError{sseq}{This can't happen!}{Internal error. Contact the author.} + \or % ^^A 1 + \sseqrearrange{#1}{#2}{\the\count1}{\the\dimen6}{\the\dimen5} + \advance\sseqx by \dimen5 + \advance\sseqy by \dimen6 + \or % ^^A 2 + \sseqrearrange{#1}{#2}{\the\count2}{0pt}{\the\dimen5} + \sseqrearrange{#1}{#2}{\the\count2}{0pt}{\the\dimen5} + \advance\sseqy by \dimen6 + \or % ^^A 3 + \sseqrearrange{#1}{#2}{\the\count3}{\the\dimen6}{0pt} + \advance\sseqx by \dimen5 + \advance\sseqy by \dimen6 + \or % ^^A 4 -- give up on being clever and put everything in one diagonal row. + \sseqrearrange{#1}{#2}{\the\count2}{\the\dimen6}{\the\dimen6} + \sseqrearrange{#1}{#2}{\the\count3}{\the\dimen5}{0pt} + \sseqrearrange{#1}{#2}{\the\count3}{\the\dimen5}{0pt} + \sseqrearrange{#1}{#2}{\the\count4}{\the\dimen5}{\the\dimen6} + \advance\sseqx by \dimen5 + \advance\sseqx by \dimen5 + \advance\sseqx by \dimen5 + \advance\sseqy by \dimen6 + \advance\sseqy by \dimen6 + \advance\sseqy by \dimen6 + \else + \advance\count11 by -1 + \multiply\dimen5 by \count11 + \multiply\dimen6 by \count11 + \advance\sseqx by \dimen5 + \advance\sseqy by \dimen6 + \fi } -\newcommand{\ssnewpos}{ -\ssfinishpos -\setboolean{sseqhasfinishedpos}{false} +\def\sspackhorizontal#1#2{ + \divide\dimen6 by 2 + \divide\dimen5 by 2 + \for\count10=1 \to \count11 \do + \sseqrearrange{#1}{#2}{\the\count\count10}{\the\dimen6}{0pt} + \od + \multiply\dimen5 by \count11 + \advance\sseqx by \dimen5 +} +\def\sspackvertical#1#2{ + \divide\dimen6 by 2 + \divide\dimen5 by 2 + \for\count10=1 \to \count11 \do + \sseqrearrange{#1}{#2}{\the\count\count10}{0pt}{\the\dimen6} + \od + \multiply\dimen5 by \count11 + \advance\sseqy by \dimen5 +} +\def\sspackdiagonal#1#2{ + \divide\dimen6 by 2 + \divide\dimen5 by 2 + \for\count10=1 \to \count11 \do + \sseqrearrange{#1}{#2}{\the\count\count10}{\the\dimen6}{\the\dimen5} + \od + \multiply\dimen5 by \count11 + \multiply\dimen6 by \count11 + \advance\sseqx by \dimen5 + \advance\sseqy by \dimen6 } -\def\ssifposinclippingregion#1#2{ - \ssclippedtrue - \ifthenelse{\boolean{sseqclip}}{ - \ifnum#1<\sseqxstart \ssclippedfalse \fi - \ifnum#1<\sseqxend \else \ssclippedfalse \fi - \ifnum#2<\sseqystart \ssclippedfalse \fi - \ifnum#2<\sseqyend \else \ssclippedfalse \fi - }{} - \ifssclipped + +\def\sseqpack#1#2{ +\expandafter\ifx\sseqpacking\ssequndefined + \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.} + \gdef\sseqpacking{\sspacksmart} +\fi +\sseqpacking{#1}{#2} } \def\sseqrearrange#1#2#3#4#5{ @@ -337,48 +582,43 @@ \expandafter\count\the\count11=\count10 \fi \od - % ^^A Now count11 contains the number of previously dropped objects that have to be rearranged. - \ifcase\count11 - % ^^A 0 - \PackageError{sseq}{This can't happen!}{Internal error. Contact the author.} - \or % ^^A 1 - \sseqrearrange{#1}{#2}{\the\count1}{\the\dimen6}{\the\dimen5} - \advance\sseqx by \dimen5 - \advance\sseqy by \dimen6 - \or % ^^A 2 - \sseqrearrange{#1}{#2}{\the\count2}{0pt}{\the\dimen5} - \sseqrearrange{#1}{#2}{\the\count2}{0pt}{\the\dimen5} - \advance\sseqy by \dimen6 - \or % ^^A 3 - \sseqrearrange{#1}{#2}{\the\count3}{\the\dimen6}{0pt} - \advance\sseqx by \dimen5 + \ifnum\count11<9 \else - \PackageError{sseq}{Too many drops at (#1,#2)}{The sseq.sty algorithm can only place up to four independent drops in one position.} + \PackageError{sseq}{Too many drops at (#1,#2)}{The sseq.sty algorithm can only place up to nine independent drops in one position.} + \fi + \sseqpack{#1}{#2} +} + +% ^^A This sets the new shape inner x- and y-separation to the new value +% ^^A It avoids issuing a command if it's already set to the right value +\def\ss@setshapesep#1{ + \ifdim\ss@currsep=#1\else + \putxy{\noexpand\pgfsetshapeinnerxsep{#1}\noexpand\pgfsetshapeinnerysep{#1}} + \ss@currsep=#1 \fi } -\newcommand{\ssplacespecial}[4]{ -\ifthenelse{\boolean{sseqhasfinishedpos}}{}{ - \ssputsemicolon +\def\sseq@setcircumference{ + \expandafter\ss@size\expandafter=\expandafter\csname\sseq@currentname size\endcsname + \advance\ss@size by 1pt + \ss@setshapesep{\the\ss@size} } -\setboolean{sseqhasfinishedpos}{false} + +% ^^A This replaces \ssplacespecial in the xy version. +% ^^A Arguments: 1,2 = x- and y-coordinates +% ^^A 3 = pgf shape +% ^^A 4 = pgf path usage +% ^^A 5 = contents % +\def\ss@placespecial#1#2#3#4#5{ % -\sseqx=\sseqentrysize -\multiply\sseqx \sseqxdir -\multiply\sseqx by #1 -\advance\sseqx by \sseqhalfentry -\advance\sseqx by \sseqoffsetx -\advance\sseqx by \sseqoffx + \ssfinishpos % -\sseqy=\sseqentrysize -\multiply\sseqy \sseqydir -\multiply\sseqy by #2 -\advance\sseqy by \sseqhalfentry -\advance\sseqy by \sseqoffsety -\advance\sseqy by \sseqoffy + \ss@getcoords{#1}{#2} + \advance\sseqx by \sseqhalfentry + \advance\sseqy by \sseqhalfentry % -\expandafter\def\expandafter\tmpname\expandafter{\csname sseqdrop#1,#2\endcsname} + \expandafter\def\expandafter\tmpname\expandafter{\csname sseqdrop#1,#2\endcsname} % \ifnodrop{#1}{#2} \expandafter\def\tmpname{1} @@ -389,107 +629,104 @@ \advance\count0 by 1 \expandafter\edef\tmpname{\the\count0} \fi -\putxy{<\csname sseqcoordx<#1,#2>\tmpname\endcsname,\csname sseqcoordy<#1,#2>\tmpname \endcsname>} +\putxyq{\pgftransformshift} +\putxy{{\noexpand\pgfpoint{\csname sseqcoordx<#1,#2>\tmpname\endcsname}{\csname sseqcoordy<#1,#2>\tmpname \endcsname}}} +% +% +\ifoutofrange % ^^A Outside clipping region -- produce an empty node + \putxyq{\pgfnode{coordinate}{center}{}} + % ^^A now give it a unique name + \putxy{{ss(#1,#2)\tmpname}} + \putxyq{{}} +\else + \sseqwritecolor{\ssplacecolor} + \putxyq{\pgfnode{#3}{center}} + \putxyq{{#5}} +% ^^A now give it a unique name + \putxy{{ss(#1,#2)\tmpname}} + \putxyq{{#4}} +\fi +% +\putxyq{\pgftransformreset} +% +\def\temp{#5} +\ifx\temp\empty % ^^A It's a bullet or a circle or such + \dimen0=1pt +\else + \setbox0=\hbox{#5} + \dimen0=0.5\wd0 +\fi \expandafter\edef\csname sseqcoordx<#1,#2>\tmpname\endcsname{\the\sseqx} \expandafter\edef\csname sseqcoordy<#1,#2>\tmpname\endcsname{\the\sseqy} +\expandafter\edef\csname ss(#1,#2)\tmpname size\endcsname{\number\dimen0 sp} \expandafter\def\csname sseqwillmove<#1,#2>\tmpname\endcsname{1} -%^^A \putxy{<\the\sseqx,\the\sseqy>} -\setboolean{sseqcurrclip}{true} -\ssifposinclippingregion{#1}{#2} - \setboolean{sseqcurrclip}{false} - \putxy{*#3} - \sseqwritecolor{\ssplacecolor} - \putxy{#4} -\fi % -% ^^A now give it a unique name +\edef\sseq@currentname{ss(#1,#2)\tmpname} % -\edef\sseqcurrentname{ss(#1,#2)\tmpname} -\putxy{="\sseqcurrentname"} \ifthenelse{\boolean{sseqhasopenconn}}{\sseqconcludeconnection}{} } \newcommand{\ssplace}[3]{ -\ssplacespecial{#1}{#2}{}{{#3}} + \ss@setshapesep{0pt} + \putxyq{\pgfsetdash{}{0pt}} + \ss@placespecial{#1}{#2}{rectangle}{\pgfusepath{discard}}{\ensuremath{#3}} } \newcommand{\ssplaceboxed}[3]{ - \ifthenelse{\boolean{usescolor}}{ - \ssplacespecial{#1}{#2}{+<2pt>[F:\ssplacecolor]}{{#3}} - }{ - \ssplacespecial{#1}{#2}{+<2pt>}{{#3}} - } + \ss@setshapesep{1pt} + \putxyq{\pgfsetdash{}{0pt}} + \ss@placespecial{#1}{#2}{rectangle}{\pgfusepath{stroke}}{\ensuremath{#3}} } \newcommand{\ssplacecircled}[3]{ -\ifthenelse{\equal{#3}{1}}{ - \ssplacespecial{#1}{#2}{}{[o]{\copy\sseqcircledone}}}{ - \ifthenelse{\equal{#3}{2}}{ - \ssplacespecial{#1}{#2}{}{[o]{\copy\sseqcircledtwo}}}{ - \ifthenelse{\equal{#3}{3}}{ - \ssplacespecial{#1}{#2}{}{[o]{\copy\sseqcircledthree}}}{ - \ifthenelse{\equal{#3}{4}}{ - \ssplacespecial{#1}{#2}{}{[o]{\copy\sseqcircledfour}}}{ - \ifthenelse{\equal{#3}{5}}{ - \ssplacespecial{#1}{#2}{}{[o]{\copy\sseqcircledfive}}}{ - \ifthenelse{\equal{#3}{6}}{ - \ssplacespecial{#1}{#2}{}{[o]{\copy\sseqcircledsix}}}{ - \ifthenelse{\equal{#3}{7}}{ - \ssplacespecial{#1}{#2}{}{[o]{\copy\sseqcircledseven}}}{ - \ifthenelse{\equal{#3}{8}}{ - \ssplacespecial{#1}{#2}{}{[o]{\copy\sseqcircledeight}}}{ - \ifthenelse{\equal{#3}{9}}{ - \ssplacespecial{#1}{#2}{}{[o]{\copy\sseqcirclednine}}}{ - \ifthenelse{\boolean{usescolor}}{ - \ssplacespecial{#1}{#2}{+<3pt>}{[o][F:\ssplacecolor]{#3}} - }{ - \ssplacespecial{#1}{#2}{+<3pt>}{[o]{#3}} - } - } - } - } - } - } - } - } - } -} -} - -\newcommand{\ssbull}[2]{ -\ifthenelse{\boolean{usescolor}}{ - \ssplacespecial{#1}{#2}{+<1.1mm>[o][F:\ssplacecolor]}{{}*[\ssplacecolor]\noexpand\frm{*}} + \ifthenelse{\equal{#3}{1} + \OR \equal{#3}{2} + \OR \equal{#3}{3} + \OR \equal{#3}{4} + \OR \equal{#3}{5} + \OR \equal{#3}{6} + \OR \equal{#3}{7} + \OR \equal{#3}{8} + \OR \equal{#3}{9}}{ +% ^^A replace circled single digits by the corresponding dings -- looks better +% ^^A The following adjustment to the bounding circle is based on experimentation +% ^^A Let's hope it doesn't differ too much from one dingbat font to the other... + \ss@setshapesep{-.3ex} + \count0=191 + \advance\count0 by #3 + \def\ss@tmpcmd{\ss@placespecial{#1}{#2}{circle}{\pgfusepath{discard}}} + \expandafter\ss@tmpcmd\expandafter{\expandafter\ding\expandafter{\the\count0}} }{ - \ssplacespecial{#1}{#2}{+<1.1mm>[o]}{{}*\noexpand\frm{*}} + \putxyq{\pgfsetdash{}{0pt}} + \ss@setshapesep{0pt} + \ss@placespecial{#1}{#2}{circle}{\pgfusepath{stroke}}{\ensuremath{#3}} } } -\newcommand{\sscirc}[2]{ -\ssplacespecial{#1}{#2}{}{[o]-={\circ}} -} - \newcommand{\ssglobalname}[1]{\currprefix#1} \def\sssetglobalname#1{ \ssassertsource - \expandafter\edef\csname sseqpos<#1>\endcsname{\sseqcurrentname} + \expandafter\edef\csname sseqpos<#1>\endcsname{\sseq@currentname} \expandafter\edef\csname sseqx<#1>\endcsname{\the\sseqposx} \expandafter\edef\csname sseqy<#1>\endcsname{\the\sseqposy} } % }{} % % \DescribeMacro{\ssmoveto} -% To move the cursor to position (x,y), use |\ssmoveto{x}{y}|. +% To move the cursor to the absolute position (x,y), use |\ssmoveto{x}{y}|. % % \ifthenelse{0=1}{ \newcommand{\ssmoveto}[2]{ + \ifthenelse{\boolean{sseqhasopenconn}} + { + \sseqconcludeconnection + }{} \ssfinishpos \sseqposx=#1 \sseqposy=#2 -\ssifposinclippingregion{#1}{#2} - \setboolean{sseqcurrclip}{false} -\fi +\sseq@updatecurrentdata } % }{} % \DescribeMacro{\ssmove} @@ -497,50 +734,79 @@ % % \iffalse \newcommand{\ssmove}[2]{ -\count0=\sseqposx -\advance\count0 by #1 -\count1=\sseqposy -\advance\count1 by #2 -\ssmoveto{\count0}{\count1} +\sseqi=\sseqposx +\advance\sseqi by #1 +\sseqj=\sseqposy +\advance\sseqj by #2 +\@eval\ssmoveto{{\number\sseqi}{\number\sseqj}} } % \fi % +% % \DescribeMacro{\ssdrop} -% The command |\ssdrop{|\emph{mathcode}|}| will display \emph{mathcode} at the current cursor position. The argument is always interpreted in math mode. +% The command |\ssdrop[|\meta{optios}|]{|\meta{mathcode}|}| will display \emph{mathcode} at the current cursor position. The argument is always interpreted in math mode. +% The following options can be given: +% \begin{description} +% \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. +% \item[|boxed|] A box is drawn around the object. +% \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. +% \item[|name=|\meta{name}] This is equivalent to issuing |\ssname{|\meta{name}|}| after |\ssdrop|, see below. +% \end{description} +% If the argument is |\bullet| or |\circle|, the object is replaced by a better-spaced graphics primitive. % -% \iffalse -\newcommand{\ssdrop}[1]{ -\ssplace {\the\sseqposx} {\the\sseqposy} {#1} +% \ifthenelse{0=1}{ +\define@key{sseqdrop}{circled}[true]{\newif\ifKV@sseqdrop@circled\csname KV@sseqdrop@circled#1\endcsname} +\define@key{sseqdrop}{boxed}[true]{\newif\ifKV@sseqdrop@boxed\csname KV@sseqdrop@boxed#1\endcsname} +\define@key{sseqdrop}{color}{\def\ssplacecolor{#1}} +\define@key{sseqdrop}{name}{\def\sseq@name{#1}} +% +\def\ssdrop{\@ifnextchar[\sseq@drop{\sseq@drop[]}} +\def\sseq@drop[#1]#2{ + \edef\sseq@savecolor{\ssplacecolor} + \def\sseq@name{\relax} + \presetkeys{sseqdrop}{circled=false,boxed=false}{} + \setkeys{sseqdrop}{#1} + \ifKV@sseqdrop@circled + \ssplacecircled{\number\sseqposx}{\number\sseqposy}{#2} + \else + \ifKV@sseqdrop@boxed + \ssplaceboxed{\number\sseqposx}{\number\sseqposy}{#2} + \else + \def\temp{#2} + \def\temptwo{\bullet} + \ifx\temp\temptwo + \ss@setshapesep{0pt} + \ss@placespecial{\number\sseqposx}{\number\sseqposy}{circle}{\pgfusepath{fill}}{} + \else + \def\temptwo{\circle} + \ifx\temp\temptwo + \ss@setshapesep{0pt} + \ss@placespecial{\number\sseqposx}{\number\sseqposy}{circle}{\pgfusepath{stroke}}{} + \else + \ssplace{\number\sseqposx}{\number\sseqposy}{#2} + \fi + \fi + \fi + \fi + \edef\ssplacecolor{\sseq@savecolor} + \def\temp{\relax} + \ifx\sseq@name\temp \else + \@eval\ssname{{\sseq@name}} + \fi } -% \fi -% -% \DescribeMacro{\ssdropbull} -% This command is a shorthand for and improvement over |\ssdrop{\bullet}|, i.e. it will typeset a thick black dot at the current cursor position. It is better than the longer version because the bounding circle of a |\bullet| is not accurate in most fonts. However, some |dvi| drivers do not support this and typeset a square instead of a bullet. If that is the case, either use a different driver (like |dvips|), or use |\ssdrop{\bullet}| instead at the cost of a slightly poorer display. -% -% \iffalse -\newcommand{\ssdropbull}{\ssbull {\the\sseqposx} {\the\sseqposy}} -% \fi +% }{} % -% \DescribeMacro{\ssdropboxed} -% This command is the same as |\ssdrop|, except that it will also draw a box around its argument. +% ^^A The following are commands purely kept for compatibility. % % \iffalse -\newcommand{\ssdropboxed}[1]{ -\ssplaceboxed {\the\sseqposx} {\the\sseqposy} {#1} -} -% \fi -% -% \DescribeMacro{\ssdropcircled} -% This command is the same as |\ssdrop|, except that it will also draw a circle around its argument. If the argument is a single digit, the symbol dropped will be prettified by replacing it with a character from the |dingbats| font. % -% \iffalse -\newcommand{\ssdropcircled}[1]{ -\ssplacecircled {\the\sseqposx} {\the\sseqposy} {#1} -} +\newcommand{\ssdropbull}{\ssdrop{\bullet}} +\newcommand{\ssdropboxed}[1]{\ssdrop[boxed]{#1}} +\newcommand{\ssdropcircled}[1]{\ssdrop[circled]{#1}} % \fi % % \DescribeMacro{\ssname} -% |\ssname{|\emph{name}|}| gives the object most recently dropped the name \emph{name}. If the previous command is one of the drop commands, then it refers to that object; if it is not, then if there is one and only one object at the current cursor position, it refers to that object; if that is also not the case, an error message is generated. +% |\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. % % \iffalse \def\ssname#1{ @@ -549,7 +815,7 @@ % \fi % % \DescribeMacro{\ssgoto} -% After an object has been given a \emph{name} with |\ssname|, the cursor can be moved back to that object at any time by issuing |\ssgoto{|\emph{name}|}|. This becomes necessary when there is more than one object in one position. +% 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. % % \iffalse \newcommand{\ssgoto}[1]{ @@ -558,7 +824,7 @@ % \fi % % \DescribeMacro{\ssprefix} -% Often the mechanism provided by |\ssname|/|\ssgoto| is not flexible enough to deal with repeated code. In that case, |\ssprefix{|\emph{prefix}|}| defines a prefix for all names that follow; i.e. a |\ssname{|\emph{name}|}| after such a command will really define a name \emph{prefixname}. However, since |\ssgoto| also observes the prefix, |\ssgoto{|\emph{name}|}| will still work. |\ssprefix| commands can be iterated; the prefices are then concatenated (most recent right). +% 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). % % \iffalse \newcommand{\ssprefix}[1]{ @@ -578,305 +844,425 @@ % % \ifthenelse{0=1}{ \newcommand{\ssabsgoto}[1]{ -\ssnewpos -\edef\ssoldconncolor{\ssconncolor} -\putxy{"\csname sseqpos<#1>\endcsname"} -\sseqposx=\csname sseqx<#1>\endcsname -\sseqposy=\csname sseqy<#1>\endcsname -\ssifposinclippingregion{\the\sseqposx}{\the\sseqposy} - \setboolean{sseqcurrclip}{false} -\fi + \ifthenelse{\boolean{sseqhasopenconn}} + { + \sseqconcludeconnection + }{} + \ssfinishpos + \edef\sseq@currentname{\csname sseqpos<#1>\endcsname} + \sseqposx=\csname sseqx<#1>\endcsname + \sseqposy=\csname sseqy<#1>\endcsname + \sseq@updatecurrentdata } % }{} % % \DescribeMacro{\ssdroplabel} -% This command decorates the previously typeset object with a label. It can be used either in the form -% -% |\ssdroplabel{|\emph{label}|}| -% -% or in the form +% This command decorates the previously typeset object with a label. It is used in the form +% |\ssdroplabel[|\meta{options...}|]{|\meta{label}|}|. % -% |\ssdroplabel[|\emph{pos}|]{|\emph{label}|}|. -% -% The \emph{label} will then be typeset next to the most recently dropped object (for a definition for what that is, exactly, consult the description of |\ssname|). The optional argument \emph{pos}, which defaults to |U|, can be one of |U|,|LU|,|RU|,|L|,|R|,|LD|,|RD|,|D|, and denotes one of eight directions in which the label is positioned relative to the object it labels. +% 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). +% As in |\ssdrop|, an option |color=|\meta{color} will typeset the label in the \LaTeX{} color \meta{color}. % % \ifthenelse{0=1}{ -\newcommand{\ssdroplabel}[2][U]{ +\define@key{sseqlabel}{color}{\def\sslabelcolor{#1}} +\define@key{sseqlabel}{pos}{\def\sseq@position{#1}} +\define@key{sseqlabel}{U}[]{\def\sseq@position{U}} +\define@key{sseqlabel}{LU}[]{\def\sseq@position{LU}} +\define@key{sseqlabel}{L}[]{\def\sseq@position{L}} +\define@key{sseqlabel}{LD}[]{\def\sseq@position{LD}} +\define@key{sseqlabel}{D}[]{\def\sseq@position{D}} +\define@key{sseqlabel}{RD}[]{\def\sseq@position{RD}} +\define@key{sseqlabel}{R}[]{\def\sseq@position{R}} +\define@key{sseqlabel}{RU}[]{\def\sseq@position{RU}} +% +\def\ssdroplabel{\@ifnextchar[\sseq@droplabel{\sseq@droplabel[]}} +\def\sseq@droplabel[#1]#2{ \ssassertsource -\ssifposinclippingregion{\the\sseqposx}{\the\sseqposy} - \putxy{="prev"} - \ifthenelse{\boolean{usescolor}}{ - \ifthenelse{\equal{#1}{U}}{ - \putxy{+U*[\sslabelcolor]!D{#2}}}{} - \ifthenelse{\equal{#1}{LU}}{ - \putxy{+LU*[\sslabelcolor]!RD{#2}}}{} - \ifthenelse{\equal{#1}{RU}}{ - \putxy{+RU*[\sslabelcolor]!LD{#2}}}{} - \ifthenelse{\equal{#1}{R}}{ - \putxy{+R*[\sslabelcolor]!L{#2}}}{} - \ifthenelse{\equal{#1}{L}}{ - \putxy{+L*[\sslabelcolor]!R{#2}}}{} - \ifthenelse{\equal{#1}{D}}{ - \putxy{+D*[\sslabelcolor]!U{#2}}}{} - \ifthenelse{\equal{#1}{LD}}{ - \putxy{+LD*[\sslabelcolor]!RU{#2}}}{} - \ifthenelse{\equal{#1}{RD}}{ - \putxy{+RD*[\sslabelcolor]!LU{#2}}}{} - }{ - \ifthenelse{\equal{#1}{U}}{ - \putxy{+U*!D{#2}}}{} - \ifthenelse{\equal{#1}{LU}}{ - \putxy{+LU*!RD{#2}}}{} - \ifthenelse{\equal{#1}{RU}}{ - \putxy{+RU*!LD{#2}}}{} - \ifthenelse{\equal{#1}{R}}{ - \putxy{+R*!L{#2}}}{} - \ifthenelse{\equal{#1}{L}}{ - \putxy{+L*!R{#2}}}{} - \ifthenelse{\equal{#1}{D}}{ - \putxy{+D*!U{#2}}}{} - \ifthenelse{\equal{#1}{LD}}{ - \putxy{+LD*!RU{#2}}}{} - \ifthenelse{\equal{#1}{RD}}{ - \putxy{+RD*!LU{#2}}}{} - } - \putxy{;"prev"} +\ifcurroutofrange\else + \edef\sseq@savecolor{\sslabelcolor} + \def\sseq@position{L} + \setkeys{sseqlabel}{#1} +% + \ifthenelse{\equal{\sseq@position}{U}}{\def\sseq@anchor{north} \def\sseq@link{south}}{} + \ifthenelse{\equal{\sseq@position}{LU}}{\def\sseq@anchor{north west} \def\sseq@link{south east}}{} + \ifthenelse{\equal{\sseq@position}{L}}{\def\sseq@anchor{west} \def\sseq@link{east}}{} + \ifthenelse{\equal{\sseq@position}{LD}}{\def\sseq@anchor{south west} \def\sseq@link{north east}}{} + \ifthenelse{\equal{\sseq@position}{D}}{\def\sseq@anchor{south} \def\sseq@link{north}}{} + \ifthenelse{\equal{\sseq@position}{RD}}{\def\sseq@anchor{south east} \def\sseq@link{north west}}{} + \ifthenelse{\equal{\sseq@position}{R}}{\def\sseq@anchor{east} \def\sseq@link{west}}{} + \ifthenelse{\equal{\sseq@position}{RU}}{\def\sseq@anchor{north east} \def\sseq@link{south west}}{} +% + \sseqwritecolor{\sslabelcolor} + \putxyq{\pgftransformshift} + \putxy{{\noexpand\pgfpointanchor{\sseq@currentname}{\sseq@anchor}}} + \putxyq{\pgfnode{rectangle}} + \putxy{{\sseq@link}} + \putxyq{{\ensuremath{#2}}{}{\pgfusepath{discard}}} + \putxyq{\pgftransformreset} + \edef\sslabelcolor{\sseq@savecolor} \fi } % }{} % % \DescribeMacro{\ssdropextension} -% This command has no arguments and is rather specialized. It refers to a previously dropped object (see |\ssname|), draws a circle around it, and considers that circle a new object. Thus it produces a new circle object that is attached to the original object, and not subject to the algorithm that tries to make objects non-overlapping +% This command has no arguments and is rather specialized. It refers to a previously dropped object (see |\ssname|), draws a circle around it, and considers that circle a new object. Thus it produces a new circle object that is attached to the original object, and not subject to the algorithm that tries to make objects non-overlapping. % % \ifthenelse{0=1}{ -\newcommand{\ssdropextension}{ -\ssassertsource -\expandafter\def\expandafter\tmpname\expandafter{\csname sseqdrop\the\sseqposx,\the\sseqposy\endcsname} -\edef\setcnt{\noexpand\count0=\tmpname} -\setcnt -\advance\count0 by 1 -\expandafter\edef\tmpname{\the\count0} -\setboolean{sseqcurrclip}{true} -\ssifposinclippingregion{\the\sseqposx}{\the\sseqposy} - \setboolean{sseqcurrclip}{false} - \putxy{*+<1mm,1mm>\noexpand\frm{}*} - \sseqwritecolor{\ssplacecolor} - \putxyq{\cir{}} -\fi +\def\ssdropextension{ + \ssassertsource + \expandafter\def\expandafter\tmpname\expandafter{\csname sseqdrop\the\sseqposx,\the\sseqposy\endcsname} + \edef\setcnt{\noexpand\count0=\tmpname} + \setcnt + \advance\count0 by 1 + \expandafter\edef\tmpname{\the\count0} + \putxyq{\pgftransformshift} + \putxy{{\noexpand\pgfpointanchor{\sseq@currentname}{center}}} + \ifoutofrange + \putxyq{\pgfnode{coordinate}{center}{}} + \putxy{{ss(\the\sseqposx,\the\sseqposy)\tmpname}{}} + \else + \sseqwritecolor{\ssplacecolor} + \sseq@setcircumference + \putxyq{\pgfnode{circle}{center}{}} + \putxy{{ss(\the\sseqposx,\the\sseqposy)\tmpname}} + \putxyq{{\pgfusepath{stroke}}} + \fi + \putxyq{\pgftransformreset} % % ^^A now give it a unique name % -\edef\sseqcurrentname{ss(\the\sseqposx,\the\sseqposy)\tmpname} -\putxy{="\sseqcurrentname"} -\ifthenelse{\boolean{sseqhasopenconn}}{\sseqconcludeconnection}{} -} - -\newcommand{\ssprepareline}[2]{ -\ifthenelse{\boolean{sseqhasfinishedpos}}{ - \ssopenposition{\the\sseqposx}{\the\sseqposy} -}{} -\advance\sseqposx by #1 -\advance\sseqposy by #2 -\setboolean{sseqhasopenconn}{true} -\edef\ssoldconncolor{\ssconncolor} -} - -\newcommand{\sspreparevoidline}[2]{ -\ifthenelse{\boolean{sseqhasfinishedpos}}{ - \ssopenposition{\the\sseqposx}{\the\sseqposy} -}{} -\ifthenelse{\boolean{sseqhasfinishedpos}}{}{ - \ssputsemicolon -} -\setboolean{sseqhasfinishedpos}{false} -% -% + \edef\sseq@currentname{ss(\number\sseqposx,\number\sseqposy)\tmpname} + \expandafter\edef\csname \sseq@currentname size\endcsname{\number\ss@size sp} % -\sseqx=\sseqentrysize -\multiply\sseqx \sseqxdir -\multiply\sseqx by #1 -% -\sseqy=\sseqentrysize -\multiply\sseqy \sseqydir -\multiply\sseqy by #2 -% -\putxy{p+<\the\sseqx,\the\sseqy>} -\edef\ssoldconncolor{\ssconncolor} + \ifthenelse{\boolean{sseqhasopenconn}}{\sseqconcludeconnection}{} } - -\def\sseqifconninclippingregion{% -\ifthenelse{\boolean{sseqcurrclip}\and\boolean{sseqprevclip}}{ - \ssclippedfalse}{ - \ssclippedtrue - } - \ifssclipped +% +\def\ssprepareline#1#2{ + \ssassertsource\ssfinishpos + \advance\sseqposx by #1 + \advance\sseqposy by #2 + \sseq@updatecurrentdata + \setboolean{sseqhasopenconn}{true} } -% }{} % -% \DescribeMacro{\ssstroke} -% There are two ways of typesetting connections between objects. One of them is the suit of commands |\ssstroke|, |\sscurve|, |\ssdashedstroke|, |\ssdashedcurve|, |\ssarrowhead|, which all behave similarly. |\ssstroke| requires that the cursor recently moved from one object to another. It takes no arguments and typesets a straight line between the two objects. Example: Suppose there are two objects, which have been given the names |a| and |b| by |\ssname|. Drawing a line between them is achieved by the command |\ssgoto{a} \ssgoto{b} \ssstroke|. +\def\extractcoords ss(#1,#2)#3{{#1}{#2}} % -% \ifthenelse{0=1}{ -\newcommand{\ssstroke}{ -\ssassertsource +\def\sseq@flushconn{ + \ifx\sseq@connbuffer\empty\else + \ifsseq@connreverse + \putxy{\noexpand\pgfsetarrows{\sseq@currarrowend-\sseq@currarrowstart}} + \else + \putxy{\noexpand\pgfsetarrows{\sseq@currarrowstart-\sseq@currarrowend}} + \fi + \sseq@connbuffer + \def\sseq@connbuffer{} + \def\sseq@currarrowstart{} + \def\sseq@currarrowend{} + \fi +} +% ^^A parameters: 1 = dashing (e.g. {{1pt}{1pt}} = dashed, {} = solid) +% ^^A 2 = bending ({} = no bend) +% ^^A 3 = target is void (true/false) +% +\def\sseq@connection#1#2#3{ + \sseq@flushconn + \ifthenelse{\boolean{#3}}{}{\ssassertsource} + \sseq@connreversefalse + \edef\sseq@prevxy{\expandafter\extractcoords\sseq@previousname} + \expandafter\ss@getcoords\sseq@prevxy +% ^^A now prevxy={fromx}{fromy}, \ifoutofrange=fromclip, \sseqx,\sseqy = fromcoords (if in range) +% ^^A sseqposx=tox,sseqposy=toy, \ifcurroutofrange=toclip, \sseqabsposx,\sseqabsposy = tocoords (if in range) % ^^A only do it if not both source and target are outside the clipping region -\sseqifconninclippingregion - \putxy{**} \sseqwritecolor{\ssoldconncolor} - \putxyq{\dir{-}} -\fi + \ifcurroutofrange + \ifoutofrange % ^^A both out of range -- do nothing + \else % ^^Afrom within range to out of range -- draw a void line + % ^^A need to recompute the relative coordinates + \@eval\sseq@diffhelper{\sseq@prevxy{\number\sseqposx}{\number\sseqposy}} + \@eval\sseq@lineintooff{{\sseq@previousname}\sseq@prevxy{\number\count0}{\number\count1}{#1}{#2}} + \fi + \else + \ifoutofrange % ^^A from out of range to within range -- draw a void line + \ifthenelse{\boolean{#3}}{}{ % ^^A if the target is also void -- do nothing. + \sseq@connreversetrue + \@eval\sseq@diffhelper{{\number\sseqposx}{\number\sseqposy}\sseq@prevxy} + \@eval\sseq@lineintooff{{\sseq@currentname}{\sseqposx}{\sseqposy}{\number\count0}{\number\count1}{#1}{#2}} + } + \else + \putxyq{\pgfsetdash{#1}{0pt}} + \ifthenelse{\boolean{#3}}{ % ^^A draw a void line + \multiply\sseqx by -1 + \advance\sseqx by \sseqabsposx + \multiply\sseqy by -1 + \advance\sseqy by \sseqabsposy + \putxy{\noexpand\pgftransformshift{\noexpand\pgfpointanchor{\sseq@previousname}{center}}} + \putxyq{\pgfpathmoveto} + \putxy{{\noexpand\pgfpointshapeborder{\sseq@previousname}% + {\noexpand\pgfpoint{\the\sseqx}{\the\sseqy}}}} + }{ + \putxyq{\pgfpathmoveto} + \putxy{{\noexpand\pgfpointshapeborder{\sseq@previousname}{\noexpand \pgfpointanchor{\sseq@currentname}{center}}}} + } + \def\sseq@temp{#2} + \ifx\sseq@temp\empty + \putxyq{\pgfpathlineto} + \else + \putxyq{\pgfsnakesegmentamplitude=#2pc} + \putxyq{\multiply\pgfsnakesegmentamplitude by 3 } + \putxyq{\pgfsnakesegmentaspect=.3} + \putxyq{\pgfpathsnaketo{bent}} + \fi + \ifthenelse{\boolean{#3}}{ + \putxy{{\noexpand\pgfpoint{\the\sseqx}{\the\sseqy}}} + }{ + \putxy{{\noexpand\pgfpointshapeborder{\sseq@currentname}{\noexpand \pgfpointanchor{\sseq@previousname}{center}}}} + } \edef\sseq@connbuffer{\noexpand\sseqwritecolor{\ssconncolor}\noexpand\putxyq{\noexpand\pgfusepath{stroke}\noexpand\pgftransformreset}} + \fi + \fi } -% }{} -% -% \DescribeMacro{\sscurve} -% This command behaves like |\ssstroke|, except that it takes an additional real number argument which denotes a curving factor for the line. $0$ means straight. -% -% \ifthenelse{0=1}{ -\newcommand{\sscurve}[1]{ -\ssassertsource -\sseqifconninclippingregion - \putxy{**} \sseqwritecolor{\ssoldconncolor} - \putxyq{\crv{:(.5,#1)}} -\fi +% ^^A xmin,ymin,xmax,ymax --> \count0,\count1 +\def\sseq@diffhelper#1#2#3#4{ + \count0=#1 + \multiply\count0 by -1 + \advance\count0 by #3 + \count1=#2 + \multiply\count1 by -1 + \advance\count1 by #4 } % }{} % -% \DescribeMacro{\ssdashedstroke} -% Like |\ssstroke|, but typesets a dashed line. +% +% \DescribeMacro{\ssstroke} +% There are two ways of typesetting connections between objects. One of them is the command |\ssstroke|, which +% requires that the cursor recently moved from one object to another. It takes no non-optional arguments and typesets a +% line between the two objects. Example: Suppose there are two objects, which have been given the names |a| and |b| +% by |\ssname|. Drawing a line between them is achieved by the command |\ssgoto{a} \ssgoto{b} \ssstroke|. +% +% The following options can be given in the form |\ssstroke[options]|: +% \begin{description} +% \item[|color=|color] the connection is drawn in the given \LaTeX{} color +% \item[|curve=|value] the connection is curved to the left by an amount proportional to the value given. +% \item[{|dashed|[=dashing type]}] the connection is drawn in a dashed style. The optional \emph{dashing type} is an +% expression of the form |{{a}{b}...}|, where each of a, b, \dots is a length (like 2pt or 3mm). The line then consists of +% a stroke of length |a|, followed by a gap of length |b|, followed by a stroke of length ... etc. +% \item[{|dotted|[=dashing type]}] the connection is drawn in a dotted style. If the optional dashing type is given, +% this option behaves exactly like |dashed|. +% \item[{|arrowfrom|[=arrow style]}] An arrow is drawn at the beginning of the line. The global arrow style can be overridden +% by specifying an arrow style. +% \item[{|arrowto|[=arrow style]}] An arrow is drawn at the end of the line. +% \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. +% \end{description} % % \ifthenelse{0=1}{ -\newcommand{\ssdashedstroke}{ -\ssassertsource -\sseqifconninclippingregion - \putxy{**} \sseqwritecolor{\ssoldconncolor} - \putxyq{\dir{--}} -\fi +% +\define@key{sseqstroke}{color}{\def\ssconncolor{#1}} +\define@key{sseqstroke}{curve}{\def\sseq@curve{#1}} +\define@key{sseqstroke}{dashed}[{{2pt}{2pt}}]{\def\sseq@dashing{#1}} +\define@key{sseqstroke}{dotted}[{{.5pt}{2pt}}]{\def\sseq@dashing{#1}} +\define@key{sseqstroke}{arrowfrom}[\sseq@defaultarrowstyle]{\edef\sseq@arrowfrom{#1}} +\define@key{sseqstroke}{arrowto}[\sseq@defaultarrowstyle]{\edef\sseq@arrowto{#1}} +\define@key{sseqstroke}{void}[true]{\newif\ifKV@sseqstroke@void\csname KV@sseqstroke@void#1\endcsname} +% +\def\ssstroke{\@ifnextchar[\sseq@stroke{\sseq@stroke[]}} +\def\sseq@stroke[#1]{ + \edef\sseq@savecolor{\ssconncolor} + \def\sseq@dashing{} + \def\sseq@curve{} + \edef\sseq@arrowfrom{\sseq@currarrowstart} + \edef\sseq@arrowto{\sseq@currarrowend} + \presetkeys{sseqstroke}{void=false}{} + \setkeys{sseqstroke}{#1} + \ifKV@sseqstroke@void % ^^A a void line + \@eval\sseq@connection{{\sseq@dashing}{\sseq@curve}{true}} + \else + \@eval\sseq@connection{{\sseq@dashing}{\sseq@curve}{false}} + \fi + \edef\sseq@currarrowstart{\sseq@arrowfrom} + \edef\sseq@currarrowend{\sseq@arrowto} + \edef\ssconncolor{\sseq@savecolor} } % }{} % -% \DescribeMacro{\ssdashedcurve} -% Like |\sscurve|, but typesets a dashed curve. -% +% ^^A Keep these for compatibility % \ifthenelse{0=1}{ -\newcommand{\ssdashedcurve}[1]{ -\ssassertsource -\sseqifconninclippingregion - \putxy{**} \sseqwritecolor{\ssoldconncolor} - \putxyq{\crv{~**\dir{--}:(.5,#1)}} -\fi -} +\newcommand{\sscurve}[1]{\sseq@stroke[curve=#1]} +\newcommand{\ssdashedstroke}{\sseq@stroke[dashed]} +\newcommand{\ssdashedcurve}[1]{\sseq@stroke[dashed,curve=#1]} +\newcommand{\ssdottedstroke}{\sseq@stroke[dotted]} +\newcommand{\ssdottedcurve}[1]{\sseq@stroke[dotted,curve=#1} % }{} % % \DescribeMacro{\ssarrowhead} -% Typesets an arrow head onto the connection most recently typeset. +% \DescribeMacro{\ssinversearrowhead} +% 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|. % % \ifthenelse{0=1}{ -\newcommand{\ssarrowhead}{ -\sseqifconninclippingregion - \putxy {?>*} \sseqwritecolor{\ssoldconncolor} - \putxyq{\dir{>}} -\fi -} +\newcommand{\ssarrowhead}[1][\sseq@defaultarrowstyle]{\edef\sseq@currarrowend{#1}} +\newcommand{\ssinversearrowhead}[1][\sseq@defaultarrowstyle]{\edef\sseq@currarrowstart{#1}} % }{} % % \DescribeMacro{\ssline} -% The second way of producing connections is the suit of commands that follow, starting with |\ssline| \emph{x y}. This command draws a straight line from the most recent object (cf. |\ssname|) to an object at relative position $(x,y)$, and it moves that cursor to that new position. If |\ssline| is followed by a drop command, then the line is attached to this newly dropped object (note the slightly out-of-order execution!), no matter how many other objects there are at the target position. However, if it is not followed by a drop command, then there has to be one and only one object at the target position, otherwise an error message is generated. +% 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|. % % \iffalse -\newcommand{\ssline}[2]{ -\ssprepareline{#1}{#2} -\def\sseqconncommand{\ssstroke} -} -% \fi -% -% \DescribeMacro{\sscurvedline} -% Like |\ssline|; the third argument is a real number denoting a curvature factor. -% -% \iffalse -\newcommand{\sscurvedline}[3]{ -\ssprepareline{#1}{#2} \def\sseqconncommand{\sscurve{#3}} -} -% \fi -% -% \DescribeMacro{\ssdashedline} -% Like |\ssline|; typesets a curved line -% -% \iffalse -\newcommand{\ssdashedline}[2]{ -\ssprepareline{#1}{#2} \def\sseqconncommand{\ssdashedstroke} -} -% \fi -% -% \DescribeMacro{\sscurveddashedline} -% Like |\sscurvedline|; typesets a dashed curve % -% \iffalse -\newcommand{\sscurveddashedline}[3]{ -\ssprepareline{#1}{#2} \def\sseqconncommand{\ssdashedcurve{#3}} +\def\ssline{\@ifnextchar[\sseq@line{\sseq@line[]}} +\def\sseq@line[#1]#2#3{ + \ssprepareline{#2}{#3} + \edef\sseqconncommand{\noexpand\ssstroke[color=\ssconncolor,#1]} } +\newcommand{\sscurvedline}[3]{\ssline[curve=#3]{#1}{#2}} +\newcommand{\ssdashedline}[2]{\ssline[dashed]{#1}{#2}} +\newcommand{\sscurveddashedline}[3]{\ssline[curve=#3,dashed]{#1}{#2}} % \fi % % \DescribeMacro{\ssarrow} -% Like |\ssline|; but adds an arrowhead at the end -% -% \iffalse -\newcommand{\ssarrow}[2]{ -\ssprepareline{#1}{#2} -\def\sseqconncommand{\ssstroke\ssarrowhead} -} -% \fi -% -% \DescribeMacro{\sscurvedarrow} -% Like |\sscurve|; but adds an arrowhead at the end -% -% \iffalse -\newcommand{\sscurvedarrow}[3]{ -\ssprepareline{#1}{#2} \def\sseqconncommand{\sscurve{#3}\ssarrowhead} -} -% \fi -% -% \DescribeMacro{\ssdashedarrow} -% Like |\ssdashedline|; but adds an arrowhead at the end +% |\ssarrow[|\meta{options...}|]{|\meta x|}{|\meta y|}| is an abbreviation for\\ +% |\ssline[|\meta{options...}|,arrowto]{|\meta x|}{|\meta y|}| % -% \iffalse -\newcommand{\ssdashedarrow}[2]{ -\ssprepareline{#1}{#2} \def\sseqconncommand{\ssdashedstroke\ssarrowhead} +% \ifthenelse{0=1}{ +\newcommand{\ssarrow}[3][]{ + \ssline[arrowto,#1]{#2}{#3} +} +\newcommand{\sscurvedarrow}[3]{\ssline[arrowto,curve=#3]{#1}{#2}} +\newcommand{\ssdashedarrow}[2]{\ssline[arrowto,dashed]{#1}{#2}} +\newcommand{\sscurveddashedarrow}[3]{\ssline[arrowto,dashed,curve=#3]{#1}{#2}} +% +% +\def\ssvoidline#1#2{ + \ssassertsource + \edef\sseq@resetcmd{\noexpand\sseqposx=\number\sseqposx% + \noexpand\sseqposy=\number\sseqposy% + \noexpand\def\noexpand\sseq@currentname{\sseq@currentname} + \noexpand\sseq@updatecurrentdata} + \ssmove{#1}{#2} + \ssstroke[void] + \sseq@resetcmd +} +\newcommand{\ssvoidarrow}[2]{\ssvoidline{#1}{#2}\ssarrowhead} +\newcommand{\ssinversevoidarrow}[2]{\ssvoidline{#1}{#2}\ssinversearrowhead} + +% This follows the conventions of pgf, i.e. #1, #2, #3, #4 are pgfpoints, return is a pgfpoint on the +% intersection of line #3 in direction #4 with axis-linear rectangle #1-#2. +\def\sseq@pointintersectionoflinewithrectangle#1#2#3#4{ + \pgf@process{#1} + \pgf@xa=\pgf@x + \pgf@ya=\pgf@y + \pgf@process{#2} + \pgf@xb=\pgf@x + \pgf@yb=\pgf@y + \pgf@process{#3} + \pgf@xc=\pgf@x + \pgf@yc=\pgf@y + \pgf@process{#4} + \dimen0=100cm % ^^A infinity + \dimen1=100cm % ^^A infinity +% ^^A + \ifnum\pgf@x>0pt % ^^A line goes to the right + \dimen0=\pgf@xb + \advance\dimen0 by -\pgf@xc + \divide\dimen0 by \pgf@x + \fi + \ifnum\pgf@x<0pt % ^^A line goes to the left + \dimen0=\pgf@xa + \advance\dimen0 by -\pgf@xc + \divide\dimen0 by \pgf@x + \fi + \ifnum\pgf@y>0pt % ^^A line goes up + \dimen1=\pgf@yb + \advance\dimen1 by -\pgf@yc + \divide\dimen1 by \pgf@y + \fi + \ifnum\pgf@y<0pt % ^^A line goes down + \dimen1=\pgf@ya + \advance\dimen1 by -\pgf@xc + \divide\dimen1 by \pgf@y + \fi + \ifnum\dimen1<\dimen0 + \dimen0=\dimen1 + \fi + % ^^A now dimen0 contains the stretching factor for #4 to the right point. + \multiply\pgf@x by \dimen0 + \multiply\pgf@y by \dimen0 + \advance\pgf@x by \pgf@xc + \advance\pgf@y by \pgf@yc } -% \fi + % -% \DescribeMacro{\sscurveddashedarrow} -% Like |\sscurveddashedline|; but adds an arrowhead at the end +% ^^A draw a line from the named position #1 (coord #2,#3) to relative position (#4,#5). +% ^^A clip it where appropriate. +% ^^A #6 = dashing (e.g. {{1pt}{1pt}} = dashed, {} = solid) +% ^^A #7 = bending ({} = no bend) % -% \iffalse -\newcommand{\sscurveddashedarrow}[3]{ -\ssprepareline{#1}{#2} \def\sseqconncommand{\ssdashedcurve{#3}\ssarrowhead} + +\def\sseq@lineintooff#1#2#3#4#5#6#7{ + \putxyq{\begin{pgfscope}} + \sseqj=0 + \def\tempcmd{\range@loop{\sseq@findxrange{#2}{#3}}} + \expandafter\tempcmd\sseq@xrange +% ^^A now \sseqxx = xmin, \sseqyy = ymin, \sseqx = xmax, \sseqy = ymax. + \putxyq{\pgfsetdash{#6}{0pt}} + \putxyq{\sseq@pointintersectionoflinewithrectangle} + \putxy{{\noexpand\pgfpoint{\number \sseqxx sp}{\number \sseqyy sp}}} + \putxy{{\noexpand\pgfpoint{\number \sseqx sp}{\number \sseqy sp}}} + \putxyq{{\pgfpointanchor{#1}{center}}{\pgfpoint{#4 sp}{#5 sp}}} + \putxyq{\sseqx=\pgf@x} + \putxyq{\sseqy=\pgf@y} + \putxyq{\pgfpathmoveto} + \putxy{{\noexpand\pgfpointshapeborder{#1}% + {\noexpand\pgfpoint{\noexpand\sseqx}{\noexpand\sseqy}}}} + \def\temp{#7} + \ifx\temp\empty + \putxyq{\pgfpathlineto} + \else + \dimen0=#7pc + \ifsseq@connreverse + \multiply\dimen0 by -1 + \fi + \putxy{\noexpand\pgfsnakesegmentamplitude=\number\dimen0 sp} + \putxyq{\advance\pgfsnakesegmentamplitude by \pgfsnakesegmentamplitude} + \putxyq{\pgfsnakesegmentaspect=.3} + \putxyq{\pgfpathsnaketo{bent}} + \fi + \putxyq{{\pgfpoint{\sseqx}{\sseqy}}} + \edef\sseq@connbuffer{\noexpand\sseqwritecolor{\ssconncolor}% + \noexpand\putxyq{\noexpand\pgfusepath{stroke}\noexpand\end{pgfscope}}} } -% \fi -% -% \DescribeMacro{\ssvoidline} -% This command behaves like |\ssline| except it disregards the target and just typesets a line to the given position. This is useful if the line is not supposed to have an object as its target. Unlike |\ssline| and its companions, it does \textbf{not} move the cursor. -% -% \iffalse -\newcommand{\ssvoidline}[2]{ -\sspreparevoidline{#1}{#2} -\ssstroke -\putxy{,p} + +\def\sseq@findxrange#1#2#3#4{ + \ifnum#1<#3\else + \ifnum#1>#4\else + % ^^A found the correct range + \sseqj=0 + \def\tempcmd{\range@loop{\sseq@findyrange{#1}{#2}{#3}{#4}}} + \expandafter\tempcmd\sseq@yrange + \rangebreaktrue + \fi + \fi } -% \fi -% -% \DescribeMacro{\ssvoidarrow} -% Same as |\ssvoidline|, but typesets an arrow. -% -% \iffalse -\newcommand{\ssvoidarrow}[2]{ -\sspreparevoidline{#1}{#2} -\ssstroke\ssarrowhead -\putxy{,p} +\def\sseq@findyrange#1#2#3#4#5#6{ + \ifnum#2<#5\else + \ifnum#2>#6\else + % ^^A found the correct range -- do the drawing + \ss@getcoords{#3}{#5} % ^^A lower left corner in \sseqx,\sseqy + \advance\sseqx by -\sseq@xleak + \advance\sseqy by -\sseq@yleak + \sseqxx=\sseqx + \sseqyy=\sseqy + \ss@getcoords{#4}{#6} % ^^A upper right corner in \sseqx,\sseqy + \advance\sseqx by \sseq@xleak + \advance\sseqx by \sseqentrysize + \advance\sseqy by \sseq@yleak + \advance\sseqy by \sseqentrysize + \rangebreaktrue + \fi + \fi } -% \fi + +% }{} % % \DescribeMacro{\ssbullstring} -% |\ssbullstring{x}{y}{n}| is a shortcut for |\ssdropbull| followed by $n$ copies of |\ssline{x}{y} \ssdropbull|. +% |\ssbullstring{x}{y}{n}| is a shortcut for |\ssdrop{\bullet}| followed by $n-1$ copies of |\ssline{x}{y} \ssdrop{\bullet}|. % \iffalse \newcommand{\ssbullstring}[3]{ \ifnum#3>0 @@ -894,7 +1280,7 @@ % \fi % % \DescribeMacro{\ssinfbullstring} -% |\ssinfbullstring{x}{y}{n}| is a shortcut for |\ssdropbull| followed by $n$ copies of |\ssline{x}{y} \ssdropbull|, followed by |\ssvoidarrow{x}{y}|. +% |\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. % % \iffalse \newcommand{\ssinfbullstring}[3]{ @@ -903,60 +1289,39 @@ } % \fi % -% \section{Additional parameters} -% -% For typesetting dropped objects, |sseq| uses the color |\ssplacecolor|, for connections, |\ssconncolor|, and for labels, |\sslabelcolor|. These all default to black, but can be |\def|'d at any point to any valid \Xy-pic color. There are pre-defined colors |ssblack|, |sseqgr|, and |ssred|, denoting black, light gray, and red. -% -% At any point, clipping can be switched on or off by setting -% -% |\setboolean{sseqclip}{true}| or |\setboolean{sseqclip}{false}| -% -% % \section{Examples} % +% % \newtheorem{ex}{Example} % %\begin{ex} -%The following code generates a $5 \times 5$ grid with labels between $-2$ and $2$. The size of every square is $(.8cm)^2$, and labels are written on every square. A bullet is drawn at coordinate (0,0). +%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). % %\noindent %\begin{minipage}{\textwidth/2} %\begin{verbatim} -%\sseqxstart=-2 -%\sseqystart=-2 -%\sseqentrysize=.8cm -%\sseqxstep=1 -%\sseqystep=1 -%\begin{sseq}{5}{5} +%\begin{sseq}[grid=chess,labelstep=1, +% entrysize=.8cm]{-2...2}{-2...2} %\ssdropbull %\end{sseq} %\end{verbatim} %\end{minipage} %\begin{minipage}{\textwidth/2} -%\sseqxstart=-2 -%\sseqystart=-2 -%\sseqentrysize=.8cm -%\sseqxstep=1 -%\sseqystep=1 -%\begin{sseq}{5}{5} +%\def\sseqgridstyle{\ssgridchess} +%\begin{sseq}[grid=chess,labelstep=1,entrysize=.8cm]{-2...2}{-2...2} %\ssdropbull %\end{sseq} %\end{minipage} %\end{ex} % -%\sseqxstart=0 -%\sseqystart=0 -%\sseqentrysize=.6cm -%\sseqxstep=2 -%\sseqystep=2 % %\begin{ex} -%This example demonstrates how to move the cursor and drop objects and labels. Note how the last bullet, which is dropped at position (8,4), is outside the grid and thus clipped. +%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 % %\noindent %\begin{minipage}{\textwidth/2} %\begin{verbatim} -%\begin{sseq}{7}{7} +%\begin{sseq}{0...6}{0...6} %\ssdropbull %\ssdroplabel{(0,0)} %\ssmove 2 1 @@ -976,7 +1341,7 @@ %\end{verbatim} %\end{minipage} %\begin{minipage}{\textwidth/2} -%\begin{sseq}{7}{7} +%\begin{sseq}{0...6}{0...6} %\ssdropbull %\ssdroplabel{(0,0)} %\ssmove 2 1 @@ -996,15 +1361,14 @@ %\end{minipage} %\end{ex} % -%\sseqentrysize=.4cm %\begin{ex} -%This example illustrates the different ways of drawing connections. Note how the size of the axis labels is adjusted to the grid size. +%This example illustrates the different ways of drawing connections. +%\bigskip % %\noindent %\begin{minipage}{\textwidth/2} %\begin{verbatim} -%\sseqentrysize=.4cm -%\begin{sseq}{10}{7} +%\begin{sseq}[grid=go]{0...9}{0...6} %\ssdropbull %\ssmove 4 4 %\ssdropbull \ssstroke @@ -1021,7 +1385,7 @@ %\end{verbatim} %\end{minipage} %\begin{minipage}{\textwidth/2} -%\begin{sseq}{10}{7} +%\begin{sseq}[grid=go]{0...9}{0...6} %\ssdropbull %\ssmove 4 4 %\ssdropbull \ssstroke @@ -1039,11 +1403,12 @@ % %\begin{ex} %This sample code shows how to use names for objects dropped in spectral sequence; this is particularly useful when more than one item is dropped at one position. It also demonstrates void arrows, which do not need a target. +%\bigskip % %\noindent %\begin{minipage}{\textwidth*2/3} %\begin{verbatim} -%\begin{sseq}{5}{5} +%\begin{sseq}[grid=dots]{0...4}{0...4} %\ssdropbull \ssname{a} \ssvoidarrow 0 1 %\ssdropbull \ssname{b} \ssvoidarrow 0 1 %\ssdropbull \ssname{c} \ssvoidarrow 0 1 @@ -1059,7 +1424,8 @@ %\end{verbatim} %\end{minipage} %\begin{minipage}{\textwidth/3} -%\begin{sseq}{5}{5} +% +%\begin{sseq}[grid=dots]{0...4}{0...4} %\ssdropbull \ssname{a}\ssvoidarrow 0 1 %\ssdropbull \ssname{b}\ssvoidarrow 0 1 %\ssdropbull \ssname{c}\ssvoidarrow 0 1 @@ -1114,7 +1480,8 @@ %\end{minipage} %\begin{minipage}[t]{\textwidth*1/3} %\begin{verbatim} -%\begin{sseq}{9}{4} +%\begin{sseq}[grid=none] +% {0...8}{0...3} %\ssmoveto 0 3 %\drawstring{a}{8} %\ssmoveto 0 3 @@ -1131,6 +1498,8 @@ %\end{verbatim} %\end{minipage} % +% \bigskip +% % The result is shown in the following chart: %\newcount\cnti %\def\drawstring#1#2{ @@ -1157,7 +1526,8 @@ % {\the\cnti} % \fi %} -%\begin{sseq}{9}{4} +%\begin{tabular}{l} +%\begin{sseq}[grid=none]{0...8}{0...3} %\ssmoveto 0 3 %\drawstring{a}{8} %\ssmoveto 0 3 @@ -1171,6 +1541,7 @@ %\ssresetprefix %\drawlines{b}{iic}{6} %\end{sseq} +%\end{tabular} %\end{ex} % %\section{Final remarks} @@ -1182,211 +1553,331 @@ % \begin{itemize} % \item |sseq| seems to be too voracious in memory % \item While object are placed next to each other, no attempt is made not to make connections overlap -% \item Other things ought to be customizable: The grid style, the axis labels, etc. % \item A ``grayout'' option that automatically turns the source and target of any arrow into a different color would be highly useful for spectral sequence charts % \end{itemize} % % Given time and leisure, I might or might not implement one or more of these improvements and make them available; of course, I would be even more happy if somebody else did it. (Needless to say, I would request that I be informed of and sent the enhancements.) I do guarantee that all further versions of |sseq| that might or might not be written by me will be compatible with the documented code written for this version. % % \endinput -% ^^A\sseqdrawgrid -% -\def\sseqdrawgrid#1#2{ -\sseqi=0 -\sseqj=0 -\loop - \sseqy=\sseqentrysize - \multiply \sseqy by \sseqj - \advance \sseqy by \sseqlabelbarwidth - % - \putxy{<\the\sseqlabelbarwidth,\the\sseqy>;<\the\sseqx,\the\sseqy>**} - \sseqwritecolor{sseqgr} - \putxyq{\dir {.},} - \advance\sseqj 1 -\ifnum\sseqj>#2 \else \repeat -% -\sseqy = \sseqentrysize -\multiply \sseqy by #2 -\advance \sseqy by \sseqlabelbarwidth -\loop - \sseqx=\sseqentrysize - \multiply \sseqx by \sseqi - \advance \sseqx by \sseqlabelbarwidth - % - \putxy{<\the\sseqx,\the\sseqlabelbarwidth>;<\the\sseqx,\the\sseqy>**} - \sseqwritecolor{sseqgr} - \putxyq{\dir {.},} - \advance \sseqi 1 -\ifnum\sseqi>#1 \else \repeat -} -% -% ^^A\sseqdrawlabels -% -\def\sseqdrawlabels#1#2{ -\sseqi=\sseqxstart -\sseqposx=\sseqxstart -\multiply \sseqposx by -1 -\advance \sseqposx \sseqi -\count0=\sseqxdir -\multiply\count0 by \sseqxdir -\multiply\count0 by \sseqxstep -\count1=\sseqydir -\multiply\count1 by \sseqydir -\multiply\count1 by \sseqystep -\loop - \sseqxx=\sseqentrysize - \multiply\sseqxx by \sseqposx - \advance\sseqxx by \sseqhalfentry - \advance\sseqxx by \sseqlabelbarwidth - \putxy { <\the\sseqxx,0pt>*} - \putxyq{\txt\sseqlabelfont} - \putxy {{\the\sseqi},} - \advance\sseqi by \sseqxstep - \advance\sseqposx by \count0 -\ifnum\sseqposx<#1 \repeat -% -\sseqj=\sseqystart -\sseqposy=\sseqj -\multiply\sseqposy by -1 -\advance\sseqposy by \sseqj -\loop - \sseqyy=\sseqentrysize - \multiply\sseqyy by \sseqposy - \advance\sseqyy by \sseqhalfentry - \advance\sseqyy by \sseqlabelbarwidth - \putxy { <0pt,\the\sseqyy>*} - \putxyq {\txt\sseqlabelfont} - \putxy{{\the\sseqj},} - \advance\sseqj by \sseqystep - \advance\sseqposy by \count1 -\ifnum\sseqposy<#2\repeat -} - - -% -% -\newenvironment{sseq}[2]{ +% +% +\def\ssgridcrossword#1#2{ + \pgfsetlinewidth{\the\sseq@gridstrokethickness} + \pgfpathgrid[stepx=\the\sseqentrysize,stepy=\the\sseqentrysize]{\pgfpointorigin}{\pgfpoint{#1*\sseqentrysize}{#2*\sseqentrysize}} + \pgfusepath{stroke} +} + +\def\ssgridgo#1#2{ + \pgfsetlinewidth{\the\sseq@gridstrokethickness} + \pgftransformxshift{\the\sseqhalfentry} + \pgftransformyshift{\the\sseqhalfentry} + \pgfpathgrid[stepx=\the\sseqentrysize,stepy=\the\sseqentrysize]{\pgfpoint{-\the\sseqhalfentry}{-\the\sseqhalfentry}}{\pgfpoint{#1*\sseqentrysize-\sseqhalfentry}{#2*\sseqentrysize-\sseqhalfentry}} + \pgfusepath{stroke} +} + +\def\ssgridnone#1#2{} + +\def\ssgriddots#1#2{ + \pgfsetlinewidth{1pt} + \pgfsetdash{{1pt}{\the\sseqentrysize-1pt}}{\the\sseqhalfentry+.5pt} + \pgftransformxshift{\the\sseqhalfentry} + \pgftransformyshift{\the\sseqhalfentry} + \pgfpathgrid[stepx=\the\sseqentrysize,stepy=\the\sseqentrysize]{\pgfpoint{-\the\sseqhalfentry}{-\the\sseqhalfentry}}{\pgfpoint{#1*\sseqentrysize-\sseqhalfentry}{#2*\sseqentrysize-\sseqhalfentry}} + \pgfusepath{stroke} +} + +\def\ssgridchess#1#2{ + \pgfsetlinewidth{\the\sseqentrysize} + \pgfsetdash{{\the\sseqentrysize}{\the\sseqentrysize}}{\the\sseqentrysize} + \pgfsetcolor{sslightgr} + \pgftransformxshift{\the\sseqhalfentry} + \pgftransformyshift{\the\sseqhalfentry} + \pgfpathgrid[stepx=\the\sseqentrysize*2,stepy=\the\sseqentrysize*2]{\pgfpoint{-\the\sseqhalfentry}{-\the\sseqhalfentry}}{\pgfpoint{#1*\sseqentrysize-\sseqhalfentry}{#2*\sseqentrysize-\sseqhalfentry}} + \pgfusepath{stroke} +} + +\def\sseq@drawgrid{ + \expandafter\ifx\sseqgridstyle\ssequndefined + \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.} + \gdef\sseqgridstyle{\ssgridnone} + \fi + \sseqj=0 + \def\tempcmd{\range@loop{\sseq@innergridloop}} + \expandafter\tempcmd\sseq@xrange +} +% ^^A The following is called for every part #1...#2 +% +\def\sseq@innergridloop#1#2{ + \sseqj=0 + \def\tempcmd{\range@loop{\sseq@gridwrapper{#1}{#2}}} + \expandafter\tempcmd\sseq@yrange +} +\def\sseq@gridwrapper#1#2#3#4{ + \begin{pgfscope} + \ss@getcoords{#1}{#3} + \sseqxx=\sseqx + \sseqyy=\sseqy + \count0=#2\advance\count0 by 1 + \count1=#4\advance\count1 by 1 + \pgftransformshift{\pgfpoint{\the\sseqxx}{\the\sseqyy}} + \count2=#1 + \multiply\count2 by -1 + \advance\count0 by \count2 + \count2=#3 + \multiply\count2 by -1 + \advance\count1 by \count2 + \@eval\sseqgridstyle{{\number\count0}{\number\count1}} + \end{pgfscope} +} +% +% ^^A \sseq@drawlabels +% +\def\sseq@drawlabels{ + \sseqj=0 + \def\tempcmd{\range@loop{\sseqk=-\sseqxstep \sseq@drawhorizontallabels}} + \expandafter\tempcmd\sseq@xrange + \sseqj=0 + \def\tempcmd{\range@loop{\sseqk=-\sseqystep \sseq@drawverticallabels}} + \expandafter\tempcmd\sseq@yrange +} +% + +\def\sseq@drawhorizontallabels#1#2{ + \advance\sseqk by \sseqxstep + \sseqi=#1 + \ifnum\sseqi>#2\else + \ss@getcoords{\the\sseqi}{0} + \advance\sseqx by \sseqhalfentry + \sseqxlabel + \sbox\sseq@labelbox{\strut\ensuremath{\sseq@answer}} + \dimen0 = \ht\sseq@labelbox + \advance\dimen0 by \dp\sseq@labelbox + \pgf@protocolsizes{0pt}{-\dimen0} % ^^A fixes a bug with bounding boxes in pgf + \pgftext[top,at=\pgfpoint{\the\sseqx}{0pt}]{\usebox{\sseq@labelbox}} + \advance\sseqi by \sseqxstep + \edef\tempcmd{\noexpand\sseq@drawhorizontallabels{\number\sseqi}{#2}} + \expandafter\tempcmd + \fi +} +% +\def\sseq@drawverticallabels#1#2{ + \advance\sseqk by \sseqystep + \sseqi=#1 + \ifnum\sseqi>#2\else + \ss@getcoords{0}{\the\sseqi} + \advance\sseqy by \sseqhalfentry + \sseqylabel + \pgftext[right,at=\pgfpoint{-2pt}{\the\sseqy}]{\ensuremath{\sseq@answer}} + \advance\sseqi by \sseqystep + \edef\tempcmd{\noexpand\sseq@drawverticallabels{\number\sseqi}{#2}} + \expandafter\tempcmd + \fi +} +% +% ^^A #1 = number of outer part +% ^^A #2 = number of inner part +% +% +\def\sseq@labelfromlist#1#2#3,{ + \def\temp{#3} + \def\tempcmd{} + \ifx\temp\range@endmarker + \def\sseq@answer{?} + \else + \count0=#1 + \ifnum\count0=0 + \def\sseq@lastlabel{} + \def\tempcmd{\sseq@innerlabelfromlist{#2}#3;END;} + \else + \advance\count0 by -1 + \edef\tempcmd{\noexpand\sseq@labelfromlist{\number\count0}{#2}} + \fi + \fi + \tempcmd +} + +\def\sseq@innerlabelfromlist#1#2;{ + \def\temp{#2} + \def\tempcmd{} + \ifx\temp\range@endmarker + \ifx\sseq@lastlabel\empty + \def\sseq@answer{?} + \else + \count0=#1 + \ifnum\count0=0 + \def\sseq@answer{\ensuremath{\sseq@lastlabel}} + \def\tempcmd{\range@gobbletoend} + \else + \advance\count0 by -1 + \edef\tempcmd{\noexpand\sseq@innerlabelfromlist{\number\count0}END;} + \fi + \fi + \else + \def\sseq@lastlabel{#2} + \count0=#1 + \ifnum\count0=0 + \def\sseq@answer{\ensuremath{#2}} + \def\tempcmd{\range@gobbletoend} + \else + \advance\count0 by -1 + \edef\tempcmd{\noexpand\sseq@innerlabelfromlist{\number\count0}} + \fi + \fi + \tempcmd +} +% +% ^^A options that can be passed to sseq +% +\define@key{sseq}{grid}{ +\expandafter\def\expandafter\sseqgridstyle\expandafter{\csname ssgrid#1\endcsname} +} +% +\define@key{sseq}{entrysize}{ +\sseqentrysize=#1 +} +\define@key{sseq}{labels}{ + \setkeys{sseq}{xlabels=#1,ylabels=#1} +} +\define@key{sseq}{xlabels}{ + \def\temp{#1} + \def\temptwo{none} + \ifx\temp\temptwo + \def\sseqxlabel{\def\sseq@answer{}} + \else + \def\temptwo{numbers} + \ifx\temp\temptwo + \def\sseqxlabel{\def\sseq@answer{\the\sseqi}} + \else + \def\sseqxlabel{% + \@eval\sseq@labelfromlist{{\number\sseqj}{\number\sseqk}}#1,END,% + } + \fi + \fi +} +\define@key{sseq}{ylabels}{ + \def\temp{#1} + \def\temptwo{none} + \ifx\temp\temptwo + \def\sseqylabel{\def\sseq@answer{}} + \else + \def\temptwo{numbers} + \ifx\temp\temptwo + \def\sseqylabel{\def\sseq@answer{\the\sseqi}} + \else + \def\sseqylabel{% + \@eval\sseq@labelfromlist{{\number\sseqj}{\number\sseqk}}#1,END,% + } + \fi + \fi +} +\define@key{sseq}{xlabelstep}{\sseqxstep=#1} +\define@key{sseq}{ylabelstep}{\sseqystep=#1} +\define@key{sseq}{labelstep}{\setkeys{sseq}{xlabelstep=#1}\setkeys{sseq}{ylabelstep=#1}} + +\define@key{sseq}{gapsize}{\setkeys{sseq}{xgapsize=#1}\setkeys{sseq}{ygapsize=#1}} +\define@key{sseq}{xgapsize}{\sseq@xgap=#1} +\define@key{sseq}{ygapsize}{\sseq@ygap=#1} +\define@key{sseq}{leak}{\setkeys{sseq}{xleak=#1}\setkeys{sseq}{yleak=#1}} +\define@key{sseq}{xleak}{\sseq@xleak=#1} +\define@key{sseq}{yleak}{\sseq@yleak=#1} +\define@key{sseq}{gridstroke}{\sseq@gridstrokethickness=#1} +\define@key{sseq}{arrows}{\def\sseq@defaultarrowstyle{#1}} +% +% ^^A Defaults +% +\sseqentrysize=0.4cm +\sseq@xgap=0.3cm +\sseq@ygap=0.3cm +\global\sseq@xleak=-100mm +\global\sseq@yleak=-100mm +\sseqxstep=2 +\sseqystep=2 +\def\sseqgridstyle{\ssgridcrossword} +\def\sseq@defaultarrowstyle{to} + +\newenvironment{sseq}[3][]{% \begingroup % +% ^^A Start the PGF environment +\begin{pgfpicture} +% % ^^A Initialize some local counters and dimensions % -\countdef\sseqxend=150 \sseqxend=\sseqxstart \advance\sseqxend by #1 -\countdef\sseqyend=151 \sseqyend=\sseqystart \advance\sseqyend by #2 -\dimendef\sseqoffx=200 \sseqoffx=0pt -\dimendef\sseqoffy=201 \sseqoffy=0pt -\dimendef\sseqoffsetx=202 -\dimendef\sseqoffsety=203 -\countdef\sseqi=152 \sseqi=0 -\countdef\sseqj=153 \sseqj=0 -\countdef\sseqxdir=154 -\countdef\sseqposx=155 -\countdef\sseqposy=156 -\countdef\sseqydir=157 -\dimendef\sseqlabelbarwidth=204 -\dimendef\sseqhalfentry=205 -\dimendef\sseqx=206 -\dimendef\sseqy=207 -\dimendef\sseqxx=208 -\dimendef\sseqyy=209 -\dimendef\sseqlabelwidth=210 -\dimendef\sseqrightlabelwidth=211 -\dimendef\sseqlabelsize=212 - -\ifnum\sseqxstep<0 \sseqxdir=-1 \else \sseqxdir=1 \fi -\ifnum\sseqystep<0 \sseqydir=-1 \else \sseqydir=1 \fi -\def\sseqlabelfontsize{12} +\countdef\sseqi=152% +\countdef\sseqj=153% +\countdef\sseqxdir=154% +\countdef\sseqposx=155% +\countdef\sseqposy=156% +\countdef\sseqydir=157% +\countdef\sseqk=158% +\dimendef\sseqhalfentry=205% +\dimendef\sseqx=206% +\dimendef\sseqy=207% +\dimendef\sseqxx=208% +\dimendef\sseqyy=209% +\dimendef\sseqabsposx=210% +\dimendef\sseqabsposy=211% +\sseq@gridstrokethickness=.1pt% +%\ifnum\sseqxstep<0 \sseqxdir=-1 \else \sseqxdir=1 \fi +%\ifnum\sseqystep<0 \sseqydir=-1 \else \sseqydir=1 \fi % % Backup count0 - count9 (these are page numbers!) % -\edef\sseqsavecnto{\the\count0} -\edef\sseqsavecnti{\the\count1} -\edef\sseqsavecntii{\the\count2} -\edef\sseqsavecntiii{\the\count3} -\edef\sseqsavecntiv{\the\count4} -\edef\sseqsavecntv{\the\count5} -\edef\sseqsavecntvi{\the\count6} -\edef\sseqsavecntvii{\the\count7} -\edef\sseqsavecntviii{\the\count8} -\edef\sseqsavecntix{\the\count9} -% -% ^^A Compute the maximal axis label width -% -\sseqlabelwidth=14pt -\sseqrightlabelwidth=10pt -\ifnum\sseqxstart<0 - \advance\sseqlabelwidth by 8pt - \ifnum\sseqxstart<-9 - \advance\sseqlabelwidth by 6pt - \ifnum\sseqxstart<-99 - \advance\sseqlabelwidth by 6pt - \fi - \fi +\edef\sseqsavecnto{\number\count0}% +\edef\sseqsavecnti{\number\count1}% +\edef\sseqsavecntii{\number\count2}% +\edef\sseqsavecntiii{\number\count3}% +\edef\sseqsavecntiv{\number\count4}% +\edef\sseqsavecntv{\number\count5}% +\edef\sseqsavecntvi{\number\count6}% +\edef\sseqsavecntvii{\number\count7}% +\edef\sseqsavecntviii{\number\count8}% +\edef\sseqsavecntix{\number\count9}% +% +% ^^A Parse arguments +% +% +\setkeys{sseq}{#1} +% +\ifnum\sseqxstep=0 % ^^A old-fashioned way of disabling labels + \setkeys{sseq}{xlabels=none} + \sseqxstep=1 +\else + \@ifundefined{sseqxlabel}{\setkeys{sseq}{xlabels=numbers}}{} \fi -\ifnum\sseqxend>10 - \advance\sseqrightlabelwidth by 6pt - \ifnum\sseqxend>100 - \advance\sseqrightlabelwidth by 6pt - \fi +\ifnum\sseqystep=0 % ^^A old-fashioned way of disabling labels + \setkeys{sseq}{ylabels=none}% + \sseqystep=1 +\else + \@ifundefined{sseqylabel}{\setkeys{sseq}{ylabels=numbers}}{} \fi -\ifnum\sseqrightlabelwidth>\sseqlabelwidth - \sseqlabelwidth=\sseqrightlabelwidth +\ifdim\sseq@xleak=-100mm + \sseq@xleak=0.3\sseq@xgap \fi -\sseqlabelsize=10pt -\count0=\sseqentrysize -\multiply \count0 by 160 -\divide \count0 by \sseqlabelwidth -\multiply \sseqlabelsize by \count0 -\divide \sseqlabelsize by 100 -\ifdim\sseqlabelsize<11pt - \def\sseqlabelfontsize{10} - \ifdim\sseqlabelsize<9.5pt - \def\sseqlabelfontsize{9} - \ifdim\sseqlabelsize<8.5pt - \def\sseqlabelfontsize{8} - \fi - \fi +\ifdim\sseq@yleak=-100mm + \sseq@yleak=0.3\sseq@ygap \fi -\edef\sz{\the\sseqlabelsize} -\putxyq {\font \sseqlabelfont = cmtt} -\putxy{\sseqlabelfontsize\space at \the\sseqlabelsize\space} -\sseqlabelbarwidth=\sseqlabelsize -\divide\sseqlabelbarwidth by 2 -\dimen0=\sseqentrysize -\multiply\dimen0 by -1 -\multiply\dimen0 by \sseqxdir -\multiply\dimen0 by \sseqxstart -\sseqoffsetx=\sseqlabelbarwidth -\advance\sseqoffsetx by \dimen0 -\dimen0=\sseqentrysize -\multiply\dimen0 by -1 -\multiply\dimen0 by \sseqydir -\multiply\dimen0 by \sseqystart -\sseqoffsety=\sseqlabelbarwidth -\advance\sseqoffsety by \dimen0 -\sseqhalfentry=\sseqentrysize -\divide\sseqhalfentry by 2 -\sseqx=\sseqentrysize -\multiply \sseqx by #1 -\advance \sseqx by \sseqlabelbarwidth -\sseqy=\sseqentrysize -\multiply \sseqy by \sseqj -\advance \sseqy by \sseqlabelbarwidth -\sseqxx=\sseqx -\sseqyy=\sseqy -\advance\sseqxx by \sseqhalfentry -\advance\sseqyy by \sseqhalfentry % % -% ^^A start the xy environment -\putxyq {\xy} % +\range@parseandnormalize{\sseq@xrange}{\sseqxstart}{#2} +\range@parseandnormalize{\sseq@yrange}{\sseqystart}{#3} % -\sseqdrawgrid{#1}{#2} -\sseqdrawlabels{#1}{#2} +% ^^A Some setup +\pgfsetshapeminwidth{1.1mm} +\pgfsetshapeinnerxsep{1pt} +\pgfsetshapeinnerysep{1pt} % +\sseqhalfentry=\sseqentrysize +\divide\sseqhalfentry by 2 +% +\sseq@drawgrid +\sseq@drawlabels % +% ^^A Move to turtle to (0,0) \sseqposx=0 \sseqposy=0 +%\sseq@updatecurrentdata } % % @@ -1394,11 +1885,10 @@ % { \relax -\ssfinishpos -\putxyq{\endxy} -\bigskip +\ssmoveto 0 0 \ssmoveto 0 0 \edef\lst{\the\sseqcmdlist} \ifthenelse{\boolean{debug}}{\show\lst}{} +\the\sseqcmdlist % % ^^A Restore count0-count9 in case we're in the middle of a page break. % @@ -1412,9 +1902,8 @@ \count7=\sseqsavecntvii \count8=\sseqsavecntviii \count9=\sseqsavecntix -\the\sseqcmdlist +\end{pgfpicture} \endgroup -\bigskip } % % \Finale |