6

Consider the following example:

\documentclass[a4paper,11pt]{article}
\usepackage{showframe}

\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.
\hfill
\fbox{At vero eos et accusam et justo duo dolores et ea rebum. Sed non arcu.}

\end{document}

The problem is that the contents of the \fbox does not fit on the line it is typeset and produces an overfull \hbox.

The question is: how to define a command that automatically puts the \fbox on the next line if an Overfull \hbox is generated?

7

You want to introduce a potential linebreak point after the fill.

enter image description here

\documentclass[a4paper,11pt]{article}
\usepackage{showframe}

\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. \hspace*{\fill}\linebreak[0]%
\fbox{At vero eos et accusam et justo duo dolores et ea rebum. Sed non arcu.}



Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy
eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam
voluptua. \hspace*{\fill}\linebreak[0]%
\fbox{At vero eos et accusam et justo duo dolores et ea rebum.}

\end{document}

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.