对于以下 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}