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

The following 'naïve' solution throws the error:

ERROR: Misplaced \omit.

--- TeX said ---
\multispan ->\omit 
l.13   }
--- HELP ---
From the .log file...

I expect to see \omit only after tab marks or the \cr of
an alignment. Proceed, and I'll ignore this case.


\seq_set_split:Nnn \l_tmpa_seq { , } { 1 , 2 , 3 }

\begin{tabular}{*{\seq_count:N \l_tmpa_seq}{c}}
  hellow & world \\
  \seq_map_inline:Nn \l_tmpa_seq {
    \multicolumn{1}{|c|}{#1} &
  } \\
  goodbye & world

where I'd like to come up with a table like:

  hello    world
|   1    |   2   | 3 |
 goodbye   world

What's the most efficient / clearest way to go about this?

share|improve this question
Isn't this caused (as the help tells you) by an unequal number of items in each row? You have 2 cells in the first row, and then write a sequence of three cells to the second. Perhaps add an & to the first and last row? – hugovdberg Apr 3 '14 at 18:34
@hugovdberg The error message is clear, but you actually don't need an equal number of items in each row :) as long as you don't make more columns than you specify, you're ok. The question is more to get the result I'm going for, not necessarily to fix the code I have. I'm fairly certain my approach will turn out to be utterly fruitless :( – Sean Allred Apr 3 '14 at 18:35
and what about a newline after the \seq_map_inline and an extra & after the third item? You have 3 items, each with a & so specifying 4 cells in that row actually, while a count of the sequence returns 3. Perhaps a conditional if items < count insert &? – hugovdberg Apr 3 '14 at 18:37
@hugovdberg Ah yes, that's a typo :) see my edit – Sean Allred Apr 3 '14 at 18:39
It's a problem of expandability. \seq_map_inline:Nn is not expandable. You can use \seq_map_function:NN after defining a (non-protected) function which does \multicolumn{...}{...}{#1}. – Bruno Le Floch Apr 3 '14 at 21:02
up vote 3 down vote accepted

You have to use an expandable function, because any unexpandable token makes \multicolumn illegal after it.



\seq_set_split:Nnn \l_tmpa_seq { , } { 1 , 2 , 3 }
\seq_pop_left:NN \l_tmpa_seq \l_tmpa_tl
\cs_new:Npn \sean_add_mc:n #1
  & \multicolumn{1}{c|}{#1}

\begin{tabular}{*{\int_eval:n { \seq_count:N \l_tmpa_seq + 1 }}{c}}
  hellow & world & some \\
  \seq_map_function:NN \l_tmpa_seq \sean_add_mc:n \\
  goodbye & world & again

Note that the first item should be detached because it needs a different treatment.

enter image description here

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.