TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

If I use the siunitx package to generate an imaginary number e.g. \SI{120i}{\per\centi\meter} then it places a 0 before the 120 (probably some artifact of expecting complex notation with a real number included).

This seems like a bug. Also it puts the number in parenthesis which would make sense if it was a complex number with a real and an imaginary component, but not if it's just an imaginary component on it's own.

I have considered turning of parsing, but that can create other formatting problems e.g. I like my "i" to be italic", which can be set up with the options, but not if parsing is turned off.

share|improve this question
Yup, this does happen and is of course wrong. I'll have to check the detail, but I think that the parenthesis are a side-effect of the initial bug. – Joseph Wright May 23 '11 at 12:49
To clarify, Joseph is the author of siunitx and, if past siunitx questions are any indication, there'll be a new version on CTAN in the next couple of days that will solve your problem. – Seamus May 23 '11 at 12:56
IMHO bug reports are better reported by email to the package author(s). Technically this post is "not a real question". – Martin Scharrer May 23 '11 at 13:03
Problem is (hopefully) solved. Version v2.2e is on its way to CTAN. – Joseph Wright May 23 '11 at 13:10
@Martin: There is always some grey in this. A lot of people like to check that they are seeing a real bug, rather than misunderstanding something. The current case is pretty clear-cut, but that is not always true for bug reports. – Joseph Wright May 23 '11 at 13:13
up vote 4 down vote accepted

For those who cannot wait for the update to hit CTAN, the following should work

\cs_set_protected:Npn \siunitx_number_in_complex:N #1 {
  \bool_set_false:N \l_siunitx_number_in_first_bool
  \bool_if:NTF \l_siunitx_number_in_complex_root_bool
        { duplicate-complex-root-token } { \token_to_str:N #1 }
      \cs_set_eq:NN \siunitx_number_in_check:n
      \bool_set_true:N \l_siunitx_number_in_complex_root_bool
      \prop_put:Nnn \l_siunitx_number_in_prop { complex-root } {#1}
      \tl_if_empty:NF \l_siunitx_number_parsed_tl
          \cs_set_eq:NN \siunitx_number_in_parse_loop:N
      \bool_if:NT \l_siunitx_number_in_decimal_bool
          \bool_if:NF \l_siunitx_number_in_complex_bool
              \prop_if_in:NnT \l_siunitx_number_in_prop
                { mantissa-uncertainty }
                    { mantissa-decimal } { complex-decimal }
                    { mantissa-uncertainty } { complex-uncertainty }
              \siunitx_number_in_complex_aux:nn { mantissa-integer }
                { complex-integer }
                { mantissa-decimal-marker } { complex-decimal-marker }
              \prop_del:Nn \l_siunitx_number_in_prop { mantissa }
              \prop_put:Nnn \l_siunitx_number_in_prop { complex }
                { true }
      \prop_if_in:NnF \l_siunitx_number_in_prop { mantissa }
          \prop_if_in:NnT \l_siunitx_number_in_prop { mantissa-sign }
              \siunitx_number_in_complex_aux:nn { mantissa-sign }
                { complex-sign }
      \bool_set_true:N \l_siunitx_number_in_complex_bool
      \bool_set_false:N \l_siunitx_number_in_first_bool
      \siunitx_number_in_init_part:n { complex }
      \prop_if_in:NnT \l_siunitx_number_in_prop
        { complex-decimal-marker }
        { \bool_set_true:N \l_siunitx_number_in_decimal_bool }
      \prop_if_in:NnTF \l_siunitx_number_in_prop
        { complex-sign }
        { \bool_set_true:N \l_siunitx_number_in_sign_bool }
        { \prop_del:Nn \l_siunitx_number_in_prop { mantissa } }

(Sorry about the length - there is only one changed line here but the function is a bit long!)

share|improve this answer
Gosh, I have a headache now X-|. This seems to work, though I actually put the code in my style file (with "new" instead of "set" for the header line). I tried some other solutions before you posted this. They were based upon the new version of the code that you released on your Bitbucket site. Using the help of another user who had the software needed to extract the correct files. It appears that the changes you made, may not have been implemented in the siunitx.dtx file. Perhaps some kind of mistake was made? Maybe it's nothing, just thought I'd let you know. Thanks for the solution. – aghsmith May 23 '11 at 20:01
@user1269: The above is exactly the same 'fixed' version of \siunitx_number_in_complex:N as you can see on BitBucket. So I'm not sure what you mean. (Also, the only software you need to extract the .sty file from siunitx.dtx is TeX itself. Doing tex siunitx.dtx will extract the style file.) – Joseph Wright May 23 '11 at 20:09
Hope I didn't cause offense there... I shall explain. It seems that some software is needed to download the siunitx.dtx file ("hg" I believe). I tried it without and it crashed out my browser. Once I received the dtx file from a guy on irc. I could not install it. tex siunitx.dtx failed as did pdflatex siunitx.dtx. I examined the dtx file though and it appeared not to incorporate the changes specified in the "changesets" section of your site. It could be that the guy on irc got the wrong file. Not that those two problems would be related. – aghsmith May 23 '11 at 20:22
Further to previous message. I have spoken to some one else who also downloaded the siunitx.dtx file from the repository. He got a working file that resolves this problem. perhaps it simply took a while to update. Any how it looks like there is no problem with the repository version of the file. Sorry if I caused any panic. – aghsmith May 23 '11 at 20:33

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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