在 tabularray 中创建景观表

在 tabularray 中创建景观表

我已经创建了下表,但需要在横向模式下旋转它。这是因为“评论”列将包含大量文本,无法容纳在普通表格中。我尝试使用 \usepackage{rotating} 和 \begin{sidewaystable},但作为最近的 Latex 用户,我不知道我哪里做错了。

我制作的初始表格是:

图像

提前感谢

PS:为了方便以后参考,我该如何

(a)确保我的所有表格都适合文档边距? (b)更改 tabularray 中的各个列宽?

再次,我们非常感谢任何帮助。

我的 MWE 显示如下:

\usepackage[margin=3cm]{geometry}
\usepackage[font=scriptsize,
            labelfont=bf]{caption}
\usepackage[xcdraw]{xcolor}
\usepackage{tabularray}
\usepackage{rotating}
\UseTblrLibrary{siunitx}


\begin{document}


\begin{table}[ht]
\fontsize{9}{10}\selectfont
\centering
\caption{Comparison between AA and BB mean values (wt\%)}
\begin{tblr}{hlines, vlines,
             colspec = {r l *{2}{S[table-format=-1.2]} *{6}{S[table-format=1.2]}},
             column{1} = {font=\bfseries},
             column{2-Z}={font=\fontsize{7}{9}\selectfont},
             row{1} = {ht = 6ex},
             row{1} = {font =\bfseries},
             row{1} = {bg = green7},
             row{1} = {font =\fontsize{9}{6}\selectfont},
             hspan=minimal}                                                                                                                                                                                                                                                             
\textbf{\begin{tabular}[c]{@{}c@{}}Column\\ Header\end{tabular}}   & {{{\textbf{\begin{tabular}[c]{@{}c@{}}Column\\ Header\end{tabular}}}}} & {{{\textbf{\begin{tabular}[c]{@{}c@{}}Variable\\ \%\end{tabular}}}}} & {{{\textbf{\begin{tabular}[c]{@{}c@{}}Variable\\ \%\end{tabular}}}}} & {{{\textbf{\begin{tabular}[c]{@{}c@{}}Column\\ Header\end{tabular}}}}} & {{{\textbf{\begin{tabular}[c]{@{}c@{}}Variable\\ \%    \end{tabular}}}}} & {{{\textbf{R\ $^{2}$}}}} & {{{\textbf{Comments}}}}       \\
\multicolumn{1}{l}{ \textbf{AA\ $-$ BB}}        &3675 & 7.18 & 8.22  & 3.29 & 3.16 & 0.03 & \multirow{4}{*}{} \\ \cline{1-7}  
\multicolumn{1}{l}{ \textbf{AA\ $-$ BB}}        &2195 & 4.51 & 7.33  & 2.96 & 2.55 & 0.08 &       \\ \cline{1-7}
\multicolumn{1}{l}{ \textbf{AA \ $-$ BB}}       &3075 & 5.63 & 7.25  & 3.28 & 3.77 & 0.03 &   \\ \cline{1-7}
\multicolumn{1}{l}{ \textbf{AA \ $-$ BB}}       &3400 & 4.29 & 10.24 & 1.94 & 2.44 & 0.004 &    
\end{tblr}
    \end{table}
    
\end{document}

答案1

以下两个建议之一怎么样?

\documentclass{article}
\usepackage[margin=3cm]{geometry}
\usepackage[font=scriptsize,
            labelfont=bf]{caption}
\usepackage[xcdraw]{xcolor}
\usepackage{tabularray}
\usepackage{rotating}
\UseTblrLibrary{siunitx}

\usepackage{pdflscape}
\usepackage{lipsum}
\begin{document}


\begin{table}[ht]
\fontsize{9}{10}\selectfont
\centering
\caption{Comparison between AA and BB mean values (wt\%)}
\begin{tblr}{hlines, vlines,vspan=even,
             colspec = {l S[table-format=4] *{4}{S[table-format=2.2]}S[table-format=1.3]X},
             column{1} = {font=\bfseries},
             column{2-Z}={font=\fontsize{7}{9}\selectfont},
             row{1} = {ht = 6ex},
             row{1} = {font =\bfseries},
             row{1} = {bg = green7},
             row{1} = {font =\fontsize{9}{6}\selectfont},
             hspan=minimal}                                                                                                                                                                                                                                                             
