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.

I've seen examples referencing a table as follows:

Table~\ref{table:overview} shows an overview of all the elements.

What is the use of the tilde in front of \ref or \cite and when do you have to apply it?

share|improve this question
2  
Also see Consistent typography. –  Werner Jan 16 '12 at 16:59
1  
For a brief (0.5 pages) overview of spaces (normal space, ~, \ , \@), see section 2.6 of The Not So Short Introduction to LaTeX2e. –  doncherry Jan 16 '12 at 17:25

3 Answers 3

up vote 39 down vote accepted

The tilde ~ is an unbreakable space, i.e. the line will never be broken at this position. If you write Table~\ref{...} the table number generated by \ref will always be on the same line as Table, which is the preferable formatting. Having "Table" at the end of a line and then "1" at the beginning of the next simply looks bad.

The tilde is also used in names if they include a title, like Dr.~Faust, which will also ensure that the "Dr." and the name is not broken between two lines, and also ensures that the . is not taken as a full-stop, which usually produces a larger space after it.

share|improve this answer
3  
Nice remark about using the tilde in names. –  vitaut Jan 16 '12 at 16:01
1  
The larger space is produced in English documents; if you use babel e.g. with the ngerman option, a sentence-final period won't be followed by an enlarged space. –  doncherry Jan 16 '12 at 17:22

From the TeX Book (Chapter 6: Running TeX, p 25):

[The ~ signs] are called ties, because they tie words together; i.e., TeX is supposed to treat ~ as a normal space but not to break between lines there. A good typist will use ties within names, as shown in our example; further discussion of ties appears in Chapter 14.

Continued in Chapter 14: How TeX Breaks Paragraphs into Lines, p 91-93:

"Ties" - denoted by ~ in plain TeX - are the key to successful line breaking. Once you learn how to insert them, you will have graduated from the ranks of ordinary TeXnical typists to the select group of Distinguished TeXnicians. And it's really not difficult to train yourself to insert occasional ties, almost without thinking, as you type a manuscript.

When you type ~ it's the same as typing a space, except that TeX won't break a line at this space. Furthermore, you shouldn't leave any blanks next to the ~, since they will count as additional spaces. If you put ~ at the very end of a line in your input file, you'll get a wider space than you want, because the <return> that follows the ~ produces an extra space.

We have already observed in Chapter 12 that it's generally a good idea to type ~ after an abbreviation that does not come at the end of a sentence. Ties also belong in several other places:

  • 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

    No ~ appears after Lemmas in the final example, since there's no harm in having 5~and~6 at the beginning of a line. The use of \hbox is explained below.

  • Between a person's forenames and between multiple surnames:

    Donald~E. Knuth & Luis~I. Trabb~Pardo
    Bartel~Leendert van~der~Waerden & Charles~XII

    Note that it is sometimes better to hyphenate a name than to break it between words; e.g., Don- and ald~E.~Knuth is more tolerable than Donald and E.~Knuth. The previous rule can be regarded as a special case of this one, since we may think of Chapter~12 as a compound name; another example is register~X. Sometimes a name is so long that we dare not tie it all together, lest there be no way to break the line:

    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$

    However, the last example should be compared 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$.

    The rule does not, however, apply to compound objects:

    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.

    It would be nice to boil all of these rules down to one or two simple principles, and it would be even nicer if the rules could be automated so that keyboarding could be done without them; but subtle semantic considerations seem to be involved. Therefore it's best to use your own judgment with respect to ties. The computer needs your help.

A tie keeps TeX from breaking at a space, but sometimes you want to prevent the machine from breaking at a hyphen or a dash. This can be done by using \hbox, because TeX will not split up the contents of a box; boxes are indecomposable units, once they have been constructed. We have already illustrated this principle in the Table~\hbox{B-8} example considered earlier. Another example occurs when you are typing the page numbers in a bibliographic reference: It doesn't look good to put 22. on a line by itself, so you can type \hbox{13--22}. to prohibit breaking 13--22. On the other hand, TeX doesn't often choose line breaks at hyphens, so you needn't bother to insert \hbox commands unless you need to correct a bad break that TeX has already made on a previous run.

share|improve this answer
1  
I think these recommendations, while sensible, have caused a too restrictive view among LaTeXers regarding style. For example, the Chicago Manual of Style writes "the squishing or stretching of text that results from the use of nonbreaking spaces can be even more unsightly [than what the OP there is asking about]" in their online Q&A (Note: When CMOS discusses page numbers there, they aren't preceded by "p." in the context of their question; but their general sentiment against overdoing it still holds.) –  Lover of Structure Nov 20 '12 at 20:46

the tilde is used to keep the table number (or other reference) from breaking to a new line during the justification process. it's especially nice to avoid this breaking when the cited reference is the last thing in a paragraph.

share|improve this answer

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.