Bug Tracker
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 | 81🔗 |
---|---|
Date: | 2015-04-03 22:42:25 |
Status | Closed (Not a Bug) |
Category | datatool |
Version | 2.22 |
Summary | Spurious line in tabular with |
Sign in to subscribe to notifications about this report.
Description
Hello!Thank you for the amazing datatool!
I have an issue with a spurious line appearing in a tabular environment.
I spent hours on datatool.sty with \tracingall
and \tracingmacro=1
tracking some spurious active space or cr but did not find anything...
So I wrote this bug report with a simple example to exhibit the issue.
Actually I found no sample in the documentation with a \hline
at the end that would have shown this bug...
Thank you!
\documentclass{report} \usepackage{datatool} \begin{document} \DTLnewdb{mydata} \DTLnewrow{mydata}% \DTLnewdbentry{mydata}{FirstName}{John}% \DTLnewdbentry{mydata}{Surname}{Smith, Jr}% \DTLnewdbentry{mydata}{Score}{68}% \DTLnewrow{mydata}% \DTLnewdbentry{mydata}{FirstName}{Jane}% \DTLnewdbentry{mydata}{Surname}{Brown}% \DTLnewdbentry{mydata}{Score}{75}% \DTLnewrow{mydata}% \DTLnewdbentry{mydata}{FirstName}{Andy}% \DTLnewdbentry{mydata}{Surname}{Brown}% \DTLnewdbentry{mydata}{Score}{42}% \DTLnewrow{mydata}% \DTLnewdbentry{mydata}{FirstName}{Z\"oe}% \DTLnewdbentry{mydata}{Score}{52}% \DTLnewdbentry{mydata}{Surname}{Adams}% \DTLdisplaydb{mydata} There is a spurious tabular line at the end:\\ \begin{tabular}{|l|l|r|}% \hline% \DTLforeach{mydata}{% \firstname=FirstName,\surname=Surname,\score=Score}{% \firstname & \surname & \score\\\hline}% \end{tabular} In a manual tabular, no spurious line at the end:\\ \begin{tabular}{|l|l|r|} \hline A & B & C\\\hline C & D & E\\\hline \end{tabular} \end{document}
MWE
Download (1.01K)
\documentclass{report} \usepackage{datatool} \begin{document} \DTLnewdb{mydata} \DTLnewrow{mydata}% \DTLnewdbentry{mydata}{FirstName}{John}% \DTLnewdbentry{mydata}{Surname}{Smith, Jr}% \DTLnewdbentry{mydata}{Score}{68}% \DTLnewrow{mydata}% \DTLnewdbentry{mydata}{FirstName}{Jane}% \DTLnewdbentry{mydata}{Surname}{Brown}% \DTLnewdbentry{mydata}{Score}{75}% \DTLnewrow{mydata}% \DTLnewdbentry{mydata}{FirstName}{Andy}% \DTLnewdbentry{mydata}{Surname}{Brown}% \DTLnewdbentry{mydata}{Score}{42}% \DTLnewrow{mydata}% \DTLnewdbentry{mydata}{FirstName}{Z\"oe}% \DTLnewdbentry{mydata}{Score}{52}% \DTLnewdbentry{mydata}{Surname}{Adams}% \DTLdisplaydb{mydata} There is a spurious tabular line at the end:\\ \begin{tabular}{|l|l|r|}% \hline% \DTLforeach{mydata}{% \firstname=FirstName,\surname=Surname,\score=Score}{% \firstname & \surname & \score\\\hline}% \end{tabular} In a manual tabular, no spurious line at the end:\\ \begin{tabular}{|l|l|r|} \hline A & B & C\\\hline C & D & E\\\hline \end{tabular} \end{document}
Evaluation
This is unfortunately a feature rather than a bug and is why all the examples in the manual place \\
at the start of the final argument of \DTLforeach
. This is due to additional stuff that has to be performed at the end of each iteration (such as incrementing the row counter) and this causes LaTeX to think a new row has started in the tabular.
This can be illustrated with a slight modification to your manual tabular:
\begin{tabular}{|l|l|r|} \hline A & B & C\\\hline C & D & E\\\hline\def\tmp{stuff}% \end{tabular}This also adds an unwanted row.
There's no way to fix this as the commands at the end of each iteration have to come after the supplied code has been performed. The only way around this is to move the \\\hline
to the start of the body. For example:
\begin{tabular}{|l|l|r|}% \hline% \DTLforeach{mydata}{% \firstname=FirstName,\surname=Surname,\score=Score}{% \DTLiffirstrow{}{\\\hline}\firstname & \surname & \score}% \\\hline \end{tabular}I will have to close this as not a bug, but I will emphasis this feature in the manual.
Comments
0 comments.
Add Comment
Page permalink: https://www.dickimaw-books.com/bugtracker.php?key=81