![文字寬度中的表格](https://rvso.com/image/399820/%E6%96%87%E5%AD%97%E5%AF%AC%E5%BA%A6%E4%B8%AD%E7%9A%84%E8%A1%A8%E6%A0%BC.png)
當我想要調整表格的文字寬度時,我使用以下程式碼:
\begin{table}[t]
\small
\caption{Summary descriptive statistics}
\label{tab1:summary_by_affiliation}
\centering{\begin{tabular*}{\textwidth}{c @{\extracolsep{\fill}} c}
\toprule
\multicolumn{1}{c}{Test 1} & \multicolumn{1}{c}{Test 2} \\
\midrule
Mean & 6.37 \\
Median & 1.00 \\
Std. Dev. & 19.01 \\
Kurtosis & 39.33 \\
Skewness & 5.79 \\
Minimum & 0.09 \\
Maximum & 194.45 \\
Sum & 5845 \\
Count & 917 \\
\bottomrule
\end{tabular*}}
\vspace{-2ex}
\begin{tablenotes}[flushleft]
\footnotesize
\singlespacing
\item\hspace{-2.5pt}\textit{Note}: Test
\end{tablenotes}
\end{table}
結果如下:
但我真正想要的是這個(沒有垂直線等,但 allignmend 應該看起來像這樣:
答案1
您可以透過從 環境切換tabular*
到tabularx
環境並使用居中版本的X
列類型而不是列c
類型來實現格式化目標。
似乎不需要環境tablenotes
。
\documentclass{article}
\usepackage{tabularx,booktabs}
\newcolumntype{C}{>{\centering\arraybackslash}X}
\begin{document}
\begin{table}[t]
%\small
\caption{Summary descriptive statistics}
\label{tab1:summary_by_affiliation}
\begin{tabularx}{\textwidth}{CC}
\toprule
Test 1 & Test 2 \\
\midrule
Mean & 6.37 \\
Median & 1.00 \\
Std. Dev. & 19.01 \\
Kurtosis & 39.33 \\
Skewness & 5.79 \\
Minimum & 0.09 \\
Maximum & 194.45 \\
Sum & 5845 \\
Count & 917 \\
\bottomrule
\end{tabularx}
\medskip
\footnotesize
\textit{Note}: Test
\end{table}
\end{document}