The tabulary package
Sets a table to a target width and gives each L, C, R or J column a width in proportion to the amount of text in it.
Loading the package
\usepackage{tabulary}tabularx gives all X columns the same width, which wastes space when one column holds sentences and another single words. tabulary measures the natural width of each column and divides the target width in that proportion, so the column with the most text gets the most room.
The capital letters mark the columns that are balanced and wrapped: L left-aligned, C centred, R right-aligned, J justified. The lowercase l, c, r and p{...} keep their usual meaning. The package loads array.
Main commands
\begin{tabulary}{\textwidth}{lLLr} ... \end{tabulary} | Table with a target width; the two L columns share the space by content. |
L, C, R, J | Balanced columns: left-aligned, centred, right-aligned, justified. |
\setlength{\tymin}{1.5cm} | Smallest width a balanced column may get; the default is 10 pt. |
\setlength{\tymax}{8cm} | Upper limit for the natural width that counts in the calculation, so one long cell does not take all the space. |
Complete example
\documentclass{article}
\usepackage{tabulary}
\usepackage{booktabs}
\begin{document}
\noindent
\begin{tabulary}{\textwidth}{l L L r}
\toprule
Step & What happens & Remark & Minutes \\
\midrule
Mix & Stir flour, water, yeast and salt until no dry flour is
left, then cover the bowl and let the dough rest. & Use
lukewarm water. & 15 \\
Bake & Put the loaf into the hot oven. & Do not open the door
early. & 40 \\
\bottomrule
\end{tabulary}
\end{document}Compiled with pdfLaTeX from TeX Live 2023.
Pitfalls
- The width is a target. A table whose content fits on one line per cell is set in its natural width and stays narrower.
- Use the capital letters only for columns with running text. A balanced column with short words can get the minimum width
\tyminof 10 pt, and its words then stick out with Overfull \hbox (263.664pt too wide) in paragraph at lines 3--6. Give such a column a lowercase type or raise\tymin. - As with
tabularx,\verbin a cell gives a warning, and a table at\textwidthneeds\noindentbefore it at the start of a paragraph.