[Tex/LaTex] Can’t change longtable width for middle column

columnslongtabletables

When I specify the width by \begin{longtable}p{xcm}

For example, here is my code

\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage{longtable}
\begin{document}

\newpage
\begin{longtable}{p{2cm}lp{2cm}lp{2cm}l}
\caption{Test}\\
\label{table:sh}\\
\hline\hline
2cm  &  2cm   & 2cm \\
\hline
Test &  test  & test  \\
\end{longtable}

\begin{longtable}{p{4cm}lp{4cm}lp{4cm}l}
\caption{Test}\\
\label{table:sh}\\
\hline\hline
4cm  &  4cm   & 4cm \\
\hline
Test &  test  & test  \\
\end{longtable}
\end{document}

And clearly the first and third column width have been changed but not the middle column. Why is that? How to fix it?

enter image description here

Best Answer

\begin{longtable}{p{2cm}lp{2cm}lp{2cm}l} means that you have 6 colums, 3 of them with specified width. Hence it is expected that the second column (l as left) has only width needed to enclose your test word.