在表格标题前添加水平线

在表格标题前添加水平线

我有一张表格,使用以下代码来生成:

\begin{table}[h!]
\centering
\hline\noalign{\smallskip}
%\vspace{-0.3cm}
\caption{ \textit{The percentages of all three cases of paired-end read alignments by HMMER and Short-Pair for the RNA-Seq data. ``HMMER w/o filtration" : running HMMER by turning off all filtration steps. ``HMMER GA cutoff": applying HMMER with gathering thresholds.}}
\label{tab:ArabThreeCases2}
%\vspace{-0.3cm}
\begin{tabular}{lllllll}
\hline\noalign{\smallskip}
Case& A, & B,  & C, & D\\
 & $E$-value 10 & w/o filtration,  & GA cutoff &\\
  &  & $E$-value 10 & & \\
\noalign{\smallskip}
\hline
\noalign{\smallskip}
Case 1 &    34.51\% &   32.83\% &   22.51\% & 0.42\%\\
Case 2 &    28.42\% &   31.58\% &   8.84\%  & 62.51\%\\
Case 3 &    37.07\% &   35.59\% &   68.65\% & 37.07\%\\
\hline
\end{tabular}{}
\end{table}

创建的表格在表格标题前有一条水平线,这正是我想要的。但如您所见,这条水平线的长度与表格中的其他水平线不同。我希望它们都具有相同的长度(标题上方线的长度)。我该如何实现? 在此处输入图片描述

答案1

像这样?

在此处输入图片描述

该表使用tabularx环境与S列类型的组合来表示带有数字的列:

\documentclass[12pt,a4paper,openright,oneside]{article}
\usepackage[font=small,
            labelfont=bf, 
            textfont=it,
            skip=1ex
            ]{caption}
\usepackage{booktabs, tabularx}
\newcommand\mc[1]{\multicolumn{1}{>{\centering\arraybackslash\hsize=1.1\hsize}X}{#1}}
\usepackage{siunitx}

\begin{document}

\begin{table}[h!]
    \centering
\hrule height 1pt\smallskip
\caption{The percentages of all three cases of paired-end read alignments by HMMER and Short-Pair for the RNA-Seq data. ``HMMER w/o filtration" : running HMMER by turning off all filtration steps. ``HMMER GA cutoff": applying HMMER with gathering thresholds.}
    \label{tab:ArabThreeCases2}
\begin{tabularx}{\linewidth}{>{\hsize=0.6\hsize}X
                                           *{4}{S[table-format=2.2,
                                                  table-space-text-post=\,\%]<{\,\%}}
                             }
    \toprule
Case    &   \mc{A,}         & \mc{B,}           & \mc{C,}           & \mc{D}    \cr
        & \mc{$E$-value 10} & \mc{w/o filtration\par 
                                  $E$-value 10} & \mc{GA cutoff}    & \mc{}     \cr
    \midrule

Case 1  &    34.51          &   32.83           &   22.51           & 0.42      \cr
Case 2  &    28.42          &   31.58           &   8.84            & 62.51     \cr
Case 3  &    37.07          &   35.59           &   68.65           & 37.07     \cr
    \bottomrule
\end{tabularx}
    \end{table}
\end{document}

相关内容