0
\documentclass[12pt,landscape,a4paper]{report}
\usepackage{amsmath}
\usepackage{siunitx}       % nice alignment for decimals

\begin{document}

\begin{tabular}{
    >{$}c<{$} 
    | S[table-format=-1.4]S[table-format=-1.4] 
    | S[table-format=-2.4]S[table-format=-1.4] 
}
    w_1  &  0.0001 & -0.0001 & -0.0000  & 0.0000  \\
   %w_1  &  0.0001 & -0.0001 & {-}0.0000  & 0.0000  \\
\end{tabular}
\end{document}

How can I ensure that -0.0000 does not lose its negative sign at front? As I have rounded the values, this minus sign is important.

But siunitx seems to have rounded it too??

  • Sorry, this doesn't make sense. If the data are only accurate to 4 decimal places then the negative reading on the original is meaningless. Either don't round or accept that when you do the result has to be logical. (Not a technical factor, of course.) – Joseph Wright Feb 7 '15 at 20:15
  • 2
    Why can't you insert the number with more precision and let siunitx do the rounding? That way you would have consistent rounding in the whole document. – hbaderts Feb 7 '15 at 20:25
  • @JosephWright I am not sure if I understand. Maybe I did not express my self clearly. My raw data is accurate up to 15 decimal places. But I have a large table, I have decided to present it only up to 4dp. This particular value is 3.332 x 10^(-7). – Chen Stats Yu Feb 7 '15 at 20:30
  • @hbaderts I never knew that. I will have a go with it! – Chen Stats Yu Feb 7 '15 at 20:32
  • @ChenStatsYu Zero is zero: it's not got a sign. I don't know of any data accurate to 15 figures, and if you have a small number with lots of leading zero digits you should be giving it in an appropriate exponent for (as you just have here!). – Joseph Wright Feb 7 '15 at 20:48
2

You can use the siunitx package for rounding the numbers instead of doing this manually. That way you can enter the original number and setup siunitx to round according to your needs. This allows for a consistent rounding and number formatting throughout the document and allows to easily change the precision if desired. You can find detailed information in the package documentation.

You can specify either a number of decimal places (round-mode=places) or a number of significant figures (round-mode=figures). The number of digits or figures is set using the round-precision option.

\documentclass[12pt,landscape,a4paper]{report}
\usepackage{amsmath}
\usepackage{siunitx}
\sisetup{round-mode=places, round-precision=4}

\begin{document}
\begin{tabular}{
    >{$}c<{$} 
    | S[table-format=-1.4]S[table-format=-1.4] 
    | S[table-format=-2.4]S[table-format=-1.4] 
    }
    w_1   &  0.0001 & -0.0001 & 0.000000001 & -0.000000001  \\
\end{tabular}
\end{document}

output

Your Answer

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

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