# Automatic non-breakable spaces?

Very often I have to manually add non-breakable spaces to make things look better. For instance:

• see~\cite{Bla98}
• for all~$x$
• see Section~\ref{sect:bla}

It looks specific enough so that it could be automated: avoid line breaking before a citation/ref/small-math-thingy.

Is there any package doing this?

• Take a look at the cleveref package. It covers at least your third bullet point. For the first two, I don't know of a general solution for these. Consider that the usage may be context-specific; for example, the non-breaking space may be desired for bracketed/numerical citations, but might not be required for author-year type citations. – Paul Gessler Feb 20 '14 at 15:42

that's possible for commands like \cite or \ref and difficult for $. Example for \ref \documentclass{article} \textwidth=5.5cm \parindent=0pt %%%% only for demo \let\myRef\ref \renewcommand\ref{\unskip~\myRef} \begin{document} \section{foo}\label{sect:bla} \rule{\textwidth}{1pt} xxxxx xxx xxx xxx xxxx see Section \myRef{sect:bla} %%% the original ref xxxxx xxx xxx xxx xxxx see Section \ref{sect:bla} \end{document}  • I like that, thanks! As for$, some people are discussing it here tex.stackexchange.com/questions/11616/… – Omit Feb 20 '14 at 15:46
• it doesn't make sense for $ in all cases. You could refedeine $$...$$ instead – user2478 Feb 20 '14 at 16:02 • @Herbert -- yes, one could redefine \{...\}, but that's adding two keystrokes as well as resetting one's thinking. it would be more efficient to reset one's thinking to initially always enter xxx~$...\$, which is a net change of 0 keystrokes. – barbara beeton Feb 20 '14 at 16:18