Trying to build a tabular, based on an array of strings, I followed the lines of http://tex.stackexchange.com/questions/62177, where a table of repeating literal rows was built.
However, instead of literal rows, I want rows depending on the strings in the array. This is what I have:
\documentclass{article}
\usepackage{forarray}
\def\array{bank;acno;name}
% item's name for column 1 item's value for column 2
\def\bankkey{Bank} \def\bank{Lehmann Brothers}
\def\acnokey{Account no.} \def\acno{123456789}
\def\namekey{In the name of} \def\name{John Doe}
\newcommand{\tablebody}{%
\def\body{}%
\ForEachX{;}{%
\expandafter\gdef\expandafter\body\expandafter{\body%
\csname\thislevelitem key\endcsname &
\csname\thislevelitem\endcsname \\
}%
}{\array}%
\body%
}
\begin{document}
% I want the following tabular to be equivalent to:
% \begin{tabular}{rl}
% \bankkey & \bank \\
% \acnokey & \acno \\
% \namekey & \name \\
% \end{tabular}
\begin{tabular}{rl}
\tablebody
\end{tabular}
\end{document}
But it produces an error message:
! Missing \endcsname inserted.
<to be read again>
\thislevelitem
l.32 \tablebody
How can I repair this?
Or are there better ways to do this?


\arrayis very badly chosen. Never use\defunless you know precisely that the macro you're going to define has a name that won't cause conflicts. – egreg Dec 09 '15 at 12:45