Using \input
inside a tabular
environment does not seem to work in all cases, but I don't see why.
The MWE below gives the following error message:
! Misplaced \noalign.
\toprule ->\noalign
{\ifnum 0=`}\fi \@aboverulesep =\abovetopsep \global \@b...
l.1 \toprule
File main.tex
:
\documentclass{standalone}
\usepackage{booktabs}
\begin{document}
\begin{tabular}{ll}
\input{inp}
\end{tabular}
\end{document}
File inp.tex
:
\toprule
a & b \\
c & d \\
\bottomrule
The document compiles properly if the contents of inp.tex
are pasted into the tabular
environment. What is happening here?
\documentclass{standalone}
\usepackage{booktabs}
\begin{document}
\begin{tabular}{ll}
\toprule
a & b \\
c & d \\
\bottomrule
\end{tabular}
\end{document}
EDIT: The following question is related: Why is \input not expandable?