%=====================================================================================================================================
% Package akkmathrel by Igor Akkerman (c) 2000, 2001, 2002, 2003, 2004, 2005, 2006
% Package providing utilities for typesetting mathematical relations.
%
% This work may be distributed and/or modified under the
% conditions of the LaTeX Project Public License (latest version).
%
% The latest version of this license can be found at
%     http://www.latex-project.org/lppl.txt
%
% This file may only be distributed together with the full 'AkkTeX' bundle.
%=====================================================================================================================================
\NeedsTeXFormat{LaTeX2e}[1995/12/01]
\ProvidesPackage{akkmathrel}[2006/10/22 2.0.1 by Igor Akkerman (c) 2000, 2001, 2002, 2003, 2004, 2005, 2006 Package providing utilities for typesetting mathematical relations]
%=====================================================================================================================================

\RequirePackage{amsmath}
\RequirePackage{amssymb}
\RequirePackage{amstext}
\RequirePackage{latexsym}
%-----------------------------------------------------------------------------------------------------------------------------------------------------------------------

\makeatletter

%------------------------------------------------------------------------------
% Definition relations
%------------------------------------------------------------------------------
\newcommand \defas {:=}
\newcommand \asdef {=:}
\newcommand \defequiv {:\iff}
\newcommand \equivdef {\iff:}

