異なる \sisetup{} 設定を持つ複数列のテーブル

異なる \sisetup{} 設定を持つ複数列のテーブル

テーブルの各列に \sisetup{} の異なるパラメータを使用する方法があるかどうか知りたいです。たとえば、次のようにしたいと思います。

\sisetup{round-mode=places,
round-precision=2,
fixed-exponent = 6,
scientific-notation = fixed,
}

私の表の最初の列と、それと少し異なるバージョンは次のとおりです。

\sisetup{round-mode=places,
round-precision=2,
fixed-exponent = 8,
scientific-notation = fixed,
}

後者の2番目の列目。

元:

\begin{table}[H]
\centering
\sisetup{round-mode=places,
round-precision=2,
fixed-exponent = 6,
scientific-notation = fixed,
}
\sisetup{round-mode=places,
round-precision=2,
fixed-exponent = 8,
scientific-notation = fixed,
}
\begin{tabular}{SSS}
\hline A & a & b \\ \hline
$B$ & -8940513.51965462 & -393467529.743240\\
$C$ & -8295841.85412406 & -365095852.079073 \\ \hline
\end{tabular}
\end{table}

答え1

TeX.SE へようこそ!

sisetup2 つの部分に分割できます。

  • S共通(グローバル)、すべての列で使用される設定
  • ローカルでは、必要に応じて共通設定を追加または上書きできます。
\documentclass{article}
\usepackage{booktabs}   % added
\usepackage{siunitx}

\begin{document}
    \begin{table}[ht]
\sisetup{round-mode=places,  % common settings
         round-precision=2,
         fixed-exponent = 6,
         scientific-notation = fixed,
         }
\begin{tabular}{l S[fixed-exponent = 8] % <--- local
                  S}
    \toprule
A   &  {a}              & {b}               \\ 
    \midrule
$B$ & -8940513.51965462 & -393467529.743240 \\
$C$ & -8295841.85412406 & -365095852.079073 \\ 
    \bottomrule
\end{tabular}
    \end{table}
\end{document}

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

答え2

テーブル全体に共通の設定をいくつか使用し、特定の列にはローカルな設定をいくつか使用したい。また、ヘッダーが正しく配置され、間隔が最適になるように桁数を指定したい。もちろん、このような設定は行われます。事後的にテーブルが実際に生成するものを確認した後。

\documentclass{article}
\usepackage{booktabs}
\usepackage{siunitx}

\begin{document}

\begin{table}[htp]

% common settings for this table
\sisetup{
  round-mode=places,
  round-precision=2,
  scientific-notation = fixed,
}

\begin{tabular}{
  l
  S[fixed-exponent = 8,table-format=-1.2e1]
  S[fixed-exponent = 6,table-format=-3.2e1]
}
\toprule
A   &  {a}              & {b}               \\ 
\midrule
$B$ & -8940513.51965462 & -393467529.743240 \\
$C$ & -8295841.85412406 & -365095852.079073 \\ 
\bottomrule
\end{tabular}

\end{table}

\end{document}

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

関連情報