[Tex/LaTex] “Misplaced \omit” error in automatically generated table

errorstables

Firstly, I have read Werner's answer to "! Misplaced \omit" error but my problem is not solved there.

A few days ago I made a table very similar to the one below, except that one had one less row and column. There were no problems. Now I get an error. This monstrosity was created using esttab, a tool that exports STATA regression tables to latex.

Relevant part of my preamble:

%---------TABLES---------
\usepackage{booktabs}
\usepackage{tabu}
\usepackage{threeparttable}
\usepackage{multirow}
\usepackage{subcaption}
\usepackage{rotating}
%indents in tables (custom command)
\newcommand*{\TableIndent}{\hspace*{0.5cm}}
%-------END TABLES--------

%---- This is a crazy patch to make sure that tabu works with threeparttable %
\usepackage{etoolbox}
\makeatletter
\chardef\TPT@@@asteriskcatcode=\catcode`*
\catcode`*=11
\expandafter\patchcmd\csname\string\threeparttable\endcsname
  {\TPT@hookin{tabular}}
  {\TPT@hookin{tabular}\TPT@hookin{tabu}}
  {}{}
\catcode`*=\TPT@@@asteriskcatcode
\makeatother
%-----END TABLES-----%

Table:

\begin{sidewaystable}[!H]{
\def\sym#1{\ifmmode^{#1}\else\(^{#1}\)\fi}
\centering
\caption{Incidence Rate Ratios of job separation on 2004 self--reported willingness to take risks in general}
\resizebox{0.80\textwidth}{!}{%
\label{tab5}
\begin{tabular}{l*{12}{l}}
\toprule
          &  \multicolumn{6}{c}{Poisson estimates} & & \multicolumn{5}{c}{Negative Binomial estimates} \\ \cmidrule(l){2-7} \cmidrule(l){9-13}
          &\multicolumn{1}{l}{(1)}&\multicolumn{1}{l}{(2)}&\multicolumn{1}{l}{(3)}&\multicolumn{1}{l}{(4)}&\multicolumn{1}{l}{(5)} &\multicolumn{1}{l}{(6)}&$\qquad$&\multicolumn{1}{l}{(7)}&\multicolumn{1}{l}{(8)}&\multicolumn{1}{l}{(9)}&\multicolumn{1}{l}{(10)}\multicolumn{1}{l}{(11)}\\
\midrule

Self--reported willingness to take risks in general&    1.046\sym{*}  &    1.029         &    1.030         &    1.037         &    1.037\sym{*}  &    1.043\sym{*}  & &    1.046\sym{*}  &    1.029         &    1.030         &    1.037         &    1.037\sym{*}  \\
                &  (0.022)         &  (0.020)         &  (0.021)         &  (0.022)         &  (0.019)         &  (0.021) &        &  (0.022)         &  (0.020)         &  (0.021)         &  (0.022)         &  (0.019)         \\
\addlinespace
Time tracked in sample     &                  &    1.359\sym{***}&    1.403\sym{***}&    1.404\sym{***}&    1.476\sym{***}&    1.513\sym{***}&    &              &    1.359\sym{***}&    1.403\sym{***}&    1.404\sym{***}&    1.476\sym{***}\\
                &                  &  (0.027)         &  (0.030)         &  (0.029)         &  (0.030)         &  (0.033)  &       &                  &  (0.027)         &  (0.030)         &  (0.029)         &  (0.030)         \\
\addlinespace
Education (\textsc{casmin})\textdagger&     &             &                  &                 &                 &                  &                 &                  &                  &                 &                 &                  \\
\addlinespace
1. Inadequately Completed&                  &                  &    1.453         &    1.556\sym{*}  &                  &   1.153         & &                 &                  &    1.453         &    1.557\sym{*}  &                  \\
                &                  &                  &  (0.291)         &  (0.323)         &                  &  (0.264)         &                  &                  &  (0.291)         &  (0.323)         &                  \\
\addlinespace
2. General Elementary School&                  &                  &    0.696\sym{*}  &    0.727\sym{*}  &                  &    0.644\sym{**} &  &                &                  &    0.696\sym{*}  &    0.727\sym{*}  &                  \\
                &                  &                  &  (0.107)         &  (0.113)         &                  &  (0.099) &         &                  &                  &  (0.107)         &  (0.113)         &                  \\
\addlinespace
4. Intermediate General Qualification&                  &                  &    0.725\sym{**} &    0.721\sym{**} &                  &    0.762\sym{*}  & &                 &                  &    0.725\sym{**} &    0.721\sym{**} &                  \\
                &                  &                  &  (0.089)         &  (0.089)         &                  &  (0.087) &        &                  &                  &  (0.089)         &  (0.089)         &                  \\
\addlinespace
5. Intermediate Vocational&                  &                  &    0.573         &    0.600         &                  &    0.570       &  &                  &                  &    0.573         &    0.600         &                  \\
                &                  &                  &  (0.232)         &  (0.259)         &                  &  (0.169) &        &                  &                  &  (0.232)         &  (0.259)         &                  \\
\addlinespace
6. General Maturity Certificate&                  &                  &    0.877         &    0.908         &                  &    0.940       &  &                  &                  &    0.877         &    0.908         &                  \\
                &                  &                  &  (0.094)         &  (0.132)         &                  &  (0.111)  &       &                  &                  &  (0.094)         &  (0.132)         &                  \\
\addlinespace
7. Vocational Maturity Certificate&                  &                  &    0.629\sym{*}  &    0.662         &                  &    0.608\sym{*} & &                  &                  &    0.629\sym{*}  &    0.662         &                  \\
                &                  &                  &  (0.146)         &  (0.182)         &                  &  (0.144) &        &                  &                  &  (0.146)         &  (0.182)         &                  \\
\addlinespace
8. Lower Tertiary Education&                  &                  &    0.134\sym{*}  &    0.153\sym{*}  &                  &    0.254      &   &                  &                  &    0.134\sym{*}  &    0.153\sym{*}  &                  \\
                &                  &                  &  (0.109)         &  (0.127)         &                  &  (0.187) &        &                  &                  &  (0.109)         &  (0.127)         &                  \\
\addlinespace
9. Higher Tertiary Education&                  &                  &    0.671         &    0.780         &                  &    0.924     &    &                  &                  &    0.671         &    0.780         &                  \\
                &                  &                  &  (0.213)         &  (0.295)         &                  &  (0.223) &        &                  &                  &  (0.213)         &  (0.295)         &                  \\
\addlinespace
Male          &                  &                  &                  &    0.826\sym{*}  &                  &    0.899   &      &                  &                  &                  &    0.826\sym{*}  &                  \\
                &                  &                  &                  &  (0.071)         &                  &  (0.071) &        &                  &                  &                  &  (0.071)         &                  \\
\addlinespace
Age             &                  &                  &                  &    0.987         &                  &    1.005 &        &                  &                  &                  &    0.987         &                  \\
                &                  &                  &                  &  (0.019)         &                  &  (0.012) &        &                  &                  &                  &  (0.019)         &                  \\
\addlinespace
Average job duration&                  &                  &                  &                  &    0.719\sym{***}&    0.725\sym{***}& &                  &                  &                  &                  &    0.719\sym{***}\\
                &                  &                  &                  &                  &  (0.021)         &  (0.022) &        &                  &                  &                  &                  &  (0.021)         \\
\addlinespace
Total unemployment in years during 2004-2012&                  &                  &                  &                  &    0.885\sym{**} &    0.919  &       &                  &                  &                  &                  &    0.885\sym{**} \\
                &                  &                  &                  &                  &  (0.041)         &  (0.042) &        &                  &                  &                  &                  &  (0.041)         \\
\addlinespace
Intercept        &    0.628\sym{***}&   0.0962\sym{***}&   0.0912\sym{***}&    0.122\sym{***}&    0.108\sym{***}&   0.0946\sym{***}& &    0.628\sym{***}&   0.0962\sym{***}&   0.0912\sym{***}&    0.122\sym{***}&    0.108\sym{***}\\
                &  (0.080)         &  (0.017)         &  (0.018)         &  (0.051)         &  (0.018)         &  (0.029)   &      &  (0.080)         &  (0.017)         &  (0.018)         &  (0.051)         &  (0.018)         \\
\midrule
Log pseudolikelihood         &        -796         &    -690              &     -599             &      -598    &       -634       &    -554          &              &                  &                  &                  &                  \\
$\alpha_i$        &                  &                  &                  &                  &                  &                  &    0.185\sym{***} & 0.255e-06\sym{***} & 0.118e-6\sym{***} & 6.36e-08\sym{***}& 7.66e-08\sym{***}\\
                &                  &                  &                  &                  &                  &                  &  (0.082)         &  (0.000)         &  (0.000)         &  (0.000)         &  (0.000)         \\
\midrule
$N$    &      659         &      659         &      595         &      595         &      659         &      595         &      659         &      659         &      595         &      595         &      659         \\
\bottomrule
\multicolumn{13}{l}{\footnotesize\emph{Notes:} Robust Standard errors in parentheses.}\\
\multicolumn{13}{l}{\footnotesize \sym{*} $p<0.05$, \sym{**} $p<0.01$, \sym{***} $p<0.001$.}\\
\multicolumn{13}{l}{\footnotesize \textdagger Omitted base category is CASMIN classification 0: ``In school''. CASMIN classification 3. ``Basic vocational qualification'' has been dropped due to the low number of respondents (2).}\\
\end{tabular}%
}
}
\end{sidewaystable}

The error I get is

Error in thesis.tex (line 351): Misplaced \omit.
\multispan ->\omit \@multispan l.351 } I expect to see \omit only after tab marks 
or the \cr of an alignment. Proceed, and I'll ignore this case. 

line 351 is towards the end of the table:

\end{tabular}%
}    <<< This is line 351
}
\end{sidewaystable}

Everything renders out fine and looks great, but I really hate creating a document with errors.

Best Answer

A & is missing from the second header row: where

\multicolumn{1}{l}{(10)}\multicolumn{1}{l}{(11)}\\

appears, there should be

\multicolumn{1}{l}{(10)}&\multicolumn{1}{l}{(11)}\\

Of course several improvements can be done to the input, but the main problem is that one.

Use a “divide and conquer” method: I commented out all lines of the table and started uncommenting them one by one until the error appeared. Then I knew what line was the culprit and found out why.

Related Question