TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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
share|improve this question
You can use, for example, \begin{tabular}{*{5}{c}} to indicate five columns of c type. – Gonzalo Medina May 1 '13 at 1:09
so it means i need to know before hand how many columns should be there – user17 May 1 '13 at 1:24

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
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.