%------------------------------------------------------------------------------
%   sd.sty v1.06    Copyright (C) Atsushi Takeuchi,1992,1993,1994,1999
%
%       v1.00   1992/10/10  by Atsushi Takeuchi
%       v1.01   1992/12/13
%                   change macro names : \dancer=>\danc  \formation=>\sdform
%                   add \lbox
%                   add \rarrow \larrow in the \cbox and \lbox
%                   add \framelinewidth
%                   change dancer size setting macros
%                   bug fix
%       v1.02   1993/01/28
%                   bug fix
%       v1.03   1993/04/29
%                   add \noseadjust \noseadjustON \noseadjustOFF
%                   add \lcaption \ccaption in the displaydance environment
%                   add \slantboxON \slantboxOFF
%                   add offset option to \priform
%       v1.04   1994/05/26
%                   add arrow drawing macros
%                   add any angle mode to dancer drawing macros
%                   add overlapped contents option to dancer drawing macros
%                   add border width of \sdform and \priform
%                   add \draftON \draftOFF
%       v1.05   1994/06/08
%                   bug fix
%       v1.06   1999/07/11
%                   change dancer size setting macros for LaTeX2e
%
%   This file contains macros to draw a dancer and a formation of square dance.
%   Example use:
%
%       \documentclass[12pt]{article}
%       \usepackage{tex-squares}
%       \usepackage{sd}
%       \usepackage{sd-pf}
%       \usepackage{sd-sf}
%       \usepackage{sd-sf12}
%
%----------------------------- MACRO LIST -------------------------------------
%<< dancer drawing macros >>
%
%   \danc[HOFF,VOFF] XYZ*{OP}   : draws a dancer.
%
%       X   : frame of a dancer
%           : .(none) b(box) g(circle) p(dashed box)
%
%       Y   : character in the frame
%           : .(none) 0-9 a-z A-Z {anything} etc.
%
%       Z   : directon of a dancer
%           : .(none) n(north) s(south) e(east) w(west)
%           : 1(north-east) 2(north-west) 3(south-west) 4(south-west)
%           : v(n and s) h(e and w) r(1 and 3) l(2 and 4)
%           : +(n and s and e and w) x(1 and 2 and 3 and 4)
%           : {0XXX} any angle of XXX degree (5 degree step)
%
%       HOFF: horizontal offset(%) of a dancer from the matrix point.
%       VOFF: vertical   offset(%) of a dancer from the matrix point.
%           : 100(one matrix) 50(half matrix) etc.
%           : [HOFF,VOFF] is a optional argument, default is [0,0].
%
%       OP  : OP is overlapped on Y.
%           : OP may be another dancer macro with offset, arrow macro,
%           :    or any string.
%           : *{OP} is optional.
%
%       ex. : \danc b1n  \danc[50,-50]g2e  \danc .+.
%             \danc .{AAA}.  \danc g2{030}*{\danc[50,50]b2{0210}}
%             \danc b1n*{\sdarrow[0,50]{1}{90}{80}}
%
%
%   \boy[HOFF,VOFF]  YZ*{OP} : same as \danc[HOFF,VOFF] bYZ*{OP}
%   \girl[HOFF,VOFF] YZ*{OP} : same as \danc[HOFF,VOFF] gYZ*{OP}
%   \phan[HOFF,VOFF] YZ*{OP} : same as \danc[HOFF,VOFF] pYZ*{OP}
%   \spot[HOFF,VOFF] YZ*{OP} : same as \danc[HOFF,VOFF] .YZ*{OP}
%
%
%   \edanc \wdanc \ndanc \sdanc \nedanc \nwdanc \sedanc \swdanc
%   \eboy    \wboy    \nboy    \sboy    \neboy    \nwboy    \seboy    \swboy
%   \egirl   \wgirl   \ngirl   \sgirl   \negirl   \nwgirl   \segirl   \swgirl
%   \ephan   \wphan   \nphan   \sphan   \nephan   \nwphan   \sephan   \swphan
%   \espot   \wspot   \nspot   \sspot   \nespot   \nwspot   \sespot   \swspot
%
%       : these are half offset dancers.
%       : for example, \edanc is \danc[50,0], \nwboy is \boy[-50,50]
%
%
%<< dancer drawing control macros >>
%
%   \framelinewidth : changes line width of dancer box frame
%       : only box and dashed box can be changed.
%       : circle is fixed to 0.4pt.
%       : this value will be used after next dancer size setting macro.
%       : initial value is 0.4pt.
%
%   \noseadjust{NUM}    : moves the center of dancer according to NUM.
%
%       NUM : the center of dancer becomes ( dancer frame + nose * NUM )/2 .
%           : initial value is 0.0.
%
%   \noseadjustON       : makes \noseadjust function ON
%   \noseadjustOFF      : makes \noseadjust function OFF
%
%       : when \noseadust is OFF, the center is adjusted as if NUM=0.0 .
%       : initial setting is \noseadjustON
%
%   \slantboxON     : uses slant box for 45 degree boy and phantom
%   \slantboxOFF    : uses normal box for 45 degree boy and phantom
%
%       : slant box needs much main memory
%       : if TeX capacity is exceeded, make \slantboxOFF
%       : initial setting is \slantboxON
%
%   \draftON    : display dancer and sdform area
%   \draftOFF   : not dispay dancer and sdform area
%
%<< formation drawing macros >>
%
%   \sdform[HMAG,VMAG]{ FORMATION }*{ CAPTION } : draw a formation.
%
%       FORMATION   : array of dancer macros .
%                   : column delimiter is & , row terminater is \cr
%
%       HMAG,VMAG   : local magnification ratio of the formation
%                   : [HMAG,VMAG] is optional, default is [1,1].
%
%       CAPTION     : text or text array that is put under the formation.
%                   : CAPTION is put in a \cbox (see below).
%                   : *{ CAPTION } is optional.
%
%       ex.         :   \sdform[0.8,1.0]
%                       {
%                           \boy 1n & \girl 1s & \girl 4n & \boy 4s \cr
%                           \boy 2n & \girl 2s & \girl 3n & \boy 3s \cr
%                       }*{ right hand wave }
%
%
%   \priform[HOFF,VOFF]{ FORMATION } : draw a primitive formation
%           : \priform is used in the \sdform same as dancer macros.
%           : \sdform magnification is automatically used in the \priform.
%
%       FORMATION   : same as FORMATION in the \sdform.
%
%       HOFF,VOFF   : offset(%) of the dancers from the matrix point.
%                   : [HOFF,VOFF] is optional, default is [0,0].
%
%       ex. :
%           \sdform{
%               \priform{\boy1n&\girl1s\cr} & \priform{\boy2e\cr\girl2w \cr}\cr
%               \priform{\girl4e\cr\boy4w\cr} & \priform{\girl3n&\boy3s\cr} \cr
%           }*{C1 phantom}
%
%
%<< formation drawing control macros >>
%
%   \formationmag{MAG}  : set a global magnification ratio of a formation
%
%       MAG : global magnification ratio. initial value is 1 .
%           : total magnification of a formation is global*local .
%
%   \captionvskip=SKIP : set a skip between formation and caption
%
%       SKIP: skip before the caption .
%           : initial value is 0.3*(dancer size) plus 0pt minus 0pt.
%           : this is initialized by dancer size setting macros.
%
%   \eborder{WIDTH} : set a east side border width of \sdform and \priform.
%   \wborder{WIDTH} : set a west side border width of \sdform and \priform.
%   \nborder{WIDTH} : set a north side border width of \sdform and \priform.
%   \sborder{WIDTH} : set a south side border width of \sdform and \priform.
%
%       WIDTH   : border width.
%               : unit is a distance between adjacent matrix points.
%
%
%<< displaydance environment >>
%
%   \begin{displaydance}[HSKIP,VSKIP]
%       CONTENTS
%   \end{displaydance}
%
%       : this environment begins new paragraph and aligns CONTENTS.
%       : no page break is allowed between the rows in the array.
%       : page break occurs between the arrays, if necessary.
%
%
%       CONTENTS: arrays of \sdform, text, \cbox, etc.
%               : column delimiter is &.
%               : \cr finishes a current row and begins a new row
%               :   and inserts a VSKIP beteen the rows.
%               : \\  finishes a current array and begins a new array
%               :   and inserts a VSKIP beteen the arrays.
%               : \lcaption{TEXT} and \ccaption{TEXT} finish a current row,
%               :   insert TEXT and VSKIP, and begin a new row.
%               :   \lcaption adjusts TEXT to the leftside.
%               :   \ccaption adjusts TEXT to the center.
%
%       HSKIP   : horizontal skip between the columns, and left/right margin.
%       VSKIP   : vertical skip between the rows, and top/bottom margin.
%               : [HSKIP,VSKIP] is optional,
%               :   default is [\displaymodehskip,\displaymodevskip].
%
%       ex.     :
%           \begin{displaydance}
%
%           \lcaption{example1:}
%           \sdform{\boy1n&\girl1s\cr} & \sdform{\boy1n\cr\girl1n\cr} \cr
%           \cbox{mini\\wave}          & tandem \\
%
%           \ccaption{example2}
%           \sdform{\boy1n&\girl1s\cr \girl2n&\boy2s\cr} \cr
%           box \\
%
%           \end{displaydance}
%
%   \displaymodehskip=HSKIP : default horizontal skip
%   \displaymodevskip=VSKIP : default vertical skip
%   \displaymodemag{MAG}    : \formationmag in the displaydance environment
%
%       HSKIP   : horizontal skip between the columns, and right/left margin.
%               : initial value is
%               :   (dancer size) plus \hsize minus 0.5*(dancer size).
%
%       VSKIP   : vertical skip between the rows, and top/bottom margin.
%               : initial value is (dancer size) plus 0pt minus 0pt.
%
%       MAG     : \formationmag in the displaydance environment.
%               : initial value is 1.2
%
%
%<< dancer size setting macros >>
%
%   \smalldancer    : set dancer size to (frame  5pt nose 2pt char  5pt)
%   \Smalldancer    : set dancer size to (frame  6pt nose 2pt char  6pt)
%   \SMALLdancer    : set dancer size to (frame  7pt nose 2pt char  7pt)
%   \normaldancer   : set dancer size to (frame  8pt nose 3pt char  8pt)
%   \Normaldancer   : set dancer size to (frame  9pt nose 3pt char  9pt)
%   \NORMALdancer   : set dancer size to (frame 10pt nose 3pt char 10pt)
%   \largedancer    : set dancer size to (frame 11pt nose 4pt char 11pt)
%   \Largedancer    : set dancer size to (frame 12pt nose 4pt char 12pt)
%   \LARGEdancer    : set dancer size to (frame 13pt nose 4pt char 12pt)
%   \hugedancer     : set dancer size to (frame 14pt nose 5pt char 14pt)
%   \Hugedancer     : set dancer size to (frame 15pt nose 5pt char 14pt)
%
%       : initial setting is \normaldancer
%
%
%<< array box macros >>
%
%   \cbox[HSKIP,VSKIP]{ CONTENTS }
%   \lbox[HSKIP,VSKIP]{ CONTENTS }
%       : centering(\cbox) and flushleft(\lbox) box.
%       : these are similar to displaydance environment,
%       : but it has no space in the top/bottom margin.
%
%       CONTENTS: array of text etc.
%               : column delimiter is &. new row is \cr. new array is \\.
%               :   \cr inserts a VSKIP beteen the rows.
%               :   \\ inserts a VSKIP beteen the arrays.
%               : \rarrow and \larrow begin a new array
%               :   and insert a horizontal arrow.
%
%       HSKIP   : horizontal skip between the column, and left/right margin.
%       VSKIP   : vertical skip between the rows.
%               : [HSKIP,VSKIP] is optional,
%               :   default is [\cboxhskip,\cboxvskip].
%
%   \cboxvhkip=HSKIP    : default cbox horizontal skip
%   \cboxvskip=VSKIP    : default cbox vertical skip
%
%       HSKIP   : horizontal skip between the rows, and left/right margin.
%               : initial value is 4pt plus 0pt minus 0pt
%       VSKIP   : vertical skip between the rows.
%               : initial value is 4pt plus 0pt minus 0pt
%
%
%<< arrow drawing macro >>
%
%   \sdarrow[XOFF,YOFF](HMAG,VMAG){R}{DIR}{ANG}     : draw an arrow.
%
%       HOFF,VOFF   : offset same as dancer macro
%                   : [HOFF,VOFF] is optional, default is [0,0].
%
%       HMAG,VMAG   : local magnification ratio of the arrow
%                   : (HMAG,VMAG) is optional, default is (1,1).
%
%       R           : local radius of arched arrow.
%                   : unit is a distance between adjacent matrix points.
%
%       DIR         : initial direction of the arrow. unit is degree.
%
%       ANG         : angle between final and initial directions of the arrow.
%                   : unit is dgree.
%
%
%<< arrow drawing control macros >>
%
%   \sdarrowwidth   : line width of the arrow. initial value is 0.6pt.
%   \sdarrowhead    : length of the arrow head. default value is nose size.
%
%
%------------------------------------------------------------------------------


