Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

How can I format a table column with siunitxwithout adding additional zeroes after the decimal separator?

I'd like to see 5,2 in the output instead of 5,200 (however: 0,246 shall still be displayed as 0,246 and e. g. 0,200 shall still be displayed as 0,200 if it is given like that in the source code), but I can not find the correction options (siunitxis too flexible - at least much more flexible then my brain ;-)).

The package options in the preamble have to stay as they are, as this otherwise would affect other tables.

\documentclass{scrbook}

\usepackage[round-mode=places, round-integer-to-decimal, round-precision=2,
    table-format = 1.2, 
    table-number-alignment=center,
    round-integer-to-decimal,
    output-decimal-marker={,}
    ]{siunitx} 

\usepackage[version=3]{mhchem}
\usepackage[tight]{units}
\usepackage{booktabs}


\begin{document}

\begin{tabular}{lllS[table-format=1.3, round-precision=3, table-comparator=true, round-integer-to-decimal=false]}
\toprule
Eigenschaft & Einheit & Spezifikation & {Wert}\\
\midrule
{\ce{Y2O3}} & {(\unit{\%})} & {4,95--5,35} & 5,2 \\
{\ce{Al2O3}} & {(\unit{\%})} & {0,15--0,35} & 0,246 \\
{\ce{SiO2}} & {(\unit{\%})} & {$<0,02$} & <0,002 \\
{\ce{Fe2O2}} & {(\unit{\%})} & {$<0,01$} & <0,002 \\
{\ce{Na2O}} & {(\unit{\%})} & {$<0,04$} & 0,007 \\
GV    & {(\unit{\%})} & {$<1,2$} & 0,42 \\
Spez. Obfl. & {(\unitfrac{m$^2$}{g})} & {5--9} & 6,9 \\
Partikelgröße & {(\unit{\AA})} & {k. A.} & 390 \\

\bottomrule
\end{tabular}%
\end{document}
share|improve this question
    
Does changing round-precision=3 to =1 have the desired effect? –  Seamus Jul 16 '11 at 11:16
    
@Seamus: no, round-precision=1 rounds all values to 1 decimal, but I just don't want that decimals are added: 5,2 shall stay 5,2 but 0,246 shall also still be displayed as 0,246! So I "just" want all numbers be aligned with the ",". (I've edited the question to hopefully make it more clear) –  Martin Jul 16 '11 at 11:25
1  
@Martin: You do know that you are abusing the rounding system, I hope. In general, I would not expect rounding to be on for an entire document as it implies that you are not thinking about where to round. The rounding system is intended for cases where auto-generated data tables need unrealistic precision removing. Leaving rounding on 'all of the time' makes it quite likely data is being rounded when you have not first checked that this is scientifically correct. –  Joseph Wright Jul 16 '11 at 14:10
2  
(My point being that while siunitx provides various tools, it is intended to support good science.) –  Joseph Wright Jul 16 '11 at 14:12
3  
I've posted some thoughts as texdev.net/2011/07/17/which-siunitx-options-to-set-globally –  Joseph Wright Jul 17 '11 at 15:07

3 Answers 3

up vote 6 down vote accepted

I think what you need is the round-mode=off switch. Here's your MWE, slightly reworked:

\documentclass{scrbook}

\usepackage[round-mode=places, round-integer-to-decimal, round-precision=2,
    table-format = 1.2, 
    table-number-alignment=center,
    round-integer-to-decimal,
    output-decimal-marker={,}
    ]{siunitx} 
\usepackage{booktabs}

\begin{document}

\begin{table}
\centering
\sisetup{table-format=1.3, round-precision=3, table-comparator=true, round-integer-to-decimal=false}
\begin{tabular}{S[round-mode=places]S[round-mode=off]}
\toprule
{``Places''} & {``Off''}\\
\midrule
  5,2   &   5,2   \\
  0,246 &   0,246 \\
 <0,002 &  <0,002 \\
 <0,002 &  <0,002 \\
  0,007 &   0,007 \\
  0,42  &   0,42  \\
  6,9   &   6,9   \\
390     & 390     \\
\bottomrule
\end{tabular}
\end{table}
\end{document}
share|improve this answer
    
Welcome to TeX.sx! A tip: If you indent lines by 4 spaces, then they are marked as a code sample. You can also highlight the code and click the "code" button (with "{}" on it). Besides, there's no need to sign with your name since it automatically appears in the lower right corner of your post. =) –  Paulo Cereda Jul 16 '11 at 11:52
    
@Mico: thanks, that's it (I just found it myself by sequentially deactivating the options in the preamble to see what caused this behavior) –  Martin Jul 16 '11 at 11:53
    
@Paulo: Many thanks for these pieces of advice. Indeed, this was my first posting to TeX.sx. :-) –  Mico Jul 16 '11 at 12:10

The option I think you are looking for is add-decimal-zero=false.

Section 5.5 of the siunitx manual (Post-processing numbers) contains all the relevant information on the options for how to represent numbers.

Having actually tried this, it appears not to work. It's certainly what the option should do. But it doesn't appear to work...

share|improve this answer
    
thanks for your effort: I've finally found it (and Mico Loretan posted it): round-mode=off helps. :-) –  Martin Jul 16 '11 at 11:54
    
@Martin also, I recomment replacing the units package and its commands with siunitx's replacements. And your package options include the round-integer-to-decimal option twice. –  Seamus Jul 16 '11 at 11:57
    
thanks for your recommendations! I started with unitsand discovered siunitx later when things got more complicated... I plan to replace units, but as I have extensively used it in the whole document, this will be quite time consuming as I fear side effects.. –  Martin Jul 16 '11 at 11:59

The solution is:

round-mode=off (to overwrite round-mode=places in the preamble)

\begin{tabular}{llcS[table-format=1.3, round-precision=3, table-comparator=true, round-integer-to-decimal=false, round-mode=off]}
share|improve this answer

Your Answer

 
discard

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.