6

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!

2 Answers 2

3

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

2
  • how can I add, at the end of this late, a comment line? Like "Note. Values are given as mean $\pm$ SD. n.a., not applicable. n.s., not significant"
    – 16per9
    Feb 25, 2015 at 15:20
  • 1
    @user2205242 I guess you already know how to this with a caption, so I assume you want something different. If you add this line \multicolumn{10}{c}{\footnotesize Note. Values are given as mean $\pm$ SD. n.a., not applicable. n.s., not significant} at the end of your table (after \cline{4-7} and before \end{tabular}), you'll have added a new row to the table that spans over all 10 columns. \footnotesize is what makes your "comment line" font size a little bit smaller. If this is not what you're looking for, you'll have to be more specific with your request. Feb 26, 2015 at 14:59
3

You can try something like this:

\documentclass{report}

\usepackage{booktabs}

\begin{document}

\begin{center}
\renewcommand{\arraystretch}{1.25}
\begin{table*}[!t]
    \centering
    \caption{Table Teste}\label{tab:teste2}
    \begin{tabular}{ccc|cccc|cccc}
        \toprule
                 & & & \multicolumn{4}{c|}{hola}  & & & & \\
                \cmidrule(rl){4-7}
         asd & fasdf 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}

\end{document}

Which produces this:

enter image description here

3
  • Hi @Mario S. E. - is there any way to add the rectangle box? And what about the last line?
    – 16per9
    Feb 24, 2015 at 12:47
  • That's why this is a community forum :) Feb 24, 2015 at 12:48
  • how can I add, at the end of this late, a comment line? Like "Note. Values are given as mean $\pm$ SD. n.a., not applicable. n.s., not significant" ?
    – 16per9
    Feb 25, 2015 at 15:21

You must log in to answer this question.

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