3

I'm trying to create 6 tables, each 3 next to each other that would look exactly like this enter image description here and this is my code so far

\documentclass[conference]{IEEEtran}
\begin{document}

\begin{table}[]
\caption{}
\label{tab:my-table}
\resizebox{0.5\textwidth}{!}{%
\begin{tabular}{llll}
\hline
\multicolumn{2}{l}{\multirow{2}{*}{}} & \multicolumn{2}{l}{Predicted} \\ \cline{3-4} 
\multicolumn{2}{l}{} & CR & NCR \\ \hline
\multirow{2}{*}{something} & CR & 340 & 22 \\ \cline{2-4} 
 & NCR & 27 & 461 \\ \hline
\multicolumn{2}{l}{Accuracy} & \multicolumn{2}{l}{94.24\%} \\ \hline
\multicolumn{2}{l}{MSE} & \multicolumn{2}{l}{0.11517} \\ \hline
\end{tabular}%

\begin{tabular}{llll}
\hline
\multicolumn{2}{l}{\multirow{2}{*}{}} & \multicolumn{2}{l}{Predicted} \\ \cline{3-4} 
\multicolumn{2}{l}{} & CR & NCR \\ \hline
\multirow{2}{*}{something} & CR & 340 & 22 \\ \cline{2-4} 
 & NCR & 27 & 461 \\ \hline
\multicolumn{2}{l}{Accuracy} & \multicolumn{2}{l}{94.24\%} \\ \hline
\multicolumn{2}{l}{MSE} & \multicolumn{2}{l}{0.11517} \\ \hline
\end{tabular}%
\begin{tabular}{llll}
\hline
\multicolumn{2}{l}{\multirow{2}{*}{}} & \multicolumn{2}{l}{Predicted} \\ \cline{3-4} 
\multicolumn{2}{l}{} & CR & NCR \\ \hline
\multirow{2}{*}{something} & CR & 340 & 22 \\ \cline{2-4} 
 & NCR & 27 & 461 \\ \hline
\multicolumn{2}{l}{Accuracy} & \multicolumn{2}{l}{94.24\%} \\ \hline
\multicolumn{2}{l}{MSE} & \multicolumn{2}{l}{0.11517} \\ \hline
\end{tabular}%


}
\end{table}
\end{document}

The above code produces the following enter image description here

and here are the issues I cant work through:

  1. I'm having trouble placing the word "Actual" the way it is, as in vertically
  2. I can't seem to recreate the borders
  3. I also can't recreate the small distance between each table
  4. I'm also having an issue creating a caption for each table (as shown in the picture) while maintaining the same Label for all 6 tables
  5. I also want to remove the word "TABLE IV"
  6. How can I place the rest of the 6 tables (the remaining 3) under the initial 3 I've provided while keeping them in the same \begin{table}[] \end{table} Environment

How can I fix the above issues?

please note that my document has a double column layout.

2
  • Please, extend your code fragment to complete small document. We need to know used document class as well page layout. From image can be concluded, that you like to have six sub tables in table float environment.
    – Zarko
    May 23, 2019 at 1:52
  • @Zarko thank you. I extended my code fragment.
    – Zyzzx
    May 23, 2019 at 1:58

1 Answer 1

4

The following MWE (Minimal Working Example) solve almost all your requirements :-)

\documentclass[conference]{IEEEtran}
\usepackage{subcaption}
\usepackage{booktabs, multirow}
\usepackage{siunitx}

%---------------- show page layout. don't use in a real document!
\usepackage{showframe}
\renewcommand\ShowFrameLinethickness{0.15pt}
\renewcommand*\ShowFrameColor{\color{red}}
%---------------------------------------------------------------%
\usepackage{lipsum}
\begin{document}
\lipsum[1]
\begin{table*}   
%    \caption{}          % if you want to have a common caption of the table, remove %
%    \label{tab:my-table} % remove % if you will use c+"\caption"
    \begin{subfigure}{0.31\linewidth}
    \centering                % center table in "sibtable" environment
    \caption{404-2}           % caption of sub table
    \label{subtab:my-table-a} % label for referencing od sub table
