Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

DEK gained a reputation of painting red the draft dissertations of his students, taking particular note of incidents when they omitted a non-breaking space that should have been included.

I have this list of places where you have to place non-breaking space:

  1. before \cite
  2. before \ref
  3. before inlined equation

But, I am not sure if I got the rules right; is a non-breaking space mandatory before all inline equations? How about numbers which occur in the text? And what if I refer to a program variable, or to program text, for example,

The 371 programmers who read, on 11 different occasions, the
Java program in Figure~\ref{Program:Example}  noticed that it is peculiar since
parameter \texttt{i} is never read by functions \texttt{f()}
and \texttt{thisLongFuncgtionName()}...

Do I have to write The 371 programmers or The~371 programmers? on 11 different occasions or on~11 different occasions?

Do I need to write parameter~\texttt{i}? I think I should. What about functions~\texttt{f()}? And should I write and~\texttt{thisLongFuncgtionName()}? How about citations that use author, year convention?

In short, I think have an idea, but no exact definition of when you should add non-breaking space.

share|improve this question
I would write The 371~programmers because having The 371 at the end of a line is much worse than The \\ 371 programmers. The same for on 11~different occasions. –  Martin Scharrer Apr 11 '11 at 15:42
See also this question –  Lev Bishop Apr 11 '11 at 20:42
Maybe I missed it below, but 10~mm between value and units should be on anyone's list. –  Steven B. Segletes Apr 22 at 2:28

5 Answers 5

up vote 21 down vote accepted

In general where the break will create orphans that would distract the reader.

Some less obvious examples:


The matching $(AW,BX,CY,DZ)$ is unstable, because for example
$A$ prefers~$Z$ to~$W$ and at the same time $Z$ prefers~$A$ to~$D$.
But the matching $(AZ,BW,CX,DY)$ is stable;

(we say that girl~$h$ rejects the proposal)

step~A2 stops when $P$ has nobody left to propose~to,
but step~B2 keeps making redundant proposals ad~infinitum when

The details of Algorithm~B

has local probability~${1\over n}$,

The "I am", "I definitely" etc., is a bit controversial, but personally like a lot of other people don't like "I" at the end of a line break.

share|improve this answer
prefers $A$~to~$D$ –  egreg Apr 7 at 7:46
and $\operatorname{mod}1$ ;) –  tohecz Apr 7 at 7:50

To quote Knuth. Ties should appear:

  • In references to named parts of a document:
    Chapter~12   Theorem~1.2
    Appendix~A   Table~\hbox{B-8}
    Figure~3   Lemmas 5 and~6
  • Between a person's forenames and between multiple surnames:
    Donald~E. Knuth   Luis~I. Trabb~Pardo
    Bartel~Leendert van~der~Waerden   Charles~XII
    but be careful of names like Charles Louis Xavier~Joseph de~la Vall\'ee~Poussin.
  • Between math symbols in apposition with nouns:
    dimension~$d$ width~$w$ function~$f(x)$
    string~$s$ of length~$l$~
    but compare with
    string~$s$ of length $l$~or more.
  • Between symbols in series:
    1,~2, or~3
    $a$,~$b$, and~$c$
    1,~2, \dots,~$n$.
  • When a symbol is a tightly bound object of a preposition:
    from 0 to~1
    increase $z$ by~1
    in common with~$m$. but compare
    of $u$~and~$v$.
  • When mathematical phrases are rendered in words:
    equals~$n$ less than~$\epsilon$ (given~$X$)
    mod~2 modulo~$p^e$ for all large~$n$
    Compare is~15 with is 15~times the height.
  • When cases are being enumerated within a paragraph:
    (b)~Show that $f(x)$ is (1)~continuous; (2)~bounded.
share|improve this answer
This is almost a duplicate of my answer here! –  Lev Bishop Apr 11 '11 at 20:43
Indeed, and if may, I would like to join a comment made there: "I must be really dense, I can't seem to figure out any "rules" from these examples; these look quite arbitrary to me. Perhaps I should bite the bullet and read the chapter. Thanks for the pointer. – gphilip Aug 16 '10 at 4:23" –  Yossi Gil Apr 12 '11 at 4:18
@Lev: Yikes! The question isn't a duplicate but the answer is! Hmm. –  TH. Apr 12 '11 at 6:07
• between a number and its unit: 4.5~m or 12~min –  Florian Oct 3 '11 at 10:35
@Florian: Probably best to use something like siunitx for that. It'll get the formatting right. ~ gives a space that's probably too large. –  TH. Oct 5 '11 at 0:34
The 371~programmers who read, on 11~different occasions, the 
Java program in Figure~\ref{Program:Example} noticed that it is peculiar since 
parameter~\texttt{i} is never read by functions~\texttt{f()} 
and \texttt{thisLongFuncgtionName()}...

