# How to make many columns blank in table easily?

\documentclass{article}
\usepackage{booktabs}
\begin{tabular{@{}ll|r|r|r|r|r|r|r|r|r|r|r|r|r|r|r|@{}}
A & B &&&&&&&&&&&&&&&\\%15 blank &
\end{tabular}


I want to do like the above where only first two column has value and others are blank.

For each row putting many & can possible to create the table.

You can replicate the & using details from Repeat command n times?:

\documentclass{article}

\usepackage{xparse}

\ExplSyntaxOn
\cs_new_eq:NN \Repeat \prg_replicate:nn
\ExplSyntaxOff

\begin{document}

\begin{tabular}{ @{} l l *{15}{|r} | @{} }
A & B \Repeat{15}{& c} \\
\Repeat{13}{&} & 1 & 2 & 3
\end{tabular}

\end{document}


A similar \Repeat macro is possible using multido:

\usepackage{multido}
\makeatletter
\renewcommand{\Repeat}[2]{%
\def\@@x{}% Make sure \@@x is defined
\multido{\i=1+1}{#1}{\protected@xdef\@@x{\@@x #2}}% Create global repetition
\@@x% Execute repetition
}
\makeatother


Using \newcommand{\Repeat}[2]{\multido{\i=1+1}{#1}{#2}} won't work here because each cell within the tabular creates a group and the default definition of \multido doesn't make a global assignment of the stepping macro (\i). Instead, one has to assemble the repetition into a macro before executing it.

Also note the condensed way in which the column specification can be specified: *{<num>}{<col spec>} repeats <col spec> a total of <num> times.

• Isn't it possible to specify the \Repeat at tabular argument begin{tabular}{--here--} so that I insert 1st and 2nd column in each row. A & B\\ C & D\\ E & F\ Oct 12, 2018 at 3:17
• I am familiar to \multido command. Isn't it possible with \multido ? Oct 12, 2018 at 3:33
• @alhelal: Yes, but it's more complicated. See the updated answer. I don't understand what you mean by your first comment.
– Werner
Oct 12, 2018 at 4:27
• In first comment I said that I don't want to write \Repeat each time for a new row. Oct 12, 2018 at 8:39
• @alhelal: tabulars are set by column (first) by row (second). It's therefore easier to manage a by-column replication than by-row.
– Werner
Oct 12, 2018 at 23:44