[Tex/LaTex] multirow table, error

multirowtables

I'm trying to create a table which some of the cells are multirow and this is my code:

\begin{table}[!htb]
\centering
\small\addtolength{\tabcolsep}{4pt}
\caption{""}
\label{table3}
\begin{tabular}{*{7}{|c}|}
\hline
 \multirow{2}{*}{H}& \multicolumn{3}{c|}{K@10} & \multicolumn{3}{c|}{K@20}\\\cline{2-7}
 & P & R & TFFR &  P & R & TFFR  \\\hline 
H\textsubscript{01}  & \multirow{2}{*} & \multirow{2}{*} & \multirow{2}{*} & \multirow{2}{*} & \multirow{2}{*}  & \multirow{2}{*}  \\\hline
H\textsubscript{02} & & & & & &  \\
H\textsubscript{03}  & \multirow{2}{*}  & \multirow{2}{*} & \multirow{2}{*} & \multirow{2}{*} & \multirow{2}{*}  & \multirow{2}{*}   \\\hline
H\textsubscript{04} & & & & & &  \\
H\textsubscript{05}  & \multirow{2}{*}  & \multirow{2}{*}  & \multirow{2}{*} & \multirow{2}{*} & \multirow{2}{*}  & \multirow{2}{*}  \\\hline
H\textsubscript{06} & & & & & &  \\\hline
 \end{tabular}
\end{table}

I don't know what's wrong with this code. This is the error which I got:

! LaTeX Error: Something's wrong--perhaps a missing \item.

See the LaTeX manual or LaTeX Companion for explanation.
Type  H <return>  for immediate help.
 ...                                              

l.487 ... & \multirow{2}{*}  & \multirow{2}{*}  \\

Best Answer

Let us list the errors first.

  1. For quotation marks you shouldn't use "..." but ``...''
  2. \multirow{2}{*}{H} takes three arguments - \multirow{<rows>}{<width>}{<content>}. You have missed the third argument. Even if you don't want to have text, you should have it but without content like \multirow{2}{*}{}.
  3. \textsubscript isn't defined by LaTeX. You have to use \usepackage{fixltx2e} in the preamble to make it work. BTW are you trying to write a chemical formula? If so, there are packages meant for that job. Or are those H\textsubscript{02}s mathematical variables? Please elaborate.
  4. To make colored cells, load colortbl package or usepackage[table]{xcolor} (Both are equivalent). and the use \cellcolor{<color> inside the cell:

    & \cellcolor{green!50!blue} <content> &
    

    or

     & \cellcolor{green!50!blue}\multirow{2}{*}{}  &
    
  5. Do you really want vertical lines? What about reducing the number of some horizontal lines? You may read the documentation of booktabs package to learn how to produce a good table.

Now your code should be:

\documentclass{article}
\usepackage{multirow,fixltx2e}
\usepackage[table]{xcolor}    %% this in turn loads colortbl
%\usepackage{colortbl}
\begin{document}
  \begin{table}[!htb]
\centering
\small\addtolength{\tabcolsep}{4pt}
\caption{``''}
\label{table3}
\begin{tabular}{*{7}{|c}|}
\hline
 \multirow{2}{*}{H}& \multicolumn{3}{c|}{K@10} & \multicolumn{3}{c|}{K@20}\\\cline{2-7}
 & P & R & TFFR &  P & R & TFFR  \\\hline
H\textsubscript{01}  & \multirow{2}{*}{} & \multirow{2}{*}{}& \multirow{2}{*}{} & \multirow{2}{*}{} & \multirow{2}{*} {} & \multirow{2}{*}{}  \\\hline
H\textsubscript{02} & \cellcolor{green!50!blue} & & & & &  \\
H\textsubscript{03}  & \cellcolor{green!50!blue}\multirow{2}{*}{}  & \multirow{2}{*}{} & \multirow{2}{*}{} & \multirow{2}{*}{} & \multirow{2}{*}{}  & \multirow{2}{*}{}   \\\hline
H\textsubscript{04} & & \cellcolor{green!50!blue} & & & &  \\
H\textsubscript{05}  & \multirow{2}{*}{}  & \cellcolor{green!50!blue}\multirow{2}{*}{}  & \multirow{2}{*}{} & \multirow{2}{*}{} & \multirow{2}{*}{}  & \multirow{2}{*}{}  \\\hline
H\textsubscript{06} & & & & & &  \\\hline
 \end{tabular}
\end{table}
\end{document}

enter image description here

Related Question