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.

1 Answer 1


\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 \NewExpandableDocumentCommand for this.

\NewExpandableDocumentCommand has been added in the 2017/03/11 release of xparse. Previously only \DeclareExpandableDocumentCommand was available.

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.


You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .