宽列多列

宽列多列

我正在尝试以双列格式制作宽列。我的表格也有多列,最后一列有间隙。我该如何消除它?而且它现在在一列中。我该如何使它变宽?

在此处输入图片描述

\lipsum[1-4]
\begin{table}[htbp]
\caption{wide table.}
\begin{tabular}{lrr|rr|rr|rr|rr|cc}
\toprule
() & \multicolumn{ 2}{c}{VGG16} & \multicolumn{ 2}{c}{Inceptionv3} & \multicolumn{ 2}{c}{ResNet50} & \multicolumn{ 2}{c}{InceptionResnetv2} \\ 
() & \multicolumn{1}{l}{32} & \multicolumn{1}{l}{64}  & \multicolumn{1}{l}{32} & \multicolumn{1}{l}{64} & \multicolumn{1}{l}{32} &
\multicolumn{1}{l}{64} & \multicolumn{1}{l}{32} & \multicolumn{1}{l}{64}  \\ 
\midrule
a & 1.2 & 0.1 & 0.2 & 3.5 & 0.4 & 0.0 & 0.2 & 0.0   \\
b & 12.8 & 3.8 & 4.9 & 5.9 & 1.4 & 0.1 & 4.8 & 1.5  \\
c & 15.5 & 10.4 & 13.4 & 0.4 & 0.3 & 0.0 & 3.8 & 2.5 \\
ç & 15.5 & 10.4 & 13.4 & 0.4 & 0.3 & 0.0 & 3.8 & 2.5 \\
d & 14.0 & 17.3 & 22.2 & 0.7 & 0.8 & 0.0 & 0.9 & 1.1   \\
e & 7.9 & 21.1 & 27.0 & 0.0 & 0.0 & 0.0 & 0.3 & 0.8  \\
f & 3.0 & 22.3 & 28.6 & 0.0 & 0.0 & 0.0 & 0.0 & 0.0 \\
g & 54.6 & 75.0 & 96.4 & 10.6 & 2.9 & 0.2 & 10.1 & 5.9  \\
h & 54.6 & 75.0 & 96.4 & 10.6 & 2.9 & 0.2 & 10.1 & 5.9  \\
i & 54.6 & 75.0 & 96.4 & 10.6 & 2.9 & 0.2 & 10.1 & 5.9  \\
j & 54.6 & 75.0 & 96.4 & 10.6 & 2.9 & 0.2 & 10.1 & 5.9  \\
l & 54.6 & 75.0 & 96.4 & 10.6 & 2.9 & 0.2 & 10.1 & 5.9  \\
m & 54.6 & 75.0 & 96.4 & 10.6 & 2.9 & 0.2 & 10.1 & 5.9  \\
n & 54.6 & 75.0 & 96.4 & 10.6 & 2.9 & 0.2 & 10.1 & 5.9  \\
o & 54.6 & 75.0 & 96.4 & 10.6 & 2.9 & 0.2 & 10.1 & 5.9  \\
p & 54.6 & 75.0 & 96.4 & 10.6 & 2.9 & 0.2 & 10.1 & 5.9  \\
q & 54.6 & 75.0 & 96.4 & 10.6 & 2.9 & 0.2 & 10.1 & 5.9  \\
r & 54.6 & 75.0 & 96.4 & 10.6 & 2.9 & 0.2 & 10.1 & 5.9  \\
s & 54.6 & 75.0 & 96.4 & 10.6 & 2.9 & 0.2 & 10.1 & 5.9  \\
t & 54.6 & 75.0 & 96.4 & 10.6 & 2.9 & 0.2 & 10.1 & 5.9  \\
uv & 54.6 & 75.0 & 96.4 & 10.6 & 2.9 & 0.2 & 10.1 & 5.9  \\
x & 54.6 & 75.0 & 96.4 & 10.6 & 2.9 & 0.2 & 10.1 & 5.9  \\
y & 54.6 & 75.0 & 96.4 & 10.6 & 2.9 & 0.2 & 10.1 & 5.9  \\
z & 54.6 & 75.0 & 96.4 & 10.6 & 2.9 & 0.2 & 10.1 & 5.9  \\
\bottomrule
\end{tabular}
\label{t:props}

