# How to improve this table?

I'm looking for ideas to improve the layout of the following table.

• Is there a better way to separate ABC Metrics and XYZ Metrics (other than using separate table for each metric)?
• Should I convert Algorithms row into a column?
• Should I convert Dataset row into a column?

I would appreciate any ideas, thanks.

\documentclass{article}

\usepackage[margin=1in]{geometry}
\usepackage{tabularx,ragged2e,booktabs}

\begin{document}

\begin{table*}[!ht]
\caption{Evaluation results}
\centering
\setlength{\tabcolsep}{4pt}
\begin{tabularx}{\textwidth}{>{\hsize=1.9\hsize\bfseries\RaggedRight}X!{\extracolsep{\fill}}*{6}{>{\centering\arraybackslash\hsize=0.48\hsize}X}}
\toprule[1pt]\midrule[0.3pt]
\multicolumn{7}{c}{\textbf{ABC Metrics}} \\ \midrule[0.3pt]
\textbf{Algorithm}& \multicolumn{2}{c}{\textit{Algo 1}} & \multicolumn{2}{c}{\textit{Algo 2}} & \multicolumn{2}{c}{\textit{Algo 3}} \\
\cmidrule(lr){2-3} \cmidrule(lr){4-5} \cmidrule(lr){6-7}%
{Dataset} & $D_1$ & $D_2$ & $D_1$ & $D_2$ & $D_1$ & $D_2$ \\
{Matric 1} & 0 & 0 & 0 & 0 & 0 & 0 \\
{Matric 2} & 0 & 0 & 0 & 0 & 0 & 0 \\
{Matric 3} & 0 & 0 & 0 & 0 & 0 & 0 \\
{Matric 4} & 0 & 0 & 0 & 0 & 0 & 0 \\
\midrule
\multicolumn{7}{c}{\textbf{XYZ Metrics}} \\ \midrule[0.3pt]
\textbf{Algorithm}& \multicolumn{2}{c}{\textit{Algo 1}} & \multicolumn{2}{c}{\textit{Algo 2}} & \multicolumn{2}{c}{\textit{Algo 3}} \\
\cmidrule(lr){2-3} \cmidrule(lr){4-5} \cmidrule(lr){6-7}%
{Matric 5} & \multicolumn{2}{c}{0} & \multicolumn{2}{c}{0} & \multicolumn{2}{c}{0} \\ \addlinespace
{Matric 6} & \multicolumn{2}{c}{0} & \multicolumn{2}{c}{0} & \multicolumn{2}{c}{0} \\
\midrule[0.3pt]\bottomrule[1pt]
\end{tabularx}
\end{table*}

\end{document}

• I think this is off-topic because it is subjective. You should ask how to make changes to a table, not opinions on what improvements can you do. – manooooh Jan 3 '19 at 2:24
• @manooooh That's actually a good question for Meta, whether code review questions are accepted here. – Henri Menke Jan 3 '19 at 4:42
• – Werner Jan 3 '19 at 5:55

i only repair some inconsistencies in your column width calculation. the sum of the defined widths is 4.78. but it should be an integer number. all other is opinion based ...

my suggestion for your table code (with some opinion based changes and simplification of writing) is:

\documentclass{article}
\usepackage[margin=1in]{geometry}
\usepackage[skip=1ex]{caption}