\begin{tabular}{*{4}{l}}
    \toprule
    &       & \multicolumn{2}{l}{Predicted} \\
    \cmidrule{3-4}
    &       & CR    & NCR  \\
    \midrule
\multirow{2}{*}{something}
    & CR    & 340   & 22 \\
    \cmidrule{2-4}
    & NCR   & 27 & 461 \\ \hline
Accuracy
    &       & \multicolumn{2}{l}{\SI{94.24}{\%}}    \\
    \midrule
MSE &       & \multicolumn{2}{l}{0.11517}           \\
    \bottomrule
\end{tabular}
    \end{subfigure}
\hfill             % push subtables away
    \begin{subfigure}{0.31\linewidth}
\centering
    \caption{404-5-2}
    \label{subtab:my-table-a}
\begin{tabular}{*{4}{l}}
    \toprule
    &       & \multicolumn{2}{l}{Predicted} \\
    \cmidrule{3-4}
    &       & CR    & NCR  \\
    \midrule
\multirow{2}{*}{something}
    & CR    & 340   & 22 \\
    \cmidrule{2-4}
    & NCR   & 27 & 461 \\ \hline
Accuracy
    &       & \multicolumn{2}{l}{\SI{94.24}{\%}}    \\
    \midrule
MSE &       & \multicolumn{2}{l}{0.11517}           \\
    \bottomrule
\end{tabular}
    \end{subfigure}%
\hfill
    \begin{subfigure}{0.31\linewidth}
\centering
    \caption{404-10-2}
    \label{subtab:my-table-a}
\begin{tabular}{*{4}{l}}
    \toprule
    &       & \multicolumn{2}{l}{Predicted} \\
    \cmidrule{3-4}
    &       & CR    & NCR  \\
    \midrule
\multirow{2}{*}{something}
    & CR    & 340   & 22 \\
    \cmidrule{2-4}
    & NCR   & 27 & 461 \\ \hline
Accuracy
    &       & \multicolumn{2}{l}{\SI{94.24}{\%}}    \\
    \midrule
MSE &       & \multicolumn{2}{l}{0.11517}           \\
    \bottomrule
\end{tabular}
    \end{subfigure}

\bigskip    % additiona vertical space between rows with subtables
    \begin{subfigure}{0.31\linewidth}
\centering
    \caption{210-2}
    \label{subtab:my-table-a}
\begin{tabular}{*{4}{l}}
    \toprule
    &       & \multicolumn{2}{l}{Predicted} \\
    \cmidrule{3-4}
    &       & CR    & NCR  \\
    \midrule
\multirow{2}{*}{something}
    & CR    & 340   & 22 \\
    \cmidrule{2-4}
    & NCR   & 27 & 461 \\ \hline
Accuracy
    &       & \multicolumn{2}{l}{\SI{94.24}{\%}}    \\
    \midrule
MSE &       & \multicolumn{2}{l}{0.11517}           \\
    \bottomrule
\end{tabular}
    \end{subfigure}%
\hfill
    \begin{subfigure}{0.31\linewidth}
 \centering
   \caption{210-5-2}
    \label{subtab:my-table-a}
\begin{tabular}{*{4}{l}}
    \toprule
    &       & \multicolumn{2}{l}{Predicted} \\
    \cmidrule{3-4}
    &       & CR    & NCR  \\
    \midrule
\multirow{2}{*}{something}
    & CR    & 340   & 22 \\
    \cmidrule{2-4}
    & NCR   & 27 & 461 \\ \hline
Accuracy
    &       & \multicolumn{2}{l}{\SI{94.24}{\%}}    \\
    \midrule
MSE &       & \multicolumn{2}{l}{0.11517}           \\
    \bottomrule
\end{tabular}
    \end{subfigure}%
\hfill
    \begin{subfigure}{0.31\linewidth}
\centering
    \caption{210-10-2}
    \label{subtab:my-table-a}
\begin{tabular}{*{4}{l}}
    \toprule
    &       & \multicolumn{2}{l}{Predicted} \\
    \cmidrule{3-4}
    &       & CR    & NCR  \\
    \midrule
\multirow{2}{*}{something}
    & CR    & 340   & 22 \\
    \cmidrule{2-4}
    & NCR   & 27 & 461 \\ \hline
