siunitx で表形式の信頼区間を [x, y] として印刷するにはどうすればいいですか?

siunitx で表形式の信頼区間を [x, y] として印刷するにはどうすればいいですか?

[x, y]S 列のように信頼区間を印刷するための推奨される方法は何でしょうかsiunitx? 現時点では、2 つの S 列ソリューションがあります。

\documentclass{article}
\usepackage{siunitx}
\begin{document}
    \begin{table}[h]
        \begin{tabular}{cS[table-format = 1.1]
                S[table-format = -1.2, table-space-text-pre=[ ]@{}
                S[table-format = -1.2, table-space-text-post=[, table-space-text-pre=[ ]
                }
            A & B & \multicolumn{2}{c}{CI} \\
            Values & 2.3 & {[}1.23{,} & 1.23{]} \\
            Values & 2.3 & {[}-3.42{,} & -2.43{]} \\
            Values & 2.3 & {[}4.12{,} & 7.33{]} \\
            Values & 2.3 & {[}-1.03{,} & -9.11{]} \\
        \end{tabular}
    \end{table}
\end{document}

もっと簡単な方法はありますかsiunitx

答え1

table-space-text-preとを使ってtable-space-text-post角括弧のためのスペースを作ることができます。列の前後に括弧を挿入するには、>{...}と構文を使用します。各行の最後の角括弧の前に間違ったスペースを入れないようにするには、 og の代わりに<{...}TeX プリミティブを使用する必要があります。\cr\\TeX プリミティブを使用する必要があります。これは、のセクション 7.13 で説明されています。siunitxマニュアル

列見出しを中央揃えにするには、Bなどのグループ内に配置するだけです{B}

\documentclass[border=10pt]{standalone}
\usepackage{siunitx}
\begin{document}
  \begin{tabular}{
    c
    S[table-format = 1.1]
    >{{[}} % Add square bracket before column
    S[table-format = -1.2,table-space-text-pre={[}]
    @{,\,} % Add comma and thin-space between the columns
    S[table-format = -1.2,table-space-text-post={]}]
    <{{]}} % Add square bracket after column
  }
    A      & {B} & \multicolumn{2}{c}{CI} \cr
    Values & 2.3 &  1.23 &  1.23 \cr
    Values & 2.3 & -3.42 & -2.43 \cr
    Values & 2.3 &  4.12 &  7.33 \cr
    Values & 2.3 & -1.03 & -9.11 \cr
  \end{tabular}
\end{document}

出力

答え2

入力する量を最小限に抑えるために、テーブル定義に括弧[、およびを入れます。]

\documentclass{article}
\usepackage{siunitx}
\begin{document}
    \begin{table}[h]
        \begin{tabular}{cS[table-format = 1.1]
                @{\quad[\,}S[table-format = -1.2]@{,\,}S[table-format = -1.2]@{\,]}
                }
                A      & \multicolumn{1}{c@{\quad\space}}{B} & \multicolumn{2}{c}{CI} \\
            Values & 2.3 & 1.23  & 1.23 \\
            Values & 2.3 & -3.42 & -2.43 \\
            Values & 2.3 & 4.12  & 7.33 \\
            Values & 2.3 & -1.03 & -9.11 \\
        \end{tabular}
    \end{table}
\end{document}

これにより、次のものが生成されます。

ここに画像の説明を入力してください

ここでは、列の間に素材を挿入するために を使用しました@{...}。正しい場所に配置するためのサイトの工夫に注意してくださいB。これは のために必要なことです\quadが、より洗練された解決策があるはずだということを示唆する傾向があります。

関連情報