1

I am trying to highlight text that includes quantities using the siunitx package. Just as when highlighting other commands like \cite, they have to be enclosed in extra brackets. But a problem occurs when using binary units (\bit, \byte, \kibi\byte) which give an Undefined control sequence error. Other units like microseconds or megahertz are highlighted with no problem.

I leave a MWE. Appreciate any help I can get.

\documentclass{article}

\usepackage{color}
\usepackage{soul}
\usepackage{siunitx}
    \sisetup{
        binary-units = true,
    }

\begin{document}

% These are OK
\hl{{\SI{32}{\MHz}}}

\hl{{\SI{32}{\us}}}

\SI{32}{\bit}

\SI{32}{\byte}

\SI{32}{\kibi\byte}

% These give errors
\hl{{\SI{32}{\bit}}}

\hl{{\SI{32}{\byte}}}

\hl{{\SI{32}{\kibi\byte}}}

\end{document}
1

Using \protect seems to remedy the problem.

\documentclass{article}

\usepackage{color}
\usepackage{soul}
\usepackage{siunitx}
    \sisetup{
        binary-units = true,
    }

\begin{document}

% These are OK
\hl{{\SI{32}{\MHz}}}

\hl{{\SI{32}{\us}}}

\SI{32}{\bit}

\SI{32}{\byte}

\SI{32}{\kibi\byte}

\hl{{\SI{32}{\protect\bit}}}

\hl{{\SI{32}{\protect\byte}}}

\hl{{\SI{32}{\protect\kibi\protect\byte}}}

\end{document}

enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.