Accuracy
    &       & \multicolumn{2}{l}{\SI{94.24}{\%}}    \\
    \midrule
MSE &       & \multicolumn{2}{l}{0.11517}           \\
    \bottomrule
\end{tabular}
    \end{subfigure}
    \end{table*}
\lipsum\lipsum
\end{document}

enter image description here

Note: your table can not be fit in one column. Therefore i suggest to use table* float environment. It is always on the top of the next page after point on insertion in document text.

addendum: MWE according to your comment:

\documentclass[conference]{IEEEtran}
\usepackage{subcaption}
\usepackage{graphicx}
\usepackage{booktabs, multirow}
\usepackage{siunitx}

%---------------- show page layout. don't use in a real document!
\usepackage{showframe}
\renewcommand\ShowFrameLinethickness{0.15pt}
\renewcommand*\ShowFrameColor{\color{red}}
%---------------------------------------------------------------%
\usepackage{lipsum}
\begin{document}
\lipsum[1]
\begin{table*}   
%    \caption{}
%    \label{tab:my-table}
\renewcommand\arraystretch{1.5}
    \begin{subfigure}{0.31\linewidth}
    \centering
    \caption{404-2}
    \label{subtab:my-table-a}
\begin{tabular}{cc|c|c}
    \hline
    &       & \multicolumn{2}{l}{Predicted} \\
    \cline{3-4}
    &       & CR    & NCR  \\
    \hline
\multirow{2}{*}{\rotatebox{90}{something}}
    \rule[-2ex]{0pt}{5ex}& CR    & 340   & 22 \\
    \cline{2-4}
    \rule[-2ex]{0pt}{5ex}& NCR   & 27 & 461 \\ \hline
\multicolumn{2}{l}{Accuracy}
            & \multicolumn{2}{l}{\SI{94.24}{\%}}    \\
    \hline
\multicolumn{2}{l}{MSE}
           & \multicolumn{2}{l}{0.11517}           \\
    \hline
\end{tabular}
    \end{subfigure}%
\hfill
    \begin{subfigure}{0.31\linewidth}
\centering
    \caption{404-5-2}
    \label{subtab:my-table-a}
\begin{tabular}{cc|c|c}
    \hline
    &       & \multicolumn{2}{l}{Predicted} \\
    \cline{3-4}
    &       & CR    & NCR  \\
    \hline
\multirow{2}{*}{\rotatebox{90}{something}}
    \rule[-2ex]{0pt}{5ex}& CR    & 340   & 22 \\
    \cline{2-4}
    \rule[-2ex]{0pt}{5ex}& NCR   & 27 & 461 \\ \hline
\multicolumn{2}{l}{Accuracy}
            & \multicolumn{2}{l}{\SI{94.24}{\%}}    \\
    \hline
\multicolumn{2}{l}{MSE}
           & \multicolumn{2}{l}{0.11517}           \\
    \hline
\end{tabular}
    \end{subfigure}%
\hfill
    \begin{subfigure}{0.31\linewidth}
\centering
    \caption{404-10-2}
    \label{subtab:my-table-a}
\begin{tabular}{cc|c|c}
    \hline
    &       & \multicolumn{2}{l}{Predicted} \\
    \cline{3-4}
    &       & CR    & NCR  \\
    \hline
\multirow{2}{*}{\rotatebox{90}{something}}
    \rule[-2ex]{0pt}{5ex}& CR    & 340   & 22 \\
    \cline{2-4}
    \rule[-2ex]{0pt}{5ex}& NCR   & 27 & 461 \\ \hline
\multicolumn{2}{l}{Accuracy}
            & \multicolumn{2}{l}{\SI{94.24}{\%}}    \\
    \hline
\multicolumn{2}{l}{MSE}
           & \multicolumn{2}{l}{0.11517}           \\
    \hline
\end{tabular}
    \end{subfigure}

\bigskip
    \begin{subfigure}{0.31\linewidth}
\centering
    \caption{210-2}
    \label{subtab:my-table-a}
\begin{tabular}{cc|c|c}
    \hline
    &       & \multicolumn{2}{l}{Predicted} \\
    \cline{3-4}
    &       & CR    & NCR  \\
    \hline
