4

Working with the llncs document class and wanted to place a large table sideways.

Code:

\documentclass[runningheads]{llncs}
\usepackage{graphicx} % Required for inserting images
\usepackage{tabularx}
\usepackage{rotating}
\usepackage{booktabs}

\begin{document}

\title{Paper Title Here ... }

\begin{sidewaystable}
     \caption{Classification results of imbalance techniques}
     \centering
     \begin{tabularx}{\linewidth}{lccccccccccccccc}%
     \toprule
     Transportation Mode & \multicolumn{5}{c}{Precision} & \multicolumn{5}{c}{Recall} & \multicolumn{5}{l}{F1\-Score} \\
     \cline{2-15}
     & RF & RF-SMOTEd & AdaBoost & SMOTEBoost & DECOC & RF & RF-SMOTEd & AdaBoost & SMOTEBoost & DECOC & RF & RF-SMOTEd & AdaBoost & SMOTEBoost & DECOC \\
     \midrule
     Walk & 0.88 & 0.78 & 0.65 & 0.59 & 0.45 & 0.38 & 0.73 & 0.95 & 0.83 & 0.57 & 0.52 & 0.07 & 0.22 & 0.66 & 0.88 \\
     Bike & 0.88 & 0.78 & 0.65 & 0.59 & 0.45 & 0.38 & 0.73 & 0.95 & 0.83 & 0.57 & 0.52 & 0.07 & 0.22 & 0.66 & 0.88 \\
     \bottomrule
     \end{tabularx}
\end{sidewaystable}

\end{document}

Output:

enter image description here

This table does not fit even after adding \tabcolsep=0pt.

EDIT

I am wondering how this paper managed to add the following large table despite using the same document class.

enter image description here

2
  • 1
    You might not be able to fit a table like that on one page sadly, please see the solutions here by @Werner to see if they can assist - you can only fit so much in a table without reducing space or increasing page size.
    – JamesT
    Commented Mar 16, 2023 at 0:12
  • 1
    @JamesT - Please see the answer I posted. :-)
    – Mico
    Commented Mar 16, 2023 at 2:42

3 Answers 3

2

I could not help myself: this is just a spin on egreg's answer with some finetuning, while not changing anything profound:

  • Streamlined legend (R: RF instead of (1) RF)
  • Grouped columns with accordingly shortened midrules

slender 16 column table with 3 groups à 5 columns with additional column separation

\documentclass[runningheads]{llncs}
\usepackage{booktabs,siunitx}

\begin{document}
  \title{Paper Title}
  
  \begin{table}[htp]
    \caption{Classification results of imbalance techniques}
    \setlength{\tabcolsep}{0pt}
    
    \begin{tabular*}{\textwidth}{
        @{\extracolsep{\fill}}
        l
        @{\hskip 1ex}
        *{5}{S[table-format=1.2]}
        @{\hskip 1ex}
        *{5}{S[table-format=1.2]}
        @{\hskip 1ex}
        *{5}{S[table-format=1.2]}
        @{}
      }
      \toprule
      TM &
      \multicolumn{5}{c}{Precision} &
      \multicolumn{5}{c}{Recall} &
      \multicolumn{5}{c}{F1-Score} \\
      \cmidrule(r{1ex}){2-6} \cmidrule(r{1ex}){7-11} \cmidrule{12-16}
      & {R} & {S} & {A} & {B} & {D}   & {R} & {S} & {A} & {B} & {D}   & {R} & {S} & {A} & {B} & {D}\\
      \midrule
      Walk & 0.88 & 0.78 & 0.65 & 0.59 & 0.45 & 0.38 & 0.73 & 0.95 & 0.83 & 0.57 & 0.52 & 0.07 & 0.22 & 0.66 & 0.88 \\
      Bike & 0.88 & 0.78 & 0.65 & 0.59 & 0.45 & 0.38 & 0.73 & 0.95 & 0.83 & 0.57 & 0.52 & 0.07 & 0.22 & 0.66 & 0.88 \\
      \bottomrule
    \end{tabular*}

    \medskip

    TM: Transportation mode

    R: RF; S: RF-SMOTEd; A: AdaBoost; B: SMOTEBoost; D: DECOC
  \end{table}
