将文本推至行尾

将文本推至行尾

我想在当前行的末尾排版文本(链接),如下所示

1 Text.                                                  [Link]

2 More text, that is unfortunately too long to fit the link.  
                                                         [Link]

3 Text that goes over two lines just places the link at the end
  of the last line, if it fits.                          [Link]

4 If it doesn't fit into the second line, because the text is
  just too long, put it flushright on the next line, as in 2.
                                                         [Link]

我不想将[链接]分成两行。


更新。感谢您的所有回答。代码来自接受的答案关于“重复”问题最有效的是:

完美的

答案1

(未经测试。)

在此处输入图片描述

\documentclass{scrartcl}

\newcommand*\link[1]{\hspace*{0em plus 1fill}\makebox{[#1]}}

\textwidth=.5\textwidth % Just for this example

\begin{document}
Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod
tempor incididunt ut labore et dolore magna aliqua. \link{whatever}

Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi
ut aliquip ex ea commodo consequat. \link{another}

Duis aute irure dolor in reprehenderit in voluptate velit esse cillum
dolore eu fugiat nulla pariatur. \link{this}

Excepteur sint occaecat cupidatat non pro ident, sunt in culpa qui officia
deserunt mollit anim id est laborum. \link{that}
\end{document}

相关内容