\newbox\@nonebox
\newbox\@girlbox
\newbox\@boybox
\newbox\@phantombox
\newbox\@nosebox
\newbox\@angledbox

\newdimen\framelinewidth    \framelinewidth=0.4pt
\newdimen\@innersize
\newdimen\@outersize
\newdimen\@noseoffset
\newdimen\@nosesize
\newdimen\@outerhmargin     \@outerhmargin=0pt
\newdimen\@outervmargin     \@outervmargin=0pt
\newdimen\@framewidth
\newtoks\nborder            \nborder{0.0}
\newtoks\sborder            \sborder{0.0}
\newtoks\eborder            \eborder{0.0}
\newtoks\wborder            \wborder{0.0}
\newtoks\n@border           \n@border{0.0}
\newtoks\s@border           \s@border{0.0}
\newtoks\e@border           \e@border{0.0}
\newtoks\w@border           \w@border{0.0}
\newtoks\formationmag       \formationmag{1.0}
\newtoks\displaymodemag     \displaymodemag{1.2}
\newtoks\noseadjust         \noseadjust{0.0}
\newtoks\@sdformhmag        \@sdformhmag{1.0}
\newtoks\@sdformvmag        \@sdformvmag{1.0}
\newskip\displaymodehskip
\newskip\displaymodevskip
\newskip\captionvskip
\newskip\cboxhskip          \cboxhskip=0.5em plus0pt minus0pt
\newskip\cboxvskip          \cboxvskip=1ex plus0pt minus0pt
\newskip\@dispvskip
\newcount\@hoffset          \@hoffset=0
\newcount\@voffset          \@voffset=0

