The reason I am including this in the `Document Class' forum is because I already have a solution to this in the memoir class (thanks GL and Lars!), but not for LaTeX's base classes.
Rather than explain, here's an MWE which should be clear:
The macro \repeatntimes works in any class. But my instinct is pointing me in the direction of an expansion problem, i.e. what's getting passed is \begin{tabular}{\cols} not \begin{tabular}{ccc}.
I think the tabular environment's table specification argument is just really fussy in what it allows. Notice that you'll get an error if you throw any stray commands in there, even if those commands have no "output", so to speak. If you write, e.g.:
Even though setting that counter there isn't affecting anything, you'd still get the "Illegal character in array arg." error. And your macro is expanding to something that has commands like that in it.
But you might not know that there's a built in method for specifying multiple columns at once. (See, e.g., here.) The syntax is *{n}{type} for n columns of the type. So, e.g.:
Thanks for the time to answer this. I'll check it out when I have a moment (at work now).
I actually did know about the *{n}{type} construction, but didn't know you could use it with counters as you describe. I think that your solution will eminently solve my problem.
I appreciate your time on this. It was holding up progress on a package I'm working on for our lab: a easy, simple, and fast tabular env for figures (figarray.sty).
The other packages I've tried for this type of functionality are too complex and cause too many problems and conflicts with other packages. When I finish it I'm going to post it somewhere for comments and feedback from people who will have tried it (hopefully).