[Tex/LaTex] Different prefixes in SIrange

siunitx

I use the siunitx package for typesetting numbers, units and ranges.
When typesetting large ranges of numbers, for example "150 kHz to 8 MHz", I prefer the notation with different prefixes, i.e. "kilo" for the first number and "mega" for the second. However, I have not been able to typeset such a range using the siunitx macro \SIrange.

So far I have found two possibilities: Simply using "kHz" for both numbers. This leads to the (in my opinion) not very nice format "150 kHz to 8000 kHz", which I want to avoid.
The only alternative I found was to manually create the two numbers using \SI, as illustrated in the following example.

\documentclass{article}
\usepackage{siunitx}
\begin{document}
    \SIrange{150}{8000}{\kilo\hertz}

    \SI{150}{\kilo\hertz} to \SI{8}{\mega\hertz}    
\end{document}

Is there any way to get an output similar to the second version (separate \SI's), but using \SIrange ? This would be nice, as it allows to globally change e.g. the range phrase ("to") and has a consistent spacing.

Best Answer

I think the shortest form for what you want would be:

% arara: pdflatex

\documentclass{article}
\usepackage{siunitx}
\sisetup{%
    ,exponent-to-prefix = true
    ,zero-decimal-to-integer
    }

\begin{document}
    \begin{tabular}{l}
            \SIrange[scientific-notation = engineering]{150}{8000}{\kilo\hertz}\\
            \SIrange[scientific-notation = engineering]{100}{50000}{\tesla}\\
            \num{1234.1245345}
    \end{tabular}
\end{document}

You have to set the scientific notation locally in order not to change the normal numbers. You will have to decide, which options can be taken globally and which don't.

enter image description here

Related Question