[Tex/LaTex] Right align address

horizontal alignmentletters

I am pretty new to LaTeX and I'm having some issues for creating a motivation letter. I have a nice structure in my mind, but I can't complete it fully.

Here's a live example: click. Everything looks fine, but the only issue I'm still having is that I want the \address{} field contents to display aligned to the right, instead of being inside a block aligned to the right but contents aligned to the left.

I've searched for the solution but haven't come across anything working.

Best Answer

Here, I used a right-aligned \Longstack to accomplish it, but there were several quirks (EDITED to handle long and short name conditions):

1) I had to place the stack in a right-aligned box of the same width as \today, to handle cases when the name was either longer than or shorter than the date;

2) I had to explicitly set the \Longstack gap as 12pt, because \baselineskip was zeroed inside of \address.

In the MWE below, you can uncomment the extended part of the name, to see that it works for long names, too.

\documentclass{letter}
\addtolength{\voffset}{-0.5in}
\addtolength{\hoffset}{-0.3in}
\addtolength{\textheight}{2cm}

\longindentation=0pt

\signature{My Name}

\usepackage[usestackEOL]{stackengine}
\setstackgap{L}{12pt}
\address{\makebox[\widthof{\today}][r]{\Longstack[r]{\textbf{My %very long 
  name}\\address\\phone\\email}}}

\begin{document}

\begin{letter}{}

\opening{\textbf{Job title goes here}}

Dear mister M,

Vivamus consectetur, mauris sit amet pharetra pharetra, tortor ante dignissim purus, vitae pellentesque ante lorem eu magna. Morbi at leo leo. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos himenaeos. Sed feugiat volutpat risus, a ullamcorper magna dictum quis. Nam dictum enim et lectus consectetur consectetur. Vestibulum vitae eros vel elit venenatis ornare ac sed felis. Nunc et laoreet libero. Cras ut fermentum dui.

Vivamus consectetur, mauris sit amet pharetra pharetra, tortor ante dignissim purus, vitae pellentesque ante lorem eu magna. Morbi at leo leo. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos himenaeos. Sed feugiat volutpat risus, a ullamcorper magna dictum quis. Nam dictum enim et lectus consectetur consectetur. Vestibulum vitae eros vel elit venenatis ornare ac sed felis. Nunc et laoreet libero. Cras ut fermentum dui.

Vivamus consectetur, mauris sit amet pharetra pharetra, tortor ante dignissim purus, vitae pellentesque ante lorem eu magna. Morbi at leo leo. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos himenaeos. Sed feugiat volutpat risus, a ullamcorper magna dictum quis. Nam dictum enim et lectus consectetur consectetur. Vestibulum vitae eros vel elit venenatis ornare ac sed felis. Nunc et laoreet libero. Cras ut fermentum dui.

Thank you for your time and consideration.

I look forward to your reply.

\vspace{2\parskip} % Extra whitespace for aesthetics
\closing{Sincerely,}
\vspace{2\parskip} % Extra whitespace for aesthetics

\end{letter}

\end{document}

enter image description here