# Single entry in list of tables using datatool + longtable

I'm using the \DTLdisplaylongdb from datatool in order to create a multi-page table with longtable. How do I provide a caption that only shows up once in the list of tables? (Right now it's showing an entry for every page of the table.)

-
Can you please add to your question a minimal working example illustrating the problem? –  Gonzalo Medina May 3 '12 at 21:37

Place the \caption{abc} command in the heading ended by \endfirsthead and use a \caption[]{...} in the repeated heading. the [] form suppresses the writing to the toc file. (See the longtable documentation).

As @lockstep noted datatool hides this longtable feature, so you need to unhide it:-)

\begin{filecontents*}{dt4.csv}
40,120,40
40,90,60
35,180,20
55,190,40
40,120,40
40,90,60
35,180,20
55,190,40
40,120,40
40,90,60
35,180,20
55,190,40
40,120,40
40,90,60
35,180,20
55,190,40
\end{filecontents*}
\documentclass{article}
\usepackage{longtable,datatool}
\textheight=12\baselineskip

\makeatletter
\def\DT@capfix{\@dtl@contcap}

\def\LT@c@ption#1[#2]#3{%
\LT@makecaption#1\fnum@table{#3}%
\def\@tempa{#2}%
\ifx\@tempa\DT@capfix\let\@tempa\@empty\fi
\ifx\@tempa\@empty\else
{\let\\\space
\fi}

\makeatother

\begin{document}

\listoftables

keys={Temperature,Time,DT4},%
\shortstack{Incubation\\Time},\shortstack{Time to\\Growth}}%
]{dt4}{dt4.csv}
Now display the data in a table:

\DTLdisplaylongdb[
caption=ho hum,
shortcaption=fi fo,
contcaption=hoo ha
]{dt4}

\end{document}


-
Does this work also with datatool's method to include longtables? –  lockstep May 3 '12 at 21:50
@lockstep looking at the datatool sources, I suspect not (which seems to be a bug) but easy to fix by patching in [] at appropriate points. If someone supplies a MWE I'll provide a patch. –  David Carlisle May 3 '12 at 22:03