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?

1 Answer 1

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}

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .