T-F-S / csvsimple

A LaTeX package for lightweight CSV file processing.
http://www.ctan.org/pkg/csvsimple
LaTeX Project Public License v1.3c
24 stars 5 forks source link

Errors due to change of \par in the LaTeX kernel. Was: \csvautotabular doesn't work after newline anymore and produces very unhelpful Errors. #11

Closed Cube707 closed 3 years ago

Cube707 commented 3 years ago

I have an issue that is probably related to the kernelupdate from the 01.06.2021

It is not longer possible to use \csvautotabular directly after text or a newline. A \par is required befor the command. That was not the case prior.

While this is not to bad and not proper form at all, the errors that come from this are very unhelpful, so finding this will be very hard and frustrating for not so experienced people.

How to reproduce:

run the following code through pdflatex :

\documentclass{article}
\usepackage{csvsimple}

\begin{filecontents*}{temp.csv}
A,B,C
1,2,3
\end{filecontents*}

\begin{document}
    Some random text.\\
    \csvautotabular{temp.csv}
\end{document}

The resulting Errors, as shown by VS Code:

File ended while scanning use of \pgfkeys@temp.
<inserted text> 

Emergency stop.
<*> d:/Projects/LaTex/stack/test.tex

 ==> Fatal error occurred, no output PDF file produced!
Transcript written on d:/Projects\LaTex\stack\.aux\test.log.

Missing number, treated as zero.
<to be read again> 

Illegal unit of measure (pt inserted).
<to be read again> 

Package csvsimple: File 'temp.csv' starts with an empty line!.

Missing \endcsname inserted.
<to be read again> 

Extra \endcsname.
\pgfkeyslet ...ter \let \csname pgfk@#1\endcsname 

Extra \endcsname.
\pgfkeyslet ...ter \let \csname pgfk@#1\endcsname 

complete Logfile: test.log

System:

Tested on:

nilshoell commented 3 years ago

I have a most likely related problem, although I'm using the \csvreader command. It only appeared after upgrading to Tex Live 2021, and subsequently the kernel 2021-06-01 as with @Cube707's issue.

\documentclass{article}
\usepackage{csvsimple}

\begin{filecontents*}{temp.csv}
    id,name,duration,group
    00,R. Greer,45,C
    01,M. Wade,45,U
    02,C. Sosa,35,U
    03,N. Dixon,30,U
    04,D. Velasquez,30,U
    05,R. Logan,50,U
    06,S. Key,30,U
    07,M. Dyer,60,U
    08,A. Terrell,40,C
    09,P. Lamb,30,U
    10,M. Bowen,40,U
    11,E. Owen,45,C
    12,A. Wallace,40,U
    13,C. Krause,35,C
    14,G. Sexton,45,C
    15,C. Rubio,55,U
    16,A. Malone,30,C
    17,D. Buck,45,U
    18,E. Whitney,30,C
    19,L. Backes,40,U
\end{filecontents*}

\begin{document}

\begin{table}
    \caption{Sample CSV Table}
    \centering
    \begin{tabular}{c c c r}
        \textbf{ID} & \textbf{Name} & \textbf{Group} & \textbf{Duration} (min.)\\
        \csvreader[
            late after line=\\,
            head to column names
            ]
        {temp.csv}{}
        {\id & \name & \group & \duration}
    \end{tabular}
    \label{table:interviews}
\end{table}

\end{document}

The table builds without errors, but the output shows two of the original rows packed into a single cell each:

grafik

This can be solved by either using different IDs than 00 and 11 (in fact, my tests showed that every id with identical digits such as 33, 44, 555555 etc. produced this problem), or by wrapping it in braces such as {00}. I have no idea if this is related to the initial issue, but since it seems related to the Kernel upgrade I'll leave it here.

T-F-S commented 3 years ago

This is bad news.

I compiled both examples with my 14 day old installation and had no errors. After updating to the current release, I can confirm that both errors are present.

Currently, I cannot say if the reason is the same. According to LaTeX News 33 from June 2021, the new kernel added the hook concept to paragraphs and changed the implementation of \\. I can only speculate that these changes may be causative for the problems.

I will investigate further, but at the moment I have no solution.

T-F-S commented 3 years ago

It seems that the change of \par in the LaTeX kernel caused the problem. Empty lines have been detected by csvsimple with an \if condition to the original \par. If this is replaced by an \ifx condition, the problems seems to be solved.

I try to publish a fix as soon as possible.

T-F-S commented 3 years ago

Solved (hopefully) with version 1.22 (2021/06/07).

Cube707 commented 3 years ago

Works in my testcase and in my Project. Thank you. Should I close or do you whant to keep it open in case more Kernel related issues come up?

T-F-S commented 3 years ago

I close it for \par now. If a new (kernel or not) issue comes up, you can open a new issue (or reopen this, if it seems connected).

kazumamatata commented 1 year ago

I have a similar problem, in which the backslash seems to be not to working in the first row (ex.: \alpha). Is it related to this issue? And is there already a fix for that?

How to reproduce:

run the following code through pdflatex :

\documentclass{article}
\usepackage{csvsimple}

\begin{filecontents*}{temp.csv}
A,B,\alpha
1,2,3
\end{filecontents*}

\begin{document}
    Some random text.\\
    \csvautotabular{temp.csv}
\end{document}

Then the following error message appears:

! Missing \endcsname inserted.
<to be read again> 
                   \alpha 
l.11     \csvautotabular{temp.csv}

? 
! Extra \endcsname.
\pgfkeyslet ...ter \let \csname pgfk@#1\endcsname 
                                                  #2
l.11     \csvautotabular{temp.csv}

? 
)
Runaway argument?
\pgfkeyssetvalue {/csv head/\alpha /.@body}{\gdef ##1{\csvcoliii }\csv@AtEndLoo
p \ETC.
! File ended while scanning use of \pgfkeys@temp.
<inserted text> 
                \par 
<*> test.tex

System:

Tested on: pdfTeX, Version 3.141592653-2.6-1.40.24 (TeX Live 2022) (preloaded format=pdflatex) Package: csvsimple 2022/09/20 v2.3.2

T-F-S commented 1 year ago

I have a similar problem, in which the backslash seems to be not to working in the first row (ex.: \alpha). Is it related to this issue? And is there already a fix for that?

Did this work with former LaTeX kernels? I do not have an old LaTeX installation to test, but I would cautiously guess that this never worked for the first line (?) which is treated special by csvsimple.

However, csvsimple is superseded by csvsimple-l3 now which is based on LaTeX3 and should be more robust. With csvsimple-l3, the following compiles for me without error:

\documentclass{article}
%\usepackage{csvsimple}
\usepackage{csvsimple-l3}

\begin{filecontents*}{temp.csv}
A,B,$\alpha$
1,2,3
\end{filecontents*}

\begin{document}
    Some random text.\\
    \csvautotabular{temp.csv}
\end{document}

grafik

I hope, switching to csvsimple-l3 is an option for you, because the legacy csvsimple should stay as untouched as possible for backward compatibility.

kazumamatata commented 1 year ago

Thank you for your answer. Changing to csvsimple-l3 solved the problem!