# Setting Dynamic Column Properties in LaTeX Tabular

I am writing a system to export reports in various formats from PHP.

When it comes to LaTeX it seems to require \begin{tabular}{mandatory column arguments}

Since the number of columns in the datasets vary, with my current method I can't export in LaTeX without adding quite a bit of extra code to deal with LaTeX. I am trying to keep it simple and have a defined export format for each type (PDF/pdflatex, XLS, CSV, etc.).

Is there a way to tell LaTeX to set all columns as one alignment?

Something which would take the place of help! in the following line of code:

\begin{tabular}{help!}


Ideally I want the first column to be left aligned, and all the other columns to be center aligned. However I could settle for all left or all center.

• Welcome to TeX.SX! Your post was migrated here from Stack Overflow. Please register on this site, too, and make sure that both accounts are associated with each other (by using the same OpenID), otherwise you won't be able to comment on or accept answers or edit your question. – Qrrbrbirlbel Jul 1 '13 at 20:32
• Thanks for the migration and answers. I think I'll go with the l*{50}{c} solution for prototyping until I develop something a little more advanced :) – Anon343224user Jul 3 '13 at 8:50

If you know the number of columns, you could easily tell tabular to repeat them, say

\begin{tabular}{l*{<number of columns - 1>}{c}}


e.g. for 12 columns

\begin{tabular}{l*{11}{c}}


which is the same as

\begin{tabular}{l ccc ccc ccc cc}% spaces don’t matter


As egreg comments, it doesn’t hurt if you define more columns than are actually used, e.g.

\begin{tabular}{l*{50}{c}}