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?
Asked
Active
Viewed 231 times
3
Tom Solid
- 839
1 Answers
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}
Steven B. Segletes
- 237,551

spreadtabpackage may provide such features – Mar 08 '16 at 19:01collcell– Werner Apr 15 '18 at 16:12