When I try to insert a \multicolumn
with a macro created using xparse
's \NewDocumentCommand
, I get a Misplaced \omit
error. When I define the "same" command using \def
, every thing works fine.
How come? Can I work around this somehow?
\documentclass{article}
\usepackage{xparse}
% This definition does not work.
\NewDocumentCommand\foo{}{%
\multicolumn{1}{c}{asdf}%
}
% This one does.
%\def\foo{%
% \multicolumn{1}{c}{asdf}%
%}
\begin{document}
\begin{tabular}{ c }
\foo
\end{tabular}
\end{document}
\NewDocumentCommand
defines the macro as robust, you can use\NewExpandableDocumentCommand
instead.