3

I am trying to make wide column in two-columns format. my table has multi-columns too and there is gap in the last column. how can I get rid of it? Also it's in one column know. how can I make it wide?

enter image description here

\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}
6
  • 1
    Welcome! The text InceptionResnetv2 is too wide. You could typeset it in two rows. E.g. \multicolumn{ 2}{c}{\begin{tabular}[t]{@{}c@{}} Inception\\ Resnetv2 \end{tabular}} is an option.
    – user194703
    Apr 7, 2020 at 2:52
  • I see. How can I do that?
    – Nouf
    Apr 7, 2020 at 2:54
  • 1
    Use e.g. \multicolumn{ 2}{c}{\begin{tabular}[t]{@{}c@{}} Inception\\ Resnetv2 \end{tabular}} for that entry. You may also want to consider removing the vertical lines.
    – user194703
    Apr 7, 2020 at 2:55
  • thanks. do you have an idea how can I make the table wide?
    – Nouf
    Apr 7, 2020 at 2:57
  • If you want to fill a certain amount of space, you could use the tabularx package. Also the cc in \begin{tabular}{lrr|rr|rr|rr|rr|cc} are unnecessary.
    – user194703
    Apr 7, 2020 at 2:58

3 Answers 3

2

You asked in a comment,

do you have an idea how can I make the table wide?

Some suggestions and observations, in no particular order:

  • When you say that you would like to make the table "wide", I assume you mean, "as wide as the textblock". If this assumption is correct, I suggest you use a 9-column tabularx environment. The first column should presumably be typeset raggedright while the 8 data columns should be typeset centered.

  • To permit equal column widths across the 8 data columns, you need to permit line breaking in at least one of the header cells. The code below shows how this may be set up.

  • The material in the first cell will get line-wrapped automatically, as needed.

  • I think your readers will appreciate it if the numbers are aligned on their respective decimal markers. This may be achieved by using the S column type of the siunitx package.

enter image description here

\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}
7
  • how is the font and appearance of your table better -- though in the preamble there is nothing additional compared to my answer below
    – js bibra
    Apr 7, 2020 at 5:34
  • @jsbibra - Please clarify what you mean by "better" font and appearance. (You don't mean the resolution of the screenshots, do you?)
    – Mico
    Apr 7, 2020 at 6:14
  • compare your table with mine -- what is the difference due? is it resolution-- becauae its is not standalone
    – js bibra
    Apr 7, 2020 at 6:22
  • @jsbibra - Our workflows for generating screenshots may differ consirably. I'm on a MacBook Air with MacOS 10.15.4 "Catalina", and I create screenshots (in png format) via Command-Shift-"4". Comparing the structures of our tables, an obvious difference is in the use of colored rows and columns. Another difference is in the use or non-use of \cmidrule directives to tie together the cells in the first and second rows of the header. Still another difference pertains to how the numbers are typeset: centered in your case, aligned on the decimal markers in mine.
    – Mico
    Apr 7, 2020 at 6:48
  • 1
    i take a screenshot with evernote -- my windows 10 desktop and macbook air both have evernote-- but what i was referring was not the details but the visual impact of your table when compared with other tables in stack exchange other answers--your table stands out when you lean back and look at it-- just wondering how its so
    – js bibra
    Apr 7, 2020 at 8:13
2

For grouping columns you can insert empty columns between their pairs:

\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}

enter image description here

2

enter image description here

\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}

Addendum

for horizontal spread of the table you can play with adding in the preamble

\setlength{\tabcolsep}{15pt}

and remove verticals for visual appeal {||||||}

the result

enter image description here

enter image description here

4
  • 1
    +1. Since you're using color (and grayscale) to provide visual formatting, you can omit the horizontal rules
    – Mico
    Apr 7, 2020 at 5:05
  • 1
    true that -- and your +1 could be on the up pointing triangle -- hahaha -- just joking
    – js bibra
    Apr 7, 2020 at 5:28
  • I've gone ahead and inserted an additional screenshot, immediately below your second screenshot. I'll let you decide if you wish to delete the older one -- or the newer one. :-)
    – Mico
    Apr 7, 2020 at 9:46
  • your table still looks better --IMHO
    – js bibra
    Apr 7, 2020 at 11:39

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.