Attempting to compile the following file gives the following error:
! Misplaced \noalign.
\pagebreak ->\noalign
{\ifnum `}=0\fi \@testopt {\LT@no@pgbk -}4
l.47 \end{letter}
I don't understand why. Making minor changes to the csv file xx.csv
makes this error go away. For example, change mm
to m
. Alternatively, change mm
to 11
.
Alternatively, adding a comma to the end of the string 2014.02.26,26,2014.11.12.tm
in
\PrintDocTableParekh[2014.02.26,26,2014.11.12.tm]{newbDB}{Documents}
thus changing it to 2014.02.26,26,2014.11.12.tm,
also makes the error go away.
\documentclass[12pt]{letter}
\usepackage{longtable}
\usepackage[verbose]{datatool}
\usepackage{array}
\usepackage{url}
\newcounter{tabenum}\setcounter{tabenum}{0}
\newcommand{\colhead}[1]{\multicolumn{1}{>{\bfseries}l}{#1}}
\newcommand{\nextnuml}[1]{\refstepcounter{tabenum}\thetabenum.\label{#1}}
\newcommand*{\checkmissing}[1]{\DTLifnull{#1}{}{#1}}
\signature{Someone}
\newcommand{\PrintDocTableParekh}[3][]{%
% #1 = list of rowIDs
% #2 = database to search
% #3 =caption
\begin{longtable}{r l p{1.5in} c c p{2.5in}}
\caption{#3}\\
& \colhead{Date} & \colhead{Filename} & \colhead{From} & \colhead{To} & \colhead{Subject}\\\hline\endhead
\DTLforeach
[\ifblank{#1}{\boolean{true}}{\DTLisSubString{#1}{\RowID}}]
{#2}{%
\RowID=RowID,%
\Date=Date,%
\Filename=Filename,%
\From=From,%
\To=To,%
\Subject=Subject%
}{%
\nextnuml{\RowID} & \Date & {\bfseries\expandafter\url\expandafter{\Filename} } & \checkmissing{\From} & \checkmissing{\To} & \Subject \\
}%
\end{longtable}
}%
\begin{filecontents*}{xx.csv}
2014.02.26, 26 Feb 2014 , something.txt , , , ,subject
2014.11.12.tm, 12 Nov 2014 , something.txt , XXX , YY , , subject
mm, date, ,,,, subject
\end{filecontents*}
\begin{document}
\begin{letter}{}
\opening{xx,}
\closing{Yours Sincerely,}
\DTLloaddb[noheader,keys={RowID,Date,Filename,From,To,Email,Subject}]{newbDB}{xx.csv}
\PrintDocTableParekh[2014.02.26,26,2014.11.12.tm]{newbDB}{Documents}
\end{letter}
\end{document}
\end{letter}
inside the table.\end{longtable}
right there. What more could I do to end it?\endgroup\end{longtable}
before\end{letter}
makes the document complete (with some warnings) showing that in this document the\end{longtable}
in your macro was never executed and you have to close the table by hand. I'm not sure I know datatool well enough to trace this just now, may look another day.