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 can use ~ to produce a non-breaking space. But it is too large for me, and I would like a non-breaking space of the size of \, for example. Is it possible ?

share|improve this question
10  
The space inserted by \, is non breaking. –  egreg Oct 10 '12 at 11:55
    
upss... :) sorry. –  nicolas roy Oct 10 '12 at 13:23
    
Don't worry, it's been a good occasion for describing some lesser known TeX features. For example, why \, is a non breaking space. –  egreg Oct 10 '12 at 13:24

1 Answer 1

up vote 34 down vote accepted

There are two kinds of spacing that TeX can use: skips and kerns. The first sort of space can be flexible (the interword space is a skip, for instance), while the second one is rigid.

Both disappear at line breaks, but TeX will never break a line at a kern (unless it's followed by a skip), while it's willing to do it at skips. Therefore

word\,word

would never be broken across lines.

The command \, inserts a kern, precisely it's defined (in text mode) as

\kern 0.16667em

(where 1em is approximately the width of an uppercase "M", whence the name, or near the font size in points); so the space inserted by \, is 1/6 of an em.

Conversely, ~ is defined as a skip: its definition is \nobreakspace, which translates into

\leavevmode\nobreak\ 

(the last is "backslash+space"). There will be no line break at it, because the skip inserted by \<space> is preceded by so high a penalty that breaks are impossible (\nobreak translates into \penalty 10000).

You can space by inserting \kern yourself, but using a macro is preferable. If you need that the space is non breakable and flexible, use the same trick as ~:

\nobreak\hspace{.16667em plus .08333em}

would insert a space normally equal to 1/6 of an em, but stretchable to 1/4 of an em.

I left out the \leavevmode because such spaces should always be inserted between words. LaTeX takes that precaution, because users might use ~ in order to indent lines (which is not the best thing to do, though).

share|improve this answer
    
\nobreak\hspace{.16667em plus .13333em} would insert a space normally equal to 1/6 of an em, but stretchable to 1/5 of an em. Are you sure that's right? Maybe I just am not familiar with the syntax, but it seems like that space would be stretchable to about 0.3em. If you want stretchable to approximately 1/5 em, shouldn't that be .16667em plus .03333em (which works out to .19997em)? –  Michael Kjörling Oct 11 '12 at 14:11
    
@MichaelKjörling I just did the math wrong. :( –  egreg Oct 11 '12 at 14:12
2  
So is \kern 0.16667em the same as \nobreak\hspace{.16667em}? –  StrongBad Oct 11 '12 at 16:21
1  
@DanielE.Shub Not really: \unskip wouldn't remove it (there's \unkern). –  egreg Oct 11 '12 at 17:16

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.