% $Id: qsymbols.sty,v 1.12 1997/01/07 23:56:44 krisrose Exp $
%
% `Quoted math symbol abbreviations' package for LaTeX2e.
% Copyright © 1994  Kristoffer H. Rose  <kris@diku.dk>
%
% This package is free software; you can redistribute it and/or modify
% it under the terms of the GNU General Public License as published by the
% Free Software Foundation; either version 2 of the License, or (at your
% option) any later version.
%
% This package is distributed in the hope that it will be useful, but
% WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
% or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
% for more details.
%
% You should have received a copy of the GNU General Public License along
% with this package; if not, write to the Free Software Foundation, Inc.,
% 675 Mass Ave, Cambridge, MA 02139, USA.
%
\NeedsTeXFormat{LaTeX2e}

\def\tmp#1Revision: #2 $,#3Date: #4 #5 ${%
  \ProvidesPackage{qsymbols}[#4 Quoted math symbol abbreviations v.#2]
  \def\qsymbolsversion{#2}\def\qsymbolsdate{#4}}
\tmp$Revision: 1.12 $,$Date: 1997/01/07 23:56:44 $

% Process Options such that \xyloaded is indicator...

\DeclareOption{noams}{\let\qsym@noams=\relax}
\DeclareOption{nostmary}{\let\qsym@nostmary=\relax}

\DeclareOption{dvips}{\PassOptionsToPackage{dvips}{xy}}

\newif\ifpurexy@
\DeclareOption{xy}{\let\qsym@xy=\relax \purexy@false}
\DeclareOption{purexy}{\let\qsym@xy=\relax \purexy@true}

\newif\ifoldcm@
\DeclareOption{oldcm}{\oldcm@true}

\def\qsymsmash@@{}
\DeclareOption{smash}{\gdef\qsymsmash@@{\ht\z@=\z@ \dp\z@=\z@}}

\def\qW@@#1#2{}
\def\qW@debug#1#2{\begingroup#1\immediate\write16{#2}\endgroup}
\DeclareOption{debug}{\let\qW@@=\qW@debug}

\DeclareOption*{%
  \expandafter\PassOptionsToPackage\expandafter{\CurrentOption}{xy}}

\ProcessOptions\relax

% Import of symbols.

\ifnum\the\catcode`\"=\active \def\restoredbl@{\catcode`\"=\active}%
\else \let\restoredbl@=\relax \fi

\catcode`\"=12

\ifx\qsym@noams\undefined
  \let\blacktriangle=\undefined % Sic.
  \RequirePackage{amssymb,amsbsy}
\fi

\ifx\qsym@nostmary\undefined
  \RequirePackage{stmaryrd}
\fi

\ifx\qsym@xy\relax
  \ifx\xyloaded\undefined \RequirePackage[arrow,cmtip]{xy}%
  \else \xyoption{arrow}\xyoption{cmtip}\makeatletter \fi
\fi

\ifx\UseTips\undefined
  \let\qTips=\UseComputerModernTips
  \let\qTips=\NoComputerModernTips
\else
  \let\qTips=\UseTips \let\qNoTips=\NoTips
\fi

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% SETUP.

% Activate ` in math mode to look up qsymbol.

\def\active@q{\futurelet\tmp\qsym@}
{\catcode`\`=\active \global\let`=\active@q}
\mathcode`\`="8000

% Definition commands.

\def\qsym@#1{\ifx\bgroup\tmp \def\tmp{`{#1}}\else\def\tmp{`#1}\fi
  \expandafter\let\expandafter\@tmp\csname\space\codeof\tmp\endcsname
  \avoidrelax@\@tmp{\@warning{Unknown symbol \codeof\tmp}}}

\def\avoidrelax@#1#2{\ifx#1\relax\def\av@id{#2}\else\let\av@id=#1\fi \av@id}

\def\newqsymbol#1{\def\tmp{#1}\edef\tmp{\codeof\tmp}%
  \expandafter\let\expandafter\@tmp\csname\space\tmp\endcsname
  \ifx\@tmp\relax\else \@warning{Redefining qsymbol \tmp}\fi
  \expandafter\def\csname\space\tmp\endcsname}

