65

I have done some search for margin alignment in Latex but cannot find how can I right-align any single line?

For example, in a letter sometimes we put a Sincerely on the right. But without using specific documentclass, how can I align any single line in a paragraph to the right in any documentclass?

Many thanks for the help!

Alan Munn
  • 218,180
Henry
  • 1,115

4 Answers4

88

Like this?

\documentclass{article}
\usepackage{kantlipsum}
\begin{document}
\kant[1]

\hspace*{\fill} Yours sincerely

This is some more text

\null\hfill Yours sincerely

Again some dummy text

\hspace*{0pt}\hfill Yours sincerely

And again Phew

\mbox{}\hfill Yours sincerely
\end{document}

enter image description here

  • The way you write your answer might induce the idea that \par is necessary. I'd simply propose the <blank line> \hspace*{\fill} <text> solution. – egreg Aug 11 '14 at 09:13
  • @egreg Oh! Sorry. I wanted it to be a new line and I preferred \par over \\\ I changed it. Thanks. –  Aug 11 '14 at 09:15
  • 4
    Can you clarify which of these options is the most appropriate in various situations? Or are they all identical? – Resigned June 2023 Mar 16 '20 at 01:40
41

For a short line (With lenght less than \linewidth) you can use \rightline{word or phrase}.

If you want to align a paragraph at right put it in a flushright environment. This way allows line breaks with \\.

\begin{flushright}
Text\\
aligned to\\
the right.
\end{flushright}
skpblack
  • 8,904
  • 3
  • 31
  • 42
12

The simpler solution to right align a line is this:

\documentclass{article}
\begin{document}

Here comes some text. Have a nice day.

\rightline{Yours sincerely}

\end{document}

6

This will work if the right-aligned content is considered a separate paragraph (i.e., it will have \parskip separation). Note that it will have less vertical separation than a flushright environment.

\documentclass{article}
\usepackage{lipsum}
\begin{document}
\lipsum[4]
{\raggedleft Sincerely,\par}
\lipsum[4]
\end{document}