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}
\usepackage{array,booktabs,csvsimple,longtable}
...
%Type of column
\newcolumntype{P}[1]{>{#1\hspace{0pt}\arraybackslash}p{75pt}}
...
\begin{document}
...
\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}\\
\end{document}
Best Answer
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: