I like the pgfplotstable package for reading and plotting tables but handling of strings and values (especially when strings contain spaces) drives me crazy... I often use a table as shown here:
\documentclass{article}
\usepackage{pgfplots}
\pgfplotsset{compat=1.8}
\usepackage{pgfplotstable}
\usepackage{booktabs}
%
\begin{filecontents*}{table.dat}
a b c d e f g
1 Item1 alpha m 1 1 10
2 Item2 beta s 1.0 11 20
3 Item3 gamma kg 10.0 111 30
4 Item4 omega deg 10.00 1111 40
5 Item5 xi \% 10.99 11111 50
\end{filecontents*}
\begin{document}
\begin{figure}[hp]
\pgfplotstableread{testMod.dat}\loadTestTable
\pgfplotstabletypeset[
% header=false,
brackets/.style={%
postproc cell content/.append style={/pgfplots/table/@cell content/.add={\relax[}{]}},
},
greek/.style={%
postproc cell content/.append style={/pgfplots/table/@cell content/.add={\textbackslash}{}},
},
column type=r,
columns/a/.style={string type},
columns/b/.style={string type,column type=l},
columns/c/.style={string type,column type=l},
columns/d/.style={string type,column type=l},
columns/c/.append style={greek},
columns/d/.append style={brackets},
fixed,
fixed zerofill,
precision=2,
% dec sep align,
every head row/.style={%
output empty row,
before row={%
\toprule
No. & Item & Symbol & Unit & Column1 & Column2 & Column3\\
},
after row=\midrule,
},
every last row/.style={%
after row=\bottomrule}]{table.dat}
\end{figure}
\end{document}
I need to have two things:
- spaces in strings, i.e. 'Item of first row'
- set greek symbols automatically (comment out line 'columns/c/.style={string type,column type=l},' did not work
Thanks for any advice!
Paul
col sep=comma
, for example), or enclose the string in{...}
({Item of first row}
). For 2. you can similarly put{$\alpha$}
into your table instead of justalpha
.