Is there any solution in LaTeX tables that implements similar functionality to MSWord's AutoFit?
-
Could you be more specific about what AutoFit does? Adjusts the column widths---with what goal?– Matthew LeingangApr 28, 2011 at 13:02
-
MSWord is not clear about that. I would say the overall goal is to minimizes height of the table while maintaining its total width.– u17Apr 28, 2011 at 14:02
-
Ah, I see. This sounds almost like a linear programming problem!– Matthew LeingangApr 28, 2011 at 18:02
1 Answer
Have a look at the tabulary
package. Its description reads:
The package defines a
tabular*
-like tabulary environment, taking a ‘total width’ argument as well as the column specifications. It then defines column typesL
,C
,R
andJ
for variable width columns (\raggedright'
,\centering
,\raggedleft
, and normally justified). In contrast totabularx
's X columns, the width of each column is weighted according to the natural width of the widest cell in the column.
In my example, I also use the ragged2e
package to allow for hyphenation within the table cells.
\documentclass{article}
\renewcommand{\arraystretch}{1.5}
\usepackage{tabulary}
\usepackage[newcommands]{ragged2e}
\begin{document}
\begin{tabulary}{0.8\textwidth}{LLL}
Definition and Validation of Dynamic Video Reframing based on & Definition and Validation of & Definition and Validation of Dynamic \\
Definition and Validation of Dynamic & Definition and Validation of & Definition and Validation of \\
\end{tabulary}
\end{document}
(Fixed a bug in an earlier version of this post that had a missing '\'.)
-
1Note that
tabulary
doesn't have a fixed total width. The 'total width' argument acts as an upper limit on the width. Feb 27, 2021 at 10:07