I am using csvsimple to import table data.

Some cell information is too long and I would like to dynamically manage the column width. I have tried combining the tabularx and tabulary environments with the csvsimple part, but I have been unsuccessful. I am using the memoir document class.

Here is my fixed-width code:

\documentclass[pdftex,10pt,letterpaper, openleft, twoside]{memoir}
%Type of column
\csvreader[tabular={P{\raggedright}P{\raggedright}P{\raggedright}P{\raggedright}P{\raggedright}}, %
head to column names=true, %
table head=\hline \textbf{Short header} & \textbf{Middle header} & %
\textbf{middle header} & \textbf{long text header} & \textbf{long text header}\\\hline, %
table foot=\hline, filter equal={\csvcoli}{Something}]{mycsv.csv}%
{\csvcolii & \csvcoliii & \csvcoliv & \csvcolv & \csvcolvi}\\
  • It seems you are out of luck, unless Thomas makes a major upgrade.
    – user11232
    Apr 1, 2015 at 5:37
  • You can try pgfplotstable which can use tabularx (IIRC). Can you please complete your example to include \documentclass{} and \end{document}? Thanks!
    – darthbith
    Apr 1, 2015 at 14:37
  • darthbith : Change done for the exemple; Would it be possible threw an other way? without tabularx or tabulary? Apr 1, 2015 at 18:02

1 Answer 1


It would be difficult to integrate tabularx into the option list of the macro \csvreader; for an environment, there would be ways.

But you can always put a tabularx environment around a \csvreader. The following example shows, how to do this:

Red,Green,This is some very very long text,This is also some very very long text
Blue,Yellow,This is some even longer text without real content,This is also some even longer text without real content

\documentclass[pdftex,10pt,letterpaper, openleft, twoside]{memoir}


\textbf{A} & \textbf{B} & \textbf{C} & \textbf{D}\\\midrule
\csvreader[late after line=\\\midrule,late after last line=\\\bottomrule]
  {\csvcoli & \csvcolii & \csvcoliii & \csvcoliv}


enter image description here

  • Thank you very much again, it worked perfectly. Would it work with tabulary also ?(I suppose yes) Apr 2, 2015 at 17:53
  • @SimonBoucher Yes, here is an example of using it with tabulary. Apr 13, 2015 at 8:30
  • To make the table span over multiple pages it is possible to use \usepackage{ltablex}, which union the advantages of tabularx and longtable. In the actuall table there is no change required, it happens automatically.
    – meles
    Feb 3, 2016 at 9:17

You must log in to answer this question.

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