我正在尝试构建一个LaTeX环境,以便对于每个整数N,
\begin{mytab}{N}
% foo bar
\end{mytab}
将扩展为
\begin{tabular}{lr.....lr}
% foo bar
\end{tabular}
有N个令牌对“lr”。
这是我做这件事的可怜尝试。我觉得我正走在正确的轨道上
\mytokens
是我想要的令牌列表。如果只有当我在最后一行的最后一行替换\junk
\mytokens
时才会有效...
\newcounter{ct}
\newenvironment{mytab}[1]{%
\setcounter{ct}{#1}
\newcommand{\mytokens}{%
\ifthenelse{\thect>0}{\addtocounter{ct}{-1}lr\mytokens}{}
}
\def\junk{lrlrlrlrlrlr}
\expandafter\tabular\expandafter{\junk}%
}{
\endtabular
}
答案 0 :(得分:1)
您可以使用*
重复列定义:
\begin{tabular}{*{6}{lr}}
%...
\end{tabular}