%%
%% This is file `ytableau.sty',
%% generated with the docstrip utility.
%%
%% The original source files were:
%%
%% ytableau.dtx  (with options: `package')
%% 
%% This is a generated file.
%% 
%% Copyright (C) 2010 by Ryan Reich <ryan.reich@gmail.com>
%% 
%% This file may be distributed and/or modified under the conditions of
%% the LaTeX Project Public License, either version 1.2 of this license
%% or (at your option) any later version.  The latest version of this
%% license is in:
%% 
%%    http://www.latex-project.org/lppl.txt
%% 
%% and version 1.2 or later is part of all distributions of LaTeX version
%% 1999/12/01 or later.
%% 
\NeedsTeXFormat{LaTeX2e}
\ProvidesPackage{ytableau}
    [2010/11/07 v1.0 Many-featured Young tableaux and Young diagrams]

\newbox\ytableau@tableaux
\newbox\ytableau@thistableau
\newbox\ytableau@thisbox
\newbox\ytableau@tmpboxa\newbox\ytableau@tmpboxb
\setbox\ytableau@tmpboxa=\hbox{$b$}
\setbox\ytableau@tmpboxb=\hbox{$g$}
\newtoks\ytableau@toks
\newtoks\ytableau@opttoksa
\newtoks\ytableau@opttoksb
\newdimen\ytableau@boxdim@normal
  \ytableau@boxdim@normal=1.5em
\newdimen\ytableau@boxdim@save
  \ytableau@boxdim@save=\ytableau@boxdim@normal
\newdimen\ytableau@boxdim
  \ytableau@boxdim=\ytableau@boxdim@normal
