延长表格中的垂直线

延长表格中的垂直线

请问如何消除水平线周围的小空间造成的空白?换句话说,如何延长垂直线?

\documentclass[12pt,a4paper]{report}
\usepackage{booktabs}       % improved horizontal lines in tables
\usepackage[font=small,labelfont=bf]{caption}
\usepackage{multirow, tabularx}

\begin{document}

\begin{table}[h!]
\captionsetup{justification=centering}
\caption{Program stars selected for detailed studies.}
\label{sample}
\def\s{\phantom{.0}}
\begingroup
\centering
\begin{tabularx}{\textwidth}{|l|l|*{6}{>{\centering\arraybackslash}X|}l|}
\hline
\multirow{2}{*}{Name}   & \multirow{2}{*}{H}     & \multicolumn{2}{c|}{A}  & \multicolumn{2}{c|}{A}  & \multicolumn{2}{c|}{A} & \multirow{2}{*}{Note} \\

\noalign{\smallskip}\cline{3-8}\noalign{\smallskip}

 & & I & J & K & L & M & N & \\
\noalign{\smallskip}\hline\noalign{\smallskip}
         A &   4180 &    &  &  &  &   \\ 
\noalign{\smallskip}\hline\noalign{\smallskip}
            B &  25204 &    &  &  &  &   \\  
\noalign{\smallskip}\hline\noalign{\smallskip}
        C & 21364  &    &  &  &  &   \\ 
\hline
\end{tabularx}
\par
\endgroup
\end{table}
    

\end{document}

在此处输入图片描述

答案1

\noalign{\smallskip}你自己添加空格不是tabular就表格垂直规则而言,环境支持该功能。

\documentclass[12pt,a4paper]{report}
\usepackage{booktabs}       % improved horizontal lines in tables
\usepackage[font=small,labelfont=bf]{caption}
\usepackage{multirow, tabularx}

\captionsetup{justification=centering}

\begin{document}

\begin{table}[!htp]
\centering

\caption{Program stars selected for detailed studies.}
\label{sample}

\begin{tabularx}{\textwidth}{|l|l|*{6}{>{\centering\arraybackslash}X|}l|}
\hline
\multirow{2}{*}{Name} &
\multirow{2}{*}{H} &
\multicolumn{2}{c|}{A} &
\multicolumn{2}{c|}{A} &
\multicolumn{2}{c|}{A} &
\multirow{2}{*}{Note} \\
\cline{3-8}
 & & I & J & K & L & M & N & \\
\hline
A &   4180 &    &  &  &  & & & \\ 
\hline
B &  25204 &    &  &  &  & & & \\  
\hline
C & 21364  &    &  &  &  & & & \\ 
\hline
\end{tabularx}

\end{table}
    
\end{document}

请注意,我删除了几个无用的部分。

在此处输入图片描述

但在我看来,结果相当糟糕,你可能想给细胞多一些空气。补救措施是消除大多数规则,特别是垂直规则。

\documentclass[12pt,a4paper]{report}
\usepackage{booktabs}       % improved horizontal lines in tables
\usepackage[font=small,labelfont=bf]{caption}

\captionsetup{justification=centering}

\begin{document}

\begin{table}[!htp]
\centering

\caption{Program stars selected for detailed studies.}
\label{sample}

\begin{tabular*}{\textwidth}{
  @{\extracolsep{\fill}}
  l
  r
  *{6}{c}
  l
  @{}
}
\toprule
Name &
\multicolumn{1}{c}{H} &
\multicolumn{2}{c}{A} &
\multicolumn{2}{c}{A} &
\multicolumn{2}{c}{A} &
\multicolumn{1}{c@{}}{Note} \\
\cmidrule(lr){3-4} \cmidrule(lr){5-6} \cmidrule(lr){7-8}
 & & I & J & K & L & M & N & \\
\midrule
A &   4180 &    &  &  &  & & & \\ 
B &  25204 &    &  &  &  & & & \\  
C & 21364  &    &  &  &  & & & \\ 
\bottomrule
\end{tabular*}

\end{table}
    
\end{document}

在此处输入图片描述

相关内容