每列下方有一条中间线,以空格分隔

每列下方有一条中间线,以空格分隔

我们如何在表格中画一条水平线,并且每列之间有空白?

MWE,booktabs使用\midrule\cmidrule

\documentclass[11pt,twoside,a4paper]{article}


\usepackage{booktabs}

\begin{document}

\begin{table}
    \begin{tabular}{lll}
    \toprule
    Header 1 & Header 2 & Header 3\\
    \midrule %Can we make a gap between each column
    Body 1 & Body 2 & Body 3\\
    \cmidrule{2-2} \cmidrule{3-3} %Can we make a gap between these two cmidrules ... or something similar using \cmidrule{2-3}
    Body 4 & Body 5 & Body 5\\
    \bottomrule
    \end{tabular}
    \end{table}

\end{document}

最终结果应如下所示:模型示例

答案1

\cmidrule有使线变短的选项。例如,(r)右侧的用较短,(l)左侧的用较短,以及(lr)两侧的用较短。有关更多详细信息,请参阅booktabs软件包的文档:

\documentclass[11pt,twoside,a4paper]{article}
\usepackage{booktabs}

\begin{document}
\begin{table}
    \begin{tabular}{lll}
    \toprule
    Header 1 & Header 2 & Header 3\\
    \cmidrule(r){1-1}\cmidrule(r){2-2} \cmidrule{3-3} 
    Body 1 & Body 2 & Body 3\\
    \cmidrule(r){2-2} \cmidrule{3-3} 
    Body 4 & Body 5 & Body 5\\
    \bottomrule
    \end{tabular}
    \end{table}
\end{document}

在此处输入图片描述

相关内容