我想将使用 tabularx 生成的表格水平居中。但是 tabularx 表格右侧有一个偏移,我无法删除:
\begin{table}
\small
\centering
\noindent
\begin{tabularx}{}{@{}X|X|X@{}}\hline
a & b & c \\ \hline
d & e & f
\\\hline
\end{tabularx}
\caption{This table is generated with tabularx. This table is generated with tabularx. This table is generated with tabularx. This table is generated with tabularx. This table is generated with tabularx. This table is generated with tabularx. }
\end{table}
\begin{table}
\small
\centering
\noindent
\begin{tabular}{ccc}\hline
a & b & c \\ \hline
d & e & f
\\\hline
\end{tabular}
\caption{This table is generated with tabular. This table is generated with tabular. This table is generated with tabular. This table is generated with tabular. This table is generated with tabular. This table is generated with tabular.}
\end{table}
如何在 tabularx 中将表格水平居中?
答案1
tabularx
需要您指定结果表的宽度,以便计算X
列的宽度。因此,请像这样使用它:
\documentclass{article}
\usepackage{tabularx}
\begin{document}
\begin{table}[t]
\small
\centering
\begin{tabularx}{10em}{ @{} X | X | X @{} }
\hline
a & b & c \\
\hline
d & e & f \\
\hline
\end{tabularx}
\caption{This table is generated with \texttt{tabularx}.}
\end{table}
\begin{table}[t]
\small
\centering
\begin{tabular}{ *{3}{c} }
\hline
a & b & c \\
\hline
d & e & f \\
\hline
\end{tabular}
\caption{This table is generated with \texttt{tabular}.}
\end{table}
Some regular text.
\end{document}