I have the following code with a command that creates rows for a tabular:
\documentclass[letterpaper,10pt]{article}
\usepackage[utf8]{inputenc}
\usepackage{xstring}
\newcommand*{\condrow}[2]{
\IfEqCase{#1}{
{l}{#2 & & \\}
{r}{ & & #2 \\}
{c}{ & #2 & \\}
{m}{\multicolumn{3}{c}{#2} \\}
}[\PackageError{condrow}{Undefined option: #1}{}]
}
\begin{document}
\begin{tabular}{|c|c|c|}
\condrow{l}{left}
\condrow{r}{right}
\condrow{c}{center}
\multicolumn{3}{c}{manual multi} \\ % WORKS
\condrow{m}{condrow multi} % FAILS
\end{tabular}
\end{document}
While using the \multicolumn directly in the tabular works, using \multicolumn through the command \condrow fails.
My guess is that \IfEqCase in \condrow prepends something to the beginning of the \multicolumn command, triggering the following error:
! Misplaced \omit.
\multispan ->\omit
\@multispan
l.20 \condrow{m}{condrow multi}
% FAILS
Prepending \\ before \multicolumn in the command makes the error disappear, but inserts an empty row.
The problem Misplaced \omit. \multispan with \newcommand is similar. However, the answers do not solve my case. I have tried using the ifthen package for branching without success.
Any ideas how to fix this?



! Undefined control sequence. \condrow #1#2->\str_case:nnF {#1}{{l}{#2&&\\}{r}{&\\}{c}{&\\}{m}{\mult... l.20 \condrow{l}{left}– faf0 Aug 29 '13 at 17:05texlive-fullon Ubuntu 12.04. – faf0 Aug 29 '13 at 17:10