16

The code below describes a table that goes like:

|_|x x|x x|

|x|x|x|x|x|

|x|x|x|x|x|

where

|_| = empty cell, |x x| = multicolumn{2}, |x| = cell with text in it.

\begin{tabular}{c|c|c|c|c|}
\label{tlc}
\cline{2-5}
& \multicolumn{2}{|c}{1 Sec Trials} & \multicolumn{2}{|c|}{100 Sec Trials} \\
\hline
\multicolumn{1}{|c|}{Target Rate} & Mean & Std. Dev & Mean & Std. Dev \\
\hline
\multicolumn{1}{|r|}{1Hz} & 1.07 & 1.08 & 1.22 & 0.11 \\
\multicolumn{1}{|r|}{5Hz} & 4.71 & 2.09 & 4.51 & 0.21 \\
\multicolumn{1}{|r|}{10Hz} & 10.3 & 3.28  & 10.1 & 0.32 \\
\multicolumn{1}{|r|}{100Hz} & 93.6 & 9.91 & 94.6 & 0.97 \\
\hline
\end{tabular}

However, when I run it I get an error that reads

! Misplaced \omit.
\@cline #1-#2\@nil ->\omit
\@multicnt #1\advance \@multispan \m@ne \ifnum \@...
l.60 \cline{2-5}
I expect to see \omit only after tab marks or the \cr of
an alignment. Proceed, and I'll ignore this case.

I've Googled around and it seems that people often get errors like this when nesting \multicolumns inside \multirows, or when they put text in the cell before starting the \multicolumn. But that is not the case in my code.

Can anyone tell me what is going on??

3

4 Answers 4

18

You cannot place a \label as the first element in a cell. If you're interested in labelling the table, place the tabular in a table environment, add a \caption and place the \label after it:

enter image description here

\documentclass{article}
\begin{document}
\begin{table}
  \centering
  \begin{tabular}{c|c|c|c|c|}
    \cline{2-5}
    & \multicolumn{2}{|c}{1 Sec Trials} & \multicolumn{2}{|c|}{100 Sec Trials} \\
    \hline
    \multicolumn{1}{|c|}{Target Rate} & Mean & Std. Dev & Mean & Std. Dev \\
    \hline
    \multicolumn{1}{|r|}{1Hz} & 1.07 & 1.08 & 1.22 & 0.11 \\
    \multicolumn{1}{|r|}{5Hz} & 4.71 & 2.09 & 4.51 & 0.21 \\
    \multicolumn{1}{|r|}{10Hz} & 10.3 & 3.28  & 10.1 & 0.32 \\
    \multicolumn{1}{|r|}{100Hz} & 93.6 & 9.91 & 94.6 & 0.97 \\
    \hline
  \end{tabular}
  \caption{Here is a caption}\label{tlc}
\end{table}
\end{document}

Here is a booktabs alternative to your tabular:

enter image description here

\documentclass{article}
\usepackage{booktabs}% http://ctan.org/pkg/booktabs
\begin{document}
\begin{table}
  \centering
  \begin{tabular}{r*{4}{c}}
    \toprule
    & \multicolumn{2}{c}{1 Sec Trials} & \multicolumn{2}{c}{100 Sec Trials} \\
    \cmidrule(lr){2-3} \cmidrule(lr){4-5}
    Target Rate & Mean & Std. Dev & Mean & Std. Dev \\
    \midrule
    1Hz & 1.07 & 1.08 & 1.22 & 0.11 \\
    5Hz & 4.71 & 2.09 & 4.51 & 0.21 \\
    10Hz & 10.3 & 3.28  & 10.1 & 0.32 \\
    100Hz & 93.6 & 9.91 & 94.6 & 0.97 \\
    \bottomrule
  \end{tabular}
  \caption{Here is a caption}\label{tlc}
\end{table}
\end{document}
0
3

I was using the longtable environment and got the \omit error message, too. In my case I had the caption/label integrated also in front of the table content. By integrating a \\ after the label command, the error message is avoided.

0
3

I stumbled in this problem too, and I solved it as I tried to create the MWE, so I am reporting for future references, maybe it's trivial, but sometimes you can miss it when you have big tables. I wanted to have the first row cells bold and centered, so I tried:

    \documentclass{article}
    \begin{document}
    \newcommand{\myh}[1]{\textbf{\multicolumn{1}{c}{#1}}}

    \begin{tabular}{|ccccc|}
    \myh{99} & \myh{4} & \myh{3} & \myh{2} & \myh{1}\\
    \end{tabular}
    \end{document}

The solution was:

    \newcommand{\myh}[1]{\multicolumn{1}{c}{\textbf{#1}}

That is: formatting inside multicolumn and not outside. Hope it helps.

2
  • @egreg, you're right, I left it by mistake, when I was stripping the code to the bone. I am going to edit the comment
    – massi
    Mar 11, 2019 at 17:45
  • Yes @massi, this helps! Thank you very much.
    – pdini
    Jun 21, 2020 at 9:54
3

Ensure you haven't redefined span! I had

\def\span#1{\ensuremath{\text{span}\left(#1\right)}}

in my preamble. Took me ages to figure it out.

For someone who needs to know how to get back the definition of span before the error,

% store default def of span
\let\oldspan\span

% redefine span for using in the whole document
\def\span...

% before the blocks in which you need the default def of span
\let\span\oldspan

% blocks need default span

% redefine span for the whole doc
\def\span...
0

You must log in to answer this question.

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