# Table typesetting with pgfplotstable

I have two questions concerning pgfplotstable and number formatting with pgf. Consider the following piece of code:

\documentclass{article}
\usepackage{pgfplotstable}
\usepackage{amsmath}

\begin{document}
A     B        C
1.1   12       1300000
21.1  200000   214300000
}\mytable
\pgfplotstabletypeset[columns={A, B, C},
columns/A/.style={postproc cell content/.append style={
/pgfplots/table/@cell content/.add={}{ s}}, fixed zerofill, precision=1
},
columns/C/.style={postproc cell content/.append style={
/pgfplots/table/@cell content/.add={}{ s${}^{-1}$}}, fixed zerofill, precision=1
}
]\mytable

\end{document}


I would like to:

1. align the content of the column A at the decimal separator (obviously I've tried dec sep align but the it messes up with the postproc cell content (it adds the " s" before the dec sep "." - e.g. : 21 s.1 s), other than that it aligns fine,
2. print the number using engineering notation (the powers of ten must be multiples of three) for the column B - e.g. : $200\:\cdot\:10^{3}$ instead of $2\:\cdot\:10^{5}$)
3. do all these for the column C: append content, print using engineering notation, align on the \cdot of the engineering notation (like sci sep align)

Do you know some way(s) to achieve any of those goals ?

EDIT Thanks to Jake's answer, I've got almost what I want, however I have one last problem with siunitx. The following piece of code compiles (note the alias to make it compile, otherwise siunitx fails..)

\documentclass{article}
\usepackage{pgfplotstable}
\usepackage{siunitx}
\usepackage{booktabs}

\begin{document}
\pgfplotstableset{
alias/as/.initial=d,
}
d
7000000
\pgfplotstabletypeset[columns={as},
columns/as/.style={
column name={$2 \times 3d$},
}
\end{document}


This next piece doesn't:

\documentclass{article}
\usepackage{pgfplotstable}
\usepackage{siunitx}
\usepackage{booktabs}

\begin{document}
\pgfplotstableset{
alias/as/.initial=d,
}
d
7000000
\pgfplotstabletypeset[columns={as},
columns/as/.style={
column name={$2 \times 3d$},
column type={S[round-mode=places, round-precision=1, scientific-notation=engineering, table-format=5.1e1, exponent-product = \cdot]},
string type
}
\end{document}


How to avoid siunitx parse the headers ? (that would also, I guess, make it possible to use column identifiers with the letters 'e' and 'd')

-

You could let siunitx take care of the of the alignment and of formatting the numbers: Since version 2.4, siunitx can format numbers to engineering notation.

\documentclass{article}
\usepackage{pgfplotstable}
\usepackage{siunitx}

\begin{document}
A     B        C
1.1   12       1300000
21.1  200000   214300000
}\mytable
\pgfplotstabletypeset[columns={A, B, C},
columns/A/.style={
column type={S[table-format=2.1]},
string type,
postproc cell content/.append style={
}
},
columns/B/.style={
column type={S[round-mode=figures, round-precision=3, scientific-notation=engineering, table-format=3e1]},
string type,
postproc cell content/.append style={
}
},
columns/C/.style={
column type={S[round-mode=figures, round-precision=3, scientific-notation=engineering, table-format=5.2e1]},
string type,
postproc cell content/.append style={
}
},
]\mytable

\end{document}


May I suggest a slight alteration to your table setup? Instead of repeating the unit symbol with each value, I would put it into the header. Here's one example of how that can be accomplished. I've also used the booktabs package to make the table a bit easier to grasp:

\documentclass{article}
\usepackage{pgfplotstable}
\usepackage{siunitx}
\usepackage{booktabs}

\begin{document}
A     B        C
1.1   12       1300000
21.1  200000   214300000
}\mytable
\pgfplotstabletypeset[columns={A, B, C},
columns/A/.style={
column type={S[table-format=2.1]},
string type
},
columns/B/.style={
column type={S[round-mode=figures, round-precision=3, scientific-notation=engineering, table-format=3e1]},
string type
},
columns/C/.style={
column type={S[round-mode=figures, round-precision=3, scientific-notation=engineering, table-format=3.2e1]},
string type
},
before row={\toprule},
after row={\si{\second} & \si{\per\second} & \si{\second}\\ \midrule}
},
every last row/.style={after row=\bottomrule}
]\mytable

\end{document}


To stop siunitx from trying to parse the column names, issue the key multicolumn names. This will wrap the cells in the head row in \multicolumn{1}{c}{<column name>}, which protects them.

\documentclass{article}
\usepackage{pgfplotstable}
\usepackage{siunitx}
\usepackage{booktabs}

\begin{document}
d
7000000
\pgfplotstabletypeset[
multicolumn names,
columns/d/.style={
column name=$\gamma \times \epsilon$,
column type={
S[
round-mode=places,
round-precision=1,
scientific-notation=engineering,
table-format=1.1e1,
exponent-product = \cdot
]
},
string type
}

You can use multicolumn names. I've edited my answer accordingly. –  Jake Jan 20 '12 at 9:26