[Tex/LaTex] Problem with options in \DeclareSiUnit

siunitx

I also wanted to know How to use siunitx to write 100 MBps?, so \sisetup{per-mode=symbol,per-symbol = p} solved my question and I decided to use it as option in \DeclareSIUnit[per-mode=symbol,per-symbol=p]{\Bps}{\byte\per\second}.

This way I can fix the format of \per with every unit and get Km/s and MBps on the same text without to write the format in each \SI command. Maybe this mixture is not correct
but this is not my question.

But something is missing because when I write \SI{10}{\Bps} I get 10 Bps, but with
\SI{10}{\mega\Bps} the result is 10 MB/s. So, what's wrong?

Here you have a MWE and it's results:

\documentclass[a4paper,12pt]{article}
\usepackage[load-configurations={abbreviations,binary}]{siunitx}
\sisetup{per-mode=symbol}

\DeclareSIUnit[per-mode=symbol,per-symbol=p]{\Bps}{\byte\per\second}

\begin{document}

\SI[per-mode=symbol,per-symbol=p]{1}{\mega\byte\per\second}

\SI{2}{\Bps} 

\SI{3}{\mega\Bps}

\SI[per-mode=symbol,per-symbol=p]{4}{\mega\Bps}

\end{document}

enter image description here

Best Answer

This is the design behaviour. As described in the manual, options set for a a unit apply to that unit only, which means that they do not apply to combinations. From the point of view of siunitx \mega\Bps and \Bps are distinct for the application of options.

At one time there was a strong implementation reason for this: in v1 of siunitx separate parsing approaches were used for different forms of output, and so changing half-way through was not possible. This limitation does not apply to the current code.

The other reason for this restriction is conceptual. The approach requested in the question is not unreasonable, but other combinations could well be. For example, if you start combining different units with different options then the 'correct' result is hard to be sure of. So the options are checked only for the 'top level' input to \SI, and only if there is exactly one unit macro and no other input.

At the same time, the 'shortcut' approach to units was only ever intended to be used at 'one level', for example

\DeclareSIUnit[per-mode=symbol,per-symbol=p]{\Bps}{\byte\per\second}
\DeclareSIUnit[per-mode=symbol,per-symbol=p]{\MBps}{\mega\byte\per\second}

It does work in more complex ways, but the options are only ever read at the 'top level'.

Related Question