我想将表格拆分成两个(或更多)部分。例如,第一部分应包含列Variable
,Cluster 0
直到Cluster 3
。第二部分,Variable
,Cluster 4
直到Cluster 7
。第三部分,Variable
,Cluster 8
直到Cluster 10
。我尝试旋转以使用longtable
,longtable + rotating
和longtable + lscape
。但我没有成功。
\begin{table}[!htp]
\scriptsize
\begin{tabular}{llllllllllll}
\hline
Variable & Cluster 0 & Cluster 1 & Cluster 2 & Cluster 3 & Cluster 4 & Cluster 5 & Cluster 6 & Cluster 7 & Cluster 8 & Cluster 9 & Cluster 10 \\
\hline
A1 & (41.92, 17.04) & (48.38, 17.46) & (45.74, 16.68) & (38.50, 17.39) & (23.61, 12.38) & (35.48, 16.78) & (30.95, 15.41) & (22.55, 10.55) & (30.0, 12.78) & (27.46, 13.68) & (47.00, 22.46) \\
A2 & (3.63, 2.45) & (4.04, 1.78) & (4.18, 2.15) & (3.40, 2.18) & (2.00, 1.00) & (2.91, 1.68) & (2.33, 1.22) & (1.85, 0.84) & (2.80, 1.48) & (2.09, 0.98) & (2.33, 1.17) \\
A3 & (81.88, 25.13) & (83.78, 25.14) & (80.75, 25.19) & (79.04, 25.85) & (62.60, 22.44) & (77.67, 25.52) & (70.62, 23.89) & (63.15, 20.90) & (78.12, 25.48) & (61.12, 20.90) & (75.13, 28.74) \\
A4 & (16.95, 5.80) & (16.80, 5.39) & (17.22, 5.79) & (16.65, 5.82) & (15.60, 6.39) & (16.17, 5.95) & (15.70, 6.21) & (15.08, 6.50) & (16.86, 5.87) & (15.25, 6.38) & (19.44, 6.05) \\
A5 & (5.58, 1.97) & (6.00, 2.03) & (5.73, 2.00) & (5.56, 2.08) & (4.28, 1.67) & (5.35, 1.97) & (4.80, 1.85) & (4.19, 1.72) & (5.43, 1.97) & (4.12, 1.69) & (5.33, 1.87) \\
A6 & (15.78, 8.20) & (19.89, 8.91) & (17.29, 8.44) & (15.32, 7.33) & (19.27, 9.38) & (14.52, 7.73) & (21.49, 10.06) & (17.16, 7.81) & (13.23, 6.26) & (24.39, 11.45) & (23.75 , 11.79) \\
A7 & (6.32, 4.11) & (8.09, 5.20) & (6.90, 4.70) & (5.46, 4.25) & (1.32, 3.07) & (4.65, 4.13) & (3.10, 3.86) & (0.79, 1.97) & (3.91, 3.52) & (1.40, 3.00) & (5.58, 5.52) \\
A7 & (1079.21, 341.87) & (1337.00, 321.09) & (1188.32, 343.02) & (969.69, 336.70)& (623.15, 308.64)& (877.80, 334.12) & (795.28, 365.01) & (529.28, 257.37)& (744.72, 247.16) & (688.08, 336.96) & (1018.33, 565.19)\\
A8 & (0.08, 0.09) & (0.08, 0.08) & (0.08, 0.08) & (0.08, 0.09) & (0.07, 0.12) & (0.08, 0.10) & (0.07, 0.11) & (0.05, 0.14) & (0.08, 0.10) & (0.06, 0.12) & (0.07, 0.10) \\
A9 & (0.45, 0.10) & (0.43, 0.09) & (0.45, 0.10) & (0.43, 0.12) & (0.42, 0.16) & (0.43, 0.13) & (0.42, 0.14) & (0.40, 0.18) & (0.43, 0.13) & (0.42, 0.15) & (0.40, 0.14) \\
A10 & (29.06, 11.90) & (29.16, 10.90) & (27.62, 11.38) & (29.37, 12.40) & (33.81, 15.23) & (30.50, 12.91) & (32.39, 13.92) & (34.34, 16.45) & (30.34, 13.30) & (33.07, 15.36) & (29.39, 16.36) \\
A11 & (48.68, 14.17) & (60.30, 13.92) & (54.95, 14.92) & (43.46, 14.03) & (25.32, 10.88) & (39.13, 13.50) & (34.31, 13.88) & (21.65, 9.36) & (34.72, 11.29) & (27.94, 11.91) & (45.27, 25.48) \\
A12 & (281.04, 89.12)& (347.93, 82.88) & (308.74, 88.32) & (253.14, 86.95) & (159.23, 76.27) & (228.18, 85.93) & (204.00, 92.58) & (134.84, 63.06) &(195.90, 63.75) & (175.90, 83.24) & (265.06, 141.55)\\
A13 & (157.10, 50.13) & (198.93, 48.32) & (171.46, 49.63) & (142.32, 50.97) & (92.37, 45.85) & (129.00, 49.12) & (117.86, 54.80) & (79.01, 37.84) &(110.36, 36.47) & (102.27, 49.94) & (148.50, 84.43) \\
A14 & (6.43, 2.16) & (7.94, 2.20) & (7.01, 2.12) & (5.86, 2.13) & (3.84, 1.82) & (5.37, 2.03) & (4.84, 2.17) & (3.36, 1.60) & (4.78, 1.65) & (4.14, 1.93) & (5.83, 2.72) \\ \hline
\end{tabular}
\caption{Caption}
\label{tab:persona}
\end{table}
观察:在longtable
环境中,我使用了下面的代码,但是它破坏了行而不是列。
\hline \multicolumn{1}{c}{Variable} & \multicolumn{1}{c}{Cluster 0} & \multicolumn{1}{c}{Cluster 1} & \multicolumn{1}{c}{Cluster 2} & \multicolumn{1}{c}{Cluster 3} & \multicolumn{1}{c}{Cluster 4} & \multicolumn{1}{c}{Cluster 5} \\ \hline
\endfirsthead
\multicolumn{7}{c}%
{\tablename\ \thetable{} -- continued from previous page} \\
\hline \multicolumn{1}{c}{Variable} & \multicolumn{1}{c}{Cluster 6} & \multicolumn{1}{c}{Cluster 7} & \multicolumn{1}{c}{Cluster 8} & \multicolumn{1}{c}{Cluster 9} & \multicolumn{1}{c}{Cluster 10} \\ \hline
\endhead
\hline \multicolumn{6}{r}{{Continued on next page}} \\ \hline
\endfoot
\hline
\endlastfoot
答案1
\documentclass{article}
\usepackage{caption}
\usepackage{longtable}
\usepackage{booktabs}
\begin{document}
{\small\setlength{\tabcolsep}{4pt}
\begin{longtable}{lllll}
\caption{Caption}
\label{tab:persona}\\
\toprule
\endfirsthead
\caption[]{Caption -- continued from previous page}\\
\toprule
\endhead
\bottomrule
\endfoot
Variable & Cluster 0 & Cluster 1 & Cluster 2 & Cluster 3 \\
\midrule
A1 & (41.92, 17.04) & (48.38, 17.46) & (45.74, 16.68) & (38.50, 17.39) \\
A2 & (3.63, 2.45) & (4.04, 1.78) & (4.18, 2.15) & (3.40, 2.18) \\
A3 & (81.88, 25.13) & (83.78, 25.14) & (80.75, 25.19) & (79.04, 25.85) \\ \addlinespace
A4 & (16.95, 5.80) & (16.80, 5.39) & (17.22, 5.79) & (16.65, 5.82) \\
A5 & (5.58, 1.97) & (6.00, 2.03) & (5.73, 2.00) & (5.56, 2.08) \\
A6 & (15.78, 8.20) & (19.89, 8.91) & (17.29, 8.44) & (15.32, 7.33) \\ \addlinespace
A7 & (6.32, 4.11) & (8.09, 5.20) & (6.90, 4.70) & (5.46, 4.25) \\
A7 & (1079.21, 341.87) & (1337.00, 321.09) & (1188.32, 343.02) & (969.69, 336.70) \\
A8 & (0.08, 0.09) & (0.08, 0.08) & (0.08, 0.08) & (0.08, 0.09) \\ \addlinespace
A9 & (0.45, 0.10) & (0.43, 0.09) & (0.45, 0.10) & (0.43, 0.12) \\
A10 & (29.06, 11.90) & (29.16, 10.90) & (27.62, 11.38) & (29.37, 12.40) \\
A11 & (48.68, 14.17) & (60.30, 13.92) & (54.95, 14.92) & (43.46, 14.03) \\ \addlinespace
A12 & (281.04, 89.12) & (347.93, 82.88) & (308.74, 88.32) & (253.14, 86.95) \\
A13 & (157.10, 50.13) & (198.93, 48.32) & (171.46, 49.63) & (142.32, 50.97) \\
A14 & (6.43, 2.16) & (7.94, 2.20) & (7.01, 2.12) & (5.86, 2.13) \\
\midrule
Variable & Cluster 4 & Cluster 5 & Cluster 6 & Cluster 7 \\
\midrule
A1 & (23.61, 12.38) & (35.48, 16.78) & (30.95, 15.41) & (22.55, 10.55) \\
A2 & (2.00, 1.00) & (2.91, 1.68) & (2.33, 1.22) & (1.85, 0.84) \\
A3 & (62.60, 22.44) & (77.67, 25.52) & (70.62, 23.89) & (63.15, 20.90) \\ \addlinespace
A4 & (15.60, 6.39) & (16.17, 5.95) & (15.70, 6.21) & (15.08, 6.50) \\
A5 & (4.28, 1.67) & (5.35, 1.97) & (4.80, 1.85) & (4.19, 1.72) \\
A6 & (19.27, 9.38) & (14.52, 7.73) & (21.49, 10.06) & (17.16, 7.81) \\ \addlinespace
A7 & (1.32, 3.07) & (4.65, 4.13) & (3.10, 3.86) & (0.79, 1.97) \\
A7 & (623.15, 308.64) & (877.80, 334.12) & (795.28, 365.01) & (529.28, 257.37) \\
A8 & (0.07, 0.12) & (0.08, 0.10) & (0.07, 0.11) & (0.05, 0.14) \\ \addlinespace
A9 & (0.42, 0.16) & (0.43, 0.13) & (0.42, 0.14) & (0.40, 0.18) \\
A10 & (33.81, 15.23) & (30.50, 12.91) & (32.39, 13.92) & (34.34, 16.45) \\
A11 & (25.32, 10.88) & (39.13, 13.50) & (34.31, 13.88) & (21.65, 9.36) \\ \addlinespace
A12 & (159.23, 76.27) & (228.18, 85.93) & (204.00, 92.58) & (134.84, 63.06) \\
A13 & (92.37, 45.85) & (129.00, 49.12) & (117.86, 54.80) & (79.01, 37.84) \\
A14 & (3.84, 1.82) & (5.37, 2.03) & (4.84, 2.17) & (3.36, 1.60) \\
\midrule
Variable & Cluster 8 & Cluster 9 & Cluster 10 \\
\midrule
A1 & (30.0, 12.78) & (27.46, 13.68) & (47.00, 22.46) \\
A2 & (2.80, 1.48) & (2.09, 0.98) & (2.33, 1.17) \\
A3 & (78.12, 25.48) & (61.12, 20.90) & (75.13, 28.74) \\ \addlinespace
A4 & (16.86, 5.87) & (15.25, 6.38) & (19.44, 6.05) \\
A5 & (5.43, 1.97) & (4.12, 1.69) & (5.33, 1.87) \\
A6 & (13.23, 6.26) & (24.39, 11.45) & (23.75 , 11.79) \\ \addlinespace
A7 & (3.91, 3.52) & (1.40, 3.00) & (5.58, 5.52) \\
A7 & (744.72, 247.16) & (688.08, 336.96) & (1018.33, 565.19) \\
A8 & (0.08, 0.10) & (0.06, 0.12) & (0.07, 0.10) \\ \addlinespace
A9 & (0.43, 0.13) & (0.42, 0.15) & (0.40, 0.14) \\
A10 & (30.34, 13.30) & (33.07, 15.36) & (29.39, 16.36) \\
A11 & (34.72, 11.29) & (27.94, 11.91) & (45.27, 25.48) \\ \addlinespace
A12 & (195.90, 63.75) & (175.90, 83.24) & (265.06, 141.55) \\
A13 & (110.36, 36.47) & (102.27, 49.94) & (148.50, 84.43) \\
A14 & (4.78, 1.65) & (4.14, 1.93) & (5.83, 2.72) \\
\end{longtable}
}
\end{document}
答案2
所有数据单元格中的左括号和右括号以及逗号后的空格实际上占用很大的空间。如果您愿意抑制它们,完全可以在单个横向页面中排版表格。
以下代码和屏幕截图展示了两种可能的解决方案。第一种在布局方面基本遵循了 OP 的代码,例如所有列都左对齐。第二种将数据列以逗号为中心,为标题提供更多结构,并通过在每三个数据行后插入额外的空格来安排一些视觉分组。
\documentclass{article} % or some other suitable document class
\usepackage[a4paper,margin=2.5cm]{geometry} % set page parameters suitably
\usepackage{rotating,booktabs,caption,dcolumn}
\newcolumntype{d}{D,,{-1}} % for second table
\newcommand\mc[1]{\multicolumn{1}{c}{#1}} % handy shortcut macro
\begin{document}
\begin{sidewaystable}
\captionsetup{font=footnotesize,skip=0.5\baselineskip}
\footnotesize
\setlength\tabcolsep{0pt} % let LaTeX figure out amount of intercolumn whitespace
\begin{tabular*}{\textwidth}{@{\extracolsep{\fill}} *{12}{l} }
\toprule
Var.
& Cluster 0 & Cluster 1 & Cluster 2 & Cluster 3 & Cluster 4
& Cluster 5 & Cluster 6 & Cluster 7 & Cluster 8 & Cluster 9
& Cluster 10 \\
\midrule
A1 & 41.92,17.04 & 48.38,17.46 & 45.74,16.68 & 38.50,17.39 & 23.61,12.38 & 35.48,16.78 & 30.95,15.41 & 22.55,10.55 & 30.0,12.78 & 27.46,13.68 & 47.00,22.46 \\
A2 & 3.63,2.45 & 4.04,1.78 & 4.18,2.15 & 3.40,2.18 & 2.00,1.00 & 2.91,1.68 & 2.33,1.22 & 1.85,0.84 & 2.80,1.48 & 2.09,0.98 & 2.33,1.17 \\
A3 & 81.88,25.13 & 83.78,25.14 & 80.75,25.19 & 79.04,25.85 & 62.60,22.44 & 77.67,25.52 & 70.62,23.89 & 63.15,20.90 & 78.12,25.48 & 61.12,20.90 & 75.13,28.74 \\
\addlinespace
A4 & 16.95,5.80 & 16.80,5.39 & 17.22,5.79 & 16.65,5.82 & 15.60,6.39 & 16.17,5.95 & 15.70,6.21 & 15.08,6.50 & 16.86,5.87 & 15.25,6.38 & 19.44,6.05 \\
A5 & 5.58,1.97 & 6.00,2.03 & 5.73,2.00 & 5.56,2.08 & 4.28,1.67 & 5.35,1.97 & 4.80,1.85 & 4.19,1.72 & 5.43,1.97 & 4.12,1.69 & 5.33,1.87 \\
A6 & 15.78,8.20 & 19.89,8.91 & 17.29,8.44 & 15.32,7.33 & 19.27,9.38 & 14.52,7.73 & 21.49,10.06 & 17.16,7.81 & 13.23,6.26 & 24.39,11.45 & 23.75 ,11.79 \\
A7 & 6.32,4.11 & 8.09,5.20 & 6.90,4.70 & 5.46,4.25 & 1.32,3.07 & 4.65,4.13 & 3.10,3.86 & 0.79,1.97 & 3.91,3.52 & 1.40,3.00 & 5.58,5.52 \\
A7 & 1079.21,341.87 & 1337.00,321.09 & 1188.32,343.02 & 969.69,336.70& 623.15,308.64& 877.80,334.12 & 795.28,365.01 & 529.28,257.37& 744.72,247.16 & 688.08,336.96 & 1018.33,565.19\\
A8 & 0.08,0.09 & 0.08,0.08 & 0.08,0.08 & 0.08,0.09 & 0.07,0.12 & 0.08,0.10 & 0.07,0.11 & 0.05,0.14 & 0.08,0.10 & 0.06,0.12 & 0.07,0.10 \\
A9 & 0.45,0.10 & 0.43,0.09 & 0.45,0.10 & 0.43,0.12 & 0.42,0.16 & 0.43,0.13 & 0.42,0.14 & 0.40,0.18 & 0.43,0.13 & 0.42,0.15 & 0.40,0.14 \\
A10 & 29.06,11.90 & 29.16,10.90 & 27.62,11.38 & 29.37,12.40 & 33.81,15.23 & 30.50,12.91 & 32.39,13.92 & 34.34,16.45 & 30.34,13.30 & 33.07,15.36 & 29.39,16.36 \\
A11 & 48.68,14.17 & 60.30,13.92 & 54.95,14.92 & 43.46,14.03 & 25.32,10.88 & 39.13,13.50 & 34.31,13.88 & 21.65,9.36 & 34.72,11.29 & 27.94,11.91 & 45.27,25.48 \\
A12 & 281.04,89.12& 347.93,82.88 & 308.74,88.32 & 253.14,86.95 & 159.23,76.27 & 228.18,85.93 & 204.00,92.58 & 134.84,63.06 &195.90,63.75 & 175.90,83.24 & 265.06,141.55\\
A13 & 157.10,50.13 & 198.93,48.32 & 171.46,49.63 & 142.32,50.97 & 92.37,45.85 & 129.00,49.12 & 117.86,54.80 & 79.01,37.84 &110.36,36.47 & 102.27,49.94 & 148.50,84.43 \\
A14 & 6.43,2.16 & 7.94,2.20 & 7.01,2.12 & 5.86,2.13 & 3.84,1.82 & 5.37,2.03 & 4.84,2.17 & 3.36,1.60 & 4.78,1.65 & 4.14,1.93 & 5.83,2.72 \\
\bottomrule
\end{tabular*}
\caption{Caption}
\label{tab:persona}
\vspace{1cm}
\begin{tabular*}{\textwidth}{@{\extracolsep{\fill}} l *{11}{d} }
\toprule
Var. & \multicolumn{11}{c}{Clusters} \\
\cmidrule{2-12}
& \mc{0} & \mc{1} & \mc{2} & \mc{3} & \mc{4} & \mc{5} & \mc{6} & \mc{7} & \mc{8} & \mc{9} & \mc{10} \\
\midrule
A1 & 41.92,17.04 & 48.38,17.46 & 45.74,16.68 & 38.50,17.39 & 23.61,12.38 & 35.48,16.78 & 30.95,15.41 & 22.55,10.55 & 30.0,12.78 & 27.46,13.68 & 47.00,22.46 \\
A2 & 3.63,2.45 & 4.04,1.78 & 4.18,2.15 & 3.40,2.18 & 2.00,1.00 & 2.91,1.68 & 2.33,1.22 & 1.85,0.84 & 2.80,1.48 & 2.09,0.98 & 2.33,1.17 \\
A3 & 81.88,25.13 & 83.78,25.14 & 80.75,25.19 & 79.04,25.85 & 62.60,22.44 & 77.67,25.52 & 70.62,23.89 & 63.15,20.90 & 78.12,25.48 & 61.12,20.90 & 75.13,28.74 \\
\addlinespace
A4 & 16.95,5.80 & 16.80,5.39 & 17.22,5.79 & 16.65,5.82 & 15.60,6.39 & 16.17,5.95 & 15.70,6.21 & 15.08,6.50 & 16.86,5.87 & 15.25,6.38 & 19.44,6.05 \\
A5 & 5.58,1.97 & 6.00,2.03 & 5.73,2.00 & 5.56,2.08 & 4.28,1.67 & 5.35,1.97 & 4.80,1.85 & 4.19,1.72 & 5.43,1.97 & 4.12,1.69 & 5.33,1.87 \\
A6 & 15.78,8.20 & 19.89,8.91 & 17.29,8.44 & 15.32,7.33 & 19.27,9.38 & 14.52,7.73 & 21.49,10.06 & 17.16,7.81 & 13.23,6.26 & 24.39,11.45 & 23.75 ,11.79 \\
\addlinespace
A7 & 6.32,4.11 & 8.09,5.20 & 6.90,4.70 & 5.46,4.25 & 1.32,3.07 & 4.65,4.13 & 3.10,3.86 & 0.79,1.97 & 3.91,3.52 & 1.40,3.00 & 5.58,5.52 \\
A7 & 1079.21,341.87 & 1337.00,321.09 & 1188.32,343.02 & 969.69,336.70& 623.15,308.64& 877.80,334.12 & 795.28,365.01 & 529.28,257.37& 744.72,247.16 & 688.08,336.96 & 1018.33,565.19\\
A8 & 0.08,0.09 & 0.08,0.08 & 0.08,0.08 & 0.08,0.09 & 0.07,0.12 & 0.08,0.10 & 0.07,0.11 & 0.05,0.14 & 0.08,0.10 & 0.06,0.12 & 0.07,0.10 \\
\addlinespace
A9 & 0.45,0.10 & 0.43,0.09 & 0.45,0.10 & 0.43,0.12 & 0.42,0.16 & 0.43,0.13 & 0.42,0.14 & 0.40,0.18 & 0.43,0.13 & 0.42,0.15 & 0.40,0.14 \\
A10 & 29.06,11.90 & 29.16,10.90 & 27.62,11.38 & 29.37,12.40 & 33.81,15.23 & 30.50,12.91 & 32.39,13.92 & 34.34,16.45 & 30.34,13.30 & 33.07,15.36 & 29.39,16.36 \\
A11 & 48.68,14.17 & 60.30,13.92 & 54.95,14.92 & 43.46,14.03 & 25.32,10.88 & 39.13,13.50 & 34.31,13.88 & 21.65,9.36 & 34.72,11.29 & 27.94,11.91 & 45.27,25.48 \\
\addlinespace
A12 & 281.04,89.12& 347.93,82.88 & 308.74,88.32 & 253.14,86.95 & 159.23,76.27 & 228.18,85.93 & 204.00,92.58 & 134.84,63.06 &195.90,63.75 & 175.90,83.24 & 265.06,141.55\\
A13 & 157.10,50.13 & 198.93,48.32 & 171.46,49.63 & 142.32,50.97 & 92.37,45.85 & 129.00,49.12 & 117.86,54.80 & 79.01,37.84 &110.36,36.47 & 102.27,49.94 & 148.50,84.43 \\
A14 & 6.43,2.16 & 7.94,2.20 & 7.01,2.12 & 5.86,2.13 & 3.84,1.82 & 5.37,2.03 & 4.84,2.17 & 3.36,1.60 & 4.78,1.65 & 4.14,1.93 & 5.83,2.72 \\
\bottomrule
\end{tabular*}
\caption{Same table, except (ii) more structure inside header, (ii) data columns centered on commas, and (iii) extra whitespace every third row}
\label{tab:take2}
\end{sidewaystable}
\end{document}