%------------------------------------------------------------------------------
% Aligned annotated relations
%------------------------------------------------------------------------------
% \ann{annotation}                typesets an annotation in the annotation font
% \annrel{relation}{annotation}   typesets an annotated relation
% \alannrel{relation}{annotation} typesets an aligned annotated relation
% \setlength \relwidth {relwidth} defines the maximum required relation width
% \annwidth{annotation}        \/ defines the maximum required annotation width
% \annw{annotation}            /\ by the width of the specified annotation
% \alrel{relation}                align a relation within a box of the width 
%                                 of the maximum required annotation width
% \annfont{fontcommand}           defines the font to use for annotations
%                                 default: \scriptsize
%------------------------------------------------------------------------------
\newcommand \ann[1] {%
	{\akk@annfontsize #1}%
}

\newcommand \annrel[2] {%
    \stackrel{\mbox{\ann{#2}}}{#1}%
}

\newcommand \alannrel[2] {%
    \stackrel{\makebox[\akk@annwidth]{\ann{#2}}}{#1}%
}

\newcommand \annwidth[1] {%
    \settowidth \akk@annwidth {\mbox{\ann{#1}}}%
}

\newcommand \annw[1] {%
    \annwidth{#1}%
}

\newcommand \alrel[1] {%
    \alannrel{#1}{}%
}

\newcommand \annfont[1] {%
    \renewcommand \akk@annfont {#1}%
}

\newcommand \akk@annfontsize \scriptsize
\newlength  \akk@annwidth
%------------------------------------------------------------------------------

%------------------------------------------------------------------------------
% predefined relations prepared for annotations
%------------------------------------------------------------------------------
\let \akk@orig@neq       \neq
\let \akk@orig@in        \in
\let \akk@orig@leq       \leq
\let \akk@orig@geq       \geq
\let \akk@orig@iff       \iff
\let \akk@orig@implies   \implies
\let \akk@orig@impliedby \impliedby
\let \akk@orig@leadsto   \leadsto
\let \akk@orig@subset    \subset
\let \akk@orig@supset    \supset
\let \akk@orig@subseteq  \subseteq
\let \akk@orig@supseteq  \supseteq

\renewcommand {\=}[1][]        {\annrel{=}{#1}}
\newcommand   \eq[1][]         {\annrel{=}{#1}}
\renewcommand \neq[1][]        {\annrel{\akk@orig@neq}{#1}}
\renewcommand \iff[1][]        {\annrel{\akk@orig@iff}{#1}}
\renewcommand \implies[1][]    {\annrel{\akk@orig@implies}{#1}}
\newcommand   \impl[1][]       {\annrel{\akk@orig@implies}{#1}}
\renewcommand \impliedby[1][]  {\annrel{\akk@orig@impliedby}{#1}}
\newcommand   \implby[1][]     {\annrel{\akk@orig@impliedby}{#1}}
\renewcommand \in[1][]         {\annrel{\akk@orig@in}{#1}}
\renewcommand \leq[1][]        {\annrel{\akk@orig@leq}{#1}}
\renewcommand \geq[1][]        {\annrel{\akk@orig@geq}{#1}}
\newcommand   \lt[1][]         {\annrel{<}{#1}}
\newcommand   \gt[1][]         {\annrel{>}{#1}}
\renewcommand \subset[1][]     {\annrel{\akk@orig@subset}{#1}}
\newcommand   \subs[1][]       {\annrel{\akk@orig@subset}{#1}}
\renewcommand \subseteq[1][]   {\annrel{\akk@orig@subseteq}{#1}}
\newcommand   \subseq[1][]     {\annrel{\akk@orig@subseteq}{#1}}
\renewcommand \supset[1][]     {\annrel{\akk@orig@supset}{#1}}
\newcommand   \sups[1][]       {\annrel{\akk@orig@supset}{#1}}
\renewcommand \supseteq[1][]   {\annrel{\akk@orig@supseteq}{#1}}
\newcommand   \supseq[1][]     {\annrel{\akk@orig@supseteq}{#1}}

\newcommand \aleq[1][]         {\alannrel{=}{#1}}
\newcommand \alneq[1][]        {\alannrel{\neq}{#1}}
\newcommand \aliff[1][]        {\alannrel{\akk@orig@iff}{#1}}
\newcommand \alimplies[1][]    {\alannrel{\akk@orig@implies}{#1}}
\newcommand \alimpl[1][]       {\alannrel{\akk@orig@implies}{#1}}
\newcommand \alimpliedby[1][]  {\alannrel{\akk@orig@impliedby}{#1}}
\newcommand \alimplby[1][]     {\alannrel{\akk@orig@impliedby}{#1}}
\newcommand \alin[1][]         {\alannrel{\akk@orig@in}{#1}}
\newcommand \alleq[1][]        {\alannrel{\akk@orig@leq}{#1}}
\newcommand \algeq[1][]        {\alannrel{\akk@orig@geq}{#1}}
\newcommand \allt[1][]         {\alannrel{<}{#1}}
\newcommand \algt[1][]         {\alannrel{>}{#1}}
\newcommand \alsubset[1][]     {\alannrel{\akk@orig@subset}{#1}}
\newcommand \alsubs[1][]       {\alannrel{\akk@orig@subset}{#1}}
\newcommand \alsubseteq[1][]   {\alannrel{\akk@orig@subseteq}{#1}}
\newcommand \alsubseq[1][]     {\alannrel{\akk@orig@subseteq}{#1}}
\newcommand \alsupset[1][]     {\alannrel{\akk@orig@supset}{#1}}
\newcommand \alsups[1][]       {\alannrel{\akk@orig@supset}{#1}}
\newcommand \alsupseteq[1][]   {\alannrel{\akk@orig@supseteq}{#1}}
\newcommand \alsupseq[1][]     {\alannrel{\akk@orig@supseteq}{#1}}

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


\newcommand \iffq[1][]      {{\iff[#1] \quad}}
\newcommand \qiff[1][]      {{\quad \iff[#1]}}
\newcommand \qqiff[1][]     {{\qquad \iff[#1]}}
\newcommand \qiffq[1][]     {{\quad \iff[#1] \quad}}
\newcommand \qqiffqq[1][]   {{\qquad \iff[#1] \qquad}}

\newcommand \qimplies[1][]    {{\quad \implies[#1]}}
\newcommand \qqimplies[1][]   {{\qquad \implies[#1]}}
\newcommand \qimpliesq[1][]   {{\quad \implies[#1] \quad}}
\newcommand \qqimpliesqq[1][] {{\qquad \implies[#1] \qquad}}

\newcommand \qimpl[1][]    {{\quad \impl[#1]}}
\newcommand \qqimpl[1][]   {{\qquad \impl[#1]}}
\newcommand \qimplq[1][]   {{\quad \impl[#1] \quad}}
\newcommand \qqimplqq[1][] {{\qquad \impl[#1] \qquad}}

\providecommand \inv {^{-1}}             % inverse relation (do not wrap twice! {{}})
\providecommand \inverse[1] {{#1}\inv}   % inverse of argument
%-----------------------------------------------------------------------------------------------------------------------------------------------------------------------

\makeatother