![如何增加规则的长度?](https://linux22.com/image/342512/%E5%A6%82%E4%BD%95%E5%A2%9E%E5%8A%A0%E8%A7%84%E5%88%99%E7%9A%84%E9%95%BF%E5%BA%A6%EF%BC%9F.png)
有没有办法使用 \toprule、\bottomrule 和 \midrule 来增加规则的长度?我希望它们能稍微延伸到表格两边的文本之外。
这是我的最小代码:
\documentclass{article}
\usepackage{booktabs}
\begin{document}
\begin{table}[h]
\centering
\begin{tabular}{lc}
\toprule
\emph{X} & \emph{Y} \\
\midrule
1 & 2\\
3 & 4\\
\bottomrule
\end{tabular}
\end{table}
\end{document}
谢谢!
答案1
您可以使用列规范强制列之间的空间@{<stuff>}
,其中<stuff>
可以\hspace{<len>}
指定特定长度。在外列上使用这些,您可以使水平规则水平延伸:
\documentclass{article}
\usepackage{booktabs}
\begin{document}
\begin{tabular}{ l c }
\toprule
\emph{X} & \emph{Y} \\
\midrule
1 & 2\\
3 & 4\\
\bottomrule
\end{tabular}
\bigskip
\begin{tabular}{ @{\hspace{2\tabcolsep}} l c @{\hspace{2\tabcolsep}} }
\toprule
\emph{X} & \emph{Y} \\
\midrule
1 & 2\\
3 & 4\\
\bottomrule
\end{tabular}
\end{document}