[Tex/LaTex] How to left-justify a paragraph cell in a table

horizontal alignmenttables

I have a table of maths as below, where I've used the p{} attribute to allow the list of partitions to wrap inside the cell. The problem is that it also justifies the column, which looks very strange for the rows 6-10 because you get huge gaps. What I want is the list of partitions to be left-justified with standard spacing, like in the first few rows, but still able to spill over onto multiple rows.

\usepackage{amsmath}

\begin{document}

\begin{table}
\renewcommand{\arraystretch}{1.3}
 \begin{center}
 \label{pntable}
 \begin{tabular}{|c|p{6.5cm}|c|}
 \hline
 \textbf{Integer} & \textbf{Partitions} & \textbf{Number of partitions} \\ \hline
 1 & 1 & 1 \\ \hline
 2 & 2, 1+1 & 2 \\ \hline
 3 & 3, 2+1, 1+1+1 & 3 \\ \hline
 4 & 4, 3+1, 2+2, 2+1+1, 1+1+1+1 & 5 \\ \hline
 5 & 5, 4+1, 3+2, 3+1+1, 2+2+1, 2+1+1+1, 1+1+1+1+1 & 7 \\ \hline
 6 & 6, 5+1, 4+2, 4+1+1, 3+3, 3+2+1, 3+1+1+1, 2+2+2, 2+2+1+1, 2+1+1+1+1, 1+1+1+1+1+1 & 11 \\ \hline
 7 & 7, 6+1, 5+2, 5+1+1, 4+3, 4+2+1, 4+1+1+1, 3+3+1, 3+2+2, 3+2+1+1, 3+1+1+1+1, 2+2+2+1, 2+2+1+1+1, 2+1+1+1+1+1, 1+1+1+1+1+1+1 & 15 \\ \hline
 8 & 8, 7+1, 6+2, 6+1+1, 5+3, 5+2+1, 5+1+1+1, 4+4, 4+3+1, 4+2+2, 4+2+1+1, 4+1+1+1+1, 3+3+2, 3+3+1+1, 3+2+2+1, 3+2+1+1+1, 3+1+1+1+1+1, 2+2+2+2, 2+2+2+1+1, 2+2+1+1+1+1, 2+1+1+1+1+1+1, 1+1+1+1+1+1+1+1 & 22 \\ \hline
 9 & 9, 8+1, 7+2, 7+1+1, 6+3, 6+2+1, 6+1+1+1, 5+4, 5+3+1, 5+2+2, 5+2+1+1, 5+1+1+1+1, 4+4+1, 4+3+2, 4+3+1+1, 4+2+2+1, 4+2+1+1+1, 4+1+1+1+1+1, 3+3+3, 3+3+2+1, 3+3+1+1+1, 3+2+2+2, 3+2+2+1+1, 3+2+1+1+1+1, 3+1+1+1+1+1+1, 2+2+2+2+1, 2+2+2+1+1+1, 2+2+1+1+1+1+1, 2+1+1+1+1+1+1+1, 1+1+1+1+1+1+1+1+1 & 30 \\ \hline
 10 & 10, 9+1, 8+2, 8+1+1, 7+3, 7+2+1, 7+1+1+1, 6+4, 6+3+1, 6+2+2, 6+2+1+1, 6+1+1+1+1, 5+5, 5+4+1, 5+3+2, 5+3+1+1, 5+2+2+1, 5+2+1+1+1, 5+1+1+1+1+1, 4+4+2, 4+4+1+1, 4+3+3, 4+3+2+1, 4+3+1+1+1, 4+2+2+2, 4+2+2+1+1, 4+2+1+1+1+1, 4+1+1+1+1+1+1, 3+3+3+1, 3+3+2+2, 3+3+2+1+1, 3+3+1+1+1+1, 3+2+2+2+1, 3+2+2+1+1+1, 3+2+1+1+1+1+1, 3+1+1+1+1+1+1+1, 2+2+2+2+2, 2+2+2+2+1+1, 2+2+2+1+1+1+1, 2+2+1+1+1+1+1+1, 2+1+1+1+1+1+1+1+1, 1+1+1+1+1+1+1+1+1+1 & 42 \\ \hline
 \end{tabular}
 \end{center}
 \caption{All the partitions of $n \in \{1,\ldots,10\}$}
\end{table}

\end{document}

Apologies in advance because I'm sure this will have been answered before, but I can't find it anywhere and really need some help!

Best Answer

use the array package then you can use

\begin{tabular}{|c|>{\raggedright}p{6.5cm}|c|}
Related Question