[pdftex] A table of variable dimension

PierLuigi Zezza pzezza at unifi.it
Wed Oct 9 23:16:24 CEST 2002


I am trying to define a macro which defines a table like the following

\begin{tabular}{|c|c|c|c|c|} \hline
1 & 2 & 3 & 4 & 5 \\ \hline
   &   &   &   &   \\ \hline
\end{tabular}

but of variable dimension.

I have defined the following macro

\newcounter{col}
\def\tabl#1#2#3{\setcounter{col}{#1} \whiledo{\value{col}<#2}{
      #3  \stepcounter{col}}}

that works as expected but if I try to write
\documentclass{article}

\usepackage{ifthen}
\usepackage{calc}
\usepackage{array}

\newcounter{col}
\def\tabl#1#2#3{\setcounter{col}{#1} \whiledo{\value{col}<#2}{
      #3  \stepcounter{col}}}

\begin{document}

\begin{tabular}{| \tabl{1}{5}{ c |}} \hline
1 \tabl{2}{5}{& \thecol} \\ \hline
   \tabl{2}{5}{& } \\ \hline
\end{tabular}

\end{document}

I get ... many ... error messages. I do understand why it happens but I do 
not have any
idea on how to solve the problem. Any help is welcome
gigi zezza


PierLuigi Zezza
         pzezza at unifi.it




More information about the pdftex mailing list