I am trying to use the \num
command from siunitx
inside a table made with pgfplotstable
, because I need the format given by siunitx
with \sisetup{scientific-notation = true}
and all the advantages of pgfplotstable
. My base code is
\documentclass{article}
\usepackage{pgfplots}
\usepackage{pgfplotstable}
\usepackage{siunitx}
\pgfplotsset{compat=1.8}
\usepackage{booktabs}
\usepackage{colortbl}
\begin{document}
\sisetup{scientific-notation = true}%
\vspace{3ex}
\pgfplotstabletypeset[col sep=comma,trim cells=true,
% dec sep align=S,
every even row/.style={
before row={\rowcolor[gray]{0.9}}},
every head row/.style={before row=\toprule, after row=\midrule},
every last row/.style={after row=\bottomrule},
%%
columns/Variable/.style={string type, column name=Quantity},
%
columns/error/.style={numeric type,dec sep align}
]{
Variable, error, IS value, custom units value,
mass error, 6.124218320291899e-16, {}, {}
omega error, {}, {}, {}
J error, 0.387621076355607, {}, {}
%Mb error Indeterminate, {}, {}, {}
Mbnew error, 0.21146255277063972, {}, {}
Mp error, 0.21146255277063972, {}, {}
Ebind error, 0.6604389526233243, {}, {}
}
\end{document}
but when I try to postprocess the numeric data with this
\sisetup{scientific-notation = true}%
\pgfplotstabletypeset[col sep=comma,trim cells=true,
every even row/.style={
before row={\rowcolor[gray]{0.9}}},
every head row/.style={before row=\toprule, after row=\midrule},
every last row/.style={after row=\bottomrule},
%%
columns/Variable/.style={string type, column name=Quantity},
%
columns/error/.style={numeric type,%dec sep align,
%preproc cell content/.append style={column type=S},
postproc cell content/.append style={
/pgfplots/table/@cell content/.add={$\num{}{}$}},
%postproc cell content/.append style={
%/pgfplots/table/dec sep align={@}
%},
%postproc cell content/.append style={dec sep align=true
%}
%}
}
]{
Variable, error, IS value, custom units value
mass error, 6.124218320291899e-16, {}, {}
omega error, {}, {}, {}
J error, 0.387621076355607, {}, {}
%Mb error, Indeterminate, {}, {}, {}
Mbnew error, 0.21146255277063972, {}, {}
Mp error, 0.01146255277063972, {}, {}
Ebind error, 0.6604389526233243, {}, {}
}
\num{0.001}
\end{document}
the numbers are clearly not processed by \num{}
and I have to comment the dec sep align
option to avoid errors. Any idea on how to combine these two tools? The reason to need num{}
is that the sci
option of pgfplotstable
gives ugly 10^0 terms, as can be seen in
\pgfplotstabletypeset[col sep=comma,trim cells=true,
every even row/.style={
before row={\rowcolor[gray]{0.9}}},
every head row/.style={before row=\toprule, after row=\midrule},
every last row/.style={after row=\bottomrule},
%%
columns/Variable/.style={string type, column name=Quantity},
%
columns/error/.style={numeric type,dec sep align,sci,zerofill
}
]{
Variable, error, IS value, custom units value
mass error, 6.124218320291899e-16, {}, {}
Ebind error, 0.6604389526233243, {}, {}
Ebind2 error, 1.6604389526233243, {}, {}
}
and the default numeric format is not able to convert 0.1234 into 1.234, so the numbers are not homogeneously formatted. What I need would look like that the following:
col sep=comma
instead? Then the code should be robust for posting.S
columns)? Take a look at this answer of mine which usedsiunitx
’sS
column (quite painfully as, in that case, it could be done much better with percusse’sdec sep align
key).