[Tex/LaTex] Using siunitx to display confidence intervals

siunitx

Is there a native way of using siunitx to display the confidence interval of a value without using a separate calls of siuntix separate definition.

I am doing something like this at the moment, which seems verbose, and isn't too readable:

\SI{107205}{meters} (\SI{99}{\% CI} \SIrange{83000}{138400}{meters})

This would result in something like:

107205 meters (99% CI 83000 meters - 1384000 meters)

Best Answer

According to section 5.4 of the siunitx package documentation:

input-open-uncertainty In some fields, it is common to give the uncertainty in a number in brackets input-close-uncertainty after the main part of the number, for example ‘1.234(5)’. The opening and closing symbols used for this type of input set as input-open-uncertainty and input-uncertainty-signs. Alternatively, the uncertainty may be given as a separate part following a sign. Which signs are valid for this operation is determined by the input-uncertainty-signs option. As with other signs, the combination +- will automatically be converted to \pm internally.

9.99(9) 9.99(9)

9.99(9)

123.0(45)

12.3(60)

\num{9.99(9)} \\  \num{9.99 +- 0.09} \\  \num{9.99 \pm 0.09} \\  \num{123> +- 4.5} \\  \num{12.3 +- 6}

Of course, you can always set your own macro (see section 4.5 of the package documentation), as stated by egreg... something like this:

\documentclass{report}

\usepackage{siunitx}

\newcommand\SIci[5]{\SI{#1}{#2} ({#3}CI: \SIrange{#4}{#5}{#2})}

\begin{document}
The sample was \SIci{89}{\metre}{99\%}{80}{99}
\end{document}

Where the output would look:

enter image description here

By all means, please feel comfortable to change whatever you want with your macro. I'm sure this is probably not the best way to do it, but it seems to work just fine. If you have any further questions, please don't hesitate to post another question on the site :)