¿Por qué faltan líneas cuando se utilizan varias columnas?

¿Por qué faltan líneas cuando se utilizan varias columnas?

Faltan líneas entre la columna sana y total

\documentclass{article}
\usepackage[table]{xcolor}
\usepackage{multirow}
\usepackage{makecell}
\begin{document}
\begin{table}
\centering
\begin{tabular}{|c|c|cc|c|c|} 
\hline
& & \multicolumn{2}{c}{BMI} & \\ 
\multirow{-2.5}{*}{\makecell{Activity level}} & 
\multirow{-2.5}{*}{\makecell{Resting heart rate}} & 
{Unhealthy} & {Healthy} & \multirow{-2.5}{*}{\makecell{Total}} \\
\hline
Inactive & Normal   & 9  & 13 & 22\\ 
         & Abnormal & 16 & \cellcolor{pink}8 & 24\\
Active   & Normal   & 3  & 28 & 31 \\ 
         & Abnormal & \cellcolor{gray}6 & \cellcolor{gray}17 & 23 \\ 
\hline
Total    &          & 34 & 56 & \textbf{100} \\ 
\hline
\end{tabular}  
\end{table}
\end{document}

ingrese la descripción de la imagen aquí

Respuesta1

Tu observas,

Faltan líneas entre la columna sana y total

Debes reemplazar

\multicolumn{2}{c}{BMI}

con

\multicolumn{2}{c|}{BMI}

Apéndice: Hay muchos detalles en tu código; peor aún, la tabla no es tan legible. No inspira confianza que tenga \begin{tabular}{|c|c|cc|c|c|}, ya que la tabla contiene 5, no 6, columnas. Eche un vistazo a cómo intenté solucionar los problemas más urgentes en la primera tabla a continuación. Hablando por mí, no puedo decir que esta mesa me parezca atractiva o atractiva. La segunda tabla elimina todas las líneas verticales y utiliza alineación a la izquierda en lugar de centrar las columnas de texto.

ingrese la descripción de la imagen aquí

\documentclass{article}
\usepackage[table]{xcolor}
\usepackage{multirow,makecell}

%% for the second table:
\usepackage{booktabs,siunitx}
\usepackage[skip=0.333\baselineskip]{caption}

\begin{document}
\begin{table}
\centering
\caption{Dreadful}
\begin{tabular}{|c|c|cc|c|} 
\hline
\multirow{2}{*}{Activity level} & 
\multirow{2}{*}{Resting heart rate} & 
\multicolumn{2}{c|}{BMI} & 
\multirow{2}{*}{Total}\\ 
& & Unhealthy & Healthy &  \\
\hline
Inactive & Normal   & 9  & 13 & 22\\ 
         & Abnormal & 16 & \cellcolor{pink}8 & 24\\
Active   & Normal   & 3  & 28 & 31 \\ 
         & Abnormal & \cellcolor{gray}6 & \cellcolor{gray}17 & 23 \\ 
\hline
Total    &          & 34 & 56 & \textbf{100} \\ 
\hline
\end{tabular}  

\bigskip
\caption{Better}
\begin{tabular}{@{} llccc @{}} 
\toprule
Activity level & Resting heart rate & 
\multicolumn{2}{c}{BMI} & Total\\ 
\cmidrule{3-4}
& & Unhealthy & Healthy &  \\
\midrule
Inactive & Normal   & 9  & 13 & 22\\ 
         & Abnormal & 16 & \cellcolor{pink}8 & 24\\
\addlinespace
Active   & Normal   & 3  & 28 & 31 \\ 
         & Abnormal & \cellcolor{gray}6 & \cellcolor{gray}17 & 23 \\ 
\addlinespace
Total    &          & 34 & 66 & \textbf{100} \\ 
\bottomrule
\end{tabular}  
\end{table}
\end{document}

información relacionada