I need to highlight some parts of code containing both text and numbers using the siunitxpackage but I get an invalid-token-in-number, the token being a number!

Here's my mwe:


\usepackage{soul} % Enables highlighting


    %% Error: 
    %% siunitx error: "invalid-token-in-number" and "Invalid token '6' in numerical input."
        Dummy text to avoid SI as very first argument of hl
        Dummy text just in case}


Thanks for your help.

  • This is a duplicate of the question just asked: use {\SI{666}{\nm}} Oct 1, 2013 at 16:47
  • Although I see this answers the question, I can't rewrite all the instances of \SI in my text when it needs to be (temporarily) highlighted. I love LaTeX but <Troll_mode> what is the use of it if one needs to deeply understand its way of doing things, just to do a simple thing as highlighting physics text.</Troll_mode>
    – Maugan
    Oct 1, 2013 at 16:58
  • Also, it is not totally a duplicate since, in the other question, double braces can easily be added, since the \hl{{\textcolor{white}{Fail}}} is in fact a \newcommandwith Fail being an argument that is passed along... which cannot be done in this question.
    – Maugan
    Oct 1, 2013 at 17:01
  • what \hl is doing can't remotely be described as simple:-) But you don't have to use it if you don't want you could use \colorbox to add the highlights or tikz or use Word. Oct 1, 2013 at 17:02
  • 2
    In simple cases \colorbox{red}{\parbox{\textwidth}{......}} is all you need. Oct 1, 2013 at 17:06


Browse other questions tagged .