I am using pgfplotstable to import .csv file to LaTeX.
I successfully wrapped column texts using p{width} command in each column type which also prevented me from centering the columns and which didn't wrap the headers (the header overlaps with the next column header).
Could you please help me wrap the header and the texts being able to center them?
Here is some of the code:
\renewcommand{\arraystretch}{1.5}
\afterpage{
\pgfplotstableset{
begin table=\begin{longtable},
end table=\end{longtable},
%outfile={testtable.tex} % to check the resulting table code
}
\pgfplotstabletypeset[
col sep=comma,
string type,
columns/No/.style={column name=No, column type={p{.05\textwidth}}},
columns/Abbreviation/.style={column name={Abbreviation}, column type={p{.05\textwidth}}},
columns/Trait/.style={column name={Trait}, column type={p{.2\textwidth}}},
columns/Unit/.style={column name={Unit}, column type={p{.2\textwidth}}},
columns/Trait description/.style={column name={Trait description}, column type={p{.4\textwidth}}},
every head row/.style={before row=\hline, after row=\hline},
every last row/.style={after row=\hline},
every head row/.append style={before row={% <==================
\caption{List of the data to be collected from different traits, their abbreviation, units and description}\label{datalist}\\[0.5cm]
\hline
\endfirsthead
\multicolumn{5}{c}{{\bfseries \tablename\ \thetable{} -- continued from previous page}} \\
\hline
\multicolumn{1}{p{.05\textwidth}}{\textbf{No}} & \multicolumn{1}{p{.05\textwidth}}{\textbf{Abbreviation}} & \multicolumn{1}{p{.2\textwidth}} {\textbf{Trait}} & \multicolumn{1}{p{.2\textwidth}}{\textbf{Unit}} & \multicolumn{1}{p{.4\textwidth}}{\textbf{Trait description}} \\
\hline
\endhead
\hline
\multicolumn{5}{r}{{Continued on next page}} \\ %\bottomrule
\endfoot % <============================================================
\endlastfoot % <========================================================
}
}
]{Datalist.csv}
}
In this code the header "Abbreviation" and "Trait" overlap rather than wrapping the header "Abbreviation".

longtableto wrap columns, and how can I uselongtablefrom withinpgfplotstable. Note thatpgfplotstableon its own does not apply any line wrapping – Christian Feuersänger Jan 15 '16 at 18:46