\usepackage{ragged2e}
\usepackage{booktabs,tabularx}
\newcommand\mcc[1]{\multicolumn{2}{c}{#1}}

\begin{document}
\begin{table}[!ht]
\caption{Evaluation results}
\centering
\begin{tabularx}{\textwidth}{
>{\hsize=0.4\hsize\bfseries\RaggedRight}X
*{6}{>{\hsize=0.1\hsize\centering\arraybackslash}X}}
\toprule
\multicolumn{7}{c}{\textbf{ABC Metrics}} \\
\midrule
\textbf{Algorithm}
& \mcc{\textit{Algo 1}} & \mcc{\textit{Algo 2}} & \mcc{\textit{Algo 3}} \\
\cmidrule(lr){2-3} \cmidrule(lr){4-5} \cmidrule(lr){6-7}%
Dataset     & $D_1$ & $D_2$ & $D_1$ & $D_2$ & $D_1$ & $D_2$ \\
\midrule
Matric 1   & 0 & 0 & 0 & 0 & 0 & 0 \\
Matric 2    & 0 & 0 & 0 & 0 & 0 & 0 \\
Matric 3    & 0 & 0 & 0 & 0 & 0 & 0 \\
Matric 4    & 0 & 0 & 0 & 0 & 0 & 0 \\
\midrule
\multicolumn{7}{c}{\textbf{XYZ Metrics}} \\ \midrule[0.3pt]
\textbf{Algorithm}
& \mcc{\textit{Algo 1}} & \mcc{\textit{Algo 2}} & \mcc{\textit{Algo 3}} \\
\cmidrule(lr){2-3} \cmidrule(lr){4-5} \cmidrule(lr){6-7}%
{Matric 5} & \mcc{0} & \mcc{0} & \mcc{0} \\
{Matric 6} & \mcc{0} & \mcc{0} & \mcc{0} \\
\bottomrule
\end{tabularx}
\end{table}
\end{document}


which gives:

• I don't understand why you're using 1 tabularx environment for two structures that don't look all that much connected. I'd use two separate environments.

• Since there appears to be no line-wrapping whatsoever, I don't understand why you'd be using a tabularx environment to begin with. Why not use a tabular* environment? For that matter, why not use tabular environments?

• Using bold-facing and/or italics in the header cells is a transparent attempt to compensate for the lack of clear visual structure. With such an approach, you are mostly going to come across as somebody who (a) isn't particularly well organized and (b) thinks it's ok to shout at people. The people I know, though, very much prefer not to be shouted at. Your experience may differ...

• Based on the information you've provided, the material can easily be presented in two separate, side-by-side tabular environments.

The following solution tries to present the material without any shouting, while still trying to be visually "open" and inviting.

PS. What's a "matric"?

\documentclass{article}
\usepackage[margin=1in,letterpaper]{geometry}
\usepackage[skip=0.5\baselineskip]{caption} % optional
\usepackage{array,booktabs}

\begin{document}
\begin{table}[!ht]
\setlength\tabcolsep{10pt} % default: 6pt
\caption{Evaluation results}

\begin{tabular}[t]{@{} l *{6}{c} @{}}
\multicolumn{7}{@{}l}{ABC Metrics, for datasets $D_1$ and $D_2$} \\
\toprule
& \multicolumn{6}{c@{}}{Algorithm}\\
\cmidrule(l){2-7}
& \multicolumn{2}{c}{Algo 1}
& \multicolumn{2}{c}{Algo 2}
& \multicolumn{2}{c@{}}{Algo 3} \\
\cmidrule(lr){2-3} \cmidrule(lr){4-5} \cmidrule(l){6-7}
& $D_1$ & $D_2$ & $D_1$ & $D_2$ & $D_1$ & $D_2$ \\
\midrule
Matric 1 & 0 & 0 & 0 & 0 & 0 & 0 \\
Matric 2 & 0 & 0 & 0 & 0 & 0 & 0 \\
Matric 3 & 0 & 0 & 0 & 0 & 0 & 0 \\
Matric 4 & 0 & 0 & 0 & 0 & 0 & 0 \\
\bottomrule
\end{tabular}
\hspace{\fill}
\begin{tabular}[t]{@{} l ccc @{}}
\multicolumn{4}{@{}l}{XYZ Metrics} \\
\toprule
& \multicolumn{3}{c@{}}{Algorithm}\\
\cmidrule(l){2-4}
& Algo 1 & Algo 2 & Algo 3 \\
\midrule
Matric 5 & 0 & 0 & 0 \\
Matric 6 & 0 & 0 & 0 \\
\bottomrule
\end{tabular}
\end{table}
\end{document}


I propose this variant layout, with correct coefficients fòr \hsize=:

\documentclass{article}
\usepackage[margin=1in]{geometry}
\usepackage[skip=1ex]{caption}
\usepackage[table, svgnames]{xcolor}

\usepackage{ragged2e}
\usepackage{booktabs,tabularx}
\newcommand\mcc[1]{\multicolumn{2}{c}{#1}}

\begin{document}

\begin{table}[!ht]
\caption{Evaluation results}
\centering
\setlength{\extrarowheight}{2pt}
\setlength{\belowrulesep}{0pt}
\begin{tabularx}{\textwidth}{
>{\hsize=2.8\hsize\bfseries\RaggedRight}X
*{6}{>{\hsize=0.7\hsize\centering\arraybackslash}X}}
\toprule
& \multicolumn{6}{c}{\textbf{Algorithm}} \\
\cmidrule{2-7}
& \mcc{\textit{Algo 1}} & \mcc{\textit{Algo 2}} & \mcc{\textit{Algo 3}} \\
\rowcolor{WhiteSmoke} ABC Metrics\hfill Dataset & $D₁$ & $D₂$ & $D₁$ & $D₂$ & $D₁$ & $D₂$ \\
Metric 1 & 0 & 0 & 0 & 0 & 0 & 0 \\
Metric 2 & 0 & 0 & 0 & 0 & 0 & 0 \\
Metric 3 & 0 & 0 & 0 & 0 & 0 & 0 \\