我们如何在表格中画一条水平线,并且每列之间有空白?
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}