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.

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

1 Answer

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

\def1{\ifhmode\unskip~\fi\string1}

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

\hspace{1em}

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
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.