Push a block of lines to the right margin

tabular Solution:

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

enter image description here

Notes:

  • 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.

Code:

\documentclass{article}
\usepackage{showframe}

\begin{document}
\hfill
\begin{tabular}{l@{}}
 some text\\
 some other text
\end{tabular}
\end{document}

varwidth Solution:

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

Notes:

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

Code:

\documentclass{article}
\usepackage{showframe}
\usepackage{varwidth}

\begin{document}
\hfill
\begin{varwidth}{\linewidth}
 some text\\
 some other text
\end{varwidth}
\end{document}