此代码:
\documentclass[a4paper,11pt]{article}
\usepackage{array}
\usepackage{booktabs}
\usepackage{tabularx}
\begin{document}
\begin{table}
\centering
\footnotesize
\begin{tabularx}{\textwidth}{l X X}
\toprule
Table title \\
\midrule
Some short text \\
\addlinespace
Some fairly short text \\
\addlinespace
Some shorter text \\
\addlinespace
Some short text \\
\addlinespace
Some fairly short text \\
\bottomrule
\end{tabularx}
\end{table}
\end{document}
制作此表:
但是我怎样才能使表格居中并让线条与表格中的文本宽度相同?
答案1
- 您已定义了三列,但只使用一列
- 居中列由说明符定义
c
- 如果你使用
tabularx
with\textwidth
,你的行那么长就不足为奇了 - 不要
\addlinespace
经常使用。只有在需要清楚地分隔表格的某些部分时才使用。
% arara: pdflatex
\documentclass[a4paper,11pt]{article}
\usepackage{booktabs}
\begin{document}
\begin{table}
\centering
\footnotesize
\begin{tabular}{c}
\toprule
Table title \\
\midrule
Some short text \\
Some fairly short text \\
Some shorter text \\
Some short text \\
Some fairly short text \\
\bottomrule
\end{tabular}
\end{table}
\end{document}