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
5  
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
add comment

4 Answers

up vote 20 down vote accepted

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

Some less obvious examples:

I~am
I~definitely
mod~1


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
1  
prefers $A$~to~$D$ –  egreg Apr 7 at 7:46
    
and $\operatorname{mod}1$ ;) –  tohecz Apr 7 at 7:50
add comment

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:
    of~$x$
    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
3  
• between a number and its unit: 4.5~m or 12~min –  Florian Oct 3 '11 at 10:35
1  
@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
show 1 more comment
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
add comment

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
1  
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
1  
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
1  
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
add comment

Your Answer

 
discard

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.