2

I am trying to create the following table (drafted in Excel) in my manuscript. enter image description here

I am working with two conferences' templates (IEEE & SPLNCS), so I organize my work like so:

├── IEEEtran.cls
├── llncs.cls
├── mainIEEE.tex
├── mainLNCS.tex
├── Introdoction.tex
└── # ... other sections' tex

So that I can navigate between mainEEE.tex and mainLNCS.tex to compile to conference's format.

However, I have difficulty aligning this table to fit with the column of these tamplates (other tables in my doc work fine).

MWE: IEEEtran.cls and llncs.cls

%%%  Introduction.tex
\section{Introduction}

\lipsum[1]

\begin{table}[ht]
    \caption{Some results}
    \label{tab:my_label}
    \centering
    \begin{tabularx}{\linewidth}{l|c|c|c|c|c|c|c|c|c|c|c|c|c|c|c|} 
    \toprule
     Mode  & \multicolumn{5}{l|}{Precision} & \multicolumn{5}{l|}{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
     cat &1&2&3&4&5 &1&2&3&4&5 &1&2&3&4&5\\
    \bottomrule
    \end{tabularx}
\end{table}
  1. mainLNCS.tex output:
\documentclass[runningheads]{llncs}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{booktabs}
\usepackage{tabularx,ragged2e}
\usepackage{lipsum}
    

\begin{document}

\title{Manuscript Title (SPLNCS) }


\maketitle

\begin{abstract}
The abstract in 150--250 words.


\keywords{keyword1  \and keyword2} 
\end{abstract}

\input{Introduction}



%\bibliographystyle{splncs04}
%\bibliography{Bib/references}

\end{document}

enter image description here

  1. mainIEEE.tex output:
\documentclass[conference]{IEEEtran}
\IEEEoverridecommandlockouts

\usepackage{booktabs}
\usepackage{lipsum}  
\usepackage{tabularx,ragged2e}

\def\BibTeX{{\rm B\kern-.05em{\sc i\kern-.025em b}\kern-.08em
    T\kern-.1667em\lower.7ex\hbox{E}\kern-.125emX}}
\begin{document}

\title{Conference Paper Title (IEEEtran)}


\begin{abstract}
This document is a model and instructions for \LaTeX.
This and the IEEEtran.cls ...
\end{abstract}

\begin{IEEEkeywords}
keyword1, keyword2
\end{IEEEkeywords}

\input{Introduction}


\end{document}

enter image description here

5
  • 1
    First, tabularx is only useful if you have X columns. Otherwise it is the same as a plain tabular. Second, there is no way you are going to fit that table on a page, much less one column, and still be legible.. I suggest you turn it into three sequential tabulars. Or rotate the headings. Mar 2 at 17:56
  • change to sequetial tabular? Can you add details to this please (or an answer)?
    – arilwan
    Mar 2 at 18:00
  • 1
    3 tabulars, possibly in 3 tables [ht] with one caption. I would rather try the rotated headers approach. BTW, booktabs does not like vertical lines in tables. Mar 2 at 18:04

2 Answers 2

3

This shows how to use rotated headers. Note the use of tabular* and \extracolsep to precisely fit the column.

\documentclass[conference]{IEEEtran}
\IEEEoverridecommandlockouts

\usepackage{graphicx}
\usepackage{booktabs}
\usepackage{lipsum}

\begin{document}

\lipsum[1]

\begin{table}[ht]
    \caption{Some results}
    \label{tab:my_label}
    %\centering
    \tabcolsep=0pt
    \begin{tabular*}{\linewidth}{@{\extracolsep{0pt plus 1fil}}lccccccccccccccc}
    \toprule
     Mode  & \multicolumn{5}{l}{Precision} & \multicolumn{5}{l}{Recall} & \multicolumn{5}{l}{F1\-score} \\
     \midrule
     & \rotatebox{90}{RF} & \rotatebox{90}{RF-SMOTEd} & \rotatebox{90}{AdaBoost} & 
      \rotatebox{90}{SMOTEBoost} & \rotatebox{90}{DECOC} & \rotatebox{90}{RF} &
      \rotatebox{90}{RF-SMOTEd} & \rotatebox{90}{AdaBoost} & \rotatebox{90}{SMOTEBoost} & 
      \rotatebox{90}{DECOC} & \rotatebox{90}{RF} & \rotatebox{90}{RF-SMOTEd} & 
      \rotatebox{90}{AdaBoost} & \rotatebox{90}{SMOTEBoost} & \rotatebox{90}{DECOC} \\
     \midrule
     cat &1&2&3&4&5 &1&2&3&4&5 &1&2&3&4&5\\
    \bottomrule
    \end{tabular*}
\end{table}

\lipsum[2-6]

\end{document}
2
  • It is not entirely clear, what is content of your table. Just one digit numbers= Or sime one letter symbol?

  • If above is the case, than you can rotate column headers as shown in @John Kormylo answer

  • As supplement to his answer here is suggestion which use tabularray package supported by rotating and makecell packages.

  • With - With ieeetran` document class:

\documentclass[runningheads]{llncs}
\usepackage[T1]{fontenc}
\usepackage{lipsum}

\usepackage{rotating}
\usepackage{makecell}
\usepackage{ragged2e}
\usepackage{tabularray}

\begin{document}

\title{Manuscript Title (SPLNCS) }
\maketitle
\begin{abstract}
The abstract in 150--250 words.
%\keywords{keyword1  \and keyword2}
\end{abstract}

\section{Introduction}
\lipsum[11]
    \begin{table}[ht]
    \caption{Some results}
    \label{tab:my_label}
    \centering
\settowidth\rotheadsize{SMOTEBoost}
\renewcommand\theadfont{}
\begin{tblr}{hlines, vlines,
             colspec = { l *{15}{X[c]} },
             cell{2}{2-Z} = {cmd=\rothead}
             }
\SetCell[r=2]{c}    Mode  
    &   \SetCell[c=5]{c} Precision
        &   &   &   &   &   \SetCell[c=5]{c}    Recall 
                            &   &   &   &   &   \SetCell[c=5]{c}    F1\-score
                                                &   &   &   &       \\
    & RF    
        & RF-SMOTEd 
            & AdaBoost 
                & SMOTEBoost 
                    & DECOC 
    & RF
        & RF-SMOTEd
            & AdaBoost
                & SMOTEBoost
                    & DECOC
    & RF
        & RF-SMOTEd
            & AdaBoost
                & SMOTEBoost
                    & DECOC                         \\
cat & 1 & 2 & 3 & 4 & 5     
        & 1 & 2 & 3 & 4 & 5     
            & 1 & 2 & 3 & 4 & 5                     \\
\end{tblr}
    \end{table}
\end{document}

enter image description here

  • With ieeetran document class:
\documentclass[conference]{IEEEtran}
\IEEEoverridecommandlockouts
%\usepackage[T1]{fontenc}
% ...
\begin{tblr}{hlines, vlines,
             colspec = { l *{15}{X[c]} },
             colsep=3pt,    % <---
             cell{2}{2-Z} = {cmd=\rothead}
             }
% rest is the same as before

enter image description here

You must log in to answer this question.

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