latexmultirow

align values in latex


i have a problem in LaTeX. I want the accuracy value centered in its cell since it is not associated with the labels but I don't know how to do it.

enter image description here

Here the code I'm using:

\documentclass[12 pt, letterpaper, twoside, openright]{book}
\usepackage{amsmath} 

\usepackage{multirow} 

\usepackage{enumitem}
\usepackage{booktabs, makecell, longtable}
\usepackage{stackengine}
\usepackage{tabularx}
\usepackage{caption}
\usepackage{subcaption}

\begin{document}
\begin{table}[H]
\caption {Logistic Regression and Random Forest Performances}
\centering
 \begin{tabular}{llssssssss}
    \toprule
    \multirow{2}{*}{Patient} &\multirow{2}{*}{Labels} &
      \multicolumn{4}{c}{Logistic Regression} &
      \multicolumn{4}{c}{Random Forest} \\
      && {Accuracy (\%)}&{$Prec$} & {$Rec$} & {$F1$} & {Accuracy (\%)}& {$Prec$} & {$Prec$} & {$F1$} \\
      \midrule
\multirow{2}{3em}{F0110} & 0 & 55 & 0.59 & 0.62 & 0.61 & 55& 0.70 & 0.76 & 0.72 \\ 
 & 1 & & 0.58 & 0.55 & 0.57& & 0.72 & 0.66 & 0.69 \\
 \hline

 \bottomrule
  \end{tabular}
 \label{tab:tab1}
\end{table}

\end{document}

Solution

  • you can use the same \multirow command as with the "FO110" cell

    \documentclass[12 pt, letterpaper, twoside, openright]{book}
    \usepackage{amsmath} 
    
    \usepackage{multirow} 
    
    \usepackage{enumitem}
    \usepackage{booktabs, makecell, longtable}
    \usepackage{stackengine}
    \usepackage{tabularx}
    \usepackage{caption}
    \usepackage{subcaption}
    
    \begin{document}
    \begin{table}[ht]
    \caption {Logistic Regression and Random Forest Performances}
    \centering
     \begin{tabular}{llcccccccc}
        \toprule
        \multirow{2}{*}{Patient} &\multirow{2}{*}{Labels} &
          \multicolumn{4}{c}{Logistic Regression} &
          \multicolumn{4}{c}{Random Forest} \\
          && {Accuracy (\%)}&{$Prec$} & {$Rec$} & {$F1$} & {Accuracy (\%)}& {$Prec$} & {$Prec$} & {$F1$} \\
          \midrule
    \multirow{2}{3em}{F0110} & 0 & \multirow{2}{1em}{55} & 0.59 & 0.62 & 0.61 & \multirow{2}{1em}{55}& 0.70 & 0.76 & 0.72 \\ 
     & 1 & & 0.58 & 0.55 & 0.57& & 0.72 & 0.66 & 0.69 \\
     \hline
    
     \bottomrule
      \end{tabular}
     \label{tab:tab1}
    \end{table}
    
    \end{document}