I have a simple text. Right after the end of the text I use \hfill to get some words right aligned.
\documentclass[11pt]{article}
\begin{document}
Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est
\hfill
\textbf{some words}
\end{document}
The problem is now that when the text ends at the end of the line, the words after \hfill won't be right aligned anymore.
\documentclass[11pt]{article}
\begin{document}
Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum.
\hfill
\textbf{some words}
\end{document}
How can I achieve the words to be right aligned even if the text fits the line?
\hfillmight be part of the previous line, not thesome wordsline. Adding\hspace*{0pt}before\hfillhelps, but I'm not 100% sure why exactly. I would also place\textbf{some words}inside a\mbox{...}to avoid line breaks there. However, this might not catch every possibility. Ulrike's answer taken from The TeXBook seems to do this. – Martin Scharrer Apr 21 '11 at 14:07\hfillbecomes space at the beginning of the next line, and disappears -- no flush right. there are several ways to get around this problem. the\hspace*{0pt}forces that space to not disappear, and the\hfilloverwhelms the space normally inserted at the end of a paragraph. the TeXbook exercise takes another approach, forcing the paragraph to end flush right, so only\hfilis needed. – barbara beeton Apr 21 '11 at 14:37