Do you know a macro/command which can tell me where was it called in a tabular environment? Specially, i wish a macro which executes \commandA if I called it in the first cell of a row (or after a \\ new line) and executes \commandB if I called it in the 2nd, 3rd... last cell?


1 Answer 1


The tabstackengine package can produce some types of tabulars, but not all. It cannot employ | column-line specifiers, and can only use l, c, and r column types.

But if your problem falls in this sub-category, then the counter TABcolindex@ in the package provides the current column, which can be used to make choices in the typesetting of a column.

\newcommand\colcheckA{\ifnum\theTABcolindex@=1First Column\else Other Column\fi}
 \colcheck& \colcheck& \colcheck& \colcheck\\
 \colcheck& \colcheck& \colcheck& \colcheck

 \colcheckA& \colcheckA& \colcheckA& \colcheckA\\
 \colcheckA& \colcheckA& \colcheckA& \colcheckA\\

enter image description here

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .