# Divide cells of my table , adding a row at the top

Can any one help me to draw this table?:

Here is my code :

\begin{document}

\begin{tabular}{|p{3cm}|p{1.5cm}|p{1.5cm}|p{1.5cm}|p{1.5cm}|}
\hline
Data set & \multicolumn{2}{l|}{Conventional} & \multicolumn{2}{l|}{IAL} \\
\hline
&Test CR (\%)&time (sec)&Test CR (\%)&time (sec) \\
\hline
Diabetes &76.07&62.0 \\
\hline
Flare&99.45&226.1 \\
\hline
Thyroid&98.01&226.1 \\
\hline

\end{tabular}

\end{document}


Once I try to add the last column "IAL& Order" by the following code it does not work I am gratefull for your time and consideration :) ...

                \begin{tabular}{l*{10}{S}}
\toprule
&   \multicolumn{2}{c}{Conventional}
&   \multicolumn{2}{c}{OIGA_Asce(average CR)}
&   \multicolumn{2}{c}{OIGA_Desc(average CR)}
&   \multicolumn{2}{c}{OIGA_Rand}
&   \multicolumn{2}{c}{OIGA_Original}
\cmidrule(lr){2-3}\cmidrule(lr){4-5}\cmidrule(lr){6-7}\cmidrule(lr){8-9}\cmidrule(lr){10-11}
Data set   &   {\makecell{Test\\ CR (\%)}} &   {\makecell{time\\ (sec)}}
&   {\makecell{Test\\ CR (\%)}} &   {\makecell{time\\ (sec)}}
&   {\makecell{Test\\ CR (\%)}} &   {\makecell{time\\ (sec)}}
&   {\makecell{Test\\ CR (\%)}} &   {\makecell{time\\(sec)}}
&   {\makecell{Test\\ CR (\%)}} &
{\makecell{time(sec)}}\\
\midrule
Ionosphere   &  58.77   &   {--}    &   94.66   &
{--}    &95.11&{--}  &   94.66   &   {--}    &95.11&
{--}             \\
Thyroid      &  76.07   &   {--}    &   98.41
&   {--}    &98.78&{--}  &   94.66   &   {--}
&95.11&{--}             \\
Musk1        &  98.13   &   {--}    &   77.31
&   {--}    &77.73&{--}  &   94.66   &   {--}
&95.11&{--}             \\
Glass        &  98.14   &   {--}    &   63.96   &
{--}    &70.75&{--}   &   94.66   &   {--}
&95.11&{--}            \\
\bottomrule
\end{tabular}


here was the modification

• The number of your columns (6) and the number of entries you give per row (Thyroid&98.01&226.1&76.07&63.0 = 5 or Data set & \multicolumn{2}{l|}{Conventional} & \multicolumn{2}{l|}{IAL}& \multicolumn{2}{l|}{IAL}=7 ) don't match Jul 13 '17 at 17:30
• 6 < 7, as far as I know. Jul 13 '17 at 17:42
• it is okey ! soory juste how to delete the line after diabete please ! and how to add the line on the top I tried but ...here is my code ( you are right am new and did not understand the repartion of columns (y) thank you Jul 13 '17 at 17:48

Since you now ask new question (probably in hope that I will your personal assistant :) ), I decided to write new answer.

Please, in future doesn't do this. This your question is not well visible to other members of site, so they can't help you. This time you are actually very lucky that I cancel my planed traveling otherwise I will read your comment after few days or even one week ...

I suspect, that you like to obtain the following table:

but I'm not sure in this due to lack of provided information. Anyway, in future question and ask please:

• always provide complete small document, called Minimal Working Example (MWE).About MWE see "I've just been asked to write a minimal example, what is that?" and also content of this CarLaTeX answer!

Only code snippet is not sufficient. In MWE preamble are information of page layout and used package. In your case, The first is the most important, since table is wide and (without any countermeasure) spill out of right border of page)

• in your code you have errors in column headers. Instead of \makecell{OIGA_Asce(average CR)} it should be \makecell{OIGA\textsubscript{Asce}\\(average CR)} or \makecell{$\mathrm{OIGA}_{\mathrm{Asce}}$(average CR)} or \dots. I guessing how this should looks. As you write, require math environment. Since it was not, you receive error.

• why you have columns for "time" which are actually empty. Is possible to omit them? At least for it is probably better to change column type, which is narrower since you have problems with table width.

• each row should be ended by \\ or \tabularnewline otherwice you have mismatch of number columns or error noalign ... for rules

• if you faced with new problem, please ask new (follow-up) question, where you can add link to previous one and in it clearly explain, what is your (new) problem

For above image i wrote on basis of MWE in previous answer the following MWE:

\documentclass{article}
\usepackage{booktabs, makecell, tabularx}
\setcellgapes{4pt}
\usepackage{siunitx}

\begin{document}
\begin{table}[ht]
\sisetup{table-format=2.2,% changed
table-column-width=11mm}%changed
\makegapedcells
\centering
\begin{tabular}{l*{5}{S c}}% changed
\toprule
&   \mcc{Conventional}
&   \mcc{\makecell{OIGA\textsubscript{Asce}\\(average CR)}}% changed
&   \mcc{\makecell{OIGA\textsubscript{Desc}\\(average CR)}}% chnged
&   \mcc{OIGA\textsubscript{Rand}}
&   \mcc{OIGA\textsubscript{Original}}    \\
\cmidrule(lr){2-3}\cmidrule(lr){4-5}\cmidrule(lr){6-7}
\cmidrule(lr){8-9}\cmidrule(lr){10-11}
Data set   &   {\makecell{Test\\ CR (\%)}} &   {\makecell{time\\ (sec)}}
&   {\makecell{Test\\ CR (\%)}} &   {\makecell{time\\ (sec)}}
&   {\makecell{Test\\ CR (\%)}} &   {\makecell{time\\ (sec)}}
&   {\makecell{Test\\ CR (\%)}} &   {\makecell{time\\(sec)}}
&   {\makecell{Test\\ CR (\%)}} &   {\makecell{time\\ (sec)}}\\
\midrule
Ionosphere   &  58.77   &   --    &   94.66
&   --    &   95.11   &   --    &   94.66   &   --    &  95.11    &   --\\
Thyroid      &  76.07   &   --    &   98.41
&   --    &   98.78   &   --    &   94.66   &   --    &   95.11   &   --\\
Musk1        &  98.13   &   --    &   77.31
&   --    &   77.73   &   --    &   94.66   &   --    &   95.11   &   --\\
Glass        &  98.14   &   --    &   63.96
&   --    &   70.75   &   --    &   94.66   &   --    &   95.11   &   --\\
\bottomrule
\end{tabular}
\end{table}
\end{document}

• Yay!!!!! :):):) Jul 14 '17 at 8:01
• thank you guys am very gratefull :) for all of you . @ zarko thank you very much and yeah sure for my future questions I would take in consideration all what you said thank you thank you a lot Jul 14 '17 at 9:31

I would move first two rows of table in the picture to table caption and to table left only rest rows:

\documentclass{article}
\usepackage{makecell,tabularx}
\setcellgapes{4pt}
\usepackage{siunitx}