\newdimen\ytableau@tableauwd
\newdimen\ytableau@boxframe \ytableau@boxframe=0.4pt
\newcount\ytableau@diagram@count
\def\ytableau@ifstar#1{\kernel@ifnextchar *{\@firstoftwo{#1}}}
\def\ytableau@ignorespaces{$}
\def\ytableau@thisboxcolor{clear}
\def\ytableau@centering{top}
\def\ytableau@defarg{}
\def\ytableau@tmpa{}
\def\ytableau@tmpb{}
\def\ytableau@tmpc{}
\def\ytableau@compare#1#2{%
 \def\ytableau@tmpa{#1}\def\ytableau@tmpb{#2}%
 \ifx\ytableau@tmpa\ytableau@tmpb%
  \global\@ytableau@eqtrue%
 \else%
  \global\@ytableau@eqfalse%
 \fi%
}
\def\ytableau@compare@#1#2{%
 \def\ytableau@tmpb{#2}%
 \ifx#1\ytableau@tmpb%
  \global\@ytableau@eqtrue%
 \else%
  \global\@ytableau@eqfalse%
 \fi%
}
\newif\if@ytableau@eq
\RequirePackage{xkeyval}
\newcommand{\ytableausetup}[1]{\setkeys[ytableau]{setup}{#1}}
\define@key[ytableau]{setup}{boxsize}{%
 \setkeys[ytableau]{setup}{nosmalltableaux}%
 \ytableau@compare{#1}{normal}%
 \if@ytableau@eq%
  \global\ytableau@boxdim=\ytableau@boxdim@normal%
 \else%
  \global\ytableau@boxdim=#1%
 \fi%
}
\define@choicekey*[ytableau]{setup}{aligntableaux}
                         {top,center,bottom}[true]{%
 \gdef\ytableau@centering{#1}
}
\define@choicekey[ytableau]{setup}{centertableaux}{true}[true]{%
 \gdef\ytableau@centering{center}%
}
\define@choicekey[ytableau]{setup}{nocentertableaux}{true}[true]{%
 \gdef\ytableau@centering{top}%
}
\define@boolkey[ytableau]{setup}{smalltableaux}[true]{%
 \ifytableau@setup@smalltableaux%
  \ifnum\ytableau@boxdim@save>0%
   \gdef\ytableau@defarg{\scriptstyle}%
   \global\ytableau@boxdim@save=-\ytableau@boxdim%
   \global\ytableau@boxdim=.81em%
  \fi%
 \else%
  \ifnum\ytableau@boxdim@save<0%
   \gdef\ytableau@defarg{}%
   \global\ytableau@boxdim=-\ytableau@boxdim@save%
  \fi%
 \fi%
}
\define@boolkey[ytableau]{setup}{nosmalltableaux}[true]{%
 \ifytableau@setup@nosmalltableaux%
  \setkeys[ytableau]{setup}{smalltableaux=false}%
 \else%
  \setkeys[ytableau]{setup}{smalltableaux=true}%
 \fi%
}
\define@boolkey[ytableau]{setup}{textmode}[true]{%
 \ifytableau@setup@textmode%
  \global\def\ytableau@ignorespaces{\ignorespaces}%
 \else%
  \global\def\ytableau@ignorespaces{$}%
 \fi%
}
\define@boolkey[ytableau]{setup}{mathmode}[true]{%
 \ifytableau@setup@mathmode%
  \setkeys[ytableau]{setup}{textmode=false}%
 \else%
  \setkeys[ytableau]{setup}{textmode=true}%
 \fi%
}
\DeclareOptionX*{\PassOptionsToPackage{\CurrentOption}{xcolor}}
\ProcessOptionsX[ytableau]<setup>[]
\RequirePackage{xcolor}
\newenvironment{ytableau}[1][]
{%
 \leavevmode%
 {\iffalse}\fi%
  \global\setbox\ytableau@thistableau=\hbox\bgroup$%
   \m@th%
   \setlength{\fboxrule}{\ytableau@boxframe}%
   \setlength{\fboxsep}{0pt}%
   \vtop\bgroup%
    \let\\=\ytableau@cr%
    \offinterlineskip%
    \openup-\fboxrule%
    \tabskip=-\fboxrule%
    \halign\bgroup&\ytableau@startbox{\ytableau@defarg}{#1}##%
                                             \ytableau@endbox\cr%
}
{%
    \crcr\egroup%
   \egroup%
  $\egroup%
 \iffalse{\fi}%
 \ifnum\wd\ytableau@thistableau>\wd\ytableau@tableaux%
  \ytableau@tableauwd=\wd\ytableau@thistableau%
 \else%
  \ytableau@tableauwd=\wd\ytableau@tableaux%
 \fi%
 \wd\ytableau@thistableau=0pt%
 \setbox\ytableau@tableaux%
  =\hbox{\box\ytableau@thistableau\unhbox\ytableau@tableaux}%
 \wd\ytableau@tableaux=\ytableau@tableauwd%
 \ytableau@ifstar%
  {\ydiagram}%
  {%
   \ytableau@compare@{\ytableau@centering}{center}%
   \if@ytableau@eq%
    \hbox{$\vcenter{\box\ytableau@tableaux}$}%
   \else\ytableau@compare@{\ytableau@centering}{bottom}%
   \if@ytableau@eq%
    \raise\dp\ytableau@tableaux\box\ytableau@tableaux%
   \fi%
    \setbox\ytableau@tableaux%
     =\hbox{\lower\ht\ytableau@tableaux\box\ytableau@tableaux}%
    \setbox\ytableau@tableaux%
     =\hbox{\raise\ytableau@boxdim\box\ytableau@tableaux}%
    \setbox\ytableau@tableaux%
     =\hbox{\raise2\ytableau@boxframe\box\ytableau@tableaux}%
    \box\ytableau@tableaux%
   \fi%
  }%
}
\def\ytableau@cr{\cr}
\def\none{\omit\ytableau@none}
\newcommand{\ytableau@none}[1][]{%
 \def\ytableau@thisboxcolor{clear}%
 \setlength{\fboxsep}{\ytableau@boxframe}%
 \setlength{\fboxrule}{0pt}%
 \ytableau@@startbox#1\ytableau@endbox%
 \ignorespaces%
}
\def\ytableau@startbox#1#2{%
 \ytableau@getcolor{\ytableau@save{\ytableau@opttoksa}}#1\@nil%
 \ytableau@getcolor{\ytableau@save{\ytableau@opttoksb}}#2\@nil%
 \ytableau@getcolor%
   {\ytableau@@startbox\the\ytableau@opttoksa\the\ytableau@opttoksb}%
}
\def\ytableau@save#1#2\@nil{#1={#2}}
\def\ytableau@getcolor#1{\ytableau@ifstar{\ytableau@@getcolor{#1}}{#1}}
\def\ytableau@@getcolor#1(#2){%
 \def\ytableau@thisboxcolor{#2}%
 #1%
}
\def\ytableau@@startbox{%
 \setbox\ytableau@thisbox=\hbox to \ytableau@boxdim\bgroup%
  \hss%
  \ytableau@ignorespaces%
}
\def\ytableau@endbox{%
     \ytableau@ignorespaces%
  \hss%
 \egroup%
 \ht\ytableau@thisbox=\ht\ytableau@tmpboxa%
 \dp\ytableau@thisbox=\dp\ytableau@tmpboxb%
 \ytableau@fcolorbox{\ytableau@thisboxcolor}{%
  \vbox to \ytableau@boxdim{\vss\box\ytableau@thisbox\vss}%
 }%
}
\def\ytableau@fcolorbox#1#2{%
 \ytableau@compare@{#1}{clear}%
 \if@ytableau@eq%
  \fbox{#2}%
 \else%
  \fcolorbox{.}{#1}{#2}%
 \fi%
}
\newcommand{\ytableaushort}[2][]{%
 \ytableau@toks={}%
 \ytableau@getentries{\ytableau@@getentries}{}#2,\@nil%
 \ytableau[#1]\the\ytableau@toks\endytableau%
}
\def\ytableau@getentries#1#2{\ytableau@getline{#1}{#2}.}
\def\ytableau@getline#1#2#3,{%
 \ytableau@opttoksa=\expandafter{\@gobble#3}%
 \ytableau@opttoksb={\ytableau@@getline{#1}{#2}}%
 \edef\ytableau@next{\the\ytableau@opttoksb{\the\ytableau@opttoksa}}%
 \ytableau@next%
}
\def\ytableau@@getline#1#2#3#4{%
 \ytableau@compare{#4}{,}%
 \if@ytableau@eq%
  \def\ytableau@next{\ytableau@@getline{#1}{#2}{#3}}%
 \else%
  \ytableau@compare{#4}{\@nil}%
  \if@ytableau@eq%
   \def\ytableau@next{#1#3#2\@nil}%
  \else%
   \def\ytableau@next{#1#3#2\@nil\ytableau@getentries{#1}{#2}{#4}}%
  \fi%
 \fi%
 \ytableau@next%
}
\def\ytableau@@getentries#1#2{%
 \ytableau@compare{#2}{\@nil}%
 \if@ytableau@eq%
  \ytableau@toks=\expandafter{\the\ytableau@toks#1\\}%
  \def\ytableau@next{}%
 \else%
  \ytableau@toks=\expandafter{\the\ytableau@toks#1&}%
  \def\ytableau@next{\ytableau@@getentries{#2}}%
 \fi%
 \ytableau@next%
}
\newcommand\ydiagram[2][]{%
 \ytableau@toks={}%
 \ytableau@getentries{\ytableau@diagram@getentries}{+}#2,\@nil%
 \ytableau[#1]\the\ytableau@toks\endytableau%
}
\def\ytableau@diagram@getentries#1+#2\@nil{%
 \ytableau@compare{#2}{}%
 \if@ytableau@eq%
  \def\ytableau@next{%
   \ytableau@loop{#1}{}%
  }%
 \else%
  \def\ytableau@next{%
   \ytableau@loop{#1}{\none}%
   \ytableau@diagram@getentries#2\@nil%
  }%
 \fi%
 \ytableau@next%
}
\def\ytableau@loop#1#2{%
 \ytableau@fullexpand{#1}%
 \loop\ifnum\ytableau@diagram@count>1%
  \ytableau@toks=\expandafter{\the\ytableau@toks#2&}%
  \advance\ytableau@diagram@count by -1%
 \repeat%
 \ifnum\ytableau@diagram@count=1%
  \ytableau@compare{#2}{}%
  \if@ytableau@eq%
   \ytableau@toks=\expandafter{\the\ytableau@toks#2\\}%
  \else
   \ytableau@toks=\expandafter{\the\ytableau@toks#2&}%
  \fi%
 \fi%
}
\def\ytableau@fullexpand#1{%
 \def\ytableau@tmpa##1{##1}%
 \edef\ytableau@tmpb{\ytableau@tmpa#1}%
 \edef\ytableau@tmpc{\ytableau@tmpb}%
 \ytableau@diagram@count=\ytableau@tmpc%
}
\endinput
%%
%% End of file `ytableau.sty'.
