4

This is more of an open-ended, personal opinion type question. I am trying to make a nice-looking table for a report. Here is what I have so far:

enter image description here

The contents of each are slightly different, but the formats are identical: 8 rows and 10 columns. The first column explains some of the variables being measured. After that, for the next nine columns, the columns are grouped depending on the clustering we used, 3 columns for each method.

Perks and drawbacks for the first table:

  • (+) The vertical dividing lines sort of separate each of the blocks of the table.
  • (-) The top-left part of the table looks absolutely disgusting, and it is weird that the list of variables is just surrounded by a box like that.

Perks and drawbacks for the second table:

  • (-) Because there are no vertical lines, it may be harder to tell the block structure of the table.
  • (+) Seems much more visually appealing than the first. I am not crazy about the empty space in the top left, but there is not much you can do about that, and it is not nearly as bad as the first table.

I also read somewhere that in papers and reports, vertical lines should never ever be used in tables. So the second table has that rule of thumb going for it as well.

Are there any tips/protocols that one should use when constructing tables of this nature? I should note that I used the pdflscape package to make the tables in a landscape format since I would like to fit them on one page.

Here is the code for the tables, sorry if it is a mess:

\documentclass{article}

\usepackage{multirow}
\usepackage{pdflscape}

\begin{document}

\begin{landscape}

\section{Tables}

\begin{table}[ht]
    \centering
    \def\arraystretch{1.5}

    \begin{tabular}{|c|ccc|ccc|ccc|} \cline{2-10}
        \multicolumn{1}{c|}{} & \multicolumn{3}{c|}{No Clustering} & \multicolumn{3}{c|}{$K$-means Clustering} & \multicolumn{3}{c|}{Hierarchical Clustering} \\
        \multicolumn{1}{c|}{} & \multicolumn{3}{c|}{--} & \multicolumn{3}{c|}{$K=2$} & \multicolumn{3}{c|}{$K=7$} \\ \cline{2-10}
        \multicolumn{1}{c|}{} & Lasso & Elastic Net & pcLasso & gLasso & sgLasso & pcLasso & gLasso & sgLasso & pcLasso \\ \hline 
        \multirow{2}{*}{Tuning Parameters} & $\lambda = $ & $\lambda = $ & $\lambda = $ & $\lambda = $ & $\lambda = $ & $\lambda = $ & $\lambda = $ & $\lambda = $ & $\lambda = $ \\
         & -- & $\alpha = 0.2$ & $\texttt{rat} = 0.95$ & -- & $\alpha = $ & $\texttt{rat} = 0.95$ & -- & $\alpha = $ & $\texttt{rat} = 0.95$ \\
        Misclassifications & $6/31$ & $5/31$ & $5/31$ & $5/31$ & $/31$ & $4/31$ & $5/31$ & $/31$ & $3/31$ \\
        Non-zero Coefficients & $16$ & $63$ & $30$ & $1909$ &  & $13$ & $687$ &  & $7$ \\
        Non-zero Groups & -- & -- & -- & $1$ &  &  & $1$ &  &  \\ \hline
    \end{tabular}
    \caption{The performance of various models on the colon data set.}
    \label{colontable}

    \vspace{0.45cm} % max is 0.49cm, 0.5cm causes page break

    \begin{tabular}{cccccccccc} \hline
         & \multicolumn{3}{c}{No Clustering} & \multicolumn{3}{c}{$K$-means Clustering} & \multicolumn{3}{c}{Hierarchical Clustering} \\
         & \multicolumn{3}{c}{--} & \multicolumn{3}{c}{$K=2$} & \multicolumn{3}{c}{$K=5$} \\ \hline
         & Lasso & Elastic Net & pcLasso & gLasso & sgLasso & pcLasso & gLasso & sgLasso & pcLasso \\ \hline
        \multirow{2}{*}{Tuning Parameters} & $\lambda = $ & $\lambda = $ & $\lambda = $ & $\lambda = $ & $\lambda = $ & $\lambda = $ & $\lambda = $ & $\lambda = $ & $\lambda = $ \\
         & -- & $\alpha = 0.8$ & $\texttt{rat} = 0.95$ & -- & $\alpha = $ & $\texttt{rat} = 0.95$ & -- & $\alpha = $ & $\texttt{rat} = 0.95$ \\
        Misclassifications & $5/36$ & $3/36$ & $3/36$ & $5/36$ & $/36$ & $2/36$ & $4/36$ & $/36$ & $2/36$ \\
        Non-zero Coefficients & $14$ & $28$ & $41$ & $7129$ &  & $62$ & $2714$ &  & $46$ \\
        Non-zero Groups & -- & -- & -- & $2$ &  &  & $2$ &  &  \\ \hline
    \end{tabular}
    \caption{The performance of various models on the leukemia data set.}
    \label{leuktable}

\end{table}

\end{landscape}

\end{document}
  • Have a look at booktabs doc. This a package devoted to improve the visual aspect of tables. This is done with different interline rules of different weights (and no vertical lines) and it largely improve tables, IMHO. – Alain Merigot Jul 20 at 21:54
6

I'd recommend the usage of the booktabs package especially the use of its \cmidrule command with which you can easily overcome the drawback that you listed for your second table. I have also used the tabularx package that might come in handy, if the contents of your first column get longer than they currently are as the X type column allows for automated line breaks and ensures that the whole table is exactly as wide as the specified length (\linewidth in case of the following MWE):

enter image description here

