I've used \mbox to prevent LaTeX from breaking certain long words into hyphenated pairs. Now I have a new problem: the unbroken words are extending into the right margin. Here's some minimal sample code that reproduces my problem:


  We summarize our method in algorithm 1. The functions \mbox{``Update''}
  and \mbox{``BatchUpdate''} implement single and multi-constraint updates
  as described above, using interpolated solving to solve for no more than
  $D_{max}$ nodes at a time. The \mbox{``GetUpstreamGPSes($b$, $n$)''}
  function crawls up the tree from node $b$, and returns the first $n$ GPS
  edges along that path.

When I compile this with pdflatex, the "BatchUpdate" and "GetUpstreamGPSes(b, n)" function names get pushed into to right margin. I wanted them to get moved to the next line.

How can I prevent particular words from being broken across lines, while preventing them from extending into the right margin?

1 Answer 1


Try \sloppy (How can I make my text never go over the right margin by always hyphenating or breaking on word-boundaries?).

I found that in the Related Links to your question. It worked for me with your text.

To fix just a part of the document:

surround the offending paragraph with \begin{sloppypar} and \end{sloppypar} commands. Then LaTeX will not break words up but rather will allow more spacing between words in the given paragraph.

(from http://ece.uprm.edu/~caceros/latex/introduction.pdf)

  • Is there no way of fixing this problem without affecting the whole document? The example I quoted is just part of a 100-page document. It'd be nice if I could just tell LaTeX not to push those three particular mboxes into the right margin, rather than making a systematic change to how it performs line breaks everywhere. Apr 26, 2012 at 18:00
  • @SuperElectric Answer edited to answer this question. Apr 27, 2012 at 1:37

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.