A tentativa de compilar o seguinte arquivo gera o seguinte erro:
! Misplaced \noalign.
\pagebreak ->\noalign
{\ifnum `}=0\fi \@testopt {\LT@no@pgbk -}4
l.47 \end{letter}
Eu não entendo o porquê. Fazer pequenas alterações no arquivo csv xx.csv
faz com que esse erro desapareça. Por exemplo, mude mm
para m
. Alternativamente, mude mm
para 11
.
Alternativamente, adicionar uma vírgula ao final da string 2014.02.26,26,2014.11.12.tm
em
\PrintDocTableParekh[2014.02.26,26,2014.11.12.tm]{newbDB}{Documents}
portanto, alterá-lo para 2014.02.26,26,2014.11.12.tm,
também faz com que o erro desapareça.
\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}
Responder1
Parece haver um problema \DTLifSubString
quando usado dentro de \DTLforeach
. (Isso inclui o uso \DTLisSubString
no argumento condicional.) O uso de letter
e longtable
é algo ofuscante, então aqui está uma versão simplificada:
\documentclass{article}
\usepackage{datatool}
\begin{filecontents*}{xx.csv}
2014.02.26
2014.11.12.tm
mm
\end{filecontents*}
\newcommand*{\ifcontainsrowid}[2]{%
\ifblank{#1}{#2}%
{%
\DTLifSubString{#1}{\RowID}{#2}{}%
}%
}
\begin{document}
\DTLloaddb[noheader,keys={RowID}]{newbDB}{xx.csv}
\DTLforeach*{newbDB}{\RowID=RowID}%
{%
\ifcontainsrowid{2014.02.26,26,2014.11.12.tm}%
{%
\RowID
}
}%
\end{document}
Isso causa uma mensagem de erro diferente:
Runaway argument?
\expandafter \dtl@ifsingle \expandafter {\dtl@first }{\expandafter \@dtl@testif
substring \ETC.
! Paragraph ended before \dtl@getfirst was complete.
<to be read again>
\par
Mas isso decorre do mesmo problema. Ainda não descobri o que está causando isso, mas estive ausente por uma semana e preciso colocar as coisas em dia, então não tive muita chance de investigar ainda. Você pode contornar isso usando um comando diferente, por exemplo \IfSubStr
do xstring
pacote:
\documentclass{article}
\usepackage{datatool}
\usepackage{xstring}
\begin{filecontents*}{xx.csv}
2014.02.26
2014.11.12.tm
mm
\end{filecontents*}
\newcommand*{\ifcontainsrowid}[2]{%
\ifblank{#1}{#2}%
{%
%\DTLifSubString{#1}{\RowID}{#2}{}%
\IfSubStr{#1}{\RowID}{#2}{}%
}%
}
\begin{document}
\DTLloaddb[noheader,keys={RowID}]{newbDB}{xx.csv}
\DTLforeach*{newbDB}{\RowID=RowID}%
{%
\ifcontainsrowid{2014.02.26,26,2014.11.12.tm}%
{%
\RowID
}
}%
\end{document}
Atualização: Este bug foi corrigido na v2.23.