Draw a horizontal line between row after utilizing makecell

rulestables

In a table, how can I draw a horizontal line to separate every three smartphone models? I mean after LG, Samsung and Xiaomi there must be another line that separates it. Also I need to separate 25%, 50% and 75% according to the first three models. Thanks. enter image description here

\begin{table*}[t!]
    \caption{Localization errors in the three testing scenarios.}
    \label{table:tab5}
    \centering
    \scalebox{0.82}{
        \begin{tabular}{|P{0.15\linewidth}|P{0.20\linewidth}|P{0.15\linewidth}|P{0.14\linewidth}|P{0.14\linewidth}|}
            \hline
            Testing condition& 
            Performance comparison& 
            Smartphone model&
            A&
            B
            \\\hline
            Scenario 1 & \makecell{25\% error \\ 50\% error \\75\% error}  & \makecell{LG \\ Samsung \\Xiaomi \\LG \\ Samsung \\Xiaomi \\LG \\ Samsung \\Xiaomi } & \makecell {1.675 \\ 2.134 \\ 2.563 \\3.858 \\4.892 \\ 4.593 \\6.564 \\ 8.277 \\ 6.723}& \makecell {2.179 \\ 2.758 \\ 2.845 \\4.215 \\ 5.560 \\ 4.964 \\7.568 \\ 8.537 \\ 7.232 } \\\hline
            Scenario 2 & \makecell{25\% error \\ 50\% error \\75\% error} & \makecell{LG \\ Samsung \\Xiaomi \\LG \\ Samsung \\Xiaomi \\LG \\ Samsung \\Xiaomi } & \makecell {2.021 \\ 2.171 \\ 2.568 \\3.021 \\3.452 \\ 4.078 \\5.691 \\ 8.277 \\ 6.328}& \makecell {2.396 \\ 2.435 \\ 2.960 \\3.156 \\3.785 \\ 4.951 \\6.413 \\ 7.809 \\ 7.625} \\\hline
            Scenario 3 & \makecell{25\% error \\ 50\% error \\75\% error}& \makecell{LG \\ Samsung \\Xiaomi \\LG \\ Samsung \\Xiaomi \\LG \\ Samsung \\Xiaomi } & \makecell {1.849 \\ 1.724 \\ 2.341 \\3.052 \\3.148 \\ 4.654 \\4.794 \\ 6.273 \\ 6.738} & \makecell {2.515 \\ 2.369 \\ 3.209 \\3.387 \\4.577 \\ 5.479 \\6.044 \\ 8.248 \\ 8.669} \\\hline
        
    \end{tabular}}
\end{table*}

Best Answer

Here is how you can do that table with {NiceTabular} of nicematrix.

\documentclass{article}
\usepackage{caption}
\usepackage{nicematrix}

\begin{document}

\begin{table*}[t!]
  \caption{Localization errors in the three testing scenarios.}
  \label{table:tab5}
  \centering
  \renewcommand{\arraystretch}{1.2}
  \begin{NiceTabular}{X[3,m,c]X[4,m,c]X[3,m,c]X[3,m,c]X[3,m,c]}[hvlines]
    Testing condition &  Performance comparison & Smartphone model & A & B \\
    \Block{9-1}{} & \Block{3-1}{} & LG      & 1.675 & 2.179 \\
                  & 25\% error    & Samsung & 2.134 & 2.758 \\
                  &               & Xiaomi  & 2.563 & 2.845 \\
                  & \Block{3-1}{} & LG      & 3.858 & 4.215 \\
    Scenario 1    & 50\% error    & Samsung & 4.892 & 5.560 \\
                  &               & Xiaomi  & 4.593 & 4.964 \\
                  & \Block{3-1}{} & LG      & 6.564 & 7.568 \\
                  & 75\% error    & Samsung & 8.277 & 8.537 \\
                  &               & Xiaomi  & 6.723 & 7.232 \\
    \Block{9-1}{} & \Block{3-1}{} & LG      & 2.021 & 2.396 \\
                  & 25\% error    & Samsung & 2.171 & 2.435 \\
                  &               & Xiaomi  & 2.568 & 2.960 \\
                  & \Block{3-1}{} & LG      & 3.021 & 3.156 \\
    Scenario 2    & 50\% error    & Samsung & 3.452 & 3.785 \\
                  &               & Xiaomi  & 4.078 & 4.951 \\
                  & \Block{3-1}{} & LG      & 5.691 & 6.413 \\
                  & 75\% error    & Samsung & 8.277 & 7.809 \\
                  &               & Xiaomi  & 6.328 & 7.625 \\
    \Block{9-1}{} & \Block{3-1}{} & LG      & 1.849 & 2.515 \\
                  & 25\% error    & Samsung & 1.724 & 2.369 \\
                  &               & Xiaomi  & 2.341 & 3.209 \\
                  & \Block{3-1}{} & LG      & 3.052 & 3.387 \\
    Scenario 3    & 50\% error    & Samsung & 3.148 & 4.577 \\
                  &               & Xiaomi  & 4.654 & 5.479 \\
                  & \Block{3-1}{} & LG      & 4.794 & 6.044 \\
                  & 75\% error    & Samsung & 6.273 & 8.248 \\
                  &               & Xiaomi  & 6.738 & 8.669 \\
  \end{NiceTabular}
\end{table*}

\end{document}

You need several compilations (because nicematrix uses PGF/Tikz nodes under the hood).

Output of the above code