"&"に展開される命令を作りたい

名前: Shizu
日時: 2010-02-16 23:31:27
IPアドレス: 61.123.195.*

\def\foo#1{% \ifnum #1=1 hoge\fi \ifnum #1=2 piyo\fi \ifnum #1=3 fuga\fi \ifnum #1=4 hogera\fi \ifnum #1=5 hogehoge\fi } のような命令があるときに, \begin{tabular}{ll} 1&\foo{1}\\ 2&\foo{2}\\ 3&\foo{3}\\ 4&\foo{4}\\ 5&\foo{5}\\ \end{tabular} のようにして表を作成したいのですが,実際には項目数は5個ではなくもっと多いので, tabular の中身を loop で作成したいと思っています。 しかし,単純に \def\bar{1,2,3,4,5} \begin{tabular}{ll} \@for\@temp:=\bar\do{\@temp&\foo{\@temp}\\} \end{tabular} などとするとエラーになります。 "&"に展開される命令があればいいのでは,と思うのですが,方法が分かりません。 お知恵を拝借できませんでしょうか。 以下ソースです。 (このままだとエラーになります。) %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \documentclass{jarticle} \begin{document} \makeatletter \def\foo#1{% \ifnum #1=1 hoge\fi \ifnum #1=2 piyo\fi \ifnum #1=3 fuga\fi \ifnum #1=4 hogera\fi \ifnum #1=5 hogehoge\fi } \begin{tabular}{ll} 1&\foo{1}\\ 2&\foo{2}\\ 3&\foo{3}\\ 4&\foo{4}\\ 5&\foo{5}\\ \end{tabular} \def\bar{1,2,3,4,5} \begin{tabular}{ll} \@for\@temp:=\bar\do{\@temp&\foo{\@temp}\\} \end{tabular} \makeatother \end{document}

この書き込みへの返事:

お名前
題名 
メッセージ(タグは <a href="...">...</a> だけ使えます。適宜改行を入れてください)