我需要使下面的代码工作,以便我可以获得一个表,该表可以根据列数自动计算列分隔以使其适合整个\linewidth
。
\documentclass[a4paper]{article}
\usepackage{booktabs,mathtools,siunitx}
\usepackage{tabularray}
\UseTblrLibrary{booktabs,siunitx}
\sisetup{
table-format = 2.2,
round-precision = 2,
round-mode = places,
round-integer-to-decimal = true
}
\begin{document}
\begin{tblr}{
colsep = 0 mm,
colspec = {@{\extracolsep{\fill}} *{2}{>{$\relax}X<{$}} *{4}{S}},
row{1} = {font=\boldmath\bfseries},
}
\toprule
& \delta [deg] & {{{5}}} & {{{10}}} & {{{15}}} & {{{20}}} \\
\midrule
\Gamma = x^2 & \beta [deg] & 1 & 2 & 3 & 4 \\
\bottomrule
\end{tblr}
\end{document}
答案1
也许您想要的是同时包含X
和 的S
列?只需写入X[si]
即可tabularray
。
PS:tabularray
该包不支持使用@{\extracolsep{\fill}}
,通常情况下您不需要它。
\documentclass[a4paper]{article}
\usepackage{booktabs,mathtools,siunitx}
\usepackage{tabularray}
\UseTblrLibrary{booktabs,siunitx}
\sisetup{
table-format = 2.2,
round-precision = 2,
round-mode = places,
round-integer-to-decimal = true
}
\begin{document}
Text Text Text Text Text Text Text Text Text Text Text Text
Text Text Text Text Text Text Text Text Text Text Text Text
\begin{center}
\begin{tblr}{
colspec = {*{2}{>{$\relax}X<{$}}*{4}{X[si]}},
row{1} = {font=\boldmath\bfseries},
vlines,
}
\toprule
& \delta [deg] & {{{5}}} & {{{10}}} & {{{15}}} & {{{20}}} \\
\midrule
\Gamma = x^2 & \beta [deg] & 1 & 2 & 3 & 4 \\
\bottomrule
\end{tblr}
\end{center}
Text Text Text Text Text Text Text Text Text Text Text Text
Text Text Text Text Text Text Text Text Text Text Text Text
\end{document}
答案2
\documentclass[a4paper]{article}
\usepackage{booktabs,mathtools,siunitx}
% \usepackage{tabularray}
\usepackage{booktabs,siunitx, array}
\sisetup{
table-format = 2.2,
round-precision = 2,
round-mode = places,
round-integer-to-decimal = true
}
\begin{document}
\begin{tabular}{@{\extracolsep{\fill}} *{2}{>{$\relax}c<{$}} *{4}{S}}
\toprule
& \delta [deg] & {{{5}}} & {{{10}}} & {{{15}}} & {{{20}}} \\
\midrule
\Gamma = x^2 & \beta [deg] & 1 & 2 & 3 & 4 \\
\bottomrule
\end{tabular}
\end{document}