这是我的代码:
\documentclass[letterpaper]{article} % DO NOT CHANGE THIS
\usepackage{times} % DO NOT CHANGE THIS
\usepackage{helvet} % DO NOT CHANGE THIS
\usepackage{courier} % DO NOT CHANGE THIS
\usepackage[hyphens]{url} % DO NOT CHANGE THIS
\usepackage{graphicx} % DO NOT CHANGE THIS
\urlstyle{rm} % DO NOT CHANGE THIS
\def\UrlFont{\rm} % DO NOT CHANGE THIS
\usepackage{graphicx} % DO NOT CHANGE THIS
\usepackage{natbib} % DO NOT CHANGE THIS AND DO NOT ADD ANY OPTIONS TO IT
\usepackage{caption} % DO NOT CHANGE THIS AND DO NOT ADD ANY OPTIONS TO IT
\usepackage{multirow}
\usepackage{makecell}
\usepackage{adjustbox}
\usepackage{amsmath}
\usepackage{bm}
\usepackage{amssymb}
\usepackage{mathtools}
\usepackage{textcomp}
\usepackage{array}
\usepackage{pbox}
\frenchspacing % DO NOT CHANGE THIS
\setlength{\pdfpagewidth}{8.5in} % DO NOT CHANGE THIS
\setlength{\pdfpageheight}{11in} % DO NOT CHANGE THIS
\begin{document}
\begin{table*}[ht]
\centering
\begin{adjustbox}{width=0.9\textwidth}
\begin{tabular}{c|c|cc|cc|cc|c}
\hline
\multirow{4}{*}{Network} & \multirow{4}{*}{\makecell{Score\\ Type}} & \multicolumn{2}{c}{\multirow{3}{*}{High SNR}} &
\multicolumn{2}{c}{\multirow{3}{*}{Medium SNR}} &
\multicolumn{2}{c}{\multirow{3}{*}{Low SNR}} &
\multirow{4}{*}{\makecell{Time\\per epoch\\(secs)}}\\
\\
& & MAE & PE (\%) & MAE & PE(\%) & MAE & PE(\%) & \\\hline \hline
\multirow{2}{*}{SVR}
& R & 8.89$\pm$2.07 & 100$\pm$0.00 & 9.23$\pm$1.85 & 100$\pm$0.00 & 9.70$\pm$1.38 & 100$\pm$0.00 & \multirow{2}{*}{---} \\
& E & 9.97$\pm$2.45 & 96.29$\pm$8.30 & 10.08$\pm$2.46 & 96.28$\pm$8.32 & 10.31$\pm$1.56 & 96.40$\pm$8.05 & \\ \hline
\multirow{2}{*}{Lasso}
& R & 18.57$\pm$5.28 & 44.89$\pm$21.06 & 18.56$\pm$5.28 & 44.84$\pm$21.12 & 18.55$\pm$5.24 & 44.85$\pm$21.02 & \multirow{2}{*}{---} \\
& E & 18.60$\pm$3.58 & 43.19$\pm$8.66 & 18.60$\pm$3.57 & 42.95$\pm$8.50 & 18.61$\pm$3.56 & 43.01$\pm$8.61 & \\ \hline
\end{tabular}
\end{adjustbox}
\caption{....}
\label{table:tab2}
\end{table*}
\end{document}
答案1
这里有三个不同的例子说明如何……
- 让你的代码可编译,
- 消除垂直线之间的缝隙
- 将您的桌子放入可用空间,而无需使用
adjustbox
- 改善表格内数字的对齐方式。
在前两个示例中,我删除了adjustbox
宽表并使用了横向页面,而在第三个示例中,我完全更改了表格布局。在第二个和第三个示例中,我删除了所有垂直线,并使用包中的规则替换了水平线booktabs
。此外,我还使用该siunitx
包来改善数字的对齐:
\documentclass[letterpaper]{article} % DO NOT CHANGE THIS
\usepackage{times} % DO NOT CHANGE THIS
\usepackage{helvet} % DO NOT CHANGE THIS
\usepackage{courier} % DO NOT CHANGE THIS
\usepackage[hyphens]{url} % DO NOT CHANGE THIS
\usepackage{graphicx} % DO NOT CHANGE THIS
\urlstyle{rm} % DO NOT CHANGE THIS
\def\UrlFont{\rm} % DO NOT CHANGE THIS
\usepackage{graphicx} % DO NOT CHANGE THIS
\usepackage{natbib} % DO NOT CHANGE THIS AND DO NOT ADD ANY OPTIONS TO IT
\usepackage{caption} % DO NOT CHANGE THIS AND DO NOT ADD ANY OPTIONS TO IT
\usepackage{multirow}
\usepackage{makecell}
\usepackage{adjustbox}
\usepackage{amsmath}
\usepackage{bm}
\usepackage{amssymb}
\usepackage{mathtools}
\usepackage{textcomp}
\usepackage{array}
\usepackage{pbox}
\frenchspacing % DO NOT CHANGE THIS
\setlength{\pdfpagewidth}{8.5in} % DO NOT CHANGE THIS
\setlength{\pdfpageheight}{11in} % DO NOT CHANGE THIS
\usepackage{pdflscape}
\usepackage{booktabs}
\usepackage{siunitx}
\begin{document}
\begin{landscape}
\begin{table}
\centering
\begin{tabular}{c|c|cc|cc|cc|c}
\hline
\multirow{3}{*}{Network} & \multirow{3}{*}{\makecell{Score\\ Type}} & \multicolumn{2}{c|}{\multirow{3}{*}{High SNR}} &
\multicolumn{2}{c|}{\multirow{2}{*}{Medium SNR}} &
\multicolumn{2}{c|}{\multirow{2}{*}{Low SNR}} &
\multirow{3}{*}{\makecell{Time\\per epoch\\(secs)}}\\
& & & & & & & & \\
& & MAE & PE (\%) & MAE & PE(\%) & MAE & PE(\%) & \\\hline \hline
\multirow{2}{*}{SVR}
& R & 8.89$\pm$2.07 & 100$\pm$0.00 & 9.23$\pm$1.85 & 100$\pm$0.00 & 9.70$\pm$1.38 & 100$\pm$0.00 & \multirow{2}{*}{---} \\
& E & 9.97$\pm$2.45 & 96.29$\pm$8.30 & 10.08$\pm$2.46 & 96.28$\pm$8.32 & 10.31$\pm$1.56 & 96.40$\pm$8.05 & \\ \hline
\multirow{2}{*}{Lasso}
& R & 18.57$\pm$5.28 & 44.89$\pm$21.06 & 18.56$\pm$5.28 & 44.84$\pm$21.12 & 18.55$\pm$5.24 & 44.85$\pm$21.02 & \multirow{2}{*}{---} \\
& E & 18.60$\pm$3.58 & 43.19$\pm$8.66 & 18.60$\pm$3.57 & 42.95$\pm$8.50 & 18.61$\pm$3.56 & 43.01$\pm$8.61 & \\ \hline
\end{tabular}
\caption{....}
\label{table:tab2}
\end{table}
\end{landscape}
\begin{landscape}
\begin{table}
\centering
\sisetup{separate-uncertainty=true}
\setlength{\tabcolsep}{5.5pt}
\begin{tabular}{l l *{3}{S[table-format=2.2(3)]S[table-format=3.2(4)]} c}
\toprule
Network
& \makecell{Score\\ Type}
& \multicolumn{2}{c}{High SNR}
& \multicolumn{2}{c}{Medium SNR}
& \multicolumn{2}{c}{Low SNR}
& \makecell{Time\\per epoch\\(secs)}\\
\cmidrule(r){3-4} \cmidrule(lr){5-6} \cmidrule(l){7-8}
& & {MAE} & {PE (\%)} & {MAE} & {PE(\%)} & {MAE} & {PE(\%)} & \\
\midrule
SVR
& R & 8.89(207) & 100(0) & 9.23(185) & 100(0) & 9.70(138) & 100(0) & --- \\
& E & 9.97(245) & 96.29(830) & 10.08(246) & 96.28(832) & 10.31(156) & 96.40(805) & --- \\
\midrule
Lasso
& R & 18.57(528) & 44.89(2106) & 18.56(528) & 44.84(2112) & 18.55(524) & 44.85(2102) & --- \\
& E & 18.60(358) & 43.19(866) & 18.60(357) & 42.95(850) & 18.61(356) & 43.01(861) & --- \\
\bottomrule
\end{tabular}
\caption{....}
\label{table:tab2}
\end{table}
\end{landscape}
\begin{table}
\centering
\sisetup{separate-uncertainty=true}
\setlength{\tabcolsep}{5.5pt}
\begin{tabular}{l l S[table-format=2.2(3)]S[table-format=3.2(4)] c}
\toprule
Network
& \multirow{2}{*}{\makecell{Score\\ Type}}
& \multicolumn{2}{c}{High SNR}
& \multirow{2}{*}{\makecell{Time per \\epoch (secs)}}\\
\cmidrule(r){3-4}
& & {MAE} & {PE (\%)} \\
\midrule
SVR
& R & 8.89(207) & 100(0) & --- \\
& E & 9.97(245) & 96.29(830) & --- \\
\addlinespace
Lasso
& R & 18.57(528) & 44.89(2106) & --- \\
& E & 18.60(358) & 43.19(866) & --- \\
\midrule
Network
& \multirow{2}{*}{\makecell{Score\\ Type}}
& \multicolumn{2}{c}{Medium SNR}
& \multirow{2}{*}{\makecell{Time per \\epoch (secs)}}\\
\cmidrule(r){3-4}
& & {MAE} & {PE (\%)} \\
\midrule
SVR
& R & 9.23(185) & 100(0) & --- \\
& E & 10.08(246) & 96.28(832) & --- \\
\addlinespace
Lass
& R & 18.56(528) & 44.84(2112) & --- \\
& E & 18.60(357) & 42.95(850) & --- \\
\midrule
Network
& \multirow{2}{*}{\makecell{Score\\ Type}}
& \multicolumn{2}{c}{Low SNR}
& \multirow{2}{*}{\makecell{Time per \\epoch (secs)}}\\
\cmidrule(r){3-4}
& & {MAE} & {PE (\%)} \\
\midrule
SVR
& R & 9.70(138) & 100(0) & --- \\
& E & 10.31(156) & 96.40(805) & --- \\
\addlinespace
Lass
& R & 18.55(524) & 44.85(2102) & --- \\
& E & 18.61(356) & 43.01(861) & --- \\
\midrule
\end{tabular}
\caption{....}
\label{table:tab2}
\end{table}
\end{document}
答案2
您没有指出文档的边距有多宽。假设每个边距大约为 1 英寸宽,实际上可以以纵向模式排版表格没有不得不诉诸\adjustbox
棍棒。
由于您的文档采用了times
文本字体包,因此我强烈建议您使用 Times Roman 数学字体包;其中一个包是newtxmath
。
我还想鼓励您让表格看起来更加开放,主要是通过摆脱所有垂直规则,并使用包中的线条绘制宏来使用更少但间距适当的水平规则booktabs
。
为了演示使用 会对表格造成的最坏影响\adjustbox
,下面是原始代码生成的表格的屏幕截图。请特别注意,表格主体和标题的字体大小存在巨大差异。
最后,这是生成第一个屏幕截图的代码。
\documentclass[letterpaper]{article}
\usepackage{amsmath,booktabs,multirow,makecell}
\usepackage[margin=1in]{geometry} % set margins as needed
\usepackage{times,newtxmath} % use a Times Roman math font
\usepackage{array}
\newcolumntype{C}{>{$}c<{$}}
\newcommand\x[1][1]{\phantom{#1}} % for spacing adjustments
\newcommand\px{\mathord{\pm}} % "\pm" but without the spacing
\begin{document}
\begin{table}[ht]
\setlength\tabcolsep{0pt}## Heading ##
\begin{tabular*}{\textwidth}{@{\extracolsep{\fill}}
l c *{6}{C} c }
\toprule
Network
& \makecell{Score\\Type}
& \multicolumn{2}{c}{High SNR}
& \multicolumn{2}{c}{Medium SNR}
& \multicolumn{2}{c}{Low SNR}
& \makecell{Time\\per epoch}\\
\cmidrule{3-4} \cmidrule{5-6} \cmidrule{7-8}
& & \text{MAE} & \text{PE (\%)}
& \text{MAE} & \text{PE (\%)}
& \text{MAE} & \text{PE (\%)}
& (secs) \\
\midrule
\multirow{2}{*}{SVR}
& R & \x8.89\px2.07 & \x[1.]100\px\x0.00 & \x9.23\px1.85
& \x[1.]100\px\x0.00 & \x9.70\px1.38 & \x[1.]100\px\x0.00
& \multirow{2}{*}{--} \\
& E & \x9.97\px2.45 & 96.29\px\x8.30 & 10.08\px2.46
& 96.28\px\x8.32 & 10.31\px1.56 & 96.40\px\x8.05 & \\
\addlinespace
\multirow{2}{*}{Lasso}
& R & 18.57\px5.28 & 44.89\px21.06 & 18.56\px5.28
& 44.84\px21.12 & 18.55\px5.24 & 44.85\px21.02
& \multirow{2}{*}{--} \\
& E & 18.60\px3.58 & 43.19\px\x8.66 & 18.60\px3.57
& 42.95\px\x8.50 & 18.61\px3.56 & 43.01\px\x8.61 & \\
\bottomrule
\end{tabular*}
\caption{\dots}
\label{table:tab2}
\end{table}
\end{document}