2

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.)

1

1 Answer 1

6

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
     \addcontentsline{lot}{table}{\protect\numberline{\thetable}{#2}}}%
  \fi}

\makeatother


\begin{document}

\listoftables

\DTLloaddb[noheader,%
keys={Temperature,Time,DT4},%
headers={\shortstack{Incubation\\Temperature},%
\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}

enter image description here

4
  • Does this work also with datatool's method to include longtables?
    – lockstep
    Commented May 3, 2012 at 21:50
  • 1
    @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. Commented May 3, 2012 at 22:03
  • I have the same problem, when i used the command endfirsthead, it also removed top line below the caption. how to handle this?
    – Ahmad
    Commented May 19, 2014 at 5:16
  • @Ahmad sorry I don't know datatool at all really, best to make a small example document and ask a new question, it is much easier with a test case, and more likely someone who knows datatool will see a new question than if you just ping me with a comment here Commented May 19, 2014 at 9:04

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .