Latest news 2024-03-02: Ebook sale (3rd–9th March 2024): short story cybercrime fiction Unsocial Media free; short story noir crime fiction I’ve Heard the Mermaid Sing free; crime fiction novel The Private Enemy US$1.99; illustrated children’s story The Foolish Hedgehog US$0.99. For further details, see latest blog post.

Bug Tracker RSS feed

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 202🔗
Date: 2022-05-02 16:58:26
Last update: 2022-05-02 17:44:23
Status Open
Sign in if you want to bump this report.
Category datatool
Version 2.32
Summary \dtldisplaystarttab is broken with \DTLdisplaylongdb

Sign in to subscribe to notifications about this report.

Description

datatool 2.32 2019-09-27

\dtldisplaystarttab is broken with \DTLdisplaylongdb

With \DTLdisplaylongdb redefining \dtldisplaystarttab to deliver \hline so that each table-head has a horizontal line above it leads to an error-message about ! Misplaced \noalign:

\documentclass{article}
\usepackage{datatool,longtable}

%===============================================================
\DTLnewdb{MyDataBase}%
\DTLaddcolumn{MyDataBase}{columnA}%
\DTLsetheader{MyDataBase}{columnA}{First Column}%
\DTLaddcolumn{MyDataBase}{columnB}%
\DTLsetheader{MyDataBase}{columnB}{Second Column}%
%---------------------------------------------------------------
\DTLnewrow{MyDataBase}
\DTLnewdbentry{MyDataBase}{columnA}{Row 1 Col A}
\DTLnewdbentry{MyDataBase}{columnB}{Row 1 Col B}
%---------------------------------------------------------------
\DTLnewrow{MyDataBase}
\DTLnewdbentry{MyDataBase}{columnA}{Row 2 Col A}
\DTLnewdbentry{MyDataBase}{columnB}{Row 2 Col B}
%===============================================================

\begin{document}

\begingroup
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%This doesn't work out but yields  ! Misplaced \noalign.
\renewcommand{\dtldisplaystarttab}{\hline}%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\renewcommand\dtldisplayafterhead{\hline}%
\renewcommand\dtldisplaystartrow{\hline}%
\renewcommand{\dtldisplayendtab}{\tabularnewline\hline}%
\renewcommand{\dtlbeforecols}{|}%
\renewcommand{\dtlaftercols}{|}%
\renewcommand{\dtlbetweencols}{|}%
\renewcommand\dtlheaderformat[1]{\textbf{#1}\hfil\null}%
\DTLdisplaylongdb{MyDataBase}
\endgroup

\end{document}
Ulrike Fischer delved into the code of datatool and found that this might be a bug:

For \DTLdisplaydb the code does \dtldisplaystarttab\@dtl@resetdoamp, but for \DTLdisplaylongdb the order is exchanged \@dtl@resetdoamp\dtldisplaystarttab and the first command starts the column before \hline coming from \dtldisplaystarttab is carried out.

If the code of the datatool-package is patched accordingly, everything seems to work out:

\documentclass{article}
\usepackage{datatool,longtable,etoolbox}

\makeatletter
\expandafter\patchcmd\expandafter{\csname\string\DTLdisplaylongdb\endcsname}%
         {\@dtl@resetdoamp\dtldisplaystarttab}%
         {\dtldisplaystarttab\@dtl@resetdoamp}%
         {\message{Patching succeeded.}}%
         {\message{Patching failed.}}%
\makeatother

%===============================================================
\DTLnewdb{MyDataBase}%
\DTLaddcolumn{MyDataBase}{columnA}%
\DTLsetheader{MyDataBase}{columnA}{First Column}%
\DTLaddcolumn{MyDataBase}{columnB}%
\DTLsetheader{MyDataBase}{columnB}{Second Column}%
%---------------------------------------------------------------
\DTLnewrow{MyDataBase}
\DTLnewdbentry{MyDataBase}{columnA}{Row 1 Col A}
\DTLnewdbentry{MyDataBase}{columnB}{Row 1 Col B}
%---------------------------------------------------------------
\DTLnewrow{MyDataBase}
\DTLnewdbentry{MyDataBase}{columnA}{Row 2 Col A}
\DTLnewdbentry{MyDataBase}{columnB}{Row 2 Col B}
%===============================================================

\begin{document}

\begingroup
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%This does work out after patching:
\renewcommand{\dtldisplaystarttab}{\hline}%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\renewcommand\dtldisplayafterhead{\hline}%
\renewcommand\dtldisplaystartrow{\hline}%
\renewcommand{\dtldisplayendtab}{\tabularnewline\hline}%
\renewcommand{\dtlbeforecols}{|}%
\renewcommand{\dtlaftercols}{|}%
\renewcommand{\dtlbetweencols}{|}%
\renewcommand\dtlheaderformat[1]{\textbf{#1}\hfil\null}%
\DTLdisplaylongdb{MyDataBase}
\endgroup

\end{document}
This problem was also discussed at TeX-LaTeX StackExchange,
Subject: "When displaying a datatool-database with \DTLdisplaylongdb - how to obtain a horizontal rule atop of the table-heads?",
URL: <[TeX.SX Link]>.

Sincerely

Ulrich Diez

MWE

Download (1.77K)

\documentclass{article}
\usepackage{datatool,longtable,etoolbox}

% Toggle \iffalse/\iftrue to see behavior if patch is/is not in effect:

\iffalse
%\iftrue
\makeatletter
\expandafter\patchcmd\expandafter{\csname\string\DTLdisplaylongdb\endcsname}%
         {\@dtl@resetdoamp\dtldisplaystarttab}%
         {\dtldisplaystarttab\@dtl@resetdoamp}%
         {\message{Patching succeeded.}}%
         {\message{Patching failed.}}%
\makeatother
\fi

%===============================================================
\DTLnewdb{MyDataBase}%
\DTLaddcolumn{MyDataBase}{columnA}%
\DTLsetheader{MyDataBase}{columnA}{First Column}%
\DTLaddcolumn{MyDataBase}{columnB}%
\DTLsetheader{MyDataBase}{columnB}{Second Column}%
%---------------------------------------------------------------
\DTLnewrow{MyDataBase}
\DTLnewdbentry{MyDataBase}{columnA}{Row 1 Col A}
\DTLnewdbentry{MyDataBase}{columnB}{Row 1 Col B}
%---------------------------------------------------------------
\DTLnewrow{MyDataBase}
\DTLnewdbentry{MyDataBase}{columnA}{Row 2 Col A}
\DTLnewdbentry{MyDataBase}{columnB}{Row 2 Col B}
%===============================================================

\begin{document}

\begingroup
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Without patching this doesn't work out but yields 
%  ! Misplaced \noalign.
\renewcommand{\dtldisplaystarttab}{\hline}%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\renewcommand\dtldisplayafterhead{\hline}%
\renewcommand\dtldisplaystartrow{\hline}%
\renewcommand{\dtldisplayendtab}{\tabularnewline\hline}%
\renewcommand{\dtlbeforecols}{|}%
\renewcommand{\dtlaftercols}{|}%
\renewcommand{\dtlbetweencols}{|}%
\renewcommand\dtlheaderformat[1]{\textbf{#1}\hfil\null}%
\DTLdisplaylongdb{MyDataBase}
\endgroup

\end{document}

Evaluation

Comments

0 comments.


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=202