\documentclass{article}

\usepackage{multirow}
\usepackage{pdflscape}
\usepackage{booktabs}
\usepackage{tabularx}

\begin{document}

\begin{landscape}

\section{Tables}


\begin{table}[ht]
    \begin{tabularx}{\linewidth}{Xccccccccc} \toprule
         & \multicolumn{3}{c}{No Clustering} & \multicolumn{3}{c}{$K$-means Clustering} & \multicolumn{3}{c}{Hierarchical Clustering} \\ 
         & \multicolumn{3}{c}{--} & \multicolumn{3}{c}{$K=2$} & \multicolumn{3}{c}{$K=5$} \\   
         \cmidrule(r){2-4} \cmidrule(lr){5-7} \cmidrule(l){8-10}
         & Lasso & Elastic Net & pcLasso & gLasso & sgLasso & pcLasso & gLasso & sgLasso & pcLasso \\ \midrule
        Tuning Parameters & $\lambda = $ & $\lambda = $ & $\lambda = $ & $\lambda = $ & $\lambda = $ & $\lambda = $ & $\lambda = $ & $\lambda = $ & $\lambda = $ \\ 
         & -- & $\alpha = 0.8$ & $\texttt{rat} = 0.95$ & -- & $\alpha = $ & $\texttt{rat} = 0.95$ & -- & $\alpha = $ & $\texttt{rat} = 0.95$ \\ \addlinespace
        Misclassifications & $5/36$ & $3/36$ & $3/36$ & $5/36$ & $/36$ & $2/36$ & $4/36$ & $/36$ & $2/36$ \\
        Non-zero Coefficients & $14$ & $28$ & $41$ & $7129$ &  & $62$ & $2714$ &  & $46$ \\
        Non-zero Groups & -- & -- & -- & $2$ &  &  & $2$ &  &  \\ \bottomrule
    \end{tabularx}
    \caption{The performance of various models on the leukemia data set.}
    \label{leuktable}
\end{table}
\end{landscape}

\end{document}
  • Accepted answer because it is very easy to use. I should note, though, that on my document I had to use 0.7865\linewidth instead of \linewidth by default since otherwise, the lines of the table extended way past the last column. – Aiden Kenny Jul 20 at 23:28
4

How about this layout? I've put the caption above the table, which is the typographic traditional position, for obvious reasons. The booktabs package defines horizontal rules with variable thickness and some vertical padding above and below. Furthermore, the \cmidrules can help visualise the groups of columns, using their optional trimming arguments l and r:

\documentclass{article}
\usepackage{multirow}
\usepackage{booktabs, caption}
\usepackage[usestackEOL]{stackengine}
\usepackage{pdflscape}

\begin{document}

\begin{landscape}

\section{Tables}

\begin{table}[ht]
    \centering
    \def\arraystretch{1.5}
\setlength{\cmidrulewidth}{\lightrulewidth}
\setlength{\tabcolsep}{4pt}
    \caption{The performance of various models on the leukemia data set.}
    \label{leuktable}
    \begin{tabular}{@{\,}lccc@{\qquad}ccc@{\qquad}ccc@{\,}}%
         & \multicolumn{3}{c}{\shortstack{No Clustering\\ --}\hspace*{2.5em}} & \multicolumn{3}{c}{\shortstack{$K$-means Clustering \\ $K = 2$}\hspace*{2.5em}} & \multicolumn{3}{c}{\shortstack{Hierarchical Clustering\\$K = 5$}\hspace*{0.5em}} \\
         \cmidrule(r{2.5em}){2-4} \cmidrule(r{2.5em}){5-7} \cmidrule(r{0.5em}){8-10}
         & Lasso & Elastic Net & pcLasso & gLasso & sgLasso & pcLasso & gLasso & sgLasso & pcLasso \\ \midrule
        \multirow{1.75}{*}{Tuning Parameters} & $\lambda = $ & $\lambda = $ & $\lambda = $ & $\lambda = $ & $\lambda = $ & $\lambda = $ & $\lambda = $ & $\lambda = $ & $\lambda = $ \\[-1.5ex]
         & -- & $\alpha = 0.8$ & $\texttt{rat} = 0.95$ & -- & $\alpha = $ & $\texttt{rat} = 0.95$ & -- & $\alpha = $ & $\texttt{rat} = 0.95$ \\
\addlinespace[0.5ex]
        Misclassifications & $5/36$ & $3/36$ & $3/36$ & $5/36$ & $/36$ & $2/36$ & $4/36$ & $/36$ & $2/36$ \\
\addlinespace[0.5ex]
        Non-zero Coefficients & $14$ & $28$ & $41$ & $7129$ & & $62$ & $2714$ & & $46$ \\
\addlinespace[0.5ex]
        Non-zero Groups & -- & -- & -- & $2$ & & & $2$ & & \\ \bottomrule
    \end{tabular}

\end{table}

\end{landscape}

\end{document} 

enter image description here

  • Just curious, what makes you say putting the caption above the table is the "typographic traditional position"? From all of the papers I have read for this project, all captions have been below the table. – Aiden Kenny Jul 20 at 23:29
  • That is because if a table does not not fit on a single page, the reader usually doesn't want to have to turn pages to see what the table is about. . Of course, I was speaking of the times of manual typography. . You also may note that the floatrow package uses a similar syntax for rows of tables and rows of figures, but automatically places table captions above and figure captions below the float. – Bernard Jul 20 at 23:36

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.