3

In my table the following problems arise :

  1. Toprule contents overlap with midrule contents.

  2. I need a little space above and below the horizontal lines used in the middle of the table.

Here's the code :

\documentclass[10pt,journal]{IEEEtran}
\usepackage[utf8]{inputenc}
\usepackage[english]{babel}
\usepackage{amssymb}
\usepackage{mathtools}
\usepackage{graphicx}
\usepackage{booktabs}
\usepackage{float}
\usepackage{multirow}
\usepackage{makecell}
\usepackage[caption=false,font=footnotesize]{subfig}
\usepackage{varwidth}
\graphicspath{ {./images/} }
\usepackage{nccmath}
\usepackage{afterpage}
\usepackage{placeins}
\usepackage{cuted}
\hyphenation{op-tical net-works semi-conduc-tor}
\bibliographystyle{IEEEtran}
\usepackage[figurename=Fig.]{caption}
\begin{document}

\begin{table}
        \begin{center}
            \caption{blah blah}
            \label{tab:table1}
            \begin{tabular}{cccccc}\toprule
                \multirow{2}{3em}{Training Size} & \multirow{2}{3em}{Test Size} & Classifier & Feature & \multirow{2}{3em}{Test Accuracy} & \multirow{2}{3em}{Training Time}\\
                \midrule
                35 & 15 & GBLinear & IEMG & 100 & 9.29\\ 
                35 & 15 & GBLinear & MAV & 100 & 8.89\\ 
                35 & 15 & GBLinear & MAV1 & 100 & 8.39\\ 
                35 & 15 & GBLinear & RMS & 100 & 5.32\\
                35 & 15 & Bagging SVM & MAV & 100 & 4.06\\
                35 & 15 & Bagging SVM & MAV1 & 100 & 2.9\\
                35 & 15 & Bagging SVM & RMS & 100 & 6.69\\\hline
                30 & 20 & GBLinear & IEMG & 98.75 & 8.23\\
                30 & 20 & GBLinear & MAV1 & 98.75 & 4.26\\
                30 & 20 & GBLinear & RMS & 98.75 & 8.31\\
                30 & 20 & Stacking SVM & MAV1 & 98.75 & 2.61\\\hline
                25 & 25 & GBLinear & IEMG & 98 & 8.08\\\hline
                20 & 30 & Bagging SVM & RMS & 98.33 & 4.3\\
                20 & 30 & GBLinear & IEMG & 98.33 & 6.13\\                
                 \bottomrule
            \end{tabular}
        \end{center}
    \end{table}

Output:

enter image description here

2
  • Entirely unrelated to the issue itself, but aren't some units missing in the column headers? – leandriis Apr 10 at 10:02
  • You define a multirow and additionally add content in the next row. So you have to add some empty cells. – Excelsior Apr 10 at 10:04
3

I guess you wanted to add a linebreak in column headers such as "Test size". If this assumption is correct, you might be interested in the following code, in which I used \thead from the makecell package, that you already loaded, instead of the \multirow commands.

I also replaced all \hline commands with \midrule for impreved spacing. In order to avoid excessive vertical white space, I replaced the center environment with the \centering command and in orde to make sure the table does not exceed the available line width, I replaced tabular with tabular* and added @{\extracolsep{\fill}}.

In the following MWE, I additionally added an alternative version of your table with less horizontal lines as well as with S type columns from the siunitx package in order to align the number sin the last two columns with respect to their decimal marker.

enter image description here

\documentclass[10pt,journal]{IEEEtran}
\usepackage[utf8]{inputenc}
\usepackage[english]{babel}
\usepackage{amssymb}
\usepackage{mathtools}
\usepackage{graphicx}
\usepackage{booktabs}
\usepackage{float}
\usepackage{multirow}
\usepackage{makecell}
\usepackage[caption=false,font=footnotesize]{subfig}
\usepackage{varwidth}
\graphicspath{ {./images/} }
\usepackage{nccmath}
\usepackage{afterpage}
\usepackage{placeins}
\usepackage{cuted}
\hyphenation{op-tical net-works semi-conduc-tor}
\bibliographystyle{IEEEtran}
\usepackage[figurename=Fig.]{caption}

\usepackage{siunitx}


\begin{document}

