%%
%% This is file `mlist.sty',
%% generated with the docstrip utility.
%%
%% The original source files were:
%%
%% mlist.dtx  (with options: `package')
%% 
%%   __________________________________
%%   Copyright (C) 2007  Will Robertson
%% 
%%   License information appended.
%% 
%% 
\ProvidesPackage{mlist}
  [2008/08/15 v0.6a Typesetting maths lists]
\let\mlisthead\@firstofone
\let\mlistelem\@secondoftwo
\newcommand\mlistsub  [2]{#1_{#2}}
\newcommand\mlistsup  [2]{#1^{#2}}
\let\mlistnowrap\@secondoftwo
\newcommand\mlistparen[2]{\left(#2\right)}
\newcommand\mlistbrack[2]{\left[#2\right]}
\newcommand\mlistbrace[2]{\left\{#2\right\}}
\newcommand\mlistangle[2]{\left<#2\right>}
\newcommand\mlistheadparen[2]{#1\left(#2\right)}
\newcommand\mlistheadbrack[2]{#1\left[#2\right]}
\newcommand\mlistheadbrace[2]{#1\left\{#2\right\}}
\newcommand\mlistheadangle[2]{#1\left<#2\right>}
\RequirePackage{xkeyval,ifmtarg}
\newif\if@mlist@notfirst@
\newif\if@mlist@implicit@
\newcount\mlist@elem@N
\def\@gobblenil#1\@nil{}
\newif\if@mlist@warn
\long\def\@sfor#1:=#2\do#3{%
  \expandafter\def\expandafter\@sfortmp\expandafter{#2}%
  \ifx\@sfortmp\@empty\else
    \expandafter\@sforloop#2;\@nil;\@nil\@@#1{#3}%
  \fi}
\long\def\@sforloop#1;#2;#3\@@#4#5{%
  \def#4{#1}%
  \ifx #4\@nnil \else
    #5%
    \def#4{#2}%
    \ifx #4\@nnil \else
      #5%
      \@siforloop #3\@@#4{#5}%
    \fi
  \fi}
\long\def\@siforloop#1;#2\@@#3#4{%
  \def#3{#1}%
  \ifx #3\@nnil
    \expandafter\@fornoop
  \else
    #4\relax\expandafter\@siforloop
  \fi
  #2\@@#3{#4}}
\providecommand\let@cc[2]{%
  \expandafter\let\csname#1\expandafter\endcsname\csname#2\endcsname}
\providecommand\def@c[1]{%
  \expandafter\def\csname#1\endcsname}
\providecommand\def@co[2]{%
  \def@c{#1\expandafter}\expandafter{#2}}
\newcommand\mlist@optarg[1]{\@ifnextchar[{#1}{#1[]}}%]
\newcommand\@ifnextbrace{\expandafter\@ifnextchar\bgroup}
\def\mlist@colon{:}
\def\mlist@period{.}
\makeatother
\expandafter\def\csname mlist@ampersat\endcsname{@}
\makeatletter
\newcommand\mlistsetup[1]{\setkeys[mlist]{sym}{#1}}
\define@cmdkeys[mlist]{sym}[mlist@]{%
  symbol,index,sep,sepsep,elem,
  elemcmd,headcmd,dot,dots,headhook}
\define@key[mlist]{sym}{wrapcmd}{\let\mlist@wrap#1}
\define@key[mlist]{sym}{wraponecmd}[\mlist@wrap]{\let\mlist@wrapone#1}
\define@key[mlist]{sym}{wrap}{%
  \def\mlist@wrap##1##2{\@firstoftwo#1##2\@secondoftwo#1}}
\define@key[mlist]{sym}{wrapone}[]{%
  \ifx\relax#1\relax
    \let\mlist@wrapone\mlist@wrap
  \else
    \def\mlist@wrapone##1##2{\@firstoftwo#1##2\@secondoftwo#1}%
  \fi}
\define@key[mlist]{sym}{elem}{%
  \@tempcnta\z@
  \@tempcntb\z@
  \mlist@elem@N\z@
  \@sfor\@jj:=#1\do{%
    \advance\@tempcnta\@ne
    \@tempcntb\z@
    \@tempswafalse
    \@for\@ii:=\@jj\do{%
      \ifx\@ii\mlist@colon
        \@tempswatrue
      \else
        \if@tempswa
          \let@cc{mlist@\the\@tempcnta @mid}{mlist@\the\@tempcnta @last}%
          \def\@tempa{\def@c{mlist@\the\@tempcnta @last}}%
          \expandafter\@tempa\expandafter{\@ii}%
        \else
          \advance\@tempcntb\@ne
          \advance\mlist@elem@N\@ne
          \def@co{mlist@\the\@tempcnta @\the\@tempcntb}{\@ii}%
          \def@co{mlist@@\the\mlist@elem@N}{\@ii}%
        \fi
      \fi}%
    \if@tempswa\@tempswafalse\fi}}
\define@key[mlist]{sym}{shorthand}{%
  \mlist@def@shorthand#1%
  \def@c{mlist@@\@tempa\expandafter}\expandafter{\@tempb}}
\def\mlist@def@shorthand#1#{%
  \def\@tempa{\string#1}
  \def\@tempb}
\newcommand\@mlist[1]{%
  \begingroup
  \let\mlist@list@elems\@empty
  \@tempcnta\@ne
  \mlist@count
  \iffalse{\fi\ifnum0=`}\fi
  \setkeys[mlist]{sym}{#1}%
  \ifnum0=`{\fi\iffalse}\fi
  \def\MID{\csname mlist@\the\@tempcnta @mid\endcsname}%
  \def\LAST{\csname mlist@\the\@tempcnta @last\endcsname}%
  \ifx\@empty\mlist@index\relax
    \def\mlist@list{\mlist@headcmd{\mlist@headhook\mlist@symbol}}%
  \else
    \@tempcnta\z@
    \@tempswafalse
    \@sfor\@jj:=\mlist@index\do{%
      \let\@jj\@jj
      \advance\@tempcnta\@ne
      \mlist@count
      \expandafter\@ifmtarg\expandafter{\@jj}{}% ignore if empty
        {\if@tempswa\mlist@add\mlist@sepsep\fi
         \@tempswatrue}%
      \@tempcntb\z@
      \@mlist@notfirst@false
      \@for\@ii:=\@jj\do{%
        \let\@ii\@ii
        \advance\@tempcntb\@ne
        \expandafter\@ifmtarg\expandafter{\@ii}%
          {\advance\@tempcntb\m@ne
           \mlist@add{\@gobble}}
          {\if@mlist@notfirst@\mlist@add\mlist@sep\fi
           \@mlist@notfirst@true
           \ifx\@ii\mlist@colon
             \mlist@add{\mlist@dots\@gobble}%
           \else
             \ifx\@ii\mlist@period
               \mlist@add{\mlist@dot\@gobble}%
             \else
               \mlist@add{\mlist@elemcmd{\mlist@headhook\mlist@symbol}}%
             \fi
           \fi}%
          \mlist@parse@implicit
          \if@mlist@implicit@
            \mlist@add@ifcs{%
              mlist@\the\@tempcnta @\expandafter\@gobble\@ii
            }{\@ii}%
          \else
            \mlist@add@ifcs{%
              mlist@@\expandafter\detokenize\expandafter{\@ii}%
            }{\@ii}%
          \fi
        }%
      }%
    \def\mlist@list{%
      \mlist@wrap{\mlist@headcmd{\mlist@headhook\mlist@symbol}}
                 {\mlist@list@elems}}%
    \ifnum\@tempcnta=\@ne
      \ifnum\@tempcntb=\@ne
        \let\mlist@wrap\mlist@wrapone
      \fi
    \fi
  \fi
  \mlist@list
  \endgroup}
\newcommand\mlist@add[1]{%
  \expandafter\gdef
  \expandafter\mlist@list@elems
  \expandafter{\mlist@list@elems#1}}
\def\mlist@count{%
  \expandafter\mlist@add
  \expandafter{%
  \expandafter\@tempcnta\the\@tempcnta\relax}}
\newcommand\mlist@add@ifcs[2]{%
  \ifcsname#1\endcsname
    \expandafter\@firstoftwo
  \else
    \expandafter\@secondoftwo
  \fi{\expandafter\mlist@add\expandafter{\expandafter{\csname#1\endcsname}}}
     {\expandafter\mlist@add\expandafter{\expandafter{#2}}}}
\def\mlist@parse@implicit{%
  \@mlist@implicit@false
  \def\@tempb{%
    \expandafter\@ifnextchar\mlist@ampersat
      {\@mlist@implicit@true\@gobblenil}
      {\@mlist@implicit@false\@gobblenil}}%
  \expandafter\@tempb\@ii\@nil
  \unless\if@mlist@implicit@
    \def\@tempb{%
      \@ifnextchar @
        {\@mlist@implicit@true\@gobblenil}
        {\@mlist@implicit@false\@gobblenil}}%
    \expandafter\@tempb\@ii\@nil
  \fi}
\newcommand\newmlist[1]{%
  \@mlist@warntrue
  \mlist@optarg{\@defmlist@opt{#1}}}
\newcommand\renewmlist[1]{%
  \@mlist@warnfalse
  \mlist@optarg{\@defmlist@opt{#1}}}
\def\@defmlist@opt#1[#2]{\@defmlist{#1}{#2}}
\newcommand\@defmlist[2]{%
  \if@mlist@warn
    \ifdefined#1
      \PackageError{mlist}{Command \string#1 already defined}
        {\string#1 will be overwritten}%
    \fi
  \fi
  \protected\def#1##1{%
    \@ifnextbrace
      {\csname\string#1@opt\endcsname{##1}}
      {\csname\string#1@opt\endcsname{##1}{}}}%
  \def@c{\string#1@opt}##1##2{%
    \csname\string#1\endcsname{##1}{##2}}%
  \def@c{\string#1}##1##2{%
    \@mlist{symbol=##1,#2,index={##2}}}%
  \def@c{new\expandafter\@gobble\string#1}##1##2{%
    \@mlist@warntrue
    \mlist@optarg{\csname @new\string#1@opt\endcsname{##1}{##2}}}%
  \def@c{renew\expandafter\@gobble\string#1}##1##2{%
    \@mlist@warnfalse
    \mlist@optarg{\csname @new\string#1@opt\endcsname{##1}{##2}}}%
  \def@c{@new\string#1@opt}##1##2[##3]{%
    \csname @new\string#1\endcsname{##1}{##2}{##3}}%
  \def@c{@new\string#1}##1##2##3{%
    \if@mlist@warn
      \ifdefined##1
        \PackageError{mlist}{Command \string##1 already defined}
          {You cannot overwrite previous definition of \string##1}%
      \fi
    \fi
    \protected\def##1{%
      \@ifnextbrace
        {\csname @new\string##1@opt\endcsname}
        {\@mlist{symbol=##2,#2,##3}}}%
    \def@c{@new\string##1@opt}####1{%
      \@mlist{symbol=##2,#2,##3,index={####1}}}}%
  }
\InputIfFileExists{mlist.cfg}{}
 {\PackageWarning{mlist}{No configuration file (mlist.cfg) found nor loaded}}
%% 
%% Copyright (C) 2007 by Will Robertson <wspr81@gmail.com>
%% 
%% Distributable under the LaTeX Project Public License,
%% version 1.3c or higher (your choice). The latest version of
%% this license is at: http://www.latex-project.org/lppl.txt
%% 
%% This work is "maintained" (as per LPPL maintenance status)
%% by Will Robertson.
%% 
%% This work consists of the file  mlist.dtx
%%           and the derived files mlist.pdf,
%%                                 mlist.sty,
%%                                 mlist.cfg, and
%%                                 mlist.ins.
%% 
%%
%% End of file `mlist.sty'.
