latextabulaoverleafmultirowmulticol

Using multirow and multicoloum in Table in Overleaf


I am trying to make a table where the first column is multiple columns (2 columns) and also multiple rows (2 rows). The error is on the first column (Aspects). How to make it work?

\begin{table}[htb]
\centering
\begin{tabular}{l|c|c|c|c|c}
\hline

\multirow{2}{c}{}\multicolumn{2}{c|}{Aspects} & \multicolumn{4}{c}{Methods} \\
\cline{3-6}
 & & Binomial Test & Tangram & Stereoscope & BayesPrism\\
\hline
\multirow{10}{*}{\begin{turn}{270}Total Number\end{turn}} & Cell Type 0 & 3381 & 25  & 1200 &  331    \\
                               & Cell Type 1 & 1903 & 40  & 3360 &  3468    \\
                               & Cell Type 2 & 3466 & 0   & 1357 &  2729    \\
                               & Cell Type 3 & 3468 & 40  & 1711 &  412   \\
                               & Cell Type 4 & 3406 & 64  & 1996 &  3458   \\
                               & Cell Type 5 & 2934 & 31  & 1512 &  1772    \\
                               & Cell Type 6 & 494  & 55  & 3463 &  3468   \\
                               & Cell Type 7 & 3159 & 30  & 2367 &  3467    \\
                               & Cell Type 8 & 3454 & 53  & 3275 &  3456    \\
                               & Cell Type 9 & 3281 & 18  & 1320 &  1451    \\
            \hline
\multicolumn{2}{c|}{Total Variables}     & 28,946 & 356 & 21,443 & 23,962\\
\multicolumn{2}{c|}{Residual Error Mean} & 3.04   & 3.50 & 2.92  & 2.93 \\
\hline
\end{tabular}
\caption{Total Number of Each Cell Types for The Model \ref{regression}}
\label{total_cell}
\end{table}

Solution

  • This line is completely messed up:

    \multirow{2}{c}{}\multicolumn{2}{c|}{Aspects} 
    

    The \multirow has the wrong syntax, and moreover, \multirow must be inside \multicolumn if you want to combine them (see the multirow manual).

    Also I added a \multicolumn{1}{l}{} to get rid of the vertical bar in the 2x2 cell.

    \documentclass{article}
    \usepackage{multirow}
    \usepackage{rotating}
    
    \begin{document}
    
    \begin{table}[htb]
    \centering
    \begin{tabular}{l|c|c|c|c|c}
    \hline
    
    \multicolumn{2}{c|}{\multirow{2}{*}{Aspects}} & \multicolumn{4}{c}{Methods} \\
    \cline{3-6}
    \multicolumn{1}{l}{} & & Binomial Test & Tangram & Stereoscope & BayesPrism\\
    \hline
    \multirow{10}{*}{\begin{turn}{270}Total Number\end{turn}} & Cell Type 0 & 3381 & 25  & 1200 &  331    \\
                                   & Cell Type 1 & 1903 & 40  & 3360 &  3468    \\
                                   & Cell Type 2 & 3466 & 0   & 1357 &  2729    \\
                                   & Cell Type 3 & 3468 & 40  & 1711 &  412   \\
                                   & Cell Type 4 & 3406 & 64  & 1996 &  3458   \\
                                   & Cell Type 5 & 2934 & 31  & 1512 &  1772    \\
                                   & Cell Type 6 & 494  & 55  & 3463 &  3468   \\
                                   & Cell Type 7 & 3159 & 30  & 2367 &  3467    \\
                                   & Cell Type 8 & 3454 & 53  & 3275 &  3456    \\
                                   & Cell Type 9 & 3281 & 18  & 1320 &  1451    \\
                \hline
    \multicolumn{2}{c|}{Total Variables}     & 28,946 & 356 & 21,443 & 23,962\\
    \multicolumn{2}{c|}{Residual Error Mean} & 3.04   & 3.50 & 2.92  & 2.93 \\
    \hline
    \end{tabular}
    \caption{Total Number of Each Cell Types for The Model \ref{regression}}
    \label{total_cell}
    \end{table}
    
    \end{document}
    

    enter image description here