[Tex/LaTex] Table with variable-width columns, width decided based on row content


I'm typesetting some material in two columns, the left one left-adjusted and the right one right-adjusted (it's a list of songs in a concert, with song names on the left and composer names on the right). My approach so far has been to use \begin{tabular}{L{4.2cm}R{3.2cm}}
where the column definitions are as follows:


However, with this approach my table becomes a little too wide. Some rows have more content on the left side (long song names) and some rows have more content on the right side (long composer names), but none of them have both – so if I could find a way to adjust the column widths automatically based on the content, that would solve my problem.

I don't know if this is even possible with a tabular approach – and I have no problem with switching to some other approach if it helps. The ultimate goal is to be able to have rows in a list with part of the row left-aligned, and the rest of the row right-aligned:

|<- left edge of text         right edge of text->|
|The first song                        by Some Guy|
|                                   who lived then|
|                                                 |
|Some other song                   by Someone Else|
|and another one by the same guy    who also lived|
|                                                 |
|A fourth song    by a guy with a Really Long Name|
|                               aw, he's dead, Jim|

Note how the "other song by the same guy" and "fourth song" rows overlap, i.e. the right column of the latter starts before the end of the left column of the former. So instead of rigidly defining the column widths, I'd like to define the width of the entire table (between the pipes above) and have the rest done for me automagically.

What's the best approach to achieve this in (Xe)LaTeX?

Best Answer

enter image description here



% http://tex.stackexchange.com/questions/87097/is-it-possible-to-make-an-underfull-tabulary-spread-out/87543#87543





\noindent X\dotfill X

\zz{The first song}{by Some Guy who lived then}

\zz{Some other song}{by Someone Else}

\zz{and another one by the same guy}{who also lived}

\zz{A fourth song }{by a guy with a Really Long Name
                               aw, he's dead, Jim}

\noindent X\dotfill X

Related Question