3

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?

2

1 Answer 1

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.

\documentclass{article}
\usepackage[TABcline]{tabstackengine}
\makeatletter
\newcommand\colcheck{\theTABcolindex@}
\newcommand\colcheckA{\ifnum\theTABcolindex@=1First Column\else Other Column\fi}
\makeatother
\begin{document}
\tabularCenterstack{cccc}{
 \colcheck& \colcheck& \colcheck& \colcheck\\
 \colcheck& \colcheck& \colcheck& \colcheck
}

\tabularShortstack{cccc}{
 \TABcline{1-4}
 \colcheckA& \colcheckA& \colcheckA& \colcheckA\\
 \TABcline{1-4}
 \colcheckA& \colcheckA& \colcheckA& \colcheckA\\
 \TABcline{1-4}
}
\end{document}

enter image description here

You must log in to answer this question.

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