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:

\usepackage{array}
\newcolumntype{L}[1]{>{\raggedright\let\newline\\\arraybackslash\hspace{0pt}}m{#1}}
\newcolumntype{C}[1]{>{\centering\let\newline\\\arraybackslash\hspace{0pt}}m{#1}}
\newcolumntype{R}[1]{>{\raggedleft\let\newline\\\arraybackslash\hspace{0pt}}m{#1}}


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|


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?

• Note: I realize I could do this with \multicolum et al, but I would like an approach which lets me generate the content from somewhere else (just separating the columns with &, or whatever is appropriate) and then have the widths decided for me based on content on each row. – Tomas Aschan Oct 2 '13 at 8:19
• Is it possible to abandon tables/arrays and build a custom object? I am thinking of a box/minipage (with frames if you need that) and then a command that puts an \hfill between its two parameters. – papabravo Oct 2 '13 at 8:31
• tabulary columns are adjusted according to how much content is in each column. – David Carlisle Oct 2 '13 at 8:38
• @DavidCarlisle: After skimming the readme for tabulary, I still don't find any way to do this without multicolums. Am I missing something? – Tomas Aschan Oct 2 '13 at 8:43
• @papabravo: Yes, I'm open to any approach that gives me the desired result. Using a tabular environment (of any kind) is by no means a requirement - it just happens to be the approach I thought would work... :P – Tomas Aschan Oct 2 '13 at 8:44

\documentclass{article}

\newcommand\zz[2]{\par
\bigskip
\noindent\begin{tabulary}{\textwidth}{LR}#1&#2\end{tabulary}\par
}
\usepackage{tabulary}

\makeatletter

\def\foo#1\def\TY@ratio#2#3!!{
\def\TY@checkmin{#1%
#3}}
\expandafter\foo\TY@checkmin!!

\makeatother

\setlength\textwidth{10cm}

\begin{document}

\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

• I wasn't sure if the 2nd and third in your ascii art were intended as one entry, you could put them back into the same \zz. If the left entry never breaks over a line you could use \mbox{#1} in the definition, otherwise to stop the column getting so narrow use \setlength\tymin{5cm} or whatever length is enough. If you mark newlines in the source with \newline (or just a blank line paragraph break) they will be honoured in the output – David Carlisle Oct 2 '13 at 12:31