\end{document}

And here my final take - the cramped look did not let me rest:

  • Switched to % as the unit, dropping all 0.
  • Transposed the axes: Transportation mode and method swapped
  • Top left corner label switched from "mode" to "method". If not clear from context, the meaning from "walk" and "bike" could be made clear in the caption.

transposed axes version

\documentclass[runningheads]{llncs}
\usepackage{booktabs,siunitx}

\begin{document}
    \title{Paper Title}
    
    \begin{table}[htp]
        \centering
        \caption{Classification results of imbalance techniques (\%)}        
        \begin{tabular}{
                @{\extracolsep{\fill}}
                l
                *{2}{S[table-format=2]}
                *{2}{S[table-format=2]}
                *{2}{S[table-format=2]}
                @{}
            }
            \toprule
            &
            \multicolumn{2}{c}{Precision} &
            \multicolumn{2}{c}{Recall} &
            \multicolumn{2}{c}{F1-Score} \\
            \cmidrule(r{1ex}){2-3} \cmidrule(r{1ex}){4-5} \cmidrule{6-7}
            Method & {Walk} & {Bike}      & {Walk} & {Bike}      & {Walk} & {Bike} \\
            \midrule
            RF         & 88 & 88 & 38 & 88 & 52 & 88 \\
            RF-SMOTEd  & 78 & 78 & 73 & 78 & 07 & 78 \\
            AdaBoost   & 65 & 65 & 95 & 65 & 22 & 65 \\
            SMOTEBoost & 59 & 59 & 83 & 59 & 66 & 59 \\
            DECOC      & 45 & 45 & 57 & 45 & 88 & 45 \\
            \bottomrule
        \end{tabular}

    \end{table}
\end{document}
6

You'll need to insert line breaks in almost all header cells. Since most of the headers appear to be acronyms, it's best to force the line breaks by hand; see the code below for how this may be done. But once you've created all the manual line breaks, there's no further need for a tabularx environment. Instead, use a tabular* environment (and set its width to \linewidth). Finally, the \centering instruction isn't doing anything useful and may (should!) be omitted.

enter image description here

\documentclass[runningheads]{llncs}
\usepackage{graphicx}
%\usepackage{tabularx} % no longer needed
\usepackage{rotating}
\usepackage{booktabs}

