# ! Misplaced \omit error when inputting table with multicolumn

I am building a table from several components that I automatically export from STATA. For this, I use \input{} to input the components inside a table and tabular environment. This usually works well, but I now want to input a line that contains a \multicolumn . This generates the LaTeX error !Misplaced \omit. \multispan ->\omit. In addition, the line that I input starts further to the right of the table and not all the way to the left as it should. Here is a minimal example of the code:

 \documentclass[11pt,oneside]{amsart}
\usepackage{booktabs,multirow}
\usepackage{tabularx}

\begin{document}
\begin{table}
\caption{Table 1}
\begin{tabular}{llcc}
\toprule
\input{no_degree}
\midrule
\multicolumn{4}{l}{Vocational training}\\
& No training & 400 & 35 \\
\midrule
\end{tabular}
\end{table}
\end{document}


The table to input, no_degree has the following code:

 \multicolumn{2}{l}{\textbf{No info on secondary degree}} & 214 & 20 \\


Running this generates the error. However, when I just copy and paste exactly the content of the inputted file, the code runs smoothly. This code is the following:

 \documentclass[11pt,oneside]{amsart}
\usepackage{booktabs,multirow}
\usepackage{tabularx}

\begin{document}
\begin{table}
\caption{Table 1}
\begin{tabular}{llcc}
\toprule
\multicolumn{2}{l}{\textbf{No info on secondary degree}}&214& 20 \\
\midrule
\multicolumn{4}{l}{Vocational training}\\
& No training & 400 & 35 \\
\midrule
\end{tabular}
\end{table}
\end{document}


Thanks a lot!

• \csname @@input\endcsname no_degree  – David Carlisle May 18 '18 at 15:10
• your mwe works fine, of course if you add missing \end{table} – Zarko May 18 '18 at 15:28
• Using \csname works! Thank you! I forgot \end{table} , but had it when I ran the code and it still gave me errors. I added \end{table} in the example. – ZoeFrance May 18 '18 at 16:55
• @Zarko no you can't have a multicolumn in the first cell if you use \input{} – David Carlisle May 18 '18 at 18:14
• @DavidCarlisle, apparently i don't understand the question. sorry for noise. – Zarko May 18 '18 at 18:40

You can not have any non-expandable commands before \multicolumnas once a non expandable token is seen the column cell is started and it is too late to make a spanning cell. unfortunately the LaTeX \input command is non-expandable, to add the brace syntax however you can use the primitive input as

\csname @@input\endcsname no_degree


or

 \@@input no_degree


if you are in a region where @ is a letter.

the primitive input is expandable and does not prevent a \multicolumn in the file from working.

• So, I have exactly the same problem as above, but I don't understand the answer (which solved the problem, apparently). Where in my script should I put the lines you wrote, @David Carlisle? Could you please clarify? – Roland Apr 3 '19 at 18:11
• @Roland if you have \input{whatever-your-file-is-called} in a tabular then replace it by \csname @@input\endcsname whatever-your-file-is-called  – David Carlisle Apr 3 '19 at 19:42