[Tex/LaTex] Using both multicolumn and multirow in a table

multicolumnmultirowtables

I want to create a table that uses both multicolumn and multirow. Currently, I used the code:

\begin{table}[!h]
\label{T:equipos}
\begin{center}
\begin{tabular}{|c|c|c|c|c|c|c|}
\hline
\multicolumn{7}{|c|}{\textbf{Datasets}}  \\ 
\cline{1-7}
\multicolumn{3}{|c|}{\textbf{in-house}} &  \multicolumn{4}{c|}{\textbf{NSL-KDD}} \\
\hline
\hline

DR & Accuracy & FPR & K value & DR & Accuracy & FPR\\ \hline
\multirow{ 1}{*}{99.75} & \multirow{ 1}{*}{99.72} & \multirow{ 1}{*}{0.06} & 

1 & 90.53 & 96.14 & 0.0\\ \hline
&  &  & 2 & 94.22 & 97.65 & 0.0\\ \hline
&  &  & 3 & 95.50 & 98.16 & 0.0\\ \hline
&  &  & 4 & 96.10 & 98.41 & 0.0\\ \hline
&  &  & 5 & 97.7 & 98.92 & 0.11\\ \hline
\end{tabular}
\end{center}
\end{table}

which produces the following table

enter image description here

but what I want is this:

enter image description here

how can I achieve the format of the table above i.e., table 2 above?

Best Answer

To be honest: You do not need multirow for that.

multirow

\documentclass{article}
\begin{document}
\begin{table}[!htb]
\label{T:equipos}
\begin{center}
\begin{tabular}{|c|c|c|c|c|c|c|}
\hline
\multicolumn{7}{|c|}{\textbf{Datasets}}  \\ 
\cline{1-7}
\multicolumn{3}{|c|}{\textbf{in-house}} &  \multicolumn{4}{c|}{\textbf{NSL-KDD}} \\
\hline
\hline
DR & Accuracy & FPR & K value & DR & Accuracy & FPR\\ \hline
99.75 & 99.72 & 0.06 & 1 & 90.53 & 96.14 & 0.0\\ \cline{4-7}
&  &  & 2 & 94.22 & 97.65 & 0.0\\ \cline{4-7}
&  &  & 3 & 95.50 & 98.16 & 0.0\\ \cline{4-7}
&  &  & 4 & 96.10 & 98.41 & 0.0\\ \cline{4-7}
&  &  & 5 & 97.7 & 98.92 & 0.11\\ \hline
\end{tabular}
\end{center}
\end{table}
\end{document}

Update: You should maybe consider to (a) align your values at the decimal point and (b) use booktabs (just as suggestion):

booktabbed

\documentclass{article}
\usepackage{booktabs}
\usepackage{siunitx}
\begin{document}
\begin{table}[!htb]
\label{T:equipos}
\begin{center}
\begin{tabular}{SSSlSSS}
\toprule
\multicolumn{7}{c}{\bfseries Datasets}\\
\multicolumn{3}{c}{\bfseries in-house} &  \multicolumn{4}{c}{\bfseries NSL-KDD}\\\cmidrule(lr){1-3}\cmidrule(lr){4-7}
\multicolumn{1}{l}{DR} & \multicolumn{1}{l}{Accuracy} & \multicolumn{1}{l}{FPR} & 
  K value & \multicolumn{1}{l}{DR} & \multicolumn{1}{l}{Accuracy} & \multicolumn{1}{l}{FPR}\\\midrule
99.75 & 99.72 & 0.06 & 1 & 90.53 & 96.14 & 0.0\\
&  &  & 2 & 94.22 & 97.65 & 0.0\\
&  &  & 3 & 95.50 & 98.16 & 0.0\\
&  &  & 4 & 96.10 & 98.41 & 0.0\\
&  &  & 5 & 97.7 & 98.92 & 0.11\\\bottomrule
\end{tabular}
\end{center}
\end{table}
\end{document}