%%
%% 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}
    [2011/01/31 v1.1 Many-featured Young tableaux and Young diagrams]

\newbox\tableaux@YT
\newbox\thistableau@YT
\let\thisbox@YT=\thistableau@YT
\newbox\refhtdp@YT
 \setbox\refhtdp@YT=\hbox{$bg$}
\newtoks\toks@YT
\newtoks\opttoksa@YT
\newtoks\opttoksb@YT
\newdimen\boxdim@normal@YT
  \boxdim@normal@YT=1.5em
\newdimen\boxdim@save@YT
  \boxdim@save@YT=\boxdim@normal@YT
\newdimen\boxdim@YT
  \boxdim@YT=\boxdim@normal@YT
\newdimen\tableauwd@YT
\newdimen\boxframe@YT \boxframe@YT=0.4pt
\newcount\count@YT
\def\ifstar@YT#1{\kernel@ifnextchar *{\@firstoftwo{#1}}}
\def\skipin@YT{$}
\def\skipout@YT{$}
\def\thisboxcolor@YT{clear}
\def\centering@YT{top}
\def\defarg@YT{}
\def\compare@YT#1#2{%
 \def\tmpa@YT{#1}\def\tmpb@YT{#2}%
 \ifx\tmpa@YT\tmpb@YT%
  \global\eq@YTtrue%
 \else%
  \global\eq@YTfalse%
 \fi%
}
\def\compare@@YT#1#2{%
 \def\tmpb@YT{#2}%
 \ifx#1\tmpb@YT%
  \global\eq@YTtrue%
 \else%
  \global\eq@YTfalse%
 \fi%
}
\newif\ifeq@YT
\RequirePackage{xkeyval}
\newcommand{\ytableausetup}[1]{\setkeys[ytableau]{setup}{#1}}
\define@key[ytableau]{setup}{boxsize}{%
 \setkeys[ytableau]{setup}{nosmalltableaux}%
 \compare@YT{#1}{normal}%
 \ifeq@YT%
  \global\boxdim@YT=\boxdim@normal@YT%
 \else%
  \global\boxdim@YT=#1%
 \fi%
}
\define@choicekey*[ytableau]{setup}{aligntableaux}
                         {top,center,bottom}[true]{%
 \gdef\centering@YT{#1}
}
\define@choicekey[ytableau]{setup}{centertableaux}{true}[true]{%
 \gdef\centering@YT{center}%
}
\define@choicekey[ytableau]{setup}{nocentertableaux}{true}[true]{%
 \gdef\centering@YT{top}%
}
\define@boolkey[ytableau]{setup}{smalltableaux}[true]{%
 \ifytableau@setup@smalltableaux%
  \ifnum\boxdim@save@YT>0%
   \gdef\defarg@YT{\scriptstyle}%
   \global\boxdim@save@YT=-\boxdim@YT%
   \global\boxdim@YT=.81em%
  \fi%
 \else%
  \ifnum\boxdim@save@YT<0%
   \gdef\defarg@YT{}%
   \global\boxdim@YT=-\boxdim@save@YT%
   \global\boxdim@save@YT=\boxdim@normal@YT%
  \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\skipin@YT{\ignorespaces}%
  \global\def\skipout@YT{\unskip}%
 \else%
  \global\def\skipin@YT{$}%
  \global\def\skipout@YT{$}%
 \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][]
{%
  \global\setbox\thistableau@YT=\vtop{\iffalse}\fi%
   \setlength{\fboxrule}{\boxframe@YT}%
   \setlength{\fboxsep}{0pt}%
   \let\\=\cr@YT%
   \offinterlineskip%
   \openup-\fboxrule%
   \tabskip=-\fboxrule%
 % \changes{v1.1}{2010/11/10}{Added the everycr fix.}
   \everycr={}%
   \halign\bgroup&\startbox@YT{\defarg@YT}{#1}##%
                                            \endbox@YT\cr%
}
{%
   \crcr\egroup%
  \iffalse{\fi}%
 \ifnum\wd\thistableau@YT>\wd\tableaux@YT%
  \tableauwd@YT=\wd\thistableau@YT%
  \advance\tableauwd@YT by -\wd\tableaux@YT%
 \else%
  \tableauwd@YT = 0pt%
 \fi%
 \wd\thistableau@YT=0pt%
 \setbox\tableaux@YT%
  =\hbox{\box\thistableau@YT\unhbox\tableaux@YT%
         \kern\tableauwd@YT}%
 \ifstar@YT%
  {\ydiagram}%
  {%
   \leavevmode%
   \compare@@YT{\centering@YT}{center}%
   \ifeq@YT%
    \hbox{$\vcenter{\box\tableaux@YT}$}%
   \else\compare@@YT{\centering@YT}{bottom}%
   \ifeq@YT%
    \hbox{\raise\dp\tableaux@YT\box\tableaux@YT}%
   \fi%
    \box\tableaux@YT%
   \fi%
  }%
}
\def\cr@YT{\cr}
\def\none{\omit\none@YT}
\newcommand{\none@YT}[1][]{%
 \def\thisboxcolor@YT{clear}%
 \setlength{\fboxsep}{\boxframe@YT}%
 \setlength{\fboxrule}{0pt}%
 \startbox@@YT#1\endbox@YT%
 \ignorespaces%
}
\def\startbox@YT#1#2{%
 \getcolor@YT{\save@YT{\opttoksa@YT}}#1\@nil%
 \getcolor@YT{\save@YT{\opttoksb@YT}}#2\@nil%
 \getcolor@YT%
   {\startbox@@YT\the\opttoksa@YT\the\opttoksb@YT}%
}
\def\save@YT#1#2\@nil{#1={#2}}
\def\getcolor@YT#1{\ifstar@YT{\getcolor@@YT{#1}}{#1}}
\def\getcolor@@YT#1(#2){%
 \def\thisboxcolor@YT{#2}%
 #1%
}
\def\startbox@@YT{%
 \setbox\thisbox@YT=\hbox to \boxdim@YT\bgroup%
  \hss%
  \skipin@YT%
}
\def\endbox@YT{%
  \skipout@YT%
  \hss%
 \egroup%
 \ht\thisbox@YT=\ht\refhtdp@YT%
 \dp\thisbox@YT=\dp\refhtdp@YT%
 \fcolorbox@YT{\thisboxcolor@YT}{%
  \vbox to \boxdim@YT{\vss\box\thisbox@YT\vss}%
 }%
}
\def\fcolorbox@YT#1#2{%
 \compare@@YT{#1}{clear}%
 \ifeq@YT%
  \fbox{#2}%
 \else%
  \fcolorbox{.}{#1}{#2}%
 \fi%
}
\newcommand{\ytableaushort}[2][]{%
 \toks@YT={}%
 \getentries@YT{\getentries@@YT}{}#2,\@nil%
 \ytableau[#1]\the\toks@YT\endytableau%
}
\def\getentries@YT#1#2{\getline@YT{#1}{#2}.}
\def\getline@YT#1#2#3,{%
 \opttoksa@YT=\expandafter{\@gobble#3}%
 \opttoksb@YT={\getline@@YT{#1}{#2}}%
 \edef\next@YT{\the\opttoksb@YT{\the\opttoksa@YT}}%
 \next@YT%
}
\def\getline@@YT#1#2#3#4{%
 \compare@YT{#4}{,}%
 \ifeq@YT%
  \def\next@YT{\getline@@YT{#1}{#2}{#3}}%
 \else%
  \compare@YT{#4}{\@nil}%
  \ifeq@YT%
   \def\next@YT{#1#3#2\@nil}%
  \else%
   \def\next@YT{#1#3#2\@nil\getentries@YT{#1}{#2}{#4}}%
  \fi%
 \fi%
 \next@YT%
}
\def\getentries@@YT#1#2{%
 \compare@YT{#2}{\@nil}%
 \ifeq@YT%
  \toks@YT=\expandafter{\the\toks@YT#1\\}%
  \def\next@YT{}%
 \else%
  \toks@YT=\expandafter{\the\toks@YT#1&}%
  \def\next@YT{\getentries@@YT{#2}}%
 \fi%
 \next@YT%
}
\newcommand\ydiagram[2][]{%
 \toks@YT={}%
 \getentries@YT{\getnumbers@YT}{+}#2,\@nil%
 \ytableau[#1]\the\toks@YT\endytableau%
}
\def\getnumbers@YT#1+#2\@nil{%
 \compare@YT{#2}{}%
 \ifeq@YT%
  \def\next@YT{%
   \loop@YT{#1}{}%
  }%
 \else%
  \def\next@YT{%
   \loop@YT{#1}{\none}%
   \getnumbers@YT#2\@nil%
  }%
 \fi%
 \next@YT%
}
\def\loop@YT#1#2{%
 \fullexpand@YT{#1}%
 \loop\ifnum\count@YT>1%
  \toks@YT=\expandafter{\the\toks@YT#2&}%
  \advance\count@YT by -1%
 \repeat%
 \ifnum\count@YT=1%
  \compare@YT{#2}{}%
  \ifeq@YT%
   \toks@YT=\expandafter{\the\toks@YT#2\\}%
  \else
   \toks@YT=\expandafter{\the\toks@YT#2&}%
  \fi%
 \fi%
}
\def\fullexpand@YT#1{%
 \def\tmpa@YT##1{##1}%
 \edef\tmpb@YT{\tmpa@YT#1}%
 \edef\tmpc@YT{\tmpb@YT}%
 \count@YT=\tmpc@YT%
}
\endinput
%%
%% End of file `ytableau.sty'.
