我正在尝试格式化一个相当大的列。我希望前两列有多行,但它们被推到第三行和第四行的顶部并打印。您有什么建议吗?
\documentclass[preprint]{elsarticle}
\usepackage{multirow}
\begin{document}
\begin{table}[h]
\centering
\begin{tabular}{c c c c c c c c c c c c c c c c c c c c c c c }
\hline
\multirow{10}{*}{ LESS } & \multirow{2}{*}{ KVA 2L } & r & \multicolumn{1}{c}{ 1 } & \multicolumn{1}{c}{ -0.062 } & \multicolumn{1}{c}{ 0.332 } & \multicolumn{1}{c}{ 0.075 } & \multicolumn{1}{c}{ .482* } & \multicolumn{1}{c}{ } \\ \multicolumn{1}{c}{ 0.425 } & \multicolumn{1}{c}{ 0.323 } & \multicolumn{1}{c}{ 0.238 } & \multicolumn{1}{c}{ 0.033 } & \multicolumn{1}{c}{ 0.070 } & \multicolumn{1}{c}{ 0.250 } \\
& & P & \multicolumn{1}{c}{ 0 } & \multicolumn{1}{c}{ 0.791 } & \multicolumn{1}{c}{ 0.165 } & \multicolumn{1}{c}{ 0.754 } & \multicolumn{1}{c}{ 0.031 } & \multicolumn{1}{c}{ } \\ \multicolumn{1}{c}{ 0.054 } & \multicolumn{1}{c}{ 0.154 } & \multicolumn{1}{c}{ 0.326 } & \multicolumn{1}{c}{ 0.891 } & \multicolumn{1}{c}{ 0.769 } & \multicolumn{1}{c}{ 0.289 } \\
& \multirow{2}{*}{ KVA 3LC } & r & \multicolumn{1}{c}{ -.820** } & \multicolumn{1}{c}{ 0.059 } & \multicolumn{1}{c}{ -.526* } & \multicolumn{1}{c}{ 0.012 } & \multicolumn{1}{c}{ -0.368 } & \multicolumn{1}{c}{ } \\ \multicolumn{1}{c}{ -.532* } & \multicolumn{1}{c}{ -0.239 } & \multicolumn{1}{c}{ -0.303 } & \multicolumn{1}{c}{ -0.084 } & \multicolumn{1}{c}{ -0.160 } & \multicolumn{1}{c}{ -0.339 } \\
& & P & \multicolumn{1}{c}{ 0.000 } & \multicolumn{1}{c}{ 0.798 } & \multicolumn{1}{c}{ 0.021 } & \multicolumn{1}{c}{ 0.959 } & \multicolumn{1}{c}{ 0.111 } & \multicolumn{1}{c}{ } \\ \multicolumn{1}{c}{ 0.013 } & \multicolumn{1}{c}{ 0.297 } & \multicolumn{1}{c}{ 0.208 } & \multicolumn{1}{c}{ 0.724 } & \multicolumn{1}{c}{ 0.501 } & \multicolumn{1}{c}{ 0.144 } \\
& \multirow{2}{*}{ KVA 3LF } & r & \multicolumn{1}{c}{ 0.117 } & \multicolumn{1}{c}{ 0.314 } & \multicolumn{1}{c}{ -0.064 } & \multicolumn{1}{c}{ -0.262 } & \multicolumn{1}{c}{ 0.425 } & \multicolumn{1}{c}{ } \\ \multicolumn{1}{c}{ 0.022 } & \multicolumn{1}{c}{ -0.028 } & \multicolumn{1}{c}{ 0.183 } & \multicolumn{1}{c}{ 0.092 } & \multicolumn{1}{c}{ -0.205 } & \multicolumn{1}{c}{ -0.326 } \\
& & P & \multicolumn{1}{c}{ 0.613 } & \multicolumn{1}{c}{ 0.165 } & \multicolumn{1}{c}{ 0.794 } & \multicolumn{1}{c}{ 0.265 } & \multicolumn{1}{c}{ 0.062 } & \multicolumn{1}{c}{ } \\ \multicolumn{1}{c}{ 0.923 } & \multicolumn{1}{c}{ 0.904 } & \multicolumn{1}{c}{ 0.454 } & \multicolumn{1}{c}{ 0.701 } & \multicolumn{1}{c}{ 0.385 } & \multicolumn{1}{c}{ 0.160 } \\
& \multirow{2}{*}{ KVA 2P } & r & \multicolumn{1}{c}{ -.743** } & \multicolumn{1}{c}{ 0.096 } & \multicolumn{1}{c}{ -0.414 } & \multicolumn{1}{c}{ -0.244 } & \multicolumn{1}{c}{ -.495* } & \multicolumn{1}{c}{ } \\ \multicolumn{1}{c}{ -0.394 } & \multicolumn{1}{c}{ -0.218 } & \multicolumn{1}{c}{ -0.006 } & \multicolumn{1}{c}{ 0.126 } & \multicolumn{1}{c}{ -0.144 } & \multicolumn{1}{c}{ -0.057 } \\
& & P & \multicolumn{1}{c}{ 0.000 } & \multicolumn{1}{c}{ 0.677 } & \multicolumn{1}{c}{ 0.078 } & \multicolumn{1}{c}{ 0.299 } & \multicolumn{1}{c}{ 0.027 } & \multicolumn{1}{c}{ } \\ \multicolumn{1}{c}{ 0.077 } & \multicolumn{1}{c}{ 0.342 } & \multicolumn{1}{c}{ 0.981 } & \multicolumn{1}{c}{ 0.598 } & \multicolumn{1}{c}{ 0.544 } & \multicolumn{1}{c}{ 0.810 } \\
& \multirow{2}{*}{ KAY } & r & \multicolumn{1}{c}{ 0.425 } & \multicolumn{1}{c}{ -.462* } & \multicolumn{1}{c}{ 0.278 } & \multicolumn{1}{c}{ 0.293 } & \multicolumn{1}{c}{ 0.153 } & \multicolumn{1}{c}{ } \\ \multicolumn{1}{c}{ 1 } & \multicolumn{1}{c}{ .787** } & \multicolumn{1}{c}{ 0.366 } & \multicolumn{1}{c}{ .469* } & \multicolumn{1}{c}{ .714** } & \multicolumn{1}{c}{ .721** } \\
& & P & \multicolumn{1}{c}{ 0.054 } & \multicolumn{1}{c}{ 0.035 } & \multicolumn{1}{c}{ 0.249 } & \multicolumn{1}{c}{ 0.209 } & \multicolumn{1}{c}{ 0.520 } & \multicolumn{1}{c}{ } \\ \multicolumn{1}{c}{ } & \multicolumn{1}{c}{ 0.000 } & \multicolumn{1}{c}{ 0.123 } & \multicolumn{1}{c}{ 0.037 } & \multicolumn{1}{c}{ 0.000 } & \multicolumn{1}{c}{ 0.000 } \\
\hline
\end{tabular}
\label{tab:xxx}
\end{table}
\end{document}
答案1
根据multirow{2}
命令,我猜测所需的输出看起来类似于以下内容:
\documentclass[preprint]{elsarticle}
\usepackage{multirow}
\usepackage{rotating}
\begin{document}
\begin{sidewaystable}[h]
\centering
\begin{tabular}{c c c c c c c c c c c c c c }
\hline
\multirow{10}{*}{ LESS } & \multirow{2}{*}{ KVA 2L } & r & 1 & -0.062 & 0.332 & 0.075 & .482* & 0.425 & 0.323 & 0.238 & 0.033 & 0.070 & 0.250 \\
& & P & 0 & 0.791 & 0.165 & 0.754 & 0.031 & 0.054 & 0.154 & 0.326 & 0.891 & 0.769 & 0.289 \\
& \multirow{2}{*}{ KVA 3LC } & r & -.820** & 0.059 & -.526* & 0.012 & -0.368 & -.532* & -0.239 & -0.303 & -0.084 & -0.160 & -0.339 \\
& & P & 0.000 & 0.798 & 0.021 & 0.959 & 0.111 & 0.013 & 0.297 & 0.208 & 0.724 & 0.501 & 0.144
\\
& \multirow{2}{*}{ KVA 3LF } & r & 0.117 & 0.314 & -0.064 & -0.262 & 0.425 & 0.022 & -0.028 & 0.183 & 0.092 & -0.205 & -0.326 \\
& & P & 0.613 & 0.165 & 0.794 & 0.265 & 0.062 & 0.923 & 0.904 & 0.454 & 0.701 & 0.385 & 0.160 \\
& \multirow{2}{*}{ KVA 2P } & r & -.743** & 0.096 & -0.414 & -0.244 & -.495* & -0.394 & -0.218 & -0.006 & 0.126 & -0.144 & -0.057 \\
& & P & 0.000 & 0.677 & 0.078 & 0.299 & 0.027 & 0.077 & 0.342 & 0.981 & 0.598 & 0.544 & 0.810 \\
& \multirow{2}{*}{ KAY } & r & 0.425 & -.462* & 0.278 & 0.293 & 0.153 & 1 & .787** & 0.366 & .469* & .714** & .721** \\
& & P & 0.054 & 0.035 & 0.249 & 0.209 & 0.520 & & 0.000 & 0.123 & 0.037 & 0.000 & 0.000 \\
\hline
\end{tabular}
\label{tab:xxx}
\end{sidewaystable}
\end{document}
为了创建上面的图像,我必须
- 删除了所有
\multicolumn{1}{c}{
命令 - 删除多余的
\\
- 删除所有多余的列说明符
- 添加了
rotating
包并使用它sidewaystable
来旋转表格,因为它比文本宽度宽很多。
可以通过以下方式进一步改进该表
- 加载
booktabs
并替换hline
为toprule
bottomrule
- 使用 的
siunitx
类型S
列以便根据小数分隔符对齐列中的所有数字。
答案2
基于莱安德里斯答案。添加了一些(题外话)改进:
- 对于数字,使用包
S
中定义的列类型siunitx
行按分组进行,每隔一行
\addlinespace
从包中插入booktabs
\documentclass[preprint]{elsarticle} \usepackage{multirow} \usepackage{booktabs} \usepackage{rotating} \usepackage{siunitx} %---------------- show page layout. don't use in a real document! \usepackage{showframe} \renewcommand\ShowFrameLinethickness{0.15pt} \renewcommand*\ShowFrameColor{\color{red}} %---------------------------------------------------------------% \begin{document} \begin{sidewaystable}[ht] \setlength\tabcolsep{0pt} \begin{tabular*}{\linewidth}{@{\extracolsep{\fill}} ll *{12}{S[table-format=-1.3, table-space-text-post=**]} @{}} \toprule \multirow{10}{*}{LESS} & \multirow{2}{*}{KVA 2L} & {r} & 1 & -0.062 & 0.332 & 0.075 & 0.482* & 0.425 & 0.323 & 0.238 & 0.033 & 0.070 & 0.250 \\ & & {P} & 0 & 0.791 & 0.165 & 0.754 & 0.031 & 0.054 & 0.154 & 0.326 & 0.891 & 0.769 & 0.289 \\ \addlinespace & \multirow{2}{*}{KVA 3LC} & {r} & -0.820** & 0.059 & -0.526* & 0.012 & -0.368 & -0.532* & -0.239 & -0.303 & -0.084 & -0.160 & -0.339 \\ & & {P} & 0.000 & 0.798 & 0.021 & 0.959 & 0.111 & 0.013 & 0.297 & 0.208 & 0.724 & 0.501 & 0.144 \\ \addlinespace & \multirow{2}{*}{KVA 3LF} & {r} & 0.117 & 0.314 & -0.064 & -0.262 & 0.425 & 0.022 & -0.028 & 0.183 & 0.092 & -0.205 & -0.326 \\ & & {P} & 0.613 & 0.165 & 0.794 & 0.265 & 0.062 & 0.923 & 0.904 & 0.454 & 0.701 & 0.385 & 0.160 \\ \addlinespace & \multirow{2}{*}{KVA 2P} & {r} & 0.743** & 0.096 & -0.414 & -0.244 & -.495* & -0.394 & -0.218 & -0.006 & 0.126 & -0.144 & -0.057 \\ & & {P} & 0.000 & 0.677 & 0.078 & 0.299 & 0.027 & 0.077 & 0.342 & 0.981 & 0.598 & 0.544 & 0.810 \\ \addlinespace & \multirow{2}{*}{KAY} & {r} & 0.425 & -0.462* & 0.278 & 0.293 & 0.153 & 1.0 & 0.787** & 0.366 & 0.469* & 0.714** & 0.721** \\ & & {P} & 0.054 & 0.035 & 0.249 & 0.209 & 0.520 & & 0.000 & 0.123 & 0.037 & 0.000 & 0.000 \\ \bottomrule \end{tabular*} \label{tab:xxx} \end{sidewaystable} \end{document}