The first line of hyphen.tex, shipped with TeX Live 2024, is a shout: The Plain TeX hyphenation tables [NOT TO BE CHANGED IN ANY WAY!]. The file holds the 4447 patterns LaTeX consults every time it decides where to break a line, and at the end sits a hand-written exception list of just fourteen words. Two of them — present and project — carry no break points at all, because each is a different word depending on how you say it, and TeX cannot tell which one you meant. Tuning line breaks means making that same judgement in your own manuscript. This page covers \\, \newline, \linebreak[n], \nolinebreak[n], the discretionary hyphen \-, \hyphenation{...}, the hyphenat package and babel’s per-language hyphenation patterns — with the numbers measured rather than repeated.
A boundary first. Starting a new paragraph (with a blank line or \par) is one thing; moving where lines break inside a paragraph is another. The first brings indentation and inter-paragraph space with it; the second only shifts where the line ends fall within a single paragraph. Outside both sits a third layer — the design of page rhythm, the world of \widowpenalty and \raggedbottom — which belongs to the page-breaking page. \looseness, the request to set a paragraph one line shorter or longer, is measured and documented there too. This page is strictly about lines.
\\ versus \newline: same macro, different door
\newline is defined as \@normalcr\relax, and \\ is the same macro without the \relax (latex.ltx). That one token is the whole difference. \\ goes on to look for a following * or [length]; \newline is blocked by the \relax and never looks. Set Alpha\newline[2ex] Beta and the page really does print a literal [2ex]. By contrast \\[2ex] adds 2ex of vertical space after the line, and \\* forbids a page break at that point. In practice: reach for \\ when you want the options, and for \newline when you want the intent to be readable in the source.
What they share is that they end the line without stretching it. The body is \unskip … \nobreak \hfil \break: an infinitely stretchable \hfil is placed at the right, and only then does the break happen. That \hfil swallows all the slack, so the line stops at its natural length and stays short. This is exactly why they suit addresses and verse, where each line should end where you intended. There is one side effect. Put \\ at the very end of a paragraph and you create an empty final line, which reports Underfull \hbox (badness 10000) in paragraph at lines 6--7. A paragraph does not need a trailing \\ — and neither does the line right after a heading. Use it where there is no line to end at all, such as at the start of a paragraph, and you get ! LaTeX Error: There's no line here to end. instead.
% \\ and \newline end the line short; \linebreak justifies it to the margin.
First road is steep\\
second road is gentle.
% \\ takes an optional length and a star; \newline takes neither.
Alpha\\[2ex] Beta % 2ex of vertical space after the line
Alpha\\* Gamma % no page break allowed here
Alpha\newline[2ex] Delta % prints a literal [2ex] on the page
% A trailing \\ at the end of a paragraph produces
% Underfull \hbox (badness 10000) in paragraph at lines 6--7
This paragraph does not need one.Inside a table the two roles separate cleanly. In a paragraph-making cell such as a p{...} column of tabular, \newline breaks only within that cell while \\ ends the whole row. Want an address on two lines in one cell? That is \newline. Measured: Line one\newline Line two in a p{3cm} cell stacks two lines inside the same row, and the cell to its right stays put. In the array environment \\ is likewise the row separator. Use \newline in a non-paragraph column such as l or c and there is no line to end, so you get the error above.
What number is behind the n in \linebreak[n] and \nolinebreak[n]
n runs 0 to 4 and translates into the penalties 0, 51, 151, 301 and 10000. \@getpen in latex.ltx returns 0 / \@lowpenalty / \@medpenalty / \@highpenalty / \@M, and in the standard classes those three are set to 51, 151 and 301 on lines 118–120 of article.cls. \linebreak[n] inserts that value negative — breaking here is a reward — and \nolinebreak[n] inserts it positive — breaking here costs. Omit the argument and both default to 4, that is ∓10000, TeX’s infinity. Seeing the numbers settles the choice: the 51 behind [1] is a whisper that the badness of ordinary body text beats easily, [3] at 301 is the first value that argues back, and only [4] is an order.
| Argument | linebreak inserts | nolinebreak inserts | How strong |
|---|---|---|---|
[0] | 0 | 0 | merely a legal break point, at zero cost |
[1] | -51 | 51 | a whisper; body-text badness beats it |
[2] | -151 | 151 | about the weight of the default \widowpenalty |
[3] | -301 | 301 | the first value that argues back |
[4] | -10000 | 10000 | the default; infinity, i.e. an order |
\linebreak and \\ produce the same break but opposite results. \linebreak only drops a penalty, so the line is justified as usual and stretched out to the right margin — which is why word spacing tends to gape. \\ swallows the slack with that \hfil and stays short. The mnemonic: \\ to break short, \linebreak to justify to the margin. In detail, \@no@lnbk removes the preceding glue with \unskip, inserts the penalty, and then puts a glue of the same width back — so word\linebreak word does not end up with a doubled space.
Forbidding a break here: the tie ~ and what \mbox costs
If all you want is to protect one space, the tilde ~ is the first choice. It is the width of an ordinary interword space; the only difference is that no line may break there. Use it wherever a word must not be torn from a number or a symbol: Fig.~3, Dr.~Smith, Chapter~12, equation~\ref{eq:1}. What matters is that ~ does not stop the surrounding words from hyphenating. It amounts to \nobreak plus a space — an infinite penalty (\nobreak is \penalty10000) at that one point — so the words themselves stay free to break. For graduated strength there is \nolinebreak[n]; for a flat prohibition, the low-level \nobreak.
\mbox{...} is a different animal. It packs its contents into a single box, so the material can neither break across lines nor hyphenate. That suits a short phrase you must not split, such as T-34, but it has a price. Measured: in a 4.2cm minipage, dichlorodiphenyltrichloroethane fits on its own, but wrapped in \mbox{...} it reports Overfull \hbox (18.8814pt too wide) and juts 18.88pt past the right margin. Freezing long URLs or chemical names inside \mbox is a cure worse than the disease. The hyphen-free entry in \hyphenation{...} and hyphenat’s \nohyphens{...}, both covered below, stop the hyphenation without building a box.
Adding a hyphenation point with \-: not “also here” but “only here”
Insert even one \- into a word and LaTeX will hyphenate it only where you marked, never at the points it found itself. Every pattern-derived candidate disappears. \showhyphens makes this plain. Left alone, supercalifragilistic breaks in five places, su-per-cal-ifrag-ilis-tic; write super\-califragilistic and it collapses to the single super-califragilistic. Likewise hyphenation goes from hy-phen-ation to hyphen-ation once you write hyphen\-ation. So \- replaces the candidate list rather than adding to it, and you must spell out every break point you want. Note also that \- does not force a break; it only says “if you break, it has to be one of these.”
% Ask TeX where it would break, and read the answer in the .log:
% [] \T1/cmr/m/n/10 su-per-cal-ifrag-ilis-tic
\showhyphens{supercalifragilistic}
% [] \T1/cmr/m/n/10 super-califragilistic <- one \- killed the other four
\showhyphens{super\-califragilistic}
% So spell out every break point you actually want:
super\-cali\-fragi\-listicWhy the second half of long-standing will not break: hyphenat and \hyp
Because the same rule applies to an ordinary hyphen you typed yourself. Check with \showhyphens: longstanding splits three ways as long-stand-ing, but write long-standing and it becomes just long-standing — only the hyphen you typed survives, and stand-ing is gone. Every compound behaves this way: well-known, X-ray, state-of-the-art. This rule is why typesetting suddenly gets hard when a long compound lands at the end of a line. The fix is \hyp from the hyphenat package. Write long\hyp standing and the measurement returns to long-stand-ing: the hyphen still prints exactly as before, but the pattern-derived candidates come back to life.
hyphenat also carries a replacement for \mbox. \nohyphens{...} is a one-line definition that simply switches \language inside the group to a language with no patterns. Measured, \nohyphens{supercalifragilistic} reports zero candidates. Because it builds no box, lines may still break before and after the word — no 18pt overhang like \mbox. In the same spirit, \bshyp, \fshyp, \dothyp and \colonhyp turn the \, /, . and : of URLs and paths into breakable characters, while the package option [none] stops hyphenation document-wide with just two assignments, \hyphenpenalty=10000\exhyphenpenalty=10000.
\usepackage{hyphenat}
% A plain "-" kills the rest of the word: long-standing
% \hyp prints the same hyphen and keeps the patterns: long-stand-ing
long\hyp standing, well\hyp known, state\hyp of\hyp the\hyp art
% No hyphens in this word, but the line may still break around it.
% Unlike \mbox this cannot overflow the margin.
\nohyphens{supercalifragilistic}
% Breakable punctuation for URLs and paths:
https:\fshyp\fshyp example\dothyp com\fshyp very\fshyp long\fshyp pathWhen \hyphenation{...} does nothing: accents, inflections, capitals
When the same word keeps coming back, register the exception once in the preamble instead of littering the body. The syntax is exactly what Knuth used at the end of hyphen.tex: list the words with their break points marked by hyphens inside \hyphenation{...}. The mechanism has one use the syntax does not advertise. Enter a word with no hyphens at all and it will never be broken again. Measured: after \hyphenation{fortran}, \showhyphens{fortran} reports zero candidates. That is precisely why present and project sit in Knuth’s exception list without a single break point. Unlike \mbox, this builds no box, so nothing can overflow the margin.
Three reasons it fails, all measured. First, accents. Under OT1 — the default font encoding — \hyphenation{r\'e-sum\'e} stops with ! Improper \hyphenation will be flushed., because an accented character in OT1 is assembled with \accent and is not a letter. Add \usepackage[T1]{fontenc} and it becomes a single glyph; the same line then passes without a murmur. Second, exact matching. Register \hyphenation{hyphena-tion} and hyphenation duly breaks as hyphena-tion, but the plural hyphenations misses the exception entirely and falls back to the patterns as hy-phen-ations. Inflected forms need their own entries. Third, case is ignored. TeX lowercases through \lccode before matching, so the single entry For-tran made all of FORTRAN, Fortran and fortran break as FOR-TRAN, For-tran and for-tran.
\usepackage[T1]{fontenc} % without this, an accent in \hyphenation errors:
% ! Improper \hyphenation will be flushed.
\hyphenation{% one entry per inflected form; case does not matter
hyphena-tion hyphena-tions
r\'e-sum\'e
fortran % no hyphens = never break this word
}babel’s per-language patterns: Wissenschaft breaks two different ways
Hyphenation patterns are per language, and switching \language makes the same word break in a different place. The measurement says it all. Load \usepackage[english,ngerman]{babel} and \language becomes 36 (ngerman); \showhyphens{Wissenschaft Wahrscheinlichkeit} then gives the correct Wis-sen-schaft Wahr-schein-lich-keit. Switch to \selectlanguage{english} (\language 0) and the very same words come out as Wis-senschaft Wahrschein-lichkeit — wrong for German. It works the other way too: set English under the German patterns and typesetting becomes ty-pe-set-ting. A German paper written without babel usually looks subtly wrong for exactly this reason.
One consequence follows directly. The exception list of \hyphenation{...} is itself held per \language, so it applies only to whichever language was in force when you declared it. Measured: after \usepackage[english,ngerman]{babel}, writing \hyphenation{Wiss-en-schaft} in the preamble makes the word break as Wiss-en-schaft in ngerman body text — but immediately after \selectlanguage{english} the exception is invisible and the English patterns return Wis-senschaft. In a multilingual document the rule is absolute: declare exceptions after selecting the language they belong to. Japanese has no hyphenation in this sense, so \- and \hyphenation are tools for the Western-language portions of a document.
\usepackage[T1]{fontenc}
\usepackage[english,ngerman]{babel}
% Exceptions belong to the language that is current when they are declared.
% Select the language first, then declare.
\selectlanguage{ngerman}
\hyphenation{Wiss-en-schaft}
\selectlanguage{english}
\hyphenation{hyphena-tion hyphena-tions}
% Check the result rather than guessing:
% ngerman -> Wis-sen-schaft english -> Wis-senschaft
\showhyphens{Wissenschaft}| Command | Role | Stretches the line? |
|---|---|---|
\\ , \newline | Force a line break (not a paragraph break); only \\ takes [length] and * | No — \hfil absorbs the slack and the line stays short |
\linebreak[n] | Inserts penalty −(0/51/151/301/10000); the default is n=4 | Yes — the line justifies to the right margin |
\nolinebreak[n] | Inserts penalty +(0/51/151/301/10000); n=4 forbids outright | — |
~ | Non-breaking interword space; still allows hyphenation | — |
\mbox{...} | One box; no break, no hyphen — a common cause of overfull boxes | — |
\- | Discretionary hyphen; the word then breaks only where marked | — |
\hyp | hyphenat; prints the hyphen but keeps the rest of the word breakable | — |
\nohyphens{...} | hyphenat; suppresses hyphens only — no box, so it cannot overflow | — |
\hyphenation{...} | Preamble exception list; exact match, case-insensitive, per \language | — |
\showhyphens{...} | Diagnostic: writes the word’s current break points into the .log | — |
The order to fix line-break warnings: force it last
The worst possible fix is to drop a \\ wherever the warning appeared. TeX optimises line breaking across the whole paragraph, so pinning one line redistributes the rest and breaks another. The order is: reword the manuscript, then add hyphenation opportunities, then forbid breaks locally with ~ or \nolinebreak, and only then relax the paragraph’s tolerance. That last rung — \tolerance, \emergencystretch, \sloppy (with \fussy to restore the default), and how to read an Overfull \hbox — belongs to the overfull-box page, where \sloppy is measured out as nothing more than four assignments. Letting microtype stretch glyphs very slightly belongs there too.
- Find the long words, URLs and chemical names first. Run them through
\showhyphens{...}to see whether they have any break points at all. - Give technical terms a
\hyphenation{...}entry. One per inflected form, and in a multilingual document written after\selectlanguage. - Save
\-for the one remaining word. Remember that a single one wipes out every other candidate in that word. - Tie names, numbers and units with
~. Keep\mboxfor short phrases that genuinely must not be split. - Always load
babelin a multilingual document. Without switching languages, one of them will always break in the wrong places.