[Tex/LaTex] Trouble creating LateX table – ieee paper

ieeetrantables

I am having trouble creating a semi-complicated table. I've already made some work but it is still not like in the image… The main issue is creating that rectangle box and adding that line/column saying "TESTE" with the X Y Z tt below. I also need to add a line before the last line of the table…

I don't know how to do it…

The code used is as follow:

\begin{center}
\renewcommand{\arraystretch}{1.25}
\begin{table*}[!t]
    \centering
    \caption{Table Teste}\label{tab:teste2}
    \begin{tabular}{ccc|cccc|cccc}
        \toprule
         asd & \# asd & \#asd & X & Y & Z & TT & \#sss & Duration (min) & (Gb) \\
      \midrule
        %\midline
        TssLE & 4 & 19 & 6 & 6 & 6 & 1 & 23,520 & 7.2 & 13.3     \\
        easdTLE & 5 & 23 & 8 & 8 & 6 & 1 & 47,876 & 13.4 & 24.8     \\
        Total & 9 & 42 & 14 & 14 & 12 & 2 & 71,396 & 20.6 & 38.1     \\
        \bottomrule
        %Note. Values are given as mean $\pm$ SD.   &                      &                     \\
\end{tabular}
\end{table*}
\end{center}

The output is created is:

enter image description here

I need this:

enter image description here

Please help me. Thanks!

Best Answer

If you use the array package you can create new column types with a fixed width and a left/center/right horizontal alignment (see https://tex.stackexchange.com/a/12712/46716). That way all your column can have the same width (if wanted).

Create the rectangle with \cline

\documentclass{IEEEtran}
\usepackage{array}

\renewcommand{\arraystretch}{1.25}
\newcolumntype{C}[1]{>{\centering\let\newline\\\arraybackslash\hspace{0pt}}b{#1}}
\newcolumntype{R}[1]{>{\raggedleft\let\newline\\\arraybackslash\hspace{0pt}}b{#1}}

\begin{document}

\begin{tabular}{R{1.3cm}*{2}{C{.8cm}}|*{4}{C{1cm}}|*{3}{C{1.3cm}}}
    \cline{4-7}
    & & & \multicolumn{4}{c|}{\textbf{TESTE}} & & & \\ \cline{4-7}
    asd & \# asd & \# asd & X & y & z & tt & \# sss & Duration (min) & (Gb) \\ \hline
    TssLe & 4 & 19 & 6 & 6 & 6 & 1 & 23520 & 7.2 & 13.3 \\
    easdTLE & 5 & 23 & 8 & 8 & 6 & 1 & 47876 & 13.4 & 24.8 \\ \hline
    Total & 9 & 42 & 14 & 14 & 12 & 2 & 71396 & 20.6 & 38.1 \\ \cline{4-7}
\end{tabular}

\end{document}

enter image description here

UPDATE: adding a "comment" line as requested in the comments

This can be done by adding another row in the table that stretches over all columns. Use \multicolumn.

\documentclass{IEEEtran}
\usepackage{array}

\renewcommand{\arraystretch}{1.25}
\newcolumntype{C}[1]{>{\centering\let\newline\\\arraybackslash\hspace{0pt}}b{#1}}
\newcolumntype{R}[1]{>{\raggedleft\let\newline\\\arraybackslash\hspace{0pt}}b{#1}}

\begin{document}

\begin{tabular}{R{1.3cm}*{2}{C{.8cm}}|*{4}{C{1cm}}|*{3}{C{1.3cm}}}
    \cline{4-7}
    & & & \multicolumn{4}{c|}{\textbf{TESTE}} & & & \\ \cline{4-7}
    asd & \# asd & \# asd & X & y & z & tt & \# sss & Duration (min) & (Gb) \\ \hline
    TssLe & 4 & 19 & 6 & 6 & 6 & 1 & 23520 & 7.2 & 13.3 \\
    easdTLE & 5 & 23 & 8 & 8 & 6 & 1 & 47876 & 13.4 & 24.8 \\ \hline
    Total & 9 & 42 & 14 & 14 & 12 & 2 & 71396 & 20.6 & 38.1 \\ \cline{4-7}
    \multicolumn{10}{c}{\footnotesize Note. Values are given as mean $\pm$ SD. n.a., not applicable. n.s., not significant} \\
\end{tabular}

\end{document}

enter image description here

Related Question