tabularray:制作一个具有可变列分隔的表格以跨越整个表格宽度

tabularray:制作一个具有可变列分隔的表格以跨越整个表格宽度

我需要使下面的代码工作,以便我可以获得一个表,该表可以根据列数自动计算列分隔以使其适合整个\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}

相关内容