I’m creating a template in plain (Xe)TeX which must have, in the first line, a location and reference number. The location is left-aligned and the reference number is right-aligned. (See example 1, below.)
If both of these are short, I can just use:
{\it Location}: UK \hfill {\it Ref}: Xyz
However, if either of these are so long that TeX cannot fit them both into the same line, it overflows the reference number onto the next line (example 2).
Usually this is the best way of dealing with the problem of too much text in one line but because of the way these documents will eventually look, it is not what I would like.
What I’d prefer is for the first half to overflow onto the next line so that the reference number is always entirely on the first line (example 3). This would be relatively easy if the reference number was always static in size but it can change quite a lot (e.g. example 4).
Is there an obvious way of doing this within plain TeX? I can't think of a good way of approaching this problem, short of putting the reference number in a box, calculating its size, subtracting that from the line width and putting the other number into a box of that width, which seems like quite a complex method.
Any pointers as to a method gratefully received. Thanks!



tabularenvironment with breakable columns. – Marco Daniel Dec 18 '11 at 12:03