# Reading Table Body from file (Problem with KoMa Script?)

David Carlisle d.p.carlisle at gmail.com
Mon Jan 6 14:21:46 CET 2020

texlive list is the wrong place to raise package issues as it can only
distribute what's on ctan, you'd need to raise on the koma-script
tracker at

https://komascript.de/

scrartcl changes \InputIfFileExists (which is used by \input) such
that it calls additional file hooks which means that it can not be
followed by \hline \bottomrule etc

This is probably something that should be a documented feature rather
than a bug, (the same is always true that you can not have such
constructs at the start of the included file)
The usual workaround is to use the primitive expandable input which is

\begin{tabular}{ll}
\toprule
Col 1 & Col 2 \\
\midrule
\csname @@input\endcsname tablebody
\bottomrule
\end{tabular}

On Mon, 6 Jan 2020 at 12:55, Alexander Krumeich
<alexander.krumeich at gmail.com> wrote:
>
> I have quite a few instances where I read the table body from a file
> (see MWE below). This used to work well up until before Christmas, but
> as of today LuaTeX crashes with:
>
> ! Misplaced \noalign.
> \bottomrule ->\noalign
>                        {\ifnum 0=}\fi \@aboverulesep =\aboverulesep \global...
>
> l.19 \end{tabularx}
>
> When I don't read the table body from a separate file it works
> alright. Please take a look at the following example:
>
> \documentclass[a4paper]{scrartcl}
> \usepackage{tabularx}
> \usepackage{booktabs}
>
> \begin{filecontents}{tablebody.tex}
>   abc & 123 \\
>   def & 456 \\
> \end{filecontents}
>
> \begin{document}
>
> \begin{tabularx}{1\linewidth}{XX}
>   \toprule
>   Col 1 & Col 2 \\
>   \midrule
>   \input{tablebody}
>   \bottomrule
> \end{tabularx}
>
> \end{document}
>
> Further experiments show that if I replace the "scrartcl" class with
> "article", LuaTeX does not crash. So it seems that something might be
> wrong after the KoMa Script update of December 23rd?
>
> I'd be glad if somebody could look into this.
>
> Thanks
>
>    Alexander
`