\textbf{\begin{tabular}[c]{@{}c@{}}Column\\ Header\end{tabular}}   & {{{\textbf{\begin{tabular}[c]{@{}c@{}}Column\\ Header\end{tabular}}}}} & {{{\textbf{\begin{tabular}[c]{@{}c@{}}Variable\\ \%\end{tabular}}}}} & {{{\textbf{\begin{tabular}[c]{@{}c@{}}Variable\\ \%\end{tabular}}}}} & {{{\textbf{\begin{tabular}[c]{@{}c@{}}Column\\ Header\end{tabular}}}}} & {{{\textbf{\begin{tabular}[c]{@{}c@{}}Variable\\ \%    \end{tabular}}}}} & {{{$\mathbf{R^{2}}$}}} & {{{\textbf{Comments}}}}       \\
AA -- BB & 3675 & 7.18 & 8.22  & 3.29 & 3.16 & 0.03  & \multirow{4}{*}{\lipsum[1][1-5]} \\ \cline{1-7}  
AA -- BB & 2195 & 4.51 & 7.33  & 2.96 & 2.55 & 0.08  &       \\ \cline{1-7}
AA -- BB & 3075 & 5.63 & 7.25  & 3.28 & 3.77 & 0.03  &   \\ \cline{1-7}
AA -- BB & 3400 & 4.29 & 10.24 & 1.94 & 2.44 & 0.004 &    
\end{tblr}
    \end{table}
    
    
    
\begin{landscape}

\begin{table}[ht]
\fontsize{9}{10}\selectfont
\centering
\caption{Comparison between AA and BB mean values (wt\%)}
\begin{tblr}{hlines, vlines,vspan=even,
             colspec = {l S[table-format=4] *{4}{S[table-format=2.2]}S[table-format=1.3]X},
             column{1} = {font=\bfseries},
             column{2-Z}={font=\fontsize{7}{9}\selectfont},
             row{1} = {ht = 6ex},
             row{1} = {font =\bfseries},
             row{1} = {bg = green7},
             row{1} = {font =\fontsize{9}{6}\selectfont},
             hspan=minimal}                                                                                                                                                                                                                                                             
\textbf{\begin{tabular}[c]{@{}c@{}}Column\\ Header\end{tabular}}    & {{{\textbf{\begin{tabular}[c]{@{}c@{}}Column\\ Header\end{tabular}}}}} & {{{\textbf{\begin{tabular}[c]{@{}c@{}}Variable\\ \%\end{tabular}}}}} & {{{\textbf{\begin{tabular}[c]{@{}c@{}}Variable\\ \%\end{tabular}}}}} & {{{\textbf{\begin{tabular}[c]{@{}c@{}}Column\\ Header\end{tabular}}}}} & {{{\textbf{\begin{tabular}[c]{@{}c@{}}Variable\\ \%    \end{tabular}}}}} & {{{$\mathbf{R^{2}}$}}} & {{{\textbf{Comments}}}}       \\
AA -- BB & 3675 & 7.18 & 8.22  & 3.29 & 3.16 & 0.03  & \multirow{4}{*}{\lipsum[1][1-8]} \\ \cline{1-7}  
AA -- BB & 2195 & 4.51 & 7.33  & 2.96 & 2.55 & 0.08  &       \\ \cline{1-7}
AA -- BB & 3075 & 5.63 & 7.25  & 3.28 & 3.77 & 0.03  &   \\ \cline{1-7}
AA -- BB & 3400 & 4.29 & 10.24 & 1.94 & 2.44 & 0.004 &    
\end{tblr}
    \end{table}
    
    
 \end{landscape}
\end{document}

答案2

不幸的是,我无权发表评论 :) 我只是想补充一点,你应该使用命令\SetCell[]{}而不是\multirow在 tblr 环境中。P.5 在文档

... & \multirow{4}{*}{\lipsum[1][1-8]} &... % old
... & \SetCell[r=4]{c} \lipsum[1][1-8] & ... % better

相关内容