表格中最后一行后面有额外的(不需要的)垂直条(从 Tex Live 2019 更新到 Tex Live 2021 后)

表格中最后一行后面有额外的(不需要的)垂直条(从 Tex Live 2019 更新到 Tex Live 2021 后)

自从更新到 Tex Live 2021(从 2019 版开始)以来,表格中最后一行后面出现了两个额外的(不需要的)垂直条。这在 2019 版中没有发生过。

在此处输入图片描述

我究竟做错了什么?

这是 MWE

\documentclass[a4paper, 12pt]{article}
\usepackage{float}
\begin{filecontents}{\jobname.txt}
&title1&title2&title3&title4 \\\hline
\end{filecontents}
\begin{document}
\begin {table}[H]
\scriptsize
\begin{center}
\begin{tabular}{| p{4.5cm} |p{2cm} |p{2cm} |p{2cm} |p{2cm}| }
\hline 
\input{\jobname.txt}
\end{tabular}
\end{center}
\end {table}
\end{document}

版本pdflatex

pdfTeX 3.141592653-2.6-1.40.22 (TeX Live 2021)
kpathsea version 6.3.3
Copyright 2021 Han The Thanh (pdfTeX) et al.
There is NO warranty.  Redistribution of this software is
covered by the terms of both the pdfTeX copyright and
the Lesser GNU General Public License.
For more information about these matters, see the file
named COPYING and the pdfTeX source.
Primary author of pdfTeX: Han The Thanh (pdfTeX) et al.
Compiled with libpng 1.6.37; using libpng 1.6.37
Compiled with zlib 1.2.11; using zlib 1.2.11
Compiled with xpdf version 4.03

答案1

感谢@UlrikeFischer,以下是该问题的解决方案:

\documentclass[a4paper, 12pt]{article}
\ExplSyntaxOn % providing \expandableinput
\cs_new:Npn \expandableinput #1
  { \use:c { @@input } { \file_full_name:n {#1} } }
\ExplSyntaxOff


\usepackage{float}
\begin{filecontents}{\jobname.txt}
&title1&title2&title3&title4 \\\hline
\end{filecontents}
\begin{document}
\begin {table}[H]
\scriptsize
\begin{center}
\begin{tabular}{| p{4.5cm} |p{2cm} |p{2cm} |p{2cm} |p{2cm}| }
\hline 
\expandableinput{\jobname.txt}
\end{tabular}
\end{center}
\end {table}
\end{document}

相关内容