# “Pretty-printing” numbers redux: engineering notation

Awhile ago I discovered the siunitx package as an answer to this question and it kind of blew my mind. For instance, if I'm using fp to compute a numerical result (in, say, a homework solution), then I can do the following:

\usepackage{siunitx}
\sisetup{exponent-product = \times,round-mode = figures,%
round-precision = 3, scientific-notation = engineering}

\def\mass{1700}
\def\velocity{29}
\FPmul\Ek{0.5}\mass
\FPmul\Ek\Ek\velocity
\FPmul\Ek\Ek\velocity

\SI{\Ek}{\joule}


To get "715 x 10^3 J", properly typeset.

This is swell, and the tabular stuff is especially powerful.

But it is not really what I want as engineering notation-- that would be "715 kJ". I know siunitx knows the metric prefixes, but I can't find anything in the documentation that will get it to use them automatically (i.e. without me saying \kilo in the \SI statement).

Am I missing a key option, or is this not something the package does? And can anyone suggest a work-around?

-
I don't think siunitx can do this, and I think it would be pretty hard to implement, because it's not as simple as replacing 10^3 with k, but the exponent of the units would have to be taken into account as well: If you have 1000 m^2, that would be 0.001 km^2. I'd be really interested in a solution for this. – Jake Oct 27 '11 at 21:19
good point. But the pkg already knows all the metric prefixes and their exponents so I don't think it would be too hard. The hard part would be specifying which prefix to modify. But if it defaulted to the "most forward" prefix then situations like 10^3 kJ/kg would resolve correctly to MJ/kg .. I should look at the source. – Brandon Kuczenski Oct 27 '11 at 21:45
You could write a feature request to Christian Feuersänger which wrote the \pgfmathprintnumber for PGF to support something like this or to Joseph Wright, the maintainer of sinunitx. – Martin Scharrer Oct 27 '11 at 22:25
Feature request opened: bitbucket.org/josephwright/siunitx/issue/173/…. I should be able to sort this for v2.4. – Joseph Wright Oct 28 '11 at 7:06
@Jake It doesn't have to be a completely automated solution. I think that the best compromise between ease of use and flexibility is to define the basic Unit you want to use, e.g. m or mm, MPa or Pa. Usually, in each problem, there is a widely accepted convention for units. If you need to typeset something differently, you can always do it manually. – pmav99 Oct 28 '11 at 7:13

Version 2.4 of siunitx has now been submitted to CTAN. With this version, you can use the option exponent-to-prefix to achieve this

\documentclass{article}
\usepackage{fp,siunitx}
\sisetup
{
exponent-to-prefix = true        ,
round-mode         = figures     ,
round-precision    = 3           ,
scientific-notation = engineering
}
\begin{document}
\newcommand*{\mass}{1700}
\newcommand*{\velocity}{29}
\FPmul{\Ek}{0.5}{\mass}
\FPmul{\Ek}{\Ek}{\velocity}
\FPmul{\Ek}{\Ek}{\velocity}

\SI{\Ek}{\joule}

\end{document}


The option adds the prefix to the first unit given, and will only work if the exponent is 'convertable' (a multiple of three and in the range of SI prefixes).

-
Thank you for the custom coding job! It works great. – Brandon Kuczenski Nov 16 '11 at 6:22
Just noticed that it is also "offsetable" by a fixed power.. i.e. in the example above, if I used the command \SI{\Ek}{\tera\joule} then the answer comes out in PJ- fantastic. This allows me to make brilliant homework solutions, and has made my night! – Brandon Kuczenski Nov 16 '11 at 6:34