TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. Join them; it only takes a minute:

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

Is there a nice way to use \multicolumn in alternate rows in a table. i.e.,

\begin{tabular}{| l  r |}
  item 1  & item 2\\

  item 1  & item 2\\

  item 1  & item 2\\

Expected output:

share|improve this question
You can define \newcommand{\C}[1]{\multicolumn{2}{|c|}{#1} and use \C{item3}. – egreg Jul 15 '12 at 11:17
or if you want to think of it as a layout for a three item row, define \newcommand\abc[3]{#1&#2\\\multicolumn{2}{|c|}{#3}\\} then \abc{item 1}{\item 2}{item 3} \abc{item 1}{\item 2}{item 3}.. ... – David Carlisle Jul 15 '12 at 11:48
@david-carlisle, your idea is a nice one. Is it possible to do it with 'collcell' by applying 'multicol' to the third column? – anandogc Jul 15 '12 at 11:51
up vote 6 down vote accepted

Here is some code that will only work if every line ends with \\.

  Hello, world & Cheers & Middle \\
  abc & def & mid \\\hline

But really, you should use \collectcell.

share|improve this answer
Thank you very much. This is exactly what I needed. – anandogc Jul 15 '12 at 14:10
Can you please explain why are so many \afrergroup required. – anandogc Jul 15 '12 at 14:17
@anandogc The c column in a tabular roughly means \hskip\tabcolsep{\hfil\ignorespaces#\unskip\hfil}\hskip\tabcolsep, where # stands for the cell contents, \hskip\tabcolsep, \hfil, \ignorespaces and \unskip have to do with spacing. The group, {...} is there to match the array environment, where the math mode $...$ creates a group. <{...} puts its material after #, hence my three \aftergroup go inside the group. The first puts the second after }. The third puts the \newlinemulticol after }. The remaining \aftergroup moves the macro after & where it belongs. – Bruno Le Floch Jul 15 '12 at 18:57

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.