\def\newqsymbol@#1#2{\def\tmp{#1}%
  \expandafter\def\csname\space\codeof\tmp\endcsname{#2}}

\def\newqsymbol@@#1#2{\ifx#2\undefined \else \newqsymbol@{#1}{#2}\fi}

% Boxification...not really an optimisation anymore.

\newcommand{\boxifyqsymbol}[2][]{\def\tmp{#2}\edef\tmp{\codeof\tmp}%
  \edef\tmp{{\expandafter\noexpand\csname\space\tmp @box\endcsname}{\tmp}}%
  \DN@##1##2{\AtBeginDocument{%
      \newsavebox{##1}\sbox{##1}{$#2$}%
      \expandafter\def\csname\space##2\endcsname{#1{\usebox{##1}}}}}%
  \expandafter\next@\tmp}

% Auxiliaries (from Xy-pic)...

%\ifx\xyloaded\undefined
{\catcode`\:=12 \catcode`\>=12 % to ensure that all of :->< are other...
  \gdef\codeof#1{\expandafter\codeof@\meaning#1<-:}
  \gdef\codeof@#1:->#2<-:{#2}}

\def\space@.{\futurelet\space@\relax}\space@. %
\def\DN@{\def\next@}
\def\DNii@{\def\nextii@}
%\fi

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% SINGLE SYMBOLS.

% Letters:

\newqsymbol@{`a}\alpha
\newqsymbol@{`b}\beta
\newqsymbol@{`c}\chi
\newqsymbol@{`d}\delta
\newqsymbol@{`D}\Delta
\newqsymbol@{`e}\epsilon
\newqsymbol@{`f}\phi
\newqsymbol@{`F}\Phi
\newqsymbol@{`g}\gamma
\newqsymbol@{`G}\Gamma
\newqsymbol@{`h}\eta
\newqsymbol@{`i}\iota
\newqsymbol@{`j}\psi
\newqsymbol@{`J}\Psi
\newqsymbol@{`k}\kappa
\newqsymbol@{`l}\lambda
\newqsymbol@{`L}\Lambda
\newqsymbol@{`m}\mu
\newqsymbol@{`n}\nu
\newqsymbol@{`p}\pi
\newqsymbol@{`P}\Pi
\newqsymbol@{`q}\theta
\newqsymbol@{`Q}\Theta
\newqsymbol@{`r}\rho
\newqsymbol@{`s}\sigma
\newqsymbol@{`S}\Sigma
\newqsymbol@{`t}\tau
\newqsymbol@{`u}\varrho
\newqsymbol@{`v}\varphi
\newqsymbol@{`w}\omega
\newqsymbol@{`W}\Omega
\newqsymbol@{`x}\xi
\newqsymbol@{`X}\Xi
\newqsymbol@{`y}\upsilon
\newqsymbol@{`Y}\Upsilon
\newqsymbol@{`z}\zeta

% Symbols:

\newqsymbol@{`+}\pm
\newqsymbol@{`*}\times
\newqsymbol@{`:}\in
\newqsymbol@{`;}\notin
\newqsymbol@{`/}\setminus
\newqsymbol@{`U}\cup
\newqsymbol@@{`C}\complement
\newqsymbol@{`_}\bot
\newqsymbol@{`T}\top
\newqsymbol@{`o}\circ
\newqsymbol@{`.}\cdot
\newqsymbol@{`=}\equiv
\newqsymbol@{`~}\simeq
\newqsymbol@{`E}\exists
\newqsymbol@{`A}\forall
\newqsymbol@{`!}\lnot
\newqsymbol@{`^}\land
\newqsymbol@{`V}\lor

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% CIRCLED & BOXED OPERATIONS.

% Circled:

\newqsymbol@{`(}{\oqsym@}

\def\oqsym@#1){\def\tmp{`(#1)}%
  \expandafter\let\expandafter\@tmp\csname\space\codeof\tmp\endcsname\relax
  \avoidrelax@\@tmp{\encircle{#1}}}

\ifx\varbigcirc\undefined \let\varbigcirc=\bigcirc \fi
\def\encircle#1{\ensuremath{%
  \def\nextii@{\kern-.1em %
   \ooalign{\hfil\hbox{$\mathstrut\scriptstyle#1$}\hfil\crcr
    $\varbigcirc$}\kern-.1em}%
 \mathchoice{\hbox{\nextii@}}{\hbox{\nextii@}}%
    {\hbox{\scriptsize\nextii@}}{\hbox{\tiny\nextii@}}}}

\newqsymbol@{`()}\bigcirc
\newqsymbol@{`(?)}\circ
\newqsymbol@{`(!)}\bullet
\newqsymbol@@{`(R)}\circledR
\newqsymbol@{`(C)}\copyright

% Circled symbols overridden by stmaryrd (bold) variants if available.
\newqsymbol@{`(+)}\oplus         \newqsymbol@@{`(+)}\varoplus
\newqsymbol@{`(-)}\ominus        \newqsymbol@@{`(-)}\varominus
\newqsymbol@{`(`*)}\otimes       \newqsymbol@@{`(`*)}\varotimes
\newqsymbol@@{`(/)}\oslash       \newqsymbol@@{`(/)}\varoslash
\newqsymbol@@{`(|)}\obar         \newqsymbol@@{`(|)}\varobar
\newqsymbol@@{`(`/)}\obslash     \newqsymbol@@{`(`/)}\varobslash
\newqsymbol@{`(`.)}\odot         \newqsymbol@@{`(`.)}\varodot
\newqsymbol@@{`(*)}\oast         \newqsymbol@@{`(*)}\varoast
\newqsymbol@@{`(`o)}\ocircle     \newqsymbol@@{`(`o)}\varocircle
\newqsymbol@@{`(`^)}\owedge      \newqsymbol@@{`(`^)}\varowedge
\newqsymbol@@{`(`V)}\ovee        \newqsymbol@@{`(`V)}\varovee
\newqsymbol@@{`(<)}\olessthan    \newqsymbol@@{`(<)}\varolessthan
\newqsymbol@@{`(>)}\ogreaterthan \newqsymbol@@{`(>)}\varogreaterthan

% Boxed:

\newqsymbol@{`[}{\boxedqsym@}

\def\boxedqsym@#1]{\def\tmp{`[#1]}%
  \expandafter\let\expandafter\@tmp\csname\space\codeof\tmp\endcsname\relax
  \avoidrelax@\@tmp{\enbox{#1}}}

\def\enbox#1{\ensuremath{%
  \def\nextii@{\kern-.1em \hbox{%
      \ooalign{\hfil\raise.1em\hbox{$\scriptstyle#1$}\hfil\crcr
        $\square$}\kern-.1em}}%
 \mathchoice{\hbox{\nextii@}}{\hbox{\nextii@}}%
    {\hbox{\scriptsize\nextii@}}{\hbox{\tiny\nextii@}}}}

\newqsymbol@@{`[+]}\boxplus
\newqsymbol@@{`[-]}\boxminus
\newqsymbol@@{`[`*]}\boxtimes
\newqsymbol@@{`[/]}\boxslash
\newqsymbol@@{`[|]}\boxbar
\newqsymbol@@{`[`/]}\boxbslash
\newqsymbol@@{`[`.]}\boxdot
\newqsymbol@@{`[*]}\boxast
\newqsymbol@@{`[`o]}\boxcircle

\def\bull{%
 \mathbin{\vcenter{%
   \setbox0=\hbox{\kern1pt \vrule height.4ex depth.4ex width.8ex }%
   \ht0=.5ex \dp0=.5ex \wd0=1ex \box0}}}

\def\whitebull{%
 \mathbin{\vcenter{%
   \setbox0=\hbox{\kern1pt %
    \vrule height.4ex depth.4ex width.1ex %
    \rlap{\vrule height.4ex depth -.3ex width.6ex }%
    \vrule height-.3ex depth.4ex width.6ex %
    \vrule height .4ex depth.4ex width .1ex }%
   \ht0=.5ex \dp0=.5ex \wd0=1ex \box0}}}

\newqsymbol@{`[]}\square
\newqsymbol@{`[?]}\whitebull
\newqsymbol@{`[!]}\bull

% Angled:

\newqsymbol@{`<}\angledqsym@

\def\angledqsym@#1>{\def\tmp{`<#1>}%
  \csname\space\codeof\tmp\endcsname\relax}

\newqsymbol@{`<>}\lozenge
\newqsymbol@{`<?>}\diamond

% Braced:

\newqsymbol@{`{}}\emptyset \newqsymbol@@{`{}}\varnothing

% Faces:

\def\smiley{{\hbox{\rlap{$\varbigcirc$}\kern.13em$\scriptstyle\ddot\smile$}}}
\def\frowny{{\hbox{\rlap{$\varbigcirc$}\kern.13em$\scriptstyle\ddot\frown$}}}
\def\weeny{{\hbox{\rlap{$\varbigcirc$}\kern.20em$%
      \scriptstyle\ddot{\mkern.5mu\smash{-}\mkern-.5mu}$}}}
\def\oopsy{{\hbox{\rlap{$\bigcirc$}\kern.5ex$\scriptstyle\ddot\sim$}}}

\newqsymbol@{`(:-)}\smiley
\newqsymbol@{`[:-]}\frowny
\newqsymbol@{`<:->}\weeny
\newqsymbol@{`{:-}}\oopsy

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% BOLD SYMBOLS

\newqsymbol@{`@}{\futurelet\tmp\boldqsymbol}

\def\boldqsymbol{%
  \ifx `\tmp \DN@`{\futurelet\tmp\boldqsymbol@}%
  \else \let\next@=\boldsymbol \fi \next@}

\def\boldqsymbol@{%
  \ifx [\tmp \DN@[##1]{\boldsymbol{`[##1]}}%]
  \else\ifx (\tmp \DN@(##1){\boldsymbol{`(##1)}}%)
  \else\ifx <\tmp \DN@<##1>{\boldsymbol{`<##1>}}%>
  \else\ifx \bgroup\tmp \DN@##1{\boldsymbol{`{##1}}}%
  \else \DN@##1{\boldsymbol{`##1}}%
  \fi\fi\fi\fi \next@}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% ORDERINGS.

\newqsymbol@{``}{\qsymord@}

\def\xqsym@@#1#2{%
  \expandafter\let\expandafter\1\csname qsym@@#1\endcsname
  \def\2{\expandafter\def\csname qsym@@#1\endcsname}%
  \expandafter\2\expandafter{\1#2}}

\def\qsymord@{\def\qsym@@@{``}%
  \let\qsym@@=\empty\let\qsym@@x=\empty\let\qsym@@v=\empty\let\qsym@@m=\empty
  \futurelet\tmp\qsymord@i}

{\restoredbl@
 \gdef\qsymord@i{%
  \ifx `\tmp \def\@tmp##1{\futurelet\tmp\qsymord@i}\xqsym@@{@}`\xqsym@@{x}x%
  \else\ifx "\tmp
    \def\@tmp"##1"{\xqsym@@{@}{"##1"}%
      \mathbin{\vcenter{\hbox{%
            $\let\undefinedarrow@=\undefinedarrowtrue@
             \def\qrightdirection@@{(0,-1):0}\qsymar##1 $}}}}%
  \else\ifx\undefined\tmp \let\@tmp=\qsymord@ii
  \else\ifcat A\tmp \def\@tmp##1{\csname##1@ord\endcsname}%
  \else \let\@tmp=\qsymord@ii \fi\fi\fi\fi \@tmp}}

\def\qsymord@ii{\def\@tmp##1{\xqsym@@{@}{##1}\futurelet\tmp\qsymord@ii}%
  \ifx /\tmp \xqsym@@{x}n%
  \else\ifx =\tmp \def\qsym@@m{eq}%
  \else\ifx -\tmp \def\qsym@@v{dash}%
  \else\ifx +\tmp \def\qsym@@v{plus}%
  \else\ifx <\tmp \def\qsym@@{less}%
  \else\ifx >\tmp \def\qsym@@{gtr}%
  \else\ifx (\tmp \def\qsym@@{subset}%
  \else\ifx )\tmp \def\qsym@@{supset}%
  \else\ifx [\tmp \def\qsym@@{sqsubset}%
  \else\ifx ]\tmp \def\qsym@@{sqsupset}%
  \else\ifx \{\tmp\def\qsym@@{prec}%
  \else\ifx \}\tmp\def\qsym@@{succ}%
  \else\ifx \<\tmp\def\qsym@@{triangleleft}%
  \else\ifx \>\tmp\def\qsym@@{triangleright}%
  \else\ifx ~\tmp \def\qsym@@{sim}%
  \else\ifx \~\tmp\def\qsym@@{backsim}%
  \else \let\@tmp=\qsymord@x
  \fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi \@tmp}

\def\qsymord@x{%
  \expandafter\let\expandafter\@tmp\csname\qsym@@x\qsym@@\qsym@@v\qsym@@m\endcsname
  \ifx\@tmp\relax \@warning{Undefined ordering \codeof\qsym@@@}%
  \else\qW@@{}{Q \codeof\qsym@@@\space :
    \expandafter\string\csname\qsym@@x\qsym@@\qsym@@v\qsym@@m\endcsname}\fi
  \@tmp}

\mathchardef\less="313C         % <
\let\lesseq=\leq \let\nlesseq=\nleq
\def\xless{\mathrel{\wedge}} \let\xxless=\bigwedge

\mathchardef\gtr="313E          % >
\let\gtreq=\geq \let\ngtreq=\ngeq
\def\xgtr{\mathrel{\vee}} \let\xxgtr=\bigvee

\let\subsetdash=\in             % `set inclusion' relations
\def\nsubset{\not\subset}
\let\nsubsetdash=\notin
\def\nsubseteq{\not\subseteq}
\def\nsubsetplus{\not\subsetplus}
\def\nsubsetpluseq{\not\subsetpluseq}
\let\xsubset=\cap \let\xxsubset=\bigcap
\let\xsubsetplus=\nplus
\let\xxsubsetplus=\bignplus
\let\xsubsetdash=\pitchfork

\let\supsetdash=\ni
\let\xsupset=\cup \let\xxsupset=\bigcup
\let\xsupsetplus=\uplus
\let\xxsupsetplus=\biguplus
\def\nsupset{\not\supset}
\def\nsupseteq{\not\supseteq}
\def\nsupsetplus{\not\supsetplus}
\def\nsupsetpluseq{\not\supsetpluseq}

\def\nsqsubset{\not\sqsubset}   % `open square' relations
\def\nsqsubseteq{\not\sqsubseteq}
\def\nsqsupset{\not\sqsupset}
\def\nsqsupseteq{\not\sqsupseteq}
\let\xsqsubset=\sqcap
\let\xsqsupset=\sqcup
\let\xxsqsubset=\bigsqcap
\let\xxsqsupset=\bigsqcup

\let\xprec=\curlywedge          % `curly' relations
\let\xsucc=\curlyvee
\let\xxprec=\bigcurlywedge
\let\xxsucc=\bigcurlyvee

\let\triangleleft=\vartriangleleft % `triangle' relations
\let\triangleright=\vartriangleright
\let\xtriangleleft=\vartriangle
\let\xtriangleright=\triangledown
\let\xxtriangleleft=\bigtriangleup
\let\xxtriangleright=\bigtriangledown

\def\nsim{\not\sim}             % ~
\def\nsimeq{\not\simeq}
\let\xsim=\wr
\def\nbacksim{\not\backsim}
\def\nbacksimeq{\not\backsimeq}
\def\xbacksim{\smallint}
\def\xxbacksim{\int}

\def\U@ord{\bigcup}             % Abbreviations... ``U
\expandafter\def\csname\string^@ord\endcsname{\bigwedge} % ``^
\def\V@ord{\bigvee}             % ``V
\def\S@ord{\sum}                % ``S
\def\P@ord{\prod}               % ``P

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% ARROWS.

\newif\ifqsym@@conn
\newif\ifqsym@@not
\newif\ifqsym@@ss

% Activate "..." in math mode to look up qsymbol arrow.

{\restoredbl@ \gdef\active@dq#1"{\def\qsym@@@{"#1"}\qsymar#1 }}
{\catcode`\"=\active \global\let"=\active@dq}
\mathcode`\"="8000

\newqsymbol@{`"}{\active@dq}

\def\qsymar{\let\qsym@@=\empty
  \let\qsym@@v=\empty \let\qsym@@m=\empty \let\qsym@@x=\empty
  \def\qsym@@w{{10.1pt}}%
  \qsym@@connfalse \qsym@@notfalse
  \setbox\qsymar@labelbox=\copy\voidb@x
  \qsym@@sstrue \let\qsym@@sb=\empty \let\qsym@@sp=\empty
  \futurelet\tmp\qsymar@}

\newbox\qsymar@labelbox

\def\qsymar@hasconn{%
 \ifqsym@@conn \qsymar@expand \else \qsym@@conntrue \fi}

{% REPAIR bug of the 2e version of AMS-LaTeX where \makeatother is broken...
 \ifx\@ifpackageloaded\undefined \makeatother
 \else \@ifpackageloaded{amstex}{\catcode`\@=\active}{\makeatother}\fi
 \gdef\addATto#1{#1@}}

\def\qsym@@labelmargin{\labelmargin{1pt}}
\def\qsymarv@#1{\def\qsym@@v{#1}\def\qsym@@labelmargin{\labelmargin{#1pt}}}

\def\qsymar@{%
  \DN@##1{\xqsym@@{}{##1}\xqsym@@{m}{##1}\futurelet\tmp\qsymar@}%default
  \ifx\space@\tmp \expandafter\DN@\space{\qsymar@i}%terminate at space
  \else\ifx2\tmp \qsymarv@{2}\xqsym@@{}2\DN@2{\futurelet\tmp\qsymar@}%
  \else\ifx3\tmp \qsymarv@{3}\xqsym@@{}3\DN@3{\futurelet\tmp\qsymar@}%
  \else\ifx^\tmp \def\qsym@@v{^}\xqsym@@{}^\DN@^{\futurelet\tmp\qsymar@}%
  \else\ifx_\tmp \def\qsym@@v{_}\xqsym@@{}_\DN@_{\futurelet\tmp\qsymar@}%
  \else\ifx<\tmp
  \else\ifx>\tmp
  \else\ifx|\tmp
  \else\ifx-\tmp \qsymar@hasconn
  \else\ifx=\tmp \qsymar@hasconn \xqsym@@{m}-\qsymarv@{2}%
    \xqsym@@{}=\DN@={\futurelet\tmp\qsymar@}%
  \else\ifx.\tmp \qsymar@hasconn
  \else\ifx:\tmp \qsymar@hasconn\xqsym@@{m}.\qsymarv@{2}%
    \xqsym@@{}:\DN@:{\futurelet\tmp\qsymar@}%
  \else\ifx~\tmp \qsymar@hasconn \qsymar@expand
  \else\ifx x\tmp
  \else\ifx o\tmp
  \else\ifx`\tmp
  \else\ifx'\tmp
  \else\ifx!\tmp
   \qsymar@expand \DN@!{\futurelet\tmp\qsymar@}%
  \else\ifx \bgroup\tmp \DN@##1{\futurelet\tmp\qsymar@group##1@@}%
  \else\addATto\ifx\tmp
    \DN@##1##2{\xqsym@@{x}{##1##2}\futurelet\tmp\qsymar@}%
  \else\ifx (\tmp \qsymar@expand\qsymar@expand
    \DN@(##1){\xqsym@@{}{(##1)}%
     \xqsym@@{x}{|*=/2\R@c/\hbox{\encircle{##1}}}%
     \futurelet\tmp\qsymar@}%
  \else\ifx [\tmp \qsymar@expand\qsymar@expand
    \DN@[##1]{\xqsym@@{}{[##1]}\xqsym@@{x}{|*\hbox{\enbox{##1}}}%
      \futurelet\tmp\qsymar@}%
  \else\ifx *\tmp \DN@*{\qsymar@star}%
  \else\ifx /\tmp \xqsym@@{}{/}%
    \ifqsym@@not
     \DN@/{\xqsym@@{x}{|-/.7pt/*\dir2{/}}\futurelet\tmp\qsymar@}%
    \else \DN@/{\xqsym@@{x}{|-/-.7pt/*\dir2{/}}\futurelet\tmp\qsymar@}%
     \qsym@@nottrue \fi
  \else\ifcat A\noexpand\tmp
    \DN@##1{\expandafter\let\expandafter\next@\csname qac@##1\endcsname
      \ifx\next@\relax \DN@{\qsymar@badescape{##1}}\fi \next@}%
  \else\ifcat .\noexpand\tmp
    \DN@##1{\expandafter\let\expandafter\next@\csname qac@##1\endcsname
      \ifx\next@\relax \DN@{\qsymar@badescape{##1}}\fi \next@}%
  \else \let\next@=\qsymar@i
    \@warning{Ignored weird token in arrow: \meaning\tmp}%
  \fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi
  \next@}

\def\qsymar@badescape#1{\DN@{\futurelet\tmp\qsymar@}%
  \@warning{Undefined qsymbol arrow macro #1}}

\def\qsymar@expand{\DNii@##1{\dimen@=##1}\expandafter\nextii@\qsym@@w\relax
  \ifdim\dimen@<11pt \def\qsym@@w{{15.1pt}}%
  \else\ifdim\dimen@<16pt \def\qsym@@w{{20.1pt}}%
  \else\ifdim\dimen@<21pt \def\qsym@@w{{25.1pt}}%
  \else \advance\dimen@5pt \edef\qsym@@w{{\the\dimen@}}\fi\fi\fi}

% Measure/keep label

\def\qsymar@group#1@@{%
  \ifx ^\tmp \let\next@=\qsymar@label
  \else\ifx _\tmp \let\next@=\qsymar@label
  \else \qsym@@ssfalse
   \ifx |\tmp \let\next@=\qsymar@label \else \DN@##1@@{}\fi
  \fi\fi \next@#1{}@@%
  \xqsym@@{x}{#1}\futurelet\tmp\qsymar@}

\def\qsymar@label#1#2#3@@{%
 \DN@{#3}\ifx\next@\empty
  \ifqsym@@ss \qsym@@ssfalse
    \ifx ^\tmp \ifx\qsym@@sp\empty \qsym@@sstrue \def\qsym@@sp{#2}\fi
    \else\ifx _\tmp \ifx\qsym@@sb\empty \qsym@@sstrue \def\qsym@@sb{#2}\fi
    \fi\fi
  \fi
  \DN@{\qsymar@label@@{#2}}%
 \else \qsym@@ssfalse \DN@{\qsymar@label@#3@@}\fi \next@}

\def\qsymar@label@#1#2@@{\DN@{#2}%
 \ifx\next@\empty \DN@{\qsymar@label@@{#1}}%
 \else \DN@{\qsymar@label@#2@@}\fi \next@}

\def\qsymar@label@@#1{\setbox\z@=\hbox{$\m@th\scriptstyle\;{#1}\;$}%
  \DNii@##1{\dimen@=##1}\expandafter\nextii@\qsym@@w\relax
  \loop\ifdim\dimen@<\wd\z@ \qsymar@expand \repeat}

\def\qsymar@star#1#{\qsymar@star@{#1}}
\def\qsymar@star@#1#2{\xqsym@@{}{*#1{#2}}\xqsym@@{m}{*#1{#2}}%
  \futurelet\tmp\qsymar@}

\def\qsymar@i{%
  \ifingraph@ \DN@{\ingraph@false \qsymar@x\GRAPHar@}%
  \else\if\inxy@ \DN@{\qsymar@x\ar}%
  \else
    \edef\nextii@{\codeof\qsym@@}%
    \expandafter\let\expandafter\tmp\csname\space"\nextii@"\endcsname
    \if\undefinedarrow@\tmp
      \ifx\xyloaded\undefined
        \DN@{\@warning{arrow "\nextii@" undefined}}%
      \else
        \DNii@##1{\setboxz@h{\kern\p@\qTips\qsym@@labelmargin
            $\expandafter\xy\qrightdirection@@
            \qsymar@x\ar*{}+/v(1,0)##1/*{}\relax
            \endxy$\kern\p@}\mathrel{\qsymsmash@@\boxz@}}%
        \DN@{\expandafter\nextii@\qsym@@w}%
        \qW@@{}{Q \codeof\qsym@@@\space : Xy-pic}\fi
    \else
      \ifx\qsym@@sp\empty \ifx\qsym@@sb\empty \qsym@@ssfalse \fi\fi
      \ifqsym@@ss \xqsym@@{}{@}%
        \expandafter\let\expandafter\@tmp\csname\space"\codeof\qsym@@"\endcsname
        \ifx\@tmp\relax
          \expandafter\def\expandafter\tmp\expandafter{\expandafter$\tmp$}%
        \else \let\tmp=\@tmp \fi
        \let\next@=\qsymar@stretch
        \qW@@{\DN@##1{\dimen@=##1}\expandafter\next@\qsym@@w}%
          {Q \codeof\qsym@@@\space
            : \codeof\tmp\space
            FROM \the\dimen@\space
            LIMITS \string_{\codeof\qsym@@sb} \string^{\codeof\qsym@@sp}}%
      \else
        \let\next@=\tmp
        \qW@@{}{Q \codeof\qsym@@@\space : \codeof\tmp\space
            LIMITS \string_{\codeof\qsym@@sb} \string^{\codeof\qsym@@sp}}%
      \fi
    \fi
  \fi\fi \next@}

\def\qrightdirection@@{}
\def\undefinedarrow@#1{\ifx#1\relax TT\else TF\fi}
\def\undefinedarrowtrue@#1{TT}

\def\qsymar@x#1{%
  %% Eval #1 @\qsym@@v{\qsym@@m}\qsym@@x ...
  \DN@{\addAT@#1}%
  \DNii@{\expandafter\expandafter\expandafter\next@
   \expandafter\qsym@@v\expandafter{\qsym@@m}}%
  \expandafter\nextii@\qsym@@x}%

% Automatic stretching to fit a label:
\def\qsymar@stretch{\mathrel{\m@th 
    \DN@##1{\dimen@=##1}\expandafter\next@\qsym@@w\relax
    \setbox\z@=\hbox{\tmp}\ifdim\dimen@<\wd\z@ \dimen@=\wd\z@ \fi
    \setbox2=\hbox{$\m@th\scriptstyle\;{\qsym@@sp}\;$}%
    \ifdim\dimen@<\wd2 \dimen@=\wd2 \fi
    \setbox4=\hbox{$\m@th\scriptstyle\;{\qsym@@sb}\;$}%
    \ifdim\dimen@<\wd4 \dimen@=\wd4 \fi
    \setbox\z@=\hbox to \dimen@{\hfil\tmp\hfil}%
    \dimen@=\ht\z@ \advance\dimen@-.3ex \ht\z@=\dimen@
    \dimen@=\dp\z@ \advance\dimen@-.3ex \dp\z@=\dimen@
    \qsymsmash@@{\textstyle\mathop{\box\z@}\limits^{\box2}_{\box4}}}}

%% User's additional constructions...and the two (only) original ones.

\def\newqsymbolarrowcharxy#1#2{%
  \DN@{#1}\expandafter\def\csname qac@\codeof\next@\endcsname{%
    \futurelet\tmp\qsymar@group#2@@}}

\newqsymbolarrowcharxy{?}{^-*-<3pt,1pt>{\scriptstyle=}}
\newqsymbolarrowcharxy{+}{^-*-<3pt,1pt>{\scriptstyle+}}

\newif\ifingraph@

% `Canned' arrows; single arrows avoided when `oldcm' option specified (they
% were ugly before getting fixed -- this is *still* bad with Y&Ys PS fonts).

\ifpurexy@\else

\newqsymbol@{"-"}{-}
\newqsymbol@{"-@"}{\genericarrowfill---}
\newqsymbol@{"/-"}{\not-}

\newqsymbol@{"="}{=}
\newqsymbol@{"=@"}{\genericarrowfill===}
\newqsymbol@{"/="}{\not=}

\newqsymbol@{"3-"}\equiv
\newqsymbol@{"3-@"}{\genericarrowfill\equiv\equiv\equiv}
\newqsymbol@{"3/-"}{\not\equiv}

\newqsymbol@{"~"}\sim
\newqsymbol@{"2~"}\approx

\ifoldcm@\else
\newqsymbol@{"<-"}\leftarrow   \newqsymbol@{"<-!"}\longleftarrow
\newqsymbol@{"<-@"}\leftarrowfill
\fi
\newqsymbol@{"<="}\Leftarrow   \newqsymbol@{"<=!"}\Longleftarrow
\newqsymbol@{"<=@"}{\genericarrowfill\Leftarrow==}

\newqsymbol@@{"<3"}\Lleftarrow
\ifx\Llefttarrow\undefined\else
  \newqsymbol@{"<3@"}{\genericarrowfill\Lleftarrow\equiv\equiv}\fi

\ifoldcm@\else
\newqsymbol@{"</-"}\nleftarrow
\fi
\newqsymbol@@{"</="}\nLeftarrow

\ifoldcm@\else
\newqsymbol@{"->"}\rightarrow  \newqsymbol@{"-!>"}\longrightarrow
\newqsymbol@{"->@"}\rightarrowfill
\fi
\newqsymbol@{"=>"}\Rightarrow  \newqsymbol@{"=!>"}\Longrightarrow
\newqsymbol@{"=>@"}{\genericarrowfill==\Rightarrow}

\newqsymbol@@{"3>"}\Rrightarrow
\ifx\Rrightarrow\undefined\else
  \newqsymbol@{"3>@"}{\genericarrowfill\equiv\equiv\Rrightarrow}\fi

\ifoldcm@\else
\newqsymbol@@{"-/>"}\nrightarrow
\fi
\newqsymbol@@{"=/>"}\nRightarrow

\ifoldcm@\else
\newqsymbol@{"<->"}\leftrightarrow \newqsymbol@{"<-!>"}\longleftrightarrow
\newqsymbol@{"<->@"}{\genericarrowfill\leftarrowfill-\rightarrowfill}
\fi
\newqsymbol@{"<=>"}\Leftrightarrow \newqsymbol@{"<=!>"}\Longleftrightarrow
\newqsymbol@{"<=>@"}{\genericarrowfill\Leftarrowfill=\Rightarrowfill}

\ifoldcm@\else
\newqsymbol@@{"</->"}\nleftrightarrow
\fi
\newqsymbol@@{"</=>"}\nLeftrightarrow

\ifoldcm@\else
\newqsymbol@@{"<-|"}\mapsfrom   \newqsymbol@@{"<-!|"}\longmapsfrom
\ifx\mapsfrom\undefined
 \newqsymbol@{"<-|@"}{\genericarrowfill\leftarrow-\mapsfromchar}\fi
\fi
\newqsymbol@@{"<=|"}\Mapsfrom   \newqsymbol@@{"<=!|"}\Longmapsfrom
\ifx\Mapsfrom\undefined
 \newqsymbol@{"<=|@"}{\genericarrowfill\Leftarrow=\Mapsfromchar}\fi

\ifoldcm@\else
\newqsymbol@{"|->"}\mapsto      \newqsymbol@@{"|-!>"}\longmapsto
\newqsymbol@{"|->@"}{\genericarrowfill\mapstochar-\rightarrow}
\fi
\newqsymbol@@{"|=>"}\Mapsto     \newqsymbol@@{"|=!>"}\Longmapsto
\ifx\Mapsto\undefined
 \newqsymbol@{"|=>@"}{\genericarrowfill\Mapstochar=\Rightarrow}\fi

\ifoldcm@\else
\newqsymbol@{"<-'"}\hookleftarrow
\newqsymbol@{"<-'@"}{\genericarrowfill\leftarrow-\rhook}

\newqsymbol@{"`->"}\hookrightarrow
\newqsymbol@{"`->@"}{\genericarrowfill\lhook-\rightarrow}

\newqsymbol@{"^<-"}\leftharpoonup   \newqsymbol@{"^->"}\rightharpoonup
\newqsymbol@{"_<-"}\leftharpoondown \newqsymbol@{"_->"}\rightharpoondown
\fi

\newqsymbol@@{"<--"}\dashleftarrow
\newqsymbol@@{"-->"}\dashrightarrow

\ifoldcm@\else
\newqsymbol@{"<<-"}{\leftarrow\mkern-15mu\leftarrow}
\newqsymbol@{"<<-@"}{\genericarrowfill{\leftarrow\mkern-15mu\leftarrow}--}
\fi
\newqsymbol@{"<<="}{\Leftarrow\mkern-15mu\Leftarrow}
\newqsymbol@{"<<=@"}{\genericarrowfill{\Leftarrow\mkern-15mu\Leftarrow}==}

\ifoldcm@\else
\newqsymbol@{"->>"}{\rightarrow\mkern-15mu\rightarrow}
\newqsymbol@{"->>@"}{\genericarrowfill--{\rightarrow\mkern-15mu\rightarrow}}
\fi
\newqsymbol@{"=>>"}{\Rightarrow\mkern-15mu\Rightarrow}
\newqsymbol@{"=>>@"}{\genericarrowfill=={\Rightarrow\mkern-15mu\Rightarrow}}

\newqsymbol@@{"<~"}\leftsquigarrow \newqsymbol@@{"~>"}\rightsquigarrow
\newqsymbol@@{"<~>"}\leftrightsquigarrow

\ifoldcm@\else
\newqsymbol@@{"<-<"}\leftarrowtail
\newqsymbol@@{">->"}\rightarrowtail
\fi

\newqsymbol@@{"<|-"}\leftarrowtriangle
\newqsymbol@@{"<|-@"}{\genericarrowfill\leftarrowtriangle--}

\newqsymbol@@{"-|>"}\rightarrowtriangle
\newqsymbol@@{"-|>@"}{\genericarrowfill--\rightarrowtriangle}

\newqsymbol@@{"<|-|>"}\leftrightarrowtriangle
\newqsymbol@@{"<|-|>@"}{\genericarrowfill\leftarrowtriangle-\rightarrowtriangle}

\newqsymbol@@{"-o"}\multimap
\newqsymbol@@{"-o@"}{\genericarrowfill--\multimap}

\newqsymbol@@{"|-"}\vdash      \newqsymbol@@{"|/-"}\nvdash
\newqsymbol@@{"||-"}\Vdash     \newqsymbol@@{"||/-"}\nVdash
\newqsymbol@@{"|="}\vDash      \newqsymbol@@{"|/="}\nvDash
\newqsymbol@@{"-|"}\dashv

\def\genericarrowfill#1#2#3{$\m@th\mathord{#1}\mkern-6mu%
  \cleaders\hbox{$\mkern-2mu\mathord{#2}\mkern-2mu$}\hfill
  \mkern-6mu\mathord{#3}$}

\fi

% Xy-pic <dir> additions...

\ifx\xyloaded\undefined \def\inxy@{TF}\else

\newdir{|>}{!/+4.6pt/\dir{|}*:(1,-.2)\hbox{\qNoTips\dir^{>}}%
                            *:(1,+.2)\hbox{\qNoTips\dir_{>}}}

\newdir{<|}{!/-4.6pt/\dir{|}*:(1,-.2)\hbox{\qNoTips\dir_{<}}%
                            *:(1,+.2)\hbox{\qNoTips\dir^{<}}}

\newdir{`}{\dir^{(}}
\newdir{'}{\dir^{)}}

\newdir{/}{:(1,-.3)\dir3{|}}

% DIAGRAMS: make `... work in Xy-graphs also:

\let\qsymbolsGRAPH@=\GRAPH@

\def\GRAPH@{%
  \ifx `\next \DN@`{\ingraph@true\active@q}%
  \else \let\next@=\qsymbolsGRAPH@ \fi \next@}

\fi

%% Restore possibly active " :-)

\restoredbl@

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% END.

\endinput

% $Log: qsymbols.sty,v $
% Revision 1.12  1997/01/07 23:56:44  krisrose
% Spacing bug with debugging fixed.
%
% Revision 1.11  1997/01/06 18:55:01  krisrose
% Deactivate " after ``.
%
% Revision 1.10  1996/12/17 18:26:33  krisrose
% Fixed bugs with new stretchable arrows.
%
% Revision 1.9  1996/12/05 04:29:15  krisrose
% Handles sub/superscripts without Xy-pic.
% Cleaned up & ready for Xy-pic version 3.3.
%
% Revision 1.8  1995/05/09  17:27:33  kris
% Intermediate.
% Arrow group decorations now properly measured.
% Bug fixes.
%
% Revision 1.7  1994/12/12  01:29:28  kris
% Updates for Xy-pic v3 in progress...
%
% Revision 1.6  1994/11/16  14:05:40  kris
% Intermediate version fits internal Xy-pic...
%
% Revision 1.5  1994/10/28  18:19:36  kris
% Added '{..} and documented "...{...}..." <labels>.
%
% Revision 1.4  1994/10/28  15:08:17  kris
% Added boldsymbol support.
%
% Revision 1.3  1994/10/26  16:47:02  kris
% Fixed a few things :-)
%
% Revision 1.2  1994/10/26  02:10:17  kris
% Integrated qarrow; use Xy-pic is an option.
%
% Revision 1.1  1994/10/24  22:55:12  kris
% Initial revision
%
% Extracted from kris.sty 1.9.

% Tell Emacs what this is...
% Local Variables:
% mode:latex
% fill-column:77
% End:
