1

The following csvsimple table keeps returning warnings of the type: Underfull \hbox (badness 10000) in paragraph at lines:

\csvreader[no head, longtable=|p{\dimexpr 0.2\linewidth-2\tabcolsep}|p{\dimexpr 0.2\linewidth-2\tabcolsep}|p{\dimexpr 0.2\linewidth-2\tabcolsep}|p{\dimexpr 0.2\linewidth-2\tabcolsep}|p{\dimexpr 0.2\linewidth-2\tabcolsep}|, table head=\hline, late after line=\\\hline]
{gantt/GanttChart.csv}
{1=\one, 2=\two, 3=\three, 4=\four, 5=\five}
{\one & \two & \three & \four & \five}%

I know that \raggedright can fix it, but I couldn't guess where to put it exactly inside the p{}?

Here are the first lines (it contains 14 lines in total) of my csv file:

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
Hakim
  • 333

1 Answers1

2

Typesetting in narrow columns is best done with \raggedright:

\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}

\begin{document}

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

\end{document}

Note the adjustment due to taking care of the six vertical rules, each \arrayrulewidth wide, to divide among the five columns (6/5=1.2).

enter image description here

As usual, filecontents is used just for making the example self-contained. I don't think you need longtable, but you can change the code as you wish.

egreg
  • 1,121,712
  • Thanks to your answer I got rid of all the warnings except the last one, which persists in the line corresponding to {\one & \two & \three & \four & \five}. And btw, I'm using longtable, because without it I cannot get an array which takes more than a page (is there another way to do so?). Also this last warning seems similar to this one: http://tex.stackexchange.com/questions/166917/underfull-vbox-badness-10000-detected-at-line – Hakim Mar 10 '16 at 14:19
  • 1
    @h4k1m I too saw tha Underfull \vbox message, but it's nature is different from the Underfull \hbox messages you got. It has something to do with how csvsimple implements its interface to longtable, but I'm not sure what it is: the warning is typical of misplaced \\. – egreg Mar 10 '16 at 14:21
  • Ok I'll ignore it then. For me, this issue is considered fixed! – Hakim Mar 10 '16 at 14:23