次のファイルをコンパイルしようとすると、次のエラーが発生します。
! Misplaced \noalign.
\pagebreak ->\noalign
{\ifnum `}=0\fi \@testopt {\LT@no@pgbk -}4
l.47 \end{letter}
理由がわかりません。csv ファイルに小さな変更を加えると、xx.csv
このエラーは解消されます。たとえば、mm
に変更しますm
。または、mm
に変更します11
。
あるいは、文字列の末尾にカンマを追加して2014.02.26,26,2014.11.12.tm
、
\PrintDocTableParekh[2014.02.26,26,2014.11.12.tm]{newbDB}{Documents}
したがって、これを に変更すると、2014.02.26,26,2014.11.12.tm,
エラーも解消されます。
\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}
答え1
\DTLifSubString
を内で使用すると問題があるようです\DTLforeach
。(\DTLisSubString
条件引数内で を使用することも含まれます。)letter
との使用はlongtable
問題をわかりにくくするため、ここでは簡略化したバージョンを示します。
\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}
これにより、異なるエラー メッセージが表示されます。
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
しかし、これは同じ問題から生じています。まだ原因は解明できていませんが、1 週間ほど不在で、物事を整理する必要があり、まだ調査する時間があまりありません。別のコマンド (たとえば、 パッケージ\IfSubStr
から)を使用して、この問題を回避できます。xstring
\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}
更新: このバグはv2.23で修正されました。