Let's say I have a hbox inside a paragraph like this:

Do you like me? \hfill\hbox{\quad$\bigcirc$ Yes\quad$\bigcirc$ No}.

If the text of the question is longer than this "Do you like me?", the line just won't break. The hbox with answers will just owerflow the right margin.

Why is that? Is that because I haven't adjusted the penalties? From what I read, for TeX hbox is something that cannot be broken into more lines. But why wouldn't it put a line break between the question and the answers?


The breakpoint is before the glue, and if it broke there, the first line would be too underfull. You can add an additional breakpoint after the glue:

enter image description here

\hsize 5cm


Do you like me? \hfill\hbox{\quad$\bigcirc$ Yes\quad$\bigcirc$ No}.

Do you like me?\ \hfill\allowbreak\hbox{\quad$\bigcirc$ Yes\quad$\bigcirc$ No}.

Do you like me?\ \hfill\allowbreak\hbox{}\nobreak\hfill\hbox{\quad$\bigcirc$ Yes\quad$\bigcirc$ No}.

  • Thank you very much. By trial and error, I achieved the same by adding \-. (Is it the same?) Now I am wondering how to make the second line align to the right; using \hfill before the \hbox leads nowhere, I assume TeX eats \hspace after a linebreak? – David Aug 27 '14 at 16:37
  • @David simplest is probably to put \hbox{}\hfill after the penalty. \- will at a hyphen if it breaks at that point, so is not the same. – David Carlisle Aug 27 '14 at 16:39
  • I'm sorry, but this doesn't work for me. Adding \hbox{x}\hfill after the \allowbreak makes the "x" stay on the same line the question is. How is that possible if the line is broken before the hbox{x}? Hope you don't mind me asking! – David Aug 27 '14 at 16:48
  • @David that's because I told you the wrong thing, will update answer in a sec – David Carlisle Aug 27 '14 at 17:26

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.