\newif\if@noseadjust
\def\noseadjustON{\@noseadjusttrue}
\def\noseadjustOFF{\@noseadjustfalse}

\newif\if@slantbox
\def\slantboxON{\@slantboxtrue}
\def\slantboxOFF{\@slantboxfalse}

\newif\if@draft
\def\draftON{\@drafttrue}
\def\draftOFF{\@draftfalse}

\def\smalldancer{%
    \def\@girlboxchar{{\tencirc\char100}}%
    \def\@nosechar{{\tencirc\char113}}%
%   \font\@dancerfont=\fontname\fivrm%
    \font\@dancerfont=cmr5%
    \@framewidth=\framelinewidth%
    \@makedancer%
}

\def\Smalldancer{%
    \def\@girlboxchar{{\tencirc\char101}}%
    \def\@nosechar{{\tencirc\char113}}%
%   \font\@dancerfont=\fontname\sixrm%
    \font\@dancerfont=cmr6%
    \@framewidth=\framelinewidth%
    \@makedancer%
}

\def\SMALLdancer{%
    \def\@girlboxchar{{\tencirc\char102}}%
    \def\@nosechar{{\tencirc\char113}}%
%   \font\@dancerfont=\fontname\sevrm%
    \font\@dancerfont=cmr7%
    \@framewidth=\framelinewidth%
    \@makedancer%
}

\def\normaldancer{%
    \def\@girlboxchar{{\tencirc\char103}}%
    \def\@nosechar{{\tencirc\char114}}%
%   \font\@dancerfont=\fontname\egtrm%
    \font\@dancerfont=cmr8%
    \@framewidth=\framelinewidth%
    \@makedancer%
}

\def\Normaldancer{%
    \def\@girlboxchar{{\tencirc\char104}}%
    \def\@nosechar{{\tencirc\char114}}%
%   \font\@dancerfont=\fontname\ninrm%
    \font\@dancerfont=cmr9%
    \@framewidth=\framelinewidth%
    \@makedancer%
}

\def\NORMALdancer{%
    \def\@girlboxchar{{\tencirc\char105}}%
    \def\@nosechar{{\tencirc\char114}}%
%   \font\@dancerfont=\fontname\tenrm%
    \font\@dancerfont=cmr10%
    \@framewidth=\framelinewidth%
    \@makedancer%
}

\def\largedancer{%
    \def\@girlboxchar{{\tencirc\char106}}%
    \def\@nosechar{{\tencirc\char115}}%
%   \font\@dancerfont=\fontname\elvrm%
    \font\@dancerfont=cmr10 scaled \magstephalf%
    \@framewidth=\framelinewidth%
    \@makedancer%
}

\def\Largedancer{%
    \def\@girlboxchar{{\tencirc\char107}}%
    \def\@nosechar{{\tencirc\char115}}%
%   \font\@dancerfont=\fontname\twlrm%
    \font\@dancerfont=cmr12%
    \@framewidth=\framelinewidth%
    \@makedancer%
}

\def\LARGEdancer{%
    \def\@girlboxchar{{\tencirc\char108}}%
    \def\@nosechar{{\tencirc\char115}}%
%   \font\@dancerfont=\fontname\twlrm%
    \font\@dancerfont=cmr12%
    \@framewidth=\framelinewidth%
    \@makedancer%
}

\def\hugedancer{%
    \def\@girlboxchar{{\tencirc\char109}}%
    \def\@nosechar{{\tencirc\char116}}%
%   \font\@dancerfont=\fontname\frtnrm%
    \font\@dancerfont=cmr10 scaled \magstep 2%
    \@framewidth=\framelinewidth%
    \@makedancer%
}

\def\Hugedancer{%
    \def\@girlboxchar{{\tencirc\char110}}%
    \def\@nosechar{{\tencirc\char116}}%
%   \font\@dancerfont=\fontname\frtnrm%
    \font\@dancerfont=cmr10 scaled \magstep 2%
    \@framewidth=\framelinewidth%
    \@makedancer%
}

