siunitx 表前导零

siunitx 表前导零

如何使用保留表中错误的前导零siunitx' S-列类型?

\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}

答案1

代码在siunitx大致基于这样的想法:数字将在打印之前标准化为“标准”形式。标准化规则之一是删除前导零。虽然有可能再次填充整数部分,但这与保留输入中的“多余”信息不同。因此,最好的选择是关闭解析器,因为在评论中建议

\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}

相关内容