![`@{}` 不会删除表格边缘的空格吗?](https://linux22.com/image/431137/%60%40%7B%7D%60%20%E4%B8%8D%E4%BC%9A%E5%88%A0%E9%99%A4%E8%A1%A8%E6%A0%BC%E8%BE%B9%E7%BC%98%E7%9A%84%E7%A9%BA%E6%A0%BC%E5%90%97%EF%BC%9F.png)
对于以下 MWE,
\documentclass[oneside,11pt,a4paper]{article}
\usepackage{booktabs}
\usepackage{tabularx}
\begin{document}
\newcolumntype{Y}{>{\centering\arraybackslash}X}
\begin{table}
\begin{tabularx}{\textwidth}{@{}cYYY@{}}
\toprule
Present State & Input & Next State & Output\\
\midrule
00 & 00 & 0 & 0 \\
00 & 00 & 0 & 0 \\
\bottomrule
\end{tabularx}
\end{table}
\end{document}
使用@{}
似乎不会消除边缘处的空格,如图所示。我基本上希望第一行和最后一行相对于边缘的间距更加“对称”。这可能吗?
答案1
最后一列与前两列一样宽,“输出”位于该宽度的中央。实际上不右侧填充。
在这种情况下,您不想使用tabularx
,而是tabular*
\documentclass[oneside,11pt,a4paper]{article}
\usepackage{booktabs}
\begin{document}
\begin{table}
\begin{tabular*}{\textwidth}{@{\extracolsep{\fill}}cccc@{}}
\toprule
Present State & Input & Next State & Output\\
\midrule
00 & 00 & 0 & 0 \\
00 & 00 & 0 & 0 \\
\bottomrule
\end{tabular*}
\caption{Some caption}
\end{table}
\end{document}
不过,除非表格的宽度几乎与文本宽度一样宽,否则我不会加宽表格:大片空白会使表格更难阅读。
答案2
\documentclass[oneside,11pt,a4paper]{article}
\usepackage{booktabs}
\usepackage{tabularx}
\begin{document}
%\newcolumntype{Y}{>{\centering\arraybackslash}X}
\begin{table}
\begin{tabular}{@{}cccc@{}}
\toprule
Present State & Input & Next State & Output\\
\midrule
00 & 00 & 0 & 0 \\
00 & 00 & 0 & 0 \\
\bottomrule
\end{tabular}
\end{table}
\end{document}
编辑
\documentclass[oneside,11pt,a4paper]{article}
\usepackage{booktabs}
\usepackage{tabularx}
\begin{document}
%\newcolumntype{Y}{>{\centering\arraybackslash}X}
\begin{table}
\begin{tabular*}{\textwidth}{@{\extracolsep{\fill}} cccc}
\toprule
Present State & Input & Next State & Output\\
\midrule
00 & 00 & 0 & 0 \\
00 & 00 & 0 & 0 \\
\bottomrule
\end{tabular*}
\end{table}
\end{document}