I need to typeset a table with units, so I'd like to use siunitx
for that. However, I don't want scientific notation, but a given number of figures. pgfplots
has the fixed relative
option for that purpose:
\documentclass{article}
\usepackage{pgfplots,siunitx}
\def\numA{1.23456789e3}
\def\numB{1.23456789e-3}
\begin{document}
\noindent
pgf standard format:\\
\pgfmathprintnumber{\numA}\\
\pgfmathprintnumber{\numB}\\
\pgfkeys{/pgf/number format/.cd,fixed relative,precision=3}
desired format:\\
\pgfmathprintnumber{\numA}\\
\pgfmathprintnumber{\numB}
\end{document}
This is the output of the above code:
I'd like to get the same output with siunitx
, if possible. I've tried explicitly disabling scientific-notation
, but as it seems that key is only useful for enabling scientific notation when siunitx
would otherwise not use it:
\num{\numA}\\
\num{\numB}\\
\sisetup{round-mode=figures,round-precision=3,scientific-notation=false}
\num{\numA}\\
\num{\numB}\
Output:
One possibility would be to redefine \SI{}{}
and \num{}
to use \pgfmathprintnumber{}
and disabling siunitx
's number parsing, but I'd like to know what else I could do.
My current workaround is:
\let\oldnum\num
\renewcommand{\num}[1]{\oldnum[parse-numbers=false]{\pgfmathprintnumber{#1}}}
\let\oldSI\SI
\renewcommand{\SI}[3][]{\oldSI[#1,parse-numbers=false]{\pgfmathprintnumber{#2}}{#3}}
but this doesn't let me pass options to \pgfmathprintnumber
. Passing options to \SI
works well, as in \SI[per-mode=fraction]{1e-3}{\meter\per\second}
.
Best Answer
This is possible in version 2.5, which deals correctly with fixed exponent of zero