0

I am trying to produce a table with quite a lot of text. I am using the tabular* and \extracolsep to make the table as wide as the text in the document. My problem is that I can't get the text to be aligned, I want to first letter in each word to be aligned with each other. Right now, the columns are centered, and when the text is of different length it looks bad. This is the code I am using:

\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

1 Answer 1

1

The tabular environment has many column definition for alignment:

  • {l} is left
  • {c} is centre
  • {r} is right

In your case: \begin{tabular*}{\textwidth}{l @{\extracolsep{\fill}} lllllll}

This will align all columns to the left.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .