0

How can I write at the end of line in LaTeX? Suppose I want to say "thank you" in a letter and then put the name of the author right below it.

Thanks for any insight.

2

Simplest:

\begin{flushright}
Sincerely,
\end{flushright}

However, this does add some spaces you may not want. Perhaps:

\hbox to\linewidth{\hfil Sincerely,\hfil}

But in LaTeX this sort of thing should be handled by your class or package file; that is, you should be typing something like \valediction{Sincerely} and having LaTeX take care of where to put it.

What class are you using? I'd suggest newlfm for letters; you can get this from your distribution's repos, or directly from CTAN. I'd also suggest reading The Not-So-Short Introduction to LaTeX2e, which you can also find on CTAN. It will give you the fundamentals for answering these questions on your own.

2

Setting aside all due comments about logical versus physical markup, how would you just dash this off quickly in a one-off scenario?

If you have just one line, then the flushright environment will do the job. If you have multiple lines, you probably want them left-justified among themselves. This can be done by enclosing them in a tabular:

\begin{flushright}
  \begin{tabular}{l}
    Sincerely,\\[0.5in]
    John Smith \\
    Vice President of Widgets 
  \end{tabular}
\end{flushright}

The \\[0.5in] leaves a half-inch space for a physical signature, etc. Modify as desired. Personally, instead of flushright I use a \rule of zero height to push the signature block a fixed distance to the right.

\noindent
\rule{4in}{0in}%
\begin{tabular}{l}
  Sincerely,\\[0.5in]
  John Smith\\
  Vice-President of Widgets
\end{tabular}

I do the same thing for the date and return-address blocks at the head of the letter, so that they all line up nicely.

Again, the idea of logical markup says we should be relying on a class to do this for us, or at least programming a class to our own ideals, rather than hard-coding this in every letter, but sometimes you just need something that's quick and works.

  • 2
    \begin{tabular}{l@{}} will remove the space at the right end. – egreg Sep 30 '15 at 16:18
  • @egreg Good catch! – Anders Hendrickson Oct 2 '15 at 19:11

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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