[texhax] tabbing in macros

Uwe Lück uwe.lueck at web.de
Thu Sep 7 14:29:43 CEST 2006

There is a simple way to avoid the problem I previously closed with
(see below). The following example may give a hint at how
to use \+ and (unmodified) \settabs in a macro (tested):



       \settabs\+\quad& \quad&\cr
       \tabalign 1& 2& 3\cr
       \tabalign  & 4& 5\cr
       \tabalign  &  & 6\cr




In general, define all your macros using \+ globally
in a group started with \let\+\relax




At 21:28 05.09.06, markrichard at cox.net wrote:
>I am trying to find a way to write tabbing commands (like \+ or
>\settabs) within a macro.  Can you help me with this or direct me to
>where this info can be located? I am using plain TeX.

At 19:13 06.09.06, Oleg Katsitadze wrote:
>\+ is defined as an outer macro, therefore it cannot be used
>inside another macro.  But \tabalign (which is what \+
>calls) can.  Unfortunately, \settabs will not work if you
>use \tabalign in the sample line:
>   \settabs\tabalign Text& More text&\cr % <- doesn't work
>because \settabs looks ahead for a \+ and doesn't find it.

Another point that I missed in my previous two postings!

>Probably the easiest way to deal with this is to redefine \+
>to be non-outer:
>   \def\+{\tabalign}

\let\+\tabalign works as well -- I tested it with Oleg's example below.

>   \def\table{%
>     \settabs\+ \quad& \quad&\cr
>     \+ 1& 2& 3\cr
>     \+  & 4& 5\cr
>     \+  &  & 6\cr
>   }
>   \table
>   \bye

To do penance additionally, I suggest another approach:
Define a variant \nosettabs of \settabs that deals with \tabalign
like \settabs deals with \+ (cf. \settabs etc. in
[which is free!!?]):


   \def\nosettabs{\setbox\tabs=\null \futurelet\next\n at sett@b}
   \def\n at sett@b{\ifx\next\tabalign
       \def\nxt{\afterassignment\n at s@tt at b\let\nxt}%
   %% <- You may replace the previous \n at s@tt at b with \s at tt@b
   %%    and drop the definition of \n at s@tt at b below if your
   %%    Plain Format is suffienctly recent ->
     \else\let\nxt\s at tcols\fi \let\next\relax \nxt}
   \def\n at s@tt at b{\let\nxt\relax \us at false\m at ketabbox} % local


Test this with the following adaptation of Oleg's example
(\settabs replaced by \nosettabs, \+ by \tabalign):

     \nosettabs\tabalign \quad& \quad&\cr
     \tabalign 1& 2& 3\cr
     \tabalign  & 4& 5\cr
     \tabalign  &  & 6\cr



[OK -- better stop reading here if you are happy enough!]

A point in favour of this approach is that otherwise
your own tabbing macros should contain something like
\let\+\tabalign -- while \outer forbids such macros -- try


to experience how it fails (I tried some \begingroup \gdef
in vain as well).

More information about the texhax mailing list