This macro is quite old, and I don't know plain TeX very well. MWE:
\documentclass{article}
\setlength{\unitlength}{0.06em}
\newlength{\cellsize} \setlength{\cellsize}{18\unitlength}
\newsavebox{\cell}
\sbox{\cell}{\begin{picture}(18,18)
\put(0,0){\line(1,0){18}}
\put(0,0){\line(0,1){18}}
\put(18,0){\line(0,1){18}}
\put(0,18){\line(1,0){18}}
\end{picture}}
\newcommand\cellify[1]{\def\thearg{#1}\def\nothing{}%
\ifx\thearg\nothing
\vrule width0pt height\cellsize depth0pt\else
\hbox to 0pt{\usebox{\cell} \hss}\fi%
\vbox to \cellsize{
\vss
\hbox to \cellsize{\hss$#1$\hss}
\vss}}
\newcommand\tableau[1]{\vtop{\let\\\cr
\baselineskip -16000pt \lineskiplimit 16000pt \lineskip 0pt
\ialign{&\cellify{##}\cr#1\crcr}}}
\begin{document}
\tableau{ & & & 5 & 6 & 8\\ & & 1 & 2 & 3\\ 3 & 5 & 7 & 5}
\end{document}
As for my confusion, it's mostly coming from
\ialign{&\cellify{##}\cr#1\crcr}}}
I know a double hash inside a nested macro definition expands to a single hash and allows the inner macro to take arguments, but that doesn't seem to be what's going on here. I have no idea what a single hash alone means. I tried searching but was only able to find explanations for appearances of eg. ##1
rather than ##
or just #
. It seems to somehow be breaking up the #1 input at alignment characters and passing them to cellify, but the specifics are black magic to me.
The reason I'm wondering is that I was trying to extend the macro to use a different picture (dashed lines) if a certain character was used, but just adding an extra \if
branch inside \cellify
comparing #1
to e.g. -
didn't work. Well, it did if you called \cellify
on its own, but \tableau
seems to be giving it more tokens.
I have very little plain TeX experience and am also confused by quite a few other things in this macro that don't seem to be documented well online (\ialign
; \cr
; \crcr
; \hss
; \vss
). Any explanation would be appreciated. Thanks.