# How can branch if I'm in a halign or not? [closed]

## Edit:

It seems that I can use \noalign\bgroup before the \halign. That's fine. But how do I test that I'm inside the halign group? I'm able to write an own if, but it would be better to ask tex for its status, instead of introducing own status variables.

## Original Question:

Plain TeX nesting of a \halign table macro

Why can't I use my \begindescrows macro nested, or how can I change the command, that I can nest it:

\def\begindescrows #1,#2,#3.{\begingroup\baselineskip 2em\parindent 0pt
\parskip 6pt plus1pt minus1pt
\def\bullet{#1}
\setbox0=\hbox{{\datefont ~\bullet~~ }} \def\dateSize{#2}
\def\descSize{#3}
\def\dcol{\hsize \descSize}
\def\fcol{\hsize \dateSize}
\def\desc##1{\vtop{\tolerance=5000\dcol\baselineskip 1.1em ##1\vskip 1em}}
\def\date##1 -- ##2:{\vtop{\datefont\tolerance=5000\fcol\parskip0pt\baselineskip 1.1em
\hskip-\wd0\copy0 ##1 --\hfill\break
##2\par\vskip 1em}}
\def\row ##1 -- ##2:##3\cr{\date ##1 -- ##2: &\desc{##3}\cr}
\halign\bgroup##\hfil&##\hfil\cr
}
\def\enddescrows{\crcr\egroup\endgroup\par\vskip -1em plus .5em\noindent}

\begindescrows von,3.5cm,13cm.
\row November 2006 -- now:      Some time went by.\cr
\begindescrows als,2.5cm,10cm.
\row This -- makes: no sense, but actually I want to nest a command similar to \\begindescrows.\cr
\enddescrows
\enddescrows
\bye


The error log looks like this:

\$ pdftex --file-line-error testfile.tex
This is pdfTeX, Version 3.14159265-2.6-1.40.16 (TeX Live 2015) (preloaded format=pdftex)
restricted \write18 enabled.
entering extended mode
encTeX v. Jun. 2004, reencoding enabled.
(./testfile.tex
Runaway definition?
#1 -- #2:#3\hfil
./testfile.tex:19: Forbidden control sequence found while scanning definition o
f \row.
<inserted text>
}
\endtemplate
<template> \hfil \endtemplate

\begindescrows ...m}} \def \row ##1 -- ##2:##3\cr
{\date ##1 -- ##2: &\desc ...
l.19 \begindescrows als,2.5cm,10cm.

? X
No pages of output.
Transcript written on testfile.log.


## closed as unclear what you're asking by egreg, Werner, Mensch, user13907, OSjerickOct 25 '15 at 3:05

Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.

• You have to use your own \ifhalign. TeX only offers a limited set of mode detecting \if…. These are \ifmmode, \ifhmode, \ifvmode, and \ifinner. – Henri Menke Jun 25 '15 at 8:22
• @HenriMenke Yes I know: "I'm able to write an own if". But the problem with the if is, that I need to switch it on \endgroup. I think I prefer my own answer, below. – ikrabbe Jun 25 '15 at 8:28
• \aftergroup\halignfalse? – Henri Menke Jun 25 '15 at 11:29

I found that it is much simpler not to use \noalign inside of the macros, but outside, where I know, that I'm inside a \halign. So

\begindescrows ...


can simply be nested at any level, using

\noalign{\begindescrows ...
....
\enddescrows}


Actually it is good that the nesting and the halign characteristic is visible from outside of the macros.

• \def\halign{\noalign\bgroup\halign} Would expand indifinetly. You have to \let something to \halign. – Manuel Jun 25 '15 at 9:15
• ah, this might has to be an expandafter construct I never managed to get right. – ikrabbe Jun 25 '15 at 9:26