\begin{table}
    \centering
    \setlength{\tabcolsep}{0pt}
            \caption{blah blah}
            \label{tab:table1}
            \begin{tabular*}{\linewidth}{@{\extracolsep{\fill}}cccccc}\toprule
                \thead{Training\\ Size} & \thead{Test\\ Size} & \thead{Classifier} &\thead{Feature} & \thead{Test\\ Accuracy} & \thead{Training\\ Time}\\
                \midrule
                35 & 15 & GBLinear & IEMG & 100 & 9.29\\ 
                35 & 15 & GBLinear & MAV & 100 & 8.89\\ 
                35 & 15 & GBLinear & MAV1 & 100 & 8.39\\ 
                35 & 15 & GBLinear & RMS & 100 & 5.32\\
                35 & 15 & Bagging SVM & MAV & 100 & 4.06\\
                35 & 15 & Bagging SVM & MAV1 & 100 & 2.9\\
                35 & 15 & Bagging SVM & RMS & 100 & 6.69\\
                \midrule
                30 & 20 & GBLinear & IEMG & 98.75 & 8.23\\
                30 & 20 & GBLinear & MAV1 & 98.75 & 4.26\\
                30 & 20 & GBLinear & RMS & 98.75 & 8.31\\
                30 & 20 & Stacking SVM & MAV1 & 98.75 & 2.61\\
                \midrule
                25 & 25 & GBLinear & IEMG & 98 & 8.08\\
                \midrule
                20 & 30 & Bagging SVM & RMS & 98.33 & 4.3\\
                20 & 30 & GBLinear & IEMG & 98.33 & 6.13\\                
                 \bottomrule
            \end{tabular*}
\end{table}
    
\begin{table}
    \centering
    \setlength{\tabcolsep}{0pt}
            \caption{blah blah}
            \label{tab:table1}
            \begin{tabular*}{\linewidth}{@{\extracolsep{\fill}}ccllS[table-format=3.2]S[table-format=1.2]}\toprule
                \thead{Training\\ Size} & \thead{Test\\ Size} & \thead{Classifier} &\thead{Feature} & {\thead{Test\\ Accuracy}} & {\thead{Training\\ Time}}\\
                \midrule
                35 & 15 & GBLinear & IEMG & 100 & 9.29\\ 
                35 & 15 & GBLinear & MAV & 100 & 8.89\\ 
                35 & 15 & GBLinear & MAV1 & 100 & 8.39\\ 
                35 & 15 & GBLinear & RMS & 100 & 5.32\\
                35 & 15 & Bagging SVM & MAV & 100 & 4.06\\
                35 & 15 & Bagging SVM & MAV1 & 100 & 2.9\\
                35 & 15 & Bagging SVM & RMS & 100 & 6.69\\
                \addlinespace
                30 & 20 & GBLinear & IEMG & 98.75 & 8.23\\
                30 & 20 & GBLinear & MAV1 & 98.75 & 4.26\\
                30 & 20 & GBLinear & RMS & 98.75 & 8.31\\
                30 & 20 & Stacking SVM & MAV1 & 98.75 & 2.61\\
                \addlinespace
                25 & 25 & GBLinear & IEMG & 98 & 8.08\\
                \addlinespace
                20 & 30 & Bagging SVM & RMS & 98.33 & 4.3\\
                20 & 30 & GBLinear & IEMG & 98.33 & 6.13\\                
                 \bottomrule
            \end{tabular*}
\end{table}
 
\end{document}
3

See the comment for the solution of your problem. I added &&&&& \\ for free space.

enter image description here

\documentclass[varwidth=\maxdimen]{standalone}

\usepackage{booktabs}
\usepackage{multirow}
\usepackage{makecell}

\begin{document}
    
    \begin{table}
        
        \caption{blah blah}
        \label{tab:table1}
        \begin{tabular}{cccccc}
            \toprule
            \makecell[c]{Training \\ Size} & \makecell[c]{Test \\ Size} & \makecell[c]{Classifier} & \makecell[c]{Feature} & \makecell[c]{Test \\ Accuracy} & \makecell[c]{Training \\ Time} \\ \midrule
            35 & 15 & GBLinear & IEMG & 100 & 9.29 \\ 
            35 & 15 & GBLinear & MAV & 100 & 8.89 \\ 
            35 & 15 & GBLinear & MAV1 & 100 & 8.39 \\ 
            35 & 15 & GBLinear & RMS & 100 & 5.32 \\
            35 & 15 & Bagging SVM & MAV & 100 & 4.06 \\
            35 & 15 & Bagging SVM & MAV1 & 100 & 2.9 \\
            35 & 15 & Bagging SVM & RMS & 100 & 6.69 \\ \midrule
            30 & 20 & GBLinear & IEMG & 98.75 & 8.23 \\
            30 & 20 & GBLinear & MAV1 & 98.75 & 4.26 \\
            30 & 20 & GBLinear & RMS & 98.75 & 8.31 \\
            30 & 20 & Stacking SVM & MAV1 & 98.75 & 2.61 \\ \midrule
            25 & 25 & GBLinear & IEMG & 98 & 8.08 \\ \midrule
            20 & 30 & Bagging SVM & RMS & 98.33 & 4.3 \\
            20 & 30 & GBLinear & IEMG & 98.33 & 6.13 \\                
            \bottomrule
        \end{tabular}
    \end{table}
\end{document}
2
  • Since \makecellby default vertically centeres its contents, all \multirow commands in your MWE are basically redundant. If you remove them and the additional empty row you added, you end up with the same output you currently get. – leandriis Apr 10 at 14:30
  • @leandriis You are right. If I use '\makecell' for all objects in the first row, my added empty lines are unnecessary. – Excelsior Apr 10 at 16:16

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.