3

i want to print a longtable from a contact list with datatool package. The database has some special characters. This is a small example:

\newcommand{\inputfile}{dbase/a.csv}
\documentclass[a4paper,10pt]{article}
\usepackage[utf8]{inputenc}
\usepackage{datatool}
\usepackage{longtable}
\DTLsetseparator{;}
%
\begin{document}
\begin{longtable}{l|l}
\DTLloadrawdb{title}{\inputfile}%
\DTLforeach*{title}{\name=NAME,\mail=MAIL}{%
\name & \mail\\
}%
\end{longtable}
\end{document}

this is the simple CSV file:

NAME;MAIL
name01;mail01@address.it
name02;mail02@address.it
name03;mail_03@address.it

Please help, i can't understand the following error:

(D:\Programmi\miktex_portable\texmfs\install\tex\latex\tools\longtable.sty)
(001.aux))
Runaway argument?
\@nil \let \@dtl@line =\@dtl@trmstr \dtl@domappings \@dtl@line     \ifdefempty \ETC
.
! File ended while scanning use of \@dtl@trim.
<inserted text>
                \par
<*> ./001.tex

?

2

Load the database outside the longtable. Tabular cells are groups and tabulars are complicated. Don't execute code inside a cell if you don't need too.

\documentclass[a4paper,10pt]{article}
\usepackage[utf8]{inputenc}
\usepackage{datatool}
\usepackage{longtable}
\DTLsetseparator{;}
%
\begin{document}
\DTLloadrawdb{title}{a.csv}%
\begin{longtable}{l|l}
\DTLforeach*{title}{\name=NAME,\mail=MAIL}{%
\name & \mail\\
}%
\end{longtable}
\end{document}

enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.