\multirow{2}{*}{\rotatebox{90}{something}}
    \rule[-2ex]{0pt}{5ex}& CR    & 340   & 22 \\
    \cline{2-4}
    \rule[-2ex]{0pt}{5ex}& NCR   & 27 & 461 \\ \hline
\multicolumn{2}{l}{Accuracy}
            & \multicolumn{2}{l}{\SI{94.24}{\%}}    \\
    \hline
\multicolumn{2}{l}{MSE}
           & \multicolumn{2}{l}{0.11517}           \\
    \hline
\end{tabular}
    \end{subfigure}%
\hfill
    \begin{subfigure}{0.31\linewidth}
 \centering
   \caption{210-5-2}
    \label{subtab:my-table-a}
\begin{tabular}{cc|c|c}
    \hline
    &       & \multicolumn{2}{l}{Predicted} \\
    \cline{3-4}
    &       & CR    & NCR  \\
    \hline
\multirow{2}{*}{\rotatebox{90}{something}}
    \rule[-2ex]{0pt}{5ex}& CR    & 340   & 22 \\
    \cline{2-4}
    \rule[-2ex]{0pt}{5ex}& NCR   & 27 & 461 \\ \hline
\multicolumn{2}{l}{Accuracy}
            & \multicolumn{2}{l}{\SI{94.24}{\%}}    \\
    \hline
\multicolumn{2}{l}{MSE}
            & \multicolumn{2}{l}{0.11517}           \\
    \hline
\end{tabular}
    \end{subfigure}%
\hfill
    \begin{subfigure}{0.31\linewidth}
\centering
    \caption{210-10-2}
    \label{subtab:my-table-a}
\begin{tabular}{cc|c|c}
    \hline
    &       & \multicolumn{2}{l}{Predicted} \\
    \cline{3-4}
    &       & CR    & NCR  \\
    \hline
\multirow{2}{*}{\rotatebox{90}{something}}
    \rule[-2ex]{0pt}{5ex}& CR    & 340   & 22 \\
    \cline{2-4}
    \rule[-2ex]{0pt}{5ex}& NCR   & 27 & 461 \\ \hline
\multicolumn{2}{l}{Accuracy}
            & \multicolumn{2}{l}{\SI{94.24}{\%}}    \\
    \hline
\multicolumn{2}{l}{MSE}
            & \multicolumn{2}{l}{0.11517}           \\
    \hline
\end{tabular}
    \end{subfigure}
    \end{table*}
\lipsum\lipsum
\end{document}

enter image description here

edit:

  • to the code of the fist MWE are added comments, which explain meaning of code parts responsible for caption and placement tables in subtable environmentand their placement intable*` environment
  • if you like to have table on the bottom of the same page (if there is enough space for table), than all what you need to do is:
    • in preamble load the stfloats package by usepackage{stfloats}
    • add placement option (b for bottomort` for the top of page):
\begin{table*}[b]
...
\end{table*}

for table on the bottom of a page or

\begin{tablee*}[t] 
...
\end{table*}

for table on the top of a page.

14
  • Unfortunately, this doesn't solve all my issues but it comes extremely close, so lemme list the things that it didn't solve 1- The vertical borders next to "CR" and "NCR" arent there 2- The word "something" isn't placed vertically 3- the tables span the entire document's width and i only want it to span a column's width
    – Zyzzx
    May 23, 2019 at 2:35
  • 1
    @Zyzzx, vertical rules doesn't work well rules from booktabs (your first image is very ugly), i will not reccomed to use it. (ii) if you persist to have them, than replace all rules withhline and add | on appropriate space in column specifications. The same is valid for rotating text. I doubt that for its lenght is enough vertical space in table. I will added what you desired to have asap.
    – Zarko
    May 23, 2019 at 2:40
  • i will wait for your edited code. Thanks in advance.
    – Zyzzx
    May 23, 2019 at 2:52
  • @Zyzzx, any news?
    – Zarko
    May 23, 2019 at 12:03
  • 1
    floats figure* and table* always appear on zthe top of the next page after point of their inserting in text. I emphasize this in Note in my answer. If you like to have it on the bottom of the same page (if there is enough space for it) you can do this by help of the package stfloats.
    – Zarko
    May 23, 2019 at 13:38

You must log in to answer this question.

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