I have a text table (where the text is often long enough to need to break lines) plus each cell contains several items. However, the number of items in each cell of a row is not the same and, especially in a particular column, this number is usually smaller.
What I want is a type of column which minimises the blank space in the whole table. In this case, then, this column which normally has less items would be narrower. But not only this, the other columns should be wider or narrower depending on how much text is in their cells.
This would be a similar behaviour to the "normal" column types of tabular
but with multiple lines in a cell.
See an example of what I mean:
This is just an excerpt of the table. Notice that column 2 is the widest, the next is column 1, followed by column 3, and column 4 is the narrowest. I need a type of column that adjusts these widths automatically depending on the text in all the cells of the table.
Here an example to try it with:
\documentclass[11pt, a4paper, oneside]{report}
\usepackage{lipsum}
\usepackage{tabularx}
\begin{document}
\begin{table}[!htb]
\centering
\caption{Caption.}
\label{label}
\small
\begin{tabularx}{\textwidth}{XXXX}
\hline
Header 1 & Header 2 & Header 3 & Header 4 \\ \hline
• \lipsum[23][1-2] \newline • \lipsum[23][1-3] \newline • \lipsum[23][1-2] & • \lipsum[23] & • \lipsum[3][1-2] \newline • \lipsum[2][1-3] \newline • \lipsum[1][1-2] & • Short and few \\ \hline
• \lipsum[4][1-2] \newline • \lipsum[4][1-3] \newline • \lipsum[4][1-2] & • \lipsum[4] & • \lipsum[3][1-2] \newline • \lipsum[2][1-3] \newline • \lipsum[1][1-2] & • Short and few \\ \hline
• \lipsum[5][1-2] \newline • \lipsum[5][1-3] \newline • \lipsum[5][1-2] & • \lipsum[5] & • \lipsum[2][1-2] \newline • \lipsum[1][1-3] \newline • \lipsum[2][1-2] & • Short and few \\
\hline
\end{tabularx}
\end{table}
\end(document)
tabulary
, thanks :-)