I am having a hard time positioning text. Especially if I need to 'float' elements to different sides. Currently, I'm trying to show a header with a 'subheader' that should be to the right of the header. Exactly to the right; not under it, not above it. Something like this:

MAIN TITLE SUB TITLE
And here goes all the text, over the full page width.
The sub title should be exactly where the content box
ends, no matter what the size of the main title, nor
what the size of the sub title.
ANOTHER LONGER MAIN TITLE ANOTHER SUBTITLE
This is another set of titles that shows just exactly
that the text subtitle should jump to the right of the
page, no matter the size.

I've tried many things but can not get this done. My closest fix was something like this:

The above MWE provides \mytitles{<main>}{<sub>} for setting the <main> and <sub> titles. It creates a box of size \textwidth but corrects for the double \fboxsep and \fboxrule used to surround the titles (using \framebox rather than \makebox). Since the box has a specific width, \hfill "knows" how far to stretch, pushing either titles flush with the (box) margin.

I've introduced \uppercase, but this is not necessary. You can, of course, also change the font shape, as in your MWE:

Great, thanks, works as a charm! In fact, I only put the borders to show how the boxes were being placed, but it was no problem disabling the boxes in your code. Also, I've been wondering for a while what MWE stands for...? (I understand it refers to the OP sample code, but what do the letters mean?)
–
userFeb 21 '12 at 12:58