我有 60 行 12 列,表格中有大量文本数据。我使用的是 IEEEtran 格式。我想将表格放在整个页面中并继续到下一页。尝试了许多库,但对我不起作用。我的代码如下。
\documentclass[conference]{IEEEtran}
\usepackage{tabularx,booktabs}
\newcolumntype{C}{>{\centering\arraybackslash}X} % centered version of "X" type
\setlength{\extrarowheight}{1pt}
\usepackage{lipsum}
\begin{document}
\lipsum[1] % filler text
\begin{table*}
\caption{CIFAR-10 Confusion Matrix}
\label{my-label}
\begin{tabularx}{\textwidth}{@{}l*{10}{C}c@{}}
\toprule
labels & airplane & automobile & bird & cat & deer & dog & frog & horse & ship & truck & accuracy \\
\midrule
airplane & 915 & 4 & 17 & 19 & 3 & 1 & 0 & 2 & 27 & 12 & 91.50\% \\
automobile & 8 & 934 & 3 & 4 & 0 & 0 & 3 & 0 & 10 & 38 & 93.40\% \\
bird & 60 & 1 & 813 & 37 & 19 & 23 & 30 & 10 & 7 & 0 & 81.30\% \\
cat & 18 & 1 & 34 & 746 & 25 & 113 & 37 & 18 & 8 & 0 & 74.60\% \\
deer & 24 & 1 & 38 & 33 & 809 & 19 & 44 & 29 & 2 & 1 & 80.90\% \\
\addlinespace
dog & 4 & 0 & 37 & 106 & 23 & 792 & 9 & 26 & 2 & 1 & 79.20\% \\
frog & 2 & 5 & 19 & 35 & 1 & 20 & 912 & 2 & 3 & 1 & 91.20\% \\
horse & 14 & 0 & 26 & 20 & 18 & 28 & 4 & 886 & 3 & 1 & 88.60\% \\
ship & 35 & 10 & 3 & 2 & 0 & 2 & 1 & 0 & 936 & 11 & 93.60\% \\
truck & 23 & 37 & 4 & 10 & 1 & 2 & 2 & 0 & 15 & 906 & 90.60\% \\
\bottomrule
\end{tabularx}
\end{table*}
\lipsum[2-15] % more filler text
\end{document}
答案1
你的意思是这样的:
\documentclass[conference]{IEEEtran}
\usepackage{tabularx,booktabs, longtable}
\newcolumntype{C}{>{\centering\arraybackslash}X} % centered version of "X" type
\setlength{\extrarowheight}{1pt}
\usepackage{lipsum}
\begin{document}
\lipsum[1] % filler text
\onecolumn
\begin{longtable}{lccccccccccc}
\hline
labels & airplane & automobile & bird & cat & deer & dog & frog & horse & ship & truck & accuracy \\
\hline
airplane & 915 & 4 & 17 & 19 & 3 & 1 & 0 & 2 & 27 & 12 & 91.50\% \\
automobile & 8 & 934 & 3 & 4 & 0 & 0 & 3 & 0 & 10 & 38 & 93.40\% \\
bird & 60 & 1 & 813 & 37 & 19 & 23 & 30 & 10 & 7 & 0 & 81.30\% \\
cat & 18 & 1 & 34 & 746 & 25 & 113 & 37 & 18 & 8 & 0 & 74.60\% \\
deer & 24 & 1 & 38 & 33 & 809 & 19 & 44 & 29 & 2 & 1 & 80.90\% \\
\addlinespace
dog & 4 & 0 & 37 & 106 & 23 & 792 & 9 & 26 & 2 & 1 & 79.20\% \\
frog & 2 & 5 & 19 & 35 & 1 & 20 & 912 & 2 & 3 & 1 & 91.20\% \\
horse & 14 & 0 & 26 & 20 & 18 & 28 & 4 & 886 & 3 & 1 & 88.60\% \\
ship & 35 & 10 & 3 & 2 & 0 & 2 & 1 & 0 & 936 & 11 & 93.60\% \\
truck & 23 & 37 & 4 & 10 & 1 & 2 & 2 & 0 & 15 & 906 & 90.60\% \\
airplane & 915 & 4 & 17 & 19 & 3 & 1 & 0 & 2 & 27 & 12 & 91.50\% \\
automobile & 8 & 934 & 3 & 4 & 0 & 0 & 3 & 0 & 10 & 38 & 93.40\% \\
bird & 60 & 1 & 813 & 37 & 19 & 23 & 30 & 10 & 7 & 0 & 81.30\% \\
cat & 18 & 1 & 34 & 746 & 25 & 113 & 37 & 18 & 8 & 0 & 74.60\% \\
deer & 24 & 1 & 38 & 33 & 809 & 19 & 44 & 29 & 2 & 1 & 80.90\% \\
\addlinespace
dog & 4 & 0 & 37 & 106 & 23 & 792 & 9 & 26 & 2 & 1 & 79.20\% \\
frog & 2 & 5 & 19 & 35 & 1 & 20 & 912 & 2 & 3 & 1 & 91.20\% \\
horse & 14 & 0 & 26 & 20 & 18 & 28 & 4 & 886 & 3 & 1 & 88.60\% \\
ship & 35 & 10 & 3 & 2 & 0 & 2 & 1 & 0 & 936 & 11 & 93.60\% \\
truck & 23 & 37 & 4 & 10 & 1 & 2 & 2 & 0 & 15 & 906 & 90.60\% \\
airplane & 915 & 4 & 17 & 19 & 3 & 1 & 0 & 2 & 27 & 12 & 91.50\% \\
automobile & 8 & 934 & 3 & 4 & 0 & 0 & 3 & 0 & 10 & 38 & 93.40\% \\
bird & 60 & 1 & 813 & 37 & 19 & 23 & 30 & 10 & 7 & 0 & 81.30\% \\
cat & 18 & 1 & 34 & 746 & 25 & 113 & 37 & 18 & 8 & 0 & 74.60\% \\
deer & 24 & 1 & 38 & 33 & 809 & 19 & 44 & 29 & 2 & 1 & 80.90\% \\
\addlinespace
dog & 4 & 0 & 37 & 106 & 23 & 792 & 9 & 26 & 2 & 1 & 79.20\% \\
frog & 2 & 5 & 19 & 35 & 1 & 20 & 912 & 2 & 3 & 1 & 91.20\% \\
horse & 14 & 0 & 26 & 20 & 18 & 28 & 4 & 886 & 3 & 1 & 88.60\% \\
ship & 35 & 10 & 3 & 2 & 0 & 2 & 1 & 0 & 936 & 11 & 93.60\% \\
truck & 23 & 37 & 4 & 10 & 1 & 2 & 2 & 0 & 15 & 906 & 90.60\% \\
airplane & 915 & 4 & 17 & 19 & 3 & 1 & 0 & 2 & 27 & 12 & 91.50\% \\
automobile & 8 & 934 & 3 & 4 & 0 & 0 & 3 & 0 & 10 & 38 & 93.40\% \\
bird & 60 & 1 & 813 & 37 & 19 & 23 & 30 & 10 & 7 & 0 & 81.30\% \\
cat & 18 & 1 & 34 & 746 & 25 & 113 & 37 & 18 & 8 & 0 & 74.60\% \\
deer & 24 & 1 & 38 & 33 & 809 & 19 & 44 & 29 & 2 & 1 & 80.90\% \\
\addlinespace
dog & 4 & 0 & 37 & 106 & 23 & 792 & 9 & 26 & 2 & 1 & 79.20\% \\
frog & 2 & 5 & 19 & 35 & 1 & 20 & 912 & 2 & 3 & 1 & 91.20\% \\
horse & 14 & 0 & 26 & 20 & 18 & 28 & 4 & 886 & 3 & 1 & 88.60\% \\
ship & 35 & 10 & 3 & 2 & 0 & 2 & 1 & 0 & 936 & 11 & 93.60\% \\
truck & 23 & 37 & 4 & 10 & 1 & 2 & 2 & 0 & 15 & 906 & 90.60\% \\
airplane & 915 & 4 & 17 & 19 & 3 & 1 & 0 & 2 & 27 & 12 & 91.50\% \\
automobile & 8 & 934 & 3 & 4 & 0 & 0 & 3 & 0 & 10 & 38 & 93.40\% \\
bird & 60 & 1 & 813 & 37 & 19 & 23 & 30 & 10 & 7 & 0 & 81.30\% \\
cat & 18 & 1 & 34 & 746 & 25 & 113 & 37 & 18 & 8 & 0 & 74.60\% \\
deer & 24 & 1 & 38 & 33 & 809 & 19 & 44 & 29 & 2 & 1 & 80.90\% \\
\addlinespace
dog & 4 & 0 & 37 & 106 & 23 & 792 & 9 & 26 & 2 & 1 & 79.20\% \\
frog & 2 & 5 & 19 & 35 & 1 & 20 & 912 & 2 & 3 & 1 & 91.20\% \\
horse & 14 & 0 & 26 & 20 & 18 & 28 & 4 & 886 & 3 & 1 & 88.60\% \\
ship & 35 & 10 & 3 & 2 & 0 & 2 & 1 & 0 & 936 & 11 & 93.60\% \\
truck & 23 & 37 & 4 & 10 & 1 & 2 & 2 & 0 & 15 & 906 & 90.60\% \\
airplane & 915 & 4 & 17 & 19 & 3 & 1 & 0 & 2 & 27 & 12 & 91.50\% \\
automobile & 8 & 934 & 3 & 4 & 0 & 0 & 3 & 0 & 10 & 38 & 93.40\% \\
bird & 60 & 1 & 813 & 37 & 19 & 23 & 30 & 10 & 7 & 0 & 81.30\% \\
cat & 18 & 1 & 34 & 746 & 25 & 113 & 37 & 18 & 8 & 0 & 74.60\% \\
deer & 24 & 1 & 38 & 33 & 809 & 19 & 44 & 29 & 2 & 1 & 80.90\% \\
\addlinespace
dog & 4 & 0 & 37 & 106 & 23 & 792 & 9 & 26 & 2 & 1 & 79.20\% \\
frog & 2 & 5 & 19 & 35 & 1 & 20 & 912 & 2 & 3 & 1 & 91.20\% \\
horse & 14 & 0 & 26 & 20 & 18 & 28 & 4 & 886 & 3 & 1 & 88.60\% \\
ship & 35 & 10 & 3 & 2 & 0 & 2 & 1 & 0 & 936 & 11 & 93.60\% \\
truck & 23 & 37 & 4 & 10 & 1 & 2 & 2 & 0 & 15 & 906 & 90.60\% \\
\hline
\end{longtable}
\twocolumn
\lipsum[2-15] % more filler text
\end{document}
从普通表进入longtable
环境并手动切换到单列;-)
。
得出:
答案2
从两列改为一列再改回来总是从新页面开始。因此,使用它们通常会在更改文档格式时引入大量空白空间。更好的方法是(在我看来)手动将表格拆分为两个(大致相等)部分,然后将它们连续插入文档中table*
。
通过使用该包stfloats
可以将表格的第一部分放在页面底部(通过使用放置选项)[b]
,将第二部分放在下一页的顶部(通过使用放置选项)[t]
。
为了使表格各部分的标题一致,即使用相同的图号,请在\caption
命令前的第二个表格部分中使用 \ContinuedFloatt defined in the
caption` 包。
除此之外,我建议使用S
列类型(在sinuntx
包中定义)来表示带数字的列,对于表格环境,使用 by ,tabularx
这样除了表格之外还可以规定列宽。对于后者,在以下 MWE 中定义了新命令:
\newcolumntype{C}{>{\centering\arraybackslash}X} % centered version of "X" type
\newcommand\mcx[1]{\multicolumn{1}{C}{#1}}
用于列标题:
\documentclass[conference]{IEEEtran}
\usepackage{booktabs, makecell, tabularx}
\newcolumntype{C}{>{\centering\arraybackslash}X} % centered version of "X" type
\newcommand\mcx[1]{\multicolumn{1}{C}{#1}}
\setlength{\extrarowheight}{1pt}
\usepackage{stfloats}
\usepackage{siunitx}
\usepackage{caption}
\usepackage{lipsum}
\begin{document}
\lipsum[1] % filler text
\begin{table*}[b]
\centering
\caption{My huge table}
\label{tab:hugetable}
\begin{tabularx}{\linewidth}{l *{10}{S[table-format=3.0]} c}
\toprule
labels
& \mcx{airplane} & \mcx{automobile} & \mcx{bird} & \mcx{cat} & \mcx{deer}
& \mcx{dog} & \mcx{frog} & \mcx{horse} & \mcx{ship} & \mcx{truck}
& accuracy \\
\midrule
airplane & 915 & 4 & 17 & 19 & 3 & 1 & 0 & 2 & 27 & 12 & 91.50\% \\
automobile & 8 & 934 & 3 & 4 & 0 & 0 & 3 & 0 & 10 & 38 & 93.40\% \\
bird & 60 & 1 & 813 & 37 & 19 & 23 & 30 & 10 & 7 & 0 & 81.30\% \\
cat & 18 & 1 & 34 & 746 & 25 & 113 & 37 & 18 & 8 & 0 & 74.60\% \\
deer & 24 & 1 & 38 & 33 & 809 & 19 & 44 & 29 & 2 & 1 & 80.90\% \\
\addlinespace
dog & 4 & 0 & 37 & 106 & 23 & 792 & 9 & 26 & 2 & 1 & 79.20\% \\
frog & 2 & 5 & 19 & 35 & 1 & 20 & 912 & 2 & 3 & 1 & 91.20\% \\
horse & 14 & 0 & 26 & 20 & 18 & 28 & 4 & 886 & 3 & 1 & 88.60\% \\
ship & 35 & 10 & 3 & 2 & 0 & 2 & 1 & 0 & 936 & 11 & 93.60\% \\
truck & 23 & 37 & 4 & 10 & 1 & 2 & 2 & 0 & 15 & 906 & 90.60\% \\
airplane & 915 & 4 & 17 & 19 & 3 & 1 & 0 & 2 & 27 & 12 & 91.50\% \\
automobile & 8 & 934 & 3 & 4 & 0 & 0 & 3 & 0 & 10 & 38 & 93.40\% \\
bird & 60 & 1 & 813 & 37 & 19 & 23 & 30 & 10 & 7 & 0 & 81.30\% \\
cat & 18 & 1 & 34 & 746 & 25 & 113 & 37 & 18 & 8 & 0 & 74.60\% \\
deer & 24 & 1 & 38 & 33 & 809 & 19 & 44 & 29 & 2 & 1 & 80.90\% \\
\addlinespace
dog & 4 & 0 & 37 & 106 & 23 & 792 & 9 & 26 & 2 & 1 & 79.20\% \\
frog & 2 & 5 & 19 & 35 & 1 & 20 & 912 & 2 & 3 & 1 & 91.20\% \\
horse & 14 & 0 & 26 & 20 & 18 & 28 & 4 & 886 & 3 & 1 & 88.60\% \\
ship & 35 & 10 & 3 & 2 & 0 & 2 & 1 & 0 & 936 & 11 & 93.60\% \\
truck & 23 & 37 & 4 & 10 & 1 & 2 & 2 & 0 & 15 & 906 & 90.60\% \\
airplane & 915 & 4 & 17 & 19 & 3 & 1 & 0 & 2 & 27 & 12 & 91.50\% \\
automobile & 8 & 934 & 3 & 4 & 0 & 0 & 3 & 0 & 10 & 38 & 93.40\% \\
bird & 60 & 1 & 813 & 37 & 19 & 23 & 30 & 10 & 7 & 0 & 81.30\% \\
cat & 18 & 1 & 34 & 746 & 25 & 113 & 37 & 18 & 8 & 0 & 74.60\% \\
deer & 24 & 1 & 38 & 33 & 809 & 19 & 44 & 29 & 2 & 1 & 80.90\% \\
\bottomrule
\multicolumn{12}{>{\footnotesize\itshape}r}{Continue on the next page}
\end{tabularx}
\end{table*}%
%
\begin{table*}[t]
\ContinuedFloat
\centering
\caption{My huge table (cont.)}
\begin{tabularx}{\linewidth}{l *{10}{S[table-format=3.0]} c}
\toprule
labels
& \mcx{airplane} & \mcx{automobile} & \mcx{bird} & \mcx{cat} & \mcx{deer}
& \mcx{dog} & \mcx{frog} & \mcx{horse} & \mcx{ship} & \mcx{truck}
& accuracy \\
\midrule
dog & 4 & 0 & 37 & 106 & 23 & 792 & 9 & 26 & 2 & 1 & 79.20\% \\
frog & 2 & 5 & 19 & 35 & 1 & 20 & 912 & 2 & 3 & 1 & 91.20\% \\
horse & 14 & 0 & 26 & 20 & 18 & 28 & 4 & 886 & 3 & 1 & 88.60\% \\
ship & 35 & 10 & 3 & 2 & 0 & 2 & 1 & 0 & 936 & 11 & 93.60\% \\
truck & 23 & 37 & 4 & 10 & 1 & 2 & 2 & 0 & 15 & 906 & 90.60\% \\
airplane & 915 & 4 & 17 & 19 & 3 & 1 & 0 & 2 & 27 & 12 & 91.50\% \\
automobile & 8 & 934 & 3 & 4 & 0 & 0 & 3 & 0 & 10 & 38 & 93.40\% \\
bird & 60 & 1 & 813 & 37 & 19 & 23 & 30 & 10 & 7 & 0 & 81.30\% \\
cat & 18 & 1 & 34 & 746 & 25 & 113 & 37 & 18 & 8 & 0 & 74.60\% \\
deer & 24 & 1 & 38 & 33 & 809 & 19 & 44 & 29 & 2 & 1 & 80.90\% \\
\addlinespace
dog & 4 & 0 & 37 & 106 & 23 & 792 & 9 & 26 & 2 & 1 & 79.20\% \\
frog & 2 & 5 & 19 & 35 & 1 & 20 & 912 & 2 & 3 & 1 & 91.20\% \\
horse & 14 & 0 & 26 & 20 & 18 & 28 & 4 & 886 & 3 & 1 & 88.60\% \\
ship & 35 & 10 & 3 & 2 & 0 & 2 & 1 & 0 & 936 & 11 & 93.60\% \\
truck & 23 & 37 & 4 & 10 & 1 & 2 & 2 & 0 & 15 & 906 & 90.60\% \\
airplane & 915 & 4 & 17 & 19 & 3 & 1 & 0 & 2 & 27 & 12 & 91.50\% \\
automobile & 8 & 934 & 3 & 4 & 0 & 0 & 3 & 0 & 10 & 38 & 93.40\% \\
bird & 60 & 1 & 813 & 37 & 19 & 23 & 30 & 10 & 7 & 0 & 81.30\% \\
cat & 18 & 1 & 34 & 746 & 25 & 113 & 37 & 18 & 8 & 0 & 74.60\% \\
deer & 24 & 1 & 38 & 33 & 809 & 19 & 44 & 29 & 2 & 1 & 80.90\% \\
\addlinespace
dog & 4 & 0 & 37 & 106 & 23 & 792 & 9 & 26 & 2 & 1 & 79.20\% \\
frog & 2 & 5 & 19 & 35 & 1 & 20 & 912 & 2 & 3 & 1 & 91.20\% \\
horse & 14 & 0 & 26 & 20 & 18 & 28 & 4 & 886 & 3 & 1 & 88.60\% \\
ship & 35 & 10 & 3 & 2 & 0 & 2 & 1 & 0 & 936 & 11 & 93.60\% \\
truck & 23 & 37 & 4 & 10 & 1 & 2 & 2 & 0 & 15 & 906 & 90.60\% \\
airplane & 915 & 4 & 17 & 19 & 3 & 1 & 0 & 2 & 27 & 12 & 91.50\% \\
automobile & 8 & 934 & 3 & 4 & 0 & 0 & 3 & 0 & 10 & 38 & 93.40\% \\
bird & 60 & 1 & 813 & 37 & 19 & 23 & 30 & 10 & 7 & 0 & 81.30\% \\
cat & 18 & 1 & 34 & 746 & 25 & 113 & 37 & 18 & 8 & 0 & 74.60\% \\
deer & 24 & 1 & 38 & 33 & 809 & 19 & 44 & 29 & 2 & 1 & 80.90\% \\
\addlinespace
dog & 4 & 0 & 37 & 106 & 23 & 792 & 9 & 26 & 2 & 1 & 79.20\% \\
frog & 2 & 5 & 19 & 35 & 1 & 20 & 912 & 2 & 3 & 1 & 91.20\% \\
horse & 14 & 0 & 26 & 20 & 18 & 28 & 4 & 886 & 3 & 1 & 88.60\% \\
ship & 35 & 10 & 3 & 2 & 0 & 2 & 1 & 0 & 936 & 11 & 93.60\% \\
truck & 23 & 37 & 4 & 10 & 1 & 2 & 2 & 0 & 15 & 906 & 90.60\% \\
\bottomrule
\end{tabularx}
\end{table*}
\lipsum % more filler text
\end{document}