[Tex/LaTex] How to make the text never go over the right margin by always hyphenating or breaking on word-boundaries

hyphenationline-breaking

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.

Best Answer

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:

\sloppy

right after \begin{document}, and then you'll see far less 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:

\usepackage[none]{hyphenat}

in the preamble.