[Tex/LaTex] Re-declaring \bit in siunitx

siunitx

It is possible to re-declare/redefine existing siunitx units in general. However, this seems to fail for the binary units \bit (and \byte) as shown in the MWE below.

Only if the declaration is done after the preamble via \AtBeginDocument the declaration works.

\documentclass{article}

\usepackage[
  binary-units,
]{siunitx}

% \AtBeginDocument{
\DeclareSIUnit\bit{b}
% }

\begin{document}

\SI{8}{\bit}

\end{document}

Why is this the case? Is this a bug? Why is \bit defined as bit in the first place while \byte is simply B? This produces rather unreadable output with IEC prefixes like Gibit.

I am using version 2.7a (2017-01-01) from TexLive 2016.

Best Answer

The time of loading is certainly intentional. The binary-units option code (for true) is:

binary-units / true .code:n = { \AtBeginDocument { \__siunitx_load_binary: } },

which as the code suggests, does basically \AtBeginDocument{\input{siunitx-binary.cfg}} (with a little more work to have the file be loaded as a package).

It isn't clear why this is loaded \AtBeginDocument and not at the time of loading siunitx (I didn't find any hint in the source, at least). But there's this:

\changes{v2.5m}{2012/11/27}{Modified loading of \opt{binary-units}}

but it doesn't say what changed...
Only Joseph knows :-)


As for the representation of \bit, the SI brochure, which is used as reference for siunitx, doesn't say anything about digital storage units, so it's probably down to what you said:

That [bit] is the official IEC/ISO unit symbol (while b was/is promoted by IEEE)

so it's basically a matter of choice between the two. Although I think that in written text 8 bit is clearer than 8 b, the former becomes weird when combined with prefixes/other units, so it's a tough pick...