5

I want to create a table in this format, but I haven't managed to get it to work. I dont need to have any colour, i would just like to have it shown as a plain table.

Table Layout

3 Answers 3

6

You're right about not wanting colors; however, you don't want vertical rules either. Nor it's necessary that “Data set” is lowered: the first row has the column headers, some of which have subheaders in the second row, with a horizontal rule to show the groups.

With siunitx and its S column you can get exact spacing between columns, alignment under the decimal point and automatic management of numbers (see in the eighth column).

The input is straightforward; only some care is needed for adjusting the column specifiers, which can be done when the data are in their final form.

A local setting of \tabcolsep is necessary, at least for the standard text width; if you have a different text width you may be able to omit the setting or you may need to change the size.

\documentclass[11pt]{article}
\usepackage{siunitx}
\usepackage{booktabs}

\begin{document}

\begin{tabular}{
  l 
  *{6}{S[table-format=1.4]}
  S[table-format=5]
  S[table-format=3.2]
}
\toprule
\multicolumn{1}{c}{Data Set} &
  \multicolumn{3}{c}{Balanced Error}  &
  \multicolumn{3}{c}{Area Under Curve} &
  \multicolumn{2}{c}{Features} \\
\cmidrule(lr){2-4} \cmidrule(lr){5-7}  \cmidrule(lr){8-9}
  & {Train} & {Valid} & {Test} & {Train} & {Valid} & {Test} & {\#} & {\%} \\
\midrule
arcene  & 0.5000 & 0.4886 & 0.5006 & 0.5000 & 0.5114 & 0.4994 & 10000 & 100.10 \\
gisette & 0.5000 & 0.4886 & 0.5006 & 0.5000 & 0.5114 & 0.4994 & 10000 & 100.10 \\
dexter  & 0.5000 & 0.4886 & 0.5006 & 0.5000 & 0.5114 & 0.4994 & 10000 & 100.10 \\ 
madelon & 0.5000 & 0.4886 & 0.5006 & 0.5000 & 0.5114 & 0.4994 & 10000 & 100.10 \\
\bottomrule
\end{tabular}

\end{document}

enter image description here

6
  • Can Data Set label centered in between the top and lower lines? like @Jared Lo's answer
    – alper
    Commented Sep 26, 2022 at 16:19
  • 1
    @alper Why would you? The header belongs in the same level as “Balanced Errors” and so on. You can use the same strategy as in the answer you're referring to, but I consider it bad style.
    – egreg
    Commented Sep 26, 2022 at 16:25
  • you are right , I will use your approach
    – alper
    Commented Sep 26, 2022 at 16:36
  • for the siunitx format what should I do if I have a variables as following pattern 50/60 ; using S[table-format=5] for 5 characters did not help
    – alper
    Commented Sep 26, 2022 at 17:34
  • @alper S column type is for aligning decimal numbers at the decimal separator.
    – egreg
    Commented Sep 26, 2022 at 17:40
2

Several good answers already exist. I'd like to suggest to use the booktabs package as it creates tables that are effective and yet simple to create.

\documentclass[11pt]{article}
\usepackage{booktabs}

\let\mc\multicolumn

\begin{document}

\begin{tabular}{r rrr rrr rr}
\toprule
 & \mc3c{Balanced Error} 
 & \mc3c{Area Under Curve}
 & \mc2c{Features} \\
 \cmidrule(r){2-4}
 \cmidrule{5-7} 
 \cmidrule(l){8-9}
  Data Set & Train &Valid &Test & Train &Valid & Test & \# & \% \\
\midrule
arcene&0.5000 &0.4886 &0.5006 & 0.5000 &0.5114 &0.4994 &10000 & 100.10\\
gisette&0.5000 &0.4886 &0.5006 & 0.5000 &0.5114 &0.4994 &10000 & 100.10\\
dexter&0.5000 &0.4886 &0.5006 & 0.5000 &0.5114 &0.4994 &10000 & 100.10\\ 
madelon&0.5000 &0.4886 &0.5006 & 0.5000 &0.5114 &0.4994 &10000 & 100.10\\
\bottomrule
\end{tabular}

\end{document}

enter image description here

0

you need to load packages multirow and multicol in the preamble and then :

\begin{table}[htdp]
\caption{default}
\begin{center}
\begin{tabular}{|c|c|c|c|c|c|c|c|c|}
\multirow{2}{*}{Data set}&\multicolumn{3}{c|}{Balanced Error}&\multicolumn{3}{c|}{Area under Curve}&\multicolumn{2}{c|}{Features}\\ \cline{2-9}
&Train&Valid&Tes&Train&Valid&Test&\#&\%\\ \hline
arcene&0.5000&0.5000&0.5000&0.5000&0.5000&0.5000&0.5000&0.5000\\
gisette&0.5000&0.5000&0.5000&0.5000&0.5000&0.5000&0.5000&0.5000\\
dexter&0.5000&0.5000&0.5000&0.5000&0.5000&0.5000&0.5000&0.5000\\
madelon&0.5000&0.5000&0.5000&0.5000&0.5000&0.5000&0.5000&0.5000
\end{tabular}
\end{center}
\label{default}
\end{table}

enter image description here

You must log in to answer this question.

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