TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

The following code does what I need:

\hbox to \textwidth{\hfill
        \hbox{some text}
        \hbox{some other text}
    } %vbox
} %hbox

The important things here are:

  1. Lines are not wrapped
  2. Lines are aligned by their left side
  3. The block as a whole is pushed to the right margin
  4. The width of the block is not specified and is calculated based on the longest line in the block

Can I achieve the same using simpler or higher-level tools? In particular, I don't like the need to wrap each line in the block in an \hbox.

share|improve this question
Also, you have an spurious space in } %vbox, which would result in your text not quite being flush with the right margin. – Peter Grill May 22 '12 at 0:41
up vote 7 down vote accepted

tabular Solution:

You can also use a simple tabular environment as shown below. This yields:

enter image description here


  • The @{} is used to eliminate the column spacing on the right hand side to ensure that the content is flushed with the margin, and to eliminate the column spacing on the left so that you have as much room as possible for the text.

  • The showframe package is used to show that the text is aligned to the right.



 some text\\
 some other text

varwidth Solution:

Alternatively, you could use the varwidth environment. This yields identical results as above.


  • Even though the varwidth environment requires a length, it takes on the natural width of the included content.



 some text\\
 some other text

share|improve this answer
Thanks Peter. Initially I tried something very similar to your tabular solution, but used flushleft instead of tabular. That didn't work. Could you explain the difference between tabular and flushleft in this regard? – Roman Cheplyaka May 22 '12 at 20:44
Well, \flushleft will make the content left aligned, but since you need the entire environment on the right side of the page, it needs to be wrapped in something to move it over. Perhaps if you add a MWE to the question with this attempt it might be easier to comment on it. – Peter Grill May 22 '12 at 21:43
I created a new question for that: tex.stackexchange.com/questions/57004/… – Roman Cheplyaka May 23 '12 at 4:00

To throw in a ConTeXt solution:


  \framed [align=right, frame=off]{%
    some text\\
    some other text}}


The \framed command takes care of the two typeset lines and the \rightaligned of their horizontal position.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.