\begin{document}
\begin{table}[ht]
\sisetup{table-format=3.1,
table-column-width=12mm}
\makegapedcells
\centering
\begin{tabular}{|l|*{6}{S|}}
\hline
Data set    &   \multicolumn{2}{c|}{Conventional}
&   \multicolumn{2}{c|}{IAL}
&   \multicolumn{2}{c|}{IAL}                                    \\
\hline
&   {\makecell{Test\\ CR (\%)}} &   {\makecell{time\\ (sec)}}
&   {\makecell{Test\\ CR (\%)}} &   {\makecell{time\\ (sec)}}
&   {\makecell{Test\\ CR (\%)}} &   {\makecell{time\\ (sec)}}    \\
\hline
Diabetes    &   76.07   &   62.0    &   76.07   &   62.0    &{--}&{--}              \\
\hline
Flare       &   99.45   &   226.1   &   76.07   &   62.0    &{--}&{--}              \\
\hline
Thyroid     &   98.01   &   226.1   &   76.07   &   63.0    &{--}&{--}              \\
\hline
\end{tabular}
\end{table}
\end{document}


Edit: or:

for the first two rows please add the following code lines to above MWE (before existing table content):

    \hline
\multicolumn{7}{|c|}{some text (please replace with actual text}                    \\
\hline
\multicolumn{7}{|c|}{some text (please replace with actual text}                    \\
enter code here


For all columns in table except the first is used S column type. By it the numbers are aligned on decimal point and also defined equal width. Column headers are set with \makecell{...} macro from package makcell. It is also used to add more vertical space above and below cells contents.

This table can have more "professional" look with use of rules from booktabs package and removed vertical lines:

\documentclass{article}
\usepackage{booktabs, makecell,tabularx}
\setcellgapes{3pt}
\usepackage{siunitx}

\begin{document}
\begin{table}[ht]
\sisetup{table-format=3.1,
table-column-width=12mm}
\makegapedcells
\centering
\begin{tabular}{l*{6}{S}}
\toprule
&   \multicolumn{2}{c}{Conventional}
&   \multicolumn{2}{c}{IAL}
&   \multicolumn{2}{c}{IAL}                                    \\
\cmidrule(lr){2-3}\cmidrule(lr){4-5}\cmidrule(lr){6-7}
Data set   &   {\makecell{Test\\ CR (\%)}} &   {\makecell{time\\ (sec)}}
&   {\makecell{Test\\ CR (\%)}} &   {\makecell{time\\ (sec)}}
&   {\makecell{Test\\ CR (\%)}} &   {\makecell{time\\ (sec)}}   \\
\midrule
Diabetes    &   76.07   &   62.0    &   76.07   &   62.0    &{--}&{--}              \\
Flare       &   99.45   &   226.1   &   76.07   &   62.0    &{--}&{--}              \\
Thyroid     &   98.01   &   226.1   &   76.07   &   63.0    &{--}&{--}              \\
\bottomrule
\end{tabular}
\end{table}
\end{document}

• @mirrete, in your edit you only repeat given table. There is nothing new. Sorry, I don't understand what you like that I fix? My answer is complete. Jul 13 '17 at 19:03
• sorry, I canit reach given link. first, my name (used here) is Zarko not Zakro, second, it would be better, if you convert your code snippet to complete small document, i.e. with used \documentclass{???}, preamble, \begin{document}, table code and ended with \end{document} Similarly as it is composed MWE in my answer. Jul 13 '17 at 19:33
• @ Zarko soory, am really so soory ( just because am so stressed about I have to finish my thesis for tomorrow, not familiar with such tables.., thanks to yu I get a coherent and correct code but when s it does not work on the template I have to do with "I get mad" I have fixed it now it works thank you I have selected your code as the desired answer and voted it so that in the future could be used and help someone else soory and thank you :) Jul 13 '17 at 19:42
• is not problem to me, I like to help you, but so far I'm not able to do this fuerther. Please, edit your question and add to your code sniped your document preamble: all before \begin{document}`. After then probably I will be able further help you. Jul 13 '17 at 19:49
• Dear Zarko excuse me :| just one question ( am trying to add two extra columns, then I have another table where I want to haver just a part (example two columns) as I said your example is complete , it is just because I did not understand maybee the way I add columns I have added the code it is same yours but + two extra columns.. juste how to fix my columns :) and thank you again ^^ Jul 13 '17 at 23:22