Smile for the Camera: a new cybercrime short story ebook.

Bug Tracker RSS feed

One or more errors has occurred:

I’m currently working on a major new version of the datatool package. This may take a while. Please be patient. (Experimental version available for testing.)

ID 130🔗
Date: 2019-05-24 16:05:26
Status Closed (Fixed)
Category datatool
Version 2.31
Summary Some tests don't support well \noalign material

Sign in to subscribe to notifications about this report.

Description

Hello,

Some tests in dataool.sty (2018/12/07 v2.31 (NLCT)) don't support well \noalign material in one of the <true> and <false> clauses. This is because they use \relax to be sure to terminate a <number>, but this is not necessary as what precedes is already a <number> according to TeX's grammar. The \relax, when seen (which depends on which clause is used), makes TeX stop its search for \noalign, which causes a (for instance) subsequent \rowcolor to fail, because \rowcolor expands to something containing \noalign, but that is too late for \noalign to be valid because of the unneeded \relax. For instance, let's have a look at:

\gdef\DTLiflastrow##1##2{%
  \expandafter\ifnum
   \csname c@DTLrow\romannumeral\dtlforeachlevel\endcsname
   =\csname dtlrows@#2\endcsname\relax
    ##1%
  \else
    ##2%
  \fi}%

\dtlrows@DBNAME being a \countdef token, it is already a <number>, therefore the \relax isn't necessary, and is actually harmful because it prevents the attached MWE from working ("Misplaced \noalign" error). Removing the \relax in the appropriate definition of \DTLiflastrow allows that example to work.

Note: both definitions of \DTLiflastrow have the same problem.

I haven't looked at all tests, but at least \DTLiffirstrow seems to suffer from the same problem:

\gdef\DTLiffirstrow##1##2{%
  \expandafter\ifnum
   \csname c@DTLrow\romannumeral\dtlforeachlevel\endcsname
   =1\relax
    ##1%
  \else
    ##2%
  \fi}%

The \relax shouldn't be needed since a space token terminates a TeX <number>. Besides, space tokens are ignored when TeX is looking for \noalign or \omit inside an alignment, therefore such a space token instead of the \relax would allow for the useful case where ##1 contains \noalign material.

FYI, this problem is mentioned here on TeX.SX:

Color rows with \rowcolor and datatool \DTLforeach loop

Thanks!

MWE

Download (487B)

\RequirePackage{filecontents}
\begin{filecontents*}{data.csv}
colname
first
second
\end{filecontents*}

\documentclass{article}
\usepackage[table]{xcolor}
\usepackage{datatool}

\DTLloaddb{sample}{data.csv}

\begin{document}

\begin{tabular}{c}
\rowcolor{orange}%
\DTLforeach*{sample}{\word=colname}{%
  \word
  \DTLiflastrow{\rowcolor{green}}{%
    \DTLifoddrow{\rowcolor{gray!20}}%
                {\rowcolor{orange}}%
  }%
}
After rows from the CSV file
\end{tabular}

\end{document}

Evaluation

I've removed \relax from \DTLiffirstrow and \DTLiflastrow in version 2.32 (2019-09-27) but your MWE is missing \\ so it won't work even with the fix. I'm guessing you intended \word\\ in the body of the loop.

Comments

3 comments.

🔗Comment from anonymous
Date: 2019-11-13 00:27:00

Yes, you guessed right about \word\\: somehow, I forgot the \\ when preparing the MWE---sorry about that.

Thanks for the fix. :-)

Replying to Comment #61:

Name (optional):

Are you human? Please confirm the bug report ID (which can be found at the top of this page) or login if you have an account.

Comment:


You can use the following markup:

Block:

[pre]Displayed verbatim[/pre]
[quote]block quote[/quote]

In line:

[tt]code[/tt]
[file]file/package/class name[/file]
[em]emphasized text[/em]
[b]bold text[/b]
[url]web address[/url] [sup]superscript[/sup]
[sub]subscript[/sub]

Ordered list:
[ol]
[li]first item[/li]
[li]second item[/li]
[/ol]

Unordered list:
[ul]
[li]first item[/li]
[li]second item[/li]
[/ul]

You can use the Preview button to review your message formatting before submitting.

🔗Comment from Nicola Talbot 🦜
Date: 2019-11-13 10:38:00

You're welcome :-)

Replying to Comment #62:

Name (optional):

Are you human? Please confirm the bug report ID (which can be found at the top of this page) or login if you have an account.

Comment:


You can use the following markup:

Block:

[pre]Displayed verbatim[/pre]
[quote]block quote[/quote]

In line:

[tt]code[/tt]
[file]file/package/class name[/file]
[em]emphasized text[/em]
[b]bold text[/b]
[url]web address[/url] [sup]superscript[/sup]
[sub]subscript[/sub]

Ordered list:
[ol]
[li]first item[/li]
[li]second item[/li]
[/ol]

Unordered list:
[ul]
[li]first item[/li]
[li]second item[/li]
[/ul]

You can use the Preview button to review your message formatting before submitting.

🔗Comment from LaTeX User
Date: 2023-06-22 16:29:21

I'm having the same problem with \DTLifstringeq.

Replying to Comment #129:

Name (optional):

Are you human? Please confirm the bug report ID (which can be found at the top of this page) or login if you have an account.

Comment:


You can use the following markup:

Block:

[pre]Displayed verbatim[/pre]
[quote]block quote[/quote]

In line:

[tt]code[/tt]
[file]file/package/class name[/file]
[em]emphasized text[/em]
[b]bold text[/b]
[url]web address[/url] [sup]superscript[/sup]
[sub]subscript[/sub]

Ordered list:
[ol]
[li]first item[/li]
[li]second item[/li]
[/ol]

Unordered list:
[ul]
[li]first item[/li]
[li]second item[/li]
[/ul]

You can use the Preview button to review your message formatting before submitting.


Add Comment

Name (optional):

Are you human? Please confirm the bug report ID (which can be found at the top of this page) or login if you have an account.

Comment:


You can use the following markup:

Block:

[pre]Displayed verbatim[/pre]
[quote]block quote[/quote]

In line:

[tt]code[/tt]
[file]file/package/class name[/file]
[em]emphasized text[/em]
[b]bold text[/b]
[url]web address[/url] [sup]superscript[/sup]
[sub]subscript[/sub]

Ordered list:
[ol]
[li]first item[/li]
[li]second item[/li]
[/ol]

Unordered list:
[ul]
[li]first item[/li]
[li]second item[/li]
[/ul]

You can use the Preview button to review your message formatting before submitting.

Page permalink: https://www.dickimaw-books.com/bugtracker.php?key=130