I have this code which works fine

\caption{Table Data }  
\begin{tabular}{c c c c}    % centered columns (4 columns)

Now i have the dynamic headers so i have to hard code this line every time accoring to headers

begin{tabular}{c c c c}

is there any way to apply that to all coumns instead of all like this

begin{tabular}{c} for all
  • 4
    You can use, for example, \begin{tabular}{*{5}{c}} to indicate five columns of c type. Commented May 1, 2013 at 1:09
  • so it means i need to know before hand how many columns should be there
    – user17
    Commented May 1, 2013 at 1:24

1 Answer 1


You can specify a number of columns which is more that you need -- there is no problem with extra column specification, AFAIK. Also, as per Gonzalo Medina's comment you can use the {*{15}{c}} notation to specify a maximum of 15 columns.

enter image description here




\begin{tabular}{c c c c c c c c c c c c c c c} \toprule
One & Two \\ \cmidrule{1-2}
 1  & 2   \\ \bottomrule
\begin{tabular}{*{15}{c}} \toprule
One & Two & Three \\ \cmidrule{1-3}
 1  & 2   & 3 \\ \bottomrule

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .