summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/source
diff options
context:
space:
mode:
Diffstat (limited to 'Master/texmf-dist/source')
-rw-r--r--Master/texmf-dist/source/latex/ytableau/ytableau.dtx1313
-rw-r--r--Master/texmf-dist/source/latex/ytableau/ytableau.ins56
2 files changed, 1369 insertions, 0 deletions
diff --git a/Master/texmf-dist/source/latex/ytableau/ytableau.dtx b/Master/texmf-dist/source/latex/ytableau/ytableau.dtx
new file mode 100644
index 00000000000..7061a721619
--- /dev/null
+++ b/Master/texmf-dist/source/latex/ytableau/ytableau.dtx
@@ -0,0 +1,1313 @@
+% \iffalse meta-comment
+%
+% 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.
+%
+% \fi
+%
+% \iffalse
+%<package>\NeedsTeXFormat{LaTeX2e}
+%<package>\ProvidesPackage{ytableau}
+%<package> [2010/11/07 v1.0 Many-featured Young tableaux and Young diagrams]
+%
+%<*driver>
+\documentclass{ltxdoc}
+\usepackage{ytableau,amsmath,microtype,changepage}
+\usepackage[numbered]{hypdoc}
+\hypersetup{colorlinks,linkcolor=blue}
+\EnableCrossrefs
+\CodelineIndex
+\RecordChanges
+\begin{document}
+ \DocInput{ytableau.dtx}
+ \newlength{\newleftmargin}
+ \setlength{\newleftmargin}{\marginparwidth}
+ \addtolength{\newleftmargin}{-0.5in}
+ \newpage
+ \begin{adjustwidth}{-\newleftmargin}{-0.5in}
+ \PrintIndex
+ \end{adjustwidth}
+\end{document}
+%</driver>
+% \fi
+%
+% \CheckSum{494}
+%
+% \CharacterTable
+% {Upper-case \A\B\C\D\E\F\G\H\I\J\K\L\M\N\O\P\Q\R\S\T\U\V\W\X\Y\Z
+% Lower-case \a\b\c\d\e\f\g\h\i\j\k\l\m\n\o\p\q\r\s\t\u\v\w\x\y\z
+% Digits \0\1\2\3\4\5\6\7\8\9
+% Exclamation \! Double quote \" Hash (number) \#
+% Dollar \$ Percent \% Ampersand \&
+% Acute accent \' Left paren \( Right paren \)
+% Asterisk \* Plus \+ Comma \,
+% Minus \- Point \. Solidus \/
+% Colon \: Semicolon \; Less than \<
+% Equals \= Greater than \> Question mark \?
+% Commercial at \@ Left bracket \[ Backslash \\
+% Right bracket \] Circumflex \^ Underscore \_
+% Grave accent \` Left brace \{ Vertical bar \|
+% Right brace \} Tilde \~}
+%
+%
+% \changes{v1.0}{2010/11/04}{Initial version}
+%
+% \GetFileInfo{ytableau.sty}
+%
+% \DoNotIndex{\@firstoftwo,\@gobble,\@ytableau@eqfalse,\@ytableau@eqtrue}
+% \DoNotIndex{\advance}
+% \DoNotIndex{\bgroup,\box}
+% \DoNotIndex{\crcr,\CurrentOption}
+% \DoNotIndex{\DeclareOptionX, \def,\define@boolkey,\define@choicekey,\define@key,\dp}
+% \DoNotIndex{\edef,\egroup,\else,\expandafter}
+% \DoNotIndex{\fi}
+% \DoNotIndex{\gdef,\global}
+% \DoNotIndex{\hbox,\hss,\ht}
+% \DoNotIndex{\ifnum,\ifx,\ifytableau@setup@nosmalltableaux,\ifytableau@setup@smalltableaux}
+% \DoNotIndex{\ifytableau@setup@mathmode,\ifytableau@setup@textmode}
+% \DoNotIndex{\leavevmode,\let,\loop}
+% \DoNotIndex{\m@th}
+% \DoNotIndex{\newbox,\newcommand,\newcount,\newdimen,\newenvironment,\newif,\newtoks}
+% \DoNotIndex{\PassOptionsToPackage,\ProcessOptionsX}
+% \DoNotIndex{\repeat}
+% \DoNotIndex{\scriptscriptstyle,\scriptstyle,\setbox,\setkeys,\setlength}
+% \DoNotIndex{\the}
+% \DoNotIndex{\unhbox}
+% \DoNotIndex{\vbox,\vcenter,\vrule,\vss,\vtop}
+% \DoNotIndex{\wd}
+%
+% \title{The \textsf{ytableau} package\thanks{This document describes
+% \textsf{ytableau}~\fileversion, dated~\filedate.}}
+% \author{Ryan Reich\\\texttt{ryan.reich@gmail.com}}
+% \maketitle
+%
+% \tableofcontents
+%\pagebreak
+% \noindent \textit{For Greta}
+%
+% \section{Y tableau?}
+%
+% At present there exist two packages with which one can draw Young tableaux: \textsf{young} and
+% \textsf{youngtab}. As the latter is explicitly an alternative to the former, they do not overlap
+% very much except in what they eventually produce. Between them, they define the following three
+% basic constructions of Young tableaux:
+%
+% \begin{itemize}
+% \item An environment with array-style syntax;
+%
+% \item A short-form macro;
+%
+% \item An even shorter-form macro for drawing Young diagrams (having nothing inside the boxes).
+% \end{itemize}
+%
+% In this package we also implement these methods. However, we aim to take them as far as possible
+% so that the conceivable needs of a mathematician making serious use of Young tableaux can be met
+% with as little effort as possible on their part (and, thus, great effort on the part of this
+% author). In writing this package we pursued the following major goals:
+%
+% \begin{itemize}
+% \item The syntax should be as convenient as possible. The \textsf{young} package makes
+% unfortunate use of the |\cr| delimiter for lines in an array, which is nowhere to be seen in
+% modern \LaTeX\ and is likely unfamiliar to casual, young writers. The \textsf{youngtab} package
+% requires the author to define individual, separate macros to draw items requiring more than one
+% token to represent in \TeX. That is, if a cell of a tableau is to contain the expression $n +
+% 1$, then one must place it into an auxiliary macro. Also, the same command, |\young|, delimits
+% its contents with parentheses |(...)| rather than braces |{...}|.
+%
+% \item The package should make no assumptions about the intentions of the user. In particular,
+% esoteric constructions such as skew tableaux and disconnected tableaux are not in principle any
+% more difficult to draw, and should be no more difficult to write.
+%
+% \item Tableaux should support totally arbitrary decoration. We took this to mean that they
+% should be easily colored; this possibility allows the depiction of tableaux within tableaux, an
+% application which was specifically requested of the author (and was the original reason for
+% writing this package).
+%
+% \item Configuration should be easy and plentiful. The \textsf{young} package has none, while
+% \textsf{youngtab} package uses a strange syntax. Now that \textsf{keyval} is available there is
+% no excuse for not providing a keyword-driven user interface to options controlling all aspects of
+% the appearance of tableaux.
+%
+% \item Interoperability with all the common environments. In particular, since this is a
+% mathematics package, it should work properly in the AMS environments, and since it is an
+% array-based package it should work properly in array environments.
+% \end{itemize}
+%
+% We believe the package achieves all these things. There should be nothing that one would want to
+% do with Young tableaux that cannot be accomplished in the obvious way using the commands given
+% below.
+
+%
+% \section{User commands}
+% \label{s:user commands}
+%
+% We provide three commands for drawing Young tableaux and diagrams. Each one is convenient for
+% slightly different purposes and each supports various operations more or less easily than the
+% others.
+%
+% \subsection{The \texttt{ytableau} environment}
+% \label{ss:the ytableau environment}
+%
+% \DescribeEnv{ytableau}
+% The |ytableau| environment is the core drawing engine for this package. It may be called as
+% follows (similarly to \textsf{young}):
+%
+% \bigskip\noindent
+% \quad |\begin{ytableau}|\oarg{general formatting}
+%
+% \smallskip\noindent
+% \qquad \meta{entry} |&| |*|\parg{color name} \meta{entry} |& ... \\|
+%
+% \smallskip\noindent
+% \qquad |...|
+%
+% \smallskip\noindent
+% \quad |\end{ytableau}|
+%
+% \bigskip\noindent
+% The result is an array of boxes separated by lines of width |0.4pt| (not tunable, and not affected
+% by outside influences), each containing the entries specified in the environment.
+%
+% Each \meta{entry} is typeset in math mode (by default, but text mode is possible) and the entries
+% are horizontally and (mostly) vertically
+% centered in their box. In fact, the entries are treated as though they consist of a single line
+% of text, and the baselines of all the entries in a row are aligned with each other for a
+% consistent appearance. The environment may appear in or out of math mode without any ill effect
+% (and without any effect on the contents).
+%
+% \DescribeMacro{\none}
+% An entry may be omitted by writing |\none|, which prevents the drawing of a frame but places an
+% invisible box of the correct dimension inside the entry. Thus, one may create a tableau
+% ``starting'' at an offset or even a ``tableau'' consisting of several disconnected regions. One
+% can actually get things into these ``empty'' boxes by passing an optional argument to |\none|.
+%
+% The \meta{color name} can be any color name familiar to the package \textsf{xcolor}, or (of
+% course) user-defined. The background of this box will be drawn in that color; by default, if no
+% color is given the background is \emph{transparent}, which probably means white, unless the
+% tableau is somehow overlaid on something else (see \ref{ss:chaining}).
+%
+% The \meta{general formatting} is simply \TeX\ material which is placed in front of each
+% \meta{entry}. It can also contain a \meta{color name}, which is overridden by those specified
+% individually.
+%
+% \subsection{The \texttt{ytableaushort} command}
+% \label{ss:the ytableaushort command}
+%
+% \DescribeMacro{\ytableaushort}
+% This command (however ironically named) allows inline specification of a tableau:
+%
+% \bigskip\noindent
+% \quad |\ytableaushort| \oarg{general formatting} |{|\meta{line}|,|\meta{line}|,...}|
+%
+% \bigskip\noindent
+% where \meta{general formatting} is as before, and each \meta{line} is a sequence of tokens
+% representing entries in the tableau, similarly to \textsf{youngtab}. However, it is possible to
+% include complex entries by surrounding them in |{...}|. This command internally reduces its
+% functioning to |ytableau|, so the entries may contain colors and in general behave exactly as
+% described above.
+%
+% \subsection{The \texttt{ydiagram} command}
+% \label{ss:the ydiagram command}
+%
+% \DescribeMacro{\ydiagram}
+% This command draws Young diagrams somewhat in the manner of \textsf{youngtab}:
+%
+% \bigskip\noindent
+% \quad |\ydiagram| \oarg{general formatting} |{[|\meta{offset}| +]|\meta{number}|,...}|
+%
+% \bigskip\noindent
+% producing an array of \emph{identical} boxes (empty by default), each row having \meta{number} in
+% it with \meta{offset} blank boxes preceding (\meta{offset} is optional but, when provided, is not
+% written with |[...]|. Thus, a typical invocation might be
+% \begin{center}
+% |\ydiagram{2 + 1, 3, 1}|.
+% \end{center}
+% Both \meta{offset} and \meta{number} may be any
+% \TeX\ expressions evaluating to the textual representation of a number (e.g.\ 6 or
+% |\thecountername|, but not just |\countername|). The boxes can be colored or filled with a single
+% expression by means of \meta{general formatting}.
+%
+% \subsection{Chaining}
+% \label{ss:chaining}
+%
+% The coloring facility for |\ydiagram| is not very interesting as-is. Thus, the package allows for
+% the augmentation of several diagrams in the following manner:
+%
+% \bigskip\noindent
+% \quad |\ydiagram| \meta{arguments} |*| \meta{arguments} |* ...|
+%
+% \bigskip\noindent
+% produces a \emph{single} Young diagram obtained by layering the ones specified by the various
+% \meta{arguments} from left (on top) to right (at the bottom). In fact, one can even write
+%
+% \bigskip\noindent
+% \quad |\ytableaushort| \meta{tableau arguments} |*| \meta{diagram arguments} |* ...|
+%
+% \bigskip\noindent
+% where first a Young tableau is constructed according to the initial set of arguments, then all
+% subsequent arguments are passed to |\ydiagram|, with the result layered from left to right. This
+% allows the construction of arbitrary color patterns with arbitrary contents.
+%
+% This operation is not possible with |\begin{ytableau}...\end{ytableau}| since the
+% |\end| command obscures the following text from the internally-called |\endytableau| command. If
+% you want to chain a |ytableau|, instead write it in the \TeX\ style |\ytableau...\endytableau|.
+% Unfortunately it is not possible to work around this.
+%
+% \section{Package options}
+% The package accepts the following options:
+% \begin{itemize}
+% \item \DescribeMacro{boxsize}
+% |boxsize|=\meta{dimension}. This manually sets the height (and width, which is the same)
+% of boxes in all tableaux to \meta{dimension}. If you change the size and want to get back to
+% the default (1.5em), just say |boxsize = normal|.
+%
+% \item \DescribeMacro{smalltableaux} \DescribeMacro{nosmalltableaux}
+% |smalltableaux|/|nosmalltableaux|. The first option makes the box size quite small;
+% indeed, small enough to fit a |$f$| precisely, as computed by careful eyeballing tests.
+% It also passes |\scriptstyle| to each box, which as usual can be overridden if you wish (but you
+% don't). The second option returns things to how they were.
+%
+% \item \DescribeMacro{aligntableaux} \DescribeMacro{centertableaux}
+% \DescribeMacro{nocentertableaux}
+% |aligntableaux|=\meta{alignment}/|centertableaux|/|nocentertableaux|. The first argument
+% allows any of |top|, |center|, or |bottom|. With |top|, the tableaux are all aligned on the
+% baseline of their top row, with |bottom| they are aligned on the baseline of their bottom row,
+% and |center| centers them (they correspond to |\vtop|, |\vbox|, and |\vcenter|). The other two
+% arguments are semantically pleasing shorthand for |aligntableaux = center| and
+% |aligntableaux = top|.
+%
+% \item \DescribeMacro{textmode} \DescribeMacro{mathmode}
+% |textmode|/|mathmode|. The former sets all the boxes in text mode, and the latter returns
+% to math mode (the default).
+% \end{itemize}
+% It may not be useful to set these options globally, so we provide a macro for changing each of
+% these parameters ``on the fly'':
+%
+% \DescribeMacro{\ytableausetup}
+% Takes all of the above options and acts on them, setting parameters for all subsequent
+% tableaux. The assignments are global with respect to \TeX\ nestings.
+%
+% One can also pass options to \textsf{xcolor} when calling \textsf{ytableau}, but these options
+% are not further configurable through |\ytableausetup|.
+%
+% \section{Samples}
+%
+% Note that the option settings are persistent.
+% \subsection{Standard Young tableaux}
+% \begin{center}
+% \ytableausetup{centertableaux}
+% \begin{ytableau}
+% 1 & 3 & 5 \\
+% 2 & 4 \\
+% 6
+% \end{ytableau}
+% \hfill
+% \begin{minipage}{0.5\textwidth}
+% \begin{verbatim}
+% \ytableausetup{centertableaux}
+% \begin{ytableau}
+% 1 & 3 & 5 \\
+% 2 & 4 \\
+% 6
+% \end{ytableau}
+% \end{verbatim}
+% \end{minipage}
+% \end{center}
+%
+% \begin{center}
+% \ytableausetup{textmode}
+% \ytableaushort{ace,bd,f}
+% \hfill
+% \begin{minipage}{0.5\textwidth}
+% \begin{verbatim}
+% \ytableausetup{textmode}
+% \ytableaushort{ace,bd,f}
+% \end{verbatim}
+% \end{minipage}
+% \end{center}
+%
+% \begin{center}
+% \ytableausetup
+% {mathmode, boxsize=2em}
+% \begin{ytableau}
+% 1 & 2 & 3 & \none[\dots] & \scriptstyle 2n-1 & 2n \\
+% 2 & 3 & 4 & \none[\dots] & 2n \\
+% \none[\vdots] & \none[\vdots] & \none[\vdots] \\
+% \scriptstyle 2n - 1 & 2n \\
+% 2n
+% \end{ytableau}
+% \hfill
+% \begin{minipage}{0.5\textwidth}
+% \begin{verbatim}
+% \ytableausetup
+% {mathmode, boxsize=2em}
+% \begin{ytableau}
+% 1 & 2 & 3 & \none[\dots]
+% & \scriptstyle 2n - 1 & 2n \\
+% 2 & 3 & 4 & \none[\dots]
+% & 2n \\
+% \none[\vdots] & \none[\vdots]
+% & \none[\vdots] \\
+% \scriptstyle 2n - 1 & 2n \\
+% 2n
+% \end{ytableau}
+% \end{verbatim}
+% \end{minipage}
+% \end{center}
+%
+% \subsection{Skew tableaux}
+%
+% \begin{center}
+% \ytableausetup{boxsize=normal}
+% \begin{ytableau}
+% \none & \none & 1 & 2 \\
+% \none & 1 & 2 \\
+% 1 & 2 \\
+% 2
+% \end{ytableau}
+% \hfill
+% \begin{minipage}{0.5\textwidth}
+% \begin{verbatim}
+% \ytableausetup{boxsize=normal}
+% \begin{ytableau}
+% \none & \none & 1 & 2 \\
+% \none & 1 & 2 \\
+% 1 & 2 \\
+% 2
+% \end{ytableau}
+% \end{verbatim}
+% \end{minipage}
+% \end{center}
+%
+% \begin{center}
+% \ytableausetup{smalltableaux}
+% \ytableaushort{
+% \none\none 12,
+% \none 12,
+% 12,
+% 2}
+% \hfill
+% \begin{minipage}{0.5\textwidth}
+% \begin{verbatim}
+% \ytableausetup{smalltableaux}
+% \ytableaushort{
+% \none\none 12,
+% \none 12, 12, 2}
+% \end{verbatim}
+% \end{minipage}
+% \end{center}
+%
+% \begin{center}
+% \ydiagram{2+2,1+2,2,1}
+% \hfill
+% \begin{minipage}{0.5\textwidth}
+% \begin{verbatim}
+% \ydiagram{2+2,1+2,2,1}
+% \end{verbatim}
+% \end{minipage}
+% \end{center}
+%
+% \subsection{Color and chaining}
+%
+% \begin{center}
+% \ytableausetup{nosmalltableaux}
+% \begin{ytableau}
+% *(red) 1 & *(red) 3 & *(red) 5 \\
+% *(blue) 2 & *(blue) 4 \\
+% *(blue) 6
+% \end{ytableau}
+% \hfill
+% \begin{minipage}{0.5\textwidth}
+% \begin{verbatim}
+% \ytableausetup{nosmalltableaux}
+% \begin{ytableau}
+% *(red) 1& *(red) 3 &*(red) 5 \\
+% *(blue) 2 & *(blue) 4 \\
+% *(blue) 6
+% \end{ytableau}
+% \end{verbatim}
+% \end{minipage}
+% \end{center}
+%
+% \begin{center}
+% \ytableaushort[*(green) x_]
+% {135,{*(white)2}4,6}
+% \hfill
+% \begin{minipage}{0.5\textwidth}
+% \begin{verbatim}
+% \ytableaushort[*(green) x_]
+% {135,{*(white)2}4,6}
+% \end{verbatim}
+% \end{minipage}
+% \end{center}
+%
+% \begin{center}
+% \begin{minipage}{0.4\textwidth}
+% \begin{multline}
+% \ytableausetup{boxsize=1.25em}
+% \ytableausetup
+% {aligntableaux=top}
+% \ytableaushort[x_]{135,24,6}
+% + \ydiagram[*(red) ]{3} \\
+% + \ydiagram[*(blue)]{3,2,1}
+% = \ytableaushort[x_]{135,24,6}
+% *[*(red)]{3} *[*(blue)]{3,2,1}
+% \end{multline}
+% \end{minipage}
+% \hfill
+% \begin{minipage}{0.5\textwidth}
+% \begin{verbatim}
+% \begin{multline}
+% \ytableausetup
+% {boxsize=1.25em}
+% \ytableausetup
+% {aligntableaux=top}
+% \ytableaushort[x_]{135,24,6}
+% + \ydiagram[*(red) ]{3} \\
+% + \ydiagram[*(blue)]{3,2,1}
+% = \ytableaushort[x_]{135,24,6}
+% *[*(red)]{3} *[*(blue)]{3,2,1}
+% \end{multline}
+% \end{verbatim}
+% \end{minipage}
+% \end{center}
+%
+% \begin{center}
+% \ytableausetup{centertableaux}
+% \ytableaushort
+% {\none,\none ab, \none c}
+% * {4,3,2,1}
+% * [*(yellow)]{4,1,1,1}
+% \hfill
+% \begin{minipage}{0.5\textwidth}
+% \begin{verbatim}
+% \ytableausetup{centertableaux}
+% \ytableaushort
+% {\none,\none ab,\none c}
+% * [*(yellow)]{4,3,2,1}
+% * {4,1,1,1}
+% \end{verbatim}
+% \end{minipage}
+% \end{center}
+%
+% \begin{center}
+% \ydiagram[*(white) \bullet]
+% {3+2,3+1,2,2}
+% *[*(green)]{5,4,3,2,1}
+% \hfill
+% \begin{minipage}{0.5\textwidth}
+% \begin{verbatim}
+% \ydiagram[*(white) \bullet]
+% {3+2,3+1,2,2}
+% *[*(green)]{5,4,3,2,1}
+% \end{verbatim}
+% \end{minipage}
+% \end{center}
+%
+% \StopEventually{}
+%
+% \section{The Code}
+%
+% \subsection{Global defintions}
+%
+% Here are all the registers set and ``variables'' used.
+%
+% \subsubsection{Box registers}
+%
+% \begin{macro}{\ytableau@tableaux}
+% When chaining, collects the successive tableaux.
+% \begin{macro}{\ytableau@thistableau}
+% When chaining, stores the present tableaux in the chain.
+% \\
+% Used in |\endytableau|.
+% \begin{macrocode}
+\newbox\ytableau@tableaux
+\newbox\ytableau@thistableau
+% \end{macrocode}
+% \end{macro}
+% \end{macro}
+%
+% \begin{macro}{\ytableau@thisbox}
+% Stores the box currently being constructed.
+% Used in |\ytableau@@startbox| and |\ytableau@endbox|.
+% \begin{macrocode}
+\newbox\ytableau@thisbox
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\ytableau@tmpboxa}
+% \begin{macro}{\ytableau@tmpboxb}
+% Boxes to hold our reference-height and reference-depth letters.
+% Is |$b$| the tallest and |$g$| the deepest? Used in |\ytableau@@endbox|.
+% \begin{macrocode}
+\newbox\ytableau@tmpboxa\newbox\ytableau@tmpboxb
+\setbox\ytableau@tmpboxa=\hbox{$b$}
+\setbox\ytableau@tmpboxb=\hbox{$g$}
+% \end{macrocode}
+% \end{macro}
+% \end{macro}
+%
+% \subsubsection{Token registers}
+%
+% \begin{macro}{\ytableau@toks}
+% Accumulates what will be put in the |ytableau| environment.
+% Used in |\ydiagram|, |\ytableau@diagram@getentries|,
+% |\ytableau@@getentries|, |\ytableau@loop|, \& |\ytableaushort|.
+% \begin{macrocode}
+\newtoks\ytableau@toks
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\ytableau@opttoksa}
+% \begin{macro}{\ytableau@opttoksb}
+% Store the optional arguments (minus color specifications) when processing each entry of the
+% tableau. Also used as temporary token registers.
+% Used in |\ytableau@startbox|, |\ytableau@getline|.
+% \begin{macrocode}
+\newtoks\ytableau@opttoksa
+\newtoks\ytableau@opttoksb
+% \end{macrocode}
+% \end{macro}
+% \end{macro}
+%
+% \subsubsection{Dimension registers}
+%
+% \begin{macro}{\ytableau@boxdim@normal}
+% \begin{macro}{\ytableau@boxdim@save}
+% Respectively, these record the |normal| size of a box in a tableau for use in option |boxsize|,
+% and the previously used size when using the option pair |smalltableaux|, |nosmalltableaux|.
+% Used in options |boxsize|, |smalltableaux|, |nosmalltableaux|.
+% \begin{macrocode}
+\newdimen\ytableau@boxdim@normal
+ \ytableau@boxdim@normal=1.5em
+\newdimen\ytableau@boxdim@save
+ \ytableau@boxdim@save=\ytableau@boxdim@normal
+% \end{macrocode}
+% \end{macro}
+% \end{macro}
+%
+% \begin{macro}{\ytableau@boxdim}
+% The size of the boxes in a tableau.
+% Used in |\none|, |\ytableau@@start|, |\ytableau@end|.
+% \begin{macrocode}
+\newdimen\ytableau@boxdim
+ \ytableau@boxdim=\ytableau@boxdim@normal
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\ytableau@tableauwd}
+% Save the total width of a tableau for supporting the ``chaining'' operation. Used in
+% |\endytableau|.
+% \begin{macrocode}
+\newdimen\ytableau@tableauwd
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\ytableau@boxframe}
+% The width of the frame in a tableau. Used in |\ytableau| and |\endytableau|.
+% \begin{macrocode}
+\newdimen\ytableau@boxframe \ytableau@boxframe=0.4pt
+% \end{macrocode}
+% \end{macro}
+%
+% \subsubsection{Count registers}
+%
+% \begin{macro}{\ytableau@diagram@count}
+% Just a counter for looping.
+% Used in |\ytableau@loop|, |\ytableau@fullexpand|.
+% \begin{macrocode}
+\newcount\ytableau@diagram@count
+% \end{macrocode}
+% \end{macro}
+%
+% \subsubsection{Macros}
+%
+% \begin{macro}{\ytableau@ifstar}
+% Fix a bug with |amsmath| where |\@ifnextchar| (used in |\@ifstar|) doesn't ignore spaces.
+% \begin{macrocode}
+\def\ytableau@ifstar#1{\kernel@ifnextchar *{\@firstoftwo{#1}}}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\ytableau@ignorespaces}
+% Stores the delimiter for text mode or math mode which absorbs spaces around the contents of a box.
+% \begin{macrocode}
+\def\ytableau@ignorespaces{$}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\ytableau@thisboxcolor}
+% Stores the color of the current box in a tableau. The color |clear| is not recognized by
+% |xcolor| but denotes for us a transparent box.
+% Used in |\ytableau@@getcolor| and |\ytableau@endbox|.
+% \begin{macrocode}
+\def\ytableau@thisboxcolor{clear}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\ytableau@centering}
+% What kind of vertical alignment our tableaux will have.
+% Used in |\ytableau| and options |aligntableaux|, |centertableaux|, |nocentertableaux|.
+% \begin{macrocode}
+\def\ytableau@centering{top}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\ytableau@defarg}
+% The ``default optional argument'' which is applied to every tableau before all the others passed
+% by the user. At the moment all it does is support option |smalltableaux|, but perhaps it can be
+% put to greater use?
+% Used in option |smalltableaux|.
+% \begin{macrocode}
+\def\ytableau@defarg{}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\ytableau@tmpa}
+% \begin{macro}{\ytableau@tmpb}
+% Some temporary variables; I probably don't even have to reserve them.
+% Used in |\ytableau@compare|, |\ytableau@compare@|, |\ytableau@fullexpand|.
+% \begin{macrocode}
+\def\ytableau@tmpa{}
+\def\ytableau@tmpb{}
+% \end{macrocode}
+% \end{macro}
+% \end{macro}
+%
+% \begin{macro}{\ytableau@tmpc}
+% Another temp variable, less widely used. Used in |\ytableau@fullexpand|.
+% \begin{macrocode}
+\def\ytableau@tmpc{}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\ytableau@compare}
+% Compares two strings. Neither of them should be hidden in macros; i.e.\ it compares exactly what
+% is given.
+% Used in options |boxsize| and |aligntableaux| as well as in |\ytableau@@getline|,
+% |\ytableau@@getentries|, |\ytableau@loop|, and |\ytableau@diagram@getentries|.
+% \begin{macro}{\ytableau@compare@}
+% Compares two strings, where the first is hidden in one layer of macros. Used in |\endytableau|,
+% |\ytableau@fcolorbox|.
+% \begin{macro}{\if@ytableau@eq}
+% Tests the result of |\ytableau@compare(@)|.
+% \begin{macrocode}
+\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
+% \end{macrocode}
+% \end{macro}
+% \end{macro}
+% \end{macro}
+%
+% \subsection{Options}
+%
+% We include |xkeyval| to support various options.
+% \begin{macrocode}
+\RequirePackage{xkeyval}
+% \end{macrocode}
+%
+% \begin{macro}{\ytableausetup}
+% The user interface to options once the document is in progress.
+% \begin{macrocode}
+\newcommand{\ytableausetup}[1]{\setkeys[ytableau]{setup}{#1}}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{boxsize}
+% Box size. Takes a dimension or |normal|.
+% \begin{macrocode}
+\define@key[ytableau]{setup}{boxsize}{%
+% \end{macrocode}
+% Make tableaux un-small before changing the box size, even if the user wants to go smaller,
+% because there is also the issue of |\ytableau@defarg| being set, and it is only ever changed in
+% that option.
+% \begin{macrocode}
+ \setkeys[ytableau]{setup}{nosmalltableaux}%
+ \ytableau@compare{#1}{normal}%
+ \if@ytableau@eq%
+ \global\ytableau@boxdim=\ytableau@boxdim@normal%
+ \else%
+ \global\ytableau@boxdim=#1%
+ \fi%
+}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\aligntableaux}
+% Most general alignment option, can be any of |top|, |center|, or |bottom|.
+% \begin{macro}{centertableaux}
+% \begin{macro}{nocentertableaux}
+% |centertableaux| is |aligntableaux = center|, \\
+% |nocentertableaux| is |aligntableaux = top|.
+% \begin{macrocode}
+\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}%
+}
+% \end{macrocode}
+% \end{macro}
+% \end{macro}
+% \end{macro}
+%
+% \begin{macro}{smalltableaux}
+% \begin{macro}{nosmalltableaux}
+% Small tableaux: reduce the box size and the text size.
+% |nosmalltableaux| resets everything to the way it was before |smalltableaux| was passed.
+% \begin{macrocode}
+\define@boolkey[ytableau]{setup}{smalltableaux}[true]{%
+ \ifytableau@setup@smalltableaux%
+% \end{macrocode}
+% This test guards against double-calling this option. Even if the user is not so malicious, this
+% can (does) happen in the \textsf{amsmath} display environments.
+% \begin{macrocode}
+ \ifnum\ytableau@boxdim@save>0%
+ \gdef\ytableau@defarg{\scriptstyle}%
+% \end{macrocode}
+% We use the sign of |\ytableau@boxdim@save| to indicate whether we are ``in'' small tableaux.
+% \begin{macrocode}
+ \global\ytableau@boxdim@save=-\ytableau@boxdim%
+% \end{macrocode}
+% Arrived at by eyeballing. Exactly fits an |$f$|.
+% \begin{macrocode}
+ \global\ytableau@boxdim=.81em%
+ \fi%
+ \else%
+% \end{macrocode}
+% Another guard against double-calling.
+% \begin{macrocode}
+ \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%
+}
+% \end{macrocode}
+% \end{macro}
+% \end{macro}
+%
+% \begin{macro}{textmode}
+% Requests that the boxes in tableaux be typeset in text mode rather than the default math mode.
+% \begin{macro}{mathmode}
+% Inverts |textmode|.
+% \begin{macrocode}
+\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%
+}
+% \end{macrocode}
+% \end{macro}
+% \end{macro}
+%
+% Now the default option, where one can ask \textsf{xcolor} for things.
+% \begin{macrocode}
+\DeclareOptionX*{\PassOptionsToPackage{\CurrentOption}{xcolor}}
+% \end{macrocode}
+%
+% Process the options now. We don't really need to be so specific but it doesn't hurt. Then we
+% load xcolor with the options we may have collected.
+% \begin{macrocode}
+\ProcessOptionsX[ytableau]<setup>[]
+\RequirePackage{xcolor}
+% \end{macrocode}
+%
+% \subsection{\texttt{ytableau} environment}
+%
+% \begin{environment}{ytableau}
+% The core tableau-drawing environment. The first argument, which is optional, is just
+% ``formatting'' pasted on to each entry. The contents are an |\halign|-style array; if an entry
+% begins with |*|\parg{color}, then the background of that box is colored.
+% \begin{macrocode}
+\newenvironment{ytableau}[1][]
+{%
+ \leavevmode%
+% \end{macrocode}
+% The point of this obtuse command is to produce a syntactically balanced pair of braces |{}| which
+% semantically is equivalent to just an open brace |{|. This is required to support tableaux nested
+% inside other alignments because |\halign| does not recognize |\bgroup|...|\egroup| as designating
+% a nesting! (We will use this fact later, actually.) But we can't just write |{| and (in
+% |\endytableau|) |}| either.
+% \begin{macrocode}
+ {\iffalse}\fi%
+ \global\setbox\ytableau@thistableau=\hbox\bgroup$%
+ \m@th%
+ \setlength{\fboxrule}{\ytableau@boxframe}%
+ \setlength{\fboxsep}{0pt}%
+% \end{macrocode}
+% Despite the alignment requirements, we set the tableau top-aligned so that it can be easily
+% chained. This will get fixed before we print it, though.
+% \begin{macrocode}
+ \vtop\bgroup%
+% \end{macrocode}
+% I hate |\cr|, let's use the \LaTeX\ convention.
+% \begin{macrocode}
+ \let\\=\ytableau@cr%
+% \end{macrocode}
+% Lines and columns should abut, accounting for the fact that each entry is framed.
+% \begin{macrocode}
+ \offinterlineskip%
+ \openup-\fboxrule%
+ \tabskip=-\fboxrule%
+% \end{macrocode}
+% Now we begin the |\halign|. Each entry is passed as an argument to our box-building function,
+% but we can't just write something like |\ytableau@box{##}| because of the following complication:
+%
+% When TeX sees |\ytableau@box{|, it absorbs tokens up until the next unmatched |}| without
+% interpreting them and then feeds that to the macro as |#1|. Unfortunately, we would like it to
+% be possible to omit |\\| on the last line (as people are used to this, and Knuth provided for it
+% with |\crcr|). But since |ytableau| is an environment, the ending of |\halign| is hidden in the
+% macro |\endytableau| (or |\end{ytableau}|) which is \emph{not expanded by} |\halign| while
+% reading for |##| in the proposed code.
+%
+% The workaround is to pretend that |##| is not an argument to a macro until we get deep inside
+% |\ytableau@startbox|, where (after some processing) it is fed to an |\hbox| inside math mode.
+% |\hbox| is not really a macro (it's a builtin) and it does interpret its contents as it reads
+% them, and since we have finally set up the desired typesetting environment we can let it read
+% |##| properly. Since we are \emph{still} inside an |\halign|, eventually it will expand
+% |\endytableau| and |##| will terminate properly. Whew.
+% \begin{macrocode}
+ \halign\bgroup&\ytableau@startbox{\ytableau@defarg}{#1}##%
+ \ytableau@endbox\cr%
+}
+{%
+% \end{macrocode}
+% The |\crcr| supports the omission of |\\| in the last row. That's a pretty modest goal for all
+% the work that went into thinking up this crazy scheme.
+% The following delimiters close, respectively, |\halign|, |\ytableau@centering|, |\hbox|, and the
+% |{| which protects the |\halign| in case the tableau finds itself in another alignment.
+% \begin{macrocode}
+ \crcr\egroup%
+ \egroup%
+ $\egroup%
+ \iffalse{\fi}%
+% \end{macrocode}
+% Support for chaining. We allow |\endytableau| to be followed by |*[...]{...}|, which is fed to
+% |\ydiagram| as-is. This only works in the short forms |\ytableaushort| and |\ydiagram|, since in
+% |\end{ytableau}| there is extra code intervening before the following characters and no way to
+% insert things in it.
+% \begin{macrocode}
+ \ifnum\wd\ytableau@thistableau>\wd\ytableau@tableaux%
+ \ytableau@tableauwd=\wd\ytableau@thistableau%
+ \else%
+ \ytableau@tableauwd=\wd\ytableau@tableaux%
+ \fi%
+% \end{macrocode}
+% We have saved the larger width, but now |\ytableau@thistableau| must have width zero so that it
+% can be overlaid with the existing tableaux.
+% \begin{macrocode}
+ \wd\ytableau@thistableau=0pt%
+ \setbox\ytableau@tableaux%
+ =\hbox{\box\ytableau@thistableau\unhbox\ytableau@tableaux}%
+% \end{macrocode}
+% Now we set the width to what it should be.
+% \begin{macrocode}
+ \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%
+% \end{macrocode}
+% The other two alignments are straightforward, but to get |top| requires some work when we are
+% surrounded by \textsf{amsmath}'s |align| or |gather|. For some reason, my boxes didn't work as
+% expected there.
+% \begin{macrocode}
+ \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%
+ }%
+}
+% \end{macrocode}
+% \end{environment}
+%
+% \begin{macro}{\ytableau@cr}
+% Annoying to have to do this, but nested halign chokes when |\cr| appears inside the definition.
+% \begin{macrocode}
+\def\ytableau@cr{\cr}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\none}
+% This one is for omitting entries but leaving their space. We also allow something to be placed
+% in the empty space (e.g.\ |\dots|), but don't allow color (that would defeat the purpose of
+% omitting the box). To support the optional argument without screwing up the |\omit|, we have to
+% go in two steps.
+% \begin{macrocode}
+\def\none{\omit\ytableau@none}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\ytableau@none}
+% This finds the optional argument to |\none| and makes the box itself. We draw an invisible frame
+% by replacing the actual frame with the frame separation. We also use |\ignorespaces| to eat up
+% any spaces that occur after |\none|; in a normal box, they would be chopped in math mode.
+% \begin{macrocode}
+\newcommand{\ytableau@none}[1][]{%
+ \def\ytableau@thisboxcolor{clear}%
+ \setlength{\fboxsep}{\ytableau@boxframe}%
+ \setlength{\fboxrule}{0pt}%
+ \ytableau@@startbox#1\ytableau@endbox%
+ \ignorespaces%
+}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\ytableau@startbox}
+% |#1| = general formatting, |#2| = specific formatting.
+% We want to extract the colors from each and then pass the whole thing on to |\ytableau@@startbox|.
+% \begin{macrocode}
+\def\ytableau@startbox#1#2{%
+% \end{macrocode}
+% We get the colors and then put the rest into temporary token registers.
+% \begin{macrocode}
+ \ytableau@getcolor{\ytableau@save{\ytableau@opttoksa}}#1\@nil%
+ \ytableau@getcolor{\ytableau@save{\ytableau@opttoksb}}#2\@nil%
+% \end{macrocode}
+% Now we get the color from the entry and proceed.
+% \begin{macrocode}
+ \ytableau@getcolor%
+ {\ytableau@@startbox\the\ytableau@opttoksa\the\ytableau@opttoksb}%
+}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\ytableau@save}
+% Stick the following text into the token register in |#1|. Note that we use |\@nil| as an
+% end-marker; it is not actually defined, so hopefully we never expand it!
+% \begin{macrocode}
+\def\ytableau@save#1#2\@nil{#1={#2}}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\ytableau@getcolor}
+% |#1| is pasted in front of what remains after removing the color. Basically, it's a ``do next''.
+% \begin{macrocode}
+\def\ytableau@getcolor#1{\ytableau@ifstar{\ytableau@@getcolor{#1}}{#1}}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\ytableau@@getcolor}
+% Save the (optional) color argument and pass the rest to |\ytableau@@startbox|.
+% \begin{macrocode}
+\def\ytableau@@getcolor#1(#2){%
+ \def\ytableau@thisboxcolor{#2}%
+ #1%
+}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\ytableau@@startbox}
+% Start collecting the current entry into a horizontally-centered hbox, but save the result.
+% \begin{macrocode}
+\def\ytableau@@startbox{%
+% \end{macrocode}
+% Use a |\bgroup|...|\egroup| so as not to introduce nesting that would block |&| or |\cr|.
+% \begin{macrocode}
+ \setbox\ytableau@thisbox=\hbox to \ytableau@boxdim\bgroup%
+ \hss%
+ \ytableau@ignorespaces%
+}
+% \end{macrocode}
+% Since we are now in the intended typesetting context (i.e. an hbox with math mode on)
+% we can let |\halign| expand tokens in the rest of the entry until it finds a |&| or |\cr| (= |\\|)
+% Then we finish the box and set it.
+% \begin{macrocode}
+\def\ytableau@endbox{%
+ \ytableau@ignorespaces%
+ \hss%
+ \egroup%
+% \end{macrocode}
+% We want all the boxes to have a consistent baseline, so we normalize them to the same size.
+% Multiple text lines will be aligned with the baseline of the last line at the center, so this
+% really only works well for single lines of text.
+% \begin{macrocode}
+ \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}%
+ }%
+}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\ytableau@fcolorbox}
+% We need a wrapper around |\fcolorbox| since it produces an opaque box, and sometimes, we want
+% |clear|.
+%
+% |#1| = color, |#2| = contents
+% \begin{macrocode}
+\def\ytableau@fcolorbox#1#2{%
+ \ytableau@compare@{#1}{clear}%
+ \if@ytableau@eq%
+% \end{macrocode}
+% Clear background; don't draw anything.
+% \begin{macrocode}
+ \fbox{#2}%
+ \else%
+% \end{macrocode}
+% Colored background; pass it to |\fcolorbox|.
+% \begin{macrocode}
+ \fcolorbox{.}{#1}{#2}%
+ \fi%
+}
+% \end{macrocode}
+% \end{macro}
+%
+% \subsection{\texttt{ytableaushort} command}
+%
+% \begin{macro}{\ytableaushort}
+% The short form of |ytableau|. It takes a comma-separated list of lines, each one a string of
+% entries given as individual tokens. |{...}| is allowed (and encouraged) for complex entries, and
+% color is possible. All sorts of redundancies in the syntax are allowed.
+% \begin{macrocode}
+\newcommand{\ytableaushort}[2][]{%
+% \end{macrocode}
+% |\endytableau| has to be right at the end, so we can't use scope to reset |\ytableau@toks|.
+% \begin{macrocode}
+ \ytableau@toks={}%
+ \ytableau@getentries{\ytableau@@getentries}{}#2,\@nil%
+ \ytableau[#1]\the\ytableau@toks\endytableau%
+}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\ytableau@getentries}
+% Split the CSV into rows. This is really a job for |etoolbox:\docsvlist| but whatever.
+% We put a |.| in front of the string so that a line may be enclosed entirely in |{...}|
+% Otherwise, |\def\cs#1,{etc}| would make |#1| = |...| and not |#1| = |{...}| as we want.
+% \begin{macrocode}
+\def\ytableau@getentries#1#2{\ytableau@getline{#1}{#2}.}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\ytableau@getline}
+% Grab the first \meta{line}|,| in the string and remove the initial |.|
+% \begin{macrocode}
+\def\ytableau@getline#1#2#3,{%
+ \ytableau@opttoksa=\expandafter{\@gobble#3}%
+ \ytableau@opttoksb={\ytableau@@getline{#1}{#2}}%
+% \end{macrocode}
+% We pass |#3| back as an \emph{argument} to |\ytableau@@getline|, thus avoiding the braces issue.
+% \begin{macrocode}
+ \edef\ytableau@next{\the\ytableau@opttoksb{\the\ytableau@opttoksa}}%
+ \ytableau@next%
+}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\ytableau@@getline}
+% |#1| = the macro to process each row,
+% |#2| = the junk to put after each row (followed by |\@nil|),
+% |#3| = everything before the first comma,
+% |#4| = the token after the first comma (possibly another comma).
+% \begin{macrocode}
+\def\ytableau@@getline#1#2#3#4{%
+% \end{macrocode}
+% Handle double commas or trailing commas.
+% \begin{macrocode}
+ \ytableau@compare{#4}{,}%
+ \if@ytableau@eq%
+% \end{macrocode}
+% Try again.
+% \begin{macrocode}
+ \def\ytableau@next{\ytableau@@getline{#1}{#2}{#3}}%
+ \else%
+% \end{macrocode}
+% If this is not the last row, we have to recurse down the list. Otherwise, just process the
+% current row.
+% \begin{macrocode}
+ \ytableau@compare{#4}{\@nil}%
+ \if@ytableau@eq%
+ \def\ytableau@next{#1#3#2\@nil}%
+ \else%
+% \end{macrocode}
+% |#4| is a single token, so it should be replaced as one. Note that this adds braces; we will
+% have to correct for this all the way down in |\ytableau@fullexpand| when we don't want them.
+% \begin{macrocode}
+ \def\ytableau@next{#1#3#2\@nil\ytableau@getentries{#1}{#2}{#4}}%
+ \fi%
+ \fi%
+ \ytableau@next%
+}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\ytableau@@getentries}
+% Separates the entries in a line of |\ytableaushort| and reformats them for |\ytableau|.
+% Takes two tokens and checks if the second is |\@nil|, which means the first is the last entry.
+% \begin{macrocode}
+\def\ytableau@@getentries#1#2{%
+% \end{macrocode}
+% If this is not the last entry, we have to recurse down the line. Otherwise, we just print |\\|.
+% \begin{macrocode}
+ \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%
+}
+% \end{macrocode}
+% \end{macro}
+%
+% \subsection{\texttt{ydiagram} commmand}
+%
+% \begin{macro}{\ydiagram}
+% Takes the same optional argument as the other macros. Its main argument |#2| is of the form
+% \\
+% \indent[\meta{offset} + ]\meta{number}, ...
+% \\
+% where both \meta{offset} and \meta{number} may be any expression evaluating to a textual number
+% (e.g.\ |\the\count|\meta{n} rather than |\count|\meta{n}).
+% \begin{macrocode}
+\newcommand\ydiagram[2][]{%
+% \end{macrocode}
+% We need |\endytableau| to be right at the end, so we can't use scope to reset |\ytableau@toks|.
+% \begin{macrocode}
+ \ytableau@toks={}%
+ \ytableau@getentries{\ytableau@diagram@getentries}{+}#2,\@nil%
+ \ytableau[#1]\the\ytableau@toks\endytableau%
+}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\ytableau@diagram@getentries}
+% Separates the entries in a line of |\ydiagram| and reformats them for |\ytableau|.
+% \begin{macrocode}
+\def\ytableau@diagram@getentries#1+#2\@nil{%
+% \end{macrocode}
+% If |#2| = |{}|, then there is no offset and |#1| is the row shape.
+% \begin{macrocode}
+ \ytableau@compare{#2}{}%
+ \if@ytableau@eq%
+ \def\ytableau@next{%
+ \ytableau@loop{#1}{}%
+ }%
+% \end{macrocode}
+% Else |#1| is the offset and |#2| is the shape.
+% \begin{macrocode}
+ \else%
+ \def\ytableau@next{%
+ \ytableau@loop{#1}{\none}%
+% \end{macrocode}
+% Now |#2| looks like \meta{number}|+|, so we feed it back in.
+% \begin{macrocode}
+ \ytableau@diagram@getentries#2\@nil%
+ }%
+ \fi%
+ \ytableau@next%
+}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\ytableau@loop}
+% Loops on the first argument, building a |\ytableau| line whose entries are the second argument.
+% The results go in |\ytableau@toks|.
+% \begin{macrocode}
+\def\ytableau@loop#1#2{%
+% \end{macrocode}
+% Fills |\ytableau@diagram@count|.
+% \begin{macrocode}
+ \ytableau@fullexpand{#1}%
+ \loop\ifnum\ytableau@diagram@count>1%
+ \ytableau@toks=\expandafter{\the\ytableau@toks#2&}%
+ \advance\ytableau@diagram@count by -1%
+ \repeat%
+% \end{macrocode}
+% The last entry in the list may not be the last entry in the line. If it's empty, it is (according
+% to our usage), otherwise not.
+% \begin{macrocode}
+ \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%
+}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\ytableau@fullexpand}
+% Fully expand its argument. Hopefully you passed an argument for which that makes sense.
+% This also strips braces.
+% \begin{macrocode}
+\def\ytableau@fullexpand#1{%
+% \end{macrocode}
+% TeX's brace parser will strip the braces for us.
+% \begin{macrocode}
+ \def\ytableau@tmpa##1{##1}%
+% \end{macrocode}
+% Turns e.g.\ both |#1| = |{23}| and |#1| = |23| into |23|.
+% As a side effect, e.g.\ if |#1| = |{2}3|, the result is |23|.
+% However, |#1| = |2{3}| stays that way, so is probably an error.
+% \begin{macrocode}
+ \edef\ytableau@tmpb{\ytableau@tmpa#1}%
+ \edef\ytableau@tmpc{\ytableau@tmpb}%
+ \ytableau@diagram@count=\ytableau@tmpc%
+}
+% \end{macrocode}
+% \end{macro}
+%
+% \Finale \ No newline at end of file
diff --git a/Master/texmf-dist/source/latex/ytableau/ytableau.ins b/Master/texmf-dist/source/latex/ytableau/ytableau.ins
new file mode 100644
index 00000000000..42ec297c3bf
--- /dev/null
+++ b/Master/texmf-dist/source/latex/ytableau/ytableau.ins
@@ -0,0 +1,56 @@
+%%
+%% 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.
+%%
+
+\input docstrip.tex
+\keepsilent
+
+\usedir{tex/latex/ytableau}
+
+\preamble
+
+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.
+
+\endpreamble
+
+\askforoverwritefalse
+\generate{\file{ytableau.sty}{\from{ytableau.dtx}{package}}}
+
+\obeyspaces
+\Msg{*************************************************************}
+\Msg{* *}
+\Msg{* To finish the installation you have to move the following *}
+\Msg{* file into a directory searched by TeX: *}
+\Msg{* *}
+\Msg{* ytableau.sty *}
+\Msg{* *}
+\Msg{* To produce the documentation run the file ytableau.dtx *}
+\Msg{* through LaTeX. *}
+\Msg{* *}
+\Msg{* Happy TeXing! *}
+\Msg{* *}
+\Msg{*************************************************************}
+
+\endbatchfile