\end{table}

答案1

你在评论中问道,

你知道怎样才能让桌子变宽吗?

一些建议和意见(无特定顺序):

  • 当您说要使表格“宽”时,我假设您的意思是“与文本块一样宽”。如果这个假设正确,我建议您使用 9 列tabularx环境。第一列应该排版为右对齐,而 8 个数据列应该排版为居中。

  • 要允许 8 个数据列的列宽相等,您需要允许至少一个标题单元格换行。以下代码显示了如何设置。

  • 第一个单元格中的内容将根据需要自动换行。

  • 我认为,如果数字与各自的小数点对齐,您的读者会很感激。这可以通过使用包S的列类型来实现siunitx

在此处输入图片描述

\documentclass{article}
\usepackage{booktabs}
\usepackage{tabularx} % for 'tabularx' env. and 'X' col. type
\usepackage{ragged2e} % for '\Centering' and '\RaggedRight' macros
\usepackage{siunitx}  % for 'S' column type
\usepackage[skip=0.333\baselineskip]{caption} % optional

\newcolumntype{L}{>{\RaggedRight\arraybackslash}X}
\newcolumntype{C}{>{\Centering\arraybackslash}X}
\newcolumntype{T}[1]{S[table-format=#1]}

\newcommand\mC[1]{\multicolumn{1}{C}{#1}} % handy shortcut macro
\newcommand\mCC[2]{\multicolumn{2}{>{\hsize=\dimexpr2\hsize+2\tabcolsep\relax}#1}{#2}}

\begin{document}
\begin{table}[htbp]
\sisetup{parse-numbers=false}
\caption{wide table.}\label{t:props}
\begin{tabularx}{\textwidth}{@{} L *{4}{T{2.1}} T{1.1} T{1.1} T{2.1} T{1.1} @{}}
\toprule
() & \mCC{C}{VGG16} 
   & \mCC{C}{Inception v3} 
   & \mCC{C}{ResNet 50} 
   & \mCC{C@{}}{Inception Resnetv2} \\
\cmidrule(lr){2-3} \cmidrule(lr){4-5} \cmidrule(lr){6-7} \cmidrule(l){8-9} 
() & \mC{32} & \mC{64}  & \mC{32} & \mC{64} 
   & \mC{32} & \mC{64}  & \mC{32} & \multicolumn{1}{C@{}}{64} \\ 
\midrule
a &  1.2 &  0.1 &  0.2 &  3.5 & 0.4 & 0.0 &  0.2 & 0.0 \\
b & 12.8 &  3.8 &  4.9 &  5.9 & 1.4 & 0.1 &  4.8 & 1.5 \\
c & 15.5 & 10.4 & 13.4 &  0.4 & 0.3 & 0.0 &  3.8 & 2.5 \\
ç & 15.5 & 10.4 & 13.4 &  0.4 & 0.3 & 0.0 &  3.8 & 2.5 \\
d & 14.0 & 17.3 & 22.2 &  0.7 & 0.8 & 0.0 &  0.9 & 1.1 \\
e &  7.9 & 21.1 & 27.0 &  0.0 & 0.0 & 0.0 &  0.3 & 0.8 \\
f &  3.0 & 22.3 & 28.6 &  0.0 & 0.0 & 0.0 &  0.0 & 0.0 \\
g & 54.6 & 75.0 & 96.4 & 10.6 & 2.9 & 0.2 & 10.1 & 5.9 \\
h & 54.6 & 75.0 & 96.4 & 10.6 & 2.9 & 0.2 & 10.1 & 5.9 \\
i & 54.6 & 75.0 & 96.4 & 10.6 & 2.9 & 0.2 & 10.1 & 5.9 \\
j & 54.6 & 75.0 & 96.4 & 10.6 & 2.9 & 0.2 & 10.1 & 5.9 \\
l & 54.6 & 75.0 & 96.4 & 10.6 & 2.9 & 0.2 & 10.1 & 5.9 \\
m & 54.6 & 75.0 & 96.4 & 10.6 & 2.9 & 0.2 & 10.1 & 5.9 \\
n & 54.6 & 75.0 & 96.4 & 10.6 & 2.9 & 0.2 & 10.1 & 5.9 \\
o & 54.6 & 75.0 & 96.4 & 10.6 & 2.9 & 0.2 & 10.1 & 5.9 \\
p & 54.6 & 75.0 & 96.4 & 10.6 & 2.9 & 0.2 & 10.1 & 5.9 \\
q & 54.6 & 75.0 & 96.4 & 10.6 & 2.9 & 0.2 & 10.1 & 5.9 \\
r & 54.6 & 75.0 & 96.4 & 10.6 & 2.9 & 0.2 & 10.1 & 5.9 \\
s & 54.6 & 75.0 & 96.4 & 10.6 & 2.9 & 0.2 & 10.1 & 5.9 \\
t & 54.6 & 75.0 & 96.4 & 10.6 & 2.9 & 0.2 & 10.1 & 5.9 \\
uv& 54.6 & 75.0 & 96.4 & 10.6 & 2.9 & 0.2 & 10.1 & 5.9 \\
x & 54.6 & 75.0 & 96.4 & 10.6 & 2.9 & 0.2 & 10.1 & 5.9 \\
y & 54.6 & 75.0 & 96.4 & 10.6 & 2.9 & 0.2 & 10.1 & 5.9 \\
z & 54.6 & 75.0 & 96.4 & 10.6 & 2.9 & 0.2 & 10.1 & 5.9 \\
\bottomrule
\end{tabularx}
\end{table}
\end{document}

答案2

对于分组列,您可以在列对之间插入空列:

\documentclass{article}
\usepackage[skip=1ex]{caption}
\usepackage{booktabs, makecell}
\usepackage{siunitx}
\usepackage{xparse}
\NewExpandableDocumentCommand\mcc{O{1}m}
    {\multicolumn{#1}{c}{#2}}

%---------------- show page layout. don't use in a real document!
\usepackage{showframe}
\renewcommand\ShowFrameLinethickness{0.15pt}
\renewcommand*\ShowFrameColor{\color{red}}
%---------------------------------------------------------------%
\usepackage{lipsum}

\begin{document}
\lipsum[1]
    \begin{table}[htbp]
    \centering
\caption{wide table.}
    \label{t:props}
\sisetup{table-format=2.1, table-column-width=2em}
\begin{tabular}{l SS c SS c S[table-format=1.1]S[table-format=1.1] c SS[table-format=1.1]}
   \toprule
    & \mcc[2]{VGG16} &&  \mcc[2]{Inceptionv3} 
        &&  \mcc[2]{ResNet50} && \mcc[2]{\makecell[b]{Inception\\Resnetv2}}  \\
    \cmidrule{2-3}
    \cmidrule{5-6}
    \cmidrule{8-9}
    \cmidrule{11-12}
    & \mcc{32} & \mcc{64}  && \mcc{32} & \mcc{64} 
        && \mcc{32} & \mcc{64} && \mcc{32} & \mcc{64}     \\
    \midrule
a   & 1.2  &  0.1 &&  0.2 &  3.5 && 0.4 & 0.0 &&  0.2 & 0.0   \\
b   & 12.8 &  3.8 &&  4.9 &  5.9 && 1.4 & 0.1 &&  4.8 & 1.5  \\
c   & 15.5 & 10.4 && 13.4 &  0.4 && 0.3 & 0.0 && 3.8 & 2.5 \\
ç   & 15.5 & 10.4 && 13.4 &  0.4 && 0.3 & 0.0 && 3.8 & 2.5 \\
d   & 14.0 & 17.3 && 22.2 &  0.7 && 0.8 & 0.0 && 0.9 & 1.1   \\
e   &  7.9 & 21.1 && 27.0 &  0.0 && 0.0 & 0.0 && 0.3 & 0.8  \\
f   &  3.0 & 22.3 && 28.6 &  0.0 && 0.0 & 0.0 && 0.0 & 0.0 \\
g   & 54.6 & 75.0 && 96.4 & 10.6 && 2.9 & 0.2 && 10.1 & 5.9  \\
h   & 54.6 & 75.0 && 96.4 & 10.6 && 2.9 & 0.2 && 10.1 & 5.9  \\
i   & 54.6 & 75.0 && 96.4 & 10.6 && 2.9 & 0.2 && 10.1 & 5.9  \\
j   & 54.6 & 75.0 && 96.4 & 10.6 && 2.9 & 0.2 && 10.1 & 5.9  \\
l   & 54.6 & 75.0 && 96.4 & 10.6 && 2.9 & 0.2 && 10.1 & 5.9  \\
m   & 54.6 & 75.0 && 96.4 & 10.6 && 2.9 & 0.2 && 10.1 & 5.9  \\
n   & 54.6 & 75.0 && 96.4 & 10.6 && 2.9 & 0.2 && 10.1 & 5.9  \\
o   & 54.6 & 75.0 && 96.4 & 10.6 && 2.9 & 0.2 && 10.1 & 5.9  \\
p   & 54.6 & 75.0 && 96.4 & 10.6 && 2.9 & 0.2 && 10.1 & 5.9  \\
q   & 54.6 & 75.0 && 96.4 & 10.6 && 2.9 & 0.2 && 10.1 & 5.9  \\
r   & 54.6 & 75.0 && 96.4 & 10.6 && 2.9 & 0.2 && 10.1 & 5.9  \\
s   & 54.6 & 75.0 && 96.4 & 10.6 && 2.9 & 0.2 && 10.1 & 5.9  \\
t   & 54.6 & 75.0 && 96.4 & 10.6 && 2.9 & 0.2 && 10.1 & 5.9  \\
uv  & 54.6 & 75.0 && 96.4 & 10.6 && 2.9 & 0.2 && 10.1 & 5.9  \\
x   & 54.6 & 75.0 && 96.4 & 10.6 && 2.9 & 0.2 && 10.1 & 5.9  \\
y   & 54.6 & 75.0 && 96.4 & 10.6 && 2.9 & 0.2 && 10.1 & 5.9  \\
z   & 54.6 & 75.0 && 96.4 & 10.6 && 2.9 & 0.2 && 10.1 & 5.9  \\
    \bottomrule
\end{tabular}
    \end{table}
\end{document}

在此处输入图片描述

答案3

在此处输入图片描述

\documentclass[11pt,a4paper]{report}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{amsmath}
\usepackage{amsfonts}
\usepackage{amssymb}
\usepackage{graphicx}
\usepackage{lipsum}
\usepackage{booktabs}
\usepackage{xcolor,colortbl}
\usepackage[left=1.00in, right=1.00in, top=1.00in, bottom=1.00in]{geometry}
\begin{document}
    \lipsum[1-4]
    \definecolor{Gray}{gray}{0.85}
    \definecolor{LightCyan}{rgb}{0.88,1,1}

    \newcolumntype{a}{>{\columncolor{Gray}}c}
    \newcolumntype{b}{>{\columncolor{white}}c}
    \begin{table}[htbp]
        \centering\caption{wide table.}
        \begin{tabular}{lab|ab|ab|ab|ab|ab}
            \toprule \rowcolor{LightCyan}
            () & \multicolumn{ 2}{c}{\begin{tabular}[t]{@{}c@{}} VGG\\16 \end{tabular}} & \multicolumn{ 2}{c}{\begin{tabular}[t]{@{}c@{}} Inception\\v3 \end{tabular}} & \multicolumn{ 2}{c}{\begin{tabular}[t]{@{}c@{}} ResNet\\ 50 \end{tabular}} & \multicolumn{ 2}{c}{\begin{tabular}[t]{@{}c@{}} Inception\\ Resnetv2 \end{tabular}} \\ 
            () & \multicolumn{1}{c}{32} & \multicolumn{1}{c}{64}  & \multicolumn{1}{c}{32} & \multicolumn{1}{c}{64} & \multicolumn{1}{c}{32} &
            \multicolumn{1}{c}{64} & \multicolumn{1}{c}{32} & \multicolumn{1}{c}{64}  \\ 
            \midrule
            a & 1.2 & 0.1 & 0.2 & 3.5 & 0.4 & 0.0 & 0.2 & 0.0   \\
            b & 12.8 & 3.8 & 4.9 & 5.9 & 1.4 & 0.1 & 4.8 & 1.5  \\
            c & 15.5 & 10.4 & 13.4 & 0.4 & 0.3 & 0.0 & 3.8 & 2.5 \\
            ç & 15.5 & 10.4 & 13.4 & 0.4 & 0.3 & 0.0 & 3.8 & 2.5 \\
            d & 14.0 & 17.3 & 22.2 & 0.7 & 0.8 & 0.0 & 0.9 & 1.1   \\
            e & 7.9 & 21.1 & 27.0 & 0.0 & 0.0 & 0.0 & 0.3 & 0.8  \\
            f & 3.0 & 22.3 & 28.6 & 0.0 & 0.0 & 0.0 & 0.0 & 0.0 \\
            g & 54.6 & 75.0 & 96.4 & 10.6 & 2.9 & 0.2 & 10.1 & 5.9  \\
            h & 54.6 & 75.0 & 96.4 & 10.6 & 2.9 & 0.2 & 10.1 & 5.9  \\
            i & 54.6 & 75.0 & 96.4 & 10.6 & 2.9 & 0.2 & 10.1 & 5.9  \\
            j & 54.6 & 75.0 & 96.4 & 10.6 & 2.9 & 0.2 & 10.1 & 5.9  \\
            l & 54.6 & 75.0 & 96.4 & 10.6 & 2.9 & 0.2 & 10.1 & 5.9  \\
            m & 54.6 & 75.0 & 96.4 & 10.6 & 2.9 & 0.2 & 10.1 & 5.9  \\
            n & 54.6 & 75.0 & 96.4 & 10.6 & 2.9 & 0.2 & 10.1 & 5.9  \\
            o & 54.6 & 75.0 & 96.4 & 10.6 & 2.9 & 0.2 & 10.1 & 5.9  \\
            p & 54.6 & 75.0 & 96.4 & 10.6 & 2.9 & 0.2 & 10.1 & 5.9  \\
            q & 54.6 & 75.0 & 96.4 & 10.6 & 2.9 & 0.2 & 10.1 & 5.9  \\
            r & 54.6 & 75.0 & 96.4 & 10.6 & 2.9 & 0.2 & 10.1 & 5.9  \\
            s & 54.6 & 75.0 & 96.4 & 10.6 & 2.9 & 0.2 & 10.1 & 5.9  \\
            t & 54.6 & 75.0 & 96.4 & 10.6 & 2.9 & 0.2 & 10.1 & 5.9  \\
            uv & 54.6 & 75.0 & 96.4 & 10.6 & 2.9 & 0.2 & 10.1 & 5.9  \\
            x & 54.6 & 75.0 & 96.4 & 10.6 & 2.9 & 0.2 & 10.1 & 5.9  \\
            y & 54.6 & 75.0 & 96.4 & 10.6 & 2.9 & 0.2 & 10.1 & 5.9  \\
            z & 54.6 & 75.0 & 96.4 & 10.6 & 2.9 & 0.2 & 10.1 & 5.9  \\
            \bottomrule
        \end{tabular}
        \label{t:props}

    \end{table}
\end{document}

附录

对于表格的水平扩展,你可以尝试添加序言

\setlength{\tabcolsep}{15pt}

并删除垂直线以增加视觉吸引力{||||||}

结果

在此处输入图片描述

在此处输入图片描述

相关内容