여러 열을 사용할 때 줄이 누락되는 이유는 무엇입니까?

여러 열을 사용할 때 줄이 누락되는 이유는 무엇입니까?

정상 열과 전체 열 사이에 줄이 누락되었습니다.

\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}

여기에 이미지 설명을 입력하세요

답변1

당신은 관찰하고,

정상 열과 전체 열 사이에 줄이 누락되었습니다.

교체해야 합니다.

\multicolumn{2}{c}{BMI}

~와 함께

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

부록: 코드에 너무 많은 내용이 있습니다. 더 나쁜 것은 테이블을 읽을 수 없다는 것입니다. \begin{tabular}{|c|c|cc|c|c|}테이블에 6개가 아닌 5개의 열이 포함되어 있으므로 이는 신뢰도를 높이는 데 도움이 되지 않습니다 . 아래 첫 번째 표에서 가장 시급한 문제를 해결하기 위해 제가 어떻게 노력했는지 살펴보세요. 나 자신에 대해 말하자면, 나는 이 테이블이 매력적이거나 매력적이라고 ​​​​생각한다고 말할 수 없습니다. 두 번째 테이블에서는 모든 수직선을 없애고 텍스트 열을 가운데 정렬하는 대신 왼쪽 정렬을 사용합니다.

여기에 이미지 설명을 입력하세요

\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}

관련 정보