| 1 |
% \iffalse meta-comment |
| 2 |
% |
| 3 |
% Copyright (C) 2010--2012 by Ryan Reich <[email protected]> |
| 4 |
% ------------------------------------------------------- |
| 5 |
% |
| 6 |
% This file may be distributed and/or modified under the |
| 7 |
% conditions of the LaTeX Project Public License, either version 1.2 |
| 8 |
% of this license or (at your option) any later version. |
| 9 |
% The latest version of this license is in: |
| 10 |
% |
| 11 |
% http://www.latex-project.org/lppl.txt |
| 12 |
% |
| 13 |
% and version 1.2 or later is part of all distributions of LaTeX |
| 14 |
% version 1999/12/01 or later. |
| 15 |
% |
| 16 |
% \fi |
| 17 |
% |
| 18 |
% \iffalse |
| 19 |
%<package>\NeedsTeXFormat{LaTeX2e} |
| 20 |
%<package>\ProvidesPackage{ytableau} |
| 21 |
%<package> [2021/06/12 v1.4 Many-featured Young tableaux and Young diagrams] |
| 22 |
% |
| 23 |
%<*driver> |
| 24 |
\documentclass{ltxdoc} |
| 25 |
\usepackage{ytableau,amsmath,microtype,changepage} |
| 26 |
\usepackage[numbered]{hypdoc} |
| 27 |
\hypersetup{colorlinks,linkcolor=blue} |
| 28 |
|
| 29 |
\makeatletter |
| 30 |
\def\DescribeOption{\leavevmode\@bsphack\begingroup\MakePrivateLetters |
| 31 |
\Describe@Option} |
| 32 |
\def\Describe@Option#1{\endgroup |
| 33 |
\marginpar{\raggedleft\PrintDescribeOption{#1}}% |
| 34 |
\SpecialOptionIndex{#1}\@esphack\ignorespaces} |
| 35 |
\let\PrintDescribeOption=\PrintDescribeEnv |
| 36 |
\def\option{\begingroup |
| 37 |
\catcode`\\12 |
| 38 |
\MakePrivateLetters \m@cro@YT} |
| 39 |
\long\def\m@cro@YT#1{\endgroup \topsep\MacroTopsep \trivlist |
| 40 |
\edef\saved@macroname{\string#1}% |
| 41 |
\def\makelabel##1{\llap{##1}}% |
| 42 |
\if@inlabel |
| 43 |
\let\@tempa\@empty \count@\macro@cnt |
| 44 |
\loop \ifnum\count@>\z@ |
| 45 |
\edef\@tempa{\@tempa\hbox{\strut}}\advance\count@\m@ne \repeat |
| 46 |
\edef\makelabel##1{\llap{\vtop to\baselineskip |
| 47 |
{\@tempa\hbox{##1}\vss}}}% |
| 48 |
\advance \macro@cnt \@ne |
| 49 |
\else \macro@cnt\@ne \fi |
| 50 |
\edef\@tempa{\noexpand\item[% |
| 51 |
\noexpand\PrintOptionName |
| 52 |
{\string#1}]}% |
| 53 |
\@tempa |
| 54 |
\global\advance\c@CodelineNo\@ne |
| 55 |
\SpecialMainOptionIndex{#1}\nobreak |
| 56 |
\global\advance\c@CodelineNo\m@ne |
| 57 |
\ignorespaces} |
| 58 |
\let\endoption\endtrivlist |
| 59 |
\let\PrintOptionName=\PrintEnvName |
| 60 |
\newcommand*\SpecialOptionIndex[1]{% |
| 61 |
\@bsphack |
| 62 |
\begingroup |
| 63 |
\HD@target |
| 64 |
\let\HDorg@encapchar\encapchar |
| 65 |
\edef\encapchar usage{% |
| 66 |
\HDorg@encapchar hdclindex{\the\c@HD@hypercount}{usage}% |
| 67 |
}% |
| 68 |
\index{#1\actualchar{\protect\ttfamily#1} (option)\encapchar usage}% |
| 69 |
\index{options:\levelchar#1\actualchar{\protect\ttfamily#1}\encapchar usage}% |
| 70 |
\endgroup |
| 71 |
\@esphack |
| 72 |
} |
| 73 |
\def\SpecialMainOptionIndex#1{\@bsphack\special@index{% |
| 74 |
#1\actualchar |
| 75 |
{\string\ttfamily\space#1} |
| 76 |
(option)% |
| 77 |
\encapchar main}% |
| 78 |
\special@index{options:\levelchar#1\actualchar{% |
| 79 |
\string\ttfamily\space#1}\encapchar |
| 80 |
main}\@esphack} |
| 81 |
\makeatother |
| 82 |
|
| 83 |
\EnableCrossrefs |
| 84 |
\CodelineIndex |
| 85 |
\RecordChanges |
| 86 |
\begin{document} |
| 87 |
\DocInput{ytableau.dtx} |
| 88 |
\newlength{\newleftmargin} |
| 89 |
\setlength{\newleftmargin}{\marginparwidth} |
| 90 |
\addtolength{\newleftmargin}{-0.5in} |
| 91 |
\newpage |
| 92 |
\begin{adjustwidth}{-\newleftmargin}{-0.5in} |
| 93 |
\PrintChanges |
| 94 |
\newpage |
| 95 |
\PrintIndex |
| 96 |
\end{adjustwidth} |
| 97 |
\end{document} |
| 98 |
%</driver> |
| 99 |
% \fi |
| 100 |
% |
| 101 |
% \CheckSum{594} |
| 102 |
% |
| 103 |
% \CharacterTable |
| 104 |
% {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 |
| 105 |
% 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 |
| 106 |
% Digits \0\1\2\3\4\5\6\7\8\9 |
| 107 |
% Exclamation \! Double quote \" Hash (number) \# |
| 108 |
% Dollar \$ Percent \% Ampersand \& |
| 109 |
% Acute accent \' Left paren \( Right paren \) |
| 110 |
% Asterisk \* Plus \+ Comma \, |
| 111 |
% Minus \- Point \. Solidus \/ |
| 112 |
% Colon \: Semicolon \; Less than \< |
| 113 |
% Equals \= Greater than \> Question mark \? |
| 114 |
% Commercial at \@ Left bracket \[ Backslash \\ |
| 115 |
% Right bracket \] Circumflex \^ Underscore \_ |
| 116 |
% Grave accent \` Left brace \{ Vertical bar \| |
| 117 |
% Right brace \} Tilde \~} |
| 118 |
% |
| 119 |
% |
| 120 |
% \changes{v1.0}{2010/11/04}{Initial version} |
| 121 |
% |
| 122 |
% \GetFileInfo{ytableau.sty} |
| 123 |
% |
| 124 |
% \DoNotIndex{\@firstoftwo,\@gobble,\eq@YTfalse,\eq@YTtrue} |
| 125 |
% \DoNotIndex{\advance} |
| 126 |
% \DoNotIndex{\bgroup,\box} |
| 127 |
% \DoNotIndex{\cr,\crcr} |
| 128 |
% \DoNotIndex{\def,\dimexpr,\dp} |
| 129 |
% \DoNotIndex{\edef,\egroup,\else,\everycr,\expandafter} |
| 130 |
% \DoNotIndex{\fbox,\fboxrule,\fboxsep,\fcolorbox,\fi} |
| 131 |
% \DoNotIndex{\gdef,\global} |
| 132 |
% \DoNotIndex{\halign,\hbox,\hss,\ht} |
| 133 |
% \DoNotIndex{\iffalse,\ifnum,\ifx,\ignorespaces} |
| 134 |
% \DoNotIndex{\kern} |
| 135 |
% \DoNotIndex{\leavevmode,\let,\loop} |
| 136 |
% \DoNotIndex{\newbox,\newcommand,\newcount,\newdimen,\newenvironment,\newif,\newtoks} |
| 137 |
% \DoNotIndex{\offinterlineskip,\omit,\openup} |
| 138 |
% \DoNotIndex{\pgfkeys,\pgfkeysalso,\ProcessPgfPackageOptions} |
| 139 |
% \DoNotIndex{\raise,\relax,\repeat} |
| 140 |
% \DoNotIndex{\scriptscriptstyle,\scriptsize,\scriptstyle,\setbox,\setlength} |
| 141 |
% \DoNotIndex{\tabskip,\the} |
| 142 |
% \DoNotIndex{\unexpanded,\unhbox,\unskip} |
| 143 |
% \DoNotIndex{\vbox,\vcenter,\vrule,\vss,\vtop} |
| 144 |
% \DoNotIndex{\wd} |
| 145 |
% \DoNotIndex{\xdef} |
| 146 |
% |
| 147 |
% \title{The \textsf{ytableau} package\thanks{This document describes |
| 148 |
% \textsf{ytableau}~\fileversion, dated~\filedate.}} |
| 149 |
% \author{Ryan Reich\\\texttt{[email protected]}} |
| 150 |
% \date{June 12th, 2021} |
| 151 |
% \maketitle |
| 152 |
% |
| 153 |
% \tableofcontents |
| 154 |
%\pagebreak |
| 155 |
% \noindent \textit{For Greta} |
| 156 |
% |
| 157 |
% \section{Y tableau?} |
| 158 |
% |
| 159 |
% At the time this package was first written, there there existed two packages with which one can |
| 160 |
% draw Young tableaux: \textsf{young} and \textsf{youngtab}. As the latter is explicitly an |
| 161 |
% alternative to the former, they do not overlap very much except in what they eventually produce. |
| 162 |
% Between them, they define the following three basic constructions of Young tableaux: |
| 163 |
% |
| 164 |
% \begin{itemize} |
| 165 |
% \item An environment with array-style syntax; |
| 166 |
% |
| 167 |
% \item A short-form macro; |
| 168 |
% |
| 169 |
% \item An even shorter-form macro for drawing Young diagrams (having nothing inside the boxes). |
| 170 |
% \end{itemize} |
| 171 |
% |
| 172 |
% In this package we also implement these methods. However, we aim to take them as far as possible |
| 173 |
% so that the conceivable needs of a mathematician making serious use of Young tableaux can be met |
| 174 |
% with as little effort as possible on their part (and, thus, great effort on the part of this |
| 175 |
% author). In writing this package we pursued the following major goals: |
| 176 |
% |
| 177 |
% \begin{itemize} |
| 178 |
% \item The syntax should be as convenient as possible. The \textsf{young} package makes |
| 179 |
% unfortunate use of the |\cr| delimiter for lines in an array, which is nowhere to be seen in |
| 180 |
% modern \LaTeX\ and is likely unfamiliar to casual, young writers. The \textsf{youngtab} package |
| 181 |
% requires the author to define individual, separate macros to draw items requiring more than one |
| 182 |
% token to represent in \TeX. That is, if a cell of a tableau is to contain the expression $n + |
| 183 |
% 1$, then one must place it into an auxiliary macro. Also, the same command, |\young|, delimits |
| 184 |
% its contents with parentheses |(...)| rather than braces |{...}|. |
| 185 |
% |
| 186 |
% \item The package should make no assumptions about the intentions of the user. In particular, |
| 187 |
% esoteric constructions such as skew tableaux and disconnected tableaux are not in principle any |
| 188 |
% more difficult to draw, and should be no more difficult to write. |
| 189 |
% |
| 190 |
% \item Tableaux should support totally arbitrary decoration. We took this to mean that they |
| 191 |
% should be easily colored; this possibility allows the depiction of tableaux within tableaux, an |
| 192 |
% application which was specifically requested of the author (and was the original reason for |
| 193 |
% writing this package). |
| 194 |
% |
| 195 |
% \item Configuration should be easy and plentiful. The \textsf{young} package has none, while |
| 196 |
% \textsf{youngtab} package uses a strange syntax. Now that \textsf{keyval} is available there is |
| 197 |
% no excuse for not providing a keyword-driven user interface to options controlling all aspects of |
| 198 |
% the appearance of tableaux. |
| 199 |
% |
| 200 |
% \item Interoperability with all the common environments. In particular, since this is a |
| 201 |
% mathematics package, it should work properly in the AMS environments, and since it is an |
| 202 |
% array-based package it should work properly in array environments. |
| 203 |
% \end{itemize} |
| 204 |
% |
| 205 |
% We believe the package achieves all these things. There should be nothing that one would want to |
| 206 |
% do with Young tableaux that cannot be accomplished in the obvious way using the commands given |
| 207 |
% below. |
| 208 |
% |
| 209 |
% \section*{Requirements} |
| 210 |
% This package is quite self-contained and I have tried to avoid pulling in |
| 211 |
% very large prerequisites. It includes \textsf{pgfkeys}, \textsf{pgfopts}, and |
| 212 |
% \textsf{xcolor}, and specifically requires version 2 (2011/06/02) of |
| 213 |
% \textsf{pgfopts}; this is enforced in the code. |
| 214 |
% |
| 215 |
% \section{User commands} |
| 216 |
% \label{s:user commands} |
| 217 |
% |
| 218 |
% We provide three commands for drawing Young tableaux and diagrams. Each one is convenient for |
| 219 |
% slightly different purposes and each supports various operations more or less easily than the |
| 220 |
% others. |
| 221 |
% |
| 222 |
% \subsection{The \texttt{ytableau} environment} |
| 223 |
% \label{ss:the ytableau environment} |
| 224 |
% |
| 225 |
% \DescribeEnv{ytableau} |
| 226 |
% The |ytableau| environment is the core drawing engine for this package. It may be called as |
| 227 |
% follows (similarly to \textsf{young}): |
| 228 |
% |
| 229 |
% \bigskip\noindent |
| 230 |
% \quad |\begin{ytableau}|\oarg{general formatting} |
| 231 |
% |
| 232 |
% \smallskip\noindent |
| 233 |
% \qquad \meta{entry} |&| |*|\parg{color name} \meta{entry} |& ... \\| |
| 234 |
% |
| 235 |
% \smallskip\noindent |
| 236 |
% \qquad |...| |
| 237 |
% |
| 238 |
% \smallskip\noindent |
| 239 |
% \quad |\end{ytableau}| |
| 240 |
% |
| 241 |
% \bigskip\noindent |
| 242 |
% The result is an array of boxes separated by lines of width |0.4pt| (not tunable, and not affected |
| 243 |
% by outside influences), each containing the entries specified in the environment. |
| 244 |
% |
| 245 |
% Each \meta{entry} is typeset in math mode (by default, but text mode is possible) and the entries |
| 246 |
% are horizontally and (mostly) vertically |
| 247 |
% centered in their box. In fact, the entries are treated as though they consist of a single line |
| 248 |
% of text, and the baselines of all the entries in a row are aligned with each other for a |
| 249 |
% consistent appearance (but see the options). |
| 250 |
|
| 251 |
% The environment may appear in or out of math mode without any ill effect |
| 252 |
% (and without any effect on the contents). However, it \emph{is} affected by the ambient font |
| 253 |
% size: in |\Huge| text the entire tableau is correspondingly Huge, at least as long as you are |
| 254 |
% careful to specify the box size in |em| or |ex| units, rather than invariant ones like |pt|. |
| 255 |
% |
| 256 |
% \DescribeMacro{\none} |
| 257 |
% An entry may be omitted by writing |\none|, which prevents the drawing of a frame but places an |
| 258 |
% invisible box of the correct dimension inside the entry. Thus, one may create a tableau |
| 259 |
% ``starting'' at an offset or even a ``tableau'' consisting of several disconnected regions. One |
| 260 |
% can actually get things into these ``empty'' boxes by passing an optional argument to |\none|. |
| 261 |
% |
| 262 |
% The \meta{color name} can be any color name familiar to the package \textsf{xcolor}, or (of |
| 263 |
% course) user-defined. The background of this box will be drawn in that color; by default, if no |
| 264 |
% color is given the background is \emph{transparent}, which probably means white, unless the |
| 265 |
% tableau is somehow overlaid on something else (see \ref{ss:chaining}). |
| 266 |
% |
| 267 |
% The \meta{general formatting} is simply \TeX\ material which is placed in front of each |
| 268 |
% \meta{entry}. It can also contain a \meta{color name}, which is overridden by those specified |
| 269 |
% individually. |
| 270 |
% |
| 271 |
% \subsection{The \texttt{ytableaushort} command} |
| 272 |
% \label{ss:the ytableaushort command} |
| 273 |
% |
| 274 |
% \DescribeMacro{\ytableaushort} |
| 275 |
% This command (however ironically named) allows inline specification of a tableau: |
| 276 |
% |
| 277 |
% \bigskip\noindent |
| 278 |
% \quad |\ytableaushort| \oarg{general formatting} |{|\meta{line}|,|\meta{line}|,...}| |
| 279 |
% |
| 280 |
% \bigskip\noindent |
| 281 |
% where \meta{general formatting} is as before, and each \meta{line} is a sequence of tokens |
| 282 |
% representing entries in the tableau, similarly to \textsf{youngtab}. However, it is possible to |
| 283 |
% include complex entries by surrounding them in |{...}|. This command internally reduces its |
| 284 |
% functioning to |ytableau|, so the entries may contain colors and in general behave exactly as |
| 285 |
% described above. |
| 286 |
% |
| 287 |
% \subsection{The \texttt{ydiagram} command} |
| 288 |
% \label{ss:the ydiagram command} |
| 289 |
% |
| 290 |
% \DescribeMacro{\ydiagram} |
| 291 |
% This command draws Young diagrams somewhat in the manner of \textsf{youngtab}: |
| 292 |
% |
| 293 |
% \bigskip\noindent |
| 294 |
% \quad |\ydiagram| \oarg{general formatting} |{[|\meta{offset}| +]|\meta{number}|,...}| |
| 295 |
% |
| 296 |
% \bigskip\noindent |
| 297 |
% producing an array of \emph{identical} boxes (empty by default), each row having \meta{number} in |
| 298 |
% it with \meta{offset} blank boxes preceding (\meta{offset} is optional but, when provided, is not |
| 299 |
% written with |[...]|. Thus, a typical invocation might be |
| 300 |
% \begin{center} |
| 301 |
% |\ydiagram{2 + 1, 3, 1}|. |
| 302 |
% \end{center} |
| 303 |
% Both \meta{offset} and \meta{number} may be any |
| 304 |
% \TeX\ expressions evaluating to the textual representation of a number, including zero (e.g.\ 6 or |
| 305 |
% |\thecountername|, but not just |\countername|). The boxes can be colored or filled with a single |
| 306 |
% expression by means of \meta{general formatting}. |
| 307 |
% |
| 308 |
% \subsection{Chaining} |
| 309 |
% \label{ss:chaining} |
| 310 |
% |
| 311 |
% The coloring facility for |\ydiagram| is not very interesting as-is. Thus, the package allows for |
| 312 |
% the augmentation of several diagrams in the following manner: |
| 313 |
% |
| 314 |
% \bigskip\noindent |
| 315 |
% \quad |\ydiagram| \meta{arguments} |*| \meta{arguments} |* ...| |
| 316 |
% |
| 317 |
% \bigskip\noindent |
| 318 |
% produces a \emph{single} Young diagram obtained by layering the ones specified by the various |
| 319 |
% \meta{arguments} from left (on top) to right (at the bottom). In fact, one can even write |
| 320 |
% |
| 321 |
% \bigskip\noindent |
| 322 |
% \quad |\ytableaushort| \meta{tableau arguments} |*| \meta{diagram arguments} |* ...| |
| 323 |
% |
| 324 |
% \bigskip\noindent |
| 325 |
% where first a Young tableau is constructed according to the initial set of arguments, then all |
| 326 |
% subsequent arguments are passed to |\ydiagram|, with the result layered from left to right. This |
| 327 |
% allows the construction of arbitrary color patterns with arbitrary contents. |
| 328 |
% |
| 329 |
% This operation is not possible with |\begin{ytableau}...\end{ytableau}| since the |
| 330 |
% |\end| command obscures the following text from the internally-called |\endytableau| command. If |
| 331 |
% you want to chain a |ytableau|, instead write it in the \TeX\ style |\ytableau...\endytableau|. |
| 332 |
% Unfortunately it is not possible to work around this. |
| 333 |
% |
| 334 |
% \section{Package options} |
| 335 |
% The package accepts the following options: |
| 336 |
% \begin{itemize} |
| 337 |
% \item \DescribeOption{boxsize} |
| 338 |
% |boxsize|=\meta{dimension}. This manually sets the height (and width, which is the same) |
| 339 |
% of boxes in all tableaux to \meta{dimension}. If you change the size and want to get back to |
| 340 |
% the default (1.5em), just say |boxsize = normal|. |
| 341 |
% |
| 342 |
% \item \DescribeOption{boxframe} |
| 343 |
% |boxframe|=\meta{dimension}. Like |boxsize|, but sets the width of the lines of the frame around |
| 344 |
% the boxes of the tableau to \meta{dimension}. If you change the size and want to get back to the |
| 345 |
% default (0.04em) just say |boxframe = normal|. |
| 346 |
% |
| 347 |
% \item \DescribeOption{smalltableaux} \DescribeOption{nosmalltableaux} |
| 348 |
% |smalltableaux|/|nosmalltableaux|. The first option makes the box size quite small; |
| 349 |
% indeed, just small enough to fit a |$($| precisely. It also passes |\scriptstyle| |
| 350 |
% to each box, which as usual can be overridden if you wish (but you |
| 351 |
% don't). The second option returns things to how they were, as do |smalltableaux=false| and |smalltableaux=off|. |
| 352 |
% |
| 353 |
% \item \DescribeOption{aligntableaux} \DescribeOption{centertableaux} |
| 354 |
% \DescribeOption{nocentertableaux} |
| 355 |
% |aligntableaux|=\meta{alignment}/|centertableaux|/|nocentertableaux|. The first argument |
| 356 |
% allows any of |top|, |center|, or |bottom|. With |top|, the tableaux are all aligned on the |
| 357 |
% baseline of their top row, with |bottom| they are aligned on the baseline of their bottom row, |
| 358 |
% and |center| centers them (they correspond to |\vtop|, |\vbox|, and |\vcenter|). The other two |
| 359 |
% arguments are semantically pleasing shorthand for |aligntableaux = center| and |
| 360 |
% |aligntableaux = top|. |
| 361 |
% |
| 362 |
% \item \DescribeOption{textmode} \DescribeOption{mathmode} |
| 363 |
% |textmode|/|mathmode|. The former sets all the boxes in text mode, and the latter returns |
| 364 |
% to math mode (the default). |
| 365 |
% |
| 366 |
% \item \DescribeOption{baseline} \DescribeOption{nobaseline} \DescribeOption{centerboxes} |
| 367 |
% |baseline|/|nobaseline|/|centerboxes|. The former, which is the default, aligns the |
| 368 |
% entries of each box so that they share a common baseline, like normal text (but |
| 369 |
% are otherwise centered). The latter (which are synonyms) center them vertically and |
| 370 |
% independently of each other. Use |nobaseline| for tableaux with numbers, but |baseline| for |
| 371 |
% anything else, particularly anything with some depth. |
| 372 |
|
| 373 |
% \item \DescribeOption{tabloids} \DescribeOption{notabloids} |
| 374 |
% |tabloids|/|notabloids|. The former switches off drawing the vertical edges |
| 375 |
% in a tableau, producing a ``tabloid''; the latter (the default) switches them |
| 376 |
% back on. Syntax such as |tabloids = off| or |tabloids = true| is allowed. |
| 377 |
% \end{itemize} |
| 378 |
% It may not be useful to set these options globally, so we provide a macro for changing each of |
| 379 |
% these parameters ``on the fly'': |
| 380 |
% |
| 381 |
% \DescribeMacro{\ytableausetup} |
| 382 |
% Takes all of the above options and acts on them, setting parameters for all subsequent |
| 383 |
% tableaux. The assignments are global with respect to \TeX\ nestings. |
| 384 |
% |
| 385 |
% \section{Samples} |
| 386 |
% |
| 387 |
% Note that the option settings are persistent. |
| 388 |
% \subsection{Standard Young tableaux} |
| 389 |
% \begin{center} |
| 390 |
% \ytableausetup{centertableaux} |
| 391 |
% \begin{ytableau} |
| 392 |
% a & d & f \\ |
| 393 |
% b & e & g \\ |
| 394 |
% c |
| 395 |
% \end{ytableau} |
| 396 |
% \hfill |
| 397 |
% \begin{minipage}{0.5\textwidth} |
| 398 |
% \begin{verbatim} |
| 399 |
% \ytableausetup{centertableaux} |
| 400 |
% \begin{ytableau} |
| 401 |
% a & d & f \\ |
| 402 |
% b & e & g \\ |
| 403 |
% c |
| 404 |
% \end{ytableau} |
| 405 |
% \end{verbatim} |
| 406 |
% \end{minipage} |
| 407 |
% \end{center} |
| 408 |
% |
| 409 |
% \begin{center} |
| 410 |
% \ytableausetup{textmode, boxframe=0.1em} |
| 411 |
% \begin{ytableau} |
| 412 |
% a & d & f \\ |
| 413 |
% b & e & g \\ |
| 414 |
% c |
| 415 |
% \end{ytableau} |
| 416 |
% \hfill |
| 417 |
% \begin{minipage}{0.5\textwidth} |
| 418 |
% \begin{verbatim} |
| 419 |
% \ytableausetup{textmode, boxframe=0.1em} |
| 420 |
% \begin{ytableau} |
| 421 |
% a & d & f \\ |
| 422 |
% b & e & g \\ |
| 423 |
% c |
| 424 |
% \end{ytableau} |
| 425 |
% \end{verbatim} |
| 426 |
% \end{minipage} |
| 427 |
% \end{center} |
| 428 |
% |
| 429 |
% \begin{center} |
| 430 |
% \ytableausetup |
| 431 |
% {mathmode, boxframe=normal, boxsize=2em} |
| 432 |
% \begin{ytableau} |
| 433 |
% 1 & 2 & 3 & \none[\dots] & \scriptstyle 2n-1 & 2n \\ |
| 434 |
% 2 & 3 & 4 & \none[\dots] & 2n \\ |
| 435 |
% \none[\vdots] & \none[\vdots] & \none[\vdots] \\ |
| 436 |
% \scriptstyle 2n - 1 & 2n \\ |
| 437 |
% 2n |
| 438 |
% \end{ytableau} |
| 439 |
% \hfill |
| 440 |
% \begin{minipage}{0.5\textwidth} |
| 441 |
% \begin{verbatim} |
| 442 |
% \ytableausetup |
| 443 |
% {mathmode, boxframe=normal, boxsize=2em} |
| 444 |
% \begin{ytableau} |
| 445 |
% 1 & 2 & 3 & \none[\dots] |
| 446 |
% & \scriptstyle 2n - 1 & 2n \\ |
| 447 |
% 2 & 3 & 4 & \none[\dots] |
| 448 |
% & 2n \\ |
| 449 |
% \none[\vdots] & \none[\vdots] |
| 450 |
% & \none[\vdots] \\ |
| 451 |
% \scriptstyle 2n - 1 & 2n \\ |
| 452 |
% 2n |
| 453 |
% \end{ytableau} |
| 454 |
% \end{verbatim} |
| 455 |
% \end{minipage} |
| 456 |
% \end{center} |
| 457 |
% |
| 458 |
% \begin{center} |
| 459 |
% \ytableausetup |
| 460 |
% {boxsize=normal,tabloids} |
| 461 |
% \ytableaushort{ |
| 462 |
% 123, 45, 6 |
| 463 |
% } |
| 464 |
% \hfill |
| 465 |
% \ytableaushort{ |
| 466 |
% 1\none3, 45, 6 |
| 467 |
% } |
| 468 |
% \hfill |
| 469 |
% \begin{minipage}{0.5\textwidth} |
| 470 |
% \begin{verbatim} |
| 471 |
% \ytableausetup |
| 472 |
% {boxsize=normal,tabloids} |
| 473 |
% \ytableaushort{ |
| 474 |
% 123, 45, 6 |
| 475 |
% } |
| 476 |
% \hfill |
| 477 |
% \ytableaushort{ |
| 478 |
% \none 23, 45, 6 |
| 479 |
% } |
| 480 |
% \end{verbatim} |
| 481 |
% \end{minipage} |
| 482 |
% \end{center} |
| 483 |
% |
| 484 |
% \subsection{Skew tableaux} |
| 485 |
% |
| 486 |
% \begin{center} |
| 487 |
% \ytableausetup{notabloids} |
| 488 |
% \begin{ytableau} |
| 489 |
% \none & \none & 1 & 2 \\ |
| 490 |
% \none & 1 & 2 \\ |
| 491 |
% 1 & 2 \\ |
| 492 |
% 2 |
| 493 |
% \end{ytableau} |
| 494 |
% \hfill |
| 495 |
% \begin{minipage}{0.5\textwidth} |
| 496 |
% \begin{verbatim} |
| 497 |
% \ytableausetup{notabloids} |
| 498 |
% \begin{ytableau} |
| 499 |
% \none & \none & 1 & 2 \\ |
| 500 |
% \none & 1 & 2 \\ |
| 501 |
% 1 & 2 \\ |
| 502 |
% 2 |
| 503 |
% \end{ytableau} |
| 504 |
% \end{verbatim} |
| 505 |
% \end{minipage} |
| 506 |
% \end{center} |
| 507 |
% |
| 508 |
% \begin{center} |
| 509 |
% \ytableausetup{smalltableaux} |
| 510 |
% \ytableaushort{ |
| 511 |
% \none\none 12, |
| 512 |
% \none 12, |
| 513 |
% 12, |
| 514 |
% 2} |
| 515 |
% \hfill |
| 516 |
% \ytableausetup{nobaseline} |
| 517 |
% \ytableaushort{ |
| 518 |
% \none\none 12, |
| 519 |
% \none 12, |
| 520 |
% 12, |
| 521 |
% 2} |
| 522 |
% \hfill |
| 523 |
% \begin{minipage}{0.5\textwidth} |
| 524 |
% \begin{verbatim} |
| 525 |
% \ytableausetup{smalltableaux} |
| 526 |
% \ytableaushort{ |
| 527 |
% \none\none12,\none12,12,2} |
| 528 |
% \ytableausetup{nobaseline} |
| 529 |
% \ytableaushort{ |
| 530 |
% \none\none12,\none12,12,2} |
| 531 |
% \end{verbatim} |
| 532 |
% \end{minipage} |
| 533 |
% \end{center} |
| 534 |
% |
| 535 |
% \begin{center} |
| 536 |
% \ydiagram{2+2,1+2,2,1} |
| 537 |
% \hfill |
| 538 |
% \ydiagram{2+2,0,0+2,1} |
| 539 |
% \hfill |
| 540 |
% \begin{minipage}{0.5\textwidth} |
| 541 |
% \begin{verbatim} |
| 542 |
% \ydiagram{2+2,1+2,2,1} |
| 543 |
% \ydiagram{2+2,0,0+2,1} |
| 544 |
% \end{verbatim} |
| 545 |
% \end{minipage} |
| 546 |
% \end{center} |
| 547 |
% |
| 548 |
% \subsection{Color and chaining} |
| 549 |
% |
| 550 |
% \begin{center} |
| 551 |
% \ytableausetup{nosmalltableaux,nobaseline} |
| 552 |
% \begin{ytableau} |
| 553 |
% *(red) 1 & *(red) 3 & *(red) 5 \\ |
| 554 |
% *(blue) 2 & *(blue) 4 \\ |
| 555 |
% *(blue) 6 |
| 556 |
% \end{ytableau} |
| 557 |
% \hfill |
| 558 |
% \begin{minipage}{0.5\textwidth} |
| 559 |
% \begin{verbatim} |
| 560 |
% \ytableausetup{nosmalltableaux} |
| 561 |
% \begin{ytableau} |
| 562 |
% *(red) 1& *(red) 3 &*(red) 5 \\ |
| 563 |
% *(blue) 2 & *(blue) 4 \\ |
| 564 |
% *(blue) 6 |
| 565 |
% \end{ytableau} |
| 566 |
% \end{verbatim} |
| 567 |
% \end{minipage} |
| 568 |
% \end{center} |
| 569 |
% |
| 570 |
% \begin{center} |
| 571 |
% \ytableausetup{baseline} |
| 572 |
% \ytableaushort[*(green) x_] |
| 573 |
% {135,{*(white)2}4,6} |
| 574 |
% \hfill |
| 575 |
% {\Large |
| 576 |
% \ytableaushort[*(green) x_] |
| 577 |
% {135,{*(white)2}4,6} |
| 578 |
% } |
| 579 |
% \hfill |
| 580 |
% \begin{minipage}{0.5\textwidth} |
| 581 |
% \begin{verbatim} |
| 582 |
% \ytableausetup{baseline} |
| 583 |
% \ytableaushort[*(green) x_] |
| 584 |
% {135,{*(white)2}4,6} |
| 585 |
% {\Large |
| 586 |
% \ytableaushort[*(green) x_] |
| 587 |
% {135,{*(white)2}4,6} |
| 588 |
% } |
| 589 |
% \end{verbatim} |
| 590 |
% \end{minipage} |
| 591 |
% \end{center} |
| 592 |
% |
| 593 |
% \begin{center} |
| 594 |
% \begin{minipage}{0.4\textwidth} |
| 595 |
% \begin{multline} |
| 596 |
% \ytableausetup{boxsize=1.25em} |
| 597 |
% \ytableausetup |
| 598 |
% {aligntableaux=top} |
| 599 |
% \ytableaushort[x_]{135,24,6} |
| 600 |
% + \ydiagram[*(red) ]{3} \\ |
| 601 |
% + \ydiagram[*(blue)]{3,2,1} |
| 602 |
% = \ytableaushort[x_]{135,24,6} |
| 603 |
% *[*(red)]{3} *[*(blue)]{3,2,1} |
| 604 |
% \end{multline} |
| 605 |
% \end{minipage} |
| 606 |
% \hfill |
| 607 |
% \begin{minipage}{0.5\textwidth} |
| 608 |
% \begin{verbatim} |
| 609 |
% \begin{multline} |
| 610 |
% \ytableausetup |
| 611 |
% {boxsize=1.25em} |
| 612 |
% \ytableausetup |
| 613 |
% {aligntableaux=top} |
| 614 |
% \ytableaushort[x_]{135,24,6} |
| 615 |
% + \ydiagram[*(red) ]{3} \\ |
| 616 |
% + \ydiagram[*(blue)]{3,2,1} |
| 617 |
% = \ytableaushort[x_]{135,24,6} |
| 618 |
% *[*(red)]{3} *[*(blue)]{3,2,1} |
| 619 |
% \end{multline} |
| 620 |
% \end{verbatim} |
| 621 |
% \end{minipage} |
| 622 |
% \end{center} |
| 623 |
% |
| 624 |
% \begin{center} |
| 625 |
% \ytableausetup{centertableaux} |
| 626 |
% \ytableaushort |
| 627 |
% {\none,\none ab, \none c} |
| 628 |
% * {4,3,2,1} |
| 629 |
% * [*(yellow)]{4,1,1,1} |
| 630 |
% \hfill |
| 631 |
% \begin{minipage}{0.5\textwidth} |
| 632 |
% \begin{verbatim} |
| 633 |
% \ytableausetup{centertableaux} |
| 634 |
% \ytableaushort |
| 635 |
% {\none,\none ab, \none c} |
| 636 |
% * {4,3,2,1} |
| 637 |
% * [*(yellow)]{4,1,1,1} |
| 638 |
% \end{verbatim} |
| 639 |
% \end{minipage} |
| 640 |
% \end{center} |
| 641 |
% |
| 642 |
% \begin{center} |
| 643 |
% \ydiagram[*(white) \bullet] |
| 644 |
% {3+2,3+1,2,2} |
| 645 |
% *[*(green)]{5,4,3,2,1} |
| 646 |
% \hfill |
| 647 |
% \begin{minipage}{0.5\textwidth} |
| 648 |
% \begin{verbatim} |
| 649 |
% \ydiagram[*(white) \bullet] |
| 650 |
% {3+2,3+1,2,2} |
| 651 |
% *[*(green)]{5,4,3,2,1} |
| 652 |
% \end{verbatim} |
| 653 |
% \end{minipage} |
| 654 |
% \end{center} |
| 655 |
% |
| 656 |
% \StopEventually{} |
| 657 |
% \newpage |
| 658 |
% \section{The Code} |
| 659 |
% \changes{v1.1}{2011/01/31}{Changed the namespace convention from \texttt{ytableau@...} to \texttt{...@YT} to make the index useful and the macros shorter.} |
| 660 |
% \changes{v1.2}{2012/06/17}{Removed a lot of pointless endline-comments after control sequences and added spaces after numbers.} |
| 661 |
% \changes{v1.2}{2012/06/17}{Fixed a bug where the prevailing font size was ignored or imperfectly obeyed.} |
| 662 |
% \changes{v1.3}{2012/08/14}{Require sufficiently new \textsf{pgfopts} since v.1 breaks.} |
| 663 |
% \changes{v1.4}{2021/06/12}{Added option |boxframe|.} |
| 664 |
% |
| 665 |
% \subsection{Global defintions} |
| 666 |
% |
| 667 |
% Here are all the registers set and ``variables'' used. |
| 668 |
% |
| 669 |
% \subsubsection{Box registers} |
| 670 |
% |
| 671 |
% \begin{macro}{\tableaux@YT} |
| 672 |
% When chaining, collects the successive tableaux. |
| 673 |
% \begin{macro}{\thistableau@YT} |
| 674 |
% When chaining, stores the current tableau in the chain. |
| 675 |
% \\ |
| 676 |
% Used in |\endytableau|. |
| 677 |
% \begin{macrocode} |
| 678 |
\newbox\tableaux@YT |
| 679 |
\newbox\thistableau@YT |
| 680 |
% \end{macrocode} |
| 681 |
% \end{macro} |
| 682 |
% \end{macro} |
| 683 |
% |
| 684 |
% \begin{macro}{\thisbox@YT} |
| 685 |
% \changes{v1.1}{2011/01/31}{Made \texttt{\textbackslash thisbox@YT} an alias for \texttt{\textbackslash thistableau@YT}.} |
| 686 |
% Stores the box currently being constructed. We define it as an alias because it is local to the construction of |\thistableau@YT| and, afterwards, irrelevant. Used in |\startbox@@YT| and |\endbox@YT|. |
| 687 |
% \begin{macrocode} |
| 688 |
\let\thisbox@YT=\thistableau@YT |
| 689 |
% \end{macrocode} |
| 690 |
% \end{macro} |
| 691 |
% |
| 692 |
% \begin{macro}{\refhtdp@YT} |
| 693 |
% \changes{v1.1}{2011/01/31}{Put the reference letters into a single box and renamed it more semantically.} |
| 694 |
% \changes{v1.2}{2012/06/17}{Moved definition to \texttt{\textbackslash ytableau}} |
| 695 |
% Box that holds the reference-height and -depth character, which should be a math-mode parenthesis. This is set in |\ytableau| and used in option |smalltableaux| and in |\endbox@YT|. |
| 696 |
% \begin{macrocode} |
| 697 |
\newbox\refhtdp@YT |
| 698 |
% \end{macrocode} |
| 699 |
% \end{macro} |
| 700 |
% |
| 701 |
% \subsubsection{Token registers} |
| 702 |
% |
| 703 |
% \begin{macro}{\toks@YT} |
| 704 |
% Accumulates what will be put in the |ytableau| environment. |
| 705 |
% Used in |\ydiagram|, |\getnumbers@YT|, |
| 706 |
% |\getentries@@YT|, |\loop@YT|, and |\ytableaushort|. |
| 707 |
% \begin{macrocode} |
| 708 |
\newtoks\toks@YT |
| 709 |
% \end{macrocode} |
| 710 |
% \end{macro} |
| 711 |
% |
| 712 |
% \begin{macro}{\opttoksa@YT} |
| 713 |
% \begin{macro}{\opttoksb@YT} |
| 714 |
% Store the optional arguments (minus color specifications) when processing each entry of the |
| 715 |
% tableau. Also used as temporary token registers. |
| 716 |
% Used in |\startbox@YT|, |\getline@YT|. |
| 717 |
% \begin{macrocode} |
| 718 |
\newtoks\opttoksa@YT |
| 719 |
\newtoks\opttoksb@YT |
| 720 |
% \end{macrocode} |
| 721 |
% \end{macro} |
| 722 |
% \end{macro} |
| 723 |
% |
| 724 |
% \subsubsection{Dimension registers} |
| 725 |
% |
| 726 |
% \begin{macro}{\boxdim@YT} |
| 727 |
% The size of the boxes in a tableau. |
| 728 |
% Used in |\ytableau|, |\startbox@@YT|, |\endbox@YT|. |
| 729 |
% \begin{macrocode} |
| 730 |
\newdimen\boxdim@YT |
| 731 |
% \end{macrocode} |
| 732 |
% \end{macro} |
| 733 |
% |
| 734 |
% \begin{macro}{\tableauwd@YT} |
| 735 |
% Save the total width of a tableau for supporting the ``chaining'' operation. Used in |
| 736 |
% |\endytableau|. |
| 737 |
% \begin{macrocode} |
| 738 |
\newdimen\tableauwd@YT |
| 739 |
% \end{macrocode} |
| 740 |
% \end{macro} |
| 741 |
% |
| 742 |
% \subsubsection{Count registers} |
| 743 |
% |
| 744 |
% \begin{macro}{\count@YT} |
| 745 |
% Just a counter for looping. |
| 746 |
% Used in |\loop@YT|, |\fullexpand@YT|. |
| 747 |
% \begin{macrocode} |
| 748 |
\newcount\count@YT |
| 749 |
% \end{macrocode} |
| 750 |
% \end{macro} |
| 751 |
% |
| 752 |
% \subsubsection{Macros} |
| 753 |
% |
| 754 |
% \begin{macro}{\ifstar@YT} |
| 755 |
% Fix a bug with |amsmath| where |\@ifnextchar| (used in |\@ifstar|) doesn't ignore spaces. |
| 756 |
% \begin{macrocode} |
| 757 |
\def\ifstar@YT#1{\kernel@ifnextchar *{\@firstoftwo{#1}}} |
| 758 |
% \end{macrocode} |
| 759 |
% \end{macro} |
| 760 |
% |
| 761 |
% \begin{macro}{\expandonce@YT} |
| 762 |
% \changes{v1.2}{2012/06/17}{Added.} |
| 763 |
% This is a substitute for using all of \textsf{etoolbox}. It operates on one token. |
| 764 |
% \begin{macrocode} |
| 765 |
\def\expandonce@YT#1{% |
| 766 |
\expandafter\unexpanded\expandafter{#1}% |
| 767 |
} |
| 768 |
% \end{macrocode} |
| 769 |
% \end{macro} |
| 770 |
% |
| 771 |
% \begin{macro}{\nil@YT} |
| 772 |
% \changes{v1.2}{2012/06/17}{Added.} |
| 773 |
% A useful marker; it is equal to itself both as text and as a macro. |
| 774 |
% \begin{macrocode} |
| 775 |
\def\nil@YT{\nil@YT} |
| 776 |
% \end{macrocode} |
| 777 |
% \end{macro} |
| 778 |
% |
| 779 |
% \begin{macro}{\boxframe@YT} |
| 780 |
% \changes{v1.2}{2012/06/17}{Made a macro.} |
| 781 |
% \begin{macro}{\boxframe@normal@YT} |
| 782 |
% \changes{v1.4}{2021/06/12}{Added.} |
| 783 |
% The font-independent "normal" width of the frame in a tableau. Used in option |boxframe|. |
| 784 |
% \begin{macrocode} |
| 785 |
\def\boxframe@normal@YT{0.04em} |
| 786 |
\edef\boxframe@YT{\boxframe@normal@YT} |
| 787 |
% \end{macrocode} |
| 788 |
% \end{macro} |
| 789 |
% \end{macro} |
| 790 |
% |
| 791 |
% \begin{macro}{\boxdim@normal@YT} |
| 792 |
% \changes{v1.2}{2012/06/17}{Made a macro.} |
| 793 |
% \begin{macro}{\boxdim@save@YT} |
| 794 |
% \changes{v1.2}{2012/06/17}{Made a macro.} |
| 795 |
% Respectively, the font-independent "normal" box size and the previously used size when using the option pair |smalltableaux|, |nosmalltableaux|. |
| 796 |
% Used in options |boxsize|, |smalltableaux|, |nosmalltableaux|. |
| 797 |
% \begin{macrocode} |
| 798 |
\def\boxdim@normal@YT{1.5em} |
| 799 |
\let\boxdim@save@YT = \boxdim@normal@YT |
| 800 |
% \end{macrocode} |
| 801 |
% \end{macro} |
| 802 |
% \end{macro} |
| 803 |
% |
| 804 |
% \begin{macro}{\macro@boxdim@YT} |
| 805 |
% \changes{v1.2}{2012/06/17}{Added.} |
| 806 |
% The font-independent dimension of a tableau box. Sometimes is a |\dimexpr|. Used in options |boxsize|, |smalltableaux|, |nosmalltableaux|, and in |\ytableau|. |
| 807 |
% \begin{macrocode} |
| 808 |
\edef\macro@boxdim@YT{\boxdim@normal@YT} |
| 809 |
% \end{macrocode} |
| 810 |
% \end{macro} |
| 811 |
% \begin{macro}{\hrule@normal@YT} |
| 812 |
% \begin{macro}{\vrule@normal@YT} |
| 813 |
% |\hrule| and |\vrule| for drawing the frames around tableau cells. The |
| 814 |
% vertical ones are a little shorter to produce a small overlap that eliminates |
| 815 |
% gaps at the corners without producing anti-gaps in the hinting at the edges. |
| 816 |
% I am basically copying the idea from \textsf{xcolor}'s |\boxframe|. |
| 817 |
% \begin{macrocode} |
| 818 |
\def\hrule@normal@YT{% |
| 819 |
\hrule width \dimexpr \boxdim@YT + \fboxrule * 2\relax |
| 820 |
height \fboxrule |
| 821 |
} |
| 822 |
\def\vrule@normal@YT{% |
| 823 |
\vrule height \dimexpr \boxdim@YT + \fboxrule\relax |
| 824 |
width \fboxrule |
| 825 |
} |
| 826 |
% \end{macrocode} |
| 827 |
% \end{macro} |
| 828 |
% \end{macro} |
| 829 |
% \begin{macro}{\hrule@none@YT} |
| 830 |
% \begin{macro}{\vrule@none@YT} |
| 831 |
% Fake rules for |\none| to give the correct spacing. |
| 832 |
% \begin{macrocode} |
| 833 |
\def\hrule@none@YT{\kern\fboxrule} |
| 834 |
\def\vrule@none@YT{% |
| 835 |
\vrule width 0pt |
| 836 |
height \dimexpr \boxdim@YT + \fboxrule\relax |
| 837 |
\kern\fboxrule |
| 838 |
} |
| 839 |
% \end{macrocode} |
| 840 |
% \end{macro} |
| 841 |
% \end{macro} |
| 842 |
% |
| 843 |
% \begin{macro}{\font@YT} |
| 844 |
% \changes{v1.2}{2012/06/17}{Changed name from \texttt{\textbackslash defarg@YT}.} |
| 845 |
% This is the font style of everything in a tableau box. By default, it is normal. |
| 846 |
% Used in option |smalltableaux|. |
| 847 |
% \begin{macrocode} |
| 848 |
\def\font@YT{} |
| 849 |
% \end{macrocode} |
| 850 |
% \end{macro} |
| 851 |
% |
| 852 |
% \begin{macro}{\skipin@YT} |
| 853 |
% \begin{macro}{\skipout@YT} |
| 854 |
% \changes{v1.1}{2011/01/31}{Split up the ``skip in'' and ``skip out'' macros.} |
| 855 |
% Stores the delimiter for text mode or math mode which absorbs spaces around the contents of a box. |
| 856 |
% \begin{macro}{\smallfont@YT} |
| 857 |
% \changes{v1.2}{2012/06/17}{Added.} |
| 858 |
% The font style for the |smalltableaux| option. It depends on math or text mode. |
| 859 |
% \begin{macro}{\set@mathmode@YT} |
| 860 |
% \changes{v1.2}{2012/06/17}{Added.} |
| 861 |
% This sets up the tableau boxes to typeset in math mode. |
| 862 |
% \begin{macrocode} |
| 863 |
\def\set@mathmode@YT{% |
| 864 |
\gdef\skipin@YT{$}% |
| 865 |
\gdef\skipout@YT{$}% |
| 866 |
\def\smallfont@YT{\scriptstyle}% |
| 867 |
} |
| 868 |
% \end{macrocode} |
| 869 |
% \end{macro} |
| 870 |
% \begin{macro}{\set@textmode@YT} |
| 871 |
% \changes{v1.2}{2012/06/17}{Added.} |
| 872 |
% This sets up the tableau boxes to typset in text mode. |
| 873 |
% In text mode, the |skipout| macro has to |\unskip| prior spaces, while the |skipin| macro has to ignore following ones. |
| 874 |
% \begin{macrocode} |
| 875 |
\def\set@textmode@YT{% |
| 876 |
\gdef\skipin@YT{\ignorespaces}% |
| 877 |
\gdef\skipout@YT{\unskip}% |
| 878 |
\def\smallfont@YT{\scriptsize}% |
| 879 |
} |
| 880 |
% \end{macrocode} |
| 881 |
% \end{macro} |
| 882 |
% \end{macro} |
| 883 |
% \end{macro} |
| 884 |
% \end{macro} |
| 885 |
% The default is math mode. |
| 886 |
% \begin{macrocode} |
| 887 |
\set@mathmode@YT |
| 888 |
% \end{macrocode} |
| 889 |
% |
| 890 |
% \begin{macro}{\thisboxcolor@YT} |
| 891 |
% Stores the color of the current box in a tableau. The color |clear| is not recognized by |
| 892 |
% |xcolor| but denotes for us a transparent box. |
| 893 |
% Used in |\getcolor@@YT| and |\endbox@YT|. |
| 894 |
% \begin{macrocode} |
| 895 |
\def\thisboxcolor@YT{clear} |
| 896 |
% \end{macrocode} |
| 897 |
% \end{macro} |
| 898 |
% |
| 899 |
% \begin{macro}{\centering@YT} |
| 900 |
% What kind of vertical alignment our tableaux will have. |
| 901 |
% Used in |\ytableau| and options |aligntableaux|, |centertableaux|, |nocentertableaux|. |
| 902 |
% \begin{macrocode} |
| 903 |
\def\centering@YT{top} |
| 904 |
% \end{macrocode} |
| 905 |
% \end{macro} |
| 906 |
% |
| 907 |
% \changes{v1.1}{2011/01/31}{Removed null initializations of temp macros \texttt{\textbackslash tmp(a,b,c)@YT}.} |
| 908 |
% |
| 909 |
% \begin{macro}{\compare@YT} |
| 910 |
% Compares two strings. Neither of them should be hidden in macros; i.e.\ it compares exactly what |
| 911 |
% is given. |
| 912 |
% Used in options |boxsize| and |aligntableaux| as well as in |\getline@@YT|, |
| 913 |
% |\getentries@@YT|, |\loop@YT|, and |\getnumbers@YT|. |
| 914 |
% \begin{macro}{\compare@@YT} |
| 915 |
% Compares two strings, where the first is hidden in one layer of macros. Used in |\endytableau|, |
| 916 |
% |\fcolorbox@YT|. |
| 917 |
% \begin{macro}{\ifeq@YT} |
| 918 |
% Tests the result of |\compare@YT(@)|. |
| 919 |
% \begin{macrocode} |
| 920 |
\def\compare@YT#1#2{% |
| 921 |
\def\tmpa@YT{#1}\def\tmpb@YT{#2}% |
| 922 |
\ifx\tmpa@YT\tmpb@YT |
| 923 |
\global\eq@YTtrue |
| 924 |
\else |
| 925 |
\global\eq@YTfalse |
| 926 |
\fi |
| 927 |
} |
| 928 |
\def\compare@@YT#1#2{% |
| 929 |
\def\tmpb@YT{#2}% |
| 930 |
\ifx#1\tmpb@YT |
| 931 |
\global\eq@YTtrue |
| 932 |
\else |
| 933 |
\global\eq@YTfalse |
| 934 |
\fi |
| 935 |
} |
| 936 |
\newif\ifeq@YT |
| 937 |
% \end{macrocode} |
| 938 |
% \end{macro} |
| 939 |
% \end{macro} |
| 940 |
% \end{macro} |
| 941 |
% |
| 942 |
% \subsection{Options} |
| 943 |
% \changes{v1.2}{2012/06/17}{Added an option \texttt{baseline} to fix an irritating irregularity in some tableaux.} |
| 944 |
% \changes{v1.2}{2012/06/17}{Switched from using \textsf{xkeyval} to \textsf{pgfkeys}.} |
| 945 |
% |
| 946 |
% We include \textsf{pgfkeys} to support various options. |
| 947 |
% \begin{macrocode} |
| 948 |
\RequirePackage{pgfkeys} |
| 949 |
\pgfkeys{/ytableau/options/.is family} |
| 950 |
% \end{macrocode} |
| 951 |
% |
| 952 |
% \begin{macro}{\ytableausetup} |
| 953 |
% The user interface to options once the document is in progress. |
| 954 |
% \end{macro} |
| 955 |
% \begin{macrocode} |
| 956 |
\newcommand{\ytableausetup}[1]{\pgfkeys{/ytableau/options,#1}} |
| 957 |
\pgfkeys{/ytableau/options, |
| 958 |
% \end{macrocode} |
| 959 |
% \begin{option}{boxsize} |
| 960 |
% Box size. Takes a dimension or |normal|. |
| 961 |
% \end{option} |
| 962 |
% \begin{macrocode} |
| 963 |
boxsize/.value required, |
| 964 |
boxsize/.code = {% |
| 965 |
% \end{macrocode} |
| 966 |
% Make tableaux un-small before changing the box size, even if the user wants to go smaller, |
| 967 |
% because there is also the issue of |\font@YT| being set, and it is only ever changed in |
| 968 |
% that option. |
| 969 |
% \begin{macrocode} |
| 970 |
\pgfkeysalso{nosmalltableaux}% |
| 971 |
\compare@YT{#1}{normal}% |
| 972 |
\ifeq@YT |
| 973 |
\xdef\macro@boxdim@YT{\expandonce@YT\boxdim@normal@YT}% |
| 974 |
\else |
| 975 |
\xdef\macro@boxdim@YT{#1}% |
| 976 |
\fi |
| 977 |
} |
| 978 |
} |
| 979 |
\pgfkeys{/ytableau/options, |
| 980 |
% \end{macrocode} |
| 981 |
% \begin{option}{boxframe} |
| 982 |
% \changes{v1.4}{2021/06/12}{Added.} |
| 983 |
% Box frame width. Takes a dimension or |normal|. |
| 984 |
% \end{option} |
| 985 |
% \begin{macrocode} |
| 986 |
boxframe/.value required, |
| 987 |
boxframe/.code = {% |
| 988 |
\compare@YT{#1}{normal}% |
| 989 |
\ifeq@YT |
| 990 |
\xdef\boxframe@YT{\expandonce@YT\boxframe@normal@YT}% |
| 991 |
\else |
| 992 |
\xdef\boxframe@YT{#1}% |
| 993 |
\fi |
| 994 |
} |
| 995 |
} |
| 996 |
\pgfkeys{/ytableau/options, |
| 997 |
% \end{macrocode} |
| 998 |
% \begin{option}{aligntableaux} |
| 999 |
% Most general alignment option, can be any of |top|, |center|, or |bottom|. |
| 1000 |
% \end{option} |
| 1001 |
% \begin{macrocode} |
| 1002 |
aligntableaux/.value required, |
| 1003 |
aligntableaux/.is choice, |
| 1004 |
aligntableaux/top/.code = {\gdef\centering@YT{top}}, |
| 1005 |
aligntableaux/center/.code = {\gdef\centering@YT{center}}, |
| 1006 |
aligntableaux/bottom/.code = {\gdef\centering@YT{bottom}}, |
| 1007 |
% \end{macrocode} |
| 1008 |
% \begin{option}{centertableaux} |
| 1009 |
% |centertableaux| is |aligntableaux = center|. |
| 1010 |
% \end{option} |
| 1011 |
% \begin{macrocode} |
| 1012 |
centertableaux/.value forbidden, |
| 1013 |
centertableaux/.style = {aligntableaux/center}, |
| 1014 |
% \end{macrocode} |
| 1015 |
% \begin{option}{nocentertableaux} |
| 1016 |
% |nocentertableaux| is |aligntableaux = top|. |
| 1017 |
% \end{option} |
| 1018 |
% \begin{macrocode} |
| 1019 |
nocentertableaux/.value forbidden, |
| 1020 |
nocentertableaux/.style = {aligntableaux/top} |
| 1021 |
} |
| 1022 |
% \end{macrocode} |
| 1023 |
% |
| 1024 |
% \changes{v1.2}{2012/06/17}{Fixed a bug in \texttt{textmode} and \texttt{smalltableaux} where \texttt{\textbackslash scriptstyle} was used outside of math mode.} |
| 1025 |
% \begin{macro}{\ifsmalltableaux@YT} |
| 1026 |
% \changes{v1.2}{2012/06/17}{Added.} |
| 1027 |
% This conditional tracks whether we are operating under the option |smalltableaux|. |
| 1028 |
% \end{macro} |
| 1029 |
% \begin{macrocode} |
| 1030 |
\newif\ifsmalltableaux@YT |
| 1031 |
\pgfkeys{/ytableau/options, |
| 1032 |
% \end{macrocode} |
| 1033 |
% \begin{option}{smalltableaux} |
| 1034 |
% Small tableaux: reduce the box size and the text size. |
| 1035 |
% \begin{macrocode} |
| 1036 |
smalltableaux/.default = true, |
| 1037 |
smalltableaux/.is choice, |
| 1038 |
smalltableaux/true/.code = {% |
| 1039 |
% \end{macrocode} |
| 1040 |
% We check whether we are ``in'' small tableaux; this prevents double-calling the option. Even if the user is not so malicious, this can (does) happen in the \textsf{amsmath} display environments. |
| 1041 |
% \begin{macrocode} |
| 1042 |
\ifsmalltableaux@YT\else |
| 1043 |
\global\smalltableaux@YTtrue |
| 1044 |
\gdef\font@YT{\smallfont@YT}% |
| 1045 |
% \end{macrocode} |
| 1046 |
% We expand once here and later so that |\macro@boxdim@YT| can be evaluated lazily. |
| 1047 |
% \begin{macrocode} |
| 1048 |
\xdef\boxdim@save@YT{\expandonce@YT\macro@boxdim@YT}% |
| 1049 |
% \end{macrocode} |
| 1050 |
% This one must be a |\def| rather than an |\edef| because |\refhtdp@YT| is not set until later. |
| 1051 |
% \begin{macrocode} |
| 1052 |
\gdef\macro@boxdim@YT{% |
| 1053 |
\dimexpr \ht\refhtdp@YT + \dp\refhtdp@YT + 0.1em\relax |
| 1054 |
} |
| 1055 |
\fi |
| 1056 |
}, |
| 1057 |
smalltableaux/false/.code = {% |
| 1058 |
\ifsmalltableaux@YT |
| 1059 |
\global\smalltableaux@YTfalse |
| 1060 |
\gdef\font@YT{}% |
| 1061 |
\xdef\macro@boxdim@YT{\expandonce@YT\boxdim@save@YT}% |
| 1062 |
\fi |
| 1063 |
}, |
| 1064 |
smalltableaux/on/.style = {smalltableaux/true}, |
| 1065 |
smalltableaux/off/.style = {smalltableaux/false}, |
| 1066 |
% \end{macrocode} |
| 1067 |
% \end{option} |
| 1068 |
% \begin{option}{nosmalltableaux} |
| 1069 |
% \changes{v1.1}{2011/01/31}{Correctly reassign a positive value to \texttt{\textbackslash boxdim@save@YT} when exiting small tableaux.} |
| 1070 |
% |nosmalltableaux| resets everything to the way it was before |smalltableaux| was passed. |
| 1071 |
% \begin{macrocode} |
| 1072 |
nosmalltableaux/.value forbidden, |
| 1073 |
nosmalltableaux/.style = {smalltableaux/false} |
| 1074 |
% \end{macrocode} |
| 1075 |
% \end{option} |
| 1076 |
% \begin{macrocode} |
| 1077 |
} |
| 1078 |
\pgfkeys{/ytableau/options, |
| 1079 |
% \end{macrocode} |
| 1080 |
% \begin{option}{textmode} |
| 1081 |
% Requests that the boxes in tableaux be typeset in text mode rather than the default math mode. |
| 1082 |
% \begin{macrocode} |
| 1083 |
textmode/.value forbidden, |
| 1084 |
textmode/.code = \set@textmode@YT, |
| 1085 |
% \end{macrocode} |
| 1086 |
% \end{option} |
| 1087 |
% \begin{option}{mathmode} |
| 1088 |
% The inverse of |textmode|. |
| 1089 |
% \end{option} |
| 1090 |
% \begin{macrocode} |
| 1091 |
mathmode/.value forbidden, |
| 1092 |
mathmode/.code = \set@mathmode@YT, |
| 1093 |
} |
| 1094 |
% \end{macrocode} |
| 1095 |
% |
| 1096 |
% \begin{macro}{\ifbaseline@YT} |
| 1097 |
% \changes{v1.2}{2012/06/17}{Added.} |
| 1098 |
% Whether or not to create a baseline in the tableau boxes. |
| 1099 |
% \begin{macrocode} |
| 1100 |
\newif\ifbaseline@YT |
| 1101 |
% \end{macrocode} |
| 1102 |
% \end{macro} |
| 1103 |
% \begin{macrocode} |
| 1104 |
\pgfkeys{/ytableau/options, |
| 1105 |
% \end{macrocode} |
| 1106 |
% \begin{option}{baseline} |
| 1107 |
% \changes{v1.2}{2012/06/17}{Added option.} |
| 1108 |
% Switches whether the cells of the tableau should have their sizes normalized (and thus establish a common baseline in each row). Enabling it (the default) improves the appearance of text and symbols. |
| 1109 |
% \begin{macrocode} |
| 1110 |
baseline/.is if = baseline@YT, |
| 1111 |
baseline/.default = true, |
| 1112 |
% \end{macrocode} |
| 1113 |
% \end{option} |
| 1114 |
% \begin{option}{nobaseline} |
| 1115 |
% \changes{v1.2}{2012/06/17}{Added option.} |
| 1116 |
% Synonymous with |baseline = false|. Improves the appearance of tableaux with numbers in their cells. |
| 1117 |
% \begin{macrocode} |
| 1118 |
nobaseline/.style = {baseline = false}, |
| 1119 |
% \end{macrocode} |
| 1120 |
% \end{option} |
| 1121 |
% \begin{option}{centerboxes} |
| 1122 |
% \changes{v1.2}{2012/06/17}{Added option.} |
| 1123 |
% Synonymous with |baseline = false|. |
| 1124 |
% \end{option} |
| 1125 |
% \begin{macrocode} |
| 1126 |
centerboxes/.style = {baseline = false}, |
| 1127 |
} |
| 1128 |
\pgfkeys{/ytableau/options, |
| 1129 |
% \end{macrocode} |
| 1130 |
% \begin{option}{tabloids} |
| 1131 |
% \changes{v1.3}{2012/08/14}{Added option.} |
| 1132 |
% Causes the vertical lines of a tableau to be omitted. |
| 1133 |
% \end{option} |
| 1134 |
% \begin{macrocode} |
| 1135 |
tabloids/.default = true, |
| 1136 |
tabloids/.is choice, |
| 1137 |
tabloids/true/.code = {% |
| 1138 |
\global\let\vrule@YT=\vrule@none@YT |
| 1139 |
\global\let\hrule@YT=\hrule@normal@YT |
| 1140 |
}, |
| 1141 |
tabloids/false/.code = {% |
| 1142 |
\global\let\vrule@YT=\vrule@normal@YT |
| 1143 |
\global\let\hrule@YT=\hrule@normal@YT |
| 1144 |
}, |
| 1145 |
tabloids/on/.style = {tabloids/true}, |
| 1146 |
tabloids/off/.style = {tabloids/false}, |
| 1147 |
notabloids/.style = {tabloids/false}, |
| 1148 |
} |
| 1149 |
% \end{macrocode} |
| 1150 |
% |
| 1151 |
% \changes{v1.2}{2012/06/17}{No longer pass options to \textsf{xcolor}.} |
| 1152 |
% Process the options now. Then we load \textsf{xcolor}. |
| 1153 |
% \begin{macrocode} |
| 1154 |
\ytableausetup{nosmalltableaux,mathmode,baseline,notabloids} |
| 1155 |
\RequirePackage{pgfopts}[2011/06/02] |
| 1156 |
\ProcessPgfPackageOptions{/ytableau/options} |
| 1157 |
\RequirePackage{xcolor} |
| 1158 |
% \end{macrocode} |
| 1159 |
% |
| 1160 |
% \subsection{\texttt{ytableau} environment} |
| 1161 |
% \changes{v1.2}{2012/06/17}{Fixed a bug where the widths of the outer rules of the tableau were ignored.} |
| 1162 |
% |
| 1163 |
% \begin{environment}{ytableau} |
| 1164 |
% The core tableau-drawing environment. The first argument, which is optional, is just |
| 1165 |
% ``formatting'' pasted on to each entry. The contents are an |\halign|-style array; if an entry |
| 1166 |
% begins with |*|\parg{color}, then the background of that box is colored. |
| 1167 |
% \begin{macrocode} |
| 1168 |
\newenvironment{ytableau}[1][] |
| 1169 |
{% |
| 1170 |
% \end{macrocode} |
| 1171 |
% \changes{v1.1}{2010/11/10}{Removed an unnecessary layer of boxes and moved the fake braces into |
| 1172 |
% the outer layer.} |
| 1173 |
% Despite the alignment requirements, we set the tableau top-aligned so that it can be easily |
| 1174 |
% chained. This will get fixed before we print it, though. |
| 1175 |
% |
| 1176 |
% The point of the mysterious |\iffalse| is to produce a syntactically balanced pair of braces |{}| |
| 1177 |
% which semantically is equivalent to just an open brace |{|. This is required to support tableaux |
| 1178 |
% nested inside other alignments because |\halign| does not recognize |\bgroup|...|\egroup| as |
| 1179 |
% designating a nesting! (We will use this fact later, actually.) But we can't just write |{| and |
| 1180 |
% (in |\endytableau|) |}| either. |
| 1181 |
% \begin{macrocode} |
| 1182 |
\global\setbox\thistableau@YT=\vtop{\iffalse}\fi |
| 1183 |
% \end{macrocode} |
| 1184 |
% \begin{macro}{\none} |
| 1185 |
% \changes{v1.2}{2012/06/17}{Moved definition inside \texttt{\textbackslash ytableau}.} |
| 1186 |
% This one is for omitting entries but leaving their space. We also allow something to be placed |
| 1187 |
% in the empty space (e.g.\ |\dots|), but don't allow color (that would defeat the purpose of |
| 1188 |
% omitting the box). To support the optional argument without screwing up the |\omit|, we have to |
| 1189 |
% go in two steps. |
| 1190 |
% \begin{macrocode} |
| 1191 |
\def\none{\omit\none@YT} |
| 1192 |
% \end{macrocode} |
| 1193 |
% \end{macro} |
| 1194 |
% Now we set all the dimensions that depend on the font. |
| 1195 |
% \changes{v1.2}{2012/06/17}{Use \texttt{(} for \texttt{\textbackslash refhtdp@YT} rather than \texttt{$bg$}.} |
| 1196 |
% \begin{macrocode} |
| 1197 |
\setbox\refhtdp@YT=\hbox{\skipin@YT\font@YT (\skipout@YT}% |
| 1198 |
\boxdim@YT=\macro@boxdim@YT\relax |
| 1199 |
\fboxrule=\boxframe@YT\relax |
| 1200 |
\fboxsep=0pt % |
| 1201 |
% \end{macrocode} |
| 1202 |
% I hate |\cr|, let's use the \LaTeX\ convention. |
| 1203 |
% \begin{macrocode} |
| 1204 |
\let\\=\cr@YT |
| 1205 |
% \end{macrocode} |
| 1206 |
% Lines and columns should abut, accounting for the fact that each entry is framed. The first entry should not have any skip, since the first rule is not doubled. |
| 1207 |
% \begin{macrocode} |
| 1208 |
\tabskip=0pt % |
| 1209 |
\offinterlineskip |
| 1210 |
\openup-\fboxrule |
| 1211 |
% \end{macrocode} |
| 1212 |
% \changes{v1.1}{2010/11/10}{Added the everycr fix.} |
| 1213 |
% We have to make sure |\everycr| is empty or else strange things could happen (like in the |
| 1214 |
% \textsf{amsmath} environment |gather|). Thanks to Harald Hanche-Olsen for telling me about this. |
| 1215 |
% \begin{macrocode} |
| 1216 |
\everycr={}% |
| 1217 |
% \end{macrocode} |
| 1218 |
% Now we begin the |\halign|. Each entry is passed as an argument to our box-building function, |
| 1219 |
% but we can't just write something like |\box@YT{##}| because of the following complication: |
| 1220 |
% |
| 1221 |
% When TeX sees |\box@YT{|, it absorbs tokens up until the next unmatched |}| without |
| 1222 |
% interpreting them and then feeds that to the macro as |#1|. Unfortunately, we would like it to |
| 1223 |
% be possible to omit |\\| on the last line (as people are used to this, and Knuth provided for it |
| 1224 |
% with |\crcr|). But since |ytableau| is an environment, the ending of |\halign| is hidden in the |
| 1225 |
% macro |\endytableau| (or |\end{ytableau}|) which is \emph{not expanded by} |\halign| while |
| 1226 |
% reading for |##| in the proposed code. |
| 1227 |
% |
| 1228 |
% The workaround is to pretend that |##| is not an argument to a macro until we get deep inside |
| 1229 |
% |\startbox@YT|, where (after some processing) it is fed to an |\hbox| inside math mode. |
| 1230 |
% |\hbox| is not really a macro (it's a builtin) and it does interpret its contents as it reads |
| 1231 |
% them, and since we have finally set up the desired typesetting environment we can let it read |
| 1232 |
% |##| properly. Since we are \emph{still} inside an |\halign|, eventually it will expand |
| 1233 |
% |\endytableau| and |##| will terminate properly. Whew. |
| 1234 |
% \begin{macrocode} |
| 1235 |
\halign\bgroup&\tabskip=-\fboxrule |
| 1236 |
\startbox@YT{\font@YT}{#1}##\endbox@YT\cr |
| 1237 |
} |
| 1238 |
{% |
| 1239 |
% \end{macrocode} |
| 1240 |
% The |\crcr| supports the omission of |\\| in the last row. That's a pretty modest goal for all |
| 1241 |
% the work that went into thinking up this crazy scheme. |
| 1242 |
% \begin{macrocode} |
| 1243 |
\crcr\egroup |
| 1244 |
\iffalse{\fi}% |
| 1245 |
% \end{macrocode} |
| 1246 |
% Support for chaining. We allow |\endytableau| to be followed by |*[...]{...}|, which is fed to |
| 1247 |
% |\ydiagram| as-is. This only works in the short forms |\ytableaushort| and |\ydiagram|, since in |
| 1248 |
% |\end{ytableau}| there is extra code intervening before the following characters and no way to |
| 1249 |
% insert things in it. |
| 1250 |
% \changes{v1.1}{2010/11/10}{Save the box width difference rather than the larger width.} |
| 1251 |
% \begin{macrocode} |
| 1252 |
\ifnum\wd\thistableau@YT>\wd\tableaux@YT |
| 1253 |
\tableauwd@YT=\wd\thistableau@YT |
| 1254 |
% \end{macrocode} |
| 1255 |
% This prevents the last rule from being ignored, as it is not doubled. |
| 1256 |
% \begin{macrocode} |
| 1257 |
\advance\tableauwd@YT by \fboxrule |
| 1258 |
\wd\thistableau@YT = \tableauwd@YT |
| 1259 |
\advance\tableauwd@YT by -\wd\tableaux@YT |
| 1260 |
\else |
| 1261 |
\tableauwd@YT = 0pt % |
| 1262 |
\fi |
| 1263 |
% \end{macrocode} |
| 1264 |
% We have saved the larger width, but now |\thistableau@YT| must have width zero so that it |
| 1265 |
% can be overlaid with the existing tableaux. |
| 1266 |
% \changes{v1.1}{2010/11/10}{Replaced explicit setting of the chained box width by a kern.} |
| 1267 |
% \begin{macrocode} |
| 1268 |
\wd\thistableau@YT=0pt % |
| 1269 |
\setbox\tableaux@YT |
| 1270 |
=\hbox{\box\thistableau@YT\unhbox\tableaux@YT |
| 1271 |
\kern\tableauwd@YT}% |
| 1272 |
\ifstar@YT |
| 1273 |
{\ydiagram}% |
| 1274 |
{% |
| 1275 |
% \end{macrocode} |
| 1276 |
% \changes{v1.1}{2010/11/10}{Moved the leavevmode down to the output routine and simplified the alignment computations now that the everycr fix is in.} |
| 1277 |
% We adjust the vertical alignment finally and print the boxes. |\leavevmode| ensures that the |
| 1278 |
% tableau is treated in horizontal mode. You are on your own if you put this inside of another box. |
| 1279 |
% \begin{macrocode} |
| 1280 |
\leavevmode |
| 1281 |
\compare@@YT{\centering@YT}{center}% |
| 1282 |
\ifeq@YT |
| 1283 |
\hbox{$\vcenter{\box\tableaux@YT}$}% |
| 1284 |
\else\compare@@YT{\centering@YT}{bottom}% |
| 1285 |
\ifeq@YT |
| 1286 |
\hbox{\raise\dp\tableaux@YT\box\tableaux@YT}% |
| 1287 |
\fi |
| 1288 |
\box\tableaux@YT |
| 1289 |
\fi |
| 1290 |
}% |
| 1291 |
} |
| 1292 |
% \end{macrocode} |
| 1293 |
% \end{environment} |
| 1294 |
% |
| 1295 |
% \begin{macro}{\cr@YT} |
| 1296 |
% Annoying to have to do this, but nested halign chokes when |\cr| appears inside the definition. |
| 1297 |
% \begin{macrocode} |
| 1298 |
\def\cr@YT{\cr} |
| 1299 |
% \end{macrocode} |
| 1300 |
% \end{macro} |
| 1301 |
% |
| 1302 |
% \changes{v1.2}{2012/06/17}{Fixed a bug in \texttt{\textbackslash none} where text outside the optional argument would be typeset off-grid.} |
| 1303 |
% \begin{macro}{\none@YT} |
| 1304 |
% This finds the optional argument to |\none| and makes the box itself. We draw an invisible frame |
| 1305 |
% by replacing the actual frame with the frame separation. We use |\nullfont| after the box |
| 1306 |
% so as to forbid any "out of alignment" characters, which would appear between columns. |
| 1307 |
% Anything outside of the optional argument is simply ignored to the end of the cell. |
| 1308 |
% \begin{macrocode} |
| 1309 |
\newcommand{\none@YT}[1][]{% |
| 1310 |
\def\thisboxcolor@YT{clear}% |
| 1311 |
\let\hrule@YT=\hrule@none@YT |
| 1312 |
\let\vrule@YT=\vrule@none@YT |
| 1313 |
\startbox@@YT#1\endbox@YT |
| 1314 |
\nullfont |
| 1315 |
} |
| 1316 |
% \end{macrocode} |
| 1317 |
% \end{macro} |
| 1318 |
% |
| 1319 |
% \begin{macro}{\startbox@YT} |
| 1320 |
% |#1| = font style, |#2| = optional material. |
| 1321 |
% We want to extract the colors from each and then pass the whole thing on to |\startbox@@YT|. |
| 1322 |
% \begin{macrocode} |
| 1323 |
\def\startbox@YT#1#2{% |
| 1324 |
% \end{macrocode} |
| 1325 |
% We get the colors and then put the rest into temporary token registers. |
| 1326 |
% \begin{macrocode} |
| 1327 |
\getcolor@YT{\save@YT{\opttoksa@YT}}#1\nil@YT |
| 1328 |
\getcolor@YT{\save@YT{\opttoksb@YT}}#2\nil@YT |
| 1329 |
% \end{macrocode} |
| 1330 |
% Now we get the color from the entry and proceed. |
| 1331 |
% \begin{macrocode} |
| 1332 |
\getcolor@YT |
| 1333 |
{\startbox@@YT\the\opttoksa@YT\the\opttoksb@YT}% |
| 1334 |
} |
| 1335 |
% \end{macrocode} |
| 1336 |
% \end{macro} |
| 1337 |
% |
| 1338 |
% \begin{macro}{\save@YT} |
| 1339 |
% Stick the following text into the token register in |#1|. Note that we use |\nil@YT| as an |
| 1340 |
% end-marker; it is not actually defined, so hopefully we never expand it! |
| 1341 |
% \begin{macrocode} |
| 1342 |
\def\save@YT#1#2\nil@YT{#1={#2}} |
| 1343 |
% \end{macrocode} |
| 1344 |
% \end{macro} |
| 1345 |
% |
| 1346 |
% \begin{macro}{\getcolor@YT} |
| 1347 |
% |#1| is pasted in front of what remains after removing the color. Basically, it's a ``do next''. |
| 1348 |
% \begin{macrocode} |
| 1349 |
\def\getcolor@YT#1{\ifstar@YT{\getcolor@@YT{#1}}{#1}} |
| 1350 |
% \end{macrocode} |
| 1351 |
% \end{macro} |
| 1352 |
% |
| 1353 |
% \begin{macro}{\getcolor@@YT} |
| 1354 |
% Save the (optional) color argument and pass the rest to |\startbox@@YT|. |
| 1355 |
% \begin{macrocode} |
| 1356 |
\def\getcolor@@YT#1(#2){% |
| 1357 |
\def\thisboxcolor@YT{#2}% |
| 1358 |
#1% |
| 1359 |
} |
| 1360 |
% \end{macrocode} |
| 1361 |
% \end{macro} |
| 1362 |
% |
| 1363 |
% \begin{macro}{\startbox@@YT} |
| 1364 |
% Start collecting the current entry into a horizontally-centered hbox, but save the result. |
| 1365 |
% \begin{macrocode} |
| 1366 |
\def\startbox@@YT{% |
| 1367 |
% \end{macrocode} |
| 1368 |
% Use a |\bgroup|...|\egroup| so as not to introduce nesting that would block |&| or |\cr|. |
| 1369 |
% \begin{macrocode} |
| 1370 |
\setbox\thisbox@YT=\hbox to \boxdim@YT\bgroup |
| 1371 |
\hss |
| 1372 |
\skipin@YT |
| 1373 |
} |
| 1374 |
% \end{macrocode} |
| 1375 |
% Since we are now in the intended typesetting context (i.e.\ an hbox with math mode on) |
| 1376 |
% we can let |\halign| expand tokens in the rest of the entry until it finds a |&| or |\cr| (= |\\|) |
| 1377 |
% \end{macro} |
| 1378 |
% |
| 1379 |
% \begin{macro}{\endbox@YT} |
| 1380 |
% Now we can finish the box and set it. |
| 1381 |
% \begin{macrocode} |
| 1382 |
\def\endbox@YT{% |
| 1383 |
\skipout@YT |
| 1384 |
\hss |
| 1385 |
\egroup |
| 1386 |
% \end{macrocode} |
| 1387 |
% We want all the boxes to have a consistent baseline, so we normalize them to |
| 1388 |
% the same size. Multiple text lines will be aligned with the baseline of the |
| 1389 |
% last line at the center, so this really only works well for single lines of |
| 1390 |
% text. |
| 1391 |
% \begin{macrocode} |
| 1392 |
\ifbaseline@YT |
| 1393 |
\ht\thisbox@YT=\ht\refhtdp@YT |
| 1394 |
\dp\thisbox@YT=\dp\refhtdp@YT |
| 1395 |
\fi |
| 1396 |
% \end{macrocode} |
| 1397 |
% The extra |\fboxrule| is to account for the margin on the vertical edges of |
| 1398 |
% the frame. |
| 1399 |
% \begin{macrocode} |
| 1400 |
\fcolorbox@YT{\thisboxcolor@YT}{% |
| 1401 |
\vbox to \dimexpr\boxdim@YT + \fboxrule\relax{\vss\box\thisbox@YT\vss}% |
| 1402 |
}% |
| 1403 |
} |
| 1404 |
% \end{macrocode} |
| 1405 |
% \end{macro} |
| 1406 |
% |
| 1407 |
% \begin{macro}{\fcolorbox@YT} |
| 1408 |
% \changes{v1.3}{2012/08/14}{Rewrote to draw the vertical and horizontal lines |
| 1409 |
% separately, so the \texttt{tabloids} option is possible.} |
| 1410 |
% We need a wrapper around |\colorbox| since it produces an opaque box, and |
| 1411 |
% sometimes, we want |clear|. We also have to draw the frame carefully. Note |
| 1412 |
% the order of the |\vbox| and the |\hbox|: it has to be that way, else |\none| |
| 1413 |
% gives a strange gap at the right edge in tabloids since the inner set of |
| 1414 |
% rules is shorter, and |\colorbox| does odd things inside a |\vbox|. |
| 1415 |
% |
| 1416 |
% |#1| = color, |#2| = contents |
| 1417 |
% \begin{macrocode} |
| 1418 |
\def\fcolorbox@YT#1#2{% |
| 1419 |
% \end{macrocode} |
| 1420 |
% This idea is again from \textsf{xcolor}. |
| 1421 |
% \begin{macrocode} |
| 1422 |
\lower\fboxrule\vbox{% |
| 1423 |
\ifodd\fboxrule\kern1sp \fi |
| 1424 |
\kern0.5\fboxrule |
| 1425 |
\hbox{% |
| 1426 |
\kern\fboxrule |
| 1427 |
\compare@@YT{#1}{clear}% |
| 1428 |
\ifeq@YT |
| 1429 |
% \end{macrocode} |
| 1430 |
% Clear background; don't draw anything. |
| 1431 |
% \begin{macrocode} |
| 1432 |
#2% |
| 1433 |
\else |
| 1434 |
% \end{macrocode} |
| 1435 |
% Colored background; pass it to |\colorbox|. |
| 1436 |
% \begin{macrocode} |
| 1437 |
\colorbox{#1}{#2}% |
| 1438 |
\fi |
| 1439 |
\rules@YT{v}% |
| 1440 |
}% |
| 1441 |
\kern-0.5\fboxrule |
| 1442 |
\rules@YT{h}% |
| 1443 |
}% |
| 1444 |
} |
| 1445 |
% \end{macrocode} |
| 1446 |
% \end{macro} |
| 1447 |
% |
| 1448 |
% \begin{macro}{\rules@YT} |
| 1449 |
% \changes{v1.3}{2012/08/14}{Added.} |
| 1450 |
% Draws |\boxdim@YT|-spaced rules either |h|orizontally or |v|ertically. This |
| 1451 |
% is so that the entire frame can be drawn after the contents of a box. |
| 1452 |
% It is drawn \emph{before} the current location. |
| 1453 |
% \begin{macrocode} |
| 1454 |
\def\rules@YT#1{% |
| 1455 |
\expandafter\let\expandafter\rule@YT\csname #1rule@YT\endcsname |
| 1456 |
\kern-\dimexpr\boxdim@YT + \fboxrule\relax |
| 1457 |
\rule@YT |
| 1458 |
\kern\boxdim@YT |
| 1459 |
\rule@YT |
| 1460 |
} |
| 1461 |
% \end{macrocode} |
| 1462 |
% \end{macro} |
| 1463 |
% \subsection{\texttt{ytableaushort} command} |
| 1464 |
% \changes{v1.2}{2012/06/17}{Fixed a bug in \texttt{\textbackslash ytableaushort} where \texttt{\{,\}} was treated as a comma at the beginning of a line.} |
| 1465 |
% |
| 1466 |
% \begin{macro}{\ytableaushort} |
| 1467 |
% The short form of |ytableau|. It takes a comma-separated list of lines, each one a string of |
| 1468 |
% entries given as individual tokens. |{...}| is allowed (and encouraged) for complex entries, and |
| 1469 |
% color is possible. All sorts of redundancies in the syntax are allowed. |
| 1470 |
% \begin{macrocode} |
| 1471 |
\newcommand{\ytableaushort}[2][]{% |
| 1472 |
% \end{macrocode} |
| 1473 |
% |\endytableau| has to be right at the end, so we can't use scope to reset |\toks@YT|. |
| 1474 |
% \begin{macrocode} |
| 1475 |
\toks@YT={}% |
| 1476 |
\getentries@YT{\getentries@@YT}{}#2,\nil@YT |
| 1477 |
\ytableau[#1]\the\toks@YT\endytableau |
| 1478 |
} |
| 1479 |
% \end{macrocode} |
| 1480 |
% \end{macro} |
| 1481 |
% |
| 1482 |
% \begin{macro}{\getentries@YT} |
| 1483 |
% Split the CSV into rows. This is really a job for |etoolbox:\docsvlist| but whatever. |
| 1484 |
% We put a |.| in front of the string so that a line may be enclosed entirely in |{...}| |
| 1485 |
% Otherwise, |\def\cs#1,{etc}| would make |#1| = |...| and not |#1| = |{...}| as we want. |
| 1486 |
% \begin{macrocode} |
| 1487 |
\def\getentries@YT#1#2{\getline@YT{#1}{#2}.} |
| 1488 |
% \end{macrocode} |
| 1489 |
% \end{macro} |
| 1490 |
% |
| 1491 |
% \begin{macro}{\getline@YT} |
| 1492 |
% Grab the first \meta{line}|,| in the string and remove the initial |.| |
| 1493 |
% \begin{macrocode} |
| 1494 |
\def\getline@YT#1#2#3,{% |
| 1495 |
\opttoksa@YT=\expandafter{\@gobble#3}% |
| 1496 |
\opttoksb@YT={\getline@@YT{#1}{#2}}% |
| 1497 |
% \end{macrocode} |
| 1498 |
% We pass |#3| back as an \emph{argument} to |\getline@@YT|, thus avoiding the braces issue. |
| 1499 |
% \begin{macrocode} |
| 1500 |
\edef\next@YT{\the\opttoksb@YT{\the\opttoksa@YT}}% |
| 1501 |
% \end{macrocode} |
| 1502 |
% We use |\futurelet| to check whether the next token is |\nil@YT| without breaking brace groups. |
| 1503 |
% \begin{macrocode} |
| 1504 |
\futurelet\tmpa@YT\next@YT |
| 1505 |
} |
| 1506 |
% \end{macrocode} |
| 1507 |
% \end{macro} |
| 1508 |
% |
| 1509 |
% \begin{macro}{\getline@@YT} |
| 1510 |
% |#1| = the macro to process each row, |
| 1511 |
% |#2| = the junk to put after each row (followed by |\nil@YT|), |
| 1512 |
% |#3| = everything before the first comma. |
| 1513 |
% If this is not the last row, we have to recurse down the list. Otherwise, just process the |
| 1514 |
% current row. Multiple commas are ignored. |
| 1515 |
% \begin{macrocode} |
| 1516 |
\def\getline@@YT#1#2#3{% |
| 1517 |
\ifx\tmpa@YT\nil@YT |
| 1518 |
\compare@YT{#3}{}% |
| 1519 |
\ifeq@YT |
| 1520 |
\def\next@YT{\@gobble}% |
| 1521 |
\else |
| 1522 |
\def\next@YT{#1#3#2}% |
| 1523 |
\fi |
| 1524 |
\else |
| 1525 |
\compare@YT{#3}{}% |
| 1526 |
\ifeq@YT |
| 1527 |
\def\next@YT{\getline@YT{#1}{#2}.}% |
| 1528 |
\else |
| 1529 |
\def\next@YT{#1#3#2\nil@YT\getentries@YT{#1}{#2}}% |
| 1530 |
\fi |
| 1531 |
\fi |
| 1532 |
\next@YT |
| 1533 |
} |
| 1534 |
% \end{macrocode} |
| 1535 |
% \end{macro} |
| 1536 |
% |
| 1537 |
% \begin{macro}{\getentries@@YT} |
| 1538 |
% Separates the entries in a line of |\ytableaushort| and reformats them for |\ytableau|. |
| 1539 |
% Takes two tokens and checks if the second is |\nil@YT|, which means the first is the last entry. |
| 1540 |
% \begin{macrocode} |
| 1541 |
\def\getentries@@YT#1#2{% |
| 1542 |
% \end{macrocode} |
| 1543 |
% If this is not the last entry, we have to recurse down the line. Otherwise, we just print |\\|. |
| 1544 |
% \begin{macrocode} |
| 1545 |
\compare@YT{#2}{\nil@YT}% |
| 1546 |
\ifeq@YT |
| 1547 |
\toks@YT=\expandafter{\the\toks@YT#1\\}% |
| 1548 |
\def\next@YT{}% |
| 1549 |
\else |
| 1550 |
\toks@YT=\expandafter{\the\toks@YT#1&}% |
| 1551 |
\def\next@YT{\getentries@@YT{#2}}% |
| 1552 |
\fi |
| 1553 |
\next@YT |
| 1554 |
} |
| 1555 |
% \end{macrocode} |
| 1556 |
% \end{macro} |
| 1557 |
% |
| 1558 |
% \subsection{\texttt{ydiagram} commmand} |
| 1559 |
% \changes{v1.2}{2012/06/17}{Fixed a bug where giving a line length of 0 in \texttt{\textbackslash ydiagram} did not draw an empty row, but rather ignored the row.} |
| 1560 |
% \changes{v1.2}{2012/06/17}{Removed \texttt{\textbackslash fullexpand@YT}.} |
| 1561 |
% |
| 1562 |
% \begin{macro}{\ydiagram} |
| 1563 |
% Takes the same optional argument as the other macros. Its main argument |#2| is of the form |
| 1564 |
% \\ |
| 1565 |
% \indent[\meta{offset} + ]\meta{number}, ... |
| 1566 |
% \\ |
| 1567 |
% where both \meta{offset} and \meta{number} may be any expression evaluating to a textual number |
| 1568 |
% (e.g.\ |\the\count|\meta{n} rather than |\count|\meta{n}). |
| 1569 |
% \begin{macrocode} |
| 1570 |
\newcommand\ydiagram[2][]{% |
| 1571 |
% \end{macrocode} |
| 1572 |
% We need |\endytableau| to be right at the end, so we can't use scope to reset |\toks@YT|. |
| 1573 |
% \begin{macrocode} |
| 1574 |
\toks@YT={}% |
| 1575 |
\getentries@YT{\getnumbers@YT}{+}#2,\nil@YT |
| 1576 |
\ytableau[#1]\the\toks@YT\endytableau |
| 1577 |
} |
| 1578 |
% \end{macrocode} |
| 1579 |
% \end{macro} |
| 1580 |
% |
| 1581 |
% \begin{macro}{\getnumbers@YT} |
| 1582 |
% Separates the entries in a line of |\ydiagram| and reformats them for |\ytableau|. |
| 1583 |
% \begin{macrocode} |
| 1584 |
\def\getnumbers@YT#1+#2\nil@YT{% |
| 1585 |
% \end{macrocode} |
| 1586 |
% If |#2| = |{}|, then there is no offset and |#1| is the row shape. |
| 1587 |
% \begin{macrocode} |
| 1588 |
\compare@YT{#2}{}% |
| 1589 |
\ifeq@YT |
| 1590 |
\def\next@YT{% |
| 1591 |
\loop@YT{#1}{}% |
| 1592 |
}% |
| 1593 |
% \end{macrocode} |
| 1594 |
% Else |#1| is the offset and |#2| is the shape. |
| 1595 |
% \begin{macrocode} |
| 1596 |
\else |
| 1597 |
\def\next@YT{% |
| 1598 |
\loop@YT{#1}{\none}% |
| 1599 |
% \end{macrocode} |
| 1600 |
% Now |#2| looks like \meta{number}|+|, so we feed it back in. |
| 1601 |
% \begin{macrocode} |
| 1602 |
\getnumbers@YT#2\nil@YT |
| 1603 |
}% |
| 1604 |
\fi |
| 1605 |
\next@YT |
| 1606 |
} |
| 1607 |
% \end{macrocode} |
| 1608 |
% \end{macro} |
| 1609 |
% |
| 1610 |
% \begin{macro}{\loop@YT} |
| 1611 |
% Loops on the first argument, building a |\ytableau| line whose entries are the second argument. |
| 1612 |
% The results go in |\toks@YT|. |
| 1613 |
% \begin{macrocode} |
| 1614 |
\def\loop@YT#1#2{% |
| 1615 |
\count@YT=#1\relax |
| 1616 |
\loop\ifnum\count@YT>1 % |
| 1617 |
\toks@YT=\expandafter{\the\toks@YT#2&}% |
| 1618 |
\advance\count@YT by -1 % |
| 1619 |
\repeat |
| 1620 |
% \end{macrocode} |
| 1621 |
% The last entry in the list may not be the last entry in the line. If it's empty, it is (according |
| 1622 |
% to our usage), otherwise not. |
| 1623 |
% \begin{macrocode} |
| 1624 |
\ifnum\count@YT=1 % |
| 1625 |
\compare@YT{#2}{}% |
| 1626 |
\ifeq@YT |
| 1627 |
\toks@YT=\expandafter{\the\toks@YT#2\\}% |
| 1628 |
\else |
| 1629 |
\toks@YT=\expandafter{\the\toks@YT#2&}% |
| 1630 |
\fi |
| 1631 |
\else |
| 1632 |
% \end{macrocode} |
| 1633 |
% This supports using 0 as a number: it inserts an empty line, but only if it is the |+0| case, not the |0+| case. |
| 1634 |
% \begin{macrocode} |
| 1635 |
\compare@YT{#2}{}% |
| 1636 |
\ifeq@YT |
| 1637 |
\toks@YT=\expandafter{\the\toks@YT\none\\}% |
| 1638 |
\fi |
| 1639 |
\fi |
| 1640 |
} |
| 1641 |
% \end{macrocode} |
| 1642 |
% \end{macro} |
| 1643 |
% \Finale |