Andreas Schwab <sch
...@lamothe.informatik.uni-dortmund.de> wrote:
> David Carlisle writes:
> |> As the TeXBook says
> |>
> |> People usually work with \TeX\ at least a year before they find
> |> their first application for |\valign|;....
> So for what else than provoking this error is \valign applicable? ;-)
For doing nasty hacky tables, I think. Here's an example of one I did
earlier (it's actually a table of encoding-specific control sequences,
but that's not terribly important). Sorry it's a little big...
% Now for the actual table. The two columns are essentially independent,
% although they get ruled up as an entity. In particular, horizontal rules
% in one column shouldn't affect the spacing in the other. The horizontal
% rules should have some extra vertical space around them, however. The
% two columns are also approximately the same height, and I'd like to even
% them out. I could play with boxes and measure things out tediously, but
% I can get TeX to do the work if I use a \valign. Each column in the
% \valign is an \halign, which makes life a little more interesting.
% TeX gets a little nasty about me putting the \halign directly into the
% preamble of the \valign, so I'll have to put it into a separate macro.
% [reading this now, I guess this is a workaround for the `interwoven
% preambles' error, but I've forgotten if this really is the case.]
\def\subalign{%
\halign\bgroup% % Then start a table in the column
\bigstrut% % Insert a strut for nice spacing
\quad% % Put some space on the left hand side
\example##\xx% % Then do the example text.
\hfil% % Space out the thing on the left
&% % Start a new column
\quad% % Add some more space here
\qex##\xx% % Describe the alternative name
\unskip% % If nothing there, gobble the quad space!
\hfil% % Pad out with inifinite glue
\quad% % And leave space on the right hand side
\cr% % End of the alignment.
}
\hbox to\hsize{\hfil\vbox{
\hbox{%
\valign{%
\hrule\vskip1\ruleglue% % Add a rule and some vertical space
% (The 1 suppresses the glue's stretch)
\subalign % Do the main table thing here
#% % Insert the \valign text here
\vskip1\ruleglue\hrule% % Insert some more glue and a final rule
\cr% % That's all there is here
%
\omit\leaders\vrule\vfil\cr % On the left hand side, there's a rule
%
% [items -- snip]
%
\egroup\cr
%
\omit\leaders\vrule\vfil\cr % A vertical rule between columns
%
% [items -- snip]
%
\egroup\cr
%
\omit\leaders\vrule\vfil\cr % A final vertical rule
%
}}% One for the \valign, one for the \hbox
% Attach a footnote
\medskip
\hbox{*\enspace Not available in the OT1 encoding}
}\hfil}
% Done!
--
[mdw]
`When our backs are against the wall, we shall turn and fight.'
-- John Major