1

SOLVED! (see below)

I'm trying to create a longtable that uses a generated input file.

This is my main file:

\documentclass[a4paper]{article}

\usepackage[left=1cm, right=1cm, top=2cm, bottom=2cm]{geometry} \usepackage{ifthen} \usepackage[pdftex]{graphicx} \usepackage[utf8]{inputenc} \usepackage[T1]{fontenc} \usepackage{longtable}

\pagestyle{empty}

\begin{document} \begin{longtable}{|l|l|l|} \hline Name & First Name & ID \ \hline\hline

    \input{generated.tex}

    \hline
\end{longtable}

\end{document}

This is the content of generated.tex:

Ebug & Dieter & 515177 \\\hline
Mority & Joe & 515192 \\\hline
Underland & Barbara & 515211 \\\hline
Ebug & Denis & 515230 \\\hline
Mustermann & Michelle & 515240 \\\hline
Onemore & Karsten & 515253 \\\hline
Astone & Leonie & 515271 \\\hline

However, when using \input{generated.tex}, I get the following errors during compilation:

! Misplaced \noalign.
\hline ->\noalign 
                  {\ifnum 0=`}\fi \penalty \@M \futurelet \@let@token \LT@@h...
l.25        \hline

? H I expect to see \noalign only after the \cr of an alignment. Proceed, and I'll ignore this case.

? ! Misplaced \omit. \multispan ->\omit @multispan l.26 \end {longtable} ? H I expect to see \omit only after tab marks or the \cr of an alignment. Proceed, and I'll ignore this case.

Note that I'm using to output of the interactive mode here to get more info on the errors.

These errors disappear if I remove the last \hline. Apart from those errors, I also get a weird extra row at the end of my table. This also doesn't disappear when removing the last \hline.

All the errors and weird last row disappear when I simply add the contents of the generated.tex into the main file. This confuses me because \input is supposed to be the equivalent of simply adding the content of the specified file in its place. Does anyone have any experiences with this? From the error messages it looks like the problem is a carriage return at the end of the generated.tex file.

SOLUTION:

As Phelype Oleinik mentioned in the comments, this has to do with a change made to \input in fall of 2020. More info can be found here.

The solution is to define a custom command \expandableinput before the beginning of the document:

\ExplSyntaxOn % providing \expandableinput
\cs_new:Npn \expandableinput #1
{ \use:c { @@input } { \file_full_name:n {#1} } }
\ExplSyntaxOff

Then this new command can be used instead of \input.

Lithimlin
  • 133

0 Answers0