[Tex/LaTex] Add a percentage error using siunitx package


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

Best Answer

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.

Related Question