3

How to preserve the leading zeros of the errors in a table using siunitx' S-column type?

\documentclass[ngerman,english]{scrreprt}

\usepackage{babel}    
\usepackage[locale=DE]{siunitx}    
\sisetup{separate-uncertainty}
\sisetup{multi-part-units=single}

\usepackage{booktabs}

\begin{document}

\selectlanguage{ngerman}    

\begin{tabular}{l*{2}{S[table-figures-decimal=1,
                        table-text-alignment=left,
                        table-number-alignment=left,
                        table-figures-uncertainty=1]}}
   \toprule
   A & {Column1 symbol $\Delta$} & {Column2 symbol $\delta$} \\
     & {Column1} & {Column2} \\
   \midrule
   B &  -5.0 \pm 1.0 & -10.0 \pm 02.0 \\
   C &   0.0 \pm 1.0 &   5.0 \pm 02.0 \\
   D & -20.0 \pm 1.0 & -100.0 \pm 20.0 \\
\bottomrule
\end{tabular}
\end{document}
3
  • 1
    The closest you'll get is minimum-integer-digits = 2, but this applies to all input. The package normalises input as a first step, so the unnecessary leading zeros are dropped before any formatting.
    – Joseph Wright
    Apr 2, 2014 at 8:05
  • minimum-integer-digits = 2 changes the numbers but has no effect on the errors.
    – A. Groh
    Apr 2, 2014 at 9:08
  • this question might be helpful: Leading zero for azimuths using siunitx Apr 2, 2014 at 14:27

1 Answer 1

5

The code in siunitx is broadly based around the idea that numbers will be normalised to a 'standard' form before printing. One of the normalisation rules is that leading zeros are removed. While there is some possibility to pad the integer part back out again, that's not the same as retaining 'excess' information in the input. As such, your best bet is to turn off the parser, as suggested in a comment:

\documentclass[
  ngerman,
  english
]{scrreprt}

\usepackage{babel}    
\usepackage{siunitx}    
\sisetup{
  locale = DE,
  separate-uncertainty,
  multi-part-units = single
}
\usepackage{booktabs}

\begin{document}

\selectlanguage{ngerman}    
\begin{table}
  \sisetup{parse-numbers = false}
  \begin{tabular}{
    l
    S[table-format = -2.1]
    @{${}\pm{}$}
    S[table-format =  1.1,table-number-alignment = left]
    S[table-format = -3.1]
    @{${}\pm{}$}
    S[table-format =  2.1,table-number-alignment = left]
  }
     \toprule
     A & \multicolumn{2}{l}{Column1 symbol $\Delta$}
       & \multicolumn{2}{l}{Column2 symbol $\delta$} \\
       & \multicolumn{2}{l}{Column1}
       & \multicolumn{2}{l}{Column2} \\
     \midrule
     B &  -5.0 & 1.0 &  -10.0 & 02.0 \\
     C &   0.0 & 1.0 &    5.0 & 02.0 \\
     D & -20.0 & 1.0 & -100.0 & 20.0 \\
    \bottomrule
  \end{tabular}
\end{table}
\end{document}

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .