the title may be confusing, but I'm not sure how to name it better.
This current question is the result of my other ones, and the hints I got from users in this board.
Steven B. Segletes helped me by creating a way to build a special table, that is build column by column and is based on the stackengine package.
I tried to work with that solution, and build a way to provide input for the first of that 'columns', but I always get the error message mentioned in the title.
This is what I got:
\documentclass{article}
\usepackage{stackengine}
\usepackage{etoolbox}
%
\fboxsep=3pt
\fboxrule=.25pt
\def\mystrutheight{.7\baselineskip}
\def\mystrutdepth{.1\baselineskip}
\def\horzbuffer{2ex}
%
\def\mybox{}
\newcounter{index}
\newlength\cellwidth
\newlength\colwidth
\newcommand\myLongstack[1]{%
\renewcommand\mybox[1]{##1}%
\getargsC{#1}%
\setlength\colwidth{0pt}%
\setcounter{index}{0}%
\whiledo{\value{index} < \narg}{%
\stepcounter{index}%
\setlength\cellwidth{\widthof{\csname arg\roman{index}\endcsname}}%
\ifthenelse{\cellwidth > \colwidth}{%
\setlength\colwidth{\the\cellwidth}}{}%
}%
\setlength\colwidth{\the\colwidth + \horzbuffer}%
\xdef\myboxwidth{\the\colwidth}%
\renewcommand\mybox[1]{\kern -\fboxrule\protect\framebox[\myboxwidth]{%
\protect\rule[-\mystrutdepth]{0ex}{\mystrutheight}\smash{##1}}}%
\Longstack{#1}%
}
\setstackgap{L}{\mystrutheight+2\fboxsep+\fboxrule}
%start of my own code
\newcounter{stNumCats} %number of categories
\newcounter{stCurRow} %current row
\newcommand{\STAddCategory}[1]{
% #1 is category name
\stepcounter{stNumCats}
\csdef{stcat\thestNumCats}{#1}
}
\newcommand{\PrintCategories}{
\setcounter{stCurRow}{0}
\myLongstack{
\whileboolexpr
{ test {\ifnumcomp{\value{stCurRow}}{<}{\value{stNumCats}}} }
{\mybox{{\stepcounter{stCurRow} \csuse{stcat\thestCurRow}}}}
}
}
\begin{document}
\STAddCategory{Cat A}
\STAddCategory{Cat B}
\PrintCategories
\end{document}
Do you know what the problem might be?
The while construct can be tested with something like
\setcounter{stCurRow}{0}
\begin{itemize}
\whileboolexpr
{ test {\ifnumcomp{\value{stCurRow}}{<}{\value{stNumCats}}} }
{\stepcounter{stCurRow} \item \csuse{stcat\thestCurRow}}
\end{itemize}

\LongStackargument is fragile and needs to be protected. – Steven B. Segletes Aug 13 '13 at 18:10\whileboolexpr { test {\ifnumcomp{\value{stCurRow}}{<}{\value{stNumCats}}} } {\mybox{{\stepcounter{stCurRow} \csuse{stcat\thestCurRow}}}}, which doesn't work, even if taken outside of the\Longstackand put into a\protected@edef– Steven B. Segletes Aug 13 '13 at 18:14\Longstack? – muffel Aug 13 '13 at 18:27