New option table/inner/spread to control X column expansion
Hi @lvjr,
one of the features I have found missing in tabularray is columns that expand automatically to fit their contents without exceeding the declared maximum table width, the way tabulary columns work. (I am maintaining a technical specification document with a lot of tables formatted that way; right now the document is using a hack that combines tabulary with longtable, but I would gladly move to tabularray and get rid of all the hacks I have to use e.g. to get lists working in tables, as well as avoid rendering problems with cell backgrounds and adjacent lines.) So, I went ahead and, after several hours looking at the tabularray code, figured out a way to implement an option that makes X columns with negative coefficients behave the way I need.
Please note that this is my first attempt at writing LaTeX3 code, so it is quite likely some of it could have been written in a more efficient way ;-) Feel free to make it better.
As you can see, I have also added a subsection to the manual demonstrating the usage of the new option.
By the way, I am aware there has been a feature request (#97) open for some time to implement something that, if implemented, would also provide a way to fulfil my needs, however the idea presented there (taken from tabu) takes a different approach and is really more complicated than what I need. That said, I did take the liberty of borrowing the option key name spread from there, even though the interface is very different from the one used by tabu. If you would like a different name, that is no problem.
Also by the way, I implemented spread=coeff because it was quite easy to do and I figured some people might appreciate the control it gives over the distribution of the surplus horizontal space, not because I actually need it — my needs are fulfilled by spread=none.
@mgrzegor Sorry for the late reply. In fact there are two relevant issues to this pull request. The first issue is about how to distribute extra space for X columns which is discussed in https://github.com/lvjr/tabularray/issues/365 . The spread=coeff implementation is about the first issue. The second issue is about how to control the size of extra space for X columns which is discussed in https://github.com/lvjr/tabularray/issues/97 . The spread=none implementation is about the second issue.
By the way, I am aware there has been a feature request (#97) open for some time to implement something that, if implemented, would also provide a way to fulfil my needs, however the idea presented there (taken from
tabu) takes a different approach and is really more complicated than what I need. That said, I did take the liberty of borrowing the option key namespreadfrom there, even though the interface is very different from the one used bytabu. If you would like a different name, that is no problem.Also by the way, I implemented
spread=coeffbecause it was quite easy to do and I figured some people might appreciate the control it gives over the distribution of the surplus horizontal space, not because I actually need it — my needs are fulfilled byspread=none.
I haven't decided yet the final interfaces for the first issue (#365). And since you actually only need the feature in the second issue (#97), I think you could focus only on this issue. In issue #97, I suggest to use key name width+. And I am afraid you need to make the key accept any dimension rather than only width+=0pt (which is the same as spread=none in your code). Since the spreading approach in tabu is complicated, you could implement the feature only for the case when all columns have negative coefficients. Spreading negative columns is much simpler than spreading positive columns in tabu.