我正在尝试制作一个包含大量文本的表格。我使用tabular*
和\extracolsep
使表格与文档中的文本一样宽。我的问题是我无法使文本对齐,我希望每个单词的首字母彼此对齐。现在,列居中,当文本长度不同时看起来很糟糕。这是我正在使用的代码:
\documentclass{article}
\usepackage{booktabs}
\begin{document}
\begin{table}[h!]
\small
\caption{DM Test}
\label{table:5:2}
\begin{tabular*}{\textwidth}{c @{\extracolsep{\fill}} ccccccccc}
\toprule
{} & \multicolumn{2}{c}{Zone 1} & \multicolumn{2}{c}{Zone 2}
& \multicolumn{2}{c}{Zone 3} & \multicolumn{2}{c}{Zone 4} \\
\cmidrule(lr){2-3} \cmidrule(lr){4-5} \cmidrule(lr){6-7} \cmidrule(l){8-9}
{} & 2021 & 2022 & 2021 & 2022 & 2021 & 2022 & 2021 & 2022 \\
\midrule
1 & Auto & Auto & Auto & Auto & Auto & Auto & Auto & Auto \\
2 & Auto & Auto* & Auto & Auto & LEAR & LEAR & Auto & Auto* \\
3 & Auto & LEAR*** & Auto & Auto*** & LEAR & LEAR & LEAR & LEAR*** \\
4 & Auto & Expert*** & Auto & Expert*** & LEAR & LEAR & LEAR & LEAR** \\
5 & Auto*** & Expert** & Expert*** & Expert*** & LEAR & LEAR & LEAR & Expert*** \\
6 & Expert** & Expert** & Expert** & Expert** & Expert** & LEAR & Expert** & Expert*** \\
7 & Expert* & Expert* & Expert* & Expert* & Expert & LEAR* & Expert & LEAR*** \\
8 & Expert & Expert*** & LEAR*** & LEAR*** & Expert** & LEAR & Expert*** & LEAR** \\
9 & Expert & Expert*** & Expert*** & Expert** & Expert*** & LEAR & Expert*** & LEAR* \\
10 & Expert & LEAR*** & Expert* & Expert*** & LEAR*** & LEAR & LEAR** & LEAR*** \\
11 & Expert & Expert*** & Expert*** & Expert*** & Expert** & LEAR* & Expert*** & LEAR*** \\
12 & Expert & Expert* & Expert** & Expert* & Expert** & LEAR & Expert*** & Auto*** \\
13 & Expert & Expert** & Expert & Expert* & Expert** & LEAR & Expert*** & LEAR*** \\
14 & Expert & Expert** & Expert* & Expert* & Expert* & LEAR* & Expert*** & LEAR*** \\
15 & Expert* & Expert** & Expert** & Expert* & Expert & LEAR*** & Expert*** & LEAR*** \\
16 & Expert & Expert* & Expert** & Expert** & Expert & Expert*** & Expert*** & LEAR*** \\
17 & Expert* & Expert*** & Expert*** & Expert*** & Expert*** & Expert* & Expert*** & LEAR*** \\
18 & Expert & LEAR** & LEAR*** & LEAR*** & Expert*** & Naive** & LEAR** & Naive** \\
19 & Naive*** & LEAR*** & Naive*** & LEAR*** & Naive*** & Naive & Expert*** & Naive \\
20 & Naive*** & LEAR*** & Naive** & LEAR*** & Naive** & Naive* & LEAR* & Naive \\
21 & Naive & LEAR** & Naive & LEAR** & Naive* & LEAR* & LEAR*** & Naive \\
22 & Naive & LEAR** & Naive & LEAR* & Naive & LEAR** & Expert** & Naive* \\
23 & Naive & LEAR** & Naive & LEAR** & Naive & LEAR* & Expert** & Naive* \\
24 & Naive & LEAR* & Naive & LEAR* & Naive & LEAR & Naive & Naive* \\
\bottomrule
\end{tabular*}
\smallskip
\footnotesize
\end{table}
\end{document}
答案1
环境tabular
有许多用于对齐的列定义:
{l}
离开了{c}
是中心{r}
是对的
就你的情况而言:
\begin{tabular*}{\textwidth}{l @{\extracolsep{\fill}} lllllll}
这会将所有列左对齐。