\def\@makedancer{%
%--- set innersize ---
    \setbox0=\hbox{\@girlboxchar}%
    \@innersize=\wd0%
%
%--- make girl box ---
    \setbox\@girlbox=\hbox{\kern0.5\wd0\unhbox0}%
    \wd\@girlbox=\@innersize%
    \ht\@girlbox=0.5\@innersize%
    \dp\@girlbox=0.5\@innersize%
%
%--- make boy box ---
    \setbox\@boybox=\hbox to \@innersize{%
        \hss\vrule width\@framewidth%
        \vbox to \@innersize{%
            \hrule width\@innersize height\@framewidth%
            \vfil%
            \hrule height\@framewidth%
        }%
        \vrule width\@framewidth\hss%
    }%
%
%--- make phantom box ---
    \setbox0=\vbox to \@innersize{
        \hrule height 0.125\@innersize width\@framewidth
        \vfil
        \hrule height 0.25\@innersize width\@framewidth
        \vfil
        \hrule height 0.125\@innersize width\@framewidth
    }%
    \setbox1=\vbox to \@innersize{
        \hrule width 0.125\@innersize height\@framewidth
        \vfil
        \hrule width 0.125\@innersize height\@framewidth
    }%
    \setbox2=\vbox to \@innersize{
        \hrule width 0.25\@innersize height\@framewidth
        \vfil
        \hrule width 0.25\@innersize height\@framewidth
    }%
    \setbox\@phantombox=\hbox to \@innersize{%
        \copy0\copy1\hfil\box2\hfil\box1\box0%
    }%
%
%--- make none box ---
    \setbox\@nonebox=\hbox to \@innersize{%
        \vrule width0pt height\@innersize depth0pt\hss%
    }%
%
%--- make nosebox ---
    \setbox\@nosebox=\hbox{\@nosechar}%
    \@nosesize=\wd\@nosebox%
    \wd\@nosebox=0pt%
    \@noseoffset=0.5\@innersize
        \advance\@noseoffset 0.5\@nosesize%
        \advance\@noseoffset -0.2pt%
%
%--- set outersize ---
    \@outersize=2\@noseoffset%
        \advance\@outersize \@nosesize%
        \@outersize=1.1\@outersize%
%
%--- set skips ---
    \displaymodehskip=\@outersize plus\hsize minus0.5\@outersize%
    \displaymodevskip=\@outersize plus0pt minus0pt%
    \captionvskip=0.3\@outersize plus0pt minus0pt%
%
%--- set arrow head ---
    \sdarrowhead=\@nosesize%
}

%--- 50% offset dancers ---
\def\edanc{\danc[50,0]}     \def\wdanc{\danc[-50,0]}
\def\ndanc{\danc[0,50]}     \def\sdanc{\danc[0,-50]}
\def\nedanc{\danc[50,50]}   \def\nwdanc{\danc[-50,50]}
\def\sedanc{\danc[50,-50]}  \def\swdanc{\danc[-50,-50]}
\def\eboy{\boy[50,0]}       \def\wboy{\boy[-50,0]}
\def\nboy{\boy[0,50]}       \def\sboy{\boy[0,-50]}
\def\neboy{\boy[50,50]}     \def\nwboy{\boy[-50,50]}
\def\seboy{\boy[50,-50]}    \def\swboy{\boy[-50,-50]}
\def\egirl{\girl[50,0]}     \def\wgirl{\girl[-50,0]}
\def\ngirl{\girl[0,50]}     \def\sgirl{\girl[0,-50]}
\def\negirl{\girl[50,50]}   \def\nwgirl{\girl[-50,50]}
\def\segirl{\girl[50,-50]}  \def\swgirl{\girl[-50,-50]}
\def\ephan{\phan[50,0]}     \def\wphan{\phan[-50,0]}
\def\nphan{\phan[0,50]}     \def\sphan{\phan[0,-50]}
\def\nephan{\phan[50,50]}   \def\nwphan{\phan[-50,50]}
\def\sephan{\phan[50,-50]}  \def\swphan{\phan[-50,-50]}
\def\espot{\spot[50,0]}     \def\wspot{\spot[-50,0]}
\def\nspot{\spot[0,50]}     \def\sspot{\spot[0,-50]}
\def\nespot{\spot[50,50]}   \def\nwspot{\spot[-50,50]}
\def\sespot{\spot[50,-50]}  \def\swspot{\spot[-50,-50]}

