I've seen several different methods that can be used to make long words not go over the right margin, but all of them have been paragraph-based. I need a solution that can apply to the entire text rather than just a piece of it of at a time. I can live with hyphens, but if it's possible to make lines break on word boundaries, that would be even better.


3 Answers 3


I guess I'm a little unsure which question you're asking: how to disable hyphens, or how to prevent words running into the margins.

When LaTeX lets words flow into the right margin, it reports a "overfull hbox", and produces a warning. This is its way of telling you that it cannot find a paragraph layout that meets its own fussy typography rules, which puts limits to how far it's willing to stretch words apart to retain full justification. It's sort of its way into annoying you into considering rewording the paragraph to make it more attractive typographically. But especially if this is not the final version, you may not care. You can make it less fussy by putting:


Or as sparhawk suggests in the comments:

\emergencystretch 3em

right after \begin{document}, and then you'll see far fewer words spill into the margin -- probably none. For a normal document, it should apply to the whole document, unless you disable it, or contain it inside braces, etc.

Disabling hyphens and forcing wrapping at word boundaries will make it more likely, not less, for there to be bad hboxes which would make words spill into the margins, since it increases how much space it may need to insert. However, if you want to disable hyphenation through the document, try putting:


in the preamble.

  • 2
    You answered both questions! Thanks, and sorry for being so vague. :\
    – Rayne
    Commented Jan 17, 2011 at 12:25
  • 22
    N.B. this answer suggests that \sloppy often produces bad results, and it's often preferable to use \emergencystretch 3em instead.
    – Sparhawk
    Commented Apr 6, 2017 at 3:20
  • 2
    @Sparhawk \emergencystretch 3em worked a treat for me, thanks for the suggestion. You could post this as an answer.
    – Ébe Isaac
    Commented Sep 14, 2017 at 8:03
  • @ÉbeIsaac Good point. I've added an answer.
    – Sparhawk
    Commented Sep 14, 2017 at 11:10

The accepted answer suggests \sloppy. However, as per this related answer, \sloppy can produce imperfect results, and it's often preferable to use \emergencystretch 3em instead.

Please have a look at the linked answer for some excellent visual examples on how the latter is a better solution.

  • 1
    \emergencystretchdoesn't fix all my overflowed words, but \sloppy does. Maybe 3em isn't enough for me but I don't know what value would be best, turned out \sloppy just easier for lazy me.
    – Mzq
    Commented Feb 13, 2019 at 6:00

In general, there's no way to keep arbitrary text justified and constrain interword spacing. frabjous suggested \sloppy which relaxes the interword space constraints.

Another solution is to give up on justified text. Using \raggedright or the better \RaggedRight from the ragged2e package is another solution. The latter gives better text since it is more likely to hyphenate. Of course, if you don't want hyphenation, the former is better.

  • 2
    Really great differentiation on the naming scheme there... ;-)
    – Rikki
    Commented May 14, 2015 at 23:28

You must log in to answer this question.

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