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

The following example has two normal LaTeX \newcommand macros and two xparse \NewDocumentCommand for specifying multicolumn text. The only difference between each pair of commands is one has the alignment character as part of the macro and one does not. However, the xparse version that requires the alignment character to be outside of the macro does NOT work and results in Misplaced \omit. error.


\newcommand{\MulticolumnB}[3]{ \multicolumn{#1}{#2}{#3}}

\NewDocumentCommand{\MulticolumnX}{m m m}{&\multicolumn{#1}{#2}{#3}}
\NewDocumentCommand{\MulticolumnY}{m m m}{ \multicolumn{#1}{#2}{#3}}

    {a} \MulticolumnA{4}{l}{A-abcdefghijkli}\\
    {a} \MulticolumnX{4}{l}{X-abcdefghijkli}\\

Above compiles as is, but does not compile if the one line is uncommented.

share|improve this question
up vote 12 down vote accepted

\NewDocumentCommand creates a robust command, via \protected. The documentation about e-TeX says, on page 14, that protected macros are not expanded when looking ahead in an alignment for \noalign or \omit. So, with \MulticolumnY after the &, the search for an \omit ends and when TeX expands \MulticolumnY it finds a misplaced \omit (from \multicolumn). You have to use \DeclareExpandableDocumentCommand for this.

With \MulticolumnX this doesn't happen, because the command is not expanded when TeX is looking for \omit; it finds &, so it finishes the table entry and starts a new one, but now it can see directly \multicolumn and is happy.

share|improve this answer
Yep, that fixes it. Thanks. – Peter Grill May 1 '11 at 23:37

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.