% new code:
\usepackage{amsmath} % for \smash[b] macro
% handy shortcut macros for line breaks in cells
\newcommand{\mytabL}[1]{\smash[b]{%
  \begin{tabular}[t]{l} #1 \end{tabular}}}
\newcommand{\mytabC}[1]{%
  \begin{tabular}[t]{c} #1 \end{tabular}}

\begin{document}

\begin{sidewaystable}
\setlength\tabcolsep{0pt} % let LaTeX figure out intercol. whitespace
\caption{Classification results of imbalance techniques\strut}

\begin{tabular*}{\linewidth}{@{\extracolsep{\fill}} l *{15}{c} }
  \toprule
  \mytabL{Transpor-\\tation\\Mode} 
  & \multicolumn{5}{c}{Precision} 
  & \multicolumn{5}{c}{Recall} 
  & \multicolumn{5}{c}{F1-Score} \\
  \cmidrule{2-6} \cmidrule{7-11} \cmidrule{12-16}
  & RF & \mytabC{RF-\\SMOTEd} & \mytabC{Ada\\Boost} & \mytabC{SMOTE\\Boost} & \mytabC{DE\\COC} 
  & RF & \mytabC{RF-\\SMOTEd} & \mytabC{Ada\\Boost} & \mytabC{SMOTE\\Boost} & \mytabC{DE\\COC} 
  & RF & \mytabC{RF-\\SMOTEd} & \mytabC{Ada\\Boost} & \mytabC{SMOTE\\Boost} & \mytabC{DE\\COC} \\
  \midrule
  Walk 
  & 0.88 & 0.78 & 0.65 & 0.59 & 0.45 & 0.38 & 0.73 & 0.95 & 0.83 & 0.57 & 0.52 & 0.07 & 0.22 & 0.66 & 0.88 \\
  Bike 
  & 0.88 & 0.78 & 0.65 & 0.59 & 0.45 & 0.38 & 0.73 & 0.95 & 0.83 & 0.57 & 0.52 & 0.07 & 0.22 & 0.66 & 0.88 \\
  \bottomrule
\end{tabular*}
\end{sidewaystable}

\end{document}
2
  • 1
    You are too good at this Mico, making the impossible possible!
    – JamesT
    Commented Mar 16, 2023 at 2:48
  • 1
    Interesting. Many thanks.
    – Amina Umar
    Commented Mar 16, 2023 at 10:23
6

No sidewaystable if you avoid lengthy repetition.

\documentclass[runningheads]{llncs}
\usepackage{booktabs,siunitx}

\begin{document}

\title{Paper Title Here ... }

\begin{table}[htp]

\caption{Classification results of imbalance techniques}

\setlength{\tabcolsep}{0pt}

\begin{tabular*}{\textwidth}{
  @{\extracolsep{\fill}}
  l
  *{15}{S[table-format=1.2]}
  @{}
}
\toprule
TM &
  \multicolumn{5}{c}{Precision} &
  \multicolumn{5}{c}{Recall} &
  \multicolumn{5}{c}{F1-Score} \\
\cmidrule{2-6} \cmidrule{7-11} \cmidrule{12-16}
& {(1)} & {(2)} & {(3)} & {(4)} & {(5)}
& {(1)} & {(2)} & {(3)} & {(4)} & {(5)}
& {(1)} & {(2)} & {(3)} & {(4)} & {(5)} \\
\midrule
Walk & 0.88 & 0.78 & 0.65 & 0.59 & 0.45 & 0.38 & 0.73 & 0.95 & 0.83 & 0.57 & 0.52 & 0.07 & 0.22 & 0.66 & 0.88 \\
Bike & 0.88 & 0.78 & 0.65 & 0.59 & 0.45 & 0.38 & 0.73 & 0.95 & 0.83 & 0.57 & 0.52 & 0.07 & 0.22 & 0.66 & 0.88 \\
\bottomrule
\end{tabular*}

\medskip

TM: Transportation mode

(1) RF; (2) RF-SMOTEd; (3) AdaBoost; (4) SMOTEBoost; (5) DECOC

\end{table}

\end{document}

enter image description here

A different possibility:

\documentclass[runningheads]{llncs}
\usepackage{booktabs,siunitx}

\begin{document}

\title{Paper Title Here ... }

\begin{table}[htp]

\caption{Classification results of imbalance techniques}

\begin{tabular}{
  @{\quad}
  l
  *{5}{S[table-format=1.2]}
  @{}
}
\toprule
Mode &
  \multicolumn{1}{wc{6em}}{RF} &
  \multicolumn{1}{wc{6em}}{RF-SMOTEd} &
  \multicolumn{1}{wc{6em}}{AdaBoost} &
  \multicolumn{1}{wc{6em}}{SMOTEBoost} &
  \multicolumn{1}{wc{6em}}{DECOC} \\
\midrule
& \multicolumn{5}{c@{}}{Precision} \\
\cmidrule(l{2em}r{2em}){2-6}
Walk & 0.88 & 0.78 & 0.65 & 0.59 & 0.45 \\
Bike & 0.88 & 0.78 & 0.65 & 0.59 & 0.45 \\
\midrule
& \multicolumn{5}{c@{}}{Recall} \\
\cmidrule(l{2em}r{2em}){2-6}
Walk & 0.38 & 0.73 & 0.95 & 0.83 & 0.57 \\
Bike & 0.38 & 0.73 & 0.95 & 0.83 & 0.57 \\
\midrule
& \multicolumn{5}{c@{}}{F1-Score} \\
\cmidrule(l{2em}r{2em}){2-6}
Walk & 0.52 & 0.07 & 0.22 & 0.66 & 0.88 \\
Bike & 0.52 & 0.07 & 0.22 & 0.66 & 0.88 \\
\bottomrule
\end{tabular}

\end{table}

\end{document}

enter image description here

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .