Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

Question

In a longtable, how do I retrieve the width of the longest line for each column?

Background

I'd like to use the longtable environment in combination with the ltablex package. The latter allows for weighting the columns, such that column 2 is twice as large as column 1, for instance.

I have many tables to format, and due to their data source it's not possible to give the tables any hint on column widths. As often there is a lot of text in one or two columns, but little text in the others, it doesn't make sense to just use X columns. Therefore, I'd like to dynamically adjust the proportions of the table.

My idea is to find the width of the longest line of each column. Using these width it should then be possible to calculate the proportions correctly (while granting each column a mininum width).

Thanks for your help!

share|improve this question
add comment

1 Answer

up vote 2 down vote accepted

That is essentially a description of tabulary as opposed to tabularx so you can look in the source of that package for how to do it, but in particular there is a merge of tabulary and longtable here:

Multi-page with Tabulary?

share|improve this answer
    
wow, didn't know about tabulary. Thanks for the link! –  Kevin Sep 5 '13 at 11:49
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.