Siunitx:抑制表中整数行的小数对齐

Siunitx:抑制表中整数行的小数对齐

我该如何对齐以下 MWE 列中的数字?

行中的数字N始终是整数,因此我不希望像上面的系数那样将其对齐到小数位:它太靠右了。除了将数字放在N花括号中以便siunitx忽略它们之外,还有其他方法吗?

此外,减号比没有 时通常要长得多siunitx。是否有可以指定的选项,以便减号达到“正常”长度?

\documentclass{article}

\usepackage{siunitx}
\usepackage{longtable}
\usepackage{booktabs}


\def\sym#1{\ifmmode^{#1}\else\(^{#1}\)\fi}%Need for STATA tables
\def\tmp{
\parbox{\linewidth-1ex}{
\footnotesize
\lipsum[3-4]
\vspace{1ex}
}
}%Need for STATA tables


\begin{document}


\begin{longtable}{@{\extracolsep{\fill}}
@{}l
S[table-format = 3.3,detect-mode,
        group-digits            = false,
        input-symbols           = ,
        input-open-uncertainty  = ,
        input-close-uncertainty = ,
        table-align-text-pre    = false,
                table-align-text-post    = false,
        round-precision         = 3,
        table-space-text-pre    = (,
]
}
\toprule

text               &       0.900\sym{***}\\
                    &     (-35.22)        \\

N                   &         512        \\
\bottomrule

\bottomrule
\end{longtable}


\end{document}

答案1

根据您关于以下的问题-

似乎siunitx使用(对于 pdflatex,或者当未加载 fontspec 时)来自 TS1(文本伴侣)编码的字体的减号。我不太熟悉,不siunitx 知道是否有选项可以更改它。因此,建议的代码中的方法:它用您喜欢的任意一个替换所选的减号siunitx。例如\textendash

siunitx 减号为文本endash

\documentclass{article}

\usepackage{siunitx}
\usepackage{longtable}
\usepackage{booktabs}


\def\sym#1{\ifmmode^{#1}\else\(^{#1}\)\fi}%Need for STATA tables
\def\tmp{
\parbox{\linewidth-1ex}{
\footnotesize
\lipsum[3-4]
\vspace{1ex}
}
}%Need for STATA tables


% AWFUL RADICAL HACK WHICH HAS BEEN MUCH FROWNED UPON

%\catcode`_11
%\protected\def \c__siunitx_minus_tl {-}
%\catcode`_ 8 

% RADICAL HACK WHICH MAY STILL BE  MUCH FROWNED UPON

\catcode`_11
\protected\def \c__siunitx_minus_tl {\textendash}
\catcode`_ 8 

\begin{document}\thispagestyle{empty}
\begin{longtable}{@{\extracolsep{\fill}}
                  @{}l
      S[table-format            = 3.3,
        group-digits            = false,
        input-symbols           = ,
        input-open-uncertainty  = ,
        input-close-uncertainty = ,
        table-align-text-pre    = false,
        table-align-text-post   = false,
        round-precision         = 3,
        table-space-text-pre    = (, 
        detect-mode, 
        ]
}
\toprule
text                &       0.900\sym{***}\\
                    &     (-35.22)        \\
N                   &         {512}      \\
\bottomrule
\bottomrule
\end{longtable}


\end{document}

使用连字符看起来很漂亮:

siunitx 减

相关内容