1

My question is somewhat related to my previous one (See Underfull \hbox warning about alignement in a csvsimple table

I need to add a caption to a csvsimple-generated longtable, but if I enclose my csv table inside a \table element, it will take just one page and be truncated at the end (even though it would appear on the list of tables).

My aim is to have this table appearing on my List of tables.

Is there any parameter of csvreader that allows it to affect a caption to a table generated with it, so that it would appear on the list of tables?

1

Something like that:

\begin{filecontents*}{\jobname.csv}
Task Mode,Task Name,Duration,Start,Finish
Manually Scheduled,task1,3.3 mons,Mon 01/06/15,Mon 31/08/15
Manually Scheduled,task2,34 days,Wed 15/07/15,Mon 31/08/15
Manually Scheduled,task3,11 days,Tue 01/09/15,Tue 15/09/15
\end{filecontents*}

\documentclass{article}

\usepackage{csvsimple,array,longtable}

\begin{document}

\listoftables

\section{Test}

\noindent
\csvreader[
  no head,
  longtable=
    |*{5}{>{\raggedright\arraybackslash}p{\dimexpr 0.2\linewidth-2\tabcolsep-1.2\arrayrulewidth}|},
  table head=\hline,
  late after line=\\\hline,
  late after last line=\\\hline\caption{My nice table}
]{\jobname.csv}
  {1=\one, 2=\two, 3=\three, 4=\four, 5=\five}
  {\one & \two & \three & \four & \five}

\end{document}

enter image description here

Alternatively, you can always create the longtable head and foot outside the \csvreader, if more control is needed.

  • Perfect, adding late after last line=\\\hline\caption{My nice table} did it. – Hakim Mar 11 '16 at 15:39

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.