That's my take and I put it up for debate. In short, I'd use a "tie" (~) whenever a line break would split a unit of thought. See also Why I should put a ~ before \ref command? Edit: the tie before f() is debatable and probably should be exchanged for a tie before thisLongFuncgtionName(), which might cause hyphenation problems.

share|improve this answer

In languages like German where spaced en dashes are used for sentence insertions, it is often frowned upon to place the en dash at the start of a new line. So, a non-breaking space should be placed before the dash.

Dieses Mal~-- anders als vorher~-- wurde er überrascht.

This time---unlike before---he was caught by surprise.
share|improve this answer
Interesting. In French, I tend to put the ~ inside, to prevent having a -- at the end of a line (it's like opening a bracket at the end of a line really). –  ℝaphink Oct 2 '11 at 22:09
Could you cite a source for this? Personally I tend to the "French" rule, whenever the en-dashes are used parenthetically: Dieses Mal --~anders als vorher~-- wurde er überrascht. but I keep the dash together with the first part of the sentence, when it could be replaced by a colon or full stop: Hans kam plötzlich herein~-- dieses Mal waren alle überrascht. But I don't know where I learned this and whether it is correct. –  Florian Oct 3 '11 at 10:29
No explicit source -- but in a lot of German books I've read, the rule of "no en dash at the start of a line" seems to have been observed. –  lockstep Oct 3 '11 at 15:58
@lockstep I cannot confirm this rule for German either, but then I haven't checked recently. –  Lover of Structure Feb 23 '13 at 13:46
The German Wikipedia page about en-dashes says that you should use a non-breaking space near the part of the sentence that gets separated – which basically means the same thing (“Der Gedankenstrich ist immer durch ein Leerzeichen vom umgebenden Text zu trennen. Dabei ist in der Textverarbeitung zu beachten, den Gedankenstrich mit einem geschützten Leerzeichen an den Satzteil zu binden, den er abgrenzt.”) –  Rafael Mar 17 at 14:50

I ask myself "are these two things intimately connected?" when using non-breaking spaces. Most of the examples in the other posts in this thread have a definite "yes" as the answer, like (number)~(things) or Equation~\eqref{eqn:NewtonSecondLaw} or (number)~(unit) (side note: use siunitx package for quantities with units) or acceleration vector~$\bm{a}$.

Math, be it inline or display, should be punctuated as if it were not symbols but actual words. The amsmath package already adjusts spacing according to the "part of speech" of the math you are typesetting. Not all inline math should have non-breaking spaces. For example: after a display equation, it is common to write where $x$ is the independent variable and $c$ is a constant, and in both of these cases the non-breaking space is not appropriate.

I would add to the list of "things to not break" multi-word nouns and verbs. English has articles, demonstrative pronouns, and multi-word infinitive verbs, all of which I feel should be tied to their neighbors. I write Johnny kicked the~ball. and This~server has an uptime of 99\%. and To~go boldly where no man has gone before. This practice helps me to avoid dangling demonstratives (this/that/these/those should be followed by a noun) and splitting infinitive verbs. My objection to doing so is not out of grammar nazism, but as someone who writes technical literature, I am being nice to my audience; most of my readers are not native speakers and the split infinitive is not found outside of English.

It is easy to overdo it with the non-breaking spaces, though, like The~371~programmers in the original post. It all depends on how the LaTeX compiler decides to justify each paragraph (side note: the microtype package really helps). Personally, I don't like a lot of hyphens, so I would use The 371~programmers if the other way gave a hyphen in programmers. I almost need a non-breaking space and try-not-to-break-it-but-its-ok-if-you-have-to space. Note well: messing with breaks and hyphens is my very last step in document creation.

I don't have any sources here. Bringhurst's "Elements of Typographic Style" has a few points about hyphens and breaks IIRC, and you owe it to yourself to read this bible of typography if you know enough about typography to even ask this question.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.