I'm having trouble with a \@for loop. I've got a macro that takes a comma delimited list and puts each element into a row of an array. When I do this using a \@for loop, I get an extra row that I don't understand. I can manually get rid of it with a negative space, (as in the commented line below) but that can't be the right way to do it, so I must be doing something wrong. Here's a minimal example. For comparison, if I construct what I expect the result of the loop to be manually, the extra row doesn't appear.
\documentclass{article}
\usepackage{amsmath}
\makeatletter
\newcommand{\fbun}[1]
{\ensuremath{\left[\begin{array}{c}
\@for\xx:=#1\do {\text{\xx}\\}
% \\ [-2.75ex] % why is this required?
\end{array}\right]}}
\makeatother
\begin{document}
$\left[\begin{array}{c}
A\\
B\\
C\\
D\\
\end{array}\right]$
% same array, but generated by a macro
\fbun{A,B,C,D}
\end{document}



\@forcommand in the LaTeX kernel (filelatex.ltx, beginning on row 859) to see if I could figure out why the loop form creates an extra row whereas the non-loop form does not. However, I must say I can't penetrate the dense, uncommented code in that file. :-( – Mico Nov 16 '11 at 03:41#2in your command, you don't get an extra row. – Alan Munn Nov 16 '11 at 03:42\\afterC, then aDis inserted as #2, so I don't see why there should be an empty row. (Incidentally, I did try out my code before posting the answer, to be sure there was no longer an extra row...) Re question 2: I can't tell for sure, but presumably it's for the same (and currently unknown/not-yet-understood) reason for why there's no blank row in the non-loop creation of the column vector... – Mico Nov 16 '11 at 03:50