%--- 0% offset dancers ---
\def\danc{\@ifnextchar[{\@dancer}{\@dancer[0,0]}}
\def\boy{\@ifnextchar[{\@boy}{\@boy[0,0]}}
\def\@boy[#1,#2]#3#4{\@dancer[#1,#2]b{#3}{#4}}
\def\girl{\@ifnextchar[{\@girl}{\@girl[0,0]}}
\def\@girl[#1,#2]#3#4{\@dancer[#1,#2]g{#3}{#4}}
\def\phan{\@ifnextchar[{\@phan}{\@phan[0,0]}}
\def\@phan[#1,#2]#3#4{\@dancer[#1,#2]p{#3}{#4}}
\def\spot{\@ifnextchar[{\@spot}{\@spot[0,0]}}
\def\@spot[#1,#2]#3#4{\@dancer[#1,#2].{#3}{#4}}

%--- primitive dancer drawing macros ---
\def\@dancer[#1,#2]#3#4#5{%
\@ifnextchar*{\@@dancer[#1,#2]{#3}{#4}{#5}}{\@@dancer[#1,#2]{#3}{#4}{#5}*{}}%
}

\def\@@dancer[#1,#2]#3#4#5*#6{{%
    \offinterlineskip
    \advance\@hoffset #1
    \advance\@voffset #2
    \dimen0=\@outersize \advance\dimen0 2\@outerhmargin \dimen0=0.02\dimen0
    \dimen1=\@outersize \advance\dimen1 2\@outervmargin \dimen1=0.02\dimen1
    \if#3b\let\@personbox\@boybox
        \if@slantbox\@makeslantbox #5]\fi
    \else\if#3g\let\@personbox\@girlbox
    \else\if#3p\let\@personbox\@phantombox
        \if@slantbox\@makeslantbox #5]\fi
    \else\if#3.\let\@personbox\@nonebox
    \else\errmessage{*** invalid dancer box character (#3) ***}
    \fi\fi\fi\fi
    \if@draft\vrule\fi
    $\vcenter to \@outersize{
        \if@draft\hrule\fi
        \vss
        \kern -\the\@voffset\dimen1
        \hbox to \@outersize{\hss\kern \the\@hoffset\dimen0%
            \vbox to \@outersize{
                \vss
                \def\@w{#4}\def\@ww{.}
                \ifx\@w\@ww
                \else
                    \vbox to \@innersize{
                        \advance\@hoffset -#1
                        \advance\@voffset -#2
                        \vss
                        \hbox to 2\@noseoffset{\hss\hbox{\@dancerfont #4}\hss}
                        \vss
                    }
                    \kern -\@innersize
                \fi
                \def\@w{#6}\def\@ww{}
                \ifx\@w\@ww
                \else
                    \vbox to \@innersize{
                        \advance\@hoffset -#1
                        \advance\@voffset -#2
                        \vss
                        \hbox to 2\@noseoffset{\hss\hbox{\@dancerfont\@w}\hss}
                        \vss
                    }
                    \kern -\@innersize
                \fi
                \hbox to 2\@noseoffset{\hss\copy\@personbox\hss}
                \@noseset #5]
                \if@noseadjust \@vnoseadjust #5]\fi
                \vss
            }\unskip%
            \if@noseadjust \@hnoseadjust #5]\fi%
            \hss%
        }
        \vss
        \if@draft\hrule\fi
    }$%
    \if@draft\vrule\fi
}}

\def\@makeslantbox{\@ifnextchar0{\@anyangle}{\@fixedangle}}

\def\@fixedangle#1]{%
    \if#11\@anyangle045]%
    \else\if#12\@anyangle045]%
    \else\if#13\@anyangle045]%
    \else\if#14\@anyangle045]%
    \else\if#1r\@anyangle045]%
    \else\if#1l\@anyangle045]%
    \else\if#1x\@anyangle045]%
    \fi\fi\fi\fi\fi\fi\fi%
}

\def\@anyangle0#1]{%
    \setbox0=\hbox{%
        \count1=#1\relax%
        \dimen0=0pt
        \count0=0
        \loop\ifnum\count0<4
            \raise\dimen0
            \hbox{%
                \ifx\@personbox\@phantombox
                    \dimen3=0pt
                    \dimen4=0pt
                    \drawline{\@framewidth}{0.125\@innersize}
                                {\dimen3}{\dimen4}{\count1}%
                    \dimen9=0.375\@innersize\@cos{\count1}\dimen3=\dimen9
                    \dimen9=0.375\@innersize\@sin{\count1}\dimen4=\dimen9
                    \drawline{\@framewidth}{0.25\@innersize}
                                {\dimen3}{\dimen4}{\count1}%
                    \dimen9=0.875\@innersize\@cos{\count1}\dimen3=\dimen9
                    \dimen9=0.875\@innersize\@sin{\count1}\dimen4=\dimen9
                    \drawline{\@framewidth}{0.125\@innersize}
                                {\dimen3}{\dimen4}{\count1}%
                \else
                    \drawline{\@framewidth}{\@innersize}{0pt}{0pt}{\count1}%
                \fi
            }%
            \dimen9=\@innersize\@cos{\count1}\kern\dimen9
            \dimen9=\@innersize\@sin{\count1}\advance\dimen0\dimen9
            \advance\count1 90
            \advance\count0 1
        \repeat
    }%
    \setbox\@angledbox=\hbox to \@innersize{%
        \hss%
        \count1=#1\relax\advance\count1 45
        \dimen9=1.414\@innersize\@cos{\count1}\kern-\dimen9
        \vbox to \@innersize{\vss\box0\vss}\unskip%
        \hss%
    }%
    \let\@personbox\@angledbox
}


\def\@noseset{\@ifnextchar0{\@nosesetB}{\@nosesetA}}

\def\@nosesetA#1]{%
    \if#1.%
    \else\if#1n\@@noseset{0pt}{-\@noseoffset}
    \else\if#1s\@@noseset{0pt}{ \@noseoffset}
    \else\if#1e\@@noseset{ \@noseoffset}{0pt}
    \else\if#1w\@@noseset{-\@noseoffset}{0pt}
    \else\if#11\@@noseset{ 0.71\@noseoffset}{-0.71\@noseoffset}
    \else\if#12\@@noseset{-0.71\@noseoffset}{-0.71\@noseoffset}
    \else\if#13\@@noseset{-0.71\@noseoffset}{ 0.71\@noseoffset}
    \else\if#14\@@noseset{ 0.71\@noseoffset}{ 0.71\@noseoffset}
    \else\if#1v\@@noseset{0pt}{\@noseoffset}\@@noseset{0pt}{-\@noseoffset}
    \else\if#1h\@@noseset{-\@noseoffset}{0pt}\@@noseset{\@noseoffset}{0pt}
    \else\if#1+\@@noseset{-\@noseoffset}{0pt}\@@noseset{\@noseoffset}{0pt}
               \@@noseset{0pt}{\@noseoffset}\@@noseset{0pt}{-\@noseoffset}
    \else\if#1r\@@noseset{ 0.71\@noseoffset}{-0.71\@noseoffset}
               \@@noseset{-0.71\@noseoffset}{ 0.71\@noseoffset}
    \else\if#1l\@@noseset{-0.71\@noseoffset}{-0.71\@noseoffset}
               \@@noseset{ 0.71\@noseoffset}{ 0.71\@noseoffset}
    \else\if#1x\@@noseset{ 0.71\@noseoffset}{-0.71\@noseoffset}
               \@@noseset{-0.71\@noseoffset}{-0.71\@noseoffset}
               \@@noseset{-0.71\@noseoffset}{ 0.71\@noseoffset}
               \@@noseset{ 0.71\@noseoffset}{ 0.71\@noseoffset}
    \else\if#1c\@@noseset{0pt}{0pt}
    \else\errmessage{*** invalid dancer direction character (#1) ***}
    \fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi
}

\def\@nosesetB0#1]{%
    \count1=#1\relax%
    \dimen9=\@noseoffset\@cos{\count1}\dimen3=\dimen9
    \dimen9=\@noseoffset\@sin{\count1}\dimen4=-\dimen9
    \@@noseset{\dimen3}{\dimen4}%
}

\def\@@noseset#1#2{%
    \kern -0.5\@innersize
    \dimen2=\@noseoffset \advance\dimen2 #1
    \kern #2
    \moveright \dimen2
    \copy\@nosebox
    \kern -#2
    \kern 0.5\@innersize
}

\def\@vnoseadjust{\@ifnextchar0{\@vnoseadjustB}{\@vnoseadjustA}}

\def\@vnoseadjustA#1]{%
    \dimen2=0.5\@nosesize \advance\dimen2 \@noseoffset
    \advance\dimen2 -0.5\@innersize \dimen2=\the\noseadjust\dimen2
    \if#1n\kern -\dimen2%
    \else\if#1s\kern \dimen2%
    \else\if#11\@vnoseadjustB 045]%
    \else\if#12\@vnoseadjustB 0135]%
    \else\if#13\@vnoseadjustB 0225]%
    \else\if#14\@vnoseadjustB 0315]%
    \fi\fi\fi\fi\fi\fi
}

\def\@vnoseadjustB0#1]{%
    \count1=#1\relax%
    \dimen9=0.5\@nosesize \advance\dimen9 \@noseoffset
    \advance\dimen9 -0.5\@innersize
    \dimen9=\the\noseadjust\dimen9\@sin{\count1}%
    \kern -\dimen9
}

\def\@hnoseadjust{\@ifnextchar0{\@hnoseadjustB}{\@hnoseadjustA}}

\def\@hnoseadjustA#1]{%
    \dimen2=0.5\@nosesize \advance\dimen2 \@noseoffset
    \advance\dimen2 -0.5\@innersize \dimen2=\the\noseadjust\dimen2
    \if#1e\kern \dimen2%
    \else\if#1w\kern -\dimen2%
    \else\if#11\@hnoseadjustB 045]%
    \else\if#12\@hnoseadjustB 0135]%
    \else\if#13\@hnoseadjustB 0225]%
    \else\if#14\@hnoseadjustB 0315]%
    \fi\fi\fi\fi\fi\fi%
}

\def\@hnoseadjustB0#1]{%
    \count1=#1\relax%
    \dimen9=0.5\@nosesize \advance\dimen9 \@noseoffset
    \advance\dimen9 -0.5\@innersize
    \dimen9=\the\noseadjust\dimen9\@cos{\count1}%
    \kern \dimen9
}

\def\sdform{\@ifnextchar[{\@formation}{\@formation[1,1]}}

\def\@formation[#1,#2]#3{%
    \@ifnextchar*{\@formation@cap[#1,#2]{#3}}{\@@formation[#1,#2]{#3}}%
}

\def\@formation@cap[#1,#2]#3*#4{%
    \cbox[0pt,0pt]{
        \@@formation[#1,#2]{#3}\crcr
        \noalign{\vskip\captionvskip}
        \cbox{#4}
    }%
}

\def\@@formation[#1,#2]#3{{%
    \@sdformhmag{#1}%
    \@sdformvmag{#2}%
    \dimen0=0.5\@outersize%
    \@outerhmargin=\the\@sdformhmag\dimen0%
        \@outerhmargin=\the\formationmag\@outerhmargin%
        \advance\@outerhmargin -\dimen0%
    \@outervmargin=\the\@sdformvmag\dimen0%
        \@outervmargin=\the\formationmag\@outervmargin%
        \advance\@outervmargin -\dimen0%
    \offinterlineskip%
    \dimen9=\@outersize\advance\dimen9 2\@outerhmargin%
    \dimen0=\the\wborder\dimen9\advance\dimen0\the\w@border\dimen9%
    \dimen3=\the\eborder\dimen9\advance\dimen3\the\e@border\dimen9%
    \dimen9=\@outersize\advance\dimen9 2\@outervmargin%
    \dimen1=\the\nborder\dimen9\advance\dimen1\the\n@border\dimen9%
    \dimen2=\the\sborder\dimen9\advance\dimen2\the\s@border\dimen9%
    \nborder{0.0}\sborder{0.0}\eborder{0.0}\wborder{0.0}%
    \n@border{0.0}\s@border{0.0}\e@border{0.0}\w@border{0.0}%
    \hbox{%
        \if@draft\vrule\fi%
        \kern\dimen0%
        $\vcenter{
            \if@draft\hrule\fi
            \kern\dimen1
            \def\cr{\crcr\noalign{\vskip2\@outervmargin}}
            \ialign{
            &\hskip\@outerhmargin\hfil##\unskip\hfil\hskip\@outerhmargin\crcr
            \noalign{\vskip\@outervmargin} #3\crcr
            \noalign{\vskip-\@outervmargin}\crcr
            }
            \kern\dimen2
            \if@draft\hrule\fi
        }$%
        \kern\dimen3%
        \if@draft\vrule\fi%
    }%
}}

\def\priform{\@ifnextchar[{\@priform}{\@priform[0,0]}}

\def\@priform[#1,#2]#3{{%
    \offinterlineskip%
    \advance\@hoffset #1%
    \advance\@voffset #2%
    \dimen9=\@outersize\advance\dimen9 2\@outerhmargin%
    \dimen0=\the\wborder\dimen9\advance\dimen0\the\w@border\dimen9%
    \dimen3=\the\eborder\dimen9\advance\dimen3\the\e@border\dimen9%
    \dimen9=\@outersize\advance\dimen9 2\@outervmargin%
    \dimen1=\the\nborder\dimen9\advance\dimen1\the\n@border\dimen9%
    \dimen2=\the\sborder\dimen9\advance\dimen2\the\s@border\dimen9%
    \nborder{0.0}\sborder{0.0}\eborder{0.0}\wborder{0.0}%
    \n@border{0.0}\s@border{0.0}\e@border{0.0}\w@border{0.0}%
    \hbox{%
%       \vrule%
        \kern\dimen0%
        $\vcenter{
%           \hrule
            \kern\dimen1
            \def\cr{\crcr\noalign{\vskip2\@outervmargin}}
            \ialign{
            \hfil##\unskip\hfil&&\hskip2\@outerhmargin\hfil##\unskip\hfil\crcr
            #3\crcr
            \noalign{\vskip-2\@outervmargin}\crcr
            }
            \kern\dimen2
%           \hrule
        }$%
        \kern\dimen3%
%       \vrule%
    }%
}}


\def\displaydance{\@ifnextchar[{\@displaydance}%
    {\@displaydance[\displaymodehskip,\displaymodevskip]}%
}

\def\@displaydance[#1,#2]{\bgroup
    \formationmag{\the\displaymodemag}
    \offinterlineskip
    \tabskip=#1
    \@dispvskip=#2
    \def\\{\crcr\egroup\egroup\vskip\@dispvskip\filbreak\vbox\bgroup
        \halign to\hsize\bgroup &\hfil####\unskip\hfil\crcr
    }
    \def\cr{\crcr\noalign{\vskip\@dispvskip}}
    \def\lcaption##1{\crcr
        \noalign{\hbox to \hsize{##1\hfil}\vskip\@dispvskip}
    }
    \def\ccaption##1{\crcr
        \noalign{\hbox to \hsize{\hfil##1\hfil}\vskip\@dispvskip}
    }
    \par
%   \hrule
    \vskip\@dispvskip
    \vbox\bgroup
        \halign to\hsize\bgroup &\hfil##\unskip\hfil\crcr
}
\def\enddisplaydance{\unskip\crcr\egroup\egroup\vskip\@dispvskip
%   \hrule%
\egroup
}


\def\cbox{\@ifnextchar[{\@cbox}{\@cbox[\cboxhskip,\cboxvskip]}}

\def\@cbox[#1,#2]#3{{%
%   \vrule%
    $\vcenter{
%       \hrule
        \offinterlineskip
        \skip0=#2
        \skip1=#1
        \def\rarrow{\crcr\egroup\egroup\crcr%
            \omit\rightarrowfill\crcr%
            \vbox\bgroup\tabskip=\skip1\halign\bgroup%
                &\hfil####\unskip\hfil\crcr
        }
        \def\larrow{\crcr\egroup\egroup\crcr%
            \omit\leftarrowfill\crcr%
            \vbox\bgroup\tabskip=\skip1\halign\bgroup%
                &\hfil####\unskip\hfil\crcr
        }
        \def\\{\crcr\egroup\egroup\cr%
            \vbox\bgroup\tabskip=\skip1\halign\bgroup%
                &\hfil####\unskip\hfil\crcr
        }
        \def\cr{\crcr\noalign{\vskip\skip0}}
        \ialign{\hfil##\unskip\hfil\crcr
            \vbox\bgroup\tabskip=\skip1\halign\bgroup%
                &\hfil##\unskip\hfil\crcr
                    #3\crcr\egroup\egroup%
        \crcr}
%       \hrule
    }$%
%   \vrule%
}}


\def\lbox{\@ifnextchar[{\@lbox}{\@lbox[\cboxhskip,\cboxvskip]}}

\def\@lbox[#1,#2]#3{{%
%   \vrule%
    $\vcenter{
%       \hrule
        \offinterlineskip
        \skip0=#2
        \skip1=#1
        \def\rarrow{\crcr\egroup\egroup\crcr%
            \omit\rightarrowfill\crcr%
            \vbox\bgroup\tabskip=\skip1\halign\bgroup%
                &####\unskip\hfil\crcr
        }
        \def\larrow{\crcr\egroup\egroup\crcr%
            \omit\leftarrowfill\crcr%
            \vbox\bgroup\tabskip=\skip1\halign\bgroup%
                &####\unskip\hfil\crcr
        }
        \def\\{\crcr\egroup\egroup\cr%
            \vbox\bgroup\tabskip=\skip1\halign\bgroup%
                &####\unskip\hfil\crcr
        }
        \def\cr{\crcr\noalign{\vskip\skip0}}
        \ialign{##\unskip\hfil\crcr
            \vbox\bgroup\tabskip=\skip1\halign\bgroup%
                &##\unskip\hfil\crcr
                    #3\crcr\egroup\egroup%
        \crcr}
%       \hrule
    }$%
%   \vrule%
}}


%---- arrow drawing macros --------------------------------------------------


% \dimen1 width
% \dimen2 length
% \dimen3 x offset
% \dimen4 y offset
% \count1 initial angle
% \count2 inc angle

\newdimen\sdarrowwidth      \sdarrowwidth=0.6pt
\newdimen\sdarrowhead       \sdarrowhead=0pt
\newtoks\drawmodehmag       \drawmodehmag{1.0}
\newtoks\drawmodevmag       \drawmodevmag{1.0}
\newtoks\@drawhmag          \@drawhmag{1.0}
\newtoks\@drawvmag          \@drawvmag{1.0}
\newtoks\drawmodedotoffset  \drawmodedotoffset{0.5}

\def\@thplus{%
    \advance\count9 360
    \ifnum\count9<0 \let\@thnext=\@thplus
    \else \let\@thnext=\relax
    \fi
    \@thnext
}
\def\@thminus{%
    \advance\count9 -360
    \ifnum\count9>360 \let\@thnext=\@thminus
    \else \let\@thnext=\relax
    \fi
    \@thnext
}

\def\@sin#1{%
    \count9=#1
    \ifnum\count9<0 \@thplus \fi
    \ifnum\count9>360 \@thminus \fi
    \divide\count9 by 5
    \ifnum\count9<19 \@@sin
    \else\ifnum\count9<37
        \advance\count9 -36 \count9=-\count9 \@@sin
    \else\ifnum\count9<55
        \advance\count9 -36 \@@sin \dimen9=-\dimen9
    \else\ifnum\count9<73
        \advance\count9 -72 \count9=-\count9 \@@sin \dimen9=-\dimen9
    \else\count9=0 \@@sin
    \fi\fi\fi\fi
}

\def\@cos#1{%
    \count9=#1
    \advance\count9 90 \@sin{\count9}%
}

\def\@@sin{%
    \ifnum\count9<1 \dimen9=0.0\dimen9
    \else\ifnum\count9<2 \dimen9=0.0871557\dimen9
    \else\ifnum\count9<3 \dimen9=0.173648\dimen9
    \else\ifnum\count9<4 \dimen9=0.258819\dimen9
    \else\ifnum\count9<5 \dimen9=0.34202\dimen9
    \else\ifnum\count9<6 \dimen9=0.422618\dimen9
    \else\ifnum\count9<7 \dimen9=0.5\dimen9
    \else\ifnum\count9<8 \dimen9=0.573576\dimen9
    \else\ifnum\count9<9 \dimen9=0.642788\dimen9
    \else\ifnum\count9<10 \dimen9=0.707107\dimen9
    \else\ifnum\count9<11 \dimen9=0.766044\dimen9
    \else\ifnum\count9<12 \dimen9=0.819152\dimen9
    \else\ifnum\count9<13 \dimen9=0.866025\dimen9
    \else\ifnum\count9<14 \dimen9=0.906308\dimen9
    \else\ifnum\count9<15 \dimen9=0.939693\dimen9
    \else\ifnum\count9<16 \dimen9=0.965926\dimen9
    \else\ifnum\count9<17 \dimen9=0.984808\dimen9
    \else\ifnum\count9<18 \dimen9=0.996195\dimen9
    \else \dimen9=1.0\dimen9
    \fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi
}


\def\drawline{\@ifnextchar[{\@drawline}{\@drawline[1,1]}}
\def\@drawline[#1,#2]#3#4#5#6#7{%
% #1 hmag
% #2 vmag
% #3 width
% #4 length
% #5 x offset
% #6 y offset
% #7 angle
    \setbox0=\hbox{%
        \dimen1=#3\relax%
        \dimen2=#4\relax%
        \dimen3=#5\relax%
        \dimen4=#6\relax%
        \dimen9=\dimen1\@cos{#7}%
        \dimen6=\the\drawmodedotoffset\dimen9
            \dimen6=#1\dimen6
            \dimen6=\the\@drawhmag\dimen6
            \dimen6=\the\drawmodehmag\dimen6
        \dimen9=\dimen1\@sin{#7}%
        \dimen7=\the\drawmodedotoffset\dimen9
            \dimen7=#2\dimen7
            \dimen7=\the\@drawvmag\dimen7
            \dimen7=\the\drawmodevmag\dimen7
        \setbox0=\hbox{\vrule width\dimen1 height0.5\dimen1 depth0.5\dimen1}%
        \kern-0.5\dimen1%
        \dimen5=0pt%
        \loop%
            \kern\dimen3\raise\dimen4\copy0\kern-\dimen1%
        \ifdim\dimen5<\dimen2%
            \dimen3=\dimen6%
            \advance\dimen4 \dimen7%
            \advance\dimen5 \the\drawmodedotoffset\dimen1%
        \repeat%
        \kern0.5\dimen1%
    }%
    \ht0=0pt\wd0=0pt\dp0=0pt%
    \box0\unskip%
}


\def\drawarrow{\@ifnextchar[{\@drawarrow}{\@drawarrow[1,1]}}
\def\@drawarrow[#1,#2]#3#4#5#6#7{%
% #1 hmag
% #2 vmag
% #3 width
% #4 R
% #5 initial direction
% #6 angle between initial and final directions
% #7 length of arrow head
    \setbox0=\hbox{%
        \dimen1=#3\relax%
        \dimen2=#4\relax%
        \count1=#5\relax%
        \count2=#6\relax%
        \ifnum\count2=0 \count3=-1%
        \else%
            \dimen2=0.087238744\dimen2%
            \count3=\count2 \divide\count3 5\relax%
            \ifnum\count3<0 \count3=-\count3 \count2=-5\relax%
            \else \count2=5\relax%
            \fi%
        \fi%
        \advance\count3 -1\relax%
        \ifnum\count3<0%
            \@drawline[#1,#2]{\dimen1}{\dimen2}{0pt}{0pt}{\count1}\unskip%
            \dimen3=0pt%
            \dimen4=0pt%
            \dimen9=#1\dimen2 \dimen9=\the\@drawhmag\dimen9
            \dimen9=\the\drawmodehmag\dimen9 \@cos{\count1}%
            \advance\dimen3 \dimen9%
            \dimen9=#2\dimen2 \dimen9=\the\@drawvmag\dimen9
            \dimen9=\the\drawmodevmag\dimen9 \@sin{\count1}%
            \advance\dimen4 \dimen9%
        \else%
            \@drawline[#1,#2]{\dimen1}{0.5\dimen2}{0pt}{0pt}{\count1}\unskip%
            \dimen3=0pt%
            \dimen4=0pt%
            \dimen9=0.5\dimen2 \dimen9=#1\dimen9 \dimen9=\the\@drawhmag\dimen9
            \dimen9=\the\drawmodehmag\dimen9\@cos{\count1}%
            \advance\dimen3 \dimen9%
            \dimen9=0.5\dimen2 \dimen9=#2\dimen9 \dimen9=\the\@drawvmag\dimen9
            \dimen9=\the\drawmodevmag\dimen9\@sin{\count1}%
            \advance\dimen4 \dimen9%
        \fi%
        \count4=0\relax%
        \loop\ifnum\count4<\count3%
            \advance\count1 \count2%
            \@drawline[#1,#2]{\dimen1}{\dimen2}{\dimen3}{\dimen4}{\count1}%
            \unskip%
            \dimen9=#1\dimen2 \dimen9=\the\@drawhmag\dimen9
            \dimen9=\the\drawmodehmag\dimen9 \@cos{\count1}%
            \advance\dimen3 \dimen9%
            \dimen9=#2\dimen2 \dimen9=\the\@drawvmag\dimen9
            \dimen9=\the\drawmodevmag\dimen9 \@sin{\count1}%
            \advance\dimen4 \dimen9%
            \advance\count4 1%
        \repeat%
        \ifnum\count3<0%
        \else%
            \advance\count1 \count2%
            \@drawline[#1,#2]{\dimen1}{0.5\dimen2}{\dimen3}{\dimen4}{\count1}%
            \unskip%
            \dimen9=0.5\dimen2 \dimen9=#1\dimen9 \dimen9=\the\@drawhmag\dimen9
            \dimen9=\the\drawmodehmag\dimen9 \@cos{\count1}%
            \advance\dimen3 \dimen9%
            \dimen9=0.5\dimen2 \dimen9=#2\dimen9 \dimen9=\the\@drawvmag\dimen9
            \dimen9=\the\drawmodevmag\dimen9 \@sin{\count1}%
            \advance\dimen4 \dimen9%
        \fi%
        \ifdim#7>0pt%
            \advance\count1 140\relax%
            \@drawline[1,1]{#3}{#7}{\dimen3}{\dimen4}{\count1}\unskip%
            \advance\count1 80\relax%
            \@drawline[1,1]{#3}{#7}{\dimen3}{\dimen4}{\count1}\unskip%
        \fi%
    }%
    \ht0=0pt\wd0=0pt\dp0=0pt%
    \box0\unskip%
}

\def\drawarch{\@ifnextchar[{\@drawarch}{\@drawarch[1,1]}}
\def\@drawarch[#1,#2]#3#4#5#6{\@drawarrow[#1,#2]{#3}{#4}{#5}{#6}{0pt}}

\def\sdarrow{\@ifnextchar[{\@sdarrow}{\@sdarrow[0,0]}}
\def\@sdarrow[#1,#2]{\@ifnextchar({\@@sdarrow[#1,#2]}{\@@sdarrow[#1,#2](1,1)}}
\def\@@sdarrow[#1,#2](#3,#4)#5#6#7{{%
% #1 x offset
% #2 y offset
% #3 hmag
% #4 vmag
% #5 R (relative to matrix size)
% #6 initial direction
% #7 angle between initial and final directions
    \offinterlineskip
    \advance\@hoffset #1
    \advance\@voffset #2
    \dimen0=\@outersize \advance\dimen0 2\@outerhmargin \dimen0=0.02\dimen0
    \dimen1=\@outersize \advance\dimen1 2\@outervmargin \dimen1=0.02\dimen1
%   \vrule
    $\vcenter to \@outersize{
%       \hrule
        \vss
        \kern -\the\@voffset\dimen1
        \hbox to \@outersize{\hss\kern \the\@hoffset\dimen0%
            \vbox to \@outersize{
                \vss
                \@drawhmag{\the\@sdformhmag}
                \@drawvmag{\the\@sdformvmag}
                \drawmodehmag{\the\formationmag}
                \drawmodevmag{\the\formationmag}
                \@drawarrow[#3,#4]
                    {\sdarrowwidth}{#5\@outersize}{#6}{#7}{\sdarrowhead}
                \vss
            }\unskip%
            \hss%
        }
        \vss
%       \hrule
    }$%
%   \vrule
}}

%------------------------------------------------------------------------------

\noseadjustON
\slantboxON
\draftOFF
\normaldancer

%------------------------------------------------------------------------------
