A & B &&&&&&&&&&&&&&&\\%15 blank &

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.

1 Answer 1


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

enter image description here



\cs_new_eq:NN \Repeat \prg_replicate:nn


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


A similar \Repeat macro is possible using multido:

  \def\@@x{}% Make sure \@@x is defined
  \multido{\i=1+1}{#1}{\protected@xdef\@@x{\@@x #2}}% Create global repetition
  \@@x% Execute repetition

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\`
    – alhelal
    Oct 12, 2018 at 3:17
  • I am familiar to \multido command. Isn't it possible with \multido ?
    – alhelal
    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.
    – alhelal
    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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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