2

I'm trying to display a table loaded from a CSV file and displaying it like this:

\DTLloadrawdb[]{myDB}{myDB.csv}
\DTLdisplaylongdb[%
    caption={myDB caption},%
    label={tab:myDB},%
    contcaption={myDB (continued)},%
    foot={\em Table continued on next page},%
    lastfoot={\em End of Table}%
]{myDB}

This works except that one of the columns contain some long text strings that push the rest of the table off of the side of the page.

The datatool documentation says that it is using the longtable environment for this and to look up how to align contents in the longtable documentation, but I can't figure out how to get this to work. I want the table centered on the page and all the cell contents left-aligned and lines broken if there is too much content.

I'm not trying to break the cells across multiple pages, just the cell contents over multiple lines on the same page.

6
  • to allow longtable to break cells you would need to completely re-write it. If there are only two columns use a list environment instead, if there are more it gets harder, you ned to provide a full example Commented Nov 20, 2013 at 12:40
  • It sounds like you need a p specifier for the columns that are too wide. In which case, you may need to manually write the \begin{longtable}{...} and \end{longtable} and use \DTLforeach* to write the table rows. Commented Nov 20, 2013 at 12:50
  • @DavidCarlisle I'm not trying to break the cells across multiple pages, just the contents over multiple lines on the same page. Commented Nov 20, 2013 at 13:11
  • @NicolaTalbot I'll give that a try in a bit, thanks. Commented Nov 20, 2013 at 13:13
  • oh in that case p as Nicola said, same as tabular, array and all other similar environments Commented Nov 20, 2013 at 13:36

1 Answer 1

2

Looking at the datatool doc (section 5.4) you can have full control over the table column specification if you use \DTLforeach So if your third column needs to be text justified to lines broken to 5cm, you can do something like

\begin{longtable}{llp{5cm}}
\bfseries heading one &
\bfseries heading two &
\bfseries heading for long text column%
\DTLforeach{mydb}{%
\firstname=FirstName,\surname=Surname,\score=Score}{
\\
\firstname & \surname & \score}
\end{longtable}

You must log in to answer this question.

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