TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Is there a way to avoid linebreaks before all numbers without explicitly using the tilde? It would be nice if it worked both for explicit numbers, as in Sample~1 as well as when a number is implied, as in Figure~\ref{fig:label}.

If not, I think I could write a macro in emacs that uses regex to find and fix all the instances of a number or \ref{} that should have a tilde.

share|improve this question
have you looked at the cleveref package? it might be useful here (for the \ref part of your question)... – cmhughes Sep 23 '12 at 22:49
I looked it up, and cleveref seems to solve the problem, and more. As far as explicit numbers go, egreg makes some good points about cases where a linebreak before a number is fine. I think I'll use something like grep ' [0-9]' doc.tex to review these on a case by case basis, since they don't show up as often as references, at least in my writings. – Anthony Sep 24 '12 at 1:45

There's no practical way. One might think to make the digits active and define them as


and similarly for the others. But this would prevent writing innocuos things such as


and so this is ruled out.

Besides, ties are not always required in front of numbers:

as we have seen in cases 1~and~2

is better than cases~1 and~2.

Conversely one might redefine \ref so that it does the \unskip~ operation, but again this is not always the best way of writing by the same reason as before.

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.