1

I have a problem with the siunitx package.

What I would like to do is the following. I have a number which for instance equals 145 and has the units mm. However, there is also an error expressed in percentages. So how I would like to represent this value is: 145 mm ± 5% using the siunitx package.

I haven't been able to figure out how to do this using the siunitx package. What I've managed to do up to this point is the following:

  • \SI{145}{\milli \meter} $\pm$ \SI{5}{\percent} which gives: 145 mm ± 5% This is the correct form. However, when I'm at a line ending it will separate the plus minus 5% from the 145 mm because they do not 'belong' together.

  • \SI{145}{\milli \meter \SI{\pm 5}{\percent}} which gives: 145 mm±5% while I would like to have the separation after the mm and plus minus in comparison to the 145 mm.

I also tried to work with \mbox{} to make sure that at a line ending my 145 mm would not be separated from its error, this however increases the length of a line with respect to the rest of the text which makes it very ugly.

I hope someone can help me

migrated from stackoverflow.com Sep 24 '13 at 1:54

This question came from our site for professional and enthusiast programmers.

  • Welcome to TeX.SX! Your post was migrated here from Stack Overflow. Please register on this site, too, and make sure that both accounts are associated with each other (by using the same OpenID), otherwise you won't be able to comment on or accept answers or edit your question. – Qrrbrbirlbel Sep 24 '13 at 2:03
  • You should be using $\SI{145}{\milli\meter} \pm \SI{5}{\percent}$ or if you really want to forbid line-breaks ${<stuff>}$. – Qrrbrbirlbel Sep 24 '13 at 2:09
3

One could regard the percentage error as part of the unit and write:

\SI{145}{\milli\meter{} \pm{} 5\percent}

Sample output

This will not break across lines, unless you use the option allow-number-unit-breaks.

Your Answer

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